public function getAnonMessages()
 {
     if ($this->wg->User->isLoggedIn()) {
         // Don't return anything if this happens
         $this->skipRendering();
         return;
     }
     $msgs = SiteWideMessages::getAllAnonMessages($this->wg->User, false, false);
     $this->siteWideMessagesCount = count($msgs);
     $this->siteWideMessages = $msgs;
     $this->notificationType = NotificationsController::NOTIFICATION_SITEWIDE;
     $this->response->setCacheValidity(self::CACHE_VALIDITY_VARNISH, self::CACHE_VALIDITY_BROWSER);
 }
Ejemplo n.º 2
0
/**
 * Show notification (in Oasis)
 *
 * @author macbre
 */
function SiteWideMessagesAddNotifications(&$skim, &$tpl)
{
    global $wgOut, $wgUser, $wgExtensionsPath;
    wfProfileIn(__METHOD__);
    if (F::app()->checkSkin('oasis')) {
        // Add site wide notifications that haven't been dismissed
        if ($wgUser->isLoggedIn()) {
            $msgs = SiteWideMessages::getAllUserMessages($wgUser, false, false);
        } else {
            $msgs = SiteWideMessages::getAllAnonMessages($wgUser, false, false);
        }
        if (!empty($msgs)) {
            wfProfileIn(__METHOD__ . '::parse');
            foreach ($msgs as &$data) {
                $data['text'] = $wgOut->parse($data['text']);
            }
            wfProfileOut(__METHOD__ . '::parse');
            wfRunHooks('SiteWideMessagesNotification', array($msgs));
            $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgExtensionsPath}/wikia/SiteWideMessages/js/SiteWideMessages.tracking.js\"></script>");
        }
    }
    wfProfileOut(__METHOD__);
    return true;
}