/** * Static function for creating a new property object from a property * identifier (string) as it might be used internally. This might be * the DB key version of some property title text or the id of a * predefined property (such as '_TYPE'). * @note This function strictly requires an internal identifier, i.e. * predefined properties must be referred to by their ID, and '-' is * not supported for indicating inverses. * @note The resulting property object might be invalid if * the provided name is not allowed. An object is returned * in any case. */ public static function makeProperty($propertyid) { $diProperty = new SMWDIProperty($propertyid); $dvProperty = new SMWPropertyValue('__pro'); $dvProperty->setDataItem($diProperty); return $dvProperty; }
/** * @since 2.1 * * @param DIProperty $property * * @return PrintRequest */ public function newPropertyPrintRequest(DIProperty $property) { $propertyValue = new PropertyValue('__pro'); $propertyValue->setDataItem($property); $instance = new PrintRequest(PrintRequest::PRINT_PROP, $propertyValue->getWikiValue(), $propertyValue); return $instance; }
private function searchForResultsThatCompareEqualToClassOf($categoryName) { $propertyValue = new PropertyValue('__pro'); $propertyValue->setDataItem(new DIProperty('_INST')); $description = new ClassDescription(new DIWikiPage($categoryName, NS_CATEGORY, '')); $description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue)); $query = new Query($description, false, false); $query->querymode = Query::MODE_INSTANCES; return $this->getStore()->getQueryResult($query); }
private function searchForResultsThatCompareEqualToOnlySingularPropertyOf(DIProperty $property) { $propertyValue = new PropertyValue('__pro'); $propertyValue->setDataItem($property); $description = new SomeProperty($property, new ThingDescription()); $description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue)); $query = new Query($description); $query->querymode = Query::MODE_INSTANCES; return $this->getStore()->getQueryResult($query); }
public function testSetLabel() { $propertyValue = new PropertyValue('__pro'); $propertyValue->setDataItem(new DIProperty('Foo')); $instance = new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue); $this->assertEquals(null, $instance->getLabel()); $this->assertEquals(null, $instance->getWikiText()); $instance->setLabel('Bar'); $this->assertEquals('Bar', $instance->getLabel()); $this->assertEquals('Bar', $instance->getWikiText()); }
function setTypeAndPossibleValues() { $proptitle = Title::makeTitleSafe(SMW_NS_PROPERTY, $this->mSemanticProperty); if ($proptitle === null) { return; } $store = smwfGetStore(); // this returns an array of objects $allowed_values = SFUtils::getSMWPropertyValues($store, $proptitle, "Allows value"); $label_formats = SFUtils::getSMWPropertyValues($store, $proptitle, "Has field label format"); if (class_exists('SMWDIProperty')) { // SMW 1.6+ $propValue = SMWDIProperty::newFromUserLabel($this->mSemanticProperty); $this->mPropertyType = $propValue->findPropertyTypeID(); } else { $propValue = SMWPropertyValue::makeUserProperty($this->mSemanticProperty); $this->mPropertyType = $propValue->getPropertyTypeID(); } foreach ($allowed_values as $allowed_value) { // HTML-unencode each value $this->mPossibleValues[] = html_entity_decode($allowed_value); if (count($label_formats) > 0) { $label_format = $label_formats[0]; $prop_instance = SMWDataValueFactory::findTypeID($this->mPropertyType); $label_value = SMWDataValueFactory::newTypeIDValue($prop_instance, $wiki_value); $label_value->setOutputFormat($label_format); $this->mValueLabels[$wiki_value] = html_entity_decode($label_value->getWikiValue()); } } // HACK - if there were any possible values, set the property // type to be 'enumeration', regardless of what the actual type is if (count($this->mPossibleValues) > 0) { $this->mPropertyType = 'enumeration'; } }
public static function printoutFromString( $printout ) { return new SMWPrintRequest( SMWPrintRequest::PRINT_PROP, $printout, SMWPropertyValue::makeUserProperty( $printout ) ); }
private function getValue($value, $escaped) { $this->value = DataValueFactory::getInstance()->newDataValueByProperty($this->property->getDataItem()); $value = $this->unescape($value, $escaped); $this->value->setUserValue($value); return $this->value->isValid() ? $this->value->getWikiValue() : $value; }
protected static function addPropertyValueToSemanticData($propertyName, $valueString, $semanticData) { $propertyDv = SMWPropertyValue::makeUserProperty($propertyName); $propertyDi = $propertyDv->getDataItem(); self::addPropertyDiValueToSemanticData($propertyDi, $valueString, $semanticData); return $propertyDi; }
/** * Read and interpret the given parameters. * * @since 1.8 * @param string $query from the web request as given by MW */ protected function processParameters($query) { global $wgRequest; // get the GET parameters $params = SMWInfolink::decodeParameters($query, false); reset($params); $inputPropertyString = $wgRequest->getText('property', current($params)); $inputValueString = $wgRequest->getText('value', next($params)); $inputValueString = str_replace(' ', ' ', $inputValueString); $inputValueString = str_replace(' ', ' ', $inputValueString); $this->property = SMWPropertyValue::makeUserProperty($inputPropertyString); if (!$this->property->isValid()) { $this->propertystring = $inputPropertyString; $this->value = null; $this->valuestring = $inputValueString; } else { $this->propertystring = $this->property->getWikiValue(); $this->value = SMWDataValueFactory::newPropertyObjectValue($this->property->getDataItem(), $inputValueString); $this->valuestring = $this->value->isValid() ? $this->value->getWikiValue() : $inputValueString; } $limitString = $wgRequest->getVal('limit'); if (is_numeric($limitString)) { $this->limit = intval($limitString); } else { $this->limit = 20; } $offsetString = $wgRequest->getVal('offset'); if (is_numeric($offsetString)) { $this->offset = intval($offsetString); } else { $this->offset = 0; } }
function testCheckIfPropertyRenamed() { // do some checks $page = Title::newFromText("5 cylinder", NS_MAIN); $prop = SMWPropertyValue::makeUserProperty("Torsional moment"); $values = smwfGetStore()->getPropertyValues($page, $prop); $this->assertTrue(count($values) > 0); }
/** * Registers all special properties of this extension in Semantic Media Wiki. * * The language files of the ExtTab extension contain a mapping from special * property constants to their string representation. These mappings are * added to the mapping defined by Semantic Media Wiki. */ function registerSpecialProperties() { global $smwgContLang; foreach ($this->smwSpecialProperties as $key => $prop) { list($typeid, $label) = $prop; SMWPropertyValue::registerProperty($key, $typeid, $label, true); } }
public function setXMLAttribute( $key, $value ) { if ( $value == '' ) throw new MWException( __METHOD__ . ": value cannot be empty" ); if ( $key == 'name' ) { $property = SMWPropertyValue::makeUserProperty( $value ); } else { throw new MWException( __METHOD__ . ": invalid key/value pair: name=property_name" ); } }
public function testUserDefinedBlobProperty() { $property = new DIProperty('SomeBlobProperty'); $property->setPropertyTypeId('_txt'); $dataItem = new DIBlob('SomePropertyBlobValue'); $semanticData = $this->semanticDataFactory->newEmptySemanticData(__METHOD__); $semanticData->addDataValue($this->dataValueFactory->newDataItemValue($dataItem, $property)); $this->getStore()->updateData($semanticData); $this->assertArrayHasKey($property->getKey(), $this->getStore()->getSemanticData($semanticData->getSubject())->getProperties()); $propertyValue = new PropertyValue('__pro'); $propertyValue->setDataItem($property); $description = new SomeProperty($property, new ThingDescription()); $description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue)); $query = new Query($description, false, false); $query->querymode = Query::MODE_INSTANCES; $queryResult = $this->getStore()->getQueryResult($query); $this->queryResultValidator->assertThatQueryResultContains($dataItem, $queryResult); }
public function testCreatePageWithSubobjectParserFunctionForQueryResultLookup() { $this->titles[] = Title::newFromText('CreatePageWithSubobjectParserFunction'); $pageCreator = new PageCreator(); $pageCreator->createPage(Title::newFromText('Has subobject parser function test', SMW_NS_PROPERTY))->doEdit('[[Has type::Page]]'); $property = DIProperty::newFromUserLabel('Has subobject parser function test'); $pageCreator->createPage($this->titles[0])->doEdit('{{#subobject:|Has subobject parser function test=WXYZ|@sortkey=B}}' . '{{#subobject:|Has subobject parser function test=ABCD|@sortkey=A}}' . '{{#subobject:|Has subobject parser function test=ABCD|@sortkey=A}}' . '{{#subobject:|Has subobject parser function test=ABCD|@sortkey=C}}'); $propertyValue = new PropertyValue('__pro'); $propertyValue->setDataItem($property); $description = new SomeProperty($property, new ThingDescription()); $description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue)); $query = new Query($description, false, false); $query->querymode = Query::MODE_COUNT; $result = $this->getStore()->getQueryResult($query); $this->assertEquals(3, $result instanceof \SMWQueryResult ? $result->getCountValue() : $result); $query->querymode = Query::MODE_INSTANCES; $this->assertCount(3, $this->getStore()->getQueryResult($query)->getResults()); }
/** * @dataProvider specialCharactersNameProvider */ public function testSpecialCharactersInQuery($subject, $subobjectId, $property, $dataItem) { $dataValue = $this->dataValueFactory->newDataItemValue($dataItem, $property); $semanticData = $this->semanticDataFactory->newEmptySemanticData($subject); $semanticData->addDataValue($dataValue); $subobject = new Subobject($semanticData->getSubject()->getTitle()); $subobject->setEmptyContainerForId($subobjectId); $subobject->addDataValue($dataValue); $semanticData->addSubobject($subobject); $this->getStore()->updateData($semanticData); $propertyValue = new PropertyValue('__pro'); $propertyValue->setDataItem($property); $description = new SomeProperty($property, new ThingDescription()); $description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue)); $query = new Query($description, false, false); $query->querymode = Query::MODE_INSTANCES; $this->queryResultValidator->assertThatQueryResultHasSubjects(array($semanticData->getSubject(), $subobject->getSubject()), $this->getStore()->getQueryResult($query)); $this->queryResultValidator->assertThatQueryResultContains($dataValue, $this->getStore()->getQueryResult($query)); $this->subjectsToBeCleared = array($semanticData->getSubject(), $subobject->getSubject(), $property->getDIWikiPage()); }
public function testRandomOrder() { $factsheet = $this->fixturesProvider->getFactsheet('Berlin'); $populationValue = $factsheet->getPopulationValue(); $this->getStore()->updateData($factsheet->asEntity()); /** * @query [[Population::+]] */ $property = $this->fixturesProvider->getProperty('Population'); $description = new SomeProperty($property, new ThingDescription()); $propertyValue = new PropertyValue('__pro'); $propertyValue->setDataItem($property); $description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue)); $query = new Query($description, false, false); $query->querymode = Query::MODE_INSTANCES; $query->sort = true; $query->sortkeys = array('Population' => 'RANDOM'); $queryResult = $this->getStore()->getQueryResult($query); $this->assertEquals(3, $queryResult->getCount()); }
public function testSortableRecordQuery() { $this->getStore()->updateData($this->fixturesProvider->getFactsheet('Berlin')->asEntity()); $this->getStore()->updateData($this->fixturesProvider->getFactsheet('Paris')->asEntity()); /** * PopulationDensity is specified as `_rec` * * @query {{#ask: [[PopulationDensity::SomeDistinctValue]] }} */ $populationDensityValue = $this->fixturesProvider->getFactsheet('Berlin')->getPopulationDensityValue(); $description = new SomeProperty($populationDensityValue->getProperty(), $populationDensityValue->getQueryDescription($populationDensityValue->getWikiValue())); $propertyValue = new PropertyValue('__pro'); $propertyValue->setDataItem($populationDensityValue->getProperty()); $query = new Query($description, false, false); $query->querymode = Query::MODE_INSTANCES; $query->sortkeys = array($populationDensityValue->getProperty()->getKey() => 'ASC'); $query->setLimit(100); $query->setExtraPrintouts(array(new PrintRequest(PrintRequest::PRINT_THIS, ''), new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue))); $expected = array($this->fixturesProvider->getFactsheet('Berlin')->asSubject(), $this->fixturesProvider->getFactsheet('Berlin')->getDemographics()->getSubject()); $this->queryResultValidator->assertThatQueryResultHasSubjects($expected, $this->getStore()->getQueryResult($query)); }
private function matchValueArgument(PropertyValue $propertyValue, $propertystring, $valuestring) { if ($propertyValue->getPropertyTypeID() === '_wpg') { $matches = array(); preg_match_all('/\\[\\[([^\\[\\]]*)\\]\\]/u', $valuestring, $matches); $objects = $matches[1]; if (count($objects) == 0) { if (trim($valuestring) !== '') { $this->addDataValue($propertystring, $valuestring); } } else { foreach ($objects as $object) { $this->addDataValue($propertystring, $object); } } } elseif (trim($valuestring) !== '') { $this->addDataValue($propertystring, $valuestring); } // $value = \SMW\DataValueFactory::getInstance()->newDataValueByProperty( $property->getDataItem(), $valuestring ); // if (!$value->isValid()) continue; }
/** * Method for handling the declare parser function. * * @since 1.5.3 * * @param Parser $parser * @param PPFrame $frame * @param array $args */ public static function render(Parser &$parser, PPFrame $frame, array $args) { if ($frame->isTemplate()) { foreach ($args as $arg) { if (trim($arg) !== '') { $expanded = trim($frame->expand($arg)); $parts = explode('=', $expanded, 2); if (count($parts) == 1) { $propertystring = $expanded; $argumentname = $expanded; } else { $propertystring = $parts[0]; $argumentname = $parts[1]; } $property = SMWPropertyValue::makeUserProperty($propertystring); $argument = $frame->getArgument($argumentname); $valuestring = $frame->expand($argument); if ($property->isValid()) { $type = $property->getPropertyTypeID(); if ($type == '_wpg') { $matches = array(); preg_match_all('/\\[\\[([^\\[\\]]*)\\]\\]/u', $valuestring, $matches); $objects = $matches[1]; if (count($objects) == 0) { if (trim($valuestring) !== '') { SMWParseData::addProperty($propertystring, $valuestring, false, $parser, true); } } else { foreach ($objects as $object) { SMWParseData::addProperty($propertystring, $object, false, $parser, true); } } } elseif (trim($valuestring) !== '') { SMWParseData::addProperty($propertystring, $valuestring, false, $parser, true); } // $value = SMWDataValueFactory::newPropertyObjectValue( $property->getDataItem(), $valuestring ); // if (!$value->isValid()) continue; } } } } else { // @todo Save as metadata } global $wgTitle; if (!is_null($wgTitle) && $wgTitle->isSpecialPage()) { global $wgOut; SMWOutputs::commitToOutputPage($wgOut); } else { SMWOutputs::commitToParser($parser); } return ''; }
public function addPropertyAndValue( $propName, $value ) { // SMW 1.6+ if ( class_exists( 'SMWDIProperty' ) ) { $property = SMWDIProperty::newFromUserLabel( $propName ); } else { $property = SMWPropertyValue::makeUserProperty( $propName ); } $dataValue = SMWDataValueFactory::newPropertyObjectValue( $property, $value ); if ( $dataValue->isValid() ) { $this->mPropertyValuePairs[] = array( $property, $dataValue ); } // else - show an error message? }
/** * Helper function to handle getPropertyValues() in both SMW 1.6 * and earlier versions. * * @param SMWStore $store * @param string $pageName * @param integer $pageNamespace * @param string $propID * @param null|SMWRequestOptions $requestOptions * * @return array of SMWDataItem */ public static function getSMWPropertyValues( SMWStore $store, $pageName, $pageNamespace, $propID, $requestOptions = null ) { // SMWDIProperty was added in SMW 1.6 if ( class_exists( 'SMWDIProperty' ) ) { $pageName = str_replace( ' ', '_', $pageName ); $page = new SMWDIWikiPage( $pageName, $pageNamespace, null ); $property = new SMWDIProperty( $propID ); return $store->getPropertyValues( $page, $property, $requestOptions ); } else { $title = Title::makeTitleSafe( $pageNamespace, $pageName ); $property = SMWPropertyValue::makeProperty( $propID ); return $store->getPropertyValues( $title, $property, $requestOptions ); } }
/** * Must be called from derived class to initialize the member variables. */ protected function SMWSemanticStore(Title $domainRangeHintRelation, Title $minCard, Title $maxCard, Title $transitiveCat, Title $symetricalCat, Title $inverseOf) { $this->domainRangeHintRelation = $domainRangeHintRelation; $this->maxCard = $maxCard; $this->minCard = $minCard; $this->transitiveCat = $transitiveCat; $this->symetricalCat = $symetricalCat; $this->inverseOf = $inverseOf; $this->domainRangeHintProp = SMWPropertyValue::makeUserProperty($this->domainRangeHintRelation->getDBkey()); $this->minCardProp = SMWPropertyValue::makeUserProperty($this->minCard->getDBkey()); $this->maxCardProp = SMWPropertyValue::makeUserProperty($this->maxCard->getDBkey()); $this->inverseOfProp = SMWPropertyValue::makeUserProperty($this->inverseOf->getDBkey()); }
/** * Refresh the concept cache for the given concept. * * @param $concept Title */ public function refreshConceptCache($concept) { global $smwgQMaxLimit, $smwgQConceptFeatures, $wgDBtype; $cid = $this->m_store->getSMWPageID($concept->getDBkey(), SMW_NS_CONCEPT, ''); $cid_c = $this->m_store->getSMWPageID($concept->getDBkey(), SMW_NS_CONCEPT, '', false); if ($cid != $cid_c) { $this->m_errors[] = "Skipping redirect concept."; return $this->m_errors; } $dv = end($this->m_store->getPropertyValues($concept, SMWPropertyValue::makeProperty('_CONC'))); $desctxt = $dv !== false ? $dv->getWikiValue() : false; $this->m_errors = array(); if ($desctxt) { // concept found $this->m_qmode = SMWQuery::MODE_INSTANCES; $this->m_queries = array(); $this->m_hierarchies = array(); $this->m_querylog = array(); $this->m_sortkeys = array(); SMWSQLStore2Query::$qnum = 0; // Pre-process query: $qp = new SMWQueryParser($smwgQConceptFeatures); $desc = $qp->getQueryDescription($desctxt); $qid = $this->compileQueries($desc); $this->executeQueries($this->m_queries[$qid]); // execute query tree, resolve all dependencies $qobj = $this->m_queries[$qid]; if ($qobj->joinfield === '') { return; } // Update database: $this->m_dbs->delete('smw_conccache', array('o_id' => $cid), 'SMW::refreshConceptCache'); if ($wgDBtype == 'postgres') { // PostgresQL: no INSERT IGNORE, check for duplicates explicitly $where = $qobj->where . ($qobj->where ? ' AND ' : '') . 'NOT EXISTS (SELECT NULL FROM ' . $this->m_dbs->tableName('smw_conccache') . ' WHERE ' . $this->m_dbs->tablename('smw_conccache') . '.s_id = ' . $qobj->alias . '.s_id ' . ' AND ' . $this->m_dbs->tablename('smw_conccache') . '.o_id = ' . $qobj->alias . '.o_id )'; } else { // MySQL just uses INSERT IGNORE, no extra conditions $where = $qobj->where; } $this->m_dbs->query("INSERT " . ($wgDBtype == 'postgres' ? "" : "IGNORE ") . "INTO " . $this->m_dbs->tableName('smw_conccache') . " SELECT DISTINCT {$qobj->joinfield} AS s_id, {$cid} AS o_id FROM " . $this->m_dbs->tableName($qobj->jointable) . " AS {$qobj->alias}" . $qobj->from . ($where ? " WHERE " : '') . $where . " LIMIT {$smwgQMaxLimit}", 'SMW::refreshConceptCache'); $this->m_dbs->update('smw_conc2', array('cache_date' => strtotime("now"), 'cache_count' => $this->m_dbs->affectedRows()), array('s_id' => $cid), 'SMW::refreshConceptCache'); } else { // just delete old data if there is any $this->m_dbs->delete('smw_conccache', array('o_id' => $cid), 'SMW::refreshConceptCache'); $this->m_dbs->update('smw_conc2', array('cache_date' => null, 'cache_count' => null), array('s_id' => $cid), 'SMW::refreshConceptCache'); $this->m_errors[] = "No concept description found."; } $this->cleanUp(); return $this->m_errors; }
/** * @since 2.1 */ public function initialize() { $params = explode('/', $this->queryString); reset($params); // Remove empty elements $params = array_filter($params, 'strlen'); $property = isset($this->requestOptions['property']) ? $this->requestOptions['property'] : current($params); $value = isset($this->requestOptions['value']) ? $this->requestOptions['value'] : next($params); $property = $this->urlEncoder->decode($property); $value = str_replace(array('-25'), array('%'), $value); $this->property = PropertyValue::makeUserProperty($property); if (!$this->property->isValid()) { $this->propertyString = $property; $this->value = null; $this->valueString = $value; } else { $this->propertyString = $this->property->getWikiValue(); $this->value = DataValueFactory::getInstance()->newPropertyObjectValue($this->property->getDataItem(), $this->urlEncoder->decode($value)); $this->valueString = $this->value->isValid() ? $this->value->getWikiValue() : $value; } $this->setLimit(); $this->setOffset(); $this->setNearbySearch(); }
function initProperties() { if (class_exists('SMWDIProperty')) { SMWDIProperty::registerProperty("__SIA_RECTCOORDS", '_str', "SIArectangleCoordinates", true); SMWDIProperty::registerProperty("__SIA_IMG_URL", '_str', "SIAimageURL", true); SMWDIProperty::registerProperty("__SIA_ANNOTATED", '_str', "SIAannotatedImage", true); SMWDIProperty::registerProperty("__SIA_CREATED_BY", '_str', "SIAcreatedBy", true); } else { SMWPropertyValue::registerProperty("__SIA_RECTCOORDS", '_str', "SIArectangleCoordinates", true); SMWPropertyValue::registerProperty("__SIA_IMG_URL", '_str', "SIAimageURL", true); SMWPropertyValue::registerProperty("__SIA_ANNOTATED", '_str', "SIAannotatedImage", true); SMWPropertyValue::registerProperty("__SIA_CREATED_BY", '_str', "SIAcreatedBy", true); } return true; }
public function testSubpropertyToQueryFromTopHierarchy() { if (!$this->getStore() instanceof \SMWSQLStore3) { $this->markTestSkipped("Subproperty/property hierarchies are currently only supported by the SQLStore"); } $semanticDataOfSpouse = $this->semanticDataFactory->setSubject(new DIWikiPage('Spouse', SMW_NS_PROPERTY, ''))->newEmptySemanticData(); $property = new DIProperty('Wife'); $property->setPropertyTypeId('_wpg'); $this->addPropertyHierarchy($property, 'Spouse'); $dataValue = $this->dataValueFactory->newPropertyObjectValue($property, 'Lien'); $semanticData = $this->semanticDataFactory->newEmptySemanticData(__METHOD__); $semanticData->addDataValue($dataValue); $this->getStore()->updateData($semanticDataOfSpouse); $this->getStore()->updateData($semanticData); $description = new SomeProperty(new DIProperty('Spouse'), new ThingDescription()); $propertyValue = new PropertyValue('__pro'); $propertyValue->setDataItem($property); $description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue)); $query = new Query($description, false, false); $query->querymode = Query::MODE_INSTANCES; $queryResult = $this->getStore()->getQueryResult($query); $this->queryResultValidator->assertThatQueryResultContains($dataValue, $queryResult); $this->subjectsToBeCleared = array($semanticData->getSubject(), $semanticDataOfSpouse->getSubject(), $property->getDiWikiPage()); }
public function __construct(LingoMessageLog &$messages = null) { parent::__construct($messages); // get the store $store = smwfGetStore(); // Create query $desc = new SMWSomeProperty(new SMWDIProperty('___glt'), new SMWThingDescription()); $desc->addPrintRequest(new SMWPrintRequest(SMWPrintRequest::PRINT_PROP, null, SMWPropertyValue::makeProperty('___glt'))); $desc->addPrintRequest(new SMWPrintRequest(SMWPrintRequest::PRINT_PROP, null, SMWPropertyValue::makeProperty('___gld'))); $desc->addPrintRequest(new SMWPrintRequest(SMWPrintRequest::PRINT_PROP, null, SMWPropertyValue::makeProperty('___gll'))); $query = new SMWQuery($desc, false, false); $query->sort = true; $query->sortkeys['___glt'] = 'ASC'; // get the query result $this->mQueryResult = $store->getQueryResult($query); }
protected static function addPropertyValueToSemanticData($propertyName, $valueString, $semanticData) { $propertyDv = SMWPropertyValue::makeUserProperty($propertyName); $propertyDi = $propertyDv->getDataItem(); if (!$propertyDi->isInverse()) { $valueDv = SMWDataValueFactory::newPropertyObjectValue($propertyDi, $valueString, false, $semanticData->getSubject()); $semanticData->addPropertyObjectValue($propertyDi, $valueDv->getDataItem()); // Take note of the error for storage (do this here and not in storage, thus avoiding duplicates). if (!$valueDv->isValid()) { $semanticData->addPropertyObjectValue(new SMWDIProperty('_ERRP'), $propertyDi->getDiWikiPage()); self::$m_errors = array_merge(self::$m_errors, $valueDv->getErrors()); } } else { self::$m_errors[] = wfMsgForContent('smw_noinvannot'); } }
/** * Main entry point for Special Pages. Gets all required parameters. * * @param[in] $query string Given by MediaWiki */ public function execute( $query ) { global $wgRequest, $wgOut; $this->setHeaders(); // get the GET parameters $this->propertystring = $wgRequest->getText( 'property' ); $this->valuestring = $wgRequest->getText( 'value' ); $params = SMWInfolink::decodeParameters( $query, false ); reset( $params ); // no GET parameters? Then try the URL if ( $this->propertystring === '' ) $this->propertystring = current( $params ); if ( $this->valuestring === '' ) $this->valuestring = next( $params ); $this->valuestring = str_replace( ' ', ' ', $this->valuestring ); $this->valuestring = str_replace( ' ', ' ', $this->valuestring ); $this->property = SMWPropertyValue::makeUserProperty( $this->propertystring ); if ( !$this->property->isValid() ) { $this->propertystring = ''; } else { $this->propertystring = $this->property->getWikiValue(); $this->value = SMWDataValueFactory::newPropertyObjectValue( $this->property->getDataItem(), $this->valuestring ); if ( $this->value->isValid() ) { $this->valuestring = $this->value->getWikiValue(); } else { $this->value = null; } } $limitstring = $wgRequest->getVal( 'limit' ); if ( is_numeric( $limitstring ) ) { $this->limit = intval( $limitstring ); } $offsetstring = $wgRequest->getVal( 'offset' ); if ( is_numeric( $offsetstring ) ) { $this->offset = intval( $offsetstring ); } $wgOut->addHTML( $this->displaySearchByProperty() ); $wgOut->addHTML( $this->queryForm() ); SMWOutputs::commitToOutputPage( $wgOut ); // make sure locally collected output data is pushed to the output! }