function ds_eval in Display Suite 6.3
Same name and namespace in other branches
- 6 ds.module \ds_eval()
- 6.2 ds.module \ds_eval()
Wrapper function around PHP eval(). We don't use drupal_eval because custom fields might need properties from the current object.
Parameters
string $code The code to evaluate from the custom field.:
stdClass $object An object to use for evaluation.:
Return value
string $output The output from eval.
1 call to ds_eval()
- theme_ds_eval_code in theme/
theme.inc - Evaluate custom code.
File
- ./
ds.module, line 693
Code
function ds_eval($code, $object) {
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_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;
}