diff --git a/src/lang/de_DE.lang.php b/src/lang/de_DE.lang.php index 0cafb2f6..fb589bbb 100644 --- a/src/lang/de_DE.lang.php +++ b/src/lang/de_DE.lang.php @@ -41,7 +41,7 @@ $sm_lang = array( 'no' => 'Nein', 'edit' => 'Bearbeiten', 'insert' => 'Einfügen', - 'add_new' => 'Neuen Eintrag erstellen?', + 'add_new' => 'Neuen Eintrag erstellen', 'update_available' => 'Ein neues Update ist verfügbar auf http://www.phpservermonitor.org.', 'back_to_top' => 'Back to top', 'go_back' => 'Go back', diff --git a/src/lang/en_US.lang.php b/src/lang/en_US.lang.php index 6c591c8e..8399e9a4 100644 --- a/src/lang/en_US.lang.php +++ b/src/lang/en_US.lang.php @@ -41,7 +41,7 @@ $sm_lang = array( 'no' => 'No', 'edit' => 'Edit', 'insert' => 'Insert', - 'add_new' => 'Add new?', + 'add_new' => 'Add new', 'update_available' => 'A new update is available from http://www.phpservermonitor.org.', 'back_to_top' => 'Back to top', 'go_back' => 'Go back', diff --git a/src/lang/nl_NL.lang.php b/src/lang/nl_NL.lang.php index d9750c21..93c5e628 100644 --- a/src/lang/nl_NL.lang.php +++ b/src/lang/nl_NL.lang.php @@ -41,7 +41,7 @@ $sm_lang = array( 'no' => 'Nee', 'edit' => 'Wijzig', 'insert' => 'Voeg toe', - 'add_new' => 'Voeg toe?', + 'add_new' => 'Voeg toe', 'update_available' => 'Een nieuwe update is beschikbaar op http://www.phpservermonitor.org.', 'back_to_top' => 'Terug naar boven', 'go_back' => 'Terug', diff --git a/src/lang/pt_BR.lang.php b/src/lang/pt_BR.lang.php index 04734b97..a14d4559 100644 --- a/src/lang/pt_BR.lang.php +++ b/src/lang/pt_BR.lang.php @@ -41,7 +41,7 @@ $sm_lang = array( 'no' => 'Não', 'edit' => 'Editar', 'insert' => 'Inserir', - 'add_new' => 'Adicionar novo?', + 'add_new' => 'Adicionar novo', 'update_available' => 'Uma atualização disponível em http://www.phpservermonitor.org.', 'back_to_top' => 'Voltar ao topo', 'go_back' => 'Go back', diff --git a/src/psm/Module/AbstractController.class.php b/src/psm/Module/AbstractController.class.php index 822f6647..e8488c60 100644 --- a/src/psm/Module/AbstractController.class.php +++ b/src/psm/Module/AbstractController.class.php @@ -80,6 +80,12 @@ abstract class AbstractController implements ControllerInterface { */ protected $messages = array(); + /** + * Sidebar to add + * @var \psm\Util\Module\Sidebar $sidebar + */ + protected $sidebar; + /** * Database object * @var \psm\Service\Database $db @@ -181,6 +187,13 @@ abstract class AbstractController implements ControllerInterface { if($this->add_menu) { $tpl_data['html_menu'] = $this->createHTMLMenu(); } + // add sidebar to page? + if($this->sidebar !== null) { + $tpl_data['html_sidebar'] = $this->sidebar->createHTML(); + $tpl_data['content_span'] = '9'; + } else { + $tpl_data['content_span'] = '12'; + } // add footer to page? if($this->add_footer) { $this->tpl->newTemplate('main_footer', 'main.tpl.html'); @@ -438,4 +451,14 @@ abstract class AbstractController implements ControllerInterface { } return $this; } + + /** + * Add a sidebar to the page + * @param \psm\Util\Module\SidebarInterface $sidebar + * @return \psm\Module\ControllerInterface + */ + public function setSidebar(\psm\Util\Module\SidebarInterface $sidebar) { + $this->sidebar = $sidebar; + return $this; + } } diff --git a/src/psm/Module/Config/Controller/ConfigController.class.php b/src/psm/Module/Config/Controller/ConfigController.class.php index dd21092b..c03b0cc4 100644 --- a/src/psm/Module/Config/Controller/ConfigController.class.php +++ b/src/psm/Module/Config/Controller/ConfigController.class.php @@ -77,6 +77,15 @@ class ConfigController extends AbstractController { */ protected function executeIndex() { $this->setTemplateId('config', 'config.tpl.html'); + $sidebar = new \psm\Util\Module\Sidebar($this->tpl); + $this->setSidebar($sidebar); + + $sidebar->addLink( + 'save', + psm_get_lang('system', 'save'), + "javascript:$('#edit_config').submit();", + 'ok' + ); $config_db = $this->db->select( PSM_DB_PREFIX . 'config', diff --git a/src/psm/Module/Server/Controller/ServerController.class.php b/src/psm/Module/Server/Controller/ServerController.class.php index 4e740adc..7abc91c7 100644 --- a/src/psm/Module/Server/Controller/ServerController.class.php +++ b/src/psm/Module/Server/Controller/ServerController.class.php @@ -52,20 +52,31 @@ class ServerController extends AbstractServerController { */ protected function executeIndex() { $this->setTemplateId('servers_list', 'servers.tpl.html'); + $sidebar = new \psm\Util\Module\Sidebar($this->tpl); + $this->setSidebar($sidebar); + // check if user is admin, in that case we add the buttons if($this->user->getUserLevel() == PSM_USER_ADMIN) { - // first add buttons at the top - $this->tpl->newTemplate('servers_list_admin_buttons', 'servers.tpl.html'); - $this->tpl->addTemplateData($this->getTemplateId(), array( - 'html_buttons_admin' => $this->tpl->getTemplate('servers_list_admin_buttons'), - 'url_add' => psm_build_url(array('mod' => 'server', 'action' => 'edit')) - )); + $sidebar->addLink( + 'add_new', + psm_get_lang('system', 'add_new'), + psm_build_url(array('mod' => 'server', 'action' => 'edit')), + 'plus' + ); // get the action buttons per server $this->tpl->newTemplate('servers_list_admin_actions', 'servers.tpl.html'); $html_actions = $this->tpl->getTemplate('servers_list_admin_actions'); } else { $html_actions = ''; } + + $sidebar->addLink( + 'update', + psm_get_lang('menu', 'server_update'), + psm_build_url(array('mod' => 'server_update')), + 'refresh' + ); + // we need an array for our template magic (see below): $html_actions = array('html_actions' => $html_actions); @@ -114,6 +125,15 @@ class ServerController extends AbstractServerController { */ protected function executeEdit() { $this->setTemplateId('servers_update', 'servers.tpl.html'); + $sidebar = new \psm\Util\Module\Sidebar($this->tpl); + $this->setSidebar($sidebar); + + $sidebar->addLink( + 'go_back', + psm_get_lang('system', 'go_back'), + psm_build_url(array('mod' => 'server')), + 'th-list' + ); $server_id = isset($_GET['id']) ? intval($_GET['id']) : 0; diff --git a/src/psm/Module/User/Controller/UserController.class.php b/src/psm/Module/User/Controller/UserController.class.php index fed51894..14269235 100644 --- a/src/psm/Module/User/Controller/UserController.class.php +++ b/src/psm/Module/User/Controller/UserController.class.php @@ -69,6 +69,15 @@ class UserController extends AbstractController { */ protected function executeIndex() { $this->setTemplateId('users_list', 'users.tpl.html'); + $sidebar = new \psm\Util\Module\Sidebar($this->tpl); + $this->setSidebar($sidebar); + + $sidebar->addLink( + 'add_new', + psm_get_lang('system', 'add_new'), + psm_build_url(array('mod' => 'user', 'action' => 'edit')), + 'plus' + ); // build label array for the next loop $servers_labels = array(); @@ -105,6 +114,15 @@ class UserController extends AbstractController { */ protected function executeEdit() { $this->setTemplateId('users_update', 'users.tpl.html'); + $sidebar = new \psm\Util\Module\Sidebar($this->tpl); + $this->setSidebar($sidebar); + + $sidebar->addLink( + 'go_back', + psm_get_lang('system', 'go_back'), + psm_build_url(array('mod' => 'user')), + 'th-list' + ); $user_id = isset($_GET['id']) ? intval($_GET['id']) : 0; $fields_prefill = array('name', 'user_name', 'mobile', 'email'); diff --git a/src/psm/Service/Template.class.php b/src/psm/Service/Template.class.php index 7fe9c6f1..39c661b3 100644 --- a/src/psm/Service/Template.class.php +++ b/src/psm/Service/Template.class.php @@ -80,22 +80,37 @@ class Template { /** * Add data to the template * - * @param string $id template_id used by add_template() + * @param string $tpl_id template_id used by add_template() * @param array $data + * @param boolean $use_html if true, $tpl_id is considered to be HTML code and used rather than a template * @return string new template */ - public function addTemplateData($id, $data) { - // does the template exist? - if (!isset($this->templates[$id])) { - // file does not exist - trigger_error('Template not found with id: '.$id); - return false; + public function addTemplateData($tpl_id, $data, $use_html = false) { + if($use_html) { + // no template + $source = $tpl_id; + } else { + // does the template exist? + if (!isset($this->templates[$tpl_id])) { + // file does not exist + trigger_error("Template '{$tpl_id}' could not be found", E_USER_WARNING); + return false; + } + $source =& $this->templates[$tpl_id]; } foreach($data as $key => $value) { - $this->templates[$id] = str_replace('{'.$key.'}', $value, $this->templates[$id]); + if(is_array($value)) { + $subdata = array(); + foreach($value as $k => $v) { + $subdata[$key.'_'.$k] = $v; + } + $source = $this->assignTplVar($source, $subdata, true); + } else { + $source = str_replace('{'.$key.'}', $value, $source); + } } - return $this->templates[$id]; + return $source; } /** diff --git a/src/psm/Util/Module/Sidebar.class.php b/src/psm/Util/Module/Sidebar.class.php new file mode 100644 index 00000000..04b34d53 --- /dev/null +++ b/src/psm/Util/Module/Sidebar.class.php @@ -0,0 +1,122 @@ +. + * + * @package phpservermon + * @author Pepijn Over + * @copyright Copyright (c) 2008-2014 Pepijn Over + * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3 + * @version Release: @package_version@ + * @link http://www.phpservermonitor.org/ + **/ + +namespace psm\Util\Module; +use psm\Service\Template; + +class Sidebar implements SidebarInterface { + + /** + * ID of active item + * @var string $active_id + * @see setActiveItem() + */ + protected $active_id; + + /** + * List of all sidebar items + * @var array $items + */ + protected $items = array(); + + /** + * Template service + * @var \psm\Service\Template $tpl + */ + protected $tpl; + + public function __construct(Template $tpl) { + $this->tpl = $tpl; + } + + /** + * Set active item + * @param string $id + * @return \psm\Util\Module\Sidebar + */ + public function setActiveItem($id) { + $this->active_id = $id; + return $this; + } + + /** + * Add new link to sidebar + * @param string $id + * @param string $label + * @param string $url + * @param string $icon + * @return \psm\Util\Module\Sidebar + */ + public function addLink($id, $label, $url, $icon = null) { + if(!isset($this->items['link'])) { + $this->items['link'] = array(); + } + + $this->items['link'][$id] = array( + 'type' => 'link', + 'label' => $label, + 'url' => str_replace('"', '\"', $url), + 'icon' => $icon, + ); + return $this; + } + + public function createHTML() { + $tpl_id = 'main_sidebar_container'; + $this->tpl->newTemplate($tpl_id, 'main_sidebar.tpl.html'); + + $types = array('link'); + $items = array(); + + // loop through all types and build their html + foreach($types as $type) { + if(empty($this->items[$type])) { + // no items for this type + continue; + } + // retrieve template for this type once so we can use it in the loop + $tpl_id_type = 'main_sidebar_types_' . $type; + $this->tpl->newTemplate($tpl_id_type, 'main_sidebar.tpl.html'); + $html_type = $this->tpl->getTemplate($tpl_id_type); + + // build html for each individual item + foreach($this->items[$type] as $id => $item) { + $items[] = array( + 'html_item' => $this->tpl->addTemplateData($html_type, $item, true), + 'class_active' => ($id === $this->active_id) ? 'active' : '', + ); + } + } + if(!empty($items)) { + $this->tpl->addTemplateDataRepeat($tpl_id, 'items', $items); + } + + $html = $this->tpl->getTemplate($tpl_id); + + return $html; + } +} \ No newline at end of file diff --git a/src/psm/Util/Module/SidebarInterface.class.php b/src/psm/Util/Module/SidebarInterface.class.php new file mode 100644 index 00000000..24f791ea --- /dev/null +++ b/src/psm/Util/Module/SidebarInterface.class.php @@ -0,0 +1,36 @@ +. + * + * @package phpservermon + * @author Pepijn Over + * @copyright Copyright (c) 2008-2014 Pepijn Over + * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3 + * @version Release: @package_version@ + * @link http://www.phpservermonitor.org/ + **/ + +namespace psm\Util\Module; + +interface SidebarInterface { + + public function __construct(\psm\Service\Template $tpl); + + public function createHTML(); + +} \ No newline at end of file diff --git a/src/templates/config.tpl.html b/src/templates/config.tpl.html index 38af9114..1fe4be28 100755 --- a/src/templates/config.tpl.html +++ b/src/templates/config.tpl.html @@ -1,7 +1,5 @@ -{config_update} -
-
+
- - - - - -
- Please update! -
- \ No newline at end of file + + \ No newline at end of file diff --git a/src/templates/install.tpl.html b/src/templates/install.tpl.html index 019119f5..c57e973b 100755 --- a/src/templates/install.tpl.html +++ b/src/templates/install.tpl.html @@ -152,7 +152,7 @@ If no errors have occurred, you are good to go.

-

{status}

+

{shortcode}

{message}

diff --git a/src/templates/log.tpl.html b/src/templates/log.tpl.html index c4f99c3e..666e40c5 100755 --- a/src/templates/log.tpl.html +++ b/src/templates/log.tpl.html @@ -1,23 +1,21 @@ -
-
- -
-
- {content_status} -
-
- {content_email} -
-
- {content_sms} -
-
-
+
+ +
+
+ {content_status} +
+
+ {content_email} +
+
+ {content_sms} +
+
diff --git a/src/templates/main.tpl.html b/src/templates/main.tpl.html index e2bbdad2..083b2664 100755 --- a/src/templates/main.tpl.html +++ b/src/templates/main.tpl.html @@ -45,12 +45,12 @@
-
-
+ {html_sidebar} +
@@ -60,9 +60,9 @@ {messages}
+ {content}
-
-
{content}
+
{html_footer}
@@ -76,8 +76,8 @@ diff --git a/src/templates/main_sidebar.tpl.html b/src/templates/main_sidebar.tpl.html new file mode 100755 index 00000000..0f4d3aac --- /dev/null +++ b/src/templates/main_sidebar.tpl.html @@ -0,0 +1,15 @@ + +
+ +
+ + + {label} \ No newline at end of file diff --git a/src/templates/servers.tpl.html b/src/templates/servers.tpl.html index 58363a0d..8eeb8891 100755 --- a/src/templates/servers.tpl.html +++ b/src/templates/servers.tpl.html @@ -1,59 +1,47 @@ -
-{html_buttons_admin} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {servers} - -
 {label_label}{label_domain}{label_port}{label_type}{label_last_check}{label_rtime}{label_last_online}{label_monitoring}{label_send_email}{label_send_sms}{label_action}
- - {status} - - {label}{ip}{port}{type}{last_check}{rtime} s{last_online}{active}{email}{sms}{html_actions}
-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {servers} + +
 {label_label}{label_domain}{label_port}{label_type}{label_last_check}{label_rtime}{label_last_online}{label_monitoring}{label_send_email}{label_send_sms}{label_action}
+ + {status} + + {label}{ip}{port}{type}{last_check}{rtime} s{last_online}{active}{email}{sms}{html_actions}
- - - - @@ -64,81 +52,79 @@ - +
+
+ {titlemode} +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ + {label_go_back} +
+
+
\ No newline at end of file diff --git a/src/templates/user/profile.tpl.html b/src/templates/user/profile.tpl.html old mode 100644 new mode 100755 index b1ed1961..71e0b85e --- a/src/templates/user/profile.tpl.html +++ b/src/templates/user/profile.tpl.html @@ -1,51 +1,49 @@ -
-
-
-
- -
- -
+ +
+
+ +
+
-
- -
- -
+
+
+ +
+
-
- -
+
+
+ +
+
+
+ +
+
-
- -
- -
+
+
+ +
+
-
- -
- -
+
+
+ +
+
-
- -
- -
+
+
+ +
+
-
- -
- -
-
-
- -
-
- -
+
+
+ +
+ + \ No newline at end of file diff --git a/src/templates/users.tpl.html b/src/templates/users.tpl.html index fba7de6c..06432e17 100755 --- a/src/templates/users.tpl.html +++ b/src/templates/users.tpl.html @@ -1,123 +1,113 @@ -
- - - - - - - - - - - - - - - - - - - - - - - - - - {users} - -
{label_name}{label_user_name}{label_level}{label_mobile}{label_email}{label_servers}{label_action}
{name}{user_name}{label_level_{level}}{mobile}{email}{emp_servers} - - - - - - -
-
+ + + + + + + + + + + + + + + + + + + + + + + + + {users} + +
{label_name}{label_user_name}{label_level}{label_mobile}{label_email}{label_servers}{label_action}
{name}{user_name}{label_level_{level}}{mobile}{email}{emp_servers} + + + + + + +
-
-
-
- {titlemode} -
- -
- -
-
-
- -
- -
-
-
- -
- -

- {label_level_description} -

-
+ +
+ {titlemode} +
+ +
+
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- - - - {servers} -
-
-
- - -
-
- -
+
+
+ +
+ +
+
+
+ +
+ +

+ {label_level_description} +

+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + + + {servers} +
+
+
+ + +
+ + \ No newline at end of file diff --git a/static/css/style.css b/static/css/style.css index 41d08ee4..a4070f89 100755 --- a/static/css/style.css +++ b/static/css/style.css @@ -11,6 +11,9 @@ body { padding-left: 0; padding-right: 0; } +.sidebar-nav { + padding: 9px 0; +} body.install{ padding-top:20px; } @@ -27,10 +30,6 @@ body.install{ color:#FFF; text-decoration:none; } -.top_buutons{ - text-align:right; - padding:10px 0px 10px 0px; -} .footer{ margin-top:20px; border-top:1px solid #EEEEEE;