Projet

Général

Profil

Révision 7c856df4

Ajouté par Assos Assos il y a plus de 8 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/libraries/libraries.module
33 33
 * @param $base_path
34 34
 *   Whether to prefix the resulting path with base_path().
35 35
 *
36
 * @return
36
 * @return string
37 37
 *   The path to the specified library or FALSE if the library wasn't found.
38 38
 *
39 39
 * @ingroup libraries
......
67 67
 * in both the site-wide directory and site-specific directory, only the
68 68
 * site-specific version will be listed.
69 69
 *
70
 * @return
70
 * @return array
71 71
 *   A list of library directories.
72 72
 *
73 73
 * @ingroup libraries
......
122 122
 * - sites/$sitename/libraries
123 123
 * - any directories specified via hook_libraries_info_file_paths()
124 124
 *
125
 * @return
125
 * @return array
126 126
 *   An array of info files, keyed by library name. The values are the paths of
127 127
 *   the files.
128 128
 */
......
429 429
/**
430 430
 * Applies default properties to a library definition.
431 431
 *
432
 * @library
432
 * @param array $library
433 433
 *   An array of library information, passed by reference.
434
 * @name
434
 * @param string $name
435 435
 *   The machine name of the passed-in library.
436
 *
437
 * @return array
438
 *   The library information array with defaults populated.
436 439
 */
437
function libraries_info_defaults(&$library, $name) {
440
function libraries_info_defaults(array &$library, $name) {
438 441
  $library += array(
439 442
    'machine name' => $name,
440 443
    'name' => $name,
441 444
    'vendor url' => '',
442 445
    'download url' => '',
446
    'download file url' => '',
443 447
    'path' => '',
444 448
    'library path' => NULL,
445 449
    'version callback' => 'libraries_get_version',
......
472 476
/**
473 477
 * Tries to detect a library and its installed version.
474 478
 *
475
 * @param $name
476
 *   The machine name of a library to return registered information for.
479
 * @param string $name
480
 *   (optional) The machine name of a library to detect and return registered
481
 *   information for. If omitted, information about all registered libraries is
482
 *   returned.
477 483
 *
478 484
 * @return array|false
479
 *   An associative array containing registered information for the library
480
 *   specified by $name, or FALSE if the library $name is not registered.
485
 *   An associative array containing registered information for all libraries,
486
 *   the registered information for the library specified by $name, or FALSE if
487
 *   the library $name is not registered.
481 488
 *   In addition to the keys returned by libraries_info(), the following keys
482 489
 *   are contained:
483 490
 *   - installed: A boolean indicating whether the library is installed. Note
......
491 498
 *
492 499
 * @see libraries_info()
493 500
 */
494
function libraries_detect($name) {
501
function libraries_detect($name = NULL) {
502
  if (!isset($name)) {
503
    $libraries = &libraries_info();
504
    foreach ($libraries as $name => $library) {
505
      libraries_detect($name);
506
    }
507
    return $libraries;
508
  }
509

  
495 510
  // Re-use the statically cached value of libraries_info() to save memory.
496 511
  $library = &libraries_info($name);
497 512

  
......
531 546
      $library['version'] = call_user_func_array($library['version callback'], array_merge(array($library), $library['version arguments']));
532 547
    }
533 548
    else {
534
      $library['version'] = $library['version callback']($library, $library['version arguments']);
549
      $library['version'] = call_user_func($library['version callback'], $library, $library['version arguments']);
535 550
    }
536 551
    if (empty($library['version'])) {
537 552
      $library['error'] = 'not detected';
......
693 708
 *   The number of loaded files.
694 709
 */
695 710
function libraries_load_files($library) {
711
  // As this key was added after 7.x-2.1 cached library structures might not
712
  // have it.
713
  $library += array('post-load integration files' => FALSE);
714

  
696 715
  // Load integration files.
697 716
  if (!$library['post-load integration files'] && !empty($library['integration files'])) {
698 717
    $enabled_themes = array();
......
867 886
  }
868 887
  fclose($file);
869 888
}
889

  
890
/**
891
 * Implements hook_help().
892
 */
893
function libraries_help($path, $arg) {
894
  switch ($path) {
895
    case 'admin/reports/libraries':
896
      return t('Click on a library for a status report or detailed installation instructions in case the library is not installed correctly.');
897
  }
898
}
899

  
900
/**
901
 * Implements hook_menu().
902
 */
903
function libraries_menu() {
904
  $items = array();
905
  $items['admin/reports/libraries'] = array(
906
    'title' => 'Libraries',
907
    'description' => 'An overview of libraries installed on this site.',
908
    'page callback' => 'drupal_get_form',
909
    'page arguments' => array('libraries_admin_overview'),
910
    'access arguments' => array('access site reports'),
911
    'file' => 'libraries.admin.inc'
912
  );
913
  $items['admin/reports/libraries/%libraries_ui'] = array(
914
    'title' => 'Library status report',
915
    'description' => 'Status overview for a single library',
916
    'page callback' => 'drupal_get_form',
917
    'page arguments' => array('libraries_admin_library_status_form', 3),
918
    'access arguments' => array('access site reports'),
919
    'file' => 'libraries.admin.inc'
920
  );
921
  return $items;
922
}
923

  
924
/**
925
 * Loads library information for display in the user interface.
926
 *
927
 * This can be used as a menu loader function by specifying a '%libraries_ui'
928
 * parameter in a path.
929
 *
930
 * We do not use libraries_load() (and, thus, a '%libraries' parameter) directly
931
 * for displaying library information in the user interface as we do not want
932
 * the library files to be loaded.
933
 *
934
 * @param string $name
935
 *   The machine name of a library to return registered information for.
936
 *
937
 * @return array|false
938
 *   An associative array containing registered information for the library
939
 *   specified by $name, or FALSE if the library $name is not registered.
940
 *
941
 * @see libraries_detect()
942
 * @see libraries_menu()
943
 */
944
function libraries_ui_load($name) {
945
  return libraries_detect($name);
946
}

Formats disponibles : Unified diff