From: daniel Date: Sat, 9 Jun 2012 11:42:05 +0000 (+0200) Subject: introduced ContentHandler::supportsSections() X-Git-Tag: 1.31.0-rc.0~22097^2^2~121 X-Git-Url: http://git.cyclocoop.org/%22%20.%20%20%20%24self2%20.%20%20%20%22&var_mode_affiche=boucle?a=commitdiff_plain;h=83d88434e6b0c833f8704f5da4621a0ba39fc2ce;p=lhc%2Fweb%2Fwiklou.git introduced ContentHandler::supportsSections() --- diff --git a/includes/ContentHandler.php b/includes/ContentHandler.php index 1495eb196b..2adbee9b2b 100644 --- a/includes/ContentHandler.php +++ b/includes/ContentHandler.php @@ -826,6 +826,17 @@ abstract class ContentHandler { new LinksDeletionUpdate( $title ), ); } + + /** + * Returns true iff this page's content model supports sections. + * + * This default implementation returns false, + * + * @return boolean whether sections are supported. + */ + public function supportsSections() { + return false; + } } /** @@ -970,6 +981,14 @@ class WikitextContentHandler extends TextContentHandler { throw new MWException( "getHtml() not implemented for wikitext. Use getParserOutput()->getText()." ); } + /** + * Returns true because wikitext supports sections. + * + * @return boolean whether sections are supported. + */ + public function supportsSections() { + return false; + } } #XXX: make ScriptContentHandler base class with plugin interface for syntax highlighting? diff --git a/includes/WikiPage.php b/includes/WikiPage.php index 20d61065f4..64cc51a626 100644 --- a/includes/WikiPage.php +++ b/includes/WikiPage.php @@ -1408,13 +1408,24 @@ class WikiPage extends Page { $sectionContent = ContentHandler::makeContent( $text, $this->getTitle() ); #XXX: could make section title, but that's not required. + #TODO: check ContentHandler::supportsSections(). throw exception?? $newContent = $this->replaceSectionContent( $section, $sectionContent, $sectionTitle, $edittime ); #TODO: check $newContent == false. throw exception?? - #TODO: add ContentHandler::supportsSections() return ContentHandler::getContentText( $newContent ); #XXX: unclear what will happen for non-wikitext! } + /** + * Returns true iff this page's content model supports sections. + * + * @return boolean whether sections are supported. + * + * @todo: the skin should check this and not offer section functionality if sections are not supported. + */ + public function supportsSections() { + return $this->getContentHandler()->supportsSections(); + } + /** * @param $section null|bool|int or a section number (0, 1, 2, T1, T2...) * @param $content Content: new content of the section