From: daniel Date: Mon, 14 May 2012 08:28:03 +0000 (+0200) Subject: merge incoming X-Git-Tag: 1.31.0-rc.0~22097^2^2~173 X-Git-Url: http://git.cyclocoop.org/%22%2C%20generer_url_ecrire%28?a=commitdiff_plain;h=8bf6ca1d1860ae924b21860578ced36d2d037b66;p=lhc%2Fweb%2Fwiklou.git merge incoming --- 8bf6ca1d1860ae924b21860578ced36d2d037b66 diff --cc includes/Content.php index 91a078435c,9f6b4d61ff..806f54d33a --- a/includes/Content.php +++ b/includes/Content.php @@@ -12,11 -12,13 +12,13 @@@ abstract class Content * Name of the content model this Content object represents. * Use with CONTENT_MODEL_XXX constants * - * @var String $model_name + * @var String $model_id */ - protected $modelName; + protected $model_id; /** + * @since WD.1 + * * @return String a string representing the content in a way useful for building a full text search index. * If no useful representation exists, this method returns an empty string. */ @@@ -65,13 -73,15 +73,15 @@@ } /** - * Returns the name of the content model used by this content objects. + * Returns the id of the content model used by this content objects. * Corresponds to the CONTENT_MODEL_XXX constants. * + * @since WD.1 + * - * @return String the model name + * @return int the model id */ - public function getModelName() { - return $this->modelName; + public function getModel() { + return $this->model_id; } /** diff --cc includes/ContentHandler.php index 33445374e0,410215622d..b3cf15ca22 --- a/includes/ContentHandler.php +++ b/includes/ContentHandler.php @@@ -70,9 -72,11 +72,11 @@@ abstract class ContentHandler /** * Conveniance function for creating a Content object from a given textual representation. * - * $text will be deserialized into a Content object of the model specified by $modelName (or, - * if that is not given, $title->getContentModelName()) using the given format. + * $text will be deserialized into a Content object of the model specified by $modelId (or, + * if that is not given, $title->getContentModel()) using the given format. * + * @since WD.1 + * * @static * @param string $text the textual represenation, will be unserialized to create the Content object * @param Title $title the title of the page this text belongs to, required as a context for deserialization @@@ -108,8 -112,10 +112,10 @@@ * * If none of the above applies, the wikitext model is used. * - * Note: this is used by, and may thus not use, Title::getContentModelName() + * Note: this is used by, and may thus not use, Title::getContentModel() * + * @since WD.1 + * * @static * @param Title $title * @return null|string default model name for the page given by $title @@@ -210,26 -220,28 +220,28 @@@ * If a class name in encountered when looking up the singleton for a given model name, the class is * instantiated and the class name is replaced by te resulting singleton in $wgContentHandlers. * - * If no ContentHandler is defined for the desired $modelName, the ContentHandler may be provided by the - * a ContentHandlerForModelName hook. if no Contenthandler can be determined, an MWException is raised. + * If no ContentHandler is defined for the desired $modelId, the ContentHandler may be provided by the + * a ContentHandlerForModelID hook. if no Contenthandler can be determined, an MWException is raised. * + * @since WD.1 + * * @static - * @param $modelName String the name of the content model for which to get a handler. Use CONTENT_MODEL_XXX constants. - * @return ContentHandler the ContentHandler singleton for handling the model given by $modelName - * @throws MWException if no handler is known for $modelName. + * @param $modelId int the id of the content model for which to get a handler. Use CONTENT_MODEL_XXX constants. + * @return ContentHandler the ContentHandler singleton for handling the model given by $modelId + * @throws MWException if no handler is known for $modelId. */ - public static function getForModelName( $modelName ) { + public static function getForModelID( $modelId ) { global $wgContentHandlers; - if ( empty( $wgContentHandlers[$modelName] ) ) { + if ( empty( $wgContentHandlers[$modelId] ) ) { $handler = null; - wfRunHooks( 'ContentHandlerForModelName', array( $modelName, &$handler ) ); + wfRunHooks( 'ContentHandlerForModelID', array( $modelId, &$handler ) ); if ( $handler ) { // NOTE: may be a string or an object, either is fine! - $wgContentHandlers[$modelName] = $handler; + $wgContentHandlers[$modelId] = $handler; } else { - throw new MWException( "No handler for model $modelName registered in \$wgContentHandlers" ); + throw new MWException( "No handler for model #$modelId registered in \$wgContentHandlers" ); } } @@@ -356,27 -302,27 +374,31 @@@ public abstract function makeEmptyContent(); /** - * Returns the model name that identifies the content model this ContentHandler can handle. + * Returns the model id that identifies the content model this ContentHandler can handle. * Use with the CONTENT_MODEL_XXX constants. * + * @since WD.1 + * - * @return String the model name + * @return int the model id */ - public function getModelName() { - return $this->mModelName; + public function getModelID() { + return $this->mModelID; } /** - * Throws an MWException if $modelName is not the content model handeled by this ContentHandler. + * Throws an MWException if $model_id is not the id of the content model + * supported by this ContentHandler. * + * @since WD.1 + * - * @param String $modelName the model name to check + * @param int $model_id the model to check */ - protected function checkModelName( $modelName ) { - if ( $modelName !== $this->mModelName ) { - throw new MWException( "Bad content model: expected " . $this->mModelName . " but got found " . $modelName ); + protected function checkModelID( $model_id ) { + if ( $model_id !== $this->mModelID ) { + $model_name = ContentHandler::getContentModelName( $model_id ); + $own_model_name = ContentHandler::getContentModelName( $this->mModelID ); + + throw new MWException( "Bad content model: expected {$this->mModelID} ($own_model_name) but got found $model_id ($model_name)." ); } } @@@ -744,11 -720,13 +796,13 @@@ } } - + /** + * @since WD.1 + */ abstract class TextContentHandler extends ContentHandler { - public function __construct( $modelName, $formats ) { - parent::__construct( $modelName, $formats ); + public function __construct( $modelId, $formats ) { + parent::__construct( $modelId, $formats ); } public function serializeContent( Content $content, $format = null ) { @@@ -796,10 -774,14 +850,14 @@@ } + + /** + * @since WD.1 + */ class WikitextContentHandler extends TextContentHandler { - public function __construct( $modelName = CONTENT_MODEL_WIKITEXT ) { - parent::__construct( $modelName, array( 'text/x-wiki' ) ); + public function __construct( $modelId = CONTENT_MODEL_WIKITEXT ) { + parent::__construct( $modelId, array( CONTENT_FORMAT_WIKITEXT ) ); } public function unserializeContent( $text, $format = null ) { @@@ -817,10 -799,13 +875,13 @@@ #XXX: make ScriptContentHandler base class with plugin interface for syntax highlighting? + /** + * @since WD.1 + */ class JavaScriptContentHandler extends TextContentHandler { - public function __construct( $modelName = CONTENT_MODEL_WIKITEXT ) { - parent::__construct( $modelName, array( 'text/javascript' ) ); #XXX: or use $wgJsMimeType? this is for internal storage, not HTTP... + public function __construct( $modelId = CONTENT_MODEL_JAVASCRIPT ) { + parent::__construct( $modelId, array( CONTENT_FORMAT_JAVASCRIPT ) ); } public function unserializeContent( $text, $format = null ) { @@@ -834,10 -819,13 +895,13 @@@ } } + /** + * @since WD.1 + */ class CssContentHandler extends TextContentHandler { - public function __construct( $modelName = CONTENT_MODEL_WIKITEXT ) { - parent::__construct( $modelName, array( 'text/css' ) ); + public function __construct( $modelId = CONTENT_MODEL_CSS ) { + parent::__construct( $modelId, array( CONTENT_FORMAT_CSS ) ); } public function unserializeContent( $text, $format = null ) {