/** * Parse the data into the template */ private function parse() { // get vars $title = vsprintf(FL::msg('CommentsOn'), array($this->record['title'])); $link = SITE_URL . FrontendNavigation::getURLForBlock('blog', 'article_comments_rss') . '/' . $this->record['url']; $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') . ' ' . $this->record['title']; $link = $detailLink . '/' . $this->record['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(); }
/** * Parse the data into the template * * @return void */ private function parse() { // get vars $title = isset($this->settings['rss_title_' . FRONTEND_LANGUAGE]) ? $this->settings['rss_title_' . FRONTEND_LANGUAGE] : FrontendModel::getModuleSetting('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 (FrontendModel::getModuleSetting('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>' . 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(); }
/** * Execute the action */ public function execute() { parent::execute(); $generalSettings = BackendModel::getModuleSettings(); $generalSettings = $generalSettings['location']; // get parameters $itemId = SpoonFilter::getPostValue('id', null, null, 'int'); $zoomLevel = trim(SpoonFilter::getPostValue('zoom', null, 'auto')); $mapType = strtoupper(trim(SpoonFilter::getPostValue('type', array('roadmap', 'satelitte', 'hybrid', 'terrain'), 'roadmap'))); $centerLat = SpoonFilter::getPostValue('centerLat', null, 1, 'float'); $centerlng = SpoonFilter::getPostValue('centerLng', null, 1, 'float'); $height = SpoonFilter::getPostValue('height', null, $generalSettings['height'], 'int'); $width = SpoonFilter::getPostValue('width', null, $generalSettings['width'], 'int'); $showLink = SpoonFilter::getPostValue('link', array('true', 'false'), 'false', 'string'); $showDirections = SpoonFilter::getPostValue('directions', array('true', 'false'), 'false', 'string'); $showOverview = SpoonFilter::getPostValue('showOverview', array('true', 'false'), 'true', 'string'); // reformat $center = array('lat' => $centerLat, 'lng' => $centerlng); $showLink = $showLink == 'true'; $showDirections = $showDirections == 'true'; $showOverview = $showOverview == 'true'; // standard dimensions if ($width > 800) { $width = 800; } if ($width < 300) { $width = $generalSettings['width']; } if ($height < 150) { $height = $generalSettings['height']; } // no id given, this means we should update the main map BackendLocationModel::setMapSetting($itemId, 'zoom_level', (string) $zoomLevel); BackendLocationModel::setMapSetting($itemId, 'map_type', (string) $mapType); BackendLocationModel::setMapSetting($itemId, 'center', (array) $center); BackendLocationModel::setMapSetting($itemId, 'height', (int) $height); BackendLocationModel::setMapSetting($itemId, 'width', (int) $width); BackendLocationModel::setMapSetting($itemId, 'directions', $showDirections); BackendLocationModel::setMapSetting($itemId, 'full_url', $showLink); $item = array('id' => $itemId, 'language' => BL::getWorkingLanguage(), 'show_overview' => $showOverview ? 'Y' : 'N'); BackendLocationModel::update($item); // output $this->output(self::OK, null, FL::msg('Success')); }
/** * Parse the data into the template */ private function parse() { // get RSS-link $rssLink = FrontendModel::getModuleSetting('blog', 'feedburner_url_' . FRONTEND_LANGUAGE); if ($rssLink == '') { $rssLink = FrontendNavigation::getURLForBlock('blog', 'rss'); } // add RSS-feed $this->header->addLink(array('rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => FrontendModel::getModuleSetting('blog', 'rss_title_' . FRONTEND_LANGUAGE), 'href' => $rssLink), true); // get RSS-link for the comments $rssCommentsLink = FrontendNavigation::getURLForBlock('blog', 'article_comments_rss') . '/' . $this->record['url']; // add RSS-feed into the metaCustom $this->header->addLink(array('rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => vsprintf(FL::msg('CommentsOn'), array($this->record['title'])), 'href' => $rssCommentsLink), true); // build Facebook Open Graph-data if (FrontendModel::getModuleSetting('core', 'facebook_admin_ids', null) !== null || FrontendModel::getModuleSetting('core', 'facebook_app_id', null) !== null) { // add specified image if (isset($this->record['image']) && $this->record['image'] != '') { $this->header->addOpenGraphImage(FRONTEND_FILES_URL . '/blog/images/source/' . $this->record['image']); } // add images from content $this->header->extractOpenGraphImages($this->record['text']); // add additional OpenGraph data $this->header->addOpenGraphData('title', $this->record['title'], true); $this->header->addOpenGraphData('type', 'article', true); $this->header->addOpenGraphData('url', SITE_URL . FrontendNavigation::getURLForBlock('blog', 'detail') . '/' . $this->record['url'], true); $this->header->addOpenGraphData('site_name', FrontendModel::getModuleSetting('core', 'site_title_' . FRONTEND_LANGUAGE, SITE_DEFAULT_TITLE), true); $this->header->addOpenGraphData('description', $this->record['title'], true); } // 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(FrontendNavigation::getURLForBlock('blog', 'detail') . '/' . $this->record['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); // assign navigation $this->tpl->assign('navigation', FrontendBlogModel::getNavigation($this->record['id'])); }
/** * Notify the admin * * @return void * @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 pushnotification if ($comment['status'] == 'moderation') { $alert = array('loc-key' => 'NEW_COMMENT_TO_MODERATE'); } else { $alert = array('loc-key' => 'NEW_COMMENT'); } // get count of unmoderated items $badge = (int) FrontendModel::getDB()->getVar('SELECT COUNT(i.id) FROM blog_comments AS i WHERE i.status = ? AND i.language = ? GROUP BY i.status', array('moderation', FRONTEND_LANGUAGE)); // reset if needed if ($badge == 0) { $badge = null; } // build data $data = array('data' => array('endpoint' => SITE_URL . '/api/1.0', 'comment_id' => $comment['id'])); // push it FrontendModel::pushToAppleApp($alert, $badge, null, $data); // get settings $notifyByMailOnComment = FrontendModel::getModuleSetting('blog', 'notify_by_email_on_new_comment', false); $notifyByMailOnCommentToModerate = FrontendModel::getModuleSetting('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) { // comment to moderate if ($comment['status'] == 'moderation') { // set variables $variables['message'] = vsprintf(FL::msg('BlogEmailNotificationsNewCommentToModerate'), array($comment['author'], $URL, $comment['post_title'], $backendURL)); } elseif ($comment['status'] == 'published') { // set variables $variables['message'] = vsprintf(FL::msg('BlogEmailNotificationsNewComment'), array($comment['author'], $URL, $comment['post_title'])); } // send the mail FrontendMailer::addEmail(FL::msg('NotificationSubject'), FRONTEND_CORE_PATH . '/layout/templates/mails/notification.tpl', $variables); } elseif ($notifyByMailOnCommentToModerate && $comment['status'] == 'moderation') { // set variables $variables['message'] = vsprintf(FL::msg('BlogEmailNotificationsNewCommentToModerate'), array($comment['author'], $URL, $comment['post_title'], $backendURL)); // send the mail FrontendMailer::addEmail(FL::msg('NotificationSubject'), FRONTEND_CORE_PATH . '/layout/templates/mails/notification.tpl', $variables); } }
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); } // format data foreach ($this->items as &$item) { // full url is set? if (!isset($item['full_url'])) { continue; } // build utm array $utm['utm_source'] = SpoonFilter::urlise(FrontendModel::getModuleSetting('core', 'site_title_' . FRONTEND_LANGUAGE, SITE_DEFAULT_TITLE)); $utm['utm_medium'] = 'fork-search'; $utm['utm_term'] = $this->term; // get parameters in url already if (strpos($item['full_url'], '?') !== false) { $glue = '&'; } else { $glue = '?'; } // add utm to url $item['full_url'] .= $glue . http_build_query($utm, '', '&'); // format description $item['text'] = !empty($item['text']) ? mb_strlen($item['text']) > $this->length ? mb_substr(strip_tags($item['text']), 0, $this->length, SPOON_CHARSET) . '…' : $item['text'] : ''; } // output $this->output(self::OK, $this->items); }
/** * Parse the languages */ protected function parseLanguages() { // just execute if the site is multi-language if (SITE_MULTILANGUAGE) { // get languages $activeLanguages = FrontendLanguage::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'] = FL::msg(strtoupper($language)); $temp['current'] = (bool) ($language == FRONTEND_LANGUAGE); // add $languages[] = $temp; } // assign if (count($languages) > 1) { $this->tpl->assign('languages', $languages); } } }
/** * 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) { // get files to process $tree = self::getTree(FRONTEND_PATH); $used = array(); // loop files foreach ($tree as $file) { // grab content $content = SpoonFile::getContent($file); // process the file based on extension switch (SpoonFile::getExtension($file)) { // 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, $used[$type][$match]['files'])) { $used[$type][$match]['files'][] = $file; } } } 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, $used[$type][$match]['files'])) { $used[$type][$match]['files'][] = $file; } } } 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, $used[$type][$match]['files'])) { $used[$type][$match]['files'][] = $file; } } } break; } } // init var $nonExisting = array(); // set language FrontendLanguage::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) == '{$' . $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) == '{$' . $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) == '{$' . $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) == '{$' . $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; }
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); } // 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, SPOON_CHARSET) . '…' : $item['text'] : ''; } // output $this->output(self::OK, $this->items); }
/** * Parse the data into the template * * @return void */ private function parse() { // get RSS-link $rssLink = FrontendModel::getModuleSetting('blog', 'feedburner_url_' . FRONTEND_LANGUAGE); if ($rssLink == '') { $rssLink = FrontendNavigation::getURLForBlock('blog', 'rss'); } // add RSS-feed $this->header->addLink(array('rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => FrontendModel::getModuleSetting('blog', 'rss_title_' . FRONTEND_LANGUAGE), 'href' => $rssLink), true); // get RSS-link for the comments $rssCommentsLink = FrontendNavigation::getURLForBlock('blog', 'article_comments_rss') . '/' . $this->record['url']; // add RSS-feed into the metaCustom $this->header->addLink(array('rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => vsprintf(FL::msg('CommentsOn'), array($this->record['title'])), 'href' => $rssCommentsLink), true); // build Facebook Open Graph-data if (FrontendModel::getModuleSetting('core', 'facebook_admin_ids', null) !== null) { // default image $image = SITE_URL . '/facebook.png'; // try to get an image in the content $matches = array(); preg_match('/<img.*src="(.*)".*\\/>/iU', $this->record['text'], $matches); // found an image? if (isset($matches[1])) { $image = $matches[1]; if (substr($image, 0, 7) != 'http://') { $image = SITE_URL . $image; } } // add OpenGraph data $this->header->addOpenGraphData('title', $this->record['title'], true); $this->header->addOpenGraphData('type', 'article', true); $this->header->addOpenGraphData('image', $image, true); $this->header->addOpenGraphData('url', SITE_URL . FrontendNavigation::getURLForBlock('blog', 'detail') . '/' . $this->record['url'], true); $this->header->addOpenGraphData('site_name', FrontendModel::getModuleSetting('core', 'site_title_' . FRONTEND_LANGUAGE, SITE_DEFAULT_TITLE), true); $this->header->addOpenGraphData('description', $this->record['title'], true); } // 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'])); } // 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); // assign navigation $this->tpl->assign('navigation', FrontendBlogModel::getNavigation($this->record['id'])); }