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

plugins/views_wizard/views_ui_node_views_wizard.class.php

00001 <?php
00002 
00003 class ViewsUiNodeViewsWizard extends ViewsUiBaseViewsWizard {
00004 
00005   protected function row_style_options($type) {
00006     $options = array();
00007     $options['teasers'] = t('teasers');
00008     $options['full_posts'] = t('full posts');
00009     $options['titles'] = t('titles');
00010     $options['titles_linked'] = t('titles (linked)');
00011     $options['fields'] = t('fields');
00012     return $options;
00013   }
00014 
00015   protected function build_form_style(&$form, &$form_state, $type) {
00016     parent::build_form_style($form, $form_state, $type);
00017     $style_form =& $form['displays'][$type]['options']['style'];
00018     // Some style plugins don't support row plugins so stop here if that's the
00019     // case.
00020     if (!isset($style_form['row_plugin']['#default_value'])) {
00021       return;
00022     }
00023     $row_plugin = $style_form['row_plugin']['#default_value'];
00024     switch ($row_plugin) {
00025       case 'full_posts':
00026       case 'teasers':
00027         $style_form['row_options']['links'] = array(
00028           '#type' => 'select',
00029           '#title_display' => 'invisible',
00030           '#title' => t('Should links be displayed below each node'),
00031           '#options' => array(
00032             1 => t('with links (allow users to add comments, etc.)'),
00033             0 => t('without links'),
00034           ),
00035           '#default_value' => 1,
00036         );
00037         $style_form['row_options']['comments'] = array(
00038           '#type' => 'select',
00039           '#title_display' => 'invisible',
00040           '#title' => t('Should comments be displayed below each node'),
00041           '#options' => array(
00042             1 => t('with comments'),
00043             0 => t('without comments'),
00044           ),
00045           '#default_value' => 0,
00046         );
00047         break;
00048     }
00049   }
00050 
00054   protected function default_display_options($form, $form_state) {
00055     $display_options = parent::default_display_options($form, $form_state);
00056 
00057     // Add permission-based access control.
00058     $display_options['access']['type'] = 'perm';
00059 
00060     // Remove the default fields, since we are customizing them here.
00061     unset($display_options['fields']);
00062 
00063     // Add the title field, so that the display has content if the user switches
00064     // to a row style that uses fields.
00065     /* Field: Content: Title */
00066     $display_options['fields']['title']['id'] = 'title';
00067     $display_options['fields']['title']['table'] = 'node';
00068     $display_options['fields']['title']['field'] = 'title';
00069     $display_options['fields']['title']['label'] = '';
00070     $display_options['fields']['title']['alter']['alter_text'] = 0;
00071     $display_options['fields']['title']['alter']['make_link'] = 0;
00072     $display_options['fields']['title']['alter']['absolute'] = 0;
00073     $display_options['fields']['title']['alter']['trim'] = 0;
00074     $display_options['fields']['title']['alter']['word_boundary'] = 0;
00075     $display_options['fields']['title']['alter']['ellipsis'] = 0;
00076     $display_options['fields']['title']['alter']['strip_tags'] = 0;
00077     $display_options['fields']['title']['alter']['html'] = 0;
00078     $display_options['fields']['title']['hide_empty'] = 0;
00079     $display_options['fields']['title']['empty_zero'] = 0;
00080     $display_options['fields']['title']['link_to_node'] = 1;
00081 
00082     return $display_options;
00083   }
00084 
00085   protected function page_display_options($form, $form_state) {
00086     $display_options = parent::page_display_options($form, $form_state);
00087     $row_plugin = isset($form_state['values']['page']['style']['row_plugin']) ? $form_state['values']['page']['style']['row_plugin'] : NULL;
00088     $row_options = isset($form_state['values']['page']['style']['row_options']) ? $form_state['values']['page']['style']['row_options'] : array();
00089     $this->display_options_row($display_options, $row_plugin, $row_options);
00090     return $display_options;
00091   }
00092 
00093   protected function block_display_options($form, $form_state) {
00094     $display_options = parent::block_display_options($form, $form_state);
00095     $row_plugin = isset($form_state['values']['block']['style']['row_plugin']) ? $form_state['values']['block']['style']['row_plugin'] : NULL;
00096     $row_options = isset($form_state['values']['block']['style']['row_options']) ? $form_state['values']['block']['style']['row_options'] : array();
00097     $this->display_options_row($display_options, $row_plugin, $row_options);
00098     return $display_options;
00099   }
00100 
00104   protected  function display_options_row(&$display_options, $row_plugin, $row_options) {
00105     switch ($row_plugin) {
00106       case 'full_posts':
00107         $display_options['row_plugin'] = 'node';
00108         $display_options['row_options']['build_mode'] = 'full';
00109         $display_options['row_options']['links'] = !empty($row_options['links']);
00110         $display_options['row_options']['comments'] = !empty($row_options['comments']);
00111         break;
00112       case 'teasers':
00113         $display_options['row_plugin'] = 'node';
00114         $display_options['row_options']['build_mode'] = 'teaser';
00115         $display_options['row_options']['links'] = !empty($row_options['links']);
00116         $display_options['row_options']['comments'] = !empty($row_options['comments']);
00117         break;
00118       case 'titles_linked':
00119         $display_options['row_plugin'] = 'fields';
00120         $display_options['field']['title']['link_to_node'] = 1;
00121         break;
00122       case 'titles':
00123         $display_options['row_plugin'] = 'fields';
00124         $display_options['field']['title']['link_to_node'] = 0;
00125         break;
00126     }
00127   }
00128 }

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