[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 #!/usr/bin/env php 2 <?php 3 // 4 // Created on: <02-Mar-2004 20:10:18 amos> 5 // 6 // SOFTWARE NAME: eZ publish 7 // SOFTWARE RELEASE: 3.9.0 8 // BUILD VERSION: 17785 9 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 10 // SOFTWARE LICENSE: GNU General Public License v2.0 11 // NOTICE: > 12 // This program is free software; you can redistribute it and/or 13 // modify it under the terms of version 2.0 of the GNU General 14 // Public License as published by the Free Software Foundation. 15 // 16 // This program is distributed in the hope that it will be useful, 17 // but WITHOUT ANY WARRANTY; without even the implied warranty of 18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 // GNU General Public License for more details. 20 // 21 // You should have received a copy of version 2.0 of the GNU General 22 // Public License along with this program; if not, write to the Free 23 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 24 // MA 02110-1301, USA. 25 // 26 // 27 28 include_once ( 'lib/ezutils/classes/ezcli.php' ); 29 include_once ( 'kernel/classes/ezscript.php' ); 30 31 $cli =& eZCLI::instance(); 32 $script =& eZScript::instance( array( 'description' => ( "eZ publish Template Compiler\n" . 33 "\n" . 34 "./bin/php/eztc.php -snews --www-dir='/mypath' --index-file='/index.php' --access-path='news'" ), 35 'use-session' => false, 36 'use-modules' => true, 37 'use-extensions' => true ) ); 38 39 $script->startup(); 40 41 $options = $script->getOptions( "[compile-directory:][www-dir:][index-file:][access-path:][force][full-url][no-full-url]", 42 "", 43 array( 'force' => "Force compilation of template whether it has changed or not", 44 'compile-directory' => "Where to place compiled files,\ndefault is template/compiled in current cache directory", 45 'full-url' => "Makes sure generated urls have http:// in them (i.e. global), used mainly by sites that include the eZ publish HTML (e.g payment gateways)", 46 'no-full-url' => "Makes sure generated urls are relative to the site. (default)", 47 'www-dir' => "The part before the index.php in your URL, you should supply this if you are running in non-virtualhost mode", 48 'index-file' => "The name of your index.php if you are running in non-virtualhost mode", 49 'access-path' => "Extra access path" ) ); 50 $sys =& eZSys::instance(); 51 52 $forceCompile = false; 53 $useFullURL = false; 54 55 if ( $options['www-dir'] ) 56 { 57 $sys->WWWDir = $options['www-dir']; 58 } 59 if ( $options['index-file'] ) 60 { 61 $sys->IndexFile = $options['index-file']; 62 } 63 if ( $options['access-path'] ) 64 { 65 $sys->AccessPath = array( $options['access-path'] ); 66 } 67 if ( $options['force'] ) 68 { 69 $forceCompile = true; 70 } 71 if ( $options['full-url'] ) 72 { 73 $useFullURL = true; 74 } 75 if ( $options['no-full-url'] ) 76 { 77 $useFullURL = false; 78 } 79 80 $script->initialize(); 81 82 include_once ( 'lib/ezutils/classes/ezhttptool.php' ); 83 $http =& eZHTTPTool::instance(); 84 $http->UseFullUrl = $useFullURL; 85 86 87 if ( count( $options['arguments'] ) > 0 ) 88 { 89 $ini =& eZINI::instance(); 90 91 include_once ( 'kernel/common/template.php' ); 92 include_once ( 'lib/eztemplate/classes/eztemplatecompiler.php' ); 93 $tpl =& templateInit(); 94 95 $fileList = $options['arguments']; 96 97 $script->setIterationData( '.', '~' ); 98 $script->setShowVerboseOutput( true ); 99 if ( $forceCompile ) 100 eZTemplateCompiler::setSettings( array( 'generate' => true ) ); 101 102 $files = array(); 103 foreach ( $fileList as $file ) 104 { 105 $filename = basename( $file ); 106 if ( preg_match( "!^.+~$|^/?#.+#$|^\..+$!", $filename ) ) 107 continue; 108 $files[] = $file; 109 } 110 111 $script->resetIteration( count( $files ) ); 112 foreach ( $files as $file ) 113 { 114 if ( is_dir( $file ) ) 115 { 116 $script->iterate( $cli, true, "Skipping directory: " . $cli->stylize( 'dir', $file ) ); 117 } 118 else 119 { 120 $status = $tpl->compileTemplateFile( $file ); 121 $text = false; 122 if ( $status ) 123 $text = "Compiled template file: " . $cli->stylize( 'file', $file ); 124 else 125 $text = "Compilation failed: " . $cli->stylize( 'file', $file ); 126 $script->iterate( $cli, $status, $text ); 127 } 128 } 129 } 130 else 131 { 132 $ini =& eZINI::instance(); 133 $standardDesign = $ini->variable( "DesignSettings", "StandardDesign" ); 134 $siteDesign = $ini->variable( "DesignSettings", "SiteDesign" ); 135 $additionalSiteDesignList = $ini->variable( "DesignSettings", "AdditionalSiteDesignList" ); 136 137 $designList = array_merge( array( $standardDesign ), $additionalSiteDesignList, array( $siteDesign ) ); 138 139 include_once ( 'kernel/common/template.php' ); 140 include_once ( 'lib/eztemplate/classes/eztemplatecompiler.php' ); 141 $tpl =& templateInit(); 142 143 $script->setIterationData( '.', '~' ); 144 if ( $forceCompile ) 145 eZTemplateCompiler::setSettings( array( 'generate' => true ) ); 146 147 foreach ( $designList as $design ) 148 { 149 $cli->output( "Compiling in design " . $cli->stylize( 'emphasize', $design ) ); 150 $baseDir = 'design/' . $design; 151 $files = eZDir::recursiveFindRelative( $baseDir, 'templates', "\.tpl" ); 152 $files = array_merge( $files, eZDir::recursiveFindRelative( $baseDir, 'override/templates', "\.tpl" ) ); 153 $script->resetIteration( count( $files ) ); 154 foreach ( $files as $fileRelative ) 155 { 156 $file = $baseDir . '/' . $fileRelative; 157 $status = $tpl->compileTemplateFile( $file ); 158 $text = false; 159 if ( $status ) 160 $text = "Compiled template file: " . $cli->stylize( 'file', $file ); 161 else 162 $text = "Compilation failed: " . $cli->stylize( 'file', $file ); 163 $script->iterate( $cli, $status, $text ); 164 } 165 } 166 } 167 168 $script->shutdown(); 169 170 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |