if ( !$page ) {
switch( $title->getNamespace() ) {
case NS_FILE:
- $page = new ImagePage( $title );
+ $page = new ImagePage( $title ); #FIXME: teach ImagePage to use ContentHandler
break;
case NS_CATEGORY:
- $page = new CategoryPage( $title );
+ $page = new CategoryPage( $title ); #FIXME: teach ImagePage to use ContentHandler
break;
default:
- $page = new Article( $title );
+ $handler = ContentHandler::getForTitle( $title );
+ $page = $handler->createArticle( $title );
}
}
$page->setContext( $context );
* This is hooked by SyntaxHighlight_GeSHi to do syntax highlighting of these
* page views.
*/
- protected function showCssOrJsPage() { #FIXME: move this to handler!
+ protected function showCssOrJsPage() { #FIXME: move this to ContentHandler!
global $wgOut;
$dir = $this->getContext()->getLanguage()->getDir();
}
#XXX: is the native model for wikitext a string or the parser output? parse early or parse late?
+
+
+ # TODO: EditPage::mergeChanges( Content $a, Content $b )
+ # TODO: Wikipage::isCountable(Content $a)
+ # TODO: Title::newFromRedirectRecurse( $this->getRawText() );
+
+ # TODO: isCacheable( )
+ # TODO: getSize( )
+
+ # TODO: WikiPage::getUndoText( Revision $undo, Revision $undoafter = null )
+ # TODO: WikiPage::replaceSection( $section, $text, $sectionTitle = '', $edittime = null )
+ # TODO: WikiPage::getAutosummary( $oldtext, $text, $flags )
+
+ # TODO: EditPage::getPreloadedText( $preload ) // $wgParser->getPreloadText
+
}
class TextContent extends Content {
if ( $content instanceof TextContent ) {
#XXX: or check by model name?
#XXX: or define $content->allowRawData()?
+ #XXX: or define $content->getDefaultWikiText()?
return $content->getRawData();
}
+ #XXX: this must not be used for editing, otherwise we may loose data:
+ #XXX: e.g. if this returns the "main" text from a multipart page, all attachments would be lost
+
return null;
}
public static function getForTitle( Title $title ) {
$modelName = $title->getContentModelName();
- return ContenteHandler::getForModelName( $modelName );
+ return ContentHandler::getForModelName( $modelName );
}
public static function getForContent( Content $content ) {
$modelName = $content->getModelName();
- return ContenteHandler::getForModelName( $modelName );
+ return ContentHandler::getForModelName( $modelName );
}
public static function getForModelName( $modelName ) {
/**
* Return an Article object suitable for viewing the given object
- *
+ *
+ * NOTE: does *not* do special handling for Image and Category pages!
+ * Use Article::newFromTitle() for that!
+ *
* @param type $title
- * @param type $obj
- * @return \Article
+ * @return \Article
* @todo Article is being refactored into an action class, keep track of that
*/
- public function createArticle( Title $title, $obj ) { #TODO: use this!
+ public function createArticle( Title $title ) {
+ #XXX: assert that $title->getContentModelName() == $this->getModelname()?
$article = new Article($title);
return $article;
}
/**
* Return an EditPage object suitable for editing the given object
*
- * @param type $title
- * @param type $obj
* @param type $article
* @return \EditPage
*/
- public function createEditPage( Title $title, $obj, Article $article ) { #TODO: use this!
- $editPage = new EditPage($article);
+ public function createEditPage( Article $article ) {
+ #XXX: assert that $article->getContentObject()->getModelName() == $this->getModelname()?
+ $editPage = new EditPage( $article );
return $editPage;
}
+ /**
+ * Return an ExternalEdit object suitable for editing the given object
+ *
+ * @param type $article
+ * @return \ExternalEdit
+ */
+ public function createExternalEdit( IContextSource $context ) {
+ #XXX: assert that $article->getContentObject()->getModelName() == $this->getModelname()?
+ $externalEdit = new ExternalEdit( $context );
+ return $externalEdit;
+ }
+
/**
public function updatePage( $title, $obj ) {
}
}
#XXX: is the native model for wikitext a string or the parser output? parse early or parse late?
+
+ #TODO: how to handle extra message for JS/CSS previews??
+ #TODO: Article::showCssOrJsPage ---> specialized classes!
}
$context = $this->getContext();
if ( wfRunHooks( 'CustomEditor', array( $page, $user ) ) ) {
+ $handler = ContentHandler::getForTitle( $page->getTitle() );
+
if ( ExternalEdit::useExternalEngine( $context, 'edit' )
&& $this->getName() == 'edit' && !$request->getVal( 'section' )
&& !$request->getVal( 'oldid' ) )
{
- $extedit = new ExternalEdit( $context );
+ $extedit = $handler->createExternalEdit( $context );
$extedit->execute();
} else {
- $editor = new EditPage( $page );
+ $editor = $handler->createEditPage( $page );
$editor->edit();
}
}