title = $title; $this->head = ""; $this->body = ""; $this->getProjectList(); $this->getUserName(); $this->getSitePrivs(); } /** * Adds any HTML "head" code to the final output */ function setHead($head) { $this->head = $head; } function addToHead($html) { $this->head .= $html; } /** * Re-sets the document's title after initialization */ function setTitle($title) { $this->title = $title; } /** * Adds HTML to be displayed */ function add($html) { $this->body .= "\r\n" . $html; } function clear() { $this->head = ""; $this->body = ""; $this->navSubElements = array(); $this->buildProjectSelect(); } /** * Sets the current navigational element (section of the system) */ function setNavElement($navElementId) { $this->navElementId = $navElementId; } /** * Adds a sub-element to the navigation (a sub-item in the navigation tree) */ function addNavSubElement($subElementHtml) { $this->navSubElements[] = $subElementHtml; return count($this->navSubElements); } /** * Builds "switch project" pulldown box */ function getProjectList() { if ( !isset($_SESSION['shell']) ) { return; } $shell = $_SESSION['shell']; $projlist = $shell->exec('hfind -start / -type project -web -return assetId,assetName,fullName'); $this->projectList = $shell->decode($projlist); } function buildProjectSelect() { $this->projectSelect = "\t\t\t\t\t\t\t\t" . 'Switch Project: ' . "\n"; } function getSitePrivs() { $cmd = "hperm -name /"; try { $privLevel = $_SESSION['shell']->exec($cmd); } catch (Exception $e) { $this->add($e->getMessage()); $this->printHtml(); exit; } $this->sitePrivLevel = $privLevel; } function getShowPrivs() { if ( !isset( $_SESSION['projectName'] ) ) { $this->showPrivLevel = 'guest'; return; } $cmd = "hperm -name " . $_SESSION['projectName']; try { $privLevel = $_SESSION['shell']->exec($cmd); } catch (Exception $e) { $this->add($e->getMessage()); $this->printHtml(); exit; } $this->showPrivLevel = $privLevel; } function getUserName () { if ( !isset($_SESSION['shell']) ) { return; } $shell = $_SESSION['shell']; $this->userName = $shell->exec('hwhoami'); } /** * Builds the navigation elements of the page */ function buildNav() { $this->buildProjectSelect(); $xml = simplexml_load_file('tabs.xml'); foreach ($xml->children() as $tabSet) { $setName = $tabSet->getName(); if ($setName == "all") { $allUserTabs = $tabSet; } elseif ($setName == "showadmin") { $showAdminTabs = $tabSet; } elseif ($setName == "siteadmin") { $siteAdminTabs = $tabSet; } } $tabs = array(); foreach ($allUserTabs as $tab) { array_push($tabs, $tab); } // if priv level is admin, display the admin and producer tabs if ($this->showPrivLevel == "admin") { foreach ($showAdminTabs as $tab) { array_push($tabs, $tab); } } if ($this->sitePrivLevel == "admin") { foreach ($siteAdminTabs as $tab) { array_push($tabs, $tab); } } $this->nav = "\t\t\t" . '' . "\n"; $this->nav .= "\t\t\t\t" . '' . "\n"; foreach ($tabs as $tab) { // Special processing for currently active navigation element $this->nav .= "\t\t\t\t\t"; if ($tab->id == $this->navElementId) { $this->nav .= ''; $this->nav .= ''; foreach ($tab->subs->children() as $subTab) { $this->addNavSubElement('' . $subTab->title . ''); } } else { $this->nav .= ''; } $this->nav .= "\n"; } // add a blank column to fill up as much space as it can between the left-hand and // right-hand nav elements $this->nav .= "\t\t\t\t\t" . '' . "\n"; $this->nav .= "\t\t\t\t\t" . '' . "\n"; $this->nav .= "\t\t\t\t\t" . '' . "\n"; $this->nav .= "\t\t\t\t\t" . '' . "\n"; $this->nav .= "\t\t\t\t" . '' . "\n"; $numNavElements = 6 + count($tabs); // Check to see if there are any sub-elements and if so add them to output $this->nav .= "\t\t\t\t" . '' . "\n"; $this->nav .= "\t\t\t\t\t" . '\n"; $this->nav .= "\t\t\t\t\n"; $this->nav .= "\t\t\t\n"; return $this->nav; } /** * Builds the HTML output */ function build () { $svnrev = trim(shell_exec("svn info /helga/dist/wc | grep Revision")); $this->buildNav(); $this->output = '' . "\n"; $this->output .= "\n\n"; $this->output .= "\n"; $this->output .= "\t" . '' . $this->title . '' . "\n"; $this->output .= "\t" . '' . "\n"; // dev javascript $this->output .= "\t" . '' . "\n"; $this->output .= "\t" . '' . "\n"; // build javascript //$this->output .= "\t" . '' . "\n"; //$this->output .= "\t" . '' . "\n"; $this->output .= $this->head; $this->output .= "\t" . '\n"; $this->output .= "\t" . '\n"; $this->output .= "\n\n"; $this->output .= '' . "\n"; $this->output .= "\t" . '' . "\n"; $this->output .= "\t\t" . '\n"; $this->output .= "\t\t\n"; $this->output .= "\t\t\t" . '' . "\n"; $this->output .= "\t\t\t" . '' . "\n"; $this->output .= "\t\t\t" . '' . "\n"; $this->output .= "\t\t\n"; $this->output .= "\t\t\n"; $this->output .= "\t\t\t" . '' . "\n"; $this->output .= "\t\t\t" . '\n"; $this->output .= "\t\t\t" . '' . "\n"; $this->output .= "\t\t\n"; $this->output .= "\t\t\n"; $this->output .= "\t\t\t" . '' . "\n"; $this->output .= "\t\t\t" . '' . "\n"; $this->output .= "\t\t\t" . '' . "\n"; $this->output .= "\t\t\n"; $this->output .= "\t
' . "\n"; $this->output .= $this->nav; $this->output .= "\t\t
' . "\n"; $this->output .= $this->body; $this->output .= "\n\n\t\t\t
\n"; $this->output .= "\t" . '\n"; $this->output .= "\n\n"; $this->output .= ''; return $this->output; } /** * Displays (and builds, if necessary) HTML output */ function printHtml() { $this->build(); echo $this->output; } } ?>