<?php
+/**
+ * Base class for content handling.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @since 1.21
+ *
+ * @file
+ * @ingroup Content
+ *
+ * @author Daniel Kinzler
+ */
/**
* Exception representing a failure to serialize or unserialize a content object.
+ *
+ * @ingroup Content
*/
class MWContentSerializationException extends MWException {
* type), but wikitext content may be represented by a DOM or AST structure in
* the future.
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @since 1.21
- *
- * @file
* @ingroup Content
- *
- * @author Daniel Kinzler
*/
abstract class ContentHandler {
* @return null|string default model name for the page given by $title
*/
public static function getDefaultModelFor( Title $title ) {
- global $wgNamespaceContentModels;
-
// NOTE: this method must not rely on $title->getContentModel() directly or indirectly,
// because it is used to initialize the mContentModel member.
$ext = false;
$m = null;
- $model = null;
-
- if ( !empty( $wgNamespaceContentModels[ $ns ] ) ) {
- $model = $wgNamespaceContentModels[ $ns ];
- }
+ $model = MWNamespace::getNamespaceContentModel( $ns );
// Hook can determine default model
if ( !wfRunHooks( 'ContentHandlerDefaultModelFor', array( $title, &$model ) ) ) {
* This default implementation always returns null. Subclasses supporting redirects
* must override this method.
*
+ * Note that subclasses that override this method to return a Content object
+ * should also override supportsRedirects() to return true.
+ *
* @since 1.21
*
* @param Title $destination the page to redirect to.
/**
* Returns true if this content model supports sections.
- *
* This default implementation returns false.
*
+ * Content models that return true here should also implement
+ * Content::getSection, Content::replaceSection, etc. to handle sections..
+ *
* @return boolean whether sections are supported.
*/
public function supportsSections() {
return false;
}
+ /**
+ * Returns true if this content model supports redirects.
+ * This default implementation returns false.
+ *
+ * Content models that return true here should also implement
+ * ContentHandler::makeRedirectContent to return a Content object.
+ *
+ * @return boolean whether redirects are supported.
+ */
+ public function supportsRedirects() {
+ return false;
+ }
+
/**
* Logs a deprecation warning, visible if $wgDevelopmentWarnings, but only if
* self::$enableDeprecationWarnings is set to true.
<?php
/**
+ * Content handler for wiki text pages.
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
+ * @since 1.21
+ *
* @file
+ * @ingroup Content
*/
/**
- * @since 1.21
+ * Content handler for wiki text pages.
+ *
+ * @ingroup Content
*/
class WikitextContentHandler extends TextContentHandler {
return new WikitextContent( $redirectText );
}
+ /**
+ * Returns true because wikitext supports redirects.
+ *
+ * @see ContentHandler::supportsRedirects
+ *
+ * @return boolean whether redirects are supported.
+ */
+ public function supportsRedirects() {
+ return true;
+ }
+
/**
* Returns true because wikitext supports sections.
*