function __construct(&$output, &$article, &$title, &$user, &$request) { parent::__construct($output, $article, $title, $user, $request); $t = Threads::withRoot($this->article); $this->thread = $t; if (!$t) { return; } $this->article = $t->article(); }
function checkParameters($par) { // Handle parameter $this->mTarget = $par; if ($par === null || $par === "") { $this->output->addHTML(wfMsg('lqt_threadrequired')); return false; } $thread = Threads::withRoot(new Article(Title::newFromURL($par))); if (!$thread) { $this->output->addHTML(wfMsg('lqt_nosuchthread')); return false; } $this->mThread = $thread; return true; }
/** * Display a moved thread * * @param $thread Thread * @throws Exception */ function showMovedThread($thread) { global $wgLang; // Grab target thread if (!$thread->title()) { return; // Odd case: moved thread with no title? } $article = new Article($thread->title(), 0); $target = Title::newFromRedirect($article->getContent()); if (!$target) { throw new Exception("Thread " . $thread->id() . ' purports to be moved, ' . 'but no redirect found in text (' . $article->getContent() . ') of ' . $thread->root()->getTitle()->getPrefixedText() . '. Dying.'); } $t_thread = Threads::withRoot(new Article($target, 0)); // Grab data about the new post. $author = $thread->author(); $sig = Linker::userLink($author->getID(), $author->getName()) . Linker::userToolLinks($author->getID(), $author->getName()); $newTalkpage = is_object($t_thread) ? $t_thread->getTitle() : ''; $html = wfMessage('lqt_move_placeholder')->rawParams(Linker::link($target), $sig)->params($wgLang->date($thread->modified()), $wgLang->time($thread->modified()))->rawParams(Linker::link($newTalkpage))->parse(); $this->output->addHTML($html); }
function redirectThread() { $rev = Revision::newFromId($this->root()->getLatest()); $rtitle = Title::newFromRedirect($rev->getRawText()); if (!$rtitle) { return null; } $this->dieIfHistorical(); $rthread = Threads::withRoot(new Article($rtitle)); return $rthread; }
static function showLqtThread($details) { $title = $details["title"]; $article = $details["article"]; global $wgUser, $wgRequest, $wgOut; $oldOut = $wgOut->getHTML(); $wgOut->clearHTML(); $root = new Article($title, 0); $thread = Threads::withRoot($root); $view = new LqtView($wgOut, $article, $title, $wgUser, $wgRequest); $view->showThread($thread); $html = $wgOut->getHTML(); $wgOut->clearHTML(); $wgOut->getHTML($oldOut); return $html; }
public function actionMerge($threads, $params) { if (count($threads) < 1) { $this->dieUsage('You must specify a thread to merge', 'no-specified-threads'); } if (empty($params['newparent'])) { $this->dieUsage('You must specify a new parent thread to merge beneath', 'no-parent-thread'); } $newParent = $params['newparent']; if (is_numeric($newParent)) { $newParent = Threads::withId($newParent); } else { $title = Title::newFromText($newParent); $article = new Article($title, 0); $newParent = Threads::withRoot($article); } $errors = $newParent->title()->getUserPermissionsErrors('lqt-merge', $this->getUser()); if ($errors) { // We don't care about multiple errors, just report one of them $this->dieUsageMsg(reset($errors)); } if (!$newParent) { $this->dieUsage('The parent thread you specified was neither the title ' . 'of a thread, nor a thread ID.', 'invalid-parent-thread'); } // Pull a reason, if applicable. $reason = ''; if (!empty($params['reason'])) { $reason = $params['reason']; } $result = array(); foreach ($threads as $thread) { $thread->moveToParent($newParent, $reason); $result[] = array('result' => 'Success', 'action' => 'merge', 'id' => $thread->id(), 'title' => $thread->title()->getPrefixedText(), 'new-parent-id' => $newParent->id(), 'new-parent-title' => $newParent->title()->getPrefixedText(), 'new-ancestor-id' => $newParent->topmostThread()->id(), 'new-ancestor-title' => $newParent->topmostThread()->title()->getPrefixedText()); } $this->getResult()->setIndexedTagName($result, 'thread'); $this->getResult()->addValue(null, 'threadaction', $result); }
/** * @param $params array * @param $db DatabaseBase * @return array */ function getConditions($params, $db) { $conds = array(); // Types $conds['thread_type'] = Threads::TYPE_NORMAL; // Limit $cutoff = time() - intval($params['days'] * 24 * 3600); $cutoff = $db->timestamp($cutoff); $conds[] = 'thread_created > ' . $db->addQuotes($cutoff); // Talkpage conditions $pageConds = array(); $talkpages = (array) $params['talkpage']; foreach ($talkpages as $page) { $title = Title::newFromText($page); $pageCond = array('thread_article_namespace' => $title->getNamespace(), 'thread_article_title' => $title->getDBkey()); $pageConds[] = $db->makeList($pageCond, LIST_AND); } // Thread conditions $threads = (array) $params['thread']; foreach ($threads as $thread) { $root = new Article(Title::newFromText($thread)); $thread = Threads::withRoot($root); if (!$thread) { continue; } $threadCond = array('thread_ancestor' => $thread->id(), 'thread_id' => $thread->id()); $pageConds[] = $db->makeList($threadCond, LIST_OR); } if (count($pageConds)) { $conds[] = $db->makeList($pageConds, LIST_OR); } // New thread v. Reply $types = (array) $params['type']; if (!in_array('replies', $types)) { $conds[] = Threads::topLevelClause(); } elseif (!in_array('newthreads', $types)) { $conds[] = '!' . Threads::topLevelClause(); } return $conds; }
static function onArticleConfirmDelete($article, $out, &$reason) { if ($article->getTitle()->getNamespace() != NS_LQT_THREAD) { return true; } $thread = Threads::withRoot($article); if (!$thread) { return true; } if ($thread->isTopmostThread() && count($thread->replies())) { $out->wrapWikiMsg('<strong>$1</strong>', 'lqt-delete-parent-warning'); } return true; }
/** * Do not allow users to read threads on talkpages that they cannot read. * * @param $title Title * @param $user * @param $action * @param $result * @return bool */ public static function onGetUserPermissionsErrors($title, $user, $action, &$result) { if ($title->getNamespace() != NS_LQT_THREAD || $action != 'read') { return true; } $thread = Threads::withRoot(new Article($title, 0)); if (!$thread) { return true; } $talkpage = $thread->article(); $canRead = $talkpage->getTitle()->quickUserCan('read', $user); if ($canRead) { return true; } else { $result = false; return false; } }
function showMovedThread($thread) { global $wgLang; $linker = class_exists('DummyLinker') ? new DummyLinker() : new Linker(); // Grab target thread if (!$thread->title()) { return; // Odd case: moved thread with no title? } $article = new Article($thread->title()); $target = Title::newFromRedirect($article->getContent()); if (!$target) { throw new MWException("Thread " . $thread->id() . ' purports to be moved, ' . 'but no redirect found in text (' . $article->getContent() . ') of ' . $thread->root()->getTitle()->getPrefixedText() . '. Dying.'); } $t_thread = Threads::withRoot(new Article($target)); // Grab data about the new post. $author = $thread->author(); $sig = $linker->userLink($author->getID(), $author->getName()) . $linker->userToolLinks($author->getID(), $author->getName()); $newTalkpage = is_object($t_thread) ? $t_thread->getTitle() : ''; $html = wfMsgExt('lqt_move_placeholder', array('parseinline', 'replaceafter'), $linker->link($target), $sig, $wgLang->date($thread->modified()), $wgLang->time($thread->modified()), $linker->link($newTalkpage)); $this->output->addHTML($html); }
function __construct(&$output, &$article, &$title, &$user, &$request) { parent::__construct($output, $article, $title, $user, $request); $t = Threads::withRoot($this->article); $this->thread = $t; if (!$t) { return; } // $this->article gets saved to thread_article, so we want it to point to the // subject page associated with the talkpage, always, not the permalink url. $this->article = $t->article(); # for creating reply threads. }