48 if (!self::$_oSmarty || $blReload) {
49 $this->_aTemplateDir = array();
50 self::$_oSmarty =
new Smarty();
70 $iDebug = $this->
getConfig()->getConfigParam(
'iDebug');
73 $aViewData = $oObject->getViewData();
74 if (is_array($aViewData)) {
75 foreach (array_keys($aViewData) as $sViewName) {
78 echo(
"TemplateData[$sViewName] : \n");
79 var_export($aViewData[$sViewName]);
81 $oSmarty->assign_by_ref($sViewName, $aViewData[$sViewName]);
85 return $oSmarty->fetch($sTemplate);
96 if (count($aErrors) > 0) {
97 foreach ($aErrors as $sLocation => $aEx2) {
98 foreach ($aEx2 as $sKey => $oEr) {
99 $aView[
'Errors'][$sLocation][$sKey] = unserialize($oEr);
116 public function addErrorToDisplay($oEr, $blFull =
false, $blCustomDestination =
false, $sCustomDestination =
"", $sActiveController =
"")
118 if ($blCustomDestination && (
oxRegistry::getConfig()->getRequestParameter(
'CustomError') || $sCustomDestination !=
'')) {
121 if ($sCustomDestination !=
'') {
122 $sDestination = $sCustomDestination;
126 $sDestination =
'default';
132 if (!$oSession->getId() && !$oSession->isHeaderSent()) {
133 $oSession->setForceNewSession();
139 $oEx =
oxNew(
'oxExceptionToDisplay');
140 $oEx->setMessage($oEr->getMessage());
141 $oEx->setExceptionType(get_class($oEr));
144 $oEx->setMessageArgs($oEr->getComponent());
147 $oEx->setValues($oEr->getValues());
148 $oEx->setStackTrace($oEr->getTraceAsString());
149 $oEx->setDebug($blFull);
154 $oEr =
oxNew(
'oxDisplayError');
155 $oEr->setMessage($sTmp);
156 } elseif ($oEr instanceof oxIDisplayError) {
163 $aEx[$sDestination][] = serialize($oEr);
166 if ($sActiveController ==
'') {
169 if ($sActiveController) {
170 $aControllerErrors[$sDestination] = $sActiveController;
194 startProfile(
"parseThroughSmarty");
196 if (!is_array($sDesc) && strpos($sDesc,
"[{") ===
false) {
197 stopProfile(
"parseThroughSmarty");
208 $sTplVars = $oSmarty->_tpl_vars;
209 $blForceRecompile = $oSmarty->force_compile;
211 $oSmarty->force_compile = $blRecompile;
214 $oActView =
oxNew(
'oxubase');
215 $oActView->addGlobalParams();
218 $aViewData = $oActView->getViewData();
219 foreach (array_keys($aViewData) as $sName) {
220 $oSmarty->assign_by_ref($sName, $aViewData[$sName]);
223 if (is_array($sDesc)) {
224 foreach ($sDesc as $sName => $aData) {
226 $sRes[$sName] = $oSmarty->fetch(
"ox:" . $aData[0] . $iLang);
230 $sRes = $oSmarty->fetch(
"ox:{$sOxid}{$iLang}");
234 $oSmarty->_tpl_vars = $sTplVars;
235 $oSmarty->force_compile = $blForceRecompile;
237 stopProfile(
"parseThroughSmarty");
249 if ($sTplDir && !in_array($sTplDir, $this->_aTemplateDir)) {
250 $this->_aTemplateDir[] = $sTplDir;
281 $sShopId = $this->
getConfig()->getShopId();
283 $sDir = reset($aDirs);
285 return md5($sDir .
'__' . $sShopId);
298 $sCompileDir =
$myConfig->getConfigParam(
'sCompileDir');
299 $sSmartyDir = $sCompileDir .
"/smarty/";
300 if (!is_dir($sSmartyDir)) {
304 if (!is_writable($sSmartyDir)) {
305 $sSmartyDir = $sCompileDir;
319 $oSmarty->left_delimiter =
'[{';
320 $oSmarty->right_delimiter =
'}]';
322 $oSmarty->register_resource(
323 'ox', array(
'ox_get_template',
331 $oSmarty->caching =
false;
332 $oSmarty->compile_dir = $sSmartyDir;
333 $oSmarty->cache_dir = $sSmartyDir;
337 $oSmarty->default_template_handler_func = array(
oxRegistry::get(
"oxUtilsView"),
'_smartyDefaultTemplateHandler');
339 include_once dirname(__FILE__) .
'/smarty/plugins/prefilter.oxblock.php';
340 $oSmarty->register_prefilter(
'smarty_prefilter_oxblock');
342 $iDebug =
$myConfig->getConfigParam(
'iDebug');
343 if ($iDebug == 1 || $iDebug == 3 || $iDebug == 4) {
344 $oSmarty->debugging =
true;
347 if ($iDebug == 8 && !
$myConfig->isAdmin()) {
348 include_once getShopBasePath() .
'core/smarty/plugins/prefilter.oxtpldebug.php';
349 $oSmarty->register_prefilter(
'smarty_prefilter_oxtpldebug');
354 $oSmarty->php_handling = (int)
$myConfig->getConfigParam(
'iSmartyPhpHandling');
355 $oSmarty->security =
false;
357 $oSmarty->php_handling = SMARTY_PHP_REMOVE;
358 $oSmarty->security =
true;
359 $oSmarty->security_settings[
'IF_FUNCS'][] =
'XML_ELEMENT_NODE';
360 $oSmarty->security_settings[
'IF_FUNCS'][] =
'is_int';
361 $oSmarty->security_settings[
'MODIFIER_FUNCS'][] =
'round';
362 $oSmarty->security_settings[
'MODIFIER_FUNCS'][] =
'floor';
363 $oSmarty->security_settings[
'MODIFIER_FUNCS'][] =
'trim';
364 $oSmarty->security_settings[
'MODIFIER_FUNCS'][] =
'implode';
365 $oSmarty->security_settings[
'MODIFIER_FUNCS'][] =
'is_array';
366 $oSmarty->security_settings[
'MODIFIER_FUNCS'][] =
'getimagesize';
367 $oSmarty->security_settings[
'ALLOW_CONSTANTS'] =
true;
368 $oSmarty->secure_dir = $oSmarty->template_dir;
380 $oSmarty->compile_check =
$myConfig->getConfigParam(
'blCheckTemplates');
398 if ($sResourceType ==
'file' && !is_readable($sResourceName)) {
400 $sResourceContent = $oSmarty->_read_file($sResourceName);
401 $sResourceTimestamp = filemtime($sResourceName);
403 return is_file($sResourceName) && is_readable($sResourceName);
423 $sModulePath = $aModuleInfo[$sModule];
425 if (substr($sFile, -4) !=
'.tpl') {
426 $sFile = $sFile .
".tpl";
429 if (basename($sFile) == $sFile) {
430 $sFile =
"out/blocks/$sFile";
432 $sFileName = $this->
getConfig()->getConfigParam(
'sShopDir') .
"/modules/$sModulePath/$sFile";
433 if (file_exists($sFileName) && is_readable($sFileName)) {
434 return file_get_contents($sFileName);
437 $oException =
oxNew(
"oxException",
"Template block file ($sFileName) not found for '$sModule' module.");
455 $sTplDir = trim($oConfig->getConfigParam(
'_sTemplateDir'),
'/\\');
456 $sFile = str_replace(array(
'\\',
'//'),
'/', $sFile);
457 if (preg_match(
'@/' . preg_quote($sTplDir,
'@') .
'/(.*)$@', $sFile, $m)) {
462 $sFileParam = $oDb->quote($sFile);
463 $sShpIdParam = $oDb->quote($oConfig->getShopId());
467 if ($this->_blIsTplBlocks === null) {
468 $this->_blIsTplBlocks =
false;
471 $sSql =
"select COUNT(*) from oxtplblocks where oxactive=1 and oxshopid=$sShpIdParam and oxmodule in ( " . implode(
", ",
oxDb::getInstance()->quoteArray(array_keys($aIds))) .
" ) ";
472 $rs = $oDb->getOne($sSql);
474 $this->_blIsTplBlocks =
true;
479 if ($this->_blIsTplBlocks) {
482 $sSql =
"select * from oxtplblocks where oxactive=1 and oxshopid=$sShpIdParam and oxtemplate=$sFileParam and oxmodule in ( " . implode(
", ",
oxDb::getInstance()->quoteArray(array_keys($aIds))) .
" ) order by oxpos asc";
484 $rs = $oDb->select($sSql);
486 if ($rs !=
false && $rs->recordCount() > 0) {
489 if (!is_array($aRet[$rs->fields[
'OXBLOCKNAME']])) {
490 $aRet[$rs->fields[
'OXBLOCKNAME']] = array();
492 $aRet[$rs->fields[
'OXBLOCKNAME']][] = $this->
_getTemplateBlock($rs->fields[
'OXMODULE'], $rs->fields[
'OXFILE']);
512 if ($this->_aActiveModuleInfo === null) {
513 $oModulelist =
oxNew(
'oxmodulelist');
514 $this->_aActiveModuleInfo = $oModulelist->getActiveModuleInfo();