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')); }
<?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(-1); require_once 'FeedModel.php'; require_once 'OrgModel.php'; require_once 'MenuModel.php'; require_once 'UserModel.php'; // BEGIN testing of FeedModel $feedModel = new FeedModel(); // add message /* $arrInsert = array("sender" => "10", "receiver" => "50", "message" => "second example"); $arrResult = $feedModel->addMessage($arrInsert); echo print_r($arrResult); */ //get message $arrResult = $feedModel->getMessages(array("id" => 50, "where_clause" => "receiver=:id")); print_r($arrResult); //delete message //$arrResult = $feedModel->deleteMessageById(50); //print_r($arrResult); // END testing of FeedModel // START testing OrgModel //$orgModel = new OrgModel(); // add Org /* $arrTest= array("name" => "Victor", "address" => "The Hub", "city" => "Madison", "state" => "Wisconsin", "zip" => "53703", "phone" => "8605752115", "email" => "*****@*****.**", "phone2" => "253535", "profileJSON" => "JSON");
<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); */ ?>
<?php // .... require_once 'config.php'; require_once 'FeedModel.php'; DatastoreService::setInstance(new DatastoreService($google_api_config)); $feed_url = 'http://www.sciam.com/xml/sciam.xml'; $feed_model = new FeedModel($feed_url); // save the instance to the datastore $feed_model->put(); // now, try fetching the saved model from the datastore $kname = sha1($feed_url); // fetch the feed with that key, as part of the transaction $feed_model_fetched = FeedModel::fetch_by_name($kname)[0]; echo "fetched feed model with subscriber url: " . $feed_model_fetched->getSubscriberUrl();
/** * Extract the results of a Datastore query into FeedModel objects * @param $results Datastore query results */ protected static function extractQueryResults($results) { $query_results = []; foreach ($results as $result) { $id = @$result['entity']['key']['path'][0]['id']; $key_name = @$result['entity']['key']['path'][0]['name']; $props = $result['entity']['properties']; $url = $props[self::SUBSCRIBER_URL_NAME]->getStringValue(); $feed_model = new FeedModel($url); $feed_model->setKeyId($id); $feed_model->setKeyName($key_name); // Cache this read feed. $feed_model->onItemWrite(); $query_results[] = $feed_model; } return $query_results; }