You are here

function _jquery_calendar_path in jQuery World Calendars API 7

Helper function to get the library path using Libraries module API.

Parameters

$library: Library name to return its path.

$filename: A library filename to check its existence as an additional condition.

Return value

Either the library path or FALSE on fail.

See also

libraries_get_path()

http://drupal.org/project/libraries

3 calls to _jquery_calendar_path()
_jquery_calendar_component_path in ./jquery_calendar.module
Helper function to build a library component path.
_jquery_calendar_datepicker_themes in ./jquery_calendar.module
Internal helper to collect all datepicker themes.
_jquery_calendar_requirements_check in ./jquery_calendar.module
Helper function that checks module requirements.

File

./jquery_calendar.module, line 376
Implements necessary hooks, API and helpers for jQuery World Calendars.

Code

function _jquery_calendar_path($library = 'jquery.calendars', $filename = '') {

  // Get library path via Libraries API.
  $path = libraries_get_path($library);

  // Scan the given path to see if it's that proper one.
  $directory = file_scan_directory($path, '/.*/', array(
    'recurse' => FALSE,
  ));

  // Check that the specified file exists in the given directory.
  $exists = !empty($filename) ? file_exists($path . '/' . $filename) : TRUE;

  // If all is set, return the path.
  if (is_dir($path) && $exists && !empty($directory)) {
    return $path;
  }

  // Or #fail.
  return FALSE;
}