r26239 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r26238‎ | r26239 | r26240 >
Date:06:26, 29 September 2007
Author:david
Status:old
Tags:
Comment:
Paged thread history -- not thoroughly tested as yet, but seems to work.
Modified paths:
  • /branches/liquidthreads/extensions/LqtBaseView.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtPages.php (modified) (history)
  • /branches/liquidthreads/skins/monobook/main.css (modified) (history)

Diff [purge]

Index: branches/liquidthreads/skins/monobook/main.css
@@ -50,7 +50,11 @@
5151 background-color: #f0f0e3;
5252 }
5353
54 -.lqt_disabled_link {
 54+.lqt_newer_older {
 55+ margin-right: 1em;
 56+}
 57+.lqt_newer_older_disabled {
 58+ margin-right: 1em;
5559 color: #999;
5660 }
5761
Index: branches/liquidthreads/extensions/LqtPages.php
@@ -237,24 +237,6 @@
238238 $result .= "</select>";
239239 return $result;
240240 }
241 -
242 - /**
243 - * Return a URL for the current page, including Title and query vars,
244 - * with the given replacements made.
245 - * @param $repls array( 'name'=>new_value, ... )
246 - */
247 - function queryReplace( $repls ) {
248 - $vs = $this->request->getValues();
249 - $rs = array();
250 - foreach ($vs as $k => $v) {
251 - if ( array_key_exists( $k, $repls ) ) {
252 - $rs[$k] = $repls[$k];
253 - } else {
254 - $rs[$k] = $vs[$k];
255 - }
256 - }
257 - return $this->title->getFullURL(self::queryStringFromArray($rs));
258 - }
259241
260242 function clip( $vals, $min, $max ) {
261243 $res = array();
@@ -289,20 +271,20 @@
290272 $this->clip( array($oatte, $oatts, $natts, $natte),
291273 0, count($months)-1 );
292274
293 - $older = '<a href="' . $this->queryReplace(array(
 275+ $older = '<a class="lqt_newer_older" href="' . $this->queryReplace(array(
294276 'lqt_archive_filter_by_date'=>'1',
295277 'lqt_archive_start' => $months[$os],
296278 'lqt_archive_end' => $months[$oe]))
297279 . '">«older</a>';
298 - $newer = '<a href="' . $this->queryReplace(array(
 280+ $newer = '<a class="lqt_newer_older" href="' . $this->queryReplace(array(
299281 'lqt_archive_filter_by_date'=>'1',
300282 'lqt_archive_start' => $months[$ns],
301283 'lqt_archive_end' => $months[$ne]))
302284 . '">newer»</a>';
303285 }
304286 else {
305 - $older = '<span class="lqt_disabled_link" title="This link is disabled because you are viewing threads from all dates.">«older</span>';
306 - $newer = '<span class="lqt_disabled_link" title="This link is disabled because you are viewing threads from all dates.">newer»</span>';
 287+ $older = '<span class="lqt_newer_older_disabled" title="This link is disabled because you are viewing threads from all dates.">«older</span>';
 288+ $newer = '<span class="lqt_newer_older_disabled" title="This link is disabled because you are viewing threads from all dates.">newer»</span>';
307289 }
308290
309291 $this->output->addHTML(<<<HTML
@@ -565,14 +547,50 @@
566548 }
567549
568550 function showHistoryListing($t) {
569 - $revisions = new ThreadHistoryIterator($t, 10, 0);
 551+ $revisions = new ThreadHistoryIterator($t, $this->perPage, $this->perPage * ($this->page - 1));
 552+
570553 $this->output->addHTML('<table>');
571554 foreach($revisions as $ht) {
572555 $this->output->addHTML($this->rowForThread($ht));
573556 }
574557 $this->output->addHTML('</table>');
 558+
 559+
 560+ if ( count($revisions) == 0 && $this->page == 1 ) {
 561+ $this->output->addHTML('<p>This thread doesn\'t have any history revisions. That\'s pretty weird.');
 562+ }
 563+ else if ( count($revisions) == 0 ) {
 564+ // we could redirect to the previous page... yow.
 565+ $this->output->addHTML('<p>You are beyond the number of pages of history that exist.');
 566+ }
 567+
 568+ if( $this->page > 1 ) {
 569+ $this->output->addHTML( '<a class="lqt_newer_older" href="' . $this->queryReplace(array('lqt_hist_page'=>$this->page - 1)) . '">«newer</a>' );
 570+ } else {
 571+ $this->output->addHTML( '<span class="lqt_newer_older_disabled" title="This link is disabled because you are on the first page.">«newer</span>' );
 572+ }
 573+
 574+ $is_last_page = false;
 575+ foreach($revisions as $r)
 576+ if( $r->changeType() == Threads::CHANGE_NEW_THREAD )
 577+ $is_last_page = true;
 578+ if( $is_last_page ) {
 579+ $this->output->addHTML( '<span class="lqt_newer_older_disabled" title="This link is disabled because you are on the last page.">older»</span>' );
 580+ } else {
 581+ $this->output->addHTML( '<a class="lqt_newer_older" href="' . $this->queryReplace(array('lqt_hist_page'=>$this->page + 1)) . '">older»</a>' );
 582+ }
575583 }
 584+
 585+ function __construct(&$output, &$article, &$title, &$user, &$request) {
 586+ parent::__construct($output, $article, $title, $user, $request);
 587+ $this->loadParametersFromRequest();
 588+ }
576589
 590+ function loadParametersFromRequest() {
 591+ $this->perPage = $this->request->getInt('lqt_hist_per_page', 10);
 592+ $this->page = $this->request->getInt('lqt_hist_page', 1);
 593+ }
 594+
577595 function show() {
578596 global $wgHooks;
579597 $wgHooks['SkinTemplateTabs'][] = array($this, 'customizeTabs');
Index: branches/liquidthreads/extensions/LqtBaseView.php
@@ -231,6 +231,25 @@
232232 $query = $operand ? "$query&lqt_operand={$operand->id()}" : $query;
233233 return $title->getFullURL( $query ) . ($operand && $includeFragment ? "#lqt_thread_{$operand->id()}" : "");
234234 }
 235+
 236+
 237+ /**
 238+ * Return a URL for the current page, including Title and query vars,
 239+ * with the given replacements made.
 240+ * @param $repls array( 'name'=>new_value, ... )
 241+ */
 242+ function queryReplace( $repls ) {
 243+ $vs = $this->request->getValues();
 244+ $rs = array();
 245+ foreach ($vs as $k => $v) {
 246+ if ( array_key_exists( $k, $repls ) ) {
 247+ $rs[$k] = $repls[$k];
 248+ } else {
 249+ $rs[$k] = $vs[$k];
 250+ }
 251+ }
 252+ return $this->title->getFullURL(self::queryStringFromArray($rs));
 253+ }
235254
236255 /*************************************************************
237256 * Editing methods (here be dragons) *

Status & tagging log