public function execute($par)
 {
     global $wgOut;
     $cacheManager = new \PageAttachment\Cache\CacheManager();
     $pageFactory = new \PageAttachment\Session\PageFactory($cacheManager);
     $security = new \PageAttachment\Security\SecurityManager();
     $session = new \PageAttachment\Session\Session($security, $pageFactory);
     $attachToPage = $session->getAttachToPage();
     if (isset($attachToPage) && $attachToPage->getId() > 0) {
         $abort = false;
         if ($security->isDownloadRequestValid()) {
             // Subsequest Passes - Upload File
             parent::execute($par);
         } else {
             // First Pass - Display Form
             $protectedPage = $attachToPage->isProtected();
             if ($security->isAttachmentAddUpdateRequireLogin($protectedPage) && !$security->isLoggedIn()) {
                 $session->setStatusMessage('YouMustBeLoggedInToAddUpdateAttachments');
                 $abort = true;
             } elseif (!$security->isRequestValidationTokenValid()) {
                 $session->setStatusMessage('UnableToAuthenticateYourRequest');
                 $abort = true;
             }
             if ($abort == true) {
                 $title = \Title::newFromText($attachToPage->getPageTitle());
                 $wgOut->redirect($title->getFullURL());
             } else {
                 $security->setDownloadRequestValid(true);
                 $session->setUploadAndAttachFileInitiated(true);
                 parent::execute($par);
             }
         }
     } else {
         $session->setStatusMessage('UnableToDetermineAttachToPage');
         $title = \Title::newFromText(\wfMsgForContent('mainpage'));
         $wgOut->redirect($title->getFullURL());
     }
 }
 function execute($par)
 {
     global $wgOut;
     $cacheManager = new \PageAttachment\Cache\CacheManager();
     $pageFactory = new \PageAttachment\Session\PageFactory($cacheManager);
     $security = new \PageAttachment\Security\SecurityManager();
     $session = new \PageAttachment\Session\Session($security, $pageFactory);
     $attachToPage = $session->getAttachToPage();
     if (isset($attachToPage) && $attachToPage->getId() > 0) {
         $pageTitle = $attachToPage->getPageTitle();
         $protectedPage = $attachToPage->isProtected();
         if (!$security->isBrowseSearchAttachAllowed($protectedPage)) {
             if ($security->isBrowseSearchAttachRequireLogin() && !$security->isLoggedIn()) {
                 $session->setStatusMessage('YouMustBeLoggedInToBrowseSearchAttach');
             } else {
                 $session->setStatusMessage('BrowseSearchAttachIsNotPermitted');
             }
             $wgOut->redirect($attachToPage->getRedirectURL());
         } else {
             $context = $this->getContext();
             $userName = $this->getRequest()->getText('user', $par);
             $search = $this->getRequest()->getText('ilsearch', '');
             $this->setHeaders();
             $pager = new ImageListPager($context, $userName, $search);
             $limit = $pager->getForm();
             $body = $pager->getBody();
             $nav = $pager->getNavigationBar();
             $msgAttachToPageName = \wfMsg('AttachToPageName', $pageTitle);
             $wgOut->addHTML("{$limit}<br />\n{$body}<br />\n{$nav}");
         }
     } else {
         $session->setStatusMessage('UnableToDetermineAttachToPage');
         $title = \Title::newFromText(\wfMsgForContent('mainpage'));
         $wgOut->redirect($title->getFullURL());
     }
 }
 function execute($par)
 {
     global $wgOut;
     global $wgRequest;
     $cacheManager = new \PageAttachment\Cache\CacheManager();
     $pageFactory = new \PageAttachment\Session\PageFactory($cacheManager);
     $security = new \PageAttachment\Security\SecurityManager();
     $session = new \PageAttachment\Session\Session($security, $pageFactory);
     $attachToPage = $session->getAttachToPage();
     if (isset($attachToPage) && $attachToPage->getId() > 0) {
         $protectedPage = $attachToPage->isProtected();
         if (!$security->isAuditLogViewAllowed($protectedPage)) {
             if ($security->isAuditLogViewRequireLogin($protectedPage) && !$security->isLoggedIn()) {
                 $session->setStatusMessage('YouMustBeLoggedInToViewAuditLog');
             } else {
                 $session->setStatusMessage('AuditLogViewingIsNotPermitted');
             }
             $wgOut->redirect($attachToPage->getFullURL());
         } else {
             $attachmentName = $wgRequest->getVal("attachmentName", null);
             if (isset($attachmentName)) {
                 $attachmentName = base64_decode($attachmentName);
             }
             $this->setHeaders();
             $pager = new AuditLogPager($attachToPage, $attachmentName);
             $limit = $pager->getForm();
             $body = $pager->getBody();
             $nav = $pager->getNavigationBar();
             $wgOut->addHTML("{$limit}<br />\n{$nav}<br />\n{$body}<br />\n{$nav}");
         }
     } else {
         $session->setStatusMessage('UnableToDetermineAttachToPage');
         $title = \Title::newFromText(\wfMsgForContent('mainpage'));
         $wgOut->redirect($title->getFullURL());
     }
 }