function views_var_export in Views (for Drupal 7) 6.3
Same name and namespace in other branches
- 6.2 views.module \views_var_export()
- 7.3 views.module \views_var_export()
Export a field.
4 calls to views_var_export()
- view::export in includes/
view.inc - Export a view as PHP code.
- views_db_object::export_row in includes/
view.inc - Export a loaded row, such as an argument, field or the view itself to PHP code.
- views_handler_filter_in_operator::validate in handlers/
views_handler_filter_in_operator.inc - Validates the handler against the complete View.
- views_object::export_option in includes/
base.inc
File
- ./
views.module, line 1653 - Primarily Drupal hooks and global API functions to manipulate views.
Code
function views_var_export($var, $prefix = '', $init = TRUE) {
if (is_array($var)) {
if (empty($var)) {
$output = 'array()';
}
else {
$output = "array(\n";
foreach ($var as $key => $value) {
$output .= " " . views_var_export($key, '', FALSE) . " => " . views_var_export($value, ' ', FALSE) . ",\n";
}
$output .= ')';
}
}
else {
if (is_bool($var)) {
$output = $var ? 'TRUE' : 'FALSE';
}
else {
if (is_string($var) && strpos($var, "\n") !== FALSE) {
// Replace line breaks in strings with a token for replacement
// at the very end. This protects multi-line strings from
// unintentional indentation.
$var = str_replace("\n", "***BREAK***", $var);
$output = var_export($var, TRUE);
}
else {
$output = var_export($var, TRUE);
}
}
}
if ($prefix) {
$output = str_replace("\n", "\n{$prefix}", $output);
}
if ($init) {
$output = str_replace("***BREAK***", "\n", $output);
}
return $output;
}