当前位置: 首页>>代码示例>>PHP>>正文


PHP News::model方法代码示例

本文整理汇总了PHP中News::model方法的典型用法代码示例。如果您正苦于以下问题:PHP News::model方法的具体用法?PHP News::model怎么用?PHP News::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在News的用法示例。


在下文中一共展示了News::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionRss

 public function actionRss()
 {
     // disabling web log
     foreach (Yii::app()->log->routes as $route) {
         if ($route instanceof CWebLogRoute) {
             $route->enabled = false;
         }
     }
     Yii::import('ext.feed.*');
     $feed = new EFeed();
     $feed->title = Yii::app()->name . ' | ' . Yii::t('newsModule.common', 'Nouvelles');
     $feed->description = Yii::app()->name . ' | ' . Yii::t('newsModule.common', 'Nouvelles');
     $feed->addChannelTag('language', Yii::app()->language);
     $feed->addChannelTag('pubDate', date(DATE_RSS, time()));
     $feed->addChannelTag('link', $this->createAbsoluteUrl('index'));
     if ($news = News::model()->findAll(array('order' => 'date DESC', 'limit' => 25, 'condition' => "date <= '" . date('Y-m-d H:i:s') . "' AND section_id = " . Yii::app()->cms->currentSectionId))) {
         foreach ($news as $new) {
             $item = $feed->createNewItem();
             $item->title = $new->title;
             $item->link = $this->createAbsoluteUrl('detail', array('n' => $new->title_url));
             $item->date = $new->date;
             if (!empty($new->image)) {
                 $item->description = '<div style="margin-bottom: 1em;"><img src="' . Yii::app()->request->hostInfo . Yii::app()->request->baseUrl . '/' . $new->imageHandler->dir . '/' . Helper::encodeFileName(Helper::fileSuffix($new->image, 's')) . '" alt="' . CHtml::encode($new->title) . '" /></div><div>' . CHtml::encode($new->summary) . '</div>';
             } else {
                 $item->description = CHtml::encode($new->summary);
             }
             $feed->addItem($item);
         }
     }
     $feed->generateFeed();
     Yii::app()->end();
 }
开发者ID:kostya1017,项目名称:our,代码行数:32,代码来源:DefaultController.php

示例2: actionIndex

 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     #if (Yii::app()->user->isGuest) {
     #    $this->render('index');
     #} else {
     #    if (Yii::app()->user->checkAccess('admin')) {
     #        $this->redirect(array('admin/index'));
     #    } else {
     #        $this->redirect(array('user/accountBalance', 'id'=>Yii::app()->user->_id));
     #    }
     #}
     $form = new SearchForm();
     // Use for Form
     $dataset = new Dataset();
     // Use for auto suggestion
     $datasetModel = $this->getDatasetByType(0);
     // Use for image slider content
     $publicIds = Yii::app()->db->createCommand()->select("id")->from("dataset")->where("upload_status = 'Published'")->queryAll();
     $datasettypes_hints = Type::model()->findAll(array('order' => 'name ASC'));
     $news = News::model()->findAll("start_date<=current_date AND end_date>=current_date");
     $criteria = new CDbCriteria();
     $criteria->limit = 10;
     $criteria->condition = "upload_status = 'Published'";
     #$criteria->order = "id DESC";
     $criteria->order = 'publication_date DESC';
     $latest_datasets = Dataset::model()->findAll($criteria);
     $criteria->condition = null;
     $criteria->order = 'publication_date DESC';
     $latest_messages = RssMessage::model()->findAll($criteria);
     $rss_arr = array_merge($latest_datasets, $latest_messages);
     $this->sortRssArray($rss_arr);
     $this->render('index', array('datasets' => $datasetModel, 'form' => $form, 'dataset' => $dataset, 'news' => $news, 'dataset_hint' => $datasettypes_hints, 'rss_arr' => $rss_arr, 'count' => count($publicIds), 'latest_datasets' => $latest_datasets));
 }
开发者ID:jessesiu,项目名称:GigaDBV3,代码行数:37,代码来源:SiteController.php

