public function index() { JSMessages::enqueuePackage('Wall', JSMessages::EXTERNAL); $title = $this->getContext()->getTitle(); $this->isThreadLevel = $this->request->getVal('threadLevelHistory', false); $path = array(); if ($this->isThreadLevel) { $threadId = intval($title->getDBkey()); $title = Title::newFromId($threadId); } $this->historyPreExecute(); $page = $this->request->getVal('page', 1); $page = ($page = intval($page)) === 0 ? 1 : $page; $this->response->setVal('sortingOptions', $this->getSortingOptions()); $this->response->setVal('sortingSelected', $this->getSortingSelectedText()); $this->response->setVal('wallHistoryMsg', $this->getHistoryMessagesArray()); $this->response->setVal('currentPage', $page); $this->response->setVal('isThreadLevelHistory', $this->isThreadLevel); if (!$title instanceof Title || $this->isThreadLevel && !in_array(MWNamespace::getSubject($title->getNamespace()), $this->wg->WallNS)) { // paranoia -- why the message is not in DB $this->response->setVal('wallmessageNotFound', true); return; } if ($this->isThreadLevel) { $wallMessage = new WallMessage($title); $wallMessage->load(); $perPage = 50; $wallHistory = new WallHistory(); $wallHistory->setPage($page, $perPage); $count = $wallHistory->getCount(null, $threadId); $sort = $this->getSortingSelected(); $history = $wallHistory->get(null, $sort, $threadId); $this->response->setVal('wallHistory', $this->getFormatedHistoryData($history, $threadId)); $path[] = array('title' => $wallMessage->getMetatitle(), 'url' => $wallMessage->getMessagePageUrl()); $wallUrl = $wallMessage->getArticleTitle()->getFullUrl(); $wallOwnerName = $wallMessage->getArticleTitle()->getText(); $this->response->setVal('wallHistoryUrl', $wallMessage->getMessagePageUrl(true) . '?action=history&sort=' . $sort); } else { $perPage = 100; $wallHistory = new WallHistory(); $wallHistory->setPage($page, $perPage); $sort = $this->getSortingSelected(); if ($title->exists()) { $count = $wallHistory->getCount($title->getArticleId(), null, false); $history = $wallHistory->get($title->getArticleId(), $sort, null, false); } else { $count = 0; $history = array(); } $wallUrl = $title->getFullUrl(); $wallOwnerName = $title->getText(); $this->response->setVal('wallHistory', $this->getFormatedHistoryData($history)); $this->response->setVal('wallHistoryUrl', $title->getFullURL(array('action' => 'history', 'sort' => $sort))); } $path = array_merge(array(array('title' => wfMessage('wall-message-elseswall', array($wallOwnerName))->escaped(), 'url' => $wallUrl)), $path); $this->response->setVal('wallOwnerName', $wallOwnerName); if ($this->isThreadLevel) { $this->response->setVal('pageTitle', wfMessage('wall-thread-history-title')->escaped()); wfRunHooks('WallHistoryThreadHeader', array($title, $wallMessage, &$path, &$this->response, &$this->request)); } else { $this->response->setVal('pageTitle', wfMessage('wall-history-title')->escaped()); wfRunHooks('WallHistoryHeader', array($title, &$path, &$this->response, &$this->request)); } $this->response->setVal('path', $path); $this->response->setVal('totalItems', $count); $this->response->setVal('itemsPerPage', $perPage); $this->response->setVal('showPager', $count > $perPage); }