当前位置: 首页>>代码示例>>PHP>>正文


PHP SMWPropertyValue::makeUserProperty方法代码示例

本文整理汇总了PHP中SMWPropertyValue::makeUserProperty方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWPropertyValue::makeUserProperty方法的具体用法?PHP SMWPropertyValue::makeUserProperty怎么用?PHP SMWPropertyValue::makeUserProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SMWPropertyValue的用法示例。


在下文中一共展示了SMWPropertyValue::makeUserProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setTypeAndPossibleValues

 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';
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:35,代码来源:SF_TemplateField.php

示例2: processParameters

 /**
  * 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;
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:39,代码来源:SMW_SpecialSearchByProperty.php

示例3: parse

 /**
  * @since 2.1
  *
  * @param PPFrame $frame
  * @param array $args
  */
 public function parse(PPFrame $frame, array $args)
 {
     // @todo Save as metadata
     if (!$frame->isTemplate()) {
         return '';
     }
     $this->subject = $this->parserData->getSemanticData()->getSubject();
     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];
             }
             $propertyValue = PropertyValue::makeUserProperty($propertystring);
             $argument = $frame->getArgument($argumentname);
             $valuestring = $frame->expand($argument);
             if ($propertyValue->isValid()) {
                 $this->matchValueArgument($propertyValue, $propertystring, $valuestring);
             }
         }
     }
     $this->parserData->pushSemanticDataToParserOutput();
     return '';
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:35,代码来源:DeclareParserFunction.php

示例4: addPropertyValueToSemanticData

 protected static function addPropertyValueToSemanticData($propertyName, $valueString, $semanticData)
 {
     $propertyDv = SMWPropertyValue::makeUserProperty($propertyName);
     $propertyDi = $propertyDv->getDataItem();
     self::addPropertyDiValueToSemanticData($propertyDi, $valueString, $semanticData);
     return $propertyDi;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:7,代码来源:SMW_Subobject.php

示例5: printoutFromString

	public static function printoutFromString( $printout ) {
		return new SMWPrintRequest(
			SMWPrintRequest::PRINT_PROP,
			$printout,
			SMWPropertyValue::makeUserProperty( $printout )
		);
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:7,代码来源:ApiAskArgs.php

示例6: testCheckIfPropertyRenamed

 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);
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:8,代码来源:TestWikiJobResults.php

示例7: setXMLAttribute

	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" );
		}
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:9,代码来源:WOM_OM_NestProperty.php

示例8: render

 /**
  * 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 '';
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:61,代码来源:SMW_Declare.php

示例9: addPropertyAndValue

	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?
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:13,代码来源:SemanticInternalObjects_body.php

示例10: SMWSemanticStore

 /**
  * 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());
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:16,代码来源:SMW_SemanticStore.php

示例11: addPropertyValueToSemanticData

 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');
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:16,代码来源:SMW_Subobject.php

示例12: execute

	/**
	 * 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!
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:52,代码来源:SMW_SpecialSearchByProperty.php

示例13: initialize

 /**
  * @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();
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:27,代码来源:PageRequestOptions.php

示例14: doMissingValues

 /**
  * Function for handling the {{\#missingvalues }} parser function.
  */
 public static function doMissingValues($parser, $querystring, $propertyname, $values)
 {
     $all_values = explode(',', $values);
     $all_values_clean = array();
     foreach ($all_values as $cur_value) {
         // remove whitespaces
         $cur_value = trim($cur_value);
         // ignore a value if it's null
         if ('' != $cur_value) {
             $all_values_clean[] = $cur_value;
         }
     }
     $params = array();
     $params['format'] = 'list';
     $params['link'] = 'none';
     $params['mainlabel'] = '-';
     $extraprintouts = array();
     $printmode = SMWPrintRequest::PRINT_PROP;
     $data = SMWPropertyValue::makeUserProperty(trim($propertyname));
     $label = '';
     $printout = new SMWPrintRequest($printmode, $label, $data);
     $extraprintouts[] = $printout;
     $outputmode = SMW_OUTPUT_WIKI;
     $result = SMWQueryProcessor::getResultFromQueryString($querystring, $params, $extraprintouts, $outputmode);
     $found_values = explode(', ', $result);
     $missing_values = array_diff($all_values_clean, $found_values);
     return join(', ', $missing_values);
 }
开发者ID:pinedance,项目名称:cjklib,代码行数:31,代码来源:CDB_ParserExtensions.php

示例15: getAnnotations

function getAnnotations($annotatedImage)
{
    global $wgExtensionCredits;
    $new = false;
    foreach ($wgExtensionCredits['semantic'] as $elem) {
        if ($elem['name'] == 'Semantic MediaWiki') {
            $vers = $elem['version'];
            $new = version_compare($vers, '1.7', '>=');
        }
    }
    $returnString = '{"shapes":[';
    $queryString = '[[SIAannotatedImage::' . $annotatedImage . ']]';
    $params = array();
    $params['link'] = 'none';
    $params['mainlabel'] = 'result';
    #$params = ['order'];
    #$params = ['sort'];
    if ($new) {
        $params['order'] = array('asc');
        $params['sort'] = array('SIAannotatedImage');
    } else {
        $params['order'] = 'asc';
        $params['sort'] = 'SIAannotatedImage';
    }
    //Generate all the extra printouts, eg all properties to retrieve:
    $printmode = SMWPrintRequest::PRINT_PROP;
    $customPrintouts = array('coordinates' => 'SIArectangleCoordinates', 'text' => 'ImageAnnotationText');
    $extraprintouts = array();
    foreach ($customPrintouts as $label => $property) {
        $extraprintouts[] = new SMWPrintRequest($printmode, $label, SMWPropertyValue::makeUserProperty($property));
    }
    $format = 'table';
    $context = SMWQueryProcessor::INLINE_QUERY;
    $query = SMWQueryProcessor::createQuery($queryString, $params, $context, $format, $extraprintouts);
    $store = smwfGetStore();
    // default store
    $res = $store->getQueryResult($query);
    $shapeCounter = 0;
    while (($resArrayArray = $res->getNext()) != false) {
        //Array of SMWResultArray Objects, eg. all retrieved Pages
        $shapeCounter++;
        if ($shapeCounter > 1) {
            $returnString .= ',';
        }
        $returnString .= '{';
        foreach ($resArrayArray as $resArray) {
            //SMWResultArray-Object, column of resulttable (pagename or propertyvalue)
            $currentPrintRequestLabel = $resArray->getPrintRequest()->getLabel();
            //The label as defined in the above array
            if ($currentPrintRequestLabel == 'coordinates') {
                $currentResultPage = $resArray->getResultSubject();
                $currentID = $currentResultPage->getTitle()->getFullText();
                $currentCoords = $resArray->getNextDataItem()->getSerialization();
                $returnString .= '"coords":"' . $currentCoords . '","id":"' . $currentID . '"';
            }
        }
        $returnString .= '}';
    }
    $returnString .= ']}';
    return $returnString;
}
开发者ID:whysasse,项目名称:kmwiki,代码行数:61,代码来源:SIA_AjaxFunctions.php


注:本文中的SMWPropertyValue::makeUserProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。