Пример #1
0
 public function search($params)
 {
     $query = Items::find()->where(['play_status' => 1]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'text', $this->text])->andFilterWhere(['like', 'tags', $this->tags]);
     return $dataProvider;
 }
Пример #2
0
 /**
  * Случайный айтем
  * @return string
  */
 function actionRandItem()
 {
     //return 45;
     $thoughts = Items::find()->where("source_id = 27 or source_id = 17 or\n            source_id = 37 or source_id = 336 or source_id = 528 or cat_id = 104 or cat_id = 94")->andWhere('cens = 0')->orderBy('id ASC')->all();
     $random_ind = rand(0, count($thoughts) - 1);
     if ($thoughts[$random_ind]) {
         return "document.getElementById('rand').innerHTML = \"" . addcslashes(nl2br($thoughts[$random_ind]->text, false), "\r\n\"\\'") . "<br><span style='font-size: 15px'> (" . $thoughts[$random_ind]->source->title . " - " . $thoughts[$random_ind]->source->author->name . ")</span>" . "\";";
     } else {
         return "document.getElementById('rand').innerHTML = 'Доброго Вам Времени!';";
     }
 }
Пример #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Items::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, 'quantity' => $this->quantity]);
     $query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'remarks', $this->remarks]);
     return $dataProvider;
 }
Пример #4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Items::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, 'category' => $this->category, 'type' => $this->type, 'weight' => $this->weight, 'price' => $this->price, 'quantity' => $this->quantity, 'additionDate' => $this->additionDate]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'color', $this->color])->andFilterWhere(['like', 'dimensions', $this->dimensions])->andFilterWhere(['like', 'comment', $this->comment])->andFilterWhere(['like', 'image', $this->image]);
     return $dataProvider;
 }
Пример #5
0
 /**
  * Lists all Items models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Items::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
Пример #6
0
 public function actionItems()
 {
     $model = Items::find()->orderBy(['id' => SORT_DESC])->limit(10)->all();
     return $this->renderPartial('latest-items', ['model' => $model]);
 }
Пример #7
0
 /**
  * Удаление из плейлиста
  * @param $id
  * @param $pl
  * @return string
  * @throws \yii\web\HttpException
  */
 public function actionPlRemove($id, $pl)
 {
     $model = $this->loadModel($id);
     $model->play_status = 1;
     $model->update(false);
     $searchModel = new ItemsQueSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $this_items = Items::find()->where(['play_status' => $pl])->orderBy('radio_que');
     $dataProvider2 = new ActiveDataProvider(['query' => $this_items]);
     return $this->render('playlist', ['items' => $dataProvider, 'new_items' => $dataProvider2, 'searchModel' => $searchModel, 'pl' => $pl]);
 }
Пример #8
0
 public function actionItems()
 {
     if (\filter_input(INPUT_POST, 'category')) {
         $added_items = array();
         if (\filter_input(INPUT_POST, 'update')) {
             $booking_id = filter_input(INPUT_POST, 'update');
             $bookings = \app\models\Bookingitems::find()->where(['=', 'idBooking', $booking_id])->all();
             if (!empty($bookings)) {
                 foreach ($bookings as $b) {
                     $array = array();
                     $array["{$b->idItem}"] = $b->quantity;
                     array_push($added_items, $array);
                 }
             }
         }
         $category_id = filter_input(INPUT_POST, 'category');
         $model = Items::find()->where(['category' => $category_id])->all();
         return $this->renderAjax('category-items', ['model' => $model, 'added_items' => $added_items]);
     }
 }
