XoopsModules25x /
xoopstube
| 1 | <?php |
||
| 2 | |||
| 3 | namespace XoopsModules\Xoopstube; |
||
| 4 | |||
| 5 | /** |
||
| 6 | * Module: XoopsTube |
||
| 7 | * |
||
| 8 | * You may not change or alter any portion of this comment or credits |
||
| 9 | * of supporting developers from this source code or any supporting source code |
||
| 10 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 11 | * |
||
| 12 | * PHP version 5 |
||
| 13 | * |
||
| 14 | * @category Module |
||
| 15 | * @package Xoopstube |
||
| 16 | * @author XOOPS Development Team |
||
| 17 | * @copyright 2001-2016 XOOPS Project (https://xoops.org) |
||
| 18 | * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||
| 19 | * @link https://xoops.org/ |
||
| 20 | * @since 1.0.6 |
||
| 21 | */ |
||
| 22 | |||
| 23 | use XoopsModules\Xoopstube; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Class Lists |
||
| 27 | * @package XoopsModules\Xoopstube |
||
| 28 | */ |
||
| 29 | class Lists |
||
| 30 | { |
||
| 31 | public $value; |
||
| 32 | public $selected; |
||
| 33 | public $path = 'uploads'; |
||
| 34 | public $size; |
||
| 35 | public $emptyselect; |
||
| 36 | public $type; |
||
| 37 | public $prefix; |
||
| 38 | public $suffix; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param string $path |
||
| 42 | * @param null $value |
||
| 43 | * @param string $selected |
||
| 44 | * @param int $size |
||
| 45 | * @param int $emptyselect |
||
| 46 | * @param int $type |
||
| 47 | * @param string $prefix |
||
| 48 | * @param string $suffix |
||
| 49 | */ |
||
| 50 | public function __construct( |
||
| 51 | $path = 'uploads', |
||
| 52 | $value = null, |
||
| 53 | $selected = '', |
||
| 54 | $size = 1, |
||
| 55 | $emptyselect = 0, |
||
| 56 | $type = 0, |
||
| 57 | $prefix = '', |
||
| 58 | $suffix = '' |
||
| 59 | ) { |
||
| 60 | $this->value = $value; |
||
| 61 | $this->selection = $selected; |
||
| 62 | $this->path = $path; |
||
| 63 | $this->size = (int)$size; |
||
| 64 | $this->emptyselect = $emptyselect ? 0 : 1; |
||
| 65 | $this->type = $type; |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @param array $this_array |
||
| 70 | * |
||
| 71 | * @return string |
||
| 72 | */ |
||
| 73 | public function getarray($this_array) |
||
| 74 | { |
||
| 75 | $ret = "<select size='" . $this->size() . "' name='$this->value()'>"; |
||
| 76 | if ($this->emptyselect) { |
||
| 77 | $ret .= "<option value='" . $this->value() . "'>----------------------</option>"; |
||
|
0 ignored issues
–
show
|
|||
| 78 | } |
||
| 79 | foreach ($this_array as $content) { |
||
| 80 | $opt_selected = ''; |
||
| 81 | |||
| 82 | if ($content[0] == $this->isSelected()) { |
||
| 83 | $opt_selected = "selected='selected'"; |
||
| 84 | } |
||
| 85 | $ret .= "<option value='" . $content . "' $opt_selected>" . $content . '</option>'; |
||
| 86 | } |
||
| 87 | $ret .= '</select>'; |
||
| 88 | |||
| 89 | return $ret; |
||
| 90 | } |
||
| 91 | |||
| 92 | /** |
||
| 93 | * Private to be called by other parts of the class |
||
| 94 | * |
||
| 95 | * @param $dirname |
||
| 96 | * |
||
| 97 | * @return array |
||
| 98 | */ |
||
| 99 | public function getDirListAsArray($dirname) |
||
| 100 | { |
||
| 101 | $dirlist = []; |
||
| 102 | if (\is_dir($dirname) && $handle = \opendir($dirname)) { |
||
| 103 | while (false !== ($file = \readdir($handle))) { |
||
| 104 | if (!\preg_match('/^[.]{1,2}$/', $file)) { |
||
| 105 | if ('cvs' !== mb_strtolower($file) && \is_dir($dirname . $file)) { |
||
| 106 | $dirlist[$file] = $file; |
||
| 107 | } |
||
| 108 | } |
||
| 109 | } |
||
| 110 | \closedir($handle); |
||
| 111 | |||
| 112 | \reset($dirlist); |
||
| 113 | } |
||
| 114 | |||
| 115 | return $dirlist; |
||
| 116 | } |
||
| 117 | |||
| 118 | /** |
||
| 119 | * @param $dirname |
||
| 120 | * @param string $type |
||
| 121 | * @param string $prefix |
||
| 122 | * @param int $noselection |
||
| 123 | * |
||
| 124 | * @return array |
||
| 125 | */ |
||
| 126 | public static function getListTypeAsArray($dirname, $type = '', $prefix = '', $noselection = 1) |
||
| 127 | { |
||
| 128 | $filelist = []; |
||
| 129 | switch (\trim($type)) { |
||
| 130 | case 'images': |
||
| 131 | $types = '[.gif|.jpg|.png]'; |
||
| 132 | if ($noselection) { |
||
| 133 | $filelist[''] = \_AM_XOOPSTUBE_NOIMAGE; |
||
| 134 | } |
||
| 135 | break; |
||
| 136 | case 'media': |
||
| 137 | $types = '[.aac|.flv|.mp3|.mp4|.swf]'; |
||
| 138 | if ($noselection) { |
||
| 139 | $filelist[''] = \_AM_XOOPSTUBE_NOVIDEO; |
||
| 140 | } |
||
| 141 | break; |
||
| 142 | case 'html': |
||
| 143 | $types = '[.htm|.tpl|.html|.xhtml|.php|.php3|.phtml|.txt]'; |
||
| 144 | if ($noselection) { |
||
| 145 | $filelist[''] = \_AM_XOOPSTUBE_NOSELECT; |
||
| 146 | } |
||
| 147 | break; |
||
| 148 | default: |
||
| 149 | $types = ''; |
||
| 150 | if ($noselection) { |
||
| 151 | $filelist[''] = \_AM_XOOPSTUBE_NOFILESELECT; |
||
| 152 | } |
||
| 153 | break; |
||
| 154 | } |
||
| 155 | |||
| 156 | if ('/' === mb_substr($dirname, -1)) { |
||
| 157 | $dirname = mb_substr($dirname, 0, -1); |
||
| 158 | } |
||
| 159 | |||
| 160 | if (\is_dir($dirname) && $handle = \opendir($dirname)) { |
||
| 161 | while (false !== ($file = \readdir($handle))) { |
||
| 162 | if (!\preg_match('/^[.]{1,2}$/', $file) && \preg_match("/$types$/i", $file) && \is_file($dirname . '/' . $file)) { |
||
| 163 | if ('blank.gif' === mb_strtolower($file)) { |
||
| 164 | continue; |
||
| 165 | } |
||
| 166 | $file = $prefix . $file; |
||
| 167 | $filelist[$file] = $file; |
||
| 168 | } |
||
| 169 | } |
||
| 170 | \closedir($handle); |
||
| 171 | \asort($filelist); |
||
| 172 | \reset($filelist); |
||
| 173 | } |
||
| 174 | |||
| 175 | return $filelist; |
||
| 176 | } |
||
| 177 | |||
| 178 | /** |
||
| 179 | * @return null |
||
| 180 | */ |
||
| 181 | public function value() |
||
| 182 | { |
||
| 183 | return $this->value; |
||
| 184 | } |
||
| 185 | |||
| 186 | public function isSelected() |
||
| 187 | { |
||
| 188 | return $this->selected; |
||
| 189 | } |
||
| 190 | |||
| 191 | /** |
||
| 192 | * @return string |
||
| 193 | */ |
||
| 194 | public function paths() |
||
| 195 | { |
||
| 196 | return $this->path; |
||
| 197 | } |
||
| 198 | |||
| 199 | /** |
||
| 200 | * @return int |
||
| 201 | */ |
||
| 202 | public function size() |
||
| 203 | { |
||
| 204 | return $this->size; |
||
| 205 | } |
||
| 206 | |||
| 207 | /** |
||
| 208 | * @return int |
||
| 209 | */ |
||
| 210 | public function isEmptySelect() |
||
| 211 | { |
||
| 212 | return $this->emptyselect; |
||
| 213 | } |
||
| 214 | |||
| 215 | /** |
||
| 216 | * @return int |
||
| 217 | */ |
||
| 218 | public function getType() |
||
| 219 | { |
||
| 220 | return $this->type; |
||
| 221 | } |
||
| 222 | |||
| 223 | public function getPrefix() |
||
| 224 | { |
||
| 225 | return $this->prefix; |
||
| 226 | } |
||
| 227 | |||
| 228 | public function getSuffix() |
||
| 229 | { |
||
| 230 | return $this->suffix; |
||
| 231 | } |
||
| 232 | } |
||
| 233 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.