/**
  * AJAX helper called from view mode to get gallery data
  * @author Marooned
  */
 public static function getGalleryDataByHash($hash, $articleId, $revisionId = 0, $type = WikiaPhotoGallery::WIKIA_PHOTO_GALLERY)
 {
     global $wgUser, $wgOut;
     wfProfileIn(__METHOD__);
     self::initParserHook();
     self::$mGalleryHash = $hash;
     $parser = new Parser();
     $parserOptions = new ParserOptions();
     $title = Title::newFromId($articleId);
     if (!$title) {
         $result['error'] = wfMsg('wikiaPhotoGallery-error-wrong-title');
         $result['errorCaption'] = wfMsg('wikiaPhotoGallery-error-caption');
         wfProfileOut(__METHOD__);
         return $result;
     }
     // let's parse current version of wikitext and store data of gallery with provided hash in self::$mGalleryData
     $rev = Revision::newFromTitle($title, $revisionId);
     //should never happen
     if (!is_null($rev)) {
         $wikitext = $rev->getText();
         $parser->parse($wikitext, $title, $parserOptions)->getText();
     }
     // Marooned: check block state of user (RT #55274)
     $permissionErrors = $title->getUserPermissionsErrors('edit', $wgUser);
     if (count($permissionErrors) && $type == WikiaPhotoGallery::WIKIA_PHOTO_GALLERY) {
         $result['error'] = $wgOut->parse($wgOut->formatPermissionsErrorMessage($permissionErrors));
         $result['errorCaption'] = wfMsg('wikiaPhotoGallery-error-caption');
     } elseif (empty(self::$mGalleryData)) {
         $result['error'] = wfMsg('wikiaPhotoGallery-error-outdated');
         $result['errorCaption'] = wfMsg('wikiaPhotoGallery-error-caption');
     } else {
         $result['info'] = 'ok';
         $result['gallery'] = self::$mGalleryData;
         $result['gallery']['starttime'] = wfTimestampNow();
     }
     wfProfileOut(__METHOD__);
     return $result;
 }