Commit f51a7b57 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Use View::get_url() to generate view urls in view listings



Bug #1006634, part 3

Changes to get_extra_view_info allow the following pages to be updated
with clean view urls, without any performance penalty:

- Latest pages block
- get_views_for_user mnet function
- Group views block
- My views block
- Sitemaps
- Shared pages

Change-Id: I25be10092a7865d34c435196d5f3569e2f08c9c4
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent 20aff7a8
......@@ -582,12 +582,6 @@ function get_views_for_user($username, $query=null) {
require_once('view.php');
$data = View::view_search($query, null, (object) array('owner' => $USER->get('id')));
$data->displayname = display_name($user);
if ($data->count) {
foreach ($data->data as &$v) {
$v['url'] = '/view/view.php?id=' . $v['id'];
$v['fullurl'] = get_config('wwwroot') . 'view/view.php?id=' . $v['id'];
}
}
return $data;
}
......
......@@ -174,7 +174,6 @@ class PluginBlocktypeGroupViews extends SystemBlocktype {
if (!empty($data['mysubmittedviews'])) {
foreach ($data['mysubmittedviews'] as &$v) {
$v['url'] = get_config('wwwroot') . 'view/view.php?id=' . $v['id'];
if ($v['submittedtime']) {
$v['submittedtime'] = format_date($v['submittedtime']);
}
......
......@@ -8,7 +8,7 @@
{if $view.template}
<div class="s fr valign">{$view.form|safe}</div>
{/if}
<h3><a href="{$WWWROOT}view/view.php?id={$view.id}">{$view.title}</a></h3>
<h3><a href="{$view.fullurl}">{$view.title}</a></h3>
<div class="s">{$view.description|str_shorten_html:100:true|strip_tags|safe}</div>
{if $view.tags}<div class="tags"><label>{str tag=tags}:</label> {list_tags owner=$view.owner tags=$view.tags}</div>{/if}
</td>
......@@ -28,7 +28,7 @@
{if $view.template}
<div class="s fr valign">{$view.form|safe}</div>
{/if}
<h3><a href="{$WWWROOT}view/view.php?id={$view.id}">{$view.title}</a></h3>
<h3><a href="{$view.fullurl}">{$view.title}</a></h3>
{if $view.sharedby}
<span class="owner">{str tag=by section=view}
{if $view.group}
......@@ -60,9 +60,9 @@
{foreach from=$mysubmittedviews item=view}
<tr class="{cycle values='r0,r1'}"><td class="submittedform">
{if $view.submittedtime}
{str tag=youhavesubmittedon section=view arg1=$view.url arg2=$view.title arg3=$view.submittedtime}
{str tag=youhavesubmittedon section=view arg1=$view.fullurl arg2=$view.title arg3=$view.submittedtime}
{else}
{str tag=youhavesubmitted section=view arg1=$view.url arg2=$view.title}
{str tag=youhavesubmitted section=view arg1=$view.fullurl arg2=$view.title}
{/if}
</td></tr>
{/foreach}
......@@ -86,8 +86,8 @@
{foreach from=$allsubmittedviews item=view}
<tr class="{cycle values='r0,r1'}">
<td>
<strong><a href="{$WWWROOT}view/view.php?id={$view.id}">{$view.title|str_shorten_text:60:true}</a></strong>
<div><a href="{$WWWROOT}user/view.php?id={$view.owner}">{$view.sharedby}</a></div>
<strong><a href="{$view.fullurl}">{$view.title|str_shorten_text:60:true}</a></strong>
<div><a href="{profile_url($view.user)}">{$view.sharedby}</a></div>
</td>
<td>
<div class="postedon nowrap">{$view.submittedtime|format_date}</div>
......
......@@ -3,7 +3,7 @@
{foreach from=$VIEWS item=item name=view}
<tr>
<td class="{cycle values='r0,r1'}">
<h4><a href="{$WWWROOT}view/view.php?id={$item.id}">{$item.title}</a></h4>
<h4><a href="{$item.fullurl}">{$item.title}</a></h4>
{if $item.description}
<div class="details">{$item.description|str_shorten_html:100:true|strip_tags|safe}</div>
{/if}
......
......@@ -2,7 +2,7 @@
<table class="viewlist">
{foreach from=$views item=view}
<tr class="{cycle values='r0,r1'}">
<td><h4><a href="{$WWWROOT}view/view.php?id={$view.id}">{$view.title}</a></h4>
<td><h4><a href="{$view.fullurl}">{$view.title}</a></h4>
<div class="details">{$view.description|str_shorten_html:100:true|strip_tags|safe}</div></td>
{if $view.sharedby}
<td class="right">
......
......@@ -170,8 +170,7 @@ class Sitemap {
if (!empty($views->data)) {
foreach ($views->data as $view) {
if (isset($view['mtime']) && $this->check_date($view['mtime'])) {
$viewurl = get_config('wwwroot') . 'view/view.php?id=' . $view['id'];
$viewurl = utf8_encode(htmlspecialchars($viewurl, ENT_QUOTES, 'UTF-8'));
$viewurl = utf8_encode(htmlspecialchars($view['fullurl'], ENT_QUOTES, 'UTF-8'));
$viewlastmod = format_date(strtotime($view['mtime']), 'strftimew3cdate');
$this->add_url($viewurl, $viewlastmod);
......
......@@ -3130,7 +3130,7 @@ class View {
SELECT
v.id, v.title, v.description, v.owner, v.ownerformat, v.group, v.institution,
v.template, v.mtime, v.ctime,
c.id AS collid, c.name, v.type
c.id AS collid, c.name, v.type, v.urlid
' . $from . $where . '
ORDER BY ' . $orderby . ', v.id ASC',
$ph, $offset, $limit
......@@ -3323,7 +3323,7 @@ class View {
$count = count_records_sql('SELECT COUNT(*) ' . $from, $ph);
$viewdata = get_records_sql_assoc('
SELECT v.id,v.title,v.startdate,v.stopdate,v.description,v.group,v.owner,v.ownerformat,v.institution ' . $from . '
SELECT v.id,v.title,v.startdate,v.stopdate,v.description,v.group,v.owner,v.ownerformat,v.institution,v.urlid ' . $from . '
ORDER BY v.title, v.id',
$ph, $offset, $limit
);
......@@ -3354,9 +3354,9 @@ class View {
$where .= ' AND v.owner = ?';
}
$viewdata = get_records_sql_array('
$viewdata = get_records_sql_assoc('
SELECT
v.id as id, v.title, v.description, v.owner, v.ownerformat, u.firstname, u.lastname, u.preferredname,
v.id as id, v.title, v.description, v.owner, v.ownerformat, v.urlid,
' . db_format_tsfield('v.submittedtime','submittedtime') . '
FROM {view} v
INNER JOIN {usr} u ON u.id = v.owner
......@@ -3366,10 +3366,11 @@ class View {
);
if ($viewdata) {
View::get_extra_view_info($viewdata, false);
foreach ($viewdata as &$v) {
$v->sharedby = full_name($v);
$v = (array)$v;
$v['sharedby'] = full_name($v['user']);
}
$viewdata = array_values($viewdata);
}
return $viewdata;
......
{foreach from=$views item=view}
<tr class="{cycle values='r0,r1'}">
<td class="sharedpages">
<h3><a href="{$WWWROOT}view/view.php?id={$view.id}">{$view.title|str_shorten_text:65:true}</a></h3>
<h3><a href="{$view.fullurl}">{$view.title|str_shorten_text:65:true}</a></h3>
{if $view.sharedby}
<span class="owner">
{if $view.group}
......
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