/** * Helper method which gets meta title from an WallMessage instance; used in WallHooksHelper::onDiffViewHeader() and WallHooksHelper::onPageHeaderEditPage() * @param Title $title * @param mixed $wmRef a variable which value will be created WallMessage instance * * @return String */ private static function getMetatitleFromTitleObject($title, &$wmRef = null) { wfProfileIn(__METHOD__); $wm = new WallMessage($title); if ($wm instanceof WallMessage) { $wm->load(); $metaTitle = $wm->getMetaTitle(); if (empty($metaTitle)) { // if wall message is a reply $wmParent = $wm->getTopParentObj(); if ($wmParent instanceof WallMessage) { $wmParent->load(); if (!is_null($wmRef)) { $wmRef = $wmParent; } wfProfileOut(__METHOD__); return $wmParent->getMetaTitle(); } } if (!is_null($wmRef)) { $wmRef = $wm; } wfProfileOut(__METHOD__); return $metaTitle; } wfProfileOut(__METHOD__); return ''; }
private function getFormatedHistoryData($history, $threadId = 0) { // VOLDEV-39: Store whether Wall is enabled $ns = $this->wg->EnableWallExt ? NS_USER_WALL : NS_USER_TALK; foreach ($history as $key => $value) { $type = intval($value['action']); if (!$this->isThreadLevel && !in_array($type, array(WH_NEW, WH_REMOVE, WH_RESTORE, WH_DELETE))) { unset($history[$key]); continue; } $title = $value['title']; $wm = new WallMessage($title); $user = $value['user']; $username = $user->getName(); $userTalk = Title::newFromText($username, $ns); $url = $userTalk->getFullUrl(); if ($user->isAnon()) { $history[$key]['displayname'] = Linker::linkKnown($userTalk, wfMessage('oasis-anon-user')->escaped()); $history[$key]['displayname'] .= ' ' . Linker::linkKnown($userTalk, Html::element('small', array(), $username), array('class' => 'username')); } else { $history[$key]['displayname'] = Linker::linkKnown($userTalk, $username); } $history[$key]['authorurl'] = $url; $history[$key]['username'] = $user->getName(); $history[$key]['userpage'] = $url; $history[$key]['type'] = $type; $history[$key]['usertimeago'] = $this->getContext()->getLanguage()->timeanddate($value['event_mw']); $history[$key]['reason'] = $value['reason']; $history[$key]['actions'] = array(); if ($this->isThreadLevel) { $history[$key]['isreply'] = $isReply = $value['is_reply']; $history[$key]['prefix'] = $isReply === '1' ? 'reply-' : 'thread-'; if (intval($value['page_id']) === $threadId) { // if the entry is about change in top message // hardcode the order number to 1 $history[$key]['msgid'] = 1; } else { $history[$key]['msgid'] = $wm->getOrderId(); } $wm->load(); $messagePageUrl = $wm->getMessagePageUrl(); $history[$key]['msgurl'] = $messagePageUrl; $msgUser = $wm->getUser(); $msgPage = Title::newFromText($msgUser->getName(), $ns); if (empty($msgPage)) { // SOC-586, SOC-578 : There is an edge case where $msgUser->getName can be empty // because of a rev_deleted flag on the revision loaded by ArticleComment via the // WallMessage $wm->load() above. ArticleComment overwrites the User objects mName // usertext with the first revision's usertext to preserve the thread author but in // rare occasions this revision can have its user hidden via a DELETED_USER flag. $history[$key]['msguserurl'] = ''; $history[$key]['msgusername'] = ''; } else { $history[$key]['msguserurl'] = $msgPage->getFullUrl(); $history[$key]['msgusername'] = $msgUser->getName(); } if ($type == WH_EDIT) { $rev = Revision::newFromTitle($title); // mech: fixing 20617 - revision_id is available only for new entries $query = array('diff' => 'prev', 'oldid' => $history[$key]['revision_id'] ? $history[$key]['revision_id'] : $title->getLatestRevID()); $history[$key]['actions'][] = array('href' => $rev->getTitle()->getLocalUrl($query), 'msg' => wfMessage('diff')->text()); } } else { $msgUrl = $wm->getMessagePageUrl(true); $history[$key]['msgurl'] = $msgUrl; $history[$key]['historyLink'] = Xml::element('a', array('href' => $msgUrl . '?action=history'), wfMessage('wall-history-action-thread-history')->text()); } if ($type == WH_REMOVE && !$wm->isAdminDelete() || $type == WH_DELETE && $wm->isAdminDelete()) { if ($wm->canRestore($this->getContext()->getUser())) { if ($this->isThreadLevel) { $restoreActionMsg = $isReply === '1' ? wfMessage('wall-history-action-restore-reply')->text() : wfMessage('wall-history-action-restore-thread')->text(); } else { $restoreActionMsg = wfMessage('wall-history-action-restore')->text(); } $history[$key]['actions'][] = array('class' => 'message-restore', 'data-id' => $value['page_id'], 'data-mode' => 'restore' . ($wm->canFastrestore($this->getContext()->getUser()) ? '-fast' : ''), 'href' => '#', 'msg' => $restoreActionMsg); } } $userid = $user->getId(); if ($user->isAnon()) { WallRailController::addAnon($userid, $user); } else { WallRailController::addUser($userid, $user); } } return $history; }
/** * @brief Filtring message wall data and spliting it to parents and childs * * @param Title $title title object instance * @param array $res a referance to array returned from recent changes * * @return array | boolean returns false if ArticleComment class does not exist * * @author Andrzej 'nAndy' Åukaszewski */ public function wikiActivityFilterMessageWall($title, &$res) { wfProfileIn(__METHOD__); $item = array(); $item['type'] = 'new'; $item['wall'] = true; $item['ns'] = $res['ns']; $item['timestamp'] = $res['timestamp']; $item['wall-comment'] = $res['rc_params']['intro']; $item['article-id'] = $title->getArticleID(); $wmessage = new WallMessage($title); $parent = $wmessage->getTopParentObj(); if (!in_array(true, array($wmessage->isAdminDelete(), $wmessage->isRemove()))) { $item['wall-title'] = $wmessage->getArticleTitle()->getPrefixedText(); $owner = $wmessage->getWallOwner(); $item['wall-owner'] = $owner->getName(); $item['wall-msg'] = ''; if (empty($parent)) { // parent $metaTitle = $wmessage->getMetaTitle(); if (!empty($metaTitle)) { $item['title'] = $metaTitle; } else { $wmessage->load(); $metaTitle = $wmessage->getMetaTitle(); $item['title'] = empty($metaTitle) ? wfMessage('wall-no-title')->escaped() : $metaTitle; } $item['url'] = $wmessage->getMessagePageUrl(); $res['title'] = 'message-wall-thread-#' . $title->getArticleID(); $item['wall-msg'] = wfMessage('wall-wiki-activity-on', $item['wall-title'], $item['wall-owner'])->parse(); } else { // child $parent->load(); if (!in_array(true, array($parent->isRemove(), $parent->isAdminDelete()))) { $title = wfMessage('wall-no-title')->escaped(); // in case metadata does not include title field if (isset($parent->mMetadata['title'])) { $title = $wmessage->getMetaTitle(); } $this->mapParentData($item, $parent, $title); $res['title'] = 'message-wall-thread-#' . $parent->getTitle()->getArticleID(); $item['wall-msg'] = wfMessage('wall-wiki-activity-on', $item['wall-title'], $item['wall-owner'])->parse(); } else { // message was removed or deleted $item = array(); } } } else { // message was removed or deleted $item = array(); } wfRunHooks('AfterWallWikiActivityFilter', array(&$item, $wmessage)); wfProfileOut(__METHOD__); return $item; }