Dotclear

Changeset 1014:65b07a8688ca


Ignore:
Timestamp:
11/14/12 22:47:48 (13 years ago)
Author:
JcDenis
Branch:
twig
Message:

Use $core->page as new Twig environment

Files:
4 edited
1 moved

Legend:

Unmodified
Added
Removed
  • admin/post.php

    r1001 r1014  
    6969 
    7070 
    71  
    72 $page = new dcAdminPage($core); 
    7371 
    7472$form = new dcForm($core,'post','post.php'); 
     
    314312} 
    315313 
    316 $ctx = $page->getContext(); 
    317 $ctx  
     314$core->page->getContext() 
    318315     ->jsDatePicker() 
    319316     ->jsToolBar() 
     
    324321     ->jsConfirmClose('entry-form','comment-form'); 
    325322 
    326 echo $page->render('post.html.twig',array( 
     323echo $core->page->render('post.html.twig',array( 
    327324     'edit_size'=> $core->auth->getOption('edit_size'))); 
    328325?> 
  • inc/admin/class.dc.admincontext.php

    r1001 r1014  
    11<?php 
    2  
    32 
    43class dcAdminContext extends Twig_Extension { 
     
    2322               } 
    2423          } 
    25           $this->blog = array( 
    26                'url' => $core->blog->url, 
    27                'name' => $core->blog->name 
    28           ); 
     24          $this->blog = array(); 
     25          if ($this->core->auth->blog_count) { // no blog on auth.php 
     26               $this->blog = array( 
     27                    'url' => $core->blog->url, 
     28                    'name' => $core->blog->name 
     29               ); 
     30          } 
    2931     } 
    3032      
     
    430432 
    431433} 
    432  
    433 class dcAdminPage { 
    434      protected $loader; 
    435      protected $twig; 
    436      protected $context; 
    437      protected $core; 
    438  
    439      public function __construct($core) { 
    440           $this->core = $core; 
    441           $this->loader = new Twig_Loader_Filesystem(dirname(__FILE__).'/default-templates'); 
    442           files::makeDir(dirname(DC_TPL_CACHE.'/admtpl'),true); 
    443           $core->twig = new Twig_Environment ( 
    444                $this->loader, 
    445                array( 
    446                     'cache' => DC_TPL_CACHE.'/admtpl', 
    447                     //'debug' => true, 
    448                     'auto_reload' => true 
    449           )); 
    450           //$core->twig->addExtension(new Twig_Extensions_Extension_Debug()); 
    451           $core->twig->addExtension(new Twig_Extension_Optimizer(0)); 
    452           $core->twig->addExtension(new dcFormExtension($GLOBALS['core'])); 
    453           $this->context = new dcAdminContext($GLOBALS['core']); 
    454           $core->twig->addExtension($this->context); 
    455           $core->twig->clearCacheFiles(); 
    456      } 
    457  
    458      public function getContext() { 
    459           return $this->context; 
    460      } 
    461       
    462      public function getTwig() { 
    463           return $this->twig; 
    464      } 
    465      public function render($name,array $context = array()) { 
    466           $tpl = $this->core->twig->loadTemplate($name); 
    467            
    468           return $tpl->render($context); 
    469  
    470      } 
    471 } 
    472  
    473  
    474434?> 
  • inc/admin/class.dc.form.php

    r992 r1014  
    145145          $this->action = $action; 
    146146          $this->fields = array(); 
    147           $this->core->twig->getExtension('dc_form')->addForm($this); 
     147          $this->core->page->getExtension('dc_form')->addForm($this); 
    148148     } 
    149149 
  • inc/core/class.dc.twig.page.php

    r1012 r1014  
    44class dcTwigPage extends Twig_Environment 
    55{ 
    6      protected $core; // not in use by now 
     6     protected $core; 
    77     protected $context = null; 
    88      
     
    3434           
    3535          # Add form helper 
    36           $this->addExtension(new dcFormExtension()); 
     36          $this->addExtension(new dcFormExtension($core)); 
    3737           
    3838          $this->clearCacheFiles(); 
  • inc/prepend.php

    r1012 r1014  
    5353$__autoload['rsExtUser']                = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 
    5454 
    55  
    56 $__autoload['dcAdminPage']                   = dirname(__FILE__).'/admin/class.dc.adminpage.php'; 
    57 $__autoload['dcAdminContext']                = dirname(__FILE__).'/admin/class.dc.adminpage.php'; 
     55$__autoload['dcAdminContext']                = dirname(__FILE__).'/admin/class.dc.admincontext.php'; 
    5856$__autoload['dcMenu']                   = dirname(__FILE__).'/admin/class.dc.menu.php'; 
    5957$__autoload['dcPage']                   = dirname(__FILE__).'/admin/lib.dc.page.php'; 
     
    8785require TWIG_PATH.'/Autoloader.php'; 
    8886Twig_Autoloader::register(); 
     87 
    8988/* ------------------------------------------------------------------------------------------- */ 
    9089 
Note: See TracChangeset for help on using the changeset viewer.

Sites map