Newer
Older
<?php
// $Id$
/**
* @file views_ui.module
* Provide structure for the administrative interface to Views.
*/
function views_ui_menu() {
$items = array();
'access callback' => 'user_access',
'access arguments' => array('administer views'),
$callback = $base + array('type' => MENU_CALLBACK);
$convert = array('file' => 'includes/convert.inc') + $base;
'title' => 'Views',
'description' => 'Views are customized lists of content on your system; they are highly configurable and give you control over how lists of content are presented.',
'type' => MENU_NORMAL_ITEM
);
'title' => 'List',
'page callback' => 'views_ui_list_views',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => '-1'
);
'title' => 'Add',
'page callback' => 'views_ui_add_page',
'type' => MENU_LOCAL_TASK
);
'title' => 'Import',
'page callback' => 'drupal_get_form',
'page arguments' => array('views_ui_import_page'),
'type' => MENU_LOCAL_TASK
);
'title' => 'Tools',
'page callback' => 'drupal_get_form',
'page arguments' => array('views_ui_admin_tools'),
'type' => MENU_LOCAL_TASK
);
$items['admin/build/views/tools/basic'] = $base + array(
'title' => 'Basic',
'page callback' => 'drupal_get_form',
'page arguments' => array('views_ui_admin_tools'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items['admin/build/views/tools/convert'] = $convert + array(
'title' => 'Convert',
'description' => 'Convert stored Views 1 views.',
'page callback' => 'views_ui_admin_convert',
'type' => MENU_LOCAL_TASK,
$items['admin/build/views1/delete'] = $convert + array(
'title' => 'Delete view',
'page callback' => 'drupal_get_form',
'page arguments' => array('views_ui_delete1_confirm', 4),
$items['admin/build/views1/convert'] = $convert + array(
'title' => 'Convert view',
'page callback' => 'views_ui_convert1',
'page arguments' => array(4),
$items['admin/build/views/delete/%views_ui_cache'] = $callback + array(
'title' => 'Delete view',
'page callback' => 'drupal_get_form',
'page arguments' => array('views_ui_delete_confirm', 4),
);
$items['admin/build/views/break-lock/%views_ui_cache'] = $callback + array(
'title' => 'Delete view',
'page callback' => 'drupal_get_form',
'page arguments' => array('views_ui_break_lock_confirm', 4),
);
$items['admin/build/views/export/%views_ui_cache'] = $callback + array(
'page callback' => 'drupal_get_form',
'page arguments' => array('views_ui_export_page', 4),
'type' => MENU_LOCAL_TASK
);
$items['admin/build/views/clone/%views_ui_cache'] = $callback + array(
'page callback' => 'views_ui_clone_page',
'page arguments' => array(4),
'type' => MENU_LOCAL_TASK
$items['admin/build/views/enable/%views_ui_default'] = $callback + array(
'page callback' => 'views_ui_enable_page',
'page arguments' => array(4),
);
$items['admin/build/views/disable/%views_ui_default'] = $callback + array(
'page callback' => 'views_ui_disable_page',
'page arguments' => array(4),
// Many line items for editing a view.
$items['admin/build/views/edit/%views_ui_cache'] = $base + array(
'title' => 'Edit',
'page callback' => 'views_ui_edit_page',
'page arguments' => array(4),
'type' => MENU_LOCAL_TASK
);
$items['admin/build/views/%views_ui_js/analyze/%views_ui_cache'] = $callback + array(
'page callback' => 'views_ui_analyze_view',
'page arguments' => array(3, 5),
);
$items['admin/build/views/%views_ui_js/details/%views_ui_cache'] = $callback + array(
$items['admin/build/views/%views_ui_js/add-display/%views_ui_cache'] = $callback + array(
Earl Miles
committed
// Live preview
$items['admin/build/views/%views_ui_js/preview/%views_ui_cache'] = $callback + array(
'page callback' => 'views_ui_preview',
'page arguments' => array(3, 5),
);
Earl Miles
committed
$items['admin/views/ajax/autocomplete/tag'] = $callback + array(
'page callback' => 'views_ui_autocomplete_tag',
);
Earl Miles
committed
// Generic ajax callback
// display specific parameters
$items['admin/build/views/%views_ui_js/%/%views_ui_cache'] = $callback + array(
'page callback' => 'views_ui_ajax_form',
'page arguments' => array(3, 4, 5),
);
return $items;
}
function views_ui_help($path, $arg) {
switch ($path) {
case 'admin/build/views/tools/convert':
return '<p>' . t('The converter will make a best-effort attempt to convert a Views 1 view to Views 2. This conversion is not reliable; you will very likely have to make adjustments to your view to get it to match. You can import Views 1 views through the normal Import tab.') . '</p>';
/*
* Implementation of hook_perm()
*/
function views_perm() {
return array('administer views');
}
Earl Miles
committed
$path = drupal_get_path('module', 'views');
require_once "./$path/includes/admin.inc";
Earl Miles
committed
Earl Miles
committed
'arguments' => array('view' => NULL),
'template' => 'views-ui-edit-view',
'path' => "$path/theme",
'views_ui_edit_tab' => array(
'arguments' => array('view' => NULL, 'display' => NULL),
'template' => 'views-ui-edit-tab',
'path' => "$path/theme",
),
'views_ui_edit_item' => array(
Earl Miles
committed
'arguments' => array('type' => NULL, 'view' => NULL, 'display' => NULL, 'no_fields' => FALSE),
'template' => 'views-ui-edit-item',
'path' => "$path/theme",
),
Earl Miles
committed
'arguments' => array('form' => NULL),
// list views
'views_ui_list_views' => array(
'template' => 'views-ui-list-views',
'path' => "$path/theme",
),
'views_ui_list_views_form' => array(
'file' => '/includes/admin.inc',
'arguments' => array('form' => NULL),
),
// tab themes
Earl Miles
committed
'arguments' => array('tabs' => NULL),
'file' => '/includes/tabs.inc',
),
'views_tab' => array(
Earl Miles
committed
'arguments' => array('body' => NULL),
// On behalf of a plugin
'views_ui_style_plugin_table' => array(
'arguments' => array('form' => NULL),
Earl Miles
committed
'file' => 'includes/plugins.inc',
/**
* Specialized menu callback to load a view either out of the cache or just
* load it.
*/
function views_ui_cache_load($name) {
views_include('cache');
views_include('view');
$view = views_object_cache_get('view', $name);
Earl Miles
committed
$view = views_get_view($name);
if (!empty($view)) {
// Check to see if someone else is already editing this view.
global $user;
$view->locked = db_fetch_object(db_query("SELECT s.uid, v.updated FROM {views_object_cache} v INNER JOIN {sessions} s ON v.sid = s.sid WHERE s.sid != '%s' and v.name = '%s' and v.obj = 'view' ORDER BY v.updated ASC", session_id(), $view->name));
}
}
function views_ui_check_lock($view) {
}
/**
* Specialized cache function to add a flag to our view, include an appropriate
* include, and cache more easily.
*/
function views_ui_cache_set(&$view) {
if (!empty($view->locked)) {
drupal_set_message('Changes cannot be made to a locked view.', 'error');
return;
}
views_include('cache');
$view->changed = TRUE; // let any future object know that this view has changed.
// Unset handlers; we don't want to write these into the cache
unset($view->display_handler);
unset($view->current_display);
unset($view->default_display);
foreach (array_keys($view->display) as $id) {
unset($view->display[$id]->handler);
unset($view->display[$id]->default_display);
}
views_object_cache_set('view', $view->name, $view);
}
/**
* Specialized menu callback to load a view that is only a default
* view.
*/
function views_ui_default_load($name) {
$view = views_get_view($name);
if ($view->type == t('Default')) {
return $view;
}
return FALSE;
}