private function findBasePropertyToRedirectFor($label)
 {
     $property = new DIProperty(PropertyRegistry::getInstance()->findPropertyIdByLabel($label));
     if ($property->getLabel() !== '' && $label !== $property->getLabel()) {
         $outputPage = $this->getContext()->getOutput();
         $outputPage->redirect($property->getDiWikiPage()->getTitle()->getFullURL());
     }
 }
 public function testCorrectInversePrefixForPredefinedProperty()
 {
     $property = new DIProperty('_SOBJ', true);
     $this->assertTrue($property->isInverse());
     $label = $property->getLabel();
     $this->assertEquals('-', $label[0]);
 }
 public function getQueryString($asValue = false)
 {
     $subDescription = $this->description;
     $propertyChainString = $this->property->getLabel();
     $propertyname = $propertyChainString;
     while ($propertyname !== '' && $subDescription instanceof SomeProperty) {
         // try to use property chain syntax
         $propertyname = $subDescription->getProperty()->getLabel();
         if ($propertyname !== '') {
             $propertyChainString .= '.' . $propertyname;
             $subDescription = $subDescription->getDescription();
         }
     }
     if ($asValue) {
         return '<q>[[' . $propertyChainString . '::' . $subDescription->getQueryString(true) . ']]</q>';
     }
     return '[[' . $propertyChainString . '::' . $subDescription->getQueryString(true) . ']]';
 }
 /**
  * Produce a formatted string representation for showing a property in
  * the list of unused properties.
  *
  * @since 1.8
  *
  * @param DIProperty $property
  *
  * @return string
  */
 protected function formatPropertyItem(DIProperty $property)
 {
     // Clear formatter before invoking messages and
     // avoid having previous data to be present
     $this->getMessageFormatter()->clear();
     if ($property->isUserDefined()) {
         $title = $property->getDiWikiPage()->getTitle();
         if (!$title instanceof \Title) {
             return '';
         }
         $propertyLink = $this->getLinker()->link($title, $property->getLabel());
         $types = $this->store->getPropertyValues($property->getDiWikiPage(), new DIProperty('_TYPE'));
         if (count($types) >= 1) {
             $typeDataValue = DataValueFactory::getInstance()->newDataItemValue(current($types), new DIProperty('_TYPE'));
         } else {
             $typeDataValue = SMWTypesValue::newFromTypeId('_wpg');
             $this->getMessageFormatter()->addFromKey('smw_propertylackstype', $typeDataValue->getLongHTMLText());
         }
     } else {
         $typeDataValue = SMWTypesValue::newFromTypeId($property->findPropertyTypeID());
         $propertyLink = DataValueFactory::getInstance()->newDataItemValue($property, null)->getShortHtmlText($this->getLinker());
     }
     return $this->msg('smw_unusedproperty_template', $propertyLink, $typeDataValue->getLongHTMLText($this->getLinker()))->text() . ' ' . $this->getMessageFormatter()->getHtml();
 }
 public function descriptionProvider()
 {
     $stringBuilder = UtilityFactory::getInstance()->newStringBuilder();
     # 0
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\FalseCondition';
     $description = new SomeProperty(new DIProperty('Foo'), new Disjunction());
     $orderByProperty = null;
     $sortkeys = array();
     $expected = $stringBuilder->addString('<http://www.example.org> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#nothing> .')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 1
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $description = new SomeProperty(new DIProperty('Foo'), new ThingDescription());
     $orderByProperty = null;
     $sortkeys = array();
     $expected = $stringBuilder->addString('?result property:Foo ?v1 .')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 2 Inverse
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $description = new SomeProperty(new DIProperty('Foo', true), new ThingDescription());
     $orderByProperty = null;
     $sortkeys = array();
     $expected = $stringBuilder->addString('?v1 property:Foo ?result .')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 3
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $description = new SomeProperty(new DIProperty('Foo'), new ThingDescription());
     $orderByProperty = new DIProperty('Foo');
     $sortkeys = array();
     $expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Foo ?v1 .')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 4
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $property = new DIProperty('Foo');
     $property->setPropertyTypeId('_txt');
     $description = new SomeProperty($property, new ValueDescription(new DIBlob('SomePropertyBlobValue')));
     $orderByProperty = null;
     $sortkeys = array();
     $expected = $stringBuilder->addString('?result property:Foo "SomePropertyBlobValue" .')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 5
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $property = new DIProperty('Foo');
     $property->setPropertyTypeId('_txt');
     $description = new SomeProperty($property, new ValueDescription(new DIBlob('SomePropertyBlobValue')));
     $orderByProperty = $property;
     $sortkeys = array();
     $expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Foo "SomePropertyBlobValue" .')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 6
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $property = new DIProperty('Foo');
     $property->setPropertyTypeId('_wpg');
     $propertyValue = new DIWikiPage('SomePropertyPageValue', NS_HELP);
     $propertyValueName = \SMWTurtleSerializer::getTurtleNameForExpElement(\SMWExporter::getInstance()->getResourceElementForWikiPage($propertyValue));
     $description = new SomeProperty($property, new ValueDescription($propertyValue));
     $orderByProperty = $property;
     $sortkeys = array();
     $expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString("?result property:Foo {$propertyValueName} .")->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 7
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $property = new DIProperty('Foo');
     $property->setPropertyTypeId('_wpg');
     $description = new SomeProperty($property, new ValueDescription(new DIWikiPage('SomePropertyPageValue', NS_HELP), $property, SMW_CMP_LEQ));
     $orderByProperty = new DIProperty('SomePropertyPageValue');
     $sortkeys = array();
     $expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Foo ?v1 .')->addNewLine()->addString('FILTER( ?v1sk <= "SomePropertyPageValue" )')->addNewLine()->addString('?v1 swivt:wikiPageSortKey ?v1sk .')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 8
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $property = new DIProperty('Foo');
     $property->setPropertyTypeId('_wpg');
     $description = new SomeProperty($property, new ValueDescription(new DIWikiPage('SomePropertyPageValue', NS_HELP), $property, SMW_CMP_LEQ));
     $description = new SomeProperty(new DIProperty('Bar'), $description);
     $orderByProperty = new DIProperty('Bar');
     $sortkeys = array('Foo' => 'ASC');
     $expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Bar ?v1 .')->addNewLine()->addString('{ ?v1 property:Foo ?v2 .')->addNewLine()->addString('FILTER( ?v2sk <= "SomePropertyPageValue" )')->addNewLine()->addString('?v2 swivt:wikiPageSortKey ?v2sk .')->addNewLine()->addString('}')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 9 Inverse -> ?v1 property:Foo ?v2 vs. ?v2 property:Foo ?v1
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $property = new DIProperty('Foo', true);
     $property->setPropertyTypeId('_wpg');
     $description = new SomeProperty($property, new ValueDescription(new DIWikiPage('SomePropertyPageValue', NS_HELP), $property, SMW_CMP_LEQ));
     $description = new SomeProperty(new DIProperty('Bar'), $description);
     $expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Bar ?v1 .')->addNewLine()->addString('{ ?v2 property:Foo ?v1 .')->addNewLine()->addString('FILTER( ?v2sk <= "SomePropertyPageValue" )')->addNewLine()->addString('?v2 swivt:wikiPageSortKey ?v2sk .')->addNewLine()->addString('}')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 10
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $property = new DIProperty('_MDAT');
     $description = new SomeProperty($property, new ThingDescription());
     $sortkeys = array('_MDAT' => 'ASC');
     $propertyLabel = str_replace(' ', '_', $property->getLabel());
     $expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString("?result property:{$propertyLabel}-23aux ?v1 .")->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 11, issue 556
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $property = new DIProperty('Foo');
     $property->setPropertyTypeId('_txt');
     $description = new SomeProperty($property, new Disjunction(array(new ValueDescription(new DIBlob('Bar')), new ValueDescription(new DIBlob('Baz')))));
     $expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Foo ?v1 .')->addNewLine()->addString('FILTER( ?v1 = "Bar" || ?v1 = "Baz" )')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 12 use the rdf/owl equivalent for a predefined property
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $property = new DIProperty('_SUBC');
     $description = new SomeProperty($property, new ValueDescription(new DIBlob('Bar')));
     $expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result rdfs:subClassOf "Bar" .')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 13
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $property = new DIProperty('_SUBP');
     $description = new SomeProperty($property, new ValueDescription(new DIWikiPage('Bar', SMW_NS_PROPERTY)));
     $expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result rdfs:subPropertyOf property:Bar .')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 14 aux-property
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $property = new DIProperty('_MDAT');
     $description = new SomeProperty($property, new ValueDescription(new DITime(1, 1970, 01, 01, 1, 1)));
     $expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Modification_date-23aux "2440587.5423611"^^xsd:double .')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     return $provider;
 }
 public function parameterDataProvider()
 {
     $provider = array();
     // Anonymous identifier
     // {{#subobject:
     // |Foo=bar
     // }}
     $provider[] = array(array('', 'Foo=bar'), array('hasErrors' => false, 'identifier' => '_', 'propertyCount' => 1, 'propertyLabels' => 'Foo', 'propertyValues' => 'Bar'));
     // Anonymous identifier
     // {{#subobject:-
     // |Foo=1001 9009
     // }}
     $provider[] = array(array('-', 'Foo=1001 9009'), array('hasErrors' => false, 'identifier' => '_', 'propertyCount' => 1, 'propertyLabels' => 'Foo', 'propertyValues' => '1001 9009'));
     // Named identifier
     // {{#subobject:FooBar
     // |FooBar=Bar foo
     // }}
     $provider[] = array(array('FooBar', 'FooBar=Bar foo'), array('hasErrors' => false, 'identifier' => 'FooBar', 'propertyCount' => 1, 'propertyLabels' => 'FooBar', 'propertyValues' => 'Bar foo'));
     // Named identifier
     // {{#subobject:Foo bar
     // |Foo=Help:Bar
     // }}
     $provider[] = array(array('Foo bar', 'Foo=Help:Bar'), array('hasErrors' => false, 'identifier' => 'Foo_bar', 'propertyCount' => 1, 'propertyLabels' => 'Foo', 'propertyValues' => 'Help:Bar'));
     // Named identifier
     // {{#subobject: Foo bar foo
     // |Bar=foo Bar
     // }}
     $provider[] = array(array(' Foo bar foo ', 'Bar=foo Bar'), array('hasErrors' => false, 'identifier' => 'Foo_bar_foo', 'propertyCount' => 1, 'propertyLabels' => 'Bar', 'propertyValues' => 'Foo Bar'));
     // Named identifier
     // {{#subobject: Foo bar foo
     // |状況=超やばい
     // |Bar=http://www.semantic-mediawiki.org/w/index.php?title=Subobject
     // }}
     $provider[] = array(array(' Foo bar foo ', '状況=超やばい', 'Bar=http://www.semantic-mediawiki.org/w/index.php?title=Subobject'), array('hasErrors' => false, 'identifier' => 'Foo_bar_foo', 'propertyCount' => 2, 'propertyLabels' => array('状況', 'Bar'), 'propertyValues' => array('超やばい', 'Http://www.semantic-mediawiki.org/w/index.php?title=Subobject')));
     // Returns an error due to wrong declaration (see Modification date)
     // Get the right language for an error object
     $diPropertyError = new DIProperty(DIProperty::TYPE_ERROR);
     // {{#subobject: Foo bar foo
     // |Bar=foo Bar
     // |Modification date=foo Bar
     // }}
     $provider[] = array(array(' Foo bar foo ', 'Bar=foo Bar', 'Modification date=foo Bar'), array('hasErrors' => true, 'identifier' => 'Foo_bar_foo', 'propertyCount' => 2, 'propertyLabels' => array('Bar', $diPropertyError->getLabel()), 'propertyValues' => array('Foo Bar', 'Modification date')));
     return $provider;
 }
 public function parameterDataProvider()
 {
     $helpNS = Localizer::getInstance()->getNamespaceTextById(NS_HELP);
     $provider = array();
     #0 Anonymous identifier
     // {{#subobject:
     // |Foo=bar
     // }}
     $provider[] = array(array('', 'Foo=bar'), array('hasErrors' => false, 'identifier' => '_', 'propertyCount' => 1, 'propertyLabels' => 'Foo', 'propertyValues' => 'Bar'));
     #1 Anonymous identifier
     // {{#subobject:-
     // |Foo=1001 9009
     // }}
     $provider[] = array(array('-', 'Foo=1001 9009'), array('hasErrors' => false, 'identifier' => '_', 'propertyCount' => 1, 'propertyLabels' => 'Foo', 'propertyValues' => '1001 9009'));
     #2 Named identifier
     // {{#subobject:FooBar
     // |FooBar=Bar foo
     // }}
     $provider[] = array(array('FooBar', 'FooBar=Bar foo'), array('hasErrors' => false, 'identifier' => 'FooBar', 'propertyCount' => 1, 'propertyLabels' => 'FooBar', 'propertyValues' => 'Bar foo'));
     #3 Named identifier
     // {{#subobject:Foo bar
     // |Foo=Help:Bar
     // }}
     $provider[] = array(array('Foo bar', 'Foo=Help:Bar'), array('hasErrors' => false, 'identifier' => 'Foo_bar', 'propertyCount' => 1, 'propertyLabels' => 'Foo', 'propertyValues' => "{$helpNS}:Bar"));
     #4 Named identifier
     // {{#subobject: Foo bar foo
     // |Bar=foo Bar
     // }}
     $provider[] = array(array(' Foo bar foo ', 'Bar=foo Bar'), array('hasErrors' => false, 'identifier' => 'Foo_bar_foo', 'propertyCount' => 1, 'propertyLabels' => 'Bar', 'propertyValues' => 'Foo Bar'));
     #5 Named identifier
     // {{#subobject: Foo bar foo
     // |状況=超やばい
     // |Bar=http://www.semantic-mediawiki.org/w/index.php?title=Subobject
     // }}
     $provider[] = array(array(' Foo bar foo ', '状況=超やばい', 'Bar=http://www.semantic-mediawiki.org/w/index.php?title=Subobject'), array('hasErrors' => false, 'identifier' => 'Foo_bar_foo', 'propertyCount' => 2, 'propertyLabels' => array('状況', 'Bar'), 'propertyValues' => array('超やばい', 'Http://www.semantic-mediawiki.org/w/index.php?title=Subobject')));
     #6 {{#subobject: Foo bar foo
     // |Bar=foo Bar
     // |Modification date=foo Bar
     // }}
     $provider[] = array(array(' Foo bar foo ', 'Bar=foo Bar', 'Modification date=foo Bar'), array('hasErrors' => true, 'identifier' => 'Foo_bar_foo', 'propertyCount' => 1, 'propertyLabels' => array('Bar'), 'propertyValues' => array('Foo Bar')));
     #7 {{#subobject: Foo bar foo
     // |Bar=foo Bar
     // |-Foo=foo Bar
     // }}
     $provider[] = array(array(' Foo bar foo ', 'Bar=foo Bar', '-Foo=foo Bar'), array('hasErrors' => true, 'identifier' => 'Foo_bar_foo', 'propertyCount' => 1, 'propertyLabels' => array('Bar'), 'propertyValues' => array('Foo Bar')));
     // An empty subobject is not being classified as valid (to create an object)
     #8 {{#subobject: Foo bar foo
     // |Bar=foo Bar
     // |Modification date=1 Jan 1970
     // }}
     $provider[] = array(array(' Foo bar foo ', 'Modification date=1 Jan 1970'), array('hasErrors' => true, 'identifier' => 'Foo_bar_foo', 'propertyCount' => 0));
     // Get the right language for an error object
     $diPropertyError = new DIProperty(DIProperty::TYPE_ERROR);
     #9 {{#subobject: Foo bar foo
     // |Bar=foo Bar
     // |Date=Foo
     // }}
     $provider[] = array(array(' Foo bar foo ', 'Date=Foo'), array('hasErrors' => true, 'identifier' => 'Foo_bar_foo', 'propertyCount' => 1, 'propertyLabels' => array($diPropertyError->getLabel()), 'propertyValues' => array('Date')));
     return $provider;
 }
 private function assertContainsPropertyLabels($labels, DIProperty $property)
 {
     $this->assertContains($property->getLabel(), $labels, __METHOD__ . " asserts property label for '{$property->getKey()}' with ({$this->formatAsString($labels)})");
 }
 private function transformPropertyLabelToAuxiliary(DIProperty $property)
 {
     return str_replace(' ', '_', $property->getLabel());
 }
 public function descriptionProvider()
 {
     $stringBuilder = UtilityFactory::getInstance()->newStringBuilder();
     # 0
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\FalseCondition';
     $description = new SomeProperty(new DIProperty('Foo'), new Disjunction());
     $orderByProperty = null;
     $sortkeys = array();
     $expected = $stringBuilder->addString('<http://www.example.org> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#nothing> .')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 1
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $description = new SomeProperty(new DIProperty('Foo'), new ThingDescription());
     $orderByProperty = null;
     $sortkeys = array();
     $expected = $stringBuilder->addString('?result property:Foo ?v1 .')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 2 Inverse
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $description = new SomeProperty(new DIProperty('Foo', true), new ThingDescription());
     $orderByProperty = null;
     $sortkeys = array();
     $expected = $stringBuilder->addString('?v1 property:Foo ?result .')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 3
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $description = new SomeProperty(new DIProperty('Foo'), new ThingDescription());
     $orderByProperty = new DIProperty('Foo');
     $sortkeys = array();
     $expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Foo ?v1 .')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 4
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $property = new DIProperty('Foo');
     $property->setPropertyTypeId('_txt');
     $description = new SomeProperty($property, new ValueDescription(new DIBlob('SomePropertyBlobValue')));
     $orderByProperty = null;
     $sortkeys = array();
     $expected = $stringBuilder->addString('?result property:Foo "SomePropertyBlobValue" .')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 5
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $property = new DIProperty('Foo');
     $property->setPropertyTypeId('_txt');
     $description = new SomeProperty($property, new ValueDescription(new DIBlob('SomePropertyBlobValue')));
     $orderByProperty = $property;
     $sortkeys = array();
     $expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Foo "SomePropertyBlobValue" .')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 6
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $property = new DIProperty('Foo');
     $property->setPropertyTypeId('_wpg');
     $description = new SomeProperty($property, new ValueDescription(new DIWikiPage('SomePropertyPageValue', NS_HELP)));
     $orderByProperty = $property;
     $sortkeys = array();
     $expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Foo wiki:Help-3ASomePropertyPageValue .')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 7
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $property = new DIProperty('Foo');
     $property->setPropertyTypeId('_wpg');
     $description = new SomeProperty($property, new ValueDescription(new DIWikiPage('SomePropertyPageValue', NS_HELP), $property, SMW_CMP_LEQ));
     $orderByProperty = new DIProperty('SomePropertyPageValue');
     $sortkeys = array();
     $expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Foo ?v1 .')->addNewLine()->addString('FILTER( ?v1sk <= "SomePropertyPageValue" )')->addNewLine()->addString('?v1 swivt:wikiPageSortKey ?v1sk .')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 8
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $property = new DIProperty('Foo');
     $property->setPropertyTypeId('_wpg');
     $description = new SomeProperty($property, new ValueDescription(new DIWikiPage('SomePropertyPageValue', NS_HELP), $property, SMW_CMP_LEQ));
     $description = new SomeProperty(new DIProperty('Bar'), $description);
     $orderByProperty = new DIProperty('Bar');
     $sortkeys = array('Foo' => 'ASC');
     $expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Bar ?v1 .')->addNewLine()->addString('{ ?v1 property:Foo ?v2 .')->addNewLine()->addString('FILTER( ?v2sk <= "SomePropertyPageValue" )')->addNewLine()->addString('?v2 swivt:wikiPageSortKey ?v2sk .')->addNewLine()->addString('}')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 9 Inverse -> ?v1 property:Foo ?v2 vs. ?v2 property:Foo ?v1
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $property = new DIProperty('Foo', true);
     $property->setPropertyTypeId('_wpg');
     $description = new SomeProperty($property, new ValueDescription(new DIWikiPage('SomePropertyPageValue', NS_HELP), $property, SMW_CMP_LEQ));
     $description = new SomeProperty(new DIProperty('Bar'), $description);
     $expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Bar ?v1 .')->addNewLine()->addString('{ ?v2 property:Foo ?v1 .')->addNewLine()->addString('FILTER( ?v2sk <= "SomePropertyPageValue" )')->addNewLine()->addString('?v2 swivt:wikiPageSortKey ?v2sk .')->addNewLine()->addString('}')->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     # 10
     $conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
     $property = new DIProperty('_MDAT');
     $description = new SomeProperty($property, new ThingDescription());
     $sortkeys = array('_MDAT' => 'ASC');
     $propertyLabel = str_replace(' ', '_', $property->getLabel());
     $expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString("?result property:{$propertyLabel}-23aux ?v1 .")->addNewLine()->getString();
     $provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
     return $provider;
 }
 /**
  * @return DataItem
  */
 protected function unserializeDataItem($property, $data, $value, $semanticData)
 {
     $dataItem = null;
     $type = $this->getDataItemId($property);
     // Verify that the current property type definition and the type of the
     // property during serialization do match, throw an error value to avoid any
     // exception during unserialization caused by the DataItem object due to a
     // mismatch of type definitions
     if ($type === $value['type']) {
         $dataItem = DataItem::newFromSerialization($value['type'], $value['item']);
     } else {
         $dataItem = $property->getDiWikiPage();
         $property = new DIProperty(DIProperty::TYPE_ERROR);
         $semanticData->addError(array(new ErrorValue($type, 'type mismatch', $property->getLabel())));
     }
     // Check whether the current dataItem has a subobject reference
     if ($dataItem->getDIType() === DataItem::TYPE_WIKIPAGE && $dataItem->getSubobjectName() !== '') {
         $dataItem = $this->unserializeSubobject($data, $value['item'], new SMWContainerSemanticData($dataItem));
     }
     // Ensure that errors are collected from a subobject level as well and
     // made available at the top
     if ($dataItem instanceof DIContainer) {
         $semanticData->addError($dataItem->getSemanticData()->getErrors());
     }
     if ($property !== null && $dataItem !== null) {
         $semanticData->addPropertyObjectValue($property, $dataItem);
     }
 }
