48 if (!self::$_oSmarty || $blReload) {
49 self::$_oSmarty =
new Smarty();
69 $iDebug = $this->
getConfig()->getConfigParam(
'iDebug');
72 $aViewData = $oObject->getViewData();
73 if (is_array($aViewData)) {
74 foreach (array_keys($aViewData) as $sViewName) {
77 echo(
"TemplateData[$sViewName] : \n");
78 var_export($aViewData[$sViewName]);
80 $oSmarty->assign_by_ref($sViewName, $aViewData[$sViewName]);
84 return $oSmarty->fetch($sTemplate);
95 if (count($aErrors) > 0) {
96 foreach ($aErrors as $sLocation => $aEx2) {
97 foreach ($aEx2 as $sKey => $oEr) {
98 $aView[
'Errors'][$sLocation][$sKey] = unserialize($oEr);
115 public function addErrorToDisplay($oEr, $blFull =
false, $blCustomDestination =
false, $sCustomDestination =
"", $sActiveController =
"")
117 if ($blCustomDestination && (
oxRegistry::getConfig()->getRequestParameter(
'CustomError') || $sCustomDestination !=
'')) {
120 if ($sCustomDestination !=
'') {
121 $sDestination = $sCustomDestination;
125 $sDestination =
'default';
131 if (!$oSession->getId() && !$oSession->isHeaderSent()) {
132 $oSession->setForceNewSession();
138 $oEx =
oxNew(
'oxExceptionToDisplay');
139 $oEx->setMessage($oEr->getMessage());
140 $oEx->setExceptionType(get_class($oEr));
143 $oEx->setMessageArgs($oEr->getComponent());
146 $oEx->setValues($oEr->getValues());
147 $oEx->setStackTrace($oEr->getTraceAsString());
148 $oEx->setDebug($blFull);
153 $oEr =
oxNew(
'oxDisplayError');
154 $oEr->setMessage($sTmp);
155 } elseif ($oEr instanceof oxIDisplayError) {
162 $aEx[$sDestination][] = serialize($oEr);
165 if ($sActiveController ==
'') {
168 if ($sActiveController) {
169 $aControllerErrors[$sDestination] = $sActiveController;
193 startProfile(
"parseThroughSmarty");
195 if (!is_array($sDesc) && strpos($sDesc,
"[{") ===
false) {
196 stopProfile(
"parseThroughSmarty");
207 $sTplVars = $oSmarty->_tpl_vars;
208 $blForceRecompile = $oSmarty->force_compile;
210 $oSmarty->force_compile = $blRecompile;
213 $oActView =
oxNew(
'oxubase');
214 $oActView->addGlobalParams();
217 $aViewData = $oActView->getViewData();
218 foreach (array_keys($aViewData) as $sName) {
219 $oSmarty->assign_by_ref($sName, $aViewData[$sName]);
222 if (is_array($sDesc)) {
223 foreach ($sDesc as $sName => $aData) {
225 $sRes[$sName] = $oSmarty->fetch(
"ox:" . $aData[0] . $iLang);
229 $sRes = $oSmarty->fetch(
"ox:{$sOxid}{$iLang}");
233 $oSmarty->_tpl_vars = $sTplVars;
234 $oSmarty->force_compile = $blForceRecompile;
236 stopProfile(
"parseThroughSmarty");
248 if ($sTplDir && !in_array($sTplDir, $this->_aTemplateDir)) {
249 $this->_aTemplateDir[] = $sTplDir;
280 $sShopId = $this->
getConfig()->getShopId();
282 $sDir = reset($aDirs);
284 return md5($sDir .
'__' . $sShopId);
297 $sCompileDir =
$myConfig->getConfigParam(
'sCompileDir');
298 $sSmartyDir = $sCompileDir .
"/smarty/";
299 if (!is_dir($sSmartyDir)) {
303 if (!is_writable($sSmartyDir)) {
304 $sSmartyDir = $sCompileDir;
318 $oSmarty->left_delimiter =
'[{';
319 $oSmarty->right_delimiter =
'}]';
321 $oSmarty->register_resource(
322 'ox', array(
'ox_get_template',
330 $oSmarty->caching =
false;
331 $oSmarty->compile_dir = $sSmartyDir;
332 $oSmarty->cache_dir = $sSmartyDir;
336 $oSmarty->default_template_handler_func = array(
oxRegistry::get(
"oxUtilsView"),
'_smartyDefaultTemplateHandler');
338 include_once dirname(__FILE__) .
'/smarty/plugins/prefilter.oxblock.php';
339 $oSmarty->register_prefilter(
'smarty_prefilter_oxblock');
341 $iDebug =
$myConfig->getConfigParam(
'iDebug');
342 if ($iDebug == 1 || $iDebug == 3 || $iDebug == 4) {
343 $oSmarty->debugging =
true;
346 if ($iDebug == 8 && !
$myConfig->isAdmin()) {
347 include_once getShopBasePath() .
'core/smarty/plugins/prefilter.oxtpldebug.php';
348 $oSmarty->register_prefilter(
'smarty_prefilter_oxtpldebug');
353 $oSmarty->php_handling = (int)
$myConfig->getConfigParam(
'iSmartyPhpHandling');
354 $oSmarty->security =
false;
356 $oSmarty->php_handling = SMARTY_PHP_REMOVE;
357 $oSmarty->security =
true;
358 $oSmarty->security_settings[
'IF_FUNCS'][] =
'XML_ELEMENT_NODE';
359 $oSmarty->security_settings[
'IF_FUNCS'][] =
'is_int';
360 $oSmarty->security_settings[
'MODIFIER_FUNCS'][] =
'round';
361 $oSmarty->security_settings[
'MODIFIER_FUNCS'][] =
'floor';
362 $oSmarty->security_settings[
'MODIFIER_FUNCS'][] =
'trim';
363 $oSmarty->security_settings[
'MODIFIER_FUNCS'][] =
'implode';
364 $oSmarty->security_settings[
'MODIFIER_FUNCS'][] =
'is_array';
365 $oSmarty->security_settings[
'ALLOW_CONSTANTS'] =
true;
366 $oSmarty->secure_dir = $oSmarty->template_dir;
378 $oSmarty->compile_check =
$myConfig->getConfigParam(
'blCheckTemplates');
396 if ($sResourceType ==
'file' && !is_readable($sResourceName)) {
398 $sResourceContent = $oSmarty->_read_file($sResourceName);
399 $sResourceTimestamp = filemtime($sResourceName);
401 return is_file($sResourceName) && is_readable($sResourceName);
418 protected function _getTemplateBlock($sModule, $sFile)
421 $sModulePath = $aModuleInfo[$sModule];
423 if (substr($sFile, -4) !=
'.tpl') {
424 $sFile = $sFile .
".tpl";
427 if (basename($sFile) == $sFile) {
428 $sFile =
"out/blocks/$sFile";
430 $sFileName = $this->
getConfig()->getConfigParam(
'sShopDir') .
"/modules/$sModulePath/$sFile";
431 if (file_exists($sFileName) && is_readable($sFileName)) {
432 return file_get_contents($sFileName);
435 $oException =
oxNew(
"oxException",
"Template block file ($sFileName) not found for '$sModule' module.");
453 $sTplDir = trim($oConfig->getConfigParam(
'_sTemplateDir'),
'/\\');
454 $sFile = str_replace(array(
'\\',
'//'),
'/', $sFile);
455 if (preg_match(
'@/' . preg_quote($sTplDir,
'@') .
'/(.*)$@', $sFile, $m)) {
460 $sFileParam = $oDb->quote($sFile);
461 $sShpIdParam = $oDb->quote($oConfig->getShopId());
465 if ($this->_blIsTplBlocks === null) {
466 $this->_blIsTplBlocks =
false;
469 $sSql =
"select COUNT(*) from oxtplblocks where oxactive=1 and oxshopid=$sShpIdParam and oxmodule in ( " . implode(
", ",
oxDb::getInstance()->quoteArray(array_keys($aIds))) .
" ) ";
470 $rs = $oDb->getOne($sSql);
472 $this->_blIsTplBlocks =
true;
477 if ($this->_blIsTplBlocks) {
480 $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";
482 $rs = $oDb->select($sSql);
484 if ($rs !=
false && $rs->recordCount() > 0) {
487 if (!is_array($aRet[$rs->fields[
'OXBLOCKNAME']])) {
488 $aRet[$rs->fields[
'OXBLOCKNAME']] = array();
490 $aRet[$rs->fields[
'OXBLOCKNAME']][] = $this->_getTemplateBlock($rs->fields[
'OXMODULE'], $rs->fields[
'OXFILE']);
510 if ($this->_aActiveModuleInfo === null) {
511 $oModulelist =
oxNew(
'oxmodulelist');
512 $this->_aActiveModuleInfo = $oModulelist->getActiveModuleInfo();