- Added table to show multiple OSs and app versions.

- Added Multiple download links (if there is more than one version available)
This commit is contained in:
bugzilla%micropipes.com 2006-03-28 00:20:25 +00:00
Родитель c11cd14ed1
Коммит 89e4d4581b
4 изменённых файлов: 120 добавлений и 22 удалений

Просмотреть файл

@ -16,9 +16,21 @@ require_once('includes.php');
// Create our AddOn object using the ID. // Create our AddOn object using the ID.
$addon = new AddOn($sql['ID']); $addon = new AddOn($sql['ID']);
/* This is kind of a cheesy hack to determine how to display
download links on the addon page. If only one link is shown,
there will just be an "Install Now" link, otherwise there will
be links for each version. */
if (sizeof($addon->OsVersions) == 1) {
$multiDownloadLinks = false;
} else {
$multiDownloadLinks = true;
}
// Assign template variables. // Assign template variables.
$tpl->assign( $tpl->assign(
array( 'addon' => $addon, array( 'addon' => $addon,
'multiDownloadLinks' => $multiDownloadLinks,
'title' => $addon->Name, 'title' => $addon->Name,
'content' => 'addon.tpl', 'content' => 'addon.tpl',
'sidebar' => 'inc/addon-sidebar.tpl') 'sidebar' => 'inc/addon-sidebar.tpl')

Просмотреть файл

@ -79,9 +79,6 @@
} }
.install a { .install a {
background: url(../../images/install.png) no-repeat;
padding: 3px 0 8px 30px;
display: block;
text-decoration: none; text-decoration: none;
} }
@ -93,6 +90,12 @@
width: 18em; width: 18em;
} }
.install div {
background: url(../../images/install.png) no-repeat;
padding: 3px 0 8px 30px;
}
#opinions h4 { #opinions h4 {
margin: 0; margin: 0;
} }

Просмотреть файл

@ -21,21 +21,45 @@ released on {$addon->VersionDateAdded|date_format}
<p>{$addon->Description}</p> <p>{$addon->Description}</p>
<p class="requires"> <p class="requires">
Requires: Works with:
</p> </p>
<table> <table summary="Compatible applications and their versions.">
{section name=AppVersions loop=$addon->AppVersions} {foreach key=key item=item from=$addon->AppVersions}
<tr> {counter assign=count start=0}
<td><img src="{$config.webpath}/images/{$addon->AppVersions[AppVersions].AppName|lower}_icon.png" width="34" height="34" alt="{$addon->AppVersions[AppVersions].AppName}"></td> <tr>
<td>{$addon->AppVersions[AppVersions].AppName}</td> <td><img src="{$config.webpath}/images/{$item.AppName|lower}_icon.png" width="34" height="34" alt="{$item.AppName|escape}"></td>
<td>{$addon->AppVersions[AppVersions].MinAppVer} - {$addon->AppVersions[AppVersions].MaxAppVer}</td> <td>{$item.AppName|escape}</td>
</tr> <td>{$item.MinAppVer|escape} - {$item.MaxAppVer|escape}</td>
{/section} <td>{foreach key=throwaway item=os from=$item.os}{counter assign=count}{if $count > 1}, {/if}{$os|escape}{/foreach}</td>
</tr>
{/foreach}
</table> </table>
<div class="key-point install-box">
<div class="key-point install-box"> <div class="install">
<div class="install"> {if $multiDownloadLinks}
<b><a href="{$addon->URI}" onclick="return install(event,'{$addon->AppName|escape} {$addon->Version|escape}', '{$config.webpath}/images/default.png');" TITLE="Install {$addon->AppName|escape} {$addon->Version|escape} (Right-Click to Download)">Install Now</a></b> ({$addon->Size|escape} KB File)</div></div> <b>Install Now:</b><br />
{/if}
{section name=OsVersions loop=$addon->OsVersions}
{if $addon->OsVersions[OsVersions].URI}
<div>
<a href="{$addon->OsVersions[OsVersions].URI|escape}" onclick="return install(event,'{$addon->OsVersions[OsVersions].AppName|escape} {$addon->OsVersions[OsVersions].Version|escape}', '{$config.webpath}/images/default.png');" title="Install for {$addon->OsVersions[OsVersions].OSName|escape} {$addon->OsVersions[OsVersions].Version|escape} (Right-Click to Download)">
{if $multiDownloadLinks}
{$addon->OsVersions[OsVersions].OSName|escape}
{else}
Install Now
{/if}
</a> ({$addon->OsVersions[OsVersions].Size|escape} <abbr title="Kilobytes">KB</abbr>)
</div>
{/if}
{/section}
</div>
</div>
<!--
</noscript>
-->
<div class="install-other">
<a href="{$config.webpath}/{$app}/{$addon->ID}/history">Other Versions</a>
</div>
<h3 id="user-comments">User Comments</h3> <h3 id="user-comments">User Comments</h3>

