function 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 with IDs, handlers sanitized.
File
-
includes/
view.inc, line 1979
Class
- view
- An object to contain all of the data to generate a view.
Code
public function export($indent = '') {
$this->init_display();
$this->init_query();
$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 .= "\n" . $indent . "/* Display: {$display->display_title} */\n";
$output .= $indent . '$handler = $view->new_display(' . ctools_var_export($display->display_plugin, $indent) . ', ' . ctools_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;
}
$output .= $display->handler
->export_options($indent, '$handler->options');
}
// Give the localization system a chance to export translatables to code.
if ($this->init_localization()) {
$this->export_locale_strings('export');
$translatables = $this->localization_plugin
->export_render($indent);
if (!empty($translatables)) {
$output .= $translatables;
}
}
return $output;
}