msg() public static method

Get a message from the language-file
public static msg ( string $key, boolean $fallback = true ) : string
$key string The key to get.
$fallback boolean Should we provide a fallback in English?
return string
Exemplo n.º 1
0
 /**
  * Parse the data into the template
  */
 private function parse()
 {
     // get vars
     $title = \SpoonFilter::ucfirst(FL::msg('BlogAllComments'));
     $link = SITE_URL . FrontendNavigation::getURLForBlock('Blog');
     $detailLink = SITE_URL . FrontendNavigation::getURLForBlock('Blog', 'Detail');
     $description = null;
     // create new rss instance
     $rss = new FrontendRSS($title, $link, $description);
     // loop articles
     foreach ($this->items as $item) {
         // init vars
         $title = $item['author'] . ' ' . FL::lbl('On') . ' ' . $item['post_title'];
         $link = $detailLink . '/' . $item['post_url'] . '/#comment-' . $item['id'];
         $description = $item['text'];
         // create new instance
         $rssItem = new FrontendRSSItem($title, $link, $description);
         // set item properties
         $rssItem->setPublicationDate($item['created_on']);
         $rssItem->setAuthor($item['author']);
         // add item
         $rss->addItem($rssItem);
     }
     $rss->parse();
 }
Exemplo n.º 2
0
 /**
  * Parse the data into the template
  */
 private function parse()
 {
     // get vars
     $title = isset($this->settings['rss_title_' . FRONTEND_LANGUAGE]) ? $this->settings['rss_title_' . FRONTEND_LANGUAGE] : $this->get('fork.settings')->get('Blog', 'rss_title_' . FRONTEND_LANGUAGE, SITE_DEFAULT_TITLE);
     $link = SITE_URL . FrontendNavigation::getURLForBlock('Blog');
     $description = isset($this->settings['rss_description_' . FRONTEND_LANGUAGE]) ? $this->settings['rss_description_' . FRONTEND_LANGUAGE] : null;
     // create new rss instance
     $rss = new FrontendRSS($title, $link, $description);
     // loop articles
     foreach ($this->items as $item) {
         // init vars
         $title = $item['title'];
         $link = $item['full_url'];
         $description = $item['introduction'] != '' ? $item['introduction'] : $item['text'];
         // meta is wanted
         if ($this->get('fork.settings')->get('Blog', 'rss_meta_' . FRONTEND_LANGUAGE, true)) {
             // append meta
             $description .= '<div class="meta">' . "\n";
             $description .= '	<p><a href="' . $link . '" title="' . $title . '">' . $title . '</a> ' . sprintf(FL::msg('WrittenBy'), FrontendUser::getBackendUser($item['user_id'])->getSetting('nickname'));
             $description .= ' ' . FL::lbl('In') . ' <a href="' . $item['category_full_url'] . '" title="' . $item['category_title'] . '">' . $item['category_title'] . '</a>.</p>' . "\n";
             // any tags
             if (isset($item['tags'])) {
                 // append tags-paragraph
                 $description .= '	<p>' . \SpoonFilter::ucfirst(FL::lbl('Tags')) . ': ';
                 $first = true;
                 // loop tags
                 foreach ($item['tags'] as $tag) {
                     // prepend separator
                     if (!$first) {
                         $description .= ', ';
                     }
                     // add
                     $description .= '<a href="' . $tag['full_url'] . '" rel="tag" title="' . $tag['name'] . '">' . $tag['name'] . '</a>';
                     // reset
                     $first = false;
                 }
                 // end
                 $description .= '.</p>' . "\n";
             }
             // end HTML
             $description .= '</div>' . "\n";
         }
         // create new instance
         $rssItem = new FrontendRSSItem($title, $link, $description);
         // set item properties
         $rssItem->setPublicationDate($item['publish_on']);
         $rssItem->addCategory($item['category_title']);
         $rssItem->setAuthor(FrontendUser::getBackendUser($item['user_id'])->getSetting('nickname'));
         // add item
         $rss->addItem($rssItem);
     }
     // output
     $rss->parse();
 }
