fgcf.views_default.inc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. // $Id$
  3. /**
  4. * @file
  5. * Implementation of hook_views_default_views().
  6. *
  7. */
  8. /**
  9. * Implements hook_views_default_views().
  10. *
  11. * @return array
  12. */
  13. function fgcf_views_default_views() {
  14. // Needed to avoid fatal 'class view not found' error when Features
  15. // checks the status of the feature.
  16. // http://drupal.org/node/509174#comment-2715130
  17. views_include('view');
  18. $info = fgcf_views_api();
  19. $path = $info['path'];
  20. $defaults = basename(__FILE__);
  21. $views = array();
  22. foreach (new DirectoryIterator($path) as $file_info) {
  23. if ($file_info->isDot()) {
  24. continue;
  25. }
  26. $name = $file_info->getFilename();
  27. if ($name == $defaults || !preg_match('/^fgcf_\w*\.php$/', $name, $matches)) {
  28. continue;
  29. }
  30. // Cannot use require_once, as scanning may load them once before entering
  31. // here, and they need to be reported each time.
  32. require $name; // will define $view and $handler
  33. if (!isset($view) || !isset($view->name)) {
  34. watchdog('fgcf', 'Ill-formed view @name.', array('@name' => $name), WATCHDOG_NOTICE);
  35. }
  36. else {
  37. $views[$view->name] = $view;
  38. }
  39. unset($view, $handler);
  40. }
  41. return $views;
  42. }