Пример #1
0
 public function search($params)
 {
     $query = ContentFlag::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['value' => $this->value, 'sort_num' => $this->sort_num]);
     $query->andFilterWhere(['like', 'id', $this->id])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Пример #2
0
 public static function getFlag($id = null)
 {
     $flags = ContentFlag::getFlags();
     if ($id !== null) {
         if (isset($flags[$id])) {
             return $flags[$id];
         }
         return '';
     }
     return $flags;
 }
Пример #3
0
 public static function createContentFlagCache()
 {
     self::createCacheFile();
     $content = '<?php' . self::$newLine;
     $dataList = ContentFlag::getFlags();
     foreach ($dataList as $row) {
         $id = $row['id'];
         $content .= '$cachedContentFlags[\'' . $row['id'] . '\']=[' . self::$newLine;
         $content .= self::getCacheItem('id', $row);
         $content .= self::getCacheItem('name', $row);
         $content .= self::getCacheItem('value', $row, 'int');
         $content .= self::getCacheItem('note', $row);
         $content .= "];" . self::$newLine;
     }
     self::writeFile('cachedContentFlags.php', $content);
 }
Пример #4
0
 /**
  * Finds the ContentFlag model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * 
  * @param string $id        	
  * @return ContentFlag the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ContentFlag::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }