function views_block in Views (for Drupal 7) 5
Same name and namespace in other branches
- 6.3 views.module \views_block()
- 6.2 views.module \views_block()
Implementation of hook_block()
File
- ./
views.module, line 321
Code
function views_block($op = 'list', $delta = 0) {
$block = array();
if ($op == 'list') {
views_load_cache();
// Grab views from the database and provide them as blocks.
$result = db_query("SELECT vid, block_title, page_title, name FROM {view_view} WHERE block = 1");
while ($view = db_fetch_object($result)) {
$block[$view->name]['info'] = filter_xss_admin(views_get_title($view, 'block-info'));
}
$default_views = _views_get_default_views();
$views_status = variable_get('views_defaults', array());
foreach ($default_views as $name => $view) {
if (!isset($block[$name]) && $view->block && ($views_status[$name] == 'enabled' || !$view->disabled && $views_status[$name] != 'disabled')) {
$title = filter_xss_admin(views_get_title($view, 'block'));
$block[$name]['info'] = empty($title) ? $name : $title;
}
}
return $block;
}
else {
if ($op == 'view') {
return views_view_block($delta);
}
}
}