PATH:
home
/
letacommog
/
letaweb
/
admin
/
models
/
subsite_models
<?php class BNews extends BActiveRecord { const STATUS_PUBLISHED = 1; const STATUS_ARCHIVED = 2; const F1_CATEGORY = 11; const MOTOSPORT_CATEGORY = 12; const BICYCLE_CATEGORY = 13; const ATHLETIC_CATEGORY = 17; const OTHER_CATEGORY = 18; const PLAIN_TEXT_TYPE = 1; const PHOTO_TYPE = 2; const PHOTOGALLERY_TYPE = 3; const VIDEO_TYPE = 4; public static function model($className = __CLASS__) { return parent::model($className); } public function tableName() { return '{{news}}'; } public function rules() { return array( //array('type', 'numerical', 'integerOnly'=>true), array('title', 'length', 'max' => 255), array('title', 'required'), array('id, title, summary, content, viewed date_added, last_modified, date_available, status', 'safe'), ); } public function schemas() { return array( //'id'=>array('name'=>'id', 'type'=>'integer'), //'title'=>array('name'=>'title', 'type'=>'string'), //'summary'=>array('name'=>'summary', 'type'=>'string'), //'content'=>array('name'=>'content', 'type'=>'string'), 'date_added' => array('name' => 'date_added', 'type' => 'datetime'), //'title'=>array('name'=>'title', 'type'=>'string'), 'viewed' => array('name' => 'viewed', 'type' => 'integer'), 'date_available' => array('name' => 'date_available', 'type' => 'datetime'), //'status'=>array('name'=>'status', 'type'=>'list', 'list'=>array(0=>array('name'=>'Draft', 'value'=>0), 1=>array('name'=>'Published', 'value'=>1))), 'tags' => array('name' => 'tags', 'type' => 'relation', 'table' => 'tags','display_field' => 'name', 'value_field' => 'id'), 'category' => array('name' => 'category', 'type' => 'relation', 'table' => 'news_categories','display_field' => 'name', 'value_field' => 'id'), ); } public function relations() { // NOTE: you may need to adjust the relation name and the related // class name for the relations automatically generated below. return array( 'main_category' => array(self::BELONGS_TO, 'BNewsCategory', array('main_category_id'=>'inline_id')), 'news_news_category' => array(self::HAS_MANY, 'BNews_News_Category',array('news_id'=>'inline_id')), // 'comment_count' => array(self::STAT, 'BComments', 'news_id'), 'comment' => array(self::HAS_MANY, 'BComments', array('news_id'=>'inline_id')), 'categories' => array(self::HAS_MANY, 'BNewsCategory', array('category_id'=>'inline_id'),'through' => 'news_news_category'), 'tags' => array(self::HAS_MANY, 'BNewsCategory', 'category_id','through' => 'news_news_category'), ); } public function getcomment_count() { return BComments::model()->count('news_id=:news_id',array(':news_id'=>$this->inline_id)); } public function afterSave() { BNews_News_Category::model()->deleteAll('news_id=:id', array(':id' => $this->id)); if (isset($this->categories)) { $categories = $this->categories; foreach ($categories as $category) { $p = new BNews_News_Category(); $p->setIsNewRecord(true); $p->news_id = $this->inline_id; $p->category_id = $category['inline_id']; $p->save(); } } BNews_Tag::model()->deleteAll('news_id =:id', array(':id' => $this->id)); if (isset($this->tags) && !is_null($this->tags)) { $tags = trim($this->tags); if (strlen($tags) > 0) { $tag_clouds = explode(',', $tags); $flag_tags = array(); foreach ($tag_clouds as $tag_cloud) { $t = trim($tag_cloud); if (isset($flag_tags[$t]) && $flag_tags[$t] == true) { continue; } $flag_tags[$t] = true; $total = BTag::model()->count('name=:name', array(':name' => $t)); if ($total == 0) { $tt = new BTag(); $tt->setIsNewRecord(true); $tt->name = $t; $tt->save(); } $databse_tag = BTag::model()->find('name=:name', array(':name' => $t)); $database_id = $databse_tag['id']; $nt = new BNews_Tag(); $nt->setIsNewRecord(true); $nt->news_id = $this->inline_id; $nt->tags_id = $database_id; $nt->save(); } } } } public $fcategories, $filter_name, $filter_status, $filter_content; public $fmonths; public function getPagedList($pageSize = 10, $start = 0, $order='') { $criteria = new CDbCriteria(); //$criteria->compare('name',$this->name,true); $fcategories = trim($this->fcategories); if (strlen($fcategories)) { $criteria->with = ( array( 'news_news_category' => array( 'condition' => 'news_news_category.category_id= :category_id', 'params' => array(':category_id' => ''.$this->fcategories.''), ), ) ); } $fmonths = trim($this->fmonths); if (strlen($fmonths)) { $s = explode('-', $fmonths); if (sizeof($s) == 2) { $criteria->compare('month(date_added)', $s[1]); $criteria->compare('year(date_added)', $s[0]); } } $criteria->compare('title', $this->filter_name, true); $criteria->compare('status', $this->filter_status); $criteria->compare('content', $this->filter_content, true); $criteria->order = $order; $criteria->together = true; return new ActiveDataProvider('BNews', array( 'criteria' => $criteria, 'pagination' => array( 'pageSize' => $pageSize, 'start'=>$start, 'class' => 'Pagination', ), )); } }
[+]
..
[-] BTag.php
[edit]
[-] BActiveRecord.php
[edit]
[-] BModule.php
[edit]
[-] BPages.php
[edit]
[-] BComments.php
[edit]
[-] BNews_News_Category.php
[edit]
[-] BNewsModule.php
[edit]
[-] BAuthAssignment.php
[edit]
[-] BNewsCategory.php
[edit]
[-] BConfigurations.php
[edit]
[-] BPages_Elements.php
[edit]
[-] BNews_Comments.php
[edit]
[-] BNews_Categories.php
[edit]
[-] BUsers.php
[edit]
[-] BUserIdentity.php
[edit]
[-] BNews.php
[edit]
[-] BWebUser.php
[edit]
[+]
forms
[-] BColors.php
[edit]
[-] BSkins.php
[edit]
[-] BNews_Tag.php
[edit]
[-] BContributor_Invites.php
[edit]
[-] BContributor.php
[edit]