4 * @file views_ui.module
5 * Provide structure for the administrative interface to Views.
8 function views_ui_menu() {
11 // Minor code reduction technique
13 'access callback' => 'user_access',
14 'access arguments' => array('administer views'),
15 'file' => 'includes/admin.inc',
18 $callback = $base + array('type' => MENU_CALLBACK
);
20 $convert = array('file' => 'includes/convert.inc') + $base;
22 $items['admin/build/views'] = $base + array(
24 'page callback' => 'views_ui_list_views',
25 '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.',
26 'type' => MENU_NORMAL_ITEM
28 $items['admin/build/views/list'] = $base + array(
30 'page callback' => 'views_ui_list_views',
31 'type' => MENU_DEFAULT_LOCAL_TASK
,
34 $items['admin/build/views/add'] = $base + array(
36 'page callback' => 'views_ui_add_page',
37 'type' => MENU_LOCAL_TASK
39 $items['admin/build/views/import'] = $base + array(
41 'page callback' => 'drupal_get_form',
42 'page arguments' => array('views_ui_import_page'),
43 'type' => MENU_LOCAL_TASK
45 $items['admin/build/views/tools'] = $base + array(
47 'page callback' => 'drupal_get_form',
48 'page arguments' => array('views_ui_admin_tools'),
49 'type' => MENU_LOCAL_TASK
51 $items['admin/build/views/tools/basic'] = $base + array(
53 'page callback' => 'drupal_get_form',
54 'page arguments' => array('views_ui_admin_tools'),
55 'type' => MENU_DEFAULT_LOCAL_TASK
,
59 $items['admin/build/views/tools/convert'] = $convert + array(
61 'description' => 'Convert stored Views 1 views.',
62 'page callback' => 'views_ui_admin_convert',
63 'type' => MENU_LOCAL_TASK
,
66 $items['admin/build/views1/delete'] = $convert + array(
67 'title' => 'Delete view',
68 'page callback' => 'drupal_get_form',
69 'page arguments' => array('views_ui_delete1_confirm', 4),
70 'type' => MENU_CALLBACK
,
72 $items['admin/build/views1/convert'] = $convert + array(
73 'title' => 'Convert view',
74 'page callback' => 'views_ui_convert1',
75 'page arguments' => array(4),
76 'type' => MENU_CALLBACK
,
79 $items['admin/build/views/delete/%views_ui_cache'] = $callback + array(
80 'title' => 'Delete view',
81 'page callback' => 'drupal_get_form',
82 'page arguments' => array('views_ui_delete_confirm', 4),
84 $items['admin/build/views/break-lock/%views_ui_cache'] = $callback + array(
85 'title' => 'Delete view',
86 'page callback' => 'drupal_get_form',
87 'page arguments' => array('views_ui_break_lock_confirm', 4),
89 $items['admin/build/views/export/%views_ui_cache'] = $callback + array(
90 'page callback' => 'drupal_get_form',
91 'page arguments' => array('views_ui_export_page', 4),
93 $items['admin/build/views/clone/%views_ui_cache'] = $callback + array(
94 'page callback' => 'views_ui_clone_page',
95 'page arguments' => array(4),
97 $items['admin/build/views/enable/%views_ui_default'] = $callback + array(
98 'page callback' => 'views_ui_enable_page',
99 'page arguments' => array(4),
101 $items['admin/build/views/disable/%views_ui_default'] = $callback + array(
102 'page callback' => 'views_ui_disable_page',
103 'page arguments' => array(4),
106 // Many line items for editing a view.
107 $items['admin/build/views/edit/%views_ui_cache'] = $base + array(
109 'page callback' => 'views_ui_edit_page',
110 'page arguments' => array(4),
111 'type' => MENU_LOCAL_TASK
113 // lots of little edit form pieces.
114 $items['admin/build/views/%views_ui_js/analyze/%views_ui_cache'] = $callback + array(
115 'page callback' => 'views_ui_analyze_view',
116 'page arguments' => array(3, 5),
118 $items['admin/build/views/%views_ui_js/details/%views_ui_cache'] = $callback + array(
119 'page callback' => 'views_ui_edit_details',
120 'page arguments' => array(3, 5),
122 $items['admin/build/views/%views_ui_js/add-display/%views_ui_cache'] = $callback + array(
123 'page callback' => 'views_ui_add_display',
124 'page arguments' => array(3, 5),
126 $items['admin/build/views/%views_ui_js/remove-display/%views_ui_cache'] = $callback + array(
127 'page callback' => 'views_ui_remove_display',
128 'page arguments' => array(3, 5),
130 $items['admin/build/views/%views_ui_js/rearrange/%views_ui_cache'] = $callback + array(
131 'page callback' => 'views_ui_rearrange_type',
132 'page arguments' => array(3, 5),
134 $items['admin/build/views/%views_ui_js/config-type/%views_ui_cache'] = $callback + array(
135 'page callback' => 'views_ui_config_type',
136 'page arguments' => array(3, 5),
138 $items['admin/build/views/%views_ui_js/add-item/%views_ui_cache'] = $callback + array(
139 'page callback' => 'views_ui_add_item',
140 'page arguments' => array(3, 5),
142 $items['admin/build/views/%views_ui_js/config-item/%views_ui_cache'] = $callback + array(
143 'page callback' => 'views_ui_config_item',
144 'page arguments' => array(3, 5),
146 $items['admin/build/views/%views_ui_js/config-item-extra/%views_ui_cache'] = $callback + array(
147 'page callback' => 'views_ui_config_item_extra',
148 'page arguments' => array(3, 5),
150 // display specific parameters
151 $items['admin/build/views/%views_ui_js/display/%views_ui_cache'] = $callback + array(
152 'page callback' => 'views_ui_edit_display',
153 'page arguments' => array(3, 5),
155 // Special style plugin stuff for arguments
156 $items['admin/build/views/%views_ui_js/change-style/%views_ui_cache'] = $callback + array(
157 'page callback' => 'views_ui_change_style',
158 'page arguments' => array(3, 5),
160 $items['admin/build/views/%views_ui_js/config-style/%views_ui_cache'] = $callback + array(
161 'page callback' => 'views_ui_config_style',
162 'page arguments' => array(3, 5),
165 $items['admin/build/views/%views_ui_js/preview/%views_ui_cache'] = $callback + array(
166 'page callback' => 'views_ui_preview',
167 'page arguments' => array(3, 5),
170 // autocompletes for handlers and such
171 $items['admin/build/views/autocomplete/user'] = $callback + array(
172 'page callback' => 'views_ui_autocomplete_user',
179 function views_ui_help($path, $arg) {
181 case
'admin/build/views/tools/convert':
182 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>';
187 * Implementation of hook_perm()
189 function views_ui_perm() {
190 return array('administer views');
193 function views_ui_theme() {
194 $path = drupal_get_path('module', 'views');
195 require_once
"./$path/includes/admin.inc";
198 'views_ui_edit_view' => array(
199 'arguments' => array('view' => NULL
),
200 'template' => 'views-ui-edit-view',
201 'path' => "$path/theme",
203 'views_ui_edit_tab' => array(
204 'arguments' => array('view' => NULL
, 'display' => NULL
),
205 'template' => 'views-ui-edit-tab',
206 'path' => "$path/theme",
208 'views_ui_edit_item' => array(
209 'arguments' => array('type' => NULL
, 'view' => NULL
, 'display' => NULL
),
210 'template' => 'views-ui-edit-item',
211 'path' => "$path/theme",
213 'views_ui_rearrange_form' => array(
214 'arguments' => array('form' => NULL
),
215 'file' => '/includes/admin.inc',
217 'views_tabset' => array(
218 'arguments' => array('tabs' => NULL
),
219 'file' => '/includes/tabs.inc',
221 'views_tab' => array(
222 'arguments' => array('body' => NULL
),
223 'file' => '/includes/tabs.inc',
226 'views_ui_style_plugin_table' => array(
227 'arguments' => array('form' => NULL
),
234 * Specialized menu callback to load a view either out of the cache or just
237 function views_ui_cache_load($name) {
238 views_include('cache');
239 views_include('view');
240 $view = views_object_cache_get('view', $name);
243 $v = views_get_view($name);
245 $view = drupal_clone($v);
249 // Check to see if someone else is already editing this view.
251 $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.uid != %d and v.name = '%s' and v.obj = 'view' ORDER BY v.updated ASC", $user->uid
, $view->name
));
265 * Specialized cache function to add a flag to our view, include an appropriate
266 * include, and cache more easily.
268 function views_ui_cache_set(&$view) {
269 if (!empty($view->locked
)) {
270 drupal_set_message('Changes cannot be made to a locked view.', 'error');
273 views_include('cache');
274 $view->changed
= TRUE
; // let any future object know that this view has changed.
276 // Unset handlers; we don't want to write these into the cache
277 unset($view->display_handler
);
278 unset($view->current_display
);
279 unset($view->default_display
);
280 foreach (array_keys($view->display
) as
$id) {
281 unset($view->display
[$id]->handler
);
282 unset($view->display
[$id]->default_display
);
284 views_object_cache_set('view', $view->name
, $view);
289 * Specialized menu callback to load a view that is only a default
292 function views_ui_default_load($name) {
293 $view = views_get_view($name);
294 if ($view->type
== t('Default')) {
302 * Check to see if the incoming menu item is js capable or not.
304 function views_ui_js_load($js) {