source: sipes/modules_contrib/views/views_ui.module @ 177a560

stableversion-3.0
Last change on this file since 177a560 was 177a560, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agrego el directorio de modulos contribuidos de drupal

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