/**
  * 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 = ArticleMedia::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Phrase::trans(193, 0));
     }
     return $model;
 }
echo $this->renderPartial('_form', array('model' => $model, 'setting' => $setting, 'tag' => $tag));
?>
</div>

<?php 
if ($model->article_type == 1 && $setting->media_limit != 1) {
    ?>
<div class="boxed mt-15">
	<h3><?php 
    echo Phrase::trans(26053, 1);
    ?>
</h3>
	<div class="clearfix horizontal-data" name="four">
		<ul id="media-render">
			<li id="upload" <?php 
    echo count(ArticleMedia::getPhoto($model->article_id)) == $setting->media_limit ? 'class="hide"' : '';
    ?>
>
				<a id="upload-gallery" href="<?php 
    echo Yii::app()->controller->createUrl('o/media/ajaxadd', array('id' => $model->article_id, 'type' => 'admin'));
    ?>
" title="<?php 
    echo Phrase::trans(26054, 1);
    ?>
"><?php 
    echo Phrase::trans(26054, 1);
    ?>
</a>
				<img src="<?php 
    echo Utility::getTimThumb(Yii::app()->request->baseUrl . '/public/article/article_default.png', 320, 250, 1);
    ?>
 /**
  * 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 = ArticleMedia::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('phrase', 'The requested page does not exist.'));
     }
     return $model;
 }
 /**
  * Before delete attributes
  */
 protected function beforeDelete()
 {
     if (parent::beforeDelete()) {
         $article_path = "public/article/" . $this->article_id;
         //delete media photos
         $article_photo = ArticleMedia::getPhoto($this->article_id);
         foreach ($article_photo as $val) {
             if (in_array($this->article_type, array(1, 3)) && $val->media != '' && file_exists($article_path . '/' . $val->media)) {
                 rename($article_path . '/' . $val->media, 'public/article/verwijderen/' . $val->article_id . '_' . $val->media);
             }
         }
         //delete media file
         if ($this->media_file != '' && file_exists($article_path . '/' . $val->media_file)) {
             rename($article_path . '/' . $val->media_file, 'public/article/verwijderen/' . $val->article_id . '_' . $val->media_file);
         }
     }
     return true;
 }
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id)
 {
     $setting = ArticleSetting::model()->findByPk(1, array('select' => 'meta_keyword'));
     $model = $this->loadModel($id);
     Articles::model()->updateByPk($id, array('view' => $model->view + 1));
     $photo = ArticleMedia::model()->findAll(array('condition' => 'article_id = :id', 'params' => array(':id' => $model->article_id), 'order' => 'media_id DESC'));
     //Random Article
     $criteria = new CDbCriteria();
     $criteria->condition = 'publish = :publish AND published_date <= curdate() AND article_id <> :id';
     $criteria->params = array(':publish' => 1, ':id' => $id);
     $criteria->compare('cat_id', $model->cat_id);
     $criteria->order = 'RAND()';
     $criteria->limit = 4;
     $random = Articles::model()->findAll($criteria);
     $this->pageTitleShow = true;
     $this->pageTitle = $model->title;
     $this->pageDescription = Utility::shortText(Utility::hardDecode($model->body), 300);
     $this->pageMeta = ArticleTag::getKeyword($setting->meta_keyword, $id);
     if ($model->media_id != 0 && $model->cover->media != '') {
         if (in_array($model->article_type, array('1', '3'))) {
             $media = Yii::app()->request->baseUrl . '/public/article/' . $id . '/' . $model->cover->media;
         } else {
             if ($model->article_type == 2) {
                 $media = 'http://www.youtube.com/watch?v=' . $model->cover->media;
             }
         }
         $this->pageImage = $media;
     }
     $this->render('front_view', array('model' => $model, 'photo' => $photo, 'random' => $random));
 }
示例#6
0
$this->breadcrumbs = array('Articles' => array('manage'), Phrase::trans($model->cat->name, 2), $model->title);
$cs = Yii::app()->getClientScript();
$cs->registerScriptFile(Yii::app()->request->baseUrl . '/externals/article/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/article/' . $model->article_id . '/' . $model->cover->media;
} else {
    $mediaPhoto = ArticleMedia::model()->findByPk($_GET['photo']);
    $images = Yii::app()->request->baseUrl . '/public/article/' . $mediaPhoto->article_id . '/' . $mediaPhoto->media;
}
?>

<div class="meta">
	<i class="fa fa-calendar-check-o"></i><?php 
echo Utility::dateFormat($model->published_date);
?>
	<i class="fa fa-bookmark-o"></i><?php 
echo $model->user->displayname;
?>
	<?php 
if ($model->media_file != '') {
    ?>
<i class="fa fa-download"></i><?php