r101851 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101850‎ | r101851 | r101852 >
Date:19:00, 3 November 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
change summary param syntax
Modified paths:
  • /trunk/extensions/SemanticResultFormats/SRF_Messages.php (modified) (history)
  • /trunk/extensions/SemanticResultFormats/SemanticResultFormats.php (modified) (history)
  • /trunk/extensions/SemanticResultFormats/iCalendar/SRF_iCalendar.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticResultFormats/iCalendar/SRF_iCalendar.php
@@ -150,9 +150,11 @@
151151
152152 $startdate = false;
153153 $enddate = false;
154 - $location = '';
155 - $description = '';
156154
 155+ $params = array(
 156+ 'summary' => $wikipage->getShortWikiText()
 157+ );
 158+
157159 foreach ( $row as /* SMWResultArray */ $field ) {
158160 // later we may add more things like a generic
159161 // mechanism to add whatever you want :)
@@ -160,24 +162,19 @@
161163 $req = $field->getPrintRequest();
162164 $label = strtolower( $req->getLabel() );
163165
164 - if ( $label == 'start' && $req->getTypeID() == '_dat' ) {
165 - $startdate = efSRFGetNextDV( $field ); // save only the first
 166+ switch ( $label ) {
 167+ case 'start': case 'end':
 168+ if ( $req->getTypeID() == '_dat' ) {
 169+ $params[$label] = $field->getNextDataValue();
 170+ }
 171+ break;
 172+ case 'location': case 'description': case 'summary':
 173+ $value = $field->getNextDataValue();
 174+ if ( $value !== false ) {
 175+ $params[$label] = $value->getShortWikiText();
 176+ }
 177+ break;
166178 }
167 - else if ( $label == 'end' && $req->getTypeID() == '_dat' ) {
168 - $enddate = efSRFGetNextDV( $field ); // save only the first
169 - }
170 - else if ( $label == 'location' ) {
171 - $value = efSRFGetNextDV( $field ); // save only the first
172 - if ( $value !== false ) {
173 - $location = $value->getShortWikiText();
174 - }
175 - }
176 - else if ( $label == 'description' ) {
177 - $value = efSRFGetNextDV( $field ); // save only the first
178 - if ( $value !== false ) {
179 - $description = $value->getShortWikiText();
180 - }
181 - }
182179 }
183180
184181 $title = $wikipage->getTitle();
@@ -185,14 +182,14 @@
186183 $url = $title->getFullURL();
187184
188185 $result .= "BEGIN:VEVENT\r\n";
189 - $result .= "SUMMARY:" . str_replace( '$1', $wikipage->getShortWikiText(), $this->params['summary'] ) . "\r\n";
 186+ $result .= "SUMMARY:" . $params['summary'] . "\r\n";
190187 $result .= "URL:$url\r\n";
191188 $result .= "UID:$url\r\n";
192189
193 - if ( $startdate != false ) $result .= "DTSTART:" . $this->parsedate( $startdate ) . "\r\n";
194 - if ( $enddate != false ) $result .= "DTEND:" . $this->parsedate( $enddate, true ) . "\r\n";
195 - if ( $location != "" ) $result .= "LOCATION:$location\r\n";
196 - if ( $description != "" ) $result .= "DESCRIPTION:$description\r\n";
 190+ if ( array_key_exists( 'start', $params ) ) $result .= "DTSTART:" . $this->parsedate( $params['start'] ) . "\r\n";
 191+ if ( array_key_exists( 'end', $params ) ) $result .= "DTEND:" . $this->parsedate( $params['end'], true ) . "\r\n";
 192+ if ( array_key_exists( 'location', $params ) ) $result .= "LOCATION:" . $params['location'] . "\r\n";
 193+ if ( array_key_exists( 'description', $params ) ) $result .= "DESCRIPTION:" . $params['description'] . "\r\n";
197194
198195 $t = strtotime( str_replace( 'T', ' ', $article->getTimestamp() ) );
199196 $result .= "DTSTAMP:" . date( "Ymd", $t ) . "T" . date( "His", $t ) . "\r\n";
@@ -240,10 +237,6 @@
241238 $params['description']->setMessage( 'srf_paramdesc_icalendardescription' );
242239 $params['description']->setDefault( '' );
243240
244 - $params['summary'] = new Parameter( 'summary' );
245 - $params['summary']->setMessage( 'srf-paramdesc-ical-summary' );
246 - $params['summary']->setDefault( '$1' );
247 -
248241 return $params;
249242 }
250243
Index: trunk/extensions/SemanticResultFormats/SemanticResultFormats.php
@@ -175,11 +175,12 @@
176176 * SMW 1.6 introduces the getNextDataValue and deprecates the getNextObject one.
177177 *
178178 * @since 1.6
 179+ * @deprecated since 1.7, removal in 1.9
179180 *
180181 * @param SMWResultArray $resArray
181182 *
182183 * @return SMWDataValue or false
183184 */
184185 function efSRFGetNextDV( SMWResultArray &$resArray ) {
185 - return method_exists( $resArray, 'getNextDataValue' ) ? $resArray->getNextDataValue(): $resArray->getNextObject();
 186+ return $resArray->getNextDataValue();
186187 }
Index: trunk/extensions/SemanticResultFormats/SRF_Messages.php
@@ -33,7 +33,6 @@
3434 'srf_printername_icalendar' => 'iCalendar export',
3535 'srf_paramdesc_icalendartitle' => 'The title of the calendar file',
3636 'srf_paramdesc_icalendardescription' => 'The description of the calendar file',
37 - 'srf-paramdesc-ical-summary' => 'The summary for each calendar entry. $1 gets replaced by the title of the page to which the entry corresponds.',
3837 // format "BibTeX"
3938 'srf_bibtex_link' => 'BibTeX',
4039 'srf_printername_bibtex' => 'BibTeX export',

Sign-offs

UserFlagDate
Nikerabbitinspected11:05, 4 November 2011