public function sendTopicNotifications(Topic $topic, $user) { if (is_numeric($user)) { $user = $this->em->getRepository('SymbbCoreUserBundle:User')->find($user); } $templateBundle = $this->siteManager->getTemplate("email"); $subject = $this->translator->trans('It was written a new answer to "%topic%"', array('%topic%' => $topic->getName()), 'symbb_email'); $sender = $this->siteManager->getSite()->getEmail(); if (!empty($sender)) { $recipient = $user->getEmail(); $message = \Swift_Message::newInstance()->setSubject($subject)->setFrom($sender)->setTo($recipient)->setBody($this->container->get('twig')->render($templateBundle . ':Email:topic_notify.' . $this->getLocale() . '.html.twig', array('topic' => $topic, 'user' => $user, 'site' => $this->siteManager->getSite())), 'text/html'); $this->mailer->send($message); } }
protected function addChildren($menu, $children, SiteManager $siteManager, $router) { foreach ($children as $child) { if ($child->getType() == 'symfony') { try { // generate directly to check if route realy exist $uri = $router->generate($child->getSymfonyRoute(), $child->getSymfonyRouteParams()); //$childMenu = $menu->addChild($child->getTitle(), array('route' => $child->getSymfonyRoute(), 'routeParameters' => $child->getSymfonyRouteParams())); $childMenu = $menu->addChild($child->getTitle(), array('uri' => $uri)); } catch (\Exception $e) { } } else { $uri = $child->getFixUrl(); $childMenu = $menu->addChild($child->getTitle(), array('uri' => $uri)); if (strpos($uri, "www.") !== false || strpos($uri, "http") === 0) { $domains = $siteManager->getSite()->getDomainArray(); $found = false; foreach ($domains as $domain) { $domain = str_replace(array('https://', 'http://', 'www.'), '', $domain); if (!empty($uri) && !empty($domain) && strpos($uri, $domain) !== false) { $found = true; break; } } if (!$found) { $childMenu->setLinkAttributes(array('target' => '_blank')); } } } if (isset($childMenu) && isset($child) && $child->hasChildren()) { $this->addChildren($childMenu, $child->getChildren(), $siteManager, $router); } } }
/** * @param $text * @param BBCode[] $bbcodes */ public function handleSpecialCasesByRef(&$text, $bbcodes) { foreach ($bbcodes as $bbcode) { if ($bbcode->getName() === "Image") { $text = preg_replace_callback('#\\[img\\](.+)\\[\\/img\\]#iUs', function ($matches) { $completeBBCode = $matches[0]; $newUrl = $url = $matches[1]; if (strpos($newUrl, 'http') !== 0) { $domain = $this->siteManager->getSite()->getMediaDomain(); if (substr($domain, 1, -1) === "/") { $domain = rtrim($domain, '/'); } $newUrl = $domain . $url; } return str_replace($url, $newUrl, $completeBBCode); }, $text); } } }
public function getSymbbSite() { return $this->siteManager->getSite(); }