1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18: 19:
20:
21: include_once dirname(__DIR__) . '/include/common.php';
22:
23: function publisher_category_items_sel_show($options)
24: {
25: $publisher = Publisher::getInstance();
26:
27: $block = array();
28:
29: $categories = $publisher->getCategoryHandler()->getCategories(0, 0, -1);
30:
31: if (count($categories) == 0) {
32: return $block;
33: }
34:
35: $selectedcatids = explode(',', $options[0]);
36: $sort = $options[1];
37: $order = PublisherUtils::getOrderBy($sort);
38: $limit = $options[2];
39: $start = 0;
40:
41:
42: $block['categories'] = array();
43:
44: foreach ($categories as $catID => $catObj) {
45: if (!in_array(0, $selectedcatids) && !in_array($catID, $selectedcatids)) {
46: continue;
47: }
48:
49: $criteria = new Criteria('categoryid', $catID);
50: $items = $publisher->getItemHandler()->getItems($limit, $start, array(_PUBLISHER_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, true);
51: unset($criteria);
52:
53: if (count($items) == 0) {
54: continue;
55: }
56:
57: $item['title'] = $catObj->getVar('name');
58: $item['itemurl'] = 'none';
59: $block['categories'][$catID]['items'][] = $item;
60:
61:
62: foreach ($items as $itemObj) {
63: $item['title'] = $itemObj->title(isset($options[3]) ? $options[3] : 0);
64: $item['itemurl'] = $itemObj->getItemUrl();
65: $block['categories'][$catID]['items'][] = $item;
66: }
67: $block['categories'][$catID]['name'] = $catObj->getVar('name');
68: }
69:
70: unset($items, $categories);
71:
72:
73: return $block;
74: }
75:
76: function publisher_category_items_sel_edit($options)
77: {
78: $form = new Xoops\Form\BlockForm();
79:
80: $catEle = new Xoops\Form\Label(_MB_PUBLISHER_SELECTCAT, PublisherUtils::createCategorySelect($options[0]), 'options[0]');
81: $orderEle = new Xoops\Form\Select(_MB_PUBLISHER_ORDER, 'options[1]', $options[1]);
82: $orderEle->addOptionArray(array(
83: 'datesub' => _MB_PUBLISHER_DATE,
84: 'counter' => _MB_PUBLISHER_HITS,
85: 'weight' => _MB_PUBLISHER_WEIGHT,
86: ));
87: $dispEle = new Xoops\Form\Text(_MB_PUBLISHER_DISP, 'options[2]', 2, 255, $options[2]);
88: $charsEle = new Xoops\Form\Text(_MB_PUBLISHER_CHARS, 'options[3]', 2, 255, $options[3]);
89:
90: $form->addElement($catEle);
91: $form->addElement($orderEle);
92: $form->addElement($dispEle);
93: $form->addElement($charsEle);
94:
95: return $form->render();
96: }
97: