XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
xoopslists.php
Go to the documentation of this file.
1 <?php
20 defined('XOOPS_ROOT_PATH') or die('Restricted access');
21 
22 if (!defined('XOOPS_LISTS_INCLUDED')) {
23  define('XOOPS_LISTS_INCLUDED', 1);
24 
34  class XoopsLists
35  {
36  static function getTimeZoneList()
37  {
38  xoops_loadLanguage('timezone');
39 
40  $time_zone_list = array(
41  '-12' => _TZ_GMTM12 ,
42  '-11' => _TZ_GMTM11 ,
43  '-10' => _TZ_GMTM10 ,
44  '-9' => _TZ_GMTM9 ,
45  '-8' => _TZ_GMTM8 ,
46  '-7' => _TZ_GMTM7 ,
47  '-6' => _TZ_GMTM6 ,
48  '-5' => _TZ_GMTM5 ,
49  '-4' => _TZ_GMTM4 ,
50  '-3.5' => _TZ_GMTM35 ,
51  '-3' => _TZ_GMTM3 ,
52  '-2' => _TZ_GMTM2 ,
53  '-1' => _TZ_GMTM1 ,
54  '0' => _TZ_GMT0 ,
55  '1' => _TZ_GMTP1 ,
56  '2' => _TZ_GMTP2 ,
57  '3' => _TZ_GMTP3 ,
58  '3.5' => _TZ_GMTP35 ,
59  '4' => _TZ_GMTP4 ,
60  '4.5' => _TZ_GMTP45 ,
61  '5' => _TZ_GMTP5 ,
62  '5.5' => _TZ_GMTP55 ,
63  '6' => _TZ_GMTP6 ,
64  '7' => _TZ_GMTP7 ,
65  '8' => _TZ_GMTP8 ,
66  '9' => _TZ_GMTP9 ,
67  '9.5' => _TZ_GMTP95 ,
68  '10' => _TZ_GMTP10 ,
69  '11' => _TZ_GMTP11 ,
70  '12' => _TZ_GMTP12);
71 
72  return $time_zone_list;
73  }
74 
78  static function getThemesList()
79  {
80  return XoopsLists::getDirListAsArray(XOOPS_THEME_PATH . '/');
81  }
82 
86  static function getModulesList()
87  {
88  return XoopsLists::getDirListAsArray(XOOPS_ROOT_PATH . '/modules/');
89  }
90 
94  static function getEditorList()
95  {
96  return XoopsLists::getDirListAsArray(XOOPS_ROOT_PATH . '/class/xoopseditor/');
97  }
98 
102  static function getDirListAsArray($dirname)
103  {
104  $ignored = array(
105  'cvs' ,
106  '_darcs');
107  $list = array();
108  if (substr($dirname, - 1) != '/') {
109  $dirname .= '/';
110  }
111  if ($handle = opendir($dirname)) {
112  while ($file = readdir($handle)) {
113  if (substr($file, 0, 1) == '.' || in_array(strtolower($file), $ignored))
114  continue;
115  if (is_dir($dirname . $file)) {
116  $list[$file] = $file;
117  }
118  }
119  closedir($handle);
120  asort($list);
121  reset($list);
122  }
123  return $list;
124  }
125 
129  static function getFileListAsArray($dirname, $prefix = '')
130  {
131  $filelist = array();
132  if (substr($dirname, - 1) == '/') {
133  $dirname = substr($dirname, 0, - 1);
134  }
135  if (is_dir($dirname) && $handle = opendir($dirname)) {
136  while (false !== ($file = readdir($handle))) {
137  if (! preg_match('/^[\.]{1,2}$/', $file) && is_file($dirname . '/' . $file)) {
138  $file = $prefix . $file;
139  $filelist[$file] = $file;
140  }
141  }
142  closedir($handle);
143  asort($filelist);
144  reset($filelist);
145  }
146  return $filelist;
147  }
148 
152  static function getImgListAsArray($dirname, $prefix = '')
153  {
154  $filelist = array();
155  if ($handle = opendir($dirname)) {
156  while (false !== ($file = readdir($handle))) {
157  if (preg_match('/(\.gif|\.jpg|\.png)$/i', $file)) {
158  $file = $prefix . $file;
159  $filelist[$file] = $file;
160  }
161  }
162  closedir($handle);
163  asort($filelist);
164  reset($filelist);
165  }
166  return $filelist;
167  }
168 
172  static function getHtmlListAsArray($dirname, $prefix = '')
173  {
174  $filelist = array();
175  if ($handle = opendir($dirname)) {
176  while (false !== ($file = readdir($handle))) {
177  if ((preg_match('/(\.htm|\.html|\.xhtml)$/i', $file) && ! is_dir($file))) {
178  $file = $prefix . $file;
179  $filelist[$file] = $prefix . $file;
180  }
181  }
182  closedir($handle);
183  asort($filelist);
184  reset($filelist);
185  }
186  return $filelist;
187  }
188 
193  static function getAvatarsList($avatar_dir = '')
194  {
195  $avatars = array();
196  if ($avatar_dir != '') {
197  $avatars = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/images/avatar/' . $avatar_dir . '/', $avatar_dir . '/');
198  } else {
199  $avatars = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/images/avatar/');
200  }
201  return $avatars;
202  }
203 
207  static function getAllAvatarsList()
208  {
209  $avatars = array();
210  $dirlist = array();
211  $dirlist = XoopsLists::getDirListAsArray(XOOPS_ROOT_PATH . '/images/avatar/');
212  if (count($dirlist) > 0) {
213  foreach($dirlist as $dir) {
214  $avatars[$dir] = &XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/images/avatar/' . $dir . '/', $dir . '/');
215  }
216  } else {
217  return false;
218  }
219  return $avatars;
220  }
221 
226  static function getSubjectsList($sub_dir = '')
227  {
228  $subjects = array();
229  if ($sub_dir != '') {
230  $subjects = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/images/subject/' . $sub_dir, $sub_dir . '/');
231  } else {
232  $subjects = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH . '/images/subject/');
233  }
234  return $subjects;
235  }
236 
240  static function getLangList()
241  {
242  $lang_list = array();
243  $lang_list = XoopsLists::getDirListAsArray(XOOPS_ROOT_PATH . '/language/');
244  return $lang_list;
245  }
246 
252  static function getCountryList()
253  {
254  xoops_loadLanguage('countries');
255  $country_list = array (
256  "" => "-",
257  "AD" => _COUNTRY_AD,
258  "AE" => _COUNTRY_AE,
259  "AF" => _COUNTRY_AF,
260  "AG" => _COUNTRY_AG,
261  "AI" => _COUNTRY_AI,
262  "AL" => _COUNTRY_AL,
263  "AM" => _COUNTRY_AM,
264  "AN" => _COUNTRY_AN,
265  "AO" => _COUNTRY_AO,
266  "AQ" => _COUNTRY_AQ,
267  "AR" => _COUNTRY_AR,
268  "AS" => _COUNTRY_AS,
269  "AT" => _COUNTRY_AT,
270  "AU" => _COUNTRY_AU,
271  "AW" => _COUNTRY_AW,
272  "AX" => _COUNTRY_AX,
273  "AZ" => _COUNTRY_AZ,
274  "BA" => _COUNTRY_BA,
275  "BB" => _COUNTRY_BB,
276  "BD" => _COUNTRY_BD,
277  "BE" => _COUNTRY_BE,
278  "BF" => _COUNTRY_BF,
279  "BG" => _COUNTRY_BG,
280  "BH" => _COUNTRY_BH,
281  "BI" => _COUNTRY_BI,
282  "BJ" => _COUNTRY_BJ,
283  "BL" => _COUNTRY_BL,
284  "BM" => _COUNTRY_BM,
285  "BN" => _COUNTRY_BN,
286  "BO" => _COUNTRY_BO,
287  "BR" => _COUNTRY_BR,
288  "BS" => _COUNTRY_BS,
289  "BT" => _COUNTRY_BT,
290  "BV" => _COUNTRY_BV,
291  "BW" => _COUNTRY_BW,
292  "BY" => _COUNTRY_BY,
293  "BZ" => _COUNTRY_BZ,
294  "CA" => _COUNTRY_CA,
295  "CC" => _COUNTRY_CC,
296  "CD" => _COUNTRY_CD,
297  "CF" => _COUNTRY_CF,
298  "CG" => _COUNTRY_CG,
299  "CH" => _COUNTRY_CH,
300  "CI" => _COUNTRY_CI,
301  "CK" => _COUNTRY_CK,
302  "CL" => _COUNTRY_CL,
303  "CM" => _COUNTRY_CM,
304  "CN" => _COUNTRY_CN,
305  "CO" => _COUNTRY_CO,
306  "CR" => _COUNTRY_CR,
307  "CS" => _COUNTRY_CS, // Not listed in ISO 3166, former Serbia & Montenegro
308  "CU" => _COUNTRY_CU,
309  "CV" => _COUNTRY_CV,
310  "CX" => _COUNTRY_CX,
311  "CY" => _COUNTRY_CY,
312  "CZ" => _COUNTRY_CZ,
313  "DE" => _COUNTRY_DE,
314  "DJ" => _COUNTRY_DJ,
315  "DK" => _COUNTRY_DK,
316  "DM" => _COUNTRY_DM,
317  "DO" => _COUNTRY_DO,
318  "DZ" => _COUNTRY_DZ,
319  "EC" => _COUNTRY_EC,
320  "EE" => _COUNTRY_EE,
321  "EG" => _COUNTRY_EG,
322  "EH" => _COUNTRY_EH,
323  "ER" => _COUNTRY_ER,
324  "ES" => _COUNTRY_ES,
325  "ET" => _COUNTRY_ET,
326  "FI" => _COUNTRY_FI,
327  "FJ" => _COUNTRY_FJ,
328  "FK" => _COUNTRY_FK,
329  "FM" => _COUNTRY_FM,
330  "FO" => _COUNTRY_FO,
331  "FR" => _COUNTRY_FR,
332  "FX" => _COUNTRY_FX, // Not listed in ISO 3166
333  "GA" => _COUNTRY_GA,
334  "GB" => _COUNTRY_GB,
335  "GD" => _COUNTRY_GD,
336  "GE" => _COUNTRY_GE,
337  "GF" => _COUNTRY_GF,
338  "GG" => _COUNTRY_GG,
339  "GH" => _COUNTRY_GH,
340  "GI" => _COUNTRY_GI,
341  "GL" => _COUNTRY_GL,
342  "GM" => _COUNTRY_GM,
343  "GN" => _COUNTRY_GN,
344  "GP" => _COUNTRY_GP,
345  "GQ" => _COUNTRY_GQ,
346  "GR" => _COUNTRY_GR,
347  "GS" => _COUNTRY_GS,
348  "GT" => _COUNTRY_GT,
349  "GU" => _COUNTRY_GU,
350  "GW" => _COUNTRY_GW,
351  "GY" => _COUNTRY_GY,
352  "HK" => _COUNTRY_HK,
353  "HM" => _COUNTRY_HM,
354  "HN" => _COUNTRY_HN,
355  "HR" => _COUNTRY_HR,
356  "HT" => _COUNTRY_HT,
357  "HU" => _COUNTRY_HU,
358  "ID" => _COUNTRY_ID,
359  "IE" => _COUNTRY_IE,
360  "IL" => _COUNTRY_IL,
361  "IM" => _COUNTRY_IM,
362  "IN" => _COUNTRY_IN,
363  "IO" => _COUNTRY_IO,
364  "IQ" => _COUNTRY_IQ,
365  "IR" => _COUNTRY_IR,
366  "IS" => _COUNTRY_IS,
367  "IT" => _COUNTRY_IT,
368  "JM" => _COUNTRY_JM,
369  "JO" => _COUNTRY_JO,
370  "JP" => _COUNTRY_JP,
371  "KE" => _COUNTRY_KE,
372  "KG" => _COUNTRY_KG,
373  "KH" => _COUNTRY_KH,
374  "KI" => _COUNTRY_KI,
375  "KM" => _COUNTRY_KM,
376  "KN" => _COUNTRY_KN,
377  "KP" => _COUNTRY_KP,
378  "KR" => _COUNTRY_KR,
379  "KW" => _COUNTRY_KW,
380  "KY" => _COUNTRY_KY,
381  "KZ" => _COUNTRY_KZ,
382  "LA" => _COUNTRY_LA,
383  "LB" => _COUNTRY_LB,
384  "LC" => _COUNTRY_LC,
385  "LI" => _COUNTRY_LI,
386  "LK" => _COUNTRY_LK,
387  "LR" => _COUNTRY_LR,
388  "LS" => _COUNTRY_LS,
389  "LT" => _COUNTRY_LT,
390  "LU" => _COUNTRY_LU,
391  "LV" => _COUNTRY_LV,
392  "LY" => _COUNTRY_LY,
393  "MA" => _COUNTRY_MA,
394  "MC" => _COUNTRY_MC,
395  "MD" => _COUNTRY_MD,
396  "ME" => _COUNTRY_ME,
397  "MF" => _COUNTRY_MF,
398  "MG" => _COUNTRY_MG,
399  "MH" => _COUNTRY_MH,
400  "MK" => _COUNTRY_MK,
401  "ML" => _COUNTRY_ML,
402  "MM" => _COUNTRY_MM,
403  "MN" => _COUNTRY_MN,
404  "MO" => _COUNTRY_MO,
405  "MP" => _COUNTRY_MP,
406  "MQ" => _COUNTRY_MQ,
407  "MR" => _COUNTRY_MR,
408  "MS" => _COUNTRY_MS,
409  "MT" => _COUNTRY_MT,
410  "MU" => _COUNTRY_MU,
411  "MV" => _COUNTRY_MV,
412  "MW" => _COUNTRY_MW,
413  "MX" => _COUNTRY_MX,
414  "MY" => _COUNTRY_MY,
415  "MZ" => _COUNTRY_MZ,
416  "NA" => _COUNTRY_NA,
417  "NC" => _COUNTRY_NC,
418  "NE" => _COUNTRY_NE,
419  "NF" => _COUNTRY_NF,
420  "NG" => _COUNTRY_NG,
421  "NI" => _COUNTRY_NI,
422  "NL" => _COUNTRY_NL,
423  "NO" => _COUNTRY_NO,
424  "NP" => _COUNTRY_NP,
425  "NR" => _COUNTRY_NR,
426  "NT" => _COUNTRY_NT, // Not listed in ISO 3166
427  "NU" => _COUNTRY_NU,
428  "NZ" => _COUNTRY_NZ,
429  "OM" => _COUNTRY_OM,
430  "PA" => _COUNTRY_PA,
431  "PE" => _COUNTRY_PE,
432  "PF" => _COUNTRY_PF,
433  "PG" => _COUNTRY_PG,
434  "PH" => _COUNTRY_PH,
435  "PK" => _COUNTRY_PK,
436  "PL" => _COUNTRY_PL,
437  "PM" => _COUNTRY_PM,
438  "PN" => _COUNTRY_PN,
439  "PR" => _COUNTRY_PR,
440  "PS" => _COUNTRY_PS,
441  "PT" => _COUNTRY_PT,
442  "PW" => _COUNTRY_PW,
443  "PY" => _COUNTRY_PY,
444  "QA" => _COUNTRY_QA,
445  "RE" => _COUNTRY_RE,
446  "RO" => _COUNTRY_RO,
447  "RS" => _COUNTRY_RS,
448  "RU" => _COUNTRY_RU,
449  "RW" => _COUNTRY_RW,
450  "SA" => _COUNTRY_SA,
451  "SB" => _COUNTRY_SB,
452  "SC" => _COUNTRY_SC,
453  "SD" => _COUNTRY_SD,
454  "SE" => _COUNTRY_SE,
455  "SG" => _COUNTRY_SG,
456  "SH" => _COUNTRY_SH,
457  "SI" => _COUNTRY_SI,
458  "SJ" => _COUNTRY_SJ,
459  "SK" => _COUNTRY_SK,
460  "SL" => _COUNTRY_SL,
461  "SM" => _COUNTRY_SM,
462  "SN" => _COUNTRY_SN,
463  "SO" => _COUNTRY_SO,
464  "SR" => _COUNTRY_SR,
465  "ST" => _COUNTRY_ST,
466  "SU" => _COUNTRY_SU, // Not listed in ISO 3166
467  "SV" => _COUNTRY_SV,
468  "SY" => _COUNTRY_SY,
469  "SZ" => _COUNTRY_SZ,
470  "TC" => _COUNTRY_TC,
471  "TD" => _COUNTRY_TD,
472  "TF" => _COUNTRY_TF,
473  "TG" => _COUNTRY_TG,
474  "TH" => _COUNTRY_TH,
475  "TJ" => _COUNTRY_TJ,
476  "TK" => _COUNTRY_TK,
477  "TL" => _COUNTRY_TL,
478  "TM" => _COUNTRY_TM,
479  "TN" => _COUNTRY_TN,
480  "TO" => _COUNTRY_TO,
481  "TP" => _COUNTRY_TP, // Not listed in ISO 3166, has changed to TL
482  "TR" => _COUNTRY_TR,
483  "TT" => _COUNTRY_TT,
484  "TV" => _COUNTRY_TV,
485  "TW" => _COUNTRY_TW,
486  "TZ" => _COUNTRY_TZ,
487  "UA" => _COUNTRY_UA,
488  "UG" => _COUNTRY_UG,
489  //"UK" => _COUNTRY_UK, // Not listed in ISO 3166
490  "UM" => _COUNTRY_UM,
491  "US" => _COUNTRY_US,
492  "UY" => _COUNTRY_UY,
493  "UZ" => _COUNTRY_UZ,
494  "VA" => _COUNTRY_VA,
495  "VC" => _COUNTRY_VC,
496  "VE" => _COUNTRY_VE,
497  "VG" => _COUNTRY_VG,
498  "VI" => _COUNTRY_VI,
499  "VN" => _COUNTRY_VN,
500  "VU" => _COUNTRY_VU,
501  "WF" => _COUNTRY_WF,
502  "WS" => _COUNTRY_WS,
503  "YE" => _COUNTRY_YE,
504  "YT" => _COUNTRY_YT,
505  "YU" => _COUNTRY_YU, // Not listed in ISO 3166, former Yugoslavia
506  "ZA" => _COUNTRY_ZA,
507  "ZM" => _COUNTRY_ZM,
508  "ZR" => _COUNTRY_ZR, // Not listed in ISO 3166
509  "ZW" => _COUNTRY_ZW
510  );
511  asort($country_list);
512  reset($country_list);
513  return $country_list;
514  }
515 
523  static function getHtmlList()
524  {
525  $html_list = array(
526  'a' => '&lt;a&gt;',
527  'abbr' => '&lt;abbr&gt;',
528  'acronym' => '&lt;acronym&gt;',
529  'address' => '&lt;address&gt;',
530  'b' => '&lt;b&gt;',
531  'bdo' => '&lt;bdo&gt;',
532  'big' => '&lt;big&gt;',
533  'blockquote' => '&lt;blockquote&gt;',
534  'br' => '&lt;br&gt;',
535  'caption' => '&lt;caption&gt;',
536  'cite' => '&lt;cite&gt;',
537  'code' => '&lt;code&gt;',
538  'col' => '&lt;col&gt;',
539  'colgroup' => '&lt;colgroup&gt;',
540  'dd' => '&lt;dd&gt;',
541  'del' => '&lt;del&gt;',
542  'dfn' => '&lt;dfn&gt;',
543  'div' => '&lt;div&gt;',
544  'dl' => '&lt;dl&gt;',
545  'dt' => '&lt;dt&gt;',
546  'em' => '&lt;em&gt;',
547  'font' => '&lt;font&gt;',
548  'h1' => '&lt;h1&gt;',
549  'h2' => '&lt;h2&gt;',
550  'h3' => '&lt;h3&gt;',
551  'h4' => '&lt;h4&gt;',
552  'h5' => '&lt;h5&gt;',
553  'h6' => '&lt;h6&gt;',
554  'hr' => '&lt;hr&gt;',
555  'i' => '&lt;i&gt;',
556  'img' => '&lt;img&gt;',
557  'ins' => '&lt;ins&gt;',
558  'kbd' => '&lt;kbd&gt;',
559  'li' => '&lt;li&gt;',
560  'map' => '&lt;map&gt;',
561  'object' => '&lt;object&gt;',
562  'ol' => '&lt;ol&gt;',
563  'p' => '&lt;p&gt;',
564  'pre' => '&lt;pre&gt;',
565  's' => '&lt;s&gt;',
566  'samp' => '&lt;samp&gt;',
567  'small' => '&lt;small&gt;',
568  'span' => '&lt;span&gt;',
569  'strike' => '&lt;strike&gt;',
570  'strong' => '&lt;strong&gt;',
571  'sub' => '&lt;sub&gt;',
572  'sup' => '&lt;sup&gt;',
573  'table' => '&lt;table&gt;',
574  'tbody' => '&lt;tbody&gt;',
575  'td' => '&lt;td&gt;',
576  'tfoot' => '&lt;tfoot&gt;',
577  'th' => '&lt;th&gt;',
578  'thead' => '&lt;thead&gt;',
579  'tr' => '&lt;tr&gt;',
580  'tt' => '&lt;tt&gt;',
581  'u' => '&lt;u&gt;',
582  'ul' => '&lt;ul&gt;',
583  'var' => '&lt;var&gt;');
584  asort($html_list);
585  reset($html_list);
586  return $html_list;
587  }
588 
594  static function getUserRankList()
595  {
598  $sql = sprintf('SELECT rank_id, rank_title FROM ' . $db->prefix('ranks') . ' WHERE rank_special = %u', 1);
599  $ret = array();
600  $result = $db->query($sql);
601  while ($myrow = $db->fetchArray($result)) {
602  $ret[$myrow['rank_id']] = $myts->htmlspecialchars($myrow['rank_title']);
603  }
604  return $ret;
605  }
606  }
607 }
608 
609 ?>