public function testNamespaces()
 {
     $obj = new ListEmbededInOptions();
     $this->assertEquals(array(), $obj->getNamespaces());
     $this->assertEquals($obj, $obj->setNamespaces(array(1)));
     $this->assertEquals(array(1), $obj->getNamespaces());
 }
Пример #2
0
 /**
  * @param string $pageName
  * @param ListEmbededInOptions $options
  *
  * @return Pages
  */
 public function getPageListFromPageTransclusions($pageName, ListEmbededInOptions $options = null)
 {
     if (is_null($options)) {
         $options = new ListEmbededInOptions();
     }
     $continue = '';
     $limit = $options->getLimit();
     $pages = new Pages();
     while (true) {
         $params = array('list' => 'embeddedin', 'eititle' => $pageName, 'einamespace' => implode('|', $options->getNamespaces()));
         if (!empty($continue)) {
             $params['eicontinue'] = $continue;
         }
         if ($limit === null) {
             $params['eilimit'] = 5000;
         } else {
             $params['eilimit'] = $limit;
         }
         $result = $this->api->getRequest(new SimpleRequest('query', $params));
         if (!array_key_exists('query', $result)) {
             return $pages;
         }
         $limit = $limit - count($result['query']['embeddedin']);
         foreach ($result['query']['embeddedin'] as $member) {
             $pages->addPage(new Page(new PageIdentifier(new Title($member['title'], $member['ns']), $member['pageid']), new Revisions()));
         }
         if ($limit !== null && $limit <= 0) {
             return $pages;
         }
         if (empty($result['query-continue']['embeddedin']['eicontinue'])) {
             return $pages;
         } else {
             $continue = $result['query-continue']['embeddedin']['eicontinue'];
         }
     }
 }