21 private $mPageSet =
null;
30 parent::__construct( $mainModule, $moduleName );
37 $rotation = $params[
'rotation'];
42 $pageSet = $this->getPageSet();
45 $result = $pageSet->getInvalidTitlesAndRevisions( [
46 'invalidTitles',
'special',
'missingIds',
'missingRevIds',
'interwikiTitles',
50 if ( $params[
'tags'] ) {
51 $ableToTag = ChangeTags::canAddTagsAccompanyingChange( $params[
'tags'], $this->
getAuthority() );
52 if ( !$ableToTag->isOK() ) {
57 foreach ( $pageSet->getPages() as $page ) {
58 $title = $this->titleFactory->newFromPageIdentity( $page );
60 $r[
'id'] = $title->getArticleID();
62 if ( !$title->exists() ) {
64 if ( $title->isKnown() ) {
69 $file = $this->repoGroup->findFile( $title, [
'latest' =>
true ] );
71 $r[
'result'] =
'Failure';
73 Status::newFatal(
'apierror-filedoesnotexist' )
78 $handler = $file->getHandler();
79 if ( !$handler || !$handler->canRotate() ) {
80 $r[
'result'] =
'Failure';
82 Status::newFatal(
'apierror-filetypecannotberotated' )
91 $srcPath = $file->getLocalRefPath();
92 if ( $srcPath ===
false ) {
93 $r[
'result'] =
'Failure';
95 Status::newFatal(
'apierror-filenopath' )
100 $ext = strtolower( pathinfo(
"$srcPath", PATHINFO_EXTENSION ) );
101 $tmpFile = $this->tempFSFileFactory->newTempFSFile(
'rotate_', $ext );
102 $dstPath = $tmpFile->getPath();
104 $err = $handler->rotate( $file, [
105 'srcPath' => $srcPath,
106 'dstPath' => $dstPath,
107 'rotation' => $rotation
110 $comment = $this->
msg(
112 )->numParams( $rotation )->inContentLanguage()->text();
114 $status = $file->upload(
122 $params[
'tags'] ?: []
124 if ( $status->isGood() ) {
125 $r[
'result'] =
'Success';
127 $r[
'result'] =
'Failure';
131 $r[
'result'] =
'Failure';
140 $apiResult->addValue(
null, $this->
getModuleName(), $result );
143 $continuationManager->setContinuationIntoResult( $apiResult );
150 private function getPageSet() {
153 return $this->mPageSet;
170 ParamValidator::PARAM_TYPE => [
'90',
'180',
'270' ],
171 ParamValidator::PARAM_REQUIRED => true
177 ParamValidator::PARAM_TYPE =>
'tags',
178 ParamValidator::PARAM_ISMULTI =>
true,
182 $result += $this->getPageSet()->getFinalParams( $flags );
196 'action=imagerotate&titles=File:Example.jpg&rotation=90&token=123ABC'
197 =>
'apihelp-imagerotate-example-simple',
198 'action=imagerotate&generator=categorymembers&gcmtitle=Category:Flip&gcmtype=file&' .
199 'rotation=180&token=123ABC'
200 =>
'apihelp-imagerotate-example-generator',
206 return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Imagerotate';
211class_alias( ApiImageRotate::class,
'ApiImageRotate' );
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.
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()