Index: trunk/extensions/BlogPage/BlogPage.php |
— | — | @@ -37,7 +37,7 @@ |
38 | 38 | } |
39 | 39 | |
40 | 40 | function view() { |
41 | | - global $wgOut, $wgUser, $wgTitle, $wgBlogPageDisplay; |
| 41 | + global $wgOut, $wgUser, $wgBlogPageDisplay; |
42 | 42 | |
43 | 43 | wfProfileIn( __METHOD__ ); |
44 | 44 | |
— | — | @@ -45,8 +45,8 @@ |
46 | 46 | |
47 | 47 | wfDebugLog( 'BlogPage', __METHOD__ ); |
48 | 48 | |
49 | | - $wgOut->setHTMLTitle( $wgTitle->getText() ); |
50 | | - $wgOut->setPageTitle( $wgTitle->getText() ); |
| 49 | + $wgOut->setHTMLTitle( $this->getTitle()->getText() ); |
| 50 | + $wgOut->setPageTitle( $this->getTitle()->getText() ); |
51 | 51 | |
52 | 52 | // Don't throw a bunch of E_NOTICEs when we're viewing the page of a |
53 | 53 | // nonexistent blog post |
— | — | @@ -94,7 +94,7 @@ |
95 | 95 | if( $wgUseEditButtonFloat == true && method_exists( $sk, 'editMenu' ) ) { |
96 | 96 | $wgOut->addHTML( $sk->editMenu() ); |
97 | 97 | } |
98 | | - $wgOut->addHTML( "<h1 class=\"page-title\">{$wgTitle->getText()}</h1>\n" ); |
| 98 | + $wgOut->addHTML( "<h1 class=\"page-title\">{$this->getTitle()->getText()}</h1>\n" ); |
99 | 99 | $wgOut->addHTML( $this->getByLine() ); |
100 | 100 | |
101 | 101 | $wgOut->addHTML( "\n<!--start Article::view-->\n" ); |
— | — | @@ -196,70 +196,22 @@ |
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
200 | | - * Get the last edit date of the page with the given ID from the revision |
201 | | - * table and cache it in memcached. |
202 | | - * The return value of this function can be passed to the various $wgLang |
203 | | - * methods for i18n-compatible code. |
204 | | - * |
205 | | - * @param $pageId Integer: page ID number |
206 | | - * @return Integer: page creation date |
207 | | - */ |
208 | | - public static function getLastEditTimestamp( $pageId ) { |
209 | | - global $wgMemc; |
210 | | - |
211 | | - // Try memcached first |
212 | | - $key = wfMemcKey( 'page', 'last_edit_date', $pageId ); |
213 | | - $data = $wgMemc->get( $key ); |
214 | | - |
215 | | - if( !$data ) { |
216 | | - wfDebugLog( 'BlogPage', "Loading last_edit_date for page {$pageId} from database" ); |
217 | | - $dbr = wfGetDB( DB_SLAVE ); |
218 | | - $lastEditDate = $dbr->selectField( |
219 | | - 'revision', |
220 | | - 'MAX(rev_timestamp)', |
221 | | - array( 'rev_page' => $pageId ), |
222 | | - __METHOD__, |
223 | | - array( 'ORDER BY' => 'rev_timestamp ASC' ) |
224 | | - ); |
225 | | - $wgMemc->set( $key, $lastEditDate ); |
226 | | - } else { |
227 | | - wfDebugLog( 'BlogPage', "Loading last_edit_date for page {$pageId} from cache" ); |
228 | | - $lastEditDate = $data; |
229 | | - } |
230 | | - |
231 | | - return $lastEditDate; |
232 | | - } |
233 | | - |
234 | | - /** |
235 | 200 | * Get the "by X, Y and Z" line, which also contains other nifty |
236 | 201 | * information, such as the date of the last edit and the creation date. |
237 | 202 | * |
238 | 203 | * @return String |
239 | 204 | */ |
240 | 205 | function getByLine() { |
241 | | - global $wgTitle, $wgLang; |
| 206 | + global $wgLang; |
242 | 207 | |
243 | 208 | $count = 0; |
244 | 209 | |
245 | 210 | // Get date of last edit |
246 | | - /* |
247 | | - $year = substr( $wgTitle->getTouched(), 0, 4 ); |
248 | | - $month = substr( $wgTitle->getTouched(), 4, 2 ); |
249 | | - $day = substr( $wgTitle->getTouched(), 6, 2 ); |
250 | | - $edit_date = date( 'F d, Y', mktime( 0, 0, 0, $month, $day, $year ) ); |
251 | | - */ |
252 | | - //$edit_date = $wgLang->timeanddate( $wgTitle->getTouched(), true ); |
253 | | - // Title::getTouched() sucks, because apparently voting for a page |
254 | | - // invalidates page cache, too... --ashley, 7 August 2011 |
255 | | - $edit_date = $wgLang->timeanddate( |
256 | | - self::getLastEditTimestamp( $wgTitle->getArticleID() ), |
257 | | - true |
258 | | - ); |
| 211 | + $edit_date = $wgLang->timeanddate( $this->getTimestamp(), true ); |
259 | 212 | |
260 | 213 | // Get date of when article was created |
261 | | - #$create_date = date( 'F d, Y', $this->getCreateDate( $wgTitle->getArticleID() ) ); |
262 | 214 | $create_date = $wgLang->timeanddate( |
263 | | - self::getCreateDate( $wgTitle->getArticleID() ), |
| 215 | + self::getCreateDate( $this->getId() ), |
264 | 216 | true |
265 | 217 | ); |
266 | 218 | |
— | — | @@ -381,7 +333,7 @@ |
382 | 334 | } |
383 | 335 | |
384 | 336 | function getAuthorArticles( $author_index ) { |
385 | | - global $wgTitle, $wgOut, $wgBlogPageDisplay, $wgMemc; |
| 337 | + global $wgOut, $wgBlogPageDisplay, $wgMemc; |
386 | 338 | |
387 | 339 | if ( $wgBlogPageDisplay['author_articles'] == false ) { |
388 | 340 | return ''; |
— | — | @@ -431,7 +383,7 @@ |
432 | 384 | $array_count = 0; |
433 | 385 | |
434 | 386 | foreach( $res as $row ) { |
435 | | - if ( $row->page_id != $wgTitle->getArticleID() && $array_count < 3 ) { |
| 387 | + if ( $row->page_id != $this->getId() && $array_count < 3 ) { |
436 | 388 | $articles[] = array( |
437 | 389 | 'page_title' => $row->page_title, |
438 | 390 | 'page_id' => $row->page_id |
— | — | @@ -502,9 +454,9 @@ |
503 | 455 | * @return Array: array containing each editors' user ID and user name |
504 | 456 | */ |
505 | 457 | function getEditorsList() { |
506 | | - global $wgMemc, $wgTitle; |
| 458 | + global $wgMemc; |
507 | 459 | |
508 | | - $pageTitleId = $wgTitle->getArticleID(); |
| 460 | + $pageTitleId = $this->getId(); |
509 | 461 | |
510 | 462 | $key = wfMemcKey( 'recenteditors', 'list', $pageTitleId ); |
511 | 463 | $data = $wgMemc->get( $key ); |
— | — | @@ -594,10 +546,10 @@ |
595 | 547 | * @return Array: array containing each voters' user ID and user name |
596 | 548 | */ |
597 | 549 | function getVotersList() { |
598 | | - global $wgMemc, $wgTitle; |
| 550 | + global $wgMemc; |
599 | 551 | |
600 | 552 | // Gets the page ID for the query |
601 | | - $pageTitleId = $wgTitle->getArticleID(); |
| 553 | + $pageTitleId = $this->getId(); |
602 | 554 | |
603 | 555 | $key = wfMemcKey( 'recentvoters', 'list', $pageTitleId ); |
604 | 556 | $data = $wgMemc->get( $key ); |
— | — | @@ -684,7 +636,7 @@ |
685 | 637 | * @return String: HTML or nothing |
686 | 638 | */ |
687 | 639 | function embedWidget() { |
688 | | - global $wgTitle, $wgBlogPageDisplay, $wgServer, $wgScriptPath; |
| 640 | + global $wgBlogPageDisplay, $wgServer, $wgScriptPath; |
689 | 641 | |
690 | 642 | // Not enabled? ContentWidget not available? |
691 | 643 | if ( |
— | — | @@ -695,7 +647,7 @@ |
696 | 648 | return ''; |
697 | 649 | } |
698 | 650 | |
699 | | - $title = Title::makeTitle( $wgTitle->getNamespace(), $wgTitle->getText() ); |
| 651 | + $title = $this->getTitle(); |
700 | 652 | |
701 | 653 | $output = ''; |
702 | 654 | $output .= '<div class="recent-container bottom-fix"><h2>' . |
— | — | @@ -1102,7 +1054,7 @@ |
1103 | 1055 | * @return String: first $maxChars characters from the page |
1104 | 1056 | */ |
1105 | 1057 | public static function getBlurb( $pageTitle, $namespace, $maxChars, $fontSize = 'small' ) { |
1106 | | - global $wgTitle, $wgOut, $wgContLang; |
| 1058 | + global $wgOut, $wgContLang; |
1107 | 1059 | |
1108 | 1060 | // Get raw text |
1109 | 1061 | $title = Title::makeTitle( $namespace, $pageTitle ); |
— | — | @@ -1139,9 +1091,8 @@ |
1140 | 1092 | $text = '__NOTOC__ ' . $text; |
1141 | 1093 | |
1142 | 1094 | // Run text through parser |
1143 | | - $blurbParser = new Parser(); |
1144 | | - $blurbText = $blurbParser->parse( $text, $wgTitle, $wgOut->parserOptions(), true ); |
1145 | | - $blurbText = strip_tags( $blurbText->getText() ); |
| 1095 | + $blurbText = $wgOut->parse( $text ); |
| 1096 | + $blurbText = strip_tags( $blurbText ); |
1146 | 1097 | |
1147 | 1098 | $blurbText = preg_replace( '/<comments><\/comments>/i', '', $blurbText ); |
1148 | 1099 | $blurbText = preg_replace( '/<vote><\/vote>/i', '', $blurbText ); |
— | — | @@ -1259,4 +1210,4 @@ |
1260 | 1211 | } |
1261 | 1212 | return $timeStr; |
1262 | 1213 | } |
1263 | | -} |
\ No newline at end of file |
| 1214 | +} |
Index: trunk/extensions/BlogPage/BlogHooks.php |
— | — | @@ -16,7 +16,7 @@ |
17 | 17 | * @return Boolean: true |
18 | 18 | */ |
19 | 19 | public static function blogFromTitle( &$title, &$article ) { |
20 | | - global $wgRequest, $wgOut, $wgParser, $wgHooks, $wgScriptPath; |
| 20 | + global $wgRequest, $wgOut, $wgHooks, $wgScriptPath; |
21 | 21 | global $wgSupressPageTitle, $wgSupressSubTitle, $wgSupressPageCategories; |
22 | 22 | |
23 | 23 | if ( $title->getNamespace() == NS_BLOG ) { |
— | — | @@ -34,7 +34,6 @@ |
35 | 35 | }; |
36 | 36 | |
37 | 37 | $wgOut->enableClientCache( false ); |
38 | | - $wgParser->disableCache(); |
39 | 38 | |
40 | 39 | // Add CSS |
41 | 40 | if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) { |
— | — | @@ -397,4 +396,4 @@ |
398 | 397 | return true; |
399 | 398 | } |
400 | 399 | */ |
401 | | -} |
\ No newline at end of file |
| 400 | +} |