1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-16 19:44:09 +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
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>';
}