Esempio n. 1
0
	/**
	 * 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 );
		}
	}
 /**
  * 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;
 }
 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);
 }
Esempio n. 4
0
 /**
  * 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);
     }
 }
Esempio n. 5
0
/**
 * 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;
}
 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;
 }
Esempio n. 7
0
 /**
  * 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;
 }
 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;
 }
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 {
            $result[$tag] = 1;
            $links[$tag] = $link;
        }
    }
    # sorting results
    arsort($result);
    # if too many tags are found, remove rear part of result array
    if (count($result) > $max_tags) {
        $result = array_slice($result, 0, $max_tags, true);
    }
    # get minimum and maximum frequency for computing font sizes
    $min = end($result) or $min = 0;
    $max = reset($result) or $max = 1;
    if ($max == $min) {
        $max += 1;
    }
    # sorting results by frequency
    if (isset($args['order'])) {
        if ($args['order'] != "frequency") {
            # ksort($result, SORT_STRING);
            uksort($result, 'compareLowercase');
        }
    } else {
        uksort($result, 'compareLowercase');
    }
    # start building html output
    $htmlOut = $htmlOut . "<div align=justify>";
    foreach ($result as $label => $count) {
        if ($count >= $min_count) {
            if (isset($args['increase'])) {
                # computing font size (logarithmic)
                if ($args[increase] = 'log') {
                    $font_size = $min_font_size + $increase_factor * (log($count) - log($min)) / (log($max) - log($min));
                } else {
                    $font_size = $min_font_size + $increase_factor * ($count - $min) / ($max - $min);
                }
            } else {
                $font_size = $min_font_size + $increase_factor * ($count - $min) / ($max - $min);
            }
            $style = "font-size: {$font_size}%;";
            # link to special page search by property with parameters
            # property=tagging property and value=current tag
            # find URL in searchlink data
            $matches = array();
            preg_match('/href="(.)*"/U', $links[$label], $matches);
            $url = $matches[0];
            # include freqency in brackets in output
            if ($args['count']) {
                $append = " ({$count})";
            }
            # appending tag
            $currentRow = "<a style=\"{$style}\" {$url}>" . $label . $append . "</a>&#160; ";
            $htmlOut = $htmlOut . $currentRow;
        }
    }
    $htmlOut = $htmlOut . "</div>";
    return $htmlOut;
}
Esempio n. 10
0
 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;
 }
Esempio n. 11
0
    protected function makeHTMLResult()
    {
        $this->checkIfThisIsAWSCALL();
        global $wgOut, $smwgAutocompleteInSpecialAsk;
        $delete_msg = wfMsg('delete');
        // Javascript code for the dynamic parts of the page
        $javascript_text = <<<END
<script type="text/javascript">       
jQuery.noConflict();
function xmlhttpPost(strURL) {
\tjQuery.ajax({ url: strURL, data: getquerystring(), context: document.body, success: function(data){
\t\tdocument.getElementById("other_options").innerHTML = data;
\t}});   
}
function getquerystring() {
\tvar format_selector = document.getElementById('formatSelector');
\treturn format_selector.value;
}

// code for handling adding and removing the "sort" inputs
var num_elements = {$this->m_num_sort_values};

function addInstance(starter_div_id, main_div_id) {
\tvar starter_div = document.getElementById(starter_div_id);
\tvar main_div = document.getElementById(main_div_id);

\t//Create the new instance
\tvar new_div = starter_div.cloneNode(true);
\tvar div_id = 'sort_div_' + num_elements;
\tnew_div.className = 'multipleTemplate';
\tnew_div.id = div_id;
\tnew_div.style.display = 'block';

\tvar children = new_div.getElementsByTagName('*');
\tvar x;
\tfor (x = 0; x < children.length; x++) {
\t\tif (children[x].name)
\t\t\tchildren[x].name = children[x].name.replace(/_num/, '[' + num_elements + ']');
\t}

\t//Create 'delete' link
\tvar remove_button = document.createElement('span');
\tremove_button.innerHTML = '[<a href="javascript:removeInstance(\\'sort_div_' + num_elements + '\\')">{$delete_msg}</a>]';
\tnew_div.appendChild(remove_button);

\t//Add the new instance
\tmain_div.appendChild(new_div);
\tnum_elements++;
}

function removeInstance(div_id) {
\tvar olddiv = document.getElementById(div_id);
\tvar parent = olddiv.parentNode;
\tparent.removeChild(olddiv);
}
</script>

END;
        $wgOut->addScript($javascript_text);
        if ($smwgAutocompleteInSpecialAsk) {
            self::addAutocompletionJavascriptAndCSS();
        }
        $result = '';
        $result_mime = false;
        // output in MW Special page as usual
        // build parameter strings for URLs, based on current settings
        $urltail = '&q=' . urlencode($this->m_querystring);
        $tmp_parray = array();
        foreach ($this->m_params as $key => $value) {
            if (!in_array($key, array('sort', 'order', 'limit', 'offset', 'title'))) {
                $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;
        }
    }
Esempio n. 12
0
 /**
  * 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);
 }
Esempio n. 13
0
 /**
  * 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";
             } else {
                 $r .= '<h4>' . wfMsg('smw_category_nrna_range', $this->title->getText()) . "</h4>\n";
                 $r .= wfMsg('smw_category_nrna_range_expl') . "\n";
             }
         }
     }
     $r .= "</div>";
     $r .= '<table style="width: 100%;" class="smw-category-schema-table smwtable">';
     if ($ns == SMW_NS_PROPERTY) {
         $r .= '<tr><th>Property</th><th>Range/Type</th></tr>';
     }
     $prevchar = 'None';
     for ($index = 0; $index < $ac; $index += 2) {
         // Property name
         if (is_array($props[$index])) {
             // Handle list of redirects
             $redirects = $props[$index];
             $r .= '<tr><td>';
             $rc = count($redirects);
             for ($i = 0; $i < $rc; $i++) {
                 if ($i == 1) {
                     $r .= ' <span class="smw-cat-redirected-from">(redirected from: ';
                 }
                 $rd = $redirects[$i];
                 $pt = $rd->getPrefixedText();
                 $searchlink = SMWInfolink::newBrowsingLink('+', $pt);
                 $link = $this->getSkin()->makeKnownLinkObj($rd, $wgContLang->convert($rd->getText()));
                 $link = preg_replace("/(.*?)(href=\".*?)\"(.*)/", "\$1\$2?redirect=no\"\$3", $link);
                 $r .= $link;
                 $r .= $searchlink->getHTML($this->getSkin()) . " ";
             }
             if ($rc > 1) {
                 $r .= ')</span>';
             }
             $r .= '</td><td>';
         } else {
             $searchlink = SMWInfolink::newBrowsingLink('+', $props[$index]->getPrefixedText());
             $r .= '<tr><td>' . $this->getSkin()->makeKnownLinkObj($props[$index], $wgContLang->convert($props[$index]->getText())) . '&nbsp;' . $searchlink->getHTML($this->getSkin()) . '</td><td>';
         }
         // Show the range
         if (is_array($props[$index + 1])) {
             $range = $props[$index + 1];
             if (count($range) > 0) {
                 ///FIXME this check is just for compatibility reasons and as catch for obscure and buggy code; the class of $range[0] should not vary between different possibilities.
                 if ($range[0] instanceof SMWWikiPageValue) {
                     $r .= $this->getSkin()->makeKnownLinkObj($range[0]->getTitle(), $wgContLang->convert($range[0]->getTitle()->getText()));
                 } elseif ($range[0] instanceof SMWDataValue) {
                     $r .= $range[0]->getShortHTMLText();
                 } else {
                     $r .= $range[0];
                 }
             }
         } else {
             if ($props[$index + 1] instanceof SMWTypesValue) {
                 $t = $props[$index + 1];
                 $t = $t->getTypeLabels();
                 $r .= $t[0];
             }
         }
         $r .= "</td></tr>\n";
     }
     $r .= '</table>';
     return $r;
 }
Esempio n. 14
0
 static function getXMLForPage($title, $simplified_format, $groupings, $depth = 0)
 {
     if ($depth > 5) {
         return "";
     }
     global $wgContLang, $dtgContLang;
     $namespace_labels = $wgContLang->getNamespaces();
     $template_label = $namespace_labels[NS_TEMPLATE];
     $namespace_str = str_replace(' ', '_', wfMsgForContent('dt_xml_namespace'));
     $page_str = str_replace(' ', '_', wfMsgForContent('dt_xml_page'));
     $field_str = str_replace(' ', '_', wfMsgForContent('dt_xml_field'));
     $name_str = str_replace(' ', '_', wfMsgForContent('dt_xml_name'));
     $title_str = str_replace(' ', '_', wfMsgForContent('dt_xml_title'));
     $id_str = str_replace(' ', '_', wfMsgForContent('dt_xml_id'));
     $free_text_str = str_replace(' ', '_', wfMsgForContent('dt_xml_freetext'));
     // 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 "";
     }
     $article = new Article($title);
     $page_title = str_replace('"', '&quot;', $title->getText());
     $page_title = str_replace('&', '&amp;', $page_title);
     $page_namespace = $title->getNamespace();
     if ($simplified_format) {
         $text = "<{$page_str}><{$id_str}>{$article->getID()}</{$id_str}><{$title_str}>{$page_title}</{$title_str}>\n";
     } else {
         $text = "<{$page_str} {$id_str}=\"" . $article->getID() . "\" {$title_str}=\"" . $page_title . '" >';
     }
     // traverse the page contents, one character at a time
     $uncompleted_curly_brackets = 0;
     $page_contents = $article->getContent();
     // escape out variables like "{{PAGENAME}}"
     $page_contents = str_replace('{{PAGENAME}}', '&#123;&#123;PAGENAME&#125;&#125;', $page_contents);
     // escape out parser functions
     $page_contents = preg_replace('/{{(#.+)}}/', '&#123;&#123;$1&#125;&#125;', $page_contents);
     // escape out transclusions
     $page_contents = preg_replace('/{{(:.+)}}/', '&#123;&#123;$1&#125;&#125;', $page_contents);
     // escape out variable names
     $page_contents = str_replace('{{{', '&#123;&#123;&#123;', $page_contents);
     $page_contents = str_replace('}}}', '&#125;&#125;&#125;', $page_contents);
     // escape out tables
     $page_contents = str_replace('{|', '&#123;|', $page_contents);
     $page_contents = str_replace('|}', '|&#125;', $page_contents);
     $free_text = "";
     $free_text_id = 1;
     $template_name = "";
     $field_name = "";
     $field_value = "";
     $field_has_name = false;
     for ($i = 0; $i < strlen($page_contents); $i++) {
         $c = $page_contents[$i];
         if ($uncompleted_curly_brackets == 0) {
             if ($c == "{" || $i == strlen($page_contents) - 1) {
                 if ($i == strlen($page_contents) - 1) {
                     $free_text .= $c;
                 }
                 $uncompleted_curly_brackets++;
                 $free_text = trim($free_text);
                 $free_text = str_replace('&', '&amp;', $free_text);
                 $free_text = str_replace('[', '&#91;', $free_text);
                 $free_text = str_replace(']', '&#93;', $free_text);
                 $free_text = str_replace('<', '&lt;', $free_text);
                 $free_text = str_replace('>', '&gt;', $free_text);
                 if ($free_text != "") {
                     $text .= "<{$free_text_str} id=\"{$free_text_id}\">{$free_text}</{$free_text_str}>";
                     $free_text = "";
                     $free_text_id++;
                 }
             } elseif ($c == "{") {
                 // do nothing
             } else {
                 $free_text .= $c;
             }
         } elseif ($uncompleted_curly_brackets == 1) {
             if ($c == "{") {
                 $uncompleted_curly_brackets++;
                 $creating_template_name = true;
             } elseif ($c == "}") {
                 $uncompleted_curly_brackets--;
                 // is this needed?
                 // if ($field_name != "") {
                 //  $field_name = "";
                 // }
                 if ($page_contents[$i - 1] == '}') {
                     if ($simplified_format) {
                         $text .= "</" . $template_name . ">";
                     } else {
                         $text .= "</{$template_label}>";
                     }
                 }
                 $template_name = "";
             }
         } else {
             // 2 or greater - probably 2
             if ($c == "}") {
                 $uncompleted_curly_brackets--;
             }
             if ($c == "{") {
                 $uncompleted_curly_brackets++;
             } else {
                 if ($creating_template_name) {
                     if ($c == "|" || $c == "}") {
                         $template_name = str_replace(' ', '_', trim($template_name));
                         $template_name = str_replace('&', '&amp;', $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('&', '&amp;', $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('&amp;#123;', '{', $text);
     $text = str_replace('&amp;#125;', '}', $text);
     return $text;
 }
Esempio n. 15
0
 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('&amp;#123;', '{', $text);
     $text = str_replace('&amp;#125;', '}', $text);
     return $text;
 }
/**
 * @file
 * @ingroup SMWHaloTriplestore
 * 
 * Schema contributor tries to add all schema information from the wiki
 * Warning: may created complex models.
 * 
 * Called when property annotations get updated in a triple store.
 *
 * @param $semData All semantic data (for context)
 * @param $property Currently processed property
 * @param $propertyValueArray Values of current property
 * @param $triplesFromHook Triples which are returned.
 *
 * @return Array of triples or false. If return value is a non-empty array processing stops for this property. Same if it is explicitly false.
 * Otherwise normal processing goes on.
 */
function smwfTripleStorePropertyUpdate(&$data, &$property, &$propertyValueArray, &$triplesFromHook)
{
    global $smwgTripleStoreGraph;
    if (!$property instanceof SMWPropertyValue) {
        // error. should not happen
        trigger_error("Triple store update: property is not SMWPropertyValue");
        return true;
    }
    // check if it is a property with special semantics
    // check for 'has domain, range' and 'is inverse of' and 'has type'
    // 'has min cardinality' and 'has max cardinality are read implictly when processing 'has domain and range'
    // and therefore ignored.
    $allProperties = $data->getProperties();
    if (smwfGetSemanticStore()->domainRangeHintRelation->getDBkey() == array_shift($property->getDBkeys())) {
        foreach ($propertyValueArray as $domRange) {
            if (!$domRange instanceof SMWRecordValue) {
                continue;
            }
            // occurs if 'has domain and range' is not n-ary
            if (count($domRange->getDVs()) == 2) {
                $dvs = $domRange->getDVs();
                if ($dvs[0] != NULL && $dvs[1] != NULL && $dvs[0]->isValid() && $dvs[1]->isValid()) {
                    // domain and range
                    $minCard = $data->getPropertyValues(smwfGetSemanticStore()->minCardProp);
                    $maxCard = $data->getPropertyValues(smwfGetSemanticStore()->maxCardProp);
                    // insert RDFS
                    $triplesFromHook[] = array("<{$smwgTripleStoreGraph}/property#" . $data->getSubject()->getDBkey() . ">", "rdfs:domain", "cat:" . $dvs[0]->getDBkey());
                    $triplesFromHook[] = array("<{$smwgTripleStoreGraph}/property#" . $data->getSubject()->getDBkey() . ">", "rdfs:range", "cat:" . $dvs[1]->getDBkey());
                    // insert OWL
                    $triplesFromHook[] = array("<{$smwgTripleStoreGraph}/category#" . $dvs[0]->getDBkey() . ">", "rdfs:subClassOf", "_:1");
                    $triplesFromHook[] = array("_:1", "owl:Restriction", "_:2");
                    $triplesFromHook[] = array("_:2", "owl:onProperty", "<{$smwgTripleStoreGraph}/property#" . $data->getSubject()->getDBkey() . ">");
                    $triplesFromHook[] = array("_:2", "owl:allValuesFrom", "<{$smwgTripleStoreGraph}/category#" . $dvs[1]->getDBkey() . ">");
                    foreach ($minCard as $value) {
                        if (array_shift($value->getDBkeys()) !== false) {
                            $triplesFromHook[] = array("_:2", "owl:minCardinality", "\"" . array_shift($value->getDBkeys()) . "\"");
                        }
                    }
                    foreach ($maxCard as $value) {
                        if (array_shift($value->getDBkeys()) !== false) {
                            $triplesFromHook[] = array("_:2", "owl:minCardinality", "\"" . array_shift($value->getDBkeys()) . "\"");
                        }
                    }
                } elseif ($dvs[0] != NULL && $dvs[0]->isValid()) {
                    // only domain
                    $typeValues = $data->getPropertyValues(SMWPropertyValue::makeProperty("_TYPE"));
                    $minCard = $data->getPropertyValues(smwfGetSemanticStore()->minCardProp);
                    $maxCard = $data->getPropertyValues(smwfGetSemanticStore()->maxCardProp);
                    // insert RDFS
                    $triplesFromHook[] = array("prop:" . $data->getSubject()->getDBkey(), "rdfs:domain", "<{$smwgTripleStoreGraph}/category#" . $dvs[0]->getDBkey() . ">");
                    foreach ($typeValues as $value) {
                        if (array_shift($value->getDBkeys()) !== false) {
                            $typeID = array_shift($value->getDBkeys());
                            if ($typeID != '_wpg') {
                                $triplesFromHook[] = array("<{$smwgTripleStoreGraph}/property#" . $data->getSubject()->getDBkey() . ">", "rdfs:range", WikiTypeToXSD::getXSDType($typeID));
                            }
                        }
                    }
                    // insert OWL
                    $triplesFromHook[] = array("<{$smwgTripleStoreGraph}/category#" . $dvs[0]->getDBkey() . ">", "rdfs:subClassOf", "_:1");
                    $triplesFromHook[] = array("_:1", "owl:Restriction", "_:2");
                    $triplesFromHook[] = array("_:2", "owl:onProperty", "<{$smwgTripleStoreGraph}/property#" . $data->getSubject()->getDBkey() . ">");
                    foreach ($typeValues as $value) {
                        if (array_shift($value->getDBkeys()) !== false) {
                            $triplesFromHook[] = array("_:2", "owl:allValuesFrom", WikiTypeToXSD::getXSDType(array_shift($value->getDBkeys())));
                        }
                    }
                    foreach ($minCard as $value) {
                        if (array_shift($value->getDBkeys()) !== false) {
                            $triplesFromHook[] = array("_:2", "owl:minCardinality", "\"" . array_shift($value->getDBkeys()) . "\"");
                        }
                    }
                    foreach ($maxCard as $value) {
                        if (array_shift($value->getDBkeys()) !== false) {
                            $triplesFromHook[] = array("_:2", "owl:maxCardinality", "\"" . array_shift($value->getDBkeys()) . "\"");
                        }
                    }
                }
            }
        }
    } elseif (smwfGetSemanticStore()->inverseOf->getDBkey() == array_shift($property->getDBkeys())) {
        foreach ($propertyValueArray as $inverseProps) {
            if (count($propertyValueArray) == 1) {
                $triplesFromHook[] = array("<{$smwgTripleStoreGraph}/property#" . $data->getSubject()->getDBkey() . ">", "owl:inverseOf", "<{$smwgTripleStoreGraph}/property#" . $inverseProps->getDBkey() . ">");
            }
        }
    } elseif (smwfGetSemanticStore()->minCard->getDBkey() == array_shift($property->getDBkeys())) {
        // do nothing
        $triplesFromHook = false;
    } elseif (smwfGetSemanticStore()->maxCard->getDBkey() == array_shift($property->getDBkeys())) {
        // do nothing
        $triplesFromHook = false;
    } elseif ($property->getPropertyID() == "_TYPE") {
        // serialize type only if there is no domain and range annotation
        $domRanges = $data->getPropertyValues(smwfGetSemanticStore()->domainRangeHintProp);
        if (count($domRanges) == 0) {
            // insert only if domain and range annotation does not exist
            // insert OWL restrictions
            $minCard = $data->getPropertyValues(smwfGetSemanticStore()->minCardProp);
            $maxCard = $data->getPropertyValues(smwfGetSemanticStore()->maxCardProp);
            $triplesFromHook[] = array("<{$smwgTripleStoreGraph}/property#DefaultRootCategory>", "rdfs:subClassOf", "_:1");
            $triplesFromHook[] = array("_:1", "owl:Restriction", "_:2");
            $triplesFromHook[] = array("_:2", "owl:onProperty", "<{$smwgTripleStoreGraph}/property#" . $data->getSubject()->getDBkey() . ">");
            foreach ($propertyValueArray as $value) {
                if (array_shift($value->getDBkeys()) !== false) {
                    $typeID = array_shift($value->getDBkeys());
                    $triplesFromHook[] = array("_:2", "owl:allValuesFrom", WikiTypeToXSD::getXSDType($typeID));
                }
            }
            foreach ($minCard as $value) {
                if (array_shift($value->getDBkeys()) !== false) {
                    $triplesFromHook[] = array("_:2", "owl:minCardinality", "\"" . array_shift($value->getDBkeys()) . "\"");
                }
            }
            foreach ($maxCard as $value) {
                if (array_shift($value->getDBkeys()) !== false) {
                    $triplesFromHook[] = array("_:2", "owl:maxCardinality", "\"" . array_shift($value->getDBkeys()) . "\"");
                }
            }
            // insert RDFS range/domain
            foreach ($propertyValueArray as $value) {
                $typeID = array_shift($value->getDBkeys());
                //$triplesFromHook[] = array("prop:".$data->getSubject()->getDBkey(), "rdfs:domain", "cat:DefaultRootCategory");
                if ($typeID != '_wpg') {
                    $triplesFromHook[] = array("<{$smwgTripleStoreGraph}/property#" . $data->getSubject()->getDBkey() . ">", "rdfs:range", WikiTypeToXSD::getXSDType($typeID));
                }
            }
        }
        // insert Has type
        foreach ($propertyValueArray as $value) {
            $typeID = array_shift($value->getDBkeys());
            if ($typeID != '_wpg') {
                $triplesFromHook[] = array("<{$smwgTripleStoreGraph}/property#" . $data->getSubject()->getDBkey() . ">", "Has_type", WikiTypeToXSD::getXSDType($typeID));
            }
        }
    }
    return true;
}
 public function getNaryProperties($sort)
 {
     $NSatt = SMW_NS_PROPERTY;
     $db =& wfGetDB(DB_SLAVE);
     $smw_ids = $db->tableName('smw_ids');
     $smw_spec2 = $db->tableName('smw_spec2');
     $smw_rels2 = $db->tableName('smw_rels2');
     $page = $db->tableName('page');
     $hasTypePropertyID = smwfGetStore()->getSMWPropertyID(SMWPropertyValue::makeProperty("_LIST"));
     // REGEXP '_[a-z]{1,3}(;_[a-z]{1,3})+' matches all n-ary properties in special property table. Is there a better way?
     return "SELECT 'Relations' as type, {$NSatt} as namespace, s.value_string as value, \r\n                        i.smw_title as title, COUNT(*) as count, '-1' as obns FROM {$smw_rels2} a \r\n                        JOIN {$smw_spec2} s ON s.s_id = a.p_id AND s.p_id={$hasTypePropertyID} AND s.value_string REGEXP '_[a-z]{1,3}(;_[a-z]{1,3})+' \r\n                        JOIN {$smw_ids} i ON i.smw_id = a.p_id\r\n                        JOIN {$page} p ON page_title = i.smw_title AND page_namespace = i.smw_namespace  \r\n                GROUP BY i.smw_title, s.value_string";
 }
Esempio n. 18
0
 private function createTriples($wsResult, $subjectCreationPattern, $wsId, $unwantedPropertys, $previewTitle)
 {
     $unwantedPropertys = array_flip($unwantedPropertys);
     global $wgParser, $IP;
     require_once $IP . "/extensions/SMWHalo/includes/storage/SMW_TS_Helper.php";
     $subjects = array();
     //get number of rows and property types
     $lineCount = 0;
     $types = array();
     foreach ($wsResult as $propertyName => $resultPart) {
         $lineCount = max($lineCount, count($resultPart));
         $title = Title::newFromText($propertyName, SMW_NS_PROPERTY);
         $semData = smwfGetStore()->getSemanticData(SMWWikiPageValue::makePageFromTitle($title));
         $property = SMWPropertyValue::makeProperty('Has_type');
         $value = $semData->getPropertyValues($property);
         if (count($value) > 0) {
             $fK = array_keys($value);
             $fK = $fK[0];
             @($types[$propertyName] = '' . $value[$fK]->getShortWikiText());
             $types[$propertyName] = str_replace('http://www.w3.org/2001/XMLSchema#', 'xsd:', $types[$propertyName]);
             //@ $types[$propertyName] = SMWDataValueFactory::findTypeID($value[$fK]->getShortWikiText());
         } else {
             $types[$propertyName] = '';
         }
     }
     $triples = array();
     $allAliases = WebService::newFromId($wsId)->getAllResultPartAliases();
     $subjectCreationPatternParts = array();
     foreach ($allAliases as $alias => $dc) {
         if (strpos($subjectCreationPattern, "?" . $alias . "?") !== false) {
             $alias = explode(".", $alias);
             $subjectCreationPatternParts[$alias[1]] = $alias[0] . "." . $alias[1];
         }
     }
     for ($i = 0; $i < $lineCount; $i++) {
         $tempTriples = array();
         $subject = $subjectCreationPattern;
         foreach ($wsResult as $property => $objects) {
             if (array_key_exists($i, $objects) && strlen($objects[$i]) > 0) {
                 if (array_key_exists($property, $subjectCreationPatternParts)) {
                     $subject = str_replace("?" . $subjectCreationPatternParts[$property] . "?", $objects[$i], $subject);
                 }
                 $triple = array();
                 $triple['property'] = $property;
                 $triple['object'] = $objects[$i];
                 if (!array_key_exists($property, $types) || strlen($types[$property]) == 0) {
                     $triple['type'] = '__objectURI';
                     $triple['object'] = trim($triple['object']);
                 } else {
                     //$typeDataValue = SMWDataValueFactory::newTypeIDValue($types[$property], $triple['object']);
                     //if($typeDataValue->isValid()){
                     //	$triple['type'] = WikiTypeToXSD::getXSDType($types[$property]);
                     //} else {
                     //	$triple['type'] = null;
                     //}
                     $triple['type'] = $types[$property];
                 }
                 if (!array_key_exists($property, $unwantedPropertys)) {
                     $tempTriples[] = $triple;
                 }
             } else {
                 if (array_key_exists($property, $subjectCreationPatternParts)) {
                     $subject = str_replace("?" . $subjectCreationPatternParts[$property] . "?", '', $subject);
                 }
             }
         }
         if (is_string($previewTitle)) {
             //we are in preview mode
             $t = Title::makeTitleSafe(0, $previewTitle);
             $popts = new ParserOptions();
             $wgParser->startExternalParse($t, $popts, Parser::OT_HTML);
             $subject = $wgParser->internalParse($subject);
             //$subject = $wgParser->doBlockLevels($subject, true);
             $subject = trim($subject);
         } else {
             $subject = trim($wgParser->replaceVariables($subject));
         }
         if (strlen($subject) > 0) {
             foreach ($tempTriples as $triple) {
                 $triple['subject'] = $subject;
                 $triples[] = $triple;
             }
         }
         if (strlen($subject) > 0 && !is_string($previewTitle)) {
             $subject = "[[" . $subject . "]]";
         }
         $subjects[] = $subject;
     }
     return array($triples, $subjects);
 }
 /**
  * Returns an XML represenatation of a schema property
  *
  * @param array & schemaData. Tuple of (title, minCard, maxCard, type, isSym, isTrans, range)
  * @param count continuous number for generating new IDs
  * @param array & issues Gardening issues for that property
  *
  * @return XML string (fragment)
  */
 private static function encapsulateAsProperty(array &$schemaData, $count, array &$issues)
 {
     $id = uniqid(rand());
     $content = "";
     // unpack schemaData array
     $title = $schemaData[0];
     $minCardinality = $schemaData[1];
     $maxCardinality = $schemaData[2];
     $type = $schemaData[3];
     $isMemberOfSymCat = $schemaData[4];
     $isMemberOfTransCat = $schemaData[5];
     $range = $schemaData[6];
     $inherited = $schemaData[7] == true ? "inherited=\"true\"" : "";
     if ($type == '_wpg') {
         // binary relation?
         if ($range == NULL) {
             $content .= "<rangeType>" . wfMsg('smw_ob_undefined_type') . "</rangeType>";
         } else {
             $content .= "<rangeType isLink=\"true\">" . $range . "</rangeType>";
         }
     } else {
         // it must be an attribute or n-ary relation otherwise.
         $v = SMWDataValueFactory::newPropertyObjectValue(SMWPropertyValue::makeProperty("_TYPE"));
         $v->setDBkeys(array($type));
         $typesOfAttributeAsString = $v->getTypeLabels();
         foreach ($typesOfAttributeAsString as $typeOfAttributeAsString) {
             $content .= "<rangeType>" . $typeOfAttributeAsString . "</rangeType>";
         }
     }
     // generate attribute strings
     $maxCardText = $maxCardinality != CARDINALITY_UNLIMITED ? "maxCard=\"" . $maxCardinality . "\"" : "maxCard=\"*\"";
     $minCardText = $minCardinality != CARDINALITY_MIN ? "minCard=\"" . $minCardinality . "\"" : "minCard=\"0\"";
     $isSymetricalText = $isMemberOfSymCat ? "isSymetrical=\"true\"" : "";
     $isTransitiveText = $isMemberOfTransCat ? "isTransitive=\"true\"" : "";
     $title_esc = htmlspecialchars($title->getDBkey());
     $titleURLEscaped = htmlspecialchars(self::urlescape($title->getDBkey()));
     $numberofUsage = smwfGetSemanticStore()->getNumberOfUsage($title);
     $numberOfUsageAtt = 'num="' . $numberofUsage . '"';
     $gi_issues = SMWOntologyBrowserErrorHighlighting::getGardeningIssuesAsXML($issues);
     return "<property title_url=\"{$titleURLEscaped}\" title=\"" . $title_esc . "\" id=\"ID_" . $id . $count . "\" " . "{$minCardText} {$maxCardText} {$isSymetricalText} {$isTransitiveText} {$numberOfUsageAtt} {$inherited}>" . $content . $gi_issues . "</property>";
 }
 /**
  * Preprocess a query as given by an array of parameters as is typically
  * produced by the #ask parser function. The parsing results in a querystring,
  * an array of additional parameters, and an array of additional SMWPrintRequest
  * objects, which are filled into call-by-ref parameters.
  * $showmode is true if the input should be treated as if given by #show
  */
 public static function processFunctionParams($rawparams, &$querystring, &$params, &$printouts, $showmode = false)
 {
     global $wgContLang;
     $querystring = '';
     $printouts = array();
     $params = array();
     $doublePipe = false;
     foreach ($rawparams as $name => $param) {
         if ($doublePipe) {
             $querystring .= " || " . $param;
             $doublePipe = false;
             continue;
         }
         if (is_string($name) && $name != '') {
             // accept 'name' => 'value' just as '' => 'name=value'
             $param = $name . '=' . $param;
         }
         if ($param == '') {
             $doublePipe = true;
             continue;
         } elseif ($param[0] == '?') {
             // print statement
             $param = substr($param, 1);
             $parts = explode('=', $param, 2);
             $propparts = explode('#', $parts[0], 2);
             if (trim($propparts[0]) == '') {
                 // print "this"
                 $printmode = SMWPrintRequest::PRINT_THIS;
                 $label = '';
                 // default
                 $title = NULL;
                 $data = NULL;
             } elseif ($wgContLang->getNsText(NS_CATEGORY) == ucfirst(trim($propparts[0]))) {
                 // print categories
                 $title = NULL;
                 $printmode = SMWPrintRequest::PRINT_CATS;
                 if (count($parts) == 1) {
                     // no label found, use category label
                     $parts[] = $showmode ? '' : $wgContLang->getNSText(NS_CATEGORY);
                 }
             } else {
                 // print property or check category
                 $title = Title::newFromText(trim($propparts[0]), SMW_NS_PROPERTY);
                 // trim needed for \n
                 if ($title === NULL) {
                     continue;
                 }
                 if (!$title->exists()) {
                     // too bad, this is no legal property/category name, ignore
                     $title = Title::newFromText(trim($propparts[0]));
                 }
                 if ($title->getNamespace() == SMW_NS_PROPERTY) {
                     $printmode = SMWPrintRequest::PRINT_PROP;
                     $property = SMWPropertyValue::makeProperty($title->getDBKey());
                     $data = $property;
                     $label = $showmode ? '' : $property->getWikiValue();
                 } elseif ($title->getNamespace() == NS_CATEGORY) {
                     $printmode = SMWPrintRequest::PRINT_CCAT;
                     $data = $title;
                     $label = $showmode ? '' : $title->getText();
                 } elseif ($title->getNamespace() == NS_MAIN) {
                     $printmode = SMWPrintRequest::PRINT_THIS;
                     $data = $title;
                     $label = $showmode ? '' : $title->getText();
                 }
                 //else?
                 if (count($parts) > 1) {
                     // no label found, use property/category name
                     $label = trim($parts[1]);
                 }
             }
             if (count($propparts) == 1) {
                 // no outputformat found, leave empty
                 $propparts[] = '';
             }
             if (count($parts) > 1) {
                 // label found, use this instead of default
                 $label = trim($parts[1]);
             }
             $printouts[] = new SMWPrintRequest($printmode, $label, $data, trim($propparts[1]));
         } else {
             // parameter or query
             // FIX:KK special handling for SPARQL queries here
             if (strpos($param, "SELECT ") !== false) {
                 $querystring .= $param;
             } else {
                 $parts = explode('=', $param, 2);
                 $knownOption = in_array($parts[0], array('merge', 'template', 'mainlabel', 'sort', 'order', 'default', 'format', 'offset', 'limit', 'headers', 'link', 'intro', 'searchlabel'));
                 $probablyOption = preg_match('/^\\s*\\w+\\s*$/', $parts[0]) > 0 && strlen($parts[0]) < 20;
                 // probably an option if alphanumeric and less than 20 chars.
                 if (count($parts) == 2 && ($knownOption || $probablyOption)) {
                     $params[strtolower(trim($parts[0]))] = $parts[1];
                     // don't trim here, some params care for " "
                 } else {
                     $querystring .= $param;
                 }
             }
         }
     }
     $querystring = str_replace(array('&lt;', '&gt;'), array('<', '>'), $querystring);
     if ($showmode) {
         $querystring = "[[:{$querystring}]]";
     }
 }
