本文整理汇总了PHP中SMW\DIProperty::newFromUserLabel方法的典型用法代码示例。如果您正苦于以下问题:PHP DIProperty::newFromUserLabel方法的具体用法?PHP DIProperty::newFromUserLabel怎么用?PHP DIProperty::newFromUserLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMW\DIProperty
的用法示例。
在下文中一共展示了DIProperty::newFromUserLabel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFindTableIdForProperty
/**
* @dataProvider propertyProvider
*/
public function testFindTableIdForProperty($property, $expected)
{
$property = DIProperty::newFromUserLabel($property);
$instance = new PropertyTableInfoFetcher();
$instance->setCustomSpecialPropertyList(array('_MDAT', '_MEDIA', '_MIME'));
$this->assertEquals($expected, $instance->findTableIdForProperty($property));
}
示例2: testImportOfDifferentDateWithAssortmentOfOutputConversion
public function testImportOfDifferentDateWithAssortmentOfOutputConversion()
{
$this->importedTitles = array('TimeDataTypeRegressionTest', 'Property:Has query date', 'Property:Has calendar date', 'Property:Has date');
$this->titleValidator->assertThatTitleIsKnown($this->importedTitles);
$title = Title::newFromText('TimeDataTypeRegressionTest');
$expectedCategoryAsWikiValue = array('property' => new DIProperty('_INST'), 'propertyValues' => array('Regression test'));
$expectedPropertiesFromImport = array('properties' => array(DIProperty::newFromUserLabel('Has date'), DIProperty::newFromUserLabel('Has calendar date'), DIProperty::newFromUserLabel('Has query date'), new DIProperty('_ASK'), new DIProperty('_MDAT'), new DIProperty('_SKEY'), new DIProperty('_SOBJ'), new DIProperty('_INST')));
$expectedDateValuesAsISO = array('valueFormatter' => $this->setISO8601DateValueFormatter(), 'property' => DIProperty::newFromUserLabel('Has query date'), 'propertyValues' => array('2010-01-04T19:00:00', '2011-06-08', '1980-01-01', '2000-02-11T10:00:00', '2000-02-03'));
$expectedDateValuesAsMediaWiki = array('valueFormatter' => $this->setMediaWikiDateValueFormatter(), 'property' => DIProperty::newFromUserLabel('Has query date'), 'propertyValues' => array('19:00, 4 January 2010', '8 June 2011', '1 January 1980', '10:00, 11 February 2000', '3 February 2000'));
$expectedDateValuesAsWikiValue = array('valueFormatter' => $this->setWikiValueDateValueFormatter(), 'property' => DIProperty::newFromUserLabel('Has query date'), 'propertyValues' => array('4 January 2010 19:00:00', '8 June 2011', '1 January 1980', '11 February 2000 10:00:00', '3 February 2000'));
// Note Windows vs Linux date conversion on PHP
// where 14000000000 BC is 2147483647 BC on Windows
$expectedCalendarSpecificDateValuesAsISO = array('valueFormatter' => $this->setISO8601DateValueFormatter(), 'property' => DIProperty::newFromUserLabel('Has calendar date'), 'propertyValues' => array('--301-12-28', '--2147483647-01-01', '--14000000000-01-01', '2000-02-24', '1492-02-11'));
$expectedCalendarSpecificDateValuesAsWikiValue = array('valueFormatter' => $this->setWikiValueDateValueFormatter(), 'property' => DIProperty::newFromUserLabel('Has calendar date'), 'propertyValues' => array('1 January 300 BC', '2147483647 BC', '14000000000 BC', '24 February 2000', '2 February 1492'));
$expectedCalendarSpecificDateValuesAsWikiValueWithGRCalendarModel = array('valueFormatter' => $this->setWikiValueDateWithGRCalendarModelValueFormatter(), 'property' => DIProperty::newFromUserLabel('Has calendar date'), 'propertyValues' => array('28 December 301 BC', '2147483647 BC', '14000000000 BC', '24 February 2000', '11 February 1492'));
$expectedCalendarSpecificDateValuesAsWikiValueWithJLCalendarModel = array('valueFormatter' => $this->setWikiValueDateWithJLCalendarModelValueFormatter(), 'property' => DIProperty::newFromUserLabel('Has calendar date'), 'propertyValues' => array('1 January 300 BC', '2147483647 BC', '14000000000 BC', '11 February 2000', '2 February 1492'));
$this->semanticDataFinder = new ByPageSemanticDataFinder();
$this->semanticDataFinder->setTitle($title)->setStore($this->getStore());
$semanticDataBatches = array($this->semanticDataFinder->fetchFromOutput(), $this->semanticDataFinder->fetchFromStore());
$expectedDateValuesBatches = array($expectedDateValuesAsISO, $expectedDateValuesAsMediaWiki, $expectedDateValuesAsWikiValue, $expectedCalendarSpecificDateValuesAsISO, $expectedCalendarSpecificDateValuesAsWikiValue, $expectedCalendarSpecificDateValuesAsWikiValueWithGRCalendarModel, $expectedCalendarSpecificDateValuesAsWikiValueWithJLCalendarModel);
foreach ($semanticDataBatches as $semanticData) {
$this->semanticDataValidator->assertThatCategoriesAreSet($expectedCategoryAsWikiValue, $semanticData);
$this->semanticDataValidator->assertThatPropertiesAreSet($expectedPropertiesFromImport, $semanticData);
$this->assertBatchesOfDateValues($expectedDateValuesBatches, $semanticData);
}
}
示例3: testImportOfRecordValues
public function testImportOfRecordValues()
{
$this->importedTitles = array('Property:Has record number field', 'Property:Has record page field', 'Property:Has record text field', 'Property:Has record type', 'Property:Has record type for single test', 'RecordDataTypePage', 'RecordDataTypeRegressionTest/WithSubpage', 'RecordDataTypeRegressionTest');
$this->titleValidator->assertThatTitleIsKnown($this->importedTitles);
$title = Title::newFromText('RecordDataTypeRegressionTest');
$expectedCategoryAsWikiValue = array('property' => new DIProperty('_INST'), 'propertyValues' => array('Regression test', 'Data type regression test', 'Record type regression test'));
$expectedSomeProperties = array('properties' => array(DIProperty::newFromUserLabel('RecordDataTypePage'), DIProperty::newFromUserLabel('BarText'), DIProperty::newFromUserLabel('BooPage'), DIProperty::newFromUserLabel('FooPage'), DIProperty::newFromUserLabel('QyuPage'), new DIProperty('_ASK'), new DIProperty('_MDAT'), new DIProperty('_SKEY'), new DIProperty('_SOBJ'), new DIProperty('_INST')));
$property = DIProperty::newFromUserLabel('Has record type for single test');
$valueString = 'ForSingleTestAsPage;ForSingleTestAsText;3333';
if ($property->findPropertyTypeID() === '_rec') {
$valueString = 'ForSingleTestAsPage; ForSingleTestAsText; 3333';
}
$expectedRecordTypeValuesAsWikiValue = array('subject' => DIWikiPage::newFromTitle($title), 'record' => $property, 'property' => $property, 'propertyValues' => array($valueString, '?; ?; ?'));
$expectedRecordPageFieldValuesAsWikiValue = array('subject' => DIWikiPage::newFromTitle($title), 'record' => DIProperty::newFromUserLabel('Has record type'), 'property' => DIProperty::newFromUserLabel('Has record page field'), 'propertyValues' => array('FooPage', 'QyuPageOnSubobject', 'QyuPage', 'XeuiPageOnSubobject', 'RecordDataTypePage', 'BooPage'));
$expectedRecordTextFieldValuesAsWikiValue = array('subject' => DIWikiPage::newFromTitle($title), 'record' => DIProperty::newFromUserLabel('Has record type'), 'property' => DIProperty::newFromUserLabel('Has record text field'), 'propertyValues' => array('BarText', 'ForSingleTestAsText', 'FooText', 'XeuiTextOnSubobject'));
$expectedRecordNumberFieldValuesAsNumber = array('subject' => DIWikiPage::newFromTitle(Title::newFromText('RecordDataTypeRegressionTest/WithSubpage')), 'record' => DIProperty::newFromUserLabel('Has record type'), 'property' => DIProperty::newFromUserLabel('Has record number field'), 'propertyValues' => array(1111, 9001, 9999, 1009));
$semanticDataFinder = new ByPageSemanticDataFinder();
$semanticDataFinder->setTitle($title)->setStore($this->getStore());
$semanticDataBatches = array($this->getStore()->getSemanticData(DIWikiPage::newFromTitle($title)));
foreach ($semanticDataBatches as $semanticData) {
$this->semanticDataValidator->assertThatCategoriesAreSet($expectedCategoryAsWikiValue, $semanticData);
$this->semanticDataValidator->assertThatPropertiesAreSet($expectedSomeProperties, $semanticData);
$this->assertThatSemanticDataValuesAreSet($expectedRecordTypeValuesAsWikiValue, $semanticData);
}
$this->assertThatRecordValuesAreSet($expectedRecordTypeValuesAsWikiValue);
$this->assertThatRecordValuesAreSet($expectedRecordPageFieldValuesAsWikiValue);
$this->assertThatRecordValuesAreSet($expectedRecordTextFieldValuesAsWikiValue);
$this->assertThatRecordValuesAreSet($expectedRecordNumberFieldValuesAsNumber);
}
示例4: newDataValueForPagePropertyValue
private function newDataValueForPagePropertyValue($property, $value)
{
$property = DIProperty::newFromUserLabel($property);
$property->setPropertyTypeId('_wpg');
$dataItem = new DIWikiPage($value, NS_MAIN, '');
return $this->dataValueFactory->newDataItemValue($dataItem, $property);
}
示例5: testPageMoveWithRemovalOfOldPage
public function testPageMoveWithRemovalOfOldPage()
{
// PHPUnit query issue
$this->skipTestForDatabase(array('postgres'));
// Revison showed an issue on 1.19 not being null after the move
$this->skipTestForMediaWikiVersionLowerThan('1.21');
// Further hooks required to ensure in-text annotations can be used for queries
$this->mwHooksHandler->register('InternalParseBeforeLinks', $this->mwHooksHandler->getHookRegistry()->getDefinition('InternalParseBeforeLinks'));
$this->mwHooksHandler->register('LinksUpdateConstructed', $this->mwHooksHandler->getHookRegistry()->getDefinition('LinksUpdateConstructed'));
$title = Title::newFromText(__METHOD__ . '-old');
$expectedNewTitle = Title::newFromText(__METHOD__ . '-new');
$this->assertNull(WikiPage::factory($expectedNewTitle)->getRevision());
$this->pageCreator->createPage($title)->doEdit('[[Has function hook test::PageCompleteMove]]');
$this->pageCreator->getPage()->getTitle()->moveTo($expectedNewTitle, false, 'test', false);
$this->assertNull(WikiPage::factory($title)->getRevision());
$this->assertNotNull(WikiPage::factory($expectedNewTitle)->getRevision());
/**
* @query {{#ask: [[Has function hook test::PageCompleteMove]] }}
*/
$description = new SomeProperty(DIProperty::newFromUserLabel('Has function hook test'), new ValueDescription(new DIWikiPage('PageCompleteMove', 0), null, SMW_CMP_EQ));
$query = new Query($description, false, true);
$query->querymode = Query::MODE_INSTANCES;
$queryResult = $this->getStore()->getQueryResult($query);
// #566
$this->assertCount(1, $queryResult->getResults());
$this->queryResultValidator->assertThatQueryResultHasSubjects(DIWikiPage::newFromTitle($expectedNewTitle), $queryResult);
$this->toBeDeleted = array($title, $expectedNewTitle);
}
示例6: testCreatePropertyFromLabelThatContainsInverseMarker
public function testCreatePropertyFromLabelThatContainsInverseMarker()
{
$property = DIProperty::newFromUserLabel('-Foo');
$property->setInterwiki('bar');
$this->assertTrue($property->isInverse());
$this->assertEquals(new DiWikiPage('Foo', SMW_NS_PROPERTY, 'bar'), $property->getDiWikiPage());
}
示例7: isExemptedPropertyById
/**
* @since 2.5
*
* @param integer $id
*
* @return boolean
*/
public function isExemptedPropertyById($id)
{
$dataItem = $this->store->getObjectIds()->getDataItemById($id);
if (!$dataItem instanceof DIWikiPage || $dataItem->getDBKey() === '') {
return false;
}
return $this->isExemptedProperty(DIProperty::newFromUserLabel($dataItem->getDBKey()));
}
示例8: testSerializeFormatForTimeValue
public function testSerializeFormatForTimeValue()
{
$property = \SMW\DIProperty::newFromUserLabel('Foo');
$property->setPropertyTypeId('_dat');
$printRequestFactory = new \SMW\Query\PrintRequestFactory();
$serialization = QueryResultSerializer::getSerialization(\SMWDITime::doUnserialize('2/1393/1/1'), $printRequestFactory->newPropertyPrintRequest($property));
$expected = array('timestamp' => '-18208281600', 'raw' => '2/1393/1/1');
$this->assertEquals($expected, $serialization);
}
示例9: specialCharactersNameProvider
public function specialCharactersNameProvider()
{
$provider[] = array('特殊文字', 'Nuñez', DIProperty::newFromUserLabel('特殊文字')->setPropertyTypeId('_txt'), new DIBlob('Nuñez'));
$provider[] = array('特殊字符', '^[0-9]*$', DIProperty::newFromUserLabel('特殊字符')->setPropertyTypeId('_txt'), new DIBlob('^[0-9]*$'));
$provider[] = array('Caractères spéciaux', 'Caractères spéciaux', DIProperty::newFromUserLabel('Caractères spéciaux')->setPropertyTypeId('_wpg'), new DIWikiPage('âêîôûëïçé', NS_MAIN));
$provider[] = array('áéíóúñÑü¡¿', 'áéíóúñÑü¡¿', DIProperty::newFromUserLabel('áéíóúñÑü¡¿')->setPropertyTypeId('_num'), new DINumber(8888));
$provider[] = array('Foo', '{({[[&,,;-]]})}', DIProperty::newFromUserLabel('{({[[&,,;-]]})}')->setPropertyTypeId('_wpg'), new DIWikiPage('{({[[&,,;-]]})}', NS_MAIN));
return $provider;
}
示例10: process
/**
* @since 2.0
*
* @return boolean
*/
public function process()
{
// Avoid having "noarticletext" info being generated for predefined
// properties as we are going to display an introductory text
if ($this->article->getTitle()->getNamespace() === SMW_NS_PROPERTY) {
return DIProperty::newFromUserLabel($this->article->getTitle()->getText())->isUserDefined();
}
return true;
}
示例11: initParameters
/**
* @see SMWOrderedListPage::initParameters()
* @note We use a smaller limit here; property pages might become large.
*/
protected function initParameters()
{
global $smwgPropertyPagingLimit;
$this->limit = $smwgPropertyPagingLimit;
$this->mProperty = DIProperty::newFromUserLabel($this->mTitle->getText());
$this->store = ApplicationFactory::getInstance()->getStore();
$this->propertyValue = DataValueFactory::getInstance()->newDataItemValue($this->mProperty);
return true;
}
示例12: testImportToVerifyAnnotationByTemplateInclusion
public function testImportToVerifyAnnotationByTemplateInclusion()
{
$this->importedTitles = array('Foo-1-19-7', 'Template:FooAsk', 'Template:FooShow', 'Template:FooSubobject', 'Template:FooTemplate');
$this->titleValidator->assertThatTitleIsKnown($this->importedTitles);
$expectedProperties = array('properties' => array(DIProperty::newFromUserLabel('Foo'), DIProperty::newFromUserLabel('Quux'), new DIProperty('_ASK'), new DIProperty('_MDAT'), new DIProperty('_SKEY'), new DIProperty('_SOBJ'), new DIProperty('_INST')));
$title = Title::newFromText('Foo-1-19-7');
$semanticDataFinder = new ByPageSemanticDataFinder();
$semanticDataFinder->setTitle($title)->setStore($this->getStore());
$this->semanticDataValidator->assertThatPropertiesAreSet($expectedProperties, $semanticDataFinder->fetchFromOutput());
}
示例13: valueDescriptionProvider
public function valueDescriptionProvider()
{
$dataItem = new DIWikiPage('Foo', NS_MAIN);
$provider[] = array($dataItem, null, SMW_CMP_EQ, array('comparator' => SMW_CMP_EQ, 'dataItem' => $dataItem, 'property' => null, 'queryString' => '[[:Foo]]', 'queryStringAsValue' => 'Foo', 'isSingleton' => true));
$provider[] = array($dataItem, null, SMW_CMP_LEQ, array('comparator' => SMW_CMP_LEQ, 'dataItem' => $dataItem, 'property' => null, 'queryString' => '[[≤Foo]]', 'queryStringAsValue' => '≤Foo', 'isSingleton' => false));
$property = DIProperty::newFromUserLabel('Foo')->setPropertyTypeId('_num');
$dataItem = new DINumber(9001);
$provider[] = array($dataItem, $property, SMW_CMP_LEQ, array('comparator' => SMW_CMP_LEQ, 'dataItem' => $dataItem, 'property' => $property, 'queryString' => '[[≤9,001]]', 'queryStringAsValue' => '≤9,001', 'isSingleton' => false));
return $provider;
}
示例14: addPropertyValues
protected function addPropertyValues()
{
$subject = $this->getSemanticData()->getSubject();
if ($subject->getNamespace() !== SMW_NS_PROPERTY) {
return;
}
$property = DIProperty::newFromUserLabel(str_replace('_', ' ', $subject->getDBKey()));
if (!$property->isUserDefined()) {
return;
}
$this->findMandatoryTypeForImportVocabulary();
}
示例15: newFromUserLabel
private function newFromUserLabel($label, $languageCode = false)
{
$property = DIProperty::newFromUserLabel($label, false, $languageCode);
$canonicalLabel = $property->getCanonicalLabel();
// #1966 and #1968
// In case something goes wrong, a recursive loop will kill PHP
// and we know we messed up
if ($canonicalLabel !== '' && $label !== $canonicalLabel) {
$this->newFromUserLabel($property->getCanonicalDiWikiPage()->getTitle()->getText());
}
return array($label, $property);
}