From: Carsten K. <car...@us...> - 2002-02-18 23:17:50
|
Update of /cvsroot/phpwiki/phpwiki/lib In directory usw-pr-cvs1:/tmp/cvs-serv24332 Modified Files: PageType.php Log Message: The enclosing <div> for the content is now generated automatically according to the PageType. Some refactoring and comments cleanup. Index: PageType.php =================================================================== RCS file: /cvsroot/phpwiki/phpwiki/lib/PageType.php,v retrieving revision 1.3 retrieving revision 1.4 diff -u -2 -b -p -d -r1.3 -r1.4 --- PageType.php 18 Feb 2002 09:27:09 -0000 1.3 +++ PageType.php 18 Feb 2002 23:17:47 -0000 1.4 @@ -49,7 +49,4 @@ function PageType(&$rev, $pagename = fal $text = $rev; } - //echo $ContentTemplateName; //debugging - //echo $text; //debugging - // PageType currently only works with InterWikiMap. @@ -81,40 +78,48 @@ class PageType { * This is a simple WikiPage */ - //var $_content = ""; - - function PageType (&$content, $markup) { - $this->_html = TransformText($content, $markup); - } - - function getContent() { - return $this->_html; - } -}; - - -class interWikiMapPageType extends PageType { var $_content = ""; + var $_markup = false; + var $_divs = array(); - function interWikiMapPageType($content, $markup) { - //echo $content; //debugging + function PageType (&$content, $markup) { $this->_content = $content; - $this->markup = $markup; + $this->_markup = $markup; $this->_html = HTML(); -// $this->_html->pushContent($this->_extractText()); -// $this->_html->pushContent($this->_getMap()); + $this->_defineSections(); + $this->_populateSections(); + } - $divs = array('interwikimap-header' => $this->_extractStartText(), - 'interwikimap' => $this->_getMap(), - 'interwikimap-footer' => $this->_extractEndText()); + function _defineSections() { + // section_id => ('css_class', $this->_section_function) + $this->_divs = array('wikitext' => array('wikitext', $this->_extractText())); + } - foreach ($divs as $class => $function) + function _populateSections() { + foreach ($this->_divs as $section => $data) { + list($class, $function) = $data; $this->_html->pushContent(HTML::div(array('class' => $class), $function)); + } } + function _extractText() { + return TransformText($this->_content, $this->_markup); + } + function getContent() { return $this->_html; } +}; + + +class interWikiMapPageType extends PageType { + + function _defineSections() { + // section_id => ('css_class', $this->_section_function) + $this->_divs = array('interwikimap-header' => array('wikitext', $this->_extractStartText()), + 'interwikimap' => array('wikitext', $this->_getMap()), + 'interwikimap-footer' => array('wikitext', $this->_extractEndText())); + } function _getMap() { @@ -148,9 +153,8 @@ class interWikiMapPageType extends PageT if ($v) { list($wikitext, $cruft) = explode("<verbatim>", $this->_content); - //echo $cruft; //debugging } else { $wikitext = $this->_content; } - return TransformText($wikitext, $this->markup); + return TransformText($wikitext, $this->_markup); } @@ -160,6 +164,5 @@ class interWikiMapPageType extends PageT if ($v) { list($cruft, $endtext) = explode("</verbatim>", $this->_content); - //echo $cruft; //debugging - return TransformText($endtext, $this->markup); + return TransformText($endtext, $this->_markup); } else { return ""; |