Ejemplo n.º 1
0
 public function beforeAction($action)
 {
     //预先传递模块ID、控制器ID和动作ID给Smarty
     $moduleName = $this->module->id;
     $controllerName = $this->id;
     $actionName = $action->id;
     static::smartyAssign("moduleName", strtolower($moduleName));
     static::smartyAssign("controllerName", strtolower($controllerName));
     static::smartyAssign("actionName", strtolower($actionName));
     //csrfToken
     $csrfToken = array('name' => Yii::$app->request->csrfParam, 'value' => Yii::$app->request->csrfToken);
     static::smartyAssign('csrfToken', $csrfToken);
     //User信息
     if (!Yii::$app->user->isGuest) {
         $user = User::findIdentity(Yii::$app->user->id);
         static::smartyAssign('user', $user);
     }
     return parent::beforeAction($action);
 }
Ejemplo n.º 2
0
 public function beforeAction($action)
 {
     //预先传递模块ID、控制器ID和动作ID给Smarty
     $moduleName = $this->module->id;
     $controllerName = $this->id;
     $actionName = $this->action->id;
     $this->smartyAssign("moduleName", strtolower($moduleName));
     $this->smartyAssign("controllerName", strtolower($controllerName));
     $this->smartyAssign("actionName", strtolower($actionName));
     //csrfToken
     $csrfToken = array('name' => Yii::$app->request->csrfParam, 'value' => Yii::$app->request->csrfToken);
     $this->smartyAssign('csrfToken', $csrfToken);
     //User信息
     if (!Yii::$app->user->isGuest) {
         $admin = User::findIdentity(Yii::$app->user->id);
         $this->smartyAssign('admin', $admin);
     }
     //激活的文章数量
     $activeArticleCount = Article::getArticleCount(Article::STATUS_DELETED, '>');
     $this->smartyAssign('activeArticleCount', $activeArticleCount);
     return parent::beforeAction($action);
 }