Dotclear


Ignore:
Timestamp:
04/09/13 09:08:48 (12 years ago)
Author:
Dsls <dsls@…>
Branch:
twig
Message:

Intermediate commit, needs to be better documented

  • introducing new dcListFetcher class for lists
  • Lists are now driving filters
  • forms tags are now defined in twig format
File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/admin/class.dc.form.php

    r1153 r1154  
    2020class dcFormNode extends Twig_Node 
    2121{ 
    22      public function __construct($name,Twig_NodeInterface $body,$lineno,$tag=null) 
    23      { 
    24           parent::__construct(array('body' => $body),array('name' => $name),$lineno,$tag); 
     22     public function __construct($name,Twig_NodeInterface $body,$attr,$lineno,$tag=null) 
     23     { 
     24          parent::__construct(array('body' => $body),array('name' => $name, 'attr' => $attr),$lineno,$tag); 
    2525     } 
    2626      
     
    3636          $compiler 
    3737               ->write("\$context['dc_form']->beginForm(") 
    38                ->subcompile($this->getAttribute('name')) 
     38               ->subcompile($this->getAttribute('name')); 
     39          if ($this->getAttribute('attr') !== null) { 
     40               $compiler 
     41                    ->write(',') 
     42                    ->subcompile($this->getAttribute('attr')); 
     43          } 
     44          $compiler 
    3945               ->write(");\n"); 
    4046          $compiler 
     
    5662          $stream = $this->parser->getStream(); 
    5763          $name = $this->parser->getExpressionParser()->parseExpression(); 
     64          $attr = null; 
     65          if ($stream->test(Twig_Token::NAME_TYPE, 'with')) { 
     66               $stream->next(); 
     67               $attr = $this->parser->getExpressionParser()->parseExpression(); 
     68          } 
    5869          $stream->expect(Twig_Token::BLOCK_END_TYPE); 
    5970          $body = $this->parser->subparse(array($this,'decideBlockEnd'),true); 
    6071          $stream->expect(Twig_Token::BLOCK_END_TYPE); 
    6172           
    62           return new dcFormNode($name,$body,$token->getLine(),$this->getTag()); 
     73          return new dcFormNode($name,$body,$attr,$token->getLine(),$this->getTag()); 
    6374     } 
    6475      
     
    219230     } 
    220231 
    221      public function beginForm($name) 
     232     public function beginForm($name,$attr=array()) 
    222233     { 
    223234          if (isset($this->forms[$name])) { 
    224235               $this->currentForm = $this->forms[$name]; 
    225                $this->currentForm->begin(); 
     236               $this->currentForm->begin($attr); 
    226237          } 
    227238          else { 
     
    381392          } 
    382393     } 
    383      public function begin() 
    384      { 
    385           echo sprintf( 
    386                '<form%s method="%s" action="%s">', 
    387                empty($this->id) ? '' : ' id="'.$this->id.'"', 
    388                $this->method, 
    389                $this->action 
    390           ); 
     394     public function begin($attr=array()) 
     395     { 
     396          $attr['method'] = $this->method; 
     397          $attr['action'] = $this->action; 
     398          if (!empty($this->id)) { 
     399               $attr['id'] = $this->id; 
     400          } 
     401          $this->core->tpl->getExtension('dc_form')->renderWidget( 
     402               'beginform', 
     403               $attr); 
    391404     } 
    392405      
Note: See TracChangeset for help on using the changeset viewer.

Sites map