/**
  * @see SpecialWikibasePage::execute
  *
  * @since 0.1
  *
  * @param string|null $subPage
  */
 public function execute($subPage)
 {
     parent::execute($subPage);
     $this->checkPermissions();
     $this->checkBlocked();
     $this->checkReadOnly();
     $this->parts = $subPage === '' ? array() : explode('/', $subPage);
     $this->prepareArguments();
     $out = $this->getOutput();
     $uiLanguageCode = $this->getLanguage()->getCode();
     if ($this->getRequest()->wasPosted() && $this->getUser()->matchEditToken($this->getRequest()->getVal('wpEditToken'))) {
         if ($this->hasSufficientArguments()) {
             $entity = $this->createEntity();
             $status = $this->modifyEntity($entity);
             if ($status->isGood()) {
                 $summary = new Summary('wbeditentity', 'create');
                 $summary->setLanguage($uiLanguageCode);
                 $summary->addAutoSummaryArgs($this->label, $this->description);
                 $status = $this->saveEntity($entity, $summary, $this->getRequest()->getVal('wpEditToken'), EDIT_NEW);
                 $out = $this->getOutput();
                 if (!$status->isOK()) {
                     $out->addHTML('<div class="error">');
                     $out->addWikiText($status->getWikiText());
                     $out->addHTML('</div>');
                 } elseif ($entity !== null) {
                     $title = $this->getEntityTitle($entity->getId());
                     $entityUrl = $title->getFullUrl();
                     $this->getOutput()->redirect($entityUrl);
                 }
             } else {
                 $out->addHTML('<div class="error">');
                 $out->addHTML($status->getHTML());
                 $out->addHTML('</div>');
             }
         }
     }
     $this->getOutput()->addModuleStyles(array('wikibase.special'));
     foreach ($this->getWarnings() as $warning) {
         $out->addHTML(Html::element('div', array('class' => 'warning'), $warning));
     }
     $this->createForm($this->getLegend(), $this->additionalFormElements());
 }
 /**
  * @see SpecialWikibasePage::execute
  *
  * @since 0.4
  *
  * @param string|null $subPage
  */
 public function execute($subPage)
 {
     parent::execute($subPage);
     $this->checkPermissions();
     $this->checkBlocked();
     $this->checkReadOnly();
     $this->setHeaders();
     $this->outputHeader();
     try {
         $this->prepareArguments($subPage);
     } catch (UserInputException $ex) {
         $error = $this->msg($ex->getKey(), $ex->getParams())->parse();
         $this->showErrorHTML($error);
     }
     $summary = false;
     $valid = $this->validateInput();
     $entity = $this->entityRevision === null ? null : $this->entityRevision->getEntity();
     if ($valid) {
         $summary = $this->modifyEntity($entity);
     }
     if (!$summary) {
         $this->setForm($entity);
     } else {
         //TODO: Add conflict detection. All we need to do is to provide the base rev from
         // $this->entityRevision to the saveEntity() call. But we need to make sure
         // conflicts are reported in a nice way first. In particular, we'd want to
         // show the form again.
         $status = $this->saveEntity($entity, $summary, $this->getRequest()->getVal('wpEditToken'));
         if (!$status->isOK() && $status->getErrorsArray()) {
             $errors = $status->getErrorsArray();
             $this->showErrorHTML($this->msg($errors[0][0], array_slice($errors[0], 1))->parse());
             $this->setForm($entity);
         } else {
             $entityUrl = $this->getEntityTitle($entity->getId())->getFullUrl();
             $this->getOutput()->redirect($entityUrl);
         }
     }
 }