'; return $output; } static public function mooTools() { $output = ' '; return $output; } static public function buildTopNav() { $dbObj = Database::connect(); $tabs = array( array('name'=>'Home', 'text'=>'Home', 'url'=>'/Home', 'sub'=>array( array('text'=>'Something', 'url'=>'/Home/something'))), array('name'=>'Applications', 'text'=>'Applications', 'url'=>'/Applications/', 'sub'=>array( array('text'=>'My Applications', 'url'=>'/Applications/MyApps/'))), array('name'=>'Users', 'text'=>'Manage Users', 'url'=>'/Users/', 'sub'=>array( array('text'=>'Add User', 'url'=>'/Users/add/'), array('text'=>'Delete User', 'url'=>'/Users/delete'))), array('name'=>'Settings', 'text'=>'Account Settings', 'url'=>'/Settings/', 'sub'=>array( array('text'=>'Password', 'url'=>'/Settings/password/'), array('text'=>'Contact Information', 'url'=>'/Settings/contact'))), array('name'=>'Notes', 'text'=>'Account Notes', 'url'=>'/Notes/', 'sub'=>array()), array('name'=>'Support', 'text'=>'Support', 'url'=>'/Support/', 'sub'=>array( array('text'=>'Tickets', 'url'=>'/Support/tickets/'), array('text'=>'Documentation', 'url'=>'/Support/docs/'), array('text'=>'FAQ', 'url'=>'/Support/faq/')))); $appsSubNavQuery = " SELECT LinkText, DashboardURL From Applications Where IsActive = 1 "; $apps = $dbObj->getAll($appsSubNavQuery); if( is_array($apps) ) { foreach($apps as $app) { $i++; $tabs[1]['sub'][$i]['text'] = $app['LinkText']; $tabs[1]['sub'][$i]['url'] = $app['DashboardURL']; } } $r = $_SERVER['REQUEST_URI']; $r = explode('/',$r); $output = '
'; $output .= $sub; return $output; } static public function getAppLeftNav() { $r = explode('/',$_GET['class']); $class = strtolower($r[1]); $dir = dirname(__FILE__); $file = $dir.'/helpers/'.$class.'.php'; if( file_exists($file) ) { require_once( $file ); } else { throw new TemplateException('Unable to find template helper: '.$file); } $object = new $class; $output = $object->getNav($_GET['method']); return $output; } public function addVar($index, $value) { $this->vars[$index] = $value; } static private function findHeader( $directory, $file ) { $default = self::$template_directory.'header.php'; $custom = self::$template_directory.$directory.'/header.php'; $veryCustom = self::$template_directory.$directory.'/'.$file.'_header.php'; if( file_exists( $veryCustom )) { return $veryCustom; } if( file_exists( $custom )) { return $custom; } if( file_exists( $default )) { return $default; } else { throw new TemplateException('Unable to find header(s): '. $default); } } static private function findFooter( $directory ) { $default = self::$template_directory.'footer.php'; $custom = self::$template_directory.$directory.'/footer.php'; if( file_exists( $custom )) { return $custom; } if( file_exists( $default )) { return $default; } else { throw new TemplateException('Unable to find footer(s): '. $default); } } public function render( $directory, $file ) { $header = self::findHeader( $directory, $file ); $footer = self::findFooter( $directory ); $f1 = self::$template_directory.$directory.'/'.$file.'.php'; $f2 = self::$template_directory.$directory.'/default.php'; $f3 = self::$template_directory.'default.php'; if( file_exists( $f1 ) ) { $f = $f1; } else if ( file_exists( $f2 ) ) { $f = $f2; } else if ( file_exists( $f3 ) ) { $f = $f3; } else { throw new TemplateException('Unable to find a template: '. $f1 .' && '. $f2 .' && '. $f3); } $contents = file_get_contents($f); foreach($this->vars as $index=>$value) { $$index = $value; } ob_start(); include($header); header('Content-type: text/html'); include($f); include($footer); ob_end_flush(); } } ?>