/**
  * @param bool $bAdmin = false
  * @param bool $bJsOutput = true
  *
  * @return string
  */
 public function compileTemplates($bAdmin = false, $bJsOutput = true)
 {
     $aTemplates = array();
     \RainLoop\Utils::CompileTemplates($aTemplates, APP_VERSION_ROOT_PATH . 'app/templates/Views/Components', 'Component');
     \RainLoop\Utils::CompileTemplates($aTemplates, APP_VERSION_ROOT_PATH . 'app/templates/Views/' . ($bAdmin ? 'Admin' : 'User'));
     \RainLoop\Utils::CompileTemplates($aTemplates, APP_VERSION_ROOT_PATH . 'app/templates/Views/Common');
     $this->oActions->Plugins()->CompileTemplate($aTemplates, $bAdmin);
     $sHtml = '';
     foreach ($aTemplates as $sName => $sFile) {
         $sName = \preg_replace('/[^a-zA-Z0-9]/', '', $sName);
         $sHtml .= '<script id="' . $sName . '" type="text/html" data-cfasync="false">' . $this->oActions->ProcessTemplate($sName, \file_get_contents($sFile)) . '</script>';
     }
     unset($aTemplates);
     return $bJsOutput ? 'window.rainloopTEMPLATES=' . \MailSo\Base\Utils::Php2js(array($sHtml), $this->Logger()) . ';' : $sHtml;
 }
示例#2
0
 /**
  * @param string $sDirName
  * @param \RainLoop\Actions $oAction
  * @param string $sNameSuffix = ''
  *
  * @return string
  */
 public static function CompileTemplates($sDirName, $oAction, $sNameSuffix = '')
 {
     $sResult = '';
     if (\file_exists($sDirName)) {
         $aList = \RainLoop\Utils::FolderFiles($sDirName, '.html');
         foreach ($aList as $sName) {
             $sTemplateName = \substr($sName, 0, -5) . $sNameSuffix;
             $sResult .= '<script id="' . \preg_replace('/[^a-zA-Z0-9]/', '', $sTemplateName) . '" type="text/html" data-cfasync="false">' . $oAction->ProcessTemplate($sTemplateName, \file_get_contents($sDirName . '/' . $sName)) . '</script>';
         }
         $sResult = \trim($sResult);
     }
     return $sResult;
 }