Dotclear

Changeset 1491:2b9253624dbe


Ignore:
Timestamp:
08/20/13 10:56:34 (12 years ago)
Author:
Dsls
Branch:
twig
Message:

Implemented last merges from default, post.php is now more flexible.
added twig function : form_field_attr

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • admin/post.php

    r1490 r1491  
    193193          new dcFieldCombo('post_status',$core->auth->getInfo('user_post_status'),$status_combo,array( 
    194194               'disabled' => !$can_publish, 
    195                'label' => __('Entry status:')))) 
     195               'label' => __('Entry status')))) 
    196196     ->addField( 
    197197          new dcFieldCombo('cat_id','',$categories_combo,array( 
    198                "label" => __('Category:')))) 
     198               "label" => __('Category')))) 
     199     ->addField( 
     200          new dcFieldCombo('new_cat_parent','',$categories_combo,array( 
     201               "label" => __('Parent:')))) 
     202     ->addField( 
     203          new dcFieldText('new_cat_title','', array( 
     204               'maxlength'         => 255, 
     205               'label'        => __('Title')))) 
     206           
    199207     ->addField( 
    200208          new dcFieldText('post_dt','',array( 
    201                "label" => __('Published on:')))) 
     209               "label" => __('Publication date and hour')))) 
    202210     ->addField( 
    203211          new dcFieldCombo('post_format',$core->auth->getOption('post_format'),$formaters_combo,array( 
    204                "label" => __('Text formating:')))) 
     212               "label" => __('Text formating')))) 
    205213     ->addField( 
    206214          new dcFieldCheckbox ('post_open_comment',$core->blog->settings->system->allow_comments,array( 
     
    302310$form->setup(); 
    303311 
     312$sidebar_blocks = new ArrayObject(array( 
     313     'status-box' => array( 
     314          'title' => __('Status'), 
     315          'items' => array('post_status','post_dt','post_lang','post_format')), 
     316     'metas-box' => array( 
     317          'title' => __('Ordering'), 
     318          'items' => array('post_selected','cat_id')), 
     319     'options-box' => array( 
     320          'title' => __('Options'), 
     321          'items' => array('post_open_comment','post_open_tb','post_password','post_url')) 
     322)); 
     323 
     324$main_blocks = new ArrayObject(array( 
     325     "post_title","post_excerpt","post_content","post_notes" 
     326)); 
     327 
     328 
     329$_ctx->sidebar_blocks = $sidebar_blocks; 
     330$_ctx->main_blocks = $main_blocks; 
     331 
    304332/* DISPLAY 
    305333-------------------------------------------------------- */ 
     
    321349     ->default_tab = $default_tab; 
    322350 
     351      
     352      
    323353$core->tpl->display('post.html.twig'); 
    324354?> 
  • inc/admin/class.dc.filter.php

    r1158 r1491  
    8787          $this->filtered = false; 
    8888          parent::__construct($core,$name,$action,'POST'); 
    89           $this->id = "filters"; 
     89          //$this->id = "filters"; 
    9090     } 
    9191 
     
    872872     protected function addValue($value=NULL) { 
    873873          if ($value === NULL) { 
    874                $value = current($this->combo); 
     874               $value = current(array_keys($this->combo)); 
    875875          } 
    876876          $this->field->addValue($value); 
  • inc/admin/class.dc.form.php

    r1489 r1491  
    165165               ), 
    166166               new Twig_SimpleFunction( 
     167                    'form_field_attr', 
     168                    array($this,'getFieldAttributes'), 
     169                    array('is_safe' => array('html')) 
     170               ), 
     171               new Twig_SimpleFunction( 
    167172                    '_form_is_choice_group', 
    168173                    array($this,'isChoiceGroup'), 
     
    286291               } 
    287292               $this->renderWidget( 
    288                     $field->getWidgetBlock(), 
     293               $field->getWidgetBlock(), 
    289294                    array_merge( 
    290295                         $attr, 
     
    292297                    ) 
    293298               ); 
     299          } 
     300     } 
     301 
     302    /** 
     303     * getFieldAttributes - binding for 'form_field_attr' twig function; returns all field attributes 
     304     * 
     305     * @param mixed $name       field name as defined on php side. 
     306     * @param mixed $name       the attribute name, null to grab all attributes as an array 
     307     * 
     308     * @access public 
     309     * 
     310     * @return array the field attributes 
     311     */    
     312     public function getFieldAttributes($name,$attr=null) 
     313     { 
     314          $field = $this->currentForm->getField($name); 
     315          if ($field) { 
     316               $a = $field->getAttributes(); 
     317               if ($attr !== null) { 
     318                    if (isset($a[$attr])) { 
     319                         return $a[$attr]; 
     320                    } else { 
     321                         return null; 
     322                    } 
     323               } else { 
     324                    return $field->getAttributes(); 
     325               } 
     326          } else { 
     327               return array(); 
    294328          } 
    295329     } 
     
    821855     } 
    822856 
     857     public function getFieldIDs() { 
     858          return array_keys($this->fields); 
     859     } 
     860      
    823861    /** 
    824862     * getHiddenFields - returns the list of hidden fields 
     
    10241062     * @return array the attributes. 
    10251063     */ 
    1026      public function getAttributes($options) 
     1064     public function getAttributes($options=array()) 
    10271065     { 
    10281066          $offset = isset($options['offset']) ? $options['offset'] : 0; 
     
    12311269     } 
    12321270      
    1233      public function getAttributes($options) 
     1271     public function getAttributes($options=array()) 
    12341272     { 
    12351273          $a = parent::getAttributes($options); 
     
    12441282     public function setup($from) 
    12451283     { 
     1284          $this->defined = true; 
    12461285          $values = $this->parseValues($from); 
    12471286          foreach ($this->checked as $k=>&$v) { 
     
    13261365 
    13271366     public function getDefaultValue() { 
    1328           return current($this->combo); 
     1367          return current(array_keys($this->combo_values)); 
    13291368     } 
    13301369 
     
    13421381     } 
    13431382 
    1344      public function getAttributes($options) { 
     1383     public function getAttributes($options=array()) { 
    13451384          $attr = parent::getAttributes($options); 
    13461385          $attr['options'] = $this->combo; 
  • inc/admin/class.dc.list.php

    r1158 r1491  
    164164     public function getOrder() { 
    165165          $id = $this->sortby->getFields()->getValue(); 
    166  
    167166          return $this->columns[$id]->getColID().' '.$this->order->getFields()->getValue(); 
    168167     } 
  • inc/admin/default-templates/forms/form_layout.html.twig

    r1414 r1491  
    8787{% endspaceless %} 
    8888{% endblock field_combo %} 
    89 {# 
    90 {% block label %} 
    91 {% spaceless %} 
    92      {% if label is not empty %} 
    93           <label for="{{name}}" {% if required is not empty %}class="required"> <abbr title="{{__('Required field')}}">*</abbr>{% else %}>{% endif %} {{label}}</label> 
    94      {% endif %} 
    95 {% endspaceless %} 
    96 {% endblock label %} 
    97 #} 
    9889 
    9990{% block startlabel %} 
  • inc/admin/default-templates/forms/formfilter_layout.html.twig

    r1154 r1491  
    44{% block filterset -%} 
    55<p> 
    6      <a href="#" id="toggle-filters">{{ __('Toggle filters and display options') }} </a> 
     6     <a href="#" id="filter-control" class="form-control">{{ __('Toggle filters and display options') }} </a> 
    77</p> 
     8{% form filtersetname with {'id':'filters-form' } -%} 
     9<h3>Filtrer la liste des billets</h3> 
     10<div class="table"> 
    811<div class="two-cols"> 
    912{% set fenv = _context['filterset_' ~ filtersetname] %} 
    10 {% form filtersetname with {'class':fenv.hide_filters?'hidden':'opened' } -%} 
    1113     <div class="col70"> 
    1214          <h3>{{__('Entries filters')}}</h3> 
     
    3739     <p class="clear margintop"></p> 
    3840{%- endform -%} 
     41</div> 
    3942</div> 
    4043{%- endblock %} 
  • inc/admin/default-templates/post.html.twig

    r1319 r1491  
    11{% extends "layout.html.twig" %} 
    22{% import "js_helpers.html.twig" as js %} 
     3{% macro img_status(status) -%} 
     4     {% if status == 1 %} 
     5          {% set title,src = __('Published'),'check-on.png' %} 
     6     {% elseif status == 0 %} 
     7          {% set title,src = __('Unpublished'),'check-off.png' %} 
     8     {% elseif status == -1 %} 
     9          {% set title,src = __('Pending'),'check-wrn.png' %} 
     10     {% elseif status == -2 %} 
     11          {% set title,src = __('Junk'),'junk.png' %} 
     12     {% endif %} 
     13     <img alt="{{title}}" title="{{title}}" src="images/{{src}}" /> 
     14{%- endmacro %} 
    315{% block header %} 
    416     {{ parent() }} 
     
    2032     <div id="entry-content"> 
    2133          <div class="constrained"> 
    22                <p class="col">{{ form_field('post_title',{'class':'maximal'}) }}</p> 
    23                <p class="area" id="excerpt-area">{{ form_field('post_excerpt',{'rows':5,'cols':50}) }}</p> 
    24                <p class="area" id="content-area">{{ form_field('post_content',{'rows':current_user.options.edit_size,'cols':5}) }}</p> 
    25                <p class="area" id="notes-area">{{ form_field('post_notes',{'rows':5,'cols':50}) }}</p> 
     34               {% for bl in main_blocks %} 
     35                    {{ block(bl) }} 
     36               {% endfor %} 
    2637               <p>{{ form_field('save')}}  
    2738               {% if preview_url is defined %} 
     
    3546</div> 
    3647<div id="entry-sidebar"> 
    37      <p>{{ form_field('cat_id',{'class':'maximal'})}}</p> 
    38      <p>{{ form_field('post_status')}}</p> 
    39      <p>{{ form_field('post_dt')}}</p> 
    40      <p>{{ form_field('post_format')}}</p> 
    41      <p>{{ form_field('post_open_comment')}}</p> 
    42      <p>{{ form_field('post_open_tb')}}</p> 
    43      <p>{{ form_field('post_selected')}}</p> 
    44      <p>{{ form_field('post_lang',{"class":"maximal"},{'nestedlabel':true})}}</p> 
    45      <p>{{ form_field('post_password',{"size":10, "class":"maximal"},{'nestedlabel':true})}}</p> 
    46      <div class="lockable"> 
    47           <p>{{ form_field('post_url',{"size":10, "class":"maximal"})}} </p> 
    48           <p class="form-note warn"> 
    49           {{ __('Warning: If you set the URL manually, it may conflict with another entry.') }} 
    50           </p> 
    51      </div> 
     48     {% for id,box in sidebar_blocks  %} 
     49          <div id="{{id}}" class="box"> 
     50               <h4>{{box.title}}</h4> 
     51               {% for bl in box.items %} 
     52                    {{ block(bl)}} 
     53               {% endfor %} 
     54          </div> 
     55     {% endfor %} 
    5256</div> 
    5357{% endform %} 
     
    7579{% endblock %} 
    7680 
     81{% block field_post_status %} 
     82<p>{{ form_field('post_status',{},{'labelclass':'ib'}) }}</p> 
     83{% endblock %} 
     84 
     85{# Field-specific blocks #} 
     86 
     87{% block post_title -%} 
     88     <p class="col">{{ form_field('post_title',{'class':'maximal'}) }}</p> 
     89{%- endblock %} 
     90 
     91{% block post_excerpt -%} 
     92     <p class="area" id="excerpt-area">{{ form_field('post_excerpt',{'rows':5,'cols':50}) }}</p> 
     93{%- endblock %} 
     94 
     95{% block post_content -%} 
     96     <p class="area" id="content-area">{{ form_field('post_content',{'rows':current_user.options.edit_size,'cols':5}) }}</p> 
     97{%- endblock %} 
     98 
     99{% block post_notes -%} 
     100     <p class="area" id="notes-area">{{ form_field('post_notes',{'rows':5,'cols':50}) }}</p> 
     101{%- endblock %} 
     102 
     103{% block post_status -%} 
     104     <p><label class="ib">{{form_field_attr('post_status','label')}} {{ _self.img_status(form_field_attr('post_status','value'))}}</label>{{ form_field('post_status',{},{'label':'','labelclass':'ib'})}}</p> 
     105{%- endblock %} 
     106 
     107{% block post_dt -%} 
     108     <p>{{ form_field('post_dt',{},{'labelclass':'ib'})}}</p> 
     109{%- endblock %} 
     110 
     111{% block post_lang -%} 
     112     <p>{{ form_field('post_lang',{"class":"maximal"},{'nestedlabel':true, 'labelclass':'ib'})}}</p> 
     113{%- endblock %} 
     114 
     115{% block post_format -%} 
     116     <p>{{ form_field('post_format',{},{'labelclass':'ib'})}}</p> 
     117     {% if post_id and form_field_attr('post_format','value')=='xhtml' %} 
     118     <p><a id="convert-xhtml" class="button maximal" href="post.php?id={{post_id}}&amp;xconv=1"> 
     119     {{__('Convert to XHTML')}}</a></p> 
     120     {% endif %} 
     121{%- endblock %} 
     122 
     123{% block post_selected -%} 
     124     <p>{{ form_field('post_selected',{},{'labelclass':'ib'})}}</p> 
     125{%- endblock %} 
     126 
     127{% block cat_id -%} 
     128     <p>{{ form_field('cat_id',{'class':'maximal'},{'labelclass':'ib'}) }}</p> 
     129     {#{% if can_edit_categories %}#} 
     130     <div> 
     131          <p id="new_cat">{{__('Add a new category')}}</p> 
     132          <p>{{ form_field('new_cat_title') }}</p> 
     133          <p>{{ form_field('new_cat_parent') }} </p> 
     134     </div> 
     135     {#{% endif %}#} 
     136{%- endblock %} 
     137 
     138{% block post_open_comment -%} 
     139     <p>{{ form_field('post_open_comment')}}</p> 
     140     {% if post_comment_warning is defined -%} 
     141     <p class="form-note warn">{{post_comment_warning}}</p> 
     142     {%- endif %} 
     143{%- endblock %} 
     144 
     145{% block post_open_tb -%} 
     146     <p>{{ form_field('post_open_tb')}}</p> 
     147     {% if post_tb_warning is defined -%} 
     148     <p class="form-note warn">{{post_tb_warning}}</p> 
     149     {%- endif %} 
     150{%- endblock %} 
     151 
     152{% block post_password -%} 
     153     <p>{{ form_field('post_password',{"size":10, "class":"maximal"},{'nestedlabel':true, 'labelclass':'ib'})}}</p> 
     154{%- endblock %} 
     155 
     156{% block post_url -%} 
     157     <div class="lockable"> 
     158          <p>{{ form_field('post_url',{"size":10, "class":"maximal"}, {'labelclass':'ib'})}} </p> 
     159          <p class="form-note warn"> 
     160          {{ __('Warning: If you set the URL manually, it may conflict with another entry.') }} 
     161          </p> 
     162     </div> 
     163{%- endblock %} 
     164 
  • inc/admin/default-templates/posts.html.twig

    r1152 r1491  
    88     {{ js.meta_editor }} 
    99     <script type="text/javascript" src="{{theme_url}}js/_posts_list.js"></script> 
    10      <script type="text/javascript" src="{{theme_url}}js/filters.js"></script> 
     10     <script type="text/javascript" src="{{theme_url}}js/filter-control.js"></script> 
    1111     {{ js.confirm_close(['entry-form','comment-form']) }} 
    1212     {{ js.page_tabs(default_tab) }} 
  • inc/core/class.dc.blog.php

    r1490 r1491  
    9191               $this->public_path = path::fullFromRoot($this->settings->system->public_path,DC_ROOT); 
    9292                
    93                $this->post_status['-2'] = __('pending'); 
    94                $this->post_status['-1'] = __('scheduled'); 
    95                $this->post_status['0'] = __('unpublished'); 
    96                $this->post_status['1'] = __('published'); 
    97                 
    98                $this->comment_status['-2'] = __('junk'); 
    99                $this->comment_status['-1'] = __('pending'); 
    100                $this->comment_status['0'] = __('unpublished'); 
    101                $this->comment_status['1'] = __('published'); 
     93               $this->post_status['-2'] = __('Pending'); 
     94               $this->post_status['-1'] = __('Scheduled'); 
     95               $this->post_status['0'] = __('Unpublished'); 
     96               $this->post_status['1'] = __('Published'); 
     97                
     98               $this->comment_status['-2'] = __('Junk'); 
     99               $this->comment_status['-1'] = __('Pending'); 
     100               $this->comment_status['0'] = __('Unpublished'); 
     101               $this->comment_status['1'] = __('Published'); 
    102102                
    103103               # --BEHAVIOR-- coreBlogConstruct 
Note: See TracChangeset for help on using the changeset viewer.

Sites map