public function buildResponseString()
 {
     if ($this->shouldStopForDebugging()) {
         $request = $this->getRequest();
         $viewer = $request->getUser();
         $view = new PhabricatorStandardPageView();
         $view->setRequest($this->getRequest());
         $view->setApplicationName(pht('Debug'));
         $view->setTitle(pht('Stopped on Redirect'));
         $dialog = new AphrontDialogView();
         $dialog->setUser($viewer);
         $dialog->setTitle(pht('Stopped on Redirect'));
         $dialog->appendParagraph(pht('You were stopped here because %s is set in your configuration.', phutil_tag('tt', array(), 'debug.stop-on-redirect')));
         $dialog->appendParagraph(pht('You are being redirected to: %s', phutil_tag('tt', array(), $this->getURI())));
         $dialog->addCancelButton($this->getURI(), pht('Continue'));
         $dialog->appendChild(phutil_tag('br'));
         $dialog->appendChild(id(new AphrontStackTraceView())->setUser($viewer)->setTrace($this->stackWhenCreated));
         $dialog->setIsStandalone(true);
         $dialog->setWidth(AphrontDialogView::WIDTH_FULL);
         $box = id(new PHUIBoxView())->addMargin(PHUI::MARGIN_LARGE)->appendChild($dialog);
         $view->appendChild($box);
         return $view->render();
     }
     return '';
 }
 public function buildResponseString()
 {
     $failure = new AphrontRequestFailureView();
     $failure->setHeader('404 Not Found');
     $failure->appendChild('<p>The page you requested was not found.</p>');
     $view = new PhabricatorStandardPageView();
     $view->setTitle('404 Not Found');
     $view->setRequest($this->getRequest());
     $view->appendChild($failure);
     return $view->render();
 }
 public function buildResponseString()
 {
     $forbidden_text = $this->getForbiddenText();
     if (!$forbidden_text) {
         $forbidden_text = 'You do not have privileges to access the requested page.';
     }
     $failure = new AphrontRequestFailureView();
     $failure->setHeader('403 Forbidden');
     $failure->appendChild('<p>' . $forbidden_text . '</p>');
     $view = new PhabricatorStandardPageView();
     $view->setTitle('403 Forbidden');
     $view->setRequest($this->getRequest());
     $view->appendChild($failure);
     return $view->render();
 }
 public function buildResponseString()
 {
     if ($this->shouldStopForDebugging()) {
         $view = new PhabricatorStandardPageView();
         $view->setRequest($this->getRequest());
         $view->setApplicationName('Debug');
         $view->setTitle('Stopped on Redirect');
         $error = new AphrontErrorView();
         $error->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
         $error->setTitle('Stopped on Redirect');
         $link = phutil_render_tag('a', array('href' => $this->getURI()), 'Continue to: ' . phutil_escape_html($this->getURI()));
         $error->appendChild('<p>You were stopped here because <tt>debug.stop-on-redirect</tt> ' . 'is set in your configuration.</p>' . '<p>' . $link . '</p>');
         $view->appendChild($error);
         return $view->render();
     }
     return '';
 }
 public function willSendResponse(AphrontResponse $response)
 {
     $request = $this->getRequest();
     $response->setRequest($request);
     if ($response instanceof AphrontDialogResponse) {
         if (!$request->isAjax()) {
             $view = new PhabricatorStandardPageView();
             $view->setRequest($request);
             $view->appendChild('<div style="padding: 2em 0;">' . $response->buildResponseString() . '</div>');
             $response = new AphrontWebpageResponse();
             $response->setContent($view->render());
             return $response;
         } else {
             return id(new AphrontAjaxResponse())->setContent(array('dialog' => $response->buildResponseString()));
         }
     } else {
         if ($response instanceof AphrontRedirectResponse) {
             if ($request->isAjax()) {
                 return id(new AphrontAjaxResponse())->setContent(array('redirect' => $response->getURI()));
             }
         } else {
             if ($response instanceof Aphront404Response) {
                 $failure = new AphrontRequestFailureView();
                 $failure->setHeader('404 Not Found');
                 $failure->appendChild('<p>The page you requested was not found.</p>');
                 $view = new PhabricatorStandardPageView();
                 $view->setTitle('404 Not Found');
                 $view->setRequest($this->getRequest());
                 $view->appendChild($failure);
                 $response = new AphrontWebpageResponse();
                 $response->setContent($view->render());
                 $response->setHTTPResponseCode(404);
                 return $response;
             }
         }
     }
     return $response;
 }