Go to the documentation of this file.
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();
64 $file = MediaWikiServices::getInstance()->getRepoGroup()->findFile(
65 $title, [
'latest' =>
true ]
68 $r[
'result'] =
'Failure';
75 $handler =
$file->getHandler();
76 if ( !$handler || !$handler->canRotate() ) {
77 $r[
'result'] =
'Failure';
88 $r[
'result'] =
'Failure';
96 $srcPath =
$file->getLocalRefPath();
97 if ( $srcPath ===
false ) {
98 $r[
'result'] =
'Failure';
105 $ext = strtolower( pathinfo(
"$srcPath", PATHINFO_EXTENSION ) );
106 $tmpFile = MediaWikiServices::getInstance()->getTempFSFileFactory()
107 ->newTempFSFile(
'rotate_',
$ext );
108 $dstPath = $tmpFile->getPath();
110 $err = $handler->rotate(
$file, [
111 'srcPath' => $srcPath,
112 'dstPath' => $dstPath,
113 'rotation' => $rotation
118 )->numParams( $rotation )->inContentLanguage()->text();
128 $params[
'tags'] ?: []
131 $r[
'result'] =
'Success';
133 $r[
'result'] =
'Failure';
137 $r[
'result'] =
'Failure';
146 $apiResult->addValue(
null, $this->
getModuleName(), $result );
149 $continuationManager->setContinuationIntoResult( $apiResult );
157 if ( $this->mPageSet ===
null ) {
187 $result += $this->
getPageSet()->getFinalParams( $flags );
199 'action=imagerotate&titles=File:Example.jpg&rotation=90&token=123ABC'
200 =>
'apihelp-imagerotate-example-simple',
201 'action=imagerotate&generator=categorymembers&gcmtitle=Category:Flip&gcmtype=file&' .
202 'rotation=180&token=123ABC'
203 =>
'apihelp-imagerotate-example-generator',
static newFatal( $message,... $parameters)
Factory function for fatal errors.
const PARAM_REQUIRED
(boolean) Is the parameter required?
mustBePosted()
Indicates whether this module must be called with a POST request.
This manages continuation state.
const PARAM_HELP_MSG
(string|array|Message) Specify an alternative i18n documentation message for this parameter.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
getPageSet()
Get a cached instance of an ApiPageSet object.
getResult()
Get the result object.
setContinuationManager(ApiContinuationManager $manager=null)
Set the continuation manager.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
checkTitleUserPermissions(LinkTarget $linkTarget, $actions, $options=[])
Helper function for permission-denied errors.
This class contains a list of pages that the client has requested.
This abstract class implements many basic API functions, and is the base of all API classes.
needsToken()
Returns the token type this module requires in order to execute.
getAllowedParams( $flags=0)
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
getExamplesMessages()
Returns usage examples for this module.
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
getModuleName()
Get the name of the module being executed by this instance.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
if(!is_readable( $file)) $ext
errorArrayToStatus(array $errors, User $user=null)
Turn an array of message keys or key+param arrays into a Status.
getErrorFormatter()
Get the error formatter.
isWriteMode()
Indicates whether this module requires write mode.
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.