Exemple #1
0
    private function run()
    {
        global $wgServerName, $wgScriptPath;
        $params = $this->extractRequestParams();
        wfDebugLog('p2p', 'ApiQueryPatch params ' . $params['patchId']);
        $array = array(1 => 'id', 2 => 'onPage', 3 => 'operation', 4 => 'previous', 5 => 'siteID', 6 => 'mime', 7 => 'size', 8 => 'url', 9 => 'DateAtt', 10 => 'siteUrl', 11 => 'causal');
        $array1 = array(1 => 'patchID', 2 => 'onPage', 3 => 'hasOperation', 4 => 'previous', 5 => 'siteID', 6 => 'mime', 7 => 'size', 8 => 'url', 9 => 'DateAtt', 10 => 'siteUrl', 11 => 'causal');
        $query = '';
        for ($j = 1; $j <= count($array1); $j++) {
            $query = $query . '?' . $array1[$j] . '
';
        }
        $res = utils::getSemanticQuery('[[patchID::' . $params['patchId'] . ']]', $query);
        $count = $res->getCount();
        for ($i = 0; $i < $count; $i++) {
            $row = $res->getNext();
            if ($row === false) {
                break;
            }
            for ($j = 1; $j <= count($array); $j++) {
                if ($j == 3) {
                    $col = $row[$j]->getContent();
                    // SMWResultArray object
                    foreach ($col as $object) {
                        // SMWDataValue object
                        $wikiValue = $object->getWikiValue();
                        $op[] = $wikiValue;
                    }
                    $results[$j] = $op;
                } else {
                    $col = $row[$j]->getContent();
                    // SMWResultArray object
                    foreach ($col as $object) {
                        // SMWDataValue object
                        $wikiValue = $object->getWikiValue();
                        $results[$j] = $wikiValue;
                    }
                }
            }
        }
        $result = $this->getResult();
        // $data = str_replace('"', '', $data);
        // $data = explode('!',$data);
        if ($results[1]) {
            for ($i = 1; $i <= count($array); $i++) {
                if ($results[$i] != null) {
                    if ($i == 2) {
                        $title = trim($results[$i], ":");
                        $result->addValue(array('query', $this->getModuleName()), $array[$i], $title);
                    } elseif ($i == 3) {
                        $op = $results[$i];
                        $result->setIndexedTagName($op, $array[$i]);
                        $result->addValue('query', $this->getModuleName(), $op);
                    } else {
                        $result->addValue(array('query', $this->getModuleName()), $array[$i], $results[$i]);
                    }
                }
            }
        }
    }
Exemple #2
0
    private function run()
    {
        global $wgServerName, $wgScriptPath;
        wfDebugLog('p2p', '@@@@@@@@@@@@@@@@@@@@ ApiQueryChangeSet : $wgServerName, $wgScriptPath');
        $params = $this->extractRequestParams();
        $res = utils::getSemanticQuery('[[inPushFeed::PushFeed:' . $params['pushName'] . ']][[previousChangeSet::' . $params['changeSet'] . ']]', '?changeSetID
?hasPatch');
        $count = $res->getCount();
        $results = array();
        for ($i = 0; $i < $count; $i++) {
            $row = $res->getNext();
            if ($row === false) {
                break;
            }
            $changesetId = $row[1];
            $col = $changesetId->getContent();
            //SMWResultArray object
            foreach ($col as $object) {
                //SMWDataValue object
                $wikiValue = $object->getWikiValue();
                $results[1] = $wikiValue;
            }
            $hasPatch = $row[2];
            $col = $hasPatch->getContent();
            //SMWResultArray object
            foreach ($col as $object) {
                //SMWDataValue object
                $wikiValue = $object->getWikiValue();
                $patches[] = $wikiValue;
            }
            $results[2] = $patches;
        }
        $result = $this->getResult();
        if (isset($results[1])) {
            $CSID = $results[1];
        } else {
            $CSID = null;
        }
        wfDebugLog('p2p', '  -> CSID : ' . $CSID);
        if ($CSID) {
            $data = $results[2];
            $result->setIndexedTagName($data, 'patch');
            $result->addValue(array('query', $this->getModuleName()), 'id', $CSID);
            $result->addValue('query', $this->getModuleName(), $data);
        }
    }
 private function run()
 {
     global $wgServerName, $wgScriptPath;
     $params = $this->extractRequestParams();
     wfDebugLog('p2p', ' - ApiQueryPatchPushed params ' . $params['pushName']);
     $publishedInPush = getPublishedPatches($params['pushName']);
     $published = null;
     // filtered on published patch on page title
     if (isset($params['pageName'])) {
         foreach ($publishedInPush as $patch) {
             $patches = array();
             $res = utils::getSemanticQuery('[[Patch:+]][[patchID::' . $patch . ']][[onPage::' . $params['pageName'] . ']]');
             $count = $res->getCount();
             for ($i = 0; $i < $count; $i++) {
                 $row = $res->getNext();
                 if ($row === false) {
                     break;
                 }
                 $row = $row[0];
                 $col = $row->getContent();
                 // SMWResultArray object
                 foreach ($col as $object) {
                     // SMWDataValue object
                     $wikiValue = $object->getWikiValue();
                     $patches[] = $wikiValue;
                 }
             }
             if (count($patches)) {
                 $published[] = $patch;
             }
         }
         wfDebugLog('p2p', '  -> isset($params[pageName]');
     } else {
         $published = $publishedInPush;
         wfDebugLog('p2p', '  -> not isset($params[pageName]');
     }
     $result = $this->getResult();
     if (!is_null($published)) {
         $result->setIndexedTagName($published, 'patch');
         $result->addValue('query', $this->getModuleName(), $published);
         $result->addValue(array('query', $this->getModuleName()), 'pushFeed', $params['pushName']);
     }
 }
 /**
  * Returns an array of page titles received via the request.
  * 
  * @return array
  */
 protected function getRequestedPages($request)
 {
     $results = array();
     $res = utils::getSemanticQuery($request);
     $count = $res->getCount();
     for ($i = 0; $i < $count; $i++) {
         $row = $res->getNext();
         if ($row === false) {
             break;
         }
         $row = $row[0];
         $col = $row->getContent();
         // SMWResultArray object
         foreach ($col as $object) {
             // SMWDataValue object
             $wikiValue = $object->getWikiValue();
             $results[] = $wikiValue;
         }
     }
     return $results;
 }
/**
 * Gets the URL of the pushfeed where the pullfeed has subscribed
 *
 * @global <String> $wgServerName
 * @global <String> $wgScriptPath
 * @param <String> $name pullfeed name
 * @return <String> Pushfeed Url
 */
function getPushURL($name)
{
    // pullfeed name with NS
    $results = array();
    $res = utils::getSemanticQuery('[[PullFeed:+]] [[name::' . $name . ']]', '?pushFeedServer');
    if ($res === false) {
        return false;
    }
    $count = $res->getCount();
    for ($i = 0; $i < $count; $i++) {
        $row = $res->getNext();
        if ($row === false) {
            break;
        }
        $row = $row[1];
        $col = $row->getContent();
        // SMWResultArray object
        foreach ($col as $object) {
            // SMWDataValue object
            $wikiValue = $object->getWikiValue();
            $results[] = $wikiValue;
        }
    }
    if (empty($results)) {
        return false;
    } else {
        return $results[0];
    }
}
Exemple #6
0
 /**
  * Used to get the list of article titles concerned by the given pullfeed
  * @param <string> $pfname pullfeed name
  * @return <array> array of page titles
  */
 static function getPageConcernedByPull($pfname)
 {
     $patchs = utils::getPulledPatches($pfname);
     $tabPage = array();
     foreach ($patchs as $patch) {
         $onPage = array();
         $res = utils::getSemanticQuery('[[Patch:+]][[patchID::' . $patch . ']]', '?onPage');
         if ($res === false) {
             return false;
         }
         $count = $res->getCount();
         for ($i = 0; $i < $count; $i++) {
             $row = $res->getNext();
             if ($row === false) {
                 break;
             }
             $row = $row[1];
             $col = $row->getContent();
             //SMWResultArray object
             foreach ($col as $object) {
                 //SMWDataValue object
                 $wikiValue = $object->getWikiValue();
                 $onPage[] = $wikiValue;
             }
         }
         if (!empty($onPage)) {
             $tabPage[$onPage[0]] = 0;
         }
     }
     return $tabPage;
 }