Changeset 756:5127beea4a3a for inc
- Timestamp:
- 11/10/11 16:12:01 (14 years ago)
- Branch:
- formfilters
- Location:
- inc
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/admin/class.dc.filter.php
r755 r756 41 41 $this->action = $action; 42 42 $this->extra_data = ''; 43 $this->filtered = false; 43 44 } 44 45 … … 62 63 $ser = array(); 63 64 $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; 68 69 } 69 70 … … 73 74 protected function loadFilters() { 74 75 $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(); 80 81 } 81 82 … … 152 153 if (isset($post['add_filter']) 153 154 && isset($this->efilters[$post['add_filter']])) { 154 echo 'addadd';155 155 $this->efilters[$post['add_filter']]->add(); 156 156 } … … 162 162 } 163 163 } 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,'','&')); 165 166 exit; 166 167 } … … 175 176 $this->hideform=false; 176 177 } else { 178 // Use case (2) 179 if (count($get)==0) { 180 $get = $this->loadFilters(); 181 } 177 182 $this->initializeFromData($this->efilters, $get); 178 183 $this->initializeFromData($this->lfilters, $get); … … 192 197 $formclass=''; 193 198 } 199 194 200 $ret .= '<p><img alt="" src="images/minus.png" /> '. 195 201 '<a href="#" id="toggle-filters">'. 196 202 __('Toggle filters and display options'). 197 '</a></p>'; 198 199 $ret .= 203 '</a></p>'. 200 204 '<div class="two-cols">'. 201 205 '<form id="filters" action="'.$this->action.'" method="post"'.$formclass.'>'. … … 217 221 } 218 222 $ret .= '</tbody></table>'. 219 '<p class="clear"><input class="delete" type="submit" value="'.__('Delete all filters').'" name="'.220 $this->form_prefix.'clear_filters" />'.221 ' <input type="submit" value="'.__('Reset').'" name="'.222 $this->form_prefix.'reset" /></p>'.223 223 '<h3 class="margintop">'.__('Add a filter').'</h3>'. 224 224 '<p id="available_filters">'. … … 226 226 '<input type="submit" value=" + " title="'.__('Add this filter').'" name="'.$this->form_prefix.'add" />'. 227 227 '</p>'. 228 '<p class="clear"><input class="delete" type="submit" value="'.__('Delete all filters').'" name="'. 229 $this->form_prefix.'clear_filters" />'. 230 ' <input type="submit" value="'.__('Reset').'" name="'. 231 $this->form_prefix.'reset" /></p>'. 228 232 '</div>'; 229 233 if ($this->extra_data != '') { … … 261 265 } 262 266 263 p rotected 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) { 266 270 if ($f->isEnabled()) 267 $ret .= '<li>'.$f->getAsText().'</li>'."\n";271 $ret .= '<li>'.$f->getAsText().'</li>'."\n"; 268 272 } 269 273 $ret .= '</ul>'; … … 276 280 */ 277 281 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; 279 287 } 280 288 … … 295 303 */ 296 304 public function applyFilters($params) { 297 $filtered = false;298 305 foreach ($this->lfilters as $filter) { 299 306 if ($filter->isEnabled()) { 300 307 $filter->applyFilter($params); 301 $ filtered = true;308 $this->filtered = true; 302 309 } 303 310 } 304 return $ filtered;311 return $this->filtered; 305 312 } 306 313 … … 488 495 } 489 496 497 public function header() { 498 return ''; 499 } 500 490 501 public abstract function getAsText(); 491 502 … … 602 613 603 614 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)); 605 620 } 606 621 } 607 622 623 624 class 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 } 608 634 /** 609 635 @ingroup DC_CORE … … 632 658 633 659 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>'. 635 661 form::combo($this->getFieldId($pos),$this->options,$this->values[$pos], 636 662 '','',false,'title="'.__('Choose an option').'"').'</td>'; … … 668 694 669 695 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>'; 672 699 } 673 700 -
inc/admin/lib.dc.page.php
r224 r756 501 501 } 502 502 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 503 510 public static function jsColorPicker() 504 511 { -
inc/core/class.dc.blog.php
r506 r756 1831 1831 $strReq .= "AND LOWER(comment_author) LIKE '".$q_author."' "; 1832 1832 } 1833 if (isset($params['comment_author'])) { 1834 $strReq .= "AND comment_author ".$this->con->in($params['comment_author']).' '; 1835 } 1833 1836 1834 1837 if (!empty($params['search'])) -
inc/prepend.php
r522 r756 75 75 $__autoload['dcFilterSet'] = dirname(__FILE__).'/admin/class.dc.filter.php'; 76 76 $__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'; 77 79 78 80 $__autoload['dcTemplate'] = dirname(__FILE__).'/public/class.dc.template.php';
Note: See TracChangeset
for help on using the changeset viewer.