* API: (bug 20700) Add amprop=default to list default messages in list=allmessages...
[lhc/web/wiklou.git] / includes / ChangeTags.php
index cbbe67e..3b72bd1 100644 (file)
@@ -13,11 +13,16 @@ class ChangeTags {
                $tags = explode( ',', $tags );
                $displayTags = array();
                foreach( $tags as $tag ) {
-                       $displayTags[] = self::tagDescription( $tag );
-                       $classes[] = "mw-tag-$tag";
+                       $displayTags[] = Xml::tags( 'span',
+                                                               array( 'class' => "mw-tag-marker ".
+                                                                                       Sanitizer::escapeClass("mw-tag-marker-$tag") ),
+                                                               self::tagDescription( $tag ) );
+                       $classes[] = Sanitizer::escapeClass( "mw-tag-$tag" );
                }
 
-               return array( '(' . implode( ', ', $displayTags ) . ')', $classes );
+               $markers = '(' . implode( ', ', $displayTags ) . ')';
+               $markers = Xml::tags( 'span', array( 'class' => 'mw-tag-markers' ), $markers );
+               return array( $markers, $classes );
        }
 
        static function tagDescription( $tag ) {
@@ -90,8 +95,9 @@ class ChangeTags {
         * Handles selecting tags, and filtering.
         * Needs $tables to be set up properly, so we can figure out which join conditions to use.
        */
-       static function modifyDisplayQuery( &$tables, &$fields,  &$conds, &$join_conds, $filter_tag = false ) {
-               global $wgRequest;
+       static function modifyDisplayQuery( &$tables, &$fields,  &$conds,
+                                                                               &$join_conds, &$options, $filter_tag = false ) {
+               global $wgRequest, $wgUseTagFilter;
                
                if ($filter_tag === false) {
                        $filter_tag = $wgRequest->getVal( 'tagfilter' );
@@ -114,10 +120,15 @@ class ChangeTags {
                $join_conds['tag_summary'] = array( 'LEFT JOIN', "ts_$join_cond=$join_cond" );
                $fields[] = 'ts_tags';
                
-               if ($filter_tag) {
+               if ($wgUseTagFilter && $filter_tag) {
                        // Somebody wants to filter on a tag.
                        // Add an INNER JOIN on change_tag
 
+                       // FORCE INDEX -- change_tags will almost ALWAYS be the correct query plan.
+                       global $wgOldChangeTagsIndex;
+                       $index = $wgOldChangeTagsIndex ? 'ct_tag' : 'change_tag_tag_id';
+                       $options['USE INDEX'] = array( 'change_tag' => $index );
+                       unset( $options['FORCE INDEX'] );
                        $tables[] = 'change_tag';
                        $join_conds['change_tag'] = array( 'INNER JOIN', "ct_$join_cond=$join_cond" );
                        $conds['ct_tag'] = $filter_tag;
@@ -129,8 +140,9 @@ class ChangeTags {
         * If $fullForm is true, it returns an entire form.
         */
        static function buildTagFilterSelector( $selected='', $fullForm = false /* used to put a full form around the selector */ ) {
-
-               if ( !count( self::listDefinedTags() ) )
+               global $wgUseTagFilter;
+               
+               if ( !$wgUseTagFilter || !count( self::listDefinedTags() ) )
                        return $fullForm ? '' : array();
        
                global $wgTitle;
@@ -175,4 +187,4 @@ class ChangeTags {
                $wgMemc->set( $key, $emptyTags, 300 );
                return $emptyTags;
        }
-}
\ No newline at end of file
+}