Changeset 1498:6d67bea812f3
- Timestamp:
- 08/20/13 16:32:39 (12 years ago)
- Branch:
- twig
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/post.php
r1497 r1498 302 302 303 303 304 $form_comment = new dcForm($core,'add-comment',' post.php');304 $form_comment = new dcForm($core,'add-comment','comment.php'); 305 305 $form_comment 306 306 ->addField( … … 322 322 'required' => true, 323 323 'label' => __('Comment:')))) 324 ->addField( 325 new dcFieldHidden('post_id',$post_id)) 324 326 ->addField( 325 327 new dcFieldSubmit('add',__('Save'),array( -
admin/posts.php
r1492 r1498 158 158 'multiple' => true))) 159 159 ->addFilter(new dcFilterRichCombo( 160 'category',__('Category'), __('Category'), 'cat_id', $categories_combo)) 160 'category',__('Category'), __('Category'), 'cat_id', $categories_combo,array( 161 'multiple' => true))) 161 162 ->addFilter(new dcFilterRichCombo( 162 163 'post_status',__('Status'), __('Status'), 'post_status', $status_combo)) … … 172 173 173 174 $lfetcher = new PostsFetcher($core); 174 $lposts = new dcItemList ($core,array('lposts','form-entries'),$filterSet,$lfetcher,'posts_actions.php'); 175 $lposts = new dcItemList ($core,array('lposts','form-entries'),$lfetcher,'posts_actions.php'); 176 $lposts->setFilterSet($filterSet); 175 177 $lposts->addTemplate('posts_cols.html.twig'); 176 178 -
inc/admin/class.dc.filter.php
r1491 r1498 382 382 $fcontext = new ArrayObject(); 383 383 $sfcontext = new ArrayObject(); 384 $afcontext = new ArrayObject(); 384 385 foreach ($this->filters as $f) { 385 386 if($f->isEnabled()) { … … 390 391 $f->appendFilterContext($sfcontext); 391 392 } 393 foreach ($this->filters as $f) { 394 if ($f->isApplied()) { 395 $afcontext[] = $f->getAppliedFilterText(); 396 } 397 } 392 398 return array( 393 399 'active_filters' => $fcontext, 394 400 'static_filters' => $sfcontext, 401 'applied_filters' => $afcontext, 395 402 'hide_filters' => $this->hide_filterset, 396 403 'prefix' => $this->form_prefix); … … 635 642 636 643 protected abstract function addValue($value=NULL); 637 644 protected abstract function getAppliedFilterText(); 645 638 646 /** 639 647 * add -- adds a value for the filter … … 832 840 $params[$this->request_param]=$this->avalues['values'][0]; 833 841 } 842 843 public function getAppliedFilterText() { 844 if ($this->isApplied()) { 845 return sprintf(__('%s contains : "%s"'),$this->desc,$this->avalues['values'][0]); 846 } 847 } 834 848 } 835 849 … … 860 874 */ 861 875 public function init() { 876 echo $this->name.":".($this->multiple?"MULTIPLE":"SIMPLE"); 862 877 $this->field = new dcFieldCombo( 863 878 $this->filter_id, 864 879 NULL, 865 $this->combo); 880 $this->combo,array( 881 'multiple' => $this->multiple)); 866 882 $this->filterset->addField($this->field); 867 883 } … … 913 929 $params[$attr]=$this->avalues['values'][0]; 914 930 } 915 931 public function getAppliedFilterText() { 932 if ($this->isApplied()) { 933 if (count($this->avalues['values'])) { 934 return sprintf(__("%s is %s"),$this->desc,join(__(' OR '), $this->avalues['values'])); 935 } else { 936 return sprintf(__('%s is %s'),$this->desc,$this->avalues['values'][0]); 937 } 938 } 939 } 916 940 } 917 941 … … 1001 1025 } 1002 1026 } 1027 public function getAppliedFilterText() { 1028 if ($this->isApplied()) { 1029 if ($this->avalues['verb'] == "is") { 1030 $txt = __("%s is %s"); 1031 $or = __(' or '); 1032 } else { 1033 $txt = __("%s is not %s"); 1034 $or = __(' nor '); 1035 } 1036 $texts = array(); 1037 foreach ($this->avalues['values'] as $v) { 1038 $texts[] = $this->field->getTextForValue($v); 1039 } 1040 if (count($texts)>=1) { 1041 return sprintf($txt,$this->desc,join($or, $texts)); 1042 } else { 1043 return sprintf($txt,$this->desc,$texts); 1044 } 1045 } 1046 } 1003 1047 1004 1048 } -
inc/admin/class.dc.form.php
r1497 r1498 1064 1064 public function getAttributes($options=array()) 1065 1065 { 1066 $offset = isset($options['offset']) ? $options['offset'] : 0; 1067 1066 $offset = 0; 1068 1067 $attr = $this->options->getArrayCopy(); 1068 if (isset($options['offset'])) { 1069 $offset = $options['offset']; 1070 unset($attr['offset']); 1071 } 1072 1069 1073 if (isset($this->values[$offset])) { 1070 1074 $attr['value'] = $this->values[$offset]; … … 1241 1245 { 1242 1246 $val = array(); 1243 if (!is_array($values) ) {1247 if (!is_array($values) && $values !== null) { 1244 1248 $values = array("1" => !empty($values)); 1245 1249 } 1246 $this->checked = $values; 1247 parent::__construct($name,array_keys($values),$options); 1250 1251 if (is_array($values)) { 1252 $keys = array_keys($values); 1253 $this->checked = $values; 1254 } else { 1255 $keys = array(); 1256 $this->checked = array(); 1257 } 1258 1259 parent::__construct($name,$keys,$options); 1248 1260 } 1249 1261 … … 1381 1393 } 1382 1394 1395 public function getTextForValue($value) { 1396 if (isset($this->combo_values[$value])) { 1397 return $this->combo_values[$value]; 1398 } else { 1399 return false; 1400 } 1401 } 1383 1402 public function getAttributes($options=array()) { 1384 1403 $attr = parent::getAttributes($options); -
inc/admin/class.dc.list.php
r1491 r1498 14 14 15 15 protected $columns; 16 protected $columns_combo; 16 17 protected $entries; 17 18 protected $filterset; … … 54 55 @param form_prefix <b>string</b> form prefix to use for parameters 55 56 */ 56 public function __construct($core,$name,$f ilterset,$fetcher,$action,$form_prefix="f_") {57 public function __construct($core,$name,$fetcher,$action,$form_prefix="f_") { 57 58 parent::__construct($core,$name,$action,'POST'); 58 59 $this->entries = array(); … … 60 61 $this->selection = new dcFieldCheckbox('entries',NULL,array('multiple' => true)); 61 62 $this->addField($this->selection); 62 $this->filterset = $filterset;63 63 $this->fetcher = $fetcher; 64 } 65 66 public function setup() { 67 $this 68 ->addField(new dcFieldCombo('action','',array(), array( 69 'label' => __('Selected entries action:')))) 70 ->addField(new dcFieldSubmit('ok',__('ok'), array())); 71 $columns_combo = array(); 72 foreach ($this->columns as $c) { 73 $columns_combo[$c->getID()] = $c->getName(); 74 } 64 $this->filterset = null; 65 } 66 67 protected function setupFilterset() { 75 68 $this->sortby = new dcFilterCombo( 76 69 'sortby', 77 70 __('Sort By'), 78 __('Sort by'), 'sortby', $ columns_combo,array('singleval'=> true,'static' => true));71 __('Sort by'), 'sortby', $this->columns_combo,array('singleval'=> true,'static' => true)); 79 72 $this->filterset->addFilter($this->sortby); 80 73 $order_combo = array('asc' => __('Ascending'),'desc' => __('Descending')); … … 88 81 $this->filterset->addFilter($this->order); 89 82 $this->filterset->addFilter($limit); 90 $this->filterset->setup(); 83 $this->filterset->setup(); 84 $this->nb_items_per_page = $limit->getFields()->getValue(); 85 86 } 87 88 public function setup() { 89 $this 90 ->addField(new dcFieldCombo('action','',array(), array( 91 'label' => __('Selected entries action:')))) 92 ->addField(new dcFieldSubmit('ok',__('ok'), array())); 93 $this->columns_combo = array(); 94 foreach ($this->columns as $c) { 95 $this->columns_combo[$c->getID()] = $c->getName(); 96 } 97 if ($this->filterset !== null) { 98 $this->setupFilterset(); 99 } 91 100 parent::setup(); 92 $this->nb_items_per_page = $limit->getFields()->getValue();93 101 if ($this->nb_items_per_page == 0) 94 102 $this->nb_items_per_page = 10; … … 99 107 protected function fetchEntries() { 100 108 $params = new ArrayObject(); 101 $this->filterset->applyFilters($params); 109 if ($this->filterset != null) { 110 $this->filterset->applyFilters($params); 111 } 102 112 $this->nb_items = $this->fetcher->getEntriesCount($params); 103 113 $this->nb_pages = round($this->nb_items / $this->nb_items_per_page) + 1; -
inc/admin/default-templates/forms/formfilter_layout.html.twig
r1491 r1498 41 41 </div> 42 42 </div> 43 <p class="applied-filters">{{__('Applied filters :') }} </p> 44 <ul> 45 {% for f in fenv.applied_filters %} 46 <li>{{f}}</li> 47 {% endfor %} 48 </ul> 43 49 {%- endblock %} 44 50 … … 57 63 {% block filter_combo -%} 58 64 {% if f.display_inline is defined -%} 59 <p id='{{f.filter_id}}'>{{form_field(f.ffield,{ },{'label':f.desc,'nestedlabel': true, 'labelclass':'classic' })}}</p>65 <p id='{{f.filter_id}}'>{{form_field(f.ffield,{'offset':f.foffset},{'label':f.desc,'nestedlabel': true, 'labelclass':'classic' })}}</p> 60 66 {%- else -%} 61 67 <td id='{{f.filter_id}}' title='{{f.desc}}' class="filter-title" colspan="2">{{f.desc}} : </td> 62 <td >{{ form_field(f.ffield ) }}</td>68 <td >{{ form_field(f.ffield,{'offset':f.foffset}) }}</td> 63 69 {%- endif %} 64 70 {%- endblock %} … … 66 72 {% block filter_combo_cont -%} 67 73 {% if f.display_inline is defined -%} 68 <p id='{{filter_id}}'>{{form_field(f.ffield,{' label':__('or :')})}}</p>74 <p id='{{filter_id}}'>{{form_field(f.ffield,{'offset':f.foffset,'label':__('or :')})}}</p> 69 75 {%- else -%} 70 <td id='{{filter_id}}' colspan="2">{{ __('or :') }} </td><td>{{ form_field(f.ffield ) }}</td>76 <td id='{{filter_id}}' colspan="2">{{ __('or :') }} </td><td>{{ form_field(f.ffield,{'offset':f.foffset}) }}</td> 71 77 {%- endif %} 72 78 {%- endblock %} … … 76 82 <td id='{{filterd_id}}' title='{{f.desc}}' class="filter-title">{{f.desc}} : </td> 77 83 <td>{{ form_field(f.fverb)}}</td> 78 <td>{{ form_field(f.ffield ) }}</td>84 <td>{{ form_field(f.ffield,{'offset':f.foffset}) }}</td> 79 85 {%- endblock %} 80 86 … … 82 88 {% block filter_boolean -%} 83 89 <td id='{{filterd_id}}' title='{{f.desc}}' class="filter-title" colspan="2">{{f.desc}}</td> 84 <td>{{ form_field(f.ffield ) }}</td>90 <td>{{ form_field(f.ffield,{'offset':f.foffset}) }}</td> 85 91 {%- endblock %} 86 92 87 93 {% block filter_text -%} 88 94 {% if f.display_inline is defined -%} 89 <p id='{{filter_id}}'>{{form_field(f.ffield,{ },{'label':f.desc,'nestedlabel': true, 'labelclass':'classic' })}}</p>95 <p id='{{filter_id}}'>{{form_field(f.ffield,{'offset':f.foffset},{'label':f.desc,'nestedlabel': true, 'labelclass':'classic' })}}</p> 90 96 {%- else -%} 91 97 <td id='{{filterd_id}}' title='{{f.desc}}' class="filter-title" colspan="2">{{f.desc}}</td> 92 <td>{{ form_field(f.ffield ) }}</td>98 <td>{{ form_field(f.ffield,{'offset':f.foffset}) }}</td> 93 99 {%- endif %} 94 100 {%- endblock %} -
inc/admin/default-templates/forms/lists_layout.html.twig
r1156 r1498 2 2 {% set lenv = _context['list_' ~ listname] %} 3 3 {% if lenv.entries %} 4 {% block list_pagination %} 5 <p>Page : {% for p in lenv.pages_links %} 6 {% if p == lenv.page or p == '...' %} 7 <b>{{p}}</b> 8 {% else %} 9 <a href="{{build_url(lenv.url,{'page':p})}}">{{p}}</a> 10 {% endif %} 11 {% endfor %}</p> 4 {% block list_pagination -%} 5 <p class="pagination">{{__('Page:')}} 6 {% for p in lenv.pages_links -%} 7 {% if p == lenv.page or p == '...' %} 8 <b>{{p}}</b> 9 {% else %} 10 <a href="{{build_url(lenv.url,{'page':p})}}">{{p}}</a> 11 {% endif %} 12 {% if not loop.last %} - {% endif %} 13 {%- endfor %}</p> 12 14 {% endblock %} 13 15 {% form listname -%} … … 17 19 <tr> 18 20 {% for h in lenv.cols -%} 19 <th scope="col" >{{h.name}}</th>21 <th scope="col"{% if loop.first %} colspan="2"{% endif %}>{{h.name}}</th> 20 22 {%- endfor %} 21 23 </tr> 22 24 {% for e in lenv.entries %} 23 25 {% block list_line_start %}<tr class="line">{% endblock %} 26 <td>{{widget('col_ref',{'e':e,'offset':loop.parent.loop.index0})}}</td> 24 27 {% for h in lenv.cols %} 25 28 <td>{{widget(h.widget,{'e':e,'offset':loop.parent.loop.index0})}}</td> … … 44 47 {% endblock filter_checkbox %} 45 48 49 50 {% block col_ref %} 51 {{form_field('entries',{'offset':offset})}} 52 {% endblock %} -
inc/admin/default-templates/post.html.twig
r1493 r1498 1 1 {% extends "layout.html.twig" %} 2 2 {% import "js_helpers.html.twig" as js %} 3 3 4 {% macro img_status(status) -%} 4 5 {% if status == 1 %} … … 13 14 <img alt="{{title}}" title="{{title}}" src="images/{{src}}" /> 14 15 {%- endmacro %} 16 15 17 {% macro post_link(id,title,link) -%} 16 18 <a href="post.php?id={{id}}" title="{{title}}">{{link}}</a> … … 75 77 {% endform %} 76 78 </div> 79 80 {# Trackbacks tab #} 77 81 {% if post_id is defined %} 78 82 <p><a href="trackbacks.php?id={{ post_id }}" class="multi-part">{{__('Ping blogs')}}</a></p> 83 84 {# Comments list tab #} 79 85 <div class="multi-part" id="comments" title="{{__('Comments')}}"> 80 86 <!-- to be completed --> 81 87 </div> 88 89 {# Add a comment tab #} 82 90 <div class="multi-part" id="add-comment" title="{{__('Add a comment')}}"> 83 91 <h3>{{__('Add a comment')}}</h3> -
inc/admin/default-templates/posts.html.twig
r1491 r1498 26 26 {{ filterset('fposts') }} 27 27 28 <p> Applied filters : {{filters}} </p>29 30 28 {{ listitems('lposts')}} 31 29 -
inc/admin/default-templates/posts_cols.html.twig
r1156 r1498 1 1 2 {% block col_ref %}3 {{form_field('entries',{'offset':offset})}}4 {% endblock %}5 2 6 3 {% block col_title %} 7 {{block('col_ref')}}8 4 <a href="post.php?id={{e.post_id}}">{{e.post_title}}</a> 9 5 {% endblock %}
Note: See TracChangeset
for help on using the changeset viewer.