Commit 1402a7c8 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Collect url information and display clean urls in collections



Bug #1006634, part 3

Updates the Collection::views() method to get a url along with each
view, and uses these in the templates related to collections.

Also gets the maximum and minimum displayorder fields by iterating
over returned records instead of performing additional queries.

Change-Id: Ia115f6057854f5746cc3c873b79324198089252a
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent af140a73
......@@ -6,7 +6,7 @@
{if $currentview == $item->view}
<h4>{$item->title}</h4>
{else}
<h4><a href="{$WWWROOT}view/view.php?id={$item->view}">{$item->title}</a></h4>
<h4><a href="{$item->fullurl}">{$item->title}</a></h4>
{/if}
</td>
</tr>
......
......@@ -370,19 +370,28 @@ class Collection {
if (!isset($this->views)) {
$sql = "SELECT cv.*, v.title
$sql = "SELECT v.id, cv.*, v.title, v.owner, v.group, v.institution, v.ownerformat, v.urlid
FROM {collection_view} cv JOIN {view} v ON cv.view = v.id
WHERE cv.collection = ?
ORDER BY cv.displayorder, v.title, v.ctime ASC";
$result = get_records_sql_array($sql, array($this->get('id')));
$result = get_records_sql_assoc($sql, array($this->get('id')));
if (!empty($result)) {
require_once('view.php');
View::get_extra_view_info($result, false, false);
$result = array_values($result);
$max = $min = $result[0]['displayorder'];
foreach ($result as &$r) {
$max = max($max, $r['displayorder']);
$min = min($min, $r['displayorder']);
$r = (object) $r;
}
$this->views = array(
'views' => $result,
'views' => array_values($result),
'count' => count($result),
'max' => get_field('collection_view', 'MAX(displayorder)', 'collection', $this->get('id')),
'min' => get_field('collection_view', 'MIN(displayorder)', 'collection', $this->get('id')),
'max' => $max,
'min' => $min,
);
}
else {
......
......@@ -16,7 +16,7 @@
<a href="{$WWWROOT}collection/delete.php?id={$collection->id}" title="{str tag=deletecollection section=collection}"><img src="{theme_url filename='images/icon_close.gif'}" alt="{str tag=delete}"></a>
</div>
{if $collection->views[0]->view}
<h3><a href="{$WWWROOT}view/view.php?id={$collection->views[0]->view}">{$collection->name}</a></h3>
<h3><a href="{$collection->views[0]->fullurl}">{$collection->name}</a></h3>
{else}
<h3 title="{str tag=emptycollection section=collection}">{$collection->name}</h3>
{/if}
......@@ -28,7 +28,7 @@
<div><label>{str tag=Views section=view}:</label>
{if $collection->views}
{foreach from=$collection->views item=view name=cviews}
<a href="{$WWWROOT}view/view.php?id={$view->view}">{$view->title}</a>{if !$.foreach.cviews.last}, {/if}
<a href="{$view->fullurl}">{$view->title}</a>{if !$.foreach.cviews.last}, {/if}
{/foreach}
{else}
{str tag=none}
......
......@@ -26,7 +26,7 @@
{else}
<td>&nbsp;</td>
{/if}
<td><label><a href="{$WWWROOT}view/view.php?id={$view->view}">{$view->title}</a></label></td>
<td><label><a href="{$view->fullurl}">{$view->title}</a></label></td>
<td><div class="fr s">{$view->remove|safe}</div></td>
</tr>
{/foreach}
......
......@@ -5,7 +5,7 @@
{foreach from=$chunk item=view}
<li{if $view->view == $viewid} class="selected"{if $haslots}{$showmore=true}{/if}{/if}>
{if $view->view != $viewid}
<a class="colnav" href="{$WWWROOT}view/view.php?id={$view->view}">{$view->title|str_shorten_text:30:true}</a>
<a class="colnav" href="{$view->fullurl}">{$view->title|str_shorten_text:30:true}</a>
{else}
<span>{$view->title|str_shorten_text:30:true}</span>
{/if}
......
......@@ -9,7 +9,7 @@
var params = {};
params.id = {/literal}{$view->view}{literal};
sendjsonrequest('../collection/viewcontent.json.php', params, 'POST', partial(showPreview, 'big'));
{/literal}" href="{$WWWROOT}view/view.php?id={$view->view}">{$view->title|str_shorten_text:30:true}</a>
{/literal}" href="{$view->fullurl}">{$view->title|str_shorten_text:30:true}</a>
{else}
<span>{$view->title|str_shorten_text:30:true}</span>
{/if}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment