Index: trunk/extensions/Wikilog/WikilogDefaultSettings.php |
— | — | @@ -69,6 +69,17 @@ |
70 | 70 | $wgWikilogMaxAuthors = 6; |
71 | 71 | |
72 | 72 | /** |
| 73 | + * Publish new articles by default. When creating new wikilog articles, |
| 74 | + * if this variable is set to true, the default value of the "Sign and |
| 75 | + * publish this article" checkbox will be checked, which means that saving |
| 76 | + * the article will automatically sign and publish it. In order to save |
| 77 | + * the article as draft, the user would have to uncheck the box before |
| 78 | + * saving. |
| 79 | + * @since Wikilog v1.0.1. |
| 80 | + */ |
| 81 | +$wgWikilogSignAndPublishDefault = false; |
| 82 | + |
| 83 | +/** |
73 | 84 | * Enable use of tags. This is disabled by default since MediaWiki category |
74 | 85 | * system already provides similar functionality, and are the preferred way |
75 | 86 | * of organizing wikilog posts. Enable this if you want or need an additional |
Index: trunk/extensions/Wikilog/Wikilog.php |
— | — | @@ -102,30 +102,34 @@ |
103 | 103 | $wgExtensionFunctions[] = array( 'Wikilog', 'ExtensionInit' ); |
104 | 104 | |
105 | 105 | // Main Wikilog hooks |
106 | | -$wgHooks['ArticleFromTitle'][] = 'Wikilog::ArticleFromTitle'; |
107 | | -$wgHooks['ArticleViewHeader'][] = 'Wikilog::ArticleViewHeader'; |
108 | | -$wgHooks['BeforePageDisplay'][] = 'Wikilog::BeforePageDisplay'; |
109 | | -$wgHooks['LinkBegin'][] = 'Wikilog::LinkBegin'; |
110 | | -$wgHooks['SkinTemplateTabAction'][] = 'Wikilog::SkinTemplateTabAction'; |
111 | | -$wgHooks['SkinTemplateTabs'][] = 'Wikilog::SkinTemplateTabs'; |
| 106 | +$wgHooks['ArticleFromTitle'][] = 'Wikilog::ArticleFromTitle'; |
| 107 | +$wgHooks['ArticleViewHeader'][] = 'Wikilog::ArticleViewHeader'; |
| 108 | +$wgHooks['BeforePageDisplay'][] = 'Wikilog::BeforePageDisplay'; |
| 109 | +$wgHooks['LinkBegin'][] = 'Wikilog::LinkBegin'; |
| 110 | +$wgHooks['SkinTemplateTabAction'][] = 'Wikilog::SkinTemplateTabAction'; |
| 111 | +$wgHooks['SkinTemplateTabs'][] = 'Wikilog::SkinTemplateTabs'; |
112 | 112 | |
113 | 113 | // General Wikilog hooks |
114 | | -$wgHooks['ArticleEditUpdates'][] = 'WikilogHooks::ArticleEditUpdates'; |
115 | | -$wgHooks['ArticleDeleteComplete'][] = 'WikilogHooks::ArticleDeleteComplete'; |
116 | | -$wgHooks['TitleMoveComplete'][] = 'WikilogHooks::TitleMoveComplete'; |
| 114 | +$wgHooks['ArticleEditUpdates'][] = 'WikilogHooks::ArticleEditUpdates'; |
| 115 | +$wgHooks['ArticleDeleteComplete'][] = 'WikilogHooks::ArticleDeleteComplete'; |
| 116 | +$wgHooks['ArticleSave'][] = 'WikilogHooks::ArticleSave'; |
| 117 | +$wgHooks['TitleMoveComplete'][] = 'WikilogHooks::TitleMoveComplete'; |
| 118 | +$wgHooks['EditPage::attemptSave'][] = 'WikilogHooks::EditPageAttemptSave'; |
| 119 | +$wgHooks['EditPage::showEditForm:fields'][] = 'WikilogHooks::EditPageEditFormFields'; |
| 120 | +$wgHooks['EditPage::importFormData'][] = 'WikilogHooks::EditPageImportFormData'; |
117 | 121 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'WikilogHooks::ExtensionSchemaUpdates'; |
118 | | -$wgHooks['UnknownAction'][] = 'WikilogHooks::UnknownAction'; |
| 122 | +$wgHooks['UnknownAction'][] = 'WikilogHooks::UnknownAction'; |
119 | 123 | |
120 | 124 | // WikilogLinksUpdate hooks |
121 | | -$wgHooks['LinksUpdate'][] = 'WikilogLinksUpdate::LinksUpdate'; |
| 125 | +$wgHooks['LinksUpdate'][] = 'WikilogLinksUpdate::LinksUpdate'; |
122 | 126 | |
123 | 127 | // WikilogParser hooks |
124 | | -$wgHooks['ParserFirstCallInit'][] = 'WikilogParser::FirstCallInit'; |
125 | | -$wgHooks['ParserClearState'][] = 'WikilogParser::ClearState'; |
126 | | -$wgHooks['ParserBeforeInternalParse'][] = 'WikilogParser::BeforeInternalParse'; |
127 | | -$wgHooks['ParserAfterTidy'][] = 'WikilogParser::AfterTidy'; |
128 | | -$wgHooks['GetLocalURL'][] = 'WikilogParser::GetLocalURL'; |
129 | | -$wgHooks['GetFullURL'][] = 'WikilogParser::GetFullURL'; |
| 128 | +$wgHooks['ParserFirstCallInit'][] = 'WikilogParser::FirstCallInit'; |
| 129 | +$wgHooks['ParserClearState'][] = 'WikilogParser::ClearState'; |
| 130 | +$wgHooks['ParserBeforeInternalParse'][] = 'WikilogParser::BeforeInternalParse'; |
| 131 | +$wgHooks['ParserAfterTidy'][] = 'WikilogParser::AfterTidy'; |
| 132 | +$wgHooks['GetLocalURL'][] = 'WikilogParser::GetLocalURL'; |
| 133 | +$wgHooks['GetFullURL'][] = 'WikilogParser::GetFullURL'; |
130 | 134 | |
131 | 135 | if ( !defined( 'MW_SUPPORTS_LOCALISATIONCACHE' ) ) { |
132 | 136 | /* pre Mw1.16 compatibility */ |
Index: trunk/extensions/Wikilog/WikilogHooks.php |
— | — | @@ -179,6 +179,24 @@ |
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |
| 183 | + * ArticleSave hook handler function. |
| 184 | + * Add article signature if user selected "sign and publish" option in |
| 185 | + * EditPage. |
| 186 | + */ |
| 187 | + static function ArticleSave( &$article, &$user, &$text, &$summary, |
| 188 | + $minor, $watch, $sectionanchor, &$flags ) |
| 189 | + { |
| 190 | + # $article->mExtWikilog piggybacked from WikilogHooks::EditPageAttemptSave(). |
| 191 | + if ( isset( $article->mExtWikilog ) && $article->mExtWikilog['signpub'] ) { |
| 192 | + $t = WikilogUtils::getPublishParameters(); |
| 193 | + $txtDate = $t['date']; |
| 194 | + $txtUser = $t['user']; |
| 195 | + $text = rtrim( $text ) . "\n{{wl-publish: {$txtDate} | {$txtUser} }}\n"; |
| 196 | + } |
| 197 | + return true; |
| 198 | + } |
| 199 | + |
| 200 | + /** |
183 | 201 | * TitleMoveComplete hook handler function. |
184 | 202 | * Handles moving articles to and from wikilog namespaces. |
185 | 203 | */ |
— | — | @@ -259,6 +277,82 @@ |
260 | 278 | } |
261 | 279 | |
262 | 280 | /** |
| 281 | + * EditPage::showEditForm:fields hook handler function. |
| 282 | + * Adds wikilog article options to edit pages. |
| 283 | + */ |
| 284 | + static function EditPageEditFormFields( &$editpage, &$output ) { |
| 285 | + $wi = Wikilog::getWikilogInfo( $editpage->mTitle ); |
| 286 | + if ( $wi && $wi->isItem() && !$wi->isTalk() ) { |
| 287 | + global $wgUser, $wgWikilogSignAndPublishDefault; |
| 288 | + $fields = array(); |
| 289 | + $item = WikilogItem::newFromInfo( $wi ); |
| 290 | + |
| 291 | + # [x] Sign and publish this wikilog article. |
| 292 | + if ( !$item || !$item->getIsPublished() ) { |
| 293 | + if ( isset( $editpage->wlSignpub ) ) { |
| 294 | + $checked = $editpage->wlSignpub; |
| 295 | + } else { |
| 296 | + $checked = !$item && $wgWikilogSignAndPublishDefault; |
| 297 | + } |
| 298 | + $label = wfMsgExt( 'wikilog-edit-signpub', array( 'parseinline' ) ); |
| 299 | + $tooltip = wfMsgExt( 'wikilog-edit-signpub-tooltip', array( 'parseinline' ) ); |
| 300 | + $fields['wlSignpub'] = |
| 301 | + Xml::check( 'wlSignpub', $checked, array( |
| 302 | + 'id' => 'wl-signpub', |
| 303 | + 'tabindex' => 1, // after text, before summary |
| 304 | + ) ) . ' ' . |
| 305 | + Xml::element( 'label', array( |
| 306 | + 'for' => 'wl-signpub', |
| 307 | + 'title' => $tooltip, |
| 308 | + ), $label ); |
| 309 | + } |
| 310 | + |
| 311 | + $fields = implode( $fields, "\n" ); |
| 312 | + $html = Xml::fieldset( |
| 313 | + wfMsgExt( 'wikilog-edit-fieldset-legend', array( 'parseinline' ) ), |
| 314 | + $fields |
| 315 | + ); |
| 316 | + $editpage->editFormTextAfterWarn .= $html; |
| 317 | + } |
| 318 | + return true; |
| 319 | + } |
| 320 | + |
| 321 | + /** |
| 322 | + * EditPage::importFormData hook handler function. |
| 323 | + * Import wikilog article options form data in edit pages. |
| 324 | + * @note Requires MediaWiki 1.16+. |
| 325 | + */ |
| 326 | + static function EditPageImportFormData( &$editpage, &$request ) { |
| 327 | + if ( $request->wasPosted() ) { |
| 328 | + $editpage->wlSignpub = $request->getCheck( 'wlSignpub' ); |
| 329 | + } |
| 330 | + return true; |
| 331 | + } |
| 332 | + |
| 333 | + /** |
| 334 | + * EditPage::attemptSave hook handler function. |
| 335 | + * Check edit page options. |
| 336 | + * @todo Remove $editpage->wlSignpub hack in Wikilog 1.1.0, along with |
| 337 | + * support for Mw < 1.16. |
| 338 | + */ |
| 339 | + static function EditPageAttemptSave( $editpage ) { |
| 340 | + # HACK: For Mw < 1.16, due to the lack of 'EditPage::importFormData' hook. |
| 341 | + if ( !isset( $editpage->wlSignpub ) ) { |
| 342 | + global $wgRequest; |
| 343 | + $editpage->wlSignpub = $wgRequest->getCheck( 'wlSignpub' ); |
| 344 | + } |
| 345 | + |
| 346 | + $options = array( |
| 347 | + 'signpub' => $editpage->wlSignpub |
| 348 | + ); |
| 349 | + |
| 350 | + # Piggyback options into article object. Will be retrieved later |
| 351 | + # in 'ArticleEditUpdates' hook. |
| 352 | + $editpage->mArticle->mExtWikilog = $options; |
| 353 | + return true; |
| 354 | + } |
| 355 | + |
| 356 | + /** |
263 | 357 | * LoadExtensionSchemaUpdates hook handler function. |
264 | 358 | * Updates wikilog database tables. |
265 | 359 | * |
Index: trunk/extensions/Wikilog/RELEASE-NOTES |
— | — | @@ -2,11 +2,19 @@ |
3 | 3 | |
4 | 4 | == Current development version == |
5 | 5 | |
| 6 | +=== New configuration options === |
| 7 | + |
| 8 | +* $wgWikilogSignAndPublishDefault: default state for the new "sign and |
| 9 | + publish" checkbox in the edit page for new articles. |
| 10 | + |
6 | 11 | === New features === |
7 | 12 | |
8 | 13 | * New parameters 'date', 'time', 'updatedDate', 'updatedTime' and 'hasMore' |
9 | 14 | for the template pager, used when embedding using templates. Old parameters |
10 | 15 | 'pubdate' and 'updated' were deprecated, and should be removed on v1.2.0. |
| 16 | +* Wikilog article edit page now features a "sign and publish" checkbox that, |
| 17 | + when selected, automatically signs and publishes the article by adding an |
| 18 | + appropriate {{wl-publish:...}} parser function call at the end of the text. |
11 | 19 | |
12 | 20 | === Bug fixes === |
13 | 21 | |
Index: trunk/extensions/Wikilog/WikilogItemPage.php |
— | — | @@ -154,20 +154,13 @@ |
155 | 155 | * that is then saved to the database and causes the post to be published. |
156 | 156 | */ |
157 | 157 | function preSaveTransform( $text ) { |
158 | | - global $wgParser, $wgUser, $wgLocaltimezone; |
| 158 | + global $wgParser, $wgUser; |
159 | 159 | |
160 | | - $user = $wgUser->getName(); |
161 | 160 | $popt = ParserOptions::newFromUser( $wgUser ); |
162 | 161 | |
163 | | - $unixts = wfTimestamp( TS_UNIX, $popt->getTimestamp() ); |
164 | | - if ( isset( $wgLocaltimezone ) ) { |
165 | | - $oldtz = getenv( 'TZ' ); |
166 | | - putenv( "TZ={$wgLocaltimezone}" ); |
167 | | - $date = date( 'Y-m-d H:i:s O', $unixts ); |
168 | | - putenv( "TZ={$oldtz}" ); |
169 | | - } else { |
170 | | - $date = date( 'Y-m-d H:i:s O', $unixts ); |
171 | | - } |
| 162 | + $t = WikilogUtils::getPublishParameters(); |
| 163 | + $date = $t['date']; |
| 164 | + $user = $t['user']; |
172 | 165 | |
173 | 166 | $sigs = array( |
174 | 167 | '/\n?(--)?~~~~~\n?/m' => "\n{{wl-publish: {$date} }}\n", |
Index: trunk/extensions/Wikilog/Wikilog.i18n.php |
— | — | @@ -81,6 +81,12 @@ |
82 | 82 | |
83 | 83 | 'wikilog-author-signature' => '[[{{ns:User}}:$1|$1]] ([[{{ns:User_talk}}:$1|talk]])', |
84 | 84 | |
| 85 | + # Edit page |
| 86 | + 'wikilog-edit-fieldset-legend' => 'Wikilog options:', |
| 87 | + 'wikilog-edit-signpub' => 'Sign and publish this article', |
| 88 | + 'wikilog-edit-signpub-tooltip' => 'Causes this article to be signed and published in its wikilog when saved. |
| 89 | +Uncheck this box to keep the article as a draft.', |
| 90 | + |
85 | 91 | # Comments |
86 | 92 | 'wikilog-comment-by-user' => 'Comment by $1 ($2)', |
87 | 93 | 'wikilog-comment-by-anon' => 'Comment by $3 (anonymous)', |
— | — | @@ -213,7 +219,7 @@ |
214 | 220 | * $1 = Wikilog URL |
215 | 221 | * $2 = Wikilog Name |
216 | 222 | * $5 = Authors, |
217 | | -* $6 = Publish date, |
| 223 | +* $6 = Publication date, |
218 | 224 | * $7 = Comments link', |
219 | 225 | 'wikilog-item-more' => 'Parameters: |
220 | 226 | * $3 = Item URL', |
— | — | @@ -223,7 +229,7 @@ |
224 | 230 | * $3 is a date |
225 | 231 | * $4 is a time', |
226 | 232 | 'wikilog-comment-autosumm' => 'Parameters: |
227 | | -* $1 is a user name |
| 233 | +* $1 is a user name |
228 | 234 | * $2 is a summary', |
229 | 235 | 'wikilog-feed-title' => 'Parameters: |
230 | 236 | * $1 is a title |
Index: trunk/extensions/Wikilog/WikilogUtils.php |
— | — | @@ -293,4 +293,27 @@ |
294 | 294 | implode( "\n", $rows ) ); |
295 | 295 | return $form; |
296 | 296 | } |
| 297 | + |
| 298 | + /** |
| 299 | + * Returns the date and user parameters suitable for substitution in |
| 300 | + * {{wl-publish:...}} parser function. |
| 301 | + */ |
| 302 | + public static function getPublishParameters() { |
| 303 | + global $wgUser, $wgLocaltimezone; |
| 304 | + |
| 305 | + $user = $wgUser->getName(); |
| 306 | + $popt = ParserOptions::newFromUser( $wgUser ); |
| 307 | + |
| 308 | + $unixts = wfTimestamp( TS_UNIX, $popt->getTimestamp() ); |
| 309 | + if ( isset( $wgLocaltimezone ) ) { |
| 310 | + $oldtz = getenv( 'TZ' ); |
| 311 | + putenv( "TZ={$wgLocaltimezone}" ); |
| 312 | + $date = date( 'Y-m-d H:i:s O', $unixts ); |
| 313 | + putenv( "TZ={$oldtz}" ); |
| 314 | + } else { |
| 315 | + $date = date( 'Y-m-d H:i:s O', $unixts ); |
| 316 | + } |
| 317 | + |
| 318 | + return array( 'date' => $date, 'user' => $user ); |
| 319 | + } |
297 | 320 | } |