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 page_blocks_show($options)
24: {
25: $xoops = \Xoops::getInstance();
26: $page = $xoops->getModuleHelper('page');
27: $xoops->theme()->addStylesheet($page->url('css/styles.css'));
28: $xoops->theme()->addStylesheet($page->url('css/rating.css'));
29:
30: $block = '';
31: if ($options[0] === 'id') {
32: $view_content = $page->getContentHandler()->get($options[1]);
33:
34:
35: $content = $view_content->getValues();
36: foreach ($content as $k => $v) {
37: $block[$k] = $v;
38: }
39:
40: $block['related'] = $page->getLinkHandler()->menu_related($options[1]);
41:
42:
43: $block['yourvote'] = $page->getRatingHandler()->getVotebyUser($options[1]);
44:
45:
46: $block['security'] = $xoops->security()->createToken();
47: } else {
48: $block['text'] = $options[4];
49: $block['mode'] = $options[0];
50:
51: if ($options[0] === 'random') {
52: $sort = ('sqlite' === \XoopsBaseConfig::get('db-type')) ? 'RANDOM()' : 'RAND()';
53: $content = $page->getContentHandler()->getPagePublished(0, $options[3], $sort);
54: } else {
55: $content = $page->getContentHandler()->getPagePublished(0, $options[3], 'content_' . $options[1], $options[2]);
56: }
57: foreach (array_keys($content) as $i) {
58: $block['content'][$i] = $content[$i]->getValues();
59: }
60: }
61: return $block;
62: }
63:
64: function page_blocks_edit($options)
65: {
66: $block_form = new Xoops\Form\BlockForm();
67: if ($options[0] !== 'id') {
68: $mode_form = new Xoops\Form\Select(PageLocale::CONF_BLOCK_MODE, 'options[0]', $options[0], 1, false);
69: $mode_form->addOption('content', PageLocale::CONF_BLOCK_L_CONTENT);
70: $mode_form->addOption('list', PageLocale::CONF_BLOCK_L_LIST);
71: $block_form->addElement($mode_form);
72:
73: $order_form = new Xoops\Form\Select(PageLocale::CONF_BLOCK_ORDER, 'options[1]', $options[1], 1, false);
74: $order_form->addOption('create', PageLocale::CONF_BLOCK_L_RECENT);
75: $order_form->addOption('hits', PageLocale::CONF_BLOCK_L_HITS);
76: $order_form->addOption('rating', PageLocale::CONF_BLOCK_L_RATING);
77: $order_form->addOption('random', PageLocale::CONF_BLOCK_L_RANDOM);
78: $block_form->addElement($order_form);
79:
80: $sort_form = new Xoops\Form\Select(PageLocale::CONF_BLOCK_SORT, 'options[2]', $options[2], 1, false);
81: $sort_form->addOption('ASC', PageLocale::CONF_BLOCK_L_ASC);
82: $sort_form->addOption('DESC', PageLocale::CONF_BLOCK_L_DESC);
83: $block_form->addElement($sort_form);
84:
85: $block_form->addElement(new Xoops\Form\Text(PageLocale::CONF_BLOCK_DISPLAY_NUMBER, 'options[3]', 1, 2, $options[3]), true);
86: $block_form->addElement(new Xoops\Form\RadioYesNo(PageLocale::CONF_BLOCK_ALL_CONTENT, 'options[4]', $options[4]));
87: } else {
88: $xoops = \Xoops::getInstance();
89: $page = $xoops->getModuleHelper('page');
90: $block_form->addElement(new Xoops\Form\Hidden('options[0]', $options[0]));
91: $content = $page->getContentHandler()->getPageTitle(1);
92:
93: $select_form = new Xoops\Form\Select(PageLocale::CONF_BLOCK_CONTENTDISPLAY, 'options[1]', $options[1], 1, false);
94: foreach ($content as $value) {
95: $select_form->addOption($value['content_id'], $value['content_title']);
96: }
97:
98: $block_form->addElement($select_form);
99: }
100: return $block_form->render();
101: }
102: