From c2c2d7aa3786e3353384427b9fe451fbe5f84494 Mon Sep 17 00:00:00 2001 From: lonalore Date: Tue, 21 Jun 2016 10:40:41 +0200 Subject: [PATCH] Removed Library Manager UI, moved library listing to prefs page. --- e107_admin/library.php | 213 ------------------ e107_admin/prefs.php | 168 +++++++++++++- e107_core/templates/admin_icons_template.php | 6 - e107_handlers/e107_class.php | 4 +- e107_handlers/library_manager.php | 12 +- e107_handlers/sitelinks_class.php | 2 - e107_languages/English/admin/lan_admin.php | 3 - e107_languages/English/admin/lan_prefs.php | 2 +- .../English/lan_library_manager.php | 16 +- e107_web/js/core/all.jquery.js | 18 ++ 10 files changed, 199 insertions(+), 245 deletions(-) delete mode 100644 e107_admin/library.php diff --git a/e107_admin/library.php b/e107_admin/library.php deleted file mode 100644 index ab1b3032a..000000000 --- a/e107_admin/library.php +++ /dev/null @@ -1,213 +0,0 @@ - array( - 'controller' => 'library_list_ui', - 'path' => null, - ), - ); - - /** - * @var array - */ - protected $adminMenu = array( - 'list/libraries' => array( - 'caption' => LAN_LIBRARY_MANAGER_12, - 'perm' => 'P', - ), - ); - - /** - * @var string - */ - protected $menuTitle = LAN_LIBRARY_MANAGER_25; - -} - - -/** - * Class library_list_ui. - */ -class library_list_ui extends e_admin_ui -{ - - /** - * @var string - */ - protected $pluginTitle = LAN_LIBRARY_MANAGER_25; - - - /** - * List libraries. - */ - function librariesPage() - { - $tp = e107::getParser(); - $libraries = e107::library('info'); - - $html = ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - - foreach($libraries as $machineName => $library) - { - $details = e107::library('detect', $machineName); - - if(empty($details['name'])) - { - continue; - } - - $provider = $this->getProvider($details); - $status = $this->getStatus($details); - $links = $this->getLinks($details); - - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - $html .= ''; - } - - $html .= ''; - $html .= '
' . LAN_LIBRARY_MANAGER_13 . '' . LAN_LIBRARY_MANAGER_21 . '' . LAN_LIBRARY_MANAGER_14 . '' . LAN_LIBRARY_MANAGER_18 . '' . LAN_LIBRARY_MANAGER_19 . '
' . $details['name'] . '' . $provider . '' . $details['version'] . '' . $status . '' . $details['error_message'] . '' . $links . '
'; - - return '
' . $html . '
'; - } - - /** - * Helper function to get links. - */ - private function getLinks($details) - { - $homepage = $this->getHomepage($details); - $download = $this->getDownload($details); - - if ($homepage && $download) - { - return $homepage . ' | ' . $download; - } - - if($homepage) - { - return $homepage; - } - - if($download) - { - return $download; - } - } - - /** - * Helper function to get homepage link. - */ - private function getHomepage($details) - { - if (empty($details['vendor_url'])) - { - return false; - } - - $href = $details['vendor_url']; - $title = $details['name']; - - return '' . LAN_LIBRARY_MANAGER_15 . ''; - } - - /** - * Helper function to get download link. - */ - private function getDownload($details) - { - if (empty($details['download_url'])) - { - return false; - } - - $href = $details['download_url']; - $title = $details['name']; - - return '' . LAN_LIBRARY_MANAGER_16 . ''; - } - - /** - * Helper function to get provider. - */ - private function getProvider($details) - { - $provider = LAN_LIBRARY_MANAGER_24; - - if(varset($details['plugin'], false) == true) - { - $provider = LAN_LIBRARY_MANAGER_22; - } - - if(varset($details['theme'], false) == true) - { - $provider = LAN_LIBRARY_MANAGER_23; - } - - return $provider; - } - - /** - * Helper function to get status. - */ - private function getStatus($details) - { - if($details['installed'] == true) - { - return '' . LAN_OK . ''; - } - - return '' . $details['error'] . ''; - } - -} - - -new library_admin(); - -require_once(e_ADMIN . "auth.php"); -e107::getAdminUI()->runPage(); -require_once(e_ADMIN . "footer.php"); -exit; diff --git a/e107_admin/prefs.php b/e107_admin/prefs.php index ca2301009..289bc50bc 100644 --- a/e107_admin/prefs.php +++ b/e107_admin/prefs.php @@ -1785,11 +1785,63 @@ $text .= " ""; } - $text .= " - ".pref_submit('javascript')." - - - "; + +$text .= pref_submit('javascript'); + +// [e_LANGUAGEDIR]/[e_LANGUAGE]/lan_library_manager.php +e107::lan('core', 'library_manager'); + +$text .= '

' . LAN_LIBRARY_MANAGER_25 . '

'; + +$text .= ''; +$text .= ''; +$text .= ''; +$text .= ''; +$text .= ''; +$text .= ''; +$text .= ''; +$text .= ''; +$text .= ''; +$text .= ''; +$text .= ''; +$text .= ''; + +$libraries = e107::library('info'); +foreach($libraries as $machineName => $library) +{ + $details = e107::library('detect', $machineName); + + if(empty($details['name'])) + { + continue; + } + + $name = libraryGetName($machineName, $details); + $provider = libraryGetProvider($details); + $status = libraryGetStatus($details); + $links = libraryGetLinks($details); + + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; + $text .= ''; +} + +if(empty($libraries)) +{ + $text .= ''; + $text .= ''; + $text .= ''; +} + +$text .= ''; +$text .= '
' . LAN_LIBRARY_MANAGER_13 . '' . LAN_LIBRARY_MANAGER_21 . '' . LAN_LIBRARY_MANAGER_14 . '' . LAN_LIBRARY_MANAGER_18 . '' . LAN_LIBRARY_MANAGER_19 . '
' . $name . '' . $provider . '' . $details['version'] . '' . $status . '' . $details['error_message'] . '' . $links . '
' . LAN_LIBRARY_MANAGER_26 . '
'; + +$text .= ""; /* e107::js('inline'," @@ -1942,3 +1994,109 @@ function prefs_adminmenu() e107::getNav()->admin("Basic ".LAN_OPTIONS.'--id--prev_nav', 'core-prefs-main', $var); } +/** + * Helper function to get library's name. + */ +function libraryGetName($machineName, $details) +{ + $text = e107::getParser()->lanVars(LAN_LIBRARY_MANAGER_27, array($machineName)); + return '' . $details['name'] . ''; +} + +/** + * Helper function to get links. + */ +function libraryGetLinks($details) +{ + $homepage = libraryGetHomepage($details); + $download = libraryGetDownload($details); + + if ($homepage && $download) + { + return $homepage . ' | ' . $download; + } + + if($homepage) + { + return $homepage; + } + + if($download) + { + return $download; + } +} + +/** + * Helper function to get homepage link. + */ +function libraryGetHomepage($details) +{ + if (empty($details['vendor_url'])) + { + return false; + } + + $href = $details['vendor_url']; + $title = $details['name']; + + return '' . LAN_LIBRARY_MANAGER_15 . ''; +} + +/** + * Helper function to get download link. + */ +function libraryGetDownload($details) +{ + if (empty($details['download_url'])) + { + return false; + } + + $href = $details['download_url']; + $title = $details['name']; + + return '' . LAN_LIBRARY_MANAGER_16 . ''; +} + +/** + * Helper function to get provider. + */ +function libraryGetProvider($details) +{ + $text = 'e107'; + $provider = LAN_LIBRARY_MANAGER_24; + + if(varset($details['plugin'], false) == true) + { + $text = $details['plugin']; + $provider = LAN_LIBRARY_MANAGER_22; + } + + if(varset($details['theme'], false) == true) + { + $text = $details['theme']; + $provider = LAN_LIBRARY_MANAGER_23; + } + + return '' . $provider . ''; +} + +/** + * Helper function to get status. + */ +function libraryGetStatus($details) +{ + $tp = e107::getParser(); + + if($details['installed'] == true) + { + $icon = $tp->toGlyph('glyphicon-ok'); + $text = LAN_OK; + return '' . $icon . ''; + } + + $icon = $tp->toGlyph('glyphicon-remove'); + $text = $details['error']; + return '' . $icon . ''; +} diff --git a/e107_core/templates/admin_icons_template.php b/e107_core/templates/admin_icons_template.php index ddaa6baa2..9ee81afa9 100644 --- a/e107_core/templates/admin_icons_template.php +++ b/e107_core/templates/admin_icons_template.php @@ -146,9 +146,6 @@ if (!defined('E_32_PLUGMANAGER')) { if (!defined('E_32_MAIN')) { define('E_32_MAIN', " "); } -if (!defined('E_32_LIBMANAGER')) { - define('E_32_LIBMANAGER', " "); // TODO CSS class. -} if (!defined('E_32_THEMEMANAGER')) { define('E_32_THEMEMANAGER', " "); @@ -414,9 +411,6 @@ if (!defined('E_16_PLUGMANAGER')) { if (!defined('E_16_THEMEMANAGER')) { define('E_16_THEMEMANAGER', ""); } -if (!defined('E_16_LIBMANAGER')) { - define('E_16_LIBMANAGER', ""); // TODO CSS class. -} // Small Admin Other Images if (!defined('E_16_ADMINLOG')) { diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index 040933aa5..16cc82a08 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -1713,7 +1713,7 @@ class e107 * $name, or FALSE if the library $name is not registered. * - In case of 'load': An associative array of the library information. */ - public static function library($action = '', $library = '') + public static function library($action = '', $library = null) { $libraryHandler = e107::getLibrary(); @@ -1728,7 +1728,7 @@ class e107 break; case 'info': - return $libraryHandler->info(); + return $libraryHandler->info($library); break; } } diff --git a/e107_handlers/library_manager.php b/e107_handlers/library_manager.php index 379b02308..69053aeab 100644 --- a/e107_handlers/library_manager.php +++ b/e107_handlers/library_manager.php @@ -89,7 +89,7 @@ class e_library_manager $library['error'] = LAN_LIBRARY_MANAGER_09; $replace_with = array($library['name']); - $library['error_message'] = e107::getParser()->lanVars(LAN_LIBRARY_MANAGER_03, $replace_with); + $library['error_message'] = e107::getParser()->lanVars(LAN_LIBRARY_MANAGER_03, $replace_with, true); return $library; } @@ -165,7 +165,7 @@ class e_library_manager $library['error'] = LAN_LIBRARY_MANAGER_10; $replace_with = array($library['name']); - $library['error_message'] = e107::getParser()->lanVars(LAN_LIBRARY_MANAGER_04, $replace_with); + $library['error_message'] = e107::getParser()->lanVars(LAN_LIBRARY_MANAGER_04, $replace_with, true); return $library; } @@ -188,7 +188,7 @@ class e_library_manager $library['error'] = LAN_LIBRARY_MANAGER_11; $replace_with = array($library['version'], $library['name']); - $library['error_message'] = e107::getParser()->lanVars(LAN_LIBRARY_MANAGER_05, $replace_with); + $library['error_message'] = e107::getParser()->lanVars(LAN_LIBRARY_MANAGER_05, $replace_with, true); return $library; } @@ -258,7 +258,7 @@ class e_library_manager $variant['error'] = LAN_LIBRARY_MANAGER_09; $replace_with = array($variant_name, $library['name']); - $variant['error_message'] = e107::getParser()->lanVars(LAN_LIBRARY_MANAGER_06, $replace_with); + $variant['error_message'] = e107::getParser()->lanVars(LAN_LIBRARY_MANAGER_06, $replace_with, true); } } } @@ -680,7 +680,7 @@ class e_library_manager $library['error'] = LAN_LIBRARY_MANAGER_07; $replace_with = array($dependency['name'], $library['name']); - $library['error_message'] = e107::getParser()->lanVars(LAN_LIBRARY_MANAGER_01, $replace_with); + $library['error_message'] = e107::getParser()->lanVars(LAN_LIBRARY_MANAGER_01, $replace_with, true); } elseif($this->checkIncompatibility($dependency_info, $dependency['version'])) { @@ -688,7 +688,7 @@ class e_library_manager $library['error'] = LAN_LIBRARY_MANAGER_08; $replace_with = array($dependency['version'], $library['name'], $library['name']); - $library['error_message'] = e107::getParser()->lanVars(LAN_LIBRARY_MANAGER_02, $replace_with); + $library['error_message'] = e107::getParser()->lanVars(LAN_LIBRARY_MANAGER_02, $replace_with, true); } // Remove the version string from the dependency, so load() can load the libraries directly. diff --git a/e107_handlers/sitelinks_class.php b/e107_handlers/sitelinks_class.php index 3f13b813f..5a0581f70 100644 --- a/e107_handlers/sitelinks_class.php +++ b/e107_handlers/sitelinks_class.php @@ -830,8 +830,6 @@ i.e-cat_users-32{ background-position: -555px 0; width: 32px; height: 32px; } 36 => array(e_ADMIN_ABS.'credits.php', LAN_CREDITS, LAN_CREDITS, '', 20, E_16_E107, E_32_E107), // 37 => array(e_ADMIN.'custom_field.php', ADLAN_161, ADLAN_162, 'U', 4, E_16_CUSTOMFIELD, E_32_CUSTOMFIELD), 38 => array(e_ADMIN_ABS.'comment.php', LAN_COMMENTMAN, LAN_COMMENTMAN, 'B', 5, E_16_COMMENT, E_32_COMMENT), - - 39 => array(e_ADMIN_ABS.'library.php', ADLAN_164, ADLAN_165, 'Z', 5 , E_16_LIBMANAGER, E_32_LIBMANAGER), ); if($mode == 'legacy') diff --git a/e107_languages/English/admin/lan_admin.php b/e107_languages/English/admin/lan_admin.php index 86974009c..edfdb8b10 100644 --- a/e107_languages/English/admin/lan_admin.php +++ b/e107_languages/English/admin/lan_admin.php @@ -184,9 +184,6 @@ define("ADLAN_161", "Custom Fields?"); define("ADLAN_162", "A newer version of your site-theme is available:"); define("ADLAN_163", "A newer version of an installed plugin is available:"); -define("ADLAN_164", "Library Manager"); -define("ADLAN_165", "Click here to see externally developed and distributed libraries."); - // define("ADLAN_CL_1", "Settings"); define("ADLAN_CL_2", "Users"); define("ADLAN_CL_3", "Content"); diff --git a/e107_languages/English/admin/lan_prefs.php b/e107_languages/English/admin/lan_prefs.php index cae5d2179..59cb19b13 100644 --- a/e107_languages/English/admin/lan_prefs.php +++ b/e107_languages/English/admin/lan_prefs.php @@ -271,7 +271,7 @@ define("PRFLAN_253", "Disable consolidated scripts browser cache:"); define("PRFLAN_254", "Email & Contact Info"); define("PRFLAN_255", "File Uploading"); define("PRFLAN_256", "Advanced Options"); -define("PRFLAN_257", "Javascript Framework"); +define("PRFLAN_257", "Libraries"); define("PRFLAN_258", "Contact Form Visibility"); define("PRFLAN_259", "Register & Login"); diff --git a/e107_languages/English/lan_library_manager.php b/e107_languages/English/lan_library_manager.php index 2399646e8..ccfc5dc79 100644 --- a/e107_languages/English/lan_library_manager.php +++ b/e107_languages/English/lan_library_manager.php @@ -5,12 +5,12 @@ * Language definitions for Library Manager. */ -define('LAN_LIBRARY_MANAGER_01', 'The "[x]" library, which the "[y]" library depends on, is not installed.'); -define('LAN_LIBRARY_MANAGER_02', 'The version "[x]" of the "[y]" library is not compatible with the "[z]" library.'); -define('LAN_LIBRARY_MANAGER_03', 'The "[x]" library could not be found.'); -define('LAN_LIBRARY_MANAGER_04', 'The version of the "[x]" library could not be detected.'); -define('LAN_LIBRARY_MANAGER_05', 'The installed version "[x]" of the "[y]" library is not supported.'); -define('LAN_LIBRARY_MANAGER_06', 'The "[x]" variant of the "[y]" library could not be found.'); +define('LAN_LIBRARY_MANAGER_01', 'The [x] library, which the [y] library depends on, is not installed.'); +define('LAN_LIBRARY_MANAGER_02', 'The version [x] of the [y] library is not compatible with the [z] library.'); +define('LAN_LIBRARY_MANAGER_03', 'The [x] library could not be found.'); +define('LAN_LIBRARY_MANAGER_04', 'The version of the [x] library could not be detected.'); +define('LAN_LIBRARY_MANAGER_05', 'The installed version [x] of the [y] library is not supported.'); +define('LAN_LIBRARY_MANAGER_06', 'The [x] variant of the [y] library could not be found.'); define('LAN_LIBRARY_MANAGER_07', 'missing dependency'); define('LAN_LIBRARY_MANAGER_08', 'incompatible dependency'); define('LAN_LIBRARY_MANAGER_09', 'not found'); @@ -30,4 +30,6 @@ define('LAN_LIBRARY_MANAGER_21', 'Provider'); define('LAN_LIBRARY_MANAGER_22', 'plugin'); define('LAN_LIBRARY_MANAGER_23', 'theme'); define('LAN_LIBRARY_MANAGER_24', 'core'); -define('LAN_LIBRARY_MANAGER_25', 'Library Manager'); +define('LAN_LIBRARY_MANAGER_25', 'Third-party libraries'); +define('LAN_LIBRARY_MANAGER_26', 'No library found'); +define('LAN_LIBRARY_MANAGER_27', 'Machine name: [x]'); diff --git a/e107_web/js/core/all.jquery.js b/e107_web/js/core/all.jquery.js index 4348a9562..e62434b7f 100644 --- a/e107_web/js/core/all.jquery.js +++ b/e107_web/js/core/all.jquery.js @@ -168,6 +168,24 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}}; } }; + /** + * Behavior to initialize tooltips on elements with data-toggle="tooltip" attribute. + * + * @type {{attach: e107.behaviors.bootstrapTooltip.attach}} + */ + e107.behaviors.bootstrapTooltip = { + attach: function (context, settings) + { + if(typeof $.fn.tooltip !== 'undefined') + { + $(context).find('[data-toggle="tooltip"]').once('bootstrap-tooltip').each(function () + { + $(this).tooltip(); + }); + } + } + }; + /** * Behavior to attach a click event to elements with .e-expandit class. *