本文整理汇总了PHP中SMWPropertyValue::makeProperty方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWPropertyValue::makeProperty方法的具体用法?PHP SMWPropertyValue::makeProperty怎么用?PHP SMWPropertyValue::makeProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWPropertyValue
的用法示例。
在下文中一共展示了SMWPropertyValue::makeProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getSMWPropertyValues
/**
* 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 );
}
}
示例2: refreshConceptCache
/**
* 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;
}
示例3: __construct
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);
}
示例4: getSMWPropertyValues
/**
* Helper function to handle getPropertyValues() in both SMW 1.6
* and earlier versions.
*/
public static function getSMWPropertyValues($store, $subject, $propID, $requestOptions = null)
{
// SMWDIProperty was added in SMW 1.6
if (class_exists('SMWDIProperty')) {
if (is_null($subject)) {
$page = null;
} else {
$page = SMWDIWikiPage::newFromTitle($subject);
}
$property = SMWDIProperty::newFromUserLabel($propID);
$res = $store->getPropertyValues($page, $property, $requestOptions);
$values = array();
foreach ($res as $value) {
if ($value instanceof SMWDIUri) {
$values[] = $value->getURI();
} else {
// getSortKey() seems to return the
// correct value for all the other
// data types.
$values[] = str_replace('_', ' ', $value->getSortKey());
}
}
return $values;
} else {
$property = SMWPropertyValue::makeProperty($propID);
$res = $store->getPropertyValues($subject, $property, $requestOptions);
$values = array();
foreach ($res as $value) {
if (method_exists($value, 'getTitle')) {
$valueTitle = $value->getTitle();
if (!is_null($valueTitle)) {
$values[] = $valueTitle->getText();
}
} else {
$values[] = str_replace('_', ' ', $value->getWikiValue());
}
}
return array_unique($values);
}
}
示例5: qiGetPropertyCustomTypeInformation
/**
* For custom types, units can be defined. This is done at the page in the type
* namespace. The special property 'Corresponds to' contains a constant for the
* conversion and one or more labels separated by comma. These labels are
* supposed to be displayed in the query interface so that the user may choose
* that a specific value is of a certain type and that he also may choose which
* unit to display in the results. If a unit has several labels, the first one
* is used only.
*
* @global SMWLanguage $smwgContLang
* @param string $typeName
* @return string xml snippet
*/
function qiGetPropertyCustomTypeInformation($typeName)
{
global $smwgContLang;
$units = "";
$conv = array();
$title = Title::newFromText($typeName, SMW_NS_TYPE);
$sspa = $smwgContLang->getPropertyLabels();
$prop = SMWPropertyValue::makeProperty($sspa['_CONV']);
$smwValues = smwfGetStore()->getPropertyValues($title, $prop);
if (count($smwValues) > 0) {
for ($i = 0, $is = count($smwValues); $i < $is; $i++) {
$un = $smwValues[$i]->getDBkeys();
if (preg_match('/([\\d\\.]+)(.*)/', $un[0], $matches)) {
$ulist = explode(',', $matches[2]);
$conv[$matches[1]] = trim($ulist[0]);
}
}
}
if (count($conv) > 0) {
foreach (array_keys($conv) as $k) {
$units .= '<unit label="' . $conv[$k] . '"/>';
}
}
return $units;
}
示例6: 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;
}
示例7: resultToItem
/**
* Transform a results' row (ie. a result) into
* an item, which is a simple associative array
*
* @param <type> $r
* @return string
*/
private function resultToItem($r)
{
// variables used to reconstruct URI from page title
global $wgServer, $wgScriptPath;
$rowsubject = false;
// the wiki page value that this row is about
$item = array();
// contains Property-Value pairs to characterize an Item
$item['properties'] = array();
foreach ($r as $field) {
$pr = $field->getPrintRequest();
if ($rowsubject === false) {
$rowsubject = $field->getResultSubject();
$item['title'] = $rowsubject->getShortText(null, null);
}
if ($pr->getMode() != SMWPrintRequest::PRINT_THIS) {
$values = array();
while (($value = $field->getNextObject()) !== false) {
switch ($value->getTypeID()) {
case '_geo':
$values[] = $value->getWikiValue();
break;
case '_num':
$values[] = $value->getValueKey();
break;
case '_dat':
$values[] = $value->getYear() . "-" . str_pad($value->getMonth(), 2, '0', STR_PAD_LEFT) . "-" . str_pad($value->getDay(), 2, '0', STR_PAD_LEFT) . " " . $value->getTimeString();
break;
default:
$values[] = $value->getShortText(null, null);
}
}
$this->addPropToItem($item, str_replace(" ", "_", strtolower($pr->getLabel())), $values);
}
}
if ($rowsubject !== false) {
// stuff in the page URI and some category data
$item['uri'] = $wgServer . $wgScriptPath . '/index.php?title=' . $rowsubject->getPrefixedText();
$page_cats = smwfGetStore()->getPropertyValues($rowsubject, SMWPropertyValue::makeProperty('_INST'));
// TODO: set limit to 1 here
if (count($page_cats) > 0) {
$this->addPropToItem($item, 'type', array(reset($page_cats)->getShortHTMLText()));
}
}
return $item;
}
示例8: getIdsOfQueriesUsingCategory
public function getIdsOfQueriesUsingCategory($semanticData, $categories)
{
$queryIds = array();
$property = SMWPropertyValue::makeProperty('___QRC_UQC');
$propVals = $semanticData->getPropertyValues($property);
foreach ($propVals as $pVs) {
$pVs = $pVs->getDBKeys();
$pVs = $pVs[0];
$break = false;
$queryId = '';
foreach ($pVs as $pV) {
if ($pV[0] == QRC_DOC_LABEL && array_key_exists($pV[1][0], $categories)) {
$break = true;
}
if ($pV[0] == QRC_HQID_LABEL) {
$queryId = $pV[1][0];
}
if ($break && strlen($queryId) > 0) {
$queryIds[$queryId] = true;
break;
}
}
}
return $queryIds;
}
示例9: renderFolkTagCloud
function renderFolkTagCloud($input, $args, $parser)
{
# definition of variables
$append = '';
$count = 0;
$max_tags = 1000;
$min_count = 1;
$increase_factor = 100;
$min_font_size = 77;
$font_size = 0;
$htmlout = '';
# disable cache
$parser->disableCache();
# not needed with searchlink data
# build URL path
# global $wgServer, $wgArticlePath;
# $path = $wgServer . $wgArticlePath;
# default tagging property
$tag_name = 'FolkTag';
# use a user-defined tagging property as default
global $wgFTCTagName;
if (isset($wgFTCTagName)) {
$tag_name = $wgFTCTagName;
}
# use a user-defined tagging property for this tag cloud
if (isset($args['property'])) {
$tag_name = str_replace(' ', '_', ucfirst($args['property']));
}
# maximum of tags shown
if (isset($args['maxtags'])) {
$max_tags = intval($args['maxtags']);
}
# minimum frequency for tags to be shown
if (isset($args['mincount'])) {
$min_count = intval($args['mincount']);
}
# increase factor
if (isset($args['increasefactor'])) {
$increase_factor = intval($args['increasefactor']);
}
# minimum font size
if (isset($args['minfontsize'])) {
$min_font_size = intval($args['minfontsize']);
}
# get database
$db =& wfGetDB(DB_SLAVE);
$store = new SMWSQLStore2();
extract($db->tableNames('categorylinks', 'page'));
# make tagging property an SMWPorpertyValue in order to access store
$property = SMWPropertyValue::makeProperty($tag_name);
# initialising result arrays
$values = array();
$result = array();
$links = array();
# if there is no filter category:
if ($input == NULL) {
$values = ft_getPropertyValues($property, $store);
# $values = $store->getPropertyValues(NULL, $property);
} else {
$categories = explode(',', $input);
# include subcategories:
if (isset($args['subcategorylevel'])) {
$subcategories = array();
foreach ($categories as $category) {
$subcategories = array_merge($subcategories, getSubCategories($category, intval($args['subcategorylevel'])));
}
$categories = array_merge($categories, $subcategories);
}
# start building sql
$sql = "SELECT page_title, page_namespace\n\t\t\t\tFROM {$page}\n\t\t\t\tINNER JOIN {$categorylinks}\n\t\t\t\tON {$page}.page_id = {$categorylinks}.cl_from\n\t\t\t\tAND (";
# disjunction of filter categories
foreach ($categories as $category) {
$category = trim($category);
$category = str_replace(' ', '_', $category);
$category = str_replace("'", "\\'", $category);
$sql .= "{$categorylinks}.cl_to = '{$category}' OR ";
}
# remainder of sql (FALSE is required to absorb the last OR)
$sql .= "FALSE) GROUP BY page_title";
# query
$res = $db->query($sql);
# parsing result of sql query: get name and namespace of pages placed in the
# filter categories and look up all values of the given property for each page
for ($i = 0; $i < $db->numRows($res); $i++) {
$row = $db->fetchObject($res);
$pagename = $row->page_title;
$namespace = $row->page_namespace;
$values = array_merge($values, $store->getPropertyValues(SMWWikiPageValue::makePage($pagename, $namespace), $property));
}
$db->freeResult($res);
}
# counting frequencies
foreach ($values as $value) {
# get surface form of property value
$tag = $value->getShortHTMLText();
# get Searchlink data for property and current property value
$link = SMWInfolink::newPropertySearchLink($tag, $tag_name, $tag)->getHTML();
if (array_key_exists($tag, $result)) {
$result[$tag] += 1;
} else {
//.........这里部分代码省略.........
示例10: getAnnotationsWithUnit
public function getAnnotationsWithUnit(Title $type, $unit)
{
$db =& wfGetDB(DB_SLAVE);
$smw_atts2 = $db->tableName('smw_atts2');
$smw_rels2 = $db->tableName('smw_rels2');
$smw_ids = $db->tableName('smw_ids');
$smw_spec2 = $db->tableName('smw_spec2');
$result = array();
$hasTypePropertyID = smwfGetStore()->getSMWPropertyID(SMWPropertyValue::makeProperty("_TYPE"));
$res = $db->query('SELECT DISTINCT i.smw_title AS subject_title, i.smw_namespace AS subject_namespace, i2.smw_title AS attribute_title FROM ' . $smw_ids . ' i JOIN ' . $smw_atts2 . ' a ON i.smw_id = a.s_id JOIN ' . $smw_spec2 . ' s ON a.p_id = s.s_id AND s.p_id = ' . $hasTypePropertyID . ' JOIN ' . $smw_ids . ' i2 ON i2.smw_id = a.p_id ' . ' WHERE s.value_string = ' . $db->addQuotes($type->getDBkey()) . ' AND a.value_unit = ' . $db->addQuotes($unit));
if ($db->numRows($res) > 0) {
while ($row = $db->fetchObject($res)) {
$result[] = array(Title::newFromText($row->subject_title, $row->subject_namespace), Title::newFromText($row->attribute_title, SMW_NS_PROPERTY));
}
}
$db->freeResult($res);
return $result;
}
示例11: makeHTMLResult
//.........这里部分代码省略.........
$tmp_parray[$key] = $value;
}
}
$urltail .= '&p=' . urlencode(SMWInfolink::encodeParameters($tmp_parray));
$printoutstring = '';
foreach ($this->m_printouts as $printout) {
$printoutstring .= $printout->getSerialisation() . "\n";
}
if ($printoutstring != '') {
$urltail .= '&po=' . urlencode($printoutstring);
}
if (array_key_exists('sort', $this->m_params)) {
$urltail .= '&sort=' . $this->m_params['sort'];
}
if (array_key_exists('order', $this->m_params)) {
$urltail .= '&order=' . $this->m_params['order'];
}
if ($this->m_querystring != '') {
$queryobj = SMWQueryProcessor::createQuery($this->m_querystring, $this->m_params, SMWQueryProcessor::SPECIAL_PAGE, $this->m_params['format'], $this->m_printouts);
$queryobj->params = $this->m_params;
$store = $this->getStore();
$res = $store->getQueryResult($queryobj);
// try to be smart for rss/ical if no description/title is given and we have a concept query:
if ($this->m_params['format'] == 'rss') {
$desckey = 'rssdescription';
$titlekey = 'rsstitle';
} elseif ($this->m_params['format'] == 'icalendar') {
$desckey = 'icalendardescription';
$titlekey = 'icalendartitle';
} else {
$desckey = false;
}
if ($desckey && $queryobj->getDescription() instanceof SMWConceptDescription && (!isset($this->m_params[$desckey]) || !isset($this->m_params[$titlekey]))) {
$concept = $queryobj->getDescription()->getConcept();
if (!isset($this->m_params[$titlekey])) {
$this->m_params[$titlekey] = $concept->getText();
}
if (!isset($this->m_params[$desckey])) {
$dv = end(smwfGetStore()->getPropertyValues(SMWWikiPageValue::makePageFromTitle($concept), SMWPropertyValue::makeProperty('_CONC')));
if ($dv instanceof SMWConceptValue) {
$this->m_params[$desckey] = $dv->getDocu();
}
}
}
$printer = SMWQueryProcessor::getResultPrinter($this->m_params['format'], SMWQueryProcessor::SPECIAL_PAGE);
$result_mime = $printer->getMimeType($res);
global $wgRequest;
$hidequery = $wgRequest->getVal('eq') == 'no';
// if it's an export format (like CSV, JSON, etc.),
// don't actually export the data if 'eq' is set to
// either 'yes' or 'no' in the query string - just
// show the link instead
if ($this->m_editquery || $hidequery) {
$result_mime = false;
}
if ($result_mime == false) {
if ($res->getCount() > 0) {
if ($this->m_editquery) {
$urltail .= '&eq=yes';
}
if ($hidequery) {
$urltail .= '&eq=no';
}
$navigation = $this->getNavigationBar($res, $urltail);
$result .= '<div style="text-align: center;">' . "\n" . $navigation . "\n</div>\n";
$query_result = $printer->getResult($res, $this->m_params, SMW_OUTPUT_HTML);
if (is_array($query_result)) {
$result .= $query_result[0];
} else {
$result .= $query_result;
}
$result .= '<div style="text-align: center;">' . "\n" . $navigation . "\n</div>\n";
} else {
$result = '<div style="text-align: center;">' . wfMsg('smw_result_noresults') . '</div>';
}
} else {
// make a stand-alone file
$result = $printer->getResult($res, $this->m_params, SMW_OUTPUT_FILE);
$result_name = $printer->getFileName($res);
// only fetch that after initialising the parameters
}
}
if ($result_mime == false) {
if ($this->m_querystring) {
$wgOut->setHTMLtitle($this->m_querystring);
} else {
$wgOut->setHTMLtitle(wfMsg('ask'));
}
$result = $this->getInputForm($printoutstring, 'offset=' . $this->m_params['offset'] . '&limit=' . $this->m_params['limit'] . $urltail) . $result;
$result = $this->postProcessHTML($result);
$wgOut->addHTML($result);
} else {
$wgOut->disable();
header("Content-type: {$result_mime}; charset=UTF-8");
if ($result_name !== false) {
header("content-disposition: attachment; filename={$result_name}");
}
print $result;
}
}
示例12: doQuery
/**
* Fill the internal arrays with the set of articles to be displayed (possibly plus one additional
* article that indicates further results).
*/
protected function doQuery()
{
$store = smwfGetStore();
$options = new SMWRequestOptions();
$options->limit = $this->limit + 1;
$options->offset = $this->offset;
$options->sort = true;
$reverse = false;
if ($this->from != '') {
$options->boundary = $this->from;
$options->ascending = true;
$options->include_boundary = true;
} elseif ($this->until != '') {
$options->boundary = $this->until;
$options->ascending = false;
$options->include_boundary = false;
$reverse = true;
}
$this->annotations = $store->getAllPropertyAnnotations($this->mProperty, $options);
$this->articles = array();
foreach ($this->annotations as $a) {
list($article, $values) = $a;
$this->articles[] = $article;
}
if ($reverse) {
$this->annotations = array_reverse($this->annotations);
$this->articles = array_reverse($this->articles);
}
// retrieve all subproperties of this property
$s_options = new SMWRequestOptions();
$s_options->sort = true;
$s_options->ascending = true;
$this->subproperties = $store->getPropertySubjects(SMWPropertyValue::makeProperty('_SUBP'), $this->getDataValue(), $s_options);
}
示例13: getPropertyList
/**
* Returns a property list with a specific namespace as HTML table.
* @param int $ns ID of the namespace of the properties of interest
* (SMW_NS_PROPERTY, SMW_NS_ATTRIBUTE, -1 (=any namespace))
* @param array(Title) $properties All title object whose domain is the
* category.
* @param boolean $domain If <true> the properties whose domain is this
* category are listed. Otherwise those whose range is this
* category.
* @return string HTML with the table of properties
*/
private function getPropertyList($ns, $properties, $domain)
{
global $wgContLang;
global $smwgHaloContLang;
$props = array();
$store = smwfGetStore();
$sspa = $smwgHaloContLang->getSpecialSchemaPropertyArray();
$relationDV = SMWPropertyValue::makeProperty($sspa[SMW_SSP_HAS_DOMAIN_AND_RANGE_HINT]);
$hastypeDV = SMWPropertyValue::makeProperty("_TYPE");
foreach ($properties as $prop) {
if (!$prop) {
// $prop may be undefined
continue;
}
$propFound = false;
if ($prop->getNamespace() == $ns) {
// Property with namespace of interest found
$props[] = $prop;
$propFound = true;
} else {
if ($prop->getNamespace() != SMW_NS_PROPERTY) {
// The property is neither a relation nor an attribute. It is
// probably redirected from one of those or it is wrongly annotated
// with a domain hint.
$titleName = $prop->getText();
$redirects = array();
$redirects[] = $prop;
$nsFound = false;
// Collect all redirects in an array.
while (($rdSource = $this->getRedirectFrom($titleName)) != null) {
$redirects[] = $rdSource;
if ($rdSource->getNamespace() == $ns) {
$nsFound = true;
break;
}
$titleName = $rdSource->getText();
}
if ($nsFound === true || $ns == -1) {
$props[] = $redirects;
$propFound = true;
}
}
}
if ($propFound) {
// Find the range of the property
$range = null;
$type = $store->getPropertyValues($prop, $hastypeDV);
if (count($type) > 0) {
$type = $type[0];
$xsd = array_shift($type->getDBkeys());
if ($xsd != '_wpg') {
$range = $type;
}
}
if ($range == null) {
$range = $store->getPropertyValues($prop, $relationDV);
$rangePageContainers = array();
foreach ($range as $c) {
$h = $c->getDVs();
$domainCatValue = reset($h);
$rangeCatValue = next($h);
if ($rangeCatValue != NULL) {
$rangePageContainers[] = $rangeCatValue;
}
}
$range = $rangePageContainers;
}
$props[] = $range;
}
}
$ac = count($props);
if ($ac == 0) {
// No properties => return
return "";
}
$r = "";
$r = '<a name="SMWResults"></a> <div id="mw-pages">';
if ($ns == SMW_NS_PROPERTY) {
if ($domain) {
$r .= '<h4>' . wfMsg('smw_category_properties', $this->title->getText()) . "</h4>\n";
} else {
$r .= '<h4>' . wfMsg('smw_category_properties_range', $this->title->getText()) . "</h4>\n";
}
} else {
if (count($props) > 0) {
// Pages with a domain, that are neither relation nor attribute
if ($domain) {
$r .= '<h4>' . wfMsg('smw_category_nrna', $this->title->getText()) . "</h4>\n";
$r .= wfMsg('smw_category_nrna_expl') . "\n";
//.........这里部分代码省略.........
示例14: getXMLForPage
//.........这里部分代码省略.........
if ($c == "|" || $c == "}") {
$template_name = str_replace(' ', '_', trim($template_name));
$template_name = str_replace('&', '&', $template_name);
if ($simplified_format) {
$text .= "<" . $template_name . ">";
} else {
$text .= "<{$template_label} {$name_str}=\"{$template_name}\">";
}
$creating_template_name = false;
$creating_field_name = true;
$field_id = 1;
} else {
$template_name .= $c;
}
} else {
if ($c == "|" || $c == "}") {
if ($field_has_name) {
$field_value = str_replace('&', '&', $field_value);
if ($simplified_format) {
$field_name = str_replace(' ', '_', trim($field_name));
$text .= "<" . $field_name . ">";
$text .= trim($field_value);
$text .= "</" . $field_name . ">";
} else {
$text .= "<{$field_str} {$name_str}=\"" . trim($field_name) . "\">";
$text .= trim($field_value);
$text .= "</{$field_str}>";
}
$field_value = "";
$field_has_name = false;
} else {
// "field_name" is actually the value
if ($simplified_format) {
$field_name = str_replace(' ', '_', $field_name);
// add "Field" to the beginning of the file name, since
// XML tags that are simply numbers aren't allowed
$text .= "<" . $field_str . '_' . $field_id . ">";
$text .= trim($field_name);
$text .= "</" . $field_str . '_' . $field_id . ">";
} else {
$text .= "<{$field_str} {$name_str}=\"{$field_id}\">";
$text .= trim($field_name);
$text .= "</{$field_str}>";
}
$field_id++;
}
$creating_field_name = true;
$field_name = "";
} elseif ($c == "=") {
// handle case of = in value
if (!$creating_field_name) {
$field_value .= $c;
} else {
$creating_field_name = false;
$field_has_name = true;
}
} elseif ($creating_field_name) {
$field_name .= $c;
} else {
$field_value .= $c;
}
}
}
}
}
// handle groupings, if any apply here; first check if SMW is installed
global $smwgIP;
if (isset($smwgIP)) {
$store = smwfGetStore();
foreach ($groupings as $pair) {
list($property_page, $grouping_label) = $pair;
$options = new SMWRequestOptions();
$options->sort = "subject_title";
// get actual property from the wiki-page of the property
if (class_exists('SMWDIProperty')) {
$wiki_page = new SMWDIWikiPage($page_title, $page_namespace, null);
$property = SMWDIProperty::newFromUserLabel($property_page->getTitle()->getText());
} else {
$wiki_page = SMWDataValueFactory::newTypeIDValue('_wpg', $page_title);
$property = SMWPropertyValue::makeProperty($property_page->getTitle()->getText());
}
$res = $store->getPropertySubjects($property, $wiki_page, $options);
$num = count($res);
if ($num > 0) {
$grouping_label = str_replace(' ', '_', $grouping_label);
$text .= "<{$grouping_label}>\n";
foreach ($res as $subject) {
$subject_title = $subject->getTitle();
$text .= self::getXMLForPage($subject_title, $simplified_format, $groupings, $depth + 1);
}
$text .= "</{$grouping_label}>\n";
}
}
}
$text .= "</{$page_str}>\n";
// escape back the curly brackets that were escaped out at the beginning
$text = str_replace('&#123;', '{', $text);
$text = str_replace('&#125;', '}', $text);
return $text;
}
示例15: getXMLForPage
static function getXMLForPage($title, $simplified_format, $groupings, $depth = 0)
{
if ($depth > 5) {
return "";
}
global $wgContLang, $dtgContLang;
// if this page belongs to the exclusion category, exit
$parent_categories = $title->getParentCategoryTree(array());
$dt_props = $dtgContLang->getPropertyLabels();
// $exclusion_category = $title->newFromText($dt_props[DT_SP_IS_EXCLUDED_FROM_XML], NS_CATEGORY);
$exclusion_category = $wgContLang->getNSText(NS_CATEGORY) . ':' . str_replace(' ', '_', $dt_props[DT_SP_IS_EXCLUDED_FROM_XML]);
if (self::treeContainsElement($parent_categories, $exclusion_category)) {
return "";
}
$pageStructure = DTPageStructure::newFromTitle($title);
$text = $pageStructure->toXML($simplified_format);
// handle groupings, if any apply here; first check if SMW is installed
global $smwgIP;
if (isset($smwgIP)) {
$store = smwfGetStore();
$page_title = $title->getText();
$page_namespace = $title->getNamespace();
// Escaping is needed for SMWSQLStore3 - this may be a bug in SMW.
$escaped_page_title = str_replace(' ', '_', $page_title);
foreach ($groupings as $pair) {
list($property_page, $grouping_label) = $pair;
$options = new SMWRequestOptions();
$options->sort = "subject_title";
// get actual property from the wiki-page of the property
if (class_exists('SMWDIProperty')) {
$wiki_page = new SMWDIWikiPage($escaped_page_title, $page_namespace, null);
$property = SMWDIProperty::newFromUserLabel($property_page->getTitle()->getText());
} else {
$wiki_page = SMWDataValueFactory::newTypeIDValue('_wpg', $escaped_page_title);
$property = SMWPropertyValue::makeProperty($property_page->getTitle()->getText());
}
$res = $store->getPropertySubjects($property, $wiki_page, $options);
$num = count($res);
if ($num > 0) {
$grouping_label = str_replace(' ', '_', $grouping_label);
$text .= "<{$grouping_label}>\n";
foreach ($res as $subject) {
$subject_title = $subject->getTitle();
$text .= self::getXMLForPage($subject_title, $simplified_format, $groupings, $depth + 1);
}
$text .= "</{$grouping_label}>\n";
}
}
}
// escape back the curly brackets that were escaped out at the beginning
$text = str_replace('&#123;', '{', $text);
$text = str_replace('&#125;', '}', $text);
return $text;
}