protected function renderContent() { //import model Yii::import('application.modules.album.models.AlbumPhoto'); Yii::import('application.modules.album.models.Albums'); $model = AlbumPhoto::model()->findAll(array('select' => 'media_id, album_id, media', 'order' => 'creation_date DESC', 'limit' => 9)); $this->render('front_album_photo', array('model' => $model)); }
public function postPhoto() { if (isset($_FILES['photo'])) { $this->model = \AlbumPhoto::model()->createUserTempPhoto($_FILES['photo']); if (!$this->model instanceof \AlbumPhoto) { throw new ApiException('CreatingPhotoError', 500); } MigrateManager::movePhoto($this->model); $this->model->refresh(); $this->controller->data = $this->model; $this->controller->setAction($this); } else { throw new ParamsMissingApiException(); } }
/** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionView($id) { $setting = AlbumSetting::model()->findByPk(1, array('select' => 'meta_keyword')); $model = $this->loadModel($id); Albums::model()->updateByPk($id, array('view' => $model->view + 1)); $photo = AlbumPhoto::model()->findAll(array('condition' => 'album_id = :id', 'params' => array(':id' => $model->album_id), 'order' => 'media_id DESC')); $this->pageTitleShow = true; $this->pageTitle = $model->title; $this->pageDescription = Utility::shortText(Utility::hardDecode($model->body), 300); $this->pageMeta = $setting->meta_keyword; $this->render('front_view', array('model' => $model, 'photo' => $photo)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = AlbumPhoto::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, Yii::t('phrase', 'The requested page does not exist.')); } return $model; }
/** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionView($id) { $setting = AlbumSetting::model()->findByPk(1, array('select' => 'meta_keyword')); $model = $this->loadModel($id); Albums::model()->updateByPk($id, array('view' => $model->view + 1)); $photo = AlbumPhoto::model()->findAll(array('condition' => 'album_id = :id', 'params' => array(':id' => $model->album_id), 'order' => 'media_id DESC')); //Random Article $criteria = new CDbCriteria(); $criteria->condition = 'publish = :publish AND album_id <> :id'; $criteria->params = array(':publish' => 1, ':id' => $id); $criteria->order = 'RAND()'; $criteria->limit = 4; $random = Albums::model()->findAll($criteria); $this->pageTitleShow = true; $this->pageTitle = $model->title; $this->pageDescription = Utility::shortText(Utility::hardDecode($model->body), 300); $this->pageMeta = $setting->meta_keyword; if ($model->media_id != 0 && $model->cover->media != '') { $media = Yii::app()->request->baseUrl . '/public/album/' . $id . '/' . $model->cover->media; $this->pageImage = $media; } $this->render('front_view', array('model' => $model, 'photo' => $photo, 'random' => $random)); }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer the ID of the model to be loaded */ public function loadModel($id) { $model = AlbumPhoto::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, Phrase::trans(193, 0)); } return $model; }
$this->breadcrumbs = array('Albums' => array('manage'), $model->title); $cs = Yii::app()->getClientScript(); $cs->registerScriptFile(Yii::app()->request->baseUrl . '/externals/album/plugin/jquery.jcarousellite.min.js', CClientScript::POS_END); $js = <<<EOP \t\t\$("#module .slider-box").jCarouselLite({ \t\t\tbtnNext: ".slider .next", \t\t\tbtnPrev: ".slider .prev", \t\t\tspeed: 800, \t\t\tvisible: 4 \t\t}); EOP; count($photo > 1) ? $cs->registerScript('jcarousellite', $js, CClientScript::POS_END) : ''; if ($model->media_id != 0 && !isset($_GET['photo'])) { $images = Yii::app()->request->baseUrl . '/public/album/' . $model->album_id . '/' . $model->cover->media; } else { $mediaPhoto = AlbumPhoto::model()->findByPk($_GET['photo']); $images = Yii::app()->request->baseUrl . '/public/album/' . $mediaPhoto->album_id . '/' . $mediaPhoto->media; } ?> <div class="meta"> <i class="fa fa-calendar-check-o"></i><?php echo Utility::dateFormat($model->creation_date); ?> <i class="fa fa-bookmark-o"></i><?php echo $model->user->displayname; ?> <i class="fa fa-picture-o"></i><?php echo $model->photos; ?> <i class="fa fa-eye"></i><?php