зеркало из https://github.com/mozilla/pjs.git
- 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:
Родитель
c11cd14ed1
Коммит
89e4d4581b
|
@ -16,9 +16,21 @@ require_once('includes.php');
|
|||
// Create our AddOn object using the 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.
|
||||
$tpl->assign(
|
||||
array( 'addon' => $addon,
|
||||
'multiDownloadLinks' => $multiDownloadLinks,
|
||||
'title' => $addon->Name,
|
||||
'content' => 'addon.tpl',
|
||||
'sidebar' => 'inc/addon-sidebar.tpl')
|
||||
|
|
|
@ -79,9 +79,6 @@
|
|||
}
|
||||
|
||||
.install a {
|
||||
background: url(../../images/install.png) no-repeat;
|
||||
padding: 3px 0 8px 30px;
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
|
@ -93,6 +90,12 @@
|
|||
width: 18em;
|
||||
}
|
||||
|
||||
.install div {
|
||||
background: url(../../images/install.png) no-repeat;
|
||||
padding: 3px 0 8px 30px;
|
||||
|
||||
}
|
||||
|
||||
#opinions h4 {
|
||||
margin: 0;
|
||||
}
|
||||
|
|
|
@ -21,21 +21,45 @@ released on {$addon->VersionDateAdded|date_format}
|
|||
<p>{$addon->Description}</p>
|
||||
|
||||
<p class="requires">
|
||||
Requires:
|
||||
Works with:
|
||||
</p>
|
||||
<table>
|
||||
{section name=AppVersions loop=$addon->AppVersions}
|
||||
<tr>
|
||||
<td><img src="{$config.webpath}/images/{$addon->AppVersions[AppVersions].AppName|lower}_icon.png" width="34" height="34" alt="{$addon->AppVersions[AppVersions].AppName}"></td>
|
||||
<td>{$addon->AppVersions[AppVersions].AppName}</td>
|
||||
<td>{$addon->AppVersions[AppVersions].MinAppVer} - {$addon->AppVersions[AppVersions].MaxAppVer}</td>
|
||||
</tr>
|
||||
{/section}
|
||||
<table summary="Compatible applications and their versions.">
|
||||
{foreach key=key item=item from=$addon->AppVersions}
|
||||
{counter assign=count start=0}
|
||||
<tr>
|
||||
<td><img src="{$config.webpath}/images/{$item.AppName|lower}_icon.png" width="34" height="34" alt="{$item.AppName|escape}"></td>
|
||||
<td>{$item.AppName|escape}</td>
|
||||
<td>{$item.MinAppVer|escape} - {$item.MaxAppVer|escape}</td>
|
||||
<td>{foreach key=throwaway item=os from=$item.os}{counter assign=count}{if $count > 1}, {/if}{$os|escape}{/foreach}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
|
||||
<div class="key-point install-box">
|
||||
<div class="install">
|
||||
<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>
|
||||
<div class="key-point install-box">
|
||||
<div class="install">
|
||||
{if $multiDownloadLinks}
|
||||
<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>
|
||||
|
||||
|
|
|
@ -40,6 +40,8 @@ class AddOn extends AMO_Object {
|
|||
|
||||
var $AppVersions;
|
||||
|
||||
var $OsVersions;
|
||||
|
||||
// Preview information.
|
||||
var $PreviewID;
|
||||
var $PreviewURI;
|
||||
|
@ -87,6 +89,7 @@ class AddOn extends AMO_Object {
|
|||
$this->getMainPreview();
|
||||
$this->getUserInfo();
|
||||
$this->getAppVersions();
|
||||
$this->getOsVersions();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -308,30 +311,86 @@ class AddOn extends AMO_Object {
|
|||
SELECT
|
||||
`applications`.`AppName`,
|
||||
`version`.`MinAppVer`,
|
||||
`version`.`MaxAppVer`
|
||||
`version`.`MaxAppVer`,
|
||||
`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
|
||||
ORDER BY
|
||||
`applications`.`AppName`
|
||||
", SQL_ALL, SQL_ASSOC);
|
||||
|
||||
foreach ($this->db->record as $var => $val) {
|
||||
$_final[] = array (
|
||||
'AppName' => $val['AppName'],
|
||||
'MinAppVer' => $val['MinAppVer'],
|
||||
'MaxAppVer' => $val['MaxAppVer'],
|
||||
);
|
||||
$_key = "{$val['AppName']} {$val['MinAppVer']} - {$val['MaxAppVer']}";
|
||||
|
||||
// We've already got at least one hit, just add the OS
|
||||
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);
|
||||
}
|
||||
|
||||
/* 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);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
Загрузка…
Ссылка в новой задаче