public static function delete($id) { $fl = Files::find($id); if (!is_null($fl->first())) { return $fl->delete(); } else { return false; } }
private static function findFile($model, $name) { $files = Files::find()->where(array("parent_type" => 'app\\models\\docs', "parent_id" => $model->id, "name" => $name))->all(); foreach ($files as $file) { if ($file->name == $name) { return $file; } } return false; }
public function delete($id) { $fl = Files::find($id); $anak = $fl->anak; $del = FilesDAO::delete($id); if ($del) { unlink($fl->file_path . '/' . $fl->file_name); Session::flash('message', "Files dengan nama {$fl->nama} telah dihapus!"); } else { Session::flash('message', "Error, Files with {$id} not found!"); } return Redirect::to('/dash/anak/files/view/' . $anak->id); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Files::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $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, 'solicitation_id' => $this->solicitation_id]); $query->andFilterWhere(['like', 'filename', $this->filename]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Files::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 50], 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]); $query->andFilterWhere(['id' => $this->id, 'project_id' => $this->project_id]); if (isset($this->tagId)) { CommonHelper::addCriteriaForTagid($query, TagModel::MODEL_FILES, $this->tagId); } if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['like', 'file', $this->file]); return $dataProvider; }
public function actionGetCard($cid) { $company = Company::find()->where(['id' => $cid])->asArray()->one(); $address = Address::find()->where(['id' => $company['address_id']])->asArray()->one(); $shedule = Shedule::find()->where(['company_id' => $cid])->asArray()->all(); $brand = Company::find()->where(['id' => $cid])->one()->brand; $service = Company::find()->where(['id' => $cid])->one()->service; $srv = ArrayHelper::getColumn($service, 'category_id'); $category = Category::find()->where(['id' => $srv])->asArray()->indexBy('id')->all(); $srv = ArrayHelper::map($service, 'id', 'name', 'category_id'); $spoffer = SpecialOffer::find()->where(['company_id' => $cid])->asArray()->one(); $file = Files::find()->where(['id' => $spoffer['file_id']])->asArray()->one(); Yii::$app->response->format = Response::FORMAT_JSON; $response = ['company' => $company, 'address' => $address, 'shedule' => $shedule, 'brand' => $brand, 'category' => $category, 'service' => $srv, 'spoffer' => $spoffer, 'file' => $file]; return $response; }
public function search($params) { $query = Files::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $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([ // 'facult' => $this->facult, // 'department' => $this->department, // 'predmet' => $this->visable_type, // ]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Files::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); $query->joinWith('user'); $query->joinWith('user.department'); $query->joinWith('user.department.faculty'); $query->joinWith('subject'); 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, 'size' => $this->size, 'visable_type' => $this->visable_type]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'path', $this->path])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'user.first_name', $this->first_name])->andFilterWhere(['like', 'department.department_name', $this->department_name])->andFilterWhere(['like', 'faculty.faculty_name', $this->faculty_name])->andFilterWhere(['like', 'subject.subject_name', $this->subject_name])->andFilterWhere(['like', 'user.last_name', $this->last_name]); return $dataProvider; }
/* @var $this yii\web\View */ use app\models\Files; ?> <div class="col-md-2"> <div class="panel panel-default"> <div class="panel-heading"> Теги </div> <div class="panel-body"> dfsdf sdsdf fg </div> </div> </div> <div class="col-md-10"> <div id="gal1"> <?php $imgs = Files::find()->all(); // foreach ($imgs as $img){ // echo "<li style = 'height : 220px; width : 220px; text-align : center; float : left;'><img src='uploads/{$img -> filename}' style = 'max-width : 200px; max-height : 150px; border-radius : 10px;'><p>{$img -> title}</p></li>"; // } foreach ($imgs as $img) { echo "<img src='thumbnails/{$img->filename}'\n\t\t\t\t\t\talt='{$img->title}'\n\t\t\t\t\t\ttitle='Or here(more priority)'\n\t\t\t\t\t\tdata-desc='some description'\n\t\t\t\t\t\tdata-category='image category here'\n\t\t\t\t\t\tdata-fullsrc='uploads/{$img->filename}'\n\t\t\t\t\t />"; } ?> </div> </div>
public function actionManage($id) { if ($id <= 0) { throw new BadRequestHttpException("Неправильный запрос"); } $album = $this->findAlbum($id); $q = Files::find()->where(['attach_table' => Resources::$tableId, 'attach_id' => $id]); $dataProvider = new ActiveDataProvider(['query' => $q]); $uploadModel = new FileUploadModel(); $uploadModel->id = $id; $uploadModel->tableId = Resources::$tableId; return $this->render('manage', ['dataProvider' => $dataProvider, 'album' => $album, 'uploadModel' => $uploadModel]); }
/** * Downloads file by hash-code * @param $code string * @return bool|string * @throws GoodException if no one file doesn't linked by code */ public function actionGet_file_by_code($code) { try { if (!($file = Files::find()->with('user')->where(['share_link' => $code])->one())) { throw new GoodException('Error', 'No such file linked to this code...'); } return $this->downloadFileByPath('../upload/' . $file->user->login . '/' . $file->path); } catch (Exception $e) { $e->getMessage(); } return false; }
public function getFiles() { return Files::find()->where(['attach_table' => self::$tableId, 'attach_id' => $this->id])->all(); }
public static function genText($news) { $files = Files::find()->where(['news_id' => $news->id])->all(); $files_in_text = ''; if (!empty($files)) { foreach ($files as $file) { $files_in_text .= sprintf("<a style='color:blue; font-weight:bold;' target='_blank' href='http://%s/%s/%s/%s/%s/%s.%s'>%s.%s</a><br />", $_SERVER['SERVER_NAME'], Files::SUB_DIR, Files::UPLOAD_DIR, Files::UPLOAD_FILE_DIR, $file->dir, $file->file_name, $file->ext, $file->origin_file_name, $file->ext); } } if (!empty($news->start_date)) { $start_date = Yii::$app->formatter->asDate($news->start_date, 'php:d.m.Y'); $date_in_text = sprintf('<u>Дата ввода в действие</u>: %s <br />', $start_date); if ($news->type == \app\models\News::NT_CAMPAIGN) { $stop_date = Yii::$app->formatter->asDate($news->stop_date, 'php:d.m.Y'); $date_in_text = sprintf('<u>Срок действия акции</u>: %s - %s <br />', $start_date, $stop_date); } } else { $date_in_text = ''; } // ---------------------------- // Документ, регламентирующий изменения -------------------- if (!empty($news->document)) { $document_in_text = sprintf('<u>Документ, регламентирующий изменения</u>: %s <br />', $news->document); } else { $document_in_text = ''; } if (!empty($news->product)) { $product_in_text = sprintf('<u>Продукт</u>: %s <br />', $news->product); } else { $product_in_text = ''; } $category_title_in_text = sprintf('<u>Сегмент</u>: %s <br />', Categories::findOne($news->category_id)->title); $textGen = sprintf("<div style='font-size:10pt;font-family:Arial,serif;'><br />\n %s\n %s\n %s\n %s\n <br />%s\n %s\n </div>", $date_in_text, $category_title_in_text, $document_in_text, $product_in_text, $news->text, $files_in_text); return $textGen; }
public function pages() { $id = $this->request->data['volume_number']; $volume_number = $id; $url = CWMG_VOLUMES_PATH . "\\v" . str_pad($id, 3, "0", STR_PAD_LEFT) . "-" . $this->roman($id) . "\\TXT"; $count = Pages::count(array('volume_number' => $id)); $numeric_vol = str_pad($id, 3, '0', STR_PAD_LEFT); $roman_vol = $this->roman($id); if ($count == 0) { $sortorder = 0; if (!empty($id)) { if ($handle = opendir($url)) { while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != "..") { if (stristr($entry, "-B-")) { $is_roman = "1"; } else { $is_roman = "0"; } $page = str_replace(".txt", "", $entry); $page = str_replace("v" . $numeric_vol . "-" . $roman_vol, "", $page); $page = str_replace("-A-", "", $page); $page = str_replace("-B-", "", $page); $page = str_replace("-C-", "", $page); $page = str_replace("-D-", "", $page); $filename = str_replace(".txt", "", $entry); // echo "$page\n"; $contents = file_get_contents($url . "\\" . $entry); $data = array('volume_number' => $id, 'type.id' => '', 'type.no' => null, 'type.name' => null, 'description' => $this->clean_hex(str_replace('\\•', '', strip_tags($contents, '<p><i><ol><li><ul>'))), 'page_no' => $page, 'is_roman' => $is_roman, 'sort_order' => $sortorder + 1, 'filename' => $filename, 'updated' => "Y", 'updated_date' => gmdate('Y-m-d'), 'ip' => $_SERVER['REMOTE_ADDR']); $new_page = Pages::create($data)->save(); $newid = $pages->_id; // Import the file in fs.files $pdfurl = CWMG_VOLUMES_PATH . "\\v" . str_pad($id, 3, "0", STR_PAD_LEFT) . "-" . $this->roman($id) . "\\PDF\\"; $pdffilename = $filename . ".pdf"; $cmd = '"E:\\MongoDB\\bin\\Mongofiles.exe" -d CWMG put ' . $pdfurl . $pdffilename; // exec($cmd); // rename the file in fs.files $file = Files::create(); $data = array('filename' => $filename . ".pdf"); $dataFS = Files::find('all', array('conditions' => array('filename' => $pdfurl . $pdffilename)))->save($data); $sortorder++; } } } closedir($handle); } } else { $sortorder = 0; if ($handle = opendir($url)) { while (false !== ($entry = readdir($handle))) { $sortorder++; if ($entry != "." && $entry != "..") { if (stristr($entry, "-B-")) { $is_roman = "1"; } else { $is_roman = "0"; } $page = str_replace(".txt", "", $entry); $page = str_replace("v" . $numeric_vol . "-" . $roman_vol, "", $page); $page = str_replace("-A-", "", $page); $page = str_replace("-B-", "", $page); $page = str_replace("-C-", "", $page); $page = str_replace("-D-", "", $page); $filename = str_replace(".txt", "", $entry); $contents = file_get_contents($url . "\\" . $entry); $conditions = array('filename' => $filename); $page_id = Pages::find(array('fields' => '_id'), array('conditions' => array('filename' => $filename))); $data = array('description' => $this->clean_hex(str_replace('\\•', '', strip_tags($contents, '<p><i><ol><li><ul>'))), 'ip' => $_SERVER['REMOTE_ADDR']); $conditions = array('_id' => $page_id['_id']); // $new_page = Pages::update($data, $conditions); Pages::find(array('fields' => '_id'), array('conditions' => array('filename' => $filename)))->save($data); // print_r("volume_number"); } } closedir($handle); } } $count = Pages::count(array('conditions' => array('volume_number' => $id, 'type.id' => ''))); return compact('count', 'numeric_vol', 'roman_vol', 'volume_number'); }
/** * Retrieves a list of models based on the current search/filter conditions. * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. */ public function search($params) { $query = Files::find(); $dataProvider = new \yii\data\ActiveDataProvider(['query' => $query]); $this->load($params); //if (!$this->validate()) { // return $dataProvider; //} $query->andFilterWhere(['hidden' => $this->hidden, 'parent_id' => $this->parent_id]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'path', $this->path])->andFilterWhere(['like', 'parent_type', $this->parent_type]); //->andFilterWhere(['like', 'hash', $this->hash]); return $dataProvider; }
public static function getAttachedFiles($table_id, $id) { return Files::find()->where(['attach_table' => $table_id, 'attach_id' => $id])->all(); }