예제 #1
0
 static function createCommonCompileTemplate()
 {
     $php = new eZPHPCreator(eZTemplateCompiler::compilationDirectory(), 'common.php');
     if ($php->exists()) {
         return;
     }
     $php->addComment("This file contains functions which are common to all compiled templates.\n\n" . 'NOTE: This file is autogenerated and should not be modified, any changes will be lost!');
     $php->addSpace();
     $php->addDefine('EZ_TEMPLATE_COMPILER_COMMON_CODE', true);
     $php->addSpace();
     $namespaceStack = array();
     $php->addCodePiece("if ( !isset( \$namespaceStack ) )\n");
     $php->addVariable('namespaceStack', $namespaceStack, eZPHPCreator::VARIABLE_ASSIGNMENT, array('spacing' => 4));
     $php->addSpace();
     $lbracket = '{';
     $rbracket = '}';
     $initText = "if ( !function_exists( 'compiledfetchvariable' ) )\n{$lbracket}\n    function compiledFetchVariable( \$vars, \$namespace, \$name )\n    {$lbracket}\n        \$exists = ( array_key_exists( \$namespace, \$vars ) and\n                    array_key_exists( \$name, \$vars[\$namespace] ) );\n        if ( \$exists )\n        {$lbracket}\n            return \$vars[\$namespace][\$name];\n        {$rbracket}\n        return null;\n    {$rbracket}\n{$rbracket}\nif ( !function_exists( 'compiledfetchtext' ) )\n{$lbracket}\n    function compiledFetchText( \$tpl, \$rootNamespace, \$currentNamespace, \$namespace, \$var )\n    {$lbracket}\n        \$text = '';\n        \$tpl->appendElement( \$text, \$var, \$rootNamespace, \$currentNamespace );\n        return \$text;\n    {$rbracket}\n{$rbracket}\nif ( !function_exists( 'compiledAcquireResource' ) )\n{$lbracket}\n    function compiledAcquireResource( \$phpScript, \$key, &\$originalText,\n                                      \$tpl, \$rootNamespace, \$currentNamespace )\n    {\n        include( '" . eZTemplateCompiler::TemplatePrefix() . "' . \$phpScript );\n        if ( isset( \$text ) )\n        {\n            \$originalText .= \$text;\n            return true;\n        }\n        return false;\n    }\n{$rbracket}\nif ( !function_exists( 'compiledfetchattribute' ) )\n{$lbracket}\n    function compiledFetchAttribute( \$value, \$attributeValue )\n    {$lbracket}\n        if ( is_object( \$value ) )\n        {$lbracket}\n            if ( method_exists( \$value, \"attribute\" ) and\n                 method_exists( \$value, \"hasattribute\" ) )\n            {$lbracket}\n                if ( \$value->hasAttribute( \$attributeValue ) )\n                {$lbracket}\n                    return \$value->attribute( \$attributeValue );\n                {$rbracket}\n            {$rbracket}\n        {$rbracket}\n        else if ( is_array( \$value ) )\n        {$lbracket}\n            if ( isset( \$value[\$attributeValue] ) )\n            {$lbracket}\n                return \$value[\$attributeValue];\n            {$rbracket}\n        {$rbracket}\n        return null;\n    {$rbracket}\n{$rbracket}\n";
     $php->addCodePiece($initText);
     $php->store(true);
 }
예제 #2
0
 static function storeCache($key)
 {
     $translationCache = eZTranslationCache::cacheTable();
     if (!isset($translationCache[$key])) {
         eZDebug::writeWarning("Translation cache for key '{$key}' does not exist, cannot store cache", __METHOD__);
         return;
     }
     $internalCharset = eZTextCodec::internalCharset();
     //         $cacheFileKey = "$key-$internalCharset";
     $cacheFileKey = $key;
     $cacheFileName = md5($cacheFileKey) . '.php';
     $cache =& $translationCache[$key];
     if (!file_exists(eZTranslationCache::cacheDirectory())) {
         eZDir::mkdir(eZTranslationCache::cacheDirectory(), false, true);
     }
     $php = new eZPHPCreator(eZTranslationCache::cacheDirectory(), $cacheFileName);
     $php->addRawVariable('eZTranslationCacheCodeDate', self::CODE_DATE);
     $php->addSpace();
     $php->addRawVariable('CacheInfo', array('charset' => $internalCharset));
     $php->addRawVariable('TranslationInfo', $cache['info']);
     $php->addSpace();
     $php->addRawVariable('TranslationRoot', $cache['root']);
     $php->store();
 }
예제 #3
0
 static function storeCache($key, $templateFilepath)
 {
     if (!eZTemplateTreeCache::isCacheEnabled()) {
         return false;
     }
     $templateCache =& eZTemplateTreeCache::cacheTable();
     $key = eZTemplateTreeCache::internalKey($key);
     if (!isset($templateCache[$key])) {
         eZDebug::writeDebug("Template cache for key '{$key}' does not exist, cannot store cache", __METHOD__);
         return;
     }
     $cacheFileName = eZTemplateTreeCache::treeCacheFilename($key, $templateFilepath);
     $cache =& $templateCache[$key];
     $php = new eZPHPCreator(eZTemplateTreeCache::cacheDirectory(), $cacheFileName);
     $php->addVariable('eZTemplateTreeCacheCodeDate', eZTemplateTreeCache::CODE_DATE);
     $php->addSpace();
     $php->addVariable('TemplateInfo', $cache['info']);
     $php->addSpace();
     $php->addVariable('TemplateRoot', $cache['root']);
     $php->store();
 }
예제 #4
0
 function storeCache($directory = false)
 {
     if (!file_exists($directory)) {
         eZDir::mkdir($directory, false, true);
     }
     $php = new eZPHPCreator($directory, 'package.php');
     $php->addComment("Automatically created cache file for the package format\n" . "Do not modify this file");
     $php->addSpace();
     $php->addVariable('CacheCodeDate', eZPackage::CACHE_CODE_DATE);
     $php->addSpace();
     $php->addVariable('Parameters', $this->Parameters, eZPHPCreator::VARIABLE_ASSIGNMENT, array('full-tree' => true));
     $php->addVariable('InstallData', $this->InstallData, eZPHPCreator::VARIABLE_ASSIGNMENT, array('full-tree' => true));
     $php->addVariable('RepositoryPath', $this->RepositoryPath);
     $php->store();
 }