public function init() { if ($this->data === null) { throw new CException(Yii::t('zii', 'Please specify the "data" property.')); } if ($this->attributes === null) { if ($this->data instanceof CModel) { $attributes = WidgetManager::getVisibleColumns(get_class($this->data), $this->id); if ($attributes) { $this->attributes = $attributes; } else { $this->attributes = $this->data->attributeNames(); } } else { if (is_array($this->data)) { $this->attributes = array_keys($this->data); } else { throw new CException(Yii::t('zii', 'Please specify the "attributes" property.')); } } } if ($this->nullDisplay === null) { $this->nullDisplay = '<span class="null">' . Yii::t('zii', 'Not set') . '</span>'; } $this->htmlOptions['id'] = $this->getId(); if ($this->baseScriptUrl === null) { $this->baseScriptUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('application.components.zii.assets')) . '/detailview'; } $this->cssFile = $this->baseScriptUrl . '/styles.css'; Yii::app()->getClientScript()->registerCssFile($this->cssFile); }
public function actionColumnsManage($model_id, $widget_id) { $model = ActiveRecord::model($model_id); if (isset($_POST['columns'])) { file_put_contents(WidgetManager::getVisibleColumnsFilePath($model_id, $widget_id), serialize(explode(',', $_POST['columns']))); if (isset($_GET['redirect'])) { $this->redirect(base64_decode($_GET['redirect'])); } } $visible_columns = WidgetManager::getVisibleColumns($model_id, $widget_id); $hidden_columns = array(); $attributes = array_keys($model->attributeLabels()); $visible_columns = array_intersect($visible_columns, $attributes); foreach ($attributes as $attribute) { if ($attribute == 'captcha') { continue; } if (in_array($attribute, $visible_columns)) { continue; } $hidden_columns[] = $attribute; } $this->render('columnsManage', array('visible_columns' => $visible_columns, 'hidden_columns' => $hidden_columns, 'model' => $model)); }
public function initColumns() { $button_column_exists = false; $attributes_columns = $this->columns; foreach ($attributes_columns as $i => $data) { if (isset($data['class'])) { if ($data['class'] == 'CButtonColumn') { $button_column_exists = true; } unset($attributes_columns[$i]); } } if (!$attributes_columns) { $model = $this->filter; $attributes = WidgetManager::getVisibleColumns(get_class($model), $this->id); if ($attributes) { foreach ($attributes as $i => $attribute) { $this->addColumn( array( 'name' => $attribute, 'value' => '$data->value("' . $attribute . '")', 'type' => 'raw', 'filter' => $model->filter($attribute), ), $i ); } } } if (!$button_column_exists) { $this->addColumn(array('class' => 'CButtonColumn'), count($this->columns) + 1); } if ($this->many_many_sortable) { $this->addColumn(array( 'class' => 'ext.sortable.ManyManySortableColumn', 'header'=> t('Сортировка') ), -1); } if ($this->sortable) { $this->addColumn(array( 'class' => 'ext.sortable.SortableColumn', 'header'=> t('Сортировка') ), -1); } if ($this->mass_removal) { $this->addColumn(array( 'class' => 'CCheckBoxColumn', 'header' => "<input type='checkbox' class='object_checkboxes'>", 'selectableRows' => 2, 'checkBoxHtmlOptions' => array( 'class' => 'object_checkbox' ) )); } parent::initColumns(); }