Dotclear


Ignore:
Timestamp:
08/20/13 16:32:39 (12 years ago)
Author:
Dsls
Branch:
twig
Message:

formfilters improvement, added applied filters features

File:
1 edited

Legend:

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

    r1491 r1498  
    382382          $fcontext = new ArrayObject(); 
    383383          $sfcontext = new ArrayObject(); 
     384          $afcontext = new ArrayObject(); 
    384385          foreach ($this->filters as $f) { 
    385386               if($f->isEnabled()) { 
     
    390391               $f->appendFilterContext($sfcontext); 
    391392          } 
     393          foreach ($this->filters as $f) { 
     394               if ($f->isApplied()) { 
     395                    $afcontext[] = $f->getAppliedFilterText(); 
     396               } 
     397          } 
    392398          return array( 
    393399               'active_filters' => $fcontext, 
    394400               'static_filters' => $sfcontext, 
     401               'applied_filters' => $afcontext, 
    395402               'hide_filters'  => $this->hide_filterset, 
    396403               'prefix'        => $this->form_prefix); 
     
    635642 
    636643     protected abstract function addValue($value=NULL); 
    637  
     644     protected abstract function getAppliedFilterText(); 
     645      
    638646    /** 
    639647     * add -- adds a value for the filter 
     
    832840          $params[$this->request_param]=$this->avalues['values'][0]; 
    833841     } 
     842      
     843     public function getAppliedFilterText() { 
     844          if ($this->isApplied()) { 
     845               return sprintf(__('%s contains : "%s"'),$this->desc,$this->avalues['values'][0]); 
     846          } 
     847     } 
    834848} 
    835849 
     
    860874     */ 
    861875     public function init() { 
     876          echo $this->name.":".($this->multiple?"MULTIPLE":"SIMPLE"); 
    862877          $this->field = new dcFieldCombo( 
    863878               $this->filter_id, 
    864879               NULL, 
    865                $this->combo); 
     880               $this->combo,array( 
     881                    'multiple' => $this->multiple)); 
    866882          $this->filterset->addField($this->field); 
    867883     } 
     
    913929               $params[$attr]=$this->avalues['values'][0]; 
    914930     } 
    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     } 
    916940} 
    917941 
     
    10011025          } 
    10021026     } 
     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     } 
    10031047 
    10041048} 
Note: See TracChangeset for help on using the changeset viewer.

Sites map