function _views_load_view in Views (for Drupal 7) 5
Load a view from the database. (deprecated; use views_load_view in favor of this function).
4 calls to _views_load_view()
- views_get_view in ./
views.module - This function loads a view by name or vid; if not found in db, it looks for a default view by that name.
- views_load_view in ./
views.module - Load a view from the database -- public version of the function.
- views_ui_admin_delete_confirm in ./
views_ui.module - views_ui_admin_edit_page in ./
views_ui.module
File
- ./
views.module, line 910
Code
function _views_load_view($arg) {
static $cache = array();
$which = is_numeric($arg) ? 'vid' : 'name';
if (isset($cache[$which][$arg])) {
return $cache[$which][$arg];
}
$where = is_numeric($arg) ? "v.vid = %d" : "v.name = '%s'";
$view = db_fetch_object(db_query("SELECT v.* FROM {view_view} v WHERE {$where}", $arg));
if (!$view->name) {
return NULL;
}
$view->access = $view->access ? explode(', ', $view->access) : array();
// load the sorting criteria too.
$result = db_query("SELECT * FROM {view_sort} vs WHERE vid = {$view->vid} ORDER BY position ASC");
$view->sort = array();
while ($sort = db_fetch_array($result)) {
if (substr($sort['field'], 0, 2) == 'n.') {
$sort['field'] = 'node' . substr($sort['field'], 1);
}
$sort['id'] = $sort['field'];
$view->sort[] = $sort;
}
$result = db_query("SELECT * FROM {view_argument} WHERE vid = {$view->vid} ORDER BY position ASC");
$view->argument = array();
while ($arg = db_fetch_array($result)) {
$arg['id'] = $arg['type'];
$view->argument[] = $arg;
}
$result = db_query("SELECT * FROM {view_tablefield} WHERE vid = {$view->vid} ORDER BY position ASC");
$view->field = array();
while ($arg = db_fetch_array($result)) {
if ($arg['tablename'] == 'n') {
$arg['tablename'] = 'node';
}
$arg['id'] = $arg['fullname'] = "{$arg['tablename']}.{$arg['field']}";
$arg['queryname'] = "{$arg['tablename']}_{$arg['field']}";
$view->field[] = $arg;
}
$result = db_query("SELECT * FROM {view_filter} WHERE vid = {$view->vid} ORDER BY position ASC");
views_load_cache();
$filters = _views_get_filters();
$view->filter = array();
while ($filter = db_fetch_array($result)) {
if (substr($filter['field'], 0, 2) == 'n.') {
$filter['field'] = 'node' . substr($filter['field'], 1);
}
if ($filter['operator'] == 'AND' || $filter['operator'] == 'OR' || $filter['operator'] == 'NOR' || $filters[$filter['field']]['value-type'] == 'array') {
if ($filter['value'] !== NULL && $filter['value'] !== '') {
$filter['value'] = explode(',', $filter['value']);
}
else {
$filter['value'] = array();
}
}
$filter['id'] = $filter['field'];
$view->filter[] = $filter;
}
$result = db_query("SELECT * FROM {view_exposed_filter} WHERE vid = {$view->vid} ORDER BY position ASC");
$view->exposed_filter = array();
while ($arg = db_fetch_array($result)) {
$arg['id'] = $arg['field'];
$view->exposed_filter[] = $arg;
}
$cache['vid'][$view->vid] = $view;
$cache['name'][$view->name] = $view;
return $view;
}