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