Example #12
0
 /**
  * Returns information related to user-defined properties
  *
  * @since 1.9
  *
  * @param Title $title
  * @param DIProperty $property
  * @param integer $useCount
  *
  * @return array
  */
 private function getUserDefinedPropertyInfo($title, $property, $useCount)
 {
     if ($useCount <= $this->settings->get('smwgPropertyLowUsageThreshold')) {
         $this->getMessageFormatter()->addFromKey('smw_propertyhardlyused');
     }
     // User defined types default to Page
     $typestring = SMWTypesValue::newFromTypeId($this->settings->get('smwgPDefaultType'))->getLongHTMLText($this->getLinker());
     $label = htmlspecialchars($property->getLabel());
     if ($title->exists()) {
         $typeProperty = new DIProperty('_TYPE');
         $types = $this->store->getPropertyValues($property->getDiWikiPage(), $typeProperty);
         if (count($types) >= 1) {
             $typeDataValue = DataValueFactory::getInstance()->newDataItemValue(current($types), $typeProperty);
             $typestring = $typeDataValue->getLongHTMLText($this->getLinker());
         } else {
             $this->getMessageFormatter()->addFromKey('smw_propertylackstype', $typestring);
         }
         $proplink = $this->getLinker()->link($title, $label);
     } else {
         $this->getMessageFormatter()->addFromKey('smw_propertylackspage');
         $proplink = $this->getLinker()->link($title, $label, array(), array('action' => 'view'));
     }
     return array($typestring, $proplink);
 }