示例3: actionIndex

 public function actionIndex()
 {
     $page = Menu::model()->findByPk(InfoPages::MAIN_PAGE_ID);
     $langs = Lang::getActiveLangs();
     $countLangs = count($langs);
     if (!isFree() && !isset($_GET['lang']) && ($countLangs > 1 || $countLangs == 1 && param('useLangPrefixIfOneLang'))) {
         $canonicalUrl = Yii::app()->getBaseUrl(true);
         $canonicalUrl .= '/' . Yii::app()->language;
         Yii::app()->clientScript->registerLinkTag('canonical', null, $canonicalUrl);
     }
     Yii::app()->user->setState('searchUrl', NULL);
     $criteriaNews = new CDbCriteria();
     $criteriaNews->limit = 10;
     $criteriaNews->order = 'date_created DESC';
     $newsIndex = News::model()->findAll($criteriaNews);
     if (isset($_GET['is_ajax'])) {
         //			$modeListShow = User::getModeListShow();
         //			if ($modeListShow == 'table') {
         //				# нужны скрипты и стили, поэтому processOutput установлен в true только для table
         //				$this->renderPartial('index', array('page' => $page, 'newsIndex' => $newsIndex), false, true);
         //			}
         //			else {
         $this->renderPartial('index', array('page' => $page, 'newsIndex' => $newsIndex));
         //			}
     } else {
         $this->render('index', array('page' => $page, 'newsIndex' => $newsIndex));
     }
 }
开发者ID:alexjkitty,项目名称:estate,代码行数:28,代码来源:SiteController.php

示例4: actionCategory

 public function actionCategory($category)
 {
     // главная страница категории новостей
     $model = NewsCategories::model()->findByAttributes(array("url" => $category));
     if (empty($model)) {
         $this->redirect("/");
     }
     if ($category == "novosti" || $category == "news" || $category == "Nouvelles") {
         $this->pageTitle = $model->title;
         $criteria = new CDbCriteria();
         $criteria->condition = "category_id =" . $model->id;
         $criteria->addCondition("lang_id = " . $this->lang);
         $modelNews = News::model()->findAll($criteria);
         $this->render("indexNovosti", array("content" => $modelNews, "categoryid" => $model->id, "categoryName" => $category));
     } else {
         $this->pageTitle = $model->title;
         $criteria = new CDbCriteria();
         $criteria->condition = "is_active=1 AND category_id =" . $model->id;
         $criteria->addCondition("lang_id = " . $this->lang);
         $modelNews = News::model()->findAll($criteria);
         $nCriteria = new CDbCriteria();
         $nCriteria->condition = "lang_id =" . $this->lang . " AND is_active=1";
         $ArtNewCategories = NewsCategories::model()->findAll($nCriteria);
         $this->render("indexEct", array("content" => $modelNews, "categories" => $ArtNewCategories));
     }
 }
开发者ID:42point,项目名称:Vinum,代码行数:26,代码来源:FrontNewsController.php

示例5: init

 public function init()
 {
     $criteria = new CDbCriteria();
     $criteria->select = 'date';
     $criteria->distinct = true;
     $this->model = News::model()->findAll($criteria);
 }
开发者ID:Vladimirtishenko,项目名称:sn,代码行数:7,代码来源:CalendarWidget.php

示例6: run

 public function run()
 {
     $criteria = new CDbCriteria();
     $criteria->addCondition('status=1');
     if ($this->catId) {
         $criteria->addCondition('term_id=' . $this->catId);
     }
     if ($this->currentId) {
         $criteria->addCondition('id<>' . $this->currentId);
     }
     $criteria->order = 'create_time DESC';
     $criteria->limit = 20;
     $news = News::model()->findAll($criteria);
     echo CHtml::openTag("div", array('class' => 'title', 'style' => 'color: #000000;font-size: 18px;'));
     echo "Tin khác";
     echo CHtml::closeTag("div");
     if ($news) {
         echo CHtml::openTag("ul", array('style' => 'border: 1px solid #CCCCCC;
 border-radius: 4px 4px 4px 4px;
 margin: 8px 0px 0px 0px;
 padding: 10px 5px;list-style:none;'));
         foreach ($news as $n) {
             echo CHtml::openTag('li');
             echo CHtml::link($n->title, array('/news/detail', 'id' => $n->id, 'tid' => $n->term_id, 'title' => Lnt::safeTitle($n->title))) . " <span style='color:#a7a7a7'>({$n->view})</span>";
             echo CHtml::closeTag('li');
         }
         echo CHtml::closeTag("ul");
     }
 }
开发者ID:ngdvan,项目名称:lntguitar,代码行数:29,代码来源:OtherNews.php

示例7: actionIndex

 public function actionIndex()
 {
     if (!empty($this->arrSystem)) {
         $this->pageTitle = "Trang chủ - " . $this->arrSystem->title;
     }
     // Hinh anh trinh dien
     $criteria = new CDBCriteria();
     $criteria->addCondition("is_product = 3");
     $arrImage = Slides::model()->findAll($criteria);
     // Linh vuc kinh doanh
     $criteria = new CDBCriteria();
     $criteria->addCondition("category_news_id = 1");
     $criteria->limit = 3;
     $arrNew = News::model()->findAll($criteria);
     // tin tuc noi bat
     $criteria = new CDBCriteria();
     $criteria->addCondition("category_news_id != 1");
     $criteria->order = 'id DESC';
     $criteria->limit = 3;
     $arrNewSpecial = News::model()->findAll($criteria);
     // hinh anh noi bat
     $criteria = new CDBCriteria();
     $criteria->addCondition("is_product = 1");
     $criteria->order = 'id DESC';
     $criteria->limit = 8;
     $arrImageSpecial = Slides::model()->findAll($criteria);
     $this->render("index", array('arrImage' => $arrImage, 'arrNew' => $arrNew, 'arrNewSpecial' => $arrNewSpecial, 'arrImageSpecial' => $arrImageSpecial));
 }
开发者ID:phiphi1992,项目名称:alongaydep,代码行数:28,代码来源:HomeController.php

示例8: actionNewDetail

 public function actionNewDetail($alias = null)
 {
     if (!empty($this->arrSystem)) {
         $this->pageTitle = "Tin tức - " . $this->arrSystem->title;
     }
     $new = $newRelated = null;
     $cateInfo = null;
     if (!empty($alias)) {
         // lay tin tuc theo alias
         $criteria = new CDBCriteria();
         $criteria->addCondition("alias = :alias");
         $criteria->params = array(":alias" => $alias);
         $new = News::model()->find($criteria);
         if (empty($new)) {
             throw new CHttpException(404, 'Không tìm thấy trang!.');
         } else {
             // lay ten cua danh muc
             $cateInfo = CategoriesNews::model()->findByPK($new->category_news_id);
             // lay cac tin lien quan
             $criteria = new CDBCriteria();
             $criteria->addCondition("alias != :alias and category_news_id = {$new->category_news_id} ");
             $criteria->params = array(":alias" => $alias);
             $criteria->order = "id DESC";
             $criteria->limit = 5;
             $newRelated = News::model()->findAll($criteria);
         }
     }
     $this->render("newDetail", array('newInfo' => $new, 'newRelated' => $newRelated, 'cateInfo' => $cateInfo));
 }
开发者ID:phiphi1992,项目名称:alongaydep,代码行数:29,代码来源:NewController.php

示例9: actionSitemap

 public function actionSitemap()
 {
     $pages = Pages::model()->findAll();
     $news = News::model()->findAll();
     header('Content-Type: application/xml');
     $this->renderPartial('../site/sitemap', array('pages' => $pages, 'news' => $news));
 }
开发者ID:lajayuhniyarsyah,项目名称:SupraCompProfile,代码行数:7,代码来源:SiteController.php

示例10: loadModel

	private function loadModel($id)
	{
		$model=News::model()->findByPk($id);
		if($model===null)
			throw new CHttpException(404,'The requested page does not exist.');
		return $model;
	}
开发者ID:noikiy,项目名称:letstravel,代码行数:7,代码来源:AboutusController.php

示例11: actions

 public function actions()
 {
     if (!($limit = (int) $this->module->rssCount)) {
         throw new CHttpException(404);
     }
     $criteria = new CDbCriteria();
     $criteria->order = 'date DESC';
     $criteria->params = array();
     $criteria->limit = $limit;
     $title = $this->yupe->siteName;
     $description = $this->yupe->siteDescription;
     $categoryId = (int) Yii::app()->getRequest()->getQuery('category');
     if (!empty($categoryId)) {
         $category = Category::model()->cache($this->yupe->coreCacheTime)->published()->findByPk($categoryId);
         if (null === $category) {
             throw new CHttpException(404);
         }
         $title = $category->name;
         $description = $category->description;
         $criteria->addCondition('category_id = :category_id');
         $criteria->params[':category_id'] = $categoryId;
     }
     $data = News::model()->cache($this->yupe->coreCacheTime)->with('user')->published()->public()->findAll($criteria);
     return array('feed' => array('class' => 'yupe\\components\\actions\\YFeedAction', 'data' => $data, 'title' => $title, 'description' => $description, 'itemFields' => array('author_object' => 'user', 'author_nickname' => 'nick_name', 'content' => 'short_text', 'datetime' => 'date', 'link' => '/news/news/show', 'linkParams' => array('title' => 'alias'), 'title' => 'title', 'updated' => 'change_date')));
 }
开发者ID:sherifflight,项目名称:yupe,代码行数:25,代码来源:NewsRssController.php

示例12: renderContent

    protected function renderContent()
    {
        $news_items = News::model()->getLatestNews();
        ?>
        <ul>
    <?php 
        foreach ($news_items as $news) {
            ?>
        <li>
            <?php 
            $title = CHtml::encode($news->title);
            echo CHtml::link($title, $news->url);
            ?>
        </li>
    <?php 
        }
        ?>
    <?php 
        if (!$news_items) {
            echo Yii::t('app', 'Sorry, no latest news!');
        }
        ?>
</ul>

        <?php 
    }
开发者ID:awecode,项目名称:awecms,代码行数:26,代码来源:LatestNews.php

示例13: actionRss

 public function actionRss()
 {
     $this->layout = '';
     header('Content-Type: text/xml; charset=utf-8', true);
     $newsFeed = News::model()->findAll(array('order' => 'date DESC', 'limit' => '50', 'condition' => 'rss = 1'));
     $this->renderPartial('rss', array('newsFeed' => $newsFeed));
 }
开发者ID:Vladimirtishenko,项目名称:val.ua,代码行数:7,代码来源:FeedController.php

示例14: dashboardAction

 public function dashboardAction()
 {
     $file = array("name" => "a71ea8d3fd1f413458fdd278261f95cad0c85eea.jpg", "type" => "image/jpeg", "tmp_name" => "F:\nmpp\tmp\\phpBA0B.tmp", "error" => '', "size" => '123');
     $upload = new Upload();
     $upload->allowType = 'jpg,gif,png';
     if (false == $upload->save($file)) {
         debug($upload->getError());
     }
     // $upload->saveRemoteImage('http://img4.cache.netease.com/ent/2015/12/15/20151215112500b0c08.jpg');
     die;
     // Log::log()->trade->debug("123");
     // $test = new Tes123123t();
     $data = News::model()->findByPk(3);
     // SELECT * FROM `news` WHERE (id = '2') LIMIT 1
     $data = News::model()->find(array('condition' => array(array('id', '=', 3))));
     // SELECT * FROM `news` WHERE (id = '1') LIMIT 1
     $data = News::model()->findAll(array('field' => '*', 'condition' => array(array('id', '>', 2), array('title', '!=', ''), array('id', 'between', array(1, 500))), 'order' => 'id desc'));
     // SELECT * FROM `news` WHERE (id > '2') AND (title != '') AND (id IN ('1','2','3')) AND (id BETWEEN '1' AND '5') ORDER BY id desc
     $data = News::model()->count(array('field' => '*', 'condition' => array(array('id', '>', 2), array('title', '!=', ''), array('id', 'between', array(1, 500))), 'order' => 'id desc'));
     // SELECT COUNT(*) as `count` FROM `news` WHERE (id > '2') AND (title != '') AND (id BETWEEN '1' AND '500') ORDER BY id desc
     // $data = News::model()
     //     ->leftJoin('news_class','news_class.id=news.class')
     //     ->findAll(array(
     //         'field'=>'news.*,news_class.name',
     //         'condition'=>array(
     //             array('news.id','>',2),
     //             array('title','!=',''),
     //             array('news.id','in',array(1,2,3)),
     //             array('news.id','between',array(1,5)),
     //         ),
     //         'order'=>'news.id desc',
     //     )
     // );
     // SELECT news.*,news_class.name FROM `news` LEFT JOIN news_class ON news_class.id=news.class WHERE (news.id > '2') AND (title != '') AND (news.id IN ('1','2','3')) AND (news.id BETWEEN '1' AND '5') ORDER BY news.id desc
     // debug($data);
     // debug($data);
     // debug($_SESSION['name']);
     // $_SESSION['name'] = 'my name is hh';
     // debug($_SESSION);
     // $r = new \Redis();
     // $r->connect('127.0.0.1', '6379');
     // $test = Redis::redis()->test->get('myname');
     // $r->set('myname','ikodota');
     // $test = $r->get('myname');
     // debug($_SESSION);
     // debug(microtime());
     // for($i=1;$i<10000;$i++)
     // {
     //     $str = substr(sha1(rand()), 0, 4);
     // }
     // debug(microtime());
     // $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
     // for($i=1;$i<10000;$i++)
     // {
     //     $str = (substr(str_shuffle($pool), 0, 4));
     // }
     // debug(microtime());
     $this->display();
 }
开发者ID:seaice,项目名称:li,代码行数:59,代码来源:SiteController.php

示例15: actionIndex

 public function actionIndex()
 {
     //lay 1 tin moi de hien thi phan tin tuc
     $headTab = new Menu();
     $numHeadTab1 = $headTab->model()->find('alias="tin-dia-phuong"')->id;
     $cdbNewsLocal = new CDbCriteria();
     $cdbNewsLocal->order = 'datecreate DESC';
     $cdbNewsLocal->limit = 1;
     $cdbNewsLocal->condition = 'idmenu =' . $numHeadTab1;
     $modelNewsLocal = News::model()->find($cdbNewsLocal);
     if ($modelNewsLocal === NULL) {
         Yii::app()->user->setFlash('LocalEmpty', 'Dữ liệu đang cập nhật');
         $modelLocalMore = Yii::app()->user->setFlash('LocalEmptyMore', 'Dữ liệu đang cập nhật');
     } else {
         //lay 4 tin khac de hien thi phan tin tuc
         $cdbLocalMore = new CDbCriteria();
         $cdbLocalMore->limit = 4;
         $cdbLocalMore->order = 'datecreate DESC';
         $cdbLocalMore->condition = 'id NOT IN ("' . $modelNewsLocal->id . '") AND idmenu=' . $modelNewsLocal->idmenu;
         $modelLocalMore = News::model()->findAll($cdbLocalMore);
     }
     //lay 1 tin moi de hien thi phan Tin cong nghe
     $numHeadTab2 = $headTab->model()->find('alias="tin-cong-nghe"')->id;
     $cdbNewsTech = new CDbCriteria();
     $cdbNewsTech->order = 'datecreate DESC';
     $cdbNewsTech->limit = 1;
     $cdbNewsTech->condition = 'idmenu =' . $numHeadTab2;
     $modelNewsTech = News::model()->find($cdbNewsTech);
     if ($modelNewsTech === NULL) {
         Yii::app()->user->setFlash('emptyData', 'Dữ liệu đang cập nhật');
         $modelTechMore = Yii::app()->user->setFlash('emptyDataMore', 'Dữ liệu đang cập nhật');
     } else {
         //lay 2 tin khac de hien thi phan Tin cong nghe
         $cdbTechMore = new CDbCriteria();
         $cdbTechMore->limit = 2;
         $cdbTechMore->order = 'datecreate DESC';
         $cdbTechMore->condition = 'id NOT IN ("' . $modelNewsTech->id . '") AND idmenu=' . $modelNewsTech->idmenu;
         $modelTechMore = News::model()->findAll($cdbTechMore);
     }
     //lay 1 tin moi de hien thi phan Thong bao
     $numHeadTab3 = $headTab->model()->find('alias="thong-bao"')->id;
     $cdbNewsNotify = new CDbCriteria();
     $cdbNewsNotify->order = 'datecreate DESC';
     $cdbNewsNotify->limit = 1;
     $cdbNewsNotify->condition = 'idmenu =' . $numHeadTab3;
     $modelNewsNotify = News::model()->find($cdbNewsNotify);
     if ($modelNewsNotify === NULL) {
         Yii::app()->user->setFlash('NofifyEmpty', 'Dữ liệu đang cập nhật');
         $modelNotifyMore = Yii::app()->user->setFlash('MoreNofifyEmpty', 'Dữ liệu đang cập nhật');
     } else {
         //lay 2 tin khac de hien thi phan Tin cong nghe
         $cdbNotifyMore = new CDbCriteria();
         $cdbNotifyMore->limit = 2;
         $cdbNotifyMore->order = 'datecreate DESC';
         $cdbNotifyMore->condition = 'id NOT IN ("' . $modelNewsNotify->id . '") AND idmenu=' . $modelNewsNotify->idmenu;
         $modelNotifyMore = News::model()->findAll($cdbNotifyMore);
     }
     $this->render('index', array('modelNewsLocal' => $modelNewsLocal, 'modelLocalMore' => $modelLocalMore, 'modelNewsTech' => $modelNewsTech, 'modelTechMore' => $modelTechMore, 'modelNewsNotify' => $modelNewsNotify, 'modelNotifyMore' => $modelNotifyMore));
 }
开发者ID:hntvu,项目名称:db_for_site,代码行数:59,代码来源:SiteController.php


注:本文中的News::model方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。