• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

views_ui.module

Go to the documentation of this file.
00001 <?php
00010 function views_ui_menu() {
00011   $items = array();
00012 
00013   //module_load_include('inc', 'views_ui', 'includes/admin');
00014 
00015   // Drupal core loads the module file when uninstall a module. So views.module is not loaded.
00016   // There is a core bug filled, remove it once the bug is fixed.
00017   // @see http://drupal.org/node/1029606
00018   if (!module_exists('views')) {
00019     return;
00020   }
00021 
00022   // Minor code reduction technique.
00023   $base = array(
00024     'access callback' => 'user_access',
00025     'access arguments' => array('administer views'),
00026     'file' => 'includes/admin.inc',
00027   );
00028 
00029   // Top-level Views module pages (not tied to a particular View).
00030   $items['admin/structure/views/add'] = array(
00031     'title' => 'Add new view',
00032     'page callback' => 'views_ui_add_page',
00033     'type' => MENU_LOCAL_ACTION,
00034   ) + $base;
00035 
00036   // Top-level Views module pages (not tied to a particular View).
00037   $items['admin/structure/views/add-template'] = array(
00038     'title' => 'Add view from template',
00039     'page callback' => 'views_ui_add_template_page',
00040     // Don't show a local action link if there aren't any templates.
00041     'type' => views_get_all_templates() ? MENU_LOCAL_ACTION : MENU_VISIBLE_IN_BREADCRUMB,
00042   ) + $base;
00043 
00044   $items['admin/structure/views/import'] = array(
00045     'title' => 'Import',
00046     'page callback' => 'drupal_get_form',
00047     'page arguments' => array('views_ui_import_page'),
00048     'access callback' => 'views_import_access',
00049     'type' => MENU_LOCAL_ACTION,
00050   ) + $base;
00051 
00052   $items['admin/structure/views/settings'] = array(
00053     'title' => 'Settings',
00054     'page callback' => 'drupal_get_form',
00055     'page arguments' => array('views_ui_admin_settings_basic'),
00056     'type' => MENU_LOCAL_TASK,
00057   ) + $base;
00058   $items['admin/structure/views/settings/basic'] = array(
00059     'title' => 'Basic',
00060     'page arguments' => array('views_ui_admin_settings_basic'),
00061     'type' => MENU_DEFAULT_LOCAL_TASK,
00062   ) + $base;
00063   $items['admin/structure/views/settings/advanced'] = array(
00064     'title' => 'Advanced',
00065     'page arguments' => array('views_ui_admin_settings_advanced'),
00066     'type' => MENU_LOCAL_TASK,
00067     'weight' => 1,
00068   ) + $base;
00069 
00070   // The primary Edit View page. Secondary tabs for each Display are added in
00071   // views_ui_menu_local_tasks_alter().
00072   $items['admin/structure/views/view/%views_ui_cache'] = array(
00073     'title callback' => 'views_ui_edit_page_title',
00074     'title arguments' => array(4),
00075     'page callback' => 'views_ui_edit_page',
00076     'page arguments' => array(4),
00077   ) + $base;
00078   $items['admin/structure/views/view/%views_ui_cache/edit'] = array(
00079     'title' => 'Edit view',
00080     'type' => MENU_DEFAULT_LOCAL_TASK,
00081     'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
00082     'weight' => -10,
00083     'theme callback' => 'ajax_base_page_theme',
00084   ) + $base;
00085   $items['admin/structure/views/view/%views_ui_cache/edit/%/ajax'] = array(
00086     'page callback' => 'views_ui_ajax_get_form',
00087     'page arguments' => array('views_ui_edit_form', 4, 6),
00088     'delivery callback' => 'ajax_deliver',
00089     'theme callback' => 'ajax_base_page_theme',
00090     'type' => MENU_CALLBACK,
00091   ) + $base;
00092   $items['admin/structure/views/view/%views_ui_cache/preview/%'] = array(
00093     'page callback' => 'views_ui_build_preview',
00094     'page arguments' => array(4, 6),
00095     'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
00096     'type' => MENU_VISIBLE_IN_BREADCRUMB,
00097   ) + $base;
00098   $items['admin/structure/views/view/%views_ui_cache/preview/%/ajax'] = array(
00099     'page callback' => 'views_ui_build_preview',
00100     'page arguments' => array(4, 6),
00101     'delivery callback' => 'ajax_deliver',
00102     'theme callback' => 'ajax_base_page_theme',
00103     'type' => MENU_CALLBACK,
00104   ) + $base;
00105 
00106   // Additional pages for acting on a View.
00107 
00108   $items['admin/structure/views/view/%views_ui_cache/break-lock'] = array(
00109     'title' => 'Break lock',
00110     'page callback' => 'drupal_get_form',
00111     'page arguments' => array('views_ui_break_lock_confirm', 4),
00112     'type' => MENU_VISIBLE_IN_BREADCRUMB,
00113   ) + $base;
00114 
00115   // NoJS/AJAX callbacks that can use the default Views AJAX form system.
00116   $items['admin/structure/views/nojs/%/%views_ui_cache'] = array(
00117     'page callback' => 'views_ui_ajax_form',
00118     'page arguments' => array(FALSE, 4, 5),
00119     'type' => MENU_CALLBACK,
00120   ) + $base;
00121   $items['admin/structure/views/ajax/%/%views_ui_cache'] = array(
00122     'page callback' => 'views_ui_ajax_form',
00123     'page arguments' => array(TRUE, 4, 5),
00124     'delivery callback' => 'ajax_deliver',
00125     'type' => MENU_CALLBACK,
00126   ) + $base;
00127 
00128   // NoJS/AJAX callbacks that require custom page callbacks.
00129   $ajax_callbacks = array(
00130     'preview' => 'views_ui_preview',
00131   );
00132   foreach ($ajax_callbacks as $menu => $menu_callback) {
00133     $items['admin/structure/views/nojs/' . $menu . '/%views_ui_cache/%'] = array(
00134       'page callback' => $menu_callback,
00135       'page arguments' => array(5, 6),
00136     ) + $base;
00137     $items['admin/structure/views/ajax/' . $menu . '/%views_ui_cache/%'] = array(
00138       'page callback' => $menu_callback,
00139       'page arguments' => array(5, 6),
00140       'delivery callback' => 'ajax_deliver',
00141     ) + $base;
00142   }
00143 
00144   // Autocomplete callback for tagging a View.
00145   // Views module uses admin/views/... instead of admin/structure/views/... for
00146   // autocomplete paths, so be consistent with that.
00147   // @todo Change to admin/structure/views/... when the change can be made to
00148   //   Views module as well.
00149   $items['admin/views/ajax/autocomplete/tag'] = array(
00150     'page callback' => 'views_ui_autocomplete_tag',
00151     'type' => MENU_CALLBACK,
00152   ) + $base;
00153 
00154   // A page in the Reports section to show usage of fields in all views
00155   $items['admin/reports/views-fields'] = array(
00156     'title' => 'Fields used in views',
00157     'description' => 'Overview of fields used in all views.',
00158     'page callback' => 'views_ui_field_list',
00159   ) + $base;
00160 
00161   return $items;
00162 }
00163 
00167 function views_ui_theme() {
00168   $path = drupal_get_path('module', 'views');
00169   require_once DRUPAL_ROOT . "/$path/includes/admin.inc";
00170 
00171   return array(
00172     // edit a view
00173     'views_ui_display_tab_setting' => array(
00174       'variables' => array('description' => '', 'link' => '', 'settings_links' => array(), 'overridden' => FALSE, 'defaulted' => FALSE, 'description_separator' => TRUE, 'class' => array()),
00175       'template' => 'views-ui-display-tab-setting',
00176       'path' => "$path/theme",
00177     ),
00178     'views_ui_display_tab_bucket' => array(
00179       'render element' => 'element',
00180       'template' => 'views-ui-display-tab-bucket',
00181       'path' => "$path/theme",
00182     ),
00183     'views_ui_edit_item' => array(
00184       'variables' => array('type' => NULL, 'view' => NULL, 'display' => NULL, 'no_fields' => FALSE),
00185       'template' => 'views-ui-edit-item',
00186       'path' => "$path/theme",
00187     ),
00188     'views_ui_rearrange_form' => array(
00189       'render element' => 'form',
00190     ),
00191     'views_ui_rearrange_filter_form' => array(
00192       'render element' => 'form',
00193       'file' => 'includes/admin.inc',
00194     ),
00195     'views_ui_expose_filter_form' => array(
00196       'render element' => 'form',
00197       'file' => 'includes/admin.inc',
00198     ),
00199 
00200     // list views
00201     'views_ui_view_info' => array(
00202       'variables' => array('view' => NULL, 'base' => NULL),
00203       'file' => "includes/admin.inc",
00204     ),
00205 
00206     // tab themes
00207     'views_tabset' => array(
00208       'variables' => array('tabs' => NULL),
00209     ),
00210     'views_tab' => array(
00211       'variables' => array('body' => NULL),
00212     ),
00213     'views_ui_reorder_displays_form' => array(
00214       'render element' => 'form',
00215       'file' => 'includes/admin.inc',
00216     ),
00217 
00218 
00219     // On behalf of a plugin
00220     'views_ui_style_plugin_table' => array(
00221       'render element' => 'form',
00222     ),
00223 
00224     // When previewing a view.
00225     'views_ui_view_preview_section' => array(
00226       'variables' => array('view' => NULL, 'section' => NULL, 'content' => NULL, 'links' => ''),
00227     ),
00228 
00229     // Generic container wrapper, to use instead of theme_container when an id
00230     // is not desired.
00231     'views_container' => array(
00232       'render element' => 'element',
00233       'file' => 'theme/theme.inc',
00234     ),
00235   );
00236 }
00237 
00241 function views_ui_custom_theme() {
00242   $theme = variable_get('views_ui_custom_theme', '_default');
00243 
00244   if ($theme != '_default') {
00245     $available = list_themes();
00246 
00247     if (isset($available[$theme]) && $available[$theme]->status && preg_match('/^admin\/structure\/views/', current_path())) {
00248       return $theme;
00249     }
00250   }
00251 }
00252 
00256 function views_ui_edit_page_title($view) {
00257   module_load_include('inc', 'views_ui', 'includes/admin');
00258   $bases = views_fetch_base_tables();
00259   $name = $view->get_human_name();
00260   if (isset($bases[$view->base_table])) {
00261     $name .= ' (' . $bases[$view->base_table]['title'] . ')';
00262   }
00263 
00264   return $name;
00265 }
00266 
00277 function views_ui_cache_load($name) {
00278   ctools_include('object-cache');
00279   views_include('view');
00280   $view = ctools_object_cache_get('view', $name);
00281   $original_view = views_get_view($name);
00282 
00283   if (empty($view)) {
00284     $view = $original_view;
00285     if (!empty($view)) {
00286       // Check to see if someone else is already editing this view.
00287       $view->locked = ctools_object_cache_test('view', $view->name);
00288       // Set a flag to indicate that this view is being edited.
00289       // This flag will be used e.g. to determine whether strings
00290       // should be localized.
00291       $view->editing = TRUE;
00292     }
00293   }
00294   else {
00295     // Keep disabled/enabled status real.
00296     if ($original_view) {
00297       $view->disabled = !empty($original_view->disabled);
00298     }
00299   }
00300 
00301   if (empty($view)) {
00302     return FALSE;
00303   }
00304 
00305   else {
00306     return $view;
00307   }
00308 }
00309 
00314 function views_ui_cache_set(&$view) {
00315   if (!empty($view->locked)) {
00316     drupal_set_message(t('Changes cannot be made to a locked view.'), 'error');
00317     return;
00318   }
00319   ctools_include('object-cache');
00320   $view->changed = TRUE; // let any future object know that this view has changed.
00321 
00322   if (isset($view->current_display)) {
00323     // Add the knowledge of the changed display, too.
00324     $view->changed_display[$view->current_display] = TRUE;
00325     unset($view->current_display);
00326   }
00327 
00328   // Unset handlers; we don't want to write these into the cache
00329   unset($view->display_handler);
00330   unset($view->default_display);
00331   $view->query = NULL;
00332   foreach (array_keys($view->display) as $id) {
00333     unset($view->display[$id]->handler);
00334     unset($view->display[$id]->default_display);
00335   }
00336   ctools_object_cache_set('view', $view->name, $view);
00337 }
00338 
00339 
00344 function views_ui_default_load($name) {
00345   $view = views_get_view($name);
00346   if ($view->type == t('Default')) {
00347     return $view;
00348   }
00349 
00350   return FALSE;
00351 }
00352 
00356 function views_ui_preprocess_views_view(&$vars) {
00357   $view = $vars['view'];
00358   if (!empty($view->views_ui_context) && module_exists('contextual')) {
00359     $view->hide_admin_links = TRUE;
00360     foreach (array('title', 'header', 'exposed', 'rows', 'pager', 'more', 'footer', 'empty', 'attachment_after', 'attachment_before') as $section) {
00361       if (!empty($vars[$section])) {
00362         $vars[$section] = array(
00363           '#theme' => 'views_ui_view_preview_section',
00364           '#view' => $view,
00365           '#section' => $section,
00366           '#content' => is_array($vars[$section]) ? drupal_render($vars[$section]) : $vars[$section],
00367           '#theme_wrappers' => array('views_container'),
00368           '#attributes' => array('class' => 'contextual-links-region'),
00369         );
00370         $vars[$section] = drupal_render($vars[$section]);
00371       }
00372     }
00373   }
00374 }
00375 
00382 function template_preprocess_views_ui_view_preview_section(&$vars) {
00383   switch ($vars['section']) {
00384     case 'title':
00385       $vars['title'] = t('Title');
00386       $links = views_ui_view_preview_section_display_category_links($vars['view'], 'title', $vars['title']);
00387       break;
00388     case 'header':
00389       $vars['title'] = t('Header');
00390       $links = views_ui_view_preview_section_handler_links($vars['view'], $vars['section']);
00391       break;
00392     case 'empty':
00393       $vars['title'] = t('No results behavior');
00394       $links = views_ui_view_preview_section_handler_links($vars['view'], $vars['section']);
00395       break;
00396     case 'exposed':
00397       // @todo Sorts can be exposed too, so we may need a better title.
00398       $vars['title'] = t('Exposed Filters');
00399       $links = views_ui_view_preview_section_display_category_links($vars['view'], 'exposed_form_options', $vars['title']);
00400       break;
00401     case 'rows':
00402       // @todo The title needs to depend on what is being viewed.
00403       $vars['title'] = t('Content');
00404       $links = views_ui_view_preview_section_rows_links($vars['view']);
00405       break;
00406     case 'pager':
00407       $vars['title'] = t('Pager');
00408       $links = views_ui_view_preview_section_display_category_links($vars['view'], 'pager_options', $vars['title']);
00409       break;
00410     case 'more':
00411       $vars['title'] = t('More');
00412       $links = views_ui_view_preview_section_display_category_links($vars['view'], 'use_more', $vars['title']);
00413       break;
00414     case 'footer':
00415       $vars['title'] = t('Footer');
00416       $links = views_ui_view_preview_section_handler_links($vars['view'], $vars['section']);
00417       break;
00418     case 'attachment_before':
00419       // @todo: Add links to the attachment configuration page.
00420       $vars['title'] = t('Attachment before');
00421       break;
00422     case 'attachment_after':
00423       // @todo: Add links to the attachment configuration page.
00424       $vars['title'] = t('Attachment after');
00425       break;
00426   }
00427 
00428   if (isset($links)) {
00429     $build = array(
00430       '#prefix' => '<div class="contextual-links-wrapper">',
00431       '#suffix' => '</div>',
00432       '#theme' => 'links__contextual',
00433       '#links' => $links,
00434       '#attributes' => array('class' => array('contextual-links')),
00435       '#attached' => array(
00436         'library' => array(array('contextual', 'contextual-links')),
00437       ),
00438     );
00439     $vars['links'] = drupal_render($build);
00440   }
00441   $vars['theme_hook_suggestions'][] = 'views_ui_view_preview_section__' . $vars['section'];
00442 }
00443 
00447 function theme_views_ui_view_preview_section($vars) {
00448   return '<h1 class="section-title">' . $vars['title'] . '</h1>'
00449   . $vars['links']
00450   . '<div class="preview-section">'. $vars['content'] . '</div>';
00451 }
00452 
00463 function views_ui_view_preview_section_handler_links($view, $type, $title = FALSE) {
00464   $display = $view->display_handler->display;
00465   $handlers = $view->display_handler->get_handlers($type);
00466   $links = array();
00467 
00468   $types = views_object_types();
00469   if ($title) {
00470     $links[$type . '-title'] = array(
00471       'title' => $types[$type]['title'],
00472     );
00473   }
00474 
00475   foreach ($handlers as $id => $handler) {
00476     $field_name = $handler->ui_name(TRUE);
00477     $links[$type . '-edit-' . $id] = array(
00478       'title' => t('Edit @section', array('@section' => $field_name)),
00479       'href' => "admin/structure/views/nojs/config-item/$view->name/$display->id/$type/$id",
00480       'attributes' => array('class' => array('views-ajax-link')),
00481     );
00482   }
00483   $links[$type . '-add'] = array(
00484     'title' => t('Add new'),
00485     'href' => "admin/structure/views/nojs/add-item/$view->name/$display->id/$type",
00486     'attributes' => array('class' => array('views-ajax-link')),
00487   );
00488 
00489   return $links;
00490 }
00491 
00495 function views_ui_view_preview_section_display_category_links($view, $type, $title) {
00496   $display = $view->display_handler->display;
00497   $links = array(
00498     $type . '-edit' => array(
00499       'title' => t('Edit @section', array('@section' => $title)),
00500       'href' => "admin/structure/views/nojs/display/$view->name/$display->id/$type",
00501       'attributes' => array('class' => array('views-ajax-link')),
00502     ),
00503   );
00504 
00505   return $links;
00506 }
00507 
00511 function views_ui_view_preview_section_rows_links($view) {
00512   $display = $view->display_handler->display;
00513   $links = array();
00514   $links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'filter', TRUE));
00515   $links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'field', TRUE));
00516   $links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'sort', TRUE));
00517   $links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'argument', TRUE));
00518   $links = array_merge($links, views_ui_view_preview_section_handler_links($view, 'relationship', TRUE));
00519 
00520   return $links;
00521 }
00522 
00523 
00529 function views_ui_ctools_plugin_directory($module, $plugin) {
00530   if ($module == 'views_ui' || ($module == 'ctools' && $plugin == 'export_ui')) {
00531     return 'plugins/' . $plugin;
00532   }
00533 }
00534 
00544 function views_ui_get_wizard($wizard_type) {
00545   ctools_include('plugins');
00546   $wizard = ctools_get_plugins('views_ui', 'views_wizard', $wizard_type);
00547   // @todo - handle this via an alter hook instead.
00548   if (!$wizard) {
00549     // Must be a base table using the default wizard plugin.
00550     $base_tables = views_fetch_base_tables();
00551     if (!empty($base_tables[$wizard_type])) {
00552       $wizard = views_ui_views_wizard_defaults();
00553       $wizard['base_table'] = $wizard_type;
00554       $wizard['title'] = $base_tables[$wizard_type]['title'];
00555     }
00556     // The plugin is neither a base table nor an existing wizard.
00557     else {
00558       vpr('Views Wizard: @wizard does not exist. Be sure to implement hook_ctools_plugin_directory.', array('@wizard' => $wizard_type));
00559     }
00560   }
00561   return $wizard;
00562 }
00563 
00570 function views_ui_get_wizards() {
00571   ctools_include('plugins');
00572   $wizard_plugins = ctools_get_plugins('views_ui', 'views_wizard');
00573   $wizard_tables = array();
00574   foreach ($wizard_plugins as $name => $info) {
00575     $wizard_tables[$info['base_table']] = TRUE;
00576   }
00577   $base_tables = views_fetch_base_tables();
00578   $default_wizard = views_ui_views_wizard_defaults();
00579   // Find base tables with no wizard.
00580   // @todo - handle this via an alter hook for plugins?
00581   foreach ($base_tables as $table => $info) {
00582     if (!isset($wizard_tables[$table])) {
00583       $wizard = $default_wizard;
00584       $wizard['title'] = $info['title'];
00585       $wizard['base_table'] = $table;
00586       $wizard_plugins[$table] = $wizard;
00587     }
00588   }
00589   return $wizard_plugins;
00590 }
00591 
00598 function views_ui_views_wizard_defaults() {
00599   return array(
00600     // The children may, for example, be a different variant for each node type.
00601     'get children' => NULL,
00602     'get child' => NULL,
00603     // title and base table must be populated.  They are empty here just
00604     // so they are documented.
00605     'title' => '',
00606     'base_table' => NULL,
00607     // This is a callback that takes the wizard as argument and returns
00608     // an instantiazed Views UI form wizard object.
00609     'get_instance' => 'views_ui_get_form_wizard_instance',
00610     'form_wizard_class' => array(
00611       'file' => 'views_ui_base_views_wizard',
00612       'class' => 'ViewsUiBaseViewsWizard',
00613     ),
00614   );
00615 }
00616 
00620 function views_ui_ctools_plugin_type() {
00621   return array(
00622     'views_wizard' => array(
00623       'child plugins' => TRUE,
00624       'classes' => array(
00625         'form_wizard_class',
00626       ),
00627       'defaults' => views_ui_views_wizard_defaults(),
00628     ),
00629   );
00630 }
00631 
00632 function views_ui_get_form_wizard_instance($wizard) {
00633   if (isset($wizard['form_wizard_class']['class'])) {
00634     $class = $wizard['form_wizard_class']['class'];
00635     return new $class($wizard);
00636   }
00637   else {
00638     return new ViewsUiBaseViewsWizard($wizard);
00639   }
00640 }
00641 
00645 function views_ui_views_plugins_alter(&$plugins) {
00646   // Attach contextual links to each display plugin. The links will point to
00647   // paths underneath "admin/structure/views/view/{$view->name}" (i.e., paths
00648   // for editing and performing other contextual actions on the view).
00649   foreach ($plugins['display'] as &$display) {
00650     $display['contextual links']['views_ui'] = array(
00651       'parent path' => 'admin/structure/views/view',
00652       'argument properties' => array('name'),
00653     );
00654   }
00655 }
00656 
00660 function views_ui_contextual_links_view_alter(&$element, $items) {
00661   // Remove contextual links from being rendered, when so desired, such as
00662   // within a View preview.
00663   if (views_ui_contextual_links_suppress()) {
00664     $element['#links'] = array();
00665   }
00666   // Append the display ID to the Views UI edit links, so that clicking on the
00667   // contextual link takes you directly to the correct display tab on the edit
00668   // screen.
00669   elseif (!empty($element['#links']['views-ui-edit']) && !empty($element['#element']['#views_contextual_links_info']['views_ui']['view_display_id'])) {
00670     $display_id = $element['#element']['#views_contextual_links_info']['views_ui']['view_display_id'];
00671     $element['#links']['views-ui-edit']['href'] .= '/' . $display_id;
00672   }
00673 }
00674 
00680 function views_ui_contextual_links_suppress($set = NULL) {
00681   $suppress = &drupal_static(__FUNCTION__);
00682   if (isset($set)) {
00683     $suppress = $set;
00684   }
00685   return $suppress;
00686 }
00687 
00700 function views_ui_contextual_links_suppress_push() {
00701   views_ui_contextual_links_suppress(((int) views_ui_contextual_links_suppress())+1);
00702 }
00703 
00709 function views_ui_contextual_links_suppress_pop() {
00710   views_ui_contextual_links_suppress(((int) views_ui_contextual_links_suppress())-1);
00711 }
00712 
00734 function views_ui_ajax_get_form($form_id) {
00735   // @see ajax_get_form()
00736   $form_state = array(
00737     'no_redirect' => TRUE,
00738   );
00739   $form_state['rebuild_info']['copy']['#build_id'] = TRUE;
00740   $form_state['rebuild_info']['copy']['#action'] = TRUE;
00741 
00742   // @see drupal_get_form()
00743   $args = func_get_args();
00744   array_shift($args);
00745   $form_state['build_info']['args'] = $args;
00746   $form = drupal_build_form($form_id, $form_state);
00747 
00748   // @see ajax_form_callback()
00749   if (!empty($form_state['triggering_element'])) {
00750     $callback = $form_state['triggering_element']['#ajax']['callback'];
00751   }
00752   if (!empty($callback) && function_exists($callback)) {
00753     return $callback($form, $form_state);
00754   }
00755 }
00756 // @todo move these when we can
00757 
00758 
00768 function _views_ui_get_paths($view) {
00769   $all_paths = array();
00770   if (empty($view->display)) {
00771     $all_paths[] = t('Edit this view to add a display.');
00772   }
00773   else {
00774     $view->init_display();   // Make sure all the handlers are set up
00775     foreach ($view->display as $display) {
00776       if (!empty($display->handler) && $display->handler->has_path()) {
00777         $one_path = $display->handler->get_option('path');
00778         if (empty($path_sort)) {
00779           $path_sort = strtolower($one_path);
00780         }
00781         if (empty($view->disabled) && strpos($one_path, '%') === FALSE) {
00782           $all_paths[] = l('/' . $one_path, $one_path);
00783         }
00784         else {
00785           $all_paths[] = check_plain('/' . $one_path);
00786         }
00787       }
00788     }
00789   }
00790 
00791   return array_unique($all_paths);
00792 }
00793 
00803 function _views_ui_get_displays_list($view) {
00804   $displays = array();
00805   foreach ($view->display as $display) {
00806     if (!empty($display->handler->definition['admin'])) {
00807       $displays[$display->handler->definition['admin']] = TRUE;
00808     }
00809   }
00810 
00811   if ($displays) {
00812     ksort($displays);
00813     $displays = array_keys($displays);
00814   }
00815   return $displays;
00816 }
00817 
00834 function views_ui_library_alter(&$libraries, $module) {
00835   if ($module == 'system' && isset($libraries['ui.dialog'])) {
00836     if (version_compare($libraries['ui.dialog']['version'], '1.7.2', '>=')) {
00837       $libraries['ui.dialog']['js'][drupal_get_path('module', 'views') . '/js/jquery.ui.dialog.patch.js'] = array();
00838     }
00839   }
00840 }
00841 
00849 function views_ui_list_views() {
00850   drupal_flush_all_caches();
00851   menu_rebuild();
00852   drupal_goto($_GET['q']);
00853 }
00854 
00860 function views_ui_truncate($string, $length) {
00861   if (drupal_strlen($string) > $length) {
00862     $string = drupal_substr($string, 0, $length);
00863     $string .= '...';
00864   }
00865 
00866   return $string;
00867 }

Generated on Sun Feb 26 2012 12:52:52 for Views by  doxygen 1.7.1