1
|
|
|
<?php |
|
|
|
|
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ |
14
|
|
|
* @license http://www.fsf.org/copyleft/gpl.html GNU public license |
15
|
|
|
* @package Publisher |
16
|
|
|
* @subpackage Blocks |
17
|
|
|
* @since 1.0 |
18
|
|
|
* @author trabis <[email protected]> |
19
|
|
|
* @author The SmartFactory <www.smartfactory.ca> |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
|
|
|
|
23
|
|
|
|
24
|
|
|
include_once dirname(__DIR__) . '/include/common.php'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @param $options |
28
|
|
|
* |
29
|
|
|
* @return array |
30
|
|
|
*/ |
31
|
|
|
function publisher_items_recent_show($options) |
32
|
|
|
{ |
33
|
|
|
$publisher = PublisherPublisher::getInstance(); |
34
|
|
|
$myts = MyTextSanitizer::getInstance(); |
35
|
|
|
|
36
|
|
|
$block = array(); |
37
|
|
|
|
38
|
|
|
$selectedcatids = explode(',', $options[0]); |
39
|
|
|
|
40
|
|
|
$allcats = false; |
41
|
|
|
if (in_array(0, $selectedcatids)) { |
42
|
|
|
$allcats = true; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
$sort = $options[1]; |
46
|
|
|
$order = publisherGetOrderBy($sort); |
47
|
|
|
$limit = $options[2]; |
48
|
|
|
$start = 0; |
49
|
|
|
|
50
|
|
|
// creating the ITEM objects that belong to the selected category |
51
|
|
View Code Duplication |
if ($allcats) { |
|
|
|
|
52
|
|
|
$criteria = null; |
53
|
|
|
} else { |
54
|
|
|
$criteria = new CriteriaCompo(); |
55
|
|
|
$criteria->add(new Criteria('categoryid', '(' . $options[0] . ')', 'IN')); |
56
|
|
|
} |
57
|
|
|
$itemsObj = $publisher->getHandler('item')->getItems($limit, $start, array(PublisherConstants::PUBLISHER_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, true); |
58
|
|
|
|
59
|
|
|
$totalItems = count($itemsObj); |
60
|
|
|
|
61
|
|
|
if ($itemsObj && $totalItems > 1) { |
62
|
|
View Code Duplication |
for ($i = 0; $i < $totalItems; ++$i) { |
|
|
|
|
63
|
|
|
$newItems['itemid'] = $itemsObj[$i]->itemid(); |
|
|
|
|
64
|
|
|
$newItems['title'] = $itemsObj[$i]->getTitle(); |
|
|
|
|
65
|
|
|
$newItems['categoryname'] = $itemsObj[$i]->getCategoryName(); |
66
|
|
|
$newItems['categoryid'] = $itemsObj[$i]->categoryid(); |
67
|
|
|
$newItems['date'] = $itemsObj[$i]->getDatesub(); |
68
|
|
|
$newItems['poster'] = $itemsObj[$i]->getLinkedPosterName(); |
69
|
|
|
$newItems['itemlink'] = $itemsObj[$i]->getItemLink(false, isset($options[3]) ? $options[3] : 65); |
70
|
|
|
$newItems['categorylink'] = $itemsObj[$i]->getCategoryLink(); |
71
|
|
|
|
72
|
|
|
$block['items'][] = $newItems; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
$block['lang_title'] = _MB_PUBLISHER_ITEMS; |
76
|
|
|
$block['lang_category'] = _MB_PUBLISHER_CATEGORY; |
77
|
|
|
$block['lang_poster'] = _MB_PUBLISHER_POSTEDBY; |
78
|
|
|
$block['lang_date'] = _MB_PUBLISHER_DATE; |
79
|
|
|
$modulename = $myts->displayTarea($publisher->getModule()->getVar('name')); |
|
|
|
|
80
|
|
|
$block['lang_visitItem'] = _MB_PUBLISHER_VISITITEM . ' ' . $modulename; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
return $block; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @param $options |
88
|
|
|
* |
89
|
|
|
* @return string |
90
|
|
|
*/ |
91
|
|
View Code Duplication |
function publisher_items_recent_edit($options) |
|
|
|
|
92
|
|
|
{ |
93
|
|
|
include_once PUBLISHER_ROOT_PATH . '/class/blockform.php'; |
94
|
|
|
xoops_load('XoopsFormLoader'); |
95
|
|
|
|
96
|
|
|
$form = new PublisherBlockForm(); |
97
|
|
|
|
98
|
|
|
$catEle = new XoopsFormLabel(_MB_PUBLISHER_SELECTCAT, publisherCreateCategorySelect($options[0], 0, true, 'options[0]')); |
99
|
|
|
$orderEle = new XoopsFormSelect(_MB_PUBLISHER_ORDER, 'options[1]', $options[1]); |
100
|
|
|
$orderEle->addOptionArray(array( |
101
|
|
|
'datesub' => _MB_PUBLISHER_DATE, |
102
|
|
|
'counter' => _MB_PUBLISHER_HITS, |
103
|
|
|
'weight' => _MB_PUBLISHER_WEIGHT |
104
|
|
|
)); |
105
|
|
|
$dispEle = new XoopsFormText(_MB_PUBLISHER_DISP, 'options[2]', 10, 255, $options[2]); |
106
|
|
|
$charsEle = new XoopsFormText(_MB_PUBLISHER_CHARS, 'options[3]', 10, 255, $options[3]); |
107
|
|
|
|
108
|
|
|
$form->addElement($catEle); |
109
|
|
|
$form->addElement($orderEle); |
110
|
|
|
$form->addElement($dispEle); |
111
|
|
|
$form->addElement($charsEle); |
112
|
|
|
|
113
|
|
|
return $form->render(); |
114
|
|
|
} |
115
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.