1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
22:
23: defined("XOOPS_ROOT_PATH") or die("XOOPS root path not defined");
24:
25: include_once dirname(__DIR__) . '/include/common.php';
26:
27: function publisher_items_new_show($options)
28: {
29: $publisher = Publisher::getInstance();
30:
31: $selectedcatids = explode(',', $options[0]);
32:
33: $block = array();
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[3];
43: $start = 0;
44: $image = $options[5];
45:
46:
47: if ($allcats) {
48: $criteria = null;
49: } else {
50: $criteria = new CriteriaCompo();
51: $criteria->add(new Criteria('categoryid', '(' . $options[0] . ')', 'IN'));
52: }
53: $xoops = \Xoops::getInstance();
54: $thumbService = $xoops->service('thumbnail');
55: $itemsObj = $publisher->getItemHandler()->getItems($limit, $start, array(_PUBLISHER_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria);
56:
57: $totalitems = count($itemsObj);
58: if ($itemsObj) {
59: for ($i = 0; $i < $totalitems; ++$i) {
60:
61: $item = array();
62: $item['link'] = $itemsObj[$i]->getItemLink(false, isset($options[4]) ? $options[4] : 65);
63: $item['id'] = $itemsObj[$i]->getVar('itemid');
64: $item['poster'] = $itemsObj[$i]->posterName();
65:
66: if ($image === 'article') {
67: $item['image'] = \XoopsBaseConfig::get('url') . '/uploads/blank.gif';
68: $item['image_name'] = '';
69: $images = $itemsObj[$i]->getImages();
70: if (is_object($images['main'])) {
71: $item['image'] = $thumbService
72: ->getImgUrl('uploads/' . $images['main']->getVar('image_name'), 50, 0)
73: ->getValue();
74:
75: $item['image_name'] = $images['main']->getVar('image_nicename');
76: }
77: } elseif ($image === 'category') {
78: $item['image'] = $itemsObj[$i]->getCategoryImagePath();
79: $item['image_name'] = $itemsObj[$i]->getCategoryName();
80: } elseif ($image === 'avatar') {
81: $auid = $itemsObj[$i]->getVar('uid');
82: if ($auid == '0') {
83: $item['image'] = \XoopsBaseConfig::get('url') . '/uploads/blank.gif';
84: $images = $itemsObj[$i]->getImages();
85: if (is_object($images['main'])) {
86: $item['image'] = $thumbService
87: ->getImgUrl('uploads/' . $images['main']->getVar('image_name'), 50, 0)
88: ->getValue();
89: }
90: } else {
91: $item['image'] = $xoops->service('avatar')->getAvatarUrl($auid)->getValue();
92: }
93: $item['image_name'] = $itemsObj[$i]->posterName();
94: }
95:
96: $item['title'] = $itemsObj[$i]->title();
97:
98: if ($sort === "datesub") {
99: $item['new'] = $itemsObj[$i]->datesub();
100: } elseif ($sort === "counter") {
101: $item['new'] = $itemsObj[$i]->getVar('counter');
102: } elseif ($sort === "weight") {
103: $item['new'] = $itemsObj[$i]->weight();
104: }
105:
106: $block['newitems'][] = $item;
107: }
108: }
109:
110: $block['show_order'] = $options[2];
111:
112: return $block;
113: }
114:
115: function publisher_items_new_edit($options)
116: {
117: $form = new Xoops\Form\BlockForm();
118:
119: $catEle = new Xoops\Form\Label(_MB_PUBLISHER_SELECTCAT, PublisherUtils::createCategorySelect($options[0], 0, true, 'options[0]'));
120: $orderEle = new Xoops\Form\Select(_MB_PUBLISHER_ORDER, 'options[1]', $options[1]);
121: $orderEle->addOptionArray(array(
122: 'datesub' => _MB_PUBLISHER_DATE,
123: 'counter' => _MB_PUBLISHER_HITS,
124: 'weight' => _MB_PUBLISHER_WEIGHT
125: ));
126:
127: $showEle = new Xoops\Form\RadioYesNo(_MB_PUBLISHER_ORDER_SHOW, 'options[2]', $options[2]);
128: $dispEle = new Xoops\Form\Text(_MB_PUBLISHER_DISP, 'options[3]', 2, 255, $options[3]);
129: $charsEle = new Xoops\Form\Text(_MB_PUBLISHER_CHARS, 'options[4]', 2, 255, $options[4]);
130:
131: $imageEle = new Xoops\Form\Select(_MB_PUBLISHER_IMAGE_TO_DISPLAY, 'options[5]', $options[5]);
132: $imageEle->addOptionArray(array(
133: 'none' => XoopsLocale::NONE,
134: 'article' => _MB_PUBLISHER_IMAGE_ARTICLE,
135: 'category' => _MB_PUBLISHER_IMAGE_CATEGORY,
136: 'avatar' => _MB_PUBLISHER_IMAGE_AVATAR
137: ));
138:
139: $form->addElement($catEle);
140: $form->addElement($orderEle);
141: $form->addElement($showEle);
142: $form->addElement($dispEle);
143: $form->addElement($charsEle);
144: $form->addElement($imageEle);
145:
146: return $form->render();
147: }
148: