function getDirectSuperProperties(Title $attribute, $requestoptions = NULL) { $result = ""; $db =& wfGetDB(DB_SLAVE); $smw_ids = $db->tableName('smw_ids'); $smw_subs2 = $db->tableName('smw_subp2'); $page = $db->tableName('page'); $sqlOptions = DBHelper::getSQLOptionsAsString($requestoptions); $res = $db->query('SELECT o.smw_title AS subject_title FROM ' . $smw_ids . ' s JOIN ' . $smw_subs2 . ' sub ON s.smw_id = sub.s_id JOIN ' . $smw_ids . ' o ON o.smw_id = sub.o_id ' . ' AND s.smw_namespace = ' . SMW_NS_PROPERTY . ' AND o.smw_namespace = ' . SMW_NS_PROPERTY . ' AND s.smw_title = ' . $db->addQuotes($attribute->getDBkey()) . ' ' . $sqlOptions); $result = array(); if ($db->numRows($res) > 0) { while ($row = $db->fetchObject($res)) { if (smwf_om_userCan($row->subject_title, 'read', SMW_NS_PROPERTY) === "true") { $result[] = Title::newFromText($row->subject_title, SMW_NS_PROPERTY); } } } $db->freeResult($res); return $result; }
public function getPages($match, $namespaces = NULL) { $result = ""; $db =& wfGetDB(DB_SLAVE); $sql = ""; $page = $db->tableName('page'); $requestoptions = new SMWRequestOptions(); $requestoptions->limit = SMW_AC_MAX_RESULTS; $options = DBHelper::getSQLOptionsAsString($requestoptions); if ($namespaces == NULL || count($namespaces) == 0) { $sql .= 'SELECT page_title, page_namespace FROM ' . $page . ' WHERE UPPER(' . DBHelper::convertColumn('page_title') . ') LIKE UPPER(' . $db->addQuotes($match . '%') . ') ORDER BY page_title '; } else { for ($i = 0, $n = count($namespaces); $i < $n; $i++) { if ($i > 0) { $sql .= ' UNION '; } $sql .= '(SELECT page_title, page_namespace FROM ' . $page . ' WHERE UPPER(' . DBHelper::convertColumn('page_title') . ') LIKE UPPER(' . $db->addQuotes($match . '%') . ') AND page_namespace=' . $db->addQuotes($namespaces[$i]) . ' ORDER BY page_title) UNION '; $sql .= '(SELECT page_title, page_namespace FROM ' . $page . ' WHERE UPPER(' . DBHelper::convertColumn('page_title') . ') LIKE UPPER(' . $db->addQuotes('%' . $match . '%') . ') AND page_namespace=' . $db->addQuotes($namespaces[$i]) . ' ORDER BY page_title) '; } } $result = array(); $res = $db->query($sql . $options); if ($db->numRows($res) > 0) { while ($row = $db->fetchObject($res)) { if (smwf_om_userCan($row->page_title, 'read', $row->page_namespace) == 'true') { if ($row->page_namespace == SMW_NS_PROPERTY) { $propertyTitle = Title::newFromText($row->page_title, SMW_NS_PROPERTY); $result[] = array($propertyTitle, false, NULL, $this->getPropertyData($propertyTitle)); } else { $result[] = Title::newFromText($row->page_title, $row->page_namespace); } } } } $db->freeResult($res); return $result; }
public function getPropertiesWithSchemaByName($requestoptions) { $db =& wfGetDB(DB_SLAVE); $this->createVirtualTableWithPropertiesByName($requestoptions, $db); $res = $db->query('SELECT DISTINCT property FROM smw_ob_properties ' . DBHelper::getSQLOptionsAsString($requestoptions, 'property')); $properties = array(); if ($db->numRows($res) > 0) { while ($row = $db->fetchObject($res)) { if (smwf_om_userCan($row->property, 'read', SMW_NS_PROPERTY) === "true") { // do not check for redirect, because it's done it the query $properties[] = array(Title::newFromText($row->property, SMW_NS_PROPERTY), false); } } } $db->freeResult($res); $result = $this->getSchemaPropertyTuple($properties, $db); $this->dropVirtualTableForProperties($db); return $result; }
/** * Retrieves the articles that use the given web service. * * @param int $wsPageID * The unique page ID of the web service's WWSD. * * @return array: * An array of page ids of articles that use the web service. */ public function getWSArticles($wsPageID, SMWRequestOptions $options) { $db =& wfGetDB(DB_SLAVE); $atbl = $db->tableName('smw_ws_articles'); $page = $db->tableName('page'); $sql = "SELECT DISTINCT art.page_id, p.page_title FROM " . $atbl . " art " . "JOIN " . $page . " p ON art.page_id = p.page_id " . "WHERE art.web_service_id='" . $wsPageID . "' "; $cond = DBHelper::getSQLConditions($options, 'p.page_title'); $opt = DBHelper::getSQLOptionsAsString($options, 'p.page_title'); $articles = array(); $res = $db->query($sql . $cond . ' ' . $opt); if ($db->numRows($res) > 0) { while ($row = $db->fetchObject($res)) { $articles[] = $row->page_id; } } $db->freeResult($res); return $articles; }