Format a column of data for display.

@param stdClass $row
@return string
322041
public function col_duedate(stdClass $row) {
        $o = '';

        if ($row->duedate) {
            $userdate = userdate($row->duedate);
            $o = ($this->is_downloading()) ? $userdate : $this->output->container($userdate, 'duedate');
        }

        return $o;
    }
129515
public function toHtml(array $row)
    {
        if ($this->getLabel() == '') {
            throw new \InvalidArgumentException(
                'A label is required for this action type, please call $action->setLabel()!'
            );
        }

        $label = $this->getLabel();
        if ($label instanceof AbstractColumn) {
            $label = $row[$label->getUniqueId()];
        }

        return '<a '.$this->getAttributesString($row).'>'.$label.'</a>';
    }
835031
protected function _generateRow($row = null)
    {
        static $fp = false;

        if (empty($row)) {
            return '';
        }

        if ($fp === false) {
            $fp = fopen('php://temp', 'r+');

            if ($this->viewVars['_setSeparator']) {
                fwrite($fp, "sep=" . $this->viewVars['_delimiter'] . "\n");
            }
        } else {
            ftruncate($fp, 0);
        }

        if ($this->viewVars['_null'] !== '') {
            foreach ($row as &$field) {
                if ($field === null) {
                    $field = $this->viewVars['_null'];
                }
            }
        }

        $delimiter = $this->viewVars['_delimiter'];
        $enclosure = $this->viewVars['_enclosure'];
        $newline = $this->viewVars['_newline'];

        $row = str_replace(["\r\n", "\n", "\r"], $newline, $row);
        if ($enclosure === '') {
            // fputcsv does not supports empty enclosure
            if (fputs($fp, implode($delimiter, $row) . "\n") === false) {
                return false;
            }
        } else {
            if (fputcsv($fp, $row, $delimiter, $enclosure) === false) {
                return false;
            }
        }

        rewind($fp);

        $csv = '';
        while (($buffer = fgets($fp, 4096)) !== false) {
            $csv .= $buffer;
        }

        $eol = $this->viewVars['_eol'];
        if ($eol !== "\n") {
            $csv = str_replace("\n", $eol, $csv);
        }

        $dataEncoding = $this->viewVars['_dataEncoding'];
        $csvEncoding = $this->viewVars['_csvEncoding'];
        if ($dataEncoding !== $csvEncoding) {
            $extension = $this->viewVars['_extension'];
            if ($extension === self::EXTENSION_ICONV) {
                $csv = iconv($dataEncoding, $csvEncoding, $csv);
            } elseif ($extension === self::EXTENSION_MBSTRING) {
                $csv = mb_convert_encoding($csv, $csvEncoding, $dataEncoding);
            }
        }

        //bom must be added after encoding
        if ($this->viewVars['_bom'] && $this->isFirstBom) {
            $csv = $this->getBom($this->viewVars['_csvEncoding']) . $csv;
            $this->isFirstBom = false;
        }

        return $csv;
    }
85547
public function getRowStyle(array $row_data): string
    {
        if ($this->ajax || (isset($row_data[$this->pid_column]) && (string)$row_data[$this->pid_column] === $this->_top_level_id)) {
            return '';
        }

        return 'display: none;';
    }
672947
public function col_scale($row) {
        global $DB;

        if (empty($this->scale)) {
            $dbparams = array('id' => -($this->assignment->get_instance()->grade));
            $this->scale = $DB->get_record('scale', $dbparams);
        }

        if (!empty($this->scale->scale)) {
            return implode("\n", explode(',', $this->scale->scale));
        }
        return '';
    }
907610
protected function displayRenderers($row)
    {
        $offset = $this->offset;

        if ($this->title != '') {
            if ($offset === 0) {
                $offset = 1;
            }

            $th_tag = new SwatHtmlTag('th', $this->getThAttributes());
            $th_tag->colspan = $offset;
            $th_tag->setContent(
                sprintf(Swat::_('%s:'), $this->title),
                $this->title_content_type
            );
            $th_tag->display();
        } elseif ($offset > 0) {
            $td_tag = new SwatHtmlTag('td');
            $td_tag->colspan = $offset;
            $td_tag->setContent('&nbsp;', 'text/xml');
            $td_tag->display();
        }

        $td_tag = new SwatHtmlTag('td', $this->getTdAttributes());
        $td_tag->colspan = $this->view->getXhtmlColspan() - $offset;

        $td_tag->open();
        $this->displayRenderersInternal($row);
        $td_tag->close();
    }
