public function make() { $way = router::getInstance()->shiftUriArray(); $lang = null; if (property::getInstance()->get('use_multi_language')) { $lang = '_' . router::getInstance()->getPathLanguage(); } if ($way[0] === "sitemap.xml") { header("Content-type: text/xml"); $render = cache::getInstance()->get('sitemap' . $lang); if (is_null($render)) { $this->loadDefaults(); $render = template::getInstance()->twigRender('components/sitemap/map.tpl', array('local' => $this->map)); cache::getInstance()->store('sitemap' . $lang, $render); } template::getInstance()->justPrint($render); } elseif ($way[0] == "sitemap.html") { $tpl = cache::getInstance()->get('htmlmap' . $lang); if (is_null($tpl)) { $this->loadDefaults(); $tpl = template::getInstance()->twigRender('components/sitemap/html.tpl', array('local' => $this->map)); cache::getInstance()->store('htmlmap' . $lang, $tpl); } template::getInstance()->set(template::TYPE_CONTENT, 'body', $tpl); } }
private function viewVideoRssFeed() { if (!extension::getInstance()->getConfig('enable_rss', 'video', extension::TYPE_COMPONENT, 'bool')) { return null; } header('Content-Type: application/rss+xml; charset=utf-8'); $way = router::getInstance()->shiftUriArray(); $fulltext_enabled = extension::getInstance()->getConfig('enable_full_rss', 'video', extension::TYPE_COMPONENT, 'bool'); $fulltext_mod = $way[1] === "fulltext" && $fulltext_enabled ? true : false; $cache_filename = null; switch ($way[1]) { case null: $cache_filename = 'rssvideofeed_' . language::getInstance()->getUseLanguage(); break; case 'fulltext': $cache_filename = 'rssvideofeed_fulltext_' . language::getInstance()->getUseLanguage(); break; case 'short': $cache_filename = 'rssvideofeed_short' . language::getInstance()->getUseLanguage(); break; case 'medium': $cache_filename = 'rssvideofeed_medium' . language::getInstance()->getUseLanguage(); break; } if (cache::getInstance()->get($cache_filename, self::RSS_UPDATE_TIME)) { template::getInstance()->justPrint(cache::getInstance()->get($cache_filename, self::RSS_UPDATE_TIME)); } $params = array(); $time = time(); $item_count = self::RSS_ITEM_LIMIT; if (extension::getInstance()->getConfig('rss_count', 'video', extension::TYPE_COMPONENT, 'int') > 0) { $item_count = extension::getInstance()->getConfig('rss_count', 'video', extension::TYPE_COMPONENT, 'int'); } $stmt = database::getInstance()->con()->prepare("SELECT a.id,a.title,a.text,a.link,a.date,a.keywords,b.path,b.name FROM " . property::getInstance()->get('db_prefix') . "_com_video_entery a,\n " . property::getInstance()->get('db_prefix') . "_com_video_category b WHERE a.category = b.category_id AND a.date <= ? AND a.display = 1 ORDER BY a.date DESC LIMIT 0,?"); $stmt->bindParam(1, $time, PDO::PARAM_INT); $stmt->bindParam(2, $item_count, PDO::PARAM_INT); $stmt->execute(); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt = null; $site_title = property::getInstance()->get('seo_title'); $site_desc = property::getInstance()->get('seo_description'); $params['channel'] = array('title' => $site_title[language::getInstance()->getUseLanguage()], 'desc' => $site_desc[language::getInstance()->getUseLanguage()], 'link' => property::getInstance()->get('url') . '/video/'); foreach ($result as $row) { $item_title = system::getInstance()->altstripslashes(unserialize($row['title'])); $item_fulltext = system::getInstance()->altstripslashes(unserialize($row['text'])); $item_langtext = system::getInstance()->stringInline(system::getInstance()->nohtml($item_fulltext[language::getInstance()->getUseLanguage()], true)); $item_catname = system::getInstance()->altstripslashes(unserialize($row['name'])); $item_keywords = unserialize($row['keywords']); $item_desc = null; $item_link = property::getInstance()->get('url') . '/video/'; if (system::getInstance()->contains('<hr />', $item_fulltext[language::getInstance()->getUseLanguage()])) { $item_desc = strstr($item_fulltext[language::getInstance()->getUseLanguage()], '<hr />', true); $item_desc = system::getInstance()->stringInline(system::getInstance()->nohtml($item_desc, true)); } elseif (system::getInstance()->length($item_langtext) > 100) { $item_desc = system::getInstance()->sentenceSub($item_langtext, 100) . "..."; } else { $item_desc = $item_langtext; } $item_desc = system::getInstance()->htmlQuoteDecode($item_desc); if ($row['path'] == null) { $item_link .= $row['link']; } else { $item_link .= $row['path'] . "/" . $row['link']; } $item_image = null; $image_size = 0; if (file_exists(root . '/upload/video/poster_' . $row['id'] . '.jpg')) { $item_image = property::getInstance()->get('script_url') . '/upload/video/poster_' . $row['id'] . '.jpg'; $image_size = filesize(root . '/upload/video/poster_' . $row['id'] . '.jpg'); } $full_text = $fulltext_mod ? system::getInstance()->stringInline(system::getInstance()->htmlQuoteDecode(system::getInstance()->nohtml($item_fulltext[language::getInstance()->getUseLanguage()]))) : null; $title = system::getInstance()->htmlQuoteDecode(system::getInstance()->nohtml($item_title[language::getInstance()->getUseLanguage()], true)); if (extension::getInstance()->getConfig('enable_soc_rss', 'video', extension::TYPE_COMPONENT, 'bol')) { $add_hash_lang = extension::getInstance()->getConfig('rss_hash', 'video', extension::TYPE_COMPONENT, 'str'); $add_hash = $add_hash_lang[language::getInstance()->getUseLanguage()]; if ($way[1] == 'short') { // twitter autopost from RSS - max length 140 chars $reserve_length = 0; $reserve_length += system::getInstance()->length($title); if (extension::getInstance()->getConfig('rss_soc_linkshort', 'video', extension::TYPE_COMPONENT, 'bool')) { $reserve_length += 20; } else { $reserve_length += system::getInstance()->length($item_link) > 25 ? 25 : system::getInstance()->length($item_link); // as test twitter not reserve more than 22 symb. 25 as max. } $used_keys = array(); foreach (system::getInstance()->altexplode(',', $item_keywords[language::getInstance()->getUseLanguage()]) as $keyitem) { $keyitem = trim($keyitem); if (system::getInstance()->length($keyitem) + $reserve_length <= 140) { // title.length + keyword.length + space + sharp(#) $title .= " #" . $keyitem; $used_keys[] = $keyitem; $reserve_length += system::getInstance()->length($keyitem); $reserve_length += 2; // space + sharp (#key ) } else { break; } } foreach (system::getInstance()->altexplode(',', $add_hash) as $add_keyitem) { $add_keyitem = system::getInstance()->altlower(trim($add_keyitem)); if (system::getInstance()->length($add_keyitem) + $reserve_length + 2 <= 140 && !in_array($add_keyitem, $used_keys)) { $title .= " #" . $add_keyitem; $used_keys[] = $add_keyitem; $reserve_length += system::getInstance()->length($add_keyitem); $reserve_length += 2; // space + sharp (#key ) } } } elseif ($way[1] == 'medium') { // other social from RSS - hash tags in desc and title UPPER $used_keys = array(); foreach (system::getInstance()->altexplode(',', $item_keywords[language::getInstance()->getUseLanguage()]) as $keyitem) { $keyitem = trim($keyitem); $item_desc .= " #" . $keyitem; $used_keys[] = $keyitem; } foreach (system::getInstance()->altexplode(',', $add_hash) as $add_keyitem) { $add_keyitem = system::getInstance()->altlower(trim($add_keyitem)); if (!in_array($add_keyitem, $used_keys)) { $item_desc .= " #" . $add_keyitem; $used_keys[] = $add_keyitem; } } $title = system::getInstance()->altupper($title); } } $params['items'][] = array('title' => $title, 'text' => $full_text, 'desc' => $item_desc, 'date' => date(DATE_RSS, $row['date']), 'link' => $item_link, 'category' => $item_catname[language::getInstance()->getUseLanguage()], 'id' => $row['id'], 'image_url' => $item_image, 'image_size' => $image_size); } $content = template::getInstance()->twigString()->render(@file_get_contents(root . '/resource/cmscontent/rss_2.xml'), $params); cache::getInstance()->store($cache_filename, $content); template::getInstance()->justPrint($content); }