function view::export

3.x view.inc view::export($indent = '')
2.x view.inc view::export($indent = '')

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

includes/view.inc, line 1895
Provides the view object type and associated methods.

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();
  $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;
}