Exemplo n.º 1
0
 /**
  * @param CActiveRecord $model
  **/
 public function getModelAttributes($model)
 {
     $result = array();
     $attributes = $model->attributeLabels();
     //       UtilHelper::dump($attributes);
     foreach ($attributes as $key => $value) {
         $result[$value] = get_class($model) . '.findByPk.' . $key . '|pk=:id';
     }
     return $result;
 }
Exemplo n.º 2
0
 /**
  * @static
  * @param CActiveRecord $model
  * @param array|string $columns can also passed from js ,if so you can use $_GET to retrive it
  *          array('id','name') | 'id,name' 或者带别名 't.id,user.name....'
  * @param array $headers
  */
 public static function export(CActiveRecord $model, $columns = array(), $headers = array())
 {
     if (isset($_GET[self::$actionKey])) {
         require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'CSVExport.php';
         $provider = $model->search();
         if (!empty($columns)) {
             $criteria = $provider->getCriteria();
             $criteria->select = $columns;
         }
         $csv = new CSVExport($provider);
         if (!empty($headers)) {
             $csv->headers = $headers;
         }
         $csv->headers = $model->attributeLabels();
         $csv->exportFull = false;
         //default use pagination
         if (!empty(self::$options)) {
             foreach (self::$options as $key => $value) {
                 $csv->{$key} = $value;
             }
         }
         //  echo var_export($provider->getCriteria()->toArray(),true);
         $content = $csv->toCSV(null, "\t", '"');
         Yii::app()->getRequest()->sendFile(self::$fileName, $content, "text/csv", false);
         die;
         //  exit;
     }
     /*
             else{
                $actionKey  = self::$actionKey;
                 throw new CException("something wrog with your request,must contain the key '{$actionKey}' your get is: ".CJSON::encode($_GET) );
             }*/
 }
Exemplo n.º 3
0
 /**
  * @return array customized attribute labels (name=>label)
  */
 public function attributeLabels()
 {
     return array_merge(parent::attributeLabels(), array('id' => 'ID', 'parent_id' => 'Родитель', 'title' => 'Название', 'description' => 'Описание', 'listorder' => 'Порядок в списке', 'is_locked' => 'Заблокирован?', 'isCat' => 'Категория?'));
 }
Exemplo n.º 4
0
 /**
  * @return array customized attribute labels (name=>label)
  */
 public function attributeLabels()
 {
     return array_merge(parent::attributeLabels(), array('id' => 'ID', 'author_id' => 'Author', 'thread_id' => 'Thread', 'editor_id' => 'Editor', 'content' => 'Текст', 'created' => 'Дата создания', 'updated' => 'Дата обновления'));
 }
Exemplo n.º 5
0
 /**
  * @return array customized attribute labels (name=>label)
  */
 public function attributeLabels()
 {
     return array_merge(parent::attributeLabels(), array('id' => 'ID', 'forum_id' => 'Форум', 'subject' => 'Тема', 'is_sticky' => 'Прикреплена?', 'is_locked' => 'Закрыта?', 'view_count' => 'Кол. просмотров', 'created' => 'Дата создания'));
 }