Example #13
0
 /**
  * @return array
  */
 public function getDataProvider()
 {
     $provider = array();
     // #0 / asserting conditions for a named identifier
     $provider[] = array(array('identifier' => 'Bar', 'properties' => array('Foo' => 'bar')), array('errors' => 0, 'identifier' => 'Bar', 'propertyCount' => 1, 'propertyLabels' => 'Foo', 'propertyValues' => 'Bar'));
     // #1 / asserting conditions for an anon identifier
     $provider[] = array(array('identifier' => '', 'properties' => array('FooBar' => 'bar Foo')), array('errors' => 0, 'identifier' => '_', 'propertyCount' => 1, 'propertyLabels' => 'FooBar', 'propertyValues' => 'Bar Foo'));
     // #2 / asserting conditions
     $provider[] = array(array('identifier' => 'foo', 'properties' => array(9001 => 1001)), array('errors' => 0, 'identifier' => 'foo', 'propertyCount' => 1, 'propertyLabels' => array(9001), 'propertyValues' => array(1001)));
     // #3
     $provider[] = array(array('identifier' => 'foo bar', 'properties' => array(1001 => 9001, 'Foo' => 'Bar')), array('errors' => 0, 'identifier' => 'foo bar', 'propertyCount' => 2, 'propertyLabels' => array(1001, 'Foo'), 'propertyValues' => array(9001, 'Bar')));
     // #4 / asserting that a property with a leading underscore would produce an error
     $provider[] = array(array('identifier' => 'bar', 'properties' => array('_FooBar' => 'bar Foo')), array('errors' => 1, 'identifier' => 'bar', 'propertyCount' => 0, 'propertyLabels' => '', 'propertyValues' => ''));
     // #5 / asserting that an inverse property would produce an error
     $provider[] = array(array('identifier' => 'bar', 'properties' => array('-FooBar' => 'bar Foo')), array('errors' => 1, 'identifier' => 'bar', 'propertyCount' => 0, 'propertyLabels' => '', 'propertyValues' => ''));
     // #6 / asserting that an improper value for a _wpg property would add "Has improper value for"
     $diPropertyError = new DIProperty(DIProperty::TYPE_ERROR);
     $provider[] = array(array('identifier' => 'bar', 'properties' => array('Foo' => '')), array('identifier' => 'bar', 'errors' => 1, 'propertyCount' => 1, 'propertyLabels' => array($diPropertyError->getLabel()), 'propertyValues' => 'Foo'));
     return $provider;
 }