Exemplo n.º 1
0
 /**
  * @param ListLogEventsOptions $options
  *
  * @return LogList
  */
 public function getLogList(ListLogEventsOptions $options = null)
 {
     if ($options == null) {
         $options = new ListLogEventsOptions();
     }
     $logList = new LogList();
     $continue = '';
     $limit = $options->getLimit();
     while (true) {
         $params = $this->getParamsFromOptions($options);
         if (!empty($continue)) {
             $params['lecontinue'] = $continue;
         }
         if ($limit === null) {
             $params['lelimit'] = 5000;
         } else {
             $params['lelimit'] = $limit;
         }
         $result = $this->api->getRequest(new SimpleRequest('query', $params));
         $limit = $limit - count($result['query']['logevents']);
         foreach ($result['query']['logevents'] as $logevent) {
             $logList->addLog(new Log($logevent['logid'], $logevent['type'], $logevent['action'], $logevent['timestamp'], $logevent['user'], new Page(new PageIdentifier(new Title($logevent['title'], $logevent['ns']), $logevent['pageid']), new Revisions()), $logevent['comment'], $this->getLogDetailsFromEvent($logevent)));
         }
         if ($limit !== null && $limit <= 0) {
             return $logList;
         }
         if (empty($result['query-continue']['logevents']['lecontinue'])) {
             return $logList;
         } else {
             $continue = $result['query-continue']['logevents']['lecontinue'];
         }
     }
 }
 /**
  * @param string|null $type filter log entries by type
  * @param string|null $action filter log entries by action, overrides $type
  * @param int $namespace filter log entries in the given namespace
  *
  * @return LogList
  */
 public function getLogList($type = null, $action = null, $namespace = 0)
 {
     $query = $this->db->from('logging')->select(array('log_id', 'log_type', 'log_action', 'log_timestamp', 'log_user', 'log_namespace', 'log_title', 'log_comment', 'log_page', 'log_params'))->where('log_type', $type)->where('log_action', $action)->where('log_namespace', $namespace);
     $rows = $query->fetchAll();
     $logList = new LogList();
     foreach ($rows as $row) {
         $logList->addLog($this->getLogFromRow($row));
     }
     return $logList;
 }
Exemplo n.º 3
0
 /**
  * @param array $extraParams
  *
  * @return LogList
  */
 public function getLogList(array $extraParams = [])
 {
     $logList = new LogList();
     while (true) {
         $params = ['list' => 'logevents', 'leprop' => 'title|ids|type|user|timestamp|comment|details'];
         $newParams = array_merge($extraParams, $params);
         $result = $this->api->getRequest(new SimpleRequest('query', $newParams));
         foreach ($result['query']['logevents'] as $logevent) {
             $logList->addLog(new Log($logevent['logid'], $logevent['type'], $logevent['action'], $logevent['timestamp'], $logevent['user'], new Page(new PageIdentifier(new Title($logevent['title'], $logevent['ns']), $logevent['pageid']), new Revisions()), $logevent['comment'], $this->getLogDetailsFromEvent($logevent)));
         }
         return $logList;
     }
 }
Exemplo n.º 4
0
 public function testJsonRoundTrip()
 {
     $logList = new LogList(array(new Log(1, 'ty', 'ac', '2014', 'Addshore', new PageIdentifier(null, 22), 'comment', array()), new Log(2, 'ty2', 'ac2', '2015', 'Addbot', new PageIdentifier(null, 33), 'comment2', array())));
     $json = $logList->jsonSerialize();
     $json = json_decode(json_encode($json), true);
     $this->assertEquals($logList, LogList::jsonDeserialize($json));
 }
Exemplo n.º 5
0
 /**
  * @param array $json
  *
  * @return self
  */
 public static function jsonDeserialize($json)
 {
     $self = new LogList();
     foreach ($json as $logJson) {
         $self->addLog(Log::jsonDeserialize($logJson));
     }
     return $self;
 }