Dotclear

Changeset 756:5127beea4a3a for inc


Ignore:
Timestamp:
11/10/11 16:12:01 (14 years ago)
Author:
Dsls <dsls@…>
Branch:
formfilters
Message:
  • Adapted comments.php do new filters
  • added author filter, with autocompletion
  • added comment_author parameter to dcBlog::getComments
  • removed jquery.autocomplete
  • added jquery UI (should be refined, this is quite raw...)
  • added dcPager::jqueryUI
  • adapted tags plugin to new jquery ui autocomplete
Location:
inc
Files:
4 edited

Legend:

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

    r755 r756  
    4141          $this->action = $action; 
    4242          $this->extra_data = ''; 
     43          $this->filtered = false; 
    4344     } 
    4445      
     
    6263          $ser = array(); 
    6364          $ws = $GLOBALS['core']->auth->user_prefs->addWorkspace('filters'); 
    64           foreach($this->lfilters as $filter) { 
    65                $ser[$filter->id]=$filter->serialize(); 
    66           } 
    67           $ws->put($this->name,serialize($ser),'string'); 
     65          $data = array(); 
     66          $data= $this->getFiltersAsParams($this->efilters); 
     67          $ws->put($this->name,serialize($data->getArrayCopy()),'string'); 
     68          return $data; 
    6869     } 
    6970      
     
    7374     protected function loadFilters() { 
    7475          $ws = $GLOBALS['core']->auth->user_prefs->addWorkspace('filters'); 
    75            
    76           $settings = !is_null($ws->{$this->name}) ? unserialize($ws->{$this->name}) : array(); 
    77           foreach($settings as $k => $v) { 
    78                $this->lfilters[$k]->unserialize($v); 
    79           } 
     76          $data = (!is_null($ws->{$this->name})) ? unserialize($ws->{$this->name}) : array(); 
     77          if (is_array($data)) 
     78               return $data; 
     79          else 
     80               return array(); 
    8081     } 
    8182      
     
    152153                         if (isset($post['add_filter'])  
    153154                              && isset($this->efilters[$post['add_filter']])) { 
    154                               echo 'addadd'; 
    155155                         $this->efilters[$post['add_filter']]->add(); 
    156156                         } 
     
    162162                         } 
    163163                    } elseif ($action=="apply") { 
    164                          http::redirect($this->action.'?'.http_build_query($this->getFiltersAsParams($this->efilters),'','&')); 
     164                         $data = $this->saveFilters(); 
     165                         http::redirect($this->action.'?'.http_build_query($data,'','&')); 
    165166                         exit; 
    166167                    } 
     
    175176               $this->hideform=false; 
    176177          } else { 
     178               // Use case (2) 
     179               if (count($get)==0) { 
     180                    $get = $this->loadFilters(); 
     181               } 
    177182               $this->initializeFromData($this->efilters, $get); 
    178183               $this->initializeFromData($this->lfilters, $get); 
     
    192197               $formclass=''; 
    193198          } 
     199           
    194200          $ret .= '<p><img alt="" src="images/minus.png" /> '. 
    195201               '<a href="#" id="toggle-filters">'. 
    196202               __('Toggle filters and display options'). 
    197                '</a></p>'; 
    198            
    199           $ret .= 
     203               '</a></p>'. 
    200204               '<div class="two-cols">'. 
    201205               '<form id="filters" action="'.$this->action.'" method="post"'.$formclass.'>'. 
     
    217221          } 
    218222          $ret .= '</tbody></table>'. 
    219                '<p class="clear"><input class="delete" type="submit" value="'.__('Delete all filters').'" name="'. 
    220                $this->form_prefix.'clear_filters" />'. 
    221                '&nbsp;<input  type="submit" value="'.__('Reset').'" name="'. 
    222                $this->form_prefix.'reset" /></p>'. 
    223223               '<h3 class="margintop">'.__('Add a filter').'</h3>'. 
    224224               '<p id="available_filters">'. 
     
    226226               '<input type="submit" value=" + " title="'.__('Add this filter').'" name="'.$this->form_prefix.'add" />'. 
    227227               '</p>'. 
     228               '<p class="clear"><input class="delete" type="submit" value="'.__('Delete all filters').'" name="'. 
     229               $this->form_prefix.'clear_filters" />'. 
     230               '&nbsp;<input  type="submit" value="'.__('Reset').'" name="'. 
     231               $this->form_prefix.'reset" /></p>'. 
    228232               '</div>'; 
    229233          if ($this->extra_data != '') { 
     
    261265     } 
    262266      
    263      protected function displayFilters($filters) { 
    264           $ret = '<ul>'; 
    265           foreach ($filters as $f) { 
     267     public function getFiltersText() { 
     268          $ret = '<p>'.__('Currently applied filters :').'</p><ul>'; 
     269          foreach ($this->lfilters as $f) { 
    266270               if ($f->isEnabled()) 
    267                $ret .= '<li>'.$f->getAsText().'</li>'."\n"; 
     271                    $ret .= '<li>'.$f->getAsText().'</li>'."\n"; 
    268272          } 
    269273          $ret .= '</ul>'; 
     
    276280     */ 
    277281     public function header() { 
    278           return dcPage::jsLoad('js/filters.js'); 
     282          $ret = dcPage::jsLoad('js/filters.js'); 
     283          foreach($this->efilters as $f) { 
     284               $ret .= $f->header(); 
     285          } 
     286          return $ret; 
    279287     } 
    280288      
     
    295303     */ 
    296304     public function applyFilters($params) { 
    297           $filtered = false; 
    298305          foreach ($this->lfilters as $filter) { 
    299306               if ($filter->isEnabled()) { 
    300307                    $filter->applyFilter($params); 
    301                     $filtered = true; 
     308                    $this->filtered = true; 
    302309               } 
    303310          } 
    304           return $filtered; 
     311          return $this->filtered; 
    305312     } 
    306313      
     
    488495     } 
    489496 
     497     public function header() { 
     498          return ''; 
     499     } 
     500      
    490501     public abstract function getAsText(); 
    491502 
     
    602613      
    603614     public function getAsText() { 
    604           return sprintf("%s %s %s",$this->desc,$this->verb,join(',',$this->values)); 
     615          $arr=array(); 
     616          foreach ($this->values as $value) { 
     617               $arr[]=array_search($value,$this->options); 
     618          } 
     619          return sprintf("%s %s %s",$this->desc,$this->verb,join(',',$arr)); 
    605620     } 
    606621} 
    607622 
     623 
     624class categoryFilter extends comboFilter { 
     625     public function getAsText() { 
     626          $arr=array(); 
     627          foreach ($this->values as $value) { 
     628               $cat=array_search($value,$this->options); 
     629               $arr[]=preg_replace("#^.* ([^ ]+) .*$#",'$1',$cat); 
     630          } 
     631          return sprintf("%s %s %s",$this->desc,$this->verb,join(',',$arr)); 
     632     } 
     633} 
    608634/** 
    609635@ingroup DC_CORE 
     
    632658 
    633659     public function getFormFields($pos=0) { 
    634           return '<td><span class="'.$labelclass.'">'.$this->desc.'</span></td><td>'. 
     660          return '<td colspan="2">'.$this->desc.'</td><td>'. 
    635661               form::combo($this->getFieldId($pos),$this->options,$this->values[$pos], 
    636662                    '','',false,'title="'.__('Choose an option').'"').'</td>'; 
     
    668694 
    669695     public function getFormFields($pos=0) { 
    670           return '<span class="'.$labelclass.'">'.$this->desc.'</span>'. 
    671                form::field($this->getFieldId($pos),$this->size,$this->max,html::escapeHTML($this->values[0])); 
     696          return '<td colspan="2">'.$this->desc.'</td><td>'. 
     697               form::field($this->getFieldId($pos),$this->size,$this->max,html::escapeHTML($this->values[0])). 
     698               '</td>'; 
    672699     } 
    673700      
  • inc/admin/lib.dc.page.php

    r224 r756  
    501501     } 
    502502      
     503     public static function jqueryUI() 
     504     { 
     505          return 
     506          '<link rel="stylesheet" type="text/css" href="style/jquery-ui-1.8.16.custom.css" />'."\n". 
     507          self::jsLoad('js/jquery/jquery-ui-1.8.16.custom.min.js'); 
     508     } 
     509 
    503510     public static function jsColorPicker() 
    504511     { 
  • inc/core/class.dc.blog.php

    r506 r756  
    18311831               $strReq .= "AND LOWER(comment_author) LIKE '".$q_author."' "; 
    18321832          } 
     1833          if (isset($params['comment_author'])) { 
     1834               $strReq .= "AND comment_author ".$this->con->in($params['comment_author']).' '; 
     1835          } 
    18331836           
    18341837          if (!empty($params['search'])) 
  • inc/prepend.php

    r522 r756  
    7575$__autoload['dcFilterSet']              = dirname(__FILE__).'/admin/class.dc.filter.php'; 
    7676$__autoload['dcFilter']                 = dirname(__FILE__).'/admin/class.dc.filter.php'; 
     77$__autoload['textFilter']                    = dirname(__FILE__).'/admin/class.dc.filter.php'; 
     78$__autoload['comboFilter']                   = dirname(__FILE__).'/admin/class.dc.filter.php'; 
    7779 
    7880$__autoload['dcTemplate']               = dirname(__FILE__).'/public/class.dc.template.php'; 
Note: See TracChangeset for help on using the changeset viewer.

Sites map