/[drupal]/contributions/modules/coder/coder_review/includes/coder_review_7x.inc
ViewVC logotype

Diff of /contributions/modules/coder/coder_review/includes/coder_review_7x.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.42, Sun Oct 18 13:35:57 2009 UTC revision 1.43, Sun Oct 18 21:28:23 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: coder_review_7x.inc,v 1.41 2009/10/18 12:45:36 snpower Exp $  // $Id: coder_review_7x.inc,v 1.42 2009/10/18 13:35:57 snpower Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 252  function coder_review_7x_reviews() { Line 252  function coder_review_7x_reviews() {
252    
253      // Block      // Block
254        // http://drupal.org/node/224333#block_optional --- Block module now optional        // http://drupal.org/node/224333#block_optional --- Block module now optional
255          array(
256            '#type' => 'callback',
257            '#source' => 'allphp',
258            '#value' => '_coder_review_7x_optional_block_review_callback',
259            '#warning_callback' => '_coder_review_7x_optional_block_warning',
260          ),
261    
262        // http://drupal.org/node/224333#remove_op        // http://drupal.org/node/224333#remove_op
263        array(        array(
# Line 943  function _coder_review_7x_drupal_behavio Line 949  function _coder_review_7x_drupal_behavio
949  }  }
950    
951  /**  /**
952     * Make sure user defined block module as a dependency if using block functions.
953     *
954     * @see http://drupal.org/node/224333#block_optional
955     */
956    function _coder_review_7x_optional_block_review_callback(&$coder_args, $review, $rule, $lines, &$results) {
957      $functions_to_check = array('block_list', 'block_custom_block_get', 'block_page_build');
958      $filename = $coder_args['#filename'];
959    
960      // Skip for unit tests as there is no physical file.
961      if ($filename == 'snippet.php') {
962        return;
963      }
964    
965      // Find out the info filename and load it.
966      $pos = strpos($filename, '.');
967      $modulename = substr($filename, 0, $pos);
968      $ini = parse_ini_file($modulename .'.info');
969    
970      // Check if the dependency has been declared.
971      $dependency_declared = is_array($ini['dependencies']) ? in_array('block', $ini['dependencies']) : FALSE;
972    
973      if (file_exists($filename) && $modulename != 'block' && !$dependency_declared) {
974        if ($lines = file($filename)) {
975          foreach ($lines as $lineno => $line) {
976            foreach ($functions_to_check as $function) {
977              if (preg_match("/[\s\(]$function\(/", $line)) {
978                $severity_name = _coder_review_severity_name($coder_args, $review, $rule);
979                $tmprule = $rule;
980                $tmprule['#warning_callback'] = '_coder_review_7x_optional_block_warning';
981                _coder_review_error($results, $tmprule, $severity_name, $lineno, $line);
982              }
983            }
984          }
985        }
986      }
987    }
988    
989    /**
990   * Define the warning callbacks.   * Define the warning callbacks.
991   */   */
992  function _coder_review_7x_referer_uri_warning() {  function _coder_review_7x_referer_uri_warning() {
# Line 1883  function _coder_review_7x_no_jsenabled_w Line 1927  function _coder_review_7x_no_jsenabled_w
1927    );    );
1928  }  }
1929    
1930    function _coder_review_7x_optional_block_warning() {
1931      return array(
1932        '#warning' => t("Block module is now optional, make sure you declare it as a dependency in your module's .info file."),
1933        '#link' => 'http://drupal.org/node/224333#block_optional',
1934      );
1935    }
1936    
1937  function _coder_review_7x_module_implements_warning() {  function _coder_review_7x_module_implements_warning() {
1938    return array(    return array(
1939      '#warning' => t('Use module_implements not module_list when calling hook implementations.'),      '#warning' => t('Use module_implements not module_list when calling hook implementations.'),

Legend:
Removed from v.1.42  
changed lines
  Added in v.1.43

  ViewVC Help
Powered by ViewVC 1.1.2