Dotclear

Changeset 1056:b67f949a98f8 for inc/core


Ignore:
Timestamp:
12/09/12 03:12:34 (13 years ago)
Author:
JcDenis
Branch:
twig
Message:
  • Twig know loaded in dcCore
  • Admin context now loaded in admin prepend and avavailable under $_ctx
  • Copy admin theme features in default-templates
  • New URL argument to serve theme file as ?tf=my_theme_file
File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.core.php

    r706 r1056  
    3939     public $rest;       ///< <b>dcRestServer</b> dcRestServer object 
    4040     public $log;        ///< <b>dcLog</b>             dcLog object 
     41     public $tpl;        ///< <b>Twig_Environment</b>  Twig_Environment object 
    4142      
    4243     private $versions = null; 
     
    9596          $this->addFormater('xhtml', create_function('$s','return $s;')); 
    9697          $this->addFormater('wiki', array($this,'wikiTransform')); 
     98           
     99          $this->loadTemplateEnvironment(); 
    97100     } 
    98101      
     
    118121     } 
    119122      
     123     /** 
     124     Create template environment (Twig_Environment instance) 
     125      
     126     default-templates path must be added from admin|public/prepend.php with: 
     127     $core->tpl->getLoader()->addPath('PATH_TO/default-templates'); 
     128     Selected theme path must be added with: 
     129     $core->tpl->getLoader()->prependPath('PATH_TO/MY_THEME'); 
     130     */ 
     131     protected function loadTemplateEnvironment() 
     132     { 
     133          # If cache dir is writable, use it. 
     134          $cache_dir = dirname(DC_TPL_CACHE.'/twtpl'); 
     135          if (!is_dir($cache_dir)) { 
     136               try { 
     137                    files::makeDir($cache_dir); 
     138               } catch (Exception $e) { 
     139                    $cache_dir = false; 
     140               } 
     141          } 
     142           
     143          $this->tpl = new Twig_Environment( 
     144               new Twig_Loader_Filesystem(dirname(__FILE__).'/../swf'), 
     145               array( 
     146                    'auto_reload' => true, 
     147                    'autoescape' => 'html', 
     148                    'base_template_class' => 'Twig_Template', 
     149                    'cache' => $cache_dir,  
     150                    'charset' => 'UTF-8', 
     151                    'debug' => DC_DEBUG, 
     152                    'optimizations' => -1, 
     153                    'strict_variables' => 0 //DC_DEBUG // Please fix undefined variables! 
     154               ) 
     155          ); 
     156          $this->tpl->addExtension(new dcFormExtension($this)); 
     157     } 
    120158      
    121159     /// @name Blog init methods 
Note: See TracChangeset for help on using the changeset viewer.

Sites map