Same name and namespace in other branches
  1. 6.x-3.x includes/view.inc \views_db_object::export_row()

Export a loaded row.

Might be an argument, field or the view itself to PHP code.

Parameters

string $identifier: The variable to assign the PHP code for this object to.

int $indent: An optional indentation for prettifying nested code.

1 call to views_db_object::export_row()
view::export in includes/view.inc
Export a view as PHP code.

File

includes/view.inc, line 2340
views_objects Objects that represent a View or part of a view

Class

views_db_object

Code

public function export_row($identifier = NULL, $indent = '') {
  ctools_include('export');
  if (!$identifier) {
    $identifier = $this->db_table;
  }
  $schema = drupal_get_schema($this->db_table);
  $output = $indent . '$' . $identifier . ' = new ' . get_class($this) . "();\n";

  // Go through our schema and build correlations.
  foreach ($schema['fields'] as $field => $info) {
    if (!empty($info['no export'])) {
      continue;
    }
    if (!isset($this->{$field})) {
      if (isset($info['default'])) {
        $this->{$field} = $info['default'];
      }
      else {
        $this->{$field} = '';
      }

      // Serialized defaults must be set as serialized.
      if (isset($info['serialize'])) {
        $this->{$field} = unserialize($this->{$field});
      }
    }
    $value = $this->{$field};
    if ($info['type'] == 'int') {
      if (isset($info['size']) && $info['size'] == 'tiny') {
        $value = (bool) $value;
      }
      else {
        $value = (int) $value;
      }
    }
    $output .= $indent . '$' . $identifier . '->' . $field . ' = ' . ctools_var_export($value, $indent) . ";\n";
  }
  return $output;
}