Merge "allow localization of elements via data-msg-text and data-msg-html"
[lhc/web/wiklou.git] / includes / cache / GenderCache.php
index c27ab00..2a169bb 100644 (file)
@@ -1,8 +1,30 @@
 <?php
-
 /**
  * Caches user genders when needed to use correct namespace aliases.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
  * @author Niklas Laxström
+ * @ingroup Cache
+ */
+
+/**
+ * Caches user genders when needed to use correct namespace aliases.
+ *
  * @since 1.18
  */
 class GenderCache {
@@ -89,6 +111,29 @@ class GenderCache {
                $this->doQuery( array_keys( $users ), $caller );
        }
 
+       /**
+        * Wrapper for doQuery that processes a title or string array.
+        *
+        * @since 1.20
+        * @param $titles List: array of Title objects or strings
+        * @param $caller String: the calling method
+        */
+       public function doTitlesArray( $titles, $caller = '' ) {
+               $users = array();
+               foreach ( $titles as $title ) {
+                       $titleObj = is_string( $title ) ? Title::newFromText( $title ) : $title;
+                       if ( !$titleObj ) {
+                               continue;
+                       }
+                       if ( !MWNamespace::hasGenderDistinction( $titleObj->getNamespace() ) ) {
+                               continue;
+                       }
+                       $users[] = $titleObj->getText();
+               }
+
+               $this->doQuery( $users, $caller );
+       }
+
        /**
         * Preloads genders for given list of users.
         * @param $users List|String: usernames