Index: trunk/extensions/Collection/Collection.php |
— | — | @@ -95,6 +95,7 @@ |
96 | 96 | $wgHooks['SkinTemplateBuildNavUrlsNav_urlsAfterPermalink'][] = 'Collection::createNavURLs'; |
97 | 97 | $wgHooks['MonoBookTemplateToolboxEnd'][] = 'Collection::insertMonoBookToolboxLink'; |
98 | 98 | $wgHooks['SkinBuildSidebar'][] = 'Collection::buildSidebar'; |
| 99 | +$wgHooks['OutputPageCheckLastModified'][] = 'Collection::checkLastModified'; |
99 | 100 | |
100 | 101 | # register global Ajax functions: |
101 | 102 | |
Index: trunk/extensions/Collection/Collection.body.php |
— | — | @@ -229,14 +229,12 @@ |
230 | 230 | } |
231 | 231 | |
232 | 232 | static function clearCollection() { |
233 | | - if ( !self::hasSession() ) { |
234 | | - return; |
235 | | - } |
236 | 233 | $_SESSION['wsCollection'] = array( |
237 | 234 | 'title' => '', |
238 | 235 | 'subtitle' => '', |
239 | 236 | 'items' => array(), |
240 | 237 | ); |
| 238 | + self::touchSession(); |
241 | 239 | } |
242 | 240 | |
243 | 241 | static function startSession() { |
— | — | @@ -246,6 +244,12 @@ |
247 | 245 | self::clearCollection(); |
248 | 246 | } |
249 | 247 | |
| 248 | + static function touchSession() { |
| 249 | + $collection = $_SESSION['wsCollection']; |
| 250 | + $collection['timestamp'] = wfTimestampNow(); |
| 251 | + $_SESSION['wsCollection'] = $collection; |
| 252 | + } |
| 253 | + |
250 | 254 | static function countArticles() { |
251 | 255 | if ( !self::hasSession() ) { |
252 | 256 | return 0; |
— | — | @@ -370,6 +374,7 @@ |
371 | 375 | 'url' => $title->getFullURL(), |
372 | 376 | ); |
373 | 377 | $_SESSION['wsCollection'] = $collection; |
| 378 | + self::touchSession(); |
374 | 379 | } |
375 | 380 | |
376 | 381 | function removeArticle( $title, $oldid=0 ) { |
— | — | @@ -382,6 +387,7 @@ |
383 | 388 | array_splice( $collection['items'], $index, 1 ); |
384 | 389 | } |
385 | 390 | $_SESSION['wsCollection'] = $collection; |
| 391 | + self::touchSession(); |
386 | 392 | } |
387 | 393 | |
388 | 394 | function addCategory( $title ) { |
— | — | @@ -1452,4 +1458,14 @@ |
1453 | 1459 | curl_close( $c ); |
1454 | 1460 | return $text; |
1455 | 1461 | } |
| 1462 | + |
| 1463 | + /** |
| 1464 | + * OutputPageCheckLastModified hook |
| 1465 | + */ |
| 1466 | + static function checkLastModified( $modifiedTimes ) { |
| 1467 | + if ( self::hasSession() ) { |
| 1468 | + $modifiedTimes['collection'] = $_SESSION['wsCollection']['timestamp']; |
| 1469 | + } |
| 1470 | + return true; |
| 1471 | + } |
1456 | 1472 | } |