Exemple #1
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->className() == Album::className()) {
         $this->visible = 1;
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Album::find()->joinWith('translations');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->request->cookies->getValue('_grid_page_size', 20)], 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'visible' => $this->visible, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Exemple #3
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     if (ctype_digit($this->album)) {
         $condition = $this->album;
     } elseif (is_string($this->album)) {
         $condition = ['slug' => $this->album];
     } else {
         throw new \yii\base\InvalidParamException('Invalid album parameter passed to a method.');
     }
     $album = Album::findOne($condition);
     if (!$album) {
         throw new \yii\web\NotFoundHttpException('Album was not found.');
     }
     $media = $album->getMedia()->all();
     foreach ($media as $image) {
         $this->items[] = ['content' => $this->render($this->contentView, ['image' => $image]), 'caption' => $this->render($this->captionView, ['image' => $image]), 'options' => $this->itemsOptions];
     }
 }
Exemple #4
0
    ?>

    <?php 
    if (User::hasPermission('editMedia')) {
        ?>
        <?php 
        echo $form->field($model, 'album_id')->dropDownList(ArrayHelper::merge([NULL => Yii::t('yee', 'Not Selected')], Album::getAlbums(true, true)));
        ?>
        <?php 
        echo $form->field($model, 'title')->textInput(['class' => 'form-control input-sm']);
        ?>
    <?php 
    } else {
        ?>
        <?php 
        echo $form->field($model, 'album_id')->dropDownList(ArrayHelper::merge([NULL => Yii::t('yee', 'Not Selected')], Album::getAlbums(true, true)), ['readonly' => 'readonly']);
        ?>
        <?php 
        echo $form->field($model, 'title')->textInput(['class' => 'form-control input-sm', 'readonly' => 'readonly']);
        ?>
    <?php 
    }
    ?>

<?php 
}
?>

<?php 
if ($model->isImage()) {
    ?>
Exemple #5
0
 public function getAlbum()
 {
     return $this->hasOne(Album::className(), ['id' => 'album_id']);
 }
Exemple #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getAlbums()
 {
     return $this->hasMany(Album::className(), ['category_id' => 'id']);
 }
Exemple #7
0
?>

<div class="row">
    <div class="col-sm-12">
        <div class="panel panel-default">
            <div style="padding: 5px; height:50px;" class="panel-body">

                <?php 
$form = ActiveForm::begin(['id' => 'gallery', 'action' => Url::to($mode == 'modal' ? ['/media/manage/index'] : ['/media/default/index']), 'method' => 'get', 'class' => 'gridview-filter-form', 'fieldConfig' => ['template' => "{input}\n{hint}\n{error}"]]);
?>
                <table id="gallery-grid-filters" class="table table-striped filters">
                    <thead>
                    <tr id="user-visit-log-grid-filters" class="filters">
                        <td style="width: auto;">
                            <?php 
echo $form->field($searchModel, 'album_id')->dropDownList(ArrayHelper::merge(['' => Yii::t('yee/media', 'All Media Items')], Album::getAlbums(true, true)), ['prompt' => '']);
?>
                        </td>
                        <td style="width: auto;">
                            <?php 
echo $form->field($searchModel, 'title')->textInput(['placeholder' => $searchModel->attributeLabels()['title']]);
?>
                        </td>
                        <td style="width: auto;">
                            <?php 
echo $form->field($searchModel, 'created_at')->widget(DatePicker::className(), ['dateFormat' => 'yyyy-MM-dd', 'options' => ['placeholder' => $searchModel->attributeLabels()['created_at'], 'class' => 'form-control']]);
?>
                        </td>
                        <?php 
if (User::hasPermission('uploadMedia')) {
    ?>