Index: trunk/extensions/Wikilog/WikilogDefaultSettings.php |
— | — | @@ -55,7 +55,7 @@ |
56 | 56 | * Wikilog style version, incremented when $wgWikilogStylePath/wikilog.css |
57 | 57 | * is changed. |
58 | 58 | */ |
59 | | -$wgWikilogStyleVersion = 4; |
| 59 | +$wgWikilogStyleVersion = 5; |
60 | 60 | |
61 | 61 | /* *** Presentation options *** */ |
62 | 62 | |
Index: trunk/extensions/Wikilog/Wikilog.php |
— | — | @@ -64,6 +64,7 @@ |
65 | 65 | 'WikilogItemQuery' => $dir . 'WikilogQuery.php', |
66 | 66 | 'WikilogLinksUpdate' => $dir . 'WikilogLinksUpdate.php', |
67 | 67 | 'WikilogUtils' => $dir . 'WikilogUtils.php', |
| 68 | + 'WikilogNavbar' => $dir . 'WikilogNavbar.php', |
68 | 69 | 'SpecialWikilog' => $dir . 'SpecialWikilog.php', |
69 | 70 | |
70 | 71 | // Objects |
Index: trunk/extensions/Wikilog/style/wikilog.css |
— | — | @@ -38,6 +38,42 @@ |
39 | 39 | padding: 0.25em 0.75em; |
40 | 40 | } |
41 | 41 | |
| 42 | +.wl-pagination { |
| 43 | + text-align: center; |
| 44 | +} |
| 45 | + |
| 46 | +.wl-pagination a, |
| 47 | +.wl-pagination span.current, |
| 48 | +.wl-pagination span.disabled { |
| 49 | + margin: 0 1pt; |
| 50 | + padding: 1pt 3pt; |
| 51 | + font-weight: bold; |
| 52 | + text-decoration: none; |
| 53 | + -moz-border-radius: 5px; |
| 54 | + -webkit-border-radius: 5px; |
| 55 | +} |
| 56 | + |
| 57 | +.wl-pagination a { |
| 58 | +/* border: 1px solid #CCCCCC; */ |
| 59 | + color: #0066CC; |
| 60 | +} |
| 61 | + |
| 62 | +.wl-pagination a:hover, .wl-pagination a:active { |
| 63 | +/* border: 1px solid #000; */ |
| 64 | + background-color: #0066CC; |
| 65 | + color: #EEEEEE; |
| 66 | +} |
| 67 | + |
| 68 | +.wl-pagination span.disabled { |
| 69 | + color: #CCCCCC; |
| 70 | +} |
| 71 | + |
| 72 | +.wl-pagination span.current { |
| 73 | + font-weight: bolder; |
| 74 | + background-color: #CCCCCC; |
| 75 | + color: black; |
| 76 | +} |
| 77 | + |
42 | 78 | .TablePager_col_wlp_num_comments { |
43 | 79 | text-align: center; |
44 | 80 | } |
Index: trunk/extensions/Wikilog/WikilogUtils.php |
— | — | @@ -374,3 +374,86 @@ |
375 | 375 | return array( 'date' => $date, 'user' => $user ); |
376 | 376 | } |
377 | 377 | } |
| 378 | + |
| 379 | +/** |
| 380 | + * Generates a more user-friendly navigation bar for use in article and |
| 381 | + * comment pagers (shared between WikilogPager and WikilogCommentPager). |
| 382 | + */ |
| 383 | +class WikilogNavbar |
| 384 | +{ |
| 385 | + static $pagingLabels = array( |
| 386 | + 'prev' => "‹ $1", |
| 387 | + 'next' => "$1 ›", |
| 388 | + 'first' => "« $1", |
| 389 | + 'last' => "$1 »" |
| 390 | + ); |
| 391 | + static $linkTextMsgs = array( |
| 392 | + 'pages' => array( |
| 393 | + 'prev' => 'prevn', |
| 394 | + 'next' => 'nextn', |
| 395 | + 'first' => 'page_first', |
| 396 | + 'last' => 'page_last' |
| 397 | + ), |
| 398 | + 'chrono-fwd' => array( |
| 399 | + 'prev' => 'pager-older-n', |
| 400 | + 'next' => 'pager-newer-n', |
| 401 | + 'first' => 'histfirst', |
| 402 | + 'last' => 'histlast' |
| 403 | + ), |
| 404 | + 'chrono-rev' => array( |
| 405 | + 'prev' => 'pager-newer-n', |
| 406 | + 'next' => 'pager-older-n', |
| 407 | + 'first' => 'histlast', |
| 408 | + 'last' => 'histfirst' |
| 409 | + ), |
| 410 | + ); |
| 411 | + |
| 412 | + protected $mPager, $mType; |
| 413 | + |
| 414 | + /** |
| 415 | + * Constructor. |
| 416 | + * @param $pager IndexPager Pager object. |
| 417 | + * @param $type string Type of navigation bar to generate: |
| 418 | + * * 'pages': For normal pages, with 'first', 'last', 'previous', 'next'; |
| 419 | + * * 'chrono-fwd': For chronological events, in forward order (later |
| 420 | + * pages contain newer events); |
| 421 | + * * 'chrono-rev': For chronological events, in reverse order (later |
| 422 | + * pages contain older events). |
| 423 | + */ |
| 424 | + function __construct( IndexPager $pager, $type = 'pages' ) { |
| 425 | + $this->mPager = $pager; |
| 426 | + $this->mType = $type; |
| 427 | + } |
| 428 | + |
| 429 | + /** |
| 430 | + * Format and return the navigation bar. |
| 431 | + * @param $limit integer Number of itens being displayed. |
| 432 | + * @return string HTML-formatted navigation bar. |
| 433 | + */ |
| 434 | + public function getNavigationBar( $limit ) { |
| 435 | + global $wgLang; |
| 436 | + |
| 437 | + $limit = $wgLang->formatNum( $limit ); |
| 438 | + $opts = array( 'parsemag', 'escapenoentities' ); |
| 439 | + $linkTexts = $disabledTexts = array(); |
| 440 | + foreach ( self::$linkTextMsgs[$this->mType] as $type => $msg ) { |
| 441 | + $label = wfMsgExt( $msg, $opts, $limit ); |
| 442 | + $linkTexts[$type] = wfMsgReplaceArgs( self::$pagingLabels[$type], array( $label ) ); |
| 443 | + $disabledTexts[$type] = Xml::wrapClass( $linkTexts[$type], 'disabled' ); |
| 444 | + } |
| 445 | + |
| 446 | + $pagingLinks = $this->mPager->getPagingLinks( $linkTexts, $disabledTexts ); |
| 447 | +// $limitLinks = $this->mPager->getLimitLinks(); // XXX: Not used yet. |
| 448 | + $ellipsis = wfMsg( 'ellipsis' ); |
| 449 | + $html = "{$pagingLinks['first']} {$pagingLinks['prev']} {$ellipsis} {$pagingLinks['next']} {$pagingLinks['last']}"; |
| 450 | + $html = WikilogUtils::wrapDiv( 'wl-pagination', $html ); |
| 451 | + return Xml::tags( 'div', |
| 452 | + array( |
| 453 | + 'class' => 'wl-navbar', |
| 454 | + 'dir' => $wgLang->getDir() |
| 455 | + ), |
| 456 | + $html |
| 457 | + ); |
| 458 | + } |
| 459 | + |
| 460 | +} |