public static function display($content = null, $current_tab = null) { self::deleteLinksAdmin(); Layout::addStyle('controlpanel'); $panel = new PHPWS_Panel('controlpanel'); $panel->disableSecure(); $current_mod = PHPWS_Core::getCurrentModule(); $checkTabs = PHPWS_ControlPanel::loadTabs(); $panel->setTabs($checkTabs); $allLinks = PHPWS_ControlPanel::getAllLinks(); if (empty($checkTabs)) { PHPWS_Error::log(CP_NO_TABS, 'controlpanel', 'display'); PHPWS_ControlPanel::makeDefaultTabs(); PHPWS_ControlPanel::reset(); PHPWS_Core::errorPage(); exit; } $defaultTabs = PHPWS_ControlPanel::getDefaultTabs(); foreach ($defaultTabs as $tempTab) { $tabList[] = $tempTab['id']; } if (!empty($allLinks)) { $links = array_keys($allLinks); if ($current_mod != 'controlpanel' && !$current_tab) { foreach ($allLinks as $key => $tablinks) { foreach ($tablinks as $link) { if ($link->itemname == $current_mod) { $current_tab = $key; break 2; } } } } } foreach ($checkTabs as $tab) { if ($tab->getItemname() == 'controlpanel' && in_array($tab->id, $tabList) && (!isset($links) || !in_array($tab->id, $links))) { $panel->dropTab($tab->id); } } if (empty($panel->tabs)) { return dgettext('controlpanel', 'No tabs available in the Control Panel.'); } if (!isset($content) && $current_mod == 'controlpanel') { if (isset($allLinks[$panel->getCurrentTab()])) { foreach ($allLinks[$panel->getCurrentTab()] as $id => $link) { $link_content[] = $link->view(); } $link_content = PHPWS_Template::process(array('LINKS' => implode('', $link_content)), 'controlpanel', 'links.tpl'); $panel->setContent($link_content); } } else { $panel->setContent($content); } if (isset($current_tab)) { $panel->setCurrentTab($current_tab); } if (!isset($panel->tabs[$panel->getCurrentTab()])) { return dgettext('controlpanel', 'An error occurred while accessing the Control Panel.'); } $tab = $panel->tabs[$panel->getCurrentTab()]; $link = str_replace('&', '&', $tab->getLink(false)) . '&tab=' . $tab->id; $current_link = str_replace($_SERVER['PHP_SELF'] . '\\?', '', $_SERVER['REQUEST_URI']); // Headers to the tab's link if it is not a control panel // link tab. if (isset($_REQUEST['command']) && $_REQUEST['command'] == 'panel_view' && !preg_match('/controlpanel/', $link) && $link != $current_link) { PHPWS_Core::reroute($link); } return $panel->display(); }