bugfix: if the upload path is absolute, don't prepend the server URL
[lhc/web/wiklou.git] / includes / SpecialContributions.php
index 8e9eced..1750b4d 100644 (file)
  * @return     none
  * @param      string  $par    (optional) user name of the user for which to show the contributions
  */
-function wfSpecialContributions( $par = '' ) {
+function wfSpecialContributions( $par = null ) {
        global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest;
        $fname = 'wfSpecialContributions';
 
        // GET values
-       $target = $par ? $par : $wgRequest->getVal( 'target' );
-       $namespace = $wgRequest->getInt( 'namespace', '' );
-       $namespace = ($namespace == '') ? NULL : $namespace;
+       $target = isset($par) ? $par : $wgRequest->getVal( 'target' );
+       $namespace = $wgRequest->getVal( 'namespace', '' );
+       $namespace = $namespace === '' ? NULL : $namespace;
        $invert = $wgRequest->getBool( 'invert' );
        $hideminor = ($wgRequest->getBool( 'hideminor' ) ? true : false);
        
@@ -29,8 +29,7 @@ function wfSpecialContributions( $par = '' ) {
 
        # FIXME: Change from numeric offsets to date offsets
        list( $limit, $offset ) = wfCheckLimits( 50, '' );
-       $offlimit = $limit + $offset;
-       $querylimit = $offlimit + 1;
+       $querylimit = $limit + 1;
        $sk = $wgUser->getSkin();
        $dbr =& wfGetDB( DB_SLAVE );
        $userCond = "";
@@ -99,11 +98,11 @@ function wfSpecialContributions( $par = '' ) {
                rev_deleted
                FROM $page,$revision $use_index
                WHERE page_id=rev_page AND $condition $minorQuery " .
-         "ORDER BY rev_timestamp DESC LIMIT {$querylimit}";
+         "ORDER BY rev_timestamp DESC " . $dbr->limitResult( $querylimit, $offset );
        $res = $dbr->query( $sql, $fname );
        $numRows = $dbr->numRows( $res );
 
-       $wgOut->addHTML( namespaceForm( $target, $hideminor, $namespace, $invert ) );
+       $wgOut->addHTML( ucNamespaceForm( $target, $hideminor, $namespace, $invert ) );
 
        $top = wfShowingResults( $offset, $limit );
        $wgOut->addHTML( "<p>{$top}\n" );
@@ -111,7 +110,7 @@ function wfSpecialContributions( $par = '' ) {
        $sl = wfViewPrevNext( $offset, $limit,
          $wgContLang->specialpage( "Contributions" ),
          "hideminor={$hideminor}&namespace={$namespace}&target=" . wfUrlEncode( $target ),
-         ($numRows) <= $offlimit);
+         ($numRows) <= $limit);
 
        $shm = wfMsg( "showhideminor", $mlink );
        $wgOut->addHTML( "<br />{$sl} ($shm)</p>\n");
@@ -123,9 +122,15 @@ function wfSpecialContributions( $par = '' ) {
        }
 
        $wgOut->addHTML( "<ul>\n" );
+       $n = 0;
        while( $obj = $dbr->fetchObject( $res ) ) {
+               if( ++$n > $limit ) {
+                       // Extra row for determining 'next'ability, don't display
+                       break;
+               }
                $wgOut->addHTML( ucListEdit( $sk, $obj ) );
        }
+       $dbr->freeResult( $res );
        $wgOut->addHTML( "</ul>\n" );
 
        $wgOut->addHTML( "<br />{$sl} ($shm)\n");
@@ -216,31 +221,33 @@ function ucListEdit( $sk, $row ) {
  * @param      string  $namespace currently selected namespace, NULL for show all
  * @param      bool    $invert  inverts the namespace selection on true (default null)
  */
-function namespaceForm ( $target, $hideminor, $namespace, $invert ) {
+function ucNamespaceForm ( $target, $hideminor, $namespace, $invert ) {
        global $wgContLang, $wgScript;
 
-       $namespaceselect = '<select name="namespace">';
+       $namespaceselect = "<select name='namespace' id='nsselectbox'>";
        $namespaceselect .= '<option value="" '.(is_null($namespace) ? ' selected="selected"' : '').'>'.wfMsg( 'contributionsall' ).'</option>';
-       $arr = $wgContLang->getNamespaces();
-       foreach( array_keys( $arr ) as $i ) {
-               if( $i < 0 ) {
+       $arr = $wgContLang->getFormattedNamespaces();
+       foreach( $arr as $ns => $name ) {
+               if( $ns < NS_MAIN )
                        continue;
-               }
-               $namespacename = str_replace ( '_', ' ', $arr[$i] );
-               $n = ($i == 0) ? wfMsg ( 'blanknamespace' ) : $namespacename;
-               $sel = ($i === $namespace) ? ' selected="selected"' : '';
-               $namespaceselect .= "<option value='{$i}'{$sel}>{$n}</option>";
+               $n = $ns === NS_MAIN ? wfMsg ( 'blanknamespace' ) : $name;
+               $sel = $namespace == $ns ? ' selected="selected"' : '';
+               $namespaceselect .= "<option value='$ns'$sel>$n</option>";
        }
        $namespaceselect .= '</select>';
 
-       $submitbutton = '<input type="submit" value="' . wfMsg( 'allpagessubmit' ) . '" />';
-       $invertbox = "<input type='checkbox' name='invert' value='1'" . ( $invert ? ' checked="checked"' : '' ) . ' />';
-
        $out = "<div class='namespaceselector'><form method='get' action='{$wgScript}'>";
        $out .= '<input type="hidden" name="title" value="'.$wgContLang->specialpage( 'Contributions' ).'" />';
        $out .= '<input type="hidden" name="target" value="'.htmlspecialchars( $target ).'" />';
        $out .= '<input type="hidden" name="hideminor" value="'.$hideminor.'" />';      
-       $out .= wfMsg ( 'contributionsformtext', $namespaceselect, $submitbutton, $invertbox );
+       $out .= "
+<div id='nsselect' class='contributions'>
+       <label for='nsselectbox'>" . wfMsg('namespace') . "</label>
+       $namespaceselect
+       <input type='submit' value='" . wfMsg( 'allpagessubmit' ) . "' />
+       <input type='checkbox' name='invert' value='1' id='nsinvert'" . ( $invert ? ' checked="checked"' : '' ) . " />
+       <label for='nsinvert'>" . wfMsg('invert') . "</label>
+</div>";
        $out .= '</form></div>';
        return $out;
 }