Index: trunk/phase3/includes/ChangeTags.php |
— | — | @@ -1,6 +1,23 @@ |
2 | 2 | <?php |
| 3 | +/** |
| 4 | + * Functions related to change tags. |
| 5 | + * |
| 6 | + * @file |
| 7 | + */ |
| 8 | +class ChangeTags { |
3 | 9 | |
4 | | -class ChangeTags { |
| 10 | + /** |
| 11 | + * Creates HTML for the given tags |
| 12 | + * |
| 13 | + * @param $tags String: Comma-seperated list of tags |
| 14 | + * @param $page String: A label for the type of action which is being displayed, |
| 15 | + * for example: 'history', 'contributions' or 'newpages' |
| 16 | + * |
| 17 | + * @return Array with two items: (html, classes) |
| 18 | + * - html: String: HTML for displaying the tags (empty string when param $tags is empty) |
| 19 | + * - classes: Array of strings: CSS classes used in the generated html, one class for each tag |
| 20 | + * |
| 21 | + */ |
5 | 22 | static function formatSummaryRow( $tags, $page ) { |
6 | 23 | if( !$tags ) |
7 | 24 | return array( '', array() ); |
— | — | @@ -18,18 +35,38 @@ |
19 | 36 | ); |
20 | 37 | $classes[] = Sanitizer::escapeClass( "mw-tag-$tag" ); |
21 | 38 | } |
22 | | - |
23 | 39 | $markers = '(' . implode( ', ', $displayTags ) . ')'; |
24 | 40 | $markers = Xml::tags( 'span', array( 'class' => 'mw-tag-markers' ), $markers ); |
| 41 | + |
25 | 42 | return array( $markers, $classes ); |
26 | 43 | } |
27 | 44 | |
| 45 | + /** |
| 46 | + * Get a short description for a tag |
| 47 | + * |
| 48 | + * @param $tag String: tag |
| 49 | + * |
| 50 | + * @return String: Short description of the tag from "mediawiki:tag-$tag" if this message exists, |
| 51 | + * html-escaped version of $tag otherwise |
| 52 | + */ |
28 | 53 | static function tagDescription( $tag ) { |
29 | 54 | $msg = wfMessage( "tag-$tag" ); |
30 | | - return $msg->exists() ? $msg->parse() : htmlspecialchars( $tag ); |
| 55 | + return $msg->exists() ? $msg->parse() : htmlspecialchars( $tag ); |
31 | 56 | } |
32 | 57 | |
33 | | - ## Basic utility method to add tags to a particular change, given its rc_id, rev_id and/or log_id. |
| 58 | + /** |
| 59 | + * Add tags to a change given its rc_id, rev_id and/or log_id |
| 60 | + * |
| 61 | + * @param $tags String|Array: Tags to add to the change |
| 62 | + * @param $rc_id int: rc_id of the change to add the tags to |
| 63 | + * @param $rev_id int: rev_id of the change to add the tags to |
| 64 | + * @param $log_id int: log_id of the change to add the tags to |
| 65 | + * @param $params String: params to put in the ct_params field of tabel 'change_tag' |
| 66 | + * |
| 67 | + * @return bool: false if no changes are made, otherwise true |
| 68 | + * |
| 69 | + * @exception MWException when $rc_id, $rev_id and $log_id are all null |
| 70 | + */ |
34 | 71 | static function addTags( $tags, $rc_id = null, $rev_id = null, $log_id = null, $params = null ) { |
35 | 72 | if ( !is_array( $tags ) ) { |
36 | 73 | $tags = array( $tags ); |
— | — | @@ -103,6 +140,16 @@ |
104 | 141 | * Applies all tags-related changes to a query. |
105 | 142 | * Handles selecting tags, and filtering. |
106 | 143 | * Needs $tables to be set up properly, so we can figure out which join conditions to use. |
| 144 | + * |
| 145 | + * @param $tables String|Array: Tabel names, see DatabaseBase::select |
| 146 | + * @param $fields String|Array: Fields used in query, see DatabaseBase::select |
| 147 | + * @param $conds String|Array: conditions used in query, see DatabaseBase::select |
| 148 | + * @param $join_conds Array: join conditions, see DatabaseBase::select |
| 149 | + * @param $options Array: options, see Database::select |
| 150 | + * @param $filter_tag String: tag to select on |
| 151 | + * |
| 152 | + * @exception MWException when unable to determine appropriate JOIN condition for tagging |
| 153 | + * |
107 | 154 | */ |
108 | 155 | static function modifyDisplayQuery( &$tables, &$fields, &$conds, |
109 | 156 | &$join_conds, &$options, $filter_tag = false ) { |
— | — | @@ -178,9 +225,13 @@ |
179 | 226 | } |
180 | 227 | |
181 | 228 | /** |
182 | | - *Basically lists defined tags which count even if they aren't applied to anything |
| 229 | + * Basically lists defined tags which count even if they aren't applied to anything. |
| 230 | + * Tags on items in table 'change_tag' which are not (or no longer) in table 'valid_tag' |
| 231 | + * are not included. |
183 | 232 | * |
184 | | - * @return array |
| 233 | + * Tries memcached first. |
| 234 | + * |
| 235 | + * @return Array of strings: tags |
185 | 236 | */ |
186 | 237 | static function listDefinedTags() { |
187 | 238 | // Caching... |