Esempio n. 1
0
 /**
  * 属性首页
  */
 public function actionIndex()
 {
     parent::_acl();
     $model = new Attr();
     $criteria = new CDbCriteria();
     $condition = '1';
     $criteria->condition = $condition;
     $criteria->order = 't.scope DESC,t.sort_order DESC';
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 13;
     $pageParams = XUtils::buildCondition($_GET, array());
     $pages->params = is_array($pageParams) ? $pageParams : array();
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     $this->render('index', array('datalist' => $result, 'pagebar' => $pages));
 }
Esempio n. 2
0
 /**
  * 属性列表
  * @param  integer $catalog [description]
  * @param  string  $scope   [description]
  * @return [type]           [description]
  */
 public static function lists($catalog = 0, $scope = 'post')
 {
     $model = new Attr();
     if ($catalog) {
         $attrModel = $model->findAll(array('condition' => 'scope=:scope AND catalog_id=:catalogId', 'params' => array('scope' => $scope, 'catalogId' => $catalog), 'order' => 'sort_order DESC,id DESC'));
     } else {
         $attrModel = $model->findAll(array('condition' => 'scope=:scope ', 'params' => array('scope' => $scope), 'order' => 'sort_order DESC,id DESC'));
     }
     foreach ((array) $attrModel as $key => $row) {
         $data[$key] = self::_attr2val($row);
     }
     return $data;
 }