1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | /* |
||
5 | You may not change or alter any portion of this comment or credits |
||
6 | of supporting developers from this source code or any supporting source code |
||
7 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
8 | |||
9 | This program is distributed in the hope that it will be useful, |
||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
12 | */ |
||
13 | |||
14 | /** |
||
15 | * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/ |
||
16 | * @license http://www.fsf.org/copyleft/gpl.html GNU public license |
||
17 | * @since 1.0 |
||
18 | * @author trabis <[email protected]> |
||
19 | * @author The SmartFactory <www.smartfactory.ca> |
||
20 | */ |
||
21 | |||
22 | use Xmf\Request; |
||
23 | use XoopsModules\Publisher\Constants; |
||
24 | use XoopsModules\Publisher\Helper; |
||
25 | use XoopsModules\Publisher\Jsonld; |
||
0 ignored issues
–
show
|
|||
26 | use XoopsModules\Publisher\Metagen; |
||
27 | use XoopsModules\Publisher\Utility; |
||
28 | |||
29 | /** @var Helper $helper */ |
||
30 | require_once __DIR__ . '/header.php'; |
||
31 | |||
32 | // At which record shall we start for the Categories |
||
33 | $catstart = Request::getInt('catstart', 0, 'GET'); |
||
34 | |||
35 | // At which record shall we start for the ITEM |
||
36 | $start = Request::getInt('start', 0, 'GET'); |
||
37 | |||
38 | // Number of categories at the top level |
||
39 | $totalCategories = $helper->getHandler('Category')->getCategoriesCount(0); |
||
40 | |||
41 | // if there ain't no category to display, let's get out of here |
||
42 | if (0 == $totalCategories) { |
||
43 | redirect_header(XOOPS_URL, 2, _MD_PUBLISHER_NO_TOP_PERMISSIONS); |
||
44 | } |
||
45 | |||
46 | $GLOBALS['xoopsOption']['template_main'] = 'publisher_display' . '_' . $helper->getConfig('idxcat_items_display_type') . '.tpl'; |
||
47 | require_once $GLOBALS['xoops']->path('header.php'); |
||
48 | require_once $helper->path('footer.php'); |
||
49 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||
50 | $grouppermHandler = xoops_getHandler('groupperm'); |
||
51 | |||
52 | // Creating the top categories objects |
||
53 | $categoriesObj = $helper->getHandler('Category')->getCategories($helper->getConfig('idxcat_cat_perpage'), $catstart); |
||
54 | |||
55 | // if no categories are found, exit |
||
56 | $totalCategoriesOnPage = count($categoriesObj); |
||
57 | if (0 == $totalCategoriesOnPage) { |
||
58 | redirect_header('<script>javascript:history.go(-1)</script>', 2, _MD_PUBLISHER_NO_CAT_EXISTS); |
||
59 | } |
||
60 | |||
61 | // Get subcats of the top categories |
||
62 | $subcats = $helper->getHandler('Category')->getSubCats($categoriesObj); |
||
63 | |||
64 | // Count of items within each top categories |
||
65 | $totalItems = $helper->getHandler('Category')->publishedItemsCount(); |
||
66 | |||
67 | // real total count of items |
||
68 | $real_total_items = $helper->getHandler('Item')->getItemsCount(-1, [Constants::PUBLISHER_STATUS_PUBLISHED]); |
||
69 | |||
70 | if (1 == $helper->getConfig('idxcat_display_last_item')) { |
||
71 | // Get the last item in each category |
||
72 | $lastItemObj = $helper->getHandler('Item')->getLastPublishedByCat(array_merge([$categoriesObj], $subcats)); |
||
73 | } |
||
74 | |||
75 | // Max size of the title in the last item column |
||
76 | $lastitemsize = (int)$helper->getConfig('idxcat_last_item_size'); |
||
77 | |||
78 | // Hide sub categories in main page only - hacked by Mowaffak |
||
79 | if ('nomain' === $helper->getConfig('idxcat_show_subcats')) { |
||
80 | // $GLOBALS['xoopsModuleConfig']->setConfig('idxcat_show_subcats', 'no'); |
||
81 | $GLOBALS['xoopsModuleConfig']['idxcat_show_subcats'] = 'no'; |
||
82 | } |
||
83 | |||
84 | $categories = []; |
||
85 | foreach ($categoriesObj as $catId => $category) { |
||
86 | $total = 0; |
||
87 | // Do we display sub categories ? |
||
88 | if ('no' !== $helper->getConfig('idxcat_show_subcats')) { |
||
89 | // if this category has subcats |
||
90 | if (isset($subcats[$catId])) { |
||
91 | foreach ($subcats[$catId] as $key => $subcat) { |
||
92 | // Get the items count of this very category |
||
93 | $subcatTotalItems = $totalItems[$key] ?? 0; |
||
94 | // Do we display empty sub-cats ? |
||
95 | if (($subcatTotalItems > 0) || ('all' === $helper->getConfig('idxcat_show_subcats'))) { |
||
96 | $subcatId = $subcat->getVar('categoryid'); |
||
97 | // if we retrieved the last item object for this category |
||
98 | if (isset($lastItemObj[$subcatId])) { |
||
99 | $subcat->setVar('last_itemid', $lastItemObj[$subcatId]->itemid()); |
||
100 | $subcat->setVar('last_title_link', $lastItemObj[$subcatId]->getItemLink(false, $lastitemsize)); |
||
101 | } |
||
102 | |||
103 | $numItems = isset($totalItems[$subcatId]) ? $totalItems[$key] : 0; |
||
104 | $subcat->setVar('itemcount', $numItems); |
||
105 | // Put this subcat in the smarty variable |
||
106 | $categories[$catId]['subcats'][$key] = $subcat->toArrayTable(); |
||
107 | //$total += $numItems; |
||
108 | } |
||
109 | } |
||
110 | // unset($subcat); |
||
111 | } |
||
112 | } |
||
113 | |||
114 | $categories[$catId]['subcatscount'] = isset($subcats[$catId]) ? count($subcats[$catId]) : 0; |
||
115 | |||
116 | // Get the items count of this very category |
||
117 | if (isset($totalItems[$catId]) && $totalItems[$catId] > 0) { |
||
118 | $total += $totalItems[$catId]; |
||
119 | } |
||
120 | // I'm commenting out this to also display empty categories... |
||
121 | // if ($total > 0) { |
||
122 | if (isset($lastItemObj[$catId])) { |
||
123 | $category->setVar('last_itemid', $lastItemObj[$catId]->getVar('itemid')); |
||
124 | $category->setVar('last_title_link', $lastItemObj[$catId]->getItemLink(false, $lastitemsize)); |
||
125 | } |
||
126 | $category->setVar('itemcount', $total); |
||
127 | |||
128 | if (!isset($categories[$catId])) { |
||
129 | $categories[$catId] = []; |
||
130 | } |
||
131 | |||
132 | $categories[$catId] = $category->toArrayTable($categories[$catId]); |
||
133 | } |
||
134 | unset($categoriesObj); |
||
135 | |||
136 | if (isset($categories[$catId])) { |
||
137 | $categories[$catId] = $category->toArraySimple($categories[$catId]); |
||
138 | $categories[$catId]['categoryPath'] = $category->getCategoryPath($helper->getConfig('format_linked_path')); |
||
139 | } |
||
140 | |||
141 | unset($catId, $category); |
||
142 | |||
143 | $xoopsTpl->assign('categories', $categories); |
||
144 | |||
145 | if ($helper->getConfig('index_display_last_items')) { |
||
146 | // creating the Item objects that belong to the selected category |
||
147 | switch ($helper->getConfig('format_order_by')) { |
||
148 | case 'title': |
||
149 | $sort = 'title'; |
||
150 | $order = 'ASC'; |
||
151 | break; |
||
152 | case 'date': |
||
153 | $sort = 'datesub'; |
||
154 | $order = 'DESC'; |
||
155 | break; |
||
156 | case 'counter': |
||
157 | $sort = 'counter'; |
||
158 | $order = 'DESC'; |
||
159 | break; |
||
160 | case 'rating': |
||
161 | $sort = 'rating'; |
||
162 | $order = 'DESC'; |
||
163 | break; |
||
164 | case 'votes': |
||
165 | $sort = 'votes'; |
||
166 | $order = 'DESC'; |
||
167 | break; |
||
168 | case 'comments': |
||
169 | $sort = 'comments'; |
||
170 | $order = 'DESC'; |
||
171 | break; |
||
172 | default: |
||
173 | $sort = 'weight'; |
||
174 | $order = 'ASC'; |
||
175 | break; |
||
176 | } |
||
177 | |||
178 | // Creating the last ITEMs |
||
179 | $itemsObj = $helper->getHandler('Item')->getAllPublished($helper->getConfig('idxcat_index_perpage'), $start, -1, $sort, $order); |
||
180 | $itemsCount = count($itemsObj); |
||
181 | |||
182 | //todo: make config for summary size |
||
183 | if ($itemsCount > 0) { |
||
184 | foreach ($itemsObj as $itemObj) { |
||
185 | $xoopsTpl->append('items', $itemObj->toArraySimple($helper->getConfig('idxcat_items_display_type'), $helper->getConfig('item_title_size'), 300, true)); //if no summary truncate body to 300 |
||
186 | } |
||
187 | $xoopsTpl->assign('show_subtitle', $helper->getConfig('index_disp_subtitle')); |
||
188 | unset($allcategories, $itemObj); |
||
189 | } |
||
190 | unset($itemsObj); |
||
191 | } |
||
192 | |||
193 | // Language constants |
||
194 | $xoopsTpl->assign('title_and_welcome', $helper->getConfig('index_title_and_welcome')); //SHINE ADDED DEBUG mainintro txt |
||
195 | $xoopsTpl->assign('lang_mainintro', $myts->displayTarea($helper->getConfig('index_welcome_msg'), 1)); |
||
196 | $xoopsTpl->assign('sectionname', $helper->getModule()->getVar('name')); |
||
197 | $xoopsTpl->assign('whereInSection', $helper->getModule()->getVar('name')); |
||
198 | $xoopsTpl->assign('module_home', Utility::moduleHome(false)); |
||
199 | $xoopsTpl->assign('indexfooter', $myts->displayTarea($helper->getConfig('index_footer'), 1)); |
||
200 | |||
201 | $xoopsTpl->assign('lang_category_summary', _MD_PUBLISHER_INDEX_CATEGORIES_SUMMARY); |
||
202 | $xoopsTpl->assign('lang_category_summary_info', _MD_PUBLISHER_INDEX_CATEGORIES_SUMMARY_INFO); |
||
203 | $xoopsTpl->assign('lang_items_title', _MD_PUBLISHER_INDEX_ITEMS); |
||
204 | $xoopsTpl->assign('indexpage', true); |
||
205 | |||
206 | require_once $GLOBALS['xoops']->path('class/pagenav.php'); |
||
207 | // Category Navigation Bar |
||
208 | $pagenav = new \XoopsPageNav($totalCategories, $helper->getConfig('idxcat_cat_perpage'), $catstart, 'catstart', ''); |
||
209 | if (1 == $helper->getConfig('format_image_nav')) { |
||
210 | $xoopsTpl->assign('catnavbar', '<div style="text-align:right;">' . $pagenav->renderImageNav() . '</div>'); |
||
211 | } else { |
||
212 | $xoopsTpl->assign('catnavbar', '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>'); |
||
213 | } |
||
214 | // ITEM Navigation Bar |
||
215 | $pagenav = new \XoopsPageNav($real_total_items, $helper->getConfig('idxcat_index_perpage'), $start, 'start', ''); |
||
216 | if (1 == $helper->getConfig('format_image_nav')) { |
||
217 | $xoopsTpl->assign('navbar', '<div style="text-align:right;">' . $pagenav->renderImageNav() . '</div>'); |
||
218 | } else { |
||
219 | $xoopsTpl->assign('navbar', '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>'); |
||
220 | } |
||
221 | //show subcategories |
||
222 | $xoopsTpl->assign('show_subcats', $helper->getConfig('idxcat_show_subcats')); |
||
223 | $xoopsTpl->assign('displaylastitems', $helper->getConfig('index_display_last_items')); |
||
224 | |||
225 | /** |
||
226 | * Generating meta information for this page |
||
227 | */ |
||
228 | $publisherMetagen = new Metagen($helper->getModule()->getVar('name')); |
||
229 | $publisherMetagen->createMetaTags(); |
||
230 | |||
231 | // generate JSON-LD and add to page |
||
232 | if ($helper->getConfig('generate_jsonld')) { |
||
233 | global $xoopsConfig, $xoopsUser, $xoops_url; |
||
234 | $jsonld = Jsonld::getIndex($xoopsConfig, $xoopsUser, $xoops_url); |
||
235 | echo $jsonld; |
||
236 | } |
||
237 | |||
238 | // RSS Link |
||
239 | if (1 == $helper->getConfig('idxcat_show_rss_link')) { |
||
240 | $link = sprintf("<a href='%s' title='%s'><img src='%s' border=0 alt='%s'></a>", PUBLISHER_URL . '/backend.php', _MD_PUBLISHER_RSSFEED, PUBLISHER_URL . '/assets/images/rss.gif', _MD_PUBLISHER_RSSFEED); |
||
241 | $xoopsTpl->assign('rssfeed_link', $link); |
||
242 | } |
||
243 | |||
244 | require_once $GLOBALS['xoops']->path('footer.php'); |
||
245 | ?> |
||
246 | |||
247 | <!--<script type="text/javascript">--> |
||
248 | <!-- $(document).ready(function () {--> |
||
249 | <!-- $("img").addClass("img-responsive");--> |
||
250 | <!-- });--> |
||
251 | <!--</script>--> |
||
252 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths