You are here

function _syntaxhighlighter_scan_lib_location in Syntax Highlighter 6.2

Same name and namespace in other branches
  1. 6 syntaxhighlighter.module \_syntaxhighlighter_scan_lib_location()
  2. 7.2 syntaxhighlighter.module \_syntaxhighlighter_scan_lib_location()
  3. 7 syntaxhighlighter.module \_syntaxhighlighter_scan_lib_location()

Do an exhaustive scan of file directories for the location of the syntaxhighlighter js lib, Allow the syntaxhighlighter js library to be installed in any of the following locations and under any sub-directory (except 'src'): 1) syntaxhighlighter module directory 2) sites/<site_domain>/files (whereever the "public://" path is) 3) sites/all/libraries 4) the install profile libraries directory

Return value

the file location of the js lib or NULL if not found

1 call to _syntaxhighlighter_scan_lib_location()
_syntaxhighlighter_get_lib_location in ./syntaxhighlighter.module

File

./syntaxhighlighter.module, line 375
Syntax highlight code using the Syntaxhighlighter javascript library. See http://alexgorbatchev.com/wiki/SyntaxHighlighter

Code

function _syntaxhighlighter_scan_lib_location() {
  $directories = array(
    drupal_get_path('module', 'syntaxhighlighter'),
    file_directory_path(),
    'sites/all/libraries',
  );

  // When this function is called during Drupal's initial installation process,
  // the name of the profile that is about to be installed is stored in the
  // global $profile variable. At all other times, the regular system variable
  // contains the name of the current profile, and we can call variable_get()
  // to determine the profile.
  global $profile;
  if (!isset($profile)) {
    $profile = variable_get('install_profile', 'default');
  }
  $directories[] = "profiles/{$profile}/libraries";
  foreach ($directories as $d) {
    foreach (file_scan_directory($d, 'shCore\\.js$', array(
      '.',
      '..',
      'CVS',
      'src',
      'pupload',
      'plupload',
    )) as $filename => $file_info) {

      // the path to syntaxhighlighter lib, (-18 to chop off "/scripts/shCore.js"
      // part at the end
      return substr($filename, 0, -18);
    }
  }
  return NULL;
}