/** * @param ApiPageSet $resultPageSet * TODO: Use the limit parameter */ private function run($resultPageSet = null) { $params = $this->extractRequestParams(); $result = $this->getResult(); $user = $this->getUser(); if ($user->isAnon()) { $this->dieUsage('To view your translations, you must log in', 'notloggedin'); } if ($params['sourcetitle'] && $params['from'] && $params['to']) { return $this->find($params['sourcetitle'], $params['from'], $params['to']); } if ($params['translationid']) { $translator = new ContentTranslation\Translator($user); $translation = $translator->getTranslation($params['translationid']); if ($translation !== null) { $result->addValue(array('query', 'contenttranslation'), 'translation', $translation->translation); } else { $this->dieUsage('Draft does not exist', $params['translationid']); } } else { $translator = new ContentTranslation\Translator($user); $translations = $translator->getAllTranslations(); $result->addValue(array('query', 'contenttranslation'), 'translations', $translations); } }
/** * @param ApiPageSet $resultPageSet */ private function run($resultPageSet = null) { $params = $this->extractRequestParams(); $result = $this->getResult(); $user = $this->getUser(); if ($user->isAnon()) { $this->dieUsage('To view your translations, you must log in', 'notloggedin'); } if ($params['sourcetitle'] && $params['from'] && $params['to']) { return $this->find($params['sourcetitle'], $params['from'], $params['to']); } if ($params['translationid']) { $translator = new ContentTranslation\Translator($user); $translation = $translator->getTranslation($params['translationid']); if ($translation !== null) { $result->addValue(array('query', 'contenttranslation'), 'translation', $translation->translation); } else { $this->dieUsage('Draft does not exist', $params['translationid']); } return; } // The main case, no filters $translator = new ContentTranslation\Translator($user); $translations = $translator->getAllTranslations($params['limit'], $params['offset'], $params['type']); // We will have extra continue in case the last batch is exactly the size of the limit $count = count($translations); if ($count === $params['limit']) { $offset = $translations[$count - 1]->translation['lastUpdateTimeStamp']; $this->setContinueEnumParameter('offset', $offset); } $result->addValue(array('query', 'contenttranslation'), 'translations', $translations); // Simple optimization if ($params['offset'] === null) { $result->addValue(array('query', 'contenttranslation'), 'languages', $translator->getLanguages($params['type'])); } }