Esempio n. 1
0
 public function saveManyAuthors($vidmageAuthors)
 {
     foreach ($vidmageAuthors as $vidmageAuthorId) {
         if (!is_numeric($vidmageAuthorId)) {
             $author = new Author();
             $author->name = $vidmageAuthorId;
             $author->save();
             $vidmageAuthorId = $author->id;
         }
         $vidmageAuthor = new VidmageAuthor();
         $vidmageAuthor->vidmage_id = $this->id;
         $vidmageAuthor->author_id = $vidmageAuthorId;
         $vidmageAuthor->save();
     }
 }
 public function actionIndex($slug)
 {
     $query = Vidmage::find()->joinWith('vidmageAuthors.author')->where(['author.slug' => $slug])->orderBy(['id' => SORT_DESC]);
     $vidmages = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     $author = Author::findOne(['slug' => $slug]);
     return $this->render('index', compact('vidmages', 'author'));
 }
Esempio n. 3
0
 public function actionIndex()
 {
     $this->layout = '/adminka-admin';
     $video_categoria = VideoCategoria::find()->all();
     $authors = Author::find()->all();
     return $this->render('index', ['video_categoria' => $video_categoria, 'authors' => $authors]);
 }
Esempio n. 4
0
 /**
  * Finds the Author model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Author the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Author::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 public function beforeDelete()
 {
     if (parent::beforeDelete()) {
         $author = Author::findOne($this->author_id);
         $author->recount--;
         $author->save();
         return true;
     } else {
         return false;
     }
 }
Esempio n. 6
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Author::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if ($this->load($params) && !$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'descr', $this->descr]);
     return $dataProvider;
 }
 public function safeUp()
 {
     $faker = Factory::create();
     $fakerRus = Factory::create('ru_RU');
     for ($i = 0; $i < 10; $i++) {
         $user = new User();
         $user->username = $faker->userName;
         $user->email = $faker->email;
         $user->setPassword(Yii::$app->params['standart_password']);
         $user->generateAuthKey();
         $result = $user->save();
         if (!$result) {
             return false;
         }
         $dataAuthor = ['id' => $user->id, 'firstname' => $fakerRus->firstName, 'lastname' => $fakerRus->lastName];
         $author = new Author();
         $author->attributes = $dataAuthor;
         $result = $author->save();
         if (!$result) {
             return false;
         }
     }
 }
Esempio n. 8
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Author::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]);
     $query->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname]);
     return $dataProvider;
 }
 /**
 * Creates data provider instance with search query applied
 *
 * @param array $params
 *
 * @return ActiveDataProvider
 */
 public function search($params)
 {
     $query = Author::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'is_famous' => $this->is_famous]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'biography', $this->biography])->andFilterWhere(['like', 'url_info', $this->url_info])->andFilterWhere(['like', 'url_vine', $this->url_vine])->andFilterWhere(['like', 'url_instagram', $this->url_instagram])->andFilterWhere(['like', 'url_youtube', $this->url_youtube])->andFilterWhere(['like', 'handle_twitter', $this->handle_twitter])->andFilterWhere(['like', 'handle_snapchat', $this->handle_snapchat]);
     return $dataProvider;
 }
 public function safeUp()
 {
     $authors = Author::find()->all();
     $authorsIds = [];
     foreach ($authors as $author) {
         $authorsIds[] = $author->id;
     }
     $fakerRus = Factory::create('ru_RU');
     for ($i = 0; $i < 40; $i++) {
         $time = $fakerRus->unixTime;
         $book = new Book();
         $book->name = $fakerRus->sentence(4);
         $book->date_create = $time;
         $book->date_update = $time;
         $book->date = $fakerRus->date;
         $book->author_id = $fakerRus->randomElement($authorsIds);
         $image = $fakerRus->image(Yii::getAlias('@frontend') . '/web/images');
         $book->preview = str_replace(Yii::getAlias('@frontend') . '/web', '', $image);
         $result = $book->save(false);
         if (!$result) {
             return false;
         }
     }
 }
Esempio n. 11
0
<?php