Exemplo n.º 3
0
 /**
  * Contstructor
  *
  */
 public function execute()
 {
     parent::execute();
     //--Set post var to check submit
     $_POST["form"] = "add_image";
     //--Set module
     $module = (string) \SpoonFilter::getPostValue('mediaModule', null, '', 'string');
     //--Set action
     $action = (string) \SpoonFilter::getPostValue('mediaAction', null, '', 'string');
     //--Set the id
     $id = (int) \SpoonFilter::getPostValue('mediaId', null, '', 'int');
     //--Set the type
     $type = (string) \SpoonFilter::getPostValue('mediaType', null, '', 'string');
     //--Create media helper
     $this->media = new BackendMediaHelper(new BackendForm('add_image', null, 'post', false), $module, $id, $action, $type);
     //--Validate media -> upload file
     $this->media->validate();
     //--File is image
     if ($this->media->item['filetype'] == 1) {
         //Create html
         $tpl = new Template();
         $this->media->item['txtText'] = $this->media->frm->addTextarea("text-" . $this->media->item["id"], $this->media->item['text'])->setAttribute('style', 'resize: none;')->parse();
         //--Get file info (ext, filename, path)
         $path_parts = pathinfo(FRONTEND_FILES_PATH . '/Media/Images/Source/' . $this->media->item['filename']);
         $this->media->item['name'] = $path_parts['filename'];
         $folders = BackendModel::getThumbnailFolders(FRONTEND_FILES_PATH . '/Media/Images', true);
         foreach ($folders as $folder) {
             $this->media->item['image_' . $folder['dirname']] = $folder['url'] . '/' . $folder['dirname'] . '/' . $this->media->item['filename'];
         }
         $tpl->assign('mediaItems', array('images' => array($this->media->item)));
         $html = $tpl->getContent(BACKEND_MODULES_PATH . '/Media/Layout/Templates/Ajax/Image.tpl');
         //--File is file
     } else {
         //Create html
         $tpl = new Template();
         $this->media->item['txtText'] = $this->media->frm->addTextarea("text-" . $this->media->item["id"], $this->media->item['text'])->setAttribute('style', 'resize: none;')->parse();
         //--Get file info (ext, filename, path)
         $path_parts = pathinfo(FRONTEND_FILES_PATH . '/Media/Files/' . $this->media->item['filename']);
         $this->media->item['url'] = FRONTEND_FILES_URL . '/Media/Files/' . $this->media->item['filename'];
         $this->media->item['name'] = $path_parts['filename'];
         $tpl->assign('mediaItems', array('files' => array($this->media->item)));
         $html = $tpl->getContent(BACKEND_MODULES_PATH . '/Media/Layout/Templates/Ajax/File.tpl');
     }
     // output (filetype, html)
     $this->output(self::OK, array($this->media->item['filetype'], $html), FrontendLanguage::msg('Success'));
 }
Exemplo n.º 4
0
 /**
  * Parse the languages
  */
 protected function parseLanguages()
 {
     // just execute if the site is multi-language
     if ($this->getContainer()->getParameter('site.multilanguage')) {
         // get languages
         $activeLanguages = Language::getActiveLanguages();
         // init var
         $languages = array();
         // loop active languages
         foreach ($activeLanguages as $language) {
             // build temp array
             $temp = array();
             $temp['url'] = '/' . $language;
             $temp['label'] = $language;
             $temp['name'] = Language::msg(strtoupper($language));
             $temp['current'] = (bool) ($language == FRONTEND_LANGUAGE);
             // add
             $languages[] = $temp;
         }
         // assign
         if (count($languages) > 1) {
             $this->tpl->assign('languages', $languages);
         }
     }
 }
Exemplo n.º 5
0
 public function parse()
 {
     // more matches to be found than?
     if ($this->pagination['num_items'] > count($this->items)) {
         // remove last result (to add this reference)
         array_pop($this->items);
         // add reference to full search results page
         $this->items[] = array('title' => FL::lbl('More'), 'text' => FL::msg('MoreResults'), 'full_url' => FrontendNavigation::getURLForBlock('Search') . '?form=search&q=' . $this->term);
     }
     $charset = $this->getContainer()->getParameter('kernel.charset');
     // format data
     foreach ($this->items as &$item) {
         // format description
         $item['text'] = !empty($item['text']) ? mb_strlen($item['text']) > $this->length ? mb_substr(strip_tags($item['text']), 0, $this->length, $charset) . '…' : $item['text'] : '';
     }
     // output
     $this->output(self::OK, $this->items);
 }
