/** * This method formats a URL for the specified routing item class name, incorporating * the get parameters specified in the get parameter map. * @param String $routingItemClassPath The class path of the target routing item. * @param array $getParamMap A map of get parameters to be included in the URL (optional). * @return String The formatted URL. */ public static function formatRoutingItemUrl($routingItemClassPath, array $getParamMap = NULL) { ClassLoader::requireClassOnce($routingItemClassPath); $routingClassName = ClassLoader::parseClassName($routingItemClassPath); $url = UrlFormatter::getBaseUrl() . '?' . IndexRoutingItem::INDEX_ROUTING_ITEM_GET_PARAM . '='; $url .= $routingClassName::getRoutingKey(); if ($getParamMap != NULL) { foreach ($getParamMap as $key => $value) { $url .= "&{$key}={$value}"; } } return $url; }
/** * Displays the header section, including opening tags, as well as the header and main menu * @param User $user If specified and not NULL, this will determine whether or not to display * options for authenticated users. * @param String $pageName The name of the page the header is being displayed for. * @return void */ protected function displayHeader(User $user = NULL, $pageName) { $cssUrl = UrlFormatter::formatRoutingItemUrl('actions/AccessStyleSheetAction'); $logoUrl = UrlFormatter::formatImageUrl('ui/teamstrausfeld.jpeg'); $siteTitle = "Journey Through Art"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title><?php echo $siteTitle; ?> </title> <link rel="stylesheet" type="text/css" href="<?php echo $cssUrl; ?> "/> <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.js"></script> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> </head> <body> <div class="headerSection"> <div class="headerTitle"> <a href="<?php echo UrlFormatter::getBaseUrl(); ?> "><?php echo $siteTitle; ?> </a> </div> <div class="headerUserSection"> <?php if ($user != NULL) { $username = $user->getUsername(); ?> User: <?php echo $username; ?> <?php } else { $loginActionUrl = UrlFormatter::formatRoutingItemUrl('views/LoginView'); ?> <a href="<?php echo $loginActionUrl; ?> ">Admin</a> <?php } ?> </div> <?php // TODO add logout link if the user is authenticated // TODO add account settings link // TODO add admin view link if the user has admin role ?> </div> <nav> <?php foreach ($this->menuItemList as $menuItemName => $menuItem) { if (!$menuItem['REQUIRES_USER'] || $user != NULL) { ?> <a href="<?php echo $menuItem['URL']; ?> "><?php echo $menuItemName; ?> </a> <?php } } ?> </nav> <div class="contentSection"> <div class="contentSectionHeader"> <p><?php echo $pageName; ?> </p> </div> <?php }