Пример #1
0
 public function getSourceUrl()
 {
     if (!empty($this->source)) {
         $source = Source::findOne(['name' => $this->source]);
         if (!empty($source->url)) {
             return $source->url;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Пример #2
0
 /**
  * Finds the Source model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Source the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Source::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #3
0
 public function loadModel($id)
 {
     $model = Source::findOne($id);
     if ($model === null) {
         throw new \yii\web\HttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #4
0
 /**
  * Закладки
  * @return string
  * @throws \Exception
  */
 public function actionMarkers()
 {
     $current_hour = date('G', time() + 7 * 60 * 60);
     //return $current_hour;
     switch ($current_hour) {
         case 6:
             $cat = 136;
             break;
         case 7:
             $cat = 113;
             break;
         case 8:
             $cat = 116;
             break;
         case 9:
             $cat = 116;
             break;
         case 10:
             $cat = 116;
             break;
         case 11:
             $cat = 116;
             break;
         case 12:
             $cat = 116;
             break;
         case 13:
             $cat = 116;
             break;
         case 14:
             $cat = 116;
             break;
         case 15:
             $cat = 116;
             break;
         case 18:
             $cat = 114;
             break;
         case 19:
             $cat = 114;
             break;
         default:
             $cat = 53;
     }
     // return $cat;
     if (Yii::$app->getRequest()->getQueryParam('user')) {
         $user = MarkUser::findOne(Yii::$app->getRequest()->getQueryParam('user'));
         if (!$user) {
             return 'Доступ запрещен!';
         }
         if (Yii::$app->getRequest()->getQueryParam('id') && Yii::$app->getRequest()->getQueryParam('mark')) {
             //return var_dump((int)Yii::$app->getRequest()->getQueryParam('id'));
             $update_source = Source::findOne((int) Yii::$app->getRequest()->getQueryParam('id'));
             $update_source->marker = Yii::$app->getRequest()->getQueryParam('mark');
             $update_source->is_next = 0;
             $update_source->update(false);
             //return var_dump($update_source);
             $next_source = Source::find()->where("id > {$update_source->id} and cat_id = {$cat} ")->one();
             if (!$next_source) {
                 $next_source = Source::find()->where("cat_id = {$cat}")->one();
                 if (!$next_source) {
                     return "Категория!";
                 }
             }
             $next_source->is_next = 1;
             //return var_dump($next_source);
             $next_source->update(false);
             return $this->renderPartial('source', ['source' => $next_source, 'user' => $user]);
         }
         $source = Source::find()->where("cat_id = {$cat} and is_next = 1")->one();
         return $this->renderPartial('source', ['source' => $source, 'user' => $user]);
     }
     return 'нет!';
 }
Пример #5
0
 /**
  * Генератор тэговых страниц
  */
 public function actionGetTags()
 {
     $list = scandir('/home/romanych/www/vrs/pages/');
     $list = array_diff($list, ['.', '..']);
     //var_dump($list); exit;
     $alphabet = fopen("/home/romanych/www/vrs/alphabet.html", "w");
     fwrite($alphabet, self::$header);
     foreach ($list as $letter) {
         fwrite($alphabet, "<div class='letters'><a href='pages/" . $letter . "/tags.html'>" . $letter . "</a></div>");
         $alfa_tags = fopen("/home/romanych/www/vrs/pages/" . $letter . "/tags.html", "w");
         fwrite($alfa_tags, self::$header);
         fwrite($alfa_tags, self::$footer);
         fclose($alfa_tags);
     }
     fwrite($alphabet, self::$footer);
     fclose($alphabet);
     $tags = Tag::find()->orderBy('name')->all();
     //var_dump($tags); exit;
     //$file =  fopen("/home/romanych/www/vrs/tags.html", "w");
     //fwrite($file, self::$header);
     foreach ($tags as $tag) {
         $first_letter = mb_substr($tag->name, 0, 1, 'UTF-8');
         //var_dump($first_letter); exit;
         $big_first_letter = mb_strtoupper($first_letter, 'UTF-8');
         $alfa_tags = fopen("/home/romanych/www/vrs/pages/" . $big_first_letter . "/tags.html", "a");
         fwrite($alfa_tags, "<a href='" . TranslateHelper::translit($tag->name) . ".html'><button type='button' class='btn btn-default btn-lg'>{$tag->name}</button></a>");
         fwrite($alfa_tags, self::$footer);
         fclose($alfa_tags);
         //fwrite($file, "<p><a href='pages/".$big_first_letter."/". TranslateHelper::translit($tag->name) .".html'>$tag->name</a></p>");
         $page = fopen("/home/romanych/www/vrs/pages/" . $big_first_letter . "/" . TranslateHelper::translit($tag->name) . ".html", "w");
         fwrite($page, '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                         <link rel="stylesheet" type="text/css" href="../../css/bootstrap.min.css">
                         <meta name="viewport" content="width=device-width, initial-scale=1.0">
                         <style>.item_head{font-weight: bold;} body{padding-left: 20px; padding-top: 20px;} </style>');
         $items = explode(",", $tag->items);
         $r = 1;
         foreach ($items as $item) {
             try {
                 $item = Items::findOne(['id' => (int) $item]);
                 $source = Source::findOne(['id' => $item->source_id]);
                 $author = Author::findOne(['id' => $source->author_id]);
                 fwrite($page, "<p class='item_head'>{$r} {$item->title} ({$author->name} - {$source->title})</p>\n                    " . $this->renderPlayer($item->audio_link) . "\n                    " . nl2br("<p>{$item->text}</p>") . "\n\n                    ");
             } catch (\ErrorException $e) {
                 echo $e->getMessage() . PHP_EOL;
                 var_dump(Items::findOne(['id' => (int) $item]));
             }
             $r++;
         }
         fwrite($page, self::$footer);
         fclose($page);
     }
     //fwrite($file, self::$footer);
     //fclose($file);
 }
Пример #6
0
        </div>
        <div class="col-lg-10">
            <?php 
$form = ActiveForm::begin(['id' => 'authors-form']);
?>

            <?php 
echo $form->field($model, 'title')->textInput();
?>

            <?php 
echo $form->field($model, 'text')->textarea(['rows' => 5, 'cols' => 5, 'id' => 'my-textarea-id']);
?>

            <?php 
echo $form->field($model, 'source_title')->widget(AutoComplete::className(), ['clientOptions' => ['source' => $sources, 'minLength' => '3', 'autoFill' => true], 'options' => ['class' => 'form-control', 'value' => $model->isNewRecord ? '' : \app\models\Source::findOne($model->source_id)->title]]);
?>

            <?php 
echo $form->field($model, 'link')->textInput();
?>

            <div class="form-group">
                <?php 
echo Html::submitButton($model->isNewRecord ? 'Создать' : 'Обновить', ['class' => 'btn btn-primary', 'name' => 'create-button']);
?>
            </div>
            <?php 
ActiveForm::end();
?>
        </div>