public function actionIndex($slug)
 {
     $meme = Meme::findOne(['slug' => $slug]);
     $query = Vidmage::find()->joinWith('memeVidmages.meme')->where(['meme.id' => $meme->id])->andWhere(['meme_vidmage.is_the_origin' => false]);
     $vidmages = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     return $this->render('index', compact('meme', 'vidmages'));
 }
Esempio n. 2
0
 /**
 * Creates data provider instance with search query applied
 *
 * @param array $params
 *
 * @return ActiveDataProvider
 */
 public function search($params)
 {
     $query = Meme::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]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Esempio n. 3
0
    <div class="panel-body">

        <div class="meme-vidmage-form">

            <?php 
$form = ActiveForm::begin(['id' => 'MemeVidmage', 'layout' => 'horizontal', 'enableClientValidation' => true, 'errorSummaryCssClass' => 'error-summary alert alert-error']);
?>

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

                <p>
            <?php 
echo $form->field($model, 'meme_id')->dropDownList(Meme::getMappedArray());
?>
            <?php 
echo $form->field($model, 'vidmage_id')->dropDownList(Vidmage::getMappedArray());
?>
			<?php 
echo $form->field($model, 'is_the_origin')->checkBox();
?>
			<?php 
echo $form->field($model, 'likes')->textInput();
?>
                </p>
                <?php 
$this->endBlock();
?>
<?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. 5
0
 public function saveManyMemes($vidmageMemes)
 {
     foreach ($vidmageMemes as $vidmageMemeId) {
         if (!is_numeric($vidmageMemeId)) {
             $meme = new Meme();
             $meme->name = $vidmageMemeId;
             $meme->save();
             $vidmageMemeId = $meme->id;
         }
         $vidmageMeme = new MemeVidmage();
         $vidmageMeme->vidmage_id = $this->id;
         $vidmageMeme->meme_id = $vidmageMemeId;
         $vidmageMeme->save();
     }
 }
Esempio n. 6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMeme()
 {
     return $this->hasOne(\common\models\Meme::className(), ['id' => 'meme_id']);
 }
Esempio n. 7
0
    echo $form->field($model, 'views')->textInput();
    ?>
                    <?php 
}
?>
                    <?php 
echo $form->field($model, 'is_active')->checkBox();
?>

                    <div class="form-group">
                        <label class="control-label col-sm-3" for="vidmage-vidmagememes">
                            Memes
                        </label>
                        <div class="col-sm-6">
                            <?php 
echo Select2::widget(['name' => 'vidmageMemes', 'data' => Meme::getMappedArray(), 'value' => ArrayHelper::getColumn($model->memeVidmages, 'meme_id'), 'options' => ['placeholder' => 'Select a Meme ...', 'multiple' => true], 'pluginOptions' => ['tags' => true]]);
?>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label col-sm-3" for="vidmage-vidmagecategories">
                            <?php 
echo $model->getAttributeLabel('vidmageCategories');
?>
                        </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>
 /**
  * Finds the Meme model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Meme the loaded model
  * @throws HttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Meme::findOne($id)) !== null) {
         return $model;
     } else {
         throw new HttpException(404, 'The requested page does not exist.');
     }
 }
 public function actionIndex()
 {
     $mostPopularMeme = Meme::mostPopular();
     $newReplicas = Vidmage::find()->joinWith('memeVidmages')->where(['meme_vidmage.is_the_origin' => false])->orderBy(['id' => SORT_DESC])->limit(4)->all();
     $editorMemePick = Meme::findOne(7);
     $newMemes = Meme::find()->joinWith('memeVidmages')->where(['meme_vidmage.is_the_origin' => true])->orderBy(['id' => SORT_DESC])->limit(4)->all();
     return $this->render('index', compact('mostPopularMeme', 'newReplicas', 'editorMemePick', 'newMemes'));
 }