Changeset 756:5127beea4a3a
- Timestamp:
- 11/10/11 16:12:01 (14 years ago)
- Branch:
- formfilters
- Files:
-
- 1 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/comments.php
r523 r756 14 14 15 15 dcPage::check('usage,contentadmin'); 16 17 class authorFilter extends textFilter { 18 public function header() { 19 return 20 dcPage::jqueryUI(). 21 dcPage::jsLoad('js/author_filter.js') 22 ; 23 } 24 public function applyFilter($params) { 25 $val = preg_split("/[\s,]+/",$this->values[0]); 26 $params[$this->request_param]=$val; 27 } 28 } 29 16 30 17 31 # Creating filter combo boxes … … 54 68 $filterSet = new dcFilterSet('comments','comments.php'); 55 69 56 $authorFilter = new textFilter(57 'author',__('Author'), __('Author'),' q_author',20,255);70 $authorFilter = new authorFilter( 71 'author',__('Author'), __('Author'),'comment_author',20,255); 58 72 $filterSet 59 73 ->addFilter(new comboFilter( … … 67 81 $core->callBehavior('adminCommentsFilters',$filterSet); 68 82 69 $filterSet->set FormValues($_GET);83 $filterSet->setup($_GET,$_POST); 70 84 if (isset($_GET['author'])) { 71 85 $authorFilter->add(); … … 91 105 $core->error->add($e->getMessage()); 92 106 } 93 $filterSet->set ColumnsForm($comment_list->getColumnsForm());107 $filterSet->setExtraData($comment_list->getColumnsForm()); 94 108 95 109 /* DISPLAY 96 110 -------------------------------------------------------- */ 97 $starting_script = dcPage::jsLoad('js/_comments.js').$filterSet->header(); ;111 $starting_script = dcPage::jsLoad('js/_comments.js').$filterSet->header(); 98 112 99 113 # --BEHAVIOR-- adminCommentsHeaders -
admin/posts.php
r755 r756 138 138 ->addFilter(new comboFilter( 139 139 'users',__('Author'), __('Author'), 'user_id', $users_combo)) 140 ->addFilter(new c omboFilter(140 ->addFilter(new categoryFilter( 141 141 'category',__('Category'), __('Category'), 'cat_id', $categories_combo)) 142 142 ->addFilter(new comboFilter( … … 147 147 'lang',__('Lang'), __('Lang'), 'post_lang', $lang_combo)) 148 148 ->addFilter(new monthComboFilter( 149 'month',__('Month'),__('Month'), 'post_month', $dt_m_combo,array('singleval' => 1))); 149 'month',__('Month'),__('Month'), 'post_month', $dt_m_combo,array('singleval' => 1))) 150 ->addFilter(new textFilter( 151 'search',__('Contains'),__('The entry contains'), 'search',20,255)); 150 152 151 153 $core->callBehavior('adminPostsFilters',$filterSet); … … 165 167 } else { 166 168 $page_title = __('Entries'); 169 $filters_info = ''; 167 170 } 168 171 $post_list->setItems($posts,$counter->f(0)); -
admin/services.php
r0 r756 25 25 $core->rest->addFunction('delMeta',array('dcRestMethods','delMeta')); 26 26 $core->rest->addFunction('setPostMeta',array('dcRestMethods','setPostMeta')); 27 $core->rest->addFunction('searchCommentAuthor',array('dcRestMethods','searchCommentAuthor')); 27 28 $core->rest->addFunction('searchMeta',array('dcRestMethods','searchMeta')); 28 29 … … 393 394 return $rsp; 394 395 } 396 397 public static function searchCommentAuthor($core,$get) 398 { 399 $q = !empty($get['q']) ? strtoupper($get['q']) : null; 400 401 $strReq = 'SELECT DISTINCT C.comment_author '. 402 'FROM '.$core->prefix.'comment C '. 403 'INNER JOIN '.$core->prefix.'post P on C.post_id = P.post_id '. 404 'WHERE P.blog_id = \''.$core->blog->id.'\' '. 405 'AND UPPER(comment_author) like \'%'.$core->con->escape($q).'%\'' 406 ; 407 //echo $strReq; 408 $rs = $core->con->select($strReq); 409 $rsp = new xmlTag(); 410 411 while ($rs->fetch()) 412 { 413 $author = new xmlTag('author'); 414 $author->name=$rs->comment_author; 415 $rsp->insertNode($author); 416 } 417 418 return $rsp; 419 } 420 395 421 } 396 422 ?> -
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'; -
plugins/tags/_admin.php
r217 r756 108 108 109 109 return 110 '<script type="text/javascript" src="index.php?pf=tags/js/jquery.autocomplete.min.js"></script>'.110 dcPage::jqueryUI(). 111 111 '<script type="text/javascript" src="index.php?pf=tags/js/post.js"></script>'. 112 112 '<script type="text/javascript">'."\n". … … 137 137 138 138 return 139 '<script type="text/javascript" src="index.php?pf=tags/js/jquery.autocomplete.min.js"></script>'.140 '<script type="text/javascript" src="index.php?pf=tags/js/posts_actions.js"></script>'.141 139 '<script type="text/javascript">'."\n". 142 140 "//<![CDATA[\n". … … 153 151 "\n//]]>\n". 154 152 "</script>\n". 153 '<script type="text/javascript" src="index.php?pf=tags/js/posts_actions.js"></script>'. 154 dcPage::jqueryUI(). 155 155 '<link rel="stylesheet" type="text/css" href="index.php?pf=tags/style.css" />'; 156 156 } -
plugins/tags/js/post.js
r0 r756 1 1 $(function() { 2 function split( val ) { 3 return val.split( /,\s*/ ); 4 } 5 function extractLast(term) { 6 return split(term).pop(); 7 } 2 8 $('#edit-entry').onetabload(function() { 3 9 var tags_edit = $('#tags-edit'); … … 18 24 } 19 25 20 $('#post_meta_input').autocomplete(mEdit.service_uri, { 21 extraParams: { 22 'f': 'searchMeta', 23 'metaType': 'tag' 24 }, 25 delay: 1000, 26 multiple: true, 27 matchSubset: false, 28 matchContains: true, 29 parse: function(xml) { 30 var results = []; 31 $(xml).find('meta').each(function(){ 32 results[results.length] = { 33 data: { 34 "id": $(this).text(), 35 "count": $(this).attr("count"), 36 "percent": $(this).attr("roundpercent") 37 }, 38 result: $(this).text() 39 }; 40 }); 41 return results; 42 }, 43 formatItem: function(tag) { 44 return tag.id + ' <em>(' + 45 dotclear.msg.tags_autocomplete. 46 replace('%p',tag.percent). 47 replace('%e',tag.count + ' ' + 48 (tag.count > 1 ? 49 dotclear.msg.entries : 50 dotclear.msg.entry) 51 ) + 52 ')</em>'; 53 }, 54 formatResult: function(tag) { 55 return tag.result; 26 $('#post_meta_input') 27 .bind( "keydown", function( event ) { 28 if ( event.keyCode === $.ui.keyCode.TAB && 29 $( this ).data( "autocomplete" ).menu.active ) { 30 event.preventDefault(); 31 } 32 }) 33 .autocomplete({ 34 minLength: 2, 35 delay: 1000, 36 source: function(request,response) { 37 $.ajax({ 38 url: mEdit.service_uri, 39 data: { 40 'f': 'searchMeta', 41 'metaType': 'tag', 42 'q': extractLast(request.term) 43 }, 44 success:function(data) { 45 results = []; 46 $(data).find('meta').each(function(){ 47 var id = $(this).text(); 48 var roundpercent = $(this).attr("roundpercent"); 49 var count = $(this).attr("count"); 50 console.log(id); 51 console.log(roundpercent); 52 console.log(count); 53 var label = id + ' (' + 54 dotclear.msg.tags_autocomplete. 55 replace('%p',roundpercent). 56 replace('%e',count + ' ' + 57 ((count > 1) ? 58 dotclear.msg.entries : 59 dotclear.msg.entry 60 )) + ')'; 61 console.log(label); 62 results.push({label:label,value:id}); 63 }); 64 response(results); 65 } 66 }); 67 }, 68 search: function() { 69 var term = extractLast( this.value ); 70 if ( term.length < 2 ) { 71 return false; 56 72 } 57 }); 73 }, 74 focus: function() { 75 // prevent value inserted on focus 76 return false; 77 }, 78 select: function( event, ui ) { 79 var terms = split( this.value ); 80 // remove the current input 81 terms.pop(); 82 // add the selected item 83 terms.push( ui.item.value ); 84 // add placeholder to get the comma-and-space at the end 85 terms.push( "" ); 86 this.value = terms.join( ", " ); 87 return false; 88 } 89 }); 90 58 91 }); 59 92 }); -
plugins/tags/js/posts_actions.js
r0 r756 1 1 $(function() { 2 function split( val ) { 3 return val.split( /,\s*/ ); 4 } 5 function extractLast(term) { 6 return split(term).pop(); 7 } 2 8 var tag_field = $('#new_tags'); 3 9 … … 19 25 }); 20 26 21 $('#post_meta_input').autocomplete(mEdit.service_uri, { 22 extraParams: { 23 'f': 'searchMeta', 24 'metaType': 'tag' 27 $('#post_meta_input') 28 .bind( "keydown", function( event ) { 29 if ( event.keyCode === $.ui.keyCode.TAB && 30 $( this ).data( "autocomplete" ).menu.active ) { 31 event.preventDefault(); 32 } 33 }) 34 .autocomplete({ 35 minLength: 2, 36 delay: 1000, 37 source: function(request,response) { 38 $.ajax({ 39 url: mEdit.service_uri, 40 data: { 41 'f': 'searchMeta', 42 'metaType': 'tag', 43 'q': extractLast(request.term) 44 }, 45 success:function(data) { 46 results = []; 47 $(data).find('meta').each(function(){ 48 var id = $(this).text(); 49 var roundpercent = $(this).attr("roundpercent"); 50 var count = $(this).attr("count"); 51 console.log(id); 52 console.log(roundpercent); 53 console.log(count); 54 var label = id + ' (' + 55 dotclear.msg.tags_autocomplete. 56 replace('%p',roundpercent). 57 replace('%e',count + ' ' + 58 ((count > 1) ? 59 dotclear.msg.entries : 60 dotclear.msg.entry 61 )) + ')'; 62 console.log(label); 63 results.push({label:label,value:id}); 64 }); 65 response(results); 66 } 67 }); 25 68 }, 26 delay: 1000, 27 multiple: true, 28 matchSubset: false, 29 matchContains: true, 30 parse: function(xml) { 31 var results = []; 32 $(xml).find('meta').each(function(){ 33 results[results.length] = { 34 data: { 35 "id": $(this).text(), 36 "count": $(this).attr("count"), 37 "percent": $(this).attr("roundpercent") 38 }, 39 result: $(this).text() 40 }; 41 }); 42 return results; 69 search: function() { 70 var term = extractLast( this.value ); 71 if ( term.length < 2 ) { 72 return false; 73 } 43 74 }, 44 formatItem: function(tag) { 45 return tag.id + ' <em>(' + 46 dotclear.msg.tags_autocomplete. 47 replace('%p',tag.percent). 48 replace('%e',tag.count + ' ' + 49 (tag.count > 1 ? 50 dotclear.msg.entries : 51 dotclear.msg.entry) 52 ) + 53 ')</em>'; 75 focus: function() { 76 // prevent value inserted on focus 77 return false; 54 78 }, 55 formatResult: function(tag) { 56 return tag.result; 57 } 79 select: function( event, ui ) { 80 var terms = split( this.value ); 81 // remove the current input 82 terms.pop(); 83 // add the selected item 84 terms.push( ui.item.value ); 85 // add placeholder to get the comma-and-space at the end 86 terms.push( "" ); 87 this.value = terms.join( ", " ); 88 return false; 89 } 58 90 }); 59 91 });
Note: See TracChangeset
for help on using the changeset viewer.