[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/phriction/controller/ -> PhrictionNewController.php (source)

   1  <?php
   2  
   3  final class PhrictionNewController extends PhrictionController {
   4  
   5    public function processRequest() {
   6      $request = $this->getRequest();
   7      $user    = $request->getUser();
   8      $slug    = PhabricatorSlug::normalize($request->getStr('slug'));
   9  
  10      if ($request->isFormPost()) {
  11        $document = id(new PhrictionDocumentQuery())
  12          ->setViewer($user)
  13          ->withSlugs(array($slug))
  14          ->executeOne();
  15        $prompt = $request->getStr('prompt', 'no');
  16        $document_exists = $document && $document->getStatus() ==
  17          PhrictionDocumentStatus::STATUS_EXISTS;
  18  
  19        if ($document_exists && $prompt == 'no') {
  20          $dialog = new AphrontDialogView();
  21          $dialog->setSubmitURI('/phriction/new/')
  22            ->setTitle(pht('Edit Existing Document?'))
  23            ->setUser($user)
  24            ->appendChild(pht(
  25              'The document %s already exists. Do you want to edit it instead?',
  26              phutil_tag('tt', array(), $slug)))
  27            ->addHiddenInput('slug', $slug)
  28            ->addHiddenInput('prompt', 'yes')
  29            ->addCancelButton('/w/')
  30            ->addSubmitButton(pht('Edit Document'));
  31  
  32          return id(new AphrontDialogResponse())->setDialog($dialog);
  33        }
  34  
  35        $uri  = '/phriction/edit/?slug='.$slug;
  36        return id(new AphrontRedirectResponse())
  37          ->setURI($uri);
  38      }
  39  
  40      if ($slug == '/') {
  41        $slug = '';
  42      }
  43  
  44      $view = id(new PHUIFormLayoutView())
  45        ->appendChild(id(new AphrontFormTextControl())
  46                         ->setLabel('/w/')
  47                         ->setValue($slug)
  48                         ->setName('slug'));
  49  
  50      $dialog = id(new AphrontDialogView())
  51        ->setUser($user)
  52        ->setTitle(pht('New Document'))
  53        ->setSubmitURI('/phriction/new/')
  54        ->appendChild(phutil_tag('p',
  55          array(),
  56          pht('Create a new document at')))
  57        ->appendChild($view)
  58        ->addSubmitButton(pht('Create'))
  59        ->addCancelButton('/w/');
  60  
  61      return id(new AphrontDialogResponse())->setDialog($dialog);
  62    }
  63  
  64  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1