1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22:
23:
24: include_once dirname(__DIR__) . '/include/common.php';
25:
26: function publisher_latest_news_show($options)
27: {
28: $xoops = Xoops::getInstance();
29: $publisher = Publisher::getInstance();
30: $publisher->loadLanguage('main');
31:
32: $block = array();
33:
34: $start = $options[0];
35: $limit = $options[1];
36: $column_count = $options[2];
37: $letters = $options[3];
38: $selected_stories = $options[4];
39: $sort = $options[9];
40: $order = PublisherUtils::getOrderBy($sort);
41: $imgwidth = $options[11];
42: $imgheight = $options[12];
43: $border = $options[13];
44: $bordercolor = $options[14];
45:
46: $block['spec']['columnwidth'] = (int)(1 / $column_count * 100);
47:
48: $allcats = false;
49: if (!isset($options[29])) {
50: $allcats = true;
51: } elseif (in_array(0, explode(',', $options[29]))) {
52: $allcats = true;
53: }
54:
55:
56: if ($allcats) {
57: $criteria = null;
58: } else {
59: $criteria = new CriteriaCompo();
60: $criteria->add(new Criteria('categoryid', '(' . $options[29] . ')', 'IN'));
61: }
62:
63:
64: if ($selected_stories != 0) {
65: unset($criteria);
66: $criteria = new CriteriaCompo();
67: $criteria->add(new Criteria('itemid', '(' . $selected_stories . ')', 'IN'));
68: }
69:
70: $itemsObj = $publisher->getItemHandler()->getItems($limit, $start, array(_PUBLISHER_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, 'itemid');
71:
72: $scount = count($itemsObj);
73:
74: if ($scount == 0) {
75: return false;
76: }
77: $k = 0;
78: $columns = array();
79:
80: $thumbService = \Xoops::getInstance()->service('thumbnail');
81:
82:
83: foreach ($itemsObj as $itemObj) {
84: $item = array();
85: $item['itemurl'] = $itemObj->getItemUrl();
86: $item['title'] = $itemObj->getItemLink();
87: $item['alt'] = strip_tags($itemObj->getItemLink());
88: $mainImage = $itemObj->getMainImage();
89: $item['item_image'] = $thumbService
90: ->getImgUrl($mainImage['image_vpath'], $imgwidth, 0)
91: ->getValue();
92:
93: $item['text'] = $itemObj->getBlockSummary($letters);
94:
95: $item = $itemObj->getMainImage($item);
96:
97: $ls_height = '';
98: if ($options[12] != 0) {
99: $ls_height = 'height="' . $imgheight . '" ';
100: }
101:
102: if ($options[15] === 'LEFT') {
103: $imgposition = "float: left";
104: $ls_margin = '-right';
105: } elseif ($options[15] === 'CENTER') {
106: $imgposition = "text-align:center";
107: $ls_margin = '';
108: } else {
109: $imgposition = "float: right";
110: $ls_margin = '-left';
111: }
112:
113:
114:
115: if ($options[10] == 1 && $item['image_path'] != '') {
116: $startdiv = '<div style="' . $imgposition . '"><a href="' . $item['itemurl'] . '">';
117: $style = 'style="margin' . $ls_margin . ': 10px; padding: 2px; border: ' . $border . 'px solid #' . $bordercolor . '"';
118: $enddiv = 'width="' . $imgwidth . '" ' . $ls_height . '/></a></div>';
119: $image = $startdiv . '<img ' . $style . ' src="' . $item['item_image'] . '" alt="' . $item['image_name'] . '" ' . $enddiv;
120:
121: $item['image'] = $image;
122: }
123:
124: if ($publisher->isUserAdmin()) {
125: $item['admin'] = "<a href='" . PUBLISHER_URL . "/submit.php?itemid=" . $itemObj->getVar('itemid'). "'><img src='" . PUBLISHER_URL . "/images/links/edit.gif'" . " title='" . _CO_PUBLISHER_EDIT . "' alt='" . _CO_PUBLISHER_EDIT . "' /></a> ";
126: $item['admin'] .= "<a href='" . PUBLISHER_URL . "/admin/item.php?op=del&itemid=" . $itemObj->getVar('itemid'). "'><img src='" . PUBLISHER_URL . "/images/links/delete.png'" . " title='" . _CO_PUBLISHER_DELETE . "' alt='" . _CO_PUBLISHER_DELETE . "' /></a>";
127: } else {
128: $item['admin'] = '';
129: }
130:
131: $block['topiclink'] = '';
132: 133: 134: 135: 136:
137: $block['archivelink'] = '';
138: if ($options[17] == 1) {
139: $block['archivelink'] = '| <a href="' . PUBLISHER_URL . '/archive.php">' . _MB_PUBLISHER_ARCHIVE . '</a> ';
140: }
141:
142:
143: $block['submitlink'] = '';
144: if ($options[18] == 1 && $xoops->isUser()) {
145: $block['submitlink'] = '| <a href="' . PUBLISHER_URL . '/submit.php">' . _MB_PUBLISHER_SUBMITNEWS . '</a> ';
146: }
147:
148: $item['poster'] = '';
149: if ($options[19] == 1) {
150: $item['poster'] = _MB_PUBLISHER_POSTER . ' ' . $itemObj->posterName();
151: }
152:
153: $item['posttime'] = '';
154: if ($options[20] == 1) {
155:
156: $item['posttime'] = strtolower(XoopsLocale::ON) . ' ' . $itemObj->datesub();
157: }
158:
159: $item['topic_title'] = '';
160: if ($options[21] == 1) {
161: $item['topic_title'] = $itemObj->getCategoryLink() . _MB_PUBLISHER_SP;
162: }
163:
164: $item['read'] = '';
165: if ($options[22] == 1) {
166:
167: $item['read'] = ' (' . $itemObj->getVar('counter') . ' ' . strtolower(XoopsLocale::READS) . ')';
168: }
169:
170: $item['more'] = '';
171: if ($itemObj->body() != '' || $itemObj->getVar('comments') > 0) {
172: $item['more'] = '<a class="publisher_spotlight_readmore" href="' . $itemObj->getItemUrl() . '">' . _MB_PUBLISHER_READMORE . '</a>';
173: }
174:
175: $comments = $itemObj->getVar('comments');
176: if ($options[23] == 1) {
177: if ($comments > 0) {
178:
179:
180: if ($comments == 1) {
181: $item['comment'] = ' ' . _MB_PUBLISHER_ONECOMMENT . ' ';
182: } else {
183: $item['comment'] = ' ' . $comments . ' ' . _MB_PUBLISHER_COMMENTS . ' ';
184: }
185: } else {
186: $item['comment'] = ' ' . _MB_PUBLISHER_NO_COMMENTS . ' ';
187: }
188: }
189:
190: $item['print'] = '';
191: if ($options[24] == 1) {
192: $item['print'] = '<a href="' . PublisherUtils::seoGenUrl("print", $itemObj->getVar('itemid'), $itemObj->getVar('short_url')) . '" rel="nofollow"><img src="' . PUBLISHER_URL . '/images/links/print.gif" title="' . _CO_PUBLISHER_PRINT . '" alt="' . _CO_PUBLISHER_PRINT . '" /></a> ';
193: }
194:
195: $item['pdf'] = '';
196: if ($options[25] == 1) {
197: $item['pdf'] = "<a href='" . PUBLISHER_URL . "/makepdf.php?itemid=" . $itemObj->getVar('itemid'). "' rel='nofollow'><img src='" . PUBLISHER_URL . "/images/links/pdf.gif' title='" . _CO_PUBLISHER_PDF . "' alt='" . _CO_PUBLISHER_PDF . "' /></a> ";
198: }
199:
200: $item['email'] = '';
201: if ($options[26] == 1 && $xoops->isActiveModule('tellafriend')) {
202: $subject = sprintf(_CO_PUBLISHER_INTITEMFOUND, $xoops->getConfig('sitename'));
203: $subject = $itemObj->_convert_for_japanese($subject);
204: $maillink = PublisherUtils::tellafriend($subject);
205:
206: $item['email'] = '<a href="' . $maillink . '"><img src="' . PUBLISHER_URL . '/images/links/friend.gif" title="' . _CO_PUBLISHER_MAIL . '" alt="' . _CO_PUBLISHER_MAIL . '" /></a> ';
207: }
208:
209: $block['morelink'] = '';
210: if ($options[27] == 1) {
211: $block['morelink'] = '<a href="' . PUBLISHER_URL . '/index.php">' . _MB_PUBLISHER_MORE_ITEMS . '</a> ';
212: }
213:
214: $block['latestnews_scroll'] = false;
215: if ($options[5] == 1) {
216: $block['latestnews_scroll'] = true;
217: }
218:
219: $block['scrollheight'] = $options[6];
220: $block['scrollspeed'] = $options[7];
221: $block['scrolldir'] = $options[8];
222:
223: $block['template'] = $options[28];
224:
225: $block['imgwidth'] = $options[11];
226: $block['imgheight'] = $options[12];
227:
228: $block['letters'] = $letters;
229:
230: $columns[$k][] = $item;
231: ++$k;
232:
233: if ($k == $column_count) {
234: $k = 0;
235: }
236: }
237:
238: unset($item);
239: $block['columns'] = $columns;
240:
241: return $block;
242: }
243:
244: function publisher_latest_news_edit($options)
245: {
246: $tabletag1 = '<tr><td style="padding:3px" width="37%">';
247: $tabletag2 = '</td><td style="padding:3px">';
248: $tabletag3 = '<tr><td style="padding-top:20px;border-bottom:1px solid #000" colspan="2">';
249: $tabletag4 = '</td></tr>';
250:
251: $form = "<table border='0' cellpadding='0' cellspacing='0'>";
252: $form .= $tabletag3 . _MB_PUBLISHER_GENERALCONFIG . $tabletag4;
253: $form .= $tabletag1 . _MB_PUBLISHER_FIRST . $tabletag2;
254: $form .= "<input type='text' name='options[]' value='" . $options[0] . "' size='4'> " . _MB_PUBLISHER_ITEMS . "</td></tr>";
255: $form .= $tabletag1 . _MB_PUBLISHER_DISP . $tabletag2;
256: $form .= "<input type='text' name='options[]' value='" . $options[1] . "' size='4'> " . _MB_PUBLISHER_ITEMS . "</td></tr>";
257: $form .= $tabletag1 . _MB_PUBLISHER_COLUMNS . $tabletag2;
258: $form .= "<input type='text' name='options[]' value='" . $options[2] . "' size='4'> " . _MB_PUBLISHER_COLUMN . "</td></tr>";
259: $form .= $tabletag1 . _MB_PUBLISHER_TEXTLENGTH . $tabletag2;
260: $form .= "<input type='text' name='options[]' value='" . $options[3] . "' size='4'> " . _MB_PUBLISHER_LETTER . "</td></tr>";
261: $form .= $tabletag1 . _MB_PUBLISHER_SELECTEDSTORIES . $tabletag2;
262: $form .= "<input type='text' name='options[]' value='" . $options[4] . "' size='16'></td></tr>";
263: $form .= $tabletag1 . _MB_PUBLISHER_SCROLL . $tabletag2;
264: $form .= publisher_mk_chkbox($options, 5);
265: $form .= $tabletag1 . _MB_PUBLISHER_SCROLLHEIGHT . $tabletag2;
266: $form .= "<input type='text' name='options[]' value='" . $options[6] . "' size='4'></td></tr>";
267: $form .= $tabletag1 . _MB_PUBLISHER_SCROLLSPEED . $tabletag2;
268: $form .= "<input type='text' name='options[]' value='" . $options[7] . "' size='4'></td></tr>";
269: $form .= $tabletag1 . _MB_PUBLISHER_SCROLLDIR . $tabletag2;
270:
271: $form .= "<select size='1' name='options[8]'>";
272:
273: $directions = array('right' => _MB_PUBLISHER_SCROLL_RIGHT, 'left' => _MB_PUBLISHER_SCROLL_LEFT, 'up' => _MB_PUBLISHER_SCROLL_UP, 'down' => _MB_PUBLISHER_SCROLL_DOWN);
274: foreach ($directions as $key => $value) {
275: $form .= "<option value='{$key}'";
276: if ($options[8] == $key) {
277: $form .= " selected='selected'";
278: }
279: $form .= ">{$value}</option>";
280: }
281: $form .= "</select></td></tr>";
282:
283: $form .= $tabletag1 . _MB_PUBLISHER_ORDER . $tabletag2;
284:
285: $form .= "<select name='options[9]'>";
286: $form .= "<option value='datesub'";
287: if ($options[9] === "datesub") {
288: $form .= " selected='selected'";
289: }
290: $form .= ">" . _MB_PUBLISHER_DATE . "</option>";
291:
292: $form .= "<option value='counter'";
293: if ($options[9] === "counter") {
294: $form .= " selected='selected'";
295: }
296: $form .= ">" . _MB_PUBLISHER_HITS . "</option>";
297:
298: $form .= "<option value='weight'";
299: if ($options[9] === "weight") {
300: $form .= " selected='selected'";
301: }
302: $form .= ">" . _MB_PUBLISHER_WEIGHT . "</option>";
303:
304: $form .= "</select></td></tr>";
305:
306: $form .= $tabletag3 . _MB_PUBLISHER_PHOTOSCONFIG . $tabletag4;
307: $form .= $tabletag1 . _MB_PUBLISHER_IMGDISPLAY . $tabletag2;
308: $form .= publisher_mk_chkbox($options, 10);
309: $form .= $tabletag1 . _MB_PUBLISHER_IMGWIDTH . $tabletag2;
310: $form .= "<input type='text' name='options[]' value='" . $options[11] . "' size='4'> " . _MB_PUBLISHER_PIXEL . "</td></tr>";
311: $form .= $tabletag1 . _MB_PUBLISHER_IMGHEIGHT . $tabletag2;
312: $form .= "<input type='text' name='options[]' value='" . $options[12] . "' size='4'> " . _MB_PUBLISHER_PIXEL . "</td></tr>";
313: $form .= $tabletag1 . _MB_PUBLISHER_BORDER . $tabletag2;
314: $form .= "<input type='text' name='options[]' value='" . $options[13] . "' size='4'> " . _MB_PUBLISHER_PIXEL . "</td></tr>";
315: $form .= $tabletag1 . _MB_PUBLISHER_BORDERCOLOR . $tabletag2;
316: $form .= "<input type='text' name='options[]' value='" . $options[14] . "' size='8'></td></tr>";
317: $form .= $tabletag1 . _MB_PUBLISHER_IMGPOSITION . $tabletag2;
318: $form .= "<select name='options[]'>";
319: $form .= "<option value='LEFT'";
320: if ($options[15] === 'LEFT') {
321: $form .= " selected='selected'";
322: }
323: $form .= '>' . XoopsLocale::LEFT . "</option>\n";
324:
325: $form .= "<option value='CENTER'";
326: if ($options[15] === 'CENTER') {
327: $form .= " selected='selected'";
328: }
329: $form .= '>' . XoopsLocale::CENTER . "</option>\n";
330:
331: $form .= "<option value='RIGHT'";
332: if ($options[15] === 'RIGHT') {
333: $form .= " selected='selected'";
334: }
335: $form .= '>' . XoopsLocale::RIGHT . '</option>';
336: $form .= "</select></td></tr>";
337:
338: $form .= $tabletag3 . _MB_PUBLISHER_LINKSCONFIG . $tabletag4;
339: $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_TOPICLINK . $tabletag2;
340: $form .= publisher_mk_chkbox($options, 16);
341: $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_ARCHIVELINK . $tabletag2;
342: $form .= publisher_mk_chkbox($options, 17);
343: $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_SUBMITLINK . $tabletag2;
344: $form .= publisher_mk_chkbox($options, 18);
345: $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_POSTEDBY . $tabletag2;
346: $form .= publisher_mk_chkbox($options, 19);
347: $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_POSTTIME . $tabletag2;
348: $form .= publisher_mk_chkbox($options, 20);
349: $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_TOPICTITLE . $tabletag2;
350: $form .= publisher_mk_chkbox($options, 21);
351: $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_READ . $tabletag2;
352: $form .= publisher_mk_chkbox($options, 22);
353: $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_COMMENT . $tabletag2;
354: $form .= publisher_mk_chkbox($options, 23);
355: $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_PRINT . $tabletag2;
356: $form .= publisher_mk_chkbox($options, 24);
357: $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_PDF . $tabletag2;
358: $form .= publisher_mk_chkbox($options, 25);
359: $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_EMAIL . $tabletag2;
360: $form .= publisher_mk_chkbox($options, 26);
361: $form .= $tabletag1 . _MB_PUBLISHER_DISPLAY_MORELINK . $tabletag2;
362: $form .= publisher_mk_chkbox($options, 27);
363:
364:
365: $form .= $tabletag3 . _MB_PUBLISHER_TEMPLATESCONFIG . $tabletag4;
366: $form .= $tabletag1 . _MB_PUBLISHER_TEMPLATE . $tabletag2;
367: $form .= "<select size='1' name='options[28]'>";
368:
369: $templates = array('normal' => _MB_PUBLISHER_TEMPLATE_NORMAL, 'extended' => _MB_PUBLISHER_TEMPLATE_EXTENDED, 'ticker' => _MB_PUBLISHER_TEMPLATE_TICKER, 'slider1' => _MB_PUBLISHER_TEMPLATE_SLIDER1, 'slider2' => _MB_PUBLISHER_TEMPLATE_SLIDER2);
370: foreach ($templates as $key => $value) {
371: $form .= "<option value='{$key}'";
372: if ($options[28] == $key) {
373: $form .= " selected='selected'";
374: }
375: $form .= ">{$value}</option>";
376: }
377: $form .= "</select></td></tr>";
378:
379:
380: $form .= $tabletag3 . _MB_PUBLISHER_TOPICSCONFIG . $tabletag4;
381: $form .= $tabletag1 . _MB_PUBLISHER_TOPICSDISPLAY . $tabletag2;
382: $form .= PublisherUtils::createCategorySelect($options[29], 0, true, 'options[29]');
383: $form .= '</td></tr>';
384:
385: $form .= "</table>";
386: return $form;
387: }
388:
389: function publisher_mk_chkbox($options, $number)
390: {
391: $chk = "";
392: if ($options[$number] == 1) {
393: $chk = " checked='checked'";
394: }
395: $chkbox = "<input type='radio' name='options[{$number}]' value='1'" . $chk . " /> " . XoopsLocale::YES . " ";
396: $chk = "";
397: if ($options[$number] == 0) {
398: $chk = " checked='checked'";
399: }
400: $chkbox .= "<input type='radio' name='options[{$number}]' value='0'" . $chk . " /> " . XoopsLocale::NO . "</td></tr>";
401: return $chkbox;
402: }
403:
404: function publisher_mk_select($options, $number)
405: {
406: $slc = "";
407: if ($options[$number] == 2) {
408: $slc = " checked='checked'";
409: }
410: $select = "<input type='radio' name='options[{$number}]' value='2'" . $slc . " /> " . XoopsLocale::LEFT . " ";
411: $slc = "";
412: if ($options[$number] == 1) {
413: $slc = " checked='checked'";
414: }
415: $select .= "<input type='radio' name='options[{$number}]' value='1'" . $slc . " /> " . XoopsLocale::CENTER . " ";
416: $slc = "";
417: if ($options[$number] == 0) {
418: $slc = " checked='checked'";
419: }
420: $select .= "<input type='radio' name='options[{$number}]' value='0'" . $slc . " /> " . XoopsLocale::RIGHT . "</td></tr>";
421: return $select;
422: }
423: