Changeset 508:7dbb15fcd538 for inc/admin
- Timestamp:
- 07/04/11 14:50:03 (14 years ago)
- Branch:
- formfilters
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/admin/lib.pager.php
r463 r508 100 100 protected $core; /// <b>object</b> dcCore object 101 101 protected $id; /// <b>string</b> ID of defined column 102 protected $alias; /// <b>string</b> ID of defined column 102 103 protected $title; /// <b>string</b> Title of defined column 103 104 protected $callback; /// <b>array</b> Callback calls to display defined column 104 protected $html; /// <b>string</b> Extra HTML for defined column 105 protected $visibility; /// <b>boolean</b> Visibility of defined column 105 protected $html; /// <b>array</b> Extra HTML for defined column 106 106 107 107 /** … … 109 109 110 110 @param id <b>string</b> Column id 111 @param alias <b>string</b> Column alias for SQL 111 112 @param title <b>string</b> Column title (for table headers) 112 113 @param callback <b>array</b> Column callback (used for display) 113 @param html <b>string</b> Extra html (used for table headers) 114 @param html <b>array</b> Extra html (used for table headers) 115 @param sortable <b>boolean</b> Defines if the column can be sorted or not 116 @param listable <b>boolean</b> Defines if the column can be listed or not 114 117 @param can_hide <b>boolean</b> Defines if the column can be hidden or not 115 118 */ 116 public function __construct($id,$ title,$callback,$html = null,$can_hide = true)119 public function __construct($id,$alias,$title,$callback,$html = null,$sortable = true,$listable = true,$can_hide = true) 117 120 { 118 121 if (!is_string($id) || $id === '') { … … 124 127 } 125 128 126 if (is_null($html) || !is_string($html)) { 127 $html = ''; 128 } 129 if (!empty($html)) { 130 $html = ' '.$html; 129 if (is_null($html) || !is_array($html)) { 130 $html = array(); 131 } 132 133 if (!is_bool($sortable)) { 134 $sortable = true; 135 } 136 137 if (!is_bool($listable)) { 138 $listable = true; 131 139 } 132 140 133 141 if (!is_bool($can_hide)) { 134 142 $can_hide = true; 143 } 144 145 if (!is_string($alias) && $sortable) { 146 throw new Exception(__('Invalid column alias')); 135 147 } 136 148 … … 162 174 163 175 $this->id = $id; 176 $this->alias = $alias; 164 177 $this->title = $title; 165 178 $this->callback = $callback; 166 179 $this->html = $html; 180 $this->sortable = $sortable; 181 $this->listable = $listable; 167 182 $this->can_hide = $can_hide; 168 183 $this->visibility = true; … … 188 203 public function setVisibility($visibility) 189 204 { 190 if (is_bool($visibility) ) {205 if (is_bool($visibility) && $this->can_hide) { 191 206 $this->visibility = $visibility; 192 207 } 208 else { 209 $this->visibility = true; 210 } 193 211 } 194 212 … … 201 219 { 202 220 return $this->visibility; 221 } 222 223 /** 224 Returns if the defined column can be sorted 225 226 @return <b>boolean</b> true if column is sortable, false otherwise 227 */ 228 public function isSortable() 229 { 230 return $this->sortable; 231 } 232 233 /** 234 Returns if the defined column can be listed 235 236 @return <b>boolean</b> true if column is listable, false otherwise 237 */ 238 public function isListable() 239 { 240 return $this->listable; 203 241 } 204 242 … … 280 318 $col_html = sprintf('<li class="line">%s</li>',$col_label.form::checkbox($col_id,1,$v->isVisible(),null,null,!$v->canHide())); 281 319 282 array_push($list,$col_html); 320 if ($v->isListable()) { 321 array_push($list,$col_html); 322 } 283 323 } 284 324 … … 323 363 foreach ($this->columns as $k => $v) { 324 364 if ($v->isVisible()) { 325 $html_extra = $v->getInfo('html') != '' ? ' '.$v->getInfo('html') : ''; 326 $html_block .= sprintf('<th scope="col"%s>%s</th>',$html_extra,$v->getInfo('title')); 365 $title = $v->getInfo('title'); 366 if ($v->isSortable()) { 367 $title = sprintf('<a href="%2$s">%1$s</a>',$title,$this->getSortLink($v)); 368 } 369 $html_extra = ''; 370 foreach ($v->getInfo('html') as $i => $j) { 371 $html_extra = $i.'="'.implode(' ',$j).'"'; 372 } 373 $html_extra = !empty($html_extra) ? ' '.$html_extra : ''; 374 $html_block .= sprintf('<th scope="col"%2$s>%1$s</th>',$title,$html_extra); 327 375 } 328 376 } … … 358 406 359 407 @param id <b>string</b> Column id 408 @param alias <b>string</b> Column alias for SQL 360 409 @param title <b>string</b> Column title (for table headers) 361 410 @param callback <b>array</b> Column callback (used for display) 362 411 @param html <b>string</b> Extra html (used for table headers) 412 @param sortable <b>boolean</b> Defines if the column can be sorted or not 413 @param listable <b>boolean</b> Defines if the column can be listed or not 363 414 @param can_hide <b>boolean</b> Defines if the column can be hidden or not 364 415 */ 365 protected function addColumn($id,$ title,$callback,$html = null,$can_hide = true)416 protected function addColumn($id,$alias,$title,$callback,$html = null,$sortable = true,$listable = true,$can_hide = true) 366 417 { 367 418 try { 368 $c = new adminGenericColumn($id,$title,$callback,$html,$can_hide); 419 if (is_null($html) || !is_array($html)) { 420 $html = array(); 421 } 422 if (isset($_GET['sortby']) && $_GET['sortby'] === $alias && isset($_GET['order'])) { 423 if (array_key_exists('class',$html)) { 424 array_push($html['class'],$_GET['order']); 425 } 426 else { 427 $html['class'] = array($_GET['order']); 428 } 429 } 430 $c = new adminGenericColumn($id,$alias,$title,$callback,$html,$sortable,$listable,$can_hide); 369 431 $this->columns[$id] = $c; 370 432 } … … 411 473 $visibility = !array_key_exists($key,$_REQUEST) ? false : true; 412 474 } 413 if (!$v->canHide()) {414 $visibility = true;415 }416 475 $v->setVisibility($visibility); 417 476 $user_pref[$k] = $visibility; … … 462 521 return $caption; 463 522 } 523 524 /** 525 Returns link to sort the defined column 526 527 @param c <b>adminGenericColumn</b> Current column 528 529 @return <b>string</b> HTML link 530 */ 531 private function getSortLink($c) 532 { 533 $order = 'desc'; 534 if (isset($_GET['sortby']) && $_GET['sortby'] === $c->getInfo('alias')) { 535 if (isset($_GET['order']) && $_GET['order'] === 'desc') { 536 $order = 'asc'; 537 } 538 } 539 540 $args = $_GET; 541 $args['sortby'] = $c->getInfo('alias'); 542 $args['order'] = $order; 543 544 array_walk($args,create_function('&$v,$k','$v=$k."=".$v;')); 545 546 $url = $_SERVER['PHP_SELF']; 547 $url .= '?'.implode('&',$args); 548 549 return $url; 550 } 464 551 } 465 552 … … 475 562 public function setColumns() 476 563 { 477 $this->addColumn('title', __('Title'),array('adminPostList','getTitle'),' class="maximal"',false);478 $this->addColumn('date', __('Date'),array('adminPostList','getDate'));479 $this->addColumn('datetime', __('Date and time'),array('adminPostList','getDateTime'));480 $this->addColumn('category', __('Category'),array('adminPostList','getCategory'));481 $this->addColumn('author', __('Author'),array('adminPostList','getAuthor'));482 $this->addColumn('comment ',__('Comments'),array('adminPostList','getComments'));483 $this->addColumn('trackback ',__('Trackbacks'),array('adminPostList','getTrackbacks'));484 $this->addColumn('status', __('Status'),array('adminPostList','getStatus'));564 $this->addColumn('title','post_title',__('Title'),array('adminPostList','getTitle'),array('class' => array('maximal')),true,true,false); 565 $this->addColumn('date','post_dt',__('Date'),array('adminPostList','getDate')); 566 $this->addColumn('datetime','post_dt',__('Date and time'),array('adminPostList','getDateTime')); 567 $this->addColumn('category','cat_title',__('Category'),array('adminPostList','getCategory')); 568 $this->addColumn('author','user_id',__('Author'),array('adminPostList','getAuthor')); 569 $this->addColumn('comments','nb_comment',__('Comments'),array('adminPostList','getComments')); 570 $this->addColumn('trackbacks','nb_trackback',__('Trackbacks'),array('adminPostList','getTrackbacks')); 571 $this->addColumn('status','post_status',__('Status'),array('adminPostList','getStatus')); 485 572 } 486 573 … … 599 686 public function setColumns() 600 687 { 601 $this->addColumn('title', __('Title'),array('adminPostMiniList','getTitle'),' class="maximal"',false);602 $this->addColumn('date', __('Date'),array('adminPostList','getDate'));603 $this->addColumn('author', __('Author'),array('adminPostList','getAuthor'));604 $this->addColumn('status', __('Status'),array('adminPostList','getStatus'));688 $this->addColumn('title','post_title',__('Title'),array('adminPostMiniList','getTitle'),array('class' => array('maximal')),true,true,false); 689 $this->addColumn('date','post_dt',__('Date'),array('adminPostList','getDate')); 690 $this->addColumn('author','user_id',__('Author'),array('adminPostList','getAuthor')); 691 $this->addColumn('status','post_status',__('Status'),array('adminPostList','getStatus')); 605 692 } 606 693 … … 627 714 public function setColumns() 628 715 { 629 $this->addColumn('title', __('Title'),array('adminCommentList','getTitle'),' class="maximal"',false);630 $this->addColumn('date', __('Date'),array('adminCommentList','getDate'));631 $this->addColumn('author', __('Author'),array('adminCommentList','getAuthor'));632 $this->addColumn('type', __('Type'),array('adminCommentList','getType'));633 $this->addColumn('status', __('Status'),array('adminCommentList','getStatus'));634 $this->addColumn('edit', '',array('adminCommentList','getEdit'));716 $this->addColumn('title','post_title',__('Title'),array('adminCommentList','getTitle'),array('class' => array('maximal')),true,true,false); 717 $this->addColumn('date','comment_dt',__('Date'),array('adminCommentList','getDate')); 718 $this->addColumn('author','comment_author',__('Author'),array('adminCommentList','getAuthor')); 719 $this->addColumn('type','comment_trackback',__('Type'),array('adminCommentList','getType')); 720 $this->addColumn('status','comment_status',__('Status'),array('adminCommentList','getStatus')); 721 $this->addColumn('edit',null,'',array('adminCommentList','getEdit'),null,false,false,false); 635 722 } 636 723 … … 730 817 public function setColumns() 731 818 { 732 $this->addColumn('username', __('Username'),array('adminUserList','getUserName'),'class="maximal"',false);733 $this->addColumn('firstname', __('First name'),array('adminUserList','getFirstName'),'class="nowrap"');734 $this->addColumn('lastname', __('Last name'),array('adminUserList','getLastName'),'class="nowrap"');735 $this->addColumn('displayname', __('Display name'),array('adminUserList','getDisplayName'),'class="nowrap"');736 $this->addColumn('entries', __('Entries'),array('adminUserList','getEntries'),'class="nowrap"');819 $this->addColumn('username','U.user_id',__('Username'),array('adminUserList','getUserName'),array('class' => array('maximal')),true,true,false); 820 $this->addColumn('firstname','user_firstname',__('First name'),array('adminUserList','getFirstName'),array('class' => array('nowrap'))); 821 $this->addColumn('lastname','user_name',__('Last name'),array('adminUserList','getLastName'),array('class' => array('nowrap'))); 822 $this->addColumn('displayname','user_displayname',__('Display name'),array('adminUserList','getDisplayName'),array('class' => array('nowrap'))); 823 $this->addColumn('entries','nb_post',__('Entries'),array('adminUserList','getEntries'),array('class' => array('nowrap'))); 737 824 } 738 825 … … 797 884 public function setColumns() 798 885 { 799 $this->addColumn('blogname', __('Blog name'),array('adminBlogList','getBlogName'),'class="maximal"',false);800 $this->addColumn('lastupdate', __('Last update'),array('adminBlogList','getLastUpdate'),'class="nowrap"');801 $this->addColumn('entries', __('Entries'),array('adminBlogList','getEntries'),'class="nowrap"');802 $this->addColumn('blogid', __('Blog ID'),array('adminBlogList','getBlogId'),'class="nowrap"');803 $this->addColumn('action', '',array('adminBlogList','getAction'),'class="nowrap"');804 $this->addColumn('status', __('status'),array('adminBlogList','getStatus'),'class="nowrap"');886 $this->addColumn('blogname','UPPER(blog_name)',__('Blog name'),array('adminBlogList','getBlogName'),array('class' => array('maximal')),true,true,false); 887 $this->addColumn('lastupdate','blog_upddt',__('Last update'),array('adminBlogList','getLastUpdate'),array('class' => array('nowrap'))); 888 $this->addColumn('entries',null,__('Entries'),array('adminBlogList','getEntries'),array('class' => array('nowrap')),false); 889 $this->addColumn('blogid','B.blog_id',__('Blog ID'),array('adminBlogList','getBlogId'),array('class' => array('nowrap'))); 890 $this->addColumn('action',null,'',array('adminBlogList','getAction'),array('class' => array('nowrap'))); 891 $this->addColumn('status','blog_status',__('status'),array('adminBlogList','getStatus'),array('class' => array('nowrap'))); 805 892 } 806 893 … … 872 959 public function setColumns() 873 960 { 874 $this->addColumn('blogid', __('Blog ID'),array('adminBlogPermissionsList','getBlogId'),'class="nowrap"',false);875 $this->addColumn('blogname', __('Blog name'),array('adminBlogPermissionsList','getBlogName'),'class="maximal"');876 $this->addColumn('entries', __('Entries'),array('adminBlogList','getEntries'),'class="nowrap"');877 $this->addColumn('status', __('status'),array('adminBlogList','getStatus'),'class="nowrap"');961 $this->addColumn('blogid','B.blog_id',__('Blog ID'),array('adminBlogPermissionsList','getBlogId'),array('class' => array('nowrap')),false,true,false); 962 $this->addColumn('blogname','UPPER(blog_name)',__('Blog name'),array('adminBlogPermissionsList','getBlogName'),array('class' => array('maximal')),false); 963 $this->addColumn('entries',null,__('Entries'),array('adminBlogList','getEntries'),array('class' => array('nowrap')),false); 964 $this->addColumn('status','blog_status',__('status'),array('adminBlogList','getStatus'),array('class' => array('nowrap')),false); 878 965 } 879 966
Note: See TracChangeset
for help on using the changeset viewer.