static function view::load_views

cis7 view.inc static view::load_views()
cle7 view.inc static view::load_views()
elmsmedia7 view.inc static view::load_views()
icor7 view.inc static view::load_views()
meedjum_blog7 view.inc static view::load_views()
mooc7 view.inc static view::load_views()

Static factory method to load a list of views based upon a $where clause.

Although this method could be implemented to simply iterate over views::load(), that would be very slow. Buiding the views externally from unified queries is much faster.

File

sites/all/modules/ulmus/views/includes/view.inc, line 1761
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

static function load_views() {
  $result = db_query("SELECT DISTINCT v.* FROM {views_view} v");
  $views = array();

  // Load all the views.
  foreach ($result as $data) {
    $view = new view;
    $view->load_row($data);
    $view->loaded = TRUE;
    $view->type = t('Normal');
    $views[$view->name] = $view;
    $names[$view->vid] = $view->name;
  }

  // Stop if we didn't get any views.
  if (!$views) {
    return array();
  }

  // Now load all the subtables:
  foreach (view::db_objects() as $key) {
    $object_name = "views_$key";
    $result = db_query("SELECT * FROM {{$object_name}} WHERE vid IN (:vids) ORDER BY vid, position", array(':vids' => array_keys($names)));

    foreach ($result as $data) {
      $object = new $object_name(FALSE);
      $object->load_row($data);

      // Because it can get complicated with this much indirection,
      // make a shortcut reference.
      $location = &$views[$names[$object->vid]]->$key;

      // If we have a basic id field, load the item onto the view based on
      // this ID, otherwise push it on.
      if (!empty($object->id)) {
        $location[$object->id] = $object;
      }
      else {
        $location[] = $object;
      }
    }
  }
  return $views;
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.