-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
editor.php
29 lines (24 loc) · 1.07 KB
/
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
28
29
<?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);
$htmlFiles = array_merge(glob('my-pages/*.html'),glob('demo/*\/*.html'), glob('demo/*.html'));
$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 = $filename;
$title = ucfirst($name);
$files .= "{name:'$name', file:'$file', title:'$title', url: '$url', folder:'$folder'},";
}
//replace files list from html with the dynamic list from demo folder
$html = str_replace('= defaultPages;', " = [$files];", $html);
echo $html;