Added ticket 357, delete wiki article.
This commit is contained in:
parent
3a28fe9d28
commit
c486ca928b
64
src/IDF/Form/WikiDelete.php
Normal file
64
src/IDF/Form/WikiDelete.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# This file is part of InDefero, an open source project management application.
|
||||
# Copyright (C) 2008 Céondo Ltd and contributors.
|
||||
#
|
||||
# InDefero is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# InDefero is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
#
|
||||
# ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/**
|
||||
* Delete a documentation page.
|
||||
*
|
||||
* This is a hard delete of the page and the revisions.
|
||||
*
|
||||
*/
|
||||
class IDF_Form_WikiDelete extends Pluf_Form
|
||||
{
|
||||
protected $page = null;
|
||||
|
||||
public function initFields($extra=array())
|
||||
{
|
||||
$this->page = $extra['page'];
|
||||
$this->fields['confirm'] = new Pluf_Form_Field_Boolean(
|
||||
array('required' => true,
|
||||
'label' => __('Yes, I understand that the page and all its revisions will be deleted.'),
|
||||
'initial' => '',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the confirmation.
|
||||
*/
|
||||
public function clean_confirm()
|
||||
{
|
||||
if (!$this->cleaned_data['confirm']) {
|
||||
throw new Pluf_Form_Invalid(__('You need to confirm the deletion.'));
|
||||
}
|
||||
return $this->cleaned_data['confirm'];
|
||||
}
|
||||
|
||||
|
||||
function save($commit=true)
|
||||
{
|
||||
if (!$this->isValid()) {
|
||||
throw new Exception(__('Cannot save the model from an invalid form.'));
|
||||
}
|
||||
$this->page->delete();
|
||||
return true;
|
||||
}
|
||||
}
|
@ -346,6 +346,46 @@ class IDF_Views_Wiki
|
||||
$request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a Wiki page.
|
||||
*/
|
||||
public $delete_precond = array('IDF_Precondition::accessDownloads',
|
||||
'IDF_Precondition::projectMemberOrOwner');
|
||||
public function delete($request, $match)
|
||||
{
|
||||
$prj = $request->project;
|
||||
$page = Pluf_Shortcuts_GetObjectOr404('IDF_WikiPage', $match[2]);
|
||||
$prj->inOr404($page);
|
||||
$params = array('page' => $page);
|
||||
if ($request->method == 'POST') {
|
||||
$form = new IDF_Form_WikiDelete($request->POST, $params);
|
||||
if ($form->isValid()) {
|
||||
$form->save();
|
||||
$request->user->setMessage(__('The documentation page has been deleted.'));
|
||||
$url = Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::index',
|
||||
array($prj->shortname));
|
||||
return new Pluf_HTTP_Response_Redirect($url);
|
||||
}
|
||||
} else {
|
||||
$form = new IDF_Form_WikiDelete(null, $params);
|
||||
}
|
||||
$title = sprintf(__('Delete Page %s'), $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));
|
||||
return Pluf_Shortcuts_RenderToResponse('idf/wiki/deletepage.html',
|
||||
array(
|
||||
'page_title' => $title,
|
||||
'page' => $page,
|
||||
'form' => $form,
|
||||
'rev' => $revision,
|
||||
'revs' => $revs,
|
||||
'tags' => $page->get_tags_list(),
|
||||
),
|
||||
$request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the wiki tags.
|
||||
*
|
||||
|
@ -224,6 +224,11 @@ $ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/delrev/(\d+)/$#',
|
||||
'model' => 'IDF_Views_Wiki',
|
||||
'method' => 'deleteRev');
|
||||
|
||||
$ctl[] = array('regex' => '#^/p/([\-\w]+)/doc/delete/(\d+)/$#',
|
||||
'base' => $base,
|
||||
'model' => 'IDF_Views_Wiki',
|
||||
'method' => 'delete');
|
||||
|
||||
$ctl[] = array('regex' => '#^/p/([\-\w]+)/page/(.*)/$#',
|
||||
'base' => $base,
|
||||
'model' => 'IDF_Views_Wiki',
|
||||
|
42
src/IDF/templates/idf/wiki/deletepage.html
Normal file
42
src/IDF/templates/idf/wiki/deletepage.html
Normal file
@ -0,0 +1,42 @@
|
||||
{extends "idf/wiki/base.html"}
|
||||
{block docclass}yui-t3{assign $inView=true}{/block}
|
||||
{block body}
|
||||
|
||||
<p>{blocktrans}If you delete this documentation page, it will be removed from the database with all the associated revisions and <strong>you will not be able to recover it</strong>.{/blocktrans}</p>
|
||||
<form method="post" action=".">
|
||||
<table class="form" summary="">
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>
|
||||
{$form.f.confirm|unsafe} <strong>{$form.f.confirm.labelTag}</strong><br />
|
||||
{if $form.f.confirm.errors}{$form.f.confirm.fieldErrors}{/if}
|
||||
<input type="submit" value="{trans 'Delete Page'}" name="submit" /> | <a href="{url 'IDF_Views_Wiki::view', array($project.shortname, $page.title)}">{trans 'Cancel'}</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<p class="desc">{$page.summary}</p>
|
||||
|
||||
{markdown $rev.content, $request}
|
||||
|
||||
{/block}
|
||||
{block context}
|
||||
{assign $submitter = $page.get_submitter()}
|
||||
<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>{assign $submitter = $rev.get_submitter()}
|
||||
<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}
|
||||
{if $revs.count() > 0}
|
||||
<p><strong>{trans 'Old Revisions'}</strong></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}
|
||||
{/block}
|
@ -56,7 +56,10 @@
|
||||
</tr>{/if}
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td><input type="submit" value="{trans 'Preview'}" name="preview" /> <input type="submit" value="{trans 'Update Page'}" name="submit" /> | <a href="{url 'IDF_Views_Wiki::view', array($project.shortname, $page.title)}">{trans 'Cancel'}</a>
|
||||
<td>{* float left is a fix for Firefox < 3.5 *}
|
||||
<span style="float: left;"><input type="submit" value="{trans 'Preview'}" name="preview" /> <input type="submit" value="{trans 'Update Page'}" name="submit" /> | <a href="{url 'IDF_Views_Wiki::view', array($project.shortname, $page.title)}">{trans 'Cancel'}</a></span>
|
||||
{aurl 'url', 'IDF_Views_Wiki::delete', array($project.shortname, $page.id)}
|
||||
<span class="dellink"><a href="{$url}" title="{trans 'Delete this page'}"><img src="{media '/idf/img/trash.png'}" style="vertical-align: text-bottom;" alt="{trans 'Trash'}" /></a> <a href="{$url}" title="{trans 'Delete this page'}">{trans 'Delete this page'}</a></span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
Loading…
Reference in New Issue
Block a user