https://www.mediawiki.org/wiki/Special:Code/MediaWiki/101851
Revision: 101851 Author: jeroendedauw Date: 2011-11-03 19:00:43 +0000 (Thu, 03 Nov 2011) Log Message: ----------- change summary param syntax Modified Paths: -------------- trunk/extensions/SemanticResultFormats/SRF_Messages.php trunk/extensions/SemanticResultFormats/SemanticResultFormats.php trunk/extensions/SemanticResultFormats/iCalendar/SRF_iCalendar.php Modified: trunk/extensions/SemanticResultFormats/SRF_Messages.php =================================================================== --- trunk/extensions/SemanticResultFormats/SRF_Messages.php 2011-11-03 18:56:51 UTC (rev 101850) +++ trunk/extensions/SemanticResultFormats/SRF_Messages.php 2011-11-03 19:00:43 UTC (rev 101851) @@ -33,7 +33,6 @@ 'srf_printername_icalendar' => 'iCalendar export', 'srf_paramdesc_icalendartitle' => 'The title of the calendar file', 'srf_paramdesc_icalendardescription' => 'The description of the calendar file', - 'srf-paramdesc-ical-summary' => 'The summary for each calendar entry. $1 gets replaced by the title of the page to which the entry corresponds.', // format "BibTeX" 'srf_bibtex_link' => 'BibTeX', 'srf_printername_bibtex' => 'BibTeX export', Modified: trunk/extensions/SemanticResultFormats/SemanticResultFormats.php =================================================================== --- trunk/extensions/SemanticResultFormats/SemanticResultFormats.php 2011-11-03 18:56:51 UTC (rev 101850) +++ trunk/extensions/SemanticResultFormats/SemanticResultFormats.php 2011-11-03 19:00:43 UTC (rev 101851) @@ -175,11 +175,12 @@ * SMW 1.6 introduces the getNextDataValue and deprecates the getNextObject one. * * @since 1.6 + * @deprecated since 1.7, removal in 1.9 * * @param SMWResultArray $resArray * * @return SMWDataValue or false */ function efSRFGetNextDV( SMWResultArray &$resArray ) { - return method_exists( $resArray, 'getNextDataValue' ) ? $resArray->getNextDataValue(): $resArray->getNextObject(); + return $resArray->getNextDataValue(); } Modified: trunk/extensions/SemanticResultFormats/iCalendar/SRF_iCalendar.php =================================================================== --- trunk/extensions/SemanticResultFormats/iCalendar/SRF_iCalendar.php 2011-11-03 18:56:51 UTC (rev 101850) +++ trunk/extensions/SemanticResultFormats/iCalendar/SRF_iCalendar.php 2011-11-03 19:00:43 UTC (rev 101851) @@ -150,9 +150,11 @@ $startdate = false; $enddate = false; - $location = ''; - $description = ''; + $params = array( + 'summary' => $wikipage->getShortWikiText() + ); + foreach ( $row as /* SMWResultArray */ $field ) { // later we may add more things like a generic // mechanism to add whatever you want :) @@ -160,24 +162,19 @@ $req = $field->getPrintRequest(); $label = strtolower( $req->getLabel() ); - if ( $label == 'start' && $req->getTypeID() == '_dat' ) { - $startdate = efSRFGetNextDV( $field ); // save only the first + switch ( $label ) { + case 'start': case 'end': + if ( $req->getTypeID() == '_dat' ) { + $params[$label] = $field->getNextDataValue(); + } + break; + case 'location': case 'description': case 'summary': + $value = $field->getNextDataValue(); + if ( $value !== false ) { + $params[$label] = $value->getShortWikiText(); + } + break; } - else if ( $label == 'end' && $req->getTypeID() == '_dat' ) { - $enddate = efSRFGetNextDV( $field ); // save only the first - } - else if ( $label == 'location' ) { - $value = efSRFGetNextDV( $field ); // save only the first - if ( $value !== false ) { - $location = $value->getShortWikiText(); - } - } - else if ( $label == 'description' ) { - $value = efSRFGetNextDV( $field ); // save only the first - if ( $value !== false ) { - $description = $value->getShortWikiText(); - } - } } $title = $wikipage->getTitle(); @@ -185,14 +182,14 @@ $url = $title->getFullURL(); $result .= "BEGIN:VEVENT\r\n"; - $result .= "SUMMARY:" . str_replace( '$1', $wikipage->getShortWikiText(), $this->params['summary'] ) . "\r\n"; + $result .= "SUMMARY:" . $params['summary'] . "\r\n"; $result .= "URL:$url\r\n"; $result .= "UID:$url\r\n"; - if ( $startdate != false ) $result .= "DTSTART:" . $this->parsedate( $startdate ) . "\r\n"; - if ( $enddate != false ) $result .= "DTEND:" . $this->parsedate( $enddate, true ) . "\r\n"; - if ( $location != "" ) $result .= "LOCATION:$location\r\n"; - if ( $description != "" ) $result .= "DESCRIPTION:$description\r\n"; + if ( array_key_exists( 'start', $params ) ) $result .= "DTSTART:" . $this->parsedate( $params['start'] ) . "\r\n"; + if ( array_key_exists( 'end', $params ) ) $result .= "DTEND:" . $this->parsedate( $params['end'], true ) . "\r\n"; + if ( array_key_exists( 'location', $params ) ) $result .= "LOCATION:" . $params['location'] . "\r\n"; + if ( array_key_exists( 'description', $params ) ) $result .= "DESCRIPTION:" . $params['description'] . "\r\n"; $t = strtotime( str_replace( 'T', ' ', $article->getTimestamp() ) ); $result .= "DTSTAMP:" . date( "Ymd", $t ) . "T" . date( "His", $t ) . "\r\n"; @@ -240,10 +237,6 @@ $params['description']->setMessage( 'srf_paramdesc_icalendardescription' ); $params['description']->setDefault( '' ); - $params['summary'] = new Parameter( 'summary' ); - $params['summary']->setMessage( 'srf-paramdesc-ical-summary' ); - $params['summary']->setDefault( '$1' ); - return $params; } _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs