protected function doRedirect(Title $fromTitle, UUID $toTopic, UUID $toPost = null)
 {
     if ($toPost) {
         $redirectAnchor = $this->urlGenerator->postLink(null, $toTopic, $toPost);
     } else {
         $redirectAnchor = $this->urlGenerator->topicLink(null, $toTopic);
     }
     $redirectTarget = $redirectAnchor->resolveTitle();
     $newContent = new WikiTextContent("#REDIRECT [[" . $redirectTarget->getFullText() . "]]");
     $page = WikiPage::factory($fromTitle);
     $summary = wfMessage('flow-lqt-redirect-reason')->plain();
     $page->doEditContent($newContent, $summary, EDIT_FORCE_BOT, false, $this->user);
     WatchedItem::duplicateEntries($fromTitle, $redirectTarget);
 }
 /**
  * Diff would format against two revisions
  */
 public function formatApi(FormatterRow $newRow, FormatterRow $oldRow, IContextSource $ctx)
 {
     $oldRes = $this->revisionViewFormatter->formatApi($oldRow, $ctx);
     $newRes = $this->revisionViewFormatter->formatApi($newRow, $ctx);
     $oldContent = $oldRow->revision->getContent('wikitext');
     $newContent = $newRow->revision->getContent('wikitext');
     $differenceEngine = new \DifferenceEngine();
     $differenceEngine->setContent(new \TextContent($oldContent), new \TextContent($newContent));
     if ($oldRow->revision->isFirstRevision()) {
         $prevLink = null;
     } else {
         $prevLink = $this->urlGenerator->diffLink($oldRow->revision, $ctx->getTitle(), UUID::create($oldRes['workflowId']))->getLocalURL();
     }
     // this is probably a network request which typically goes in the query
     // half, but we don't have to worry about batching because we only show
     // one diff at a time so just do it.
     $nextRevision = $newRow->revision->getCollection()->getNextRevision($newRow->revision);
     if ($nextRevision === null) {
         $nextLink = null;
     } else {
         $nextLink = $this->urlGenerator->diffLink($nextRevision, $ctx->getTitle(), UUID::create($newRes['workflowId']))->getLocalURL();
     }
     return array('new' => $newRes, 'old' => $oldRes, 'diff_content' => $differenceEngine->getDiffBody(), 'links' => array('previous' => $prevLink, 'next' => $nextLink));
 }
 /**
  * Generate the links for single and diff view actions
  *
  * @param FormatterRow $row
  * @param IContextSource $ctx
  * @return array
  */
 public function buildLinks(FormatterRow $row, IContextSource $ctx)
 {
     $workflowId = $row->workflow->getId();
     $boardTitle = $row->workflow->getOwnerTitle();
     $title = $row->workflow->getArticleTitle();
     $links = array('hist' => $this->urlGenerator->boardHistoryLink($title), 'board' => $this->urlGenerator->boardLink($boardTitle));
     if ($row->revision instanceof PostRevision || $row->revision instanceof PostSummary) {
         $links['root'] = $this->urlGenerator->topicLink($row->workflow->getArticleTitle(), $workflowId);
         $links['root']->setMessage($title->getPrefixedText());
     }
     if ($row->revision instanceof PostRevision) {
         $links['single-view'] = $this->urlGenerator->postRevisionLink($title, $workflowId, $row->revision->getPostId(), $row->revision->getRevisionId());
         $links['single-view']->setMessage($title->getPrefixedText());
     } elseif ($row->revision instanceof Header) {
         $links['single-view'] = $this->urlGenerator->headerRevisionLink($title, $workflowId, $row->revision->getRevisionId());
         $links['single-view']->setMessage($title->getPrefixedText());
     } elseif ($row->revision instanceof PostSummary) {
         $links['single-view'] = $this->urlGenerator->summaryRevisionLink($title, $workflowId, $row->revision->getRevisionId());
         $links['single-view']->setMessage($title->getPrefixedText());
     } else {
         wfDebugLog('Flow', __METHOD__ . ': Received unknown revision type ' . get_class($row->revision));
     }
     if ($row->revision->getPrevRevisionId() !== null) {
         $links['diff'] = $this->urlGenerator->diffLink($row->revision, null, $workflowId);
         $links['diff']->setMessage(wfMessage('diff'));
     } else {
         $links['diff'] = array('url' => '', 'title' => '');
     }
     $recentChange = $row->revision->getRecentChange();
     if ($recentChange !== null) {
         $user = $ctx->getUser();
         if (ChangesList::isUnpatrolled($recentChange, $user)) {
             $links['markPatrolled'] = $this->urlGenerator->markRevisionPatrolledAction($title, $workflowId, $recentChange, $user->getEditToken($recentChange->getAttribute('rc_id')));
         }
     }
     return $links;
 }
 protected function redirect(Workflow $workflow)
 {
     $link = $this->urlGenerator->workflowLink($workflow->getArticleTitle(), $workflow->getId());
     $this->getOutput()->redirect($link->getFullURL());
 }
 protected function buildApiActions(Workflow $workflow)
 {
     return array('newtopic' => array('url' => $this->urlGenerator->newTopicAction($workflow->getArticleTitle(), $workflow->getId())));
 }