|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
// $Id: blocksadmin.inc.php 8344 2011-11-26 02:38:25Z beckmi $ |
|
3
|
|
|
// ------------------------------------------------------------------------ // |
|
4
|
|
|
// XOOPS - PHP Content Management System // |
|
5
|
|
|
// Copyright (c) 2000 XOOPS.org // |
|
6
|
|
|
// <http://www.xoops.org/> // |
|
7
|
|
|
// ------------------------------------------------------------------------ // |
|
8
|
|
|
// This program is free software; you can redistribute it and/or modify // |
|
9
|
|
|
// it under the terms of the GNU General Public License as published by // |
|
10
|
|
|
// the Free Software Foundation; either version 2 of the License, or // |
|
11
|
|
|
// (at your option) any later version. // |
|
12
|
|
|
// // |
|
13
|
|
|
// You may not change or alter any portion of this comment or credits // |
|
14
|
|
|
// of supporting developers from this source code or any supporting // |
|
15
|
|
|
// source code which is considered copyrighted (c) material of the // |
|
16
|
|
|
// original comment or credit authors. // |
|
17
|
|
|
// // |
|
18
|
|
|
// This program is distributed in the hope that it will be useful, // |
|
19
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
20
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
21
|
|
|
// GNU General Public License for more details. // |
|
22
|
|
|
// // |
|
23
|
|
|
// You should have received a copy of the GNU General Public License // |
|
24
|
|
|
// along with this program; if not, write to the Free Software // |
|
25
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|
26
|
|
|
// ------------------------------------------------------------------------ // |
|
27
|
|
|
// Author: Kazumi Ono (AKA onokazu) // |
|
28
|
|
|
// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // |
|
29
|
|
|
// Project: The XOOPS Project // |
|
30
|
|
|
// ------------------------------------------------------------------------- // |
|
31
|
|
|
|
|
32
|
|
|
if (!is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid())) { |
|
33
|
|
|
exit('Access Denied'); |
|
34
|
|
|
} |
|
35
|
|
|
include_once XOOPS_ROOT_PATH.'/class/xoopsblock.php'; |
|
36
|
|
|
include XOOPS_ROOT_PATH.'/modules/system/admin/blocksadmin/blocksadmin.php'; |
|
37
|
|
|
|
|
38
|
|
|
$op = 'list'; |
|
39
|
|
|
|
|
40
|
|
|
if (!empty($_POST['op'])) { |
|
41
|
|
|
$op = $_POST['op']; |
|
42
|
|
|
} |
|
43
|
|
|
if (!empty($_POST['bid'])) { |
|
44
|
|
|
$bid = intval($_POST['bid']); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
if (isset($_GET['op'])) { |
|
48
|
|
|
if ($_GET['op'] == 'edit' || $_GET['op'] == 'delete' || $_GET['op'] == 'delete_ok' || $_GET['op'] == 'clone' /* || $_GET['op'] == 'previewpopup'*/) { |
|
|
|
|
|
|
49
|
|
|
$op = $_GET['op']; |
|
50
|
|
|
$bid = isset($_GET['bid']) ? intval($_GET['bid']) : 0; |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
if (isset($_POST['previewblock'])) { |
|
55
|
|
|
/* |
|
|
|
|
|
|
56
|
|
|
if (!admin_refcheck("/modules/$admin_mydirname/admin/")) { |
|
57
|
|
|
exit('Invalid Referer'); |
|
58
|
|
|
} |
|
59
|
|
|
*/ |
|
60
|
|
View Code Duplication |
if (!$xoopsGTicket->check(true, 'myblocksadmin')) { |
|
|
|
|
|
|
61
|
|
|
redirect_header(XOOPS_URL.'/', 3, $xoopsGTicket->getErrors()); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
if(empty($bid)) { |
|
65
|
|
|
die('Invalid bid.'); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
$bside = (!empty($_POST['bside'])) ? intval($_POST['bside']) : 0; |
|
69
|
|
|
$bweight = (!empty($_POST['bweight'])) ? intval($_POST['bweight']) : 0; |
|
70
|
|
|
$bvisible = (!empty($_POST['bvisible'])) ? intval($_POST['bvisible']) : 0; |
|
71
|
|
|
$bmodule = (!empty($_POST['bmodule'])) ? $_POST['bmodule'] : array(); |
|
72
|
|
|
$btitle = (!empty($_POST['btitle'])) ? $_POST['btitle'] : ''; |
|
73
|
|
|
$bcontent = (!empty($_POST['bcontent'])) ? $_POST['bcontent'] : ''; |
|
74
|
|
|
$bctype = (!empty($_POST['bctype'])) ? $_POST['bctype'] : ''; |
|
75
|
|
|
$bcachetime = (!empty($_POST['bcachetime'])) ? intval($_POST['bcachetime']) : 0; |
|
76
|
|
|
|
|
77
|
|
|
xoops_cp_header(); |
|
78
|
|
|
include_once XOOPS_ROOT_PATH.'/class/template.php'; |
|
79
|
|
|
$xoopsTpl = new XoopsTpl(); |
|
80
|
|
|
//$xoopsTpl->xoops_setCaching(0); |
|
|
|
|
|
|
81
|
|
|
$xoopsTpl->caching=0; |
|
82
|
|
|
$block['bid'] = $bid; |
|
83
|
|
|
|
|
84
|
|
|
if ($op == 'clone_ok') { |
|
85
|
|
|
$block['form_title'] = _AM_CLONEBLOCK; |
|
86
|
|
|
$block['submit_button'] = _CLONE; |
|
87
|
|
|
$myblock = new XoopsBlock(); |
|
88
|
|
|
$myblock->setVar('block_type', 'C'); |
|
89
|
|
|
} else { |
|
90
|
|
|
$op = 'update'; |
|
91
|
|
|
$block['form_title'] = _AM_EDITBLOCK; |
|
92
|
|
|
$block['submit_button'] = _SUBMIT; |
|
93
|
|
|
$myblock = new XoopsBlock($bid); |
|
94
|
|
|
$block['name'] = $myblock->getVar('name'); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
$myts =& MyTextSanitizer::getInstance(); |
|
98
|
|
|
$myblock->setVar('title', $myts->stripSlashesGPC($btitle)); |
|
99
|
|
|
$myblock->setVar('content', $myts->stripSlashesGPC($bcontent)); |
|
100
|
|
|
/* |
|
|
|
|
|
|
101
|
|
|
$dummyhtml = '<html><head><meta http-equiv="content-type" content="text/html; charset='._CHARSET.'"><meta http-equiv="content-language" content="'._LANGCODE.'"><title>'.$xoopsConfig['sitename'].'</title><link rel="stylesheet" type="text/css" media="all" href="'.getcss($xoopsConfig['theme_set']).'"></head><body><table><tr><th>'.$myblock->getVar('title').'</th></tr><tr><td>'.$myblock->getContent('S', $bctype).'</td></tr></table></body></html>'; |
|
102
|
|
|
$dummyfile = '_dummyfile_'.time().'.html'; |
|
103
|
|
|
$fp = fopen(XOOPS_CACHE_PATH.'/'.$dummyfile, 'w'); |
|
104
|
|
|
fwrite($fp, $dummyhtml); |
|
105
|
|
|
fclose($fp); |
|
106
|
|
|
*/ |
|
107
|
|
|
$block['edit_form'] = false; |
|
108
|
|
|
$block['template'] = ''; |
|
109
|
|
|
$block['op'] = $op; |
|
110
|
|
|
$block['side'] = $bside; |
|
111
|
|
|
$block['weight'] = $bweight; |
|
112
|
|
|
$block['visible'] = $bvisible; |
|
113
|
|
|
$block['title'] = $myblock->getVar('title', 'E'); |
|
114
|
|
|
$block['content'] = $myblock->getVar('content','n'); |
|
115
|
|
|
$block['modules'] =& $bmodule; |
|
116
|
|
|
$block['ctype'] = isset($bctype) ? $bctype : $myblock->getVar('c_type'); |
|
117
|
|
|
$block['is_custom'] = true; |
|
118
|
|
|
$block['cachetime'] = intval($bcachetime); |
|
119
|
|
|
echo '<a href="myblocksadmin.php">'. _AM_MYLINKS_BADMIN .'</a> <span style="font-weight:bold;">»»</span> ' . $block['form_title'] . '<br><br>'; |
|
120
|
|
|
include __DIR__ . '/../admin/myblockform.php'; //GIJ |
|
121
|
|
|
//echo '<a href="admin.php?fct=blocksadmin">'. _AM_MYLINKS_BADMIN .'</a> <span style="font-weight:bold;">»»</span> '.$block['form_title'].'<br><br>'; |
|
|
|
|
|
|
122
|
|
|
//include XOOPS_ROOT_PATH.'/modules/system/admin/blocksadmin/blockform.php'; |
|
|
|
|
|
|
123
|
|
|
$xoopsGTicket->addTicketXoopsFormElement($form, __LINE__, 1800, 'myblocksadmin'); //GIJ |
|
124
|
|
|
$form->display(); |
|
125
|
|
|
|
|
126
|
|
|
$original_level = error_reporting(E_ALL); |
|
127
|
|
|
echo "<table width='100%' class='outer' cellspacing='1'>\n" |
|
128
|
|
|
. " <tr>\n" |
|
129
|
|
|
. ' <th>' . $myblock->getVar('title') . "</th>\n" |
|
130
|
|
|
. " </tr>\n" |
|
131
|
|
|
. " <tr>\n" |
|
132
|
|
|
. " <td class='odd'>" . $myblock->getContent('S', $bctype) . "</td>\n" |
|
133
|
|
|
. " </tr>\n" |
|
134
|
|
|
. "</table>\n"; |
|
135
|
|
|
error_reporting($original_level); |
|
136
|
|
|
|
|
137
|
|
|
xoops_cp_footer(); |
|
138
|
|
|
/* |
|
|
|
|
|
|
139
|
|
|
echo '<script type="text/javascript"> |
|
140
|
|
|
preview_window = openWithSelfMain("'.XOOPS_URL.'/modules/system/admin.php?fct=blocksadmin&op=previewpopup&file='.$dummyfile.'", "popup", 250, 200); |
|
141
|
|
|
</script>'; |
|
142
|
|
|
*/ |
|
143
|
|
|
exit(); |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/* |
|
|
|
|
|
|
147
|
|
|
if ($op == 'previewpopup') { |
|
148
|
|
|
if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
|
149
|
|
|
exit('Invalid Referer'); |
|
150
|
|
|
} |
|
151
|
|
|
$file = str_replace('..', '', XOOPS_CACHE_PATH.'/'.trim($_GET['file'])); |
|
152
|
|
|
if (file_exists($file)) { |
|
153
|
|
|
include $file; |
|
154
|
|
|
@unlink($file); |
|
155
|
|
|
} |
|
156
|
|
|
exit(); |
|
157
|
|
|
} |
|
158
|
|
|
*/ |
|
159
|
|
|
|
|
160
|
|
|
/* |
|
|
|
|
|
|
161
|
|
|
if ( $op == "list" ) { |
|
162
|
|
|
xoops_cp_header(); |
|
163
|
|
|
list_blocks(); |
|
164
|
|
|
xoops_cp_footer(); |
|
165
|
|
|
exit(); |
|
166
|
|
|
} |
|
167
|
|
|
*/ |
|
168
|
|
|
|
|
169
|
|
|
if ($op == 'order') { |
|
170
|
|
|
//if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
|
|
|
|
|
|
171
|
|
|
// exit('Invalid Referer'); |
|
|
|
|
|
|
172
|
|
|
//} |
|
173
|
|
View Code Duplication |
if (!$xoopsGTicket->check(true, 'myblocksadmin')) { |
|
|
|
|
|
|
174
|
|
|
redirect_header(XOOPS_URL.'/', 3, $xoopsGTicket->getErrors()); |
|
175
|
|
|
} |
|
176
|
|
|
if (!empty($_POST['side'])) { |
|
177
|
|
|
$side = $_POST['side']; |
|
178
|
|
|
} |
|
179
|
|
|
// if ( !empty($_POST['weight']) ) { $weight = $_POST['weight']; } |
|
|
|
|
|
|
180
|
|
|
if (!empty($_POST['visible'])) { |
|
181
|
|
|
$visible = $_POST['visible']; |
|
182
|
|
|
} |
|
183
|
|
|
/* |
|
|
|
|
|
|
184
|
|
|
if (!empty($_POST['oldside'])) { |
|
185
|
|
|
$oldside = $_POST['oldside']; |
|
186
|
|
|
} |
|
187
|
|
|
if (!empty($_POST['oldweight'])) { |
|
188
|
|
|
$oldweight = $_POST['oldweight']; |
|
189
|
|
|
} |
|
190
|
|
|
if (!empty($_POST['oldvisible'])) { |
|
191
|
|
|
$oldvisible = $_POST['oldvisible']; |
|
192
|
|
|
} |
|
193
|
|
|
*/ |
|
194
|
|
|
$bid = (!empty($_POST['bid'])) ? $_POST['bid'] : array(); |
|
195
|
|
|
// GIJ start |
|
196
|
|
View Code Duplication |
foreach (array_keys($bid) as $i) { |
|
|
|
|
|
|
197
|
|
|
if ($side[$i] < 0) { |
|
198
|
|
|
$visible[$i] = 0; |
|
199
|
|
|
$side[$i] = -1; |
|
200
|
|
|
} else { |
|
201
|
|
|
$visible[$i] = 1; |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
$bmodule = (isset($_POST['bmodule'][$i]) && is_array($_POST['bmodule'][$i])) ? $_POST['bmodule'][$i] : array(-1); |
|
205
|
|
|
myblocksadmin_update_block($i, $side[$i], $_POST['weight'][$i], $visible[$i], $_POST['title'][$i], null , null , $_POST['bcachetime'][$i], $bmodule, array()); |
|
206
|
|
|
|
|
207
|
|
|
// if ( $oldweight[$i] != $weight[$i] || $oldvisible[$i] != $visible[$i] || $oldside[$i] != $side[$i] ) |
|
|
|
|
|
|
208
|
|
|
// order_block($bid[$i], $weight[$i], $visible[$i], $side[$i]); |
|
209
|
|
|
} |
|
210
|
|
|
$query4redirect = '?dirname=' . urlencode( strip_tags( substr( $_POST['query4redirect'], 9 ) ) ); |
|
211
|
|
|
redirect_header("myblocksadmin.php$query4redirect", 1, _AM_DBUPDATED); |
|
212
|
|
|
// GIJ end |
|
213
|
|
|
exit(); |
|
214
|
|
|
} |
|
215
|
|
|
|
|
216
|
|
|
if ( $op == 'order2' ) { |
|
217
|
|
View Code Duplication |
if (!$xoopsGTicket->check( true , 'myblocksadmin')) { |
|
|
|
|
|
|
218
|
|
|
redirect_header(XOOPS_URL.'/', 3, $xoopsGTicket->getErrors()); |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
if (isset($_POST['addblock']) && is_array($_POST['addblock'])) { |
|
222
|
|
|
// addblock |
|
223
|
|
|
foreach ($_POST['addblock'] as $bid => $val) { |
|
224
|
|
|
myblocksadmin_update_blockinstance(0, 0, 0, 0, '', null, null, 0, array(), array(), intval( $bid )); |
|
225
|
|
|
} |
|
226
|
|
|
} else { |
|
227
|
|
|
|
|
228
|
|
|
// else change order |
|
229
|
|
|
if (!empty($_POST['side'])) { |
|
230
|
|
|
$side = $_POST['side']; |
|
231
|
|
|
} |
|
232
|
|
|
if (!empty($_POST['visible'])) { |
|
233
|
|
|
$visible = $_POST['visible']; |
|
234
|
|
|
} |
|
235
|
|
|
$id = (!empty($_POST['id'])) ? $_POST['id'] : array(); |
|
236
|
|
|
|
|
237
|
|
View Code Duplication |
foreach (array_keys($id) as $i) { |
|
|
|
|
|
|
238
|
|
|
// separate side and visible |
|
239
|
|
|
if ($side[$i] < 0) { |
|
240
|
|
|
$visible[$i] = 0; |
|
241
|
|
|
$side[$i] = -1; // for not to destroy the original position |
|
242
|
|
|
} else { |
|
243
|
|
|
$visible[$i] = 1; |
|
244
|
|
|
} |
|
245
|
|
|
|
|
246
|
|
|
$bmodule = (isset($_POST['bmodule'][$i]) && is_array($_POST['bmodule'][$i])) ? $_POST['bmodule'][$i] : array(-1); |
|
247
|
|
|
myblocksadmin_update_blockinstance($i, $side[$i], $_POST['weight'][$i], $visible[$i], $_POST['title'][$i], null, null, $_POST['bcachetime'][$i], $bmodule, array()); |
|
248
|
|
|
} |
|
249
|
|
|
} |
|
250
|
|
|
|
|
251
|
|
|
$query4redirect = '?dirname=' . urlencode(strip_tags(substr($_POST['query4redirect'], 9))); |
|
252
|
|
|
redirect_header("myblocksadmin.php$query4redirect", 1, _MD_MYLINKS_AM_DBUPDATED); |
|
253
|
|
|
exit; |
|
254
|
|
|
} |
|
255
|
|
|
|
|
256
|
|
|
/* if ( $op == 'save' ) { |
|
|
|
|
|
|
257
|
|
|
if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
|
258
|
|
|
exit('Invalid Referer'); |
|
259
|
|
|
} |
|
260
|
|
|
if ( ! $xoopsGTicket->check( true , 'myblocksadmin' ) ) { |
|
261
|
|
|
redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors()); |
|
262
|
|
|
} |
|
263
|
|
|
if ( !empty($_POST['bside']) ) { $bside = intval($_POST['bside']); } else { $bside = 0; } |
|
264
|
|
|
if ( !empty($_POST['bweight']) ) { $bweight = intval($_POST['bweight']); } else { $bweight = 0; } |
|
265
|
|
|
if ( !empty($_POST['bvisible']) ) { $bvisible = intval($_POST['bvisible']); } else { $bvisible = 0; } |
|
266
|
|
|
if ( !empty($_POST['bmodule']) ) { $bmodule = $_POST['bmodule']; } else { $bmodule = array(); } |
|
267
|
|
|
if ( !empty($_POST['btitle']) ) { $btitle = $_POST['btitle']; } else { $btitle = ""; } |
|
268
|
|
|
if ( !empty($_POST['bcontent']) ) { $bcontent = $_POST['bcontent']; } else { $bcontent = ""; } |
|
269
|
|
|
if ( !empty($_POST['bctype']) ) { $bctype = $_POST['bctype']; } else { $bctype = ""; } |
|
270
|
|
|
if ( !empty($_POST['bcachetime']) ) { $bcachetime = intval($_POST['bcachetime']); } else { $bcachetime = 0; } |
|
271
|
|
|
save_block($bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bmodule, $bcachetime); |
|
272
|
|
|
exit(); |
|
273
|
|
|
} */ |
|
274
|
|
|
|
|
275
|
|
|
if ('update' ==$op) { |
|
276
|
|
|
/* |
|
|
|
|
|
|
277
|
|
|
if (!admin_refcheck("/modules/$admin_mydirname/admin/")) { |
|
278
|
|
|
exit('Invalid Referer'); |
|
279
|
|
|
} |
|
280
|
|
|
*/ |
|
281
|
|
View Code Duplication |
if (!$xoopsGTicket->check(true, 'myblocksadmin')) { |
|
|
|
|
|
|
282
|
|
|
redirect_header(XOOPS_URL.'/', 3, $xoopsGTicket->getErrors()); |
|
283
|
|
|
} |
|
284
|
|
|
/* |
|
|
|
|
|
|
285
|
|
|
if ( !empty($_POST['bside']) ) { $bside = intval($_POST['bside']); } else { $bside = 0; } |
|
286
|
|
|
if ( !empty($_POST['bweight']) ) { $bweight = intval($_POST['bweight']); } else { $bweight = 0; } |
|
287
|
|
|
if ( !empty($_POST['bvisible']) ) { $bvisible = intval($_POST['bvisible']); } else { $bvisible = 0; } |
|
288
|
|
|
if ( !empty($_POST['btitle']) ) { $btitle = $_POST['btitle']; } else { $btitle = ""; } |
|
289
|
|
|
if ( !empty($_POST['bcontent']) ) { $bcontent = $_POST['bcontent']; } else { $bcontent = ""; } |
|
290
|
|
|
if ( !empty($_POST['bctype']) ) { $bctype = $_POST['bctype']; } else { $bctype = ""; } |
|
291
|
|
|
if ( !empty($_POST['bcachetime']) ) { $bcachetime = intval($_POST['bcachetime']); } else { $bcachetime = 0; } |
|
292
|
|
|
if ( !empty($_POST['bmodule']) ) { $bmodule = $_POST['bmodule']; } else { $bmodule = array(); } |
|
293
|
|
|
if ( !empty($_POST['options']) ) { $options = $_POST['options']; } else { $options = array(); } |
|
294
|
|
|
update_block($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $bmodule, $options); |
|
295
|
|
|
*/ |
|
296
|
|
|
|
|
297
|
|
|
$bcachetime = isset($_POST['bcachetime']) ? intval($_POST['bcachetime']) : 0; |
|
298
|
|
|
$options = isset($_POST['options']) ? $_POST['options'] : array(); |
|
299
|
|
|
$bcontent = isset($_POST['bcontent']) ? $_POST['bcontent'] : ''; |
|
300
|
|
|
$bctype = isset($_POST['bctype']) ? $_POST['bctype'] : ''; |
|
301
|
|
|
$bmodule = (isset($_POST['bmodule']) && is_array($_POST['bmodule'])) ? $_POST['bmodule'] : array(-1); // GIJ + |
|
302
|
|
|
$msg = myblocksadmin_update_block($_POST['bid'], $_POST['bside'], $_POST['bweight'], $_POST['bvisible'], $_POST['btitle'], $bcontent, $bctype, $bcachetime, $bmodule, $options); // GIJ ! |
|
303
|
|
|
redirect_header('myblocksadmin.php', 1, $msg); |
|
304
|
|
|
} |
|
305
|
|
|
|
|
306
|
|
|
if ('delete_ok' == $op) { |
|
307
|
|
|
/* |
|
|
|
|
|
|
308
|
|
|
if ( !admin_refcheck("/modules/$admin_mydirname/admin/") ) { |
|
309
|
|
|
exit('Invalid Referer'); |
|
310
|
|
|
} |
|
311
|
|
|
*/ |
|
312
|
|
View Code Duplication |
if (!$xoopsGTicket->check(true, 'myblocksadmin')) { |
|
|
|
|
|
|
313
|
|
|
redirect_header(XOOPS_URL.'/', 3, $xoopsGTicket->getErrors()); |
|
314
|
|
|
} |
|
315
|
|
|
// delete_block_ok($bid); GIJ imported from blocksadmin.php |
|
316
|
|
|
$myblock = new XoopsBlock($bid); |
|
317
|
|
|
if ('D' != $myblock->getVar('block_type') && 'C' != $myblock->getVar('block_type')) { |
|
318
|
|
|
redirect_header('myblocksadmin.php', 4, 'Invalid block'); |
|
319
|
|
|
exit(); |
|
320
|
|
|
} |
|
321
|
|
|
$myblock->delete(); |
|
322
|
|
|
if ('' != $myblock->getVar('template') && !defined('XOOPS_ORETEKI')) { |
|
323
|
|
|
$tplfile_handler =& xoops_getHandler('tplfile'); |
|
324
|
|
|
$btemplate =& $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid); |
|
325
|
|
|
if (count($btemplate) > 0) { |
|
326
|
|
|
$tplman->delete($btemplate[0]); |
|
327
|
|
|
} |
|
328
|
|
|
} |
|
329
|
|
|
redirect_header('myblocksadmin.php', 1, _AM_DBUPDATED); |
|
330
|
|
|
// end of delete_block_ok() GIJ |
|
331
|
|
|
exit(); |
|
332
|
|
|
} |
|
333
|
|
|
|
|
334
|
|
|
if ('delete' == $op) { |
|
335
|
|
|
xoops_cp_header(); |
|
336
|
|
|
// delete_block($bid); GIJ imported from blocksadmin.php |
|
337
|
|
|
$myblock = new XoopsBlock($bid); |
|
338
|
|
|
if ('S' == $myblock->getVar('block_type')) { |
|
339
|
|
|
$message = _AM_SYSTEMCANT; |
|
340
|
|
|
redirect_header('admin.php?fct=blocksadmin', 4, $message); |
|
341
|
|
|
exit(); |
|
342
|
|
|
} elseif ('M' == $myblock->getVar('block_type')) { |
|
343
|
|
|
$message = _AM_MODULECANT; |
|
344
|
|
|
redirect_header('admin.php?fct=blocksadmin', 4, $message); |
|
345
|
|
|
exit(); |
|
346
|
|
|
} else { |
|
347
|
|
|
xoops_confirm(array('fct' => 'blocksadmin', 'op' => 'delete_ok', 'bid' => $myblock->getVar('bid')) + $xoopsGTicket->getTicketArray( __LINE__ , 1800 , 'myblocksadmin' ), 'admin.php', sprintf(_AM_RUSUREDEL, $myblock->getVar('title'))); |
|
348
|
|
|
} |
|
349
|
|
|
// end of delete_block() GIJ |
|
350
|
|
|
xoops_cp_footer(); |
|
351
|
|
|
exit(); |
|
352
|
|
|
} |
|
353
|
|
|
|
|
354
|
|
View Code Duplication |
if ('edit' == $op) { |
|
|
|
|
|
|
355
|
|
|
|
|
356
|
|
|
xoops_cp_header(); |
|
357
|
|
|
// edit_block($bid); GIJ imported from blocksadmin.php |
|
358
|
|
|
$myblock = new XoopsBlock($bid); |
|
359
|
|
|
|
|
360
|
|
|
$db =& XoopsDatabaseFactory::getDatabaseConnection(); |
|
361
|
|
|
$sql = 'SELECT module_id FROM '.$db->prefix('block_module_link').' WHERE block_id='.intval($bid); |
|
362
|
|
|
$result = $db->query($sql); |
|
363
|
|
|
$modules = array(); |
|
364
|
|
|
while ($row = $db->fetchArray($result)) { |
|
365
|
|
|
$modules[] = intval($row['module_id']); |
|
366
|
|
|
} |
|
367
|
|
|
$is_custom = ('C' == $myblock->getVar('block_type') || 'E' == $myblock->getVar('block_type')) ? true : false; |
|
368
|
|
|
$block = array('form_title' => _AM_EDITBLOCK, 'name' => $myblock->getVar('name'), 'side' => $myblock->getVar('side'), 'weight' => $myblock->getVar('weight'), 'visible' => $myblock->getVar('visible'), 'title' => $myblock->getVar('title','E'), 'content' => $myblock->getVar('content','n'), 'modules' => $modules, 'is_custom' => $is_custom, 'ctype' => $myblock->getVar('c_type'), 'cachetime' => $myblock->getVar('bcachetime'), 'op' => 'update', 'bid' => $myblock->getVar('bid'), 'edit_form' => $myblock->getOptions(), 'template' => $myblock->getVar('template'), 'options' => $myblock->getVar('options'), 'submit_button' => _SUBMIT); |
|
369
|
|
|
|
|
370
|
|
|
echo '<a href="myblocksadmin.php">' . _AM_MYLINKS_BADMIN . '</a> <span style="font-weight:bold;">»»</span> ' . _AM_EDITBLOCK . '<br><br>'; |
|
371
|
|
|
include __DIR__ . '/../admin/myblockform.php'; //GIJ |
|
372
|
|
|
$xoopsGTicket->addTicketXoopsFormElement($form, __LINE__, 1800, 'myblocksadmin'); //GIJ |
|
373
|
|
|
$form->display(); |
|
374
|
|
|
// end of edit_block() GIJ |
|
375
|
|
|
xoops_cp_footer(); |
|
376
|
|
|
exit(); |
|
377
|
|
|
} |
|
378
|
|
|
|
|
379
|
|
View Code Duplication |
if ('clone' == $op) { |
|
|
|
|
|
|
380
|
|
|
xoops_cp_header(); |
|
381
|
|
|
$myblock = new XoopsBlock($bid); |
|
382
|
|
|
|
|
383
|
|
|
$db =& XoopsDatabaseFactory::getDatabaseConnection(); |
|
384
|
|
|
$sql = 'SELECT module_id FROM ' . $db->prefix('block_module_link') . ' WHERE block_id=' . intval($bid); |
|
385
|
|
|
$result = $db->query($sql); |
|
386
|
|
|
$modules = array(); |
|
387
|
|
|
while ($row = $db->fetchArray($result)) { |
|
388
|
|
|
$modules[] = intval($row['module_id']); |
|
389
|
|
|
} |
|
390
|
|
|
$is_custom = ('C' == $myblock->getVar('block_type') || 'E' == $myblock->getVar('block_type')) ? true : false; |
|
391
|
|
|
$block = array('form_title' => _AM_CLONEBLOCK, 'name' => $myblock->getVar('name'), 'side' => $myblock->getVar('side'), 'weight' => $myblock->getVar('weight'), 'visible' => $myblock->getVar('visible'), 'content' => $myblock->getVar('content', 'N'), 'title' => $myblock->getVar('title','E'), 'modules' => $modules, 'is_custom' => $is_custom, 'ctype' => $myblock->getVar('c_type'), 'cachetime' => $myblock->getVar('bcachetime'), 'op' => 'clone_ok', 'bid' => $myblock->getVar('bid'), 'edit_form' => $myblock->getOptions(), 'template' => $myblock->getVar('template'), 'options' => $myblock->getVar('options'), 'submit_button' => _CLONE); |
|
392
|
|
|
echo '<a href="myblocksadmin.php">' . _AM_MYLINKS_BADMIN . '</a> <span style="font-weight:bold;">»»</span> '. _AM_CLONEBLOCK . '<br><br>'; |
|
393
|
|
|
include __DIR__ . '/../admin/myblockform.php'; |
|
394
|
|
|
$xoopsGTicket->addTicketXoopsFormElement($form, __LINE__, 1800, 'myblocksadmin'); //GIJ |
|
395
|
|
|
$form->display(); |
|
396
|
|
|
xoops_cp_footer(); |
|
397
|
|
|
exit(); |
|
398
|
|
|
} |
|
399
|
|
|
|
|
400
|
|
|
if ('clone_ok' == $op) { |
|
401
|
|
|
// Ticket Check |
|
402
|
|
View Code Duplication |
if (!$xoopsGTicket->check(true, 'myblocksadmin')) { |
|
|
|
|
|
|
403
|
|
|
redirect_header(XOOPS_URL . '/', 3, $xoopsGTicket->getErrors()); |
|
404
|
|
|
} |
|
405
|
|
|
|
|
406
|
|
|
$block = new XoopsBlock($bid); |
|
407
|
|
|
|
|
408
|
|
|
// block type check |
|
409
|
|
|
$block_type = $block->getVar('block_type'); |
|
410
|
|
|
if( 'C' != $block_type && 'M' != $block_type && 'D' != $block_type) { |
|
411
|
|
|
redirect_header('myblocksadmin.php', 4, 'Invalid block'); |
|
412
|
|
|
} |
|
413
|
|
|
|
|
414
|
|
|
if(empty($_POST['options'])) { |
|
415
|
|
|
$options = array(); |
|
416
|
|
|
} elseif (is_array($_POST['options'])) { |
|
417
|
|
|
$options = $_POST['options']; |
|
418
|
|
|
} else { |
|
419
|
|
|
$options = explode('|', $_POST['options']); |
|
420
|
|
|
} |
|
421
|
|
|
|
|
422
|
|
|
// for backward compatibility |
|
423
|
|
|
// $cblock =& $block->clone(); or $cblock =& $block->xoopsClone(); |
|
|
|
|
|
|
424
|
|
|
$cblock = new XoopsBlock(); |
|
425
|
|
|
foreach ($block->vars as $k=>$v) { |
|
426
|
|
|
$cblock->assignVar($k, $v['value']); |
|
427
|
|
|
} |
|
428
|
|
|
$cblock->setNew(); |
|
429
|
|
|
|
|
430
|
|
|
$myts =& MyTextSanitizer::getInstance(); |
|
431
|
|
|
$cblock->setVar('side', $_POST['bside']); |
|
432
|
|
|
$cblock->setVar('weight', $_POST['bweight']); |
|
433
|
|
|
$cblock->setVar('visible', $_POST['bvisible']); |
|
434
|
|
|
$cblock->setVar('title', $_POST['btitle']); |
|
435
|
|
|
$cblock->setVar('content', @$_POST['bcontent']); |
|
436
|
|
|
$cblock->setVar('c_type', @$_POST['bctype']); |
|
437
|
|
|
$cblock->setVar('bcachetime', $_POST['bcachetime']); |
|
438
|
|
View Code Duplication |
if (isset($options) && (count($options) > 0)) { |
|
|
|
|
|
|
439
|
|
|
$options = implode('|', $options); |
|
440
|
|
|
$cblock->setVar('options', $options); |
|
441
|
|
|
} |
|
442
|
|
|
$cblock->setVar('bid', 0); |
|
443
|
|
|
$cblock->setVar('block_type', $block_type == 'C' ? 'C' : 'D'); |
|
444
|
|
|
$cblock->setVar('func_num', 255); |
|
445
|
|
|
$newid = $cblock->store(); |
|
446
|
|
|
if (!$newid) { |
|
447
|
|
|
xoops_cp_header(); |
|
448
|
|
|
$cblock->getHtmlErrors(); |
|
449
|
|
|
xoops_cp_footer(); |
|
450
|
|
|
exit(); |
|
451
|
|
|
} |
|
452
|
|
|
/* |
|
|
|
|
|
|
453
|
|
|
if ($cblock->getVar('template') != '') { |
|
454
|
|
|
$tplfile_handler =& xoops_getHandler('tplfile'); |
|
455
|
|
|
$btemplate =& $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid); |
|
456
|
|
|
if (count($btemplate) > 0) { |
|
457
|
|
|
$tplclone =& $btemplate[0]->clone(); |
|
458
|
|
|
$tplclone->setVar('tpl_id', 0); |
|
459
|
|
|
$tplclone->setVar('tpl_refid', $newid); |
|
460
|
|
|
$tplman->insert($tplclone); |
|
461
|
|
|
} |
|
462
|
|
|
} |
|
463
|
|
|
*/ |
|
464
|
|
|
$db =& XoopsDatabaseFactory::getDatabaseConnection(); |
|
465
|
|
|
$bmodule = (isset($_POST['bmodule']) && is_array($_POST['bmodule'])) ? $_POST['bmodule'] : array(-1); // GIJ + |
|
466
|
|
|
foreach( $bmodule as $bmid ) { |
|
467
|
|
|
$sql = 'INSERT INTO ' . $db->prefix('block_module_link') . " (block_id, module_id) VALUES ('{$newid}', '{$bmid}')"; |
|
468
|
|
|
$db->query($sql); |
|
469
|
|
|
} |
|
470
|
|
|
|
|
471
|
|
|
/* global $xoopsUser; |
|
|
|
|
|
|
472
|
|
|
$groups =& $xoopsUser->getGroups(); |
|
473
|
|
|
$count = count($groups); |
|
474
|
|
|
for ($i = 0; $i < $count; $i++) { |
|
475
|
|
|
$sql = "INSERT INTO ".$db->prefix('group_permission')." (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (".$groups[$i].", ".$newid.", 1, 'block_read')"; |
|
476
|
|
|
$db->query($sql); |
|
477
|
|
|
} |
|
478
|
|
|
*/ |
|
479
|
|
|
|
|
480
|
|
|
$sql = 'SELECT gperm_groupid FROM ' . $db->prefix('group_permission') . " WHERE gperm_name='block_read' AND gperm_modid='1' AND gperm_itemid='{$bid}'"; |
|
481
|
|
|
$result = $db->query($sql); |
|
482
|
|
|
while (list($gid) = $db->fetchRow($result)) { |
|
483
|
|
|
$sql = 'INSERT INTO ' . $db->prefix('group_permission') . " (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES ({$gid}, {$newid}, 1, 'block_read')"; |
|
484
|
|
|
$db->query($sql); |
|
485
|
|
|
} |
|
486
|
|
|
|
|
487
|
|
|
redirect_header('myblocksadmin.php', 1, _AM_DBUPDATED); |
|
488
|
|
|
} |
|
489
|
|
|
|
|
490
|
|
|
// import from modules/system/admin/blocksadmin/blocksadmin.php |
|
491
|
|
|
function myblocksadmin_update_block($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $bmodule, $options=array()) |
|
|
|
|
|
|
492
|
|
|
{ |
|
493
|
|
|
global $xoopsConfig; |
|
|
|
|
|
|
494
|
|
|
/* |
|
|
|
|
|
|
495
|
|
|
if (empty($bmodule)) { |
|
496
|
|
|
xoops_cp_header(); |
|
497
|
|
|
xoops_error(sprintf(_AM_NOTSELNG, _AM_MYLINKS_VISIBLEIN)); |
|
498
|
|
|
xoops_cp_footer(); |
|
499
|
|
|
exit(); |
|
500
|
|
|
} |
|
501
|
|
|
*/ |
|
502
|
|
|
$myblock = new XoopsBlock($bid); |
|
503
|
|
|
//$myblock->setVar('side', $bside); GIJ - |
|
|
|
|
|
|
504
|
|
|
if ($bside >= 0) { |
|
505
|
|
|
$myblock->setVar('side', $bside); // GIJ + |
|
506
|
|
|
} |
|
507
|
|
|
$myblock->setVar('weight', $bweight); |
|
508
|
|
|
$myblock->setVar('visible', $bvisible); |
|
509
|
|
|
$myblock->setVar('title', $btitle); |
|
510
|
|
|
if (isset($bcontent)) { |
|
511
|
|
|
$myblock->setVar('content', $bcontent); |
|
512
|
|
|
} |
|
513
|
|
|
if (isset($bctype)) { |
|
514
|
|
|
$myblock->setVar('c_type', $bctype); |
|
515
|
|
|
} |
|
516
|
|
|
$myblock->setVar('bcachetime', $bcachetime); |
|
517
|
|
View Code Duplication |
if (isset($options) && (count($options) > 0)) { |
|
|
|
|
|
|
518
|
|
|
$options = implode('|', $options); |
|
519
|
|
|
$myblock->setVar('options', $options); |
|
520
|
|
|
} |
|
521
|
|
|
if ('C' == $myblock->getVar('block_type')) { |
|
522
|
|
|
switch ($myblock->getVar('c_type')) { |
|
523
|
|
|
case 'H': |
|
524
|
|
|
$name = _AM_CUSTOMHTML; |
|
525
|
|
|
break; |
|
526
|
|
|
case 'P': |
|
527
|
|
|
$name = _AM_CUSTOMPHP; |
|
528
|
|
|
break; |
|
529
|
|
|
case 'S': |
|
530
|
|
|
$name = _AM_CUSTOMSMILE; |
|
531
|
|
|
break; |
|
532
|
|
|
default: |
|
533
|
|
|
$name = _AM_CUSTOMNOSMILE; |
|
534
|
|
|
break; |
|
535
|
|
|
} |
|
536
|
|
|
$myblock->setVar('name', $name); |
|
537
|
|
|
} |
|
538
|
|
|
$msg = _AM_DBUPDATED; |
|
539
|
|
|
if (false != $myblock->store()) { |
|
540
|
|
|
$db =& XoopsDatabaseFactory::getDatabaseConnection(); |
|
541
|
|
|
$sql = sprintf('DELETE FROM %s WHERE block_id = %u', $db->prefix('block_module_link'), $bid); |
|
542
|
|
|
$db->query($sql); |
|
543
|
|
|
foreach ($bmodule as $bmid) { |
|
544
|
|
|
$sql = sprintf('INSERT INTO %s (block_id, module_id) VALUES (%u, %d)', $db->prefix('block_module_link'), $bid, intval($bmid)); |
|
545
|
|
|
$db->query($sql); |
|
546
|
|
|
} |
|
547
|
|
|
include_once XOOPS_ROOT_PATH.'/class/template.php'; |
|
548
|
|
|
$xoopsTpl = new XoopsTpl(); |
|
549
|
|
|
//$xoopsTpl->xoops_setCaching(2); |
|
|
|
|
|
|
550
|
|
|
$xoopsTpl->caching=2; |
|
551
|
|
|
if ('' != $myblock->getVar('template')) { |
|
552
|
|
|
if ($xoopsTpl->is_cached('db:'.$myblock->getVar('template'))) { |
|
553
|
|
|
if (!$xoopsTpl->clear_cache('db:'.$myblock->getVar('template'))) { |
|
554
|
|
|
$msg = "Unable to clear cache for block ID: {$bid}"; |
|
555
|
|
|
} |
|
556
|
|
|
} |
|
557
|
|
|
} else { |
|
558
|
|
|
if ($xoopsTpl->is_cached('db:system_dummy.html', 'block'.$bid)) { |
|
559
|
|
|
if (!$xoopsTpl->clear_cache('db:system_dummy.html', 'block'.$bid)) { |
|
560
|
|
|
$msg = 'Unable to clear cache for block ID'.$bid; |
|
561
|
|
|
} |
|
562
|
|
|
} |
|
563
|
|
|
} |
|
564
|
|
|
} else { |
|
565
|
|
|
$msg = "Failed update of block. ID: {$bid}"; |
|
566
|
|
|
} |
|
567
|
|
|
// redirect_header('admin.php?fct=blocksadmin&t='.time(),1,$msg); |
|
|
|
|
|
|
568
|
|
|
// exit(); GIJ - |
|
|
|
|
|
|
569
|
|
|
return $msg; // GIJ + |
|
570
|
|
|
} |
|
571
|
|
|
|
|
572
|
|
|
// update block instance for 2.2 |
|
573
|
|
|
function myblocksadmin_update_blockinstance($id, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $bmodule, $options=array(), $bid=null) |
|
|
|
|
|
|
574
|
|
|
{ |
|
575
|
|
|
global $xoopsDB; |
|
|
|
|
|
|
576
|
|
|
|
|
577
|
|
|
$instance_handler =& xoops_getHandler('blockinstance'); |
|
578
|
|
|
$block_handler =& xoops_getHandler('block'); |
|
579
|
|
|
if ($id > 0) { |
|
580
|
|
|
// update |
|
581
|
|
|
$instance =& $instance_handler->get($id); |
|
582
|
|
|
if ($bside >= 0) { |
|
583
|
|
|
$instance->setVar('side', $bside); |
|
584
|
|
|
} |
|
585
|
|
|
if (!empty($options)) { |
|
586
|
|
|
$instance->setVar('options', $options); |
|
587
|
|
|
} |
|
588
|
|
|
} else { |
|
589
|
|
|
// insert |
|
590
|
|
|
$instance =& $instance_handler->create(); |
|
591
|
|
|
$instance->setVar('bid', $bid); |
|
592
|
|
|
$instance->setVar('side', $bside); |
|
593
|
|
|
$block = $block_handler->get($bid); |
|
594
|
|
|
$instance->setVar('options', $block->getVar('options')); |
|
595
|
|
|
if(empty($btitle)) { |
|
596
|
|
|
$btitle = $block->getVar('name'); |
|
597
|
|
|
} |
|
598
|
|
|
} |
|
599
|
|
|
$instance->setVar('weight', $bweight); |
|
600
|
|
|
$instance->setVar('visible', $bvisible); |
|
601
|
|
|
$instance->setVar('title', $btitle); |
|
602
|
|
|
//if (isset($bcontent)) $instance->setVar('content', $bcontent); |
|
|
|
|
|
|
603
|
|
|
//if (isset($bctype)) $instance->setVar('c_type', $bctype); |
|
|
|
|
|
|
604
|
|
|
$instance->setVar('bcachetime', $bcachetime); |
|
605
|
|
|
|
|
606
|
|
|
if ($instance_handler->insert($instance)) { |
|
607
|
|
|
$GLOBALS['xoopsDB']->query('DELETE FROM ' . $GLOBALS['xoopsDB']->prefix('block_module_link') . ' WHERE block_id=' . $instance->getVar('instanceid')); |
|
608
|
|
|
foreach ($bmodule as $mid) { |
|
609
|
|
|
$page = explode('-', $mid); |
|
610
|
|
|
$mid = $page[0]; |
|
611
|
|
|
$pageid = $page[1]; |
|
612
|
|
|
$GLOBALS['xoopsDB']->query('INSERT INTO ' . $GLOBALS['xoopsDB']->prefix('block_module_link') . ' VALUES (' . $instance->getVar('instanceid') . ', ' . intval($mid) . ', ' . intval($pageid) . ')'); |
|
613
|
|
|
} |
|
614
|
|
|
|
|
615
|
|
|
return _MD_MYLINKS_AM_DBUPDATED; |
|
616
|
|
|
} |
|
617
|
|
|
|
|
618
|
|
|
return "Failed update of block instance. ID: {$id}"; |
|
619
|
|
|
|
|
620
|
|
|
/* // NAME for CUSTOM BLOCK |
|
|
|
|
|
|
621
|
|
|
if ( $instance->getVar('block_type') == 'C') { |
|
622
|
|
|
switch ( $instance->getVar('c_type') ) { |
|
623
|
|
|
case 'H': |
|
624
|
|
|
$name = _AM_CUSTOMHTML; |
|
625
|
|
|
break; |
|
626
|
|
|
case 'P': |
|
627
|
|
|
$name = _AM_CUSTOMPHP; |
|
628
|
|
|
break; |
|
629
|
|
|
case 'S': |
|
630
|
|
|
$name = _AM_CUSTOMSMILE; |
|
631
|
|
|
break; |
|
632
|
|
|
default: |
|
633
|
|
|
$name = _AM_CUSTOMNOSMILE; |
|
634
|
|
|
break; |
|
635
|
|
|
} |
|
636
|
|
|
$instance->setVar('name', $name); |
|
637
|
|
|
} |
|
638
|
|
|
*/ |
|
639
|
|
|
/* // CLEAR TEMPLATE CACHE |
|
|
|
|
|
|
640
|
|
|
include_once XOOPS_ROOT_PATH.'/class/template.php'; |
|
641
|
|
|
$xoopsTpl = new XoopsTpl(); |
|
642
|
|
|
//$xoopsTpl->xoops_setCaching(2); |
|
643
|
|
|
$xoopsTpl->caching=2; |
|
644
|
|
|
if ($instance->getVar('template') != '') { |
|
645
|
|
|
if ($xoopsTpl->is_cached('db:'.$instance->getVar('template'))) { |
|
646
|
|
|
if (!$xoopsTpl->clear_cache('db:'.$instance->getVar('template'))) { |
|
647
|
|
|
$msg = 'Unable to clear cache for block ID'.$bid; |
|
648
|
|
|
} |
|
649
|
|
|
} |
|
650
|
|
|
} else { |
|
651
|
|
|
if ($xoopsTpl->is_cached('db:system_dummy.html', 'block'.$bid)) { |
|
652
|
|
|
if (!$xoopsTpl->clear_cache('db:system_dummy.html', 'block'.$bid)) { |
|
653
|
|
|
$msg = 'Unable to clear cache for block ID'.$bid; |
|
654
|
|
|
} |
|
655
|
|
|
} |
|
656
|
|
|
} |
|
657
|
|
|
*/ |
|
658
|
|
|
} |
|
659
|
|
|
|
|
660
|
|
|
// TODO edit2, delete2, customblocks |
|
661
|
|
|
|
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.