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: 26: 27: 28: 29: 30: 31:
32: function publisher_items_columns_show($options)
33: {
34: $xoops = Xoops::getInstance();
35: $publisher = Publisher::getInstance();
36:
37: $xoTheme = $xoops->theme();
38:
39:
40: $opt_num_columns = isset($options[0]) ? (int)($options[0]) : '2';
41: $sel_categories = isset($options[1]) ? explode(',', $options[1]) : array();
42: $opt_cat_items = (int)($options[2]);
43: $opt_cat_truncate = isset($options[3]) ? (int)($options[3]) : '0';
44:
45: $block = array();
46: $block['lang_reads'] = _MB_PUBLISHER_READS;
47: $block['lang_comments'] = _MB_PUBLISHER_COMMENTS;
48: $block['lang_readmore'] = _MB_PUBLISHER_READMORE;
49:
50: $sel_categories_obj = array();
51:
52:
53: $categories_obj = $publisher->getCategoryHandler()->getCategories(0, 0, -1);
54:
55:
56: if (!in_array(0, $sel_categories)) {
57: foreach ($categories_obj as $key => $value) {
58: if (in_array($key, $sel_categories)) {
59: $sel_categories_obj[$key] = $value;
60: }
61: }
62: } else {
63: $sel_categories_obj = $categories_obj;
64: }
65:
66: $ccount = count($sel_categories_obj);
67:
68: if ($ccount == 0) {
69: return false;
70: }
71:
72: if ($ccount < $opt_num_columns) {
73: $opt_num_columns = $ccount;
74: }
75:
76: $k = 0;
77: $columns = array();
78:
79:
80: foreach ($sel_categories_obj as $categoryId => $mainitemCatObj) {
81: $categoryItemsObj = $publisher->getItemHandler()->getAllPublished($opt_cat_items, 0, $categoryId);
82: $scount = count($categoryItemsObj);
83: if ($scount > 0 && is_array($categoryItemsObj)) {
84: reset($categoryItemsObj);
85:
86: list($itemid, $thisitem) = each($categoryItemsObj);
87:
88:
89: $mainitem['item_title'] = $thisitem->title();
90: $mainitem['item_cleantitle'] = strip_tags($thisitem->title());
91: $mainitem['item_link'] = $thisitem->getVar('itemid');
92: $mainitem['itemurl'] = $thisitem->getItemUrl();
93: $mainImage = $thisitem->getMainImage();
94:
95: $mainitem['item_image'] = $mainImage['image_path'];
96: if (!empty($mainImage['image_path'])) {
97: $mainitem['item_image'] = \Xoops::getInstance()
98: ->service('thumbnail')
99: ->getImgUrl($mainImage['image_vpath'], 100, 0)
100: ->getValue();
101: }
102:
103: $mainitem['item_summary'] = $thisitem->getBlockSummary($opt_cat_truncate);
104:
105: $mainitem['item_cat_name'] = $mainitemCatObj->getVar('name');
106: $mainitem['item_cat_description'] = $mainitemCatObj->getVar('description') != '' ? $mainitemCatObj->getVar('description') : $mainitemCatObj->getVar('name');
107: $mainitem['item_cat_link'] = $mainitemCatObj->getCategoryLink();
108: $mainitem['categoryurl'] = $mainitemCatObj->getCategoryUrl();
109:
110:
111: if ($scount > 1) {
112: while (list($itemid, $thisitem) = each($categoryItemsObj)) {
113: $subitem['title'] = $thisitem->title();
114: $subitem['cleantitle'] = strip_tags($thisitem->title());
115: $subitem['link'] = $thisitem->getItemLink();
116: $subitem['itemurl'] = $thisitem->getItemUrl();
117: $subitem['summary'] = $thisitem->getBlockSummary($opt_cat_truncate);
118: $mainitem['subitem'][] = $subitem;
119: unset($subitem);
120: }
121: }
122: $columns[$k][] = $mainitem;
123: unset($thisitem);
124: unset($mainitem);
125: ++$k;
126:
127: if ($k == $opt_num_columns) {
128: $k = 0;
129: }
130: }
131: }
132: $block['template'] = $options[4];
133: $block['columns'] = $columns;
134: $block['columnwidth'] = (int)(100 / $opt_num_columns);
135:
136: $xoTheme->addStylesheet(\XoopsBaseConfig::get('url') . '/modules/' . PUBLISHER_DIRNAME . '/css/publisher.css');
137:
138: return $block;
139: }
140:
141: 142: 143: 144: 145: 146:
147: function publisher_items_columns_edit($options)
148: {
149: $form = new Xoops\Form\BlockForm();
150: $colEle = new Xoops\Form\Select(_MB_PUBLISHER_NUMBER_COLUMN_VIEW, 'options[0]', $options[0]);
151: $colEle->addOptionArray(array(
152: '1' => 1,
153: '2' => 2,
154: '3' => 3,
155: '4' => 4,
156: '5' => 5,
157: ));
158: $catEle = new Xoops\Form\Label(_MB_PUBLISHER_SELECTCAT, PublisherUtils::createCategorySelect($options[1], 0, true, 'options[1]'));
159: $cItemsEle = new Xoops\Form\Text(_MB_PUBLISHER_NUMBER_ITEMS_CAT, 'options[2]', 4, 255, $options[2]);
160: $truncateEle = new Xoops\Form\Text(_MB_PUBLISHER_TRUNCATE, 'options[3]', 4, 255, $options[3]);
161:
162: $tempEle = new Xoops\Form\Select(_MB_PUBLISHER_TEMPLATE, 'options[4]', $options[4]);
163: $tempEle->addOptionArray(array(
164: 'normal' => _MB_PUBLISHER_TEMPLATE_NORMAL,
165: 'extended' => _MB_PUBLISHER_TEMPLATE_EXTENDED
166: ));
167:
168: $form->addElement($colEle);
169: $form->addElement($catEle);
170: $form->addElement($cItemsEle);
171: $form->addElement($truncateEle);
172: $form->addElement($tempEle);
173:
174: return $form->render();
175: }
176: