diff --git a/app/core/template/Output.class.php b/app/core/template/Output.php similarity index 85% rename from app/core/template/Output.class.php rename to app/core/template/Output.php index 1a01ef0..e454fc0 100755 --- a/app/core/template/Output.class.php +++ b/app/core/template/Output.php @@ -11,7 +11,7 @@ class Output { private $_template = ''; private $_extension = ''; - + private function __construct() { $this->_template = ( defined('TEMPLATE_DEFAULT') ) ? TEMPLATE_DEFAULT : 'DefaultTemplate'; $this->_extension = ( defined('TEMPLATE_FILETYPE') ) ? TEMPLATE_FILETYPE : '.mustache'; @@ -43,7 +43,7 @@ class Output { array_pop($segments); $location = implode('/', $segments) . '/views/'; } - + self::getInstance()->setView($name, $values, $location)->render(); } @@ -82,7 +82,7 @@ class Output { } include_once __DIR__."/classes/".strtolower($instance->_template)."/".$instance->_template.'.php'; - + $class = new $instance->_template; $class->setView($instance->view)->render(); @@ -95,14 +95,32 @@ class Output { public static function addSubmenu($key, $name, $icon = '', $attributes = [], $weight = 0){ global $SIDEBAR; - $SIDEBAR->create_submenu($key, $name, $icon, $attributes , $weight); + $SIDEBAR->create_submenu($key, $name, $icon, $attributes , $weight); } - + public static function addOnSubmenu($key, $route, $name, $icon = '', $attributes = [], $weight = 0){ global $SIDEBAR; $SIDEBAR->add_on_new($key, $route, $name, $icon, $attributes, $weight); } - + + //======== + + public static function headAdd($route, $name){ + global $DROPDOWN; + $DROPDOWN[] = ['route' => $route, 'name' => $name]; + } + + public static function addSubHeader($key, $name, $icon = '', $attributes = [], $weight = 0){ + global $DROPDOWN; + $DROPDOWN->create_submenu($key, $name, $icon, $attributes , $weight); + } + + public static function addOnSubHeader($key, $route, $name, $icon = '', $attributes = [], $weight = 0){ + global $DROPDOWN; + $DROPDOWN->add_on_new($key, $route, $name, $icon, $attributes, $weight); + } + + public static function icon($icon){ return ""; } diff --git a/app/core/template/Routes.php b/app/core/template/Routes.php index 960e4c4..7c04894 100755 --- a/app/core/template/Routes.php +++ b/app/core/template/Routes.php @@ -1,15 +1,19 @@ 'side-menu', 'class' => "nav") ); - $DROPDOWN = new Menu( array("class" => 'dropdown-menu') ); + + //HACK + //$DROPDOWN = new Menu( array("class" => 'dropdown-menu') ); + $DROPDOWN = []; }, -11)->doIgnore(); diff --git a/app/core/template/__Output.php b/app/core/template/__Output.php new file mode 100755 index 0000000..cd748ae --- /dev/null +++ b/app/core/template/__Output.php @@ -0,0 +1,128 @@ +_template = ( defined('TEMPLATE_DEFAULT') ) ? TEMPLATE_DEFAULT : 'DefaultTemplate'; + $this->_extension = ( defined('TEMPLATE_FILETYPE') ) ? TEMPLATE_FILETYPE : '.mustache'; + } + + private static function newObj() { + if (!isset(self::$_instance)) { + self::$_instance = new Output(); + } + return self::$_instance; + } + + public function getInstance() { + if (!isset(self::$_instance)) { + return self::newObj(); + } + return self::$_instance; + } + + public function setTemplate($template = 'DefaultTemplate') { + self::getInstance()->_template = $template; +// self::getInstance()->_template = ''; + return self::getInstance(); + } + + public static function renderView($name, $values = null, $location = null) { + if (!$location) { + $segments = explode('/', debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)[0]['file']); + array_pop($segments); + $location = implode('/', $segments) . '/views/'; + } + + self::getInstance()->setView($name, $values, $location)->render(); + } + + public static function setView($name = '', $values = Array(), $location = null) { + if($name == ''){ return self::getInstance(); } + $instance = self::getInstance(); + $folder = ''; + if (!$location) { + $segments = explode('/', debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS)[0]['file']); + array_pop($segments); + $location = implode('/', $segments) . '/views/'; + } + $folder = $location; + $location .= $name; + + if (strpos($instance->_extension, $location) == 0) { + $location .= $instance->_extension; + } + + $instance->view = Array(); + $instance->view['location'] = $location; + $instance->view['folder'] = $folder; + $instance->view['values'] = $values; + return self::getInstance(); + } + + public static function addValue($key, $value){ + self::getInstance()->view['values'][$key] = $value; + } + + public static function render() { + $instance = self::getInstance(); + + if(!is_file(__DIR__."/classes/".strtolower($instance->_template)."/".$instance->_template.'.php') ){ + $instance->_template = 'DefaultTemplate'; + } + + include_once __DIR__."/classes/".strtolower($instance->_template)."/".$instance->_template.'.php'; + + $class = new $instance->_template; + $class->setView($instance->view)->render(); + + } + + public static function addMenu($route, $name, $icon = '', $attributes = [], $weight = 0){ + global $SIDEBAR; + $SIDEBAR->add($route, $name, $icon, $attributes, $weight); + } + + public static function addSubmenu($key, $name, $icon = '', $attributes = [], $weight = 0){ + global $SIDEBAR; + $SIDEBAR->create_submenu($key, $name, $icon, $attributes , $weight); + } + + public static function addOnSubmenu($key, $route, $name, $icon = '', $attributes = [], $weight = 0){ + global $SIDEBAR; + $SIDEBAR->add_on_new($key, $route, $name, $icon, $attributes, $weight); + } + + //======== + + public static function headAdd($route, $name){ + global $DROPDOWN; + $DROPDOWN[] = ['route' => $route, 'name' => $name]; + } + + public static function addSubHeader($key, $name, $icon = '', $attributes = [], $weight = 0){ + global $DROPDOWN; + $DROPDOWN->create_submenu($key, $name, $icon, $attributes , $weight); + } + + public static function addOnSubHeader($key, $route, $name, $icon = '', $attributes = [], $weight = 0){ + global $DROPDOWN; + $DROPDOWN->add_on_new($key, $route, $name, $icon, $attributes, $weight); + } + + + public static function icon($icon){ + return ""; + } + +} diff --git a/app/core/template/classes/dashboard/Dashboard.php b/app/core/template/classes/dashboard/Dashboard.php index 7f507fe..0d2bae3 100755 --- a/app/core/template/classes/dashboard/Dashboard.php +++ b/app/core/template/classes/dashboard/Dashboard.php @@ -1,22 +1,29 @@ -content = file_get_contents($this->getView()['location']); - $this->implate(); + if(is_file($this->getView()['location'])){ + $this->content = file_get_contents($this->getView()['location']); + $this->implate(); + }else{ + $this->content = ''; + $this->implate(); + } return; } - global $DROPDOWN, $SIDEBAR; - + //global $DROPDOWN, $SIDEBAR; + $head = ''; - + $head .= ''; $head .= ''; @@ -24,7 +31,7 @@ class Dashboard extends RenderableTemplate { $head .= ''; $head .= ''; - $head .= ''; + $head .= ''; $head .= ''; @@ -36,35 +43,37 @@ class Dashboard extends RenderableTemplate { $head .= ''; $head .= ''; - $head .= ''; - $head .= ''; - $head .= ''; $head .= ''; - $head .= ''; - $head .= ''; - $foot = ''; $foot .= ''; - + $this->content = file_get_contents(__DIR__ . '/template.html'); $this->content = str_replace("{{usermenu}}", "", $this->content); $this->content = str_replace("{{elements}}", $SIDEBAR->render(), $this->content); + $header = ''; + + //HACK + foreach ($DROPDOWN as $item){ + $header .= "".$item['name'].""; + } + $this->content = str_replace("{{dropdown}}", $header, $this->content); + $this->content = str_replace("{{head}}", $head, $this->content); - - if(is_file($this->getView()['location'])){ + + if(isset($this->getView()['location']) && is_file($this->getView()['location'])){ $this->content = str_replace('{{>content}}', $this->replaceSections(file_get_contents($this->getView()['location']), $this->_view['values']), $this->content); }else{ $this->content = str_replace('{{>content}}', '', $this->content); } - + $this->content = str_replace("{{footer}}", $foot, $this->content); - + $this->implate(); - + } } diff --git a/app/core/template/classes/dashboard/template.html b/app/core/template/classes/dashboard/template.html index aba8d0f..945ace5 100755 --- a/app/core/template/classes/dashboard/template.html +++ b/app/core/template/classes/dashboard/template.html @@ -9,17 +9,18 @@
@@ -31,24 +32,19 @@ - + diff --git a/app/core/welcome/WellcomeController.php b/app/core/welcome/WellcomeController.php deleted file mode 100644 index 13ea3f2..0000000 --- a/app/core/welcome/WellcomeController.php +++ /dev/null @@ -1,11 +0,0 @@ - Lang::getString('welcome', 'welcome')))->send()->done(); - } - -} \ No newline at end of file diff --git a/public/dist/script.js b/public/dist/script.js index 8251379..731ad2b 100755 --- a/public/dist/script.js +++ b/public/dist/script.js @@ -45,7 +45,7 @@ function revalidate_screen() { $(this).mask($(this).data('format'), {}); }); - $('[data-toggle="popover"]').popover(); + //$('[data-toggle="popover"]').popover(); $('select').each(function () { if (typeof $(this).data('value') !== "undefined" && $(this).data('value') !== '') { @@ -68,6 +68,19 @@ function revalidate_screen() { liveSearch: true }); }); + + $(".wysiwyg").each(function () { + $(this).trumbowyg(); + }); + + $(".form-control-range").each(function(i, item){ + $(item).on('change', function(item, i){ + $(item.currentTarget) + .parent() + .find('.range-monitor') + .html(item.currentTarget.value + "%"); + }) + }); $('.popup-toggle').each(() => { var template = '