1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/limesurvey_ynh.git synced 2024-09-03 19:36:32 +02:00
limesurvey_ynh/sources/application/extensions/CallbackColumn.php

42 lines
991 B
PHP
Raw Normal View History

<?php
Yii::import('zii.widgets.grid.CGridColumn');
class CallbackColumn extends CGridColumn
{
public $label;
public $url;
public function renderDataCellContent($row, $data)
{
if (isset($this->label) && is_callable($this->label))
{
$text = call_user_func($this->label, $data);
}
else
{
$text = $data[$this->label];
}
// Create link.
if (isset($this->url))
{
if (is_callable($this->url))
{
$url = call_user_func($this->url, $data);
}
else
{
$url = $this->url;
}
echo CHtml::link($text, $url);
}
else
{
echo $text;
}
}
}
?>