1
|
|
|
<?php |
|
|
|
|
2
|
|
|
// ------------------------------------------------------------------------- |
3
|
|
|
|
4
|
|
|
require_once dirname(dirname(dirname(__DIR__))) . '/mainfile.php'; |
5
|
|
|
xoops_loadLanguage('main', basename(dirname(dirname(__DIR__)))); |
6
|
|
|
|
7
|
|
|
// Include any common code for this module. |
8
|
|
|
require_once dirname(__DIR__) . '/include/common.php'; |
9
|
|
|
|
10
|
|
|
$xoopsOption['template_main'] = 'pedigree_tools.tpl'; |
11
|
|
|
|
12
|
|
|
include XOOPS_ROOT_PATH . '/header.php'; |
13
|
|
|
$xoopsTpl->assign('page_title', 'Pedigree database - Add owner/breeder'); |
14
|
|
|
|
15
|
|
|
//check for access |
16
|
|
|
$xoopsModule = XoopsModule::getByDirname('pedigree'); |
17
|
|
View Code Duplication |
if (empty($GLOBALS['xoopsUser'])) { |
|
|
|
|
18
|
|
|
redirect_header('index.php', 3, _NOPERM . '<br />' . _MA_PEDIGREE_REGIST); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
//add JS routines |
22
|
|
|
echo '<script language="JavaScript" src="picker.js"></script>'; |
23
|
|
|
|
24
|
|
|
//set form to be empty |
25
|
|
|
$form = ''; |
26
|
|
|
|
27
|
|
|
//get module configuration |
28
|
|
|
$moduleHandler = xoops_getHandler('module'); |
29
|
|
|
$module = $moduleHandler->getByDirname('pedigree'); |
30
|
|
|
$configHandler = xoops_getHandler('config'); |
31
|
|
|
$moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
32
|
|
|
|
33
|
|
|
switch ($_GET['op']) { |
34
|
|
|
case 'lang': |
35
|
|
|
lang(); |
36
|
|
|
break; |
37
|
|
|
case 'langsave': |
38
|
|
|
langsave(); |
39
|
|
|
break; |
40
|
|
|
case 'colours': |
41
|
|
|
colours(); |
42
|
|
|
break; |
43
|
|
|
case 'settings': |
44
|
|
|
settings(); |
45
|
|
|
break; |
46
|
|
|
case 'settingssave': |
47
|
|
|
settingssave(); |
48
|
|
|
break; |
49
|
|
|
case 'pro': |
50
|
|
|
pro(); |
51
|
|
|
break; |
52
|
|
|
case 'userfields': |
53
|
|
|
userfields(); |
54
|
|
|
break; |
55
|
|
|
case 'deleted': |
56
|
|
|
deleted(); |
57
|
|
|
break; |
58
|
|
|
case 'delperm': |
59
|
|
|
delperm($_GET['id']); |
60
|
|
|
break; |
61
|
|
|
case 'delall': |
62
|
|
|
delall(); |
63
|
|
|
break; |
64
|
|
|
case 'restore': |
65
|
|
|
restore($_GET['id']); |
66
|
|
|
break; |
67
|
|
|
case 'database': |
68
|
|
|
database(); |
69
|
|
|
$db = true; |
70
|
|
|
break; |
71
|
|
|
case 'dbanc': |
72
|
|
|
database_oa(); |
73
|
|
|
$db = true; |
74
|
|
|
break; |
75
|
|
|
case 'fltypar': |
76
|
|
|
database_fp(); |
77
|
|
|
$db = true; |
78
|
|
|
break; |
79
|
|
|
case 'credits': |
80
|
|
|
credits(); |
81
|
|
|
break; |
82
|
|
|
default : |
|
|
|
|
83
|
|
|
index(); |
|
|
|
|
84
|
|
|
break; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
//create tools array |
88
|
|
|
$tools[] = array('title' => 'General settings', 'link' => 'tools.php?op=settings', 'main' => '1'); |
89
|
|
|
if ($moduleConfig['proversion'] == '1') { |
90
|
|
|
$tools[] = array('title' => 'Pro-version settings', 'link' => 'tools.php?op=pro', 'main' => '1'); |
91
|
|
|
} |
92
|
|
|
$tools[] = array('title' => 'Language options', 'link' => 'tools.php?op=lang', 'main' => '1'); |
93
|
|
|
$tools[] = array('title' => 'Create user fields', 'link' => 'tools.php?op=userfields', 'main' => '1'); |
94
|
|
|
$tools[] = array('title' => 'Create colours', 'link' => 'tools.php?op=colours', 'main' => '1'); |
95
|
|
|
$tools[] = array('title' => "Deleted pedigree's", 'link' => 'tools.php?op=deleted', 'main' => '1'); |
96
|
|
|
$tools[] = array('title' => 'Database tools', 'link' => 'tools.php?op=database', 'main' => '1'); |
97
|
|
|
if (isset($db)) { |
98
|
|
|
//create database submenu |
99
|
|
|
$tools[] = array('title' => 'Own ancestors', 'link' => 'tools.php?op=dbanc', 'main' => '0'); |
100
|
|
|
$tools[] = array('title' => 'Incorrect gender', 'link' => 'tools.php?op=fltypar', 'main' => '0'); |
101
|
|
|
$tools[] = array('title' => 'User Queries', 'link' => 'tools.php?op=userq', 'main' => '0'); |
102
|
|
|
} |
103
|
|
|
$tools[] = array('title' => 'Credits', 'link' => 'tools.php?op=credits', 'main' => '1'); |
104
|
|
|
$tools[] = array('title' => 'Logout', 'link' => '../../user.php?op=logout', 'main' => '1'); |
105
|
|
|
//add data (form) to smarty template |
106
|
|
|
|
107
|
|
|
$xoopsTpl->assign('tools', $tools); |
108
|
|
|
|
109
|
|
|
//footer |
110
|
|
|
include XOOPS_ROOT_PATH . '/footer.php'; |
111
|
|
|
|
112
|
|
|
function index() |
113
|
|
|
{ |
114
|
|
|
$form = ''; |
|
|
|
|
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
function colours() |
118
|
|
|
{ |
119
|
|
|
global $xoopsTpl, $femaleTextColour; |
|
|
|
|
120
|
|
|
$form = 'This will be the wizard to create and modify the website colourscheme.<hr>'; |
121
|
|
|
$form .= '<FORM NAME="myForm" action=\'savecolors.php\' method=\'POST\'>'; |
122
|
|
|
$form .= '<INPUT TYPE="text" id="ftxtcolor" name="ftxtcolor" value="#' . $femaleTextColour . '" size="11" maxlength="7">'; |
123
|
|
|
$form .= '<a href="javascript:TCP.popup(document.forms[\'myForm\'].elements[\'ftxtcolor\'])">'; |
124
|
|
|
$form .= '<img width="15" height="13" border="0" alt="Click Here to Pick up the color" src="img/sel.gif"></a>'; |
125
|
|
|
$form .= '</form>'; |
126
|
|
|
$xoopsTpl->assign('form', $form); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
function userfields() |
130
|
|
|
{ |
131
|
|
|
global $xoopsTpl; |
|
|
|
|
132
|
|
|
$form = 'This will be the wizard to create and modify the custom userfields.<hr>'; |
133
|
|
|
$xoopsTpl->assign('form', $form); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
function credits() |
137
|
|
|
{ |
138
|
|
|
global $xoopsTpl; |
|
|
|
|
139
|
|
|
$form = "Pedigree database module<br /><br /><li>Programming : James Cotton<br/><li>Design & Layout : Ton van der Hagen<br /><br />Technical support :<br /><li><a href=\"mailto:[email protected]\">[email protected]<br /><li><a href=\"http://www.animalpedigree.com\">www.animalpedigree.com</a><hr>"; |
140
|
|
|
$xoopsTpl->assign('form', $form); |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
function database() |
144
|
|
|
{ |
145
|
|
|
global $xoopsTpl; |
|
|
|
|
146
|
|
|
$form = _MA_PEDIGREE_QUERY_EXPLAN; |
147
|
|
|
$xoopsTpl->assign('form', $form); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
function database_oa() |
|
|
|
|
151
|
|
|
{ |
152
|
|
|
global $xoopsTpl; |
|
|
|
|
153
|
|
|
$form = _AM_PEDIGREE_DATABASE_CHECK_ANCESTORS; |
154
|
|
|
$sql = 'SELECT d.id AS d_id, d.naam AS d_naam |
155
|
|
|
FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' d |
156
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' m ON m.id = d.mother |
157
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' f ON f.id = d.father |
158
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mm ON mm.id = m.mother |
159
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' mf ON mf.id = m.father |
160
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' fm ON fm.id = f.mother |
161
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' ff ON ff.id = f.father |
162
|
|
|
WHERE |
163
|
|
|
d.mother = d.id |
164
|
|
|
OR d.father = d.id |
165
|
|
|
OR m.mother = d.id |
166
|
|
|
OR m.father = d.id |
167
|
|
|
OR f.mother = d.id |
168
|
|
|
OR f.father = d.id |
169
|
|
|
OR mm.mother = d.id |
170
|
|
|
OR mm.father = d.id |
171
|
|
|
OR mf.mother = d.id |
172
|
|
|
OR mf.father = d.id |
173
|
|
|
OR fm.mother = d.id |
174
|
|
|
OR fm.father = d.id |
175
|
|
|
OR ff.mother = d.id |
176
|
|
|
OR ff.father = d.id |
177
|
|
|
'; |
178
|
|
|
$result = $GLOBALS['xoopsDB']->query($sql); |
179
|
|
View Code Duplication |
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
|
|
|
180
|
|
|
$form .= "<li><a href=\"pedigree.php?pedid=" . $row['d_id'] . "\">" . $row['d_naam'] . '</a> [own parent or grandparent]<br />'; |
181
|
|
|
} |
182
|
|
|
$xoopsTpl->assign('form', $form); |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
function database_fp() |
|
|
|
|
186
|
|
|
{ |
187
|
|
|
global $xoopsTpl; |
|
|
|
|
188
|
|
|
$form = _AM_PEDIGREE_DATABASE_CHECK_GENDER; |
189
|
|
|
$sql = 'SELECT d.id AS d_id, d.naam AS d_naam, m.roft as m_roft |
190
|
|
|
FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' d |
191
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " m ON m.id = d.mother |
192
|
|
|
WHERE |
193
|
|
|
d.mother = m.id |
194
|
|
|
AND m.roft = '0' "; |
195
|
|
|
$result = $GLOBALS['xoopsDB']->query($sql); |
196
|
|
View Code Duplication |
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
|
|
|
197
|
|
|
$form .= "<li><a href=\"dog.php?id=" . $row['d_id'] . "\">" . $row['d_naam'] . '</a> [mother seems to be male]<br />'; |
198
|
|
|
} |
199
|
|
|
$sql = 'SELECT d.id AS d_id, d.naam AS d_naam, f.roft as f_roft |
200
|
|
|
FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' d |
201
|
|
|
LEFT JOIN ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . " f ON f.id = d.father |
202
|
|
|
WHERE |
203
|
|
|
d.father = f.id |
204
|
|
|
AND f.roft = '1' "; |
205
|
|
|
$result = $GLOBALS['xoopsDB']->query($sql); |
206
|
|
View Code Duplication |
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
|
|
|
207
|
|
|
$form .= "<li><a href=\"dog.php?id=" . $row['d_id'] . "\">" . $row['d_naam'] . '</a> [father seems to be female]<br />'; |
208
|
|
|
} |
209
|
|
|
$xoopsTpl->assign('form', $form); |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
function pro() |
213
|
|
|
{ |
214
|
|
|
global $xoopsTpl; |
|
|
|
|
215
|
|
|
$form = 'Pro version settings go here.<hr>'; |
216
|
|
|
$xoopsTpl->assign('form', $form); |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
function deleted() |
|
|
|
|
220
|
|
|
{ |
221
|
|
|
global $xoopsTpl, $moduleConfig; |
|
|
|
|
222
|
|
|
$form = "Below the line are the animals which have been deleted from your database.<br /><br />By clicking on the name you can reinsert them into the database.<br />By clicking on the 'X' in front of the name you can permanently delete the animal.<hr>"; |
223
|
|
|
$sql = 'SELECT ID, NAAM FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_trash'); |
224
|
|
|
$result = $GLOBALS['xoopsDB']->query($sql); |
225
|
|
|
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
226
|
|
|
$form .= "<a href=\"tools.php?op=delperm&id=" . $row['Id'] . "\"><img src=\"assets/images/delete.gif\" /></a> <a href=\"tools.php?op=restore&id=" . $row['Id'] . "\">" . $row['NAAM'] . '</a><br />'; |
227
|
|
|
} |
228
|
|
View Code Duplication |
if ($GLOBALS['xoopsDB']->getRowsNum($result) > 0) { |
|
|
|
|
229
|
|
|
$form .= "<hr><a href=\"tools.php?op=delall\">Click here</a> to remove all these " . $moduleConfig['animalTypes'] . ' permenantly '; |
230
|
|
|
} |
231
|
|
|
$xoopsTpl->assign('form', $form); |
232
|
|
|
} |
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* @param $id |
236
|
|
|
*/ |
237
|
|
View Code Duplication |
function delperm($id) |
|
|
|
|
238
|
|
|
{ |
239
|
|
|
global $xoopsTpl; |
|
|
|
|
240
|
|
|
$sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_trash') . ' WHERE ID = ' . $id; |
241
|
|
|
$GLOBALS['xoopsDB']->queryF($sql); |
242
|
|
|
deleted(); |
243
|
|
|
} |
244
|
|
|
|
245
|
|
View Code Duplication |
function delall() |
|
|
|
|
246
|
|
|
{ |
247
|
|
|
global $xoopsTpl; |
|
|
|
|
248
|
|
|
$sql = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_trash'); |
249
|
|
|
$GLOBALS['xoopsDB']->queryF($sql); |
250
|
|
|
deleted(); |
251
|
|
|
} |
252
|
|
|
|
253
|
|
|
/** |
254
|
|
|
* @param $id |
255
|
|
|
*/ |
256
|
|
|
function restore($id) |
|
|
|
|
257
|
|
|
{ |
258
|
|
|
global $xoopsTpl; |
|
|
|
|
259
|
|
|
$sql = 'SELECT * from ' . $GLOBALS['xoopsDB']->prefix('pedigree_trash') . ' WHERE ID = ' . $id; |
260
|
|
|
$result = $GLOBALS['xoopsDB']->query($sql); |
261
|
|
View Code Duplication |
while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
|
|
|
|
262
|
|
|
foreach ($row as $key => $values) { |
263
|
|
|
// $queryvalues .= "'" . $values . "',"; |
264
|
|
|
$queryvalues .= "'" . $GLOBALS['xoopsDB']->escape($values) . "',"; |
|
|
|
|
265
|
|
|
} |
266
|
|
|
$outgoing = substr_replace($queryvalues, '', -1); |
267
|
|
|
$query = 'INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('pedigree_tree') . ' VALUES (' . $outgoing . ')'; |
268
|
|
|
$GLOBALS['xoopsDB']->queryF($query); |
269
|
|
|
$delquery = 'DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_trash') . ' WHERE ID = ' . $id; |
270
|
|
|
$GLOBALS['xoopsDB']->queryF($delquery); |
271
|
|
|
$form .= "<li><a href=\"pedigree.php?pedid=" . $row['Id'] . "\">" . $row['NAAM'] . '</a> has been restored into the database.<hr>'; |
|
|
|
|
272
|
|
|
} |
273
|
|
|
$xoopsTpl->assign('form', $form); |
274
|
|
|
} |
275
|
|
|
|
276
|
|
|
function settings() |
277
|
|
|
{ |
278
|
|
|
global $xoopsTpl, $moduleConfig; |
|
|
|
|
279
|
|
|
include XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
280
|
|
|
$form = new XoopsThemeForm('General settings', 'settings', 'tools.php?op=settingssave', 'POST', 1); |
281
|
|
|
$form->addElement(new XoopsFormHiddenToken($name = 'XOOPS_TOKEN_REQUEST', $timeout = 360)); |
282
|
|
|
$select = new XoopsFormSelect('<b>Number of results per page</b>', 'perpage', $value = $moduleConfig['perpage'], $size = 1, $multiple = false); |
283
|
|
|
$options = array('50' => 50, '100' => 100, '250' => 250, '500' => 500, '1000' => 1000, '2000' => 2000, '5000' => 5000, '10000' => 10000); |
284
|
|
|
foreach ($options as $key => $values) { |
285
|
|
|
$select->addOption($key, $name = $values); |
286
|
|
|
} |
287
|
|
|
unset($options); |
288
|
|
|
$form->addElement($select); |
289
|
|
|
$form->addElement(new XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'This field is used to set the number of results a page will return from a search. If more results are returned extra pages will be created for easy browsing.<br />Set this number higher as your database grows and the number of pages increase.')); |
290
|
|
|
$radio = new XoopsFormRadio('<b>Use owner/breeder fields</b>', 'ownerbreeder', $value = $moduleConfig['ownerbreeder']); |
291
|
|
|
$radio->addOption(1, $name = 'yes'); |
292
|
|
|
$radio->addOption(0, $name = 'no'); |
293
|
|
|
$form->addElement($radio); |
294
|
|
|
$form->addElement(new XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set if you would like to use the owner/breeder fields of the database.<br />As the name suggests the owner/breeder fields let you record and display information about the owner and or breeder.<br />The owner/breeder menu items will also be affected by this setting.')); |
295
|
|
|
$radiobr = new XoopsFormRadio('<b>Show brother & sister field</b>', 'brothers', $value = $moduleConfig['brothers']); |
296
|
|
|
$radiobr->addOption(1, $name = 'yes'); |
297
|
|
|
$radiobr->addOption(0, $name = 'no'); |
298
|
|
|
$form->addElement($radiobr); |
299
|
|
|
$form->addElement(new XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set if you would like to use the add a ' . $moduleConfig['litter'] . 'feature.<br />If your chosen animal only has one offspring at a time this feature will not be useful to you.')); |
300
|
|
|
$radiolit = new XoopsFormRadio('<b>Use add a ' . $moduleConfig['litter'] . ' feature</b>', 'uselitter', $value = $moduleConfig['uselitter']); |
301
|
|
|
$radiolit->addOption(1, $name = 'yes'); |
302
|
|
|
$radiolit->addOption(0, $name = 'no'); |
303
|
|
|
$form->addElement($radiolit); |
304
|
|
|
$form->addElement(new XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set if you would like to display the brothers & sisters field on the detailed ' . $moduleConfig['animalType'] . ' information page.')); |
305
|
|
|
$radioch = new XoopsFormRadio('<b>Show ' . $moduleConfig['children'] . ' field</b>', 'pups', $value = $moduleConfig['pups']); |
306
|
|
|
$radioch->addOption(1, $name = 'yes'); |
307
|
|
|
$radioch->addOption(0, $name = 'no'); |
308
|
|
|
$form->addElement($radioch); |
309
|
|
|
$form->addElement(new XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set if you would like to display the ' . $moduleConfig['children'] . ' field on the detailed ' . $moduleConfig['animalType'] . ' information page.')); |
310
|
|
|
$form->addElement(new XoopsFormButton('', 'button_id', 'Submit', 'submit')); |
311
|
|
|
$xoopsTpl->assign('form', $form->render()); |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
function settingssave() |
|
|
|
|
315
|
|
|
{ |
316
|
|
|
global $xoopsTpl; |
|
|
|
|
317
|
|
|
$form = ''; |
318
|
|
|
$settings = array('perpage', 'ownerbreeder', 'brothers', 'uselitter', 'pups'); |
319
|
|
View Code Duplication |
foreach ($_POST as $key => $values) { |
|
|
|
|
320
|
|
|
if (in_array($key, $settings)) { |
321
|
|
|
// $query = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('config') . " SET conf_value = '" . $values . "' WHERE conf_name = '" . $key . "'"; |
|
|
|
|
322
|
|
|
$query = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('config') . " SET conf_value = '" . $GLOBALS['xoopsDB']->escape($values) . "' WHERE conf_name = '" . $GLOBALS['xoopsDB']->escape($key) . "'"; |
323
|
|
|
$GLOBALS['xoopsDB']->query($query); |
324
|
|
|
} |
325
|
|
|
} |
326
|
|
|
$form .= 'Your settings have been saved.<hr>'; |
327
|
|
|
$xoopsTpl->assign('form', $form); |
328
|
|
|
} |
329
|
|
|
|
330
|
|
|
function lang() |
331
|
|
|
{ |
332
|
|
|
global $xoopsTpl, $moduleConfig; |
|
|
|
|
333
|
|
|
include XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
334
|
|
|
$form = new XoopsThemeForm('Language options', 'language', 'tools.php?op=langsave', 'POST'); |
335
|
|
|
$form->addElement(new XoopsFormHiddenToken($name = 'XOOPS_TOKEN_REQUEST', $timeout = 360)); |
336
|
|
|
$form->addElement(new XoopsFormText('<b>type of animal</b>', 'animalType', $size = 50, $maxsize = 255, $value = $moduleConfig['animalType'])); |
337
|
|
|
$form->addElement(new XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set the animal type which will be used in the application.<br /><i>example : </i>snake, pigeon, dog, owl<br /><br />The value should fit in the sentences below.<br />Please add optional information for this <b>' . $moduleConfig['animalType'] . '</b>.<br />Select the first letter of the <b>' . $moduleConfig['animalType'] . '</b>.')); |
338
|
|
|
$form->addElement(new XoopsFormText('<b>type of animal</b>', 'animalTypes', $size = 50, $maxsize = 255, $value = $value = $moduleConfig['animalTypes'])); |
339
|
|
|
$form->addElement(new XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set the animal type which will be used in the application.<br />This field is the plural of the previous field<br /><i>example : </i>snakes, pigeons, dogs, owls<br /><br />The value should fit in the sentence below.<br />No <b>' . $moduleConfig['animalTypes'] . '</b> meeting your query have been found.')); |
340
|
|
|
$form->addElement(new XoopsFormText('<b>male</b>', 'male', $size = 50, $maxsize = 255, $value = $moduleConfig['male'])); |
341
|
|
|
$form->addElement(new XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set the name used for the male animal.<br /><i>example : </i>male, buck, sire etc.')); |
342
|
|
|
$form->addElement(new XoopsFormText('<b>female</b>', 'female', $size = 50, $maxsize = 255, $value = $moduleConfig['female'])); |
343
|
|
|
$form->addElement(new XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set the name used for the female animal.<br /><i>example : </i>female, vixen, dam etc.')); |
344
|
|
|
$form->addElement(new XoopsFormText('<b>children</b>', 'children', $size = 50, $maxsize = 255, $value = $moduleConfig['children'])); |
345
|
|
|
$form->addElement(new XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set the name used for children of this type of animal (' . $moduleConfig['animalTypes'] . ').<br /><i>example : </i>pups, cubs, kittens etc.')); |
346
|
|
|
$form->addElement(new XoopsFormText('<b>mother</b>', 'mother', $size = 50, $maxsize = 255, $value = $moduleConfig['mother'])); |
347
|
|
|
$form->addElement(new XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set the name used for mother of this type of animal (' . $moduleConfig['animalTypes'] . ').<br /><i>example : </i>dam, mare etc.')); |
348
|
|
|
$form->addElement(new XoopsFormText('<b>father</b>', 'father', $size = 50, $maxsize = 255, $value = $moduleConfig['father'])); |
349
|
|
|
$form->addElement(new XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set the name used for father of this type of animal (' . $moduleConfig['animalTypes'] . ').<br /><i>example : </i>sire, stallion etc.')); |
350
|
|
|
$form->addElement(new XoopsFormText('<b>litter</b>', 'litter', $size = 50, $maxsize = 255, $value = $moduleConfig['litter'])); |
351
|
|
|
$form->addElement(new XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set the name used for a collection of newborn animals.<br /><i>example : </i>litter, nest etc.')); |
352
|
|
|
$form->addElement(new XoopsFormTextArea('<b>Welcome text</b>', 'welcome', $value = $moduleConfig['welcome'], $rows = 15, $cols = 50)); |
353
|
|
|
|
354
|
|
|
$form->addElement(new XoopsFormLabel(_MA_PEDIGREE_EXPLAIN, 'Use this field to set the text you would like to display for the welcome page.<br /><br />You may use the follwing variables :<br />[animalType] = ' . $moduleConfig['animalType'] . '<br />[animalTypes] =' . $moduleConfig['animalTypes'] . '<br />[numanimals] = number of animals in the database.')); |
355
|
|
|
$form->addElement(new XoopsFormButton('', 'button_id', 'Submit', 'submit')); |
356
|
|
|
$xoopsTpl->assign('form', $form->render()); |
357
|
|
|
} |
358
|
|
|
|
359
|
|
|
function langsave() |
|
|
|
|
360
|
|
|
{ |
361
|
|
|
global $xoopsTpl; |
|
|
|
|
362
|
|
|
$form = ''; |
363
|
|
|
$settings = array('animalType', 'animalTypes', 'male', 'female', 'children', 'mother', 'father', 'litter', 'welcome'); |
364
|
|
View Code Duplication |
foreach ($_POST as $key => $values) { |
|
|
|
|
365
|
|
|
if (in_array($key, $settings)) { |
366
|
|
|
// $query = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('config') . " SET conf_value = '" . $values . "' WHERE conf_name = '" . $key . "'"; |
|
|
|
|
367
|
|
|
$query = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('config') . " SET conf_value = '" . $GLOBALS['xoopsDB']->escape($values) . "' WHERE conf_name = '" . $GLOBALS['xoopsDB']->escape($key) . "'"; |
368
|
|
|
$GLOBALS['xoopsDB']->query($query); |
369
|
|
|
} |
370
|
|
|
} |
371
|
|
|
$form .= 'Your settings have been saved.<hr>'; |
372
|
|
|
$xoopsTpl->assign('form', $form); |
373
|
|
|
} |
374
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.