index = $index; $this->servers = $_SESSION[APPCONFIG]->servers->Instance($this->index); } /** * Displays the menu in HTML */ public function draw() { if (DEBUG_ENABLED) debug_log('Entered with ()',33,__FILE__,__LINE__,__METHOD__); echo ''; $this->draw_server_name(); $this->javascript = ''; $javascript_id = 0; # Is the user logged in, if so, show the menu. if ($this->servers->isLoggedIn('user')) { $this->draw_menu(); $this->draw_logged_in_user(); if ($this->servers->isReadOnly()) printf('',$this->getDepth()+3-1,_('read only')); else printf('',$this->getDepth()+3); # Draw the menu items. foreach ($_SESSION[APPCONFIG]->getCommandList() as $command) { printf('',$this->getDepth()+3,' '); echo ''; echo "\n\n"; $this->draw_javascript(); } protected function draw_server_name() { echo ''; printf('%s',_('Server')); printf('',$this->getDepth()+3-1); printf('%s',htmlspecialchars($this->servers->getValue('server','name'))); if ($this->servers->isLoggedIn('user')) { $m = sprintf(_('Inactivity will log you off at %s'), strftime('%H:%M',time() + ($this->servers->getValue('login','timeout')*60))); printf(' %s',$m,$m); } echo ''; } protected function draw_menu() { $links = ''; if (is_array($_SESSION[APPCONFIG]->getValue('menu','session'))) foreach ($_SESSION[APPCONFIG]->getValue('menu','session') as $link => $title) { if ($link = $this->menu_item($link)) $links .= sprintf('%s',$link); } # Finally add our logout link. $links .= sprintf('%s',$this->get_logout_menu_item()); # Draw the quick-links below the server name: if ($links) { printf('',$this->getDepth()+3-1); printf('%s
',$links); echo ''; } } protected function menu_item($item) { $menu = $_SESSION[APPCONFIG]->getValue('menu','session'); if (isset($menu[$item])) return sprintf('%s
%s
', $menu[$item]['text'],$menu[$item]['php'],$this->servers->getIndex(),IMGDIR,$menu[$item]['icon'],$item,$item); else return ' '; } protected function get_logout_menu_item() { global $app; $href = sprintf('cmd.php?cmd=logout&index=%s',$this->servers->getIndex()); return sprintf('%s
%s
', _('Logout of this server'),htmlspecialchars($href),'images/logout.png',_('logout'),_('logout')); } protected function draw_logged_in_user() { if (! is_null($_SESSION[APPCONFIG]->getValue('appearance','logged_in_chars')) && (strlen($this->servers->getLogin('user')) > $_SESSION[APPCONFIG]->getValue('appearance','logged_in_chars'))) { printf('%s%s %s...', $this->getDepth()+3-1,_('Logged in as'),_(':'), $this->servers->getLogin('user'), substr($this->servers->getLogin('user'),0,$_SESSION[APPCONFIG]->getValue('appearance','logged_in_chars'))); } else printf('%s%s %s', $this->getDepth()+3-1,_('Logged in as'),_(':'),$this->servers->getLogin('user')); } protected function draw_login_link() { global $recently_timed_out_servers; $server = $this->getServer(); $href = htmlspecialchars( sprintf('cmd.php?cmd=%s&index=%s',get_custom_file($server->getIndex(),'login_form',''),$this->servers->getIndex())); echo ''; printf('%s',$href,_('login')); printf('%s',$this->getDepth()+3-2,$href,_('Login').'...'); echo ''; printf(' ',$this->getDepth()+3); printf(' ',$this->getDepth()+3); # If the server recently timed out display the message if (is_array($recently_timed_out_servers) && in_array($this->servers->getIndex(),$recently_timed_out_servers)) printf('%s', $this->getDepth()+3-1,_('(Session timed out. Automatically logged out.)')); } protected function draw_javascript() { if ($this->javascript) { echo "\n"; echo $this->javascript; echo "\n"; } } /** * Work out how long the deepest "opened" menu item is. * This is used to dynamically build our cells for our menu table. */ protected function getDepth() { return 1; } } ?>