public function execute()
 {
     $pageIds = $this->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);
         foreach ($images as $img) {
             // if its a "transcode" add the transcode status table output
             if (TimedMediaHandlerHooks::isTranscodableTitle($img->getTitle())) {
                 $transcodeStatus = WebVideoTranscode::getTranscodeState($img->getTitle()->getDBKey());
                 // 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 execute() {
		global $wgUser, $wgEnabledTranscodeSet, $wgEnableTranscode, $wgWaitTimeForTranscodeReset;		
		// Check if transcoding is enabled on this wiki at all: 
		if( !$wgEnableTranscode ){
			$this->dieUsage( 'Transcode is disabled on this wiki', 'disabledtranscode' );
		}
		
		// Confirm the user has the transcode-reset right
		if( !$wgUser->isAllowed( 'transcode-reset' ) ){
			$this->dieUsage( 'You don\'t have permission to reset transcodes', 'missingpermission' );
		}
		$params = $this->extractRequestParams();
		
		// Make sure we have a valid Title
		$titleObj = Title::newFromText( $params['title'] );
		if ( !$titleObj || $titleObj->isExternal() ) {
			$this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
		}
		// Make sure the title can be transcoded
		if( !TimedMediaHandlerHooks::isTranscodableTitle( $titleObj ) ){
			$this->dieUsage( array( 'invalidtranscodetitle', $params['title'] ) );
		}
		$transcodeKey = false;
		// Make sure its a enabled transcode key we are trying to remove:
		// ( if you update your transcode keys the api is not how you purge the database of expired keys ) 
		if( isset( $params['transcodekey'] ) ){
			global $wgEnabledTranscodeSet;
			if( !in_array( $params['transcodekey'], $wgEnabledTranscodeSet ) ){
				$this->dieUsage( 'Invalid or disabled transcode key: ' . htmlspecialchars( $params['transcodekey'] ) , 'badtranscodekey' );
			} else {	
				$transcodeKey = $params['transcodekey'];
			}
		} 
		
		// Don't reset if less than 1 hour has passed and we have no error )
		$timeSinceLastReset = self::checkTimeSinceLastRest( $titleObj->getDBKey(), $transcodeKey );
		if( $timeSinceLastReset < $wgWaitTimeForTranscodeReset){
			$this->dieUsage( 'Not enough time has passed since the last reset of this transcode. ' .
				TimedMediaHandler::getTimePassedMsg( $wgWaitTimeForTranscodeReset - $timeSinceLastReset  ) .
				' until this transcode can be reset', 'notenoughtimereset');
		}
		
		// All good do the transcode removal:		
		WebVideoTranscode::removeTranscodes( $titleObj, $transcodeKey );
		
		$this->getResult()->addValue(null, 'success', 'removed transcode');
	}