Beispiel #1
0
 public function __construct($pathinfo, $controller)
 {
     $this->sitename = "OurCoders (我们程序员)";
     $this->short_sitename = "OurCoders";
     $this->pathinfo = $pathinfo;
     parent::__construct($pathinfo, $controller);
     $this->begintime = microtime(true);
     $this->_layout = "index";
     $this->cas[] = array('name' => 'index', 'title' => '首页');
     $this->cas[] = array('name' => 'app', 'title' => '应用列表');
     $this->cas[] = array('name' => 'user', 'title' => '用户');
     $this->cas[] = array('name' => 'group', 'title' => '群组');
     $mainMenu = $this->createMainMenu();
     $title = $this->findTitle();
     $this->_view->assign("sitename", $this->sitename);
     $this->_view->assign("short_sitename", $this->short_sitename);
     if ($title) {
         $this->title = "{$title} - {$this->sitename}";
     } else {
         $this->title = "{$this->sitename}";
     }
     $controller = $this->_controller['name'];
     if ($controller == 'index') {
         $this->breadCrumb = '';
     } else {
         $this->breadCrumb = "<a href='/'>首页</a>-&gt;<a href='/{$controller}/'>{$title}</a>";
     }
     $this->_view->assign('mainMenu', $mainMenu);
     $this->_view->assign('title', $this->title);
     $this->_view->assign('breadCrumb', $this->breadCrumb);
     $controller = ucwords($this->_controller['name']);
     $action = $this->_controller['action'];
     $mainContentFile = "{$controller}/{$action}.html";
     if (file_exists($this->_pathinfo['views'] . '/' . $mainContentFile)) {
         $this->viewFile = $mainContentFile;
     }
     $this->_mainContent->assign("retUrl", $_SERVER['REQUEST_URI']);
     $this->_view->assign("retUrl", $_SERVER['REQUEST_URI']);
     $this->_view->assign("navsel", $controller);
     $userModel = new UserModel();
     $this->userid = $userModel->checklogin();
     if ($this->userid) {
         $this->username = $userModel->username($this->userid);
         $this->isEmailValidated = $userModel->isEmailValidated($this->userid);
         $userinfo = $userModel->userInfo($this->userid);
     }
     $toplinkadsModel = new ToplinkadsModel();
     $toplink = $toplinkadsModel->toplink();
     if ($toplink) {
         $alerttype = array();
         $alerttype[] = "alert-info";
         $alerttype[] = "alert-success";
         $alerttype[] = "";
         $toplink["alert"] = $alerttype[rand(0, 2)];
     }
     $this->_view->assign("toplink", $toplink);
     $this->_view->assign("userid", $this->userid);
     $this->_view->assign("username", $this->username);
     if (isset($this->isEmailValidated)) {
         $this->_view->assign("isEmailValidated", $this->isEmailValidated);
     }
     if (isset($userinfo)) {
         $this->_view->assign("userinfo", $userinfo);
     }
     $iPhone = ToolModel::is_iPhone();
     $this->_view->assign("iPhone", $iPhone);
     $this->_mainContent->assign("userid", $this->userid);
     $this->_mainContent->assign("iPhone", $iPhone);
 }