-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
45 lines (42 loc) · 1.17 KB
/
functions.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
function getFiles($dir)
{
$directory = $dir;
$filenames = array();
$iterator = new DirectoryIterator($directory);
foreach ($iterator as $fileinfo) {
if ($fileinfo->isFile()) {
$filenames[] = array('name' => $fileinfo->getFilename(), 'path' => str_replace('\\', '/', $fileinfo->getPathname()));
}
}
return $filenames;
}
function showTemplates($dir)
{
foreach(getFiles($dir) as $file)
{
$tplListArray[] = '<script type="text/template" id="tpl_'.array_shift(explode('.', $file['name'])).'">';
$tplListArray[] = file_get_contents($file['path']);
$tplListArray[] = '</script>';
}
return implode("\n\n", $tplListArray);
}
function showTemplate($file)
{
$tplListArray[] = '<script type="text/template" id="tpl_'.array_shift(explode('.', $file['name'])).'">';
$tplListArray[] = file_get_contents($file['path']);
$tplListArray[] = '</script>';
return implode("\n\n", $tplListArray);
}
function showJs($dir, $front = '')
{
$front = FRONT_URL . $front;
$files = getFiles($dir);
asort($files);
foreach($files as $file)
{
$jsListArray[] = '<script type="text/javascript" src="'.$front. $dir.'/'.$file['name'].'"></script>';
}
return implode("\n\n", $jsListArray);
}
?>