66 if ( !self::$_oSmarty || $blReload ) {
67 self::$_oSmarty =
new Smarty();
87 $iDebug = $this->
getConfig()->getConfigParam(
'iDebug' );
90 $aViewData = $oObject->getViewData();
91 if ( is_array( $aViewData ) ) {
92 foreach ( array_keys( $aViewData ) as $sViewName ) {
95 echo(
"TemplateData[$sViewName] : \n");
96 var_export( $aViewData[$sViewName] );
98 $oSmarty->assign_by_ref( $sViewName, $aViewData[$sViewName] );
102 return $oSmarty->fetch( $sTemplate );
115 if ( count( $aErrors ) > 0 ) {
116 foreach ( $aErrors as $sLocation => $aEx2 ) {
117 foreach ( $aEx2 as $sKey => $oEr ) {
118 $aView[
'Errors'][$sLocation][$sKey] = unserialize( $oEr );
137 public function addErrorToDisplay( $oEr, $blFull =
false, $blCustomDestination =
false, $sCustomDestination =
"", $sActiveController =
"" )
142 if ( $sCustomDestination !=
'' ) {
143 $sDestination = $sCustomDestination;
147 $sDestination =
'default';
153 if ( !$oSession->getId() && !$oSession->isHeaderSent() ) {
154 $oSession->setForceNewSession();
160 $oEx =
oxNew(
'oxExceptionToDisplay' );
161 $oEx->setMessage( $oEr->getMessage() );
162 $oEx->setExceptionType( get_class( $oEr ) );
165 $oEx->setMessageArgs( $oEr->getComponent() );
168 $oEx->setValues( $oEr->getValues() );
169 $oEx->setStackTrace( $oEr->getTraceAsString() );
170 $oEx->setDebug( $blFull );
175 $oEr =
oxNew(
'oxDisplayError' );
176 $oEr->setMessage( $sTmp );
177 } elseif ( $oEr instanceof oxIDisplayError ) {
184 $aEx[$sDestination][] = serialize( $oEr );
187 if ( $sActiveController ==
'' ) {
190 if ( $sActiveController ) {
191 $aControllerErrors[$sDestination] = $sActiveController;
215 startProfile(
"parseThroughSmarty");
217 if (!is_array($sDesc) && strpos($sDesc,
"[{") ===
false) {
218 stopProfile(
"parseThroughSmarty");
228 $sTplVars = $oSmarty->_tpl_vars;
229 $blForceRecompile = $oSmarty->force_compile;
231 $oSmarty->force_compile = $blRecompile;
234 $oActView =
oxNew(
'oxubase' );
235 $oActView->addGlobalParams();
238 $aViewData = $oActView->getViewData();
239 foreach ( array_keys( $aViewData ) as $sName ) {
240 $oSmarty->assign_by_ref( $sName, $aViewData[$sName] );
243 if ( is_array( $sDesc ) ) {
244 foreach ( $sDesc as $sName => $aData ) {
246 $sRes[$sName] = $oSmarty->fetch(
"ox:".$aData[0].$iLang );
250 $sRes = $oSmarty->fetch(
"ox:{$sOxid}{$iLang}" );
254 $oSmarty->_tpl_vars = $sTplVars;
255 $oSmarty->force_compile = $blForceRecompile;
257 stopProfile(
"parseThroughSmarty");
271 if ( $sTplDir && !in_array( $sTplDir, $this->_aTemplateDir ) ) {
272 $this->_aTemplateDir[] = $sTplDir;
303 $sShopId = $this->
getConfig()->getShopId();
305 $sDir = reset($aDirs);
306 return md5( $sDir.
'__'.$sShopId );
319 $sCompileDir =
$myConfig->getConfigParam(
'sCompileDir' );
320 $sSmartyDir = $sCompileDir .
"/smarty/";
321 if ( !is_dir( $sSmartyDir ) ) {
325 if ( !is_writable($sSmartyDir) ) {
326 $sSmartyDir = $sCompileDir;
342 $oSmarty->left_delimiter =
'[{';
343 $oSmarty->right_delimiter =
'}]';
345 $oSmarty->register_resource(
'ox', array(
'ox_get_template',
348 'ox_get_trusted' ) );
353 $oSmarty->caching =
false;
354 $oSmarty->compile_dir = $sSmartyDir;
355 $oSmarty->cache_dir = $sSmartyDir;
359 $oSmarty->default_template_handler_func = array(
oxRegistry::get(
"oxUtilsView"),
'_smartyDefaultTemplateHandler');
361 include_once dirname(__FILE__).
'/smarty/plugins/prefilter.oxblock.php';
362 $oSmarty->register_prefilter(
'smarty_prefilter_oxblock');
364 $iDebug =
$myConfig->getConfigParam(
'iDebug' );
365 if ( $iDebug == 1 || $iDebug == 3 || $iDebug == 4 ) {
366 $oSmarty->debugging =
true;
369 if ($iDebug == 8 && !
$myConfig->isAdmin()) {
370 include_once getShopBasePath().
'core/smarty/plugins/prefilter.oxtpldebug.php';
371 $oSmarty->register_prefilter(
'smarty_prefilter_oxtpldebug');
376 $oSmarty->php_handling = (int)
$myConfig->getConfigParam(
'iSmartyPhpHandling' );
377 $oSmarty->security =
false;
379 $oSmarty->php_handling = SMARTY_PHP_REMOVE;
380 $oSmarty->security =
true;
381 $oSmarty->security_settings[
'IF_FUNCS'][] =
'XML_ELEMENT_NODE';
382 $oSmarty->security_settings[
'MODIFIER_FUNCS'][] =
'round';
383 $oSmarty->security_settings[
'MODIFIER_FUNCS'][] =
'floor';
384 $oSmarty->security_settings[
'MODIFIER_FUNCS'][] =
'trim';
385 $oSmarty->security_settings[
'MODIFIER_FUNCS'][] =
'implode';
386 $oSmarty->security_settings[
'MODIFIER_FUNCS'][] =
'is_array';
387 $oSmarty->security_settings[
'ALLOW_CONSTANTS'] =
true;
388 $oSmarty->secure_dir = $oSmarty->template_dir;
402 $oSmarty->compile_check =
$myConfig->getConfigParam(
'blCheckTemplates' );
420 if ( $sResourceType ==
'file' && !is_readable($sResourceName) ) {
422 $sResourceContent = $oSmarty->_read_file($sResourceName);
423 $sResourceTimestamp = filemtime($sResourceName);
424 return is_file($sResourceName) && is_readable($sResourceName);
443 $sModulePath = $aModuleInfo[$sModule];
445 if ( substr($sFile, -4) !=
'.tpl' ) {
446 $sFile = $sFile .
".tpl";
449 if ( basename($sFile) == $sFile ) {
450 $sFile =
"out/blocks/$sFile";
452 $sFileName = $this->
getConfig()->getConfigParam(
'sShopDir' ).
"/modules/$sModulePath/$sFile";
453 if ( file_exists($sFileName) && is_readable($sFileName) ) {
454 return file_get_contents($sFileName);
456 throw oxNew(
"oxException",
"Template block file ($sFileName) not found for '$sModule' module." );
473 $sTplDir = trim($oConfig->getConfigParam(
'_sTemplateDir'),
'/\\');
474 $sFile = str_replace(array(
'\\',
'//'),
'/', $sFile);
475 if (preg_match(
'@/'.preg_quote($sTplDir,
'@').
'/(.*)$@', $sFile, $m)) {
480 $sFileParam = $oDb->quote($sFile);
481 $sShpIdParam = $oDb->quote($oConfig->getShopId());
485 if ( $this->_blIsTplBlocks === null ) {
486 $this->_blIsTplBlocks =
false;
489 $sSql =
"select COUNT(*) from oxtplblocks where oxactive=1 and oxshopid=$sShpIdParam and oxmodule in ( " . implode(
", ",
oxDb::getInstance()->quoteArray(array_keys($aIds)) ) .
" ) ";
490 $rs = $oDb->getOne( $sSql );
492 $this->_blIsTplBlocks =
true;
497 if ( $this->_blIsTplBlocks ) {
500 $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";
502 $rs = $oDb->select( $sSql );
504 if ($rs !=
false && $rs->recordCount() > 0) {
507 if (!is_array($aRet[$rs->fields[
'OXBLOCKNAME']])) {
508 $aRet[$rs->fields[
'OXBLOCKNAME']] = array();
510 $aRet[$rs->fields[
'OXBLOCKNAME']][] = $this->
_getTemplateBlock($rs->fields[
'OXMODULE'], $rs->fields[
'OXFILE']);
530 if ($this->_aActiveModuleInfo === null) {
531 $oModulelist =
oxNew(
'oxmodulelist');
532 $this->_aActiveModuleInfo = $oModulelist->getActiveModuleInfo();