/**
	 * Get the interwiki list
	 * @todo Needs to respect interwiki cache!
	 * @return array
	 */
	private function getInterwikiList() {
		$result = $this->db->select( 'interwiki', array( 'iw_prefix' ) );
		$prefixes = array();
		foreach( $result as $row ) {
			$prefixes[] = $row->iw_prefix;
		}
		$this->db->freeResult( $result );
		return $prefixes;
	}
Esempio n. 2
0
 private static function __getResults()
 {
     global $wgLang;
     wfProfileIn(__METHOD__);
     /* main query */
     $aResult = array();
     $aFields = array('/* BLOGS */ rev_page as page_id', 'page_namespace', 'page_title', 'min(rev_timestamp) as create_timestamp', 'unix_timestamp(rev_timestamp) as timestamp', 'rev_timestamp', 'min(rev_id) as rev_id', 'rev_user');
     $res = self::$dbr->select(array_map(array(self::$dbr, 'tableName'), self::$aTables), $aFields, self::$aWhere, __METHOD__, self::__makeDBOrder());
     while ($oRow = self::$dbr->fetchObject($res)) {
         if (class_exists('ArticleCommentList')) {
             $oComments = ArticleCommentList::newFromText($oRow->page_title, $oRow->page_namespace);
             $iCount = $oComments ? $oComments->getCountAllNested() : 0;
         } else {
             $iCount = 0;
         }
         /* username */
         $oTitle = Title::newFromText($oRow->page_title, $oRow->page_namespace);
         $sUsername = "";
         if (!$oTitle instanceof Title) {
             continue;
         }
         $username = BlogArticle::getOwner($oTitle);
         $oRevision = Revision::newFromTitle($oTitle);
         $aResult[$oRow->page_id] = array("page" => $oRow->page_id, "namespace" => $oRow->page_namespace, "title" => $oRow->page_title, "page_touched" => !is_null($oRevision) ? $oRevision->getTimestamp() : $oTitle->getTouched(), "rev_timestamp" => $oRow->rev_timestamp, "timestamp" => $oRow->timestamp, "username" => isset($username) ? $username : "", "text" => self::__getRevisionText($oRow->page_id, $oRevision), "revision" => $oRow->rev_id, "comments" => $iCount, "votes" => '', "props" => BlogArticle::getProps($oRow->page_id));
         // Sort by comment count for popular blog posts module
         if (isset(self::$aOptions['order']) && self::$aOptions['order'] == 'page_id') {
             uasort($aResult, array("BlogTemplateClass", "__sortByCommentCount"));
         }
         // We may need to query for 50 results but display 5
         if (isset(self::$aOptions['displaycount']) && self::$aOptions['displaycount'] != self::$aOptions['count']) {
             $aResult = array_slice($aResult, 0, self::$aOptions['displaycount']);
         }
     }
     // macbre: change for Oasis to add avatars and comments / likes data
     wfRunHooks('BlogTemplateGetResults', array(&$aResult));
     self::$dbr->freeResult($res);
     wfProfileOut(__METHOD__);
     return $aResult;
 }
 /**
  * Free a result object
  */
 function free()
 {
     $this->db->freeResult($this);
     unset($this->result);
     unset($this->db);
 }
 /**
  * Get the current data stored for the given ID in the given database
  * table. The result is an array of updates, formatted like the one of
  * the table insertion arrays created by preparePropertyTableInserts().
  *
  * @note Tables without IDs as subject are not supported. They will
  * hopefully vanish soon anyway.
  *
  * @since 1.8
  * @param integer $sid
  * @param SMWSQLStore3Table $tableDeclaration
  * @param DatabaseBase $dbr used for reading only
  * @return array
  */
 protected function getCurrentPropertyTableContents($sid, SMWSQLStore3Table $propertyTable, DatabaseBase $dbr)
 {
     if (!$propertyTable->usesIdSubject()) {
         // does not occur, but let's be strict
         throw new InvalidArgumentException('Operation not supported for tables without subject IDs.');
     }
     $contents = array();
     $results = $dbr->select($propertyTable->getName(), '*', array('s_id' => $sid), __METHOD__);
     foreach ($results as $result) {
         $rowArray = (array) $result;
         $rowKey = self::makeDatabaseRowKey($rowArray);
         $contents[$rowKey] = $rowArray;
     }
     $dbr->freeResult($results);
     return $contents;
 }
 /**
  * Update the usage count in the property statistics table for all
  * properties. This function also initialises the required entry for
  * all properties that have IDs in the SMW IDs table.
  *
  * @since 1.8
  * @param boolean $verbose
  * @param DatabaseBase $dbw used for writing
  */
 protected function refreshPropertyStatistics($verbose, $dbw)
 {
     $this->reportProgress("Updating property statistics. This may take a while.\n", $verbose);
     $res = $dbw->select(SMWSql3SmwIds::tableName, array('smw_id', 'smw_title'), array('smw_namespace' => SMW_NS_PROPERTY), __METHOD__);
     $propertyTables = SMWSQLStore3::getPropertyTables();
     foreach ($res as $row) {
         $this->reportProgress('.', $verbose);
         $usageCount = 0;
         foreach ($propertyTables as $propertyTable) {
             if ($propertyTable->isFixedPropertyTable() && $propertyTable->getFixedProperty() != $row->smw_title) {
                 // This table cannot store values for this property
                 continue;
             }
             $propRow = $dbw->selectRow($propertyTable->getName(), 'Count(*) as count', $propertyTable->isFixedPropertyTable() ? array() : array('p_id' => $row->smw_id), __METHOD__);
             $usageCount += $propRow->count;
         }
         $dbw->replace(SMWSQLStore3::PROPERTY_STATISTICS_TABLE, 'p_id', array('p_id' => $row->smw_id, 'usage_count' => $usageCount), __METHOD__);
     }
     $this->reportProgress("\nUpdated statistics for {$res->numRows()} Properties.\n", $verbose);
     $dbw->freeResult($res);
 }