1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear |
---|
7 | # Licensed under the GPL version 2.0 license. |
---|
8 | # See LICENSE file or |
---|
9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
10 | # |
---|
11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
12 | if (!defined('DC_RC_PATH')) { return; } |
---|
13 | |
---|
14 | /** |
---|
15 | @ingroup DC_CORE |
---|
16 | @nosubgrouping |
---|
17 | @brief Dotclear items pager class. |
---|
18 | |
---|
19 | Dotclear items pager handles pagination for every admin list. |
---|
20 | */ |
---|
21 | class adminItemsPager extends pager |
---|
22 | { |
---|
23 | public function getLinks() |
---|
24 | { |
---|
25 | $htmlText = ''; |
---|
26 | $htmlStart = ''; |
---|
27 | $htmlEnd = ''; |
---|
28 | $htmlPrev = ''; |
---|
29 | $htmlNext = ''; |
---|
30 | $htmlDirectAccess = ''; |
---|
31 | $htmlHidden = ''; |
---|
32 | |
---|
33 | $this->setURL(); |
---|
34 | |
---|
35 | # Page text |
---|
36 | $htmlText = '<span>'.sprintf(__('Page %s over %s'),$this->env,$this->nb_pages).'</span>'; |
---|
37 | |
---|
38 | # Previous page |
---|
39 | if($this->env != 1) { |
---|
40 | $htmlPrev = '<a href="'.sprintf($this->page_url,$this->env-1).'" class="prev">'. |
---|
41 | $htmlPrev .= $this->html_prev.'</a>'; |
---|
42 | } |
---|
43 | |
---|
44 | # Next page |
---|
45 | if($this->env != $this->nb_pages) { |
---|
46 | $htmlNext = '<a href="'.sprintf($this->page_url,$this->env+1).'" class="next">'; |
---|
47 | $htmlNext .= $this->html_next.'</a>'; |
---|
48 | } |
---|
49 | |
---|
50 | # Start |
---|
51 | if($this->env != 1) { |
---|
52 | $htmlStart = '<a href="'.sprintf($this->page_url,1).'" class="start">'. |
---|
53 | $htmlStart .= $this->html_start.'</a>'; |
---|
54 | } |
---|
55 | |
---|
56 | # End |
---|
57 | if($this->env != $this->nb_pages) { |
---|
58 | $htmlEnd = '<a href="'.sprintf($this->page_url,$this->nb_pages).'" class="end">'. |
---|
59 | $htmlEnd .= $this->html_end.'</a>'; |
---|
60 | } |
---|
61 | |
---|
62 | # Direct acces |
---|
63 | $htmlDirectAccess = |
---|
64 | '<span>'.__('Direct access to page').' '. |
---|
65 | form::field(array('page'),3,3,$this->env).' '. |
---|
66 | '<input type="submit" value="'.__('ok').'" />'. |
---|
67 | '</span>'; |
---|
68 | |
---|
69 | # Hidden fields |
---|
70 | foreach ($_GET as $k => $v) { |
---|
71 | if ($k != $this->var_page) { |
---|
72 | $htmlHidden .= form::hidden(array($k),$v); |
---|
73 | } |
---|
74 | } |
---|
75 | |
---|
76 | $res = |
---|
77 | '<form method="get" action="'.$this->base_url.'"><p>'. |
---|
78 | $htmlStart. |
---|
79 | $htmlPrev. |
---|
80 | $htmlText. |
---|
81 | $htmlNext. |
---|
82 | $htmlEnd. |
---|
83 | $htmlDirectAccess. |
---|
84 | $htmlHidden. |
---|
85 | '</p></form>'; |
---|
86 | |
---|
87 | return $this->nb_elements > 0 ? $res : ''; |
---|
88 | } |
---|
89 | } |
---|
90 | |
---|
91 | /** |
---|
92 | @ingroup DC_CORE |
---|
93 | @nosubgrouping |
---|
94 | @brief Dotclear items column class. |
---|
95 | |
---|
96 | Dotclear items column handles each column object use in adminItemsList class. |
---|
97 | */ |
---|
98 | class adminItemsColumn |
---|
99 | { |
---|
100 | protected $core; /// <b>object</b> dcCore object |
---|
101 | protected $id; /// <b>string</b> ID of defined column |
---|
102 | protected $alias; /// <b>string</b> ID of defined column |
---|
103 | protected $title; /// <b>string</b> Title of defined column |
---|
104 | protected $callback; /// <b>array</b> Callback calls to display defined column |
---|
105 | protected $html; /// <b>array</b> Extra HTML for defined column |
---|
106 | |
---|
107 | /** |
---|
108 | Inits Generic column object |
---|
109 | |
---|
110 | @param id <b>string</b> Column id |
---|
111 | @param alias <b>string</b> Column alias for SQL |
---|
112 | @param title <b>string</b> Column title (for table headers) |
---|
113 | @param callback <b>array</b> Column callback (used for display) |
---|
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 |
---|
117 | @param can_hide <b>boolean</b> Defines if the column can be hidden or not |
---|
118 | */ |
---|
119 | public function __construct($id,$alias,$title,$callback,$html = null,$sortable = true,$listable = true,$can_hide = true) |
---|
120 | { |
---|
121 | if (!is_string($id) || $id === '') { |
---|
122 | throw new Exception(__('Invalid column ID')); |
---|
123 | } |
---|
124 | |
---|
125 | if (!is_string($title)) { |
---|
126 | throw new Exception(__('Invalid column title')); |
---|
127 | } |
---|
128 | |
---|
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; |
---|
139 | } |
---|
140 | |
---|
141 | if (!is_bool($can_hide)) { |
---|
142 | $can_hide = true; |
---|
143 | } |
---|
144 | |
---|
145 | if (!is_string($alias) && $sortable) { |
---|
146 | throw new Exception(__('Invalid column alias')); |
---|
147 | } |
---|
148 | |
---|
149 | try { |
---|
150 | if (!is_array($callback) || count($callback) < 2) { |
---|
151 | throw new Exception(__('Callback parameter should be an array')); |
---|
152 | } |
---|
153 | $r = new ReflectionClass($callback[0]); |
---|
154 | $f = $r->getMethod($callback[1]); |
---|
155 | $p = $r->getParentClass(); |
---|
156 | $find_parent = false; |
---|
157 | |
---|
158 | while (!$p) { |
---|
159 | if ($p->name == 'adminItemsList') { |
---|
160 | $find_parent = true; |
---|
161 | } |
---|
162 | else { |
---|
163 | $p->getParentClass(); |
---|
164 | } |
---|
165 | } |
---|
166 | |
---|
167 | if (!$p || !$f) { |
---|
168 | throw new Exception(__('Callback class should be inherited of adminItemsList class')); |
---|
169 | } |
---|
170 | } |
---|
171 | catch (Exception $e) { |
---|
172 | throw new Exception(sprintf(__('Invalid column callback: %s'),$e->getMessage())); |
---|
173 | } |
---|
174 | |
---|
175 | $this->id = $id; |
---|
176 | $this->alias = $alias; |
---|
177 | $this->title = $title; |
---|
178 | $this->callback = $callback; |
---|
179 | $this->html = $html; |
---|
180 | $this->sortable = $sortable; |
---|
181 | $this->listable = $listable; |
---|
182 | $this->can_hide = $can_hide; |
---|
183 | $this->visibility = true; |
---|
184 | } |
---|
185 | |
---|
186 | /** |
---|
187 | Gets information of defined column |
---|
188 | |
---|
189 | @param info <b>string</b> Column info to retrive |
---|
190 | |
---|
191 | @return <b>mixed</b> The information requested, null otherwise |
---|
192 | */ |
---|
193 | public function getInfo($info) |
---|
194 | { |
---|
195 | return property_exists(get_class($this),$info) ? $this->{$info} : null; |
---|
196 | } |
---|
197 | |
---|
198 | /** |
---|
199 | Sets visibility of defined column |
---|
200 | |
---|
201 | @param visibility <b>boolean</b> Column visibility |
---|
202 | */ |
---|
203 | public function setVisibility($visibility) |
---|
204 | { |
---|
205 | if (is_bool($visibility) && $this->can_hide) { |
---|
206 | $this->visibility = $visibility; |
---|
207 | } |
---|
208 | else { |
---|
209 | $this->visibility = true; |
---|
210 | } |
---|
211 | } |
---|
212 | |
---|
213 | /** |
---|
214 | Returns visibility status of defined column |
---|
215 | |
---|
216 | @return <b>boolean</b> true if column is visible, false otherwise |
---|
217 | */ |
---|
218 | public function isVisible() |
---|
219 | { |
---|
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; |
---|
241 | } |
---|
242 | |
---|
243 | /** |
---|
244 | Returns if the defined column can be hidden |
---|
245 | |
---|
246 | @return <b>boolean</b> true if column can be hidden, false otherwise |
---|
247 | */ |
---|
248 | public function canHide() |
---|
249 | { |
---|
250 | return $this->can_hide; |
---|
251 | } |
---|
252 | } |
---|
253 | |
---|
254 | /** |
---|
255 | @ingroup DC_CORE |
---|
256 | @nosubgrouping |
---|
257 | @brief abstract items list class. |
---|
258 | |
---|
259 | Dotclear items list handles administration lists |
---|
260 | */ |
---|
261 | abstract class adminItemsList implements dcFilterExtraInterface |
---|
262 | { |
---|
263 | protected $core; |
---|
264 | protected $rs; |
---|
265 | protected $rs_count; |
---|
266 | protected $columns; |
---|
267 | protected $sortby; |
---|
268 | protected $order; |
---|
269 | protected $nb_per_page; |
---|
270 | protected $page; |
---|
271 | |
---|
272 | /* |
---|
273 | Sets columns of defined list |
---|
274 | */ |
---|
275 | abstract function setColumns(); |
---|
276 | |
---|
277 | /** |
---|
278 | Inits List object |
---|
279 | |
---|
280 | @param core <b>dcCore</b> dcCore object |
---|
281 | */ |
---|
282 | public function __construct($core) |
---|
283 | { |
---|
284 | |
---|
285 | $this->core = $core; |
---|
286 | $this->context = get_class($this); |
---|
287 | $this->columns = new ArrayObject(); |
---|
288 | $this->form_prefix = 'col_'; |
---|
289 | |
---|
290 | $this->html_prev = __('prev'); |
---|
291 | $this->html_next = __('next'); |
---|
292 | $this->html_start = __('start'); |
---|
293 | $this->html_end = __('end'); |
---|
294 | |
---|
295 | $this->nb_per_page = 10; |
---|
296 | |
---|
297 | $this->setColumns(); |
---|
298 | |
---|
299 | # --BEHAVIOR-- adminItemsListConstruct |
---|
300 | $core->callBehavior('adminItemsListConstruct',$this); |
---|
301 | |
---|
302 | } |
---|
303 | |
---|
304 | public function __clone() { |
---|
305 | $arr = new ArrayObject(); |
---|
306 | foreach ($this->columns as $k=>$v) { |
---|
307 | $arr[$k]= clone $v; |
---|
308 | } |
---|
309 | $this->columns = $arr; |
---|
310 | } |
---|
311 | /** |
---|
312 | Apply limit, sortby and order filters to items parameters |
---|
313 | |
---|
314 | @param params <b>array</b> Items parameters |
---|
315 | |
---|
316 | @return <b>array</b> Items parameters |
---|
317 | */ |
---|
318 | public function applyFilters($params) |
---|
319 | { |
---|
320 | if (!is_null($this->sortby) && !is_null($this->order)) { |
---|
321 | foreach ($this->columns as $k => $c) { |
---|
322 | if ( |
---|
323 | $this->sortby === $c->getInfo('alias') && |
---|
324 | in_array($this->order,array('asc','desc')) |
---|
325 | ) { |
---|
326 | $params['order'] = $this->sortby.' '.$this->order; |
---|
327 | break; |
---|
328 | } |
---|
329 | } |
---|
330 | } |
---|
331 | |
---|
332 | $params['limit'] = array((($this->page-1)*$this->nb_per_page),$this->nb_per_page); |
---|
333 | |
---|
334 | return $params; |
---|
335 | } |
---|
336 | |
---|
337 | /** |
---|
338 | Sets items and items counter |
---|
339 | |
---|
340 | @param rs <b>recordSet</b> Items recordSet to display |
---|
341 | @param rs_count <b>int</b> Total items number |
---|
342 | */ |
---|
343 | public function setItems($rs,$rs_count) |
---|
344 | { |
---|
345 | $this->rs = $rs; |
---|
346 | $this->rs_count = $rs_count; |
---|
347 | } |
---|
348 | |
---|
349 | /** |
---|
350 | Returns HTML code form used to choose which column to display |
---|
351 | |
---|
352 | @return <b>string</b> HTML code form |
---|
353 | */ |
---|
354 | public function getFormContent() |
---|
355 | { |
---|
356 | $block = |
---|
357 | '<h3>'.__('Displayed information').'</h3>'. |
---|
358 | '<ul>%s</ul>'; |
---|
359 | |
---|
360 | $list = array(); |
---|
361 | |
---|
362 | foreach ($this->columns as $k => $v) { |
---|
363 | $col_id = $this->form_prefix.$k; |
---|
364 | $col_label = sprintf('<label for="%s">%s</label>',$col_id,$v->getInfo('title')); |
---|
365 | $col_html = sprintf('<li class="line">%s</li>',$col_label.form::checkbox($col_id,1,$v->isVisible(),null,null,!$v->canHide())); |
---|
366 | |
---|
367 | if ($v->isListable()) { |
---|
368 | array_push($list,$col_html); |
---|
369 | } |
---|
370 | } |
---|
371 | |
---|
372 | $nb_per_page = !is_null($this->nb_per_page) ? $this->nb_per_page : 10; |
---|
373 | |
---|
374 | return |
---|
375 | sprintf($block,implode('',$list)). |
---|
376 | '<p><label for="nb_per_page">'.__('Items per page:'). |
---|
377 | '</label> '.form::field('nb_per_page',3,3,$nb_per_page). |
---|
378 | '</p>'; |
---|
379 | } |
---|
380 | |
---|
381 | public function updateRequestParams($params) { |
---|
382 | if (!is_null($this->sortby)) { |
---|
383 | $params['sortby'] = $this->sortby; |
---|
384 | } |
---|
385 | if (!is_null($this->order)) { |
---|
386 | $params['order'] = $this->order; |
---|
387 | } |
---|
388 | if (!is_null($this->nb_per_page)) { |
---|
389 | $params['nb_per_page'] = $this->nb_per_page; |
---|
390 | } |
---|
391 | if (!is_null($this->page)) { |
---|
392 | $params['page'] = $this->page; |
---|
393 | } |
---|
394 | foreach ($this->columns as $k => $v) { |
---|
395 | if($v->isVisible()) |
---|
396 | $params[$this->form_prefix.$k] = 1; |
---|
397 | } |
---|
398 | |
---|
399 | } |
---|
400 | |
---|
401 | /** |
---|
402 | Returns HTML hidden fields for list options |
---|
403 | |
---|
404 | @return <b>string</b> HTML hidden fields |
---|
405 | */ |
---|
406 | public function getFormFieldsAsHidden() |
---|
407 | { |
---|
408 | $res = ''; |
---|
409 | |
---|
410 | if (!is_null($this->sortby)) { |
---|
411 | $res .= form::hidden(array('sortby'),$this->sortby); |
---|
412 | } |
---|
413 | if (!is_null($this->order)) { |
---|
414 | $res .= form::hidden(array('order'),$this->order); |
---|
415 | } |
---|
416 | if (!is_null($this->nb_per_page)) { |
---|
417 | $res .= form::hidden(array('nb_per_page'),$this->nb_per_page); |
---|
418 | } |
---|
419 | if (!is_null($this->page)) { |
---|
420 | $res .= form::hidden(array('page'),$this->page); |
---|
421 | } |
---|
422 | |
---|
423 | return $res; |
---|
424 | } |
---|
425 | |
---|
426 | /** |
---|
427 | Returns HTML code list to display |
---|
428 | |
---|
429 | @param enclose_block <b>string</b> HTML wrapper of defined list |
---|
430 | |
---|
431 | @return <b>string</b> HTML code list |
---|
432 | */ |
---|
433 | public function display($enclose_block = '') |
---|
434 | { |
---|
435 | if ($this->rs->isEmpty()) |
---|
436 | { |
---|
437 | echo '<p><strong>'.__('No item').'</strong></p>'; |
---|
438 | } |
---|
439 | else |
---|
440 | { |
---|
441 | $pager = new adminItemsPager($this->page,$this->rs_count,$this->nb_per_page,10); |
---|
442 | $pager->html_prev = $this->html_prev; |
---|
443 | $pager->html_next = $this->html_next; |
---|
444 | $pager->html_start = $this->html_start; |
---|
445 | $pager->html_end = $this->html_end; |
---|
446 | $pager->var_page = 'page'; |
---|
447 | |
---|
448 | $html_block = |
---|
449 | '<table class="maximal clear">'. |
---|
450 | $this->getCaption($this->page). |
---|
451 | '<thead><tr>'; |
---|
452 | |
---|
453 | foreach ($this->columns as $k => $v) { |
---|
454 | if ($v->isVisible()) { |
---|
455 | $title = $v->getInfo('title'); |
---|
456 | if ($v->isSortable()) { |
---|
457 | $title = sprintf('<a href="%2$s">%1$s</a>',$title,$this->getSortLink($v)); |
---|
458 | } |
---|
459 | $html_extra = ''; |
---|
460 | foreach ($v->getInfo('html') as $i => $j) { |
---|
461 | $html_extra = $i.'="'.implode(' ',$j).'"'; |
---|
462 | } |
---|
463 | $html_extra = !empty($html_extra) ? ' '.$html_extra : ''; |
---|
464 | $html_block .= sprintf('<th scope="col"%2$s>%1$s</th>',$title,$html_extra); |
---|
465 | } |
---|
466 | } |
---|
467 | |
---|
468 | $html_block .= |
---|
469 | '</tr></thead>'. |
---|
470 | '<tbody>%s</tbody>'. |
---|
471 | '</table>'; |
---|
472 | |
---|
473 | if ($enclose_block) { |
---|
474 | $html_block = sprintf($enclose_block,$html_block); |
---|
475 | } |
---|
476 | |
---|
477 | echo '<div class="pagination">'.$pager->getLinks().'</div>'; |
---|
478 | |
---|
479 | $blocks = explode('%s',$html_block); |
---|
480 | |
---|
481 | echo $blocks[0]; |
---|
482 | |
---|
483 | while ($this->rs->fetch()) |
---|
484 | { |
---|
485 | echo $this->displayLine(); |
---|
486 | } |
---|
487 | |
---|
488 | echo $blocks[1]; |
---|
489 | |
---|
490 | echo '<div class="pagination">'.$pager->getLinks().'</div>'; |
---|
491 | } |
---|
492 | } |
---|
493 | |
---|
494 | /** |
---|
495 | Adds column to defined list |
---|
496 | |
---|
497 | @param id <b>string</b> Column id |
---|
498 | @param alias <b>string</b> Column alias for SQL |
---|
499 | @param title <b>string</b> Column title (for table headers) |
---|
500 | @param callback <b>array</b> Column callback (used for display) |
---|
501 | @param html <b>string</b> Extra html (used for table headers) |
---|
502 | @param sortable <b>boolean</b> Defines if the column can be sorted or not |
---|
503 | @param listable <b>boolean</b> Defines if the column can be listed or not |
---|
504 | @param can_hide <b>boolean</b> Defines if the column can be hidden or not |
---|
505 | */ |
---|
506 | protected function addColumn($id,$alias,$title,$callback,$html = null,$sortable = true,$listable = true,$can_hide = true) |
---|
507 | { |
---|
508 | try { |
---|
509 | if (is_null($html) || !is_array($html)) { |
---|
510 | $html = array(); |
---|
511 | } |
---|
512 | if ($this->sortby === $alias && !is_null($this->order)) { |
---|
513 | if (array_key_exists('class',$html)) { |
---|
514 | array_push($html['class'],$this->order); |
---|
515 | } |
---|
516 | else { |
---|
517 | $html['class'] = array($this->order); |
---|
518 | } |
---|
519 | } |
---|
520 | $c = new adminItemsColumn($id,$alias,$title,$callback,$html,$sortable,$listable,$can_hide); |
---|
521 | $this->columns[$id] = $c; |
---|
522 | } |
---|
523 | catch (Exception $e) { |
---|
524 | if (DC_DEBUG) { |
---|
525 | $this->core->error->add(sprintf('[%s] %s',$id,$e->getMessage())); |
---|
526 | } |
---|
527 | } |
---|
528 | } |
---|
529 | |
---|
530 | /** |
---|
531 | Returns default caption text |
---|
532 | |
---|
533 | @return <b>string</b> Default caption |
---|
534 | */ |
---|
535 | protected function getDefaultCaption() |
---|
536 | { |
---|
537 | return; |
---|
538 | } |
---|
539 | |
---|
540 | /** |
---|
541 | Returns default HTML code line |
---|
542 | |
---|
543 | @return <b>string</b> Default HTMl code line |
---|
544 | */ |
---|
545 | protected function getDefaultLine() |
---|
546 | { |
---|
547 | return '<tr class="line">%s</tr>'; |
---|
548 | } |
---|
549 | |
---|
550 | /** |
---|
551 | Loads list from user settings |
---|
552 | */ |
---|
553 | public function load() { |
---|
554 | $ws = $this->core->auth->user_prefs->addWorkspace('lists'); |
---|
555 | $user_pref = !is_null($ws->{$this->context.'_opts'}) ? unserialize($ws->{$this->context.'_opts'}) : array(); |
---|
556 | $this->sortby = array_key_exists('sortby',$user_pref) ? $user_pref['sortby'] : null; |
---|
557 | $this->order = array_key_exists('order',$user_pref) ? $user_pref['order'] : null; |
---|
558 | $this->nb_per_page = array_key_exists('nb_per_page',$user_pref) ? $user_pref['nb_per_page'] : 10; |
---|
559 | $user_pref = !is_null($ws->{$this->context.'_col'}) ? unserialize($ws->{$this->context.'_col'}) : array(); |
---|
560 | foreach ($this->columns as $k => $v) { |
---|
561 | $visibility = array_key_exists($k,$user_pref) ? $user_pref[$k] : true; |
---|
562 | $v->setVisibility($visibility); |
---|
563 | } |
---|
564 | } |
---|
565 | |
---|
566 | /** |
---|
567 | Saves list to user settings |
---|
568 | */ |
---|
569 | public function save() { |
---|
570 | $ws = $this->core->auth->user_prefs->addWorkspace('lists'); |
---|
571 | $user_pref = !is_null($ws->{$this->context.'_opts'}) ? unserialize($ws->{$this->context.'_opts'}) : array(); |
---|
572 | $user_pref['order'] = $this->order; |
---|
573 | $user_pref['nb_per_page'] = $this->nb_per_page; |
---|
574 | $user_pref['sortby'] = $this->sortby; |
---|
575 | |
---|
576 | $this->core->auth->user_prefs->lists->put($this->context.'_opts',serialize($user_pref),'string'); |
---|
577 | |
---|
578 | $user_pref = !is_null($ws->{$this->context.'_col'}) ? unserialize($ws->{$this->context.'_col'}) : array(); |
---|
579 | |
---|
580 | foreach ($this->columns as $k => $v) { |
---|
581 | $user_pref[$k] = $v->isVisible(); |
---|
582 | } |
---|
583 | $this->core->auth->user_prefs->lists->put($this->context.'_col',serialize($user_pref),'string'); |
---|
584 | } |
---|
585 | |
---|
586 | /** |
---|
587 | Set dedicated data from form submission |
---|
588 | (either $_GET or $_POST depending on the context |
---|
589 | |
---|
590 | @param data <b>array</b> Data to retrieve information from |
---|
591 | */ |
---|
592 | public function initializeFromData ($data) |
---|
593 | { |
---|
594 | $load_from_settings = true; |
---|
595 | foreach ($data as $k=>$v) { |
---|
596 | if (strpos($k,$this->form_prefix) === 0) { |
---|
597 | $load_from_settings = false; |
---|
598 | } |
---|
599 | } |
---|
600 | if ($load_from_settings) { |
---|
601 | $this->load(); |
---|
602 | } |
---|
603 | # Sortby |
---|
604 | $this->sortby = array_key_exists('sortby',$data) ? $data['sortby'] : $this->sortby; |
---|
605 | $this->order = array_key_exists('order',$data) ? $data['order'] : $this->order; |
---|
606 | $this->nb_per_page = array_key_exists('nb_per_page',$data) ? $data['nb_per_page'] : $this->nb_per_page; |
---|
607 | # Page |
---|
608 | $this->page = array_key_exists('page',$data) ? $data['page'] : 1; |
---|
609 | if ($load_from_settings) |
---|
610 | return; |
---|
611 | |
---|
612 | foreach ($this->columns as $k => $v) { |
---|
613 | $key = $this->form_prefix.$k; |
---|
614 | $visibility = !array_key_exists($key,$data) ? false : true; |
---|
615 | $v->setVisibility($visibility); |
---|
616 | } |
---|
617 | } |
---|
618 | |
---|
619 | /** |
---|
620 | Returns HTML code for each line of defined list |
---|
621 | |
---|
622 | @return <b>string</b> HTML code line |
---|
623 | */ |
---|
624 | private function displayLine() |
---|
625 | { |
---|
626 | $res = ''; |
---|
627 | |
---|
628 | foreach ($this->columns as $k => $v) { |
---|
629 | if ($v->isVisible()) { |
---|
630 | $c = $v->getInfo('callback'); |
---|
631 | $res .= $this->{$c[1]}(); |
---|
632 | } |
---|
633 | } |
---|
634 | |
---|
635 | return sprintf($this->getDefaultLine(),$res); |
---|
636 | } |
---|
637 | |
---|
638 | /** |
---|
639 | Returns caption of defined list |
---|
640 | |
---|
641 | @param page <b>string|int</b> Current page |
---|
642 | |
---|
643 | @return <b>string</b> HTML caption tag |
---|
644 | */ |
---|
645 | private function getCaption($page) |
---|
646 | { |
---|
647 | $caption = $this->getDefaultCaption(); |
---|
648 | |
---|
649 | if (!empty($caption)) { |
---|
650 | $caption = sprintf( |
---|
651 | '<caption>%s - %s</caption>', |
---|
652 | $caption,sprintf(__('Page %s'),$page) |
---|
653 | ); |
---|
654 | } |
---|
655 | |
---|
656 | return $caption; |
---|
657 | } |
---|
658 | |
---|
659 | /** |
---|
660 | Returns link to sort the defined column |
---|
661 | |
---|
662 | @param c <b>adminGenericColumn</b> Current column |
---|
663 | |
---|
664 | @return <b>string</b> HTML link |
---|
665 | */ |
---|
666 | private function getSortLink($c) |
---|
667 | { |
---|
668 | $order = 'desc'; |
---|
669 | if (!is_null($this->sortby) && $this->sortby === $c->getInfo('alias')) { |
---|
670 | if (!is_null($this->order) && $this->order === $order) { |
---|
671 | $order = 'asc'; |
---|
672 | } |
---|
673 | } |
---|
674 | |
---|
675 | $args = $_GET; |
---|
676 | $args['sortby'] = $c->getInfo('alias'); |
---|
677 | $args['order'] = $order; |
---|
678 | |
---|
679 | array_walk($args,create_function('&$v,$k','$v=$k."=".$v;')); |
---|
680 | |
---|
681 | $url = $_SERVER['PHP_SELF']; |
---|
682 | $url .= '?'.implode('&',$args); |
---|
683 | |
---|
684 | return $url; |
---|
685 | } |
---|
686 | } |
---|
687 | |
---|
688 | /** |
---|
689 | @ingroup DC_CORE |
---|
690 | @nosubgrouping |
---|
691 | @brief abstract posts list class. |
---|
692 | |
---|
693 | Handle posts list on admin side |
---|
694 | */ |
---|
695 | class adminPostList extends adminItemsList |
---|
696 | { |
---|
697 | public function setColumns() |
---|
698 | { |
---|
699 | $this->addColumn('title','post_title',__('Title'),array('adminPostList','getTitle'),array('class' => array('maximal')),true,true,false); |
---|
700 | $this->addColumn('date','post_dt',__('Date'),array('adminPostList','getDate')); |
---|
701 | $this->addColumn('datetime','post_dt',__('Date and time'),array('adminPostList','getDateTime')); |
---|
702 | $this->addColumn('category','cat_title',__('Category'),array('adminPostList','getCategory')); |
---|
703 | $this->addColumn('author','user_id',__('Author'),array('adminPostList','getAuthor')); |
---|
704 | $this->addColumn('comments','nb_comment',__('Comments'),array('adminPostList','getComments')); |
---|
705 | $this->addColumn('trackbacks','nb_trackback',__('Trackbacks'),array('adminPostList','getTrackbacks')); |
---|
706 | $this->addColumn('status','post_status',__('Status'),array('adminPostList','getStatus')); |
---|
707 | } |
---|
708 | |
---|
709 | protected function getDefaultCaption() |
---|
710 | { |
---|
711 | return __('Entries list'); |
---|
712 | } |
---|
713 | |
---|
714 | protected function getDefaultLine() |
---|
715 | { |
---|
716 | return |
---|
717 | '<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'. |
---|
718 | ' id="p'.$this->rs->post_id.'">%s</tr>'; |
---|
719 | } |
---|
720 | |
---|
721 | protected function getTitle() |
---|
722 | { |
---|
723 | return |
---|
724 | '<th scope="row" class="maximal">'. |
---|
725 | form::checkbox(array('entries[]'),$this->rs->post_id,'','','',!$this->rs->isEditable()).' '. |
---|
726 | '<a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'">'. |
---|
727 | html::escapeHTML($this->rs->post_title).'</a></th>'; |
---|
728 | } |
---|
729 | |
---|
730 | protected function getDate() |
---|
731 | { |
---|
732 | return '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d'),$this->rs->post_dt).'</td>'; |
---|
733 | } |
---|
734 | |
---|
735 | protected function getDateTime() |
---|
736 | { |
---|
737 | return '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->post_dt).'</td>'; |
---|
738 | } |
---|
739 | |
---|
740 | protected function getCategory() |
---|
741 | { |
---|
742 | if ($this->core->auth->check('categories',$this->core->blog->id)) { |
---|
743 | $cat_link = '<a href="category.php?id=%s">%s</a>'; |
---|
744 | } else { |
---|
745 | $cat_link = '%2$s'; |
---|
746 | } |
---|
747 | |
---|
748 | if ($this->rs->cat_title) { |
---|
749 | $cat_title = sprintf($cat_link,$this->rs->cat_id, |
---|
750 | html::escapeHTML($this->rs->cat_title)); |
---|
751 | } else { |
---|
752 | $cat_title = __('None'); |
---|
753 | } |
---|
754 | |
---|
755 | return '<td class="nowrap">'.$cat_title.'</td>'; |
---|
756 | } |
---|
757 | |
---|
758 | protected function getAuthor() |
---|
759 | { |
---|
760 | return '<td class="nowrap">'.$this->rs->user_id.'</td>'; |
---|
761 | } |
---|
762 | |
---|
763 | protected function getComments() |
---|
764 | { |
---|
765 | return '<td class="nowrap">'.$this->rs->nb_comment.'</td>'; |
---|
766 | } |
---|
767 | |
---|
768 | protected function getTrackbacks() |
---|
769 | { |
---|
770 | return '<td class="nowrap">'.$this->rs->nb_trackback.'</td>'; |
---|
771 | } |
---|
772 | |
---|
773 | protected function getStatus() |
---|
774 | { |
---|
775 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
776 | switch ($this->rs->post_status) { |
---|
777 | case 1: |
---|
778 | $img_status = sprintf($img,__('published'),'check-on.png'); |
---|
779 | break; |
---|
780 | case 0: |
---|
781 | $img_status = sprintf($img,__('unpublished'),'check-off.png'); |
---|
782 | break; |
---|
783 | case -1: |
---|
784 | $img_status = sprintf($img,__('scheduled'),'scheduled.png'); |
---|
785 | break; |
---|
786 | case -2: |
---|
787 | $img_status = sprintf($img,__('pending'),'check-wrn.png'); |
---|
788 | break; |
---|
789 | } |
---|
790 | |
---|
791 | $protected = ''; |
---|
792 | if ($this->rs->post_password) { |
---|
793 | $protected = sprintf($img,__('protected'),'locker.png'); |
---|
794 | } |
---|
795 | |
---|
796 | $selected = ''; |
---|
797 | if ($this->rs->post_selected) { |
---|
798 | $selected = sprintf($img,__('selected'),'selected.png'); |
---|
799 | } |
---|
800 | |
---|
801 | $attach = ''; |
---|
802 | $nb_media = $this->rs->countMedia(); |
---|
803 | if ($nb_media > 0) { |
---|
804 | $attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments'); |
---|
805 | $attach = sprintf($img,sprintf($attach_str,$nb_media),'attach.png'); |
---|
806 | } |
---|
807 | |
---|
808 | return '<td class="nowrap status">'.$img_status.' '.$selected.' '.$protected.' '.$attach.'</td>'; |
---|
809 | } |
---|
810 | } |
---|
811 | |
---|
812 | /** |
---|
813 | @ingroup DC_CORE |
---|
814 | @nosubgrouping |
---|
815 | @brief abstract mini posts list class. |
---|
816 | |
---|
817 | Handle mini posts list on admin side (used for link popup) |
---|
818 | */ |
---|
819 | class adminPostMiniList extends adminPostList |
---|
820 | { |
---|
821 | public function setColumns() |
---|
822 | { |
---|
823 | $this->addColumn('title','post_title',__('Title'),array('adminPostMiniList','getTitle'),array('class' => array('maximal')),true,true,false); |
---|
824 | $this->addColumn('date','post_dt',__('Date'),array('adminPostList','getDate')); |
---|
825 | $this->addColumn('author','user_id',__('Author'),array('adminPostList','getAuthor')); |
---|
826 | $this->addColumn('status','post_status',__('Status'),array('adminPostList','getStatus')); |
---|
827 | } |
---|
828 | |
---|
829 | protected function getTitle() |
---|
830 | { |
---|
831 | return |
---|
832 | '<th scope="row" class="maximal">'. |
---|
833 | form::checkbox(array('entries[]'),$this->rs->post_id,'','','',!$this->rs->isEditable()).' '. |
---|
834 | '<a href="'.$this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id).'" '. |
---|
835 | 'title="'.html::escapeHTML($this->rs->getURL()).'">'. |
---|
836 | html::escapeHTML($this->rs->post_title).'</a></td>'; |
---|
837 | } |
---|
838 | } |
---|
839 | |
---|
840 | /** |
---|
841 | @ingroup DC_CORE |
---|
842 | @nosubgrouping |
---|
843 | @brief abstract comments list class. |
---|
844 | |
---|
845 | Handle comments list on admin side |
---|
846 | */ |
---|
847 | class adminCommentList extends adminItemsList |
---|
848 | { |
---|
849 | public function setColumns() |
---|
850 | { |
---|
851 | $this->addColumn('title','post_title',__('Title'),array('adminCommentList','getTitle'),array('class' => array('maximal')),true,true,false); |
---|
852 | $this->addColumn('date','comment_dt',__('Date'),array('adminCommentList','getDate')); |
---|
853 | $this->addColumn('author','comment_author',__('Author'),array('adminCommentList','getAuthor')); |
---|
854 | $this->addColumn('type','comment_trackback',__('Type'),array('adminCommentList','getType')); |
---|
855 | $this->addColumn('status','comment_status',__('Status'),array('adminCommentList','getStatus')); |
---|
856 | $this->addColumn('edit',null,'',array('adminCommentList','getEdit'),null,false,false,false); |
---|
857 | } |
---|
858 | |
---|
859 | protected function getDefaultCaption() |
---|
860 | { |
---|
861 | return __('Comments list'); |
---|
862 | } |
---|
863 | |
---|
864 | protected function getDefaultLine() |
---|
865 | { |
---|
866 | return |
---|
867 | '<tr class="line'.($this->rs->comment_status != 1 ? ' offline' : '').'"'. |
---|
868 | ' id="c'.$this->rs->comment_id.'">%s</tr>'; |
---|
869 | } |
---|
870 | |
---|
871 | protected function getTitle() |
---|
872 | { |
---|
873 | $post_url = $this->core->getPostAdminURL($this->rs->post_type,$this->rs->post_id); |
---|
874 | |
---|
875 | return |
---|
876 | '<th scope="row" class="maximal">'. |
---|
877 | form::checkbox(array('comments[]'),$this->rs->comment_id,'','','',0).' '. |
---|
878 | '<a href="'.$post_url.'">'. |
---|
879 | html::escapeHTML($this->rs->post_title).'</a>'. |
---|
880 | ($this->rs->post_type != 'post' ? ' ('.html::escapeHTML($this->rs->post_type).')' : '').'</th>'; |
---|
881 | } |
---|
882 | |
---|
883 | protected function getDate() |
---|
884 | { |
---|
885 | return '<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'),$this->rs->comment_dt).'</td>'; |
---|
886 | } |
---|
887 | |
---|
888 | protected function getAuthor() |
---|
889 | { |
---|
890 | global $author, $status, $sortby, $order, $nb_per_page; |
---|
891 | |
---|
892 | $author_url = |
---|
893 | 'comments.php?n='.$nb_per_page. |
---|
894 | '&status='.$status. |
---|
895 | '&sortby='.$sortby. |
---|
896 | '&order='.$order. |
---|
897 | '&author='.rawurlencode($this->rs->comment_author); |
---|
898 | |
---|
899 | $comment_author = html::escapeHTML($this->rs->comment_author); |
---|
900 | if (mb_strlen($comment_author) > 20) { |
---|
901 | $comment_author = mb_strcut($comment_author,0,17).'...'; |
---|
902 | } |
---|
903 | |
---|
904 | return '<td class="nowrap"><a href="'.$author_url.'">'.$comment_author.'</a></td>'; |
---|
905 | } |
---|
906 | |
---|
907 | protected function getType() |
---|
908 | { |
---|
909 | return '<td class="nowrap">'.($this->rs->comment_trackback ? __('trackback') : __('comment')).'</td>'; |
---|
910 | } |
---|
911 | |
---|
912 | protected function getStatus() |
---|
913 | { |
---|
914 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
915 | switch ($this->rs->comment_status) { |
---|
916 | case 1: |
---|
917 | $img_status = sprintf($img,__('published'),'check-on.png'); |
---|
918 | break; |
---|
919 | case 0: |
---|
920 | $img_status = sprintf($img,__('unpublished'),'check-off.png'); |
---|
921 | break; |
---|
922 | case -1: |
---|
923 | $img_status = sprintf($img,__('pending'),'check-wrn.png'); |
---|
924 | break; |
---|
925 | case -2: |
---|
926 | $img_status = sprintf($img,__('junk'),'junk.png'); |
---|
927 | break; |
---|
928 | } |
---|
929 | |
---|
930 | return '<td class="nowrap status">'.$img_status.'</td>'; |
---|
931 | } |
---|
932 | |
---|
933 | protected function getEdit() |
---|
934 | { |
---|
935 | $comment_url = 'comment.php?id='.$this->rs->comment_id; |
---|
936 | |
---|
937 | return |
---|
938 | '<td class="nowrap status"><a href="'.$comment_url.'">'. |
---|
939 | '<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /></a></td>'; |
---|
940 | } |
---|
941 | } |
---|
942 | |
---|
943 | /** |
---|
944 | @ingroup DC_CORE |
---|
945 | @nosubgrouping |
---|
946 | @brief abstract users list class. |
---|
947 | |
---|
948 | Handle users list on admin side |
---|
949 | */ |
---|
950 | class adminUserList extends adminItemsList |
---|
951 | { |
---|
952 | public function setColumns() |
---|
953 | { |
---|
954 | $this->addColumn('username','U.user_id',__('Username'),array('adminUserList','getUserName'),array('class' => array('maximal')),true,true,false); |
---|
955 | $this->addColumn('firstname','user_firstname',__('First name'),array('adminUserList','getFirstName'),array('class' => array('nowrap'))); |
---|
956 | $this->addColumn('lastname','user_name',__('Last name'),array('adminUserList','getLastName'),array('class' => array('nowrap'))); |
---|
957 | $this->addColumn('displayname','user_displayname',__('Display name'),array('adminUserList','getDisplayName'),array('class' => array('nowrap'))); |
---|
958 | $this->addColumn('entries','nb_post',__('Entries'),array('adminUserList','getEntries'),array('class' => array('nowrap'))); |
---|
959 | } |
---|
960 | |
---|
961 | protected function getDefaultCaption() |
---|
962 | { |
---|
963 | return __('Users list'); |
---|
964 | } |
---|
965 | |
---|
966 | protected function getUserName() |
---|
967 | { |
---|
968 | $img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />'; |
---|
969 | $img_status = ''; |
---|
970 | |
---|
971 | $p = $this->core->getUserPermissions($this->rs->user_id); |
---|
972 | |
---|
973 | if (isset($p[$this->core->blog->id]['p']['admin'])) { |
---|
974 | $img_status = sprintf($img,__('admin'),'admin.png'); |
---|
975 | } |
---|
976 | if ($this->rs->user_super) { |
---|
977 | $img_status = sprintf($img,__('superadmin'),'superadmin.png'); |
---|
978 | } |
---|
979 | |
---|
980 | return |
---|
981 | '<th scope="row" class="maximal">'.form::hidden(array('nb_post[]'),(integer) $this->rs->nb_post). |
---|
982 | form::checkbox(array('user_id[]'),$this->rs->user_id).' '. |
---|
983 | '<a href="user.php?id='.$this->rs->user_id.'">'. |
---|
984 | $this->rs->user_id.'</a> '.$img_status.'</th>'; |
---|
985 | } |
---|
986 | |
---|
987 | protected function getFirstName() |
---|
988 | { |
---|
989 | return '<td class="nowrap">'.$this->rs->user_firstname.'</td>'; |
---|
990 | } |
---|
991 | |
---|
992 | protected function getLastName() |
---|
993 | { |
---|
994 | return '<td class="nowrap">'.$this->rs->user_name.'</td>'; |
---|
995 | } |
---|
996 | |
---|
997 | protected function getDisplayName() |
---|
998 | { |
---|
999 | return '<td class="nowrap">'.$this->rs->user_displayname.'</td>'; |
---|
1000 | } |
---|
1001 | |
---|
1002 | protected function getEntries() |
---|
1003 | { |
---|
1004 | return |
---|
1005 | '<td class="nowrap"><a href="posts.php?user_id='.$this->rs->user_id.'">'. |
---|
1006 | $this->rs->nb_post.'</a></td>'; |
---|
1007 | } |
---|
1008 | } |
---|
1009 | |
---|
1010 | /** |
---|
1011 | @ingroup DC_CORE |
---|
1012 | @nosubgrouping |
---|
1013 | @brief abstract blogs list class. |
---|
1014 | |
---|
1015 | Handle blogs list on admin side |
---|
1016 | */ |
---|
1017 | class adminBlogList extends adminItemsList |
---|
1018 | { |
---|
1019 | public function setColumns() |
---|
1020 | { |
---|
1021 | $this->addColumn('blogname','UPPER(blog_name)',__('Blog name'),array('adminBlogList','getBlogName'),array('class' => array('maximal')),true,true,false); |
---|
1022 | $this->addColumn('lastupdate','blog_upddt',__('Last update'),array('adminBlogList','getLastUpdate'),array('class' => array('nowrap'))); |
---|
1023 | $this->addColumn('entries',null,__('Entries'),array('adminBlogList','getEntries'),array('class' => array('nowrap')),false); |
---|
1024 | $this->addColumn('blogid','B.blog_id',__('Blog ID'),array('adminBlogList','getBlogId'),array('class' => array('nowrap'))); |
---|
1025 | $this->addColumn('action',null,'',array('adminBlogList','getAction'),array('class' => array('nowrap')),false); |
---|
1026 | $this->addColumn('status','blog_status',__('status'),array('adminBlogList','getStatus'),array('class' => array('nowrap'))); |
---|
1027 | } |
---|
1028 | |
---|
1029 | protected function getDefaultCaption() |
---|
1030 | { |
---|
1031 | return __('Blogs list'); |
---|
1032 | } |
---|
1033 | |
---|
1034 | protected function getBlogName() |
---|
1035 | { |
---|
1036 | return |
---|
1037 | '<th scope="row" class="maximal"><a href="index.php?switchblog='.$this->rs->blog_id.'" '. |
---|
1038 | 'title="'.sprintf(__('Switch to blog %s'),$this->rs->blog_id).'">'. |
---|
1039 | html::escapeHTML($this->rs->blog_name).'</a></th>'; |
---|
1040 | } |
---|
1041 | |
---|
1042 | protected function getLastUpdate() |
---|
1043 | { |
---|
1044 | $offset = dt::getTimeOffset($this->core->auth->getInfo('user_tz')); |
---|
1045 | $blog_upddt = dt::str(__('%Y-%m-%d %H:%M'),strtotime($this->rs->blog_upddt) + $offset); |
---|
1046 | |
---|
1047 | return '<td class="nowrap">'.$blog_upddt.'</td>'; |
---|
1048 | } |
---|
1049 | |
---|
1050 | protected function getEntries() |
---|
1051 | { |
---|
1052 | return '<td class="nowrap">'.$this->core->countBlogPosts($this->rs->blog_id).'</td>'; |
---|
1053 | } |
---|
1054 | |
---|
1055 | protected function getBlogId() |
---|
1056 | { |
---|
1057 | return '<td class="nowrap">'.html::escapeHTML($this->rs->blog_id).'</td>'; |
---|
1058 | } |
---|
1059 | |
---|
1060 | protected function getAction() |
---|
1061 | { |
---|
1062 | $edit_link = ''; |
---|
1063 | $blog_id = html::escapeHTML($this->rs->blog_id); |
---|
1064 | |
---|
1065 | if ($GLOBALS['core']->auth->isSuperAdmin()) { |
---|
1066 | $edit_link = |
---|
1067 | '<a href="blog.php?id='.$blog_id.'" '. |
---|
1068 | 'title="'.sprintf(__('Edit blog %s'),$blog_id).'">'. |
---|
1069 | __('edit').'</a>'; |
---|
1070 | } |
---|
1071 | |
---|
1072 | return '<td class="nowrap">'.$edit_link.'</td>'; |
---|
1073 | } |
---|
1074 | |
---|
1075 | protected function getStatus() |
---|
1076 | { |
---|
1077 | $img_status = $this->rs->blog_status == 1 ? 'check-on' : 'check-off'; |
---|
1078 | $txt_status = $GLOBALS['core']->getBlogStatus($this->rs->blog_status); |
---|
1079 | $img_status = sprintf('<img src="images/%1$s.png" alt="%2$s" title="%2$s" />',$img_status,$txt_status); |
---|
1080 | |
---|
1081 | return '<td class="status">'.$img_status.'</td>'; |
---|
1082 | } |
---|
1083 | } |
---|
1084 | |
---|
1085 | /** |
---|
1086 | @ingroup DC_CORE |
---|
1087 | @nosubgrouping |
---|
1088 | @brief abstract blogs permissions list class. |
---|
1089 | |
---|
1090 | Handle blogs permissions list on admin side |
---|
1091 | */ |
---|
1092 | class adminBlogPermissionsList extends adminBlogList |
---|
1093 | { |
---|
1094 | public function setColumns() |
---|
1095 | { |
---|
1096 | $this->addColumn('blogid','B.blog_id',__('Blog ID'),array('adminBlogPermissionsList','getBlogId'),array('class' => array('nowrap')),false,true,false); |
---|
1097 | $this->addColumn('blogname','UPPER(blog_name)',__('Blog name'),array('adminBlogPermissionsList','getBlogName'),array('class' => array('maximal')),false); |
---|
1098 | $this->addColumn('entries',null,__('Entries'),array('adminBlogList','getEntries'),array('class' => array('nowrap')),false); |
---|
1099 | $this->addColumn('status','blog_status',__('status'),array('adminBlogList','getStatus'),array('class' => array('nowrap')),false); |
---|
1100 | } |
---|
1101 | |
---|
1102 | protected function getBlogId() |
---|
1103 | { |
---|
1104 | return |
---|
1105 | '<th scope="row" class="nowrap">'. |
---|
1106 | form::checkbox(array('blog_id[]'),$this->rs->blog_id,'','','',false,'title="'.__('select').' '.$this->rs->blog_id.'"'). |
---|
1107 | $this->rs->blog_id.'</th>'; |
---|
1108 | } |
---|
1109 | |
---|
1110 | protected function getBlogName() |
---|
1111 | { |
---|
1112 | return '<td class="maximal">'.html::escapeHTML($this->rs->blog_name).'</td>'; |
---|
1113 | } |
---|
1114 | } |
---|
1115 | |
---|
1116 | ?> |
---|