/** * @since 1.11 * @author calguy1000 * @internal * @ignore */ public static function smarty_internal_fetch_contentblock($params, $template) { $smarty = $template->smarty; $gCms = cmsms(); $contentobj = $gCms->variables['content_obj']; $page_id = cmsms()->get_variable('page_id'); if (is_object($contentobj)) { if (!$contentobj->IsPermitted()) { throw new CmsError403Exception(); } $id = ''; $modulename = ''; $action = ''; $inline = false; if (isset($_REQUEST['module'])) { $modulename = $_REQUEST['module']; } if (isset($_REQUEST['id'])) { $id = $_REQUEST['id']; } elseif (isset($_REQUEST['mact'])) { $ary = explode(',', cms_htmlentities($_REQUEST['mact']), 4); $modulename = isset($ary[0]) ? $ary[0] : ''; $id = isset($ary[1]) ? $ary[1] : ''; $action = isset($ary[2]) ? $ary[2] : ''; $inline = isset($ary[3]) && $ary[3] == 1 ? true : false; } if (isset($_REQUEST[$id . 'action'])) { $action = $_REQUEST[$id . 'action']; } else { if (isset($_REQUEST['action'])) { $action = $_REQUEST['action']; } } //Only consider doing module processing if //a. There is no block parameter //b. then // 1. $id is cntnt01 or _preview_ // 2. or inline is false if (!isset($params['block']) && ($id == 'cntnt01' || $id == '_preview_' || $id != '' && $inline == false)) { // todo, would be neat here if we could get a list of only frontend modules. $installedmodules = ModuleOperations::get_instance()->GetInstalledModules(); if (count($installedmodules)) { // case insensitive module match. foreach ($installedmodules as $key) { if (strtolower($modulename) == strtolower($key)) { $modulename = $key; } } if (!isset($modulename) || empty($modulename)) { // no module specified. @trigger_error('Attempt to call a module action, without specifying a valid module name'); return self::content_return('', $params, $smarty); } $modobj = ModuleOperations::get_instance()->get_module_instance($modulename); if (!$modobj) { // module not found... couldn't even autoload it. @trigger_error('Attempt to access module ' . $modulename . ' which could not be found (is it properly installed and configured?'); return self::content_return('', $params, $smarty); } if ($modobj->IsPluginModule()) { @ob_start(); unset($params['block']); unset($params['label']); unset($params['wysiwyg']); unset($params['oneline']); unset($params['default']); unset($params['size']); unset($params['tab']); $params = array_merge($params, GetModuleParameters($id)); $returnid = ''; if (isset($params['returnid'])) { $returnid = $params['returnid']; } else { $returnid = $contentobj->Id(); } $oldcache = $smarty->caching; $smarty->caching = false; $result = $modobj->DoActionBase($action, $id, $params, $returnid); $smarty->caching = $oldcache; if ($result !== FALSE) { echo $result; } $modresult = @ob_get_contents(); @ob_end_clean(); return self::content_return($modresult, $params, $smarty); } else { @trigger_error('Attempt to access module ' . $key . ' which could not be found (is it properly installed and configured?'); return self::content_return("<!-- Not a tag module -->\n", $params, $smarty); } } } else { $block = isset($params['block']) ? $params['block'] : 'content_en'; $result = ''; $oldvalue = $smarty->caching; $smarty->caching = false; if ($id == '_preview_' || $page_id == '__CMS_PREVIEW_PAGE__') { // note: content precompile/postcompile events will not be triggererd in preview. $val = $contentobj->Show($block); $result = $smarty->fetch('string:' . $val); } else { $result = $smarty->fetch(str_replace(' ', '_', 'content:' . $block), '|' . $block, $contentobj->Id() . $block); } $smarty->caching = $oldvalue; return self::content_return($result, $params, $smarty); } } return _smarty_cms_function_content_return('', $params, $smarty); }
function smarty_cms_function_content_image($params, &$smarty) { global $gCms; $pageinfo =& $gCms->variables['pageinfo']; if (!isset($pageinfo) || $pageinfo === FALSE || !isset($pageinfo->content_id)) { return _smarty_cms_function_content_return('', $params, $smarty); } $result = ''; if (isset($params['block'])) { $oldvalue = $smarty->caching; $smarty->caching = false; $result = $smarty->fetch(str_replace(' ', '_', 'content:' . $params['block']), '', $pageinfo->content_id); $smarty->caching = $oldvalue; } $img = _smarty_cms_function_content_return($result, $params, $smarty); if ($img == -1 || empty($img)) { return; } $name = $params['block']; $alt = ''; $width = ''; $height = ''; $urlonly = false; $xid = ''; $class = ''; if (isset($params['name'])) { $name = $params['name']; } if (isset($params['class'])) { $class = $params['class']; } if (isset($params['id'])) { $xid = $params['id']; } if (isset($params['alt'])) { $alt = $params['alt']; } if (isset($params['width'])) { $width = $params['width']; } if (isset($params['height'])) { $height = $params['height']; } if (isset($params['urlonly'])) { $urlonly = true; } if ($urlonly) { return $img; } $out = '<img src="' . $img . '" '; if (!empty($name)) { $out .= 'name="' . $name . '" '; } if (!empty($class)) { $out .= 'class="' . $class . '" '; } if (!empty($xid)) { $out .= 'id="' . $xid . '" '; } if (!empty($width)) { $out .= 'width="' . $width . '" '; } if (!empty($height)) { $out .= 'height="' . $height . '" '; } if (!empty($alt)) { $out .= 'alt="' . $alt . '" '; } $out .= '/>'; return $out; }
function smarty_cms_function_content_image($params, &$smarty) { $gCms = cmsms(); $config = $gCms->GetConfig(); $contentobj = $gCms->variables['content_obj']; if (isset($_SESSION['cms_preview_data']) && $contentobj->Id() == '__CMS_PREVIEW_PAGE__') { // it's a preview. if (!isset($_SESSION['cms_preview_data']['content_obj'])) { $contentops =& $gCms->GetContentOperations(); $_SESSION['cms_preview_data']['content_obj'] = $contentops->LoadContentFromSerializedData($_SESSION['cms_preview_data']); } $contentobj =& $_SESSION['cms_preview_data']['content_obj']; } if (!is_object($contentobj) || $contentobj->Id() <= 0) { return _smarty_cms_function_content_return('', $params, $smarty); } $adddir = get_site_preference('contentimage_path'); if ($params['dir'] != '') { $adddir = $params['dir']; } $dir = cms_join_path($config['uploads_path'], $adddir); $basename = basename($config['uploads_path']); $result = ''; if (isset($params['block'])) { $oldvalue = $smarty->caching; $smarty->caching = false; $result = $smarty->fetch(str_replace(' ', '_', 'content:' . $params['block']), '', $contentobj->Id()); $smarty->caching = $oldvalue; } $img = _smarty_cms_function_content_return($result, $params, $smarty); if ($img == -1 || empty($img)) { return; } // create the absolute url. if (startswith($img, $basename)) { // old style url. if (!startswith($img, 'http')) { $img = str_replace('//', '/', $img); } $img = substr($img, strlen($basename . '/')); $img = $config['uploads_url'] . '/' . $img; } else { $img = $config['uploads_url'] . '/' . $adddir . '/' . $img; } $name = $params['block']; $alt = ''; $width = ''; $height = ''; $urlonly = false; $xid = ''; $class = ''; if (isset($params['name'])) { $name = $params['name']; } if (isset($params['class'])) { $class = $params['class']; } if (isset($params['id'])) { $xid = $params['id']; } if (isset($params['alt'])) { $alt = $params['alt']; } if (isset($params['width'])) { $width = $params['width']; } if (isset($params['height'])) { $height = $params['height']; } if (isset($params['urlonly'])) { $urlonly = true; } if (!isset($params['alt'])) { $alt = $params['block']; } if ($urlonly) { return $img; } $out = '<img src="' . $img . '" '; if (!empty($name)) { $out .= 'name="' . $name . '" '; } if (!empty($class)) { $out .= 'class="' . $class . '" '; } if (!empty($xid)) { $out .= 'id="' . $xid . '" '; } if (!empty($width)) { $out .= 'width="' . $width . '" '; } if (!empty($height)) { $out .= 'height="' . $height . '" '; } if (!empty($alt)) { $out .= 'alt="' . $alt . '" '; } $out .= '/>'; if (isset($params['assign'])) { $smarty->assign(trim($params['assign']), $out); return; } return $out; }
function smarty_cms_function_content($params, &$smarty) { global $gCms; $pageinfo =& $gCms->variables['pageinfo']; if (isset($pageinfo) && $pageinfo !== FALSE && isset($pageinfo->content_id)) { $id = ''; $modulename = ''; $action = ''; $inline = false; if (isset($_REQUEST['module'])) { $modulename = $_REQUEST['module']; } if (isset($_REQUEST['id'])) { $id = $_REQUEST['id']; } elseif (isset($_REQUEST['mact'])) { $ary = explode(',', cms_htmlentities($_REQUEST['mact']), 4); $modulename = isset($ary[0]) ? $ary[0] : ''; $id = isset($ary[1]) ? $ary[1] : ''; $action = isset($ary[2]) ? $ary[2] : ''; $inline = isset($ary[3]) && $ary[3] == 1 ? true : false; } if (isset($_REQUEST[$id . 'action'])) { $action = $_REQUEST[$id . 'action']; } else { if (isset($_REQUEST['action'])) { $action = $_REQUEST['action']; } } //Only consider doing module processing if //a. There is no block parameter //b. then // 1. $id is cntnt01 // 2. or inline is false if (!isset($params['block']) && ($id == 'cntnt01' || $id != '' && $inline == false)) { $cmsmodules =& $gCms->modules; if (isset($cmsmodules)) { foreach ($cmsmodules as $key => $value) { if (strtolower($modulename) == strtolower($key)) { $modulename = $key; } } if (!isset($modulename) || empty($modulename) || !isset($cmsmodules[$modulename])) { // module not found @trigger_error('Attempt to access module ' . $modulename . ' which could not be foune (is it properly installed and configured?'); return _smarty_cms_function_content_return('', $params, $smarty); } if (isset($cmsmodules[$modulename])) { if (isset($cmsmodules[$modulename]['object']) && $cmsmodules[$modulename]['installed'] == true && $cmsmodules[$modulename]['active'] == true && $cmsmodules[$modulename]['object']->IsPluginModule()) { @ob_start(); unset($params['block']); unset($params['label']); unset($params['wysiwyg']); unset($params['oneline']); unset($params['default']); unset($params['size']); $params = array_merge($params, GetModuleParameters($id)); //$params = GetModuleParameters($id); $returnid = ''; if (isset($params['returnid'])) { $returnid = $params['returnid']; } else { $returnid = $pageinfo->content_id; } $result = $cmsmodules[$modulename]['object']->DoActionBase($action, $id, $params, $returnid); if ($result !== FALSE) { echo $result; } $modresult = @ob_get_contents(); @ob_end_clean(); return _smarty_cms_function_content_return($modresult, $params, $smarty); } else { @trigger_error('Attempt to access module ' . $key . ' which could not be foune (is it properly installed and configured?'); return _smarty_cms_function_content_return("<!-- Not a tag module -->\n", $params, $smarty); } } } } else { $result = ''; $oldvalue = $smarty->caching; $smarty->caching = false; $result = $smarty->fetch(str_replace(' ', '_', 'content:' . (isset($params['block']) ? $params['block'] : 'content_en')), '', $pageinfo->content_id); $smarty->caching = $oldvalue; return _smarty_cms_function_content_return($result, $params, $smarty); } } return _smarty_cms_function_content_return('', $params, $smarty); }