r69630 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69629‎ | r69630 | r69631 >
Date:15:50, 20 July 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Style and doc improvements
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_PrintRequest.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_PrintRequest.php
@@ -13,6 +13,7 @@
1414 * @ingroup SMWQuery
1515 */
1616 class SMWPrintRequest {
 17+
1718 /// Query mode to print all direct categories of the current element.
1819 const PRINT_CATS = 0;
1920 /// Query mode to print all property values of a certain attribute of the current element.
@@ -94,8 +95,9 @@
9596 case SMWPrintRequest::PRINT_PROP:
9697 return $this->m_data->getShortWikiText( $linked );
9798 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;
100102 }
101103 }
102104 }
@@ -126,6 +128,8 @@
127129 /**
128130 * If this print request refers to some property, return the type id of this property.
129131 * Otherwise return FALSE.
 132+ *
 133+ * @return string
130134 */
131135 public function getTypeID() {
132136 if ( $this->m_typeid === false ) {
@@ -135,6 +139,7 @@
136140 $this->m_typeid = '_wpg'; // return objects might be titles, but anyway
137141 }
138142 }
 143+
139144 return $this->m_typeid;
140145 }
141146
@@ -143,6 +148,8 @@
144149 * print requests. The hash also includes the chosen label,
145150 * so it is possible to print the same date with different
146151 * labels.
 152+ *
 153+ * @return string
147154 */
148155 public function getHash() {
149156 if ( $this->m_hash === false ) {
@@ -167,35 +174,44 @@
168175 */
169176 public function getSerialisation( $showparams = false ) {
170177 $parameters = '';
 178+
171179 if ( $showparams ) foreach ( $this->m_params as $key => $value ) {
172180 $parameters .= "|+" . $key . "=" . $value;
173181 }
 182+
174183 switch ( $this->m_mode ) {
175184 case SMWPrintRequest::PRINT_CATS:
176185 global $wgContLang;
 186+
177187 $catlabel = $wgContLang->getNSText( NS_CATEGORY );
178188 $result = '?' . $catlabel;
 189+
179190 if ( $this->m_label != $catlabel ) {
180191 $result .= '=' . $this->m_label;
181192 }
 193+
182194 return $result . $parameters;
183195 case SMWPrintRequest::PRINT_PROP: case SMWPrintRequest::PRINT_CCAT:
184196 if ( $this->m_mode == SMWPrintRequest::PRINT_CCAT ) {
185197 $printname = $this->m_data->getPrefixedText();
186198 $result = '?' . $printname;
 199+
187200 if ( $this->m_outputformat != 'x' ) {
188201 $result .= '#' . $this->m_outputformat;
189202 }
190203 } else {
191204 $printname = $this->m_data->getWikiValue();
192205 $result = '?' . $printname;
 206+
193207 if ( $this->m_outputformat != '' ) {
194208 $result .= '#' . $this->m_outputformat;
195209 }
196210 }
 211+
197212 if ( $printname != $this->m_label ) {
198213 $result .= '=' . $this->m_label;
199214 }
 215+
200216 return $result . $parameters;
201217 case SMWPrintRequest::PRINT_THIS: default: return ''; // no current serialisation
202218 }
@@ -203,15 +219,18 @@
204220
205221 /**
206222 * Returns the value of a named parameter.
 223+ *
207224 * @param $key string the name of the parameter key
 225+ *
208226 * @return string Value of the paramer, if set (else FALSE)
209227 */
210228 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;
212230 }
213231
214232 /**
215233 * Returns the array of parameters, where a string is mapped to a string.
 234+ *
216235 * @return array Map of parameter names to values.
217236 */
218237 public function getParameters() {
@@ -220,10 +239,12 @@
221240
222241 /**
223242 * Sets a print request parameter.
 243+ *
224244 * @param $key string Name of the parameter
225245 * @param $value string Value for the parameter
226246 */
227247 public function setParameter( $key, $value ) {
228248 $this->m_params[$key] = $value;
229249 }
 250+
230251 }
\ No newline at end of file

Status & tagging log