Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_PrintRequest.php |
— | — | @@ -13,6 +13,7 @@ |
14 | 14 | * @ingroup SMWQuery |
15 | 15 | */ |
16 | 16 | class SMWPrintRequest { |
| 17 | + |
17 | 18 | /// Query mode to print all direct categories of the current element. |
18 | 19 | const PRINT_CATS = 0; |
19 | 20 | /// Query mode to print all property values of a certain attribute of the current element. |
— | — | @@ -94,8 +95,9 @@ |
95 | 96 | case SMWPrintRequest::PRINT_PROP: |
96 | 97 | return $this->m_data->getShortWikiText( $linked ); |
97 | 98 | case SMWPrintRequest::PRINT_CCAT: |
98 | | - return '[[:' . $this->m_data->getPrefixedText() . '|' . $this->m_label . ']]'; |
99 | | - case SMWPrintRequest::PRINT_THIS: default: return $this->m_label; |
| 99 | + return '[[:' . $this->m_data->getPrefixedText() . '|' . $this->m_label . ']]'; |
| 100 | + case SMWPrintRequest::PRINT_THIS: default: |
| 101 | + return $this->m_label; |
100 | 102 | } |
101 | 103 | } |
102 | 104 | } |
— | — | @@ -126,6 +128,8 @@ |
127 | 129 | /** |
128 | 130 | * If this print request refers to some property, return the type id of this property. |
129 | 131 | * Otherwise return FALSE. |
| 132 | + * |
| 133 | + * @return string |
130 | 134 | */ |
131 | 135 | public function getTypeID() { |
132 | 136 | if ( $this->m_typeid === false ) { |
— | — | @@ -135,6 +139,7 @@ |
136 | 140 | $this->m_typeid = '_wpg'; // return objects might be titles, but anyway |
137 | 141 | } |
138 | 142 | } |
| 143 | + |
139 | 144 | return $this->m_typeid; |
140 | 145 | } |
141 | 146 | |
— | — | @@ -143,6 +148,8 @@ |
144 | 149 | * print requests. The hash also includes the chosen label, |
145 | 150 | * so it is possible to print the same date with different |
146 | 151 | * labels. |
| 152 | + * |
| 153 | + * @return string |
147 | 154 | */ |
148 | 155 | public function getHash() { |
149 | 156 | if ( $this->m_hash === false ) { |
— | — | @@ -167,35 +174,44 @@ |
168 | 175 | */ |
169 | 176 | public function getSerialisation( $showparams = false ) { |
170 | 177 | $parameters = ''; |
| 178 | + |
171 | 179 | if ( $showparams ) foreach ( $this->m_params as $key => $value ) { |
172 | 180 | $parameters .= "|+" . $key . "=" . $value; |
173 | 181 | } |
| 182 | + |
174 | 183 | switch ( $this->m_mode ) { |
175 | 184 | case SMWPrintRequest::PRINT_CATS: |
176 | 185 | global $wgContLang; |
| 186 | + |
177 | 187 | $catlabel = $wgContLang->getNSText( NS_CATEGORY ); |
178 | 188 | $result = '?' . $catlabel; |
| 189 | + |
179 | 190 | if ( $this->m_label != $catlabel ) { |
180 | 191 | $result .= '=' . $this->m_label; |
181 | 192 | } |
| 193 | + |
182 | 194 | return $result . $parameters; |
183 | 195 | case SMWPrintRequest::PRINT_PROP: case SMWPrintRequest::PRINT_CCAT: |
184 | 196 | if ( $this->m_mode == SMWPrintRequest::PRINT_CCAT ) { |
185 | 197 | $printname = $this->m_data->getPrefixedText(); |
186 | 198 | $result = '?' . $printname; |
| 199 | + |
187 | 200 | if ( $this->m_outputformat != 'x' ) { |
188 | 201 | $result .= '#' . $this->m_outputformat; |
189 | 202 | } |
190 | 203 | } else { |
191 | 204 | $printname = $this->m_data->getWikiValue(); |
192 | 205 | $result = '?' . $printname; |
| 206 | + |
193 | 207 | if ( $this->m_outputformat != '' ) { |
194 | 208 | $result .= '#' . $this->m_outputformat; |
195 | 209 | } |
196 | 210 | } |
| 211 | + |
197 | 212 | if ( $printname != $this->m_label ) { |
198 | 213 | $result .= '=' . $this->m_label; |
199 | 214 | } |
| 215 | + |
200 | 216 | return $result . $parameters; |
201 | 217 | case SMWPrintRequest::PRINT_THIS: default: return ''; // no current serialisation |
202 | 218 | } |
— | — | @@ -203,15 +219,18 @@ |
204 | 220 | |
205 | 221 | /** |
206 | 222 | * Returns the value of a named parameter. |
| 223 | + * |
207 | 224 | * @param $key string the name of the parameter key |
| 225 | + * |
208 | 226 | * @return string Value of the paramer, if set (else FALSE) |
209 | 227 | */ |
210 | 228 | public function getParameter( $key ) { |
211 | | - return ( array_key_exists( $key, $this->m_params ) ) ? $this->m_params[$key]:false; |
| 229 | + return array_key_exists( $key, $this->m_params ) ? $this->m_params[$key] : false; |
212 | 230 | } |
213 | 231 | |
214 | 232 | /** |
215 | 233 | * Returns the array of parameters, where a string is mapped to a string. |
| 234 | + * |
216 | 235 | * @return array Map of parameter names to values. |
217 | 236 | */ |
218 | 237 | public function getParameters() { |
— | — | @@ -220,10 +239,12 @@ |
221 | 240 | |
222 | 241 | /** |
223 | 242 | * Sets a print request parameter. |
| 243 | + * |
224 | 244 | * @param $key string Name of the parameter |
225 | 245 | * @param $value string Value for the parameter |
226 | 246 | */ |
227 | 247 | public function setParameter( $key, $value ) { |
228 | 248 | $this->m_params[$key] = $value; |
229 | 249 | } |
| 250 | + |
230 | 251 | } |
\ No newline at end of file |