コード例 #1
0
ファイル: ExplorerSearch.php プロジェクト: jorry2008/turen
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Explorer::find();
     //->isExists();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'is_exsit' => $this->is_exsit, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'action', $this->action])->andFilterWhere(['like', 'session', $this->session])->andFilterWhere(['like', 'field', $this->field])->andFilterWhere(['like', 'path', $this->path])->andFilterWhere(['like', 'dir', $this->dir]);
     return $dataProvider;
 }
コード例 #2
0
 /**
  * @inheritdoc
  */
 protected function getValue($event)
 {
     //查找资源表,获取有效资源信息
     $del = Explorer::find()->where(['field' => $this->fileAttribute])->deleteDraft()->all();
     $ins = Explorer::find()->where(['field' => $this->fileAttribute])->insertDraft()->all();
     $owner = $this->owner;
     $value = $owner->getOldAttribute($this->fileAttribute);
     //注意:bug
     //     	print_r($value);
     //     	print_r($del);
     //     	print_r($ins);
     //     	exit;
     $fvalue = [];
     if ($value) {
         $fvalue = explode(',', $value);
     }
     $fdel = [];
     foreach ($del as $de) {
         $fdel[] = $de->path;
         //更新草稿状态
         $de->status = Explorer::STATUS_COMPLETE;
         $de->update(false);
     }
     $fins = [];
     foreach ($ins as $in) {
         $fins[] = $in->path;
         //更新草稿状态
         $in->status = Explorer::STATUS_COMPLETE;
         $in->update(false);
     }
     $fnew = [];
     if ($fins) {
         $fvalue = ArrayHelper::merge($fvalue, $fins);
         //所有不重复的文件
     }
     if ($fdel) {
         $fvalue = array_diff($fvalue, $fdel);
         //取差集
     }
     if (is_array($fvalue)) {
         sort($fvalue);
     }
     //排序
     return empty($fvalue) ? '' : implode(',', $fvalue);
 }