225769
public function renderDataCell($row)
	{
		if ($this->grid->json) {
			$data = $this->grid->dataProvider->data[$row];
			$col = array();
			ob_start();
			$this->renderDataCellContent($row, $data);
			$col['content'] = ob_get_contents();
			ob_end_clean();
			$col['attrs'] = '';
			return $col;

		}

		parent::renderDataCell($row);
	}
441633
protected function renderDataCellContent($row, $data)
    {
        /* @var $am CAuthManager|AuthBehavior */
        $am = Yii::app()->getAuthManager();

        /* @var $controller AssignmentController */
        $controller = $this->grid->getController();

        $assignments = $am->getAuthAssignments($data->{$this->idColumn});
        $permissions = $am->getItemsPermissions(array_keys($assignments));
        foreach ($permissions as $itemPermission) {
            echo $itemPermission['item']->description;
            echo ' <small>' . $controller->getItemTypeText($itemPermission['item']->type, false) . '</small><br />';
        }
    }
775600
protected function renderBodyColumn($td, array $column, Result\Row $row)
    {
        switch ($column[ 'format' ]) {
            default:
                if (is_callable($column[ 'format' ])) {
                    if (is_array($column[ 'field' ])) {
                        foreach ($column[ 'field' ] as $field) {
                            $args[ $field ] = $row->offsetGet($field);
                        }
                        $textContent = call_user_func_array($column[ 'format' ], $args);
                    } elseif ($row->offsetExists($column[ 'field' ])) {
                        $textContent = call_user_func_array($column[ 'format' ],
                            [$row->offsetGet($column[ 'field' ])]);
                    }

                    $td->textContent->push($textContent);

                } elseif (strpos($column[ 'format' ], '{{') !== false) {
                    $textContent = str_replace(['{{', '}}'], '', $column[ 'format' ]);
                    if (is_array($column[ 'field' ])) {
                        foreach ($column[ 'field' ] as $field) {
                            if ($row->offsetExists($field)) {
                                $textContent = str_replace('$' . $field, $row->offsetGet($field), $textContent);
                            } else {
                                $textContent = str_replace('$' . $field, '', $textContent);
                            }
                        }
                    } elseif ($row->offsetExists($column[ 'field' ])) {
                        $textContent = str_replace('$' . $column[ 'field' ], $row->offsetGet($column[ 'field' ]),
                            $textContent);
                    }

                    $td->textContent->push($textContent);
                }
                break;

            case 'checkbox':
                $checkbox = new Ui\Components\Form\Elements\Checkbox([
                    'data-role' => 'table-crud-checkbox',
                ]);
                $td->childNodes->push($checkbox);
                break;

            case 'number':
            case 'txt':
            case 'text':
            case 'price':
            case 'number':
                if ($row->offsetExists($column[ 'field' ])) {
                    $td->textContent->push($row->offsetGet($column[ 'field' ]));
                }
                break;
            case 'date':
                if ($row->offsetExists($column[ 'field' ])) {
                    print_out('date');
                }
                break;

            case 'status':
                if ($row->offsetExists($column[ 'field' ])) {
                    $options = [
                        'PUBLISH'   => 'success',
                        'UNPUBLISH' => 'warning',
                        'DRAFT'     => 'default',
                        'ARCHIVE'   => 'info',
                        'DELETE'    => 'danger',
                    ];

                    $badge = new Ui\Components\Badge(
                        language()->getLine('TABLE_OPTION_' . $row->offsetGet($column[ 'field' ])),
                        $options[ $row->offsetGet($column[ 'field' ]) ]
                    );

                    $td->childNodes->push($badge);
                }

                break;

            case 'actions':

                $buttons = new Ui\Components\Buttons\Group();

                foreach ($this->actions as $key => $action) {

                    if ($action[ 'show' ] === false) {
                        continue;
                    }

                    if ($action[ 'label' ] === true) {
                        $button = $buttons->createButton(language()->getLine('TABLE_BUTTON_' . strtoupper($key)));
                        if ( ! empty($action[ 'icon' ])) {
                            $button->setIcon($action[ 'icon' ]);
                        }
                    } else {
                        $button = $buttons->createButton(new Ui\Contents\Icon($action[ 'icon' ]));
                        $button->attributes->addAttribute('data-toggle', 'tooltip');
                        $button->attributes->addAttribute('title',
                            language()->getLine('TABLE_BUTTON_' . strtoupper($key)));
                    }

                    if (isset($action[ 'attr' ])) {
                        foreach ($action[ 'attr' ] as $name => $value) {
                            $button->attributes->addAttribute($name, $value);
                        }
                    }

                    $button->setContextualClass($action[ 'contextual' ]);
                    $button->smallSize();
                    $button->attributes->addAttribute('data-action', $key);
                }

                $td->childNodes->push($buttons);

                break;
        }
    }