Пример #9
0
 /**
  * Creates a new Items model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Items();
     $model->setScenario("create");
     $last = Items::find()->orderBy(['id' => SORT_DESC])->one();
     $last_item = empty($last) ? 1 : $last->id + 1;
     if (isset($_POST['Items'])) {
         $model->attributes = $_POST['Items'];
         $model->additionDate = preg_replace('#(\\d{2})/(\\d{2})/(\\d{4})\\s(.*)#', '$3-$2-$1 $4', date('Y-m-d g:i:s'));
         $main_img = UploadedFile::getInstance($model, 'img');
         $pathimage = null;
         if (!empty($main_img)) {
             $model->img = $main_img;
             $model->image = Yii::$app->security->generateRandomString() . $main_img->name . "." . $main_img->extension;
             $pathimage = getcwd() . '/images/items/' . $model->image;
         }
         if ($model->save()) {
             if (isset($pathimage)) {
                 $main_img->saveAs($pathimage);
             }
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             return $this->render('create', ['model' => $model, 'last_item' => $last_item]);
         }
     } else {
         return $this->render('create', ['model' => $model, 'last_item' => $last_item]);
     }
 }
Пример #10
0
 /**
  * Выборка для случайного концерта
  * @return string
  */
 function actionConcert()
 {
     if ($user = Yii::$app->getRequest()->getQueryParam('user')) {
         if (!$user) {
             return 'Доступ запрещн!';
         }
         // $user = Yii::$app->getRequest()->getQueryParam('user');
         if (Items::find()->where(['is_next' => 1])->one()) {
             $item = Items::find()->where(['is_next' => 1])->one();
             $song_id = $item->id;
         } else {
             $song_id = 100;
         }
         $songs = [];
         //return $song_id;
         $songs1 = Items::find()->where("(source_id = 6 or source_id = 40) and id < {$song_id} and published = 1")->limit(5)->orderBy('id DESC')->all();
         $songs2 = Items::find()->where("(source_id = 19 or source_id = 41) and id < {$song_id} and published = 1")->limit(5)->orderBy('id DESC')->all();
         $songs3 = Items::find()->where("source_id = 38 and id < {$song_id} and published = 1")->limit(5)->orderBy('id DESC')->all();
         $songs4 = Items::find()->where("(source_id = 29 or source_id = 326 or source_id = 526) and id < {$song_id} and published = 1")->limit(1)->orderBy('id DESC')->all();
         $songs = array_merge($songs1, $songs2, $songs3, $songs4);
         shuffle($songs);
         //return var_dump($songs);
         //$choosen_songs = [];
         foreach ($songs as $song) {
             try {
                 $items_records = [];
                 $tags = explode(',', $song->tags);
                 $rand_tag = $tags[mt_rand(0, count($tags) - 1)];
                 $this->rand_tag[] = $rand_tag;
                 $query = new Query();
                 // $search_result = $query_search->from('siteSearch')->match($q)->all();  // поиск осуществляется по средством метода match с переданной поисковой фразой.
                 $query_items_ids = $query->from('items')->match($rand_tag)->all();
                 //return var_dump($query_items_ids);
                 foreach ($query_items_ids as $arr_item_rec) {
                     foreach ($arr_item_rec as $id) {
                         $item = Items::findOne((int) $id);
                         if ($item->cat_id == 93 || $item->cat_id == 104 || $item->cat_id == 105 || $item->cat_id == 143 || $item->cat_id == 136) {
                             $items_records[] = Items::findOne((int) $id);
                         }
                     }
                 }
                 //return var_dump($items_records[mt_rand(0,count($items_records)-1)]->text);
                 if (empty($items_records)) {
                     continue;
                 }
                 $rand_index = mt_rand(0, count($items_records) - 1);
                 $song->phrase = $items_records[$rand_index]->text;
                 if (isset($items_records[$rand_index + 1]) && $song->phrase != $song->phrase2) {
                     $song->phrase2 = $items_records[$rand_index + 1]->text;
                 } else {
                     $song->phrase2 = $items_records[0]->text;
                 }
                 //return $song->phrase.'<br>'.$song->phrase2;
                 //return var_dump($song);
                 $this->choosen_songs[] = $song;
             } catch (\ErrorException $e) {
                 return $e->getMessage();
             }
         }
         //exit;
         //return var_dump($this->choosen_songs);
         return $this->renderPartial('concert', ['songs' => $this->choosen_songs, 'tags' => $this->rand_tag]);
     }
 }
Пример #11
0
 /**
  * Формирование рандомного (но с учетом статуса записи) плейлиста для радио
  */
 public function actionMakeRadioPlayListRandChess()
 {
     $f = fopen("/home/romanych/radio/dio/playlist.txt", 'w');
     $arr = [];
     $dibilizmy = Items::find()->where(["source_id" => 17])->all();
     shuffle($dibilizmy);
     $limerik = Items::find()->where(["source_id" => 27])->all();
     shuffle($limerik);
     $cavers = Items::find()->where(["source_id" => 38])->all();
     shuffle($cavers);
     $frazy = Items::find()->where("source_id = 181 or source_id = 37 or source_id = 30 or source_id = 29 or source_id = 25 or source_id = 20")->all();
     shuffle($frazy);
     $peredelki = Items::find()->where(["source_id" => 19])->all();
     shuffle($peredelki);
     $pesni = Items::find()->where(["source_id" => 6])->all();
     shuffle($pesni);
     for ($i = 0; $i < 100; $i++) {
         if (isset($dibilizmy[$i])) {
             array_push($arr, $dibilizmy[$i]);
         }
         if (isset($limerik[$i])) {
             array_push($arr, $limerik[$i]);
         }
         if (isset($cavers[$i])) {
             array_push($arr, $cavers[$i]);
         }
         if (isset($frazy[$i])) {
             array_push($arr, $frazy[$i]);
         }
         if (isset($peredelki[$i])) {
             array_push($arr, $peredelki[$i]);
         }
         if (isset($pesni[$i])) {
             array_push($arr, $pesni[$i]);
         }
     }
     foreach ($arr as $item) {
         if (strstr($item->audio_link, '/music')) {
             $one = str_replace('/music', 'music', $item->audio_link);
             fwrite($f, "/home/romanych/" . $one . PHP_EOL);
         } else {
             fwrite($f, "/home/romanych/Музыка/Thoughts_and_klassik/new_ideas/" . $item->audio_link . PHP_EOL);
         }
     }
     fclose($f);
     // print_r($arr);
 }
Пример #12
0
 function getDecendants($nodeId)
 {
     $node = Items::find($nodeId);
     if (!$node) {
         return false;
     }
     return $node->getDescendants();
 }