diff --git a/framework/zii/widgets/grid/CButtonColumn.php b/framework/zii/widgets/grid/CButtonColumn.php index 20ca54b38..378db2955 100644 --- a/framework/zii/widgets/grid/CButtonColumn.php +++ b/framework/zii/widgets/grid/CButtonColumn.php @@ -305,13 +305,15 @@ EOD; } /** - * Renders the data cell content. + * Returns the data cell content. * This method renders the view, update and delete buttons in the data cell. * @param integer $row the row number (zero-based) - * @param mixed $data the data associated with the row + * @return string the data cell content. + * @since 1.1.15 */ - protected function renderDataCellContent($row,$data) + public function getDataCellContent($row) { + $data=$this->grid->dataProvider->data[$row]; $tr=array(); ob_start(); foreach($this->buttons as $id=>$button) @@ -321,7 +323,7 @@ EOD; ob_clean(); } ob_end_clean(); - echo strtr($this->template,$tr); + return strtr($this->template,$tr); } /** diff --git a/framework/zii/widgets/grid/CCheckBoxColumn.php b/framework/zii/widgets/grid/CCheckBoxColumn.php index 5a582bdf4..9a2779ae8 100644 --- a/framework/zii/widgets/grid/CCheckBoxColumn.php +++ b/framework/zii/widgets/grid/CCheckBoxColumn.php @@ -187,43 +187,39 @@ EOD; } /** - * Renders the header cell content. + * Returns the header cell content. * This method will render a checkbox in the header when {@link selectableRows} is greater than 1 * or in case {@link selectableRows} is null when {@link CGridView::selectableRows} is greater than 1. + * @return string the header cell content. + * @since 1.1.15 */ - protected function renderHeaderCellContent() + public function getHeaderCellContent() { if(trim($this->headerTemplate)==='') - { - echo $this->grid->blankDisplay; - return; - } + return $this->grid->blankDisplay; - $item = ''; if($this->selectableRows===null && $this->grid->selectableRows>1) - $item = CHtml::checkBox($this->id.'_all',false,array('class'=>'select-on-check-all')); + $item=CHtml::checkBox($this->id.'_all',false,array('class'=>'select-on-check-all')); elseif($this->selectableRows>1) - $item = CHtml::checkBox($this->id.'_all',false); + $item=CHtml::checkBox($this->id.'_all',false); else - { - ob_start(); - parent::renderHeaderCellContent(); - $item = ob_get_clean(); - } + $item=parent::getHeaderCellContent(); - echo strtr($this->headerTemplate,array( + return strtr($this->headerTemplate,array( '{item}'=>$item, )); } /** - * Renders the data cell content. + * Returns the data cell content. * This method renders a checkbox in the data cell. * @param integer $row the row number (zero-based) - * @param mixed $data the data associated with the row + * @return string the data cell content. + * @since 1.1.15 */ - protected function renderDataCellContent($row,$data) + public function getDataCellContent($row) { + $data=$this->grid->dataProvider->data[$row]; if($this->value!==null) $value=$this->evaluateExpression($this->value,array('data'=>$data,'row'=>$row)); elseif($this->name!==null) @@ -243,6 +239,6 @@ EOD; unset($options['name']); $options['value']=$value; $options['id']=$this->id.'_'.$row; - echo CHtml::checkBox($name,$checked,$options); + return CHtml::checkBox($name,$checked,$options); } } diff --git a/framework/zii/widgets/grid/CDataColumn.php b/framework/zii/widgets/grid/CDataColumn.php index 7d2abc91f..92c90760b 100644 --- a/framework/zii/widgets/grid/CDataColumn.php +++ b/framework/zii/widgets/grid/CDataColumn.php @@ -85,54 +85,59 @@ class CDataColumn extends CGridColumn } /** - * Renders the filter cell content. - * This method will render the {@link filter} as is if it is a string. + * Returns the filter cell content. + * This method will return the {@link filter} as is if it is a string. * If {@link filter} is an array, it is assumed to be a list of options, and a dropdown selector will be rendered. * Otherwise if {@link filter} is not false, a text field is rendered. - * @since 1.1.1 + * @return string the filter cell content + * @since 1.1.15 */ - protected function renderFilterCellContent() + public function getFilterCellContent() { if(is_string($this->filter)) - echo $this->filter; + return $this->filter; elseif($this->filter!==false && $this->grid->filter!==null && $this->name!==null && strpos($this->name,'.')===false) { if(is_array($this->filter)) - echo CHtml::activeDropDownList($this->grid->filter, $this->name, $this->filter, array('id'=>false,'prompt'=>'')); + return CHtml::activeDropDownList($this->grid->filter, $this->name, $this->filter, array('id'=>false,'prompt'=>'')); elseif($this->filter===null) - echo CHtml::activeTextField($this->grid->filter, $this->name, array('id'=>false)); + return CHtml::activeTextField($this->grid->filter, $this->name, array('id'=>false)); } else - parent::renderFilterCellContent(); + return parent::getFilterCellContent(); } /** - * Renders the header cell content. + * Returns the header cell content. * This method will render a link that can trigger the sorting if the column is sortable. + * @return string the header cell content. + * @since 1.1.15 */ - protected function renderHeaderCellContent() + public function getHeaderCellContent() { if($this->grid->enableSorting && $this->sortable && $this->name!==null) - echo $this->grid->dataProvider->getSort()->link($this->name,$this->header,array('class'=>'sort-link')); + return $this->grid->dataProvider->getSort()->link($this->name,$this->header,array('class'=>'sort-link')); elseif($this->name!==null && $this->header===null) { if($this->grid->dataProvider instanceof CActiveDataProvider) - echo CHtml::encode($this->grid->dataProvider->model->getAttributeLabel($this->name)); + return CHtml::encode($this->grid->dataProvider->model->getAttributeLabel($this->name)); else - echo CHtml::encode($this->name); + return CHtml::encode($this->name); } else - parent::renderHeaderCellContent(); + return parent::getHeaderCellContent(); } /** - * Renders the data cell content. + * Returns the data cell content. * This method evaluates {@link value} or {@link name} and renders the result. * @param integer $row the row number (zero-based) - * @param mixed $data the data associated with the row + * @return string the data cell content. + * @since 1.1.15 */ - protected function renderDataCellContent($row,$data) + public function getDataCellContent($row) { + $data=$this->grid->dataProvider->data[$row]; if($this->value!==null) $value=$this->evaluateExpression($this->value,array('data'=>$data,'row'=>$row)); elseif($this->name!==null) diff --git a/framework/zii/widgets/grid/CLinkColumn.php b/framework/zii/widgets/grid/CLinkColumn.php index f73b8a23a..12a73c3d4 100644 --- a/framework/zii/widgets/grid/CLinkColumn.php +++ b/framework/zii/widgets/grid/CLinkColumn.php @@ -87,13 +87,15 @@ class CLinkColumn extends CGridColumn public $linkHtmlOptions=array(); /** - * Renders the data cell content. + * Returns the data cell content. * This method renders a hyperlink in the data cell. * @param integer $row the row number (zero-based) - * @param mixed $data the data associated with the row + * @return string the data cell content. + * @since 1.1.15 */ - protected function renderDataCellContent($row,$data) + public function getDataCellContent($row) { + $data=$this->grid->dataProvider->data[$row]; if($this->urlExpression!==null) $url=$this->evaluateExpression($this->urlExpression,array('data'=>$data,'row'=>$row)); else