コード例 #1
0
ファイル: BoardController.php プロジェクト: liasica/yiiforum
 /**
  * Updates an existing Board model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * 
  * @param integer $id        	
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post())) {
         $parentIds = Board::getParentIds($model['parent_id']);
         if (in_array($model['id'], $parentIds)) {
             return $this->redirect(['update', 'id' => $id, 'message' => 1]);
         }
         $model->save();
         Board::createCache();
         return $this->redirect(['index']);
     } else {
         $locals = [];
         $locals['boardArrayTree'] = Board::getBoardArrayTree();
         $locals['model'] = $model;
         return $this->render('update', $locals);
     }
 }
コード例 #2
0
ファイル: Board.php プロジェクト: liasica/yiiforum
 public static function createCache()
 {
     $newLine = "\r\n";
     $content = '<?php' . $newLine;
     $channels = Board::find()->all();
     foreach ($channels as $row) {
         $id = $row['id'];
         $content .= '$cachedBoards[' . $row['id'] . ']=[' . $newLine;
         $content .= Board::getCacheItem('id', $row, true);
         $content .= Board::getCacheItem('parent_id', $row, true);
         $parentIds = Board::getParentIds($id);
         $content .= Board::getCacheItemValue('parent_ids', implode(',', $parentIds));
         $content .= Board::getCacheItem('name', $row);
         $content .= Board::getCacheItem('icon', $row);
         $content .= Board::getCacheItem('description', $row);
         $content .= Board::getCacheItem('rule', $row);
         $content .= Board::getCacheItem('columns', $row, true);
         $content .= Board::getCacheItem('sort_num', $row, true);
         $content .= Board::getCacheItem('redirect_url', $row);
         $content .= Board::getCacheItem('target', $row);
         $content .= Board::getCacheItemValue('level', count($parentIds) - 1, true);
         $content .= "];" . $newLine;
     }
     $dataRoot = \Yii::getAlias('@data');
     TFileHelper::writeFile([$dataRoot, 'cache', 'cachedBoards.php'], $content);
 }