function view::export in Views (for Drupal 7) 6.2
Same name and namespace in other branches
- 6.3 includes/view.inc \view::export()
- 7.3 includes/view.inc \view::export()
Export a view as PHP code.
1 call to view::export()
- view::copy in includes/
view.inc - Make a copy of this view that has been sanitized of all database IDs and handlers and other stuff.
File
Class
- view
- An object to contain all of the data to generate a view, plus the member functions to build the view query, execute the query and render the output.
Code
function export($indent = '') {
$this
->init_display();
$output = '';
$output .= $this
->export_row('view', $indent);
// Set the API version
$output .= $indent . '$view->api_version = \'' . views_api_version() . "';\n";
$output .= $indent . '$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */' . "\n";
foreach ($this->display as $id => $display) {
$output .= $indent . '$handler = $view->new_display(' . views_var_export($display->display_plugin, $indent) . ', ' . views_var_export($display->display_title, $indent) . ', \'' . $id . "');\n";
if (empty($display->handler)) {
// @todo -- probably need a method of exporting broken displays as
// they may simply be broken because a module is not installed. That
// does not invalidate the display.
continue;
}
foreach ($display->handler
->option_definition() as $option => $definition) {
// Special handling for some items
switch ($option) {
case 'defaults':
// skip these
break;
default:
if (!$display->handler
->is_defaulted($option)) {
$value = $display->handler
->get_option($option);
if ($id == 'default') {
$default = isset($definition['default']) ? $definition['default'] : NULL;
}
else {
$default = $this->display['default']->handler
->get_option($option);
}
if ($value !== $default) {
$output .= $indent . '$handler->override_option(\'' . $option . '\', ' . views_var_export($value, $indent) . ");\n";
}
}
}
}
}
return $output;
}