1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 03:40:37 +02:00

Removed Library Manager UI, moved library listing to prefs page.

This commit is contained in:
lonalore
2016-06-21 10:40:41 +02:00
parent 6cac761e47
commit c2c2d7aa37
10 changed files with 199 additions and 245 deletions

View File

@@ -1,213 +0,0 @@
<?php
/**
* @file
* Class installations to handle configuration forms on Admin UI.
*/
require_once('../class2.php');
if(!getperms("Z"))
{
e107::redirect('admin');
exit;
}
// [e_LANGUAGEDIR]/[e_LANGUAGE]/lan_library_manager.php
e107::lan('core', 'library_manager');
/**
* Class library_admin.
*/
class library_admin extends e_admin_dispatcher
{
/**
* @var array
*/
protected $modes = array(
'list' => 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 = '<table width="100%" class="table table-striped" cellpadding="0" cellspacing="0">';
$html .= '<thead>';
$html .= '<tr>';
$html .= '<th>' . LAN_LIBRARY_MANAGER_13 . '</th>';
$html .= '<th>' . LAN_LIBRARY_MANAGER_21 . '</th>';
$html .= '<th>' . LAN_LIBRARY_MANAGER_14 . '</th>';
$html .= '<th>' . LAN_LIBRARY_MANAGER_18 . '</th>';
$html .= '<th>' . LAN_LIBRARY_MANAGER_19 . '</th>';
$html .= '<th></th>';
$html .= '</tr>';
$html .= '</thead>';
$html .= '<tbody>';
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 .= '<tr>';
$html .= '<td>' . $details['name'] . '</td>';
$html .= '<td>' . $provider . '</td>';
$html .= '<td>' . $details['version'] . '</td>';
$html .= '<td>' . $status . '</td>';
$html .= '<td>' . $details['error_message'] . '</td>';
$html .= '<td>' . $links . '</td>';
$html .= '</tr>';
}
$html .= '</tbody>';
$html .= '</table>';
return '<div class="table-responsive">' . $html . '</div>';
}
/**
* 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 '<a href="' . $href . '" title="' . $title . '" target="_blank">' . LAN_LIBRARY_MANAGER_15 . '</a>';
}
/**
* 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 '<a href="' . $href . '" title="' . $title . '" target="_blank">' . LAN_LIBRARY_MANAGER_16 . '</a>';
}
/**
* 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 '<span class="text-success">' . LAN_OK . '</span>';
}
return '<span class="text-danger">' . $details['error'] . '</span>';
}
}
new library_admin();
require_once(e_ADMIN . "auth.php");
e107::getAdminUI()->runPage();
require_once(e_ADMIN . "footer.php");
exit;

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

@@ -146,9 +146,6 @@ if (!defined('E_32_PLUGMANAGER')) {
if (!defined('E_32_MAIN')) {
define('E_32_MAIN', "<i class='S32 e-main-32'></i> ");
}
if (!defined('E_32_LIBMANAGER')) {
define('E_32_LIBMANAGER', "<i class='S32 e-plugmanager-32'></i> "); // TODO CSS class.
}
if (!defined('E_32_THEMEMANAGER')) {
define('E_32_THEMEMANAGER', "<i class='S32 e-themes-32'></i> ");
@@ -414,9 +411,6 @@ if (!defined('E_16_PLUGMANAGER')) {
if (!defined('E_16_THEMEMANAGER')) {
define('E_16_THEMEMANAGER', "<i class='S16 e-themes-16'></i>");
}
if (!defined('E_16_LIBMANAGER')) {
define('E_16_LIBMANAGER', "<i class='S16 e-plugmanager-16'></i>"); // TODO CSS class.
}
// Small Admin Other Images
if (!defined('E_16_ADMINLOG')) {

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

@@ -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')

View File

@@ -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");

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,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]');

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