r68813 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68812‎ | r68813 | r68814 >
Date:03:58, 1 July 2010
Author:yaron
Status:deferred
Tags:
Comment:
Improved comments, and handling in case of two or more date properties being "displayed"
Modified paths:
  • /trunk/extensions/SemanticResultFormats/Calendar/SRF_Calendar.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticResultFormats/Calendar/SRF_Calendar.php
@@ -84,12 +84,16 @@
8585 }
8686 }
8787 } else { // build simple text
 88+ $numNonDateProperties = 0;
 89+ // cycle through a 'row', which is the page
 90+ // name (the first field) plus all its
 91+ // properties
8892 foreach ( $row as $i => $field ) {
8993 $pr = $field->getPrintRequest();
90 - if ( $i == 2 )
91 - $text .= " (";
92 - elseif ( $i > 2 )
93 - $text .= ", ";
 94+ // a property can have more than one
 95+ // value - cycle through all the values
 96+ // for this property
 97+ $textForProperty = '';
9498 while ( ( $object = $field->getNextObject() ) !== false ) {
9599 if ( $object->getTypeID() == '_dat' ) {
96100 // don't add date values to the display
@@ -97,30 +101,42 @@
98102 if ( $i == 0 ) {
99103 $title = Title::newFromText( $object->getShortWikiText( false ) );
100104 } else {
 105+ $numNonDateProperties++;
101106 // handling of "headers=" param
102107 if ( $this->mShowHeaders == SMW_HEADERS_SHOW ) {
103 - $text .= $pr->getHTMLText( $skin ) . " ";
 108+ $textForProperty .= $pr->getHTMLText( $skin ) . " ";
104109 } elseif ( $this->mShowHeaders == SMW_HEADERS_PLAIN ) {
105 - $text .= $pr->getLabel() . " ";
 110+ $textForProperty .= $pr->getLabel() . " ";
106111 }
107112 // if $this->mShowHeaders == SMW_HEADERS_HIDE, print nothing
108113 // handling of "link=" param
109114 if ( $this->mLinkOthers ) {
110 - $text .= $object->getLongText( $outputmode, $skin );
 115+ $textForProperty .= $object->getLongText( $outputmode, $skin );
111116 } else {
112 - $text .= $object->getWikiValue();
 117+ $textForProperty .= $object->getWikiValue();
113118 }
114119 }
115120 } else {
116 - $text .= $pr->getHTMLText( $skin ) . " " . $object->getShortText( $outputmode, $skin );
 121+ $numNonDateProperties++;
 122+ $textForProperty .= $pr->getHTMLText( $skin ) . " " . $object->getShortText( $outputmode, $skin );
117123 }
118124 if ( $pr->getMode() == SMWPrintRequest::PRINT_PROP && $pr->getTypeID() == '_dat' ) {
119125 $dates[] = SRFCalendar::formatDateStr( $object );
120126 }
121127 }
 128+ // add the text for this property to
 129+ // the main text, adding on parentheses
 130+ // or commas as needed
 131+ if ( $numNonDateProperties == 1 ) {
 132+ $text .= " (";
 133+ } elseif ( $numNonDateProperties > 1 ) {
 134+ $text .= ", ";
 135+ }
 136+ $text .= $textForProperty;
122137 }
123 - if ( $i > 1 )
 138+ if ( $numNonDateProperties > 0 ) {
124139 $text .= ")";
 140+ }
125141 }
126142 if ( count( $dates ) > 0 ) {
127143 // handle the 'color=' value, whether it came

Status & tagging log