public static function create() { if (self::$_bdApi_viewRenderer === null) { self::$_bdApi_viewRenderer = bdApi_Template_Simulation_ViewRenderer::create(); } return new bdApi_Template_Simulation_View(self::$_bdApi_viewRenderer, self::$_bdApi_viewRenderer->bdApi_getResponse()); }
protected function _preparePingDataManyNotification($pingDataMany) { /* @var $alertModel bdApi_XenForo_Model_Alert */ $alertModel = $this->getModelFromCache('XenForo_Model_Alert'); $alertIds = array(); foreach ($pingDataMany as $pingData) { $alertIds[] = $pingData['object_data']; } $alerts = $alertModel->bdApi_getAlertsByIds($alertIds); $userIds = array(); $alertsByUser = array(); foreach ($alerts as $alert) { $userIds[] = $alert['alerted_user_id']; if (!isset($alertsByUser[$alert['alerted_user_id']])) { $alertsByUser[$alert['alerted_user_id']] = array(); } $alertsByUser[$alert['alerted_user_id']][$alert['alert_id']] = $alert; } $viewingUsers = $this->_preparePingData_getViewingUsers($userIds); foreach ($alertsByUser as $userId => &$userAlerts) { if (!isset($viewingUsers[$userId])) { // user not found foreach (array_keys($userAlerts) as $userAlertId) { // delete the alert too unset($alerts[$userAlertId]); } continue; } $userAlerts = $alertModel->bdApi_prepareContentForAlerts($userAlerts, $viewingUsers[$userId]); bdApi_Template_Simulation_Template::$bdApi_visitor = $viewingUsers[$userId]; $userAlerts = bdApi_ViewApi_Helper_Alert::getTemplates(bdApi_Template_Simulation_View::create(), $userAlerts, $alertModel->bdApi_getAlertHandlers()); foreach (array_keys($userAlerts) as $userAlertId) { $alerts[$userAlertId] = $userAlerts[$userAlertId]; } } foreach (array_keys($pingDataMany) as $pingDataKey) { $pingDataRef =& $pingDataMany[$pingDataKey]; if (empty($pingDataRef['object_data'])) { // no alert is attached to object data continue; } if (!isset($alerts[$pingDataRef['object_data']])) { // alert not found unset($pingDataMany[$pingDataKey]); continue; } $alertRef =& $alerts[$pingDataRef['object_data']]; $pingDataRef['object_data'] = $alertModel->prepareApiDataForAlert($alertRef); if (isset($alertRef['template'])) { $pingDataRef['object_data']['notification_html'] = strval($alertRef['template']); } } return $pingDataMany; }