Index: branches/Wikidata/phase3/includes/Content.php |
— | — | @@ -52,6 +52,21 @@ |
53 | 53 | } |
54 | 54 | |
55 | 55 | #XXX: is the native model for wikitext a string or the parser output? parse early or parse late? |
| 56 | + |
| 57 | + |
| 58 | + # TODO: EditPage::mergeChanges( Content $a, Content $b ) |
| 59 | + # TODO: Wikipage::isCountable(Content $a) |
| 60 | + # TODO: Title::newFromRedirectRecurse( $this->getRawText() ); |
| 61 | + |
| 62 | + # TODO: isCacheable( ) |
| 63 | + # TODO: getSize( ) |
| 64 | + |
| 65 | + # TODO: WikiPage::getUndoText( Revision $undo, Revision $undoafter = null ) |
| 66 | + # TODO: WikiPage::replaceSection( $section, $text, $sectionTitle = '', $edittime = null ) |
| 67 | + # TODO: WikiPage::getAutosummary( $oldtext, $text, $flags ) |
| 68 | + |
| 69 | + # TODO: EditPage::getPreloadedText( $preload ) // $wgParser->getPreloadText |
| 70 | + |
56 | 71 | } |
57 | 72 | |
58 | 73 | class TextContent extends Content { |
Index: branches/Wikidata/phase3/includes/api/ApiEditPage.php |
— | — | @@ -240,7 +240,9 @@ |
241 | 241 | // TODO: Make them not or check if they still do |
242 | 242 | $wgTitle = $titleObj; |
243 | 243 | |
244 | | - $ep = new EditPage( $articleObj ); |
| 244 | + $handler = ContentHandler::getForTitle( $titleObj ); |
| 245 | + $ep = $handler->createEditPage( $articleObj ); |
| 246 | + |
245 | 247 | $ep->setContextTitle( $titleObj ); |
246 | 248 | $ep->importFormData( $req ); |
247 | 249 | |
Index: branches/Wikidata/phase3/includes/ContentHandler.php |
— | — | @@ -19,9 +19,13 @@ |
20 | 20 | if ( $content instanceof TextContent ) { |
21 | 21 | #XXX: or check by model name? |
22 | 22 | #XXX: or define $content->allowRawData()? |
| 23 | + #XXX: or define $content->getDefaultWikiText()? |
23 | 24 | return $content->getRawData(); |
24 | 25 | } |
25 | 26 | |
| 27 | + #XXX: this must not be used for editing, otherwise we may loose data: |
| 28 | + #XXX: e.g. if this returns the "main" text from a multipart page, all attachments would be lost |
| 29 | + |
26 | 30 | return null; |
27 | 31 | } |
28 | 32 | |
— | — | @@ -90,12 +94,12 @@ |
91 | 95 | |
92 | 96 | public static function getForTitle( Title $title ) { |
93 | 97 | $modelName = $title->getContentModelName(); |
94 | | - return ContenteHandler::getForModelName( $modelName ); |
| 98 | + return ContentHandler::getForModelName( $modelName ); |
95 | 99 | } |
96 | 100 | |
97 | 101 | public static function getForContent( Content $content ) { |
98 | 102 | $modelName = $content->getModelName(); |
99 | | - return ContenteHandler::getForModelName( $modelName ); |
| 103 | + return ContentHandler::getForModelName( $modelName ); |
100 | 104 | } |
101 | 105 | |
102 | 106 | public static function getForModelName( $modelName ) { |
— | — | @@ -145,13 +149,16 @@ |
146 | 150 | |
147 | 151 | /** |
148 | 152 | * Return an Article object suitable for viewing the given object |
149 | | - * |
| 153 | + * |
| 154 | + * NOTE: does *not* do special handling for Image and Category pages! |
| 155 | + * Use Article::newFromTitle() for that! |
| 156 | + * |
150 | 157 | * @param type $title |
151 | | - * @param type $obj |
152 | | - * @return \Article |
| 158 | + * @return \Article |
153 | 159 | * @todo Article is being refactored into an action class, keep track of that |
154 | 160 | */ |
155 | | - public function createArticle( Title $title, $obj ) { #TODO: use this! |
| 161 | + public function createArticle( Title $title ) { |
| 162 | + #XXX: assert that $title->getContentModelName() == $this->getModelname()? |
156 | 163 | $article = new Article($title); |
157 | 164 | return $article; |
158 | 165 | } |
— | — | @@ -159,17 +166,28 @@ |
160 | 167 | /** |
161 | 168 | * Return an EditPage object suitable for editing the given object |
162 | 169 | * |
163 | | - * @param type $title |
164 | | - * @param type $obj |
165 | 170 | * @param type $article |
166 | 171 | * @return \EditPage |
167 | 172 | */ |
168 | | - public function createEditPage( Title $title, $obj, Article $article ) { #TODO: use this! |
169 | | - $editPage = new EditPage($article); |
| 173 | + public function createEditPage( Article $article ) { |
| 174 | + #XXX: assert that $article->getContentObject()->getModelName() == $this->getModelname()? |
| 175 | + $editPage = new EditPage( $article ); |
170 | 176 | return $editPage; |
171 | 177 | } |
172 | 178 | |
173 | 179 | /** |
| 180 | + * Return an ExternalEdit object suitable for editing the given object |
| 181 | + * |
| 182 | + * @param type $article |
| 183 | + * @return \ExternalEdit |
| 184 | + */ |
| 185 | + public function createExternalEdit( IContextSource $context ) { |
| 186 | + #XXX: assert that $article->getContentObject()->getModelName() == $this->getModelname()? |
| 187 | + $externalEdit = new ExternalEdit( $context ); |
| 188 | + return $externalEdit; |
| 189 | + } |
| 190 | + |
| 191 | + /** |
174 | 192 | public function updatePage( $title, $obj ) { |
175 | 193 | } |
176 | 194 | **/ |
— | — | @@ -187,6 +205,9 @@ |
188 | 206 | } |
189 | 207 | |
190 | 208 | #XXX: is the native model for wikitext a string or the parser output? parse early or parse late? |
| 209 | + |
| 210 | + #TODO: how to handle extra message for JS/CSS previews?? |
| 211 | + #TODO: Article::showCssOrJsPage ---> specialized classes! |
191 | 212 | } |
192 | 213 | |
193 | 214 | |
Index: branches/Wikidata/phase3/includes/actions/EditAction.php |
— | — | @@ -40,14 +40,16 @@ |
41 | 41 | $context = $this->getContext(); |
42 | 42 | |
43 | 43 | if ( wfRunHooks( 'CustomEditor', array( $page, $user ) ) ) { |
| 44 | + $handler = ContentHandler::getForTitle( $page->getTitle() ); |
| 45 | + |
44 | 46 | if ( ExternalEdit::useExternalEngine( $context, 'edit' ) |
45 | 47 | && $this->getName() == 'edit' && !$request->getVal( 'section' ) |
46 | 48 | && !$request->getVal( 'oldid' ) ) |
47 | 49 | { |
48 | | - $extedit = new ExternalEdit( $context ); |
| 50 | + $extedit = $handler->createExternalEdit( $context ); |
49 | 51 | $extedit->execute(); |
50 | 52 | } else { |
51 | | - $editor = new EditPage( $page ); |
| 53 | + $editor = $handler->createEditPage( $page ); |
52 | 54 | $editor->edit(); |
53 | 55 | } |
54 | 56 | } |
Index: branches/Wikidata/phase3/includes/Article.php |
— | — | @@ -113,13 +113,14 @@ |
114 | 114 | if ( !$page ) { |
115 | 115 | switch( $title->getNamespace() ) { |
116 | 116 | case NS_FILE: |
117 | | - $page = new ImagePage( $title ); |
| 117 | + $page = new ImagePage( $title ); #FIXME: teach ImagePage to use ContentHandler |
118 | 118 | break; |
119 | 119 | case NS_CATEGORY: |
120 | | - $page = new CategoryPage( $title ); |
| 120 | + $page = new CategoryPage( $title ); #FIXME: teach ImagePage to use ContentHandler |
121 | 121 | break; |
122 | 122 | default: |
123 | | - $page = new Article( $title ); |
| 123 | + $handler = ContentHandler::getForTitle( $title ); |
| 124 | + $page = $handler->createArticle( $title ); |
124 | 125 | } |
125 | 126 | } |
126 | 127 | $page->setContext( $context ); |
— | — | @@ -742,7 +743,7 @@ |
743 | 744 | * This is hooked by SyntaxHighlight_GeSHi to do syntax highlighting of these |
744 | 745 | * page views. |
745 | 746 | */ |
746 | | - protected function showCssOrJsPage() { #FIXME: move this to handler! |
| 747 | + protected function showCssOrJsPage() { #FIXME: move this to ContentHandler! |
747 | 748 | global $wgOut; |
748 | 749 | |
749 | 750 | $dir = $this->getContext()->getLanguage()->getDir(); |