3 * @file views_ui.module
4 * Provide structure for the administrative interface to Views.
8 * Implementation of hook_menu()
10 function views_ui_menu() {
13 // Minor code reduction technique
15 'access callback' => 'user_access',
16 'access arguments' => array('administer views'),
17 'file' => 'includes/admin.inc',
20 $callback = $base + array('type' => MENU_CALLBACK
);
22 $convert = array('file' => 'includes/convert.inc') + $base;
24 $items['admin/build/views'] = $base + array(
26 'page callback' => 'views_ui_list_views',
27 '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.',
28 'type' => MENU_NORMAL_ITEM
30 $items['admin/build/views/list'] = $base + array(
32 'page callback' => 'views_ui_list_views',
33 'type' => MENU_DEFAULT_LOCAL_TASK
,
36 $items['admin/build/views/add'] = $base + array(
38 'page callback' => 'views_ui_add_page',
39 'type' => MENU_LOCAL_TASK
41 $items['admin/build/views/import'] = array(
43 'page callback' => 'drupal_get_form',
44 'page arguments' => array('views_ui_import_page'),
45 'access callback' => 'views_import_access',
46 'type' => MENU_LOCAL_TASK
48 $items['admin/build/views/tools'] = $base + array(
50 'page callback' => 'drupal_get_form',
51 'page arguments' => array('views_ui_admin_tools'),
52 'type' => MENU_LOCAL_TASK
54 $items['admin/build/views/tools/basic'] = $base + array(
56 'page callback' => 'drupal_get_form',
57 'page arguments' => array('views_ui_admin_tools'),
58 'type' => MENU_DEFAULT_LOCAL_TASK
,
62 $items['admin/build/views/tools/convert'] = $convert + array(
64 'description' => 'Convert stored Views 1 views.',
65 'page callback' => 'views_ui_admin_convert',
66 'type' => MENU_LOCAL_TASK
,
69 $items['admin/build/views1/delete'] = $convert + array(
70 'title' => 'Delete view',
71 'page callback' => 'drupal_get_form',
72 'page arguments' => array('views_ui_delete1_confirm', 4),
73 'type' => MENU_CALLBACK
,
75 $items['admin/build/views1/convert'] = $convert + array(
76 'title' => 'Convert view',
77 'page callback' => 'views_ui_convert1',
78 'page arguments' => array(4),
79 'type' => MENU_CALLBACK
,
82 $items['admin/build/views/delete/%views_ui_cache'] = $callback + array(
83 'title' => 'Delete view',
84 'page callback' => 'drupal_get_form',
85 'page arguments' => array('views_ui_delete_confirm', 4),
87 $items['admin/build/views/break-lock/%views_ui_cache'] = $callback + array(
88 'title' => 'Delete view',
89 'page callback' => 'drupal_get_form',
90 'page arguments' => array('views_ui_break_lock_confirm', 4),
92 $items['admin/build/views/export/%views_ui_cache'] = $callback + array(
93 'page callback' => 'drupal_get_form',
94 'page arguments' => array('views_ui_export_page', 4),
95 'type' => MENU_LOCAL_TASK
97 $items['admin/build/views/clone/%views_ui_cache'] = $callback + array(
98 'page callback' => 'views_ui_clone_page',
99 'page arguments' => array(4),
100 'type' => MENU_LOCAL_TASK
102 $items['admin/build/views/enable/%views_ui_default'] = $callback + array(
103 'page callback' => 'views_ui_enable_page',
104 'page arguments' => array(4),
106 $items['admin/build/views/disable/%views_ui_default'] = $callback + array(
107 'page callback' => 'views_ui_disable_page',
108 'page arguments' => array(4),
111 // Many line items for editing a view.
112 $items['admin/build/views/edit/%views_ui_cache'] = $base + array(
114 'page callback' => 'views_ui_edit_page',
115 'page arguments' => array(4),
116 'type' => MENU_LOCAL_TASK
118 // lots of little edit form pieces.
119 $items['admin/build/views/%views_ui_js/analyze/%views_ui_cache'] = $callback + array(
120 'page callback' => 'views_ui_analyze_view',
121 'page arguments' => array(3, 5),
123 $items['admin/build/views/%views_ui_js/reorder-displays/%views_ui_cache'] = $callback + array(
124 'page callback' => 'views_ui_reorder_view',
125 'page arguments' => array(3, 5),
127 $items['admin/build/views/%views_ui_js/human_name/%views_ui_cache'] = $callback + array(
128 'page callback' => 'views_ui_edit_details',
129 'page arguments' => array('human_name', 3, 5),
131 $items['admin/build/views/%views_ui_js/tag/%views_ui_cache'] = $callback + array(
132 'page callback' => 'views_ui_edit_details',
133 'page arguments' => array('tag', 3, 5),
135 $items['admin/build/views/%views_ui_js/description/%views_ui_cache'] = $callback + array(
136 'page callback' => 'views_ui_edit_details',
137 'page arguments' => array('description', 3, 5),
139 $items['admin/build/views/%views_ui_js/add-display/%views_ui_cache'] = $callback + array(
140 'page callback' => 'views_ui_add_display',
141 'page arguments' => array(3, 5),
143 $items['admin/build/views/%views_ui_js/clone-display/%views_ui_cache'] = $callback + array(
144 'page callback' => 'views_ui_clone_display',
145 'page arguments' => array(3, 5, 6),
148 $items['admin/build/views/%views_ui_js/preview/%views_ui_cache'] = $callback + array(
149 'page callback' => 'views_ui_preview',
150 'page arguments' => array(3, 5),
153 // autocompletes for handlers and such
154 $items['admin/views/ajax/autocomplete/tag'] = $callback + array(
155 'page callback' => 'views_ui_autocomplete_tag',
159 // Generic ajax callback
160 // display specific parameters
161 $items['admin/build/views/%views_ui_js/%/%views_ui_cache'] = $callback + array(
162 'page callback' => 'views_ui_ajax_form',
163 'page arguments' => array(3, 4, 5),
170 * Implementation of hook_help()
172 function views_ui_help($path, $arg = '') {
174 case
'admin/build/views/tools/convert':
175 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>';
180 * Implementation of hook_theme()
182 function views_ui_theme() {
183 $path = drupal_get_path('module', 'views');
184 require_once
"./$path/includes/admin.inc";
188 'views_ui_edit_view' => array(
189 'arguments' => array('view' => NULL
),
190 'template' => 'views-ui-edit-view',
191 'path' => "$path/theme",
193 'views_ui_edit_tab' => array(
194 'arguments' => array('view' => NULL
, 'display' => NULL
),
195 'template' => 'views-ui-edit-tab',
196 'path' => "$path/theme",
198 'views_ui_edit_item' => array(
199 'arguments' => array('type' => NULL
, 'view' => NULL
, 'display' => NULL
, 'no_fields' => FALSE
),
200 'template' => 'views-ui-edit-item',
201 'path' => "$path/theme",
203 'views_ui_rearrange_form' => array(
204 'arguments' => array('form' => NULL
),
205 'file' => 'includes/admin.inc',
207 'views_ui_rearrange_filter_form' => array(
208 'arguments' => array('form' => NULL
),
209 'file' => 'includes/admin.inc',
213 'views_ui_list_views' => array(
214 'template' => 'views-ui-list-views',
215 'path' => "$path/theme",
217 'views_ui_list_views_form' => array(
218 'file' => 'includes/admin.inc',
219 'arguments' => array('form' => NULL
),
223 'views_tabset' => array(
224 'arguments' => array('tabs' => NULL
),
225 'file' => 'includes/tabs.inc',
227 'views_tab' => array(
228 'arguments' => array('body' => NULL
),
229 'file' => 'includes/tabs.inc',
231 'views_ui_reorder_displays_form' => array(
232 'arguments' => array('form' => NULL
),
233 'file' => 'includes/admin.inc',
237 // On behalf of a plugin
238 'views_ui_style_plugin_table' => array(
239 'arguments' => array('form' => NULL
),
240 'file' => 'includes/admin.inc',
246 * Specialized menu callback to load a view either out of the cache or just
249 function views_ui_cache_load($name) {
250 views_include('cache');
251 views_include('view');
252 $view = views_object_cache_get('view', $name);
255 $view = views_get_view($name);
258 // Check to see if someone else is already editing this view.
260 $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
));
261 // Set a flag to indicate that this view is being edited.
262 // This flag will be used e.g. to determine whether strings
263 // should be localized.
264 $view->editing
= TRUE
;
277 function views_ui_check_lock($view) {
282 * Specialized cache function to add a flag to our view, include an appropriate
283 * include, and cache more easily.
285 function views_ui_cache_set(&$view) {
286 if (!empty($view->locked
)) {
287 drupal_set_message(t('Changes cannot be made to a locked view.'), 'error');
290 views_include('cache');
291 $view->changed
= TRUE
; // let any future object know that this view has changed.
293 // Unset handlers; we don't want to write these into the cache
294 unset($view->display_handler
);
295 unset($view->current_display
);
296 unset($view->default_display
);
298 foreach (array_keys($view->display
) as
$id) {
299 unset($view->display
[$id]->handler
);
300 unset($view->display
[$id]->default_display
);
302 views_object_cache_set('view', $view->name
, $view);
307 * Specialized menu callback to load a view that is only a default
310 function views_ui_default_load($name) {
311 $view = views_get_view($name);
312 if ($view->type
== t('Default')) {
320 * Check to see if the incoming menu item is js capable or not.
322 function views_ui_js_load($js) {