mambax7 /
pedigree
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
|
0 ignored issues
–
show
|
|||
| 2 | require_once 'wizard.php'; |
||
| 3 | |||
| 4 | /** |
||
| 5 | * Class CheckoutWizard |
||
| 6 | */ |
||
| 7 | class CheckoutWizard extends ZervWizard |
||
| 8 | { |
||
| 9 | function CheckoutWizard() |
||
| 10 | { |
||
| 11 | global $field; |
||
| 12 | // start the session and initialize the wizard |
||
| 13 | if (!isset($_SESSION)) { |
||
| 14 | session_start(); |
||
| 15 | } |
||
| 16 | parent::ZervWizard($_SESSION, __CLASS__); |
||
| 17 | |||
| 18 | $this->addStep('Fieldname', _MA_PEDIGREE_ENTER_FIELD); |
||
| 19 | if ($this->getValue('field') == 0) { //only for a new field |
||
| 20 | $this->addStep('Fieldtype', _MA_PEDIGREE_FIELD_TYP_SEL); |
||
| 21 | if ($this->getValue('fieldtype') == 'selectbox' || $this->getValue('fieldtype') == 'radiobutton') { |
||
| 22 | $this->addStep('lookup', _MA_PEDIGREE_FIELD_ADD_VALUE); |
||
| 23 | } |
||
| 24 | } |
||
| 25 | |||
| 26 | $this->addStep('Settings', _MA_PEDIGREE_FIELD_PARAM); |
||
| 27 | if ($this->getValue('hassearch') == 'hassearch') { |
||
| 28 | $this->addStep('search', _MA_PEDIGREE_SEARCH_PARAMFIELD); |
||
| 29 | } |
||
| 30 | if ($this->getValue('fieldtype') != 'picture') { |
||
| 31 | $this->addStep('defaultvalue', _MA_PEDIGREE_FIELD_DEFAUT); |
||
| 32 | } |
||
| 33 | $this->addStep('confirm', _MA_PEDIGREE_FIELDCONFIRM); |
||
| 34 | } |
||
| 35 | |||
| 36 | function prepare_Fieldname() |
||
| 37 | { |
||
| 38 | global $xoopsDB, $field; |
||
| 39 | if (!$field == 0) // field allready exists (editing mode) |
||
| 40 | { |
||
| 41 | $sql = "SELECT * from " . $xoopsDB->prefix("pedigree_fields") . " WHERE ID=" . $field; |
||
| 42 | $result = $xoopsDB->query($sql); |
||
| 43 | while ($row = $xoopsDB->fetchArray($result)) { |
||
| 44 | $name = $row['FieldName']; |
||
| 45 | $fieldexplenation = $row['FieldExplenation']; |
||
| 46 | $fieldtype = $row['FieldType']; |
||
| 47 | } |
||
| 48 | $this->setValue('name', $name); |
||
| 49 | $this->setValue('explain', $fieldexplenation); |
||
| 50 | //set the fieldtype because we wont allow it to be edited |
||
| 51 | $this->setValue('fieldtype', $fieldtype); |
||
| 52 | |||
| 53 | } |
||
| 54 | $this->setValue('field', $field); //is it a new field or are we editing a field |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @param $form |
||
| 59 | * |
||
| 60 | * @return bool |
||
| 61 | */ |
||
| 62 | function process_Fieldname(&$form) |
||
| 63 | { |
||
| 64 | $name = $this->coalesce($form['name']); |
||
| 65 | if (strlen($name) > 0) { |
||
| 66 | $this->setValue('name', $name); |
||
| 67 | } else { |
||
| 68 | $this->addError('name', _MA_PEDIGREE_FIELD_NAM); |
||
| 69 | } |
||
| 70 | |||
| 71 | $fieldexplenation = $this->coalesce($form['explain']); |
||
| 72 | if (strlen($fieldexplenation) > 0) { |
||
| 73 | $this->setValue('explain', $fieldexplenation); |
||
| 74 | } else { |
||
| 75 | $this->addError('explain', _MA_PEDIGREE_FIELD_EXPLAN1); |
||
| 76 | } |
||
| 77 | |||
| 78 | return !$this->isError(); |
||
| 79 | } |
||
| 80 | |||
| 81 | function prepare_Fieldtype() |
||
| 82 | { |
||
| 83 | $this->fieldtype[] = array('value' => "radiobutton", 'description' => "Radiobutton"); |
||
| 84 | $this->fieldtype[] = array('value' => "selectbox", 'description' => _MA_PEDIGREE_DROPDOWNFIELD); |
||
| 85 | $this->fieldtype[] = array('value' => "textbox", 'description' => _MA_PEDIGREE_TEXTBOXFIELD); |
||
| 86 | $this->fieldtype[] = array('value' => "textarea", 'description' => _MA_PEDIGREE_TEXTAREAFIELD); |
||
| 87 | $this->fieldtype[] = array('value' => "dateselect", 'description' => _MA_PEDIGREE_DATEFIELD); |
||
| 88 | $this->fieldtype[] = array('value' => "urlfield", 'description' => _MA_PEDIGREE_URLFIELD); |
||
| 89 | } |
||
| 90 | |||
| 91 | /** |
||
| 92 | * @param $form |
||
| 93 | * |
||
| 94 | * @return bool |
||
| 95 | */ |
||
| 96 | function process_Fieldtype(&$form) |
||
| 97 | { |
||
| 98 | $this->prepare_Fieldtype(); |
||
| 99 | $fieldtype = $this->coalesce($form['fieldtype']); |
||
| 100 | $this->setValue('fieldtype', $fieldtype); |
||
| 101 | |||
| 102 | return !$this->isError(); |
||
| 103 | } |
||
| 104 | |||
| 105 | /** |
||
| 106 | * @param $form |
||
| 107 | * |
||
| 108 | * @return bool |
||
| 109 | */ |
||
| 110 | function process_lookup(&$form) |
||
| 111 | { |
||
| 112 | |||
| 113 | $fc = $this->coalesce($form['fc']); |
||
| 114 | $this->setValue('fc', $fc); |
||
| 115 | $lookup = $this->coalesce($form['lookup' . $fc]); |
||
| 116 | $lookupid = $this->coalesce($form['id' . $fc]); |
||
| 117 | if (strlen($lookup) > 0) { |
||
| 118 | $this->setValue('lookup' . $fc, $lookup); |
||
| 119 | $this->setValue('id' . $fc, $lookupid); |
||
| 120 | } |
||
| 121 | $lastlookup = $this->getValue('lookup' . $fc); |
||
| 122 | if ($lastlookup == "") { |
||
| 123 | $this->setValue('fc', $fc - 1); |
||
| 124 | } |
||
| 125 | |||
| 126 | for ($i = 0; $i < $fc; ++$i) { |
||
| 127 | $radioarray[] = array('id' => $this->getValue('id' . ($i+1)), 'value' => $this->getValue('lookup' . ($i+1))); |
||
| 128 | } |
||
| 129 | //print_r($radioarray); die(); |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
80% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. Loading history...
|
|||
| 130 | $this->setValue('radioarray', $radioarray); |
||
| 131 | |||
| 132 | return !$this->isError(); |
||
| 133 | // |
||
| 134 | } |
||
| 135 | |||
| 136 | function prepare_Settings() |
||
| 137 | { |
||
| 138 | global $xoopsDB; |
||
| 139 | if (!$this->getValue('field') == 0) // field allready exists (editing mode) |
||
| 140 | { |
||
| 141 | { |
||
| 142 | $sql = "SELECT * from " . $xoopsDB->prefix("pedigree_fields") . " WHERE ID='" . $this->getValue('field') . "'"; |
||
| 143 | } |
||
| 144 | $result = $xoopsDB->query($sql); |
||
| 145 | while ($row = $xoopsDB->fetchArray($result)) { |
||
| 146 | $hs = $row['HasSearch']; |
||
| 147 | if ($hs == "1") { |
||
| 148 | $this->setValue('hassearch', "hassearch"); |
||
| 149 | } |
||
| 150 | $vip = $row['ViewInPedigree']; |
||
| 151 | if ($vip == "1") { |
||
| 152 | $this->setValue('viewinpedigree', "viewinpedigree"); |
||
| 153 | } |
||
| 154 | $via = $row['ViewInAdvanced']; |
||
| 155 | if ($via == "1") { |
||
| 156 | $this->setValue('viewinadvanced', "viewinadvanced"); |
||
| 157 | } |
||
| 158 | $vipie = $row['ViewInPie']; |
||
| 159 | if ($vipie == "1") { |
||
| 160 | $this->setValue('viewinpie', "viewinpie"); |
||
| 161 | } |
||
| 162 | $vil = $row['ViewInList']; |
||
| 163 | if ($vil == "1") { |
||
| 164 | $this->setValue('viewinlist', "viewinlist"); |
||
| 165 | } |
||
| 166 | $lit = $row['Litter']; |
||
| 167 | if ($lit == "1") { |
||
| 168 | $this->setValue('Litter', "Litter"); |
||
| 169 | } |
||
| 170 | $Glit = $row['Generallitter']; |
||
| 171 | if ($Glit == "1") { |
||
| 172 | $this->setValue('Generallitter', "Generallitter"); |
||
| 173 | } |
||
| 174 | } |
||
| 175 | } |
||
| 176 | } |
||
| 177 | |||
| 178 | /** |
||
| 179 | * @param $form |
||
| 180 | * |
||
| 181 | * @return bool |
||
| 182 | */ |
||
| 183 | function process_Settings(&$form) |
||
| 184 | { |
||
| 185 | $hassearch = $this->coalesce($form['hassearch']); |
||
| 186 | $this->setValue('hassearch', $hassearch); |
||
| 187 | $viewinpedigree = $this->coalesce($form['viewinpedigree']); |
||
| 188 | $this->setValue('viewinpedigree', $viewinpedigree); |
||
| 189 | $viewinadvanced = $this->coalesce($form['viewinadvanced']); |
||
| 190 | $this->setValue('viewinadvanced', $viewinadvanced); |
||
| 191 | $viewinpie = $this->coalesce($form['viewinpie']); |
||
| 192 | $this->setValue('viewinpie', $viewinpie); |
||
| 193 | $viewinlist = $this->coalesce($form['viewinlist']); |
||
| 194 | $this->setValue('viewinlist', $viewinlist); |
||
| 195 | $Litter = $this->coalesce($form['Litter']); |
||
| 196 | $this->setValue('Litter', $Litter); |
||
| 197 | $Generallitter = $this->coalesce($form['Generallitter']); |
||
| 198 | $this->setValue('Generallitter', $Generallitter); |
||
| 199 | |||
| 200 | //if both litter and general litter are set; unset one of them |
||
| 201 | if ($this->getValue('Litter') == "Litter" && $this->getValue('Generallitter') == "Generallitter") { |
||
| 202 | $this->setValue('Generallitter', 0); |
||
| 203 | } |
||
| 204 | |||
| 205 | return !$this->isError(); |
||
| 206 | } |
||
| 207 | |||
| 208 | function prepare_search() |
||
| 209 | { |
||
| 210 | global $xoopsDB; |
||
| 211 | if (!$this->getValue('field') == 0) // field allready exists (editing mode) |
||
| 212 | { |
||
| 213 | $sql = "SELECT * from " . $xoopsDB->prefix("pedigree_fields") . " WHERE ID=" . $this->getValue('field'); |
||
| 214 | $result = $xoopsDB->query($sql); |
||
| 215 | while ($row = $xoopsDB->fetchArray($result)) { |
||
| 216 | if ($this->getValue('hassearch') == "hassearch") { |
||
| 217 | $searchname = $row['SearchName']; |
||
| 218 | $this->setValue('searchname', $searchname); |
||
| 219 | $searchexplain = $row['SearchExplenation']; |
||
| 220 | $this->setValue('searchexplain', $searchexplain); |
||
| 221 | } |
||
| 222 | } |
||
| 223 | } |
||
| 224 | } |
||
| 225 | |||
| 226 | /** |
||
| 227 | * @param $form |
||
| 228 | * |
||
| 229 | * @return bool |
||
| 230 | */ |
||
| 231 | function process_search(&$form) |
||
| 232 | { |
||
| 233 | $searchname = $this->coalesce($form['searchname']); |
||
| 234 | if (strlen($searchname) > 0) { |
||
| 235 | $this->setValue('searchname', $searchname); |
||
| 236 | } else { |
||
| 237 | $this->addError('searchname', 'Please enter the searchname'); |
||
| 238 | } |
||
| 239 | |||
| 240 | $fieldexplenation = $this->coalesce($form['searchexplain']); |
||
| 241 | if (strlen($fieldexplenation) > 0) { |
||
| 242 | $this->setValue('searchexplain', $fieldexplenation); |
||
| 243 | } else { |
||
| 244 | $this->addError('searchexplain', 'Please enter the search explanation for this field'); |
||
| 245 | } |
||
| 246 | |||
| 247 | return !$this->isError(); |
||
| 248 | } |
||
| 249 | |||
| 250 | function prepare_defaultvalue() |
||
| 251 | { |
||
| 252 | global $xoopsDB; |
||
| 253 | if (!$this->getValue('field') == 0) // field allready exists (editing mode) |
||
| 254 | { |
||
| 255 | $sql = "SELECT * from " . $xoopsDB->prefix("pedigree_fields") . " WHERE ID=" . $this->getValue('field'); |
||
| 256 | $result = $xoopsDB->query($sql); |
||
| 257 | while ($row = $xoopsDB->fetchArray($result)) { |
||
| 258 | $def = $row['DefaultValue']; |
||
| 259 | $this->setValue('defaultvalue', $def); |
||
| 260 | if ($row['LookupTable'] == "1") { //we have a lookup table; load values |
||
| 261 | $sql = "SELECT * from " . $xoopsDB->prefix("pedigree_lookup" . $this->getValue('field')) . " order by 'order'"; |
||
| 262 | $fc = 0; |
||
| 263 | $result = $xoopsDB->query($sql); |
||
| 264 | View Code Duplication | while ($row = $xoopsDB->fetchArray($result)) { |
|
| 265 | $radioarray[] = array('id' => $row['ID'], 'value' => $row['value']); |
||
| 266 | ++$fc; |
||
| 267 | } |
||
| 268 | $this->setValue('radioarray', $radioarray); |
||
| 269 | $this->setValue('fc', $fc); |
||
| 270 | } |
||
| 271 | } |
||
| 272 | |||
| 273 | } |
||
| 274 | } |
||
| 275 | |||
| 276 | /** |
||
| 277 | * @param $form |
||
| 278 | * |
||
| 279 | * @return bool |
||
| 280 | */ |
||
| 281 | function process_defaultvalue(&$form) |
||
| 282 | { |
||
| 283 | $defaultvalue = $this->coalesce($form['defaultvalue']); |
||
| 284 | if (strlen($defaultvalue) >= 0) { |
||
| 285 | $this->setValue('defaultvalue', $defaultvalue); |
||
| 286 | } else { |
||
| 287 | $this->addError('defaultvalue', 'Please enter a defaultvalue'); |
||
| 288 | } |
||
| 289 | |||
| 290 | return !$this->isError(); |
||
| 291 | } |
||
| 292 | |||
| 293 | /** |
||
| 294 | * @param $form |
||
| 295 | * |
||
| 296 | * @return bool |
||
| 297 | */ |
||
| 298 | function process_confirm(&$form) |
||
| 299 | { |
||
| 300 | return !$this->isError(); |
||
| 301 | } |
||
| 302 | |||
| 303 | function completeCallback() |
||
| 304 | { |
||
| 305 | global $xoopsDB; |
||
| 306 | //can this field be searched |
||
| 307 | $search = $this->getValue('hassearch'); |
||
| 308 | if ($search == "hassearch") { |
||
| 309 | $search = "1"; |
||
| 310 | $searchname = $this->getValue('searchname'); |
||
| 311 | $searchexplain = $this->getValue('searchexplain'); |
||
| 312 | } else { |
||
| 313 | $search = "0"; |
||
| 314 | $searchname = ""; |
||
| 315 | $searchexplain = ""; |
||
| 316 | } |
||
| 317 | //show in pedigree |
||
| 318 | $viewinpedigree = $this->getValue('viewinpedigree'); |
||
| 319 | if ($viewinpedigree == "viewinpedigree") { |
||
| 320 | $viewinpedigree = "1"; |
||
| 321 | } else { |
||
| 322 | $viewinpedigree = "0"; |
||
| 323 | } |
||
| 324 | //show in advanced |
||
| 325 | $viewinadvanced = $this->getValue('viewinadvanced'); |
||
| 326 | if ($viewinadvanced == "viewinadvanced") { |
||
| 327 | $viewinadvanced = "1"; |
||
| 328 | } else { |
||
| 329 | $viewinadvanced = "0"; |
||
| 330 | } |
||
| 331 | //show in pie |
||
| 332 | $viewinpie = $this->getValue('viewinpie'); |
||
| 333 | if ($viewinpie == "viewinpie") { |
||
| 334 | $viewinpie = "1"; |
||
| 335 | } else { |
||
| 336 | $viewinpie = "0"; |
||
| 337 | } |
||
| 338 | //view in list |
||
| 339 | $viewinlist = $this->getValue('viewinlist'); |
||
| 340 | if ($viewinlist == "viewinlist") { |
||
| 341 | $viewinlist = "1"; |
||
| 342 | } else { |
||
| 343 | $viewinlist = "0"; |
||
| 344 | } |
||
| 345 | //add a litter |
||
| 346 | $Litter = $this->getValue('Litter'); |
||
| 347 | if ($Litter == "Litter") { |
||
| 348 | $Litter = "1"; |
||
| 349 | } else { |
||
| 350 | $Litter = "0"; |
||
| 351 | } |
||
| 352 | //general litter |
||
| 353 | $Generallitter = $this->getValue('Generallitter'); |
||
| 354 | if ($Generallitter == "Generallitter") { |
||
| 355 | $Generallitter = "1"; |
||
| 356 | } else { |
||
| 357 | $Generallitter = "0"; |
||
| 358 | } |
||
| 359 | |||
| 360 | if (!$this->getValue('field') == 0) // field allready exists (editing mode) |
||
| 361 | { |
||
| 362 | $sql = "UPDATE " . $xoopsDB->prefix("pedigree_fields") . " SET FieldName = '" . htmlSpecialChars($this->getValue('name')) . "', FieldType = '" . $this->getValue('fieldtype') |
||
| 363 | . "', DefaultValue = '" . $this->getValue('defaultvalue') . "', FieldExplenation = '" . $this->getValue('explain') . "', HasSearch = '" . $search . "', Litter = '" . $Litter |
||
| 364 | . "', Generallitter = '" . $Generallitter . "', SearchName = '" . $searchname . "', SearchExplenation = '" . $searchexplain . "', ViewInPedigree = '" . $viewinpedigree |
||
| 365 | . "', ViewInAdvanced = '" . $viewinadvanced . "', ViewInPie = '" . $viewinpie . "', ViewInList = '" . $viewinlist . "' WHERE ID ='" . $this->getValue('field') . "'"; |
||
| 366 | $xoopsDB->queryF($sql); |
||
| 367 | //possible change defaultvalue for userfield |
||
| 368 | $sql |
||
| 369 | = "ALTER TABLE " . $xoopsDB->prefix("pedigree_tree") . " CHANGE `user" . $this->getValue('field') . "` `user" . $this->getValue( |
||
| 370 | 'field' |
||
| 371 | ) . "` VARCHAR( 255 ) NOT NULL DEFAULT '" . $this->getValue('defaultvalue') . "'"; |
||
| 372 | $xoopsDB->queryF($sql); |
||
| 373 | $sql |
||
| 374 | = "ALTER TABLE " . $xoopsDB->prefix("pedigree_temp") . " CHANGE `user" . $this->getValue('field') . "` `user" . $this->getValue( |
||
| 375 | 'field' |
||
| 376 | ) . "` VARCHAR( 1024 ) NOT NULL DEFAULT '" . $this->getValue('defaultvalue') . "'"; |
||
| 377 | $xoopsDB->queryF($sql); |
||
| 378 | $sql = "ALTER TABLE " . $xoopsDB->prefix("pedigree_trash") . " CHANGE `user" . $this->getValue('field') . "` `user" . $this->getValue( |
||
| 379 | 'field' |
||
| 380 | ) . "` VARCHAR( 255 ) NOT NULL DEFAULT '" . $this->getValue('defaultvalue') . "'"; |
||
| 381 | $xoopsDB->queryF($sql); |
||
| 382 | } else { //this is a new field |
||
| 383 | $sql = "SELECT MAX(ID) AS lid from " . $xoopsDB->prefix("pedigree_fields") . " LIMIT 1"; |
||
| 384 | $result = $xoopsDB->query($sql); |
||
| 385 | while ($row = $xoopsDB->fetchArray($result)) { |
||
| 386 | $nextfieldnum = $row['lid'] + 1; |
||
| 387 | } |
||
| 388 | //add userfield to various tables as a new field. |
||
| 389 | //allways add at the end of the table |
||
| 390 | $tables = array('pedigree_tree', 'pedigree_temp', 'pedigree_trash'); |
||
| 391 | foreach ($tables as $table) { |
||
| 392 | $SQL = "ALTER TABLE " . $xoopsDB->prefix($table) . " ADD `user" . $nextfieldnum . "` VARCHAR( 255 ) NOT NULL DEFAULT '" . $this->getValue( |
||
| 393 | 'defaultvalue' |
||
| 394 | ) . "'"; |
||
| 395 | $xoopsDB->queryF($SQL); |
||
| 396 | } |
||
| 397 | //is a lookup table present |
||
| 398 | $lookup = $this->getValue('lookup1'); |
||
| 399 | if ($lookup == "") { |
||
| 400 | $lookup = "0"; |
||
| 401 | } else { |
||
| 402 | $lookup = "1"; |
||
| 403 | //create table for lookupfield |
||
| 404 | $createtable = "CREATE TABLE " . $xoopsDB->prefix("pedigree_lookup" . $nextfieldnum) . " (`ID` INT( 10 ) NOT NULL ,`value` VARCHAR( 255 ) NOT NULL, `order` INT( 10 )) ENGINE = MyISAM"; |
||
| 405 | $xoopsDB->queryF($createtable); |
||
| 406 | //fill table |
||
| 407 | $count = $this->getValue('fc'); |
||
| 408 | for ($x = 1; $x < $count + 1; ++$x) { |
||
| 409 | $y = $x - 1; |
||
| 410 | $sql = "INSERT INTO " . $xoopsDB->prefix("pedigree_lookup" . $nextfieldnum) . " ( `ID` , `value`, `order`) VALUES ('" . $y . "', '" . $this->getValue('lookup' . $x) . "','" . $y |
||
| 411 | . "')"; |
||
| 412 | $xoopsDB->queryF($sql); |
||
| 413 | } |
||
| 414 | |||
| 415 | } |
||
| 416 | |||
| 417 | //Insert new record into pedigree_config |
||
| 418 | $sql = "INSERT INTO " . $xoopsDB->prefix("pedigree_fields") . " VALUES ('" . $nextfieldnum . "', '1', '" . htmlSpecialChars( |
||
| 419 | $this->getValue('name') |
||
| 420 | ) . "', '" . $this->getValue('fieldtype') . "', '" . $lookup . "', '" . $this->getValue('defaultvalue') . "', '" . $this->getValue( |
||
| 421 | 'explain' |
||
| 422 | ) . "', '" . $search . "', '" . $Litter . "', '" . $Generallitter . "', '" . $searchname . "', '" . $searchexplain . "', '" . $viewinpedigree . "', '" . $viewinadvanced . "', '" |
||
| 423 | . $viewinpie . "', '" . $viewinlist . "','','" . $nextfieldnum . "')"; |
||
| 424 | $xoopsDB->queryF($sql); |
||
| 425 | } |
||
| 426 | } |
||
| 427 | |||
| 428 | /** |
||
| 429 | * Miscellaneous utility functions |
||
| 430 | * |
||
| 431 | * @param $email |
||
| 432 | * |
||
| 433 | * @return int |
||
| 434 | */ |
||
| 435 | |||
| 436 | function isValidEmail($email) |
||
| 437 | { |
||
| 438 | return preg_match('/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$/i', $email); |
||
| 439 | } |
||
| 440 | } |
||
| 441 |
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.