use yii\helpers\Html;
use common\models\Category;
use common\models\Tag;
use common\models\Author;
use common\models\Meme;
use common\models\Vidmage;
use common\helpers\Tools;
$channels = Category::find()->all();
$tags = Tag::find()->orderBy(['recount' => SORT_DESC])->limit(10)->all();
$authors = Author::find()->orderBy(['recount' => SORT_DESC])->limit(5)->all();
$latestMemes = Meme::find()->orderBy(['id' => SORT_DESC])->limit(10)->all();
$latestReplicas = Vidmage::find()->joinWith('memeVidmages')->where(['meme_vidmage.is_the_origin' => false])->orderBy(['id' => SORT_DESC])->limit(10)->all();
?>

<?php 
echo $this->render('_left-column-list-items', ['items' => $latestMemes, 'title' => 'Latest Memes', 'icon' => 'globe', 'divId' => 'latest-memes', 'class' => 'success']);
?>

<?php 
echo $this->render('_left-column-list-items', ['items' => $latestReplicas, 'title' => 'Latest Replicas', 'icon' => 'film', 'divId' => 'latest-replicas', 'class' => 'info']);
?>

<?php 
echo $this->render('_left-column-list-items', ['items' => $channels, 'title' => 'Channels', 'icon' => 'blackboard', 'divId' => 'channels', 'class' => 'warning']);
?>

<?php 
echo $this->render('_left-column-list-items', ['items' => $tags, 'title' => 'Trending Tags', 'icon' => 'tag', 'divId' => 'tags', 'class' => 'danger']);
?>
Esempio n. 12
0
/* @var $form yii\widgets\ActiveForm */
?>

<div class="book-search">

    <?php 
$form = ActiveForm::begin(['action' => ['index'], 'method' => 'get']);
?>
    <?php 
$render = new Render($form, $model);
?>

    <div class="row">
        <div class="col-md-6">
            <?php 
echo $render->selectField('author_id', Author::getList());
?>
        </div>

        <div class="col-md-6">
            <?php 
echo $form->field($model, 'name');
?>
        </div>

        <div class="col-md-6">
            <?php 
echo $render->dateField('date_from');
?>
        </div>
Esempio n. 13
0
 public static function getAuthorList()
 {
     $droptions = Author::find()->asArray()->all();
     return Arrayhelper::map($droptions, 'id', 'lastname');
 }
Esempio n. 14
0
 /**
  * Creates a new Posts model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     if (Yii::$app->user->can('create-post')) {
         $modelPost = new Posts();
         $model = new Postt($modelPost);
         if (Yii::$app->request->isAjax && $model->load($_POST)) {
             Yii::$app->response->format = 'json';
             return ActiveForm::validate($model);
         }
         if ($model->load(Yii::$app->request->post())) {
             /*
              * get the instance of the uploaded file
              */
             //            $imagename = $model->title;
             //            $model->file = UploadedFile::getInstance($model, 'file');
             //            $model->file->saveAs('uploads/'. $imagename.'.'.$model->file->extension);
             //save the path in the db
             //            $model->logo = 'uploads/'. $imagename.'.'.$model->file->extension;
             $model->save();
             //                print_r($model->getErrors());
             //                return $this->redirect(['view', 'id' => $model->id]);
             return $this->redirect(['index']);
         } else {
             //                $model->id = Yii::$app->user->id;
             //                $model->loadDefaultValues();
             return $this->renderAjax('create', ['model' => $model, 'tags' => Tags::find()->all(), 'authors' => Author::find()->all()]);
         }
     } else {
         throw new ForbiddenHttpException();
     }
 }
Esempio n. 15
0
            </li>
        <?php 
    }
    ?>
    </ul>
    <ul class="list-group">

        <h1 class="page-header">Posts: <?php 
    echo Category::findOne($_GET['category'])->name;
    ?>
</h1>
<?php 
    foreach ($postOrders as $post) {
        ?>
            <?php 
        $author = Author::getAuthor($post->author_id);
        ?>
            <li class="list-group-item">
                Title: <a href="<?php 
        echo Yii::$app->urlManager->createUrl(['posts/details', 'id' => $post->id]);
        ?>
"><?php 
        echo $post->title;
        ?>
</a>
            </li>
            <li class="list-group-item">
                Author: <?php 
        echo $author;
        ?>
            </li>
Esempio n. 16
0
 public function actionAuthor()
 {
     $slug = Yii::$app->request->get('slug');
     $models = Author::find()->where(['slug' => $slug])->one();
     $model = Video::find()->where(['author_id' => $models->id]);
     //vd($model_video);
     $countQuery = clone $model;
     $pages = new Pagination(['totalCount' => $countQuery->count(), 'defaultPageSize' => 12]);
     $model_video = $model->offset($pages->offset)->limit($pages->limit)->orderBy('created_at Desc')->all();
     return $this->render('view', ['model' => $model_video, 'pages' => $pages]);
 }
Esempio n. 17
0
?>
    <?php 
echo $form->field($model, 'file')->fileInput();
?>

<!--    --><?php 
//= $form->field($model, 'image')->textInput(['maxlength' => true])
//= $form->field($model, 'tags')->checkboxList(
//    ArrayHelper::map($tags, 'id', 'title')
//);
?>
    <?php 
echo $form->field($model, 'category_id')->label('Category')->dropDownList(Category::find()->select(['name', 'id'])->with('posts')->indexBy('id')->column(), ['prompt' => 'List of categories'])->hint('Choose the author');
?>
    <?php 
echo $form->field($model, 'author_id')->label('Author')->dropDownList(Author::find()->select(['name', 'id'])->with('posts')->indexBy('id')->column(), ['prompt' => 'List of authors'])->hint('Choose the author');
?>

<!--    --><?php 
//= $form->field($model, 'tags')->textInput(['maxlength' => true])
?>
<!--    --><?php 
//
//    echo "<pre>";
//    print_r($model->listTags);
//    echo "</pre>";
//    die();
//
?>

    <?php 
Esempio n. 18
0
                        </label>
                        <div class="col-sm-6">
                            <?php 
echo Select2::widget(['name' => 'vidmageCategories', 'data' => Category::getMappedArray(), 'value' => ArrayHelper::getColumn($model->vidmageCategories, 'category_id'), 'options' => ['placeholder' => 'Select a category ...', 'multiple' => true], 'pluginOptions' => []]);
?>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-3" for="vidmage-vidmageauthors">
                            <?php 
echo $model->getAttributeLabel('vidmageAuthors');
?>
                        </label>
                        <div class="col-sm-6">
                            <?php 
echo Select2::widget(['name' => 'vidmageAuthors', 'data' => Author::getMappedArray(), 'value' => ArrayHelper::getColumn($model->vidmageAuthors, 'author_id'), 'options' => ['placeholder' => 'Select an author ...', 'multiple' => true], 'pluginOptions' => ['tags' => true, 'tokenSeparators' => [',']]]);
?>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-3" for="vidmage-vidmagetags">
                            <?php 
echo $model->getAttributeLabel('vidmageTags');
?>
                        </label>
                        <div class="col-sm-6">
                            <?php 
echo Select2::widget(['name' => 'vidmageTags', 'data' => Tag::getMappedArray(), 'value' => ArrayHelper::getColumn($model->vidmageTags, 'tag_id'), 'options' => ['placeholder' => 'Select a tag ...', 'multiple' => true], 'pluginOptions' => ['tags' => true, 'tokenSeparators' => [',', ' ']]]);
?>
                        </div>
                    </div>
Esempio n. 19
0
            <?php 
$form = ActiveForm::begin(['id' => 'VidmageAuthor', 'layout' => 'horizontal', 'enableClientValidation' => true, 'errorSummaryCssClass' => 'error-summary alert alert-error']);
?>

            <div class="">
                <?php 
$this->beginBlock('main');
?>

                <p>
                    
			<?php 
echo $form->field($model, 'vidmage_id')->dropDownList(Vidmage::getMappedArray());
?>
			<?php 
echo $form->field($model, 'author_id')->dropDownList(Author::getMappedArray());
?>
			<?php 
echo $form->field($model, 'is_main_author')->checkBox();
?>
                </p>
                <?php 
$this->endBlock();
?>
                
                <?php 
echo Tabs::widget(['encodeLabels' => false, 'items' => [['label' => 'VidmageAuthor', 'content' => $this->blocks['main'], 'active' => true]]]);
?>
                <hr/>
                <?php 
echo $form->errorSummary($model);
Esempio n. 20
0
    ?>
        <?php 
    foreach ($moderate as $post) {
        ?>
            <li class="list-group-item">
                Title: <a href="<?php 
        echo Yii::$app->urlManager->createUrl(['posts/details', 'id' => $post->id]);
        ?>
"><?php 
        echo $post->title;
        ?>
</a>
            </li>
            <li class="list-group-item">
                Author: <?php 
        echo Author::getAuthor($post->author_id);
        ?>
            </li>
        <?php 
    }
    ?>
    <?php 
} else {
    ?>
        <h2 class="alert-danger">There are no posts1</h2>
    <?php 
}
?>
</ul>
<?php 
//var_dump(Author::find()->all());
Esempio n. 21
0
 public function actionAccount($id)
 {
     $account = Author::findOne(['id' => $id]);
     if (!$account) {
         return $this->run('error');
     }
     return $this->render('account', ['account' => $account]);
 }
Esempio n. 22
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAuthor()
 {
     return $this->hasOne(Author::className(), ['id' => 'author_id']);
 }
Esempio n. 23
0
<?php

use yii\helpers\Url;
use common\models\VideoCategoria;
use common\models\Author;
$model_author = Author::find()->all();
$url = Yii::$app->controller->module->id . '/' . Yii::$app->controller->action->id;
$module = Yii::$app->controller->module->id;
$file_avatar = Yii::getAlias('@frontend') . '/web/upload/user/' . Yii::$app->user->id . '/avatar/avatar.jpg';
//vd($url);
?>

<div class="container">
    <div class="row">
        <div class="span12">
            <div class="header-block clearfix">
                <div class="clearfix header-block-pad">

                    <a href="<?php 
echo Url::to('/site/index');
?>
"><h1 class="logo"><span class="red">Kot</span>monstr</h1></a><a href="<?php 
echo Url::to('/shop/index');
?>
"><span>Магазин</span></a>
                    <form id="search-form" action="<?php 
echo Url::to('/search/show-item');
?>
" method="GET" accept-charset="utf-8" class="navbar-form" >
                        <input type="text" name="item" onBlur="if (this.value == '')
                                    this.value = ''" onFocus="if (this.value == '')
Esempio n. 24
0
/* @var $this yii\web\View */
/* @var $model common\models\BookSearch */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="book-search">

    <?php 
$form = ActiveForm::begin(['action' => ['index'], 'method' => 'get']);
?>


    <div class="row">
        <div class="col-lg-6">
            <?php 
echo $form->field($model, 'author_id')->label(false)->dropDownList(ArrayHelper::map(Author::find()->orderBy(['lastname' => SORT_ASC])->asArray()->all(), 'id', function ($model, $defaultValue) {
    return $model['lastname'] . ' ' . $model['firstname'];
}), ['prompt' => '---автор---']);
?>
        </div>
        <div class="col-lg-6">
            <?php 
echo $form->field($model, 'name')->label(false)->textInput(['maxwidth' => true, 'placeholder' => 'название книги']);
?>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-3">
            Дата выход книги:
            <?php 
Esempio n. 25
0
 public function actionAuthors()
 {
     return $this->render('authors', ['dataProvider' => new ActiveDataProvider(['query' => Author::find(), 'pagination' => ['pageSize' => 25]])]);
 }
Esempio n. 26
0
<?php 
use common\models\Author;
$this->title = 'Tags';
$this->params['breadcrumbs'][] = ['label' => 'Posts', 'url' => 'index'];
$this->params['breadcrumbs'][] = ['label' => 'Tags', 'url' => 'http://admin.yiiadv/tag/index'];
$this->params['breadcrumbs'][] = Yii::$app->request->get('tag');
if ($model) {
    ?>
    <ul class="list-group">
    <?php 
    foreach ($model as $item) {
        ?>
    <?php 
        $author = Author::getAuthor($item->author_id);
        ?>
    <li class="list-group-item">
        Title: <a href="<?php 
        echo Yii::$app->urlManager->createUrl(['posts/details', 'id' => $item->id]);
        ?>
"><?php 
        echo $item->title;
        ?>
</a>
    </li>
    <li class="list-group-item">
        Author: <?php 
        echo $author;
        ?>
    </li>
<?php 
Esempio n. 27
0
        <h1><?php 
echo Html::encode($this->title);
?>
</h1>


        <?php 
$form = ActiveForm::begin(['method' => 'get', 'action' => Url::to(['/books'])]);
?>

        <div class="row" style="margin-bottom: 20px">
            <div class="col-md-8">
                <div class="col-md-6">
                    <?php 
$authors = array_merge(['' => Yii::t('app', 'author')], ArrayHelper::map(Author::find()->all(), 'id', 'fullname'));
echo $form->field($searchModel, 'author_id')->dropDownList($authors)->label(false);
?>

                    <?php 
echo $form->field($searchModel, 'dateFrom', ['template' => "{label}\n<div class='col-md-6'>{input}</div>\n{hint}\n{error}", 'labelOptions' => ['class' => 'col-md-6']])->widget(DatePicker::classname(), ['language' => 'ru', 'dateFormat' => Yii::$app->params['bookSearchDateFormat'], 'options' => ['class' => 'form-control']]);
?>
                </div>
                <div class="col-md-6">

                    <?php 
echo $form->field($searchModel, 'name')->textInput(['placeholder' => Yii::t('app', 'book_name')])->label(false);
?>

                    <?php 
echo $form->field($searchModel, 'dateTo', ['template' => "{label}\n<div class='col-md-6'>{input}</div>\n{hint}\n{error}", 'labelOptions' => ['class' => 'col-md-2']])->widget(DatePicker::classname(), ['language' => 'ru', 'dateFormat' => Yii::$app->params['bookSearchDateFormat'], 'options' => ['class' => 'form-control']]);
Esempio n. 28
0
use yii\bootstrap\Modal;
use yii\grid\GridView;
use yii\helpers\Html;
use yii\helpers\Url;
use dosamigos\datepicker\DatePicker;
use yii\helpers\ArrayHelper;
$this->title = 'Books Library';
?>

<?php 
$form = ActiveForm::begin(['action' => '', 'method' => 'GET']);
?>
    <div class="col-lg-12">
        <div class="col-lg-3">
            <?php 
echo $form->field($searchModel, 'author_id')->dropDownList(ArrayHelper::merge(['' => 'Выберите автора'], Author::getAuthorArray()));
?>
        </div>
        <div class="col-lg-3">
            <?php 
echo $form->field($searchModel, 'name')->textInput();
?>
        </div>
    </div>
    <div class="col-lg-12">
        <div class="col-lg-3">
            <?php 
echo $form->field($searchModel, 'dateFrom')->widget(DatePicker::className(), ['template' => '{addon}{input}', 'clientOptions' => ['autoclose' => true, 'format' => 'dd/mm/yyyy']]);
?>
        </div>
        <div class="col-lg-3">
Esempio n. 29
0
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>

    <?php 
echo Html::img($model->preview);
?>
    <?php 
echo $form->field($model, 'previewFile')->fileInput();
?>

    <?php 
echo $form->field($model, 'date')->widget(DatePicker::classname(), ['language' => 'ru', 'dateFormat' => Yii::$app->params['bookSearchDateFormat'], 'options' => ['class' => 'form-control']]);
?>

    <?php 
$authors = ArrayHelper::map(Author::find()->all(), 'id', 'fullname');
echo $form->field($model, 'author_id')->dropDownList($authors);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>