* (bug 10636) Update Thai translation
[lhc/web/wiklou.git] / includes / SpecialLog.php
index 3c9d096..0ed417c 100644 (file)
@@ -74,7 +74,8 @@ class LogReader {
                
                // XXX This all needs to use Pager, ugly hack for now.
                global $wgMiserMode;
-               if ($wgMiserMode && ($this->offset >10000)) $this->offset=10000;
+               if( $wgMiserMode )
+                       $this->offset = min( $this->offset, 10000 );
        }
 
        /**
@@ -123,9 +124,10 @@ class LogReader {
        function limitTitle( $page , $pattern ) {
                global $wgMiserMode;
                $title = Title::newFromText( $page );
-               if( empty( $page ) || is_null( $title )  ) {
+               
+               if( strlen( $page ) == 0 || !$title instanceof Title )
                        return false;
-               }
+
                $this->title =& $title;
                $this->pattern = $pattern;
                $ns = $title->getNamespace();
@@ -215,6 +217,23 @@ class LogReader {
                        return $this->title->getPrefixedText();
                }
        }
+       
+       /**
+        * Is there at least one row?
+        *
+        * @return bool
+        */
+       public function hasRows() {
+               # Little hack...
+               $limit = $this->limit;
+               $this->limit = 1;
+               $res = $this->db->query( $this->getQuery() );
+               $this->limit = $limit;
+               $ret = $this->db->numRows( $res ) > 0;
+               $this->db->freeResult( $res );
+               return $ret;
+       }
+       
 }
 
 /**
@@ -366,15 +385,18 @@ class LogViewer {
                                wfMsg( 'unblocklink' ),
                                'action=unblock&ip=' . urlencode( $s->log_title ) ) . ')';
                // show change protection link
-               } elseif ( $s->log_action == 'protect' && $wgUser->isAllowed( 'protect' ) ) {
-                       $revert = '(' .  $skin->makeKnownLink( $title->getPrefixedDBkey() ,
-                               wfMsg( 'protect_change' ),
-                               'action=unprotect' ) . ')';
+               } elseif ( ( $s->log_action == 'protect' || $s->log_action == 'modify' ) && $wgUser->isAllowed( 'protect' ) ) {
+                       $revert = '(' .  $skin->makeKnownLinkObj( $title, wfMsg( 'protect_change' ), 'action=unprotect' ) . ')';
                // show user tool links for self created users
+               // TODO: The extension should be handling this, get it out of core!
                } elseif ( $s->log_action == 'create2' ) {
-                       $revert = $this->skin->userToolLinksRedContribs( $s->log_user, $s->log_title );
-                       // do not show $comment for self created accounts. It includes wrong user tool links:
-                       // 'blockip' for users w/o block allowance and broken links for very long usernames (bug 4756)
+                       if( isset( $paramArray[0] ) ) {
+                               $revert = $this->skin->userToolLinks( $paramArray[0], $s->log_title, true );
+                       } else {
+                               # Fall back to a blue contributions link
+                               $revert = $this->skin->userToolLinks( 1, $s->log_title );
+                       }
+                       # Suppress $comment from old entries, not needed and can contain incorrect links
                        $comment = '';
                }
 
@@ -497,4 +519,4 @@ class LogViewer {
 }
 
 
-?>
+