/** * Campsite render function plugin * * Type: function * Name: render * Purpose: template rendering * * @param array * $p_params * @param object * $p_smarty The Smarty object * * @return * rendered content */ function smarty_function_render($p_params, &$p_smarty) { if (empty($p_params['file'])) { return null; } $smarty = CampTemplate::singleton(); $cache_lifetimeBak = $smarty->cache_lifetime; $campsiteVectorBak = $smarty->campsiteVector; if (SystemPref::Get('TemplateCacheHandler')) { $campsiteVector = $smarty->campsiteVector; foreach ($campsiteVector as $key => $value) { if (isset($p_params[$key])) { if (empty($p_params[$key]) || strtolower($p_params[$key]) == 'off') { $campsiteVector[$key] = null; } if (is_int($p_params[$key])) { $campsiteVector[$key] = $p_params[$key]; } } } if (isset($p_params['params'])) { $campsiteVector['params'] = $p_params['params']; } $smarty->campsiteVector = $campsiteVector; if (empty($p_params['cache'])) { $template = new Template(CampSite::GetURIInstance()->getThemePath() . $p_params['file']); $smarty->cache_lifetime = (int) $template->getCacheLifetime(); } else { $smarty->cache_lifetime = (int) $p_params['cache']; } } $smarty->display($p_params['file']); $smarty->cache_lifetime = $cache_lifetimeBak; $smarty->campsiteVector = $campsiteVectorBak; }
public function indexAction() { global $controller; $controller = $this; require_once $GLOBALS['g_campsiteDir'] . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'campsite_constants.php'; require_once CS_PATH_CONFIG . DIR_SEP . 'install_conf.php'; $local_path = dirname(__FILE__) . '/include'; set_include_path($local_path . PATH_SEPARATOR . get_include_path()); require_once CS_PATH_INCLUDES . DIR_SEP . 'campsite_init.php'; // initializes the campsite object $campsite = new CampSite(); // loads site configuration settings $campsite->loadConfiguration(CS_PATH_CONFIG . DIR_SEP . 'configuration.php'); // starts the session $campsite->initSession(); // initiates the context $campsite->init(); // dispatches campsite $campsite->dispatch(); if (APPLICATION_ENV !== 'development' || APPLICATION_ENV !== 'dev') { set_error_handler(create_function('', 'return true;')); } // renders the site $campsite->render(); // triggers an event after displaying $campsite->event('afterRender'); }
public function preDispatch() { $uri = CampSite::GetURIInstance(); $themePath = $uri->getThemePath(); $this->view = new Newscoop\SmartyView(); $this->view->addScriptPath(APPLICATION_PATH . '/views/scripts/')->addScriptPath(realpath(APPLICATION_PATH . "/../themes/{$themePath}")); $this->view->addPath(realpath(APPLICATION_PATH . "/../themes/{$themePath}")); $this->getHelper('viewRenderer')->setView($this->view)->setViewScriptPathSpec(':controller_:action.:suffix')->setViewSuffix('tpl'); $this->getHelper('layout')->disableLayout(); $this->view->publication = $this->getRequest()->getServer('SERVER_NAME', 'localhost'); $this->view->site = \SystemPref::Get('SiteTitle'); $this->_helper->contextSwitch()->addActionContext('comment-notify', 'xml')->initContext(); }
/** * Class constructor */ final public function __construct() { // gets the config object from the main class $config = CampSite::GetConfigInstance(); // sets the new connection resource $this->m_db = ADONewConnection($config->getSetting('db.type')); $this->m_db->SetFetchMode(ADODB_FETCH_ASSOC); $this->m_db->Connect($config->getSetting('db.host'), $config->getSetting('db.user'), $config->getSetting('db.pass'), $config->getSetting('db.name')); } // fn __construct
public function indexAction() { global $controller; $controller = $this; require_once $GLOBALS['g_campsiteDir'] . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'campsite_constants.php'; require_once CS_PATH_CONFIG . DIR_SEP . 'install_conf.php'; $local_path = dirname(__FILE__) . '/include'; set_include_path($local_path . PATH_SEPARATOR . get_include_path()); require_once CS_PATH_INCLUDES . DIR_SEP . 'campsite_init.php'; if (file_exists(CS_PATH_SITE . DIR_SEP . 'reset_cache')) { CampCache::singleton()->clear('user'); @unlink(CS_PATH_SITE . DIR_SEP . 'reset_cache'); } // initializes the campsite object $campsite = new CampSite(); // loads site configuration settings $campsite->loadConfiguration(CS_PATH_CONFIG . DIR_SEP . 'configuration.php'); // starts the session $campsite->initSession(); if (file_exists(CS_PATH_SITE . DIR_SEP . 'conf' . DIR_SEP . 'upgrading.php')) { $this->upgrade(); exit(0); } // initiates the context $campsite->init(); // dispatches campsite $campsite->dispatch(); // triggers an event before render the page. // looks for preview language if any. $previewLang = $campsite->event('beforeRender'); if (!is_null($previewLang)) { require_once $GLOBALS['g_campsiteDir'] . '/template_engine/classes/SyntaxError.php'; set_error_handler('templateErrorHandler'); // loads translations strings in the proper language for the error messages display camp_load_translation_strings('preview', $previewLang); } else { set_error_handler(create_function('', 'return true;')); } if ($this->_request->getParam('logout') == 'true') { $this->_redirect('/auth/logout/?url=' . urlencode($this->getRequest()->getPathInfo())); } // renders the site $campsite->render(); // triggers an event after displaying $campsite->event('afterRender'); }
private function __construct() { parent::Smarty(); $config = CampSite::GetConfigInstance(); $this->debugging = $config->getSetting('smarty.debugging'); $this->force_compile = $config->getSetting('smarty.force_compile'); $this->compile_check = $config->getSetting('smarty.compile_check'); $this->use_sub_dirs = $config->getSetting('smarty.use_subdirs'); // cache settings $cacheHandler = SystemPref::Get('TemplateCacheHandler'); if ($cacheHandler) { $this->caching = 1; $this->cache_handler_func = "TemplateCacheHandler_$cacheHandler::handler"; require_once CS_PATH_SITE.DIR_SEP.'classes'.DIR_SEP.'cache'.DIR_SEP."TemplateCacheHandler_$cacheHandler.php"; } else { $this->caching = 0; } // define dynamic uncached block require_once CS_PATH_SMARTY.DIR_SEP.'campsite_plugins/block.dynamic.php'; $this->register_block('dynamic', 'smarty_block_dynamic', false); // define render function require_once CS_PATH_SMARTY.DIR_SEP.'campsite_plugins/function.render.php'; $this->register_function('render', 'smarty_function_render', false); $this->left_delimiter = $config->getSetting('smarty.left_delimeter'); $this->right_delimiter = $config->getSetting('smarty.right_delimeter'); $this->cache_dir = CS_PATH_SITE.DIR_SEP.'cache'; $this->config_dir = CS_PATH_SMARTY.DIR_SEP.'configs'; $plugin_smarty_camp_plugin_paths = array(); foreach (CampPlugin::GetEnabled() as $CampPlugin) { $plugin_smarty_camp_plugin_paths[] = CS_PATH_SITE.DIR_SEP.$CampPlugin->getBasePath().DIR_SEP.'smarty_camp_plugins'; } $this->plugins_dir = array_merge(array(CS_PATH_SMARTY.DIR_SEP.'campsite_plugins', CS_PATH_SMARTY.DIR_SEP.'plugins'), $plugin_smarty_camp_plugin_paths); $this->template_dir = CS_PATH_TEMPLATES; $this->compile_dir = CS_PATH_SITE.DIR_SEP.'templates_cache'; } // fn __constructor
/** */ public function __construct() { parent::__construct(); $config = CampSite::GetConfigInstance(); $this->debugging = $config->getSetting('smarty.debugging'); $this->force_compile = $config->getSetting('smarty.force_compile'); $this->compile_check = $config->getSetting('smarty.compile_check'); $this->use_sub_dirs = $config->getSetting('smarty.use_subdirs'); // cache settings $preferencesService = \Zend_Registry::get('container')->getService('system_preferences_service'); $this->useprotocol = $preferencesService->get('SmartyUseProtocol') === 'Y' ? 'true' : 'false'; $this->templateCacheHandler = $preferencesService->TemplateCacheHandler; if ($this->templateCacheHandler) { $this->caching = 1; $this->caching_type = 'newscoop'; CampTemplateCache::factory(); } else { $this->caching = 0; } if (defined('APPLICATION_ENV') && APPLICATION_ENV == 'development') { $this->force_compile = true; } // define dynamic uncached block require_once APPLICATION_PATH . self::PLUGINS . '/block.dynamic.php'; $this->registerPlugin('block', 'dynamic', 'smarty_block_dynamic', false); // define render function require_once APPLICATION_PATH . self::PLUGINS . '/function.render.php'; $this->registerPlugin('function', 'render', 'smarty_function_render', false); // define translate modifier require_once APPLICATION_PATH . self::PLUGINS . '/modifier.translate.php'; $this->registerPlugin('modifier', 'translate', 'smarty_modifier_translate', false); $this->left_delimiter = '{{'; $this->right_delimiter = '}}'; $this->auto_literal = false; $this->cache_dir = APPLICATION_PATH . '/../cache'; $this->compile_dir = APPLICATION_PATH . '/../cache'; $this->plugins_dir = array_merge((array) $this->plugins_dir, array(APPLICATION_PATH . self::PLUGINS), self::getPluginsPluginsDir()); $this->setTemplateDir(array(APPLICATION_PATH . '/../themes/', APPLICATION_PATH . '/../themes/system_templates/', APPLICATION_PATH . self::SCRIPTS)); $this->assign('view', \Zend_Registry::get('container')->get('view')); $this->assign('userindex', false); $this->assign('user', new MetaUser()); $this->assign('siteinfo', array('title' => $preferencesService->SiteTitle, 'keywords' => $preferencesService->SiteMetaKeywords, 'description' => $preferencesService->SiteMetaDescription)); $this->getTemplateTranslationsFiles(); }
/** */ public function preDispatch() { $controller = $this->getActionController(); $GLOBALS['controller'] = $controller; $request = $this->getRequest(); $format = $request->getParam('format', null); if (isset($format) && $format == "json") { return; } if (!in_array($request->getParam('module', 'default'), $this->modules) || !array_key_exists('module', $request->getParams())) { return; } $uri = CampSite::GetURIInstance(); $themePath = $uri->getThemePath(); $controller->view = new Newscoop\SmartyView(); $controller->view->addScriptPath(APPLICATION_PATH . '/views/scripts/')->addScriptPath(realpath(APPLICATION_PATH . "/../themes/{$themePath}")); $controller->view->addPath(realpath(APPLICATION_PATH . "/../themes/{$themePath}")); $controller->getHelper('viewRenderer')->setView($controller->view)->setViewScriptPathSpec(':controller_:action.:suffix')->setViewSuffix('tpl'); $controller->getHelper('layout')->disableLayout(); }
/** */ public function __construct() { parent::__construct(); $config = CampSite::GetConfigInstance(); $this->debugging = $config->getSetting('smarty.debugging'); $this->force_compile = $config->getSetting('smarty.force_compile'); $this->compile_check = $config->getSetting('smarty.compile_check'); $this->use_sub_dirs = $config->getSetting('smarty.use_subdirs'); $this->allow_php_tag = true; // cache settings $cacheHandler = SystemPref::Get('TemplateCacheHandler'); $auth = Zend_Auth::getInstance(); if ($cacheHandler) { $this->caching = 1; $this->caching_type = 'newscoop'; CampTemplateCache::factory(); } else { $this->caching = 0; } if (self::isDevelopment()) { $this->force_compile = true; } // define dynamic uncached block require_once APPLICATION_PATH . self::PLUGINS . '/block.dynamic.php'; $this->registerPlugin('block', 'dynamic', 'smarty_block_dynamic', false); // define render function require_once APPLICATION_PATH . self::PLUGINS . '/function.render.php'; $this->registerPlugin('function', 'render', 'smarty_function_render', false); $this->left_delimiter = '{{'; $this->right_delimiter = '}}'; $this->auto_literal = false; $this->cache_dir = APPLICATION_PATH . '/../cache'; $this->config_dir = APPLICATION_PATH . '/../configs'; $this->compile_dir = APPLICATION_PATH . '/../cache'; $this->plugins_dir = array_merge((array) $this->plugins_dir, array(APPLICATION_PATH . self::PLUGINS), self::getPluginsPluginsDir()); $this->template_dir = array(APPLICATION_PATH . '/../themes/', APPLICATION_PATH . '/../themes/unassigned/system_templates/', APPLICATION_PATH . self::SCRIPTS); if (isset($GLOBALS['controller'])) { $this->assign('view', $GLOBALS['controller']->view); } }
/** * Reads a configuration setting. * * @param string $p_varName * * @return mixed * The value of the configuration variable */ protected function getSetting($p_varName) { $config = CampSite::GetConfigInstance(); return $config->getSetting($p_varName); }
/** * Renders the document. * * Displays the document after parsing it. * * @param array $p_params * * @return void */ public function render($p_params) { $siteinfo = array(); $context = $p_params['context']; $template = $p_params['template']; $siteinfo['info_message'] = isset($p_params['info_message']) ? $p_params['info_message'] : null; $siteinfo['error_message'] = isset($p_params['error_message']) ? $p_params['error_message'] : null; $siteinfo['templates_path'] = isset($p_params['templates_dir']) ? $p_params['templates_dir'] : CS_TEMPLATES_DIR; $siteinfo['title'] = $this->getTitle(); $siteinfo['content_type'] = $this->getMetaTag('Content-Type', true); $siteinfo['generator'] = $this->getGenerator(); $siteinfo['keywords'] = $this->getMetaTag('keywords'); $siteinfo['description'] = $this->getMetaTag('description'); if (!file_exists(CS_PATH_SITE.DIR_SEP.$siteinfo['templates_path'].DIR_SEP.$template) || $template === false) { if (empty($template)) { $siteinfo['error_message'] = "No template set for display."; } else { $siteinfo['error_message'] = "The template '$template' does not exist in the templates directory."; } $template = CS_SYS_TEMPLATES_DIR.DIR_SEP.'_campsite_error.tpl'; $siteinfo['templates_path'] = CS_TEMPLATES_DIR; } $tpl = CampTemplate::singleton(); $tpl->template_dir = $siteinfo['templates_path']; $subdir = $this->m_config->getSetting('SUBDIR'); if (!empty($subdir)) { $siteinfo['templates_path'] = substr($subdir, 1) . '/' . $siteinfo['templates_path']; } $tpl->assign('gimme', $context); $tpl->assign('siteinfo', $siteinfo); // on template caching add additional info if (SystemPref::Get('TemplateCacheHandler')) { $uri = CampSite::GetURIInstance(); $tpl->campsiteVector = $uri->getCampsiteVector(); $templateObj = new Template($template); $tpl->cache_lifetime = (int)$templateObj->getCacheLifetime(); } try { $tpl->display($template); } catch (Exception $ex) { CampTemplate::trigger_error($ex->getMessage(), $tpl); } } // fn render
if (!file_exists(CS_PATH_CONFIG.DIR_SEP.'configuration.php') || !file_exists(CS_PATH_CONFIG.DIR_SEP.'database_conf.php')) { header('Location: '.$Campsite['SUBDIR'].'/install/'); exit(0); } require_once(CS_PATH_INCLUDES.DIR_SEP.'campsite_init.php'); if (file_exists(CS_PATH_SITE . DIR_SEP . 'reset_cache')) { CampCache::singleton()->clear('user'); @unlink(CS_PATH_SITE . DIR_SEP . 'reset_cache'); } $start1 = microtime(true); // initializes the campsite object $campsite = new CampSite(); $start2 = microtime(true); // loads site configuration settings $campsite->loadConfiguration(CS_PATH_CONFIG.DIR_SEP.'configuration.php'); $start3 = microtime(true); // starts the session $campsite->initSession(); if (file_exists(CS_PATH_SITE.DIR_SEP.'upgrade.php')) { camp_upgrade(); exit(0); } $start4 = microtime(true);
function camp_display_message($p_message) { $params = array('context' => null, 'template' => '_campsite_message.tpl', 'templates_dir' => CS_TEMPLATES_DIR . DIR_SEP . CS_SYS_TEMPLATES_DIR, 'info_message' => $p_message); $document = CampSite::GetHTMLDocumentInstance(); $document->render($params); }
/** * Campsite set_map function plugin * * Type: function * Name: set_map * Purpose: * * @param array * $p_params the map constarints set at the template * @param object * $p_smarty The Smarty object */ function smarty_function_set_map($p_params, &$p_smarty) { // gets the context variable $campsite = $p_smarty->getTemplateVars('gimme'); $run_article = $campsite->article->defined ? $campsite->article : null; $run_language = $campsite->language; $run_topic = $campsite->topic->defined ? $campsite->topic : null; $parameters = array(); $running = '_current'; $of_article = '_article'; $map_label = ''; $map_max_points = 0; $con_article_types = array(); $con_authors = array(); $con_articles = array(); $con_issues_num = array(); $con_sections_num = array(); $con_sections_str = array(); $con_topics = array(); $con_match_all_topics = array(); $con_has_multimedia = array(); $con_start_date = array(); $con_end_date = array(); $con_date = array(); $con_areas = array(); $con_match_any_area = array(); $con_exact_area = array(); $con_icons = array(); if (isset($p_params['label'])) { $map_label = trim('' . $p_params['label']); } if (isset($p_params['max_points'])) { $map_max_points = trim('' . $p_params['max_points']); if (!is_numeric($map_max_points)) { $map_max_points = 0; } $map_max_points = 0 + $map_max_points; } $campsite->map_dynamic_max_points = $map_max_points; if (isset($p_params['article_types'])) { foreach (explode(',', $p_params['article_types']) as $one_article_type) { $one_article_type = trim('' . $one_article_type); if (0 < strlen($one_article_type)) { if ($of_article == $one_article_type) { if ($run_article) { $con_article_types[] = $run_article->type_name; } } else { $con_article_types[] = $one_article_type; } } } } if (isset($p_params['authors'])) { foreach (explode(',', $p_params['authors']) as $one_author) { $one_author = trim('' . $one_author); if (0 < strlen($one_author)) { if ($of_article == $one_author) { if ($run_article) { $run_authors = $run_article->authors; foreach ($run_authors as $art_author) { $con_authors[] = $art_author->name; } } } else { $con_authors[] = $one_author; } } } } if (isset($p_params['articles'])) { foreach (explode(',', '' . $p_params['articles']) as $one_article) { $one_article = trim('' . $one_article); if (is_numeric($one_article)) { $con_articles[] = $one_article; } } } if (isset($p_params['issues'])) { foreach (explode(',', $p_params['issues']) as $one_issue) { $one_issue = trim('' . $one_issue); if ($running == $one_issue) { if ($run_article) { $run_issue = $run_article->issue; if ($run_issue) { $con_issues_num[] = $run_issue->number; } } } else { if (is_numeric($one_issue)) { $con_issues_num[] = $one_issue; } } } } if (isset($p_params['sections'])) { foreach (explode(',', $p_params['sections']) as $one_section) { $one_section = trim('' . $one_section); if ($running == $one_section) { if ($run_article) { $run_section = $run_article->section; if ($run_section) { $con_sections_num[] = $run_section->number; } } } elseif (is_numeric($one_section)) { $con_sections_num[] = $one_section; } elseif (0 < strlen($one_section)) { $one_section = trim($one_section); $con_sections_str[] = $one_section; } } } if (isset($p_params['topics'])) { foreach (explode(',', $p_params['topics']) as $one_topic) { $one_topic = trim('' . $one_topic); if (0 < strlen($one_topic)) { if ($of_article == $one_topic) { if ($run_article) { $run_topics = $run_article->topics; foreach ($run_topics as $art_topic) { $con_topics[] = $art_topic . ':' . $run_language->code; } } } elseif ($running == $one_topic) { if ($run_topic) { $cur_topic = $run_topic->name; if (!empty($cur_topic)) { $con_topics[] = htmlspecialchars_decode($cur_topic); } } } else { $one_topic = trim($one_topic); $con_topics[] = $one_topic; } } } } $values_known_yes = array('true' => true, 'yes' => true); $values_known_no = array('false' => true, 'no' => true); if (isset($p_params['match_all_topics'])) { $match_all_topics_val = $p_params['match_all_topics']; if (is_bool($match_all_topics_val)) { $con_match_all_topics[0] = $match_all_topics_val; } elseif (is_string($match_all_topics_val)) { $match_all_topics_val = trim(strtolower($match_all_topics_val)); if (array_key_exists($match_all_topics_val, $values_known_yes)) { $con_match_all_topics[0] = true; } if (array_key_exists($match_all_topics_val, $values_known_no)) { $con_match_all_topics[0] = false; } } } if (isset($p_params['match_any_topic'])) { $match_any_topic_val = $p_params['match_any_topic']; if (is_bool($match_any_topic_val)) { $con_match_all_topics[0] = !$match_any_topic_val; } elseif (is_string($match_any_topic_val)) { $match_any_topic_val = trim(strtolower($match_any_topic_val)); if (array_key_exists($match_any_topic_val, $values_known_yes)) { $con_match_all_topics[0] = false; } if (array_key_exists($match_any_topic_val, $values_known_no)) { $con_match_all_topics[0] = true; } } } if (isset($p_params['has_multimedia'])) { $has_multimedia_val = $p_params['has_multimedia']; if (is_bool($has_multimedia_val)) { if ($has_multimedia_val) { $con_has_multimedia[0] = 'any'; } else { $con_has_multimedia = array(); } } elseif (is_string($has_multimedia_val)) { $has_multimedia_val = trim(strtolower($has_multimedia_val)); if (array_key_exists($has_multimedia_val, $values_known_yes)) { $con_has_multimedia[0] = 'any'; } if (array_key_exists($has_multimedia_val, $values_known_no)) { $con_has_multimedia = array(); } if ('video' == $has_multimedia_val) { $con_has_multimedia[0] = 'video'; } if ('image' == $has_multimedia_val) { $con_has_multimedia[0] = 'image'; } } } if (isset($p_params['start_date'])) { $start_date_val = trim($p_params['start_date']); $start_date_val = str_replace('"', '""', trim($start_date_val)); if (0 < strlen($start_date_val)) { $con_start_date[0] = $start_date_val; } } if (isset($p_params['end_date'])) { $end_date_val = trim($p_params['end_date']); $end_date_val = str_replace('"', '""', trim($end_date_val)); if (0 < strlen($end_date_val)) { $con_end_date[0] = $end_date_val; } } if (isset($p_params['date'])) { $date_val = trim($p_params['date']); $date_val = str_replace('"', '""', trim($date_val)); if (0 < strlen($date_val)) { $con_date[0] = $date_val; } } if (isset($p_params['area'])) { $area_val = trim($p_params['area']); if (0 < strlen($area_val)) { aux_parser_set_map_area($area_val, $con_areas); } } if (isset($p_params['areas'])) { $area_val = trim($p_params['areas']); if (0 < strlen($area_val)) { aux_parser_set_map_area($area_val, $con_areas); } } if (isset($p_params['area_match'])) { $area_match_val = $p_params['area_match']; if (is_string($area_match_val)) { $area_match_val = strtolower($area_match_val); if ('intersection' == $area_match_val) { $con_match_any_area[0] = false; } if ('union' == $area_match_val) { $con_match_any_area[0] = true; } } } if (isset($p_params['area_exact'])) { $area_exact_val = $p_params['area_exact']; if (is_string($area_exact_val)) { $area_exact_val = strtolower($area_exact_val); if ('false' == $area_exact_val) { $con_exact_area[0] = false; } if ('true' == $area_exact_val) { $con_exact_area[0] = true; } } else { if ($area_exact_val) { $con_exact_area[0] = true; } else { $con_exact_area[0] = false; } } } if (isset($p_params['icons'])) { $icons_val = trim($p_params['icons']); foreach (explode(',', $icons_val) as $cur_icon) { $cur_icon = str_replace('"', '""', trim($cur_icon)); if (0 < strlen($cur_icon)) { $con_icons[] = $cur_icon; } } } // to put the read constraints into parameters list foreach ($con_article_types as $one_article_type) { $leftOperand = 'article_type'; $rightOperand = $one_article_type; $operator = new Operator('is', 'sql'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; } foreach ($con_authors as $one_author) { $leftOperand = 'author'; $rightOperand = $one_author; $operator = new Operator('is', 'sql'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; } foreach ($con_articles as $one_article) { $leftOperand = 'article'; $rightOperand = $one_article; $operator = new Operator('is', 'sql'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; } foreach ($con_issues_num as $one_issue) { $leftOperand = 'issue'; $rightOperand = $one_issue; $operator = new Operator('is', 'sql'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; } foreach ($con_sections_num as $one_section) { $leftOperand = 'section'; $rightOperand = $one_section; $operator = new Operator('is', 'sql'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; } foreach ($con_sections_str as $one_section) { $leftOperand = 'section_name'; $rightOperand = $one_section; $operator = new Operator('is', 'sql'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; } foreach ($con_topics as $one_topic) { $leftOperand = 'topic_name'; $rightOperand = $one_topic; $operator = new Operator('is', 'sql'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; } if (1 == count($con_match_all_topics)) { $leftOperand = 'matchalltopics'; $rightOperand = $con_match_all_topics[0]; $operator = new Operator('is', 'sql'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; } foreach ($con_has_multimedia as $one_multimedia) { $leftOperand = 'multimedia'; $rightOperand = $one_multimedia; $operator = new Operator('is', 'php'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; } if (0 < count($con_start_date)) { $leftOperand = 'date'; $rightOperand = $con_start_date; $operator = new Operator('greater_equal', 'sql'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; } if (0 < count($con_end_date)) { $leftOperand = 'date'; $rightOperand = $con_end_date; $operator = new Operator('smaller_equal', 'sql'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; } if (0 < count($con_date)) { $leftOperand = 'date'; $rightOperand = $con_date; $operator = new Operator('is', 'sql'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; } foreach ($con_areas as $one_area) { $leftOperand = 'area'; $rightOperand = json_encode($one_area); $operator = new Operator('is', 'php'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; } if (0 < count($con_match_any_area)) { $leftOperand = 'matchanyarea'; $rightOperand = $con_match_any_area[0]; $operator = new Operator('is', 'sql'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; } if (0 < count($con_exact_area)) { $leftOperand = 'exactarea'; $rightOperand = $con_exact_area[0]; $operator = new Operator('is', 'sql'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; } foreach ($con_icons as $one_icon) { $leftOperand = 'icon'; $rightOperand = $one_icon; $operator = new Operator('is', 'sql'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; } $run_publicationId = 0; if (CampTemplate::singleton()) { $Context = CampTemplate::singleton()->context(); if ($Context->publication) { $run_publicationId = $Context->publication->identifier; } } $leftOperand = 'publication'; $rightOperand = $run_publicationId; $operator = new Operator('is', 'sql'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; $campsite->map_dynamic_constraints = $parameters; if (!empty($con_areas)) { $campsite->map_dynamic_areas = json_encode($con_areas); } else { $campsite->map_dynamic_areas = null; } $campsite->map_dynamic_map_label = $map_label; $leftOperand = 'as_array'; $rightOperand = true; $operator = new Operator('is', 'php'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; $leftOperand = 'active_only'; $rightOperand = true; $operator = new Operator('is', 'php'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; $leftOperand = 'text_only'; $rightOperand = false; $operator = new Operator('is', 'php'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; $leftOperand = 'language'; $rightOperand = (int) $run_language->number; $operator = new Operator('is', 'php'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; $leftOperand = 'constrained'; $rightOperand = true; $operator = new Operator('is', 'php'); $constraint = new ComparisonOperation($leftOperand, $operator, $rightOperand); $parameters[] = $constraint; $poi_count = 0; $poi_array = array(); $poi_objects = Geo_MapLocation::GetListExt($parameters, array(), 0, $map_max_points, $poi_count, false, $poi_array); $campsite->map_dynamic_tot_points = $poi_count; $map_art_ids = array(); $art_backlinks = array(); $meta_art_objs = array(); $arts_per_pois = array(); $poi_retrieved_count = count($poi_array); for ($poi_idx = 0; $poi_idx < $poi_retrieved_count; $poi_idx++) { $poi_arts = array(); $articleNos = $poi_array[$poi_idx]['art_numbers']; if (0 < strlen($articleNos)) { foreach (explode(',', $articleNos) as $one_art) { $one_art = trim($one_art); if (0 == strlen($one_art)) { continue; } if (!is_numeric($one_art)) { continue; } $one_art = 0 + $one_art; $poi_arts[] = $one_art; $map_art_ids[$one_art] = true; } } if (0 == count($poi_arts)) { $articleNo = $poi_array[$poi_idx]['art_number']; if (is_numeric($articleNo)) { $articleNo = 0 + $articleNo; if (0 < $articleNo) { $poi_arts[] = $articleNo; $map_art_ids[$articleNo] = true; } } } $arts_per_pois[] = $poi_arts; } foreach ($map_art_ids as $one_art_id => $one_art_aux) { $myArticle = new MetaArticle((int) $run_language->number, $one_art_id); $meta_art_objs[$one_art_id] = $myArticle; $url = CampSite::GetURIInstance(); $url->publication = $myArticle->publication; $url->issue = $myArticle->issue; $url->section = $myArticle->section; $url->article = $myArticle; $articleURI = $url->getURI('article'); $article_name = $myArticle->name; $art_backlinks[$one_art_id] = array('link' => $articleURI, 'label' => $article_name); } krsort($meta_art_objs); for ($poi_idx = 0; $poi_idx < $poi_retrieved_count; $poi_idx++) { $curr_back_list = array(); $curr_art_ids = $arts_per_pois[$poi_idx]; foreach ($curr_art_ids as $one_art_id) { $curr_back_list[] = $art_backlinks[$one_art_id]; } if (0 < count($curr_back_list)) { $poi_array[$poi_idx]['backlinks'] = $curr_back_list; } } $campsite->map_dynamic_points_raw = $poi_array; $campsite->map_dynamic_points_objects = $poi_objects; $campsite->map_dynamic_meta_article_objects = $meta_art_objs; $campsite->map_dynamic_id_counter += 1; }
public function __construct() { $this->m_customProperties = self::$m_defaultCustomProperties; $this->m_uriObj = CampSite::GetURIInstance(); }
public function handler($action, &$cache_content, $tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = 0) { global $g_ado_db; static $cacheParams = array(); $exp_time += time(); $tpl_file = md5($tpl_file) . substr($tpl_file, -15); $uri = CampSite::GetURIInstance(); $smarty = CampTemplate::singleton(); $campsiteVector = array_merge($uri->getCampsiteVector(), $smarty->campsiteVector); $return = false; if ($action != 'clean') { if (!isset($campsiteVector['params'])) { $campsiteVector['params'] = null; } } switch ($action) { case 'read': $whereStr = self::vectorToWhereString($campsiteVector) . " AND template = '{$tpl_file}'"; $cacheParams[$tpl_file] = array(); $cacheParams[$tpl_file]['where'] = $whereStr; $queryStr = 'SELECT expired, content, status FROM Cache WHERE ' . $whereStr; $result = $g_ado_db->GetRow($queryStr); if ($result) { if ($result['expired'] > time()) { if ($result['status'] == 'E') { $queryStr = 'UPDATE Cache SET status = "U" WHERE ' . $whereStr . ' AND status = "E"'; $g_ado_db->executeUpdate($queryStr); if ($g_ado_db->affected_rows() > 0) { $cacheParams[$tpl_file]['update'] = true; $return = false; } else { $cache_content = $result['content']; $return = $result['expired']; } } else { $cacheParams[$tpl_file]['cached'] = true; $cache_content = $result['content']; $return = $result['expired']; } } else { // clear expired cache $queryStr = 'DELETE FROM Cache WHERE expired <= ' . time(); $g_ado_db->execute($queryStr); $return = false; } } break; case 'write': // in case template changing the old cached templates should be updated if (isset($cacheParams[$tpl_file]['cached'])) { $queryStr = 'UPDATE Cache SET status = "E" WHERE template = ' . "'{$tpl_file}'"; $g_ado_db->execute($queryStr); $cacheParams[$tpl_file]['update'] = true; } if ($exp_time > time() + 1) { // update/insert new cached content if (isset($cacheParams[$tpl_file]['update'])) { $queryStr = 'UPDATE Cache SET status = null, expired = ' . $exp_time . ', ' . "content = '" . addslashes($cache_content) . "' WHERE " . $cacheParams[$tpl_file]['where']; } else { $queryStr = 'INSERT IGNORE INTO Cache (' . implode(',', array_keys($campsiteVector)) . ',template,expired,content) VALUES ('; foreach ($campsiteVector as $key => $value) { $queryStr .= !isset($value) ? ($key == 'params' ? "''" : '0') . ',' : ($key == 'params' ? "'" . addslashes($value) . "'" : $value) . ','; } $queryStr .= "'{$tpl_file}',{$exp_time},'" . addslashes($cache_content) . "')"; } unset($cacheParams[$tpl_file]); $g_ado_db->executeUpdate($queryStr); $return = $g_ado_db->affected_rows() > 0; } break; case 'clean': $queryStr = 'DELETE FROM Cache'; if ($tpl_file) { $queryStr .= " WHERE template = '{$tpl_file}'"; } $g_ado_db->execute($queryStr); $return = true; break; default: } return $return; }
function display_upgrade_error($p_errorMessage, $exit = TRUE) { if (defined('APPLICATION_ENV') && APPLICATION_ENV == 'development') { var_dump($p_errorMessage); if ($exit) { exit(1); } } $template = CS_SYS_TEMPLATES_DIR . DIR_SEP . '_campsite_error.tpl'; $templates_dir = CS_TEMPLATES_DIR; $params = array('context' => null, 'template' => $template, 'templates_dir' => $templates_dir, 'error_message' => $p_errorMessage); $document = CampSite::GetHTMLDocumentInstance(); $document->render($params); if ($exit) { exit(0); } }
/** * Renders the document. * * Displays the document after parsing it. * * @param array $p_params * * @return void */ public function render($p_params) { $siteinfo = array(); $context = $p_params['context']; $template = $p_params['template']; $siteinfo['info_message'] = isset($p_params['info_message']) ? $p_params['info_message'] : null; $siteinfo['error_message'] = isset($p_params['error_message']) ? $p_params['error_message'] : null; $siteinfo['templates_path'] = isset($p_params['templates_dir']) ? $p_params['templates_dir'] : CS_TEMPLATES_DIR; $siteinfo['title'] = $this->getTitle(); $siteinfo['content_type'] = $this->getMetaTag('Content-Type', true); $siteinfo['generator'] = $this->getGenerator(); $siteinfo['keywords'] = $this->getMetaTag('keywords'); $siteinfo['description'] = $this->getMetaTag('description'); $tpl = CampTemplate::singleton(); $tpl->template_dir = array_unique($tpl->template_dir); if (!$template) { $siteinfo['error_message'] = "No template set for display."; } elseif (!$this->templateExists($template, $tpl)) { $siteinfo['error_message'] = "The template '{$template}' does not exist in the templates directory."; } if (!is_null($siteinfo['error_message'])) { $siteinfo['templates_path'] = CS_TEMPLATES_DIR . DIR_SEP . CS_SYS_TEMPLATES_DIR; $template = '_campsite_error.tpl'; } $tpl->assign('gimme', $context); $tpl->assign('siteinfo', $siteinfo); // on template caching add additional info if ($tpl->templateCacheHandler) { $themesService = \Zend_Registry::get('container')->getService('newscoop_newscoop.themes_service'); $uri = CampSite::GetURIInstance(); $smarty = CampTemplate::singleton(); $tpl->campsiteVector = array_merge($uri->getCampsiteVector(), $smarty->campsiteVector); $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache'); $cacheKey = $cacheService->getCacheKey(array('template', $themesService->getThemePath(), ltrim($template, '/')), 'template'); if ($cacheService->contains($cacheKey)) { $tpl->cache_lifetime = $cacheService->fetch($cacheKey); } else { $templateObj = new Template($themesService->getThemePath() . ltrim($template, '/')); $tpl->cache_lifetime = (int) $templateObj->getCacheLifetime(); $cacheService->save($cacheKey, $tpl->cache_lifetime); } } try { $tpl->display($template); } catch (\Exception $e) { // log samrty errors to sentry channel $logger = \Zend_Registry::get('container')->get('monolog.logger.sentry'); $logger->log(\Psr\Log\LogLevel::CRITICAL, 'Uncaught exception', array('exception' => $e)); CampTemplate::singleton()->trigger_error($e->getMessage(), $tpl); } }
/** * Send comment notification * * @param Newscoop\Entity\Comment $comment * @param Newscoop\Entity\Article $article * @param array $authors * @param Newscoop\Entity\User $user * * @return void */ public function sendCommentNotification(Comment $comment, Article $article, array $authors, User $user = null) { $publicationService = $this->container->get('newscoop_newscoop.publication_service'); $templatesService = $this->container->get('newscoop.templates.service'); $placeholdersService = $this->container->get('newscoop.placeholders.service'); $preferencesService = $this->container->get('preferences'); $translator = $this->container->get('translator'); $emails = array_unique(array_filter(array_map(function ($author) { return $author->getEmail(); }, $authors))); $publication = $publicationService->getPublication(); $moderatorTo = $this->getModeratorEmailIfModerationEnabled($publication, $user); $moderatorTo ? $emails['moderator'] = $moderatorTo : null; $moderatorFrom = $publication->getModeratorFrom(); if (empty($emails)) { return; } $smarty = $templatesService->getSmarty(); $uri = \CampSite::GetURIInstance(); if ($user) { $smarty->assign('username', $user->getUsername()); } else { $smarty->assign('username', $translator->trans('anonymous')); } $smarty->assign('comment', $comment); $smarty->assign('article', new \MetaArticle($article->getLanguageId(), $article->getNumber())); $smarty->assign('publication', $uri->getBase()); $smarty->assign('site', $uri->getBase()); $smarty->assign('articleLink', \ShortURL::GetURI($article->getPublicationId(), $article->getLanguageId(), $article->getIssueId(), $article->getSectionId(), $article->getNumber())); $message = $templatesService->fetchTemplate("email_comment-notify.tpl"); $this->send($placeholdersService->get('subject'), $message, $emails, $moderatorFrom ?: $preferencesService->EmailFromAddress); }
/** * Gets the current URL. * * @return string * The current URL */ public static function GetURL() { $uri = CampSite::GetURIInstance(); return $uri->getURL(); } // fn getURI
function display_upgrade_error($p_errorMessage, $exit = TRUE) { $template = CS_SYS_TEMPLATES_DIR.DIR_SEP.'_campsite_error.tpl'; $templates_dir = CS_TEMPLATES_DIR; $params = array('context' => null, 'template' => $template, 'templates_dir' => $templates_dir, 'error_message' => $p_errorMessage ); $document = CampSite::GetHTMLDocumentInstance(); $document->render($params); if ($exit) exit(0); }