Added ticket 90, propose to create a new documentation page when it doesn't exists.

This commit is contained in:
Loic d'Anterroches 2009-01-02 13:58:55 +01:00
parent a36e89ac2e
commit 60bc06f5c3
4 changed files with 18 additions and 5 deletions

View File

@ -54,10 +54,11 @@ Add your content here. Format your content with:
or $this->user->hasPerm('IDF.project-member', $this->project)) { or $this->user->hasPerm('IDF.project-member', $this->project)) {
$this->show_full = true; $this->show_full = true;
} }
$initname = (!empty($extra['name'])) ? $extra['name'] : __('PageName');
$this->fields['title'] = new Pluf_Form_Field_Varchar( $this->fields['title'] = new Pluf_Form_Field_Varchar(
array('required' => true, array('required' => true,
'label' => __('Page title'), 'label' => __('Page title'),
'initial' => __('PageName'), 'initial' => $initname,
'widget_attrs' => array( 'widget_attrs' => array(
'maxlength' => 200, 'maxlength' => 200,
'size' => 67, 'size' => 67,

View File

@ -53,9 +53,13 @@ class IDF_Template_Markdown extends Pluf_Template_Tag
$sql = new Pluf_SQL('project=%s AND title=%s', $sql = new Pluf_SQL('project=%s AND title=%s',
array($this->project->id, $m[1])); array($this->project->id, $m[1]));
$pages = Pluf::factory('IDF_WikiPage')->getList(array('filter'=>$sql->gen())); $pages = Pluf::factory('IDF_WikiPage')->getList(array('filter'=>$sql->gen()));
if ($pages->count() != 1) { if ($pages->count() != 1 and !$this->request->rights['hasWikiAccess']) {
return $m[0]; return $m[0];
} }
if ($pages->count() != 1 and $this->request->rights['hasWikiAccess']
and !$this->request->user->isAnonymous()) {
return '<img style="vertical-align: text-bottom;" alt=" " src="'.Pluf::f('url_media').'/idf/img/add.png" /><a href="'.Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::create', array($this->project->shortname), array('name'=>$m[1])).'" title="'.__('Create this documentation page').'">'.$m[1].'</a>';
}
if (!$this->request->rights['hasWikiAccess']) { if (!$this->request->rights['hasWikiAccess']) {
return $m[1]; return $m[1];
} }

View File

@ -90,7 +90,7 @@ class IDF_Template_MarkdownPrefilter extends Pluf_Text_HTML_Filter
); );
public $allowed = array( public $allowed = array(
'img' => array('src', 'class', 'alt', 'height', 'width'), 'img' => array('src', 'class', 'alt', 'height', 'width', 'style'),
'strong' => array(), 'strong' => array(),
'em' => array(), 'em' => array(),
'b' => array(), 'b' => array(),
@ -98,6 +98,9 @@ class IDF_Template_MarkdownPrefilter extends Pluf_Text_HTML_Filter
'ul' => array(), 'ul' => array(),
'ol' => array(), 'ol' => array(),
'li' => array(), 'li' => array(),
'dl' => array(),
'dt' => array(),
'dd' => array(),
'p' => array('align', 'class'), 'p' => array('align', 'class'),
'div' => array('align', 'class'), 'div' => array('align', 'class'),
'br' => array(), 'br' => array(),

View File

@ -56,6 +56,7 @@ class IDF_Views_Wiki
$sql .= ' AND id NOT IN ('.implode(',', $ids).')'; $sql .= ' AND id NOT IN ('.implode(',', $ids).')';
} }
$pag->forced_where = new Pluf_SQL($sql, array($prj->id)); $pag->forced_where = new Pluf_SQL($sql, array($prj->id));
$pag->extra_classes = array('right', '', 'a-c');
$list_display = array( $list_display = array(
'title' => __('Page Title'), 'title' => __('Page Title'),
array('summary', 'IDF_Views_Wiki_SummaryAndLabels', __('Summary')), array('summary', 'IDF_Views_Wiki_SummaryAndLabels', __('Summary')),
@ -102,6 +103,7 @@ class IDF_Views_Wiki
$pag->summary = __('This table shows the pages found.'); $pag->summary = __('This table shows the pages found.');
$pag->action = array('IDF_Views_Wiki::search', array($prj->shortname), array('q'=> $q)); $pag->action = array('IDF_Views_Wiki::search', array($prj->shortname), array('q'=> $q));
$pag->edit_action = array('IDF_Views_Wiki::view', 'shortname', 'title'); $pag->edit_action = array('IDF_Views_Wiki::view', 'shortname', 'title');
$pag->extra_classes = array('right', '', 'a-c');
$list_display = array( $list_display = array(
'title' => __('Page Title'), 'title' => __('Page Title'),
array('summary', 'IDF_Views_Wiki_SummaryAndLabels', __('Summary')), array('summary', 'IDF_Views_Wiki_SummaryAndLabels', __('Summary')),
@ -190,9 +192,12 @@ class IDF_Views_Wiki
$preview = $request->POST['content']; $preview = $request->POST['content'];
} }
} else { } else {
$pagename = (isset($request->GET['name'])) ?
$request->GET['name'] : '';
$form = new IDF_Form_WikiCreate(null, $form = new IDF_Form_WikiCreate(null,
array('project' => $prj, array('name' => $pagename,
'user' => $request->user)); 'project' => $prj,
'user' => $request->user));
} }
return Pluf_Shortcuts_RenderToResponse('idf/wiki/create.html', return Pluf_Shortcuts_RenderToResponse('idf/wiki/create.html',
array( array(