Additional changes to search. No pagination, just prev|next. Works4me.

Fixed some image sizing in addon.tpl and search.tpl.
This commit is contained in:
mike.morgan%oregonstate.edu 2005-07-26 00:27:55 +00:00
Родитель 72662c774b
Коммит bf21d55122
7 изменённых файлов: 146 добавлений и 42 удалений

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

@ -77,6 +77,27 @@
padding: 10px;
}
.pages {
color: #999;
font-weight: bold;
height: 2em;
}
.next {
border-left: 1px solid #000;
display: inline;
padding-left: 5px;
}
.prev {
display: inline;
}
.pages a {
color: blue;
text-decoration: none;
}
.popularlist {
font-size: 85%;
}
@ -211,6 +232,7 @@
padding: 3px;
padding-left: 10px;
font-size: 8pt;
clear: right;
color: #333;
}

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

@ -44,6 +44,8 @@ class AddOn extends AMO_Object
// Preview information.
var $PreviewID;
var $PreviewURI;
var $PreviewHeight;
var $PreviewWidth;
var $Caption;
var $Previews = array(); // Store the information for previews
@ -104,7 +106,14 @@ class AddOn extends AMO_Object
if (!empty($this->db->record)) {
$this->setVars($this->db->record);
if (file_exists(ROOT_PATH.$this->PreviewURI)) {
$size = getimagesize(ROOT_PATH.$this->PreviewURI);
$this->setVar('PreviewWidth',$size[0]);
$this->setVar('PreviewHeight',$size[1]);
}
}
}
function getPreviews()
@ -117,8 +126,7 @@ class AddOn extends AMO_Object
FROM
previews
WHERE
ID = {$this->ID} AND
preview = 'NO'
ID = {$this->ID}
ORDER BY
PreviewID ASC
", SQL_NONE);
@ -250,13 +258,16 @@ class AddOn extends AMO_Object
// Gather addon categories.
$this->db->query("
SELECT DISTINCT
categories.CatName
categories.CatName,
categories.CategoryID
FROM
categoryxref
INNER JOIN categories ON categoryxref.CategoryID = categories.CategoryID
INNER JOIN main ON categoryxref.ID = main.ID
WHERE
categoryxref.ID = {$this->ID}
GROUP BY
categories.CatName
ORDER BY
categories.CatName
", SQL_ALL, SQL_ASSOC);

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

@ -10,6 +10,9 @@
$clean = array();
$sql = array();
// Array to store our page information.
$page = array();
// Category.
if (isset($_GET['cat'])&&ctype_digit($_GET['cat'])) {
$clean['cat'] = intval($_GET['cat']);
@ -53,7 +56,7 @@ if (isset($_GET['sort'])&&ctype_alpha($_GET['sort'])) {
}
// Starting point.
$clean['left'] = (isset($_GET['left'])) ? intval($_GET['left']) : 0;
$page['left'] = (isset($_GET['left'])) ? intval($_GET['left']) : 0;
// Per page.
$_GET['perpage'] = (isset($_GET['perpage'])) ? intval($_GET['perpage']) : null;
@ -71,7 +74,7 @@ switch ($_GET['perpage']) {
}
// Ending point.
$clean['right'] = $clean['left'] + $clean['perpage'];
$page['right'] = $page['left'] + $clean['perpage'];
// Prepared verified inputs for their destinations.
@ -93,10 +96,10 @@ $dates = array(
);
$sort = array(
'newest' => 'Newest',
'name' => 'Name',
'rating' => 'Rating',
'downloads' => 'Popularity',
'newest' => 'Newest'
'downloads' => 'Popularity'
);
$apps = array(
@ -154,6 +157,10 @@ if (!empty($sql['q'])) {
$where .= " main.Name LIKE '%{$sql['q']}%' AND ";
}
if (!empty($sql['type'])) {
$where .= " main.Type = '{$sql['type']}' AND ";
}
if (!empty($sql['date'])) {
switch ($sql['date']) {
case 'day':
@ -180,8 +187,11 @@ if (!empty($sql['date'])) {
if (!empty($sql['sort'])) {
switch ($sql['sort']) {
case 'name':
case 'newest':
default:
$orderby .= " main.DateUpdated DESC";
break;
case 'name':
$orderby .= " main.Name ASC";
break;
case 'rating':
@ -190,12 +200,9 @@ if (!empty($sql['sort'])) {
case 'downloads':
$orderby .= " main.TotalDownloads DESC";
break;
case 'newest':
$orderby .= " main.DateUpdated DESC";
break;
}
} else {
$orderby .= " main.Name ASC ";
$orderby .= " main.DateUpdated DESC ";
}
$where .= ' 1 ';
@ -207,35 +214,47 @@ $rawResults = array();
$db->query($query, SQL_ALL);
unset($select);
unset($where);
unset($orderby);
unset($query);
if (is_array($db->record)) {
foreach ($db->record as $row) {
$rawResults[] = $row[0];
}
}
for ($i=$clean['left'];$i<$clean['right'];$i++) {
for ($i=$page['left'];$i<$page['right'];$i++) {
if (isset($rawResults[$i])) {
$results[] = new Addon($rawResults[$i]);
}
}
$resultCount = count($rawResults);
if ($resultCount<$clean['right']) {
$clean['right'] = $resultCount;
if ($resultCount<$page['right']) {
$page['right'] = $resultCount;
}
unset($select);
unset($where);
unset($orderby);
unset($query);
// Do we even have a next or previous page?
$page['previous'] = ($page['left'] >= $clean['perpage']) ? $page['left']-$clean['perpage'] : null;
$page['next'] = ($page['left']+$clean['perpage'] < $resultCount) ? $page['left']+$clean['perpage'] : null;
$page['resultCount'] = $resultCount;
$page['leftDisplay'] = $page['left']+1;
// Build the URL based on passed arguments.
foreach ($clean as $key=>$val) {
if (!empty($val)) {
$buf[] = $key.'='.$val;
}
}
$page['url'] = implode('&amp;',$buf);
unset($buf);
// Pass variables to template object.
$tpl->assign(
array(
'left' => $clean['left']+1,
'right' => $clean['right'],
'perpage' => $clean['perpage'],
'resultcount' => $resultCount,
'page' => $page,
'results' => $results,
'clean' => $clean,
'cats' => $amo->Cats,

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

@ -2,20 +2,21 @@
<script type="text/javascript" src="/js/auto.js"></script>
{if $addon->PreviewURI}
<p class="screenshot">
<a href="./previews.php?id={$addon->ID}" title="See more {$addon->Name} previews.">
<img src="{$config.webpath}{$addon->PreviewURI}" height="{$addon->PreviewHeight}" width="{$addon->PreviewWidth}" alt="{$addon->Name} screenshot">
</a>
<strong><a href="./previews.php?id={$addon->ID}" title="See more {$addon->Name} previews.">More Previews &raquo;</a></strong>
</p>
{/if}
<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>
{if $addon->PreviewURI}
<p class="screenshot">
<a href="./previews.php?id={$addon->ID}" title="See more {$addon->Name} previews.">
<img src="{$config.webpath}{$addon->PreviewURI}" alt="{$addon->Name} screenshot">
</a>
<strong><a href="./previews.php?id={$addon->ID}" title="See more {$addon->Name} previews.">More Previews &raquo;</a></strong>
</p>
{/if}
<p>{$addon->Description}</p>

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

@ -18,7 +18,7 @@
<li><span>Find similar Addons...</span>
<ul>
{section name=cats loop=$addon->AddonCats}
<li><a href="./search.php?cat={$addon->AddonCats[cats].CatName}" title="See other Addons in this category.">{$addon->AddonCats[cats].CatName}</a></li>
<li><a href="./search.php?cat={$addon->AddonCats[cats].CategoryID}" title="See other Addons in this category.">{$addon->AddonCats[cats].CatName}</a></li>
{/section}
<li><a href="./search.php?app={$addon->AppName}">Other {$addon->AppName} Addons</a></li>
</ul>

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

@ -19,7 +19,7 @@
</li>
{/section}
</ol>
<p><strong><a href="./search.php?app={$app}&amp;cat=Newest">More ...</a></strong></p>
<p><strong><a href="./search.php?app={$app}&amp;sort=newest">More ...</a></strong></p>
<h2>Popular {$app} Extensions</h2>
<ol class="popularlist">
@ -29,7 +29,7 @@
</li>
{/section}
</ol>
<p><strong><a href="./search.php?app={$app}&amp;cat=Popular&amp;type=E">More ...</a></strong></p>
<p><strong><a href="./search.php?app={$app}&amp;sort=popular&amp;type=E">More ...</a></strong></p>
<h2>Popular {$app} Themes</h2>
<ol class="popularlist">
@ -37,7 +37,7 @@
<li><a href="./addon.php?id={$popularThemes[pt].id}">{$popularThemes[pt].name}</a> <span class="downloads">({$popularThemes[pt].Rating} rating, {$popularThemes[pt].dc} downloads)</span> - {$popularThemes[pt].Description|escape} ...</li>
{/section}
</ol>
<p><strong><a href="./search.php?app={$app}&amp;cat=Popular&amp;type=T">More ...</a></strong></p>
<p><strong><a href="./search.php?app={$app}&amp;sort=popular&amp;type=T">More ...</a></strong></p>
</div>
<!-- end mainContent -->

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

@ -82,18 +82,47 @@
<div id="mainContent">
{if $results}
<h2>Addon Search Results</h2>
<p class="first">{$resultcount} Addons found. Showing records {$left}-{$right}.</p>
<h2>Addon Search Results - </h2>
<p class="first"><b>{$page.resultCount}</b> Addons found. Showing records <b>{$page.leftDisplay}-{$page.right}</b>. <em>Too many results? Try narrowing your search.</em></p>
<div class="pages">
<div class="prev">
{if $page.left}
<a href="./search.php?{$page.url}&amp;left={$page.previous}">&laquo; Previous Page</a>
{else}
&laquo; Previous Page
{/if}
</div>
<div class="next">
{if $page.next}
<a href="./search.php?{$page.url}&amp;left={$page.next}">Next Page &raquo;</a>
{else}
Next Page &raquo;
{/if}
</div>
</div>
{section name=r loop=$results}
<div class="item">
<div class="rating" title="4.67 Stars out of 5">Rating: {$results[r]->Rating}</div>
<h2 class="first"><a href="./addon.php?id={$results[r]->ID}">{$results[r]->Name} {$results[r]->Version}</a></h2>
<h2 class="first"><a href="./addon.php?id={$results[r]->ID}">{$results[r]->Name}</a></h2>
<p class="first">By <a href="author.php?id={$results[r]->UserID}">{$results[r]->UserName}</a></p>
{if $results[r]->PreviewURI}
<p class="screenshot">
<a href="./previews.php?id={$results[r]->ID}" title="See more {$results[r]->Name} previews.">
<img src="{$config.webpath}{$results[r]->PreviewURI}" height="{$results[r]->PreviewHeight}" width="{$results[r]->PreviewWidth}" alt="{$results[r]->Name} screenshot">
</a>
<strong><a href="./previews.php?id={$results[r]->ID}" title="See more {$results[r]->Name} previews.">More Previews &raquo;</a></strong>
</p>
{/if}
<p class="first">By <a href="./author.php?id={$results[r]->UserID}">{$results[r]->UserName}</a></p>
<p class="first">{$results[r]->Description}</p>
<div style="margin-top: 30px; height: 34px">
<div class="iconbar">
<a href="{$results[r]->DownloadURI}" onclick="return install(event,'{$results[r]->Name}', '{$config.webpath}/img/default.png');">
<a href="{$results[r]->URI}" onclick="return install(event,'{$results[r]->Name}', '{$config.webpath}/img/default.png');">
<img src="{$config.webpath}/img/download.png" height="32" width="32" title="Install {$results[r]->Name}" ALT="">Install</a><br>
<span class="filesize">&nbsp;&nbsp;{$results[r]->Size} kb</span>
</div>
@ -104,9 +133,31 @@
<div class="baseline">Last Update: {$results[r]->DateUpdated|date_format} | Downloads Last 7 Days: {$results[r]->downloadcount} | Total Downloads: {$results[r]->TotalDownloads}</DIV>
</div>
{/section}
<div class="pages">
<div class="prev">
{if $page.left}
<a href="./search.php?{$page.url}&amp;left={$page.previous}">&laquo; Previous Page</a>
{else}
<h2>Addon Search</h2>
<p class="first">There are currently no results. Please use the options at the left to begin a search or try adjusting your search terms.</p>
&laquo; Previous Page
{/if}
</div>
<div class="next">
{if $page.next}
<a href="./search.php?{$page.url}&amp;left={$page.next}">Next Page &raquo;</a>
{else}
Next Page &raquo;
{/if}
</div>
</div>
{else}
<h2>Addon Search</h2>
<p class="first">There are currently no results. Please use the options at the left to begin a search or try adjusting your search terms.</p>
{/if}
</div>