/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Artist::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, 'user_id' => $this->user_id]);
     //        $query->andFilterWhere(['like', 'original_name', $this->original_name])
     //            ->andFilterWhere(['like', 'latin_name', $this->latin_name]);
     $query->andWhere('original_name LIKE :original_name OR latin_name LIKE :latin_name')->addParams([':original_name' => "%{$this->original_name}%", ':latin_name' => "%{$this->latin_name}%"]);
     if (Utils::get('tags', $params)) {
         $query->leftJoin('artist_tag', 'artist_tag.artist_id = artist.id');
         if (Utils::get('tags_mode', $params)) {
             # all tags
             $tags = explode(',', $params['tags']);
             foreach ($tags as $k => $v) {
                 $tags[$k] = (int) $v;
             }
             $tags_count = count($tags);
             $tags = implode(',', $tags);
             $query->andWhere("(\n                    SELECT count(*)\n                    FROM artist_tag\n                    WHERE artist_tag.artist_id = artist.id\n                    AND artist_tag.tag_id IN ({$tags})\n                ) = {$tags_count}");
         } else {
             # any tag
             $query->andWhere(['in', 'artist_tag.tag_id', explode(',', $params['tags'])]);
         }
     }
     return $dataProvider;
 }
Beispiel #2
0
 public function testGet()
 {
     $array = ['artist' => 'Red Velvet', 'name' => 'Ice Cream Cake', 'date' => '2015-03-17'];
     $this->assertEquals('Ice Cream Cake', Utils::get('name', $array));
     $this->assertNull(Utils::get('genre', $array));
 }
Beispiel #3
0
 /**
  * @return string
  */
 public function getComname()
 {
     return Utils::mergeNames($this->original_name, $this->latin_name);
 }
Beispiel #4
0
                    <header>
                        <h1><?php 
    echo $item->title;
    ?>
</h1>
                    </header>

                    <p><?php 
    echo $item->short;
    ?>
</p>

                    <footer>
                        <div class="date">
                            <span><?php 
    echo Yii::$app->language === 'ru' ? Utils::getDate($item->date) : date('j F Y', $item->time);
    ?>
</span>
                        </div>

                        <div class="btn-wrapper">
                            <a href="<?php 
    echo Url::toRoute(['articles/view', 'slug' => $item->slug]);
    ?>
" class="btn btn-simple">
                                <?php 
    echo Yii::t('all', 'read article');
    ?>
                            </a>
                        </div>
                    </footer>
Beispiel #5
0
" id="<?php 
    echo $sid . $languageCode;
    ?>
">

			<?php 
    if (get_class($this->context->model) == 'app\\easyii\\modules\\carousel\\models\\Carousel' && ($attribute == 'video' || $attribute == 'video_ru')) {
        ?>

				<?php 
        if (isset($this->context->model->{$attribute}) && !empty($this->context->model->{$attribute})) {
            ?>

					<div style="margin: 10px 0">
						<?php 
            if (\app\components\Utils::isImageFile(\Yii::getAlias('@webroot') . $this->context->model->{$attribute})) {
                ?>

							<img width=400px" src="<?php 
                echo $this->context->model->{$attribute};
                ?>
" alt="">

						<?php 
            } else {
                ?>

							<video width=400px" preload="none" autoplay>
								<source src="<?php 
                echo $this->context->model->{$attribute};
                ?>
Beispiel #6
0
</h1>
            </header>

            <p class="caption"><?php 
echo $article->short;
?>
</p>

            <?php 
echo $article->text;
?>

            <footer>
                <div class="date">
                    <span><?php 
echo Yii::$app->language == 'ru' ? Utils::getDate($article->date) : date('j F Y', $article->time);
?>
</span>
                </div>

                <div class="btn-wrapper">
                    <a href="<?php 
echo Url::toRoute('/articles');
?>
" class="btn btn-simple">
                        <?php 
echo Yii::t('all', 'back to articles');
?>
                    </a>
                </div>
            </footer>