Index: trunk/extensions/Wikilog/WikilogItemPage.php |
— | — | @@ -48,15 +48,32 @@ |
49 | 49 | * @param $title Article title object. |
50 | 50 | * @param $wi Wikilog info object. |
51 | 51 | */ |
52 | | - function __construct( &$title, &$wi ) { |
| 52 | + public function __construct( Title $title, WikilogItem $item = null ) { |
53 | 53 | parent::__construct( $title ); |
54 | | - $this->mItem = WikilogItem::newFromInfo( $wi ); |
| 54 | + $this->mItem = $item; |
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
| 58 | + * Return the appropriate WikiPage object for WikilogItemPage. |
| 59 | + */ |
| 60 | + protected function newPage( Title $title ) { |
| 61 | + return new WikilogWikiItemPage( $title ); |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | + * Constructor from a page ID. |
| 66 | + * @param $id Int article ID to load. |
| 67 | + */ |
| 68 | + public static function newFromID( $id ) { |
| 69 | + $t = Title::newFromID( $id ); |
| 70 | + $i = WikilogItem::newFromID( $id ); |
| 71 | + return $t == null ? null : new self( $t, $i ); |
| 72 | + } |
| 73 | + |
| 74 | + /** |
58 | 75 | * View page action handler. |
59 | 76 | */ |
60 | | - function view() { |
| 77 | + public function view() { |
61 | 78 | global $wgOut, $wgUser, $wgContLang, $wgFeed, $wgWikilogFeedClasses; |
62 | 79 | |
63 | 80 | # Get skin |
— | — | @@ -132,35 +149,62 @@ |
133 | 150 | } |
134 | 151 | |
135 | 152 | /** |
| 153 | + * Compatibility with MediaWiki 1.17. |
| 154 | + * @todo Remove this in Wl1.3. |
| 155 | + */ |
| 156 | + public function preSaveTransform( $text ) { |
| 157 | + return $this->newPage( $this->getTitle() )->preSaveTransform( $text ); |
| 158 | + } |
| 159 | +} |
| 160 | + |
| 161 | +/** |
| 162 | + * Wikilog WikiPage class for WikilogItemPage. |
| 163 | + */ |
| 164 | +class WikilogWikiItemPage |
| 165 | + extends WikiPage |
| 166 | +{ |
| 167 | + /** |
| 168 | + * Constructor from a page ID. |
| 169 | + * @param $id Int article ID to load. |
| 170 | + */ |
| 171 | + public static function newFromID( $id ) { |
| 172 | + $t = Title::newFromID( $id ); |
| 173 | + return $t == null ? null : new self( $t ); |
| 174 | + } |
| 175 | + |
| 176 | + /** |
136 | 177 | * Override for preSaveTransform. Enables quick post publish by signing |
137 | 178 | * the article using the standard --~~~~ marker. This causes the signature |
138 | 179 | * marker to be replaced by a {{wl-publish:...}} parser function call, |
139 | 180 | * that is then saved to the database and causes the post to be published. |
140 | 181 | */ |
141 | | - function preSaveTransform( $text ) { |
| 182 | + public function preSaveTransform( $text, User $user = null, ParserOptions $popts = null ) { |
142 | 183 | global $wgParser, $wgUser; |
| 184 | + $user = is_null( $user ) ? $wgUser : $user; |
143 | 185 | |
144 | | - $popt = ParserOptions::newFromUser( $wgUser ); |
| 186 | + if ( $popts === null ) { |
| 187 | + $popts = ParserOptions::newFromUser( $user ); |
| 188 | + } |
145 | 189 | |
146 | 190 | $t = WikilogUtils::getPublishParameters(); |
147 | | - $date = $t['date']; |
148 | | - $user = $t['user']; |
| 191 | + $date_txt = $t['date']; |
| 192 | + $user_txt = $t['user']; |
149 | 193 | |
150 | 194 | $sigs = array( |
151 | | - '/\n?(--)?~~~~~\n?/m' => "\n{{wl-publish: {$date} }}\n", |
152 | | - '/\n?(--)?~~~~\n?/m' => "\n{{wl-publish: {$date} | {$user} }}\n", |
153 | | - '/\n?(--)?~~~\n?/m' => "\n{{wl-author: {$user} }}\n" |
| 195 | + '/\n?(--)?~~~~~\n?/m' => "\n{{wl-publish: {$date_txt} }}\n", |
| 196 | + '/\n?(--)?~~~~\n?/m' => "\n{{wl-publish: {$date_txt} | {$user_txt} }}\n", |
| 197 | + '/\n?(--)?~~~\n?/m' => "\n{{wl-author: {$user_txt} }}\n" |
154 | 198 | ); |
155 | 199 | |
156 | 200 | if ( !StubObject::isRealObject( $wgParser ) ) { |
157 | 201 | $wgParser->_unstub(); |
158 | 202 | } |
159 | | - $wgParser->startExternalParse( $this->mTitle, $popt, Parser::OT_WIKI ); |
| 203 | + $wgParser->startExternalParse( $this->mTitle, $popts, Parser::OT_WIKI ); |
160 | 204 | |
161 | 205 | $text = $wgParser->replaceVariables( $text ); |
162 | 206 | $text = preg_replace( array_keys( $sigs ), array_values( $sigs ), $text ); |
163 | 207 | $text = $wgParser->mStripState->unstripBoth( $text ); |
164 | 208 | |
165 | | - return parent::preSaveTransform( $text ); |
| 209 | + return parent::preSaveTransform( $text, $user, $popts ); |
166 | 210 | } |
167 | 211 | } |
Index: trunk/extensions/Wikilog/Wikilog.php |
— | — | @@ -107,6 +107,7 @@ |
108 | 108 | // Namespace pages |
109 | 109 | 'WikilogMainPage' => $dir . 'WikilogMainPage.php', |
110 | 110 | 'WikilogItemPage' => $dir . 'WikilogItemPage.php', |
| 111 | + 'WikilogWikiItemPage' => $dir . 'WikilogItemPage.php', |
111 | 112 | 'WikilogCommentsPage' => $dir . 'WikilogCommentsPage.php', |
112 | 113 | |
113 | 114 | // Captcha adapter |
— | — | @@ -274,7 +275,8 @@ |
275 | 276 | return true; |
276 | 277 | } |
277 | 278 | } elseif ( $wi->isItem() ) { |
278 | | - $article = new WikilogItemPage( $title, $wi ); |
| 279 | + $item = WikilogItem::newFromInfo( $wi ); |
| 280 | + $article = new WikilogItemPage( $title, $item ); |
279 | 281 | } else { |
280 | 282 | $article = new WikilogMainPage( $title, $wi ); |
281 | 283 | } |
Index: trunk/extensions/Wikilog/TODO |
— | — | @@ -2,4 +2,4 @@ |
3 | 3 | |
4 | 4 | === Wikilog 1.3.0. === |
5 | 5 | |
6 | | -(empty) |
| 6 | +* Remove WikilogItemPage::preSaveTransform() (Mw 1.17 compatibility). |