|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Class: wflLists |
|
4
|
|
|
* $Id: wfl_list.php v 1.00 21 June 2005 John N Exp $ |
|
5
|
|
|
* Module: WF-Links |
|
6
|
|
|
* Version: v1.0.3 |
|
7
|
|
|
* Release Date: 21 June 2005 |
|
8
|
|
|
* Developer: John N |
|
9
|
|
|
* Team: WF-Projects |
|
10
|
|
|
* Licence: GNU |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
class wflLists |
|
|
|
|
|
|
14
|
|
|
{ |
|
15
|
|
|
var $value; |
|
|
|
|
|
|
16
|
|
|
var $selected; |
|
|
|
|
|
|
17
|
|
|
var $path='uploads'; |
|
|
|
|
|
|
18
|
|
|
var $size; |
|
|
|
|
|
|
19
|
|
|
var $emptyselect; |
|
|
|
|
|
|
20
|
|
|
var $type; |
|
|
|
|
|
|
21
|
|
|
var $prefix; |
|
|
|
|
|
|
22
|
|
|
var $suffix; |
|
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
function __construct($path="uploads", $value = null, $selected='', $size = 1, $emptyselect = 0, $type = 0, $prefix='', $suffix='') |
|
|
|
|
|
|
25
|
|
|
{ |
|
26
|
|
|
$this -> value = $value; |
|
27
|
|
|
$this -> selection = $selected; |
|
|
|
|
|
|
28
|
|
|
$this -> path = $path; |
|
29
|
|
|
$this -> size = intval($size); |
|
30
|
|
|
$this -> emptyselect = ($emptyselect) ? 0 : 1; |
|
31
|
|
|
$this -> type = $type; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
View Code Duplication |
function &getarray($this_array) { |
|
|
|
|
|
|
35
|
|
|
$ret="<select size='" . $this -> size() . "' name='$this->value()'>"; |
|
36
|
|
|
if ($this -> emptyselect) { |
|
37
|
|
|
$ret .= "<option value='" . $this -> value() . "'>----------------------</option>"; |
|
38
|
|
|
} |
|
39
|
|
|
foreach ($this_array as $content) { |
|
40
|
|
|
$opt_selected=""; |
|
41
|
|
|
|
|
42
|
|
|
if ($content[0] == $this -> selected()) { |
|
43
|
|
|
$opt_selected="selected='selected'"; |
|
44
|
|
|
} |
|
45
|
|
|
$ret .= "<option value='" . $content . "' $opt_selected>" . $content . "</option>"; |
|
46
|
|
|
} |
|
47
|
|
|
$ret .= "</select>"; |
|
48
|
|
|
|
|
49
|
|
|
return $ret; |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Private to be called by other parts of the class |
|
54
|
|
|
*/ |
|
55
|
|
|
function &getDirListAsArray($dirname) { |
|
56
|
|
|
$dirlist = array(); |
|
57
|
|
|
if (is_dir($dirname) && $handle = opendir($dirname)) { |
|
58
|
|
|
while (false !== ($file = readdir($handle))) { |
|
59
|
|
|
if (!preg_match("/^[.]{1,2}$/", $file)) { |
|
60
|
|
|
if (strtolower($file) != 'cvs' && is_dir($dirname . $file)) { |
|
61
|
|
|
$dirlist[$file] = $file; |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
closedir($handle); |
|
66
|
|
|
|
|
67
|
|
|
reset($dirlist); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
return $dirlist; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
function &getListTypeAsArray($dirname, $type='', $prefix="", $noselection = 1) { |
|
74
|
|
|
|
|
75
|
|
|
$filelist = array(); |
|
76
|
|
|
switch (trim($type)) { |
|
77
|
|
|
case "images": |
|
78
|
|
|
$types="[.gif|.jpg|.png]"; |
|
79
|
|
|
if ($noselection) |
|
80
|
|
|
$filelist[""]=_AM_WFL_SHOWNOIMAGE; |
|
81
|
|
|
break; |
|
82
|
|
|
case "html": |
|
83
|
|
|
$types="[.htm|.html|.xhtml|.php|.php3|.phtml|.txt]"; |
|
84
|
|
|
if ($noselection) |
|
85
|
|
|
$filelist[""]="No Selection"; |
|
86
|
|
|
break; |
|
87
|
|
|
default: |
|
88
|
|
|
$types=""; |
|
89
|
|
|
if ($noselection) |
|
90
|
|
|
$filelist[""]="No Selected File"; |
|
91
|
|
|
break; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
if (substr($dirname, -1) == '/') { |
|
95
|
|
|
$dirname = substr($dirname, 0, -1); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
if (is_dir($dirname) && $handle = opendir($dirname)) { |
|
99
|
|
|
while (false !== ($file = readdir($handle))) { |
|
100
|
|
|
if (!preg_match("/^[.]{1,2}$/", $file) && preg_match("/$types$/i", $file) && is_file($dirname . '/' . $file)) { |
|
101
|
|
|
if (strtolower($file) == "blank.gif") |
|
102
|
|
|
Continue; |
|
103
|
|
|
$file = $prefix . $file; |
|
104
|
|
|
$filelist[$file] = $file; |
|
105
|
|
|
} |
|
106
|
|
|
} |
|
107
|
|
|
closedir($handle); |
|
108
|
|
|
asort($filelist); |
|
109
|
|
|
reset($filelist); |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
return $filelist; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
function &getForum( $type = 1, $selected ) { |
|
|
|
|
|
|
116
|
|
|
global $xoopsDB; |
|
|
|
|
|
|
117
|
|
|
switch ( xoops_trim( $type ) ) { |
|
118
|
|
|
case 2: |
|
119
|
|
|
$sql = "SELECT id, name FROM " . $xoopsDB->prefix( "ibf_forums" ) . " ORDER BY id"; |
|
120
|
|
|
break; |
|
121
|
|
|
case 3: |
|
122
|
|
|
$sql = "SELECT forum_id, forum_name FROM " . $xoopsDB->prefix( "pbb_forums" ) . " ORDER BY forum_id"; |
|
123
|
|
|
break; |
|
124
|
|
|
case 4: |
|
125
|
|
|
$sql = "SELECT forum_id, forum_name FROM " . $xoopsDB -> prefix('bbex_forums') . " ORDER BY forum_id"; |
|
126
|
|
|
break; |
|
127
|
|
|
case 1: |
|
128
|
|
|
case 0: |
|
129
|
|
|
default: |
|
130
|
|
|
$sql = "SELECT forum_id, forum_name FROM " . $xoopsDB->prefix( "bb_forums" ) . " ORDER BY forum_id"; |
|
131
|
|
|
break; |
|
132
|
|
|
} |
|
133
|
|
|
$result = $xoopsDB->query( $sql ); |
|
134
|
|
|
|
|
135
|
|
|
$noforum = ( defined( '_WFL_NO_FORUM' ) ) ? _WFL_NO_FORUM : _AM_WFL_NO_FORUM; |
|
136
|
|
|
|
|
137
|
|
|
echo "<select size='1' name='forumid'>"; |
|
138
|
|
|
echo "<option value='0'>" . $noforum . "</option>"; |
|
139
|
|
View Code Duplication |
while (list($forum_id, $forum_name ) = $xoopsDB -> fetchRow($result)) { |
|
|
|
|
|
|
140
|
|
|
$opt_selected = ""; |
|
141
|
|
|
if ($forum_id == $selected) { |
|
142
|
|
|
$opt_selected = "selected='selected'"; |
|
143
|
|
|
} |
|
144
|
|
|
echo "<option value='" . $forum_id . "' $opt_selected>" . $forum_name . "</option>"; |
|
145
|
|
|
} |
|
146
|
|
|
echo "</select>"; |
|
147
|
|
|
|
|
148
|
|
|
return $forum_array; |
|
|
|
|
|
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
function value() |
|
|
|
|
|
|
152
|
|
|
{ |
|
153
|
|
|
return $this->value; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
function selected() |
|
|
|
|
|
|
157
|
|
|
{ |
|
158
|
|
|
return $this->selected; |
|
159
|
|
|
} |
|
160
|
|
|
|
|
161
|
|
|
function paths() |
|
|
|
|
|
|
162
|
|
|
{ |
|
163
|
|
|
return $this->path; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
function size() |
|
|
|
|
|
|
167
|
|
|
{ |
|
168
|
|
|
return $this->size; |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
function emptyselect() |
|
|
|
|
|
|
172
|
|
|
{ |
|
173
|
|
|
return $this->emptyselect; |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
function type() |
|
|
|
|
|
|
177
|
|
|
{ |
|
178
|
|
|
return $this->type; |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
function prefix() |
|
|
|
|
|
|
182
|
|
|
{ |
|
183
|
|
|
return $this->prefix; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
function suffix() |
|
|
|
|
|
|
187
|
|
|
{ |
|
188
|
|
|
return $this->suffix; |
|
189
|
|
|
} |
|
190
|
|
|
} |
|
191
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.