Просмотреть файл

@ -40,6 +40,8 @@ class AddOn extends AMO_Object {
var $AppVersions; var $AppVersions;
var $OsVersions;
// Preview information. // Preview information.
var $PreviewID; var $PreviewID;
var $PreviewURI; var $PreviewURI;
@ -87,6 +89,7 @@ class AddOn extends AMO_Object {
$this->getMainPreview(); $this->getMainPreview();
$this->getUserInfo(); $this->getUserInfo();
$this->getAppVersions(); $this->getAppVersions();
$this->getOsVersions();
} }
/** /**
@ -308,30 +311,86 @@ class AddOn extends AMO_Object {
SELECT SELECT
`applications`.`AppName`, `applications`.`AppName`,
`version`.`MinAppVer`, `version`.`MinAppVer`,
`version`.`MaxAppVer` `version`.`MaxAppVer`,
`os`.`OSName`
FROM FROM
`version` `version`
INNER JOIN INNER JOIN
`applications` `applications`
ON ON
`version`.`AppID` = `applications`.`AppID` `version`.`AppID` = `applications`.`AppID`
INNER JOIN
`os`
ON
`version`.`OSID` = `os`.`OSID`
WHERE WHERE
`version`.`Version`='{$this->Version}' `version`.`Version`='{$this->Version}'
AND AND
`version`.`ID`={$this->ID} `version`.`ID`={$this->ID}
AND AND
`applications`.`supported` = 1 `applications`.`supported` = 1
ORDER BY
`applications`.`AppName`
", SQL_ALL, SQL_ASSOC); ", SQL_ALL, SQL_ASSOC);
foreach ($this->db->record as $var => $val) { foreach ($this->db->record as $var => $val) {
$_final[] = array ( $_key = "{$val['AppName']} {$val['MinAppVer']} - {$val['MaxAppVer']}";
'AppName' => $val['AppName'],
'MinAppVer' => $val['MinAppVer'], // We've already got at least one hit, just add the OS
'MaxAppVer' => $val['MaxAppVer'], if (array_key_exists($_key, $_final)) {
); array_push($_final[$_key]['os'], $val['OSName']);
} else {
$_final[$_key] = array (
'AppName' => $val['AppName'],
'MinAppVer' => $val['MinAppVer'],
'MaxAppVer' => $val['MaxAppVer'],
'os' => array ($val['OSName'])
);
}
} }
$this->setVar('AppVersions',$_final); $this->setVar('AppVersions',$_final);
} }
/* A very similar function as getAppVersions() but this
has an additional GROUP BY which limits the OS's that
come back */
function getOsVersions() {
$_final = array();
$this->db->query("
SELECT
`version`.`URI`,
`version`.`Size`,
`os`.`OSName`
FROM
`version`
INNER JOIN
`applications`
ON
`version`.`AppID` = `applications`.`AppID`
INNER JOIN
`os`
ON
`version`.`OSID` = `os`.`OSID`
WHERE
`version`.`Version`='{$this->Version}'
AND
`version`.`ID`={$this->ID}
AND
`applications`.`supported` = 1
GROUP BY
`os`.`OSID`
", SQL_ALL, SQL_ASSOC);
foreach ($this->db->record as $var => $val) {
$_final[] = array (
'URI' => $val['URI'],
'Size' => $val['Size'],
'OSName' => $val['OSName']
);
}
$this->setVar('OsVersions',$_final);
}
} }
?> ?>