-
Notifications
You must be signed in to change notification settings - Fork 0
/
qa-ma-cache-that-admin.php
84 lines (58 loc) · 2.38 KB
/
qa-ma-cache-that-admin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
class qa_ma_cache_that_admin {
var $directory;
var $urltoroot;
//this runs before the module is used.
function load_module($directory, $urltoroot)
{
//file system path to the plugin directory
$this->directory=$directory;
//url path to the plugin relative to the current page request.
$this->urltoroot=$urltoroot;
}
//a request for the default value for $option
function option_default($option)
{
if ($option == 'ma_cache_that_enabled') {
HH_cache::enabledSave(false);
return false;
}
}
function admin_form()
{
//default form as unsaved
$saved=false;
//has the save button been pressed?
if (qa_clicked('ma_cache_that_save_button')) {
//save the checkbox value as an int value
qa_opt('ma_cache_that_enabled', (int)qa_post_text('ma_cache_that_enabled'));
HH_cache::enabledSave((int)qa_post_text('ma_cache_that_enabled'));
//mark form as saved
$saved=true;
}
//build the form.
//'ok' displays a message above the form. Used here to display a success message if the form has been saved.
//files contains an array of field options.
$form=array(
'ok' => $saved ? 'Cache That settings saved' : null,
'fields' => array(
'ma_cache_that_enabled' => array(
'label' => 'Enable Cache That?',
'type' => 'checkbox',
'value' => (int)qa_opt('ma_cache_that_enabled'),
'tags' => 'NAME="ma_cache_that_enabled"',
),
),
'buttons' => array(
array(
'label' => 'Save Changes',
'tags' => 'NAME="ma_cache_that_save_button"',
),
),
);
return $form;
}
};
/*
Omit PHP closing tag to help avoid accidental output
*/