r93260 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93259‎ | r93260 | r93261 >
Date:11:53, 27 July 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
tried to fix some issues in this huge pile of crap, only partially successful
Modified paths:
  • /trunk/extensions/SemanticResultFormats/Math/SRF_Math.php (modified) (history)
  • /trunk/extensions/SemanticResultFormats/SRF_Messages.php (modified) (history)
  • /trunk/extensions/SemanticResultFormats/Timeline/SRF_Timeline.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticResultFormats/Math/SRF_Math.php
@@ -93,8 +93,6 @@
9494 *
9595 * @param SMWDataValue $dataValue
9696 * @param array $numbers
97 - *
98 - * @return array
9997 */
10098 public static function addNumbersForDataValue( SMWDataValue $dataValue, array &$numbers ) {
10199 // Make use of instanceof instead of getTypeId so that deriving classes will get handled as well.
@@ -123,13 +121,11 @@
124122 *
125123 * @param SMWDataItem $dataItem
126124 * @param array $numbers
127 - *
128 - * @return array
129125 */
130126 public static function addNumbersForDataItem( SMWDataItem $dataItem, array &$numbers ) {
131127 switch ( $dataItem->getDIType() ) {
132 - case SMWDataItem::TYPE_NUMBER: /* case SMWDataItem::TYPE_WIKIPAGE: */
133 - $numbers[] = /* !method_exists( $dataItem, 'getNumber' ) ? $dataItem->getDBkey() : */ $dataItem->getNumber();
 128+ case SMWDataItem::TYPE_NUMBER:
 129+ $numbers[] = $dataItem->getNumber();
134130 break;
135131 case SMWDataItem::TYPE_CONTAINER:
136132 foreach ( $dataItem->getDataItems() as $di ) {
Index: trunk/extensions/SemanticResultFormats/Timeline/SRF_Timeline.php
@@ -6,6 +6,8 @@
77 * @ingroup SemanticResultFormats
88 *
99 * @author Markus Krötzsch
 10+ *
 11+ * FIXME: this code is just insane; rewrite from 0 is probably the only way to get it right
1012 */
1113
1214 /**
@@ -90,9 +92,9 @@
9193 }
9294
9395 // print header
94 - $link = $res->getQueryLink( wfMsgForContent( 'smw_iq_altresults' ) );
 96+ $link = $res->getQueryLink( wfMsgForContent( 'srf-timeline-allresults' ) );
9597 $result = "<div class=\"smwtimeline\" id=\"smwtimeline$smwgIQRunningNumber\" style=\"height: $this->m_tlsize\">";
96 - $result .= '<span class="smwtlcomment">' . wfMsgForContent( 'smw_iq_nojs' ) . ' ' . $link->getText( $outputmode, $this->mLinker ) . '</span>'; // note for people without JavaScript
 98+ $result .= '<span class="smwtlcomment">' . wfMsgForContent( 'srf-timeline-nojs' ) . ' ' . $link->getText( $outputmode, $this->mLinker ) . '</span>'; // note for people without JavaScript
9799
98100 foreach ( $this->m_tlbands as $band ) {
99101 $result .= '<span class="smwtlband" style="display:none;">' . htmlspecialchars( $band ) . '</span>';
@@ -154,6 +156,8 @@
155157 * @return string
156158 */
157159 protected function getEventsHTML( SMWQueryResult $res, $outputmode, $isEventline ) {
 160+ global $curarticle, $cururl; // why not, code flow has reached max insanity already
 161+
158162 $positions = array(); // possible positions, collected to select one for centering
159163 $curcolor = 0; // color cycling is used for eventline
160164
@@ -167,6 +171,7 @@
168172 $hastitle = false; // true as soon as some label for the event was found
169173 $curdata = ''; // current *inner* print data (within some event span)
170174 $curmeta = ''; // current event meta data
 175+ $cururl = '';
171176 $curarticle = ''; // label of current article, if it was found; needed only for eventline labeling
172177 $first_col = true;
173178
@@ -223,7 +228,7 @@
224229
225230 if ( $isEventline ) {
226231 foreach ( $events as $event ) {
227 - $result .= '<span class="smwtlevent" style="display:none;" ><span class="smwtlstart">' . $event[0] . '</span><span class="smwtlurl">' . $event[1] . '</span><span class="smwtlcoloricon">' . $curcolor . '</span>';
 232+ $result .= '<span class="smwtlevent" style="display:none;" ><span class="smwtlstart">' . $event[0] . '</span><span class="smwtlurl">' . str_replace( ' ', '_', $curarticle ) . '</span><span class="smwtlcoloricon">' . $curcolor . '</span>';
228233 if ( $curarticle != '' ) $result .= '<span class="smwtlprefix">' . $curarticle . ' </span>';
229234 $result .= $curdata . '</span>';
230235 $positions[$event[2]] = $event[0];
@@ -279,6 +284,7 @@
280285 */
281286 protected function handlePropertyValue( SMWDataValue $object, $outputmode, SMWPrintRequest $pr, $first_col,
282287 &$hastitle, &$hastime, $first_value, $isEventline, &$curmeta, &$curdata, $date_value, &$output, array &$positions ) {
 288+ global $curarticle, $cururl;
283289
284290 $event = false;
285291
@@ -339,10 +345,12 @@
340346 $objectlabel
341347 );
342348
343 - if ( ( $pr->getMode() == SMWPrintRequest::PRINT_THIS ) ) {
344 - // NOTE: type Title of $object implied
345 - $curarticle = $object->getLongWikiText();
 349+ if ( $pr->getMode() == SMWPrintRequest::PRINT_THIS ) {
 350+ $curarticle = $object->getShortText( $outputmode, false );
 351+ $cururl = $object->getTitle()->getFullUrl();
346352 }
 353+
 354+ // NOTE: type Title of $object implied
347355 $hastitle = true;
348356 }
349357 } elseif ( $output ) {
@@ -358,7 +366,7 @@
359367 if ( $isEventline && ( $pr->getMode() == SMWPrintRequest::PRINT_PROP ) && ( $pr->getTypeID() == '_dat' ) && ( '' != $pr->getLabel() ) && ( $date_value != $this->m_tlstart ) && ( $date_value != $this->m_tlend ) ) {
360368 // SMW >= 1.6
361369 if ( method_exists ( $object, 'getDataItem' ) ) {
362 - $numericValue = $object->getDataItem()->getForCalendarModel( SMWDITime::CM_GREGORIAN );
 370+ $numericValue = $object->getDataItem()->getSortKey();
363371 } // SMW 1.5.x
364372 elseif ( method_exists ( $object, 'getValueKey' ) ) {
365373 $numericValue = $object->getValueKey();
@@ -370,10 +378,10 @@
371379 $event = array(
372380 $object->getXMLSchemaDate(),
373381 $pr->getLabel(),
374 - $numericValue
 382+ $numericValue,
375383 );
376384 }
377 -
 385+
378386 return $event;
379387 }
380388
Index: trunk/extensions/SemanticResultFormats/SRF_Messages.php
@@ -47,7 +47,7 @@
4848 'srf_printername_min' => 'Minimum number',
4949 'srf_paramdesc_limit' => 'The maximum number of pages to query',
5050 'srf_printername_product' => 'Product of numbers',
51 - // format "timeline"
 51+ // formats "timeline" and "eventline"
5252 'srf_printername_timeline' => 'Timeline',
5353 'srf_printername_eventline' => 'Eventline',
5454 'srf_paramdesc_timelinebands' => 'Defines which bands are displayed in the result.',
@@ -55,6 +55,8 @@
5656 'srf_paramdesc_timelinestart' => 'A property name used to define a first time point',
5757 'srf_paramdesc_timelineend' => 'A property name used to define a second time point',
5858 'srf_paramdesc_timelinesize' => 'The height of the timeline (default is 300px)',
 59+ 'srf-timeline-allresults' => 'Further results for this query.',
 60+ 'srf-timeline-nojs' => 'You need to have JavaScript enabled to view the interactive timeline.',
5961
6062 // format "Exhibit"
6163 'srf_paramdesc_views' => 'The views to be displayed',