You are here

function workflow_views_views_default_views in Workflow 7.2

Same name and namespace in other branches
  1. 6.2 workflow_views/includes/workflow_views.views_default.inc \workflow_views_views_default_views()
  2. 6 workflow_views/includes/workflow_views.views_default.inc \workflow_views_views_default_views()
  3. 7 workflow_views/includes/workflow_views.views_default.inc \workflow_views_views_default_views()

Implements hook_views_default_views().

Loads all Views, custom made by this module, as stored in files xxx.view.inc.

https://api.drupal.org/api/views/views.api.php/function/hook_views_defau... "This hook allows modules to provide their own views which can either be used as-is or as a "starter" for users to build from. "This hook should be placed in MODULENAME.views_default.inc and it will be auto-loaded. "The $view->disabled boolean flag indicates whether the View should be enabled (FALSE) or disabled (TRUE) by default.

"A best practice is to go through and add t() to all title and label strings, with the exception of menu strings.

See also

http://www.deckfifty.com/blog/2012-02/using-drupal-views-code

http://mc-kenna.com/drupal/2009/05/managing-drupal-views-the-proper-way

http://www.chapterthree.com/blog/matt_cheney/howto_best_practices_embedd...

File

workflow_views/workflow_views.module, line 74
Provide views integration for workflows.

Code

function workflow_views_views_default_views() {
  $views = array();
  $modulename = 'workflow_views';

  // Find views in this directory, and the 'views' subdirectory.
  $dir = drupal_get_path('module', $modulename) . '/';
  $regex = '/\\.view\\.inc$/';
  $files = array();
  $files += file_scan_directory($dir, $regex, array(
    'recurse' => FALSE,
  ));
  $files += file_scan_directory($dir . 'views/', $regex, array(
    'recurse' => FALSE,
  ));
  foreach ($files as $filepath => $file) {
    require $filepath;
    if (isset($view)) {
      $views[$view->name] = $view;
    }
  }
  return $views;
}