mambax7 /
pedigree
| 1 | <?php namespace XoopsModules\Pedigree; |
||
| 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 | |||
| 8 | This program is distributed in the hope that it will be useful, |
||
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 11 | */ |
||
| 12 | /** |
||
| 13 | * Pedigree\Breadcrumb Class |
||
| 14 | * |
||
| 15 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 16 | * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
||
| 17 | * @author lucio <[email protected]> |
||
| 18 | * @package Pedigree |
||
| 19 | * @since 1.31 |
||
| 20 | * |
||
| 21 | */ |
||
| 22 | |||
| 23 | use XoopsModules\Pedigree; |
||
|
0 ignored issues
–
show
|
|||
| 24 | |||
| 25 | |||
| 26 | /** |
||
| 27 | * Class Field |
||
| 28 | */ |
||
| 29 | class Field |
||
| 30 | { |
||
| 31 | protected $id; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @param $fieldnumber |
||
| 35 | * @param $config |
||
| 36 | */ |
||
| 37 | public function __construct($fieldnumber, $config) |
||
| 38 | { |
||
| 39 | //find key where id = $fieldnumber; |
||
| 40 | $configCount = count($config); |
||
| 41 | foreach ($config as $x => $xValue) { |
||
| 42 | //@todo - figure out if this is suppose to be an assignment or just a compare ('=' or '==') |
||
| 43 | if ($config[$x]['id'] = $fieldnumber) { |
||
| 44 | foreach ($config[$x] as $key => $value) { |
||
| 45 | $this->$key = $value; |
||
| 46 | } |
||
| 47 | } |
||
| 48 | } |
||
| 49 | $this->id = $fieldnumber; |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @return bool |
||
| 54 | */ |
||
| 55 | public function isActive() |
||
| 56 | { |
||
| 57 | return '1' == $this->getSetting('isactive'); |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return bool |
||
| 62 | */ |
||
| 63 | public function inAdvanced() |
||
| 64 | { |
||
| 65 | return '1' == $this->getSetting('viewinadvanced'); |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @return bool |
||
| 70 | */ |
||
| 71 | public function isLocked() |
||
| 72 | { |
||
| 73 | return '1' == $this->getSetting('locked'); |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @return bool |
||
| 78 | */ |
||
| 79 | public function hasSearch() |
||
| 80 | { |
||
| 81 | return '1' == $this->getSetting('hassearch'); |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @return bool |
||
| 86 | */ |
||
| 87 | public function addLitter() |
||
| 88 | { |
||
| 89 | return '1' == $this->getSetting('litter'); |
||
| 90 | } |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @return bool |
||
| 94 | */ |
||
| 95 | public function generalLitter() |
||
| 96 | { |
||
| 97 | return ('1' == $this->getSetting('generallitter')); |
||
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @return bool |
||
| 102 | */ |
||
| 103 | public function hasLookup() |
||
| 104 | { |
||
| 105 | return ('1' == $this->getSetting('lookuptable')); |
||
| 106 | } |
||
| 107 | |||
| 108 | /** |
||
| 109 | * @return string |
||
| 110 | */ |
||
| 111 | public function getSearchString() |
||
| 112 | { |
||
| 113 | return '&o=naam&p'; |
||
| 114 | } |
||
| 115 | |||
| 116 | /** |
||
| 117 | * @return bool |
||
| 118 | */ |
||
| 119 | public function inPie() |
||
| 120 | { |
||
| 121 | return ('1' == $this->getSetting('viewinpie')); |
||
| 122 | } |
||
| 123 | |||
| 124 | /** |
||
| 125 | * @return bool |
||
| 126 | */ |
||
| 127 | public function inPedigree() |
||
| 128 | { |
||
| 129 | return ('1' == $this->getSetting('viewinpedigree')); |
||
| 130 | } |
||
| 131 | |||
| 132 | /** |
||
| 133 | * @return bool |
||
| 134 | */ |
||
| 135 | public function inList() |
||
| 136 | { |
||
| 137 | return '1' == $this->getSetting('viewinlist'); |
||
| 138 | } |
||
| 139 | |||
| 140 | public function getId() |
||
| 141 | { |
||
| 142 | return $this->id; |
||
| 143 | } |
||
| 144 | |||
| 145 | /** |
||
| 146 | * @param $setting |
||
| 147 | * |
||
| 148 | * @return mixed |
||
| 149 | */ |
||
| 150 | public function getSetting($setting) |
||
| 151 | { |
||
| 152 | return $this->{$setting}; |
||
| 153 | } |
||
| 154 | |||
| 155 | /** |
||
| 156 | * @param $fieldnumber |
||
| 157 | * |
||
| 158 | * @return array |
||
| 159 | */ |
||
| 160 | public function lookupField($fieldnumber) |
||
| 161 | { |
||
| 162 | $ret = []; |
||
| 163 | |||
| 164 | /** @var \Xmf\Database\Tables $pTables */ |
||
| 165 | $pTables = new \Xmf\Database\Tables(); |
||
| 166 | $exists = $pTables->useTable('pedigree_lookup' . $fieldnumber); |
||
| 167 | if ($exists) { |
||
| 168 | $tableName = $pTables->name('pedigree_lookup' . $fieldnumber); |
||
| 169 | $SQL = "SELECT * FROM `{$tableName}` ORDER BY 'order'"; |
||
| 170 | //$SQL = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix("pedigree_lookup{$fieldnumber}") . " ORDER BY 'order'"; |
||
|
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
55% 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...
|
|||
| 171 | $result = $GLOBALS['xoopsDB']->query($SQL); |
||
| 172 | while (false !== ($row = $GLOBALS['xoopsDB']->fetchArray($result))) { |
||
| 173 | $ret[] = ['id' => $row['id'], 'value' => $row['value']]; |
||
| 174 | } |
||
| 175 | } |
||
| 176 | |||
| 177 | //array_multisort($ret,SORT_ASC); |
||
| 178 | return $ret; |
||
| 179 | } |
||
| 180 | |||
| 181 | /** |
||
| 182 | * @return \XoopsFormLabel |
||
| 183 | */ |
||
| 184 | public function viewField() |
||
| 185 | { |
||
| 186 | $view = new \XoopsFormLabel($this->fieldname, $this->value); |
||
| 187 | |||
| 188 | return $view; |
||
| 189 | } |
||
| 190 | |||
| 191 | /** |
||
| 192 | * @return string |
||
| 193 | */ |
||
| 194 | public function showField() |
||
| 195 | { |
||
| 196 | return $this->fieldname . ' : ' . $this->value; |
||
| 197 | } |
||
| 198 | |||
| 199 | /** |
||
| 200 | * @return mixed|string |
||
| 201 | */ |
||
| 202 | public function showValue() |
||
| 203 | { |
||
| 204 | $myts = \MyTextSanitizer::getInstance(); |
||
| 205 | return $myts->displayTarea($this->value); |
||
| 206 | } |
||
| 207 | |||
| 208 | /** |
||
| 209 | * @return string |
||
| 210 | */ |
||
| 211 | public function searchField() |
||
| 212 | { |
||
| 213 | return '<input type="text" name="query" size="20">'; |
||
| 214 | } |
||
| 215 | } |
||
| 216 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: