Loading openlayers.install +1 −1 Original line number Diff line number Diff line Loading @@ -460,7 +460,7 @@ function openlayers_requirements($phase) { ); } else { $variant = Config::get('openlayers.variant'); $variant = Openlayers::getLibraryVersion(); $requirements['openlayers3'] = array( 'title' => $t('Openlayers'), 'severity' => REQUIREMENT_ERROR, Loading openlayers.module +4 −29 Original line number Diff line number Diff line Loading @@ -215,14 +215,12 @@ function openlayers_libraries_info() { $js_css_group = Config::get('openlayers.js_css.group'); } $info = system_get_info('module', 'openlayers'); $module_version = $info['version'] ? $info['version'] : '7.x-3.x'; $module_path = drupal_get_path('module', 'openlayers'); $library_path = libraries_get_path('openlayers3'); $versions = scandir($library_path . '/versions'); $local_variants = []; foreach ($versions as $key => $version) { foreach ($versions as $version) { $variant_path = $library_path . '/versions/' . $version; if (is_dir($variant_path) && substr($version, 0, 1) == 'v') { $local_variants['local:' . substr($version, 1)] = [ Loading Loading @@ -349,38 +347,15 @@ function openlayers_libraries_info() { 'timeout' => 10, ), ), 'variants' => [], 'variants' => $local_variants, 'dependencies' => array( 'openlayers3_integration', ), ); if ($local_version = Openlayers::getLocalLibraryVersion()) { unset($libraries['openlayers3']['library path']); $libraries['openlayers3']['variants'] = $local_variants; $libraries['openlayers3']['variants']['local:' . $local_version] = array( 'name' => 'Openlayers ' . $local_version, 'files' => array( 'js' => array( 'build/ol.js' => array( 'type' => 'file', 'weight' => 6, 'group' => $js_css_group, ), ), 'css' => array( 'css/ol.css' => array( 'type' => 'file', 'weight' => 4, 'group' => $js_css_group, ), ), ), ); } return $libraries; } Loading src/Config.php +0 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ class Config { 'openlayers.js_css.weight' => 20, 'openlayers.js_css.media' => 'screen', 'openlayers.edit_view_map' => 'openlayers_map_view_edit_form', 'openlayers.variant' => 'local:3.11.2', 'openlayers.debug' => 0, ); if ($key == NULL) { Loading src/Openlayers.php +9 −23 Original line number Diff line number Diff line Loading @@ -249,27 +249,14 @@ class Openlayers { * Return the version of the Openlayers library set in the configuration. */ public static function getLibraryVersion() { $variant = Config::get('openlayers.variant'); if (strpos($variant, 'local-') !== FALSE) { $version = self::getLocalLibraryVersion(); } else { $version = Config::get('openlayers.variant', NULL); } $version = Config::get('openlayers.variant'); if (strpos($version, 'local:') !== FALSE) { return $version; } /** * Return the version of the Openlayers library in use. * * @return string * Return the version of the Openlayers library in the filesystem. */ public static function getLocalLibraryVersion() { if ($path = libraries_get_path('openlayers3')) { $versions = current(array_diff(scandir($path . '/versions'), ['.', '..'])); } return $versions; $version = array_diff(scandir(libraries_get_path('openlayers3') . '/versions'), ['.', '..']); rsort($version); $version = current($version); return str_replace('v', 'local:', $version); } /** Loading Loading @@ -408,7 +395,7 @@ class Openlayers { $attached['libraries_load'] = array( 'openlayers3' => array( 'openlayers3', Config::get('openlayers.variant', NULL), self::getLibraryVersion(), ), ); Loading @@ -428,8 +415,7 @@ class Openlayers { */ public static function detectLibrary() { $library = libraries_detect('openlayers3'); return isset($library['variants'][Config::get('openlayers.variant', NULL)]) ? $library : FALSE; return isset($library['variants'][self::getLibraryVersion()]) ? $library : FALSE; } } Loading
openlayers.install +1 −1 Original line number Diff line number Diff line Loading @@ -460,7 +460,7 @@ function openlayers_requirements($phase) { ); } else { $variant = Config::get('openlayers.variant'); $variant = Openlayers::getLibraryVersion(); $requirements['openlayers3'] = array( 'title' => $t('Openlayers'), 'severity' => REQUIREMENT_ERROR, Loading
openlayers.module +4 −29 Original line number Diff line number Diff line Loading @@ -215,14 +215,12 @@ function openlayers_libraries_info() { $js_css_group = Config::get('openlayers.js_css.group'); } $info = system_get_info('module', 'openlayers'); $module_version = $info['version'] ? $info['version'] : '7.x-3.x'; $module_path = drupal_get_path('module', 'openlayers'); $library_path = libraries_get_path('openlayers3'); $versions = scandir($library_path . '/versions'); $local_variants = []; foreach ($versions as $key => $version) { foreach ($versions as $version) { $variant_path = $library_path . '/versions/' . $version; if (is_dir($variant_path) && substr($version, 0, 1) == 'v') { $local_variants['local:' . substr($version, 1)] = [ Loading Loading @@ -349,38 +347,15 @@ function openlayers_libraries_info() { 'timeout' => 10, ), ), 'variants' => [], 'variants' => $local_variants, 'dependencies' => array( 'openlayers3_integration', ), ); if ($local_version = Openlayers::getLocalLibraryVersion()) { unset($libraries['openlayers3']['library path']); $libraries['openlayers3']['variants'] = $local_variants; $libraries['openlayers3']['variants']['local:' . $local_version] = array( 'name' => 'Openlayers ' . $local_version, 'files' => array( 'js' => array( 'build/ol.js' => array( 'type' => 'file', 'weight' => 6, 'group' => $js_css_group, ), ), 'css' => array( 'css/ol.css' => array( 'type' => 'file', 'weight' => 4, 'group' => $js_css_group, ), ), ), ); } return $libraries; } Loading
src/Config.php +0 −1 Original line number Diff line number Diff line Loading @@ -22,7 +22,6 @@ class Config { 'openlayers.js_css.weight' => 20, 'openlayers.js_css.media' => 'screen', 'openlayers.edit_view_map' => 'openlayers_map_view_edit_form', 'openlayers.variant' => 'local:3.11.2', 'openlayers.debug' => 0, ); if ($key == NULL) { Loading
src/Openlayers.php +9 −23 Original line number Diff line number Diff line Loading @@ -249,27 +249,14 @@ class Openlayers { * Return the version of the Openlayers library set in the configuration. */ public static function getLibraryVersion() { $variant = Config::get('openlayers.variant'); if (strpos($variant, 'local-') !== FALSE) { $version = self::getLocalLibraryVersion(); } else { $version = Config::get('openlayers.variant', NULL); } $version = Config::get('openlayers.variant'); if (strpos($version, 'local:') !== FALSE) { return $version; } /** * Return the version of the Openlayers library in use. * * @return string * Return the version of the Openlayers library in the filesystem. */ public static function getLocalLibraryVersion() { if ($path = libraries_get_path('openlayers3')) { $versions = current(array_diff(scandir($path . '/versions'), ['.', '..'])); } return $versions; $version = array_diff(scandir(libraries_get_path('openlayers3') . '/versions'), ['.', '..']); rsort($version); $version = current($version); return str_replace('v', 'local:', $version); } /** Loading Loading @@ -408,7 +395,7 @@ class Openlayers { $attached['libraries_load'] = array( 'openlayers3' => array( 'openlayers3', Config::get('openlayers.variant', NULL), self::getLibraryVersion(), ), ); Loading @@ -428,8 +415,7 @@ class Openlayers { */ public static function detectLibrary() { $library = libraries_detect('openlayers3'); return isset($library['variants'][Config::get('openlayers.variant', NULL)]) ? $library : FALSE; return isset($library['variants'][self::getLibraryVersion()]) ? $library : FALSE; } }