diff --git a/classes/Button.class.php b/classes/Button.class.php new file mode 100644 index 0000000..36eecc1 --- /dev/null +++ b/classes/Button.class.php @@ -0,0 +1,64 @@ +name; + } + + public function setName($name) { + $this->name = $name; + return $this; + } + + public function isDismissable() { + return $this->dismissable; + } + + public function setDismissable() { + $this->dismissable = true; + return $this; + } + + public function hasModal() { + return !empty($this->modal); + } + + public function getModal() { + return $this->modal; + } + + public function setModal($modal) { + $this->modal = $modal; + return $this; + } + + public function getLabel() { + return $this->label; + } + + public function setLabel($label) { + $this->label = $label; + return $this; + } + + public function getClasses($raw = true) { + if($raw) { + return $this->classes; + } + + return implode(' ', $this->classes); + } + + public function addClass($class) { + $this->classes[] = $class; + return $this; + } + } +?> \ No newline at end of file diff --git a/classes/Core.class.php b/classes/Core.class.php index 6ff5744..4ff27bb 100644 --- a/classes/Core.class.php +++ b/classes/Core.class.php @@ -71,8 +71,8 @@ private function init() { $this->hooks = new Hooks(); - $this->modules = new Modules($this); $this->template = new Template($this); + $this->modules = new Modules($this); $this->router = new Router($this); $this->router->addRoute('/', function() { @@ -128,6 +128,24 @@ return; } + $module = $this->getModules()->getModule($module); + + if(empty($module)) { + $this->template->display('error/module', [ + 'module' => $module, + 'submodule' => $submodule + ]); + return; + } + + if(!method_exists($module->getInstance(), 'content')) { + $this->template->display('error/module_empty', [ + 'module' => $module, + 'submodule' => $submodule + ]); + return; + } + $this->template->display('module', [ 'module' => $module, 'submodule' => $submodule diff --git a/classes/Modal.class.php b/classes/Modal.class.php new file mode 100644 index 0000000..e27a2b2 --- /dev/null +++ b/classes/Modal.class.php @@ -0,0 +1,45 @@ +name = $name; + $this->title = $title; + + if(is_string($content)) { + $this->content = $content; + } + } + + public function getName() { + return $this->name; + } + + public function getTitle() { + return $this->title; + } + + public function addButton($button) { + $this->buttons[] = $button; + return $this; + } + + public function getButtons() { + return $this->buttons; + } + + public function getContent($template) { + if(preg_match('/\.php$/', $this->content)) { + require_once($this->content); + return; + } + + return $this->content; + } + } +?> \ No newline at end of file diff --git a/classes/Module.class.php b/classes/Module.class.php index 579cc6e..8a45162 100644 --- a/classes/Module.class.php +++ b/classes/Module.class.php @@ -15,6 +15,10 @@ return (!empty($this->info) && !$this->info->isValid()); } + public function getInfo() { + return $this->info; + } + public function getInstance() { return $this->instance; } diff --git a/classes/ModuleInterface.class.php b/classes/ModuleInterface.class.php index ca4e31b..a9895ee 100644 --- a/classes/ModuleInterface.class.php +++ b/classes/ModuleInterface.class.php @@ -18,6 +18,28 @@ return $this->core; } + public function addButton($button) { + $this->addFilter('buttons', function($buttons) use($button) { + $buttons[] = $button; + return $buttons; + }); + } + + public function addModal($modal) { + $this->addFilter('modals', function($modals) use($modal) { + $modals[] = $modal; + return $modals; + }); + } + + public function assign($name, $value) { + $this->getCore()->getTemplate()->assign($name, $value); + } + + public function url($path) { + $this->getCore()->getTemplate()->url($path); + } + /* Filter */ public function addFilter($name, $method, $priority = 10) { return $this->core->getHooks()->addFilter($name, $method, $priority); diff --git a/classes/Modules.class.php b/classes/Modules.class.php index 24032ce..c3f4f6f 100644 --- a/classes/Modules.class.php +++ b/classes/Modules.class.php @@ -13,7 +13,9 @@ continue; } - $this->addModule(new Module(sprintf('%s%s%s', $this->getPath(), DS, $info->getFilename()))); + $path = sprintf('%s%s%s', $this->getPath(), DS, $info->getFilename()); + + $this->addModule(basename($path), new Module($path)); } } @@ -21,8 +23,20 @@ return sprintf('%s%s%s', dirname(PATH), DS, 'modules'); } - public function addModule($module) { - $this->modules[] = $module->init($this->core); + public function addModule($name, $module) { + $this->modules[$name] = $module->init($this->core); + } + + public function getModules() { + return $this->modules; + } + + public function getModule($name) { + if(!isset($this->modules[$name])) { + return null; + } + + return $this->modules[$name]; } } ?> \ No newline at end of file diff --git a/classes/Template.class.php b/classes/Template.class.php index 54275d6..d71ad4c 100644 --- a/classes/Template.class.php +++ b/classes/Template.class.php @@ -19,12 +19,14 @@ $this->core->getHooks()->addAction('html_head', [ $this, 'head_robots' ]); $this->core->getHooks()->addAction('html_head', [ $this, 'head_scripts' ]); $this->core->getHooks()->addAction('html_foot', [ $this, 'foot_scripts' ]); + $this->core->getHooks()->addAction('html_foot', [ $this, 'foot_modals' ]); $this->files->addStylesheet('bootstrap', $this->url('css/bootstrap/bootstrap.min.css'), '4.3.1'); $this->files->addStylesheet('jquery-ui', $this->url('css/jquery-ui/jquery-ui.css'), '1.12.1'); $this->files->addStylesheet('material-icons', $this->url('fonts/material-icons/material-icons.css'), '3.0.1', [ 'bootstrap' ]); + $this->files->addJavascript('popper', $this->url('js/popper/popper.min.js'), '3.3.1', [ 'jquery' ], TemplateFiles::FOOTER); $this->files->addJavascript('jquery', $this->url('js/jquery/jquery-3.3.1.min.js'), '3.3.1', [], TemplateFiles::FOOTER); - $this->files->addJavascript('bootstrap', $this->url('js/bootstrap/bootstrap.bundle.min.js'), '4.3.1', [ 'jquery' ], TemplateFiles::FOOTER); + $this->files->addJavascript('bootstrap', $this->url('js/bootstrap/bootstrap.bundle.min.js'), '4.3.1', [ 'jquery', 'popper' ], TemplateFiles::FOOTER); $this->navigation->addCategory('account', 'Account'); $this->navigation->addCategory('database', 'Databases'); @@ -80,7 +82,7 @@ } else { $this->getFiles()->addStylesheet('style', $this->url('css/style.css'), '1.0.0', [ 'bootstrap', 'material-icons' ]); $this->getFiles()->addJavascript('jquery-ui', $this->url('js/jquery-ui/jquery-ui.min.js'), '1.12.1', [ 'jquery' ], TemplateFiles::FOOTER); - $this->getFiles()->addJavascript('ui', $template->url('js/ui.js'), '1.0.0', [ 'jquery', 'jquery-ui', 'bootstrap' ], TemplateFiles::FOOTER); + $this->getFiles()->addJavascript('ui', $template->url('js/ui.js'), '1.0.0', [ 'jquery', 'jquery-ui', 'popper', 'bootstrap' ], TemplateFiles::FOOTER); } $path = sprintf('%1$s%2$stheme%2$s%3$s.php', PATH, DS, $file); diff --git a/classes/TemplateDefaults.class.php b/classes/TemplateDefaults.class.php index 4052708..1605a88 100644 --- a/classes/TemplateDefaults.class.php +++ b/classes/TemplateDefaults.class.php @@ -56,6 +56,54 @@ } } + public function foot_modals() { + $modals = $this->getCore()->getHooks()->applyFilter('modals', []); + $template = $this; + + foreach($modals AS $modal) { + ?> +
+Current personal details that you have provided us with, We ask that you keep these upto date in case we require to contact you regarding your hosting package.
+ +Change your current control panel password.
diff --git a/theme/css/style.css b/theme/css/style.css index 67cc4fe..7ec41d3 100644 --- a/theme/css/style.css +++ b/theme/css/style.css @@ -28,6 +28,8 @@ body.sortable { .sidebar-sticky { position: relative; top: 0; + left: 0; + right: 0; height: calc(100vh - 48px); padding-top: .5rem; overflow-x: hidden; @@ -72,10 +74,10 @@ body.sortable { } [role="main"] { - padding-top: 133px; + padding-top: 100px; } -@media (min-width: 768px) { +@media (min-width: 576px) { [role="main"] { padding-top: 48px; } @@ -181,4 +183,12 @@ ul.sortable li ul.list-unstyled li a div.icon { ul.sortable li ul.list-unstyled li a div.label { font-size: 12px; +} + +.jumbotron .material-icons { + font-size: 100px; +} + +.jumbotron .btn-lg { + padding: 15px 50px; } \ No newline at end of file diff --git a/theme/error/module_empty.php b/theme/error/module_empty.php new file mode 100644 index 0000000..05142a2 --- /dev/null +++ b/theme/error/module_empty.php @@ -0,0 +1,12 @@ +header(); + ?> +Empty module...!
+ footer(); +?> \ No newline at end of file diff --git a/theme/header.php b/theme/header.php index 0f9519d..dfb9af3 100644 --- a/theme/header.php +++ b/theme/header.php @@ -16,7 +16,10 @@ if(Auth::isLoggedIn()) { ?>