| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: views_ui.module,v 1.109.4.1 2010/04/07 23:40:35 merlinofchaos Exp $ 3 /** 4 * @file views_ui.module 5 * Provide structure for the administrative interface to Views. 6 */ 7 8 /* 9 * Implementation of hook_menu() 10 */ 11 function views_ui_menu() { 12 $items = array(); 13 14 // Minor code reduction technique 15 $base = array( 16 'access callback' => 'user_access', 17 'access arguments' => array('administer views'), 18 'file' => 'includes/admin.inc', 19 ); 20 21 $callback = $base + array('type' => MENU_CALLBACK); 22 23 $convert = array('file' => 'includes/convert.inc') + $base; 24 25 $items['admin/build/views'] = $base + array( 26 'title' => 'Views', 27 'page callback' => 'views_ui_list_views', 28 '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.', 29 'type' => MENU_NORMAL_ITEM 30 ); 31 $items['admin/build/views/list'] = $base + array( 32 'title' => 'List', 33 'page callback' => 'views_ui_list_views', 34 'type' => MENU_DEFAULT_LOCAL_TASK, 35 'weight' => '-1' 36 ); 37 $items['admin/build/views/add'] = $base + array( 38 'title' => 'Add', 39 'page callback' => 'views_ui_add_page', 40 'type' => MENU_LOCAL_TASK 41 ); 42 $items['admin/build/views/import'] = array( 43 'title' => 'Import', 44 'page callback' => 'drupal_get_form', 45 'page arguments' => array('views_ui_import_page'), 46 'access callback' => 'views_import_access', 47 'type' => MENU_LOCAL_TASK 48 ) + $base; 49 $items['admin/build/views/tools'] = $base + array( 50 'title' => 'Tools', 51 'page callback' => 'drupal_get_form', 52 'page arguments' => array('views_ui_admin_tools'), 53 'type' => MENU_LOCAL_TASK 54 ); 55 $items['admin/build/views/tools/basic'] = $base + array( 56 'title' => 'Basic', 57 'page callback' => 'drupal_get_form', 58 'page arguments' => array('views_ui_admin_tools'), 59 'type' => MENU_DEFAULT_LOCAL_TASK, 60 'weight' => -10, 61 ); 62 63 $items['admin/build/views/tools/convert'] = $convert + array( 64 'title' => 'Convert', 65 'description' => 'Convert stored Views 1 views.', 66 'page callback' => 'views_ui_admin_convert', 67 'type' => MENU_LOCAL_TASK, 68 'weight' => 1, 69 ); 70 $items['admin/build/views1/delete'] = $convert + array( 71 'title' => 'Delete view', 72 'page callback' => 'drupal_get_form', 73 'page arguments' => array('views_ui_delete1_confirm', 4), 74 'type' => MENU_CALLBACK, 75 ); 76 $items['admin/build/views1/convert'] = $convert + array( 77 'title' => 'Convert view', 78 'page callback' => 'views_ui_convert1', 79 'page arguments' => array(4), 80 'type' => MENU_CALLBACK, 81 ); 82 83 $items['admin/build/views/delete/%views_ui_cache'] = $callback + array( 84 'title' => 'Delete view', 85 'page callback' => 'drupal_get_form', 86 'page arguments' => array('views_ui_delete_confirm', 4), 87 ); 88 $items['admin/build/views/break-lock/%views_ui_cache'] = $callback + array( 89 'title' => 'Delete view', 90 'page callback' => 'drupal_get_form', 91 'page arguments' => array('views_ui_break_lock_confirm', 4), 92 ); 93 $items['admin/build/views/export/%views_ui_cache'] = $callback + array( 94 'page callback' => 'drupal_get_form', 95 'page arguments' => array('views_ui_export_page', 4), 96 'type' => MENU_LOCAL_TASK 97 ); 98 $items['admin/build/views/clone/%views_ui_cache'] = $callback + array( 99 'page callback' => 'views_ui_clone_page', 100 'page arguments' => array(4), 101 'type' => MENU_LOCAL_TASK 102 ); 103 $items['admin/build/views/enable/%views_ui_default'] = $callback + array( 104 'page callback' => 'views_ui_enable_page', 105 'page arguments' => array(4), 106 ); 107 $items['admin/build/views/disable/%views_ui_default'] = $callback + array( 108 'page callback' => 'views_ui_disable_page', 109 'page arguments' => array(4), 110 ); 111 112 // Many line items for editing a view. 113 $items['admin/build/views/edit/%views_ui_cache'] = $base + array( 114 'title' => 'Edit', 115 'page callback' => 'views_ui_edit_page', 116 'page arguments' => array(4), 117 'type' => MENU_LOCAL_TASK 118 ); 119 // lots of little edit form pieces. 120 $items['admin/build/views/%views_ui_js/analyze/%views_ui_cache'] = $callback + array( 121 'page callback' => 'views_ui_analyze_view', 122 'page arguments' => array(3, 5), 123 ); 124 $items['admin/build/views/%views_ui_js/details/%views_ui_cache'] = $callback + array( 125 'page callback' => 'views_ui_edit_details', 126 'page arguments' => array(3, 5), 127 ); 128 $items['admin/build/views/%views_ui_js/add-display/%views_ui_cache'] = $callback + array( 129 'page callback' => 'views_ui_add_display', 130 'page arguments' => array(3, 5), 131 ); 132 // Live preview 133 $items['admin/build/views/%views_ui_js/preview/%views_ui_cache'] = $callback + array( 134 'page callback' => 'views_ui_preview', 135 'page arguments' => array(3, 5), 136 ); 137 138 // autocompletes for handlers and such 139 $items['admin/views/ajax/autocomplete/tag'] = $callback + array( 140 'page callback' => 'views_ui_autocomplete_tag', 141 ); 142 143 144 // Generic ajax callback 145 // display specific parameters 146 $items['admin/build/views/%views_ui_js/%/%views_ui_cache'] = $callback + array( 147 'page callback' => 'views_ui_ajax_form', 148 'page arguments' => array(3, 4, 5), 149 ); 150 151 return $items; 152 } 153 154 /* 155 * Implementation of hook_help() 156 */ 157 function views_ui_help($path, $arg = '') { 158 switch ($path) { 159 case 'admin/build/views/tools/convert': 160 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>'; 161 } 162 } 163 164 /* 165 * Implementation of hook_theme() 166 */ 167 function views_ui_theme() { 168 $path = drupal_get_path('module', 'views'); 169 require_once "./$path/includes/admin.inc"; 170 171 return array( 172 // edit a view 173 'views_ui_edit_view' => array( 174 'arguments' => array('view' => NULL), 175 'template' => 'views-ui-edit-view', 176 'path' => "$path/theme", 177 ), 178 'views_ui_edit_tab' => array( 179 'arguments' => array('view' => NULL, 'display' => NULL), 180 'template' => 'views-ui-edit-tab', 181 'path' => "$path/theme", 182 ), 183 'views_ui_edit_item' => array( 184 'arguments' => array('type' => NULL, 'view' => NULL, 'display' => NULL, 'no_fields' => FALSE), 185 'template' => 'views-ui-edit-item', 186 'path' => "$path/theme", 187 ), 188 'views_ui_rearrange_form' => array( 189 'arguments' => array('form' => NULL), 190 'file' => 'includes/admin.inc', 191 ), 192 193 // list views 194 'views_ui_list_views' => array( 195 'template' => 'views-ui-list-views', 196 'path' => "$path/theme", 197 ), 198 'views_ui_list_views_form' => array( 199 'file' => 'includes/admin.inc', 200 'arguments' => array('form' => NULL), 201 ), 202 203 // tab themes 204 'views_tabset' => array( 205 'arguments' => array('tabs' => NULL), 206 'file' => 'includes/tabs.inc', 207 ), 208 'views_tab' => array( 209 'arguments' => array('body' => NULL), 210 'file' => 'includes/tabs.inc', 211 ), 212 213 // On behalf of a plugin 214 'views_ui_style_plugin_table' => array( 215 'arguments' => array('form' => NULL), 216 'file' => 'includes/admin.inc', 217 ), 218 ); 219 } 220 221 /** 222 * Specialized menu callback to load a view either out of the cache or just 223 * load it. 224 */ 225 function views_ui_cache_load($name) { 226 views_include('cache'); 227 views_include('view'); 228 $view = views_object_cache_get('view', $name); 229 230 if (empty($view)) { 231 $view = views_get_view($name); 232 233 if (!empty($view)) { 234 // Check to see if someone else is already editing this view. 235 global $user; 236 $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)); 237 } 238 } 239 240 if (empty($view)) { 241 return FALSE; 242 } 243 244 else { 245 return $view; 246 } 247 } 248 249 function views_ui_check_lock($view) { 250 251 } 252 253 /** 254 * Specialized cache function to add a flag to our view, include an appropriate 255 * include, and cache more easily. 256 */ 257 function views_ui_cache_set(&$view) { 258 if (!empty($view->locked)) { 259 drupal_set_message(t('Changes cannot be made to a locked view.'), 'error'); 260 return; 261 } 262 views_include('cache'); 263 $view->changed = TRUE; // let any future object know that this view has changed. 264 265 // Unset handlers; we don't want to write these into the cache 266 unset($view->display_handler); 267 unset($view->current_display); 268 unset($view->default_display); 269 foreach (array_keys($view->display) as $id) { 270 unset($view->display[$id]->handler); 271 unset($view->display[$id]->default_display); 272 } 273 views_object_cache_set('view', $view->name, $view); 274 } 275 276 277 /** 278 * Specialized menu callback to load a view that is only a default 279 * view. 280 */ 281 function views_ui_default_load($name) { 282 $view = views_get_view($name); 283 if ($view->type == t('Default')) { 284 return $view; 285 } 286 287 return FALSE; 288 } 289 290 /** 291 * Check to see if the incoming menu item is js capable or not. 292 */ 293 function views_ui_js_load($js) { 294 if ($js == 'ajax') { 295 return TRUE; 296 } 297 return 0; 298 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |