-
Notifications
You must be signed in to change notification settings - Fork 0
/
backend.php
51 lines (40 loc) · 1.13 KB
/
backend.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
46
47
48
49
50
51
<?php defined( 'SYSPATH' ) or die( 'No direct script access.' );
Kohana::load(PLUGPATH . '/less/vendors/lessc.inc.php');
if (Auth::is_logged_in())
{
less_compile($plugin);
}
function less_compile($plugin)
{
try
{
$less_folder_path = trim($plugin->get('less_folder_path'), '/');
$css_folder_path = trim($plugin->get('css_folder_path'), '/');
$less_path = DOCROOT . $less_folder_path . DIRECTORY_SEPARATOR;
$css_path = DOCROOT . $css_folder_path . DIRECTORY_SEPARATOR;
if ((!is_dir($less_path) AND !is_dir($css_path)) OR $plugin->get('enabled') == Config::NO)
{
return;
}
$files = new DirectoryIterator($less_path);
$less = new lessc;
foreach ($files as $file)
{
if ($file->isDot() OR $file->isDir() OR $file->getFilename() !== 'common.less')
continue;
$pathinfo = pathinfo($file->getFilename());
if ($pathinfo['extension'] == 'less')
{
$less_file = $less_path . $file->getFilename();
$css_file = $css_path . DIRECTORY_SEPARATOR . $pathinfo['filename'] . '.css';
$less->checkedCompile($less_file, $css_file);
}
}
}
catch (Exception $e)
{
echo $e->getMessage();
exit();
return;
}
}