Esempio n. 21
0
 /**
  * returns an array that contains already existing term import annotations
  * 
  * @param $title
  * @return array
  */
 public function getExistingTermAnnotations($title)
 {
     $existingAnnotations = array();
     $existingAnnotations['added'] = array();
     $existingAnnotations['updated'] = array();
     $existingAnnotations['ignored'] = array();
     if ($title == null) {
         return $existingAnnotations;
     }
     if ($title->exists()) {
         $semdata = smwfGetStore()->getSemanticData(SMWWikiPageValue::makePageFromTitle($title));
         $property = SMWPropertyValue::makeProperty('WasAddedDuringTermImport');
         $values = $semdata->getPropertyValues($property);
         foreach ($values as $value) {
             $existingAnnotations['added'][] = $value->getShortWikiText();
         }
         $property = SMWPropertyValue::makeProperty('WasUpdatedDuringTermImport');
         $values = $semdata->getPropertyValues($property);
         foreach ($values as $value) {
             $existingAnnotations['updated'][] = $value->getShortWikiText();
         }
         $property = SMWPropertyValue::makeProperty('WasIgnoredDuringTermImport');
         $values = $semdata->getPropertyValues($property);
         foreach ($values as $value) {
             $existingAnnotations['ignored'][] = $value->getShortWikiText();
         }
     }
     return $existingAnnotations;
 }
	/**
	 * This function returns to results of a certain query
	 * Thank you Yaron Koren for advices concerning this code
	 * @param $query_string String : the query
	 * @param $properties_to_display array(String): array of property names to display
	 * @param $display_title Boolean : add the page title in the result
	 * @return TODO
	 */
	static function getQueryResults( $query_string, $properties_to_display, $display_title ) {
		// We use the Semantic MediaWiki Processor
		// $smwgIP is defined by Semantic MediaWiki, and we don't allow
		// this file to be sourced unless Semantic MediaWiki is included.
		global $smwgIP;
		include_once( $smwgIP . "/includes/SMW_QueryProcessor.php" );

		$params = array();
		$inline = true;
		$printlabel = "";
		$printouts = array();

		// add the page name to the printouts
		if ( $display_title ) {
			$to_push = new SMWPrintRequest( SMWPrintRequest::PRINT_THIS, $printlabel );
			array_push( $printouts, $to_push );
		}

		// Push the properties to display in the printout array.
		foreach ( $properties_to_display as $property ) {
			if ( class_exists( 'SMWPropertyValue' ) ) { // SMW 1.4
				$to_push = new SMWPrintRequest( SMWPrintRequest::PRINT_PROP, $printlabel, SMWPropertyValue::makeProperty( $property ) );
			} else {
				$to_push = new SMWPrintRequest( SMWPrintRequest::PRINT_PROP, $printlabel, Title::newFromText( $property, SMW_NS_PROPERTY ) );
			}
			array_push( $printouts, $to_push );
		}

		if ( version_compare( SMW_VERSION, '1.6.1', '>' ) ) {
			SMWQueryProcessor::addThisPrintout( $printouts, $params );
			$params = SMWQueryProcessor::getProcessedParams( $params, $printouts );
			$format = null;
		}
		else {
			$format = 'auto';
		}
		
		$query = SMWQueryProcessor::createQuery( $query_string, $params, $inline, $format, $printouts );
		$results = smwfGetStore()->getQueryResult( $query );

		return $results;
	}
/**
 * Returns relation schema data as XML.
 *
 * 1. Arity of relation
 * 2. Parameter names
 *
 * Example: (Note that arity is #params + 1, because of subject)
 *
 * <relationSchema name="hasState" arity="4">
 *  <param name="Pressure"/>
 *  <param name="Temperature"/>
 *  <param name="State"/>
 * </relationSchema>
 *
 * @param relationTitle as String
 *
 * @return xml string
 */
function smwf_om_RelationSchemaData($relationName)
{
    global $smwgHaloContLang;
    $smwSpecialSchemaProperties = $smwgHaloContLang->getSpecialSchemaPropertyArray();
    // get type definition (if it exists)
    $relationTitle = Title::newFromText($relationName, SMW_NS_PROPERTY);
    $hasTypeDV = SMWPropertyValue::makeProperty("_TYPE");
    $type = smwfGetStore()->getPropertyValues($relationTitle, $hasTypeDV);
    // if no 'has type' annotation => normal binary relation
    if (count($type) == 0) {
        // return binary schema (arity = 2)
        $relSchema = '<relationSchema name="' . $relationName . '" arity="0">' . '</relationSchema>';
    } else {
        $typeLabels = $type[0]->getTypeLabels();
        $typeValues = $type[0]->getTypeValues();
        if ($type[0] instanceof SMWTypesValue) {
            // get arity
            $arity = count($typeLabels) + 1;
            // +1 because of subject
            $relSchema = '<relationSchema name="' . $relationName . '" arity="' . $arity . '">';
            // If first parameter is a wikipage, take the property name + "|Page" as label, otherwise use type label.
            $firstParam = $typeValues[0] instanceof SMWWikiPageValue ? $relationName . "|Page" : $typeLabels[0];
            $relSchema .= '<param name="' . $firstParam . '"/>';
            for ($i = 1, $n = $arity - 1; $i < $n; $i++) {
                // for all other wikipage parameters, use the range hint as label. If no range hint exists, simply print 'Page'.
                // makes normally only sense if at most one wikipage parameter exists. This will be handeled in another way in future.
                if ($typeValues[$i] instanceof SMWWikiPageValue) {
                    $rangeHints = smwfGetStore()->getPropertyValues($relationTitle, smwfGetSemanticStore()->domainRangeHintProp);
                    if (count($rangeHints) > 0) {
                        $dvs = $rangeHints->getDVs();
                        if ($dvs[1] !== NULL) {
                            $labelToPaste = htmlspecialchars($dvs[1]->getTitle()->getText());
                        } else {
                            $labelToPaste = 'Page';
                        }
                    } else {
                        $labelToPaste = 'Page';
                    }
                } else {
                    $labelToPaste = $typeLabels[$i];
                }
                $relSchema .= '<param name="' . $labelToPaste . '"/>';
            }
            $relSchema .= '</relationSchema>';
        } else {
            // this should never happen, huh?
            $relSchema = '<relationSchema name="' . $relationName . '" arity="2">' . '<param name="Page"/>' . '</relationSchema>';
        }
    }
    return $relSchema;
}