mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-49582 core_lib: Add button to allow user to reset table preferences
This commit is contained in:
parent
e1d4e288ac
commit
bf7c844e94
2 changed files with 37 additions and 0 deletions
|
@ -1530,6 +1530,7 @@ $string['resetnotimplemented'] = 'Reset not implemented';
|
||||||
$string['resetrecordexpired'] = 'The password reset link you used is more than {$a} minutes old and has expired. Please initiate a new password reset.';
|
$string['resetrecordexpired'] = 'The password reset link you used is more than {$a} minutes old and has expired. Please initiate a new password reset.';
|
||||||
$string['resetstartdate'] = 'Reset start date';
|
$string['resetstartdate'] = 'Reset start date';
|
||||||
$string['resetstatus'] = 'Status';
|
$string['resetstatus'] = 'Status';
|
||||||
|
$string['resettable'] = 'Reset table preferences';
|
||||||
$string['resettask'] = 'Task';
|
$string['resettask'] = 'Task';
|
||||||
$string['resettodefaults'] = 'Reset to defaults';
|
$string['resettodefaults'] = 'Reset to defaults';
|
||||||
$string['resortsubcategoriesby'] = 'Sort subcategories by {$a} ascending';
|
$string['resortsubcategoriesby'] = 'Sort subcategories by {$a} ascending';
|
||||||
|
|
|
@ -34,6 +34,7 @@ define('TABLE_VAR_SHOW', 3);
|
||||||
define('TABLE_VAR_IFIRST', 4);
|
define('TABLE_VAR_IFIRST', 4);
|
||||||
define('TABLE_VAR_ILAST', 5);
|
define('TABLE_VAR_ILAST', 5);
|
||||||
define('TABLE_VAR_PAGE', 6);
|
define('TABLE_VAR_PAGE', 6);
|
||||||
|
define('TABLE_VAR_RESET', 7);
|
||||||
/**#@-*/
|
/**#@-*/
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
|
@ -138,6 +139,7 @@ class flexible_table {
|
||||||
TABLE_VAR_IFIRST => 'tifirst',
|
TABLE_VAR_IFIRST => 'tifirst',
|
||||||
TABLE_VAR_ILAST => 'tilast',
|
TABLE_VAR_ILAST => 'tilast',
|
||||||
TABLE_VAR_PAGE => 'page',
|
TABLE_VAR_PAGE => 'page',
|
||||||
|
TABLE_VAR_RESET => 'treset'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -508,6 +510,17 @@ class flexible_table {
|
||||||
$this->prefs['i_first'] = $ifirst;
|
$this->prefs['i_first'] = $ifirst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allow user to reset table preferences.
|
||||||
|
if (optional_param($this->request[TABLE_VAR_RESET], 0, PARAM_BOOL) === 1) {
|
||||||
|
$this->prefs = array(
|
||||||
|
'collapse' => array(),
|
||||||
|
'sortby' => array(),
|
||||||
|
'i_first' => '',
|
||||||
|
'i_last' => '',
|
||||||
|
'textsort' => $this->column_textsort,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Save user preferences if they have changed.
|
// Save user preferences if they have changed.
|
||||||
if ($this->prefs != $oldprefs) {
|
if ($this->prefs != $oldprefs) {
|
||||||
if ($this->persistent) {
|
if ($this->persistent) {
|
||||||
|
@ -971,6 +984,10 @@ class flexible_table {
|
||||||
*/
|
*/
|
||||||
function print_nothing_to_display() {
|
function print_nothing_to_display() {
|
||||||
global $OUTPUT;
|
global $OUTPUT;
|
||||||
|
|
||||||
|
// Render button to allow user to reset table preferences.
|
||||||
|
echo $this->render_reset_button();
|
||||||
|
|
||||||
$this->print_initials_bar();
|
$this->print_initials_bar();
|
||||||
|
|
||||||
echo $OUTPUT->heading(get_string('nothingtodisplay'));
|
echo $OUTPUT->heading(get_string('nothingtodisplay'));
|
||||||
|
@ -1325,6 +1342,10 @@ class flexible_table {
|
||||||
*/
|
*/
|
||||||
function start_html() {
|
function start_html() {
|
||||||
global $OUTPUT;
|
global $OUTPUT;
|
||||||
|
|
||||||
|
// Render button to allow user to reset table preferences.
|
||||||
|
echo $this->render_reset_button();
|
||||||
|
|
||||||
// Do we need to print initial bars?
|
// Do we need to print initial bars?
|
||||||
$this->print_initials_bar();
|
$this->print_initials_bar();
|
||||||
|
|
||||||
|
@ -1363,6 +1384,21 @@ class flexible_table {
|
||||||
}
|
}
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate the HTML for the table preferences reset button.
|
||||||
|
*
|
||||||
|
* @return string HTML fragment.
|
||||||
|
*/
|
||||||
|
private function render_reset_button() {
|
||||||
|
$url = $this->baseurl->out(false, array($this->request[TABLE_VAR_RESET] => 1));
|
||||||
|
|
||||||
|
$html = html_writer::start_div('mdl-right');
|
||||||
|
$html .= html_writer::link($url, get_string('resettable'));
|
||||||
|
$html .= html_writer::end_div();
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue