Changeset 1142
- Timestamp:
- 10/30/08 10:07:07 (2 months ago)
- Files:
-
- trunk/build/buildjtpl.php (modified) (3 diffs)
- trunk/build/config/jtpl-dist.ini (modified) (1 diff)
- trunk/build/config/jtpl-test.ini (modified) (1 diff)
- trunk/build/manifests/jtpl-standalone-tests.mn (added)
- trunk/build/manifests/jtpl-standalone.mn (modified) (1 diff)
- trunk/build/VERSION (modified) (1 diff)
- trunk/lib/jelix/tpl/jTpl.class.php (modified) (4 diffs)
- trunk/lib/jelix/tpl/jTplCompiler.class.php (modified) (4 diffs)
- trunk/lib/jelix/tpl/jtpl_standalone_prepend.php (modified) (1 diff)
- trunk/lib/jelix/tpl/locales/fr.php (modified) (1 diff)
- trunk/lib/jelix/tpl/tests_std/exemple.php (modified) (2 diffs)
- trunk/testapp/scripts/tests.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/build/buildjtpl.php
r421 r1142 21 21 'PACKAGE_ZIP'=>array( 22 22 "create a zip package", 23 false, 24 ), 25 'WITH_TESTS'=>array( 26 "includes tests", 23 27 false, 24 28 ), … … 48 52 $SVN_REVISION = Subversion::revision(); 49 53 50 if($VERSION == 'SVN'){ 51 $VERSION = 'SVN-'.$SVN_REVISION; 52 $IS_NIGHTLY = true; 53 }else{ 54 $IS_NIGHTLY = false; 54 $IS_NIGHTLY = (strpos($VERSION,'SVN') !== false); 55 56 if($IS_NIGHTLY){ 57 $PACKAGE_NAME='jtpl-'.str_replace('SVN', '', $VERSION); 58 if(substr($PACKAGE_NAME,-1,1) == '.') 59 $PACKAGE_NAME = substr($PACKAGE_NAME,0,-1); 60 $VERSION = str_replace('SVN', $SVN_REVISION, $VERSION); 61 } 62 else { 63 $PACKAGE_NAME='jtpl-'.$VERSION; 55 64 } 56 65 57 66 if($PACKAGE_TAR_GZ || $PACKAGE_ZIP ){ 58 if($IS_NIGHTLY)59 $PACKAGE_NAME = 'jtpl-nightly';60 else61 $PACKAGE_NAME = 'jtpl-'.$VERSION;62 63 67 $BUILD_TARGET_PATH = jBuildUtils::normalizeDir($MAIN_TARGET_PATH).$PACKAGE_NAME.'/'; 64 68 }else{ … … 74 78 //... execution des manifests 75 79 jManifest::process('build/manifests/jtpl-standalone.mn', '.', $BUILD_TARGET_PATH, ENV::getAll()); 80 81 if($WITH_TESTS) { 82 jManifest::process('build/manifests/jtpl-standalone-tests.mn', '.', $BUILD_TARGET_PATH, ENV::getAll()); 83 } 84 76 85 77 86 trunk/build/config/jtpl-dist.ini
r292 r1142 2 2 PACKAGE_TAR_GZ = 1 3 3 PACKAGE_ZIP = 1 4 WITH_TESTS = 0 trunk/build/config/jtpl-test.ini
r292 r1142 2 2 PACKAGE_TAR_GZ = 3 3 PACKAGE_ZIP = 4 WITH_TESTS = 1 trunk/build/manifests/jtpl-standalone.mn
r706 r1142 50 50 sd lib/jelix/tpl/templates/ 51 51 dd templates/ 52 53 sd lib/jelix/tpl/tests_std/54 dd tests_std/55 exemple.php56 test.tpltrunk/build/VERSION
r154 r1142 1 SVN1 1.0pre.SVN trunk/lib/jelix/tpl/jTpl.class.php
r1070 r1142 232 232 $fct = $fctname.md5($sel->module.'_'.$sel->resource.'_'.$sel->outputType.($trusted?'_t':'')); 233 233 #else 234 $tpl = JTPL_TEMPLATES_PATH. $tpl;234 $tpl = jTplConfig::$templatePath . $tpl; 235 235 $this->_templateName = basename($tpl); 236 $cachefile = JTPL_CACHE_PATH.$outputtype.($trusted?'_t':'').'_'.$this->_templateName;237 238 $mustCompile = $GLOBALS['jTplConfig']['compilation_force']['force']|| !file_exists($cachefile);236 $cachefile = jTplConfig::$cachePath.$outputtype.($trusted?'_t':'').'_'.$this->_templateName; 237 238 $mustCompile = jTplConfig::$compilationForce || !file_exists($cachefile); 239 239 if (!$mustCompile) { 240 240 if (filemtime($tpl) > filemtime($cachefile)) { … … 276 276 $this->_templateName = $sel->toString(); 277 277 #else 278 $tpl = JTPL_TEMPLATES_PATH. $tpl;278 $tpl = jTplConfig::$templatePath . $tpl; 279 279 $this->_templateName = basename($tpl); 280 $cachefile = JTPL_CACHE_PATH.$outputtype.($trusted?'_t':'').'_'.$this->_templateName;281 282 $mustCompile = $GLOBALS['jTplConfig']['compilation_force']['force']|| !file_exists($cachefile);280 $cachefile = jTplConfig::$cachePath.$outputtype.($trusted?'_t':'').'_'.$this->_templateName; 281 282 $mustCompile = jTplConfig::$compilationForce || !file_exists($cachefile); 283 283 if (!$mustCompile) { 284 284 if (filemtime($tpl) > filemtime($cachefile)) { … … 291 291 $compiler = new jTplCompiler(); 292 292 $compiler->setUserPlugins( $this->userModifiers, $this->userFunctions); 293 $compiler->compile($tpl, $outputtype,$trusted);293 $compiler->compile($tpl, $outputtype, $trusted); 294 294 } 295 295 require_once($cachefile); … … 358 358 public static function getEncoding (){ 359 359 #if JTPL_STANDALONE 360 return $GLOBALS['jTplConfig']['charset'];360 return jTplConfig::$charset; 361 361 #else 362 362 return $GLOBALS['gJConfig']->charset; trunk/lib/jelix/tpl/jTplCompiler.class.php
r1112 r1142 81 81 82 82 #if JTPL_STANDALONE 83 require_once( JTPL_LOCALES_PATH.$GLOBALS['jTplConfig']['lang'].'.php');84 $this->_locales = $GLOBALS['jTplConfig']['locales'];83 require_once(jTplConfig::$localizedMessagesPath.jTplConfig::$lang.'.php'); 84 $this->_locales = jTplConfig::$localizedMessages; 85 85 #endif 86 86 } … … 98 98 $this->_sourceFile = $tplFile; 99 99 $this->outputType = ($outputtype==''?'html':$outputtype); 100 $cachefile = JTPL_CACHE_PATH.$this->outputType.($trusted?'_t':'').'_'. basename($tplFile);100 $cachefile = jTplConfig::$cachePath .$this->outputType.($trusted?'_t':'').'_'. basename($tplFile); 101 101 $this->trusted = $trusted; 102 102 $this->_modifier = array_merge($this->_modifier, $userModifiers); … … 499 499 } else { 500 500 #if JTPL_STANDALONE 501 $result.='${ $GLOBALS[\'jTplConfig\'][\'localesGetter\']}(\''.$locale.'\')';501 $result.='${jTplConfig::$localesGetter}(\''.$locale.'\')'; 502 502 #else 503 503 $result.='jLocale::get(\''.$locale.'\')'; … … 575 575 576 576 #if JTPL_STANDALONE 577 if(isset( $GLOBALS['jTplConfig']['tplpluginsPathList'][$this->outputType])){578 foreach( $GLOBALS['jTplConfig']['tplpluginsPathList'][$this->outputType] as $path){577 if(isset(jTplConfig::$pluginPathList[$this->outputType])){ 578 foreach(jTplConfig::$pluginPathList[$this->outputType] as $path){ 579 579 #else 580 580 global $gJConfig; trunk/lib/jelix/tpl/jtpl_standalone_prepend.php
r1026 r1142 5 5 * @contributor Laurent Jouanneau 6 6 * @copyright 2006 Mathaud Loic 7 * @copyright 2006 Jouanneau Laurent7 * @copyright 2006-2008 Jouanneau Laurent 8 8 * @link http://www.jelix.org 9 9 * @licence GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 10 10 */ 11 if(!defined('JTPL_PATH'))12 define('JTPL_PATH', dirname(__FILE__) . '/');13 if(!defined('JTPL_CACHE_PATH'))14 define('JTPL_CACHE_PATH', realpath(JTPL_PATH.'temp/') . '/');15 if(!defined('JTPL_PLUGIN_PATH'))16 define('JTPL_PLUGIN_PATH', realpath(JTPL_PATH.'plugins/') . '/');17 if(!defined('JTPL_LOCALES_PATH'))18 define('JTPL_LOCALES_PATH', realpath(JTPL_PATH.'locales/') . '/');19 if(!defined('JTPL_TEMPLATES_PATH'))20 define('JTPL_TEMPLATES_PATH', realpath(JTPL_PATH.'templates/') . '/');21 11 22 $GLOBALS['jTplConfig'] = array( 23 'tplpluginsPathList'=> array( 24 'common' => array(JTPL_PLUGIN_PATH . 'common/'), 25 'html' => array(JTPL_PLUGIN_PATH . 'html/') 26 ), 27 'compilation_force' => false, 28 'lang'=>'fr', 29 'charset'=>'UTF-8', 30 'localesGetter' => 'getLocales' 31 ); 12 define('JTPL_PATH', dirname(__FILE__) . '/'); 13 14 function getDummyLocales($locale) { 15 return $locale; 16 } 17 18 class jTplConfig { 19 20 /** 21 * the path of the directory which contains the 22 * templates 23 */ 24 static $templatePath = ''; 25 26 /** 27 * boolean which indicates if the templates 28 * should be compiled at each call or not 29 */ 30 static $compilationForce = false; 31 32 /** 33 * the lang activated in the templates 34 */ 35 static $lang = 'fr'; 36 37 /** 38 * the charset used in the templates 39 */ 40 static $charset = 'UTF-8'; 41 42 /** 43 * the function which allow to retrieve the locales used in your templates 44 */ 45 static $localesGetter = 'getDummyLocales'; 46 47 /** 48 * the path of the cache directory 49 */ 50 static $cachePath = ''; 51 52 /** 53 * the path of the directory which contains the 54 * localization files of jtpl 55 */ 56 static $localizedMessagesPath = ''; 57 58 /** 59 * @internal 60 */ 61 static $localizedMessages = array(); 62 63 /** 64 * @internal 65 */ 66 static $pluginPathList = array(); 67 68 69 static function addPluginsRepository($path){ 70 if(trim($path) == '') return; 71 if(!file_exists($path)){ 72 throw new Exception('The given path, '.$path.' doesn\'t exists'); 73 } 74 if(substr($path,-1) !='/') 75 $path.='/'; 76 77 if ($handle = opendir($path)) { 78 while (false !== ($f = readdir($handle))) { 79 if ($f{0} != '.' && is_dir($path.$f)) { 80 self::$pluginPathList[$f][]= $path.$f.'/'; 81 } 82 } 83 closedir($handle); 84 } 85 } 86 } 87 88 jTplConfig::$cachePath = realpath(JTPL_PATH.'temp/') . '/'; 89 jTplConfig::$localizedMessagesPath = realpath(JTPL_PATH.'locales/') . '/'; 90 jTplConfig::$templatePath = realpath(JTPL_PATH.'templates/') . '/'; 91 92 jTplConfig::addPluginsRepository(realpath(JTPL_PATH.'plugins/')); 32 93 33 94 include(JTPL_PATH . 'jTpl.class.php'); 34 95 35 96 36 function getLocales($locale) {37 return $locale;38 }39 97 40 98 trunk/lib/jelix/tpl/locales/fr.php
r1026 r1142 1 1 <?php 2 2 3 $GLOBALS['jTplConfig']['locales']=array(3 jTplConfig::$localizedMessages =array( 4 4 'errors.tpl.not.found'=>'Le fichier template %s est introuvable', 5 5 'file.directory.notexists'=>'Le répertoire demandé (%s) n\'existe pas', trunk/lib/jelix/tpl/tests_std/exemple.php
r1026 r1142 1 1 <?php 2 2 3 include '../jtpl_standalone_prepend.php'; 3 4 4 include 'jtpl_standalone_prepend.php';5 jTplConfig::$templatePath = dirname(__FILE__) . '/'; 5 6 6 7 $tpl = new jTpl(); … … 8 9 $countries = array('France', 'Italie', 'Espagne', 'Belgique'); 9 10 $tpl->assign('countries', $countries); 10 $tpl->assign('titre', ' Ceci est untest !');11 $tpl->assign('titre', 'This is a test !'); 11 12 $tpl->display('test.tpl'); 12 13 trunk/testapp/scripts/tests.php
r919 r1142 21 21 $jelix->process(new jCmdLineRequest()); 22 22 23 ?>
