You are here

function boost_views_generate_default_list in Boost 6

Genrate a list of views based off of defaults.

Views that have a path, can be cached by boost & anonymous users can access

Return value

array (view_name . ' - ' . display_name . ' - /' . path => Enabled/Disabled)

3 calls to boost_views_generate_default_list()
boost_admin_boost_performance_page_submit in ./boost.admin.inc
submit boost_admin_boost_performance_page form submissions.
boost_cron in ./boost.module
Implementation of hook_cron(). Performs periodic actions.
boost_views_get_valid_list in ./boost.module
Genrate a list of valid views that boost will search for new content.

File

./boost.module, line 325
Provides static file caching for Drupal text output. Pages, Feeds, ect...

Code

function boost_views_generate_default_list() {
  $account = user_load(0);
  $views = views_get_all_views();
  $enabled = array();
  $disabled = array();
  foreach ($views as $view_name => $view) {

    // disabled views get nothing.
    if (!empty($view->disabled)) {
      unset($views[$view_name]);
      continue;
    }
    $view
      ->init_display();
    foreach ($view->display as $display_id => $display) {

      // Anonymous users can access view
      if (!$view
        ->access($display_id, $account)) {
        continue;
      }
      $hash = $view_name . ' - ' . $display_id;

      // Use the default view
      if (strcmp($display_id, 'default') == 0) {
        $enabled[$hash] = $hash;
      }
      elseif (isset($display->display_options['path'])) {
        $path = $display->display_options['path'];
        $hash = $view_name . ' - ' . $display_id . ' - /' . $path;

        // Path is cacheable via boost & does not take arguments
        if (boost_is_cacheable($path) && !stristr($path, '%')) {
          $enabled[$hash] = $hash;
        }
        else {
          $disabled[$hash] = 0;
        }
      }
      else {
        $disabled[$hash] = 0;
      }
    }
  }
  ksort($disabled);
  natcasesort($enabled);
  $checkboxes = array_merge(array(
    'line-break' => 0,
  ), $disabled, $enabled);
  return $checkboxes;
}