r109446 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109445‎ | r109446 | r109447 >
Date:22:40, 18 January 2012
Author:mrbluesky
Status:ok
Tags:
Comment:
Additional doc/comments
Modified paths:
  • /trunk/phase3/includes/ChangeTags.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ChangeTags.php
@@ -1,6 +1,23 @@
22 <?php
 3+/**
 4+ * Functions related to change tags.
 5+ *
 6+ * @file
 7+ */
 8+class ChangeTags {
39
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+ */
522 static function formatSummaryRow( $tags, $page ) {
623 if( !$tags )
724 return array( '', array() );
@@ -18,18 +35,38 @@
1936 );
2037 $classes[] = Sanitizer::escapeClass( "mw-tag-$tag" );
2138 }
22 -
2339 $markers = '(' . implode( ', ', $displayTags ) . ')';
2440 $markers = Xml::tags( 'span', array( 'class' => 'mw-tag-markers' ), $markers );
 41+
2542 return array( $markers, $classes );
2643 }
2744
 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+ */
2853 static function tagDescription( $tag ) {
2954 $msg = wfMessage( "tag-$tag" );
30 - return $msg->exists() ? $msg->parse() : htmlspecialchars( $tag );
 55+ return $msg->exists() ? $msg->parse() : htmlspecialchars( $tag );
3156 }
3257
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+ */
3471 static function addTags( $tags, $rc_id = null, $rev_id = null, $log_id = null, $params = null ) {
3572 if ( !is_array( $tags ) ) {
3673 $tags = array( $tags );
@@ -103,6 +140,16 @@
104141 * Applies all tags-related changes to a query.
105142 * Handles selecting tags, and filtering.
106143 * 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+ *
107154 */
108155 static function modifyDisplayQuery( &$tables, &$fields, &$conds,
109156 &$join_conds, &$options, $filter_tag = false ) {
@@ -178,9 +225,13 @@
179226 }
180227
181228 /**
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.
183232 *
184 - * @return array
 233+ * Tries memcached first.
 234+ *
 235+ * @return Array of strings: tags
185236 */
186237 static function listDefinedTags() {
187238 // Caching...

Follow-up revisions

RevisionCommit summaryAuthorDate
r109510Typofix, ping r109446nikerabbit09:20, 19 January 2012

Status & tagging log