2007-07-20 12:03:04 +04:00
|
|
|
<?php
|
2007-09-01 03:38:43 +04:00
|
|
|
/**
|
|
|
|
* Parses for links to other documentation sections.
|
|
|
|
*
|
|
|
|
* @category Text
|
|
|
|
* @package Text_Wiki
|
|
|
|
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
|
|
|
|
* @license LGPL
|
|
|
|
* @version $Id$
|
|
|
|
*
|
|
|
|
*/
|
2007-07-20 12:03:04 +04:00
|
|
|
class Text_Wiki_Parse_Doclink extends Text_Wiki_Parse {
|
|
|
|
|
|
|
|
var $conf = array(
|
|
|
|
'toc' => null
|
|
|
|
);
|
|
|
|
|
|
|
|
var $regex = '/\[doc ([a-z0-9-]+(?::[a-z0-9-]+)*)(?: ([^\n\]]*))?]/';
|
|
|
|
|
|
|
|
function process(&$matches)
|
|
|
|
{
|
|
|
|
$toc = $this->getConf('toc');
|
|
|
|
|
|
|
|
if ($toc instanceof Sensei_Doc_Toc) {
|
|
|
|
$section = $toc->findByPath($matches[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($section)) {
|
|
|
|
$options = array();
|
|
|
|
|
|
|
|
$options['path'] = $matches[1];
|
|
|
|
|
|
|
|
if (isset($matches[2])) {
|
|
|
|
$options['text'] = $matches[2];
|
2007-09-24 01:38:11 +04:00
|
|
|
$options['text'] = str_replace(':index', $section->getIndex(), $options['text']);
|
|
|
|
$options['text'] = str_replace(':name', $section->getName(), $options['text']);
|
|
|
|
$options['text'] = str_replace(':fullname', $section->getName(true), $options['text']);
|
2007-07-20 12:03:04 +04:00
|
|
|
} else {
|
2007-09-24 01:38:11 +04:00
|
|
|
$options['text'] = $section->getIndex();
|
2007-07-20 12:03:04 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->wiki->addToken($this->rule, $options);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
return $matches[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|