public static function getData($type, $id)
 {
     if (!empty($type) && !empty($id)) {
         switch ($type) {
             case SectionConfig::TYPE_CONTENT:
                 $model = Content::findOne(['id' => $id]);
                 break;
             case SectionConfig::TYPE_GALLERY:
                 $model = Gallery::findOne(['id' => $id]);
                 break;
             case SectionConfig::TYPE_FEED:
                 $model = Feed::findOne(['id' => $id]);
                 break;
             case SectionConfig::TYPE_FEED_CONTENT:
                 $model = FeedContent::getFeedItems($id, 3);
                 break;
             case SectionConfig::TYPE_WEATHER:
                 $model = WeatherForecast::findOne(['id' => $id]);
                 break;
             case SectionConfig::TYPE_QUOTE:
                 $model = Quote::findOne(['id' => $id]);
                 break;
             case SectionConfig::TYPE_WIDGET:
                 $model = Widget::findOne(['id' => $id]);
                 break;
         }
         if (empty($model)) {
             return array();
         } else {
             return $model;
         }
     }
 }
Beispiel #2
0
 public static function getAllImages()
 {
     $gallery = Yii::$app->db->cache(function () {
         return Gallery::find()->all();
     }, 1);
     return $gallery;
 }
 /**
  * Finds the Gallery model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Gallery the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Gallery::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #4
0
 public function init()
 {
     parent::init();
     if ($this->id) {
         $this->_gallery = \common\models\Gallery::findOne($this->id);
     } else {
         throw new InvalidConfigException(\Yii::t('front', 'No required parameter given') . ' - id');
     }
     if (!$this->type) {
         throw new InvalidConfigException(\Yii::t('front', 'No required parameter given') . ' - type');
     }
 }
Beispiel #5
0
 /**
 * Creates data provider instance with search query applied
 *
 * @param array $params
 *
 * @return ActiveDataProvider
 */
 public function search($params)
 {
     $query = Gallery::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, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'slug', $this->slug]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Gallery::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, 'category_id' => $this->category_id, 'status' => $this->status, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'gallery', $this->gallery])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'meta_title', $this->meta_title])->andFilterWhere(['like', 'meta_keywords', $this->meta_keywords])->andFilterWhere(['like', 'meta_description', $this->meta_description]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Gallery::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
Beispiel #8
0
 /**
  * Creates data provider instance with search query applied
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     /** @var ActiveQuery $query */
     $query = Gallery::find();
     if (!isset($params['sort'])) {
         $query->orderBy(['updated_at' => SORT_DESC]);
     }
     $session = Yii::$app->session;
     if (!$session['language_id']) {
         $session['language_id'] = LanguageRecord::getMainLanguageId();
     }
     $query->andWhere(['language_id' => $session['language_id']]);
     $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(['public' => $this->public, 'active' => $this->active]);
     $query->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }
Beispiel #9
0
 public function init()
 {
     $this->gallery = GalleryModel::findOne(['slug' => $this->slug]);
     parent::init();
 }
Beispiel #10
0
 public function run()
 {
     $model = Gallery::find()->where(['status' => 'on'])->orderBy('id DESC')->limit($this->limit)->all();
     return $this->render($this->template, ['model' => $model]);
 }
Beispiel #11
0
 public function getAllGallery()
 {
     return Gallery::find()->where(['status' => 'on'])->all();
 }
Beispiel #12
0
use common\models\Gallery;
use common\models\LanguageRecord;
use yii\bootstrap\ActiveField;
use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use yii\widgets\ListView;
/* @var $this yii\web\View */
/* @var $model backend\models\GalleryAddPhotosForm */
/* @var $gallery common\models\Gallery */
/* @var $dataProvider yii\data\ActiveDataProvider */
/* @var $form yii\bootstrap\ActiveForm */
$session = Yii::$app->session;
if (!$session['language_id']) {
    $session['language_id'] = LanguageRecord::getMainLanguageId();
}
$gallery = Gallery::findOne($model->item_id);
$this->title = Yii::t('back', 'add photos into gallery');
$this->params['breadcrumbs'][] = ['label' => Yii::t('back', 'Galleries'), 'url' => ['gallery/index']];
$this->params['breadcrumbs'][] = ['label' => $gallery->title . ' - ' . Yii::t('back', 'photos in gallery'), 'url' => ['gallery/photos', 'id' => $model->item_id]];
$this->params['breadcrumbs'][] = $this->title;
FormAsset::register($this);
?>

<div>

	<h1><?php 
echo Html::encode($this->title);
?>
</h1>

	<?php 
Beispiel #13
0
 public function actionGallery($id)
 {
     $gallery = Gallery::findOne($id);
     $this->layout = 'main-gallery';
     return $this->render('gallery', compact('gallery'));
 }
 /**
  * Sets array of photos
  */
 private function setPhotos()
 {
     /** @var Gallery $gallery */
     $gallery = Gallery::findOne($this->item_id);
     $this->photos = $gallery->images;
 }
 /**
  * Returns gallery display types for CKEditor gallery plugin
  * @return array
  */
 public function actionDisplayItems()
 {
     $items = Gallery::getDisplayTypes();
     $response = Yii::$app->response;
     $response->format = Response::FORMAT_JSON;
     $response->data = $items;
     return $response;
 }
Beispiel #16
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGallery()
 {
     return $this->hasOne(Gallery::className(), ['id' => 'gallery_id']);
 }
Beispiel #17
0
 /**
  * ให้ค่า instance ของ model ที่ระบุด้วย entity type และ $refId
  * @param int $type
  * @param int $refId
  * @return ActiveRecord
  */
 public static function getInstance($type, $refId, $orderNo = NULL)
 {
     $instance = null;
     switch ($type) {
         case self::TYPE_ACTIVITY:
             $instance = Activity::findOne($refId);
             break;
         case self::TYPE_BLOG:
             $instance = Blogs::findOne($refId);
             break;
         case self::TYPE_CARTOON:
             $arr = preg_split('/-/', $refId);
             $instance = CartoonChapter::findOne(array('cartoonId' => $arr[0], 'chapter' => $arr[1]));
             break;
         case self::TYPE_CONTENT:
             $instance = Content::findOne($refId);
             break;
         case self::TYPE_DOCUMENT:
             $instance = Document::findOne(array('type' => $type, 'refId' => $refId, 'itemNo' => $orderNo));
             break;
         case self::TYPE_FAQ:
             $instance = Faq::findOne($refId);
             break;
         case self::TYPE_FEEDCONTENT:
             $instance = FeedContent::findOne($refId);
             break;
         case self::TYPE_FEED:
             $instance = Feed::findOne($refId);
             break;
         case self::TYPE_GALLERY:
             $instance = Gallery::findOne($refId);
             break;
         case self::TYPE_INFOGRAPHIC:
             $instance = InfoGraphic::findOne($refId);
             break;
         case self::TYPE_LIVEREPORT:
             $instance = LiveReport::findOne($refId);
             break;
         case self::TYPE_LOTTERY:
             $instance = Lottery::findOne($refId);
             break;
         case self::TYPE_BUNNY:
         case self::TYPE_MEDIA_COLLECTION:
             $instance = MediaCollection::findOne($refId);
             break;
         case self::TYPE_NEWSPAPER:
             // temporary class for media upload
             $instance = new stdClass();
             $instance->createTime = date('Y-m-d H:i:s');
             break;
         case self::TYPE_NOVEL:
             $instance = Novel::findOne($refId);
             break;
         case self::TYPE_PERSON:
             $instance = Person::findOne($refId);
             break;
         case self::TYPE_SPORT_PLAYER:
             $instance = Player::findOne($refId);
             break;
         case self::TYPE_SPORT_TEAM:
             $instance = Team::findOne($refId);
             break;
         case self::TYPE_QUOTE:
             $instance = Quote::findOne($refId);
             break;
         case self::TYPE_WIDGET:
             $instance = Widget::findOne($refId);
             break;
         case self::TYPE_TV_ANCHOR:
             $instance = TvAnchor::findOne($refId);
             break;
         case self::TYPE_TV_PROGRAM:
             $instance = TvProgram::findOne($refId);
             break;
         case self::TYPE_TV_HIGHLIGHT:
             $instance = TvHighlight::findOne($refId);
             break;
         case self::TYPE_TV_SCHEDULE:
             $instance = TvSchedule::findOne($refId);
             break;
         case self::TYPE_USER:
             $instance = User::findOne($refId);
             break;
         case self::TYPE_VIDEO:
             $instance = Video::findOne($refId);
             break;
         case self::TYPE_VIDEO_PLAYLIST:
             $instance = VideoPlaylist::findOne($refId);
             break;
         case self::TYPE_WATCHTOPIC:
             $instance = WatchTopic::findOne($refId);
             break;
         case self::TYPE_WEATHER:
             $instance = WeatherForecast::findOne($refId);
             break;
     }
     return $instance;
 }
Beispiel #18
0
 public function attributeLabels()
 {
     $parentAttributeLabels = parent::attributeLabels();
     $parentAttributeLabels['uploadedImages'] = Yii::t('app', 'Upload Images');
     return $parentAttributeLabels;
 }
Beispiel #19
0
 /**
  * Deletes Gallery
  * @throws \Exception
  */
 public function deleteGallery()
 {
     /** @var $gallery Gallery */
     if ($gallery = Gallery::findOne($this->item_id)) {
         $gallery->delete();
     }
 }