function ds_format_php_eval in Display Suite 7.2
Wrapper function around PHP eval(). We don't use php_eval from the PHP module because custom fields might need properties from the current entity.
Parameters
$code: The code to evaluate from the custom field.
$object: An object to use for evaluation.
Return value
$output The output from eval.
1 call to ds_format_php_eval()
- ds_render_code_field in ./
ds.module - Render a code field.
1 string reference to 'ds_format_php_eval'
- ds_format_filter_info in modules/
ds_format/ ds_format.module - Implements hook_filter_info().
File
- modules/
ds_format/ ds_format.module, line 49 - Display Suite Format
Code
function ds_format_php_eval($code, $entity, $build = array()) {
global $theme_path, $theme_info, $conf;
// Store current theme path.
$old_theme_path = $theme_path;
// Restore theme_path to the theme, as long as ds_php_eval() executes,
// so code evaluted will not see the caller module as the current theme.
// If theme info is not initialized get the path from theme_default.
if (!isset($theme_info)) {
$theme_path = drupal_get_path('theme', $conf['theme_default']);
}
else {
$theme_path = dirname($theme_info->filename);
}
ob_start();
print eval('?>' . $code);
$output = ob_get_contents();
ob_end_clean();
// Recover original theme path.
$theme_path = $old_theme_path;
return $output;
}