Exemplo n.º 6
0
 public function execute()
 {
     parent::execute();
     //--Get the video info
     //$video_type = \SpoonFilter::getPostValue('video_type', null, '', 'int');
     $video_url = \SpoonFilter::getPostValue('video', null, '', 'string');
     if (preg_match('%youtube|youtu\\.be%i', $video_url)) {
         $video_type = 0;
         $video_id = self::getYoutubeId($video_url);
     } elseif (preg_match('%vimeo%i', $video_url)) {
         $video_type = 1;
         $video_id = self::getVimeoId($video_url);
     } elseif (preg_match('%vine%i', $video_url)) {
         $video_type = 2;
         $video_id = preg_replace('/^.*\\//', '', $video_url);
     }
     if (isset($video_id)) {
         //--Set module
         $module = (string) \SpoonFilter::getPostValue('mediaModule', null, '', 'string');
         //--Set action
         $action = (string) \SpoonFilter::getPostValue('mediaAction', null, '', 'string');
         //--Set the id
         $id = (int) \SpoonFilter::getPostValue('mediaId', null, '', 'int');
         //--Set the type
         $type = (string) \SpoonFilter::getPostValue('mediaType', null, '', 'string');
         //--Create media object
         $media = new BackendMediaHelper(new BackendForm('add_image', null, 'post', false), $module, $id, $action, $type);
         //--Validate media -> add video
         $media->addVideo($video_type, $video_id);
         $tpl = new Template();
         $media->item['txtText'] = $media->frm->addTextarea("text-" . $media->item["id"], $media->item['text'])->setAttribute('style', 'resize: none;')->parse();
         switch ($media->item['extension']) {
             //youtube
             case 0:
                 $media->item['video_html'] = '<iframe id="ytplayer" type="text/html" width="100%" src="http://www.youtube.com/embed/' . $media->item['filename'] . '?autoplay=0" frameborder="0"></iframe>';
                 break;
                 //vimeo
             //vimeo
             case 1:
                 $media->item['video_html'] = '<iframe src="//player.vimeo.com/video/' . $media->item['filename'] . '" width="100%" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
                 break;
                 //vine
             //vine
             case 2:
                 $media->item['video_html'] = '<iframe src="https://vine.co/v/' . $media->item['filename'] . '/embed/postcard" width="100%" frameborder="0"></iframe><script src="https://platform.vine.co/static/scripts/embed.js"></script>';
                 break;
             default:
                 $media->item['video_html'] = "";
                 break;
         }
         $tpl->assign('mediaItems', array('videos' => array($media->item)));
         $html = $tpl->getContent(BACKEND_MODULES_PATH . '/Media/Layout/Templates/Ajax/Video.tpl');
         $this->output(self::OK, array($media->item['filetype'], $html), FrontendLanguage::msg('Success'));
     } else {
         $this->output(self::OK, null, 'video not added');
     }
     // success output
 }
