1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
22: function banners_blocks_show($options) {
23: $block = array();
24: $xoops = Xoops::getInstance();
25: require_once dirname(__DIR__) . '/class/bannerrender.php';
26: $render = new BannerRender();
27: switch ($options[0]) {
28: case 'random':
29: $nb_display = $options[1];
30: $align = $options[2];
31: array_shift($options);
32: array_shift($options);
33: array_shift($options);
34: $client = $options;
35: $block['banners'] = $render->displayBanner($nb_display, $align, $client);
36: break;
37:
38: case 'id':
39: $ids = $options[1];
40: $align = $options[2];
41: $block['banners'] = $render->displayBanner(1, $align, 0, $ids);
42: break;
43: }
44: return $block;
45: }
46:
47: function banners_blocks_edit($options) {
48: $form = '';
49: switch ($options[0]) {
50:
51: case 'random':
52: $form .= _MB_BANNERS_DISP . " \n";
53: $form .= "<input type=\"hidden\" name=\"options[0]\" value=\"" . $options[0] . "\" />\n";
54: $form .= "<input name=\"options[1]\" size=\"5\" maxlength=\"255\" value=\"" . $options[1] . "\" type=\"text\" /> " . _MB_BANNERS . "<br />\n";
55: switch ($options[2]){
56: case 'H':
57: $checked_H = 'checked="checked"';
58: $checked_V = '';
59: break;
60:
61: case 'V':
62: $checked_H = '';
63: $checked_V = 'checked="checked"';
64: break;
65: }
66: $form .= _MB_BANNERS_ALIGNEMENT . " : <input name=\"options[2]\" value=\"H\" type=\"radio\" " . $checked_H . "/>" . _MB_BANNERS_ALIGNEMENT_H . " \n";
67: $form .= "<input name=\"options[2]\" value=\"V\" type=\"radio\" " . $checked_V . "/>" . _MB_BANNERS_ALIGNEMENT_V . "<br />\n";
68: array_shift($options);
69: array_shift($options);
70: array_shift($options);
71: $form .= _MB_BANNERS_CLIENTSTODISPLAY . "<br /><select name=\"options[]\" multiple=\"multiple\" size=\"5\">\n";
72: $xoops = Xoops::getInstance();
73: $client_Handler = $xoops->getModuleHandler('bannerclient','banners');
74: $criteria = new CriteriaCompo();
75: $criteria->setSort('bannerclient_name');
76: $criteria->setOrder('ASC');
77: $client_arr = $client_Handler->getAll($criteria);
78: $form .= "<option value=\"0\" " . (array_search(0, $options) === false ? '' : 'selected="selected"') . ">" . _MB_BANNERS_ALLCLIENTS . "</option>\n";
79: foreach (array_keys($client_arr) as $i) {
80: $form .= "<option value=\"" . $client_arr[$i]->getVar('cid') . "\" " . (array_search($client_arr[$i]->getVar('cid'), $options) === false ? '' : 'selected="selected"') . ">" . $client_arr[$i]->getVar('name')."</option>\n";
81: }
82: $form .= "</select>\n";
83: break;
84:
85: case 'id':
86: $form .= _MB_BANNERS_IDDISPLAY . " \n";
87: $form .= "<input type=\"hidden\" name=\"options[0]\" value=\"" . $options[0] . "\" />\n";
88: $form .= "<input name=\"options[1]\" size=\"20\" maxlength=\"255\" value=\"" . $options[1] . "\" type=\"text\" /> " . _MB_BANNERS_SEP . "<br />\n";
89: switch ($options[2]){
90: case 'H':
91: $checked_H = 'checked="checked"';
92: $checked_V = '';
93: break;
94:
95: case 'V':
96: $checked_H = '';
97: $checked_V = 'checked="checked"';
98: break;
99: }
100: $form .= _MB_BANNERS_ALIGNEMENT . " : <input name=\"options[2]\" value=\"H\" type=\"radio\" " . $checked_H . "/>" . _MB_BANNERS_ALIGNEMENT_H . " \n";
101: $form .= "<input name=\"options[2]\" value=\"V\" type=\"radio\" " . $checked_V . "/>" . _MB_BANNERS_ALIGNEMENT_V . "<br />\n";
102: break;
103: }
104: return $form;
105: }
106: