当前位置: 首页>>代码示例>>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;未经允许,请勿转载。