. * * @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://phpservermon.neanderthal-technology.com/ **/ abstract class modCore { /** * Custom message * @var string */ public $message; /** * Current mode. Can be used by modules to determine * what to do * @var string */ public $mode; /** * smDatabase object * @var object */ protected $db; /** * smTemplate object * @var object */ protected $tpl; /** * Template Id that should be added to the main template * @var string * @see setTemplateId() getTemplateId() */ protected $tpl_id; function __construct() { global $db; $this->db = ($db) ? $db : new smDatabase(); $this->tpl = new smTemplate(); } /** * Create the HTML code for the module. * First the createHTMLLabels() will be called to add all labels to the template, * Then the tpl_id set in $this->getTemplateId() will be added to the main template automatically */ public function createHTML() { // add JS and CSS files $this->tpl->addJS('monitor.js'); $this->tpl->addCSS('monitor.css'); if(sm_get_conf('show_update')) { // user wants updates, lets see what we can do $this->createHTMLUpdateAvailable(); } $this->createHTMLLabels(); // add the module's custom template to the main template to get some content $this->tpl->addTemplatedata( 'main', array( 'content' => $this->tpl->getTemplate($this->getTemplateId()), 'message' => ($this->message == '') ? ' ' : $this->message, ) ); // display main template echo $this->tpl->display('main'); } /** * First check if an update is available, if there is add a message * to the main template */ protected function createHTMLUpdateAvailable() { // check for updates? if(sm_check_updates()) { // yay, new update available =D $this->tpl->addTemplateData( 'main', array( 'update_available' => '
'.sm_get_lang('system', 'update_available').'
', ) ); } } /** * Use this to add language specific labels to template * * @see createHTML() */ protected function createHTMLLabels() { global $type; $this->tpl->addTemplateData( 'main', array( 'title' => strtoupper(sm_get_lang('system', 'title')), 'subtitle' => sm_get_lang('system', $type), 'active_' . $type => 'active', 'label_servers' => sm_get_lang('system', 'servers'), 'label_users' => sm_get_lang('system', 'users'), 'label_log' => sm_get_lang('system', 'log'), 'label_config' => sm_get_lang('system', 'config'), 'label_update' => sm_get_lang('system', 'update'), 'label_help' => sm_get_lang('system', 'help'), ) ); } /** * Set a template id that will be added to the main template automatically * once you call the parent::createHTML() * * @param string $tpl_id * @param string $tpl_file if given, the tpl_id will be created automatically from this file * @see getTemplateId() createHTML() */ public function setTemplateId($tpl_id, $tpl_file = null) { $this->tpl_id = $tpl_id; if($tpl_file != null) { // tpl_file given, try to load the template.. $this->tpl->newTemplate($tpl_id, $tpl_file); } } /** * Get the mpalte id that will be added to the main template * * @return string * @see setTemplateId() */ public function getTemplateId() { return $this->tpl_id; } } ?>