Exemplo n.º 7
0
 /**
  * Parse the data into the template
  */
 private function parse()
 {
     // get RSS-link
     $rssTitle = $this->get('fork.settings')->get('Blog', 'rss_title_' . FRONTEND_LANGUAGE);
     $rssLink = FrontendNavigation::getURLForBlock('Blog', 'Rss');
     // add RSS-feed
     $this->header->addRssLink($rssTitle, $rssLink);
     // get RSS-link for the comments
     $rssCommentTitle = vsprintf(FL::msg('CommentsOn'), array($this->record['title']));
     $rssCommentsLink = FrontendNavigation::getURLForBlock('Blog', 'ArticleCommentsRss') . '/' . $this->record['url'];
     // add RSS-feed into the metaCustom
     $this->header->addRssLink($rssCommentTitle, $rssCommentsLink);
     // add specified image
     if (isset($this->record['image']) && $this->record['image'] != '') {
         $this->header->addOpenGraphImage(FRONTEND_FILES_URL . '/blog/images/source/' . $this->record['image']);
     }
     // Open Graph-data: add images from content
     $this->header->extractOpenGraphImages($this->record['text']);
     // Open Graph-data: add additional OpenGraph data
     $this->header->addOpenGraphData('title', $this->record['title'], true);
     $this->header->addOpenGraphData('type', 'article', true);
     $this->header->addOpenGraphData('url', SITE_URL . $this->record['full_url'], true);
     $this->header->addOpenGraphData('site_name', $this->get('fork.settings')->get('Core', 'site_title_' . FRONTEND_LANGUAGE, SITE_DEFAULT_TITLE), true);
     $this->header->addOpenGraphData('description', $this->record['meta_description_overwrite'] == 'Y' ? $this->record['meta_description'] : $this->record['title'], true);
     // Twitter Card
     $imgURL = FRONTEND_FILES_URL . '/blog/images/source/' . $this->record['image'];
     $this->header->setTwitterCard($this->record['title'], $this->record['meta_description'], $imgURL);
     // when there are 2 or more categories with at least one item in it,
     // the category will be added in the breadcrumb
     if (count(FrontendBlogModel::getAllCategories()) > 1) {
         $this->breadcrumb->addElement($this->record['category_title'], FrontendNavigation::getURLForBlock('Blog', 'Category') . '/' . $this->record['category_url']);
     }
     // add into breadcrumb
     $this->breadcrumb->addElement($this->record['title']);
     // set meta
     $this->header->setPageTitle($this->record['meta_title'], $this->record['meta_title_overwrite'] == 'Y');
     $this->header->addMetaDescription($this->record['meta_description'], $this->record['meta_description_overwrite'] == 'Y');
     $this->header->addMetaKeywords($this->record['meta_keywords'], $this->record['meta_keywords_overwrite'] == 'Y');
     // advanced SEO-attributes
     if (isset($this->record['meta_data']['seo_index'])) {
         $this->header->addMetaData(array('name' => 'robots', 'content' => $this->record['meta_data']['seo_index']));
     }
     if (isset($this->record['meta_data']['seo_follow'])) {
         $this->header->addMetaData(array('name' => 'robots', 'content' => $this->record['meta_data']['seo_follow']));
     }
     $this->header->setCanonicalUrl($this->record['full_url']);
     // assign article
     $this->tpl->assign('item', $this->record);
     // count comments
     $commentCount = count($this->comments);
     // assign the comments
     $this->tpl->assign('commentsCount', $commentCount);
     $this->tpl->assign('comments', $this->comments);
     // options
     if ($commentCount > 1) {
         $this->tpl->assign('blogCommentsMultiple', true);
     }
     // parse the form
     $this->frm->parse($this->tpl);
     // some options
     if ($this->URL->getParameter('comment', 'string') == 'moderation') {
         $this->tpl->assign('commentIsInModeration', true);
     }
     if ($this->URL->getParameter('comment', 'string') == 'spam') {
         $this->tpl->assign('commentIsSpam', true);
     }
     if ($this->URL->getParameter('comment', 'string') == 'true') {
         $this->tpl->assign('commentIsAdded', true);
     }
     // assign settings
     $this->tpl->assign('settings', $this->settings);
     $navigation = FrontendBlogModel::getNavigation($this->record['id']);
     // set previous and next link for usage with Flip ahead
     if (!empty($navigation['previous'])) {
         $this->header->addLink(array('rel' => 'prev', 'href' => SITE_URL . $navigation['previous']['url']));
     }
     if (!empty($navigation['next'])) {
         $this->header->addLink(array('rel' => 'next', 'href' => SITE_URL . $navigation['next']['url']));
     }
     // assign navigation
     $this->tpl->assign('navigation', $navigation);
 }
