[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/station/schedule/views/ -> station_schedule.views.inc (source)

   1  <?php
   2  // $Id: station_schedule.views.inc,v 1.13 2010/09/13 18:54:05 timplunkett Exp $
   3  
   4  /**
   5   * Implementation of hook_views_handlers().
   6   */
   7  function station_schedule_views_handlers() {
   8    return array(
   9      'info' => array(
  10        'path' => drupal_get_path('module', 'station_schedule') . '/views',
  11      ),
  12      'handlers' => array(
  13        // Field handlers
  14        'station_schedule_handler_field_streams' => array(
  15          'parent' => 'views_handler_field',
  16        ),
  17        'station_schedule_handler_field_time' => array(
  18          'parent' => 'views_handler_field',
  19        ),
  20        'station_schedule_handler_field_time_range' => array(
  21          'parent' => 'views_handler_field',
  22        ),
  23        'station_schedule_handler_field_iid_link' => array(
  24          'parent' => 'views_handler_field',
  25        ),
  26        'station_schedule_handler_field_iid_link_edit' => array(
  27          'parent' => 'station_schedule_handler_field_iid_link',
  28        ),
  29        'station_schedule_handler_field_iid_link_remove' => array(
  30          'parent' => 'station_schedule_handler_field_iid_link',
  31        ),
  32  
  33        // Sort handlers
  34        'station_schedule_handler_sort_time' => array(
  35          'parent' => 'views_handler_sort',
  36        ),
  37  
  38        // Argument handlers
  39        'station_schedule_handler_argument_day' => array(
  40          'parent' => 'views_handler_argument',
  41        ),
  42  
  43        // Filter handlers
  44        'station_schedule_handler_filter_time' => array(
  45          'parent' => 'views_handler_filter_numeric',
  46        ),
  47        'station_schedule_handler_filter_schedule_item' => array(
  48          'parent' => 'views_handler_filter_boolean_operator',
  49        ),
  50        'station_schedule_handler_filter_schedule_selected' => array(
  51          'parent' => 'views_handler_filter_boolean_operator',
  52        ),
  53      ),
  54    );
  55  }
  56  
  57  /**
  58   * Implementation of hook_views_plugins().
  59   */
  60  function station_schedule_views_plugins() {
  61    return array(
  62      'module' => 'station_schedule', // This just tells our themes are elsewhere.
  63  //    'argument validator' => array(
  64  //      'station_schedule_day' => array(
  65  //        'title' => t('Validate day'),
  66  //        'handler' => 'station_schedule_plugin_argument_validate_day',
  67  //      ),
  68  //    ),
  69    );
  70  }
  71  
  72  /**
  73   * Implementation of views_query_substitutions().
  74   */
  75  function station_schedule_views_query_substitutions($view) {
  76    $minute = station_minute_from_local_ts();
  77    return array(
  78      '***STATION_CURRENT_MINUTE***' => $minute,
  79      '***STATION_CURRENT_DAY_IN_MINUTES***' => $minute - ($minute % MINUTES_IN_DAY),
  80    );
  81  }
  82  
  83  /**
  84   * Implementation of hook_views_data().
  85   */
  86  function station_schedule_views_data() {
  87    // ----------------------------------------------------------------
  88    // Basic table information.
  89  
  90    // Define the base group of this table. Fields that don't
  91    // have a group defined will go into this field by default.
  92    $data['station_schedule']['table']['group']  = t('Station Schedule');
  93  
  94    // For other base tables, explain how we join
  95    $data['station_schedule']['table']['join'] = array(
  96      'node' => array(
  97        'left_field' => 'nid',
  98        'field' => 'nid',
  99      ),
 100    );
 101  
 102    // ----------------------------------------------------------------
 103    // Fields
 104    $data['station_schedule']['increment'] = array(
 105      'title' => t('Scheduling increment'),
 106      'help' => t("The schedule's block size in minutes."),
 107      'field' => array(
 108        'handler' => 'views_handler_field_numeric',
 109        'click sortable' => TRUE,
 110      ),
 111       'filter' => array(
 112         'handler' => 'views_handler_filter_numeric',
 113         'label' => t('Increment'),
 114      ),
 115      'sort' => array(
 116        'handler' => 'views_handler_sort',
 117      ),
 118    );
 119    $data['station_schedule']['streams'] = array(
 120      'title' => t('Webstream'),
 121      'help' => t("Link to M3U files with stream URLs."),
 122      'field' => array(
 123        'handler' => 'station_schedule_handler_field_streams',
 124      ),
 125    );
 126    $data['station_schedule']['unscheduled_message'] = array(
 127      'title' => t('Unscheduled message'),
 128      'help' => t("Message displayed when there is no scheduled programming."),
 129      'field' => array(
 130        'handler' => 'views_handler_field',
 131        'click sortable' => TRUE,
 132      ),
 133       'filter' => array(
 134         'handler' => 'views_handler_filter_string',
 135         'label' => t('Unscheduled message'),
 136      ),
 137      'sort' => array(
 138        'handler' => 'views_handler_sort',
 139      ),
 140    );
 141    $data['station_schedule']['default_schedule'] = array(
 142      'title' => t('Default Schedule'),
 143      'help' => t("Only display the default schedule."),
 144      'filter' => array(
 145        'handler' => 'station_schedule_handler_filter_schedule_selected',
 146        'title' => t('Default Schedule'),
 147        'type' => 'yes-no',
 148        'label' => t('Default Schedule'),
 149        'help' => t('Only display the default schedule.'),
 150      ),
 151    );
 152  
 153  
 154  
 155    // ----------------------------------------------------------------
 156    // Basic table information.
 157  
 158    $data['station_schedule_item']['table']['group']  = t('Station Schedule Item');
 159    $data['station_schedule_item']['table']['base'] = array(
 160      'field' => 'iid',
 161      'title' => t('Station Schedule Item ID'),
 162      'help' => t("Items on the station's schedules."),
 163    );
 164  
 165    // ----------------------------------------------------------------
 166    // Fields
 167    $data['station_schedule_item']['iid'] = array(
 168      'title' => t('Schedule item id'),
 169      'help' => t("The schedule item's id."),
 170      'field' => array(
 171        'handler' => 'views_handler_field_numeric',
 172      ),
 173    );
 174    $data['station_schedule_item']['link_iid'] = array(
 175      'field' => array(
 176        'title' => t('View link'),
 177        'help' => t('Provide a simple link to the schedule item.'),
 178        'handler' => 'station_schedule_handler_field_iid_link',
 179      ),
 180    );
 181    $data['station_schedule_item']['edit_iid'] = array(
 182      'field' => array(
 183        'title' => t('Edit link'),
 184        'help' => t('Provide a simple link to edit the schedule item.'),
 185        'handler' => 'station_schedule_handler_field_iid_link_edit',
 186      ),
 187    );
 188    $data['station_schedule_item']['remove_iid'] = array(
 189      'field' => array(
 190        'title' => t('Remove link'),
 191        'help' => t('Provide a simple link to remove the schedule item.'),
 192        'handler' => 'station_schedule_handler_field_iid_link_remove',
 193      ),
 194    );
 195    $data['station_schedule_item']['schedule_nid'] = array(
 196      'title' => t('Schedule'),
 197      'help' => t("The schedule this slot belongs to."),
 198      'relationship' => array(
 199        'base' => 'node',
 200        'base field' => 'nid',
 201        'field' => 'schedule_nid',
 202        'handler' => 'views_handler_relationship',
 203        'label' => t('Schedule'),
 204      ),
 205    );
 206    $data['station_schedule_item']['program_nid'] = array(
 207      'title' => t('Program'),
 208      'help' => t("The program scheduled in this slot."),
 209      'relationship' => array(
 210        'base' => 'node',
 211        'base field' => 'nid',
 212        'field' => 'schedule_nid',
 213        'handler' => 'views_handler_relationship',
 214        'label' => t('Program'),
 215      ),
 216    );
 217    $data['station_schedule_item']['time'] = array(
 218      'title' => t('Time range'),
 219      'help' => t("Schedule instance time range."),
 220      'field' => array(
 221        'handler' => 'station_schedule_handler_field_time_range',
 222        'additional fields' => array('start', 'finish'),
 223      ),
 224      'argument' => array(
 225        'handler' => 'station_schedule_handler_argument_day',
 226        'label' => t('Day of week'),
 227      ),
 228      'sort' => array(
 229        'handler' => 'station_schedule_handler_sort_time',
 230      ),
 231    );
 232    $data['station_schedule_item']['start'] = array(
 233      'title' => t('Start'),
 234      'help' => t("Schedule instance start time."),
 235      'field' => array(
 236        'handler' => 'station_schedule_handler_field_time',
 237        'click sortable' => TRUE,
 238      ),
 239      'filter' => array(
 240        'handler' => 'station_schedule_handler_filter_time',
 241        'allow empty' => FALSE,
 242        'label' => t('Start'),
 243      ),
 244      'sort' => array(
 245        'handler' => 'station_schedule_handler_sort_time',
 246      ),
 247    );
 248    $data['station_schedule_item']['finish'] = array(
 249      'title' => t('Finish'),
 250      'help' => t("Schedule instance completion time."),
 251      'field' => array(
 252        'handler' => 'station_schedule_handler_field_time',
 253        'click sortable' => TRUE,
 254      ),
 255      'filter' => array(
 256        'handler' => 'station_schedule_handler_filter_time',
 257        'allow empty' => FALSE,
 258        'label' => t('Finish'),
 259      ),
 260      'sort' => array(
 261        'handler' => 'station_schedule_handler_sort_time',
 262      ),
 263    );
 264    $data['station_schedule_item']['may_archive'] = array(
 265      'title' => t('May be archived'),
 266      'help' => t("Is this program allowed to be stored in the Station Archive."),
 267      'field' => array(
 268        'handler' => 'views_handler_field_boolean',
 269        'click sortable' => TRUE,
 270      ),
 271       'filter' => array(
 272         'handler' => 'views_handler_filter_boolean_operator',
 273         'label' => t('Active'),
 274      ),
 275      'sort' => array(
 276        'handler' => 'views_handler_sort',
 277      ),
 278    );
 279  
 280    return $data;
 281  }
 282  
 283  /**
 284   * Use views_data_alter to add relations from {node} to {schedule_items}.
 285   */
 286  function station_schedule_views_data_alter(&$data) {
 287    $data['node']['station_schedule_iid'] = array(
 288      'group' => t('Station Schedule'),
 289      'title' => t('Scheduled Programs'),
 290      'help' => t('All programs on this schedule.'),
 291      'real field' => 'schedule_nid',
 292  //    'field' => array(
 293  //      'handler' => 'views_handler_field_upload_fid',
 294  //    ),
 295      'filter' => array(
 296        'handler' => 'station_schedule_handler_filter_schedule_item',
 297        'title' => t('Has scheduled programs'),
 298        'type' => 'yes-no',
 299        'label' => t('Has scheduled programs'),
 300        'help' => t('Only display schedules with programs. This can cause duplicates if there are multiple programs scheduled.'),
 301      ),
 302      'relationship' => array(
 303        'title' => t('Scheduled Programs'),
 304        'help' => t('Add a relationship to gain access to data about the programs on a schedule. Note that this relationship will cause duplicate schedule nodes if there are multiple programs on the schedule.'),
 305        'relationship table' => 'node',
 306        'relationship field' => 'nid',
 307        'base' => 'station_schedule_item',
 308        'base field' => 'schedule_nid',
 309        'handler' => 'views_handler_relationship',
 310        'label' => t('Scheduled Programs'),
 311      ),
 312    );
 313    $data['node']['station_program_iid'] = array(
 314      'group' => t('Station Program'),
 315      'title' => t('Program Schedule Times'),
 316      'help' => t('All the times this program is scheduled.'),
 317      'real field' => 'program_nid',
 318  //    'field' => array(
 319  //      'handler' => 'views_handler_field_upload_fid',
 320  //    ),
 321      'filter' => array(
 322        'handler' => 'station_schedule_handler_filter_schedule_item',
 323        'title' => t('Is scheduled'),
 324        'type' => 'yes-no',
 325        'label' => t('Program is scheduled'),
 326        'help' => t('Only display programs that are on a schedule. This can cause duplicates if the schedule is on multiple schedules.'),
 327      ),
 328      'relationship' => array(
 329        'title' => t('Program Scheduling'),
 330        'help' => t('Add a relationship to gain access to data about the times a program is scheduled. Note that this relationship will cause duplicate schedule nodes if the program is multiple slots or on multiple schedules.'),
 331        'relationship table' => 'node',
 332        'relationship field' => 'nid',
 333        'base' => 'station_schedule_item',
 334        'base field' => 'program_nid',
 335        'handler' => 'views_handler_relationship',
 336        'label' => t("Program's scheduling"),
 337      ),
 338    );
 339  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7