Index: trunk/extensions/LiquidThreads/LqtFunctions.php |
— | — | @@ -133,7 +133,7 @@ |
134 | 134 | function lqtSetupParserFunctions() { |
135 | 135 | global $wgParser; |
136 | 136 | |
137 | | - $wgParser->setFunctionHook( 'archivestartdays', |
138 | | - array( 'LqtParserFunctions', 'archivestartdays' ) ); |
| 137 | + $wgParser->setFunctionHook( 'useliquidthreads', |
| 138 | + array( 'LqtParserFunctions', 'useLiquidThreads' ) ); |
139 | 139 | } |
140 | 140 | |
Index: trunk/extensions/LiquidThreads/i18n/Lqt.i18n.php |
— | — | @@ -166,6 +166,7 @@ |
167 | 167 | 'lqt-thread-split-subject'=> 'New thread subject', |
168 | 168 | 'lqt-split-submit' => 'Split', |
169 | 169 | 'lqt_split_badsubject' => 'The subject you entered is invalid.', |
| 170 | + 'lqt-no-threads' => 'There are no threads on this page yet.', |
170 | 171 | |
171 | 172 | // Logging |
172 | 173 | 'lqt-log-name' => 'Threaded discussion log', |
Index: trunk/extensions/LiquidThreads/i18n/LiquidThreads.magic.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | * English |
10 | 10 | */ |
11 | 11 | $words['en'] = array( |
12 | | - 'archivestartdays' => array( 0, 'archivestartdays' ), |
| 12 | + 'useliquidthreads' => array( 0, 'UseLiquidThreads' ), |
13 | 13 | ); |
14 | 14 | |
15 | 15 | $magicWords += ( $lang == 'en' || !isset( $words[$lang] ) ) |
Index: trunk/extensions/LiquidThreads/pages/TalkpageView.php |
— | — | @@ -254,8 +254,12 @@ |
255 | 255 | |
256 | 256 | // $html .= $this->getArchiveWidget(); |
257 | 257 | |
258 | | - $html .= Xml::element( 'br', array( 'style' => 'clear: both;' ) ); |
259 | | - $html .= $this->getTOC( $threads ); |
| 258 | + if ( count($threads) > 0 ) { |
| 259 | + $html .= Xml::element( 'br', array( 'style' => 'clear: both;' ) ); |
| 260 | + $html .= $this->getTOC( $threads ); |
| 261 | + } else { |
| 262 | + $html .= wfMsgExt( 'lqt-no-threads', 'parseinline' ); |
| 263 | + } |
260 | 264 | |
261 | 265 | $html .= $pager->getNavigationBar(); |
262 | 266 | |
Index: trunk/extensions/LiquidThreads/classes/LqtThreads.php |
— | — | @@ -31,9 +31,6 @@ |
32 | 32 | |
33 | 33 | static $cache_by_root = array(); |
34 | 34 | static $cache_by_id = array(); |
35 | | - |
36 | | - /** static cache of per-page archivestartdays setting */ |
37 | | - static $archiveStartDays; |
38 | 35 | |
39 | 36 | static function newThread( $root, $article, $superthread = null, |
40 | 37 | $type = self::TYPE_NORMAL, $subject = '' ) { |
— | — | @@ -252,53 +249,4 @@ |
253 | 250 | |
254 | 251 | return $dbr->makeList( $arr, LIST_OR ); |
255 | 252 | } |
256 | | - |
257 | | - static function getArticleArchiveStartDays( $article ) { |
258 | | - global $wgLqtThreadArchiveStartDays; |
259 | | - |
260 | | - $article = $article->getId(); |
261 | | - |
262 | | - // Instance cache |
263 | | - if ( isset( self::$archiveStartDays[$article] ) ) { |
264 | | - $cacheVal = self::$archiveStartDays[$article]; |
265 | | - if ( !is_null( $cacheVal ) ) { |
266 | | - return $cacheVal; |
267 | | - } else { |
268 | | - return $wgLqtThreadArchiveStartDays; |
269 | | - } |
270 | | - } |
271 | | - |
272 | | - // Memcached: It isn't clear that this is needed yet, but since I already wrote the |
273 | | - // code, I might as well leave it commented out instead of deleting it. |
274 | | - // Main reason I've left this commented out is because it isn't obvious how to |
275 | | - // purge the cache when necessary. |
276 | | -// global $wgMemc; |
277 | | -// $key = wfMemcKey( 'lqt-archive-start-days', $article ); |
278 | | -// $cacheVal = $wgMemc->get( $key ); |
279 | | -// if ($cacheVal != false) { |
280 | | -// if ( $cacheVal != -1 ) { |
281 | | -// return $cacheVal; |
282 | | -// } else { |
283 | | -// return $wgLqtThreadArchiveStartDays; |
284 | | -// } |
285 | | -// } |
286 | | - |
287 | | - // Load from the database. |
288 | | - $dbr = wfGetDB( DB_SLAVE ); |
289 | | - |
290 | | - $dbVal = $dbr->selectField( 'page_props', 'pp_value', |
291 | | - array( 'pp_propname' => 'lqt-archivestartdays', |
292 | | - 'pp_page' => $article ), __METHOD__ ); |
293 | | - |
294 | | - if ($dbVal) { |
295 | | - self::$archiveStartDays[$article] = $dbVal; |
296 | | -# $wgMemc->set( $key, $dbVal, 1800 ); |
297 | | - return $dbVal; |
298 | | - } else { |
299 | | - // Negative caching. |
300 | | - self::$archiveStartDays[$article] = null; |
301 | | -# $wgMemc->set( $key, -1, 86400 ); |
302 | | - return $wgLqtThreadArchiveStartDays; |
303 | | - } |
304 | | - } |
305 | 253 | } |
Index: trunk/extensions/LiquidThreads/classes/LqtView.php |
— | — | @@ -965,17 +965,6 @@ |
966 | 966 | |
967 | 967 | if ( $thread->summary() ) { |
968 | 968 | $html .= $this->getSummary( $thread ); |
969 | | - } elseif ( $thread->isArchiveEligible() ) { |
970 | | - wfLoadExtensionMessages( 'LiquidThreads' ); |
971 | | - |
972 | | - $permalink_text = wfMsgNoTrans( 'lqt_summary_notice_link' ); |
973 | | - $permalink = self::permalink( $thread, $permalink_text, 'summarize', |
974 | | - $thread->id() ); |
975 | | - $msg = wfMsgExt( 'lqt_summary_notice', array('parseinline', 'replaceafter'), |
976 | | - array( $permalink, $thread->getArchiveStartDays() ) ); |
977 | | - $msg = Xml::tags( 'p', array( 'class' => 'lqt_summary_notice' ), $msg ); |
978 | | - |
979 | | - $html .= $msg; |
980 | 969 | } |
981 | 970 | |
982 | 971 | // Unfortunately, I can't rewrite showRootPost() to pass back HTML |
Index: trunk/extensions/LiquidThreads/classes/LqtDispatch.php |
— | — | @@ -14,6 +14,9 @@ |
15 | 15 | 'ThreadWatchView' => 'ThreadWatchView', |
16 | 16 | 'SummaryPageView' => 'SummaryPageView' |
17 | 17 | ); |
| 18 | + |
| 19 | + /** static cache of per-page LiquidThreads activation setting */ |
| 20 | + static $userLQTActivated; |
18 | 21 | |
19 | 22 | static function talkpageMain( &$output, &$talk_article, &$title, &$user, &$request ) { |
20 | 23 | // We are given a talkpage article and title. Find the associated |
— | — | @@ -96,11 +99,59 @@ |
97 | 100 | static function isLqtPage( $title ) { |
98 | 101 | global $wgLqtPages, $wgLqtTalkPages; |
99 | 102 | $isTalkPage = ($title->isTalkPage() && $wgLqtTalkPages) || |
100 | | - in_array( $title->getPrefixedText(), $wgLqtPages ); |
| 103 | + in_array( $title->getPrefixedText(), $wgLqtPages ) || |
| 104 | + self::hasUserEnabledLQT( $title->getArticleId() ); |
101 | 105 | |
102 | 106 | return $isTalkPage; |
103 | 107 | } |
| 108 | + |
| 109 | + static function hasUserEnabledLQT( $article ) { |
| 110 | + |
| 111 | + if (is_object($article)) { |
| 112 | + $article = $article->getId(); |
| 113 | + } |
| 114 | + |
| 115 | + // Instance cache |
| 116 | + if ( isset( self::$userLQTActivated[$article] ) ) { |
| 117 | + $cacheVal = self::$userLQTActivated[$article]; |
104 | 118 | |
| 119 | + return $cacheVal; |
| 120 | + } |
| 121 | + |
| 122 | + // Memcached: It isn't clear that this is needed yet, but since I already wrote the |
| 123 | + // code, I might as well leave it commented out instead of deleting it. |
| 124 | + // Main reason I've left this commented out is because it isn't obvious how to |
| 125 | + // purge the cache when necessary. |
| 126 | +// global $wgMemc; |
| 127 | +// $key = wfMemcKey( 'lqt-archive-start-days', $article ); |
| 128 | +// $cacheVal = $wgMemc->get( $key ); |
| 129 | +// if ($cacheVal != false) { |
| 130 | +// if ( $cacheVal != -1 ) { |
| 131 | +// return $cacheVal; |
| 132 | +// } else { |
| 133 | +// return $wgLqtThreadArchiveStartDays; |
| 134 | +// } |
| 135 | +// } |
| 136 | + |
| 137 | + // Load from the database. |
| 138 | + $dbr = wfGetDB( DB_SLAVE ); |
| 139 | + |
| 140 | + $dbVal = $dbr->selectField( 'page_props', 'pp_value', |
| 141 | + array( 'pp_propname' => 'use-liquid-threads', |
| 142 | + 'pp_page' => $article ), __METHOD__ ); |
| 143 | + |
| 144 | + if ($dbVal) { |
| 145 | + self::$userLQTActivated[$article] = true; |
| 146 | +# $wgMemc->set( $key, $dbVal, 1800 ); |
| 147 | + return true; |
| 148 | + } else { |
| 149 | + // Negative caching. |
| 150 | + self::$userLQTActivated[$article] = false; |
| 151 | +# $wgMemc->set( $key, -1, 86400 ); |
| 152 | + return false; |
| 153 | + } |
| 154 | + } |
| 155 | + |
105 | 156 | /** |
106 | 157 | * If the page we recieve is a Liquid Threads page of any kind, process it |
107 | 158 | * as needed and return True. If it's a normal, non-liquid page, return false. |
Index: trunk/extensions/LiquidThreads/classes/LqtParserFunctions.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class LqtParserFunctions { |
5 | | - static function archivestartdays( &$parser, $param1 ) { |
6 | | - $parser->mOutput->setProperty( 'lqt-archivestartdays', $param1 ); |
| 5 | + static function useLiquidThreads( &$parser ) { |
| 6 | + $parser->mOutput->setProperty( 'use-liquid-threads', 1 ); |
7 | 7 | } |
8 | 8 | } |
Index: trunk/extensions/LiquidThreads/classes/LqtThread.php |
— | — | @@ -886,22 +886,7 @@ |
887 | 887 | } |
888 | 888 | |
889 | 889 | } |
890 | | - |
891 | | - /** |
892 | | - * Tells you whether or not the thread is eligible for archival |
893 | | - * (includes a check as to whether or not the thread has already been archived. |
894 | | - */ |
895 | | - function isArchiveEligible( ) { |
896 | | - $startDays = $this->getArchiveStartDays(); |
897 | 890 | |
898 | | - $timestamp = wfTimestamp( TS_UNIX, $this->modified() ); |
899 | | - $archiveCutoff = time() - $startDays * 86400; |
900 | | - |
901 | | - return $timestamp < $archiveCutoff // X days must have elapsed |
902 | | - && !$this->hasSuperthread() // Must be a primary thread (i.e. not a reply) |
903 | | - && !$this->isHistorical(); // Can't have already been archived, obviously |
904 | | - } |
905 | | - |
906 | 891 | function getArchiveStartDays() { |
907 | 892 | return Threads::getArticleArchiveStartDays( $this->article() ); |
908 | 893 | } |