1
0
mirror of https://github.com/e107inc/e107.git synced 2025-05-01 09:48:19 +02:00

Merge pull request #1720 from lonalore/master

Library Manager UI.
This commit is contained in:
Cameron 2016-06-22 14:28:51 -07:00 committed by GitHub
commit 92d67a886e
8 changed files with 219 additions and 22 deletions

View File

@ -1785,11 +1785,63 @@ $text .= "
"</div>";
}
$text .= "
".pref_submit('javascript')."
</fieldset>
";
$text .= pref_submit('javascript');
// [e_LANGUAGEDIR]/[e_LANGUAGE]/lan_library_manager.php
e107::lan('core', 'library_manager');
$text .= '<h4 class="caption">' . LAN_LIBRARY_MANAGER_25 . '</h4>';
$text .= '<table width="100%" class="table table-striped" cellpadding="0" cellspacing="0">';
$text .= '<thead>';
$text .= '<tr>';
$text .= '<th>' . LAN_LIBRARY_MANAGER_13 . '</th>';
$text .= '<th class="text-center">' . LAN_LIBRARY_MANAGER_21 . '</th>';
$text .= '<th class="text-center">' . LAN_LIBRARY_MANAGER_14 . '</th>';
$text .= '<th class="text-center">' . LAN_LIBRARY_MANAGER_18 . '</th>';
$text .= '<th>' . LAN_LIBRARY_MANAGER_19 . '</th>';
$text .= '<th></th>';
$text .= '</tr>';
$text .= '</thead>';
$text .= '<tbody>';
$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 .= '<tr>';
$text .= '<td>' . $name . '</td>';
$text .= '<td class="text-center">' . $provider . '</td>';
$text .= '<td class="text-center">' . $details['version'] . '</td>';
$text .= '<td class="text-center">' . $status . '</td>';
$text .= '<td>' . $details['error_message'] . '</td>';
$text .= '<td>' . $links . '</td>';
$text .= '</tr>';
}
if(empty($libraries))
{
$text .= '<tr>';
$text .= '<td colspan="6">' . LAN_LIBRARY_MANAGER_26 . '</td>';
$text .= '</tr>';
}
$text .= '</tbody>';
$text .= '</table>';
$text .= "</fieldset>";
/*
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 '<span data-toggle="tooltip" data-placement="top" title="' . $text . '">' . $details['name'] . '</span>';
}
/**
* 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 '<a href="' . $href . '" title="' . $title . '" target="_blank">' . LAN_LIBRARY_MANAGER_15 . '</a>';
}
/**
* Helper function to get download link.
*/
function libraryGetDownload($details)
{
if (empty($details['download_url']))
{
return false;
}
$href = $details['download_url'];
$title = $details['name'];
return '<a href="' . $href . '" title="' . $title . '" target="_blank">' . LAN_LIBRARY_MANAGER_16 . '</a>';
}
/**
* 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 '<span data-toggle="tooltip" data-placement="top" title="' . $text . '">' . $provider . '</span>';
}
/**
* Helper function to get status.
*/
function libraryGetStatus($details)
{
$tp = e107::getParser();
if($details['installed'] == true)
{
$icon = $tp->toGlyph('glyphicon-ok');
$text = LAN_OK;
return '<span class="text-success" data-toggle="tooltip" data-placement="top" title="' . $text . '">' . $icon . '</span>';
}
$icon = $tp->toGlyph('glyphicon-remove');
$text = $details['error'];
return '<span class="text-danger" data-toggle="tooltip" data-placement="top" title="' . $text . '">' . $icon . '</span>';
}

View File

@ -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();
@ -1726,6 +1726,10 @@ class e107
case 'load':
return $libraryHandler->load($library);
break;
case 'info':
return $libraryHandler->info($library);
break;
}
}

View File

@ -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);
}
}
}
@ -433,7 +433,7 @@ class e_library_manager
* An associative array containing registered information for all libraries, the registered information for the
* library specified by $name, or FALSE if the library $name is not registered.
*/
private function &info($library = null)
public function &info($library = null)
{
// This static cache is re-used by detect() to save memory.
static $libraries;
@ -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.

View File

@ -829,7 +829,7 @@ i.e-cat_users-32{ background-position: -555px 0; width: 32px; height: 32px; }
// 35 => array('#TODO', 'System Info', 'System Information', '', 20, '', ''),
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)
38 => array(e_ADMIN_ABS.'comment.php', LAN_COMMENTMAN, LAN_COMMENTMAN, 'B', 5, E_16_COMMENT, E_32_COMMENT),
);
if($mode == 'legacy')

View File

@ -182,7 +182,7 @@ define("ADLAN_159", "URL Configuration");
define("ADLAN_160", "Configure Site URLs");
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_163", "A newer version of an installed plugin is available:");
// define("ADLAN_CL_1", "Settings");
define("ADLAN_CL_2", "Users");

View File

@ -271,7 +271,7 @@ define("PRFLAN_253", "Disable consolidated scripts browser cache:");
define("PRFLAN_254", "Email &amp; 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");

View File

@ -5,14 +5,31 @@
* 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');
define('LAN_LIBRARY_MANAGER_10', 'not detected');
define('LAN_LIBRARY_MANAGER_11', 'not supported');
define('LAN_LIBRARY_MANAGER_12', 'List');
define('LAN_LIBRARY_MANAGER_13', 'Library');
define('LAN_LIBRARY_MANAGER_14', 'Version');
define('LAN_LIBRARY_MANAGER_15', 'Homepage');
define('LAN_LIBRARY_MANAGER_16', 'Download');
define('LAN_LIBRARY_MANAGER_17', 'Installed');
define('LAN_LIBRARY_MANAGER_18', 'Status');
define('LAN_LIBRARY_MANAGER_19', 'Message');
define('LAN_LIBRARY_MANAGER_20', 'link');
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', 'Third-party libraries');
define('LAN_LIBRARY_MANAGER_26', 'No library found');
define('LAN_LIBRARY_MANAGER_27', 'Machine name: [x]');

View File

@ -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.
*