Pluf Framework

Pluf Framework Commit Details


Date:2009-10-06 03:48:51 (15 years 2 months ago)
Author:Loic d'Anterroches
Branch:develop, master
Commit:d56046b47e1727e8b9479c1854ec8963a7b50872
Parents: 791783b9a78f13f09958be6454f0e16ff757fb9d
Message:Added the option to filter a list in the paginator.

Changes:

File differences

src/Pluf/Paginator.php
3636
3737
3838
39
39
4040
4141
4242
......
8484
8585
8686
87
88
89
90
91
92
93
94
95
8796
8897
8998
......
203212
204213
205214
215
216
217
206218
207219
208220
......
265277
266278
267279
280
281
268282
269283
270284
......
285299
286300
287301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
288316
289317
290318
......
396424
397425
398426
427
428
429
430
431
399432
400433
401434
......
605638
606639
607640
641
642
643
644
608645
609646
610647
......
641678
642679
643680
644
681
645682
646683
647684
* $model = new Pluf_Permission();
* $pag = new Pluf_Paginator($model);
* // Set the action to the page listing the permissions
* $pag->action = '/permission/';
* $pag->action = 'view_name';
* // Get the paginator parameters from the request
* $pag->setFromRequest($request);
* print $pag->render();
* you can create new columns in the table.
*/
protected $list_display = array();
/**
* List filter.
*
* Allow the generation of filtering options for the list. If you
* provide a list of fields having a "choices" option, you will be
* able to filter on the choice values.
*/
public $list_filters = array();
/**
* Extra classes that will be applied to the td of each cell of
* Available only after the rendering of the paginator.
*/
public $nb_items = 0;
protected $active_list_filter = array();
/**
* Construct the paginator for a model.
*
* _px_p : Current page.
* _px_sk : Sort key.
* _px_so : Sort order.
* _px_fk : Filter key.
* _px_fv : Filter value.
*
* @param Pluf_HTTP_Request The request
*/
$this->sort_order[1] = 'DESC';
}
}
if (isset($request->REQUEST['_px_fk'])
and in_array($request->REQUEST['_px_fk'], $this->list_filters)
and isset($request->REQUEST['_px_fv'])) {
// We add a forced where query
$sql = new Pluf_SQL($request->REQUEST['_px_fk'].'=%s',
$request->REQUEST['_px_fv']);
if (!is_null($this->forced_where)) {
$this->forced_where->SAnd($sql);
} else {
$this->forced_where = $sql;
}
$this->active_list_filter = array($request->REQUEST['_px_fk'],
$request->REQUEST['_px_fv']);
}
}
$params['_px_sk'] = $this->sort_order[0];
$params['_px_so'] = ($this->sort_order[1] == 'ASC') ? 'a' : 'd';
}
// Add the filtering
if (!empty($this->active_list_filter)) {
$params['_px_fk'] = $this->active_list_filter[0];
$params['_px_fv'] = $this->active_list_filter[1];
}
$out = '<tfoot><tr><th colspan="'.count($this->list_display).'">'."\n";
if ($this->current_page != 1) {
$params['_px_p'] = $this->current_page - 1;
if (!empty($this->search_fields)) {
$params['_px_q'] = $this->search_string;
}
if (!empty($this->active_list_filter)) {
$params['_px_fk'] = $this->active_list_filter[0];
$params['_px_fv'] = $this->active_list_filter[1];
}
$params['_px_sk'] = $field;
$out = '<span class="px-sort">'.__('Sort').' %s/%s</span>';
$params['_px_so'] = 'a';
.' value="'.htmlspecialchars($this->search_string).'" />'
.'<input type="submit" name="submit" value="'.__('Filter').'" />'
.'</form></th></tr>'."\n";
}
/**

Archive Download the corresponding diff file

Branches

Tags

Number of commits:
Page rendered in 0.06239s using 13 queries.