1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18: 19: 20:
21:
22: include_once __DIR__ . '/admin_header.php';
23:
24: $xoops = Xoops::getInstance();
25:
26: $itemid = isset($_POST['itemid']) ? (int)($_POST['itemid']) : 0;
27:
28: $pick = isset($_GET['pick']) ? (int)($_GET['pick']) : 0;
29: $pick = isset($_POST['pick']) ? (int)($_POST['pick']) : $pick;
30:
31: $statussel = isset($_GET['statussel']) ? (int)($_GET['statussel']) : 0;
32: $statussel = isset($_POST['statussel']) ? (int)($_POST['statussel']) : $statussel;
33:
34: $sortsel = isset($_GET['sortsel']) ? $_GET['sortsel'] : 'itemid';
35: $sortsel = isset($_POST['sortsel']) ? $_POST['sortsel'] : $sortsel;
36:
37: $ordersel = isset($_GET['ordersel']) ? $_GET['ordersel'] : 'DESC';
38: $ordersel = isset($_POST['ordersel']) ? $_POST['ordersel'] : $ordersel;
39:
40: $module_id = $publisher->getModule()->mid();
41: $gperm_handler = $xoops->getHandlerGroupPermission();
42: $groups = $xoops->getUserGroups();
43:
44:
45:
46: $startentry = isset($_GET['startentry']) ? (int)($_GET['startentry']) : 0;
47:
48: PublisherUtils::cpHeader();
49:
50:
51:
52: $totalitems = $publisher->getItemHandler()->getItemsCount();
53:
54:
55: $totalcategories = $publisher->getCategoryHandler()->getCategoriesCount(-1);
56:
57:
58: $totalsubmitted = $publisher->getItemHandler()->getItemsCount(-1, array(_PUBLISHER_STATUS_SUBMITTED));
59:
60:
61: $totalpublished = $publisher->getItemHandler()->getItemsCount(-1, array(_PUBLISHER_STATUS_PUBLISHED));
62:
63:
64: $totaloffline = $publisher->getItemHandler()->getItemsCount(-1, array(_PUBLISHER_STATUS_OFFLINE));
65:
66:
67: $totalrejected = $publisher->getItemHandler()->getItemsCount(-1, array(_PUBLISHER_STATUS_REJECTED));
68:
69:
70: if ((PublisherUtils::getPathStatus('root', true) < 0) ||
71: (PublisherUtils::getPathStatus('images', true) < 0) ||
72: (PublisherUtils::getPathStatus('images/category', true) < 0) ||
73: (PublisherUtils::getPathStatus('images/item', true) < 0) ||
74: (PublisherUtils::getPathStatus('content', true) < 0)) {
75:
76: createDir();
77: }
78:
79: PublisherUtils::openCollapsableBar('inventorytable', 'inventoryicon', _AM_PUBLISHER_INVENTORY);
80: echo "<br />";
81: echo "<table width='100%' class='outer' cellspacing='1' cellpadding='3' border='0' ><tr>";
82: echo "<td class='head'>" . _AM_PUBLISHER_TOTALCAT . "</td><td align='center' class='even'>" . $totalcategories . "</td>";
83: echo "<td class='head'>" . _AM_PUBLISHER_TOTALSUBMITTED . "</td><td align='center' class='even'>" . $totalsubmitted . "</td>";
84: echo "<td class='head'>" . _AM_PUBLISHER_TOTALPUBLISHED . "</td><td align='center' class='even'>" . $totalpublished . "</td>";
85: echo "<td class='head'>" . _AM_PUBLISHER_TOTAL_OFFLINE . "</td><td align='center' class='even'>" . $totaloffline . "</td>";
86: echo "</tr></table>";
87: echo "<br />";
88:
89: echo "<form><div style=\"margin-bottom: 12px;\">";
90: echo "<input type='button' name='button' onclick=\"location='category.php?op=mod'\" value='" . _AM_PUBLISHER_CATEGORY_CREATE . "'> ";
91: echo "<input type='button' name='button' onclick=\"location='item.php?op=mod'\" value='" . _AM_PUBLISHER_CREATEITEM . "'> ";
92: echo "</div></form>";
93:
94: PublisherUtils::closeCollapsableBar('inventorytable', 'inventoryicon');
95:
96:
97: PublisherUtils::openCollapsableBar('allitemstable', 'allitemsicon', _AM_PUBLISHER_ALLITEMS, _AM_PUBLISHER_ALLITEMSMSG);
98:
99: $showingtxt = '';
100: $selectedtxt = '';
101: $cond = "";
102: $selectedtxt0 = '';
103: $selectedtxt1 = '';
104: $selectedtxt2 = '';
105: $selectedtxt3 = '';
106: $selectedtxt4 = '';
107:
108: $sorttxttitle = "";
109: $sorttxtcreated = "";
110: $sorttxtweight = "";
111: $sorttxtitemid = "";
112:
113: $ordertxtasc = '';
114: $ordertxtdesc = '';
115:
116: switch ($sortsel) {
117: case 'title':
118: $sorttxttitle = "selected='selected'";
119: break;
120:
121: case 'datesub':
122: $sorttxtcreated = "selected='selected'";
123: break;
124:
125: case 'weight':
126: $sorttxtweight = "selected='selected'";
127: break;
128:
129: default:
130: $sorttxtitemid = "selected='selected'";
131: break;
132: }
133:
134: switch ($ordersel) {
135: case 'ASC':
136: $ordertxtasc = "selected='selected'";
137: break;
138:
139: default:
140: $ordertxtdesc = "selected='selected'";
141: break;
142: }
143:
144: switch ($statussel) {
145: case _PUBLISHER_STATUS_ALL:
146: $selectedtxt0 = "selected='selected'";
147: $caption = _AM_PUBLISHER_ALL;
148: $cond = "";
149: $status_explaination = _AM_PUBLISHER_ALL_EXP;
150: break;
151:
152: case _PUBLISHER_STATUS_SUBMITTED:
153: $selectedtxt1 = "selected='selected'";
154: $caption = _CO_PUBLISHER_SUBMITTED;
155: $cond = " WHERE status = " . _PUBLISHER_STATUS_SUBMITTED . " ";
156: $status_explaination = _AM_PUBLISHER_SUBMITTED_EXP;
157: break;
158:
159: case _PUBLISHER_STATUS_PUBLISHED:
160: $selectedtxt2 = "selected='selected'";
161: $caption = _CO_PUBLISHER_PUBLISHED;
162: $cond = " WHERE status = " . _PUBLISHER_STATUS_PUBLISHED . " ";
163: $status_explaination = _AM_PUBLISHER_PUBLISHED_EXP;
164: break;
165:
166: case _PUBLISHER_STATUS_OFFLINE:
167: $selectedtxt3 = "selected='selected'";
168: $caption = _CO_PUBLISHER_OFFLINE;
169: $cond = " WHERE status = " . _PUBLISHER_STATUS_OFFLINE . " ";
170: $status_explaination = _AM_PUBLISHER_OFFLINE_EXP;
171: break;
172:
173: case _PUBLISHER_STATUS_REJECTED:
174: $selectedtxt4 = "selected='selected'";
175: $caption = _CO_PUBLISHER_REJECTED;
176: $cond = " WHERE status = " . _PUBLISHER_STATUS_REJECTED . " ";
177: $status_explaination = _AM_PUBLISHER_REJECTED_ITEM_EXP;
178: break;
179: }
180:
181:
182: echo "<form name='pick' id='pick' action='" . $_SERVER['PHP_SELF'] . "' method='POST' style='margin: 0;'>";
183:
184: echo "
185: <table width='100%' cellspacing='1' cellpadding='2' border='0' style='border-left: 1px solid silver; border-top: 1px solid silver; border-right: 1px solid silver;'>
186: <tr>
187: <td><span style='font-weight: bold; font-variant: small-caps;'>" . _AM_PUBLISHER_SHOWING . " " . $caption . "</span></td>
188: <td align='right'>" . _AM_PUBLISHER_SELECT_SORT . "
189: <select name='sortsel' onchange='submit()'>
190: <option value='itemid' $sorttxtitemid>" . _AM_PUBLISHER_ID . "</option>
191: <option value='title' $sorttxttitle>" . _AM_PUBLISHER_TITLE . "</option>
192: <option value='datesub' $sorttxtcreated>" . _AM_PUBLISHER_CREATED . "</option>
193: <option value='weight' $sorttxtweight>" . _CO_PUBLISHER_WEIGHT . "</option>
194: </select>
195: <select name='ordersel' onchange='submit()'>
196: <option value='ASC' $ordertxtasc>" . _AM_PUBLISHER_ASC . "</option>
197: <option value='DESC' $ordertxtdesc>" . _AM_PUBLISHER_DESC . "</option>
198: </select>
199: " . _AM_PUBLISHER_SELECT_STATUS . " :
200: <select name='statussel' onchange='submit()'>
201: <option value='0' $selectedtxt0>" . _AM_PUBLISHER_ALL . " [$totalitems]</option>
202: <option value='1' $selectedtxt1>" . _CO_PUBLISHER_SUBMITTED . " [$totalsubmitted]</option>
203: <option value='2' $selectedtxt2>" . _CO_PUBLISHER_PUBLISHED . " [$totalpublished]</option>
204: <option value='3' $selectedtxt3>" . _CO_PUBLISHER_OFFLINE . " [$totaloffline]</option>
205: <option value='4' $selectedtxt4>" . _CO_PUBLISHER_REJECTED . " [$totalrejected]</option>
206: </select>
207: </td>
208: </tr>
209: </table>
210: </form>";
211:
212:
213:
214: $statusSelected = ($statussel == 0) ? -1 : $statussel;
215:
216: $numrows = $publisher->getItemHandler()->getItemsCount(-1, $statusSelected);
217:
218:
219: $itemsObj = $publisher->getItemHandler()->getItems($publisher->getConfig('idxcat_perpage'), $startentry, $statusSelected, -1, $sortsel, $ordersel);
220:
221: $totalItemsOnPage = count($itemsObj);
222:
223: buildTable();
224:
225: if ($numrows > 0) {
226:
227: for ($i = 0; $i < $totalItemsOnPage; ++$i) {
228:
229: $categoryObj = $itemsObj[$i]->category();
230: $approve = '';
231:
232: switch ($itemsObj[$i]->getVar('status')) {
233:
234: case _PUBLISHER_STATUS_SUBMITTED:
235: $statustxt = _CO_PUBLISHER_SUBMITTED;
236: $approve = "<a href='item.php?op=mod&itemid=" . $itemsObj[$i]->getVar('itemid'). "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/approve.gif' title='" . _AM_PUBLISHER_SUBMISSION_MODERATE . "' alt='" . _AM_PUBLISHER_SUBMISSION_MODERATE . "' /></a> ";
237: $clone = '';
238: $delete = "<a href='item.php?op=del&itemid=" . $itemsObj[$i]->getVar('itemid'). "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='" . _AM_PUBLISHER_DELETEITEM . "' /></a>";
239: $modify = "";
240: break;
241:
242: case _PUBLISHER_STATUS_PUBLISHED:
243: $statustxt = _CO_PUBLISHER_PUBLISHED;
244: $approve = "";
245: $clone = "<a href='item.php?op=clone&itemid=" . $itemsObj[$i]->getVar('itemid'). "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/clone.gif' title='" . _AM_PUBLISHER_CLONE_ITEM . "' alt='" . _AM_PUBLISHER_CLONE_ITEM . "' /></a> ";
246: $modify = "<a href='item.php?op=mod&itemid=" . $itemsObj[$i]->getVar('itemid'). "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/edit.gif' title='" . _AM_PUBLISHER_ITEM_EDIT . "' alt='" . _AM_PUBLISHER_ITEM_EDIT . "' /></a> ";
247: $delete = "<a href='item.php?op=del&itemid=" . $itemsObj[$i]->getVar('itemid'). "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='" . _AM_PUBLISHER_DELETEITEM . "' /></a>";
248: break;
249:
250: case _PUBLISHER_STATUS_OFFLINE:
251: $statustxt = _CO_PUBLISHER_OFFLINE;
252: $approve = "";
253: $clone = "<a href='item.php?op=clone&itemid=" . $itemsObj[$i]->getVar('itemid'). "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/clone.gif' title='" . _AM_PUBLISHER_CLONE_ITEM . "' alt='" . _AM_PUBLISHER_CLONE_ITEM . "' /></a> ";
254: $modify = "<a href='item.php?op=mod&itemid=" . $itemsObj[$i]->getVar('itemid'). "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/edit.gif' title='" . _AM_PUBLISHER_ITEM_EDIT . "' alt='" . _AM_PUBLISHER_ITEM_EDIT . "' /></a> ";
255: $delete = "<a href='item.php?op=del&itemid=" . $itemsObj[$i]->getVar('itemid'). "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='" . _AM_PUBLISHER_DELETEITEM . "' /></a>";
256: break;
257:
258: case _PUBLISHER_STATUS_REJECTED:
259: $statustxt = _CO_PUBLISHER_REJECTED;
260: $approve = "";
261: $clone = "<a href='item.php?op=clone&itemid=" . $itemsObj[$i]->getVar('itemid'). "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/clone.gif' title='" . _AM_PUBLISHER_CLONE_ITEM . "' alt='" . _AM_PUBLISHER_CLONE_ITEM . "' /></a> ";
262: $modify = "<a href='item.php?op=mod&itemid=" . $itemsObj[$i]->getVar('itemid'). "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/edit.gif' title='" . _AM_PUBLISHER_REJECTED_EDIT . "' alt='" . _AM_PUBLISHER_REJECTED_EDIT . "' /></a> ";
263: $delete = "<a href='item.php?op=del&itemid=" . $itemsObj[$i]->getVar('itemid'). "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='" . _AM_PUBLISHER_DELETEITEM . "' /></a>";
264: break;
265:
266: case "default":
267: default:
268: $statustxt = _AM_PUBLISHER_STATUS0;
269: $approve = "";
270: $clone = '';
271: $modify = "<a href='item.php?op=mod&itemid=" . $itemsObj[$i]->getVar('itemid'). "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/edit.gif' title='" . _AM_PUBLISHER_REJECTED_EDIT . "' alt='" . _AM_PUBLISHER_REJECTED_EDIT . "' /></a> ";
272: $delete = "<a href='item.php?op=del&itemid=" . $itemsObj[$i]->getVar('itemid'). "'><img src='" . \XoopsBaseConfig::get('url') . "/modules/" . $publisher->getModule()->dirname() . "/images/links/delete.png' title='" . _AM_PUBLISHER_DELETEITEM . "' alt='" . _AM_PUBLISHER_DELETEITEM . "' /></a>";
273: break;
274: }
275:
276: echo "<tr>";
277: echo "<td class='head' align='center'>" . $itemsObj[$i]->getVar('itemid'). "</td>";
278: echo "<td class='even' align='left'>" . $categoryObj->getCategoryLink() . "</td>";
279: echo "<td class='even' align='left'>" . $itemsObj[$i]->getItemLink() . "</td>";
280: echo "<td class='even' align='center'>" . $itemsObj[$i]->datesub() . "</td>";
281: echo "<td class='even' align='center'>" . $statustxt . "</td>";
282: echo "<td class='even' align='center'> " . $approve . $clone . $modify . $delete . "</td>";
283: echo "</tr>";
284: }
285: } else {
286:
287: echo "<tr>";
288: echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOITEMSSEL . "</td>";
289: echo "</tr>";
290: }
291: echo "</table>\n";
292: echo "<span style=\"color: #567; margin: 3px 0 18px 0; font-size: small; display: block; \">$status_explaination</span>";
293: $pagenav = new XoopsPageNav($numrows, $publisher->getConfig('idxcat_perpage'), $startentry, 'startentry', "statussel=$statussel&sortsel=$sortsel&ordersel=$ordersel");
294:
295: if ($publisher->getConfig('format_image_nav') == 1) {
296: echo '<div style="text-align:right; background-color: white; margin: 10px 0;">' . $pagenav->renderImageNav() . '</div>';
297: } else {
298: echo '<div style="text-align:right; background-color: white; margin: 10px 0;">' . $pagenav->renderNav() . '</div>';
299: }
300:
301: PublisherUtils::closeCollapsableBar('allitemstable', 'allitemsicon');
302:
303:
304: $xoops->footer();
305:
306:
307:
308:
309: function createDir()
310: {
311:
312: $thePath = PublisherUtils::getUploadDir();
313:
314: if (PublisherUtils::getPathStatus('root', true) < 0) {
315: $thePath = PublisherUtils::getUploadDir();
316: $res = PublisherUtils::mkdir($thePath);
317: $msg = $res ? _AM_PUBLISHER_DIRCREATED : _AM_PUBLISHER_DIRNOTCREATED;
318: }
319:
320: if (PublisherUtils::getPathStatus('images', true) < 0) {
321: $thePath = PublisherUtils::getImageDir();
322: $res = PublisherUtils::mkdir($thePath);
323:
324: if ($res) {
325: $source = PUBLISHER_ROOT_PATH . "/images/blank.png";
326: $dest = $thePath . "blank.png";
327: PublisherUtils::copyr($source, $dest);
328: }
329: $msg = $res ? _AM_PUBLISHER_DIRCREATED : _AM_PUBLISHER_DIRNOTCREATED;
330: }
331:
332: if (PublisherUtils::getPathStatus('images/category', true) < 0) {
333: $thePath = PublisherUtils::getImageDir('category');
334: $res = PublisherUtils::mkdir($thePath);
335:
336: if ($res) {
337: $source = PUBLISHER_ROOT_PATH . '/images/blank.png';
338: $dest = $thePath . 'blank.png';
339: PublisherUtils::copyr($source, $dest);
340: }
341: $msg = $res ? _AM_PUBLISHER_DIRCREATED : _AM_PUBLISHER_DIRNOTCREATED;
342: }
343:
344: if (PublisherUtils::getPathStatus('images/item', true) < 0) {
345: $thePath = PublisherUtils::getImageDir('item');
346: $res = PublisherUtils::mkdir($thePath);
347:
348: if ($res) {
349: $source = PUBLISHER_ROOT_PATH . '/images/blank.png';
350: $dest = $thePath . 'blank.png';
351: PublisherUtils::copyr($source, $dest);
352: }
353: $msg = $res ? _AM_PUBLISHER_DIRCREATED : _AM_PUBLISHER_DIRNOTCREATED;
354: }
355:
356: if (PublisherUtils::getPathStatus('content', true) < 0) {
357: $thePath = PublisherUtils::getUploadDir(true, 'content');
358: $res = PublisherUtils::mkdir($thePath);
359: $msg = $res ? _AM_PUBLISHER_DIRCREATED : _AM_PUBLISHER_DIRNOTCREATED;
360: }
361: }
362:
363: function buildTable()
364: {
365: echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'>";
366: echo "<tr>";
367: echo "<td width='40px' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEMID . "</strong></td>";
368: echo "<td width='100px' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEMCAT . "</strong></td>";
369: echo "<td class='bg3' align='center'><strong>" . _AM_PUBLISHER_TITLE . "</strong></td>";
370: echo "<td width='90px' class='bg3' align='center'><strong>" . _AM_PUBLISHER_CREATED . "</strong></td>";
371: echo "<td width='90px' class='bg3' align='center'><strong>" . _CO_PUBLISHER_STATUS . "</strong></td>";
372: echo "<td width='90px' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . "</strong></td>";
373: echo "</tr>";
374: }
375: