/** * Displays a value, including all relevant links (browse and search by property) * * @param[in] $property SMWPropertyValue The property this value is linked to the subject with * @param[in] $value DataValue The actual value * @param[in] $incoming bool If this is an incoming or outgoing link * * @return string HTML with the link to the article, browse, and search pages */ private function displayValue(\SMWPropertyValue $property, DataValue $dataValue, $incoming) { $linker = smwfGetLinker(); // Allow the DV formatter to access a specific language code $dataValue->setOption(DataValue::OPT_CONTENT_LANGUAGE, Localizer::getInstance()->getPreferredContentLanguage($this->subject->getDataItem())->getCode()); $dataValue->setOption(DataValue::OPT_USER_LANGUAGE, Localizer::getInstance()->getUserLanguage()->getCode()); $dataValue->setContextPage($this->subject->getDataItem()); // Use LOCL formatting where appropriate (date) $dataValue->setOutputFormat('LOCL'); $html = $dataValue->getLongHTMLText($linker); if ($dataValue->getTypeID() === '_wpg' || $dataValue->getTypeID() === '__sob') { $html .= " " . \SMWInfolink::newBrowsingLink('+', $dataValue->getLongWikiText())->getHTML($linker); } elseif ($incoming && $property->isVisible()) { $html .= " " . \SMWInfolink::newInversePropertySearchLink('+', $dataValue->getTitle(), $property->getDataItem()->getLabel(), 'smwsearch')->getHTML($linker); } elseif ($dataValue->getProperty() instanceof DIProperty && $dataValue->getProperty()->getKey() !== '_INST') { $html .= $dataValue->getInfolinkText(SMW_OUTPUT_HTML, $linker); } return $html; }
/** * Hanldes a single property value. Returns an array with data for a single event or false. * * FIXME: 13 arguments, of which a whole bunch are byref... not a good design :) * * @since 1.5.3 * * @param SMWDataValue $object * @param $outputmode * @param SMWPrintRequest $pr * @param boolean $first_col * @param boolean &$hastitle * @param boolean &$hastime * @param boolean $first_value * @param boolean $isEventline * @param string &$curmeta * @param string &$curdata * @param &$date_value * @param boolean &$output * @param array &$positions * * @return false or array */ protected function handlePropertyValue( SMWDataValue $object, $outputmode, SMWPrintRequest $pr, $first_col, &$hastitle, &$hastime, $first_value, $isEventline, &$curmeta, &$curdata, $date_value, &$output, array &$positions ) { global $curarticle, $cururl; $event = false; $l = $this->getLinker( $first_col ); if ( !$hastitle && $object->getTypeID() != '_wpg' ) { // "linking" non-pages in title positions confuses timeline scripts, don't try this $l = null; } if ( $object->getTypeID() == '_wpg' ) { // use shorter "LongText" for wikipage $objectlabel = $object->getLongText( $outputmode, $l ); } else { $objectlabel = $object->getShortText( $outputmode, $l ); } $urlobject = ( $l !== null ); $header = ''; if ( $first_value ) { // find header for current value: if ( $this->mShowHeaders && ( '' != $pr->getLabel() ) ) { $header = $pr->getText( $outputmode, $this->mLinker ) . ': '; } // is this a start date? if ( ( $pr->getMode() == SMWPrintRequest::PRINT_PROP ) && ( $date_value == $this->m_tlstart ) ) { // FIXME: Timeline scripts should support XSD format explicitly. They // currently seem to implement iso8601 which deviates from XSD in cases. // NOTE: We can assume $object to be an SMWDataValue in this case. $curmeta .= Html::element( 'span', array( 'class' => 'smwtlstart' ), $object->getXMLSchemaDate() ); $positions[$object->getHash()] = $object->getXMLSchemaDate(); $hastime = true; } // is this the end date? if ( ( $pr->getMode() == SMWPrintRequest::PRINT_PROP ) && ( $date_value == $this->m_tlend ) ) { // NOTE: We can assume $object to be an SMWDataValue in this case. $curmeta .= Html::element( 'span', array( 'class' => 'smwtlend' ), $object->getXMLSchemaDate( false ) ); } // find title for displaying event if ( !$hastitle ) { $curmeta .= Html::element( 'span', array( 'class' => $urlobject ? 'smwtlurl' : 'smwtltitle' ), $objectlabel ); if ( $pr->getMode() == SMWPrintRequest::PRINT_THIS ) { $curarticle = $object->getShortText( $outputmode, false ); $cururl = $object->getTitle()->getFullUrl(); } // NOTE: type Title of $object implied $hastitle = true; } } elseif ( $output ) { // it *can* happen that output is false here, if the subject was not printed (fixed subject query) and mutliple items appear in the first row $curdata .= ', '; } if ( !$first_col || !$first_value || $isEventline ) { $curdata .= $header . $objectlabel; $output = true; } if ( $isEventline && ( $pr->getMode() == SMWPrintRequest::PRINT_PROP ) && ( $pr->getTypeID() == '_dat' ) && ( '' != $pr->getLabel() ) && ( $date_value != $this->m_tlstart ) && ( $date_value != $this->m_tlend ) ) { $event = array( $object->getXMLSchemaDate(), $pr->getLabel(), $object->getDataItem()->getSortKey(), ); } return $event; }
/** * Displays a value, including all relevant links (browse and search by property) * * @param[in] $property SMWPropertyValue The property this value is linked to the subject with * @param[in] $value SMWDataValue The actual value * @param[in] $incoming bool If this is an incoming or outgoing link * * @return string HTML with the link to the article, browse, and search pages */ private function displayValue( SMWPropertyValue $property, SMWDataValue $dataValue, $incoming ) { $linker = smwfGetLinker(); $html = $dataValue->getLongHTMLText( $linker ); if ( $dataValue->getTypeID() == '_wpg' ) { $html .= " " . SMWInfolink::newBrowsingLink( '+', $dataValue->getLongWikiText() )->getHTML( $linker ); } elseif ( $incoming && $property->isVisible() ) { $html .= " " . SMWInfolink::newInversePropertySearchLink( '+', $dataValue->getTitle(), $property->getDataItem()->getLabel(), 'smwsearch' )->getHTML( $linker ); } else { $html .= $dataValue->getInfolinkText( SMW_OUTPUT_HTML, $linker ); } return $html; }
/** * Handles a single property (SMWPrintRequest) to be displayed for a record (SMWDataValue). * * @since 1.0 * * @param SMWDataValue $object * @param SMWPrintRequest $printRequest * * @return string */ protected function handleResultProperty(SMWDataValue $object, SMWPrintRequest $printRequest) { if ($this->template) { if ($object instanceof SMWWikiPageValue) { return $object->getTitle()->getPrefixedText(); } else { return $object->getLongText(SMW_OUTPUT_WIKI, NULL); } } if ($this->linkAbsolute) { $t = Title::newFromText($printRequest->getHTMLText(NULL), SMW_NS_PROPERTY); if ($t instanceof Title && $t->exists()) { $propertyName = $propertyName = Html::element('a', array('href' => $t->getFullUrl()), $printRequest->getHTMLText(NULL)); } else { $propertyName = $printRequest->getHTMLText(NULL); } } else { $propertyName = $printRequest->getHTMLText(smwfGetLinker()); } if ($this->linkAbsolute) { $hasPage = $object->getTypeID() == '_wpg'; if ($hasPage) { $t = Title::newFromText($object->getLongText($this->outputmode, NULL), NS_MAIN); $hasPage = $t->exists(); } if ($hasPage) { $propertyValue = Html::element('a', array('href' => $t->getFullUrl()), $object->getLongText($this->outputmode, NULL)); } else { $propertyValue = $object->getLongText($this->outputmode, NULL); } } else { $propertyValue = $object->getLongText($this->outputmode, smwfGetLinker()); } return $propertyName . ($propertyName === '' ? '' : ': ') . $propertyValue; }