public function commit()
 {
     if ($this->action !== 'new-topic') {
         throw new FailCommitException('Unknown commit action', 'fail-commit');
     }
     $metadata = array('workflow' => $this->topicWorkflow, 'board-workflow' => $this->workflow, 'topic-title' => $this->topicTitle, 'first-post' => $this->firstPost);
     /*
      * Order of storage is important! We've been changing when we stored
      * workflow a couple of times. For now, it needs to be stored first:
      * * OccupationListener.php (workflow listener) must first create the
      *   board before NotificationListener.php (topic/post listeners)
      *   creates notifications (& mails) that link to the board
      * * ReferenceExtractor.php (run from ReferenceRecorder.php, a post
      *   listener) needs to parse content with Parsoid & for that it needs
      *   the board title. AbstractRevision::getContent() will figure out
      *   the title from the workflow: $this->getCollection()->getTitle()
      * If you even feel the need to change the order, make sure you come
      * up with a fix for the above things ;)
      */
     $this->storage->put($this->workflow, array());
     // 'discussion' workflow
     $this->storage->put($this->topicWorkflow, $metadata);
     // 'topic' workflow
     $this->storage->put($this->topicListEntry, $metadata);
     $this->storage->put($this->topicTitle, $metadata);
     if ($this->firstPost !== null) {
         $this->storage->put($this->firstPost, $metadata + array('reply-to' => $this->topicTitle));
     }
     $output = array('topic-page' => $this->topicWorkflow->getArticleTitle()->getPrefixedText(), 'topic-id' => $this->topicTitle->getPostId(), 'topic-revision-id' => $this->topicTitle->getRevisionId(), 'post-id' => $this->firstPost ? $this->firstPost->getPostId() : null, 'post-revision-id' => $this->firstPost ? $this->firstPost->getRevisionId() : null);
     return $output;
 }
 /**
  * @param Workflow $workflow
  * @param string $objectType
  * @param UUID $objectId
  */
 public function __construct(Workflow $workflow, $objectType, UUID $objectId)
 {
     $this->workflowId = $workflow->getId();
     $this->title = $workflow->getArticleTitle();
     $this->objectType = $objectType;
     $this->objectId = $objectId;
 }
 /**
  * @param \OutputPage $out
  */
 public function setPageTitle(\OutputPage $out)
 {
     if ($out->getPageTitle()) {
         // Don't override page title if another block has already set it.
         // If this should *really* be done, the specific block extending
         // this AbstractBlock should just implement this itself ;)
         return;
     }
     $out->setPageTitle($this->workflow->getArticleTitle()->getFullText());
 }
 public function doUpdate(Workflow $workflow)
 {
     $title = $workflow->getArticleTitle();
     $page = WikiPage::factory($title);
     $content = $page->getContent();
     if ($content === null) {
         $updates = array();
     } else {
         $updates = $content->getSecondaryDataUpdates($title);
     }
     DataUpdate::runUpdates($updates);
 }
 /**
  * @param Workflow $workflow
  * @param User $user
  * @param string $content
  * @param string $format wikitext|html
  * @param string[optional] $changeType
  * @return Header
  */
 public static function create(Workflow $workflow, User $user, $content, $format, $changeType = 'create-header')
 {
     $obj = new self();
     $obj->revId = UUID::create();
     $obj->workflowId = $workflow->getId();
     $obj->user = UserTuple::newFromUser($user);
     $obj->prevRevision = null;
     // no prior revision
     $obj->setContent($content, $format, $workflow->getArticleTitle());
     $obj->changeType = $changeType;
     return $obj;
 }
 /**
  * @param Workflow $workflow Topic list workflow
  * @param array $links pagination link data
  *
  * @return array link structure
  */
 protected function buildPaginationLinks(Workflow $workflow, array $links)
 {
     $res = array();
     $title = $workflow->getArticleTitle();
     foreach ($links as $key => $options) {
         // prefix all options with topiclist_
         $realOptions = array();
         foreach ($options as $k => $v) {
             $realOptions["topiclist_{$k}"] = $v;
         }
         $res[$key] = new Anchor($key, $title, $realOptions);
     }
     return $res;
 }
 protected function getBlandTestObjects()
 {
     return array($this->workflow, $this->revision, $this->workflow->getArticleTitle());
 }
 protected function redirect(Workflow $workflow)
 {
     $link = $this->urlGenerator->workflowLink($workflow->getArticleTitle(), $workflow->getId());
     $this->getOutput()->redirect($link->getFullURL());
 }
 /**
  * @param Workflow $workflow
  * @param User $user
  * @param string $content
  * @param string $format wikitext|html
  * @param string[optional] $changeType
  * @return PostRevision
  */
 public function reply(Workflow $workflow, User $user, $content, $format, $changeType = 'reply')
 {
     $reply = new self();
     // UUIDs should not be reused for different entities/entity types in the future.
     // (It is also inconsistent with newFromId, which uses separate ones.)
     // This may be changed here in the future.
     $reply->revId = $reply->postId = UUID::create();
     $reply->user = UserTuple::newFromUser($user);
     $reply->origUser = $reply->user;
     $reply->replyToId = $this->postId;
     $reply->setContent($content, $format, $workflow->getArticleTitle());
     $reply->changeType = $changeType;
     $reply->setChildren(array());
     $reply->setDepth($this->getDepth() + 1);
     $reply->rootPost = $this->rootPost;
     return $reply;
 }
 /**
  * @param Workflow $workflow
  * @param string $action
  * @return \Title
  */
 public function getRcTitle(Workflow $workflow, $action)
 {
     if ($this->actions->getValue($action, 'rc_title') === 'owner') {
         return $workflow->getOwnerTitle();
     } else {
         return $workflow->getArticleTitle();
     }
 }
 protected function buildApiActions(Workflow $workflow)
 {
     return array('newtopic' => array('url' => $this->urlGenerator->newTopicAction($workflow->getArticleTitle(), $workflow->getId())));
 }
 /**
  * @param string $changeType
  * @param Workflow $workflow
  */
 public function onAfterInsertExpectedChange($changeType, Workflow $workflow)
 {
     $users = static::getUsersToSubscribe($changeType, 'immediate', array($this->watchedTopicItems));
     foreach ($users as $user) {
         if (!$user instanceof User) {
             continue;
         }
         $title = $workflow->getArticleTitle();
         WatchedItem::fromUserTitle($user, $title)->addWatch();
         $this->watchedTopicItems->addOverrideWatched($title);
     }
 }