Index: trunk/extensions/SemanticResultFormats/iCalendar/SRF_iCalendar.php |
— | — | @@ -150,9 +150,11 @@ |
151 | 151 | |
152 | 152 | $startdate = false; |
153 | 153 | $enddate = false; |
154 | | - $location = ''; |
155 | | - $description = ''; |
156 | 154 | |
| 155 | + $params = array( |
| 156 | + 'summary' => $wikipage->getShortWikiText() |
| 157 | + ); |
| 158 | + |
157 | 159 | foreach ( $row as /* SMWResultArray */ $field ) { |
158 | 160 | // later we may add more things like a generic |
159 | 161 | // mechanism to add whatever you want :) |
— | — | @@ -160,24 +162,19 @@ |
161 | 163 | $req = $field->getPrintRequest(); |
162 | 164 | $label = strtolower( $req->getLabel() ); |
163 | 165 | |
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; |
166 | 178 | } |
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 | | - } |
182 | 179 | } |
183 | 180 | |
184 | 181 | $title = $wikipage->getTitle(); |
— | — | @@ -185,14 +182,14 @@ |
186 | 183 | $url = $title->getFullURL(); |
187 | 184 | |
188 | 185 | $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"; |
190 | 187 | $result .= "URL:$url\r\n"; |
191 | 188 | $result .= "UID:$url\r\n"; |
192 | 189 | |
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"; |
197 | 194 | |
198 | 195 | $t = strtotime( str_replace( 'T', ' ', $article->getTimestamp() ) ); |
199 | 196 | $result .= "DTSTAMP:" . date( "Ymd", $t ) . "T" . date( "His", $t ) . "\r\n"; |
— | — | @@ -240,10 +237,6 @@ |
241 | 238 | $params['description']->setMessage( 'srf_paramdesc_icalendardescription' ); |
242 | 239 | $params['description']->setDefault( '' ); |
243 | 240 | |
244 | | - $params['summary'] = new Parameter( 'summary' ); |
245 | | - $params['summary']->setMessage( 'srf-paramdesc-ical-summary' ); |
246 | | - $params['summary']->setDefault( '$1' ); |
247 | | - |
248 | 241 | return $params; |
249 | 242 | } |
250 | 243 | |
Index: trunk/extensions/SemanticResultFormats/SemanticResultFormats.php |
— | — | @@ -175,11 +175,12 @@ |
176 | 176 | * SMW 1.6 introduces the getNextDataValue and deprecates the getNextObject one. |
177 | 177 | * |
178 | 178 | * @since 1.6 |
| 179 | + * @deprecated since 1.7, removal in 1.9 |
179 | 180 | * |
180 | 181 | * @param SMWResultArray $resArray |
181 | 182 | * |
182 | 183 | * @return SMWDataValue or false |
183 | 184 | */ |
184 | 185 | function efSRFGetNextDV( SMWResultArray &$resArray ) { |
185 | | - return method_exists( $resArray, 'getNextDataValue' ) ? $resArray->getNextDataValue(): $resArray->getNextObject(); |
| 186 | + return $resArray->getNextDataValue(); |
186 | 187 | } |
Index: trunk/extensions/SemanticResultFormats/SRF_Messages.php |
— | — | @@ -33,7 +33,6 @@ |
34 | 34 | 'srf_printername_icalendar' => 'iCalendar export', |
35 | 35 | 'srf_paramdesc_icalendartitle' => 'The title of the calendar file', |
36 | 36 | '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.', |
38 | 37 | // format "BibTeX" |
39 | 38 | 'srf_bibtex_link' => 'BibTeX', |
40 | 39 | 'srf_printername_bibtex' => 'BibTeX export', |