/** * show the template * * @access public * @param string $sName name of the template * @param \Apollina\Template $oTemplate datas to add * @return bool */ public function display($sName = null, \Apollina\Template $oTemplate = null) { if ($oTemplate !== null) { if ($this->_oTemplateLink !== null) { $aVar = $this->getAllAssign(); $aVar = array_merge($aVar, $this->_oTemplateLink->getAllAssign()); $this->assignAll($aVar); } } $sTemplate = $this->fetch($sName); echo $sTemplate; }
/** * run before * * @access public * @param array $aParams parameters * @return \Apollina\Template\ToInclude */ public function replaceBy($aParams = array()) { $aParams['to_include'] = $aParams['real_name']; $sViewDirectory = Template::getBasePath(); $sCacheDirectory = Template::getCachePath(); if (class_exists('\\Mobile_Detect')) { $oMobileDetect = new \Mobile_Detect(); } else { $oMobileDetect = null; } if ($oMobileDetect !== null && $oMobileDetect->isMobile() && file_exists(str_replace('lib/Template/Functions', '../../..', __DIR__) . str_replace('.tpl', 'Mobile.tpl', $aParams['real_name']))) { eval('$oTemplate = new \\Apollina\\Template("' . str_replace('.tpl', 'Mobile.tpl', $aParams['real_name']) . '"); $oTemplate->fetch(null, false);'); } else { eval('$oTemplate = new \\Apollina\\Template("' . str_replace("\\", "/", $aParams['real_name']) . '"); $oTemplate->fetch(null, false);'); } if (strstr($aParams['file'], '$_aProtectedVar[\'model\']')) { return '<?php ' . $aParams['file'] . ' = str_replace("\\\\", "/", ' . $aParams['file'] . '); if (!strstr(' . $aParams['file'] . ', \'/\')) { ' . $aParams['file'] . ' = "src/' . PORTAL . '/View/".' . $aParams['file'] . '; } if (class_exists(\'\\Mobile_Detect\')) { $oMobileDetect = new \\Mobile_Detect; } else { $oMobileDetect = null; } if ($oMobileDetect !== null && $oMobileDetect->isMobile()) { if (file_exists(\'' . $sCacheDirectory . '\'.md5(' . str_replace('.tpl', 'Mobile.tpl', $aParams['file']) . ').".cac.php")) { include \'' . $sCacheDirectory . '\'.md5(' . str_replace('.tpl', 'Mobile.tpl', $aParams['file']) . ').".cac.php"; } else { include \'' . $sCacheDirectory . '\'.md5(' . $aParams['file'] . ').".cac.php"; }} else { include \'' . $sCacheDirectory . '\'.md5(' . $aParams['file'] . ').".cac.php"; } ?' . '>'; } else { return '<?php if (class_exists(\'\\Mobile_Detect\')) { $oMobileDetect = new \\Mobile_Detect; } else { $oMobileDetect = null; } if ($oMobileDetect !== null && $oMobileDetect->isMobile()) { if (file_exists("' . $sCacheDirectory . '".md5("' . str_replace('.tpl', 'Mobile.tpl', $aParams['to_include']) . '").".cac.php")) { include "' . $sCacheDirectory . '".md5("' . str_replace('.tpl', 'Mobile.tpl', $aParams['to_include']) . '").".cac.php"; } else { include "' . $sCacheDirectory . '".md5("' . $aParams['to_include'] . '").".cac.php"; } } else { include "' . $sCacheDirectory . '".md5("' . $aParams['to_include'] . '").".cac.php"; } ?' . '>'; } }