47 parent::__construct( $mainModule, $moduleName );
56 $rotation = $params[
'rotation'];
64 $result = $pageSet->getInvalidTitlesAndRevisions( [
65 'invalidTitles',
'special',
'missingIds',
'missingRevIds',
'interwikiTitles',
69 if ( $params[
'tags'] ) {
71 if ( !$ableToTag->isOK() ) {
76 foreach ( $pageSet->getTitles() as
$title ) {
78 $r[
'id'] =
$title->getArticleID();
79 ApiQueryBase::addTitleInfo( $r,
$title );
87 $file = $this->repoGroup->findFile(
$title, [
'latest' =>
true ] );
89 $r[
'result'] =
'Failure';
91 Status::newFatal(
'apierror-filedoesnotexist' )
96 $handler =
$file->getHandler();
97 if ( !$handler || !$handler->canRotate() ) {
98 $r[
'result'] =
'Failure';
100 Status::newFatal(
'apierror-filetypecannotberotated' )
109 $srcPath =
$file->getLocalRefPath();
110 if ( $srcPath ===
false ) {
111 $r[
'result'] =
'Failure';
113 Status::newFatal(
'apierror-filenopath' )
118 $ext = strtolower( pathinfo(
"$srcPath", PATHINFO_EXTENSION ) );
119 $tmpFile = $this->tempFSFileFactory->newTempFSFile(
'rotate_',
$ext );
120 $dstPath = $tmpFile->getPath();
122 $err = $handler->rotate(
$file, [
123 'srcPath' => $srcPath,
124 'dstPath' => $dstPath,
125 'rotation' => $rotation
130 )->numParams( $rotation )->inContentLanguage()->text();
132 $status =
$file->upload(
140 $params[
'tags'] ?: []
142 if ( $status->isGood() ) {
143 $r[
'result'] =
'Success';
145 $r[
'result'] =
'Failure';
149 $r[
'result'] =
'Failure';
151 Status::newFatal( ApiMessage::create( $err->getMsg() ) )
157 ApiResult::setIndexedTagName( $result,
'page' );
158 $apiResult->addValue(
null, $this->
getModuleName(), $result );
161 $continuationManager->setContinuationIntoResult( $apiResult );
169 if ( $this->mPageSet ===
null ) {
199 $result += $this->
getPageSet()->getFinalParams( $flags );
211 'action=imagerotate&titles=File:Example.jpg&rotation=90&token=123ABC'
212 =>
'apihelp-imagerotate-example-simple',
213 'action=imagerotate&generator=categorymembers&gcmtitle=Category:Flip&gcmtype=file&' .
214 'rotation=180&token=123ABC'
215 =>
'apihelp-imagerotate-example-generator',
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
This abstract class implements many basic API functions, and is the base of all API classes.
setContinuationManager(ApiContinuationManager $manager=null)
getResult()
Get the result object.
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
checkTitleUserPermissions( $pageIdentity, $actions, array $options=[])
Helper function for permission-denied errors.
getModuleName()
Get the name of the module being executed by this instance.
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
This manages continuation state.
mustBePosted()
Indicates whether this module must be called with a POST request.
isWriteMode()
Indicates whether this module requires write mode.
getAllowedParams( $flags=0)
getExamplesMessages()
Returns usage examples for this module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
needsToken()
Returns the token type this module requires in order to execute.
getPageSet()
Get a cached instance of an ApiPageSet object.
TempFSFileFactory $tempFSFileFactory
__construct(ApiMain $mainModule, $moduleName, RepoGroup $repoGroup, TempFSFileFactory $tempFSFileFactory)
This is the main API class, used for both external and internal processing.
This class contains a list of pages that the client has requested.
Prioritized list of file repositories.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
if(!is_readable( $file)) $ext