960287
protected function renderDataCellContent($row, $data)
    {
        echo CHtml::link(CHtml::value($data, $this->nameColumn), array('view', 'id' => $data->{$this->idColumn}));
    }
152590
public function getColumnValue(Row $row)
	{
		$value = parent::getColumnValue($row);

		if (!is_numeric($value)) {
			return $value;
		}

		return number_format(
			(float) $value,
			(int) $this->number_format[0],
			(string) $this->number_format[1],
			(string) $this->number_format[2]
		);
	}
706840
public function renderRowDefinition(PHPRtfLite_Table_Row $row)
    {
        $rowIndex = $row->getRowIndex();
        $stream = $this->getRtf()->getWriter();
        $stream->write('\trowd');

        if ($this->_alignment) {
            switch ($this->_alignment) {
                case self::ALIGN_CENTER:
                    $stream->write('\trqc');
                    break;

                case self::ALIGN_RIGHT:
                    $stream->write('\trqr');
                    break;

                default:
                    $stream->write('\trql');
                    break;
            }
        }

        $rowHeight = $row->getHeight();
        if ($rowHeight) {
            $stream->write('\trrh' . PHPRtfLite_Unit::getUnitInTwips($rowHeight));
        }

        if ($this->isPreventPageBreak()) {
            $stream->write('\trkeep ');
        }

        if ($this->isFirstRowHeader() && $rowIndex == 1) {
            $stream->write('\trhdr ');
        }

        if ($this->getLeftPosition() != '') {
            $stream->write('\trleft' . PHPRtfLite_Unit::getUnitInTwips($this->getLeftPosition()) . ' ');
        }

        $width = 0;
        foreach ($this->getColumns() as $columnIndex => $column) {
            $cell = $this->getCell($rowIndex, $columnIndex + 1);

            // render cell definition
            if (!$cell->isHorizontalMerged()) {
                $cell->renderDefinition();

                // cell width
                $width += PHPRtfLite_Unit::getUnitInTwips($cell->getWidth());
                $stream->write('\cellx' . $width);
            }
        }
    }
826552
private function render($row = 0)
    {
        if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
            $rows = ($this->showSummary ? array_merge($this->rows, [$this->getSummary()]) : $this->rows);
            $this->output->reWrite($rows, !$this->showSummary);
        } else {
            $this->output->writeln($this->rows[$row]);
        }
    }
493685
public function prepareData($row)
    {
        if (!$row) {
            return $row;
        }

        if (!is_array($row)) {
            $row = $this->serializer->serialize($row, 'array', SerializationContext::create()->setSerializeNull(true));
        }

        foreach ($row as $key => $value) {
            if ($value instanceof \DateTime) {
                $row[$key] = $value->format(\DateTime::RFC3339);
            } elseif (is_bool($value)) {
                $row[$key] = true === $value ? 1 : 0;
            } elseif (is_array($value) || is_object($value)) {
                $row[$key] = json_encode($value);
            }
        }

        return $row;
    }
909703
public function col_type($row) : string {
        if (\core\task\database_logger::TYPE_SCHEDULED == $row->type) {
            return get_string('task_type:scheduled', 'admin');
        } else {
            return get_string('task_type:adhoc', 'admin');
        }
    }
878917
public function format($row)
    {
        $data = $this->getArray($row);
        $prefix = $this->getHeaderPrefix($data);
        $data = $this->process($data);

        foreach ($data as &$element) {
            if (is_null($element)) {
                $element = $this->csvFormat->getNullValue();
            } else {
                $element = $this->csvFormat->getQuote() . $this->escape($element) . $this->csvFormat->getQuote();
            }
        }

        return $prefix . $this->encode(implode($this->csvFormat->getDelimiter(), $data));
    }
1193519
protected function renderDataCellContent($row, $data)
    {
        if ($this->userId !== null) {
            echo TbHtml::linkButton(
                TbHtml::icon(TbHtml::ICON_REMOVE),
                array(
                    'color' => TbHtml::BUTTON_COLOR_LINK,
                    'size' => TbHtml::BUTTON_SIZE_MINI,
                    'url' => array('revoke', 'itemName' => $data['name'], 'userId' => $this->userId),
                    'rel' => 'tooltip',
                    'title' => Yii::t('AuthModule.main', 'Revoke'),
                )
            );
        }
    }