/** * Returns a (new) request id * * ScavixWDF creates a new ID for every request and passed it to every subsequent AJAX call. * This method does the real magic and creates a new request id or returns the current. * @return string A new request id or the current one */ function RequestId() { if (!isset($GLOBALS['session_request_id'])) { $p = current_controller(); $e = current_event(); $GLOBALS['session_request_id'] = md5($p . $e . microtime()); } return $GLOBALS['session_request_id']; }
/** * Tries to figure out the item that must have the focus * * Will then set it active and return * @return void */ function DetectSelected() { $controller = strtolower(current_controller()); $event = current_event(true); $data = md5(render_var($_GET)); for ($level = 1; $level <= 6; $level++) { foreach ($this->GetItems() as $item) { if ($level < 4) { foreach ($item->GetItems() as $sub) { if ($sub->controller == $controller && ($level > 2 || $sub->event == $event) && ($level > 1 || $sub->data == $data)) { $sub->SetSelected(); $item->SetSelected(); return; } } } else { if ($item->controller == $controller && ($level > 5 || $item->event == $event) && ($level > 4 || $item->data == $data)) { $item->SetSelected(); return; } } } } }
/** * Builds a query for the current page. * * Calls buildQuery internally to build an URL to the current route. * @param string|array $data Additional data * @return string A complete Request (for use as HREF) */ function samePage($data = "") { return buildQuery(current_controller(), current_event(), $data); }
function __initialize($title = "", $body_class = false) { global $CONFIG; // sometimes state-/UI-less sites (like APIs) trickout the AJAX detection by setting this. // as we need UI this must be reset here unset($GLOBALS['result_of_system_is_ajax_call']); header("Content-Type: text/html; charset=utf-8"); // overwrite previously set header to ensure we deliver HTML unset($CONFIG["use_compiled_js"]); unset($CONFIG["use_compiled_css"]); if (current_event(true) != 'login' && (!isset($_SESSION['admin_handler_username']) || !isset($_SESSION['admin_handler_password']) || $_SESSION['admin_handler_username'] != $CONFIG['system']['admin']['username'] || $_SESSION['admin_handler_password'] != $CONFIG['system']['admin']['password'])) { log_debug(current_event(true)); log_debug($_SESSION['admin_handler_username']); log_debug($_SESSION['admin_handler_password']); redirect('sysadmin', 'login'); } parent::__initialize("SysAdmin - {$title}", 'sysadmin'); $this->_translate = false; if (current_event(true) != 'login') { $nav = parent::content(new Control('div')); $nav->class = "navigation"; foreach ($CONFIG['system']['admin']['actions'] as $label => $def) { if (!class_exists(fq_class_name($def[0]))) { continue; } $nav->content(new Anchor(buildQuery($def[0], $def[1]), $label)); } $nav->content(new Anchor(buildQuery('sysadmin', 'cache'), 'Cache')); $nav->content(new Anchor(buildQuery('sysadmin', 'phpinfo'), 'PHP info')); $nav->content(new Anchor(buildQuery('translationadmin', 'newstrings'), 'Translations')); $nav->content(new Anchor(buildQuery('sysadmin', 'testing'), 'Testing')); $nav->content(new Anchor(buildQuery('', ''), 'Back to app')); $nav->content(new Anchor(buildQuery('sysadmin', 'logout'), 'Logout', 'logout')); $this->_subnav = parent::content(new Control('div')); } $this->_contentdiv = parent::content(new Control('div'))->addClass('content'); $copylink = new Anchor('http://www.scavix.com', '© 2012-' . date('Y') . ' Scavix® Software Ltd. & Co. KG'); $copylink->target = '_blank'; $footer = parent::content(new Control('div'))->addClass('footer'); $footer->content("<br class='clearer'/>"); $footer->content($copylink); if (current_event() == strtolower($CONFIG['system']['default_event']) && !system_method_exists($this, current_event())) { redirect('sysadmin', 'index'); } }