Add support for viewing all the preview images

This commit is contained in:
mozilla%colinogilvie.co.uk 2005-07-21 17:03:09 +00:00
Родитель 3e76300e96
Коммит 5c0a99c09c
3 изменённых файлов: 66 добавлений и 0 удалений

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

@ -45,6 +45,7 @@ class AddOn extends AMO_Object
var $PreviewID;
var $PreviewURI;
var $Caption;
var $Previews = array(); // Store the information for previews
// Comments.
var $Comments;
@ -178,5 +179,33 @@ class AddOn extends AMO_Object
$this->Cats = $this->db->record;
}
function getPreviews()
{
// Gather preview information
$this->db->query("
SELECT
PreviewURI,
caption
FROM
previews
WHERE
ID = {$this->ID} AND
preview = 'NO'
ORDER BY
PreviewID ASC
", SQL_NONE);
while ($this->db->next(SQL_ASSOC)) {
$result = $this->db->record;
$uri = $result['PreviewURI'];
list($src_width, $src_height, $type, $attr) = getimagesize(ROOT_PATH.$uri);
$this->Previews[] = array(
'PreviewURI' => $uri,
'caption' => $result['caption'],
'width' => $src_width,
'height' => $src_height
);
}
}
}
?>

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

@ -0,0 +1,24 @@
<?php
/**
* Addon previews page. Displays all the previews for a particular addon or extension.
*
* @package amo
* @subpackage docs
*/
// Arrays to store clean inputs.
$clean = array(); // General array for verified inputs.
$sql = array(); // Trusted for SQL.
// Get our addon ID.
$clean['ID'] = intval($_GET['id']);
$sql['ID'] =& $clean['ID'];
$addon = new AddOn($sql['ID']);
$addon->getPreviews();
// Assign template variables.
$tpl->assign(
array( 'addon' => $addon,
'title' => $addon->Name,
'content' => 'previews.tpl')
);

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

@ -0,0 +1,13 @@
<h2><strong>{$addon->Name}</strong></h2>
<p class="first">
<strong><a href="./addon.php?id={$addon->ID}">{$addon->Name} {$addon->Version}</a></strong>,
by <a href="./author.php?id={$addon->UserID}">{$addon->UserName}</a>,
released on {$addon->VersionDateAdded|date_format}
</p>
<h3>Previews for {$addon->Name}</h3>
{section name=preview loop=$addon->Previews}
<h4>{$addon->Previews[preview].caption}</h4>
<img src="{$config.webpath}{$addon->Previews[preview].PreviewURI}" alt="{$addon->Previews[preview].caption}" width="{$addon->Previews[preview].width}" height="{$addon->Previews[preview].height}"><br>
{/section}