-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_config.php
More file actions
180 lines (118 loc) · 4.27 KB
/
admin_config.php
File metadata and controls
180 lines (118 loc) · 4.27 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
// Generated e107 Plugin Admin Area
require_once('../../class2.php');
if (!getperms('P'))
{
e107::redirect('admin');
exit;
}
e107::lan('ihaf',true);
class ihaf_adminArea extends e_admin_dispatcher
{
protected $modes = array(
'main' => array(
'controller' => 'ihaf_ui',
'path' => null,
'ui' => 'ihaf_form_ui',
'uipath' => null
),
);
protected $adminMenu = array(
'main/prefs' => array('caption'=> LAN_PREFS, 'perm' => 'P'),
// 'main/div0' => array('divider'=> true),
// 'main/custom' => array('caption'=> 'Custom Page', 'perm' => 'P'),
);
protected $adminMenuAliases = array(
'main/edit' => 'main/list'
);
protected $menuTitle = 'Insert header and footer';
}
class ihaf_ui extends e_admin_ui
{
protected $pluginTitle = 'Insert header and footer';
protected $pluginName = 'ihaf';
// protected $eventName = 'ihaf-'; // remove comment to enable event triggers in admin.
protected $table = '';
protected $pid = '';
protected $perPage = 10;
protected $batchDelete = true;
protected $batchExport = true;
protected $batchCopy = true;
// protected $sortField = 'somefield_order';
// protected $sortParent = 'somefield_parent';
// protected $treePrefix = 'somefield_title';
// protected $tabs = array('Tabl 1','Tab 2'); // Use 'tab'=>0 OR 'tab'=>1 in the $fields below to enable.
// protected $listQry = "SELECT * FROM `#tableName` WHERE field != '' "; // Example Custom Query. LEFT JOINS allowed. Should be without any Order or Limit.
protected $listOrder = ' DESC';
protected $fields = array (
);
protected $fieldpref = array();
// protected $preftabs = array('General', 'Other' );
protected $prefs = array(
'ihaf_header_area' => array('title'=> IHAF_HEADER_AREA, 'tab'=>0, 'type'=>'dropdown', 'data' => 'int', 'writeparms' => array('default' => 2), 'help' => IHAF_HEADER_AREA_HELP),
'ihaf_header' => array('title'=> IHAF_HEADER, 'tab'=>0, 'type'=>'textarea', 'data' => 'str', 'help'=>IHAF_HEADER_HELP),
'ihaf_footer_area' => array('title'=> IHAF_FOOTER_AREA, 'tab'=>0, 'type'=>'dropdown', 'data' => 'int', 'writeparms' => array('default' => 2), 'help'=>IHAF_FOOTER_AREA_HELP),
'ihaf_footer' => array('title'=> IHAF_FOOTER, 'tab'=>0, 'type'=>'textarea', 'data' => 'str', 'help'=>IHAF_FOOTER_HELP),
);
public function init()
{
// This code may be removed once plugin development is complete.
if(!e107::isInstalled('ihaf'))
{
e107::getMessage()->addWarning("This plugin is not yet installed. Saving and loading of preference or table data will fail.");
}
// Set drop-down values (if any).
$this->prefs['ihaf_header_area']['writeParms'] = array(0 => IHAF_BOTH, 1 => IHAF_ADMIN, 2 => IHAF_USER);
$this->prefs['ihaf_footer_area']['writeParms'] = array(0 => IHAF_BOTH, 1 => IHAF_ADMIN, 2 => IHAF_USER);
}
// ------- Customize Create --------
public function beforeCreate($new_data,$old_data)
{
return $new_data;
}
public function afterCreate($new_data, $old_data, $id)
{
// do something
}
public function onCreateError($new_data, $old_data)
{
// do something
}
// ------- Customize Update --------
public function beforeUpdate($new_data, $old_data, $id)
{
return $new_data;
}
public function afterUpdate($new_data, $old_data, $id)
{
// do something
}
public function onUpdateError($new_data, $old_data, $id)
{
// do something
}
// left-panel help menu area. (replaces e_help.php used in old plugins)
public function renderHelp()
{
$caption = LAN_HELP;
$text = nl2br(IHAF_HELP); //deftrue('IHAF_HELP', "Insert header and footer lets you insert text (e.g. javascript) into the header and/or footer of the page.");
return array('caption'=>$caption,'text'=> $text);
}
/*
// optional - a custom page.
public function customPage()
{
$text = 'Hello World!';
$otherField = $this->getController()->getFieldVar('other_field_name');
return $text;
}
*/
}
class ihaf_form_ui extends e_admin_form_ui
{
}
new ihaf_adminArea();
require_once(e_ADMIN."auth.php");
e107::getAdminUI()->runPage();
require_once(e_ADMIN."footer.php");
exit;