Partial fix of issue 55, addition of a simple Wiki.
Added a base wiki, it is now possible to create wiki pages and update them. Revisions are kept also not used/displayed at the moment.
This commit is contained in:
@@ -32,13 +32,13 @@ class IDF_Template_IssueComment extends Pluf_Template_Tag
|
||||
private $request = null;
|
||||
private $scm = null;
|
||||
|
||||
function start($text, $request, $echo=true, $wordwrap=true)
|
||||
function start($text, $request, $echo=true, $wordwrap=true, $esc=true)
|
||||
{
|
||||
$this->project = $request->project;
|
||||
$this->request = $request;
|
||||
$this->scm = IDF_Scm::get($request);
|
||||
if ($wordwrap) $text = wordwrap($text, 69, "\n", true);
|
||||
$text = Pluf_esc($text);
|
||||
if ($esc) $text = Pluf_esc($text);
|
||||
$text = ereg_replace('[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]',
|
||||
'<a href="\\0" rel="nofollow">\\0</a>',
|
||||
$text);
|
||||
|
@@ -23,80 +23,55 @@
|
||||
|
||||
Pluf::loadFunction('Pluf_Text_MarkDown_parse');
|
||||
|
||||
function IDF_Template_Markdown_filter($mdtext)
|
||||
/**
|
||||
* Make the links to issues and commits.
|
||||
*/
|
||||
class IDF_Template_Markdown extends Pluf_Template_Tag
|
||||
{
|
||||
$filter = new IDF_Template_Markdown();
|
||||
return Pluf_Template::markSafe(Pluf_Text_MarkDown_parse($filter->go($mdtext)));
|
||||
private $project = null;
|
||||
private $request = null;
|
||||
private $scm = null;
|
||||
|
||||
function start($text, $request)
|
||||
{
|
||||
$this->project = $request->project;
|
||||
$this->request = $request;
|
||||
$filter = new IDF_Template_MarkdownPrefilter();
|
||||
$text = $filter->go($text);
|
||||
// The filter has replace < and > also in the code blocks so
|
||||
// we need to revert them
|
||||
$tmp = array();
|
||||
foreach (preg_split("/\015\012|\015|\012/", $text, -1) as $s) {
|
||||
if (0 === strpos($s, ' ')) {
|
||||
$s = str_replace(array('<', '>'),
|
||||
array('<', '>'), $s);
|
||||
}
|
||||
$tmp[] = $s;
|
||||
}
|
||||
$text = implode("\n", $tmp);
|
||||
// Replace like in the issue text
|
||||
$tag = new IDF_Template_IssueComment();
|
||||
$text = $tag->start($text, $request, false, false, false);
|
||||
// Replace [[PageName]] with corresponding link to the page.
|
||||
// if not the right to see the
|
||||
$text = preg_replace_callback('#\[\[([A-Za-z0-9\-]+)\]\]#im',
|
||||
array($this, 'callbackWikiPage'),
|
||||
$text);
|
||||
echo Pluf_Text_MarkDown_parse($text);
|
||||
}
|
||||
|
||||
function callbackWikiPage($m)
|
||||
{
|
||||
$sql = new Pluf_SQL('project=%s AND title=%s',
|
||||
array($this->project->id, $m[1]));
|
||||
$pages = Pluf::factory('IDF_WikiPage')->getList(array('filter'=>$sql->gen()));
|
||||
if ($pages->count() != 1) {
|
||||
return $m[0];
|
||||
}
|
||||
if (!$this->request->rights['hasWikiAccess']) {
|
||||
return $m[1];
|
||||
}
|
||||
return '<a href="'.Pluf_HTTP_URL_urlForView('IDF_Views_Wiki::view', array($this->project->shortname, $pages[0]->title)).'" title="'.Pluf_esc($pages[0]->summary).'">'.$m[1].'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Strict class to only allow entities.
|
||||
*/
|
||||
class IDF_Template_Markdown extends Pluf_Text_HTML_Filter
|
||||
{
|
||||
public $allowed = array();
|
||||
public $always_close = array();
|
||||
public $remove_blanks = array();
|
||||
public $allowed_entities = array(
|
||||
'amp',
|
||||
'gt',
|
||||
'lt',
|
||||
'quot',
|
||||
'nbsp',
|
||||
'ndash',
|
||||
'rdquo',
|
||||
'ldquo',
|
||||
'Alpha',
|
||||
'Beta',
|
||||
'Gamma',
|
||||
'Delta',
|
||||
'Epsilon',
|
||||
'Zeta',
|
||||
'Eta',
|
||||
'Theta',
|
||||
'Iota',
|
||||
'Kappa',
|
||||
'Lambda',
|
||||
'Mu',
|
||||
'Nu',
|
||||
'Xi',
|
||||
'Omicron',
|
||||
'Pi',
|
||||
'Rho',
|
||||
'Sigma',
|
||||
'Tau',
|
||||
'Upsilon',
|
||||
'Phi',
|
||||
'Chi',
|
||||
'Psi',
|
||||
'Omega',
|
||||
'alpha',
|
||||
'beta',
|
||||
'gamma',
|
||||
'delta',
|
||||
'epsilon',
|
||||
'zeta',
|
||||
'eta',
|
||||
'theta',
|
||||
'iota',
|
||||
'kappa',
|
||||
'lambda',
|
||||
'mu',
|
||||
'nu',
|
||||
'xi',
|
||||
'omicron',
|
||||
'pi',
|
||||
'rho',
|
||||
'sigmaf',
|
||||
'sigma',
|
||||
'tau',
|
||||
'upsilon',
|
||||
'phi',
|
||||
'chi',
|
||||
'psi',
|
||||
'omega',
|
||||
'thetasym',
|
||||
'upsih',
|
||||
'piv',
|
||||
);
|
||||
}
|
||||
|
94
src/IDF/Template/MarkdownPrefilter.php
Normal file
94
src/IDF/Template/MarkdownPrefilter.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?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 ***** */
|
||||
|
||||
/**
|
||||
* Strict class to only allow entities.
|
||||
*/
|
||||
class IDF_Template_MarkdownPrefilter extends Pluf_Text_HTML_Filter
|
||||
{
|
||||
public $allowed = array();
|
||||
public $always_close = array();
|
||||
public $remove_blanks = array();
|
||||
public $allowed_entities = array(
|
||||
'amp',
|
||||
'gt',
|
||||
'lt',
|
||||
'quot',
|
||||
'nbsp',
|
||||
'ndash',
|
||||
'rdquo',
|
||||
'ldquo',
|
||||
'Alpha',
|
||||
'Beta',
|
||||
'Gamma',
|
||||
'Delta',
|
||||
'Epsilon',
|
||||
'Zeta',
|
||||
'Eta',
|
||||
'Theta',
|
||||
'Iota',
|
||||
'Kappa',
|
||||
'Lambda',
|
||||
'Mu',
|
||||
'Nu',
|
||||
'Xi',
|
||||
'Omicron',
|
||||
'Pi',
|
||||
'Rho',
|
||||
'Sigma',
|
||||
'Tau',
|
||||
'Upsilon',
|
||||
'Phi',
|
||||
'Chi',
|
||||
'Psi',
|
||||
'Omega',
|
||||
'alpha',
|
||||
'beta',
|
||||
'gamma',
|
||||
'delta',
|
||||
'epsilon',
|
||||
'zeta',
|
||||
'eta',
|
||||
'theta',
|
||||
'iota',
|
||||
'kappa',
|
||||
'lambda',
|
||||
'mu',
|
||||
'nu',
|
||||
'xi',
|
||||
'omicron',
|
||||
'pi',
|
||||
'rho',
|
||||
'sigmaf',
|
||||
'sigma',
|
||||
'tau',
|
||||
'upsilon',
|
||||
'phi',
|
||||
'chi',
|
||||
'psi',
|
||||
'omega',
|
||||
'thetasym',
|
||||
'upsih',
|
||||
'piv',
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user