[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/dtools/wsod/ -> wsod.inc (source)

   1  <?php
   2  
   3  /**
   4   * @file
   5   *   Include file contain additional functions
   6   *
   7   * @version
   8   *   $Id: wsod.inc,v 1.1.2.4 2009/06/22 12:18:40 kenorb Exp $
   9   *
  10   * @developers:
  11   *   Rafal Wieczorek <kenorb@gmail.com>
  12   */
  13  
  14  /** 
  15   * Validate theme hook files and callbacks
  16   * 
  17   * @param string $router_item
  18   * @return array or false 
  19   */ 
  20  function wsod_validate_theme_hooks($verbose = FALSE, &$output) {
  21      $hooks = theme_get_registry(); // get list of theme hook
  22      $theme_test = true;
  23      $nl = t('<br>');
  24      $output .= t("Validating theme hooks...").$nl;
  25      foreach ($hooks as $hook_name => $hook) {
  26          if (isset($hook['path']) && !file_exists($hook['path'])) {
  27              $output .= t("ERROR: File or path doesn't exist (path: %path; theme callback: %function)", array('%path' => $hook['path'], '%function' => $hook_name)).$nl;
  28              $theme_test = false;
  29          }
  30          $filepath = $hook['path'] ? $hook['path'].'/'.$hook['file'] : $hook['file'];
  31          if (isset($hook['file']) && !file_exists($filepath)) {
  32              $output .= t("ERROR: File or path doesn't exist (path: %path; theme callback: %function)", array('%path' => $filepath, '%function' => $hook_name)).$nl;
  33              $theme_test = false;
  34          }
  35          if (isset($hook['theme path']) && !file_exists($hook['theme path'])) {
  36              $output .= t("ERROR: Theme path doesn't exist (path: %path; theme callback: %function)", array('%path' => $hook['theme path'], '%function' => $hook_name)).$nl;
  37              $theme_test = false;
  38          }
  39          if (isset($hook['access_callback']) && !function_exists($hook['access_callback'])) {
  40              $output .= t("ERROR: Access callback doesn't exist (callback: %function)", array('%function' => $hook['access_callback'])).$nl;
  41              $theme_error = false;
  42          }
  43      }
  44      return $theme_test;
  45  }
  46  
  47  /** 
  48   * Get menu items and simulate menu router callback
  49   * 
  50   * @param string $router_item
  51   * @return array or false 
  52   */ 
  53  function wsod_check_page_callback($router_item, $verbose = FALSE, &$messages, &$content_output) {
  54      $res = FALSE;
  55      ob_start(); // start output buffering
  56      $nl = t('<br>');
  57      if ($router_item) {
  58          if ($router_item['access']) {
  59              if ($router_item['file']) {
  60                  require_once($router_item['file']);
  61                  $file = basename($router_item['file']);
  62                  $messages .= t("Included render file: %file",array('%file' => $file)).$nl; // PRINT included file
  63              }
  64              $messages .= t("Checking %function() page callback...",array('%function' => $router_item['page_callback'])).$nl; // PRINT included file
  65              $res = call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
  66          } else {
  67              $messages .= t("User permission denied to execute %function() page callback...",array('%function' => $router_item['page_callback'])).$nl;
  68          }
  69      }
  70      $content_output = ob_get_clean(); // get output
  71      return $res;
  72  }
  73  


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7