/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionAjaxManage($id) { $model = AlbumPhoto::getPhoto($id); $setting = AlbumSetting::model()->findByPk(1, array('select' => 'photo_limit')); $data = ''; if ($model != null) { foreach ($model as $key => $val) { $image = Yii::app()->request->baseUrl . '/public/album/' . $val->album_id . '/' . $val->media; $url = Yii::app()->controller->createUrl('ajaxdelete', array('id' => $val->media_id)); $urlCover = Yii::app()->controller->createUrl('ajaxcover', array('id' => $val->media_id)); $data .= '<li>'; if ($val->cover == 0) { $data .= '<a id="set-cover" href="' . $urlCover . '" title="' . Phrase::trans(26108, 1) . '">' . Phrase::trans(26108, 1) . '</a>'; } $data .= '<a id="set-delete" href="' . $url . '" title="' . Phrase::trans(24012, 1) . '">' . Phrase::trans(24012, 1) . '</a>'; $data .= '<img src="' . Utility::getTimThumb($image, 320, 250, 1) . '" alt="' . $val->album->title . '" />'; $data .= '</li>'; } } if (isset($_GET['replace'])) { // begin.Upload Button $class = count($model) == $setting->photo_limit ? 'class="hide"' : ''; $url = Yii::app()->controller->createUrl('ajaxadd', array('id' => $id)); $data .= '<li id="upload" ' . $class . '>'; $data .= '<a id="upload-gallery" href="' . $url . '" title="' . Phrase::trans(26054, 1) . '">' . Phrase::trans(26054, 1) . '</a>'; $data .= '<img src="' . Utility::getTimThumb(Yii::app()->request->baseUrl . '/public/album/album_default.png', 320, 250, 1) . '" alt="" />'; $data .= '</li>'; // end.Upload Button } $data .= ''; $result['data'] = $data; echo CJSON::encode($result); }
<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); ?>
/** * 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; }