Changeset 1154:e85c1417b8a4 for inc/admin/class.dc.list.php
- Timestamp:
- 04/09/13 09:08:48 (12 years ago)
- Branch:
- twig
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/admin/class.dc.list.php
r1152 r1154 16 16 protected $entries; 17 17 protected $filterset; 18 protected $fetcher; 18 19 protected $selection; 20 protected $current_page; 21 protected $nb_items; 22 protected $nb_items_per_page; 19 23 20 24 … … 46 50 @param form_prefix <b>string</b> form prefix to use for parameters 47 51 */ 48 public function __construct($core,$name,$ action,$form_prefix="f_") {52 public function __construct($core,$name,$filterset,$fetcher,$action,$form_prefix="f_") { 49 53 parent::__construct($core,$name,$action,'POST'); 50 54 $this->entries = array(); … … 52 56 $this->selection = new dcFieldCheckbox('entries',NULL,array('multiple' => true)); 53 57 $this->addField($this->selection); 58 $this->filterset = $filterset; 59 $this->fetcher = $fetcher; 54 60 } 55 61 56 62 public function setup() { 57 parent::setup();58 63 $this 59 64 ->addField(new dcFieldCombo('action',$this->actions_combo, '', array( 60 65 'label' => __('Selected entries action:')))) 61 ->addField(new dcFieldSubmit('ok',__('ok'), array())); 66 ->addField(new dcFieldSubmit('ok',__('ok'), array())) 67 ->addField(new dcFieldHidden('page','1')); 62 68 $columns_combo = array(); 63 69 foreach ($this->columns as $c) { … … 73 79 __('Order'), 74 80 __('Order'), 'orderby', $order_combo,array('singleval'=> true, 'static' => true))); 75 $ this->filterset->addFilter(new dcFilterText(81 $limit = new dcFilterText( 76 82 'limit', 77 __('Limit'), __('Limit'), 'limit',array('singleval'=> true,'static' =>true))); 83 __('Limit'), __('Limit'), 'limit',array('singleval'=> true,'static' =>true)); 84 $this->filterset->addFilter($limit); 85 $this->filterset->setup(); 86 parent::setup(); 87 $this->nb_items_per_page = $limit->getFields()->getValue(); 88 $this->fetchEntries(); 89 90 } 91 92 protected function fetchEntries() { 93 $params = new ArrayObject(); 94 $offset = $this->nb_items_per_page*($this->page->getValue()-1); 95 $this->filterset->applyFilters($params); 96 $this->nb_items = $this->fetcher->getEntriesCount($params); 97 $entries = $this->fetcher->getEntries($params,$offset,$this->nb_items_per_page); 98 $this->setEntries($entries); 99 /*echo "LIMIT:".$this->nb_items_per_page; 100 echo 'count :'.print_r($this->nb_items,true); 101 echo 'page'.$this->page;*/ 78 102 } 79 103 … … 104 128 public function setFilterSet($fs) { 105 129 $this->filterset = $fs; 106 }107 108 }109 110 class dcFilterCheckbox extends dcFilter {111 112 public function __construct($id,$name,$desc) {113 parent::__construct($id,$name,$desc,$request_param);114 }115 116 117 118 public function appendSingleLine($line,$pos) {119 $f = $this->fields[$pos];120 $line['ffield'] = $f->getName();121 if ($this->static) {122 $line['display_inline'] = true;123 }124 125 if ($pos == 0) {126 $line['fwidget']='filter_checkbox';127 $line['desc']=$this->desc;128 };129 }130 131 public function addValue($value=NULL) {132 if (count($this->fields)>0)133 return;134 if ($value === NULL) {135 $value = 1;136 }137 $f = new dcFieldCheckbox(138 $this->getFieldID($pos),139 $value,140 array());141 $this->filterset->addField($f);142 $this->fields[]=$f;143 }144 145 public function applyFilter($params) {146 130 } 147 131 … … 186 170 } 187 171 172 abstract class dcListFetcher { 173 protected $core; 174 public function __construct($core) { 175 $this->core = $core; 176 } 177 178 abstract function getEntries($params,$offset,$limit); 179 abstract function getEntriesCount($params); 180 } 188 181 189 182 dcItemList::__init__($GLOBALS['core']->tpl);
Note: See TracChangeset
for help on using the changeset viewer.