You are here

function _simplhtmldom_get_library_path in simplehtmldom API 7.2

Same name and namespace in other branches
  1. 8.2 helper.inc \_simplhtmldom_get_library_path()
  2. 6.2 helper.inc \_simplhtmldom_get_library_path()

Returns path of simplhtmldom library.

Return value

bool|string Path to the library.

2 calls to _simplhtmldom_get_library_path()
simplehtmldom.module in ./simplehtmldom.module
Include the only file of the library.
simplehtmldom_requirements in ./simplehtmldom.install
Implements hook_requirements().

File

./helper.inc, line 13
Helper functions.

Code

function _simplhtmldom_get_library_path() {
  $file = 'simple_html_dom.php';
  $library = 'simplehtmldom';

  // Implement simple cache.
  $library_path =& drupal_static(__FUNCTION__);
  if (!empty($library_path)) {
    return $library_path;
  }

  // Support libraries module.
  if (module_exists('libraries') && function_exists('libraries_get_path')) {
    $library_path = libraries_get_path($library) . "/{$file}";
    if (file_exists($library_path)) {
      return $library_path;
    }
  }
  else {
    $paths = array(
      'sites/all/libraries/' . $library,
      drupal_get_path('module', 'simplehtmldom') . '/' . $library,
      drupal_get_path('module', 'simplehtmldom') . "/libraries",
      'profiles/' . variable_get('install_profile', 'default') . '/libraries/' . $library,
    );
    foreach ($paths as $library_dir) {
      $library_path = $library_dir . "/{$file}";
      if (file_exists($library_path)) {
        return $library_path;
      }
    }
  }
  return FALSE;
}