예제 #1
0
파일: Wikia.php 프로젝트: Tjorriemorrie/app
 /**
  * Add variables to SkinTemplate
  */
 public static function onSkinTemplateOutputPageBeforeExec(SkinTemplate $skinTemplate, QuickTemplate $tpl)
 {
     wfProfileIn(__METHOD__);
     $out = $skinTemplate->getOutput();
     $title = $skinTemplate->getTitle();
     # quick hack for rt#15730; if you ever feel temptation to add 'elseif' ***CREATE A PROPER HOOK***
     if ($title instanceof Title && NS_CATEGORY == $title->getNamespace()) {
         // FIXME
         $tpl->set('pagetitle', preg_replace("/^{$title->getNsText()}:/", '', $out->getHTMLTitle()));
     }
     // Pass parameters to skin, see: Login friction project (Marooned)
     $tpl->set('thisurl', $title->getPrefixedURL());
     $tpl->set('thisquery', $skinTemplate->thisquery);
     wfProfileOut(__METHOD__);
     return true;
 }
예제 #2
0
 /**
  * Handler for PersonalUrls hook.
  * Add a "Notifications" item to the user toolbar ('personal URLs').
  * @see http://www.mediawiki.org/wiki/Manual:Hooks/PersonalUrls
  * @param &$personal_urls Array of URLs to append to.
  * @param &$title Title of page being visited.
  * @param SkinTemplate $sk
  * @return bool true in all cases
  */
 static function onPersonalUrls(&$personal_urls, &$title, $sk)
 {
     global $wgEchoNewMsgAlert;
     $user = $sk->getUser();
     if ($user->isAnon() || self::isEchoDisabled($user)) {
         return true;
     }
     // Add a "My notifications" item to personal URLs
     if ($user->getOption('echo-notify-show-link')) {
         $notificationCount = MWEchoNotifUser::newFromUser($user)->getNotificationCount();
         $text = EchoNotificationController::formatNotificationCount($notificationCount);
         $url = SpecialPage::getTitleFor('Notifications')->getLocalURL();
         if ($notificationCount == 0) {
             $linkClasses = array('mw-echo-notifications-badge');
         } else {
             $linkClasses = array('mw-echo-unread-notifications', 'mw-echo-notifications-badge');
         }
         $notificationsLink = array('href' => $url, 'text' => $text, 'active' => $url == $title->getLocalUrl(), 'class' => $linkClasses);
         $insertUrls = array('notifications' => $notificationsLink);
         $personal_urls = wfArrayInsertAfter($personal_urls, $insertUrls, 'userpage');
     }
     // If the user has new messages, display a talk page alert
     if ($wgEchoNewMsgAlert && $user->getOption('echo-show-alert') && $user->getNewtalk()) {
         $personal_urls['mytalk']['text'] = $sk->msg('echo-new-messages')->text();
         $personal_urls['mytalk']['class'] = array('mw-echo-alert');
         $sk->getOutput()->addModuleStyles('ext.echo.alert');
     }
     return true;
 }