A better Package Manager List?

Started by Vendetta, December 07, 2005, 09:05:42 PM

Previous topic - Next topic

Vendetta

Ok, I don't say this is ready for release. Actually, I only started this, but I think I is worth being discussed here.

I rewrote the function template_package_list to be more usefull. The idea is that only mad titles and authors are displayed by default, and you can expand to a full view.

Here is a screenshot:



Please note that I have not added any i18n, all strings are hard coded for now. Howevere, there is other work to do.

Feel free to give it a try:


function template_package_list()
{
global $context, $settings, $options, $txt, $scripturl;

echo '
<script type="text/javascript">//<![CDATA[
function switchPackage(id,img)
{
var tr = document.getElementById(id);
tr.style.display = (tr.style.display == "table-row") ? "none" : "table-row";
img.src = (tr.style.display == "none") ? "', $settings['images_url'] ,'/expand.gif" : "', $settings['images_url'] ,'/collapse.gif";
}
//]]>
</script>
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="tborder">
<tr class="titlebg">
<td>' . $context['page_title'] . '</td>
</tr><tr>
<td width="100%" align="left" valign="middle" class="windowbg2">
<ul>';

// No packages, as yet.
if (empty($context['package_list']))
{
echo '
<li>', $txt['smf189'], '</li>';
}
else
{
// TODO: Add links to the mod-categories
echo '
<li>Packages</li>
<li>New Feature</li>
<li>Feature Enhancement</li>';
}
echo '
</ul>
</td>
</tr>';

// List out the packages...
if (!empty($context['package_list']))
{
$i = 0;
foreach ($context['package_list'] as $package)
{
$i++;

if ($package['is_title'])
{
echo '
</table>
<table border="0" width="100%" cellspacing="1" cellpadding="4" class="tborder" style="margin-top:2ex;">
<tr class="titlebg">
<td colspan="2">', $package['name'] ,'</td>
</tr>';
}

elseif ($package['is_heading'])
{
echo '<tr class="windowbg">
<th style="font-size:1.2em;">', $package['name'] ,'</th>
</tr colspan="2">';
}

elseif ($package['is_text'])
{
echo '<tr class="windowbg">
<td colspan="2">', $package['name'] ,'</td>
</tr>';
}

elseif ($package['is_line'])
{
echo '<tr class="windowbg">
<td colspan="2"><hr /></td>
</tr>';
}
elseif ($package['is_remote'])
{
echo '<tr class="windowbg">
<td colspan="2"><b>', $package['name'] ,'</td>
</tr>';
}

// This is for Modifications
else
{
echo '<tr>
<td class="catbg" colspan="2" style="font-weight:normal">
<img src="', $settings['images_url'] ,'/expand.gif" alt="" onclick="switchPackage(\'package', $i ,'\',this)" />&nbsp;&nbsp;
'/*, $package['count'] */, ($package['can_install'] || $package['is_installed']) ? '<b>'. $package['name'] .'</b>' : $package['name'] ,'
by ', ($package['author'] && !empty($package['author']['name'])) ? $package['author']['link'] : '[Unknown]','
', ($package['is_installed'] && !$package['is_newer'])
? '<img src="'. $settings['images_url']. '/icons/package_'.
($package['is_current']
? 'installed'
: 'old').
'.gif" width="12" height="11" border="0" align="middle" style="margin-left: 2ex; vertical-align:middle" alt="'.
($package['is_current']
? $txt['package_installed_current']
: $txt['package_installed_old']).
'" />'
: '','
</td>
</tr><tr id="package', $i ,'" style="display:none">
<td class="windowbg" valign="top" align="center" width="180">
',/* ($package['version'] && $package['is_installed']) ? 'installed<br />' : '' ,*/'
', ($package['version'] && $package['is_installed']) ? ($package['is_newer'] ? '<a href="' . $package['download']['href'] . '">[ update ]</a>&nbsp;' : '[ up to date ]&nbsp;') : '' ,'
', (!$package['is_installed'] && $package['can_install']) ? '<a href="' . $package['download']['href'] . '">[ install ]</a>&nbsp;': '' ,'
<a href="', $package['href'], '">[ download ]</a><br />
', !empty($package['type']) ? ucwords(strtolower($package['type'])) : '' ,'&nbsp;<b>', $package['name'] ,'</b><br />
in version: ', $package['version'] ,'<br />
by ', ($package['author'] && !empty($package['author']['name'])) ? $package['author']['link'] : '[Unknown]' ,'
</td>
<td class="windowbg2">
', ($package['is_installed'] && !$package['is_newer'])
? '<img src="'. $settings['images_url'] .'/icons/package_'.
($package['is_current']
? 'installed'
: 'old').
'.gif" width="12" height="11" border="0" align="middle" style="margin-left: 2ex;" alt="'.
($package['is_current']
? $txt['package_installed_current']
: $txt['package_installed_old']).
'" />'
: '' ,'
<div style="max-height: 15em; overflow: auto;">', $package['description'], '</div>
</td>
</tr>';
}

}
echo '</table>
<br />';
}

echo '
</td>
</tr>
</table>
<table border="0" width="100%" cellspacing="1" cellpadding="4">
<tr>
<td class="smalltext">
', $txt['package_installed_key'], '
<img src="', $settings['images_url'], '/icons/package_installed.gif" alt="" width="12" height="11" align="middle" style="margin-left: 1ex;" /> ', $txt['package_installed_current'], '
<img src="', $settings['images_url'], '/icons/package_old.gif" alt="" width="12" height="11" align="middle" style="margin-left: 2ex;" /> ', $txt['package_installed_old'], '
</td>
</tr>
</table>';
}

SleePy

i like it. I can find things better. but it would be nice if im hovering over something to give me the description as well :)
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Advertisement: