本文整理汇总了PHP中SMWDataValueFactory::findTypeID方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWDataValueFactory::findTypeID方法的具体用法?PHP SMWDataValueFactory::findTypeID怎么用?PHP SMWDataValueFactory::findTypeID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWDataValueFactory
的用法示例。
在下文中一共展示了SMWDataValueFactory::findTypeID方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
$propValue = SMWDIProperty::newFromUserLabel($this->mSemanticProperty);
$this->mPropertyType = $propValue->findPropertyTypeID();
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';
}
}
示例2: setTypeAndPossibleValues
function setTypeAndPossibleValues()
{
if (!defined('SMW_NS_PROPERTY')) {
return;
}
// The presence of "-" at the beginning of a property name
// (which happens if SF tries to parse an inverse query)
// leads to an error in SMW - just exit if that's the case.
if (strpos($this->mSemanticProperty, '-') === 0) {
return;
}
$proptitle = Title::makeTitleSafe(SMW_NS_PROPERTY, $this->mSemanticProperty);
if ($proptitle === null) {
return;
}
$store = SFUtils::getSMWStore();
// this returns an array of objects
$allowed_values = SFUtils::getSMWPropertyValues($store, $proptitle, "Allows value");
$label_formats = SFUtils::getSMWPropertyValues($store, $proptitle, "Has field label format");
$propValue = SMWDIProperty::newFromUserLabel($this->mSemanticProperty);
$this->mPropertyType = $propValue->findPropertyTypeID();
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';
}
}
示例3: getOWLPropertyType
/**
* Determine what kind of OWL property some SMW property should be exported as.
* The input is an SMWTypesValue object, a typeid string, or empty (use default)
* @todo An improved mechanism for selecting property types here is needed.
*/
public static function getOWLPropertyType($type = '')
{
if ($type instanceof SMWDIWikiPage) {
$type = SMWDataValueFactory::findTypeID(str_replace('_', ' ', $type->getDBkey()));
} elseif ($type == false) {
$type = '';
}
// else keep $type
switch ($type) {
case '_anu':
return 'AnnotationProperty';
case '':
case '_wpg':
case '_wpp':
case '_wpc':
case '_wpf':
case '_uri':
case '_ema':
case '_tel':
case '_rec':
case '__typ':
case '__red':
case '__spf':
case '__spu':
return 'ObjectProperty';
default:
return 'DatatypeProperty';
}
}
示例4: getDBkey
/**
* This class uses type ids as DB keys.
*
* @return string
*/
public function getDBkey()
{
return $this->isValid() ? SMWDataValueFactory::findTypeID($this->m_realLabel) : '';
}
示例5: getPropertyWithType
public function getPropertyWithType($match, $typeLabel)
{
$db =& wfGetDB(DB_SLAVE);
$smw_spec2 = $db->tableName('smw_spec2');
$smw_ids = $db->tableName('smw_ids');
$page = $db->tableName('page');
$result = array();
$typeID = SMWDataValueFactory::findTypeID($typeLabel);
$hasTypePropertyID = smwfGetStore()->getSMWPropertyID(SMWPropertyValue::makeProperty("_TYPE"));
$res = $db->query('(SELECT i2.smw_title AS title FROM ' . $smw_ids . ' i2 ' . 'JOIN ' . $smw_spec2 . ' s1 ON i2.smw_id = s1.s_id AND s1.p_id = ' . $hasTypePropertyID . ' ' . 'JOIN ' . $smw_ids . ' i ON s1.value_string = i.smw_title AND i.smw_namespace = ' . SMW_NS_TYPE . ' ' . 'JOIN ' . $smw_spec2 . ' s2 ON s2.s_id = i.smw_id AND s2.value_string REGEXP ' . $db->addQuotes("([0-9].?[0-9]*|,) {$typeLabel}(,|\$)") . 'WHERE i2.smw_namespace = ' . SMW_NS_PROPERTY . ' AND UPPER(' . DBHelper::convertColumn('i2.smw_title') . ') LIKE UPPER(' . $db->addQuotes("%{$match}%") . '))' . ' UNION (SELECT smw_title AS title FROM smw_ids i ' . 'JOIN ' . $smw_spec2 . ' s1 ON i.smw_id = s1.s_id AND s1.p_id = ' . $hasTypePropertyID . ' ' . 'WHERE UPPER(' . DBHelper::convertColumn('i.smw_title') . ') LIKE UPPER(' . $db->addQuotes('%' . $match . '%') . ') AND ' . 'UPPER(' . DBHelper::convertColumn('s1.value_string') . ') = UPPER(' . $db->addQuotes($typeID) . ') AND smw_namespace = ' . SMW_NS_PROPERTY . ') ' . 'ORDER BY title LIMIT ' . SMW_AC_MAX_RESULTS);
if ($db->numRows($res) > 0) {
while ($row = $db->fetchObject($res)) {
if (smwf_om_userCan($row->title, 'read', SMW_NS_PROPERTY) == 'true') {
$result[] = Title::newFromText($row->title, SMW_NS_PROPERTY);
}
}
}
$db->freeResult($res);
return $result;
}
示例6: compilePropertyCondition
/**
* Modify the given query object to account for some property condition for the given property.
* The parameter $property may be a property object or an internal storage id. This is what makes
* this method useful: it can be used even with internal properties that have no MediaWiki Title.
* $typeid is set if property ids are used, since internal properties may not have a defined type.
* Some properties cannot be queried for; in this case, the query type is changed to SMW_SQL2_NOQUERY.
* Callers need to check for this.
*/
protected function compilePropertyCondition(&$query, $property, SMWDescription $valuedesc, $typeid = false)
{
$query->joinfield = "{$query->alias}.s_id";
if ($property instanceof SMWPropertyValue) {
$typeid = $property->getPropertyTypeID();
$mode = SMWSQLStore2::getStorageMode($typeid);
$pid = $this->m_store->getSMWPropertyID($property);
$sortkey = $property->getDBkey();
// / TODO: strictly speaking, the DB key is not what we want here, since sortkey is based on a "wiki value"
if ($mode != SMW_SQL2_SUBS2) {
// also make property hierarchy (though not for all properties)
$pqid = SMWSQLStore2Query::$qnum;
$pquery = new SMWSQLStore2Query();
$pquery->type = SMW_SQL2_PROP_HIERARCHY;
$pquery->joinfield = array($pid);
$query->components[$pqid] = "{$query->alias}.p_id";
$this->m_queries[$pqid] = $pquery;
}
} else {
$pid = $property;
$sortkey = false;
$mode = SMWSQLStore2::getStorageMode($typeid);
if ($mode != SMW_SQL2_SUBS2) {
// no property hierarchy, but normal query (not for all properties)
$query->where = "{$query->alias}.p_id=" . $this->m_dbs->addQuotes($pid);
}
}
$mode = SMWSQLStore2::getStorageMode($typeid);
$sortfield = '';
// used if we should sort by this property
switch ($mode) {
case SMW_SQL2_RELS2:
case SMW_SQL2_SUBS2:
// subconditions as subqueries (compiled)
$query->jointable = $mode == SMW_SQL2_RELS2 ? 'smw_rels2' : 'smw_subs2';
$sub = $this->compileQueries($valuedesc);
if ($sub >= 0) {
$query->components[$sub] = "{$query->alias}.o_id";
}
if ($sortkey && array_key_exists($sortkey, $this->m_sortkeys)) {
$query->from = ' INNER JOIN ' . $this->m_dbs->tableName('smw_ids') . " AS ids{$query->alias} ON ids{$query->alias}.smw_id={$query->alias}.o_id";
$sortfield = "ids{$query->alias}.smw_title";
// / TODO: as below, smw_ids here is possibly duplicated! Can we prevent that? (PERFORMANCE)
}
break;
case SMW_SQL2_NARY2:
$query->jointable = 'smw_rels2';
if ($valuedesc instanceof SMWValueList) {
// anything else is ignored!
$typevalue = $property->getTypesValue();
$typelabels = $typevalue->getTypeLabels();
reset($typelabels);
$subqid = SMWSQLStore2Query::$qnum;
$subquery = new SMWSQLStore2Query();
$subquery->type = SMW_SQL2_CONJUNCTION;
$query->components[$subqid] = "{$query->alias}.o_id";
$this->m_queries[$subqid] = $subquery;
for ($i = 0; $i < $valuedesc->getCount(); $i++) {
$desc = $valuedesc->getDescription($i);
if ($desc !== NULL) {
$stypeid = SMWDataValueFactory::findTypeID(current($typelabels));
$valpid = $this->m_store->getSMWPageID(strval($i), SMW_NS_PROPERTY, SMW_SQL2_SMWIW);
$valqid = SMWSQLStore2Query::$qnum;
$valquery = new SMWSQLStore2Query();
$this->compilePropertyCondition($valquery, $valpid, $desc, $stypeid);
if ($valquery->type != SMW_SQL2_NOQUERY) {
$subquery->components[$valqid] = true;
$this->m_queries[$valqid] = $valquery;
}
}
next($typelabels);
}
}
break;
case SMW_SQL2_TEXT2:
// no subconditions
$query->jointable = 'smw_text2';
break;
case SMW_SQL2_ATTS2:
case SMW_SQL2_SPEC2:
// subquery only conj/disj of values, compile to single "where"
$query->jointable = $mode == SMW_SQL2_ATTS2 ? 'smw_atts2' : 'smw_spec2';
$aw = $this->compileAttributeWhere($valuedesc, "{$query->alias}");
if ($aw != '') {
$query->where .= ($query->where ? ' AND ' : '') . $aw;
}
if ($sortkey && array_key_exists($sortkey, $this->m_sortkeys)) {
if ($mode == SMW_SQL2_ATTS2) {
$sortfield = "{$query->alias}." . (SMWDataValueFactory::newTypeIDValue($typeid)->isNumeric() ? 'value_num' : 'value_xsd');
} else {
$sortfield = "{$query->alias}.value_string";
}
//.........这里部分代码省略.........
示例7: smwf_qi_QIAccess
function smwf_qi_QIAccess($method, $params)
{
$p_array = explode(",", $params);
global $smwgQEnabled;
if ($method == "getPropertyInformation") {
return qiGetPropertyInformation($p_array[0]);
} else {
if ($method == "getPropertyTypes") {
$p_array = func_get_args();
$types = "<propertyTypes>";
for ($i = 1; $i < count($p_array); $i++) {
$types .= qiGetPropertyInformation($p_array[$i]);
}
$types .= "</propertyTypes>";
return $types;
} else {
if ($method == "getNumericTypes") {
$numtypes = array();
$types = SMWDataValueFactory::getKnownTypeLabels();
foreach ($types as $v) {
$id = SMWDataValueFactory::findTypeID($v);
if (SMWDataValueFactory::newTypeIDValue($id)->isNumeric()) {
array_push($numtypes, strtolower($v));
}
}
return implode(",", $numtypes);
} else {
if ($method == "getQueryResult") {
$result = "null";
if ($smwgQEnabled) {
// read fix parameters from QI GUI
$params = count($p_array) > 1 ? explode("|", $p_array[1]) : array();
$fixparams = array();
foreach ($params as $p) {
if (strlen($p) > 0 && strpos($p, "=") !== false) {
list($key, $value) = explode("=", $p);
$fixparams[trim($key)] = str_replace('%2C', ',', $value);
}
}
// indicate that it comes from an ajax call
$fixparams['ajaxCall'] = true;
// fix bug 10812: if query string contains a ,
$p_array[0] = str_replace('%2C', ',', $p_array[0]);
// read query with printouts and (possibly) other parameters like sort, order, limit, etc...
$pos = strpos($p_array[0], "|?");
if ($pos > 0) {
$rawparams[] = trim(substr($p_array[0], 0, $pos));
$ps = explode("|?", trim(substr($p_array[0], $pos + 2)));
foreach ($ps as $param) {
$rawparams[] = "?" . trim($param);
}
} else {
$ps = preg_split('/[^\\|]{1}\\|{1}(?!\\|)/s', $p_array[0]);
if (count($ps) > 1) {
// last char of query condition is missing (matched with [^\|]{1}) therefore copy from original
$rawparams[] = trim(substr($p_array[0], 0, strlen($ps[0]) + 1));
array_shift($ps);
// remove the query condition
// add other params for formating etc.
foreach ($ps as $param) {
$rawparams[] = trim($param);
}
} else {
$rawparams[] = trim($p_array[0]);
}
}
$rawparams = array_merge($rawparams, $fixparams);
// set some default values, if params are not set
if (!in_array('reasoner', array_keys($fixparams))) {
$fixparams['reasoner'] = 'ask';
}
if (!in_array('format', array_keys($fixparams))) {
$fixparams['format'] = 'table';
}
// use SMW classes or TSC classes and parse params and answer query
if ($fixparams['reasoner'] == 'ask') {
SMWQueryProcessor::processFunctionParams($rawparams, $querystring, $params, $printouts);
} else {
if ($fixparams['reasoner'] == 'sparql') {
SMWSPARQLQueryProcessor::processFunctionParams($rawparams, $querystring, $params, $printouts);
}
}
// check if there is any result and if it corresponds to the selected format
$mainlabel = isset($rawparams['mainlabel']) && $rawparams['mainlabel'] == '-';
$invalidRes = smwf_qi_CheckValidResult($printouts, $fixparams['format'], $mainlabel);
if ($invalidRes != 0) {
return wfMsg('smw_qi_printout_err' . $invalidRes);
}
// quickfix: unset conflicting params for maps
if (in_array($fixparams['format'], array("map", "googlemaps2", "openlayers", "yahoomaps"))) {
if (isset($params['reasoner'])) {
unset($params['reasoner']);
}
if (isset($params['ajaxcall'])) {
unset($params['ajaxcall']);
}
if (isset($params['merge'])) {
unset($params['merge']);
}
}
//.........这里部分代码省略.........