[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/calendar/includes/ -> calendar.views.inc (source)

   1  <?php
   2  //$Id: calendar.views.inc,v 1.1.2.11 2010/11/29 11:41:58 karens Exp $
   3  /**
   4   *  Implementation of hook_views_query()
   5   *  
   6   *  Handle the date_popup calendar goto date.
   7   */
   8  function calendar_views_query_alter(&$view, &$query) {
   9    // Check if a new date has been selected and if so redirect.
  10    if (isset($_POST['calendar_goto']) && $_POST['view_name'] == $view->name) {
  11      require_once('./'. drupal_get_path('module', 'date_api') .'/date_api_elements.inc');
  12      $format = date_limit_format(variable_get('date_format_short', 'm/d/Y - H:i'), array('year', 'month', 'day'));
  13      $date = date_convert_from_custom($_POST['calendar_goto']['date'], $format);  
  14      switch ($_POST['calendar_type']) {
  15        case 'year':
  16          $arg = date_pad(date_part_extract($date, 'year'), 4);
  17          break; 
  18        case 'month':
  19          $arg = date_pad(date_part_extract($date, 'year'), 4) .'-'. date_pad(date_part_extract($date, 'month'));
  20          break; 
  21        case 'week':
  22          $arg = date_pad(date_part_extract($date, 'year'), 4) .'-W'. date_pad(date_week($date));
  23          break; 
  24        default:
  25          $arg = date_pad(date_part_extract($date, 'year'), 4) .'-'. date_pad(date_part_extract($date, 'month')) .'-'. date_pad(date_part_extract($date, 'day'));
  26          break; 
  27          
  28      }
  29      drupal_goto(str_replace($_POST['calendar_previous_arg'], $arg, $_POST['view_url']));
  30      exit();
  31    }
  32  }
  33  
  34  function calendar_views_pre_view(&$view, &$display_id, &$args) {
  35    //
  36  }
  37  
  38  /**
  39   * @file
  40   * 
  41   * Creates calendar displays of Views results.
  42   * 
  43   * Create a new calendar by enabling or cloning the default calendar,
  44   * changing the date argument to use the correct date field(s), and setting
  45   * up the year, month, day, week, and block views with the desired styles 
  46   * and fields.
  47   * 
  48   * Unlike previous versions of the Calendar module, there is just a single
  49   * Date argument instead of year, month, and day arguments. The argument
  50   * value will be YYYY-MM-DD for a day, YYYY-MM for a month, YYYY for a
  51   * year, and YYYY-W99 for a week. There is a default option to set the 
  52   * argument to the current date when the argument is empty.
  53   * 
  54   * A calendar display creates calendar navigation and links to 
  55   * multiple displays for the year, month, day, or week views. The actual
  56   * displays are created by attaching calendar views that use whatever
  57   * styles are desired for those pages. 
  58   * 
  59   * Calendar views are attachments to create the year, month, day,
  60   * and week displays. They can be set to use any style, either a
  61   * calendar style or any other Views style, like teasers or lists.
  62   * If you don't want to use one of them, don't attach it to
  63   * anything. Only the attached views will show up in the calendar.
  64   * 
  65   * A calendar block will create a calendar block for the
  66   * view results. Attach a block view to the block and set up the
  67   * desired style in the block view. 
  68   */
  69  /**
  70   * Implementation of hook_views_plugins
  71   */
  72  function calendar_views_plugins() {
  73    $path = drupal_get_path('module', 'calendar');
  74    $theme_path = $path;
  75    if (module_exists('calendar_multiday')) {
  76      $theme_path = drupal_get_path('module', 'calendar_multiday');
  77    }
  78    
  79    $views_path = drupal_get_path('module', 'views');
  80    require_once "./$theme_path/theme/theme.inc";
  81  
  82    $data = array(
  83      'module' => 'calendar', // This just tells our themes are elsewhere.
  84      'display' => array(
  85        // Parents are not really displays, just needed so the files can
  86        // be included.
  87        'parent' => array(
  88          'no ui' => TRUE,
  89          'handler' => 'views_plugin_display',
  90          'path' => "$views_path/plugins",
  91          'parent' => '',
  92        ),
  93        'page' => array(
  94          'no ui' => TRUE,
  95          'handler' => 'views_plugin_display_page',
  96          'path' => "$views_path/plugins",
  97          'parent' => 'parent',
  98        ),
  99        'block' => array(
 100          'no ui' => TRUE,
 101          'handler' => 'views_plugin_display_block',
 102          'path' => "$views_path/plugins",
 103          'parent' => 'parent',
 104        ),
 105        'attachment' => array(
 106          'no ui' => TRUE,
 107          'handler' => 'views_plugin_display_attachment',
 108          'path' => "$views_path/plugins",
 109          'parent' => 'parent',
 110        ),
 111        'calendar_attachment' => array(
 112          'handler' => 'calendar_plugin_display_attachment',
 113          'path' => "$path/includes",
 114          'parent' => 'attachment',
 115          'no ui' => TRUE,
 116          ),
 117        // Main calendar display plugin.
 118        'calendar' => array(
 119          'title' => t('Calendar page'),
 120          'help' => t('Calendar page. Attach Calendar period attachments to this page, set to show the year, month, day, and week views.'),
 121          'handler' => 'calendar_plugin_display_page',
 122          'path' => "$path/includes",
 123          'parent' => 'page',
 124          'theme' => 'views_view',
 125          'no ui' => TRUE,
 126          //'no remove' => TRUE,
 127          'uses hook menu' => TRUE,
 128          'uses hook block' => FALSE,
 129          'use ajax' => TRUE,
 130          'use pager' => FALSE,
 131          'accept attachments' => TRUE,
 132          'admin' => t('Calendar page'),
 133          'help topic' => 'getting-started',
 134          'js' => array(
 135            'misc/farbtastic/farbtastic.js', 
 136            drupal_get_path('module', 'calendar') .'/js/calendar_colorpicker.js',
 137            ),
 138        ),
 139        // Calendar block display plugin.
 140        'calendar_block' => array(
 141          'title' => t('Calendar block'),
 142          'help' => t('Calendar page. Attach a Calendar period attachment to this block, set to show the year, month, day, or week view.'),
 143          'handler' => 'calendar_plugin_display_block',
 144          'path' => "$path/includes",
 145          'parent' => 'block',
 146          'theme' => 'views_view',
 147          'no ui' => TRUE,
 148          //'no remove' => TRUE,
 149          'uses hook block' => TRUE,
 150          'use ajax' => TRUE,
 151          'use pager' => FALSE,
 152          'use more' => TRUE,
 153          'accept attachments' => TRUE,
 154          'admin' => t('Calendar block'),
 155          'help topic' => 'getting-started',
 156        ),
 157        // Display plugins for calendar displays.
 158        'calendar_period' => array(
 159          'title' => t('Calendar period'),
 160          'help' => t('An attachment for a Year, Month, Day, or Week calendar display, using any style you choose. Attach to a Calendar page and/or a Calendar block.'),
 161          'handler' => 'calendar_plugin_display_attachment',
 162          'path' => "$path/includes",
 163          'file' => 'calendar_plugin_display_attachment.inc',
 164          'parent' => 'calendar_attachment',
 165          'theme' => 'views_view',
 166          'no ui' => TRUE,
 167          //'no remove' => TRUE,
 168          'use ajax' => TRUE,
 169          'use pager' => TRUE,
 170          'admin' => t('Calendar page year, month, week, or day view'),
 171          'help topic' => 'getting-started',
 172        ),
 173      ),
 174      'style' => array(
 175        'parent' => array(
 176          // this isn't really a display but is necessary so the file can
 177          // be included.
 178          'no ui' => TRUE,
 179          'handler' => 'views_plugin_style',
 180          'path' => "$views_path/plugins",
 181          'parent' => '',
 182        ),
 183        // Style plugin for the navigation.
 184        'calendar_nav' => array(
 185          'title' => t('Calendar navigation'),
 186          'help' => t('Creates back/next navigation and calendar links.'),
 187          'handler' => 'calendar_plugin_style',
 188          'path' => "$path/includes",
 189          'parent' => 'parent',
 190          'theme' => 'calendar_main',
 191          'theme file' => 'theme.inc',
 192          'theme path' => "$theme_path/theme",
 193          'uses row plugin' => FALSE,
 194          'uses fields' => TRUE,
 195          'uses options' => FALSE,
 196          'type' => 'calendar', // Only used on calendar page or block displays.
 197          'even empty' => TRUE,
 198        ),
 199        'calendar_style' => array(
 200          'title' => t('Calendar'),
 201          'help' => t('Displays Views results in a calendar.'),
 202          'handler' => 'calendar_view_plugin_style',
 203          'path' => "$path/includes",
 204          'parent' => 'calendar_nav',
 205          'theme' => 'calendar_month',
 206          'theme file' => 'theme.inc',
 207          'theme path' => "$theme_path/theme",
 208          'additional themes' => array(
 209            'calendar_year' => 'style',
 210            'calendar_day' => 'style',
 211            'calendar_week' => 'style',
 212            'calendar_mini' => 'style',
 213            ),
 214          'uses row plugin' => FALSE,
 215          'uses fields' => TRUE,
 216          'uses options' => TRUE,
 217          'type' => 'normal',
 218          'even empty' => TRUE,
 219        ),
 220      ),
 221    );
 222    
 223    if (module_exists('calendar_multiday')) {
 224      $data['style']['calendar_style']['additional themes'] += array(
 225        'calendar_day_overlap' => 'style',
 226        'calendar_week_overlap' => 'style',    
 227      );
 228    }
 229  
 230    return $data;
 231  }


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7