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);
     }
 }
Exemplo n.º 2
0
 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;
 }