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: function publisher_latest_files_show($options)
26: {
27: $publisher = Publisher::getInstance();
28: 29: 30: 31: 32: 33:
34:
35: $block = array();
36:
37: $sort = $options[1];
38: $order = PublisherUtils::getOrderBy($sort);
39: $limit = $options[2];
40: $directDownload = $options[3];
41:
42:
43: $filesObj = $publisher->getFileHandler()->getAllFiles(0, _PUBLISHER_STATUS_FILE_ACTIVE, $limit, 0, $sort, $order, explode(',', $options[0]));
44:
45: foreach ($filesObj as $fileObj) {
46: $aFile = array();
47: $aFile['link'] = $directDownload ? $fileObj->getFileLink() : $fileObj->getItemLink();
48: if ($sort === "datesub") {
49: $aFile['new'] = $fileObj->datesub();
50: } elseif ($sort === "counter") {
51: $aFile['new'] = $fileObj->getVar('counter');
52: } elseif ($sort === "weight") {
53: $aFile['new'] = $fileObj->getVar('weight');
54: }
55: $block['files'][] = $aFile;
56: }
57:
58: return $block;
59: }
60:
61: function publisher_latest_files_edit($options)
62: {
63: $form = new Xoops\Form\BlockForm();
64:
65: $catEle = new Xoops\Form\Label(_MB_PUBLISHER_SELECTCAT, PublisherUtils::createCategorySelect($options[0], 0, true, 'options[0]'));
66: $orderEle = new Xoops\Form\Select(_MB_PUBLISHER_ORDER, 'options[1]', $options[1]);
67: $orderEle->addOptionArray(array(
68: 'datesub' => _MB_PUBLISHER_DATE,
69: 'counter' => _MB_PUBLISHER_HITS,
70: 'weight' => _MB_PUBLISHER_WEIGHT,
71: ));
72: $dispEle = new Xoops\Form\Text(_MB_PUBLISHER_DISP, 'options[2]', 10, 255, $options[2]);
73: $directEle = new Xoops\Form\RadioYesNo(_MB_PUBLISHER_DIRECTDOWNLOAD, 'options[3]', $options[3]);
74:
75: $form->addElement($catEle);
76: $form->addElement($orderEle);
77: $form->addElement($dispEle);
78: $form->addElement($directEle);
79:
80: return $form->render();
81: }
82: