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(); } }
<div class="form" name="post-on"> <?php echo $this->renderPartial('_form', array('model' => $model, 'setting' => $setting, 'tag' => $tag)); ?> </div> <div class="boxed mt-15"> <h3><?php echo Yii::t('phrase', 'Album Photo'); ?> </h3> <div class="clearfix horizontal-data" name="four"> <ul id="media-render"> <li id="upload" <?php echo count(AlbumPhoto::getPhoto($model->album_id)) == $photo_limit ? 'class="hide"' : ''; ?> > <a id="upload-gallery" href="<?php echo Yii::app()->controller->createUrl('o/photo/ajaxadd', array('id' => $model->album_id, 'type' => 'admin')); ?> " title="<?php echo Yii::t('phrase', 'Upload Photo'); ?> "><?php echo Yii::t('phrase', 'Upload Photo'); ?> </a> <img src="<?php echo Utility::getTimThumb(Yii::app()->request->baseUrl . '/public/album/album_plus.png', 320, 250, 1); ?>
/** * 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)); }
/** * Before delete attributes */ protected function beforeDelete() { if (parent::beforeDelete()) { $album_path = "public/album/" . $this->album_id; //delete media photos $album_photo = AlbumPhoto::getPhoto($this->album_id); foreach ($album_photo as $val) { if ($val->media != '' && file_exists($album_path . '/' . $val->media)) { rename($album_path . '/' . $val->media, 'public/album/verwijderen/' . $val->album_id . '_' . $val->media); } } } return true; }
/** * 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