function execute($par) { global $wgOut, $wgUser, $wgRequest; $this->setHeaders(); $wgOut->setPageTitle(wfMsg('lqt-hot-topics')); $title = $this->getTitle(); $view = new LqtView($wgOut, new Article($title), $title, $wgUser, $wgRequest); // Get hot topics $topics = LqtHotTopicsController::getHotThreads(); foreach ($topics as $thread) { $view->showThread($thread); } }
function createPost($info, $subject, $super = null) { $userName = $info['user']; if (strpos($userName, '#') !== false) { $pos = strpos($userName, '#'); $userName = substr($userName, 0, $pos); } $user = User::newFromName($userName, false); if (!$user) { throw new MWException("Username " . $info['user'] . " is invalid."); } global $article; if ($super) { $title = Threads::newReplyTitle($super, $user); } else { $title = Threads::newThreadTitle($subject, $article); } print "Creating thread {$title} as a subthread of " . ($super ? $super->title() : 'none') . "\n"; $root = new Article($title); $root->doEdit($info['content'], 'Imported from JSON', EDIT_NEW, false, $user); $t = LqtView::postEditUpdates($super ? 'reply' : 'new', $super, $root, $article, $subject, 'Imported from JSON', null); $t = Threads::withId($t->id()); // Some weirdness. return $t; }
function getTOC($threads) { global $wgLang, $wgContLang; $html = ''; $h2_header = Xml::tags('h2', null, wfMessage('lqt_contents_title')->parse()); // Header row $headerRow = ''; $headers = array('lqt_toc_thread_title', 'lqt_toc_thread_replycount', 'lqt_toc_thread_modified'); foreach ($headers as $msg) { $headerRow .= Xml::tags('th', null, wfMessage($msg)->parse()); } $headerRow = Xml::tags('tr', null, $headerRow); $headerRow = Xml::tags('thead', null, $headerRow); // Table body $rows = array(); foreach ($threads as $thread) { if ($thread->root() && !$thread->root()->getContent() && !LqtView::threadContainsRepliesWithContent($thread)) { continue; } $row = ''; $anchor = '#' . $this->anchorName($thread); $subject = Xml::tags('a', array('href' => $anchor), Threads::stripHTML($thread->formattedSubject())); $row .= Xml::tags('td', array('dir' => $wgContLang->getDir()), $subject); $row .= Xml::element('td', null, $wgLang->formatNum($thread->replyCount())); $timestamp = $wgLang->timeanddate($thread->modified(), true); $row .= Xml::element('td', null, $timestamp); $row = Xml::tags('tr', null, $row); $rows[] = $row; } $html .= $headerRow . "\n" . Xml::tags('tbody', null, implode("\n", $rows)); $html = $h2_header . Xml::tags('table', array('class' => 'lqt_toc'), $html); // wrap our output in a div for containment $html = Xml::tags('div', array('class' => 'lqt-contents-wrapper'), $html); return $html; }
function postDivClass($thread) { $origClass = parent::postDivClass($thread); if (in_array($thread->id(), $this->highlightThreads)) { return "{$origClass} lqt_post_new_message"; } return $origClass; }
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 trySubmit($data) { // Load data $newSubject = $data['subject']; $reason = $data['reason']; $this->mThread->split($newSubject, $reason); $link = LqtView::linkInContext($this->mThread); $this->getOutput()->addHTML($this->msg('lqt-split-success')->rawParams($link)->parse()); return true; }
function trySubmit($data) { // Load data $newSubject = $data['subject']; $reason = $data['reason']; $this->mThread->split($newSubject, $reason); $link = LqtView::linkInContext($this->mThread); global $wgOut; $wgOut->addHTML(wfMsgExt('lqt-split-success', array('parseinline', 'replaceafter'), $link)); return true; }
function trySubmit($data) { // Load data $srcThread = $this->mThread; $dstThread = $this->mDestThread; $reason = $data['reason']; $srcThread->moveToParent($dstThread, $reason); $srcLink = LqtView::linkInContext($srcThread); $dstLink = LqtView::linkInContext($dstThread); $this->getOutput()->addHTML($this->msg('lqt-merge-success')->rawParams($srcLink, $dstLink)->parse()); return true; }
function trySubmit($data) { // Load data $srcThread = $this->mThread; $dstThread = $this->mDestThread; $reason = $data['reason']; $srcThread->moveToParent($dstThread, $reason); $srcLink = LqtView::linkInContext($srcThread); $dstLink = LqtView::linkInContext($dstThread); global $wgOut; $wgOut->addHTML(wfMsgExt('lqt-merge-success', array('parseinline', 'replaceafter'), $srcLink, $dstLink)); return true; }
function getChangeDescription() { $args = array(); $revision = $this->mDisplayRevision; $change_type = $revision->getChangeType(); $post = $revision->getChangeObject(); $args[] = LqtView::linkInContextURL($post); $msg = $this->getMessageForChangeType($change_type); switch ($change_type) { case Threads::CHANGE_EDITED_SUBJECT: $args[] = $revision->prev()->getChangeObject()->subject(); $args[] = $revision->getChangeObject()->subject(); break; } $html = wfMsgExt($msg, 'parseinline', $args); if ($change_type == Threads::CHANGE_ROOT_BLANKED || $change_type == Threads::CHANGE_EDITED_ROOT) { $diff_link = $this->diffPermalink($post, wfMsgExt('diff', 'parseinline'), $this->mDisplayRevision); $html .= " [{$diff_link}]"; } return $html; }
/** * @param $thread Thread */ function threadSignature($thread) { global $wgLang; $signature = $thread->signature(); $signature = LqtView::parseSignature($signature); $signature = Xml::tags('span', array('class' => 'lqt-thread-user-signature'), $signature); $signature .= $wgLang->getDirMark(); $timestamp = $wgLang->timeanddate($thread->created(), true); $signature .= Xml::element('span', array('class' => 'lqt-thread-toolbar-timestamp'), $timestamp); Hooks::run('LiquidThreadsThreadSignature', array($thread, &$signature)); $signature = Xml::tags('div', array('class' => 'lqt-thread-signature'), $signature); return $signature; }
public function actionInlineEditForm($threads, $params) { $method = $talkpage = $operand = null; if (isset($params['method'])) { $method = $params['method']; } if (isset($params['talkpage'])) { $talkpage = $params['talkpage']; } //HJ : f**k 받는다. if (isset($params['f**k'])) { $f**k = $params['f**k']; } if ($talkpage) { $talkpage = new Article(Title::newFromText($talkpage), 0); } else { $talkpage = null; } if (count($threads)) { $operand = $threads[0]; $operand = $operand->id(); } //HJ : 중요!! 여기서 javascript에서 받은 f**k 인자를 물려받고, 이를 view로 넘겨줘서, html hidden으로 f**k 값을 부여해서 js로 읽을수 있게 하는겨 //$output = LqtView::getInlineEditForm( $talkpage, $method, $operand); $output = LqtView::getInlineEditForm($talkpage, $method, $operand, $f**k); $result = array('inlineeditform' => array('html' => $output)); /* FIXME $result['resources'] = LqtView::getJSandCSS(); $result['resources']['messages'] = LqtView::exportJSLocalisation(); */ $this->getResult()->addValue(null, 'threadaction', $result); }
public function setSignature($sig) { $sig = LqtView::signaturePST($sig, $this->author()); $this->signature = $sig; }
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; }
protected function renderThread($row, $params, &$entry) { // Set up OutputPage $out = $this->getOutput(); $oldOutputText = $out->getHTML(); $out->clearHTML(); // Setup $thread = Thread::newFromRow($row); $article = $thread->root(); if (!$article) { return; } $title = $article->getTitle(); $user = $this->getUser(); $request = $this->getRequest(); $view = new LqtView($out, $article, $title, $user, $request); // Parameters $view->threadNestingLevel = $params['renderlevel']; $renderpos = $params['renderthreadpos']; $rendercount = $params['renderthreadcount']; $options = array(); if (isset($params['rendermaxthreadcount'])) { $options['maxCount'] = $params['rendermaxthreadcount']; } if (isset($params['rendermaxdepth'])) { $options['maxDepth'] = $params['rendermaxdepth']; } if (isset($params['renderstartrepliesat'])) { $options['startAt'] = $params['renderstartrepliesat']; } $view->showThread($thread, $renderpos, $rendercount, $options); $result = $out->getHTML(); $out->clearHTML(); $out->addHTML($oldOutputText); $entry['content'] = $result; }
public function actionInlineEditForm($threads, $params) { $method = $talkpage = $operand = null; if (isset($params['method'])) { $method = $params['method']; } if (isset($params['talkpage'])) { $talkpage = $params['talkpage']; } if ($talkpage) { $talkpage = new Article(Title::newFromText($talkpage), 0); } else { $talkpage = null; } if (count($threads)) { $operand = $threads[0]; $operand = $operand->id(); } $output = LqtView::getInlineEditForm($talkpage, $method, $operand); $result = array('inlineeditform' => array('html' => $output)); /* FIXME $result['resources'] = LqtView::getJSandCSS(); $result['resources']['messages'] = LqtView::exportJSLocalisation(); */ $this->getResult()->addValue(null, 'threadaction', $result); }
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. }
/** * @param $article Article * @param $user User * @param $text * @param $summary * @param $minoredit * @param $watchthis * @param $sectionanchor * @param $flags * @param $revision * @param $status Status * @param $baseRevId * @return bool */ static function onArticleSaveComplete(&$article, &$user, $text, $summary, $minoredit, $watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId) { if (!$status->isGood()) { // Failed return true; } $title = $article->getTitle(); if ($title->getNamespace() != NS_LQT_THREAD) { // Not a thread return true; } if (!$baseRevId) { // New page return true; } $thread = Threads::withRoot($article); if (!$thread) { // No matching thread. return true; } LqtView::editMetadataUpdates(array('root' => $article, 'thread' => $thread, 'summary' => $summary, 'text' => $text)); return true; }
/** * Sends a Reflect email in response to a new bullet or response. * * @param $threadObj A reference to the relevant LQT Thread * @param $to A User object to whom the email will be sent * @param $catalystUser A User object who triggered this series of events * @param $msgType The name of the message type to be used in accessing localized msg * @param $bodyParams Additional parameters to be used in the sprintf of the body text * @param $subjectParams Additional parameters to be used in the sprintf of the subject text * */ private function sendMail($threadObj, $to, $catalystUser, $msgType, $bodyParams, $subjectParams) { global $wgPasswordSender, $wgLanguageCode; // TODO: create Reflect mailing preferences for individuals & respect them if (!$to) { return; } $from = new MailAddress($wgPasswordSender, 'WikiAdmin'); $permaLink = LqtView::linkInContextURL($threadObj); $params = array($to->getName(), $catalystUser->getName(), $threadObj->subjectWithoutIncrement(), $permaLink); $bodyParams = array_merge($params, $bodyParams); $subjectParams = array_merge($params, $subjectParams); $msg = wfMsgReal($msgType, $bodyParams, true, $wgLanguageCode, true); $subject = wfMsgReal($msgType . '-subject', $subjectParams, true, $wgLanguageCode, true); UserMailer::send(new MailAddress($to), $from, $subject, $msg); }
static function notifyUsersByMail($t, $watching_users, $timestamp, $type) { $messages = array(Threads::CHANGE_REPLY_CREATED => 'lqt-enotif-reply', Threads::CHANGE_NEW_THREAD => 'lqt-enotif-newthread'); $subjects = array(Threads::CHANGE_REPLY_CREATED => 'lqt-enotif-subject-reply', Threads::CHANGE_NEW_THREAD => 'lqt-enotif-subject-newthread'); if (!isset($messages[$type]) || !isset($subjects[$type])) { wfDebugLog('LiquidThreads', "Email notification failed: type {$type} unrecognised"); return; } else { $msgName = $messages[$type]; $subjectMsg = $subjects[$type]; } // Send email notification, fetching all the data in one go $dbr = wfGetDB(DB_SLAVE); $tables = array('user', 'tc_prop' => 'user_properties', 'l_prop' => 'user_properties'); $fields = array($dbr->tableName('user') . '.*', 'tc_prop.up_value AS timecorrection', 'l_prop.up_value as language'); $join_conds = array('tc_prop' => array('LEFT JOIN', array('tc_prop.up_user=user_id', 'tc_prop.up_property' => 'timecorrection')), 'l_prop' => array('LEFT JOIN', array('l_prop.up_user=user_id', 'l_prop.up_property' => 'language'))); $res = $dbr->select($tables, $fields, array('user_id' => $watching_users), __METHOD__, array(), $join_conds); // Set up one-time data. global $wgPasswordSender; $link_title = clone $t->getTitle(); $link_title->setFragment('#' . $t->getAnchorName()); $permalink = LqtView::linkInContextCanonicalURL($t); $talkPage = $t->getTitle()->getPrefixedText(); $from = new MailAddress($wgPasswordSender, 'WikiAdmin'); $threadSubject = $t->subject(); // Parse content and strip HTML of post content foreach ($res as $row) { $u = User::newFromRow($row); if ($row->language) { $langCode = $row->language; } else { global $wgLanguageCode; $langCode = $wgLanguageCode; } $lang = Language::factory($langCode); // Adjust with time correction $timeCorrection = $row->timecorrection; $adjustedTimestamp = $lang->userAdjust($timestamp, $timeCorrection); $date = $lang->date($adjustedTimestamp); $time = $lang->time($adjustedTimestamp); $params = array($u->getName(), $t->subjectWithoutIncrement(), $date, $time, $talkPage, $permalink, $t->root()->getContent(), $t->author()->getName()); // Get message in user's own language, bug 20645 $msg = wfMsgReal($msgName, $params, true, $langCode, true); $to = new MailAddress($u); $subject = wfMsgReal($subjectMsg, array($threadSubject), true, $langCode, true); UserMailer::send($to, $from, $subject, $msg); } }