public function actionIndex($fraid)
 {
     $query = Fragment1Data::find()->where(['fragment_id' => $fraid]);
     $locals = LuLu::getPagedRows($query, ['order' => 'id desc']);
     $locals['currentFragment'] = Fragment::findOne($fraid);
     return $this->render('index', $locals);
 }
Exemplo n.º 2
0
 public function search($params)
 {
     $query = Fragment1Data::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'fragment_id' => $this->fragment_id, 'sort_num' => $this->sort_num]);
     $query->andFilterWhere(['like', 'data', $this->data]);
     return $dataProvider;
 }
Exemplo n.º 3
0
 public static function getFragmentData($fraid, $other = [], $withFragment = false)
 {
     $query = null;
     // $query=Fragment1Data::find();
     $fragment = Fragment::findOne($fraid);
     if ($fragment == null) {
         return [];
     }
     $type = $fragment->type;
     if ($type == 1) {
         $query = Fragment1Data::find();
     } else {
         if ($type == 2) {
             $query = Fragment2Data::find();
         } else {
             if ($type == 3) {
                 $query = Fragment3Data::find();
             }
         }
     }
     if ($query == null) {
         return [];
     }
     $query->where(['fragment_id' => $fraid]);
     if (isset($other['where'])) {
         $query->andWhere($other['where']);
     }
     if (isset($other['order'])) {
         $query->orderBy($other['where']);
     } else {
         $query->orderBy('sort_num desc');
     }
     if (isset($other['offset']) && is_integer($other['offset'])) {
         $query->offset($other['offset']);
     }
     if (isset($other['limit']) && $other['limit']) {
         $query->limit($other['limit']);
     }
     $ret = $query->all();
     if ($type === 3) {
         $temp = [];
         foreach ($ret as $row) {
             $item = self::getContentByChannel($row['channel_id'], ['where' => 'id=' . $row['content_id']]);
             if (empty($item)) {
                 continue;
             }
             $temp[] = $item[0];
         }
         $ret = $temp;
     }
     if ($withFragment) {
         return [$fragment, $ret];
     } else {
         return $ret;
     }
 }