コード例 #1
0
 /**
  * @since 0.4
  *
  * @param Summary|null $summary
  * @param string $action
  * @param string $language
  * @param string|array $args
  *
  * @throws InvalidArgumentException
  */
 protected function updateSummary(Summary $summary = null, $action, $language = '', $args = '')
 {
     if ($summary !== null) {
         $summary->setAction($action);
         $summary->setLanguage($language);
         $summary->addAutoSummaryArgs($args);
     }
 }
コード例 #2
0
 /**
  * @dataProvider provideFormatSummary
  */
 public function testFormatSummary($module, $action, $language, $commentArgs, $summaryArgs, $userSummary, $expected)
 {
     $summary = new Summary($module);
     if ($action !== null) {
         $summary->setAction($action);
     }
     if ($language !== null) {
         $summary->setLanguage($language);
     }
     if ($commentArgs) {
         call_user_func_array(array($summary, 'addAutoCommentArgs'), $commentArgs);
     }
     if ($summaryArgs) {
         call_user_func_array(array($summary, 'addAutoSummaryArgs'), $summaryArgs);
     }
     if ($userSummary !== null) {
         $summary->setUserSummary($userSummary);
     }
     $formatter = $this->newFormatter();
     $this->assertEquals($expected, $formatter->formatSummary($summary));
 }
コード例 #3
0
 /**
  * @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());
 }
コード例 #4
0
 /**
  * @return Summary
  */
 private function getSummaryForLabelDescriptionAliases()
 {
     // FIXME: Introduce more specific messages if only 2 of the 3 fields changed.
     $summary = new Summary('wbsetlabeldescriptionaliases');
     $summary->addAutoSummaryArgs($this->label, $this->description, $this->aliases);
     $summary->setLanguage($this->languageCode);
     return $summary;
 }
コード例 #5
0
 public function testSetLanguage()
 {
     $summary = new Summary('summarytest');
     $summary->setLanguage("xyz");
     $this->assertEquals('xyz', $summary->getLanguageCode());
 }