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;
         }
     }
 }
 /**
  * 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 #3
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 #4
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 #5
0
 public function init()
 {
     $this->gallery = GalleryModel::findOne(['slug' => $this->slug]);
     parent::init();
 }
Beispiel #6
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 #7
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;
 }
Beispiel #9
0
 /**
  * Deletes Gallery
  * @throws \Exception
  */
 public function deleteGallery()
 {
     /** @var $gallery Gallery */
     if ($gallery = Gallery::findOne($this->item_id)) {
         $gallery->delete();
     }
 }