1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
22:
23: include_once dirname(__DIR__) . '/include/common.php';
24:
25: function publisher_items_recent_show($options)
26: {
27: $publisher = Publisher::getInstance();
28: $myts = \Xoops\Core\Text\Sanitizer::getInstance();
29:
30: $block = array();
31:
32: $selectedcatids = explode(',', $options[0]);
33:
34: if (in_array(0, $selectedcatids)) {
35: $allcats = true;
36: } else {
37: $allcats = false;
38: }
39:
40: $sort = $options[1];
41: $order = PublisherUtils::getOrderBy($sort);
42: $limit = $options[2];
43: $start = 0;
44:
45:
46: if ($allcats) {
47: $criteria = null;
48: } else {
49: $criteria = new CriteriaCompo();
50: $criteria->add(new Criteria('categoryid', '(' . $options[0] . ')', 'IN'));
51: }
52: $itemsObj = $publisher->getItemHandler()->getItems($limit, $start, array(_PUBLISHER_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, true);
53:
54: $totalItems = count($itemsObj);
55:
56: if ($itemsObj) {
57: for ($i = 0; $i < $totalItems; ++$i) {
58:
59: $newItems['itemid'] = $itemsObj[$i]->getVar('itemid');
60: $newItems['title'] = $itemsObj[$i]->title();
61: $newItems['categoryname'] = $itemsObj[$i]->getCategoryName();
62: $newItems['categoryid'] = $itemsObj[$i]->getVar('categoryid');
63: $newItems['date'] = $itemsObj[$i]->datesub();
64: $newItems['poster'] = $itemsObj[$i]->linkedPosterName();
65: $newItems['itemlink'] = $itemsObj[$i]->getItemLink(false, isset($options[3]) ? $options[3] : 65);
66: $newItems['categorylink'] = $itemsObj[$i]->getCategoryLink();
67:
68: $block['items'][] = $newItems;
69: }
70:
71: $block['lang_title'] = _MB_PUBLISHER_ITEMS;
72: $block['lang_category'] = _MB_PUBLISHER_CATEGORY;
73: $block['lang_poster'] = _MB_PUBLISHER_POSTEDBY;
74: $block['lang_date'] = _MB_PUBLISHER_DATE;
75: $modulename = $myts->displayTarea($publisher->getModule()->getVar('name'));
76: $block['lang_visitItem'] = _MB_PUBLISHER_VISITITEM . " " . $modulename;
77: }
78:
79: return $block;
80: }
81:
82: function publisher_items_recent_edit($options)
83: {
84: $form = new Xoops\Form\BlockForm();
85:
86: $catEle = new Xoops\Form\Label(_MB_PUBLISHER_SELECTCAT, PublisherUtils::createCategorySelect($options[0], 0, true, 'options[0]'));
87: $orderEle = new Xoops\Form\Select(_MB_PUBLISHER_ORDER, 'options[1]', $options[1]);
88: $orderEle->addOptionArray(array(
89: 'datesub' => _MB_PUBLISHER_DATE,
90: 'counter' => _MB_PUBLISHER_HITS,
91: 'weight' => _MB_PUBLISHER_WEIGHT,
92: ));
93: $dispEle = new Xoops\Form\Text(_MB_PUBLISHER_DISP, 'options[2]', 2, 255, $options[2]);
94: $charsEle = new Xoops\Form\Text(_MB_PUBLISHER_CHARS, 'options[3]', 2, 255, $options[3]);
95:
96:
97: $form->addElement($catEle);
98: $form->addElement($orderEle);
99: $form->addElement($dispEle);
100: $form->addElement($charsEle);
101:
102: return $form->render();
103: }
104: