1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 04:10:38 +02:00

Library Manager UI.

This commit is contained in:
lonalore
2016-06-20 11:12:25 +02:00
parent 6d9a98fdf6
commit 90e25f1d8a
7 changed files with 214 additions and 4 deletions

180
e107_admin/library.php Normal file
View File

@@ -0,0 +1,180 @@
<?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);
$homepage = $this->getHomepage($details);
$download = $this->getDownload($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>' . $homepage . ' | ' . $download . '</td>';
$html .= '</tr>';
}
$html .= '</tbody>';
$html .= '</table>';
return '<div class="table-responsive">' . $html . '</div>';
}
/**
* Helper function to get homepage link.
*/
private function getHomepage($details)
{
$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)
{
$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

@@ -146,6 +146,9 @@ 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> ");
@@ -411,6 +414,9 @@ 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 = '')
{
$libraryHandler = e107::getLibrary();
@@ -1726,6 +1726,10 @@ class e107
case 'load':
return $libraryHandler->load($library);
break;
case 'info':
return $libraryHandler->info();
break;
}
}

View File

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

View File

@@ -829,7 +829,9 @@ 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),
39 => array(e_ADMIN_ABS.'library.php', ADLAN_164, ADLAN_165, 'Z', 5 , E_16_LIBMANAGER, E_32_LIBMANAGER),
);
if($mode == 'legacy')

View File

@@ -182,7 +182,10 @@ 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_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");

View File

@@ -16,3 +16,18 @@ 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', 'Library Manager');