| Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
| — | — | @@ -23,7 +23,9 @@ |
| 24 | 24 | |
| 25 | 25 | if( !defined( 'FLAGGED_CSS' ) ) define('FLAGGED_CSS', $wgScriptPath.'/extensions/FlaggedRevs/flaggedrevs.css' ); |
| 26 | 26 | |
| 27 | | -$wgExtensionFunctions[] = 'efLoadReviewMessages'; |
| | 27 | +if( !function_exists( 'extAddSpecialPage' ) ) { |
| | 28 | + require( dirname(__FILE__) . '/../ExtensionFunctions.php' ); |
| | 29 | +} |
| 28 | 30 | |
| 29 | 31 | $wgExtensionCredits['other'][] = array( |
| 30 | 32 | 'author' => 'Aaron Schulz, Joerg Baach', |
| — | — | @@ -32,15 +34,25 @@ |
| 33 | 35 | 'description' => 'Gives editors/reviewers the ability to validate revisions and stabilize pages' |
| 34 | 36 | ); |
| 35 | 37 | |
| 36 | | -# Internationilization |
| | 38 | +$wgExtensionFunctions[] = 'efLoadReviewMessages'; |
| | 39 | + |
| | 40 | +# Load promotion UI |
| | 41 | +include_once('SpecialMakevalidate.php'); |
| | 42 | +# Load review UI |
| | 43 | +extAddSpecialPage( dirname(__FILE__) . '/FlaggedRevsPage.body.php', 'Revisionreview', 'Revisionreview' ); |
| | 44 | +# Load stableversions UI |
| | 45 | +extAddSpecialPage( dirname(__FILE__) . '/FlaggedRevsPage.body.php', 'Stableversions', 'Stableversions' ); |
| | 46 | +# Load unreviewed pages list |
| | 47 | +extAddSpecialPage( dirname(__FILE__) . '/FlaggedRevsPage.body.php', 'Unreviewedpages', 'UnreviewedPages' ); |
| | 48 | + |
| 37 | 49 | function efLoadReviewMessages() { |
| 38 | 50 | global $wgMessageCache, $RevisionreviewMessages, $wgOut; |
| | 51 | + # Internationalization |
| 39 | 52 | require( dirname( __FILE__ ) . '/FlaggedRevsPage.i18n.php' ); |
| 40 | | - |
| 41 | 53 | foreach ( $RevisionreviewMessages as $lang => $langMessages ) { |
| 42 | 54 | $wgMessageCache->addMessages( $langMessages, $lang ); |
| 43 | 55 | } |
| 44 | | - # Set the CSS |
| | 56 | + # UI CSS |
| 45 | 57 | $wgOut->addLink( array( |
| 46 | 58 | 'rel' => 'stylesheet', |
| 47 | 59 | 'type' => 'text/css', |
| — | — | @@ -963,18 +975,6 @@ |
| 964 | 976 | |
| 965 | 977 | } |
| 966 | 978 | |
| 967 | | -# Load promotion UI |
| 968 | | -include_once('SpecialMakevalidate.php'); |
| 969 | | - |
| 970 | | -if( !function_exists( 'extAddSpecialPage' ) ) { |
| 971 | | - require( dirname(__FILE__) . '/../ExtensionFunctions.php' ); |
| 972 | | -} |
| 973 | | -extAddSpecialPage( dirname(__FILE__) . '/FlaggedRevsPage.body.php', 'Revisionreview', 'Revisionreview' ); |
| 974 | | -extAddSpecialPage( dirname(__FILE__) . '/FlaggedRevsPage.body.php', 'Stableversions', 'Stableversions' ); |
| 975 | | - |
| 976 | | -# Load approve/unapprove UI |
| 977 | | -$wgHooks['LoadAllMessages'][] = 'efLoadReviewMessages'; |
| 978 | | - |
| 979 | 979 | $flaggedrevs = new FlaggedRevs(); |
| 980 | 980 | $flaggedarticle = new FlaggedArticle(); |
| 981 | 981 | $wgHooks['BeforePageDisplay'][] = array($flaggedarticle, 'setPageContent'); |
| Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.body.php |
| — | — | @@ -511,7 +511,7 @@ |
| 512 | 512 | $time = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->rev_timestamp), true ); |
| 513 | 513 | $ftime = $wgLang->timeanddate( wfTimestamp(TS_MW, $row->fr_timestamp), true ); |
| 514 | 514 | $review = wfMsg( 'stableversions-review', $ftime ); |
| 515 | | - return '<li>'.$skin->makeKnownLinkObj( $special, $time, 'oldid='.$row->fr_rev_id ).' ('.$review.')'.'</li>'; |
| | 515 | + return '<li>'.$skin->makeKnownLinkObj( $special, $time, 'oldid='.$row->fr_rev_id ).' ('.$review.') '.'</li>'; |
| 516 | 516 | } |
| 517 | 517 | } |
| 518 | 518 | |
| — | — | @@ -537,8 +537,8 @@ |
| 538 | 538 | function getQueryInfo() { |
| 539 | 539 | $conds = $this->mConds; |
| 540 | 540 | $conds[] = "fr_page_id = $this->page_id"; |
| 541 | | - $conds[] = 'fr_rev_id = rev_id'; |
| 542 | | - $conds[] = 'rev_deleted = 0'; |
| | 541 | + $conds[] = "fr_rev_id = rev_id"; |
| | 542 | + $conds[] = "rev_deleted = 0"; |
| 543 | 543 | return array( |
| 544 | 544 | 'tables' => array('flaggedrevs','revision'), |
| 545 | 545 | 'fields' => 'fr_rev_id,fr_timestamp,rev_timestamp', |
| — | — | @@ -550,4 +550,145 @@ |
| 551 | 551 | return 'fr_rev_id'; |
| 552 | 552 | } |
| 553 | 553 | } |
| | 554 | + |
| | 555 | +class Unreviewedpages extends SpecialPage |
| | 556 | +{ |
| | 557 | + |
| | 558 | + function Unreviewedpages() { |
| | 559 | + SpecialPage::SpecialPage('Unreviewedpages'); |
| | 560 | + } |
| | 561 | + |
| | 562 | + function execute( $par ) { |
| | 563 | + global $wgRequest; |
| | 564 | + |
| | 565 | + $this->setHeaders(); |
| | 566 | + |
| | 567 | + $this->showList( $wgRequest ); |
| | 568 | + } |
| | 569 | + |
| | 570 | + function showList( $wgRequest ) { |
| | 571 | + global $wgOut, $wgUser, $wgScript, $wgTitle; |
| | 572 | + |
| | 573 | + $skin = $wgUser->getSkin(); |
| | 574 | + $namespace = $wgRequest->getIntOrNull( 'namespace' ); |
| | 575 | + $nonquality = $wgRequest->getVal( 'includenonquality' ); |
| | 576 | + |
| | 577 | + $action = htmlspecialchars( $wgScript ); |
| | 578 | + $wgOut->addHTML( "<form action=\"$action\" method=\"get\">\n" . |
| | 579 | + '<fieldset><legend>' . wfMsg('viewunreviewed') . '</legend>' . |
| | 580 | + $this->getNamespaceMenu( $namespace ) . "\n" . |
| | 581 | + Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" . |
| | 582 | + '<p>' . Xml::check( 'includenonquality', $nonquality, array('id' => 'includenonquality') ) . |
| | 583 | + ' ' . Xml::label( wfMsgHtml("included-nonquality"), 'includenonquality' ) . "</p>\n" . |
| | 584 | + Xml::hidden( 'title', $wgTitle->getPrefixedText() ) . |
| | 585 | + "</fieldset></form>"); |
| | 586 | + |
| | 587 | + list( $limit, $offset ) = wfCheckLimits(); |
| | 588 | + |
| | 589 | + $sdr = new UnreviewedPagesPage( $namespace, $nonquality ); |
| | 590 | + $sdr->doQuery( $offset, $limit ); |
| | 591 | + } |
| | 592 | + |
| | 593 | + function getNamespaceMenu( $selected=NULL, $allnamespaces = null, $includehidden=false ) { |
| | 594 | + global $wgContLang, $wgContentNamespaces; |
| | 595 | + |
| | 596 | + $selector = "<label for='namespace'>" . wfMsgHtml('namespace') . "</label>"; |
| | 597 | + if( $selected !== '' ) { |
| | 598 | + if( is_null( $selected ) ) { |
| | 599 | + // No namespace selected; let exact match work without hitting Main |
| | 600 | + $selected = ''; |
| | 601 | + } else { |
| | 602 | + // Let input be numeric strings without breaking the empty match. |
| | 603 | + $selected = intval( $selected ); |
| | 604 | + } |
| | 605 | + } |
| | 606 | + $s = "\n<select id='namespace' name='namespace' class='namespaceselector'>\n"; |
| | 607 | + $arr = $wgContLang->getFormattedNamespaces(); |
| | 608 | + if( !is_null($allnamespaces) ) { |
| | 609 | + $arr = array($allnamespaces => wfMsg('namespacesall')) + $arr; |
| | 610 | + } |
| | 611 | + foreach ($arr as $index => $name) { |
| | 612 | + # Content only |
| | 613 | + if ($index < NS_MAIN || !isset($wgContentNamespaces[$index]) ) continue; |
| | 614 | + |
| | 615 | + $name = $index !== 0 ? $name : wfMsg('blanknamespace'); |
| | 616 | + |
| | 617 | + if ($index === $selected) { |
| | 618 | + $s .= "\t" . Xml::element("option", |
| | 619 | + array("value" => $index, "selected" => "selected"), |
| | 620 | + $name) . "\n"; |
| | 621 | + } else { |
| | 622 | + $s .= "\t" . Xml::element("option", array("value" => $index), $name) . "\n"; |
| | 623 | + } |
| | 624 | + } |
| | 625 | + $s .= "</select>\n"; |
| | 626 | + return $s; |
| | 627 | + } |
| | 628 | +} |
| | 629 | + |
| | 630 | +class UnreviewedPagesPage extends PageQueryPage { |
| | 631 | + |
| | 632 | + function __construct( $namespace=NULL, $nonquality=false ) { |
| | 633 | + $this->namespace = $namespace; |
| | 634 | + $this->nonquality = $nonquality; |
| | 635 | + } |
| | 636 | + |
| | 637 | + function getName() { |
| | 638 | + return 'UnreviewedPages'; |
| | 639 | + } |
| | 640 | + |
| | 641 | + function isExpensive( ) { return true; } |
| | 642 | + function isSyndicated() { return false; } |
| | 643 | + |
| | 644 | + function getPageHeader( ) { |
| | 645 | + #FIXME : probably need to add a backlink to the maintenance page. |
| | 646 | + return '<p>'.wfMsg("unreviewed-list")."</p><br />\n"; |
| | 647 | + } |
| | 648 | + |
| | 649 | + function getSQLText( &$dbr, $namespace, $nonquality = false ) { |
| | 650 | + global $wgContentNamespaces; |
| | 651 | + |
| | 652 | + list( $page, $flaggedpages ) = $dbr->tableNamesN( 'page', 'flaggedpages' ); |
| | 653 | + |
| | 654 | + $ns = ($namespace !== null) ? "page_namespace=$namespace" : '1 = 1'; |
| | 655 | + $where = $nonquality ? 'fp_latest IS NULL OR fp_latest=0' : 'fp_latest_q IS NULL OR fp_latest_q=0'; |
| | 656 | + $content = array(); |
| | 657 | + foreach( $wgContentNamespaces as $cns ) { |
| | 658 | + $content[] = "page_namespace=$cns"; |
| | 659 | + } |
| | 660 | + $content = implode(' OR ',$content); |
| | 661 | + $sql = |
| | 662 | + "SELECT page_namespace AS namespace,page_title AS title,page_len AS size |
| | 663 | + FROM $page |
| | 664 | + LEFT JOIN $flaggedpages ON page_id = fp_page_id |
| | 665 | + WHERE page_is_redirect=0 AND $ns AND ($where) AND ($content) "; |
| | 666 | + return $sql; |
| | 667 | + } |
| | 668 | + |
| | 669 | + function getSQL() { |
| | 670 | + $dbr = wfGetDB( DB_SLAVE ); |
| | 671 | + return $this->getSQLText( $dbr, $this->namespace, $this->nonquality ); |
| | 672 | + } |
| | 673 | + |
| | 674 | + function getOrder() { |
| | 675 | + return 'ORDER BY page_id DESC'; |
| | 676 | + } |
| | 677 | + |
| | 678 | + function formatResult( $skin, $result ) { |
| | 679 | + global $wgLang; |
| | 680 | + |
| | 681 | + $fname = 'UnreviewedPagesPage::formatResult'; |
| | 682 | + $title = Title::makeTitle( $result->namespace, $result->title ); |
| | 683 | + $link = $skin->makeKnownLinkObj( $title ); |
| | 684 | + $stxt = ''; |
| | 685 | + if (!is_null($size = $result->size)) { |
| | 686 | + if ($size == 0) |
| | 687 | + $stxt = ' <small>' . wfMsgHtml('historyempty') . '</small>'; |
| | 688 | + else |
| | 689 | + $stxt = ' <small>' . wfMsgHtml('historysize', $wgLang->formatNum( $size ) ) . '</small>'; |
| | 690 | + } |
| | 691 | + |
| | 692 | + return( "{$link} {$stxt}" ); |
| | 693 | + } |
| | 694 | +} |
| 554 | 695 | ?> |
| Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php |
| — | — | @@ -85,7 +85,14 @@ |
| 86 | 86 | 'stableversions-none' => '[[$1]] has no reviewed revisions.', |
| 87 | 87 | 'stableversions-list' => 'The following is a list of revisions of [[$1]] that have been reviewed:', |
| 88 | 88 | 'stableversions-review' => 'Reviewed on <i>$1</i>', |
| | 89 | + 'stableversions-quality' => '[Latest quality revision]', |
| 89 | 90 | 'review-diff2stable' => 'Diff to the last stable revision', |
| 90 | 91 | 'review-diff2oldest' => "Diff to the oldest revision", |
| | 92 | + |
| | 93 | + |
| | 94 | + 'unreviewedpages' => 'Unreviewed pages', |
| | 95 | + 'viewunreviewed' => 'List unreviewed content pages', |
| | 96 | + 'included-nonquality' => 'Include reviewed pages not marked as quality.', |
| | 97 | + 'unreviewed-list' => 'This page lists articles that have not yet been reviewed.', |
| 91 | 98 | ); |
| 92 | 99 | ?> |