Dotclear


Ignore:
Timestamp:
03/08/13 15:37:34 (13 years ago)
Author:
Dsls <dsls@…>
Branch:
twig
Message:

Oops, I did it again (c).

Fist draft of merge from formfilters to dctwig. lists need to be broken up too.

From now all post lists are broken.

Location:
inc/admin
Files:
3 added
8 edited

Legend:

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

    r1091 r1147  
    4545                
    4646               'admin_url'    => DC_ADMIN_URL, 
    47                'theme_url'    => DC_ADMIN_URL.'index.php?tf=', 
     47               'theme_url'    => '', 
    4848               'plugin_url'   => DC_ADMIN_URL.'index.php?pf=', 
    4949                
  • inc/admin/class.dc.form.php

    r1090 r1147  
    1313 
    1414/** 
    15  * Template form node 
    16  */ 
     15* dcFormNode 
     16* 
     17* @uses     Twig_Node 
     18* 
     19*/ 
    1720class dcFormNode extends Twig_Node 
    1821{ 
     
    3033     { 
    3134          $compiler 
    32                ->addDebugInfo($this) 
    33                ->write("\$context['dc_form']->beginForm('". 
    34                     $this->getAttribute('name')."');\n") 
     35               ->addDebugInfo($this); 
     36          $compiler 
     37               ->write("\$context['dc_form']->beginForm(") 
     38               ->subcompile($this->getAttribute('name')) 
     39               ->write(");\n"); 
     40          $compiler 
    3541               ->subcompile($this->getNode('body')) 
    3642               ->write("\$context['dc_form']->renderHiddenWidgets();\n") 
     
    4955          $lineno = $token->getLine(); 
    5056          $stream = $this->parser->getStream(); 
    51           $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); 
     57          $name = $this->parser->getExpressionParser()->parseExpression(); 
    5258          $stream->expect(Twig_Token::BLOCK_END_TYPE); 
    5359          $body = $this->parser->subparse(array($this,'decideBlockEnd'),true); 
     
    7783     protected $core; 
    7884     protected $twig; 
    79      protected $blocks; 
    8085     protected $forms; 
    8186     protected $currentForm; 
     87     protected $blocks; 
    8288      
    8389     public function __construct($core) 
     
    96102     } 
    97103      
     104     public function addTemplate($tpl) { 
     105          $t = $this->twig->loadTemplate($tpl); 
     106          $this->blocks = array_merge($this->blocks,$t->getBlocks()); 
     107     } 
     108 
    98109     public function getGlobals() 
    99110     { 
     
    137148     } 
    138149      
    139      public function renderWidget($name,$attributes=array()) 
     150     public function renderBlock($name,$attr) { 
     151          echo $this->template->renderBlock( 
     152               $name, 
     153               $attr, 
     154               $this->blocks 
     155          ); 
     156     } 
     157 
     158     public function getCurrentForm() { 
     159          return $this->currentForm; 
     160     } 
     161 
     162     public function renderWidget($name,$attributes=array(),$extra=array()) 
    140163     { 
    141164          $field = $this->currentForm->$name; 
    142165          if ($field) { 
    143                echo $this->template->renderBlock( 
     166               $attr = $field->getAttributes(); 
     167               if (isset($attr['attr'])) { 
     168                    $attr['attr'] = array_merge($attr['attr'],$attributes); 
     169               } else { 
     170                    $attr['attr'] = $attributes; 
     171               } 
     172               $this->renderBlock( 
    144173                    $field->getWidgetBlock(), 
    145174                    array_merge( 
    146                          $field->getAttributes(), 
    147                          array('attr' => $attributes) 
    148                     ), 
    149                     $this->blocks 
     175                         $attr, 
     176                         $extra 
     177                    ) 
    150178               ); 
    151179          } 
     
    197225 
    198226/** 
    199  * Template form 
    200  */ 
     227* dcForm - Template form 
     228* 
     229*/ 
    201230class dcForm 
    202231{ 
     
    211240     protected $errors; 
    212241      
    213      private function addNonce() 
     242 
     243    /** 
     244     * addNonce -- adds dc nonce to form fields 
     245     *  
     246     * @access protected 
     247     * 
     248     * @return nothing 
     249     */ 
     250     protected function addNonce() 
    214251     { 
    215252          $this->addField( 
     
    219256     } 
    220257      
    221      protected function getNID($nid) 
     258 
     259    /** 
     260     * Defines Name & ID from field 
     261     *  
     262     * @param mixed $nid either an array (name, id) or a string (name only, id will be set to null). 
     263     * 
     264     * @access protected 
     265     * 
     266     * @return nothing. 
     267     */ 
     268     protected function setNID($nid) 
    222269     { 
    223270          if (is_array($nid)) { 
     
    231278     } 
    232279      
     280     public function getContext() { 
     281          return array(); 
     282     } 
     283 
     284    /** 
     285     * Class constructor 
     286     *  
     287     * @param mixed  $core   dotclear core 
     288     * @param mixed  $name   form name 
     289     * @param mixed  $action form action 
     290     * @param string $method form method ('GET' or 'POST') 
     291     * 
     292     * @access public 
     293     * 
     294     * @return mixed Value. 
     295     */ 
    233296     public function __construct($core,$name,$action,$method='POST') 
    234297     { 
    235298          $this->core = $core; 
    236           $this->getNID($name); 
     299          $this->setNID($name); 
    237300          $this->method = $method; 
    238301          $this->action = $action; 
     
    247310     } 
    248311      
     312 
     313    /** 
     314     * Returns form name 
     315     *  
     316     * @access public 
     317     * 
     318     * @return mixed Value. 
     319     */ 
    249320     public function getName() 
    250321     { 
     
    270341     } 
    271342      
     343     public function removeField(dcField $f) { 
     344          $n = $f->getName(); 
     345          if (isset($this->fields[$n])){ 
     346               unset($this->fields[$n]); 
     347          } 
     348 
     349     } 
     350     public function renameField($field,$newname) { 
     351          $oldname = $field->getName(); 
     352          if (isset($this->fields[$oldname])) { 
     353               unset($this->fields[$oldname]); 
     354               $field->setName($newname); 
     355               $this->fields[$newname] = $field; 
     356          } 
     357          //print_r($this->fields); 
     358     } 
    272359     public function begin() 
    273360     { 
     
    292379     public function __get($name) 
    293380     { 
    294           return isset($this->fields[$name]) ?  
     381          return isset($this->fields[$name]) ? 
    295382               $this->fields[$name] : null; 
    296383     } 
    297       
     384 
    298385     public function __set($name,$value) 
    299386     { 
     
    302389          } 
    303390     } 
    304       
     391 
    305392     public function isSubmitted() 
    306393     { 
    307394          $from = $this->method == 'POST' ? $_POST : $_GET; 
    308           echo "form fields :\n"; 
    309      } 
    310       
    311      public function setup() 
    312      { 
     395     } 
     396 
     397     protected function setupFields() { 
    313398          $from = $this->method == 'POST' ? $_POST : $_GET; 
    314399          foreach ($this->fields as $f) { 
    315400               $f->setup($from); 
    316401          } 
     402     } 
     403 
     404     protected function handleActions($submitted) { 
     405          foreach ($submitted as $f) { 
     406               $action = $f->getAction(); 
     407               if ($action != NULL) { 
     408                    $ret = call_user_func($action,$this); 
     409               } 
     410          } 
     411     } 
     412 
     413     protected function getSubmittedFields() { 
     414          $s = array(); 
    317415          foreach ($this->submitfields as $f) { 
    318416               if ($f->isDefined()) { 
    319                     $ret = call_user_func($f->getAction(),$this); 
    320                     return; 
     417                    $s[$f->getName()] = $f; 
    321418               } 
    322419          } 
    323      } 
    324       
     420          return $s; 
     421     } 
     422 
     423     public function setup() 
     424     { 
     425          $this->setupFields(); 
     426          $submitted = $this->getSubmittedFields(); 
     427          $this->handleActions($submitted); 
     428     } 
     429 
    325430     public function check() 
    326431     { 
     
    352457     protected $defined; 
    353458      
    354      protected function getNID($nid) 
     459     protected function setNID($nid) 
    355460     { 
    356461          if (is_array($nid)) { 
     
    365470     public function __construct($name,$value,$attributes=array()) 
    366471     { 
    367           $this->getNID($name); 
     472          $this->setNID($name); 
    368473          $this->attributes = $attributes; 
    369           $this->value = $value; 
     474          $this->setValue($value); 
    370475          $this->attributes['name'] = $this->name; 
    371476          $this->attributes['id'] = $this->id; 
     477          $this->defined = false; 
     478     } 
     479      
     480     public function setValue($value) { 
     481          $this->value = $value; 
    372482          $this->attributes['value'] = $this->value; 
    373           $this->defined = false; 
    374      } 
    375       
     483     } 
     484 
     485     public function getValue() { 
     486          return $this->value; 
     487     } 
     488 
    376489     public function __toString() 
    377490     { 
     
    395508          return $this->name; 
    396509     } 
    397       
     510     public function setName($name) { 
     511          $this->setNID($name); 
     512          $this->attributes['name'] = $this->name; 
     513          $this->attributes['id'] = $this->id; 
     514     } 
     515 
    398516     public function check() 
    399517     { 
     
    406524     } 
    407525      
     526     public function parseValue($from) { 
     527          if (isset($from[$this->id])) { 
     528               return $from[$this->id]; 
     529          } 
     530          return null; 
     531     } 
     532 
    408533     public function setup($from) 
    409534     { 
    410           if (isset($from[$this->id])) { 
    411                $this->value = $from[$this->id]; 
     535          $value = $this->parseValue($from); 
     536          if ($value !== null) { 
     537               $this->setValue($value); 
    412538               $this->defined = true; 
    413539          } 
     
    488614          if (isset($attributes['action'])) { 
    489615               $this->action = $attributes['action']; 
     616          } else { 
     617               $this->action = NULL; 
    490618          } 
    491619     } 
     
    527655     } 
    528656 
     657     public function parseValue($from) { 
     658 
     659          $v = parent::parseValue($from); 
     660          if (!isset($this->options[$v])) { 
     661               return $this->value; 
     662          } else { 
     663               return $v; 
     664          } 
     665     } 
    529666} 
    530667?> 
  • inc/admin/default-templates/auth.html.twig

    r1089 r1147  
    1818<body id="dotclear-admin" class="auth"> 
    1919 
    20 {% form auth %} 
     20{% form 'auth' %} 
    2121<div id="login-screen"> 
    2222<h1>{{vendor_name}}</h1> 
  • inc/admin/default-templates/form_layout.html.twig

    r1001 r1147  
    1818{% block field_textarea %} 
    1919{% spaceless %} 
    20      {{ block('label') }} 
     20     {{ block('startlabel') }} 
    2121    <textarea {{ block('field_attr') }}>{{ value }}</textarea> 
     22    {{ block('endlabel') }} 
    2223{% endspaceless %} 
    2324{% endblock field_textarea %} 
     
    3839{% spaceless %} 
    3940    {% set type = type|default('text') %} 
    40     {{ block('label') }} 
     41    {{ block('startlabel') }} 
    4142     <input type="{{ type }}" {{ block('field_attr') }} {% if value is not empty %}value="{{ value }}" {% endif %} /> 
     43    {{ block('endlabel') }} 
    4244{% endspaceless %} 
    4345{% endblock field_input %} 
     
    8082{% block field_combo %} 
    8183{% spaceless %} 
    82     {{ block('label') }} 
     84    {{ block('startlabel') }} 
    8385    <select {{ block('field_attr') }}> 
    8486        {{ block('field_options') }} 
    8587    </select> 
     88    {{ block('endlabel') }} 
    8689{% endspaceless %} 
    8790{% endblock field_combo %} 
    88  
     91{# 
    8992{% block label %} 
    9093{% spaceless %} 
     
    9497{% endspaceless %} 
    9598{% endblock label %} 
     99#} 
     100 
     101{% block startlabel %} 
     102{% spaceless %} 
     103    {% if label is not empty %} 
     104        {% if required is not empty %} 
     105            {% set labelclass = labelclass + " required" %} 
     106        {% endif %} 
     107        <label for="{{name}}" {% if labelclass is not empty %}class="{{labelclass}}"{% endif %} {% if required is not empty %}<abbr title="{{__('Required field')}}">*</abbr>{% else %}>{% endif %} {{label}} 
     108        {% if nestedlabel is empty %}</label> {% endif %} 
     109    {% endif %} 
     110{% endspaceless %} 
     111{% endblock startlabel %} 
     112 
     113{% block endlabel %} 
     114{% spaceless %} 
     115    {% if label is not empty %} 
     116        {% if nestedlabel is not empty %}</label>{% endif %} 
     117    {% endif %} 
     118{% endspaceless %} 
     119{% endblock endlabel %} 
     120 
  • inc/admin/default-templates/index.html.twig

    r1099 r1147  
    2828          <div id="quick"> 
    2929               <h3>{{__('Quick entry')}}</h3> 
    30                {% form quickentry %} 
     30               {% form 'quickentry' %} 
    3131                    <fieldset><legend>{{__('New entry')}}</legend> 
    3232                         <p class="col">{{ form_field('post_title',{'class':'maximal'}) }}</p> 
  • inc/admin/default-templates/layout.html.twig

    r1089 r1147  
    1919<body id="dotclear-admin{% if safe_mode %} safe-mode{% endif %}"> 
    2020     <div id="header"> 
    21           <ul id="prelude"> 
    22                <li><a href="#content">{{__('To content')}}</a></li> 
    23                <li><a href="#main-menu">{{__('To menu')}}</a></li> 
    24           </ul> 
     21          {% block prelude %} 
     22               <ul id="prelude"> 
     23                    <li><a href="#content">{{__('To content')}}</a></li> 
     24                    <li><a href="#main-menu">{{__('To menu')}}</a></li> 
     25               </ul> 
     26          {% endblock %} 
    2527          <div id="top"><h1><a href="index.php">{{vendor_name}}</a></h1></div> 
    2628          <div id="info-boxes"> 
    2729               <div id="info-box1"> 
    28                  {% form switchblog_menu %} 
     30                 {% form 'switchblog_menu' %} 
    2931                    {% if blog_count > 1 and blog_count < 20 %} 
    30                          <p>{{ form_field('switchblog') }}</p> 
    31                          <noscript><p>{{ form_field('switchblog_submit') }}</p></noscript> 
     32                         {{ form_field('switchblog',{},{'nestedlabel' : true, labelclass:'classic'}) }} 
     33                         <noscript>{{ form_field('switchblog_submit') }}</noscript> 
    3234                    {% else %} 
    33                          <p>{{__('Blog:')}} <strong title="{{current_blog.url}}">{{current_blog.name}}</strong> 
    34                          {% if blogs is not empty %} - <a href="blogs.php">{{__('Change blog')}}</a>{% endif %}</p> 
     35                         {{__('Blog:')}} <strong title="{{current_blog.url}}">{{current_blog.name}}</strong> 
     36                         {% if blogs is not empty %} - <a href="blogs.php">{{__('Change blog')}}</a>{% endif %} 
    3537                    {% endif %} 
    36                     <p><a href="{{current_blog.url}}" onclick="window.open(this.href);return false;" title="{{__('Go to site')}} ({{__('new window')}})">{{__('Go to site')}} <img src="{{theme_url}}images/outgoing.png" alt="" /></a></p> 
     38                    <a href="{{current_blog.url}}" onclick="window.open(this.href);return false;" title="{{__('Go to site')}} ({{__('new window')}})">{{__('Go to site')}} <img src="{{theme_url}}images/outgoing.png" alt="" /></a> 
    3739                 {% endform %} 
    3840               </div> 
  • inc/admin/default-templates/post.html.twig

    r1088 r1147  
    1616 
    1717<div class="multi-part" title="{{__('Edit entry')}}" id="edit-entry"> 
    18 {% form post %} 
     18{% form 'post' %} 
    1919<div id="entry-wrapper"> 
    2020     <div id="entry-content"> 
  • inc/admin/default-templates/style/default.css

    r1085 r1147  
    13561356     background-color: #2373A8; 
    13571357} 
    1358  
     1358form#filters {font-size: 100%; background: #f0f0f0; padding: 1em; border-radius: .5em; border: 1px solid #ddd;} 
     1359form#filters .margintop {padding-top: 1.33em;} 
     1360form#filters ul, form#filters p {list-style-type:none;margin: 0; padding: 0 0 .5em 0; margin-left: 1em;} 
     1361form#filters .col30 {border-left: 1px solid #999;} 
     1362form#filters .col30 h3 {margin-left: 1em;} 
     1363 
     1364p.line, li.line { position: relative; padding: 3px 0 0 28px; margin: 0 0 1em 0;} 
     1365li.line input[type=submit] {position: absolute; left:0;top:0; padding: 0 .1em; margin: 0;} 
     1366li.line input[type=checkbox], li.line input[type=checkbox] {position: absolute; left: 0; top: .2em; padding: 0 .1em; margin: 0;} 
     1367li.line select { margin-right: 2em;} 
     1368li.line label { display: block; width: 8em; float: left;} 
     1369li.line label img {margin-right: 8px;} 
     1370li.line span.or { 
     1371     text-align: right; 
     1372     margin-left: 5em; 
     1373     font-weight: bold; 
     1374} 
     1375p.line label.or + select {margin-left: 2em;} 
     1376li.line { padding: 0 0 0 20px; height: 1em;} 
     1377li.line label {width: auto;} 
     1378 
     1379#available_filters input[type=submit] {padding: 0 .1em; margin-left: .5em;} 
     1380 
     1381div.pagination span, div.pagination a { 
     1382     margin-right: 1em; 
     1383} 
    13591384/* jQuery Autocomplete plugin */ 
    13601385.ac_results { 
Note: See TracChangeset for help on using the changeset viewer.

Sites map