From a5f917bbc55e295896b8084f6657eb8b6abaf8a8 Mon Sep 17 00:00:00 2001 From: André Fabian Silva Delgado Date: Fri, 15 Jul 2016 15:33:36 -0300 Subject: Add TimedMediaHandler extension that allows display audio and video files in wiki pages, using the same syntax as for image files --- .../TimedMediaHandler/ApiTranscodeStatus.php | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 extensions/TimedMediaHandler/ApiTranscodeStatus.php (limited to 'extensions/TimedMediaHandler/ApiTranscodeStatus.php') diff --git a/extensions/TimedMediaHandler/ApiTranscodeStatus.php b/extensions/TimedMediaHandler/ApiTranscodeStatus.php new file mode 100644 index 00000000..38dcccc6 --- /dev/null +++ b/extensions/TimedMediaHandler/ApiTranscodeStatus.php @@ -0,0 +1,79 @@ +getPageSet()->getAllTitlesByNamespace(); + // Make sure we have files in the title set: + if ( !empty( $pageIds[NS_FILE] ) ) { + $titles = array_keys( $pageIds[NS_FILE] ); + asort( $titles ); // Ensure the order is always the same + + $result = $this->getResult(); + $images = RepoGroup::singleton()->findFiles( $titles ); + /** + * @var $img File + */ + foreach ( $images as $img ) { + // if its a "transcode" add the transcode status table output + if( TimedMediaHandlerHooks::isTranscodableTitle( $img->getTitle() ) ){ + $transcodeStatus = WebVideoTranscode::getTranscodeState( $img ); + // remove useless properties + foreach($transcodeStatus as $key=>&$val ){ + unset( $val['id'] ); + unset( $val['image_name']); + unset( $val['key'] ); + } + $result->addValue( array( 'query', 'pages', $img->getTitle()->getArticleID() ), 'transcodestatus', $transcodeStatus ); + } + } + } + } + + public function getCacheMode( $params ) { + return 'public'; + } + + public function getAllowedParams() { + return array(); + } + + /** + * @deprecated since MediaWiki core 1.25 + */ + public function getDescription() { + return array( + 'Get transcode status for a given file page' + ); + } + + /** + * @deprecated since MediaWiki core 1.25 + */ + protected function getExamples() { + return array ( + 'api.php?action=query&prop=transcodestatus&titles=File:Clip.webm', + ); + } + + /** + * @see ApiBase::getExamplesMessages() + */ + protected function getExamplesMessages() { + return array( + 'action=query&prop=transcodestatus&titles=File:Clip.webm' + => 'apihelp-query+transcodestatus-example-1', + ); + } +} -- cgit v1.2.3-54-g00ecf