_set_standard_markups();
if ($_SERVER['REQUEST_URI'] != '/')
$request = $_SERVER['REQUEST_URI'];
else
$request = '/welcome';
// var_dump('$request',$request,'$_GET',$_GET);
$pagerequest = explode('/',$request);
$page = $pagerequest[1];
if ($page == 'display')
{
$group = @$pagerequest[2];
$page = @$pagerequest[3];
$dirs = array('article'=>'articles/','code'=>'','public'=>'public/','driver'=>'','muster'=>'muster/','simplewiki'=>'muster/simplewiki/');
$exts = array('article'=>'.txt','code'=>'.php','public'=>'','driver'=>'.php','muster'=>'.php','simplewiki'=>'.php',);
if (isset($dirs[$group]) and ($page))
{
$dir = $dirs[$group];
$ext = $exts[$group];
$markup = @file_get_contents($dir . $page . $ext);
if ($markup)
{
header('Content-type: text/plain');
echo $markup; exit();
}
}
$this->_markups['messagemarkup'] = 'no such source to display (' . $request . ')';
$markup = NULL;
}
else
{
$markup = @file_get_contents('articles/' . $page . '.txt');
}
if ($markup === FALSE) // no such page
{
$this->_markups['messagemarkup'] = 'no such page (' . $page . ')';
}
elseif ($page == 'welcome')
{
// -- powered by
$this->_markups['poweredbymarkup'] = 'website powered by
SimpleWiki';
}
if ($markup)
{
$this->_wiki = $wiki = new Muster\SimpleWiki($markup);
$wiki->register_symlinks(array('Anchor'=>'/' . $page));
$wiki->register_symlinks(array('Local'=>'/'));
$wiki->parser()->argchars('(?s:.)');
$wiki->register_charfilter_handler(array($this,'process_htmlentities'));
$this->_markups['contentmarkup'] = $wiki->get_html();
$metadata = $wiki->get_metadata();
$this->_set_metadata_markups($metadata);
}
return $this->_markups;
}
public function process_htmlentities($text,$node) // not using $node parameters
{
return htmlentities(html_entity_decode($text,ENT_COMPAT | ENT_HTML401,'UTF-8'),ENT_COMPAT | ENT_HTML401,'UTF-8');// allow html entities
}
protected function _set_metadata_markups($metadata)
{
$markups = $this->_markups;
$attributes = $metadata->attributes;
// var_dump($metadata);
// set by page metadata
// - text
$textattributes = array('titletext','descriptiontext','keywordtext','tabid','subjecttext','menuid');
foreach ($textattributes as $textattribute)
{
if (isset($attributes[$textattribute]))
$markups[$textattribute] = $attributes[$textattribute];
}
// - framework markup
$markupattributes = array('navigationmarkup','infomarkup','utilitiesmarkup','helpmarkup','footermarkup');
foreach ($markupattributes as $markupattribute)
{
if (isset($attributes[$markupattribute]))
{
$markupfile = $attributes[$markupattribute];
$markup = @file_get_contents('articles/' . $markupfile . '.txt');
if ($markup)
$markups[$markupattribute] = $this->markuptohtml($markup);
}
}
$this->_markups = $markups;
}
protected function markuptohtml($markup)
{
$wiki = $this->_wiki;
return $wiki->prepare($markup)->get_html();
}
protected function _set_standard_markups()
{
$markups = $this->_markups;
// all pages
$markups['contextmarkup'] =
'Home of