source: sipes/modules_contrib/libraries/libraries.module @ 6e81fb4

stableversion-3.0
Last change on this file since 6e81fb4 was 177a560, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agrego el directorio de modulos contribuidos de drupal

  • Propiedad mode establecida a 100755
File size: 3.4 KB
Línea 
1<?php
2// $Id: libraries.module,v 1.2.2.3 2011/01/27 02:25:40 sun Exp $
3
4/**
5 * @file
6 * External library handling for Drupal modules.
7 */
8
9/**
10 * Gets the path of a library.
11 *
12 * @param $name
13 *   The machine name of a library to return the path for.
14 * @param $base_path
15 *   Whether to prefix the resulting path with base_path().
16 *
17 * @return
18 *   The path to the specified library.
19 *
20 * @ingroup libraries
21 */
22function libraries_get_path($name, $base_path = FALSE) {
23  static $libraries;
24
25  if (!isset($libraries)) {
26    $libraries = libraries_get_libraries();
27  }
28
29  $path = ($base_path ? base_path() : '');
30  if (!isset($libraries[$name])) {
31    // Most often, external libraries can be shared across multiple sites, so
32    // we return sites/all/libraries as the default path.
33    $path .= 'sites/all/libraries/' . $name;
34  }
35  else {
36    $path .= $libraries[$name];
37  }
38
39  return $path;
40}
41
42/**
43 * Returns an array of library directories.
44 *
45 * Returns an array of library directories from the all-sites directory
46 * (i.e. sites/all/libraries/), the profiles directory, and site-specific
47 * directory (i.e. sites/somesite/libraries/). The returned array will be keyed
48 * by the library name. Site-specific libraries are prioritized over libraries
49 * in the default directories. That is, if a library with the same name appears
50 * in both the site-wide directory and site-specific directory, only the
51 * site-specific version will be listed.
52 *
53 * @return
54 *   A list of library directories.
55 *
56 * @ingroup libraries
57 */
58function libraries_get_libraries() {
59  global $profile;
60
61  // When this function is called during Drupal's initial installation process,
62  // the name of the profile that is about to be installed is stored in the
63  // global $profile variable. At all other times, the regular system variable
64  // contains the name of the current profile, and we can call variable_get()
65  // to determine the profile.
66  if (!isset($profile)) {
67    $profile = variable_get('install_profile', 'default');
68  }
69
70  $directory = 'libraries';
71  $searchdir = array();
72  $config = conf_path();
73
74  // Similar to 'modules' and 'themes' directories in the root directory,
75  // certain distributions may want to place libraries into a 'libraries'
76  // directory in Drupal's root directory.
77  $searchdir[] = $directory;
78
79  // The 'profiles' directory contains pristine collections of modules and
80  // themes as organized by a distribution.  It is pristine in the same way
81  // that /modules is pristine for core; users should avoid changing anything
82  // there in favor of sites/all or sites/<domain> directories.
83  if (file_exists("profiles/$profile/$directory")) {
84    $searchdir[] = "profiles/$profile/$directory";
85  }
86
87  // Always search sites/all/*.
88  $searchdir[] = 'sites/all/' . $directory;
89
90  // Also search sites/<domain>/*.
91  if (file_exists("$config/$directory")) {
92    $searchdir[] = "$config/$directory";
93  }
94
95  // Retrieve list of directories.
96  // @todo Core: Allow to scan for directories.
97  $directories = array();
98  $nomask = array('CVS');
99  foreach ($searchdir as $dir) {
100    if (is_dir($dir) && $handle = opendir($dir)) {
101      while (FALSE !== ($file = readdir($handle))) {
102        if (!in_array($file, $nomask) && $file[0] != '.') {
103          if (is_dir("$dir/$file")) {
104            $directories[$file] = "$dir/$file";
105          }
106        }
107      }
108      closedir($handle);
109    }
110  }
111
112  return $directories;
113}
114
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.