private function loadNewArticle($num = 3) { $uid = Ibos::app()->user->uid; $allDeptId = Ibos::app()->user->alldeptid . ""; $allPosId = Ibos::app()->user->allposid . ""; $deptCondition = ""; $deptIdArr = explode(",", $allDeptId); if (0 < count($deptIdArr)) { foreach ($deptIdArr as $deptId) { $deptCondition .= "FIND_IN_SET('{$deptId}',deptid) OR "; } $deptCondition = substr($deptCondition, 0, -4); } else { $deptCondition = "FIND_IN_SET('',deptid)"; } $condition = " ( ((deptid='alldept' OR {$deptCondition} OR FIND_IN_SET('{$allPosId}',positionid) OR FIND_IN_SET('{$uid}',uid)) OR (deptid='' AND positionid='' AND uid='') OR (author='{$uid}') OR (approver='{$uid}')) ) AND `status`='1'"; $criteria = array("select" => "articleid,subject,content,addtime,type", "condition" => $condition, "order" => "`istop` DESC, `addtime` DESC", "offset" => 0, "limit" => $num); $articles = Article::model()->fetchAll($criteria); if (!empty($articles)) { foreach ($articles as &$article) { $read = ArticleReader::model()->fetchByAttributes(array("articleid" => $article["articleid"], "uid" => $uid)); $readStatus = $read ? 1 : 0; if ($readStatus) { $article["iconStyle"] = $this->iconReadStyle[$article["type"]]; } else { $article["iconStyle"] = $this->iconNormalStyle[$article["type"]]; } } } return $articles; }
public function getNews($id) { $gUid = Ibos::app()->user->uid; $article = Article::model()->fetchByPk($id); $attribute = ICArticle::getShowData($article); return $attribute; }
public function actionView() { $article_id = $_GET['article_id']; $article = Article::model()->findByPk($article_id); $this->data['article'] = $article; $this->render('view', $this->data); }
public function loadModel($id) { if (($model = Article::model()->findByPk($id)) === null) { throw new CHttpException(404, 'Страница не найдена'); } return $model; }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { $criteria = new CDbCriteria(); $criteria->limit = 6; $news = Article::model()->published()->findAll($criteria); $this->render('index', array('news' => $news)); }
public function delete($catid) { $clear = false; $ids = $this->fetchAllSubId($catid); $idStr = implode(",", array_unique(explode(",", trim($ids, ",")))); if (empty($idStr)) { $idStr = $catid; } else { $idStr .= "," . $catid; } $count = Article::model()->count("catid IN ({$idStr})"); if ($count) { return -1; } if (!is_null($this->_related)) { $count = $this->_related->count("`{$this->index}` IN ({$idStr})"); !$count && ($clear = true); } else { $clear = true; } if ($clear) { $status = $this->_category->deleteAll("FIND_IN_SET({$this->index},'{$idStr}')"); $this->afterDelete(); return $status; } else { return false; } }
public function actionFeel() { $keywords = Yii::app()->request->getParam('keywords'); $sql = "select * from {{article}} where title like'%{$keywords}%' order by create_time desc"; $article = Article::model()->findAllBySql($sql); $data = array('article' => $article, 'id' => $keywords); $this->render('feel', $data); }
public function loadModelByAlias($alias) { $model = Article::model()->find('alias=:alias', array(':alias' => $alias)); if ($model === null) { throw new CHttpException(404, 'Запрашиваемая страница не существует.'); } return $model; }
/** * 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 $id the ID of the model to be loaded * @return Article the loaded model * @throws CHttpException */ public function loadModel($url) { $model = Article::model()->findByAttributes(array('url' => $url)); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionShow($alias) { $model = Article::model()->published()->findByAlias($alias); if (!$model) { throw new CHttpException(404, Yii::t('PublicationModule.publication', 'Article was not found!')); } $this->render('show', array('model' => $model)); }
// // $cid = implode(',', $cids); // // $condition = $cate_id ? ' cate_id in(' . $cate_id . ',' . $cid . ')' : ''; // } else { // // $condition = $cate_id ? ' cate_id in(' . $cate_id . ')' : ''; // } // }
public function actionNews() { $newsData = Article::model()->getBriefArticlesData(null, Article::POST_TYPE_NEWS); $newsData->pagination = new CPagination(self::listingsPerPage); $this->breadcrumbs = array('News'); $this->tabMenus = array(array('label' => 'Articles', 'url' => array('/site/articles')), array('label' => 'News', 'active' => true), array('label' => 'Events', 'url' => array('/event/event/index')), array('label' => 'Workshops', 'url' => array('//site/workshops'))); $this->render('news', array('newsData' => $newsData)); }
public function actionIndex($cid) { $article = Yii::app()->cache->get('cache'); if ($article == false) { $article = Article::model()->findAllBySql('SELECT * FROM {{article}} WHERE cid = ' . $cid); Yii::app()->cache->set('cache', $article); } $this->render('index', array('article' => $article)); }
public function actionView($id) { //$this->layout='//layouts/inner'; $criteria = new CDbCriteria(); $criteria->order = 'sorter'; $criteria->condition = 'active=1'; $articles = Article::model()->findAll($criteria); $this->render('view', array('model' => $this->loadModel($id), 'articles' => $articles)); }
public function run() { $criteria = new CDbCriteria(); if ($this->limit > 0) { $criteria->limit = (int) $this->limit; } $models = Article::model()->sortByDate('DESC')->published()->findAll($criteria); $this->render($this->view, array('models' => $models)); }
public function actionIndex() { $db = Account::model()->getDbConnection(); $total = $db->createCommand("SELECT SUM(amount) FROM account")->queryScalar(); $criteria = new CDbCriteria(); $criteria->order = "id DESC"; $criteria->limit = 5; $articles = Article::model()->findAll($criteria); $this->render('index', array('total' => $total, 'articles' => $articles)); }
public function actionIndex() { //echo Yii::app()->request->baseUrl;die; $sqlNew = "SELECT thumb,aid,title,info,time FROM {{article}} ORDER BY time DESC LIMIT 5"; $sqlHot = "SELECT thumb,aid,title,info,time FROM {{article}} WHERE type=1 ORDER BY time DESC LIMIT 5"; $articleModel = Article::model(); $articleNew = $articleModel->findAllBySql($sqlNew); $articleHot = $articleModel->findAllBySql($sqlHot); $data = array('articleNew' => $articleNew, 'articleHot' => $articleHot); $this->render('index', $data); }
/** * 文章列表 */ public function actionList() { $criteria = new CDbCriteria(); $criteria->order = 'updatetime desc'; $count = Article::model()->count($criteria); $pager = new CPagination($count); $pager->pageSize = 10; $pager->applyLimit($criteria); $articlelist = Article::model()->findAll($criteria); $this->render('list', array('pages' => $pager, 'articlelist' => $articlelist)); }
public function run() { $article_model = Article::model()->findAll(array('select' => '*')); $article_model = CJSON::encode($article_model); $sort = new CSort(); $sort->defaultOrder = array('name DESC', 'id DESC'); $sort->attributes = array('name', 'id'); $this->widget('bootstrap.widgets.TbGridView', array('type' => 'striped bordered condensed', 'dataProvider' => new CArrayDataProvider(CJSON::decode($article_model), array('keyField' => 'id', 'pagination' => array('pageSize' => 3), 'sort' => $sort)), 'template' => "{items}", 'rowCssClass' => array('block_1', 'block_2', 'block_3'), 'columns' => array(array('name' => 'id', 'header' => '#'), array('name' => 'name', 'header' => 'Наименование'), array('name' => 'description', 'header' => 'Описание'), array('class' => 'bootstrap.widgets.TbButtonColumn', 'htmlOptions' => array('style' => 'width: 50px'))))); //example json encode //$this->render('widgets.indexgrid.view.indexgrid', array('article_model'=>CJSON::encode($article_model))); }
public function actionDel($cid) { $articleModel = Article::model(); $sql = "SELECT aid FROM {{article}} where cid={$cid}"; $articleInfo = $articleModel->findAllBySql($sql); if (is_object($articleInfo)) { Yii::app()->user->setFlash("hasArt", "栏目下面有文章,请先删除文章"); } else { if (Category::model()->deleteByPk($cid)) { $this->redirect(array('index')); } } }
public static function handle(CExceptionEvent $event) { $exception = $event->exception; if (get_class($exception) == "CHttpException" && $exception->statusCode === 404) { $pathParts = explode('/', Yii::app()->getRequest()->getRequestUri()); $pathPart = array_pop($pathParts); $criteria = new CDbCriteria(); $criteria->addSearchCondition('alias', $pathPart); $criteria->limit = 5; $models = Article::model()->findAll($criteria); $controller = new CController(null); $controller->renderPartial('//error/404', array('models' => $models)); $event->handled = true; } }
public function __construct($scenario = '', $id = null) { if ($scenario == 'view' && $id != null) { $this->article = Article::model()->findByPk($id); if ($this->article != null) { $this->postItem = $this->article->postItem; } else { throw new CHttpException(400, 'Cannot find the article post.'); } } else { $this->postItem = new PostItem(); $this->article = new Article(); $this->postItem->post_type_id = Article::POST_TYPE; } }
public function actionDellabel($id) { $label = Article::model(); $uid = Yii::app()->session['uid']; $sql = "select id from {{blog}} where userid = {$uid} and labelid = {$id} "; $blog = $label->findBySql($sql); if (is_object($blog)) { Yii::app()->user->setFlash("hasBlog", "此标签下有文章,删除文章先 :("); $this->redirect(array('labels')); } else { if ($label->deleteByPk($id)) { $this->redirect(array('labels')); } } $this->render($view); }
public function actionView($id = 0, $url = '') { $criteria = new CDbCriteria(); $criteria->order = 'sorter'; $criteria->condition = 'active=1'; $articles = Article::model()->cache(param('cachingTime', 1209600), Article::getCacheDependency())->findAll($criteria); if ($url && issetModule('seo')) { $seo = SeoFriendlyUrl::getForView($url, $this->modelName); if (!$seo) { throw404(); } $this->setSeo($seo); $id = $seo->model_id; } $this->render('view', array('model' => $this->loadModel($id), 'articles' => $articles)); }
public function actionAddReviewArticle($id) { $id = (int)$id; $review = Article::model()->active()->findByPk($id); if(!$review) Yii::app()->end(); if(isset($_POST['CommentArticle'])) { $model = new CommentArticle; $model->scenario = 'subcomment'; $model->object_pk = $review->id; if(!Yii::app()->user->isGuest) { $model->user_id = Yii::app()->user->id; } else { Yii::app()->end(); } $model->setAttribute('status', CommentArticle::STATUS_APPROVED); $this->performAjaxValidation($model, 'comments-form'); $model->attributes=$_POST['CommentArticle']; if(empty($model->id_parent)) $model->id_parent = null; if($model->validate()){ if($model->save()){ if(isset($_POST['type']) && $_POST['type']==1){ $this->renderPartial('_comment_super',array('model'=>$model,'supermodel'=>$review)); } else{ // $this->renderPartial('_comment',array('model'=>$model)); } } } } Yii::app()->end(); }
function actionIndex() { //首页幻灯片展示,读取最新4条 $ppt = Article::model()->findAll(array('order' => 'create_time desc', 'limit' => 4)); //首页最新微语展示 $wei = Weiyu::model()->findAll(array('order' => 'create_time desc')); // 首页点击率思想展示 $sixiang = Article::model()->findAll(array('order' => 'click desc', 'limit' => 8)); // 首页得瑟会员、小丫丫展示 $jiaoya = User::model()->findAll(array('order' => 'regtime desc', 'limit' => 5)); //首页展示标签 $pictag = Albumcate::model()->findAll(); $articletag = Type::model()->findAll(); //首页展示新的图 $likepic = Album::model()->findAll(array('order' => 'create_time desc', 'limit' => 9)); $data = array('quote' => $this->getRandomQuote(), 'ppt' => $ppt, 'wei' => $wei, 'sixiang' => $sixiang, 'jiaoya' => $jiaoya, 'pictag' => $pictag, 'likepic' => $likepic, 'articletag' => $articletag); $this->render('index', $data); }
public function actionIndex() { $id = $_REQUEST['id']; $this->data['cur_moduleid'] = $id; $module = Yii::app()->cache->get("module_" . $id); if ($module == false) { $module = $this->connection->createCommand("select * from xm_module where module_id = " . $id)->queryRow(); Yii::app()->cache->set("module_" . $id, $module); } $this->data['module'] = $module; /*右侧导航栏*/ $topid = $this->getTopIdFromIDEN($module['iden']); $this->topid = $topid; $modulequeue = Yii::app()->cache->get("modulequeue_" . $topid); if ($modulequeue == false) { $modulequeue = $this->getQueueModulesById($topid); Yii::app()->cache->set("modulequeue_" . $topid, $modulequeue); } $this->data['modulequeue'] = $modulequeue; /*最新文章*/ $lastarticles = Yii::app()->cache->get("lastarticles_" . $id); if ($lastarticles == false) { $lastarticles = $this->getTopArticleByModule($id, 5); Yii::app()->cache->set("lastarticles_" . $id, $lastarticles); } $this->data['lastarticles'] = $lastarticles; //查看对应的文章 $criteria = new CDbCriteria(); $criteria->addCondition('infotype="article"', 'AND'); $criteria->join = " LEFT JOIN xm_module module ON module.module_id=t.module_id "; $criteria->addCondition('module.iden like "%' . $id . '%" ', 'AND'); $criteria->order = "article_id desc ,seq desc,top desc,recommend desc,createtime desc"; $count = Article::model()->count($criteria); $pager = new CPagination($count); $pager->pageSize = 10; $pager->applyLimit($criteria); $articles = Article::model()->findAll($criteria); $this->data['pages'] = $pager; $this->data['list'] = $articles; Yii::app()->params['TITLE'] = $module['category']; Yii::app()->params['APPKEYWORDS'] = $module['category']; Yii::app()->params['APPDESCRIPTION'] = $module['category']; $this->render('index', $this->data); }
public function actionIndex() { $type = $_GET['type']; $this->data['type'] = $type; $criteria = new CDbCriteria(); if (empty($type)) { $type = 'article'; } $criteria->addCondition('infotype="' . $type . '"', 'AND'); $criteria->order = " seq desc,top desc,recommend desc,createtime desc,article_id desc "; $count = Article::model()->count($criteria); $pager = new CPagination($count); $pager->pageSize = 10; $pager->applyLimit($criteria); $articles = Article::model()->findAll($criteria); $this->data['pages'] = $pager; $this->data['list'] = $articles; $this->render('index', $this->data); }
/** * Displays the contact page */ public function actionContact() { $model = new ContactForm(); if (isset($_POST['ContactForm'])) { $model->attributes = $_POST['ContactForm']; if ($model->validate()) { $criteria = new CDbCriteria(array('condition' => 'superuser=1', 'condition' => 'notify=1', 'with' => 'profile')); $users = User::model()->findAll($criteria); foreach ($users as $email) { $headers = "From: {$model->name} <{$model->email}>\r\nReply-To: {$model->email}"; mail($email->email, 'Запрос со страницы контактов', $model->body, $headers); Yii::app()->user->setFlash('contact', 'Спасибо за Ваше сообщение. Мы ответим как можно скорее.'); } $this->refresh(); } } $content = Article::model()->findByAttributes(array('url' => 'contact')); $this->render('contact', array('model' => $model, 'content' => $content)); }
public function actionReply() { $model = new Post(); $now = date("Y-m-d H:i:s"); if (isset($_POST['Post']) && !Yii::app()->user->isGuest) { $model->attributes = $_POST['Post']; $model->c_time = $now; $model->user_id = Yii::app()->user->id; $article = Article::model()->findByPk($model->article_id); /* if( strlen($article->content) > 0 ){ $model->content = str_replace('<div><br /></div>','<div> </div>',$model->content); } */ if ($model->save()) { $article->reply_count++; $article->reply_time = $now; $article->save(); // add Notification except the auther of the article if ($article->user_id != Yii::app()->user->id) { $n = new Notification(); $n->attributes = array('user_id' => $article->user_id, 'article_id' => $article->id, 'post_id' => $model->id, 'c_time' => $now); $n->save(); } $this->redirect(array('t/index', 'id' => $model->article_id)); } if ($model->content == '') { // $model->content = "<p></p>"; } // only show the author reply if ($_GET['s']) { $criteria = new CDbCriteria(); $criteria->condition = "t.user_id = {$article->user_id} AND t.article_id = {$article->id}"; $criteria->order = 't.c_time ASC '; $posts = Post::model()->findAll($criteria); } else { $posts = $article->posts; } $this->render('index', array('inst' => $article, 'model' => $model, 'posts' => $posts)); } else { throw new CHttpException(404, 'The requested does not allow.'); } }