public function onBeforeRender() { parent::onBeforeRender(); $limit = self::SECTION_ITEMS_LIMIT; $this->addComponent('itemsCmp', new NOTIFICATIONS_MCMP_ConsoleItems($limit)); $this->assign('loadMore', $this->service->findNotificationCount(OW::getUser()->getId()) > $limit); OW::getDocument()->addScript(OW::getPluginManager()->getPlugin('notifications')->getStaticUrl() . 'mobile.js'); $params = array('limit' => $limit); $script = 'var notificationsConsole = new OWM_NotificationsConsole(' . json_encode($params) . ');'; OW::getDocument()->addOnloadScript($script); }
public function ping(BASE_CLASS_ConsoleDataEvent $event) { $userId = OW::getUser()->getId(); $data = $event->getItemData(self::CONSOLE_ITEM_KEY); $newNotificationCount = $this->service->findNotificationCount($userId, false); $allNotificationCount = $this->service->findNotificationCount($userId); $data['counter'] = array('all' => $allNotificationCount, 'new' => $newNotificationCount); $event->setItemData(self::CONSOLE_ITEM_KEY, $data); }