/** * Get relative site path. This path is used for * properly setting cookies. * * @note: Although not specified in documentation cookie path * must be URL encoded. Otherwise you will run into mysterious * problems of cookies not being set. Additionally only ASCII * characters are allowed. */ public static function get_path() { if (!isset(self::$path)) { self::$path = urlencode(dirname($_SERVER['PHP_SELF'])); } return self::$path; }
/** +---------------------------------------------------------- * 当前Session文件名 +---------------------------------------------------------- * @access public +---------------------------------------------------------- * @return string +---------------------------------------------------------- */ static function getFilename() { return Session::path() . '/sess_' . session_id(); }
public static function Menu($object) { $class = isset($object['class']) ? $object['class'] : ""; $style = isset($object['style']) ? "style=\"" . $object['style'] . "\"" : ""; if (isset($object["items"])) { ?> <nav role="navigation" class="navbar navbar-default <?php echo $class; ?> " <?php echo $style; ?> > <!-- Brand and toggle get grouped for better mobile display --> <div class="navbar-header"> <button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a href="<?php echo Session::relativePath(); ?> " class="navbar-brand"><?php echo WEBSITE_TITLE; ?> </a> </div> <!-- Collection of nav links and other content for toggling --> <div id="navbarCollapse" class="collapse navbar-collapse"> <ul class="nav navbar-nav"> <?php foreach ($object["items"] as $item) { if (is_array($item['url'])) { $label = isset($item["label"]) ? $item["label"] : 'Dropdown'; $class = isset($item['class']) ? $item['class'] : ""; $style = isset($item['style']) ? "style=\"" . $item['style'] . "\"" : ""; echo "<li class=\"dropdown {$class}\" {$style}><a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\" role=\"button\" aria-haspopup=\"true\" aria-expanded=\"false\">" . $label . " </a><ul class=\"dropdown-menu\">"; foreach ($item['url'] as $subitem) { $url = isset($subitem['url']) ? $subitem['url'] : '#'; $class = isset($subitem['class']) ? $subitem['class'] : ""; $class = strcasecmp($url, Session::path()) == 0 ? "active " . $class : $class; $target = "target=\"_blank\""; if (0 !== strpos($url, 'http://') && 0 !== strpos($url, 'https://')) { $url = Session::relativePath() . $url; $target = ""; } $label = isset($subitem["label"]) ? $subitem["label"] : $url; $style = isset($subitem['style']) ? "style=\"" . $item['style'] . "\"" : ""; echo "<li class=\"{$class}\" {$style}><a {$target} href=\"" . $url . "\">" . $label . "</a></li>"; } echo "</ul>"; } else { $url = isset($item['url']) ? $item['url'] . "/" : '#'; $class = isset($item['class']) ? $item['class'] : ""; $class = strcasecmp($url, Session::path()) == 0 ? "active " . $class : $class; $target = "target=\"_blank\""; if (0 !== strpos($url, 'http://') && 0 !== strpos($url, 'https://')) { $url = Session::relativePath() . $url; $target = ""; } $label = isset($item["label"]) ? $item["label"] : $url; $style = isset($item['style']) ? "style=\"" . $item['style'] . "\"" : ""; echo "<li class=\"{$class}\" {$style}><a {$target} href=\"" . $url . "\">" . $label . "</a></li>"; } } ?> </ul> </div> </nav> <?php } }