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;
$items['admin/build/views'] = $base + array(
'title' => t('Views'),
'page callback' => 'views_ui_list_views',
'description' => t('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' => t('List'),
'page callback' => 'views_ui_list_views',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => '-1'
);
'title' => t('Add'),
'page callback' => 'views_ui_add_page',
'type' => MENU_LOCAL_TASK
);
'title' => t('Import'),
'page callback' => 'drupal_get_form',
'page arguments' => array('views_ui_import_page'),
'type' => MENU_LOCAL_TASK
);
'title' => t('Tools'),
'page callback' => 'views_ui_admin_tools',
'type' => MENU_LOCAL_TASK
);
$items['admin/build/views/tools/basic'] = $base + array(
'title' => t('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' => t('Convert'),
'description' => t('Convert stored Views 1 views.'),
'page callback' => 'views_ui_admin_convert',
'type' => MENU_LOCAL_TASK,
$items['admin/build/views1/delete'] = $convert + array(
'title' => t('Delete view'),
'page callback' => 'drupal_get_form',
'page arguments' => array('views_ui_delete1_confirm', 4),
$items['admin/build/views1/convert'] = $convert + array(
'title' => t('Convert view'),
'page callback' => 'views_ui_convert1',
'page arguments' => array(4),
$items['admin/build/views/delete/%views_ui_cache'] = $callback + array(
'title' => t('Delete view'),
'page callback' => 'drupal_get_form',
'page arguments' => array('views_ui_delete_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),
);
$items['admin/build/views/clone/%views_ui_cache'] = $callback + array(
'page callback' => 'views_ui_clone_page',
'page arguments' => array(4),
);
$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' => t('Edit'),
'page callback' => 'views_ui_edit_page',
'page arguments' => array(4),
'type' => MENU_LOCAL_TASK
);
$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(
'page arguments' => array(3, 5),
);
$items['admin/build/views/%views_ui_js/remove-display/%views_ui_cache'] = $callback + array(
'page callback' => 'views_ui_remove_display',
'page arguments' => array(3, 5),
$items['admin/build/views/%views_ui_js/rearrange/%views_ui_cache'] = $callback + array(
'page callback' => 'views_ui_rearrange_type',
Earl Miles
committed
$items['admin/build/views/%views_ui_js/add-item/%views_ui_cache'] = $callback + array(
'page callback' => 'views_ui_add_item',
'page arguments' => array(3, 5),
);
$items['admin/build/views/%views_ui_js/config-item/%views_ui_cache'] = $callback + array(
'page callback' => 'views_ui_config_item',
'page arguments' => array(3, 5),
);
// display specific parameters
$items['admin/build/views/%views_ui_js/display/%views_ui_cache'] = $callback + array(
'page callback' => 'views_ui_edit_display',
'page arguments' => array(3, 5),
);
// Special style plugin stuff for arguments
$items['admin/build/views/%views_ui_js/change-style/%views_ui_cache'] = $callback + array(
'page callback' => 'views_ui_change_style',
'page arguments' => array(3, 5),
);
$items['admin/build/views/%views_ui_js/config-style/%views_ui_cache'] = $callback + array(
'page callback' => 'views_ui_config_style',
'page arguments' => array(3, 5),
);
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),
);
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_ui_perm() {
return array('administer views');
}
Earl Miles
committed
$path = drupal_get_path('module', 'views');
include_once "$path/includes/admin.inc";
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(
'arguments' => array('type' => NULL, 'view' => NULL, 'display' => NULL),
'template' => 'views-ui-edit-item',
'path' => "$path/theme",
),
Earl Miles
committed
'arguments' => array('form' => NULL),
Earl Miles
committed
'arguments' => array('tabs' => NULL),
'file' => '/includes/tabs.inc',
),
'views_tab' => array(
Earl Miles
committed
'arguments' => array('body' => NULL),
'views_ui_style_plugin_table' => array(
'arguments' => array('form' => NULL),
),
/**
* 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);
$v = views_get_view($name);
if ($v) {
$view = drupal_clone($v);
}
}
}
/**
* 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;
}
/**
* Check to see if the incoming menu item is js capable or not.
*/
function views_ui_js_load($js) {
if ($js == 'ajax') {
return TRUE;
}
return 0;
}
* Specialized cache function to add a flag to our view, include an appropriate
* include, and cache more easily.
$view->changed = TRUE; // let any future object know that this view has changed.
Earl Miles
committed
// 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);
}