function views_load_display_records

Export callback to load the view subrecords, which are the displays.

1 string reference to 'views_load_display_records'
views_schema_6000 in ./views.install
Views 2's initial schema.

File

./views.module, line 1770

Code

function views_load_display_records(&$views) {
    // Get vids from the views.
    $names = array();
    foreach ($views as $view) {
        if (empty($view->display)) {
            $names[$view->vid] = $view->name;
        }
    }
    if (empty($names)) {
        return;
    }
    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;
            }
        }
    }
}