* (bug 10181) Support the XCache object caching mechanism [patch from Kurt Radwanski]
[lhc/web/wiklou.git] / includes / SpecialLog.php
index 021a620..2fcce66 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 );
        }
 
        /**
@@ -131,10 +132,10 @@ class LogReader {
                $ns = $title->getNamespace();
                if ( $pattern && !$wgMiserMode ) {
                        $safetitle = $this->db->escapeLike( $title->getDBkey() ); // use escapeLike to avoid expensive search patterns like 't%st%'
-                       $this->whereClauses[] = "log_namespace=".$ns." AND log_title LIKE '$safetitle%'";
+                       $this->whereClauses[] = "log_namespace=$ns AND log_title LIKE '$safetitle%'";
                } else {
                        $safetitle = $this->db->strencode( $title->getDBkey() );
-                       $this->whereClauses[] = "log_namespace=".$ns." AND log_title = '$safetitle'";
+                       $this->whereClauses[] = "log_namespace=$ns AND log_title = '$safetitle'";
                }
        }
 
@@ -215,6 +216,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;
+       }
+       
 }
 
 /**
@@ -347,12 +365,12 @@ class LogViewer {
                if ( $s->log_type == 'move' && isset( $paramArray[0] ) ) {
                        $destTitle = Title::newFromText( $paramArray[0] );
                        if ( $destTitle ) {
-                               $reviewlink = $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Movepage' ),
+                               $revert = '(' . $this->skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Movepage' ),
                                        wfMsg( 'revertmove' ),
                                        'wpOldTitle=' . urlencode( $destTitle->getPrefixedDBkey() ) .
                                        '&wpNewTitle=' . urlencode( $title->getPrefixedDBkey() ) .
                                        '&wpReason=' . urlencode( wfMsgForContent( 'revertmove' ) ) .
-                                       '&wpMovetalk=0' );
+                                       '&wpMovetalk=0' ) . ')';
                        }
                // show undelete link
                } elseif ( $s->log_action == 'delete' && $wgUser->isAllowed( 'delete' ) ) {
@@ -401,28 +419,19 @@ class LogViewer {
         */
        function showOptions( &$out ) {
                global $wgScript, $wgMiserMode;
+               $action = htmlspecialchars( $wgScript );
                $title = SpecialPage::getTitleFor( 'Log' );
-               $form  = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) );
-               $form .= Xml::hidden( 'title', $title->getPrefixedDBkey() );
-               $form .= '<fieldset><legend>' . wfMsgHtml( 'log-search-legend' ) . '</legend>';
-               $form .= '<table>';
-               # Log selection
-               $form .= '<tr><td>&nbsp;</td><td>' . $this->getTypeMenu() . '</td></tr>';
-               $form .= '<tr><td>' . Xml::label( wfMsg( 'specialloguserlabel' ), 'user' ) . '</td>';
-               # User filter
-               $form .= '<td>' . Xml::input( 'user', 30, $this->reader->queryUser(), array( 'id' => 'user' ) ) . '</td></tr>';         
-               # Title filter
-               $form .= '<tr><td>' . Xml::label( wfMsg( 'speciallogtitlelabel' ), 'page' ) . '</td>';
-               $form .= '<td>' . Xml::input( 'page', 30, $this->reader->queryTitle(), array( 'id' => 'page' ) ) . '</td></tr>';
-               # Title "wildcard" checkbox (if enabled)
-               if( !$wgMiserMode ) {
-                       $form .= '<tr><td>&nbsp;</td><td>' . Xml::checkLabel( wfMsg( 'log-title-wildcard' ), 'pattern', 'pattern', $this->reader->queryPattern() ) . '</td></tr>';
-               }
-               $form .= '<tr><td>&nbsp;</td><td>' . Xml::submitButton( wfMsg( 'log-search-submit' ) ) . '</td></tr>';
-               $form .= '</table>';
-               $form .= '</fieldset>';
-               $form .= '</form>';
-               $out->addHtml( $form );
+               $special = htmlspecialchars( $title->getPrefixedDBkey() );
+               $out->addHTML( "<form action=\"$action\" method=\"get\">\n" .
+                       '<fieldset>' .
+                       Xml::element( 'legend', array(), wfMsg( 'log' ) ) .
+                       Xml::hidden( 'title', $special ) . "\n" .
+                       $this->getTypeMenu() . "\n" .
+                       $this->getUserInput() . "\n" .
+                       $this->getTitleInput() . "\n" .
+                       (!$wgMiserMode?($this->getTitlePattern()."\n"):"") .
+                       Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .
+                       "</fieldset></form>" );
        }
 
        /**
@@ -454,6 +463,33 @@ class LogViewer {
                return $out;
        }
 
+       /**
+        * @return string Formatted HTML
+        * @private
+        */
+       function getUserInput() {
+               $user =  $this->reader->queryUser();
+               return Xml::inputLabel( wfMsg( 'specialloguserlabel' ), 'user', 'user', 12, $user );
+       }
+
+       /**
+        * @return string Formatted HTML
+        * @private
+        */
+       function getTitleInput() {
+               $title = $this->reader->queryTitle();
+               return Xml::inputLabel( wfMsg( 'speciallogtitlelabel' ), 'page', 'page', 20, $title );
+       }
+
+       /**
+        * @return boolean Checkbox
+        * @private
+        */
+       function getTitlePattern() {
+               $pattern = $this->reader->queryPattern();
+               return Xml::checkLabel( wfMsg( 'log-title-wildcard' ), 'pattern', 'pattern', $pattern );
+       }
+
        /**
         * @param OutputPage &$out where to send output
         * @private