You are here

function date_views_browser_get_views in Date 5.2

Same name and namespace in other branches
  1. 5 date_views.inc \date_views_browser_get_views()

Find all the views that qualify for date browser treatment

Parameters

$view: if called from Views UI validation, $edit_view will be populated, otherwise it will be empty. Use that to tell if the list needs to be refreshed.

3 calls to date_views_browser_get_views()
date_clear_all in date/date.module
Empty or reset cached values.
theme_date_views_browser_full_view in date/date.theme
View, themed so it can be overridden
_date_views_query_alter in date/date_views.inc
Implementation of hook_views_query().

File

date/date_views.inc, line 645

Code

function date_views_browser_get_views($reset = FALSE) {
  static $date_views_browser_views;
  if (empty($date_views_browser_views) || $reset) {
    $cid = 'date_browser_views';
    if (!$reset && ($cached = cache_get($cid, 'cache_views'))) {
      $date_views_browser_views = unserialize($cached->data);
    }
    else {
      $date_views_browser_views = array();
      $arguments = array();
      $fields = content_fields();
      foreach ($fields as $field) {
        if ($field['type'] == DATE_UNIX || $field['type'] == DATE_ISO) {
          $arguments = array_merge($arguments, _date_views_arguments($field));
        }
      }
      $argument_list = implode("','", array_keys($arguments));
      if (!$argument_list) {
        return array();
      }
      $argument_list = "'" . $argument_list . "'";
      $result = db_query("SELECT arg.*, view.name FROM {view_argument} arg INNER JOIN {view_view} view ON arg.vid=view.vid WHERE arg.type IN ({$argument_list}) AND view.page_type='date_views_browser'");
      while ($view = db_fetch_object($result)) {
        $date_views_browser_views[$view->name] = $view;
      }
      cache_set($cid, 'cache_views', serialize($date_views_browser_views));
    }
  }
  return $date_views_browser_views;
}