/** * Render the special page * @param string|null $par Username to get uploads from */ public function executeWhenAvailable($par = '') { if (($par === '' || $par === null) && $this->getUser()->isAnon()) { // Anons don't get to see Special:Uploads $this->requireLogin('mobile-frontend-donate-image-anon'); } else { // uploads by a particular user, i.e Special:Uploads/username, are shown even to anons $this->setHeaders(); $output = $this->getOutput(); $output->addJsConfigVars('wgMFPhotoUploadEndpoint', $this->getMFConfig()->get('MFPhotoUploadEndpoint')); if ($par !== '' && $par !== null) { $user = User::newFromName($par); if (!$user || $user->isAnon()) { $output->setPageTitle($this->msg('mobile-frontend-donate-image-title-username', $par)); $output->setStatusCode(404); $html = MobileUI::contentElement(MobileUI::errorBox($this->msg('mobile-frontend-photo-upload-invalid-user', $par))); } else { if ($user->equals($this->getUser())) { $output->setPageTitle($this->msg('mobile-frontend-donate-image-title-you')); } else { $output->setPageTitle($this->msg('mobile-frontend-donate-image-title-username', $par)); } $html = $this->getUserUploadsPageHtml($user); } } else { $user = $this->getUser(); $output->setPageTitle($this->msg('mobile-frontend-donate-image-title-you')); // TODO: what if the user cannot upload to the destination wiki in $wgMFPhotoUploadEndpoint? $html = $this->getUserUploadsPageHtml($user); } $output->addHTML($html); } }
/** * Render the special page and redirect the user to the editor (if page exists) * @param string $subpage The name of the page to edit */ public function executeWhenAvailable($subpage) { if (!is_string($subpage)) { $this->showPageNotFound(); return; } else { $title = Title::newFromText($subpage); if (is_null($title)) { $this->showPageNotFound(); return; } } $data = $this->getRequest()->getValues(); unset($data['title']); // Remove the title of the special page $section = (int) $this->getRequest()->getVal('section', 0); $output = $this->getOutput(); $output->addModules('mobile.special.mobileeditor.scripts'); $output->setPageTitle($this->msg('mobile-frontend-editor-redirect-title')->text()); $context = MobileContext::singleton(); $articleUrl = $context->getMobileUrl($title->getFullURL($data)); $targetUrl = $articleUrl . '#/editor/' . $section; $html = Html::openElement('div', array('id' => 'mw-mf-editor', 'data-targeturl' => $targetUrl)) . Html::openElement('noscript') . MobileUI::errorBox($this->msg('mobile-frontend-editor-unavailable')->text()) . Html::openElement('p') . Html::element('a', array('href' => $title->getLocalUrl()), $this->msg('returnto', $title->getText())->text()) . Html::closeElement('noscript') . Html::closeElement('div'); // #mw-mf-editorunavailable $output->addHTML($html); }
/** * Show error page, that the user does not exist, or no user provided * @param string $msgKey Message key to use as error message body * @return string */ protected function displayNoUserError($msgKey) { $out = $this->getOutput(); // generate a user friendly error with a meaningful message $html = MobileUI::contentElement(MobileUI::errorBox(Html::element('h2', array(), $this->msg('mobile-frontend-profile-error')) . Html::element('p', array(), $this->msg($msgKey)))); // return page with status code 404, instead of 200 and output the error page $out->setStatusCode(404); $out->addHtml($html); }
/** * Render Special Page Nearby * @param string $par Parameter submitted as subpage */ public function executeWhenAvailable($par = '') { $this->setHeaders(); $output = $this->getOutput(); // set config $output->addJsConfigVars('wgMFNearbyRange', $this->getMFConfig()->get('MFNearbyRange')); $output->setPageTitle(wfMessage('mobile-frontend-nearby-title')->escaped()); $html = Html::openElement('div', array('class' => 'content-unstyled', 'id' => 'mw-mf-nearby')) . MobileUI::contentElement(MobileUI::errorBox(Html::element('h2', array(), wfMessage('mobile-frontend-nearby-requirements')) . Html::element('p', array(), wfMessage('mobile-frontend-nearby-requirements-guidance'))), 'noscript') . Html::closeElement('div'); // #mw-mf-nearby $output->addHTML($html); }