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';
70 Status::newFatal(
'apierror-filedoesnotexist' )
75 $handler =
$file->getHandler();
76 if ( !$handler || !$handler->canRotate() ) {
77 $r[
'result'] =
'Failure';
79 Status::newFatal(
'apierror-filetypecannotberotated' )
88 $r[
'result'] =
'Failure';
96 $srcPath =
$file->getLocalRefPath();
97 if ( $srcPath ===
false ) {
98 $r[
'result'] =
'Failure';
100 Status::newFatal(
'apierror-filenopath' )
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();
120 $status =
$file->upload(
128 $params[
'tags'] ?: []
130 if ( $status->isGood() ) {
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',
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.
const PARAM_REQUIRED
(boolean) Is the parameter required?
checkTitleUserPermissions(LinkTarget $linkTarget, $actions, $options=[])
Helper function for permission-denied errors.
const PARAM_TYPE
(string|string[]) Either an array of allowed value strings, or a string type as described below.
getErrorFormatter()
Get the error formatter.
errorArrayToStatus(array $errors, User $user=null)
Turn an array of message keys or key+param arrays into a Status.
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.
dieStatus(StatusValue $status)
Throw an ApiUsageException based on the Status object.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
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.
static create( $msg, $code=null, array $data=null)
Create an IApiMessage for the message.
This class contains a list of pages that the client has requested.
static addTitleInfo(&$arr, $title, $prefix='')
Add information (title and namespace) about a Title object to a result array.
static setIndexedTagName(array &$arr, $tag)
Set the tag name for numeric-keyed values in XML format.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
if(!is_readable( $file)) $ext