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
{status}
+{shortcode}
{message}
- | {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} | -
+ | {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} | +