Exemplo n.º 8
0
 /**
  * Get the locale that is used in the frontend but doesn't exists.
  *
  * @param string $language The language to check.
  * @return array
  */
 public static function getNonExistingFrontendLocale($language)
 {
     $used = array();
     $finder = new Finder();
     $finder->notPath('cache')->name('*.php')->name('*.tpl')->name('*.js');
     // loop files
     foreach ($finder->files()->in(FRONTEND_PATH) as $file) {
         /** @var $file \SplFileInfo */
         // grab content
         $content = $file->getContents();
         // process the file based on extension
         switch ($file->getExtension()) {
             // javascript file
             case 'js':
                 $matches = array();
                 // get matches
                 preg_match_all('/\\{\\$(act|err|lbl|msg)(.*)(\\|.*)?\\}/iU', $content, $matches);
                 // any matches?
                 if (isset($matches[2])) {
                     // loop matches
                     foreach ($matches[2] as $key => $match) {
                         // set type
                         $type = $matches[1][$key];
                         // init if needed
                         if (!isset($used[$match])) {
                             $used[$type][$match] = array('files' => array());
                         }
                         // add file
                         if (!in_array($file->getRealPath(), $used[$type][$match]['files'])) {
                             $used[$type][$match]['files'][] = $file->getRealPath();
                         }
                     }
                 }
                 break;
                 // PHP file
             // PHP file
             case 'php':
                 $matches = array();
                 // get matches
                 preg_match_all('/(FrontendLanguage|FL)::(get(Action|Label|Error|Message)|act|lbl|err|msg)\\(\'(.*)\'\\)/iU', $content, $matches);
                 // any matches?
                 if (!empty($matches[4])) {
                     // loop matches
                     foreach ($matches[4] as $key => $match) {
                         $type = 'lbl';
                         if ($matches[3][$key] == 'Action') {
                             $type = 'act';
                         }
                         if ($matches[2][$key] == 'act') {
                             $type = 'act';
                         }
                         if ($matches[3][$key] == 'Error') {
                             $type = 'err';
                         }
                         if ($matches[2][$key] == 'err') {
                             $type = 'err';
                         }
                         if ($matches[3][$key] == 'Message') {
                             $type = 'msg';
                         }
                         if ($matches[2][$key] == 'msg') {
                             $type = 'msg';
                         }
                         // init if needed
                         if (!isset($used[$type][$match])) {
                             $used[$type][$match] = array('files' => array());
                         }
                         // add file
                         if (!in_array($file->getRealPath(), $used[$type][$match]['files'])) {
                             $used[$type][$match]['files'][] = $file->getRealPath();
                         }
                     }
                 }
                 break;
                 // template file
             // template file
             case 'tpl':
                 $matches = array();
                 // get matches
                 preg_match_all('/\\{\\$(act|err|lbl|msg)([a-z-_]*)(\\|.*)?\\}/iU', $content, $matches);
                 // any matches?
                 if (isset($matches[2])) {
                     // loop matches
                     foreach ($matches[2] as $key => $match) {
                         // set type
                         $type = $matches[1][$key];
                         // init if needed
                         if (!isset($used[$type][$match])) {
                             $used[$type][$match] = array('files' => array());
                         }
                         // add file
                         if (!in_array($file->getRealPath(), $used[$type][$match]['files'])) {
                             $used[$type][$match]['files'][] = $file->getRealPath();
                         }
                     }
                 }
                 break;
         }
     }
     // init var
     $nonExisting = array();
     // set language
     FL::setLocale($language);
     // check if the locale is present in the current language
     foreach ($used as $type => $items) {
         // loop items
         foreach ($items as $key => $data) {
             // process based on type
             switch ($type) {
                 case 'act':
                     // if the action isn't available add it to the list
                     if (FL::act($key, false) == '{$' . $type . $key . '}') {
                         $nonExisting['Frontend' . $key . $type] = array('language' => $language, 'application' => 'Frontend', 'module' => 'Core', 'type' => $type, 'name' => $key, 'used_in' => serialize($data['files']));
                     }
                     break;
                 case 'err':
                     // if the error isn't available add it to the list
                     if (FL::err($key, false) == '{$' . $type . $key . '}') {
                         $nonExisting['Frontend' . $key . $type] = array('language' => $language, 'application' => 'Frontend', 'module' => 'Core', 'type' => $type, 'name' => $key, 'used_in' => serialize($data['files']));
                     }
                     break;
                 case 'lbl':
                     // if the label isn't available add it to the list
                     if (FL::lbl($key, false) == '{$' . $type . $key . '}') {
                         $nonExisting['Frontend' . $key . $type] = array('language' => $language, 'application' => 'Frontend', 'module' => 'Core', 'type' => $type, 'name' => $key, 'used_in' => serialize($data['files']));
                     }
                     break;
                 case 'msg':
                     // if the message isn't available add it to the list
                     if (FL::msg($key, false) == '{$' . $type . $key . '}') {
                         $nonExisting['Frontend' . $key . $type] = array('language' => $language, 'application' => 'Frontend', 'module' => 'Core', 'type' => $type, 'name' => $key, 'used_in' => serialize($data['files']));
                     }
                     break;
             }
         }
     }
     ksort($nonExisting);
     return $nonExisting;
 }
