1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
22:
23: function b_xlanguage_select_show($options)
24: {
25: $xoops = \Xoops::getInstance();
26: $helper = \Xoops\Module\Helper::getHelper('xlanguage');
27:
28: $xlanguage = $xoops->registry()->get('XLANGUAGE');
29: $lang_tag = $xoops->registry()->get('XLANGUAGE_LANG_TAG');
30:
31: $options[3] = $helper->getConfig('theme');
32:
33: $block = array();
34: $helper->getHandlerLanguage()->loadConfig();
35:
36: if (!is_array($helper->getHandlerLanguage()->cached_config) || count($helper->getHandlerLanguage()->cached_config) < 1) {
37: return $block;
38: }
39:
40: $QUERY_STRING_array = array_filter(explode('&', $xoops->getEnv('QUERY_STRING')));
41: $QUERY_STRING_new = array();
42: foreach ($QUERY_STRING_array as $QUERY) {
43: if (substr($QUERY, 0, (strlen($lang_tag) + 1)) != $lang_tag . '=') {
44: $vals = explode('=', $QUERY);
45: foreach (array_keys($vals) as $key) {
46: if (preg_match('/^a-z0-9$/i', $vals[$key])) {
47: $vals[$key] = urlencode($vals[$key]);
48: }
49: }
50: $QUERY_STRING_new[] = implode('=', $vals);
51: }
52: }
53:
54: $block['display'] = $options[0];
55: $block['delimitor'] = $options[1];
56: $block['number'] = $options[2];
57:
58: if ($options[0]==='jquery') {
59: $xoops = \Xoops::getInstance();
60: $xoops->theme()->addBaseScriptAssets('@jqueryui');
61: }
62:
63: $block['selected'] = $xlanguage['lang'];
64:
65: if ($options[0] === 'images' || $options[0] === 'text') {
66: $query_string = htmlspecialchars(implode('&', $QUERY_STRING_new));
67: $query_string .= empty($query_string) ? '' : '&';
68: } else {
69: $query_string = implode('&', array_map('htmlspecialchars', $QUERY_STRING_new));
70: $query_string .= empty($query_string) ? '' : '&';
71: }
72: $block['url'] = $xoops->getEnv('PHP_SELF') . '?' . $query_string . $lang_tag . '=';
73: $block['languages'] = $helper->getHandlerLanguage()->cached_config;
74:
75: return $block;
76: }
77:
78: 79: 80: 81: 82:
83: function b_xlanguage_select_edit($options)
84: {
85: $block_form = new Xoops\Form\BlockForm();
86:
87: $tmp = new Xoops\Form\Select(_MB_XLANGUAGE_DISPLAY_METHOD . ' : ', 'options[0]', $options[0]);
88: $tmp->addOption('images', _MB_XLANGUAGE_DISPLAY_FLAGLIST);
89: $tmp->addOption('text', _MB_XLANGUAGE_DISPLAY_TEXTLIST);
90: $tmp->addOption('select', _MB_XLANGUAGE_DISPLAY_SELECT);
91: $tmp->addOption('jquery', _MB_XLANGUAGE_DISPLAY_JQUERY);
92: $tmp->addOption('bootstrap', _MB_XLANGUAGE_DISPLAY_BOOTSTRAP);
93: $block_form->addElement($tmp);
94:
95: $block_form->addElement(new Xoops\Form\Text(_MB_XLANGUAGE_IMAGE_SEPARATOR . ' (' . _MB_XLANGUAGE_OPTIONAL . ') : ', 'options[1]', 5, 5, $options[1]));
96: $block_form->addElement(new Xoops\Form\Text(_MB_XLANGUAGE_IMAGE_PERROW . ' (' . _MB_XLANGUAGE_OPTIONAL . ') : ', 'options[2]', 2, 2, $options[2]));
97:
98: return $block_form->render();
99: }
100: