Revision ed912c77
Added by Assos Assos about 6 years ago
drupal7/sites/all/modules/libraries/CHANGELOG.txt | ||
---|---|---|
1 |
Libraries 7.x-2.x, xxxx-xx-xx |
|
2 |
----------------------------- |
|
3 |
#2699799 by flaviovs, hanoii: Support reading version from package.json. |
|
4 |
#2816781 by joelstein: Add a 'access library reports' permission. |
|
5 |
#2823735 by amanaplan, tstoeckler: Add admin_menu cache clear integration. |
|
6 |
#2745763 by Albert Volkman, tstoeckler: Allow downloading all libraries at once. |
|
7 |
#2310753 by tstoeckler: Avoid libraries_get_libraries() scanning the root. |
|
8 |
#2341955 by sadashiv, tstoeckler: Clear library cache on library report. |
|
9 |
#819610 by tstoeckler: Show variants and dependencies in the UI. |
|
10 |
#2724925 by ron_s, tstoeckler: Separate installed from uninstalled libraries. |
|
1 | 11 |
|
2 | 12 |
Libraries 7.x-2.3, 2016-05-12 |
3 | 13 |
----------------------------- |
... | ... | |
94 | 104 |
#719896 by tstoeckler, sun: Added starting point for hook_libraries_info(). |
95 | 105 |
|
96 | 106 |
|
97 |
Libraries 7.x-1.x, xxxx-xx-xx |
|
98 |
----------------------------- |
|
99 |
|
|
100 | 107 |
Libraries 7.x-1.0, 2010-01-27 |
101 | 108 |
----------------------------- |
102 | 109 |
#743522 by sun: Ported to D7. |
103 | 110 |
|
104 | 111 |
|
105 |
Libraries 6.x-1.x, xxxx-xx-xx |
|
106 |
----------------------------- |
|
107 |
|
|
108 | 112 |
Libraries 6.x-1.0, 2010-01-27 |
109 | 113 |
----------------------------- |
110 | 114 |
#1028744 by tstoeckler: Code clean-up. |
drupal7/sites/all/modules/libraries/css/libraries.admin.css | ||
---|---|---|
1 |
.libraries-table { |
|
2 |
margin-bottom: 2em; |
|
3 |
} |
drupal7/sites/all/modules/libraries/libraries.admin.inc | ||
---|---|---|
20 | 20 |
* The form array for the overview form. |
21 | 21 |
*/ |
22 | 22 |
function libraries_admin_overview(array $form, array &$form_state) { |
23 |
$header = array(t('Name'), t('Status'), t('Installed version'), t('Provider'), t('Links')); |
|
24 |
$rows = array(); |
|
25 |
|
|
26 |
$libraries = libraries_detect(); |
|
27 |
uasort($libraries, 'libraries_admin_sort_title'); |
|
28 |
|
|
29 |
foreach ($libraries as $machine_name => $library) { |
|
23 |
// Only show variants for installed libraries. |
|
24 |
$header_installed = array(t('Name'), t('Version'), t('Variants'), t('Dependencies'), t('Provider'), t('Links')); |
|
25 |
// Only show status for libraries with an error. |
|
26 |
$header_error = array(t('Name'), t('Status'), t('Version'), t('Dependencies'), t('Provider'), t('Links')); |
|
27 |
// For unregistered libraries the only information we can show is the path. |
|
28 |
$header_unregistered = array(t('Name'), t('Path')); |
|
29 |
|
|
30 |
$rows_installed = array(); |
|
31 |
$rows_error = array(); |
|
32 |
$rows_unregistered = array(); |
|
33 |
|
|
34 |
// Registered libraries: we prefer to use libraries_detect() since it provides |
|
35 |
// library metadata. |
|
36 |
$libraries_registered = libraries_detect(); |
|
37 |
uasort($libraries_registered, 'libraries_admin_sort_title'); |
|
38 |
|
|
39 |
// Unregistered libraries: modules can depend on Libraries API without sharing |
|
40 |
// metadata by using libraries_get_path(). Libraries can also be placed in the |
|
41 |
// filesystem that are incorrectly installed, a wrong version, or a standalone |
|
42 |
// not connected to any module. In these cases, libraries_get_libraries() |
|
43 |
// provides a full library list. Libraries found by libraries_get_libraries(), |
|
44 |
// but not identified by libraries_detect, are displayed in a separate table. |
|
45 |
$libraries_unregistered = libraries_get_libraries(); |
|
46 |
natcasesort($libraries_unregistered); |
|
47 |
|
|
48 |
foreach ($libraries_registered as $machine_name => $library) { |
|
30 | 49 |
$actions = array(); |
50 |
$row = array(); |
|
31 | 51 |
|
32 | 52 |
if ($library['vendor url']) { |
33 |
$actions[] = l('Homepage', $library['vendor url']);
|
|
53 |
$actions[] = l(t('Homepage'), $library['vendor url']);
|
|
34 | 54 |
} |
35 | 55 |
if ($library['download url']) { |
36 |
$actions[] = l('Download', $library['download url']); |
|
56 |
$actions[] = l(t('Download'), $library['download url']); |
|
57 |
} |
|
58 |
|
|
59 |
$row['data'][] = l($library['name'], 'admin/reports/libraries/' . $machine_name); |
|
60 |
// Only show status for libraries with an error. See above. |
|
61 |
if (!$library['installed']) { |
|
62 |
$row['data'][] = drupal_ucfirst($library['error']); |
|
63 |
} |
|
64 |
$row['data'][] = isset($library['version']) ? $library['version'] : ''; |
|
65 |
if ($library['installed']) { |
|
66 |
$row['data'][] = implode(', ', array_keys($library['variants'])); |
|
67 |
} |
|
68 |
$row['data'][] = libraries_admin_get_dependencies($library); |
|
69 |
$row['data'][] = libraries_admin_get_provider_with_type($library); |
|
70 |
$row['data'][] = implode(' | ', $actions); |
|
71 |
$row['class'] = $library['installed'] ? array('ok') : array('warning'); |
|
72 |
|
|
73 |
if ($library['installed']) { |
|
74 |
$rows_installed[] = $row; |
|
37 | 75 |
} |
76 |
else { |
|
77 |
$rows_error[] = $row; |
|
78 |
} |
|
79 |
|
|
80 |
// Filter registered libraries from unregistered libraries. |
|
81 |
unset($libraries_unregistered[$library['machine name']]); |
|
82 |
} |
|
83 |
|
|
84 |
// Build table of registered libraries with installed status. |
|
85 |
$form['libraries']['installed'] = array( |
|
86 |
'#theme' => 'libraries_table_with_title', |
|
87 |
'#title' => t('Installed'), |
|
88 |
'#header' => $header_installed, |
|
89 |
'#rows' => $rows_installed, |
|
90 |
'#description' => t('These libraries are registered and installed correctly.'), |
|
91 |
'#empty' => t('There are currently no libraries that are registered and installed.'), |
|
92 |
); |
|
93 |
|
|
94 |
// Build table of registered libraries with error status. |
|
95 |
$form['libraries']['error'] = array( |
|
96 |
'#theme' => 'libraries_table_with_title', |
|
97 |
'#title' => t('Uninstalled'), |
|
98 |
'#header' => $header_error, |
|
99 |
'#rows' => $rows_error, |
|
100 |
'#description' => t('These libraries are registered but not installed. They may not need to be installed in case a module or theme provides optional integration with a library.'), |
|
101 |
'#empty' => t('There are currently no libraries that are registered but not installed.'), |
|
102 |
); |
|
38 | 103 |
|
39 |
$rows[] = array( |
|
104 |
// Build table of unregistered libraries. |
|
105 |
foreach ($libraries_unregistered as $name => $path) { |
|
106 |
$rows_unregistered[] = array( |
|
40 | 107 |
'data' => array( |
41 |
l($library['name'], 'admin/reports/libraries/' . $machine_name), |
|
42 |
($library['installed'] ? t('OK') : drupal_ucfirst($library['error'])), |
|
43 |
(isset($library['version']) ? $library['version'] : ''), |
|
44 |
libraries_admin_get_provider_with_type($library), |
|
45 |
implode(' | ', $actions), |
|
108 |
$name, |
|
109 |
$path, |
|
46 | 110 |
), |
47 |
'class' => ($library['installed'] ? array('ok') : array('error')), |
|
48 | 111 |
); |
49 | 112 |
} |
50 |
|
|
51 |
$form['libraries']['list'] = array( |
|
52 |
'#theme' => 'table', |
|
53 |
'#header' => $header, |
|
54 |
'#rows' => $rows, |
|
55 |
'#empty' => t('There are currently no libraries installed'), |
|
113 |
$form['libraries']['unregistered'] = array( |
|
114 |
'#theme' => 'libraries_table_with_title', |
|
115 |
'#title' => t('Unregistered'), |
|
116 |
'#header' => $header_unregistered, |
|
117 |
'#rows' => $rows_unregistered, |
|
118 |
'#description' => t('These libraries were found in the filesystem but there is no metadata about them.'), |
|
119 |
// Do not show the table at all, if there are no unregistered libraries. |
|
120 |
'#access' => (bool) $libraries_unregistered, |
|
56 | 121 |
); |
57 | 122 |
|
123 |
// Clear the cached library information so that the library can be loaded if |
|
124 |
// it was just downloaded. Because these instructions use libraries_detect() |
|
125 |
// directly, they will never use the cached information, but this avoids the |
|
126 |
// overview showing a library as installed but it not being loadable. |
|
127 |
libraries_cache_clear(); |
|
128 |
|
|
58 | 129 |
return $form; |
59 | 130 |
} |
60 | 131 |
|
... | ... | |
99 | 170 |
break; |
100 | 171 |
|
101 | 172 |
case 'missing dependency': |
102 |
$form['instructions']['instruction']['#markup'] = t('There a missing dependency in your configuration that prevent this library to work properly.') . '<br>';
|
|
173 |
$form['instructions']['instruction']['#markup'] = t('There is a missing dependency in your configuration that prevents this library from working properly.') . '<br>';
|
|
103 | 174 |
break; |
104 | 175 |
|
105 | 176 |
case 'incompatible dependency': |
106 |
$form['instructions']['instruction']['#markup'] = t('There an incompatible dependency in your configuration that prevent this library to work properly.') . '<br>';
|
|
177 |
$form['instructions']['instruction']['#markup'] = t('There is an incompatible dependency in your configuration that prevents this library from working properly.') . '<br>';
|
|
107 | 178 |
break; |
108 | 179 |
} |
109 | 180 |
} |
... | ... | |
483 | 554 |
return strnatcasecmp($a['name'], $b['name']); |
484 | 555 |
} |
485 | 556 |
|
557 |
/** |
|
558 |
* Returns the library's dependencies, if any. |
|
559 |
* |
|
560 |
* @param array $library |
|
561 |
* A library information array. |
|
562 |
* |
|
563 |
* @return string |
|
564 |
* The dependencies. |
|
565 |
*/ |
|
566 |
function libraries_admin_get_dependencies($library) { |
|
567 |
$dependencies = array(); |
|
568 |
foreach ($library['dependencies'] as $dependency_name) { |
|
569 |
if ($dependency = libraries_info($dependency_name)) { |
|
570 |
$dependencies[] = $dependency['name']; |
|
571 |
} |
|
572 |
else { |
|
573 |
$dependencies[] = $dependency_name; |
|
574 |
} |
|
575 |
} |
|
576 |
return implode(', ', $dependencies); |
|
577 |
} |
|
578 |
|
|
486 | 579 |
/** |
487 | 580 |
* Returns the library's provider. |
488 | 581 |
* |
drupal7/sites/all/modules/libraries/libraries.api.php | ||
---|---|---|
47 | 47 |
* Unless 'version' is declared or libraries_get_version() is being used as |
48 | 48 |
* a version callback, 'version callback' must be declared. In the latter |
49 | 49 |
* case, however, 'version arguments' must be declared in the specified way. |
50 |
* For libraries that provide a package.json file, use |
|
51 |
* 'libraries_get_package_json_version' as the version callback. |
|
50 | 52 |
* - version arguments: (optional) A list of arguments to pass to the version |
51 | 53 |
* callback. Version arguments can be declared either as an associative |
52 | 54 |
* array whose keys are the argument names or as an indexed array without |
drupal7/sites/all/modules/libraries/libraries.drush.inc | ||
---|---|---|
23 | 23 |
'arguments' => array( |
24 | 24 |
'libraries' => 'A comma delimited list of library machine names.', |
25 | 25 |
), |
26 |
'required-arguments' => TRUE, |
|
26 |
'options' => array( |
|
27 |
'all' => 'Download all registered libraries.', |
|
28 |
), |
|
27 | 29 |
); |
28 | 30 |
|
29 | 31 |
return $items; |
... | ... | |
42 | 44 |
* Clears the library cache. |
43 | 45 |
*/ |
44 | 46 |
function libraries_drush_invalidate_cache() { |
45 |
// @see drupal_flush_all_caches() |
|
46 |
foreach (libraries_flush_caches() as $table) { |
|
47 |
cache_clear_all('*', $table, TRUE); |
|
48 |
} |
|
47 |
libraries_cache_clear(); |
|
49 | 48 |
} |
50 | 49 |
|
51 | 50 |
/** |
... | ... | |
109 | 108 |
function drush_libraries_download() { |
110 | 109 |
drush_command_include('pm-download'); |
111 | 110 |
|
112 |
$libraries = libraries_info();
|
|
111 |
$all_libraries = libraries_detect();
|
|
113 | 112 |
|
114 |
// @todo Consider supporting downloading all downloadable libraries. |
|
115 |
// @todo Consider offering a selection if no library is specified. |
|
116 |
foreach (pm_parse_arguments(func_get_args(), FALSE) as $machine_name) { |
|
117 |
if (!isset($libraries[$machine_name])) { |
|
118 |
$message = dt("The !library library is not registered with Libraries API.\n", array('!library' => $machine_name)); |
|
119 |
$message .= dt("Provide an info file for it or implement hook_libraries_info().\n"); |
|
120 |
$message .= dt("See hook_libraries_info() for more information.\n"); |
|
121 |
drush_set_error('DRUSH_LIBRARY_UKNOWN', $message); |
|
122 |
continue; |
|
113 |
// Prepare a list of names of downloadable libraries. |
|
114 |
$downloadable_names = array(); |
|
115 |
foreach ($all_libraries as $machine_name => $library) { |
|
116 |
// Skip libraries that are already installed. |
|
117 |
// @todo Allow (optionally) re-downloading installing libraries. |
|
118 |
if (!empty($library['download file url']) && !$library['installed']) { |
|
119 |
$downloadable_names[] = $machine_name; |
|
123 | 120 |
} |
124 |
$library = $libraries[$machine_name];
|
|
121 |
}
|
|
125 | 122 |
|
126 |
if (empty($library['download file url'])) { |
|
127 |
$message = dt("The !library library cannot be downloaded.\n", array('!library' => $machine_name)); |
|
128 |
$message .= dt("Libraries need to specify a download file URL to support being downloaded via Drush.\n"); |
|
129 |
$message .= dt("See hook_libraries_info() for more information.\n"); |
|
130 |
drush_set_error('DRUSH_LIBRARY_NOT_DOWNLOADABLE', $message); |
|
131 |
continue; |
|
123 |
// Gather a list of libraries to download. If '--all' was specified, that |
|
124 |
// takes precedence over any other arguments. Otherwise and if no arguments |
|
125 |
// are specified, we present a choice of all downloadable libraries. |
|
126 |
if (drush_get_option('all', FALSE) && $downloadable_names) { |
|
127 |
$machine_names = $downloadable_names; |
|
128 |
} |
|
129 |
elseif (pm_parse_arguments(func_get_args(), FALSE)) { |
|
130 |
$machine_names = array(); |
|
131 |
foreach (pm_parse_arguments(func_get_args(), FALSE) as $machine_name) { |
|
132 |
// If there was an error with with one of the libraries, continue to try |
|
133 |
// to install any remaining libraries. |
|
134 |
if (!isset($all_libraries[$machine_name])) { |
|
135 |
$message = dt("The !library library is not registered with Libraries API.\n", array('!library' => $machine_name)); |
|
136 |
$message .= dt("Provide an info file for it or implement hook_libraries_info().\n"); |
|
137 |
$message .= dt("See hook_libraries_info() for more information.\n"); |
|
138 |
drush_set_error('DRUSH_LIBRARY_UKNOWN', $message); |
|
139 |
continue; |
|
140 |
} |
|
141 |
if (empty($all_libraries[$machine_name]['download file url'])) { |
|
142 |
$message = dt("The !library library cannot be downloaded.\n", array('!library' => $machine_name)); |
|
143 |
$message .= dt("Libraries need to specify a download file URL to support being downloaded via Drush.\n"); |
|
144 |
$message .= dt("See hook_libraries_info() for more information.\n"); |
|
145 |
drush_set_error('DRUSH_LIBRARY_NOT_DOWNLOADABLE', $message); |
|
146 |
continue; |
|
147 |
} |
|
148 |
$machine_names[] = $machine_name; |
|
149 |
} |
|
150 |
} |
|
151 |
elseif ($downloadable_names) { |
|
152 |
$machine_names = drush_choice_multiple(drupal_map_assoc($downloadable_names), FALSE, 'Select which libraries to download.'); |
|
153 |
// If the operation was cancelled by the user, or if no libraries were |
|
154 |
// selected, bail out without any further error message. |
|
155 |
if (!$machine_names) { |
|
156 |
return; |
|
132 | 157 |
} |
133 |
$download_url = $library['download file url']; |
|
158 |
} |
|
159 |
else { |
|
160 |
drush_log(dt('There are no registered, uninstalled libraries that can be downloaded.'), 'warning'); |
|
161 |
return; |
|
162 |
} |
|
163 |
|
|
164 |
foreach ($machine_names as $machine_name) { |
|
165 |
$download_url = $all_libraries[$machine_name]['download file url']; |
|
134 | 166 |
|
135 | 167 |
drush_log(dt('Downloading library !name ...', array('!name' => $machine_name))); |
136 | 168 |
|
... | ... | |
205 | 237 |
drush_delete_dir($install_location, TRUE); |
206 | 238 |
} |
207 | 239 |
else { |
208 |
drush_log(dt("Skip installation of !project to !dest.", array('!project' => $library['machine name'], '!dest' => $install_location)), 'warning');
|
|
240 |
drush_log(dt("Skip installation of !project to !dest.", array('!project' => $machine_name, '!dest' => $install_location)), 'warning');
|
|
209 | 241 |
continue; |
210 | 242 |
} |
211 | 243 |
} |
drupal7/sites/all/modules/libraries/libraries.info | ||
---|---|---|
8 | 8 |
files[] = tests/LibrariesUnitTest.test |
9 | 9 |
files[] = tests/LibrariesWebTestBase.test |
10 | 10 |
|
11 |
; Information added by Drupal.org packaging script on 2016-05-12
|
|
12 |
version = "7.x-2.3"
|
|
11 |
; Information added by Drupal.org packaging script on 2018-09-10
|
|
12 |
version = "7.x-2.4"
|
|
13 | 13 |
core = "7.x" |
14 | 14 |
project = "libraries" |
15 |
datestamp = "1463077450" |
|
16 |
|
|
15 |
datestamp = "1536581584" |
drupal7/sites/all/modules/libraries/libraries.install | ||
---|---|---|
34 | 34 |
// during the 7.x-2.x cycle. |
35 | 35 |
registry_rebuild(); |
36 | 36 |
} |
37 |
|
|
38 |
/** |
|
39 |
* Grant the "View library reports" permission to roles with the "View site reports" permission. |
|
40 |
*/ |
|
41 |
function libraries_update_7202() { |
|
42 |
$rids = array_keys(user_roles(FALSE, 'access site reports')); |
|
43 |
foreach ($rids as $rid) { |
|
44 |
_update_7000_user_role_grant_permissions($rid, array('access library reports'), 'libraries'); |
|
45 |
} |
|
46 |
} |
drupal7/sites/all/modules/libraries/libraries.module | ||
---|---|---|
25 | 25 |
} |
26 | 26 |
} |
27 | 27 |
|
28 |
/** |
|
29 |
* Implements hook_admin_menu_cache_info(). |
|
30 |
*/ |
|
31 |
function libraries_admin_menu_cache_info() { |
|
32 |
$caches['libraries'] = array( |
|
33 |
'title' => t('Libraries'), |
|
34 |
'callback' => 'libraries_cache_clear', |
|
35 |
); |
|
36 |
return $caches; |
|
37 |
} |
|
38 |
|
|
39 |
/** |
|
40 |
* Clears the cached library information. |
|
41 |
*/ |
|
42 |
function libraries_cache_clear() { |
|
43 |
foreach (libraries_flush_caches() as $bin) { |
|
44 |
// Using the wildcard argument leads to DrupalDatabaseCache::clear() |
|
45 |
// truncating the libraries cache table which is more performant that |
|
46 |
// deleting the rows. |
|
47 |
cache_clear_all('*', $bin, TRUE); |
|
48 |
} |
|
49 |
} |
|
50 |
|
|
28 | 51 |
/** |
29 | 52 |
* Gets the path of a library. |
30 | 53 |
* |
... | ... | |
77 | 100 |
$profile = drupal_get_path('profile', drupal_get_profile()); |
78 | 101 |
$config = conf_path(); |
79 | 102 |
|
103 |
// $config and $profile should never be empty in a proper Drupal setup. |
|
104 |
// However, we should never search into the root filesystem under any |
|
105 |
// circumstances, so just bail out in that case. |
|
106 |
if (!$profile || !$config) { |
|
107 |
return array(); |
|
108 |
} |
|
109 |
|
|
80 | 110 |
// Similar to 'modules' and 'themes' directories in the root directory, |
81 | 111 |
// certain distributions may want to place libraries into a 'libraries' |
82 | 112 |
// directory in Drupal's root directory. |
... | ... | |
546 | 576 |
$library['version'] = call_user_func_array($library['version callback'], array_merge(array($library), $library['version arguments'])); |
547 | 577 |
} |
548 | 578 |
else { |
549 |
$library['version'] = call_user_func($library['version callback'], $library, $library['version arguments']);
|
|
579 |
$library['version'] = call_user_func_array($library['version callback'], array(&$library, $library['version arguments']));
|
|
550 | 580 |
} |
551 | 581 |
if (empty($library['version'])) { |
552 | 582 |
$library['error'] = 'not detected'; |
... | ... | |
887 | 917 |
fclose($file); |
888 | 918 |
} |
889 | 919 |
|
920 |
/** |
|
921 |
* Gets the version information from a library's package.json file. |
|
922 |
* |
|
923 |
* @param $library |
|
924 |
* An associative array containing all information about the library. |
|
925 |
* @param $options |
|
926 |
* This callback expects no option. |
|
927 |
* @return |
|
928 |
* A string containing the version of the library. |
|
929 |
* |
|
930 |
* @see libraries_get_path() |
|
931 |
*/ |
|
932 |
function libraries_get_package_json_version($library, $options) { |
|
933 |
$file = DRUPAL_ROOT . '/' . $library['library path'] . '/package.json'; |
|
934 |
if (!file_exists($file)) { |
|
935 |
return; |
|
936 |
} |
|
937 |
|
|
938 |
$content = file_get_contents($file); |
|
939 |
if (!$content) { |
|
940 |
return; |
|
941 |
} |
|
942 |
|
|
943 |
$data = drupal_json_decode($content); |
|
944 |
if (isset($data['version'])) { |
|
945 |
return $data['version']; |
|
946 |
} |
|
947 |
} |
|
948 |
|
|
890 | 949 |
/** |
891 | 950 |
* Implements hook_help(). |
892 | 951 |
*/ |
893 | 952 |
function libraries_help($path, $arg) { |
894 | 953 |
switch ($path) { |
895 | 954 |
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.');
|
|
955 |
return t('Click on a library for a status report or detailed installation instructions.'); |
|
897 | 956 |
} |
898 | 957 |
} |
899 | 958 |
|
959 |
/** |
|
960 |
* Implements hook_permission(). |
|
961 |
*/ |
|
962 |
function libraries_permission() { |
|
963 |
return array( |
|
964 |
'access library reports' => array( |
|
965 |
'title' => t('View library reports'), |
|
966 |
), |
|
967 |
); |
|
968 |
} |
|
969 |
|
|
900 | 970 |
/** |
901 | 971 |
* Implements hook_menu(). |
902 | 972 |
*/ |
... | ... | |
907 | 977 |
'description' => 'An overview of libraries installed on this site.', |
908 | 978 |
'page callback' => 'drupal_get_form', |
909 | 979 |
'page arguments' => array('libraries_admin_overview'), |
910 |
'access arguments' => array('access site reports'),
|
|
980 |
'access arguments' => array('access library reports'),
|
|
911 | 981 |
'file' => 'libraries.admin.inc' |
912 | 982 |
); |
913 | 983 |
$items['admin/reports/libraries/%libraries_ui'] = array( |
... | ... | |
915 | 985 |
'description' => 'Status overview for a single library', |
916 | 986 |
'page callback' => 'drupal_get_form', |
917 | 987 |
'page arguments' => array('libraries_admin_library_status_form', 3), |
918 |
'access arguments' => array('access site reports'),
|
|
988 |
'access arguments' => array('access library reports'),
|
|
919 | 989 |
'file' => 'libraries.admin.inc' |
920 | 990 |
); |
921 | 991 |
return $items; |
... | ... | |
944 | 1014 |
function libraries_ui_load($name) { |
945 | 1015 |
return libraries_detect($name); |
946 | 1016 |
} |
1017 |
|
|
1018 |
/** |
|
1019 |
* Implements hook_theme(). |
|
1020 |
*/ |
|
1021 |
function libraries_theme($existing, $type, $theme, $path) { |
|
1022 |
// Because we extend the 'table' theme function, fetch the respective |
|
1023 |
// variables dynamically. |
|
1024 |
$common_theme = drupal_common_theme(); |
|
1025 |
$variables = $common_theme['table']['variables'] + array('title' => '', 'description' => ''); |
|
1026 |
return array( |
|
1027 |
'libraries_table_with_title' => array( |
|
1028 |
'variables' => $variables, |
|
1029 |
'file' => 'libraries.theme.inc', |
|
1030 |
), |
|
1031 |
); |
|
1032 |
} |
drupal7/sites/all/modules/libraries/libraries.theme.inc | ||
---|---|---|
1 |
<?php |
|
2 |
|
|
3 |
/** |
|
4 |
* @file |
|
5 |
* Provides theme and preprocess functions for Libraries API. |
|
6 |
*/ |
|
7 |
|
|
8 |
/** |
|
9 |
* Prepare variables for theming a table with a title. |
|
10 |
* |
|
11 |
* @param array $variables |
|
12 |
* An array of theme variables, passed by reference. |
|
13 |
*/ |
|
14 |
function template_preprocess_libraries_table_with_title(&$variables) { |
|
15 |
drupal_add_css(drupal_get_path('module', 'libraries') . '/css/libraries.admin.css'); |
|
16 |
|
|
17 |
$variables['attributes'] += array('class' => array()); |
|
18 |
$variables['attributes']['class'][] = 'libraries-table'; |
|
19 |
} |
|
20 |
|
|
21 |
/** |
|
22 |
* Returns HTML for a table with a title. |
|
23 |
* |
|
24 |
* @param array $variables |
|
25 |
* An array theme variables. |
|
26 |
* |
|
27 |
* @return string |
|
28 |
* The HTML output for this table with a title. |
|
29 |
*/ |
|
30 |
function theme_libraries_table_with_title(array $variables) { |
|
31 |
$output = ''; |
|
32 |
$output .= '<h2>' . $variables['title'] . '</h2>'; |
|
33 |
$output .= '<div class="description">' . $variables['description'] . '</div>'; |
|
34 |
$output .= theme_table($variables); |
|
35 |
return $output; |
|
36 |
} |
drupal7/sites/all/modules/libraries/tests/LibrariesAdminWebTest.test | ||
---|---|---|
40 | 40 |
* Tests the libraries report at /admin/reports/libraries. |
41 | 41 |
*/ |
42 | 42 |
public function testLibrariesReportOverview() { |
43 |
$this->getWithPermissions(array('access site reports'), 'admin/reports/libraries'); |
|
44 |
$this->assertRaw('Libraries'); |
|
43 |
$this->getWithPermissions(array('access library reports'), 'admin/reports/libraries'); |
|
44 |
// Assert the page title and table titles show up. |
|
45 |
$this->assertText('Libraries'); |
|
46 |
$this->assertRaw('<h2>Installed</h2>'); |
|
47 |
$this->assertRaw('<h2>Uninstalled</h2>'); |
|
48 |
|
|
49 |
// Make sure the table headings show up. |
|
50 |
$this->assertText('Name'); |
|
51 |
$this->assertText('Status'); |
|
52 |
$this->assertText('Version'); |
|
53 |
$this->assertText('Variants'); |
|
54 |
$this->assertText('Dependencies'); |
|
55 |
$this->assertText('Provider'); |
|
56 |
$this->assertText('Links'); |
|
45 | 57 |
|
46 | 58 |
// Make sure that all the libraries are listed. |
47 | 59 |
$libraries = libraries_info(); |
... | ... | |
51 | 63 |
$this->assertLinkByHref('admin/reports/libraries/' . $library['machine name']); |
52 | 64 |
} |
53 | 65 |
|
54 |
// Make sure that all possible statuses are displayed. |
|
55 |
$this->assertText('OK'); |
|
66 |
// Make sure that all possible error statuses are displayed. |
|
56 | 67 |
$this->assertText('Not found'); |
57 | 68 |
$this->assertText('Not detected'); |
58 | 69 |
$this->assertText('Not supported'); |
... | ... | |
73 | 84 |
* Tests the libraries report for an installed library. |
74 | 85 |
*/ |
75 | 86 |
public function testLibrariesReportInstalled() { |
76 |
$this->getWithPermissions(array('access site reports'), 'admin/reports/libraries/example_files');
|
|
87 |
$this->getWithPermissions(array('access library reports'), 'admin/reports/libraries/example_files');
|
|
77 | 88 |
$this->assertRaw('Status report for library <em class="placeholder">Example files</em>'); |
78 | 89 |
$this->assertRaw('The <em class="placeholder">Example files</em> library is installed correctly.'); |
79 | 90 |
// Check that the information in the status report is displayed. |
... | ... | |
88 | 99 |
* Tests the libraries report for a missing library. |
89 | 100 |
*/ |
90 | 101 |
public function testLibrariesReportMissing() { |
91 |
$this->getWithPermissions(array('access site reports'), 'admin/reports/libraries/example_missing');
|
|
102 |
$this->getWithPermissions(array('access library reports'), 'admin/reports/libraries/example_missing');
|
|
92 | 103 |
$this->assertRaw('Status report for library <em class="placeholder">Example missing</em>'); |
93 | 104 |
$this->assertRaw('The <em class="placeholder">Example missing</em> library could not be found.'); |
94 | 105 |
// Check that the download link is being displayed. |
... | ... | |
100 | 111 |
* Tests the libraries report for a missing library. |
101 | 112 |
*/ |
102 | 113 |
public function testLibrariesReportNotDetected() { |
103 |
$this->getWithPermissions(array('access site reports'), 'admin/reports/libraries/example_undetected_version');
|
|
114 |
$this->getWithPermissions(array('access library reports'), 'admin/reports/libraries/example_undetected_version');
|
|
104 | 115 |
$this->assertRaw('Status report for library <em class="placeholder">Example undetected version</em>'); |
105 | 116 |
$this->assertRaw('The version of the <em class="placeholder">Example undetected version</em> library could not be detected.'); |
106 | 117 |
} |
... | ... | |
109 | 120 |
* Tests the libraries report for a missing library. |
110 | 121 |
*/ |
111 | 122 |
public function testLibrariesReportNotSupported() { |
112 |
$this->getWithPermissions(array('access site reports'), 'admin/reports/libraries/example_unsupported_version');
|
|
123 |
$this->getWithPermissions(array('access library reports'), 'admin/reports/libraries/example_unsupported_version');
|
|
113 | 124 |
$this->assertRaw('Status report for library <em class="placeholder">Example unsupported version</em>'); |
114 | 125 |
$this->assertRaw('The installed version <em class="placeholder">1</em> of the <em class="placeholder">Example unsupported version</em> library is not supported.'); |
115 | 126 |
// Check that the download link is being displayed. |
drupal7/sites/all/modules/libraries/tests/libraries/example_info_file.libraries.info | ||
---|---|---|
2 | 2 |
name = Example info file |
3 | 3 |
|
4 | 4 |
|
5 |
; Information added by Drupal.org packaging script on 2016-05-12
|
|
6 |
version = "7.x-2.3"
|
|
5 |
; Information added by Drupal.org packaging script on 2018-09-10
|
|
6 |
version = "7.x-2.4"
|
|
7 | 7 |
core = "7.x" |
8 | 8 |
project = "libraries" |
9 |
datestamp = "1463077450" |
|
10 |
|
|
9 |
datestamp = "1536581584" |
drupal7/sites/all/modules/libraries/tests/modules/libraries_test_module/libraries_test_module.info | ||
---|---|---|
5 | 5 |
dependencies[] = libraries |
6 | 6 |
hidden = TRUE |
7 | 7 |
|
8 |
; Information added by Drupal.org packaging script on 2016-05-12
|
|
9 |
version = "7.x-2.3"
|
|
8 |
; Information added by Drupal.org packaging script on 2018-09-10
|
|
9 |
version = "7.x-2.4"
|
|
10 | 10 |
core = "7.x" |
11 | 11 |
project = "libraries" |
12 |
datestamp = "1463077450" |
|
13 |
|
|
12 |
datestamp = "1536581584" |
drupal7/sites/all/modules/libraries/tests/themes/libraries_test_theme/libraries_test_theme.info | ||
---|---|---|
3 | 3 |
core = 7.x |
4 | 4 |
hidden = TRUE |
5 | 5 |
|
6 |
; Information added by Drupal.org packaging script on 2016-05-12
|
|
7 |
version = "7.x-2.3"
|
|
6 |
; Information added by Drupal.org packaging script on 2018-09-10
|
|
7 |
version = "7.x-2.4"
|
|
8 | 8 |
core = "7.x" |
9 | 9 |
project = "libraries" |
10 |
datestamp = "1463077450" |
|
11 |
|
|
10 |
datestamp = "1536581584" |
Also available in: Unified diff
Weekly update of contrib modules