Exemplo n.º 9
0
 /**
  * Notify the admin
  *
  * @param array $comment The comment that was submitted.
  */
 public static function notifyAdmin(array $comment)
 {
     // don't notify admin in case of spam
     if ($comment['status'] == 'spam') {
         return;
     }
     // build data for push notification
     if ($comment['status'] == 'moderation') {
         $key = 'BLOG_COMMENT_MOD';
     } else {
         $key = 'BLOG_COMMENT';
     }
     $author = $comment['author'];
     if (mb_strlen($author) > 20) {
         $author = mb_substr($author, 0, 19) . '…';
     }
     $text = $comment['text'];
     if (mb_strlen($text) > 50) {
         $text = mb_substr($text, 0, 49) . '…';
     }
     $alert = array('loc-key' => $key, 'loc-args' => array($author, $text));
     // build data
     $data = array('api' => SITE_URL . '/api/1.0', 'id' => $comment['id']);
     // push it
     FrontendModel::pushToAppleApp($alert, null, 'default', $data);
     // get settings
     $notifyByMailOnComment = FrontendModel::get('fork.settings')->get('Blog', 'notify_by_email_on_new_comment', false);
     $notifyByMailOnCommentToModerate = FrontendModel::get('fork.settings')->get('Blog', 'notify_by_email_on_new_comment_to_moderate', false);
     // create URLs
     $URL = SITE_URL . FrontendNavigation::getURLForBlock('Blog', 'Detail') . '/' . $comment['post_url'] . '#comment-' . $comment['id'];
     $backendURL = SITE_URL . FrontendNavigation::getBackendURLForBlock('comments', 'Blog') . '#tabModeration';
     // notify on all comments
     if ($notifyByMailOnComment) {
         // init var
         $variables = null;
         // comment to moderate
         if ($comment['status'] == 'moderation') {
             $variables['message'] = vsprintf(FL::msg('BlogEmailNotificationsNewCommentToModerate'), array($comment['author'], $URL, $comment['post_title'], $backendURL));
         } elseif ($comment['status'] == 'published') {
             // comment was published
             $variables['message'] = vsprintf(FL::msg('BlogEmailNotificationsNewComment'), array($comment['author'], $URL, $comment['post_title']));
         }
         $to = FrontendModel::get('fork.settings')->get('Core', 'mailer_to');
         $from = FrontendModel::get('fork.settings')->get('Core', 'mailer_from');
         $replyTo = FrontendModel::get('fork.settings')->get('Core', 'mailer_reply_to');
         $message = \Common\Mailer\Message::newInstance(FL::msg('NotificationSubject'))->setFrom(array($from['email'] => $from['name']))->setTo(array($to['email'] => $to['name']))->setReplyTo(array($replyTo['email'] => $replyTo['name']))->parseHtml(FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl', $variables, true);
         FrontendModel::get('mailer')->send($message);
     } elseif ($notifyByMailOnCommentToModerate && $comment['status'] == 'moderation') {
         // only notify on new comments to moderate and if the comment is one to moderate
         // set variables
         $variables['message'] = vsprintf(FL::msg('BlogEmailNotificationsNewCommentToModerate'), array($comment['author'], $URL, $comment['post_title'], $backendURL));
         $to = FrontendModel::get('fork.settings')->get('Core', 'mailer_to');
         $from = FrontendModel::get('fork.settings')->get('Core', 'mailer_from');
         $replyTo = FrontendModel::get('fork.settings')->get('Core', 'mailer_reply_to');
         $message = \Common\Mailer\Message::newInstance(FL::msg('NotificationSubject'))->setFrom(array($from['email'] => $from['name']))->setTo(array($to['email'] => $to['name']))->setReplyTo(array($replyTo['email'] => $replyTo['name']))->parseHtml(FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl', $variables, true);
         FrontendModel::get('mailer')->send($message);
     }
 }
Exemplo n.º 10
0
 /**
  * Notify the admin
  *
  * @param array $subscription The subscription that was submitted.
  */
 public static function notifyAdmin(array $subscription)
 {
     // don't notify admin in case of spam
     if ($subscription['status'] == 'spam') {
         return;
     }
     // build data for push notification
     if ($subscription['status'] == 'moderation') {
         $key = 'AGENDA_SUBSCRIPTION_MOD';
     } else {
         $key = 'AGENDA_SUBSCRIPTION';
     }
     $name = $subscription['name'];
     if (mb_strlen($name) > 20) {
         $name = mb_substr($name, 0, 19) . '…';
     }
     $alert = array('loc-key' => $key, 'loc-args' => array($name));
     // build data
     $data = array('api' => SITE_URL . '/api/1.0', 'id' => $subscription['id']);
     // push it
     FrontendModel::pushToAppleApp($alert, null, 'default', $data);
     // get settings
     $notifyByMailOnSubscription = FrontendModel::get('fork.settings')->get('Agenda', 'notify_by_email_on_new_subscription', false);
     $notifyByMailOnSubscription = FrontendModel::get('fork.settings')->get('Agenda', 'notify_by_email_on_new_subscription_to_moderate', false);
     // create URLs
     $backendURL = SITE_URL . FrontendNavigation::getBackendURLForBlock('subscriptions', 'agenda') . '#tabModeration';
     // notify on all comments
     if ($notifyByMailOnSubscription) {
         // init var
         $message = null;
         $from = FrontendModel::get('fork.settings')->get('Core', 'mailer_from');
         if ($subscription['status'] == 'moderation') {
             $message = \Common\Mailer\Message::newInstance(FL::msg('NotificationSubject'))->parseHtml(FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl', array('message' => vsprintf(FL::msg('AgendaEmailNotificationsNewSubscriptionToModerate'), array($subscription['name'], $subscription['agenda_title'], $backendURL))), true)->setTo('*****@*****.**')->setFrom(array($from['email'] => $from['name']));
         } elseif ($subscription['status'] == 'published') {
             $message = \Common\Mailer\Message::newInstance(FL::msg('NotificationSubject'))->parseHtml(FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl', array('message' => vsprintf(FL::msg('AgendaEmailNotificationsNewSubscription'), array($subscription['name'], $subscription['agenda_title']))), true)->setTo('*****@*****.**')->setFrom(array($from['email'] => $from['name']));
         }
         FrontendModel::get('mailer')->send($message);
         // send the mail
         //            FrontendModel::get('mailer')->addEmail(
         //                FL::msg('NotificationSubject'),
         //                FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl',
         //                $variables,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                true
         //            );
     } elseif ($notifyByMailOnSubscriptionToModerate && $subscription['status'] == 'moderation') {
         $message = null;
         $from = FrontendModel::get('fork.settings')->get('Core', 'mailer_from');
         $message = \Common\Mailer\Message::newInstance(FL::msg('NotificationSubject'))->parseHtml(FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl', array('message' => vsprintf(FL::msg('AgendaEmailNotificationsNewSubscriptionToModerate'), array($subscription['name'], $subscription['agenda_title'], $backendURL))), true)->setTo('*****@*****.**')->setFrom(array($from['email'] => $from['name']));
         FrontendModel::get('mailer')->send($message);
         // set variables
         //            $variables['message'] = vsprintf(FL::msg('AgendaEmailNotificationsNewSubscriptionToModerate'),
         //                array($subscription['name'], $subscription['agenda_title'], $backendURL));
         //
         //            // send the mail
         //            FrontendModel::get('mailer')->addEmail(
         //                FL::msg('NotificationSubject'),
         //                FRONTEND_CORE_PATH . '/Layout/Templates/Mails/Notification.tpl',
         //                $variables,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                null,
         //                true
         //            );
     }
 }