Example #1
0
 /**
  * Returns the locations found in the provided result row.
  *
  * @since 0.7.3
  *
  * @param array $row Array of SMWResultArray
  *
  * @return array of MapsLocation
  */
 protected function handleResultRow(array $row)
 {
     $locations = array();
     $properties = array();
     $title = '';
     $text = '';
     // Loop throught all fields of the record.
     foreach ($row as $i => $resultArray) {
         /* SMWPrintRequest */
         $printRequest = $resultArray->getPrintRequest();
         // Loop throught all the parts of the field value.
         while (($dataValue = $resultArray->getNextDataValue()) !== false) {
             if ($dataValue->getTypeID() == '_wpg' && $i == 0) {
                 list($title, $text) = $this->handleResultSubject($dataValue);
             } else {
                 if ($dataValue->getTypeID() == '_str' && $i == 0) {
                     $title = $dataValue->getLongText($this->outputmode, null);
                     $text = $dataValue->getLongText($this->outputmode, smwfGetLinker());
                 } else {
                     if ($dataValue->getTypeID() == '_gpo') {
                         $dataItem = $dataValue->getDataItem();
                         $polyHandler = new PolygonHandler($dataItem->getString());
                         $this->geoShapes[$polyHandler->getGeoType()][] = $polyHandler->shapeFromText();
                     } else {
                         if ($dataValue->getTypeID() != '_geo' && $i != 0) {
                             $properties[] = $this->handleResultProperty($dataValue, $printRequest);
                         } else {
                             if ($printRequest->getMode() == SMWPrintRequest::PRINT_PROP && $printRequest->getTypeID() == '_geo') {
                                 $dataItem = $dataValue->getDataItem();
                                 $location = MapsLocation::newFromLatLon($dataItem->getLatitude(), $dataItem->getLongitude());
                                 if ($location->isValid()) {
                                     $locations[] = $location;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if (count($properties) > 0 && $text !== '') {
         $text .= $this->subjectSeparator;
     }
     $icon = $this->getLocationIcon($row);
     $this->geoShapes['locations'] = array_merge($this->geoShapes['locations'], $this->buildLocationsList($locations, $text, $icon, $properties, Title::newFromText($title)));
 }
Example #2
0
 /**
  * Returns the locations found in the provided result row.
  *
  * @since 0.7.3
  *
  * @param array $row Array of SMWResultArray
  *
  * @return array of MapsLocation
  */
 protected function handleResultRow(array $row)
 {
     $locations = array();
     $properties = array();
     $title = '';
     $text = '';
     // Loop throught all fields of the record.
     foreach ($row as $i => $resultArray) {
         /* SMWPrintRequest */
         $printRequest = $resultArray->getPrintRequest();
         // Loop throught all the parts of the field value.
         while (($dataValue = $resultArray->getNextDataValue()) !== false) {
             if ($dataValue->getTypeID() == '_wpg' && $i == 0) {
                 list($title, $text) = $this->handleResultSubject($dataValue);
             } else {
                 if ($dataValue->getTypeID() == '_str' && $i == 0) {
                     $title = $dataValue->getLongText($this->outputmode, null);
                     $text = $dataValue->getLongText($this->outputmode, $GLOBALS['wgUser']->getSkin());
                 } else {
                     if ($dataValue->getTypeID() != '_geo' && $i != 0) {
                         $properties[] = $this->handleResultProperty($dataValue, $printRequest);
                     } else {
                         if ($printRequest->getMode() == SMWPrintRequest::PRINT_PROP && $printRequest->getTypeID() == '_geo') {
                             $dataItem = $dataValue->getDataItem();
                             $location = MapsLocation::newFromLatLon($dataItem->getLatitude(), $dataItem->getLongitude());
                             if ($location->isValid()) {
                                 $locations[] = $location;
                             }
                         }
                     }
                 }
             }
         }
     }
     if (count($properties) > 0 && $text !== '') {
         $text .= $this->subjectSeparator;
     }
     $icon = $this->getLocationIcon($row);
     return $this->buildLocationsList($locations, $title, $text, $icon, $properties);
 }