public function actionIndex() { $c = array('conditions' => array('status' => array('==' => 1))); $total = WebArticlesModel::model()->count($c); $pager = new CPagination($total); $itemOnPaging = 5; $pager->pageSize = 10; $curr_page = $pager->getCurrentPage(); $limit = $pager->getLimit(); $offset = $pager->getOffset(); $c = array('conditions' => array('status' => array('==' => 1)), 'sort' => array('_id' => EMongoCriteria::SORT_DESC), 'limit' => $limit, 'offset' => $offset); $data = FeedModel::model()->findAll($c); $this->render('index', compact('data', 'pager', 'itemOnPaging')); }
/** * Displays a particular model. */ public function actionView() { $id = Yii::app()->request->getParam('id'); $genre = Yii::app()->request->getParam('url_key_cat1'); $this->activemenu = $genre; $article = WebArticlesModel::model()->model()->findByPk(new MongoId($id)); if (!$article) { throw new CHttpException(404, "There is not found!"); } $limit = 10; $offset = 0; $c = array('conditions' => array('status' => array('==' => 1)), 'sort' => array('_id' => EMongoCriteria::SORT_DESC), 'limit' => $limit, 'offset' => $offset); $data = FeedModel::model()->findAll($c); $this->render('view', array('article' => $article, 'data' => $data)); }
public function actionIndex() { $url_key = Yii::app()->request->getParam('url_key'); $url_key = trim($url_key); $this->activemenu = $url_key; $c = array('conditions' => array('url_key' => array('==' => $url_key)), 'limit' => 1); $genre = GenreModel::model()->find($c); if (empty($genre)) { throw new CHttpException(404); } $genreCode = $genre->code; $limit = 10; $offset = 0; $c = array('conditions' => array('genre' => array('==' => $genreCode)), 'sort' => array('_id' => EMongoCriteria::SORT_DESC), 'limit' => $limit, 'offset' => $offset); $articles = FeedModel::model()->findAll($c); $this->render('index', compact('articles', 'genre')); }
<div class="form"> <?php $form = $this->beginWidget('CActiveForm', array('id' => 'admin-articles-model-form', 'enableAjaxValidation' => false)); ?> <p class="note">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <?php $image = FeedModel::model()->getAvatarUrl($model->thumb); $width = Yii::app()->params['profile_image']['thumb']['width']; $height = Yii::app()->params['profile_image']['thumb']['height']; ?> <div class="row"> <img class="img-thumbnail" width="<?php echo $width; ?> " height="<?php echo $height; ?> " src="<?php echo $image; ?> " id="thumb" /> <?php $this->widget('ext.EAjaxUpload.EAjaxUpload', array('id' => 'uploadFile', 'config' => array('action' => Yii::app()->createUrl('/site/upload'), 'allowedExtensions' => array("jpg"), 'sizeLimit' => 10 * 1024 * 1024, 'minSizeLimit' => 1 * 1024, 'onComplete' => "js:function(id, fileName, responseJSON){\n \$('#thumb').html(fileName);\n \$('#AdminArticlesModel_thumb').attr('value',fileName);\n }"))); ?> <input type="hidden" name="AdminArticlesModel[thumb]" id="AdminArticlesModel_thumb" value="" />
private function processThumb($_id, $imgsrc) { $storage = Yii::app()->params['feed_path']; $temp = Yii::app()->params['temp']; $fileInfo = explode('.', $imgsrc); $fileType = $fileInfo[count($fileInfo) - 1]; $fileName = 'tmp_' . $_id . "." . $fileType; $tmpFile = $temp . DS . $fileName; $res_get_file = FileRemote::getFromUrl($imgsrc, $tmpFile); if ($res_get_file && file_exists($tmpFile)) { $fileDest = StorageHelper::generalStoragePath($_id, $fileType, $storage); $fileSystem = new Filesystem(); //$copy = $fileSystem->copy($tmpFile,$fileDest); $width = Yii::app()->params['profile_image']['thumb']['width']; $height = Yii::app()->params['profile_image']['thumb']['height']; $resizeObj = new ResizeImage($tmpFile); $resizeObj->resizeImage($width, $height, 0); $resizeObj->saveImage($fileDest, 100); //$resize = $imageCrop->resizeCrop($fileDest,$width,$height); if ($resizeObj) { echo 'copy file success!' . "\n"; $feed = FeedModel::model()->findByPk(new MongoId($_id)); $thumbPath = str_replace($storage, '', $fileDest); $feed->thumb = $thumbPath; $feed->status = 1; return $feed->save(); } } }
public static function model($className = __CLASS__) { return parent::model($className); }
<?php $link = Yii::app()->createUrl('/post/view', array('id' => $article->_id, 'url_key' => Common::makeFriendlyUrl($article->title))); $image = FeedModel::model()->getAvatarUrl($article->thumb); ?> <div class="post"> <div class="title"> <h1><?php echo CHtml::encode($article->title); ?> </h1> </div> <!--<div class="author"> posted by <?php /*echo $article->created_by; */ ?> </div>--> <div class="content"> <?php echo $article->fulltext; ?> </div> <!--<div class="nav"> <b>Tags:</b> <?php /*echo $article->tags; */ ?> <br/> <?php /*echo CHtml::link('Permalink', $link); */ ?>