function custom_formatters_engine_php_export in Custom Formatters 7.2
Export callback for Custom Formatters PHP engine.
Parameters
object $item: The Custom formatter object.
string $module: The user defined module name.
Return value
string The exported formatter value.
1 string reference to 'custom_formatters_engine_php_export'
- custom_formatters_custom_formatters_engine_info in includes/
custom_formatters.inc - Implements hook_custom_formatters_engine().
File
- engines/
php.inc, line 150 - PHP engine for Custom Formatters modules.
Code
function custom_formatters_engine_php_export($item, $module) {
$formatter = clone $item;
if (isset($formatter->fapi)) {
ob_start();
eval($formatter->fapi);
ob_get_clean();
if (isset($form)) {
$formatter->form = $form;
}
}
// Modify #default_value for hook_field_formatter_settings_form() export.
if (module_exists('form_builder') && function_exists('form_builder_examples_export_recurse')) {
include drupal_get_path('module', 'form_builder') . '/examples/form_builder_examples.module';
foreach (element_children($form) as $key) {
if (isset($form[$key]['#default_value'])) {
unset($form[$key]['#default_value']);
}
$form[$key]['#default_value'] = "[default-value::{$key}]";
}
$formatter->fapi = form_builder_examples_export_recurse($form);
preg_match_all('/\'\\[default-value::(.*)?\\]\'/', $formatter->fapi, $matches, PREG_SET_ORDER);
foreach ($matches as $match) {
$formatter->fapi = str_replace($match[0], "\$settings['{$match[1]}']", $formatter->fapi);
}
}
return theme('custom_formatters_php_export', array(
'item' => $formatter,
'module' => $module,
));
}