public function testGetEmailFormat() { global $wgAllowHTMLEmail; $format = $wgAllowHTMLEmail; $user = User::newFromId(2); $notifUser = MWEchoNotifUser::newFromUser($user); $this->setMwGlobals('wgAllowHTMLEmail', true); $this->assertEquals($notifUser->getEmailFormat(), $user->getOption('echo-email-format')); $this->setMwGlobals('wgAllowHTMLEmail', false); $this->assertEquals($notifUser->getEmailFormat(), EchoHooks::EMAIL_FORMAT_PLAIN_TEXT); $this->setMwGlobals('wgAllowHTMLEmail', $format); }
/** * @param $row array */ public function createNotification($row) { $dbw = MWEchoDbFactory::getDB(DB_MASTER); $fname = __METHOD__; $dbw->onTransactionIdle(function () use($dbw, $row, $fname) { $dbw->begin($fname); // reset the base if this notification has a display hash if ($row['notification_bundle_display_hash']) { $dbw->update('echo_notification', array('notification_bundle_base' => 0), array('notification_user' => $row['notification_user'], 'notification_anon_ip' => !$row['notification_user'] ? $row['notification_anon_ip'] : '', 'notification_bundle_display_hash' => $row['notification_bundle_display_hash'], 'notification_bundle_base' => 1), $fname); } $row['notification_timestamp'] = $dbw->timestamp($row['notification_timestamp']); $dbw->insert('echo_notification', $row, $fname); $dbw->commit($fname); //XXCHANGEDXX - allow anons [sc|rs] $user = !$row['notification_user'] ? User::newFromName($row['notification_anon_ip'], false) : User::newFromId($row['notification_user']); MWEchoNotifUser::newFromUser($user)->resetNotificationCount(DB_MASTER); }); }
public function execute() { // To avoid API warning, register the parameter used to bust browser cache $this->getMain()->getVal('_'); $user = $this->getUser(); //XXCHANGEDXX - allow anons [sc|rs] // if ( $user->isAnon() ) { // $this->dieUsage( 'Login is required', 'login-required' ); // } $notifUser = MWEchoNotifUser::newFromUser($user); $params = $this->extractRequestParams(); $prop = $params['prop']; $result = array(); if (in_array('list', $prop)) { $result['list'] = self::getNotifications($user, $params['format'], $params['limit'] + 1, $params['continue']); // check if there is more elements than we request if (count($result['list']) > $params['limit']) { $lastItem = array_pop($result['list']); $result['continue'] = $lastItem['timestamp']['utcunix'] . '|' . $lastItem['id']; } else { $result['continue'] = null; } $this->getResult()->setIndexedTagName($result['list'], 'notification'); } if (in_array('count', $prop)) { $rawCount = $notifUser->getNotificationCount(); $result['rawcount'] = $rawCount; $result['count'] = EchoNotificationController::formatNotificationCount($rawCount); } if (in_array('index', $prop)) { $result['index'] = array(); foreach (array_keys($result['list']) as $key) { // Don't include the XML tag name ('_element' key) if ($key != '_element') { $result['index'][] = $key; } } $this->getResult()->setIndexedTagName($result['index'], 'id'); } $this->getResult()->setIndexedTagName($result, 'notification'); $this->getResult()->addValue('query', $this->getModuleName(), $result); }
/** * Create text version and/or html version for email notification * * @param $event EchoEvent * @param $user User * @param $type string deprecated * @return array */ protected function formatEmail($event, $user, $type) { // Email should be always sent in user language $this->language = $user->getOption('language'); // Email digest if ($this->distributionType === 'emaildigest') { return $this->formatEmailDigest($event, $user); } // Echo single email $emailSingle = new BsEchoEmailSingle($this, $event, $user); $textEmailFormatter = new BsEchoTextEmailFormatter($emailSingle); global $wgSitename; $content = array('subject' => "[{$wgSitename}] " . $this->formatFragment($this->email['subject'], $event, $user)->text(), 'body' => $textEmailFormatter->formatEmail()); $format = MWEchoNotifUser::newFromUser($user)->getEmailFormat(); if ($format == EchoHooks::EMAIL_FORMAT_HTML) { $htmlEmailFormatter = new EchoHTMLEmailFormatter($emailSingle); $outputFormat = $this->outputFormat; $this->setOutputFormat('htmlemail'); // Add single email html body if user prefers html format $content['body'] = array('text' => $content['body'], 'html' => $htmlEmailFormatter->formatEmail()); $this->setOutputFormat($outputFormat); } return $content; }
public function execute() { // To avoid API warning, register the parameter used to bust browser cache $this->getMain()->getVal('_'); $user = $this->getUser(); //XXCHANGEDXX - allow anons [sc|rs] // if ( $user->isAnon() ) { // $this->dieUsage( 'Login is required', 'login-required' ); // } $notifUser = MWEchoNotifUser::newFromUser($user); $params = $this->extractRequestParams(); // There is no need to trigger markRead if all notifications are read if ($notifUser->getNotificationCount() > 0) { if (count($params['list'])) { // Make sure there is a limit to the update $notifUser->markRead(array_slice($params['list'], 0, ApiBase::LIMIT_SML2)); } elseif ($params['all']) { $notifUser->markAllRead(); } } $rawCount = $notifUser->getNotificationCount(); $result = array('result' => 'success', 'rawcount' => $rawCount, 'count' => EchoNotificationController::formatNotificationCount($rawCount)); $this->getResult()->addValue('query', $this->getModuleName(), $result); }
/** * Prepares the user button. * @param QuickTemplate $tpl */ protected function prepareUserButton(QuickTemplate $tpl) { // Set user button to empty string by default $tpl->set('secondaryButton', ''); $notificationsTitle = ''; $countLabel = ''; $isZero = true; $user = $this->getUser(); $newtalks = $this->getNewtalks(); $currentTitle = $this->getTitle(); // If Echo is available, the user is logged in, and they are not already on the // notifications archive, show the notifications icon in the header. if ($this->useEcho() && $user->isLoggedIn()) { $notificationsTitle = SpecialPage::getTitleFor('Notifications'); $notificationsMsg = wfMessage('mobile-frontend-user-button-tooltip'); if ($currentTitle->getPrefixedText() !== $notificationsTitle->getPrefixedText()) { $count = MWEchoNotifUser::newFromUser($user)->getNotificationCount(); $isZero = $count === 0; $countLabel = EchoNotificationController::formatNotificationCount($count); } } elseif (!empty($newtalks)) { $notificationsTitle = SpecialPage::getTitleFor('Mytalk'); $notificationsMsg = wfMessage('mobile-frontend-user-newmessages')->text(); } if ($notificationsTitle) { $spanClass = $isZero ? 'zero notification-count' : 'notification-count'; $url = $notificationsTitle->getLocalURL(array('returnto' => $currentTitle->getPrefixedText())); $tpl->set('secondaryButton', $this->createSecondaryButton($notificationsMsg, $url, $countLabel, $spanClass)); } }
public function execute($par) { $this->setHeaders(); $out = $this->getOutput(); $out->setPageTitle($this->msg('echo-specialpage')->text()); $user = $this->getUser(); //XXCHANGEDXX - allow anons [sc|rs] // if ( $user->isAnon() ) { // $notificationsPageName = $this->getPageTitle()->getPrefixedDBkey(); // $returnTo = array( 'returnto' => $notificationsPageName ); // $signupTitle = SpecialPage::getTitleFor( 'UserLogin', 'signup' ); // $signupURL = $signupTitle->getFullURL( $returnTo ); // $loginTitle = SpecialPage::getTitleFor( 'UserLogin' ); // $loginURL = $loginTitle->getFullURL( $returnTo ); // $anonMsgHtml = $this->msg( 'echo-anon', $signupURL, $loginURL )->parse(); // $out->addHTML( Html::rawElement( 'span', array( 'class' => 'plainlinks' ), $anonMsgHtml ) ); // return; // } $out->addSubtitle($this->buildSubtitle()); // The continue parameter to pull current set of data from, this // would be used for browsers with javascript disabled $continue = $this->getRequest()->getVal('continue', null); // Pull the notifications $notif = ApiEchoNotifications::getNotifications($user, 'html', self::$displayNum + 1, $continue); // If there are no notifications, display a message saying so if (!$notif) { $out->addWikiMsg('echo-none'); return; } // Check if there is more data to load for next request if (count($notif) > self::$displayNum) { $lastItem = array_pop($notif); $nextContinue = $lastItem['timestamp']['utcunix'] . '|' . $lastItem['id']; } else { $nextContinue = null; } // Add the notifications to the page (interspersed with date headers) $dateHeader = ''; $notices = ''; $unread = array(); foreach ($notif as $row) { $class = 'mw-echo-notification'; if (!isset($row['read'])) { $class .= ' mw-echo-unread'; $unread[] = $row['id']; } if (!$row['*']) { continue; } // Output the date header if it has not been displayed if ($dateHeader !== $row['timestamp']['date']) { $dateHeader = $row['timestamp']['date']; $notices .= Html::rawElement('li', array('class' => 'mw-echo-date-section'), $dateHeader); } $notices .= Html::rawElement('li', array('class' => $class, 'data-notification-category' => $row['category'], 'data-notification-event' => $row['id'], 'data-notification-type' => $row['type']), $row['*']); } $html = Html::rawElement('ul', array('id' => 'mw-echo-special-container'), $notices); // Build the more link if ($nextContinue) { $html .= Html::element('a', array('href' => SpecialPage::getTitleFor('Notifications')->getLinkURL(array('continue' => $nextContinue)), 'id' => 'mw-echo-more'), $this->msg('moredotdotdot')->text()); } $out->addHTML($html); $out->addModules('ext.echo.special'); $out->addJsConfigVars(array('wgEchoDisplayNum' => self::$displayNum, 'wgEchoNextContinue' => $nextContinue, 'wgEchoDateHeader' => $dateHeader)); // For no-js support global $wgExtensionAssetsPath; $out->addExtensionStyle("{$wgExtensionAssetsPath}/Echo/modules/base/ext.echo.base.css"); // Mark items as read if ($unread) { MWEchoNotifUser::newFromUser($user)->markRead($unread); } }
/** * Outputs the entire contents of the (X)HTML page */ public function execute() { global $wgVectorUseIconWatch, $wgUser; // Build additional attributes for navigation urls $nav = $this->data['content_navigation']; if ($this->config->get('NewiWikiUseIconWatch')) { $mode = $this->getSkin()->getUser()->isWatched($this->getSkin()->getRelevantTitle()) ? 'unwatch' : 'watch'; if (isset($nav['actions'][$mode])) { $nav['views'][$mode] = $nav['actions'][$mode]; $nav['views'][$mode]['class'] = rtrim('icon ' . $nav['views'][$mode]['class'], ' '); $nav['views'][$mode]['primary'] = true; unset($nav['actions'][$mode]); } } $xmlID = ''; foreach ($nav as $section => $links) { foreach ($links as $key => $link) { if ($section == 'views' && !(isset($link['primary']) && $link['primary'])) { $link['class'] = rtrim('collapsible ' . $link['class'], ' '); } $xmlID = isset($link['id']) ? $link['id'] : 'ca-' . $xmlID; $nav[$section][$key]['attributes'] = ' id="' . Sanitizer::escapeId($xmlID) . '"'; if ($link['class']) { $nav[$section][$key]['attributes'] .= ' class="' . htmlspecialchars($link['class']) . '"'; unset($nav[$section][$key]['class']); } if (isset($link['tooltiponly']) && $link['tooltiponly']) { $nav[$section][$key]['key'] = Linker::tooltip($xmlID); } else { $nav[$section][$key]['key'] = Xml::expandAttributes(Linker::tooltipAndAccesskeyAttribs($xmlID)); } } } $this->data['namespace_urls'] = $nav['namespaces']; $this->data['view_urls'] = $nav['views']; $this->data['action_urls'] = $nav['actions']; $this->data['variant_urls'] = $nav['variants']; // Reverse horizontally rendered navigation elements if ($this->data['rtl']) { $this->data['view_urls'] = array_reverse($this->data['view_urls']); $this->data['namespace_urls'] = array_reverse($this->data['namespace_urls']); $this->data['personal_urls'] = array_reverse($this->data['personal_urls']); } $userLinks = $this->getPersonalTools(); $user = $wgUser->isLoggedIn() ? array_shift($userLinks) : array_pop($userLinks); $userLink = $user['links'][0]; // Output HTML Page $this->html('headelement'); ?> <div id="mw-page-base" class="noprint"></div> <div id="mw-head-base" class="noprint"></div> <div id="body_wrap" class="container-fluid"> <div class="top_navi"> <div class="navbar navbar-iWiki navbar-fixed-top"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle navbar-left collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span> <span class="glyphicon glyphicon-th-large" aria-hidden="true"></span> </button> <form class="navbar-form navbar-right navbar-small-form" action="<?php $this->text('wgScript'); ?> "> <input type='hidden' name="title" value="<?php $this->text('searchtitle'); ?> "/> <?php echo $this->makeSearchInput(array("id" => "searchInput", "class" => "form-control", "placeholder" => "검색어")); ?> </form> <button type="button" class="navbar-toggle navbar-toogle-right collapsed" data-toggle="collapse" <?php if ($wgUser->isLoggedIn()) { ?> data-target="#personalbar" <?php } else { ?> onclick="location.href='<?php echo $userLink['href']; ?> '"<?php } ?> aria-expanded="false" aria-controls="personalbar"> <span class="sr-only">Toggle navigation</span> <span class="glyphicon glyphicon-user" aria-hidden="true"></span> </button> <a class="navbar-brand" href="/wiki/FrontPage"><?php $this->msg('tagline'); ?> </a> </div> <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav navbar-left"> <?php $this->customBox('navigaion', $this->data['sidebar']['navigation']); ?> </ul> <?php if ($wgUser->isLoggedIn()) { $notificationCount = MWEchoNotifUser::newFromUser($this->getSkin()->getUser())->getNotificationCount(); ?> <button type="button" class="btn <?php if ($notificationCount) { echo "btn-danger"; } else { echo "btn-success"; } ?> loginbtn navbar-right" data-toggle="collapse" href="#personalbar" aria-expanded="false" aria-controls="personalbar"> <?php echo $wgUser->getName(); ?> <?php ?> </button> <?php } else { echo Linker::linkKnown(SpecialPage::getTitleFor('Userlogin'), wfMsg('login'), array('class' => 'navbar-right btn btn-warning loginbtn ')); } ?> </div> <div id="personalbar" class="navbar-personal collapse"> <ul class="nav nav-stacked navbar-personalbar"> <?php $this->renderNavigation('PERSONAL'); ?> </ul> </div> </div> </div> </div> <div class="row main_content"> <div class="col-xs-9"> <div id="content" class="mw-body" role="main"> <a id="top"></a> <div class="top_menu"> <ul> <?php $title = $this->getSkin()->getTitle(); if ($title->getNamespace() != NS_SPECIAL) { $companionTitle = $title->isTalkPage() ? $title->getSubjectPage() : $title->getTalkPage(); //echo $title->getArticleID(); //echo $this->getSkin()->getOldID(); //echo $this->getSkin()->getActionName(); ?> <li><?php echo Linker::linkKnown($title, '<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> 편집', array(), array('action' => 'edit', 'oldid' => $this->getSkin()->getRevisionId())); ?> </li> <li><?php echo Linker::linkKnown($title, '<span class="glyphicon glyphicon-menu-right" aria-hidden="true"></span> 새문단', array(), array('action' => 'edit', 'section' => 'new')); ?> </li> <li><?php echo Linker::linkKnown($title, '<span class="glyphicon glyphicon-time" aria-hidden="true"></span> 기록', array(), array('action' => 'history')); ?> </li> <?php if ($companionTitle) { if ($title->getNamespace() == NS_TALK || $title->getNamespace() == NS_PROJECT_TALK || $title->getNamespace() == NS_FILE_TALK || $title->getNamespace() == NS_TEMPLATE_TALK) { ?> <li><?php echo Linker::linkKnown($companionTitle, '<span class="glyphicon glyphicon-arrow-left" aria-hidden="true"></span> 본문'); ?> </li> <?php } else { ?> <li><?php echo Linker::linkKnown($companionTitle, '<span class="glyphicon glyphicon-fire" aria-hidden="true"></span> 토론'); ?> </li> <?php } } ?> <li><?php echo Linker::linkKnown(SpecialPage::getTitleFor('WhatLinksHere', $title), '<span class="glyphicon glyphicon-pushpin" aria-hidden="true"></span> 역링크'); ?> </li> <?php $mode = $this->getSkin()->getUser()->isWatched($this->getSkin()->getRelevantTitle()) ? 'unwatch' : 'watch'; if ($mode != 'watch') { $watchname = '주시해제'; $emptystar = ''; } else { $watchname = '주시'; $emptystar = '-empty'; } if ($title->getNamespace() != NS_SPECIAL) { ?> <li><?php echo Linker::linkKnown($title, '<span class="glyphicon glyphicon-star' . $emptystar . '" aria-hidden="true"></span> ' . $watchname, array(), array('action' => $mode)); ?> </li> <?php } ?> <li><?php echo Linker::linkKnown(SpecialPage::getTitleFor('Movepage', $title), '<span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span> 옮기기'); ?> </li> <?php if ($title->quickUserCan('protect', $user)) { ?> <li><?php echo Linker::linkKnown($title, '<span class="glyphicon glyphicon-lock" aria-hidden="true"></span> 보호', array(), array('action' => 'protect')); ?> </li> <?php } ?> <?php if ($title->quickUserCan('delete', $user)) { ?> <li><?php echo Linker::linkKnown($title, '<span class="glyphicon glyphicon-trash" aria-hidden="true"></span> 삭제', array(), array('action' => 'delete')); ?> </li> <?php } } ?> </ul> </div> <div id="mw-js-message" style="display:none;"<?php $this->html('userlangattributes'); ?> ></div> <?php if ($this->data['sitenotice']) { ?> <div id="alertmsg" class="alert alert-info siteNotice alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button> <?php $this->html('sitenotice'); ?> </div> <?php } ?> <!-- Footer ad --> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <ins class="adsbygoogle" style="display:block; min-width:320px; width:100%; height:90px;margin-top:15px;" data-ad-client="ca-pub-2664061841343191" data-ad-slot="6502738263" data-ad-format="auto"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <h1 id="firstHeading" class="firstHeading" lang="<?php $this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode(); $this->text('pageLanguage'); ?> "><span dir="auto"><?php $this->html('title'); ?> </span></h1> <?php $this->html('prebodyhtml'); ?> <div id="bodyContent"> <?php if ($this->data['isarticle']) { ?> <div id="siteSub"><?php $this->msg('tagline'); ?> </div> <?php } ?> <div id="contentSub"<?php $this->html('userlangattributes'); ?> ><?php $this->html('subtitle'); ?> </div> <?php if ($this->data['undelete']) { ?> <div id="contentSub2"><?php $this->html('undelete'); ?> </div> <?php } ?> <?php if ($this->data['newtalk']) { ?> <div class="usermessage"><?php $this->html('newtalk'); ?> </div> <?php } ?> <div id="jump-to-nav" class="mw-jump"> <?php $this->msg('jumpto'); ?> <a href="#mw-navigation"><?php $this->msg('jumptonavigation'); ?> </a><?php $this->msg('comma-separator'); ?> <a href="#p-search"><?php $this->msg('jumptosearch'); ?> </a> </div> <?php $this->html('bodycontent'); ?> <?php if ($this->data['printfooter']) { ?> <div class="printfooter"> <?php $this->html('printfooter'); ?> </div> <?php } ?> <?php if ($this->data['catlinks']) { ?> <?php $this->html('catlinks'); ?> <?php } ?> <?php if ($this->data['dataAfterContent']) { ?> <?php $this->html('dataAfterContent'); ?> <?php } ?> <div class="visualClear"></div> <?php $this->html('debughtml'); ?> </div> </div> <div id="footer" role="contentinfo"<?php $this->html('userlangattributes'); ?> > <?php foreach ($this->getFooterLinks() as $category => $links) { ?> <ul id="footer-<?php echo $category; ?> "> <?php foreach ($links as $link) { ?> <li id="footer-<?php echo $category; ?> -<?php echo $link; ?> "><?php $this->html($link); ?> </li> <?php } ?> </ul> <?php } ?> <?php $footericons = $this->getFooterIcons("icononly"); if (count($footericons) > 0) { ?> <ul id="footer-icons"> <?php foreach ($footericons as $blockName => $footerIcons) { ?> <li id="footer-<?php echo htmlspecialchars($blockName); ?> ico"> <?php foreach ($footerIcons as $icon) { ?> <?php echo $this->getSkin()->makeFooterIcon($icon); ?> <?php } ?> </li> <?php } ?> </ul> <?php } ?> <div style="clear:both"></div> </div> </div> <div class="col-xs-3"> <div class="right_col"> <form class="right_search" action="<?php $this->text('wgScript'); ?> "> <input type='hidden' name="title" value="<?php $this->text('searchtitle'); ?> "/> <?php echo $this->makeSearchInput(array("id" => "searchInput", "class" => "form-control", "placeholder" => "검색어")); ?> </form> <div id="right_toc"> </div> <div id = "recent-list-div"> <div id="recent-title"> <h2>최근 바뀜 <span class="recent-more"> <span class="mw-editsection-bracket">[</span> <a href="/wiki/특수:최근바뀜" title="최근바뀜문서">more</a> <span class="mw-editsection-bracket">]</span> </span> </h2> </div> <ul id = "recent-list"> </ul> </div> <!-- sidebar ad --> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- 사이드바 --> <ins class="adsbygoogle" style="display:block;max-width:230px;margin-top:10px;margin-left:10px;height:100%;max-height:600px;" data-ad-client="ca-pub-2664061841343191" data-ad-slot="2751059465" data-ad-format="auto"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> </div> </div> <div class="top_scroll"> <a href="#" class="top_s_btn"> <span class="glyphicon glyphicon-open"></span> </a> </div> <?php $this->printTrail(); ?> </body> </html> <?php }
function getHeaderMenu($menu) { global $wgLanguageCode, $wgTitle, $wgUser, $wgForumLink; $html = ''; $menu_css = 'menu'; $sk = $this->getSkin(); $isLoggedIn = $wgUser->getID() > 0; switch ($menu) { case 'edit': $html = "<a href='" . $wgTitle->getLocalURL($sk->editUrlOptions()) . "'>" . wfMessage('edit-this-article')->text() . "</a>"; if (!$isLoggedIn) { break; } $html .= Linker::link(SpecialPage::getTitleFor('Importvideo', $wgTitle->getText()), wfMessage('importvideo')->text()); if ($wgLanguageCode == 'en') { $html .= Linker::link(Title::makeTitle(NS_SPECIAL, "RelatedArticle"), wfMessage('manage_related_articles')->text(), array(), array("target" => $wgTitle->getPrefixedURL())) . Linker::link(SpecialPage::getTitleFor("Articlestats", $wgTitle->getText()), wfMessage('articlestats')->text()); } $html .= "<a href='" . Title::makeTitle(NS_SPECIAL, "Whatlinkshere")->getLocalUrl() . "/" . $wgTitle->getPrefixedURL() . "'>" . wfMessage('whatlinkshere')->text() . "</a>"; break; case 'profile': if ($isLoggedIn) { $html = Linker::link(Title::makeTitle(NS_SPECIAL, 'Mytalk', 'post'), wfMessage('mytalkpage')->text()) . Linker::link(Title::makeTitle(NS_SPECIAL, 'Mypage'), wfMessage('myauthorpage')->text()) . Linker::link(Title::makeTitle(NS_SPECIAL, 'Notifications'), wfMessage('mynotifications')->text()) . Linker::link(Title::makeTitle(NS_SPECIAL, 'Watchlist'), wfMessage('watchlist')->text()) . Linker::link(Title::makeTitle(NS_SPECIAL, 'Drafts'), wfMessage('mydrafts')->text()) . Linker::link(SpecialPage::getTitleFor('Mypages', 'Contributions'), wfMessage('mycontris')->text()) . Linker::link(SpecialPage::getTitleFor('Mypages', 'Fanmail'), wfMessage('myfanmail')->text()) . Linker::link(Title::makeTitle(NS_SPECIAL, 'Preferences'), wfMessage('mypreferences')->text()) . Linker::link(Title::makeTitle(NS_SPECIAL, 'Userlogout'), wfMessage('logout')->text()); } else { $html = UserLoginBox::getLogin(true); $menu_css = 'menu_login'; } break; case 'explore': $dashboardPage = $wgLanguageCode == 'en' ? Title::makeTitle(NS_SPECIAL, "CommunityDashboard") : Title::makeTitle(NS_PROJECT, wfMessage("community")->text()); $html = Linker::link($dashboardPage, wfMessage('community_dashboard')->text()); if ($isLoggedIn) { $html .= "<a href='{$wgForumLink}'>" . wfMessage('forums')->text() . "</a>"; } $html .= "<a href='/Special:Randomizer'>" . wfMessage('randompage')->text() . "</a>"; if (!$isLoggedIn) { $html .= Linker::link(Title::makeTitle(NS_PROJECT, "About-wikiHow"), wfMessage('navmenu_aboutus')->text()); } $html .= Linker::link(Title::makeTitle(NS_SPECIAL, "Categorylisting"), wfMessage('navmenu_categories')->text()) . Linker::link(Title::makeTitle(NS_SPECIAL, "Recentchanges"), wfMessage('recentchanges')->text()); if ($isLoggedIn) { $html .= Linker::link(Title::makeTitle(NS_SPECIAL, "Specialpages"), wfMessage('specialpages')->text()); $html .= Linker::link(Title::makeTitle(NS_PROJECT_TALK, 'Help-Team'), wfMessage('help')->text()); } break; case 'help': $html = Linker::link(Title::makeTitle(NS_SPECIAL, "CreatePage"), wfMessage('Write-an-article')->text()); if ($wgLanguageCode == 'en') { $html .= Linker::link(Title::makeTitle(NS_SPECIAL, "RequestTopic"), wfMessage('requesttopic')->text()) . Linker::link(Title::makeTitle(NS_SPECIAL, "ListRequestedTopics"), wfMessage('listrequtestedtopics')->text()); } if ($isLoggedIn) { if ($wgLanguageCode == 'en') { $html .= Linker::link(Title::makeTitle(NS_SPECIAL, "TipsPatrol"), wfMessage('navmenu_tipspatrol')->text()); } $html .= Linker::link(Title::makeTitle(NS_SPECIAL, "RCPatrol"), wfMessage('PatrolRC')->text()); if ($wgLanguageCode == 'en') { $html .= Linker::link(Title::makeTitle(NS_SPECIAL, "Categorizer"), wfMessage('categorize_articles')->text()); } } if ($wgLanguageCode == 'en') { $html .= "<a href='/Special:CommunityDashboard'>" . wfMessage('more-ideas')->text() . "</a>"; } else { $html .= Linker::link(Title::makeTitle(NS_SPECIAL, "Uncategorizedpages"), wfMessage('categorize_articles')->text()) . "<a href='/Contribute-to-wikiHow'>" . wfMessage('more-ideas')->text() . "</a>"; } break; case 'messages': if (class_exists('EchoEvent') && $wgUser->hasCookies()) { $maxNotesShown = 5; $notif = ApiEchoNotifications::getNotifications($wgUser, 'html', $maxNotesShown); if ($notif) { //show those notifications foreach ($notif as $note) { $this_note = $note['*']; //unread? if (!isset($note['read'])) { $this_note = str_replace('mw-echo-state', 'mw-echo-state mw-echo-unread', $this_note); } $html .= $this_note; } //get the unread count $notifUser = MWEchoNotifUser::newFromUser($wgUser); $this->notifications_count = $notifUser->getNotificationCount(); if ($this->notifications_count > $maxNotesShown) { $unshown = '<br /><a href="/Special:Notifications">(' . ($this->notifications_count - $maxNotesShown) . ' unread)</a>'; } else { $unshown = ''; } //add view all link $html .= '<div class="menu_message_morelink"><a href="/Special:Notifications">' . wfMessage('more-notifications-link')->text() . '</a>' . $unshown . '</div>'; } else { //no notifications $html .= '<div class="menu_message_morelink">' . wfMessage('no-notifications')->parse() . '</div>'; } } else { //old school $ret = Notifications::loadNotifications(); if (is_array($ret)) { list($html, $this->notifications_count) = $ret; } } $menu_css = 'menu_messages'; break; } if ($html) { $html = '<div class="' . $menu_css . '">' . $html . '</div>'; } return $html; }
/** * Handler for EchoCreateNotificationComplete hook, this will allow some * extra stuff to be done upon creating a new notification * @param $notif EchoNotification * @return bool true in all cases */ public static function onEchoCreateNotificationComplete(EchoNotification $notif) { if ($notif->getEvent() && $notif->getUser()) { // Extra stuff for talk page notification if ($notif->getEvent()->getType() === 'edit-user-talk') { $notifUser = MWEchoNotifUser::newFromUser($notif->getUser()); $notifUser->flagCacheWithNewTalkNotification(); } } return true; }
/** * Send the batch email */ public function sendEmail() { global $wgNotificationSender, $wgNotificationSenderName, $wgNotificationReplyName; // @Todo - replace them with the CONSTANT in 33810 once it is merged if ($this->mUser->getOption('echo-email-frequency') == 7) { $frequency = 'weekly'; $emailDeliveryMode = 'weekly_digest'; } else { $frequency = 'daily'; $emailDeliveryMode = 'daily_digest'; } // Echo digest email mode $emailDigest = new EchoEmailDigest($this->mUser, $this->content, $frequency); $textEmailFormatter = new EchoTextEmailFormatter($emailDigest); $body = $textEmailFormatter->formatEmail(); $format = MWEchoNotifUser::newFromUser($this->mUser)->getEmailFormat(); if ($format == EchoHooks::EMAIL_FORMAT_HTML) { $htmlEmailFormatter = new EchoHTMLEmailFormatter($emailDigest); $body = array('text' => $body, 'html' => $htmlEmailFormatter->formatEmail()); } // email subject if ($this->count > self::$displaySize) { $count = wfMessage('echo-notification-count')->inLanguage($this->mUser->getOption('language'))->params(self::$displaySize)->text(); } else { $count = $this->count; } // Give grep a chance to find the usages: // echo-email-batch-subject-daily, echo-email-batch-subject-weekly $subject = wfMessage('echo-email-batch-subject-' . $frequency)->inLanguage($this->mUser->getOption('language'))->params($count, $this->count)->text(); $toAddress = new MailAddress($this->mUser); $fromAddress = new MailAddress($wgNotificationSender, $wgNotificationSenderName); $replyAddress = new MailAddress($wgNotificationSender, $wgNotificationReplyName); // @Todo Push the email to job queue or just send it out directly? UserMailer::send($toAddress, $fromAddress, $subject, $body, $replyAddress); MWEchoEventLogging::logSchemaEchoMail($this->mUser, $emailDeliveryMode); }
/** * Format text and/or html verion of email digest fragment for this event * @param $event EchoEvent * @param $user User * @return array */ protected function formatEmailDigest($event, $user) { if ($this->bundleData['use-bundle'] && $this->email['batch-bundle-body']) { $key = $this->email['batch-bundle-body']; } else { $key = $this->email['batch-body']; } // Email digest text body $content = array('batch-body' => $this->formatFragment($key, $event, $user)->text()); $format = MWEchoNotifUser::newFromUser($user)->getEmailFormat(); if ($format == EchoHooks::EMAIL_FORMAT_HTML) { $outputFormat = $this->outputFormat; $this->setOutputFormat('htmlemail'); $content['batch-body-html'] = $this->formatFragment($key, $event, $user)->parse(); $content['icon'] = $this->icon; $this->setOutputFormat($outputFormat); } return $content; }