當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DashboardController::buildTemplate方法代碼示例

本文整理匯總了PHP中DashboardController::buildTemplate方法的典型用法代碼示例。如果您正苦於以下問題:PHP DashboardController::buildTemplate方法的具體用法?PHP DashboardController::buildTemplate怎麽用?PHP DashboardController::buildTemplate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DashboardController的用法示例。


在下文中一共展示了DashboardController::buildTemplate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: displayPage

 /** Display the requested page. */
 function displayPage($webPage)
 {
     setcookie("last-page", full_url($_SERVER));
     if (isset($_SESSION["message"])) {
         $message = $_SESSION["message"];
         $this->tpl->assign('message', $message);
         unset($_SESSION["message"]);
     }
     try {
         if (isset($this->pdo)) {
             $sth = $this->pdo->prepare("SELECT COUNT(alerts.id) AS c FROM alerts WHERE resolved = 0");
             $sth->execute();
             $countAlerts = $sth->fetch(PDO::FETCH_ASSOC);
             $countAlerts = $countAlerts["c"];
             $this->tpl->assign('countAlerts', $countAlerts);
         }
     } catch (Exception $e) {
         Log::getLogger()->write(Log::LOG_ERROR, "Unable to request DB", $e);
         $this->tpl->assign('countAlerts', 0);
     }
     try {
         switch ($webPage) {
             case CONTROLLER_DASHBOARD:
                 $c = new DashboardController($this->pdo);
                 $c->buildTemplate($this->tpl);
                 break;
             case CONTROLLER_ADMIN:
                 $c = new AdminController($this->pdo);
                 $c->buildTemplate($this->tpl);
                 break;
             case CONTROLLER_PROFILE:
                 $c = new ProfileController($this->pdo);
                 $c->buildTemplate($this->tpl);
                 break;
             case CONTROLLER_HELP:
                 $c = new HelpController($this->pdo);
                 $c->buildTemplate($this->tpl);
                 break;
             case CONTROLLER_LOGIN:
                 $c = new LoginController($this->pdo);
                 $c->buildTemplate($this->tpl);
                 break;
             case CONTROLLER_DEFAULT:
             default:
                 $this->tpl->display('controller_blank.tpl');
                 break;
         }
     } catch (SecurityAccessException $sae) {
         if ($this->tpl->getTemplateVars('message') == null) {
             $_SESSION["message"] = array("type" => "danger", "title" => "Accès interdit", "descr" => "Cette page est protégée. Veuillez vous connecter avec un compte ayant accès à cette page.");
             $this->tpl->assign('message', $_SESSION["message"]);
             unset($_SESSION["message"]);
         }
         // A Security Access Exception occurs when the user cannot see the asked page.
         // So in this case let's redirect to login page.
         $c = new LoginController($this->pdo);
         $c->buildTemplate($this->tpl);
     } catch (SecurityException $se) {
         // A Security Exception is more generic so display a message.
         Log::getLogger()->write(Log::LOG_ALERT, "Security Exception dropped on dispatcher", $se);
         $_SESSION["message"] = array("type" => "danger", "title" => "Erreur", "descr" => $se->getMessage());
         $this->tpl->assign('message', $_SESSION["message"]);
         unset($_SESSION["message"]);
         $this->tpl->display('controller_error.tpl');
     } catch (Exception $e) {
         Log::getLogger()->write(Log::LOG_ERROR, "Unknown Exception dropped on dispatcher", $e);
         // A very generic exception.
         $_SESSION["message"] = array("type" => "danger", "title" => "Erreur", "descr" => $e->getMessage());
         $this->tpl->assign('message', $_SESSION["message"]);
         unset($_SESSION["message"]);
         $this->tpl->display('controller_error.tpl');
     }
 }
開發者ID:yashodhank,項目名稱:Monitoring,代碼行數:74,代碼來源:dispatcher.php


注:本文中的DashboardController::buildTemplate方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。