Index: trunk/extensions/Translate/utils/MessageHandle.php |
— | — | @@ -28,8 +28,8 @@ |
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
32 | | - * Check if a title is in a message namespace. |
33 | | - * @return bool If title is in a message namespace. |
| 32 | + * Check if this handle is in a message namespace. |
| 33 | + * @return bool |
34 | 34 | */ |
35 | 35 | public function isMessageNamespace() { |
36 | 36 | global $wgTranslateMessageNamespaces; |
— | — | @@ -38,7 +38,8 @@ |
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
42 | | - * @return Array of the message and the language |
| 42 | + * Recommended to use getCode and getKey instead. |
| 43 | + * @return Array of the message key and the language code |
43 | 44 | */ |
44 | 45 | public function figureMessage() { |
45 | 46 | if ( $this->key === null ) { |
— | — | @@ -61,6 +62,7 @@ |
62 | 63 | } |
63 | 64 | |
64 | 65 | /** |
| 66 | + * Returns the identified or guessed message key. |
65 | 67 | * @return String |
66 | 68 | */ |
67 | 69 | public function getKey() { |
— | — | @@ -69,6 +71,8 @@ |
70 | 72 | } |
71 | 73 | |
72 | 74 | /** |
| 75 | + * Returns the language code. |
| 76 | + * For language codeless source messages will return empty string. |
73 | 77 | * @return String |
74 | 78 | */ |
75 | 79 | public function getCode() { |
— | — | @@ -87,12 +91,20 @@ |
88 | 92 | |
89 | 93 | /** |
90 | 94 | * Determine whether the current handle is for page translation feature. |
| 95 | + * This does not consider whether the handle corresponds to any message. |
91 | 96 | * @return bool |
92 | 97 | */ |
93 | 98 | public function isPageTranslation() { |
94 | 99 | return $this->getTitle()->getNamespace() == NS_TRANSLATIONS; |
95 | 100 | } |
96 | 101 | |
| 102 | + /** |
| 103 | + * Returns all message group ids this message belongs to. |
| 104 | + * The primary message group id is always the first one. |
| 105 | + * If the handle does not correspond to any message, the returned array |
| 106 | + * is empty. |
| 107 | + * @return array |
| 108 | + */ |
97 | 109 | public function getGroupIds() { |
98 | 110 | if ( $this->groupIds === null ) { |
99 | 111 | $this->groupIds = TranslateUtils::messageKeyToGroups( $this->getTitle()->getNamespace(), $this->getKey() ); |
— | — | @@ -111,17 +123,18 @@ |
112 | 124 | } |
113 | 125 | |
114 | 126 | /** |
115 | | - * Checks if the title corresponds to a known message. |
| 127 | + * Checks if the handle corresponds to a known message. |
116 | 128 | * @since 2011-03-16 |
117 | | - * @return \bool |
| 129 | + * @return bool |
118 | 130 | */ |
119 | 131 | public function isValid() { |
120 | 132 | return $this->isMessageNamespace() && $this->getGroupIds(); |
121 | 133 | } |
122 | 134 | |
123 | 135 | /** |
| 136 | + * Get the original title. |
124 | 137 | * @return Title |
125 | | - */ |
| 138 | + */ |
126 | 139 | public function getTitle() { |
127 | 140 | return $this->title; |
128 | 141 | } |
— | — | @@ -129,8 +142,8 @@ |
130 | 143 | /** |
131 | 144 | * Check if a string contains the fuzzy string. |
132 | 145 | * |
133 | | - * @param $text \string Arbitrary text |
134 | | - * @return \bool If string contains fuzzy string. |
| 146 | + * @param $text string Arbitrary text |
| 147 | + * @return bool If string contains fuzzy string. |
135 | 148 | */ |
136 | 149 | public static function hasFuzzyString( $text ) { |
137 | 150 | return strpos( $text, TRANSLATE_FUZZY ) !== false; |
— | — | @@ -154,7 +167,6 @@ |
155 | 168 | ); |
156 | 169 | |
157 | 170 | $res = $dbr->selectField( $tables, $field, $conds, __METHOD__ ); |
158 | | - |
159 | 171 | return $res !== false; |
160 | 172 | } |
161 | 173 | |