Enhancement of the history of a wiki page.
- Add more visibility to the delete revision function - Add a restore function Don't send 404 when the user what to see a specific revision that is the current revision
This commit is contained in:
parent
69d0384ec3
commit
9a6a6c21f5
@ -262,7 +262,13 @@ class IDF_Views_Wiki
|
|||||||
if (isset($request->GET['rev']) and preg_match('/^[0-9]+$/', $request->GET['rev'])) {
|
if (isset($request->GET['rev']) and preg_match('/^[0-9]+$/', $request->GET['rev'])) {
|
||||||
$oldrev = Pluf_Shortcuts_GetObjectOr404('IDF_WikiRevision',
|
$oldrev = Pluf_Shortcuts_GetObjectOr404('IDF_WikiRevision',
|
||||||
$request->GET['rev']);
|
$request->GET['rev']);
|
||||||
if ($oldrev->wikipage != $page->id or $oldrev->is_head == true) {
|
if ($oldrev->is_head == true) {
|
||||||
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::view',
|
||||||
|
array($prj->shortname, $page->title));
|
||||||
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($oldrev->wikipage != $page->id) {
|
||||||
return new Pluf_HTTP_Response_NotFound($request);
|
return new Pluf_HTTP_Response_NotFound($request);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -288,6 +294,39 @@ class IDF_Views_Wiki
|
|||||||
$request);
|
$request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* See the revision list of a documentation page.
|
||||||
|
*/
|
||||||
|
public $history_precond = array('IDF_Precondition::accessWiki');
|
||||||
|
public function history($request, $match)
|
||||||
|
{
|
||||||
|
$prj = $request->project;
|
||||||
|
// Find the page
|
||||||
|
$sql = new Pluf_SQL('project=%s AND title=%s',
|
||||||
|
array($prj->id, $match[2]));
|
||||||
|
$pages = Pluf::factory('IDF_WikiPage')->getList(array('filter'=>$sql->gen()));
|
||||||
|
if ($pages->count() != 1) {
|
||||||
|
return new Pluf_HTTP_Response_NotFound($request);
|
||||||
|
}
|
||||||
|
$page = $pages[0];
|
||||||
|
$ptags = self::getWikiTags($prj);
|
||||||
|
$dtag = array_pop($ptags); // The last tag is the deprecated tag.
|
||||||
|
$tags = $page->get_tags_list();
|
||||||
|
$dep = Pluf_Model_InArray($dtag, $tags);
|
||||||
|
$title = sprintf(__('History of the wiki page %s'), $page->title);
|
||||||
|
$revision = $page->get_current_revision();
|
||||||
|
$revs = $page->get_revisions_list(array('order' => 'creation_dtime DESC'));
|
||||||
|
return Pluf_Shortcuts_RenderToResponse('idf/wiki/history.html',
|
||||||
|
array(
|
||||||
|
'page' => $page,
|
||||||
|
'page_title' => $title,
|
||||||
|
'rev' => $revision,
|
||||||
|
'revs' => $revs,
|
||||||
|
'tags' => $tags,
|
||||||
|
),
|
||||||
|
$request);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a revision of a page.
|
* Remove a revision of a page.
|
||||||
*/
|
*/
|
||||||
@ -327,6 +366,57 @@ class IDF_Views_Wiki
|
|||||||
$request);
|
$request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public $restoreRev_precond = array('IDF_Precondition::accessWiki',
|
||||||
|
'IDF_Precondition::projectMemberOrOwner');
|
||||||
|
public function restoreRev($request, $match)
|
||||||
|
{
|
||||||
|
$prj = $request->project;
|
||||||
|
$oldrev = Pluf_Shortcuts_GetObjectOr404('IDF_WikiRevision', $match[2]);
|
||||||
|
$page = $oldrev->get_wikipage();
|
||||||
|
$prj->inOr404($page);
|
||||||
|
|
||||||
|
// Prevent restore the current version
|
||||||
|
if ($oldrev->is_head == true) {
|
||||||
|
$request->user->setMessage(__('This revision is already the current revision.'));
|
||||||
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::view',
|
||||||
|
array($prj->shortname, $page->title));
|
||||||
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
$params = array(
|
||||||
|
'project' => $prj,
|
||||||
|
'user' => $request->user,
|
||||||
|
'page' => $page,
|
||||||
|
);
|
||||||
|
|
||||||
|
$data = array(
|
||||||
|
'title' => $page->title,
|
||||||
|
'summary' => $page->summary,
|
||||||
|
'content' => $oldrev->content,
|
||||||
|
'comment' => sprintf(__('Restore old revision (%s)'), $oldrev->id),
|
||||||
|
);
|
||||||
|
|
||||||
|
$tags = $page->get_tags_list();
|
||||||
|
for ($i=1;$i<4;$i++) {
|
||||||
|
if (isset($tags[$i-1])) {
|
||||||
|
if ($tags[$i-1]->class != 'Other') {
|
||||||
|
$data['label'.$i] = (string) $tags[$i-1];
|
||||||
|
} else {
|
||||||
|
$data['label'.$i] = $tags[$i-1]->name;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$data['label'.$i] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$form = new IDF_Form_WikiUpdate($data, $params);
|
||||||
|
$page = $form->save();
|
||||||
|
|
||||||
|
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::view',
|
||||||
|
array($prj->shortname, $page->title));
|
||||||
|
return new Pluf_HTTP_Response_Redirect($url);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View a documentation page.
|
* View a documentation page.
|
||||||
*/
|
*/
|
||||||
|
@ -292,11 +292,21 @@ $ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/delrev/(\d+)/$#',
|
|||||||
'model' => 'IDF_Views_Wiki',
|
'model' => 'IDF_Views_Wiki',
|
||||||
'method' => 'deleteRev');
|
'method' => 'deleteRev');
|
||||||
|
|
||||||
|
$ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/resrev/(\d+)/$#',
|
||||||
|
'base' => $base,
|
||||||
|
'model' => 'IDF_Views_Wiki',
|
||||||
|
'method' => 'restoreRev');
|
||||||
|
|
||||||
$ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/delete/(\d+)/$#',
|
$ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/delete/(\d+)/$#',
|
||||||
'base' => $base,
|
'base' => $base,
|
||||||
'model' => 'IDF_Views_Wiki',
|
'model' => 'IDF_Views_Wiki',
|
||||||
'method' => 'delete');
|
'method' => 'delete');
|
||||||
|
|
||||||
|
$ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/history/(.*)/$#',
|
||||||
|
'base' => $base,
|
||||||
|
'model' => 'IDF_Views_Wiki',
|
||||||
|
'method' => 'history');
|
||||||
|
|
||||||
$ctl[] = array('regex' => '#^/p/([\-\w]+)/page/(.*)/$#',
|
$ctl[] = array('regex' => '#^/p/([\-\w]+)/page/(.*)/$#',
|
||||||
'base' => $base,
|
'base' => $base,
|
||||||
'model' => 'IDF_Views_Wiki',
|
'model' => 'IDF_Views_Wiki',
|
||||||
|
38
src/IDF/templates/idf/wiki/history.html
Normal file
38
src/IDF/templates/idf/wiki/history.html
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{extends "idf/wiki/base.html"}
|
||||||
|
|
||||||
|
{block extraheader}
|
||||||
|
<meta name="ROBOTS" content="NOINDEX" />
|
||||||
|
{/block}
|
||||||
|
|
||||||
|
{block docclass}yui-t3{assign $inView=true}{/block}
|
||||||
|
|
||||||
|
{block body}
|
||||||
|
<table class="recent-issues">
|
||||||
|
<tr><th>Id</th><th>Who</th><th>When</th><th>Summary</th><th>Actions</th></tr>
|
||||||
|
{foreach $revs as $r}
|
||||||
|
{ashowuser 'submitter', $rev.get_submitter(), $request}
|
||||||
|
{aurl 'view_url', 'IDF_Views_Wiki::view', array($project.shortname, $page.title), array('rev' => $r->id)}
|
||||||
|
{aurl 'delete_url', 'IDF_Views_Wiki::deleteRev', array($project.shortname, $r->id)}
|
||||||
|
{aurl 'restore_url', 'IDF_Views_Wiki::restoreRev', array($project.shortname, $r->id)}
|
||||||
|
<tr><td><a href="{$view_url}">{$r->id}</a></td><td>{$submitter}</td><td class="a-c">{$r->creation_dtime|dateago}</td><td>{$r->summary}</td><td>{if $r->is_head == false}<a href="{$view_url}">View</a> - <a href="{$delete_url}">Delete</a> - <a href="{$restore_url}">Restore</a>{/if}</td></tr>
|
||||||
|
{/foreach}
|
||||||
|
</table>
|
||||||
|
{aurl 'add_rev', 'IDF_Views_Wiki::update', array($project.shortname, $page.title)}
|
||||||
|
<p><a href="{$add_rev}"><img style="vertical-align: text-bottom;" src="{media '/idf/img/add.png'}" alt="+" align="bottom"></a> <a href="{$add_rev}">{trans 'Update This Page'}</a></p>
|
||||||
|
{/block}
|
||||||
|
|
||||||
|
|
||||||
|
{block context}
|
||||||
|
{ashowuser 'submitter', $page.get_submitter(), $request}
|
||||||
|
<p><strong>{trans 'Created:'}</strong> <span class="nobrk">{$page.creation_dtime|dateago}</span><br /><span class="nobrk">{blocktrans}by {$submitter}{/blocktrans}</span></p>
|
||||||
|
{if $rev.creation_dtime != $page.creation_dtime}<p>{ashowuser 'submitter', $rev.get_submitter(), $request}
|
||||||
|
<strong>{trans 'Updated:'}</strong> <span class="nobrk">{$rev.creation_dtime|dateago}</span><br /><span class="nobrk">{blocktrans}by {$submitter}{/blocktrans}</span></p>{/if}
|
||||||
|
{if $tags.count()}
|
||||||
|
<p>
|
||||||
|
<strong>{trans 'Labels:'}</strong><br />
|
||||||
|
{foreach $tags as $tag}
|
||||||
|
<span class="label"><strong>{$tag.class}:</strong>{$tag.name}</span><br />
|
||||||
|
{/foreach}
|
||||||
|
</p>{/if}
|
||||||
|
<p class="helptext"><a href="{url 'IDF_Views_Wiki::view', array($project.shortname, $page.title)}">{trans 'See current revision'}</a></p>
|
||||||
|
{/block}
|
@ -52,9 +52,6 @@ by {$submitter}.{/blocktrans}</p>
|
|||||||
{/foreach}
|
{/foreach}
|
||||||
</p>{/if}
|
</p>{/if}
|
||||||
{if $revs.count() > 0}
|
{if $revs.count() > 0}
|
||||||
<p><strong>{trans 'Old Revisions'}</strong></p>
|
<p class="helptext"><a href="{url 'IDF_Views_Wiki::history', array($project.shortname, $page.title)}">{trans 'See older revision'}</a></p>
|
||||||
<ul>{foreach $revs as $old}
|
|
||||||
<li><a href="{url 'IDF_Views_Wiki::view', array($project.shortname, $page.title), array('rev'=>$old.id)}">{$old.summary}</a></li>
|
|
||||||
{/foreach}</ul>
|
|
||||||
{/if}
|
{/if}
|
||||||
{/block}
|
{/block}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{aurl 'syntax_url', 'IDF_Views_Wiki::view', array($project.shortname, 'IndeferoMarkdownHelp')}
|
{aurl 'syntax_url', 'IDF_Views_Wiki::view', array($project.shortname, 'IndeferoMarkdownHelp')}
|
||||||
{aurl 'wiki_add', 'IDF_Views_Wiki::create', array($project.shortname)}
|
{aurl 'wiki_add', 'IDF_Views_Wiki::create', array($project.shortname)}
|
||||||
{aurl 'wiki_update', 'IDF_Views_Wiki::update', array($project.shortname, 'IndeferoSummaryDefault')}
|
{aurl 'wiki_update', 'IDF_Views_Wiki::update', array($project.shortname, 'IndeferoSummaryDefault')}
|
||||||
|
{aurl 'wiki_history', 'IDF_Views_Wiki::history', array($project.shortname, 'IndeferoSummaryDefault')}
|
||||||
{aurl 'wiki_admin', 'IDF_Views_Project::adminWiki', array($project.shortname)}
|
{aurl 'wiki_admin', 'IDF_Views_Project::adminWiki', array($project.shortname)}
|
||||||
{blocktrans}
|
{blocktrans}
|
||||||
Welcome on the documentation section of the project {$project->name}.
|
Welcome on the documentation section of the project {$project->name}.
|
||||||
@ -10,8 +11,7 @@ All documentation page use the markdown syntax, you can find help about this syn
|
|||||||
- You can update this page [here]({$wiki_update}).
|
- You can update this page [here]({$wiki_update}).
|
||||||
- You can select an other default wiki page [here]({$wiki_admin}). You need to be admin.
|
- You can select an other default wiki page [here]({$wiki_admin}). You need to be admin.
|
||||||
|
|
||||||
{*
|
|
||||||
All modification on wiki pages are saved, and you can see this history on the detail part of each pages.
|
All modification on a wiki page are saved, and you can see this history for each pages.
|
||||||
The history of the current page can be see here.
|
The history of the current page can be see [here]({$wiki_history}).
|
||||||
*}
|
|
||||||
{/blocktrans}
|
{/blocktrans}
|
||||||
|
Loading…
Reference in New Issue
Block a user