XoopsModules25x /
xoopstube
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 | /** |
||
| 3 | * |
||
| 4 | * You may not change or alter any portion of this comment or credits |
||
| 5 | * of supporting developers from this source code or any supporting source code |
||
| 6 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 7 | * This program is distributed in the hope that it will be useful, |
||
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 10 | * |
||
| 11 | * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ |
||
| 12 | * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||
| 13 | * @package |
||
| 14 | * @since 2.5.9 |
||
| 15 | * @author Michael Beck (aka Mamba) |
||
| 16 | */ |
||
| 17 | |||
| 18 | require_once __DIR__ . '/../../../mainfile.php'; |
||
| 19 | |||
| 20 | if (!isset($moduleDirName)) { |
||
| 21 | $moduleDirName = basename(dirname(__DIR__)); |
||
| 22 | } |
||
| 23 | |||
| 24 | $op = \Xmf\Request::getCmd('op', ''); |
||
| 25 | |||
| 26 | switch ($op) { |
||
| 27 | case 'load': |
||
| 28 | loadSampleData(); |
||
| 29 | break; |
||
| 30 | } |
||
| 31 | |||
| 32 | // XMF TableLoad for SAMPLE data |
||
| 33 | |||
| 34 | function loadSampleData() |
||
| 35 | { |
||
| 36 | xoops_loadLanguage('admin', $moduleDirName); |
||
|
0 ignored issues
–
show
The variable
$moduleDirName does not exist. Did you forget to declare it?
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug. Loading history...
|
|||
| 37 | $items = \Xmf\Yaml::readWrapped('item-data.yml'); |
||
| 38 | $cat = \Xmf\Yaml::readWrapped('cat-data.yml'); |
||
| 39 | |||
| 40 | \Xmf\Database\TableLoad::truncateTable('xoopstube_videos'); |
||
| 41 | \Xmf\Database\TableLoad::truncateTable('xoopstube_cat'); |
||
| 42 | |||
| 43 | \Xmf\Database\TableLoad::loadTableFromArray('xoopstube_cat', $cat); |
||
| 44 | \Xmf\Database\TableLoad::loadTableFromArray('xoopstube_videos', $items); |
||
| 45 | |||
| 46 | redirect_header('../admin/main.php', 1, _AM_XOOPSTUBE_SAMPLEDATA_SUCCESS); |
||
| 47 | } |
||
| 48 |
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.