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),
92 'type' => MENU_LOCAL_TASK
94 $items['admin/build/views/clone/%views_ui_cache'] = $callback + array(
95 'page callback' => 'views_ui_clone_page',
96 'page arguments' => array(4),
97 'type' => MENU_LOCAL_TASK
99 $items['admin/build/views/enable/%views_ui_default'] = $callback + array(
100 'page callback' => 'views_ui_enable_page',
101 'page arguments' => array(4),
103 $items['admin/build/views/disable/%views_ui_default'] = $callback + array(
104 'page callback' => 'views_ui_disable_page',
105 'page arguments' => array(4),
108 // Many line items for editing a view.
109 $items['admin/build/views/edit/%views_ui_cache'] = $base + array(
111 'page callback' => 'views_ui_edit_page',
112 'page arguments' => array(4),
113 'type' => MENU_LOCAL_TASK
115 // lots of little edit form pieces.
116 $items['admin/build/views/%views_ui_js/analyze/%views_ui_cache'] = $callback + array(
117 'page callback' => 'views_ui_analyze_view',
118 'page arguments' => array(3, 5),
120 $items['admin/build/views/%views_ui_js/details/%views_ui_cache'] = $callback + array(
121 'page callback' => 'views_ui_edit_details',
122 'page arguments' => array(3, 5),
124 $items['admin/build/views/%views_ui_js/add-display/%views_ui_cache'] = $callback + array(
125 'page callback' => 'views_ui_add_display',
126 'page arguments' => array(3, 5),
129 $items['admin/build/views/%views_ui_js/preview/%views_ui_cache'] = $callback + array(
130 'page callback' => 'views_ui_preview',
131 'page arguments' => array(3, 5),
134 // autocompletes for handlers and such
135 // Path is not admin/build/views due to menu complications with the wildcards from
136 // the generic ajax callback.
137 $items['admin/views/ajax/autocomplete/user'] = $callback + array(
138 'page callback' => 'views_ui_autocomplete_user',
140 $items['admin/views/ajax/autocomplete/tag'] = $callback + array(
141 'page callback' => 'views_ui_autocomplete_tag',
145 // Generic ajax callback
146 // display specific parameters
147 $items['admin/build/views/%views_ui_js/%/%views_ui_cache'] = $callback + array(
148 'page callback' => 'views_ui_ajax_form',
149 'page arguments' => array(3, 4, 5),
155 function views_ui_help($path, $arg) {
157 case
'admin/build/views/tools/convert':
158 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>';
163 * Implementation of hook_perm()
165 function views_perm() {
166 return array('administer views');
169 function views_ui_theme() {
170 $path = drupal_get_path('module', 'views');
171 require_once
"./$path/includes/admin.inc";
175 'views_ui_edit_view' => array(
176 'arguments' => array('view' => NULL
),
177 'template' => 'views-ui-edit-view',
178 'path' => "$path/theme",
180 'views_ui_edit_tab' => array(
181 'arguments' => array('view' => NULL
, 'display' => NULL
),
182 'template' => 'views-ui-edit-tab',
183 'path' => "$path/theme",
185 'views_ui_edit_item' => array(
186 'arguments' => array('type' => NULL
, 'view' => NULL
, 'display' => NULL
),
187 'template' => 'views-ui-edit-item',
188 'path' => "$path/theme",
190 'views_ui_rearrange_form' => array(
191 'arguments' => array('form' => NULL
),
192 'file' => '/includes/admin.inc',
196 'views_ui_list_views' => array(
197 'template' => 'views-ui-list-views',
198 'path' => "$path/theme",
200 'views_ui_list_views_form' => array(
201 'file' => '/includes/admin.inc',
202 'arguments' => array('form' => NULL
),
206 'views_tabset' => array(
207 'arguments' => array('tabs' => NULL
),
208 'file' => '/includes/tabs.inc',
210 'views_tab' => array(
211 'arguments' => array('body' => NULL
),
212 'file' => '/includes/tabs.inc',
215 // On behalf of a plugin
216 'views_ui_style_plugin_table' => array(
217 'arguments' => array('form' => NULL
),
223 * Specialized menu callback to load a view either out of the cache or just
226 function views_ui_cache_load($name) {
227 views_include('cache');
228 views_include('view');
229 $view = views_object_cache_get('view', $name);
232 $view = views_get_view($name);
235 // Check to see if someone else is already editing this view.
237 $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
));
250 function views_ui_check_lock($view) {
255 * Specialized cache function to add a flag to our view, include an appropriate
256 * include, and cache more easily.
258 function views_ui_cache_set(&$view) {
259 if (!empty($view->locked
)) {
260 drupal_set_message('Changes cannot be made to a locked view.', 'error');
263 views_include('cache');
264 $view->changed
= TRUE
; // let any future object know that this view has changed.
266 // Unset handlers; we don't want to write these into the cache
267 unset($view->display_handler
);
268 unset($view->current_display
);
269 unset($view->default_display
);
270 foreach (array_keys($view->display
) as
$id) {
271 unset($view->display
[$id]->handler
);
272 unset($view->display
[$id]->default_display
);
274 views_object_cache_set('view', $view->name
, $view);
279 * Specialized menu callback to load a view that is only a default
282 function views_ui_default_load($name) {
283 $view = views_get_view($name);
284 if ($view->type
== t('Default')) {
292 * Check to see if the incoming menu item is js capable or not.
294 function views_ui_js_load($js) {