config = Config::get(); } //设置网页标题 public function setLayoutTitle($e) { $matches = $e->getRouteMatch(); if(empty($matches)) { return; } $action = $matches->getParam('action'); $controller = $matches->getParam('controller'); $viewHelperManager = $e->getApplication()->getServiceManager()->get('viewHelperManager'); $headTitleHelper = $viewHelperManager->get('headTitle'); // Setting a separator string for segments $headTitleHelper->setSeparator(' - '); if(isset($this->config->title_map->$controller->action->$action)) { $headTitleHelper->append($this->config->title_map->$controller->action->$action->title); } if(isset($this->config->title_map->$controller)) { $headTitleHelper->append($this->config->title_map->$controller->title); } } //导航条按钮激活 public function setPageNav($e) { $matches = $e->getRouteMatch(); $action = $matches->getParam('action'); $controller = $matches->getParam('controller'); $viewHelperManager = $e->getApplication()->getServiceManager()->get('viewHelperManager'); $inlineScriptHelper = $viewHelperManager->get('inlineScript'); $inlineScriptHelper ->captureStart(); echo "$('#page-nav-".$this->getControllerNavName($controller)."-".$action."').addClass('active');"; $inlineScriptHelper ->captureEnd(); } public function getControllerNavName($invokename) { $ctl = array( 'Application\Controller\Index' => 'index', 'Application\Controller\Account' => 'account' ); return isset($ctl[$invokename]) ? $ctl[$invokename]:""; } //添加用户Ajax脚本 public function setMemberScript($e) { $viewHelperManager = $e->getApplication()->getServiceManager()->get('viewHelperManager'); $inlineScriptHelper = $viewHelperManager->get('inlineScript'); $inlineScriptHelper->prependFile('/js/member.js'); } //移动设备识别 public function mobileDetect($e) { if(!isset($_COOKIE['deviceType']) || empty($_COOKIE['deviceType'])) { $detect = new MobileDetect; $deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer'); setcookie("deviceType", $deviceType, time()+86400,"/"); if(!isset($_SESSION['deviceType']) || empty($_SESSION['deviceType'])) { $_SESSION['deviceType'] = $deviceType; } }else{ if(!isset($_SESSION['deviceType']) || empty($_SESSION['deviceType'])) { $_SESSION['deviceType'] = $_COOKIE['deviceType']; } } } //重置session支持flash上传 public function resetSession($e) { $session_name = session_name(); //echo session_id(); if (isset($_POST[$session_name])) { if(view::checkOs() !== 'windows') { session_destroy(); session_id($_POST[$session_name]); session_start(); }else{ session_id($_POST[$session_name]); } } } }