-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommons.php
92 lines (76 loc) · 3.1 KB
/
commons.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
85
86
87
88
89
90
91
92
<?php
if (!isset($frontpage_options_main['no_translation'])) {
$plugin_dir = basename(dirname(__FILE__));
load_plugin_textdomain('frontpage', 'wp-content/plugins/' . $plugin_dir . '/languages/');
}
$action = $_REQUEST['act'];
if (isset($action) && !check_admin_referer()) die('Invalid call');
/**
* Utility class to generate HTML form fields.
*/
class frontpage_frontpageControls {
var $data;
var $action = false;
function frontpage_frontpageControls($options=null) {
$this->data = $options;
}
function frontpage_yesno($name) {
$value = isset($this->data[$name])?(int)$this->data[$name]:0;
echo '<select style="width: 60px" name="options[' . $name . ']">';
echo '<option value="0"';
if ($value == 0) echo ' selected';
echo '>No</option>';
echo '<option value="1"';
if ($value == 1) echo ' selected';
echo '>Yes</option>';
echo '</select>';
}
function frontpage_select($name, $options) {
$value = $this->data[$name];
echo '<select name="options[' . $name . ']">';
foreach($options as $key=>$label) {
echo '<option value="' . $key . '"';
if ($value == $key) echo ' selected';
echo '>' . htmlspecialchars($label) . '</option>';
}
echo '</select>';
}
function frontpage_text($name, $size) {
echo '<input name="options[' . $name . ']" type="text" size="' . $size . '" value="';
echo htmlspecialchars($this->data[$name]);
echo '"/>';
}
function frontpage_button($action, $label, $function=null) {
if (!$this->action) echo '<input name="act" type="hidden" value=""/>';
$this->action = true;
if ($function != null) {
echo '<input type="button" value="' . $label . '" onclick="this.form.act.value=\'' . $action . '\';' . $function . '"/>';
}
else {
echo '<input type="button" value="' . $label . '" onclick="this.form.act.value=\'' . $action . '\';this.form.submit()"/>';
}
}
function frontpage_editor($name, $rows=5, $cols=75) {
echo '<textarea class="visual" name="options[' . $name . ']" wrap="off" rows="' . $rows . '" cols="' . $cols . '">';
echo htmlspecialchars($this->data[$name]);
echo '</textarea>';
}
function frontpage_textarea($name, $rows=5, $cols=75) {
echo '<textarea name="options[' . $name . ']" wrap="off" rows="' . $rows . '" cols="' . $cols . '">';
echo htmlspecialchars($this->data[$name]);
echo '</textarea>';
}
function frontpage_view($prefix) {
echo 'Subject:<br />';
$this->frontpage_text($prefix . '_subject', 70);
echo '<br />Message:<br />';
$this->frontpage_editor($prefix . '_message');
}
function frontpage_checkbox($name, $label='') {
echo '<input type="checkbox" id="' . $name . '" name="options[' . $name . ']" value="1"';
if (isset($this->data[$name])) echo ' checked="checked"';
echo '/>';
if ($label != '') echo ' <label for="' . $name . '">' . $label . '</label>';
}
}
?>