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