Indefero

Indefero Commit Details


Date:2011-12-05 19:16:27 (13 years 16 days ago)
Author:Thomas Keller
Branch:develop, release-1.3
Commit:3f0c7c23d2907fa3ed90659c7c62c8f8d0df5d5b
Parents: 8fde1e4762e8ff9f36acbf8602b099c2f7bd2211
Message:Finally save pagerevision and resourcerevision relations when a new page revision is created; fix a couple of bugs and streamline the view logic for viewPage and viewResource.

Changes:

File differences

src/IDF/Template/Markdown.php
130130
131131
132132
133
134
133
134
135
136
135137
136138
137139
......
140142
141143
142144
145
146
147
143148
144149
145150
if (isset($this->request->GET['rev']) and preg_match('/^[0-9]+$/', $this->request->GET['rev'])) {
$pageRevision = Pluf_Shortcuts_GetObjectOr404('IDF_Wiki_PageRevision',
$this->request->GET['rev']);
if ($pageRevision->wikipage != $pages[0]->id) {
return '<span title="'.__('This revision of the resource is no longer available.').'">'.$match.'</span>';
// this is actually an invariant since we came so far looking at
// and rendering the old revision already
if ($pageRevision == null) {
throw new Exception('page revision with id '.$this->request->GET['rev'].' not found');
}
}
$resourceRevision = Pluf::factory('IDF_Wiki_ResourceRevision')->getOne(
array('filter' => $sql->gen(), 'view' => 'join_pagerevision'));
if ($resourceRevision == null) {
return '<span title="'.__('This revision of the resource is no longer available.').'">'.$match.'</span>';
}
}
$validOpts = array(
src/IDF/Views/Wiki.php
297297
298298
299299
300
300
301
301302
302303
303
304
304305
305
306
306307
307308
308309
......
311312
312313
313314
314
315315
316316
317317
......
319319
320320
321321
322
323322
324323
325324
......
348347
349348
350349
351
350
352351
353352
354353
return new Pluf_HTTP_Response_NotFound($request);
}
$page = $pages[0];
$oldrev = false;
$revision = $page->get_current_revision();
// We grab the old revision if requested.
if (isset($request->GET['rev']) and preg_match('/^[0-9]+$/', $request->GET['rev'])) {
$oldrev = Pluf_Shortcuts_GetObjectOr404('IDF_Wiki_PageRevision',
$revision = Pluf_Shortcuts_GetObjectOr404('IDF_Wiki_PageRevision',
$request->GET['rev']);
if ($oldrev->wikipage != $page->id or $oldrev->is_head == true) {
if ($revision->wikipage != $page->id) {
return new Pluf_HTTP_Response_NotFound($request);
}
}
$tags = $page->get_tags_list();
$dep = Pluf_Model_InArray($dtag, $tags);
$title = $page->title;
$revision = $page->get_current_revision();
$false = Pluf_DB_BooleanToDb(false, $page->getDbConnection());
$revs = $page->get_revisions_list(array('order' => 'creation_dtime DESC',
'filter' => 'is_head='.$false));
array(
'page_title' => $title,
'page' => $page,
'oldrev' => $oldrev,
'rev' => $revision,
'revs' => $revs,
'tags' => $tags,
if (isset($request->GET['rev']) and preg_match('/^[0-9]+$/', $request->GET['rev'])) {
$revision = Pluf_Shortcuts_GetObjectOr404('IDF_Wiki_ResourceRevision',
$request->GET['rev']);
if ($revision->wikiresource != $resource->id or $revision->is_head == true) {
if ($revision->wikiresource != $resource->id) {
return new Pluf_HTTP_Response_NotFound($request);
}
}
src/IDF/Wiki/PageRevision.php
137137
138138
139139
140
141
140142
141143
142144
......
146148
147149
148150
149
150
151
151152
152153
153154
......
159160
160161
161162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
162181
163182
164183
function postSave($create=false)
{
$prj = $this->get_wikipage()->get_project();
if ($create) {
// Check if more than one revision for this page. We do
// not want to insert the first revision in the timeline
$sql = new Pluf_SQL('wikipage=%s', array($this->wikipage));
$rev = Pluf::factory('IDF_Wiki_PageRevision')->getList(array('filter'=>$sql->gen()));
if ($rev->count() > 1) {
IDF_Timeline::insert($this, $this->get_wikipage()->get_project(),
$this->get_submitter());
IDF_Timeline::insert($this, $prj, $this->get_submitter());
foreach ($rev as $r) {
if ($r->id != $this->id and $r->is_head) {
$r->is_head = false;
$page->update(); // Will update the modification timestamp.
IDF_Search::index($page);
}
// remember the resource revisions used in this page revision
if ($this->is_head) {
preg_match_all('#\[\[!([A-Za-z0-9\-]+)[^\]]*\]\]#im', $this->content, $matches, PREG_PATTERN_ORDER);
if (count($matches) > 1 && count($matches[1]) > 0) {
foreach ($matches[1] as $resourceName) {
$sql = new Pluf_SQL('project=%s AND title=%s',
array($prj->id, $resourceName));
$resources = Pluf::factory('IDF_Wiki_Resource')->getList(array('filter'=>$sql->gen()));
if ($resources->count() == 0)
continue;
$current_revision = $resources[0]->get_current_revision();
$current_revision->setAssoc($this);
$this->setAssoc($current_revision);
}
}
}
}
public function timelineFragment($request)
src/IDF/conf/urls.php
332332
333333
334334
335
335
336336
337337
338338
'model' => 'IDF_Views_Wiki',
'method' => 'viewPage');
$ctl[] = array('regex' => '#^/p/([\-\w]+)/resouce/(.*)/$#',
$ctl[] = array('regex' => '#^/p/([\-\w]+)/resource/(.*)/$#',
'base' => $base,
'model' => 'IDF_Views_Wiki',
'method' => 'viewResource');
src/IDF/templates/idf/wiki/viewPage.html
11
22
33
4
4
55
66
77
......
1414
1515
1616
17
18
17
18
1919
2020
2121
......
2828
2929
3030
31
3231
33
34
35
32
33
34
3635
3736
38
3937
4038
4139
{extends "idf/wiki/base.html"}
{block extraheader}
{if $oldrev}<meta name="ROBOTS" content="NOINDEX" />{/if}
{if !$rev.is_head}<meta name="ROBOTS" content="NOINDEX" />{/if}
<link rel="stylesheet" type="text/css" media="print" href="{media '/idf/css/print-wiki.css'}" />
{/block}
use it as reference only if you are sure you need these specific information.{/blocktrans}</p>
</div>
{/if}
{if $oldrev}
{ashowuser 'submitter', $oldrev.get_submitter(), $request}{aurl 'url', 'IDF_Views_Wiki::viewPage', array($project.shortname, $page.title)}
{if !$rev.is_head}
{ashowuser 'submitter', $rev.get_submitter(), $request}{aurl 'url', 'IDF_Views_Wiki::viewPage', array($project.shortname, $page.title)}
<div class="old-rev">
<p>{blocktrans}You are looking at an old revision of the page
<a href="{$url}">{$page.title}</a>. This revision was created
<script type="text/javascript" src="{media '/idf/js/wiki-toc.js'}"></script>
<p class="desc">{$page.summary}</p>
{if !$oldrev}
{markdown $rev.content, $request}
{else}
{markdown $oldrev.content, $request}
{if $isOwner or $isAdmin}{aurl 'url', 'IDF_Views_Wiki::deletePageRev', array($project.shortname, $oldrev.id)}
{if !$rev.is_head and ($isOwner or $isAdmin)}
{aurl 'url', 'IDF_Views_Wiki::deletePageRev', array($project.shortname, $rev.id)}
<p class="delp"><a href="{$url}" title="{trans 'Delete this revision'}"><img src="{media '/idf/img/trash.png'}" style="vertical-align: text-bottom;" alt="{trans 'Trash'}" /></a> <a href="{$url}">{trans 'Delete this revision'}</a></p>
{/if}
{/if}
</div>
{/block}
src/IDF/templates/idf/wiki/viewResource.html
3030
3131
3232
33
33
34
35
3436
3537
3638
<li>{trans 'MIME type'}: {$resource.mime_type}</li>
<li><a href="{$rev.getRawURL(true)}">{trans 'Download this file'}</a></li>
</ul>
{if ($isOwner or $isAdmin) and !$rev.is_head}{aurl 'url', 'IDF_Views_Wiki::deleteResourceRev', array($project.shortname, $rev.id)}
{if !$rev.is_head and ($isOwner or $isAdmin)}
{aurl 'url', 'IDF_Views_Wiki::deleteResourceRev', array($project.shortname, $rev.id)}
<p class="delp"><a href="{$url}" title="{trans 'Delete this revision'}"><img src="{media '/idf/img/trash.png'}" style="vertical-align: text-bottom;" alt="{trans 'Trash'}" /></a> <a href="{$url}">{trans 'Delete this revision'}</a></p>
{/if}

Archive Download the corresponding diff file

Page rendered in 0.09300s using 13 queries.