public function formatApi(Workflow $listWorkflow, array $workflows, array $found, PagerPage $page, IContextSource $ctx) { $res = $this->buildResult($workflows, $found, $ctx) + $this->buildEmptyResult($listWorkflow); $pagingOption = $page->getPagingLinksOptions(); $res['links']['pagination'] = $this->buildPaginationLinks($listWorkflow, $pagingOption); $title = $listWorkflow->getArticleTitle(); $saveSortBy = true; $res['links']['board-sort']['updated'] = $this->urlGenerator->boardLink($title, 'updated', $saveSortBy)->getLinkURL(); $res['links']['board-sort']['newest'] = $this->urlGenerator->boardLink($title, 'newest', $saveSortBy)->getLinkURL(); // Link to designated new-topic page, for no-JS users $res['links']['newtopic'] = $this->urlGenerator->newTopicAction($title, $listWorkflow->getId())->getLinkURL(); return $res; }
/** * 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; }