* $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";␊ |
␊ |
␊ |
}␊ |
␊ |
/**␊ |