function markup_eval in Markup 6
Prepare and evaluate of a string of PHP code.
This method is mostly a copy of drupal_eval().
Parameters
string $code:
array $arguments:
Return value
string
1 call to markup_eval()
- markup_widget_process in ./
markup.module - Process the markup_widget element.
File
- ./
markup.module, line 275 - Defines a field type for displaying markup on the node/edit form.
Code
function markup_eval($code, $arguments = array()) {
global $theme_path, $theme_info, $conf;
// Extract the arguments and make available.
extract($arguments);
// Store current theme path.
$old_theme_path = $theme_path;
// Restore theme_path to the theme, as long as drupal_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);
}
// Evaluate the php code
ob_start();
print eval('?>' . $code);
$output = ob_get_clean();
// Recover original theme path.
$theme_path = $old_theme_path;
return $output;
}