Improved the wiki links to have better descripting links.
This commit is contained in:
parent
14d07a22e2
commit
c5c7ebff04
@ -46,25 +46,32 @@ class IDF_Template_Markdown extends Pluf_Template_Tag
|
|||||||
array($this, 'callbackEmbeddedDoc'),
|
array($this, 'callbackEmbeddedDoc'),
|
||||||
$text);
|
$text);
|
||||||
}
|
}
|
||||||
|
// Replace [Page]([[PageName]]) with corresponding link to the page, with link text being Page.
|
||||||
|
$text = preg_replace_callback('#\[([^\]]+)\]\(\[\[([A-Za-z0-9\-]+)\]\]\)#im',
|
||||||
|
array($this, 'callbackWikiPage'),
|
||||||
|
$text);
|
||||||
// Replace [[PageName]] with corresponding link to the page.
|
// Replace [[PageName]] with corresponding link to the page.
|
||||||
$text = preg_replace_callback('#\[\[([A-Za-z0-9\-]+)\]\]#im',
|
$text = preg_replace_callback('#\[\[([A-Za-z0-9\-]+)\]\]#im',
|
||||||
array($this, 'callbackWikiPage'),
|
array($this, 'callbackWikiPageNoName'),
|
||||||
$text);
|
$text);
|
||||||
$filter = new IDF_Template_MarkdownPrefilter();
|
$filter = new IDF_Template_MarkdownPrefilter();
|
||||||
echo $filter->go(Pluf_Text_MarkDown_parse($text));
|
echo $filter->go(Pluf_Text_MarkDown_parse($text));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function callbackWikiPageNoName($m)
|
||||||
|
{
|
||||||
|
$m[2] = $m[1]; //Set the link text to be the same as the page name.
|
||||||
|
return $this->callbackWikiPage($m);
|
||||||
|
}
|
||||||
|
|
||||||
function callbackWikiPage($m)
|
function callbackWikiPage($m)
|
||||||
{
|
{
|
||||||
$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[2]));
|
||||||
$pages = Pluf::factory('IDF_WikiPage')->getList(array('filter'=>$sql->gen()));
|
$pages = Pluf::factory('IDF_WikiPage')->getList(array('filter'=>$sql->gen()));
|
||||||
if ($pages->count() != 1 and !$this->request->rights['hasWikiAccess']) {
|
|
||||||
return $m[0];
|
|
||||||
}
|
|
||||||
if ($pages->count() != 1 and $this->request->rights['hasWikiAccess']
|
if ($pages->count() != 1 and $this->request->rights['hasWikiAccess']
|
||||||
and !$this->request->user->isAnonymous()) {
|
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>';
|
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[2])).'" title="'.__('Create this documentation page').'">'.$m[1].'</a>';
|
||||||
}
|
}
|
||||||
if (!$this->request->rights['hasWikiAccess'] or $pages->count() == 0) {
|
if (!$this->request->rights['hasWikiAccess'] or $pages->count() == 0) {
|
||||||
return $m[1];
|
return $m[1];
|
||||||
|
Loading…
Reference in New Issue
Block a user