Currently you cant use ctools_include if the file is not in a subdir, which is kind of unhandy.

fairly easy extension:

function ctools_include($file, $module = 'ctools', $dir = 'includes') {
  static $used = array();
  $ref = $used[$module];
  
  if ($dir != NULL) {
    $ref = $used[$module][$dir];
  }  
    
  if (!isset($ref[$file])) {
    if ($dir != NULL) {    
      require_once './' . drupal_get_path('module', $module) . "/$dir/$file.inc";
      $used[$module][$dir][$file] = true;
    }
    else {
      require_once './' . drupal_get_path('module', $module) . "/$file.inc";
      $used[$module][$file] = true;
    }
  }
}

Comments

eugenmayer’s picture

Priority: Normal » Minor

surely a minor

dawehner’s picture

Status: Active » Needs review

.

neclimdul’s picture

StatusFileSize
new871 bytes
new873 bytes

I'm not really sure about the NULL logic. Would the attached patch work as well? The logic seems a little more straightforward.

This definitely needs some review though, I wrote this off the cuff without testing it.

voxpelli’s picture

StatusFileSize
new444 bytes

I would propose a patch like the one I attach instead.

Avoids possible conflicts between dir-names and file-names and is a lot more compact.

voxpelli’s picture

StatusFileSize
new463 bytes

Reroll that avoids a // path on empty $dir.

merlinofchaos’s picture

Status: Needs review » Fixed

Committed #5 to all branches.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.