33 $rotation = $params[
'rotation'];
41 $result = $pageSet->getInvalidTitlesAndRevisions( [
42 'invalidTitles',
'special',
'missingIds',
'missingRevIds',
'interwikiTitles',
46 if ( $params[
'tags'] ) {
48 if ( !$ableToTag->isOK() ) {
53 foreach ( $pageSet->getTitles() as
$title ) {
55 $r[
'id'] =
$title->getArticleID();
56 ApiQueryBase::addTitleInfo( $r,
$title );
64 $file = MediaWikiServices::getInstance()->getRepoGroup()->findFile(
65 $title, [
'latest' =>
true ]
68 $r[
'result'] =
'Failure';
70 Status::newFatal(
'apierror-filedoesnotexist' )
75 $handler =
$file->getHandler();
76 if ( !$handler || !$handler->canRotate() ) {
77 $r[
'result'] =
'Failure';
79 Status::newFatal(
'apierror-filetypecannotberotated' )
88 $srcPath =
$file->getLocalRefPath();
89 if ( $srcPath ===
false ) {
90 $r[
'result'] =
'Failure';
92 Status::newFatal(
'apierror-filenopath' )
97 $ext = strtolower( pathinfo(
"$srcPath", PATHINFO_EXTENSION ) );
98 $tmpFile = MediaWikiServices::getInstance()->getTempFSFileFactory()
99 ->newTempFSFile(
'rotate_',
$ext );
100 $dstPath = $tmpFile->getPath();
102 $err = $handler->rotate(
$file, [
103 'srcPath' => $srcPath,
104 'dstPath' => $dstPath,
105 'rotation' => $rotation
110 )->numParams( $rotation )->inContentLanguage()->text();
112 $status =
$file->upload(
120 $params[
'tags'] ?: []
122 if ( $status->isGood() ) {
123 $r[
'result'] =
'Success';
125 $r[
'result'] =
'Failure';
129 $r[
'result'] =
'Failure';
131 Status::newFatal( ApiMessage::create( $err->getMsg() ) )
137 ApiResult::setIndexedTagName( $result,
'page' );
138 $apiResult->addValue(
null, $this->
getModuleName(), $result );
141 $continuationManager->setContinuationIntoResult( $apiResult );
149 if ( $this->mPageSet ===
null ) {
179 $result += $this->
getPageSet()->getFinalParams( $flags );
191 'action=imagerotate&titles=File:Example.jpg&rotation=90&token=123ABC'
192 =>
'apihelp-imagerotate-example-simple',
193 'action=imagerotate&generator=categorymembers&gcmtitle=Category:Flip&gcmtype=file&' .
194 'rotation=180&token=123ABC'
195 =>
'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.
getErrorFormatter()
Get the error formatter Stable to override.
setContinuationManager(ApiContinuationManager $manager=null)
Set the continuation manager.
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.
getModuleName()
Get the name of the module being executed by this instance.
checkTitleUserPermissions(LinkTarget $linkTarget, $actions, array $options=[])
Helper function for permission-denied errors.
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 Stable to override.
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.
This class contains a list of pages that the client has requested.
getUser()
Stable to override.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
if(!is_readable( $file)) $ext