XoopsModules25x /
myiframe
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 | * MYIFRAME - MODULE FOR XOOPS |
||
| 5 | * Copyright (c) Hervé Thouzard of Instant Zero (http://www.instant-zero.com) |
||
| 6 | * **************************************************************************** |
||
| 7 | */ |
||
| 8 | |||
| 9 | if (!defined('XOOPS_ROOT_PATH')) { |
||
| 10 | die('XOOPS root path not defined'); |
||
| 11 | } |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Returns a module's option |
||
| 15 | * |
||
| 16 | * Return's a module's option (for the myiframe module) |
||
| 17 | * |
||
| 18 | * @package Myiframe |
||
| 19 | * @author Instant Zero (http://www.instant-zero.com) |
||
| 20 | * @copyright Instant Zero (http://www.instant-zero.com) |
||
| 21 | * @param string $option module option's name |
||
| 22 | * @param string $repmodule |
||
| 23 | * @return bool |
||
| 24 | */ |
||
| 25 | function myiframe_getmoduleoption($option, $repmodule = 'myiframe') |
||
| 26 | { |
||
| 27 | global $xoopsModuleConfig, $xoopsModule; |
||
|
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
Loading history...
|
|||
| 28 | static $tbloptions = array(); |
||
| 29 | if (is_array($tbloptions) && array_key_exists($option, $tbloptions)) { |
||
| 30 | return $tbloptions[$option]; |
||
| 31 | } |
||
| 32 | |||
| 33 | $retval = false; |
||
| 34 | if (isset($xoopsModuleConfig) && (is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $repmodule && $xoopsModule->getVar('isactive'))) { |
||
| 35 | if (isset($xoopsModuleConfig[$option])) { |
||
| 36 | $retval = $xoopsModuleConfig[$option]; |
||
| 37 | } |
||
| 38 | } else { |
||
| 39 | $moduleHandler = xoops_getHandler('module'); |
||
| 40 | $module = $moduleHandler->getByDirname($repmodule); |
||
| 41 | $configHandler = xoops_getHandler('config'); |
||
| 42 | if ($module) { |
||
| 43 | $moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
||
| 44 | if (isset($moduleConfig[$option])) { |
||
| 45 | $retval = $moduleConfig[$option]; |
||
| 46 | } |
||
| 47 | } |
||
| 48 | } |
||
| 49 | $tbloptions[$option] = $retval; |
||
| 50 | return $retval; |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Verify that a field exists inside a mysql table |
||
| 55 | * |
||
| 56 | * @package Myiframe |
||
| 57 | * @author Instant Zero (http://www.instant-zero.com) |
||
| 58 | * @copyright Instant Zero (http://www.instant-zero.com) |
||
| 59 | * @param $fieldname |
||
| 60 | * @param $table |
||
| 61 | * @return bool |
||
| 62 | */ |
||
| 63 | function myiframe_FieldExists($fieldname, $table) |
||
| 64 | { |
||
| 65 | global $xoopsDB; |
||
|
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
Loading history...
|
|||
| 66 | $result = $xoopsDB->queryF("SHOW COLUMNS FROM $table LIKE '$fieldname'"); |
||
| 67 | return ($xoopsDB->getRowsNum($result) > 0); |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * Set the page's title, meta description and meta keywords |
||
| 72 | * Datas are supposed to be sanitized |
||
| 73 | * |
||
| 74 | * @package Myiframe |
||
| 75 | * @author Instant Zero http://www.instant-zero.com |
||
| 76 | * @copyright (c) Instant Zero http://www.instant-zero.com |
||
| 77 | * |
||
| 78 | * @param string $page_title Page's Title |
||
| 79 | * @param string $meta_description Page's meta description |
||
| 80 | * @param string $meta_keywords Page's meta keywords |
||
| 81 | * @return none |
||
|
0 ignored issues
–
show
|
|||
| 82 | */ |
||
| 83 | function myiframe_set_metas($page_title = '', $meta_description = '', $meta_keywords = '') |
||
| 84 | { |
||
| 85 | global $xoTheme, $xoTheme, $xoopsTpl; |
||
|
0 ignored issues
–
show
Compatibility
Best Practice
introduced
by
Use of
global functionality is not recommended; it makes your code harder to test, and less reusable.
Instead of relying on 1. Pass all data via parametersfunction myFunction($a, $b) {
// Do something
}
2. Create a class that maintains your stateclass MyClass {
private $a;
private $b;
public function __construct($a, $b) {
$this->a = $a;
$this->b = $b;
}
public function myFunction() {
// Do something
}
}
Loading history...
|
|||
| 86 | $xoopsTpl->assign('xoops_pagetitle', $page_title); |
||
| 87 | if (isset($xoTheme) && is_object($xoTheme)) { |
||
| 88 | if (!empty($meta_keywords)) { |
||
| 89 | $xoTheme->addMeta('meta', 'keywords', $meta_keywords); |
||
| 90 | } |
||
| 91 | if (!empty($meta_description)) { |
||
| 92 | $xoTheme->addMeta('meta', 'description', $meta_description); |
||
| 93 | } |
||
| 94 | } elseif (isset($xoopsTpl) && is_object($xoopsTpl)) { // Compatibility for old Xoops versions |
||
| 95 | if (!empty($meta_keywords)) { |
||
| 96 | $xoopsTpl->assign('xoops_meta_keywords', $meta_keywords); |
||
| 97 | } |
||
| 98 | if (!empty($meta_description)) { |
||
| 99 | $xoopsTpl->assign('xoops_meta_description', $meta_description); |
||
| 100 | } |
||
| 101 | } |
||
| 102 | } |
||
| 103 |
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.