-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
editor.php
27 lines (22 loc) · 971 Bytes
/
editor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
//include 'editor.html';
$html = file_get_contents('editor.html');
//search for html files in demo and my-pages folders
$htmlFiles = glob('{my-pages/*.html,demo/*\/*.html, demo/*.html}', GLOB_BRACE);
$files = '';
foreach ($htmlFiles as $file) {
if (in_array($file, array('new-page-blank-template.html', 'editor.html'))) continue;//skip template files
$pathInfo = pathinfo($file);
$filename = $pathInfo['filename'];
$folder = preg_replace('@/.+?$@', '', $pathInfo['dirname']);
$subfolder = preg_replace('@^.+?/@', '', $pathInfo['dirname']);
if ($filename == 'index' && $subfolder) {
$filename = $subfolder;
}
$url = $pathInfo['dirname'] . '/' . $pathInfo['basename'];
$name = ucfirst($filename);
$files .= "{name:'$name', file:'$file', title:'$name', url: '$url', folder:'$folder'},";
}
//replace files list from html with the dynamic list from demo folder
$html = str_replace('(pages);', "([$files]);", $html);
echo $html;