views_php_handler_area.inc in Views PHP 6
File
plugins/views/views_php_handler_area.inc
View source
<?php
class views_php_handler_area extends views_handler_area {
function option_definition() {
$options = parent::option_definition();
$options['php_output'] = array(
'default' => "<h4>Example PHP code</h4>\n<p>Time: <?php print date('H:i', time());?></p>\n",
);
return $options;
}
function options_form(&$form, &$form_state) {
parent::options_form($form, $form_state);
$form += views_php_form_element($this, FALSE, array(
'php_output',
t('Output code'),
t('Code to construct the output of this area.'),
TRUE,
), array(
'$view',
'$handler',
'$results',
));
}
function render($empty = FALSE) {
if ((!$empty || !empty($this->options['empty'])) && !empty($this->options['php_output'])) {
$function = create_function('$view, $handler, $results', ' ?>' . $this->options['php_output'] . '<?php ');
ob_start();
$function($this->view, $this, $this->view->result);
return ob_get_clean();
}
return '';
}
}