1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: use Xoops\Core\Request;
13:
14: 15: 16: 17: 18: 19: 20: 21: 22:
23:
24: include_once __DIR__ . '/admin_header.php';
25: $xoops = Xoops::getInstance();
26:
27: $op = Request::getString('op');
28:
29: function publisher_editFile($showmenu = false, $fileid = 0, $itemid = 0)
30: {
31: $publisher = Publisher::getInstance();
32: $xoops = Xoops::getInstance();
33:
34:
35: if ($fileid != 0) {
36:
37:
38: $fileObj = $publisher->getFileHandler()->get($fileid);
39:
40: if ($fileObj->notLoaded()) {
41: $xoops->redirect("javascript:history.go(-1)", 1, _AM_PUBLISHER_NOFILESELECTED);
42: }
43:
44: if ($showmenu) {
45:
46: }
47:
48: echo "<br />\n";
49: echo "<span style='color: #2F5376; font-weight: bold; font-size: 16px; margin: 6px 06 0 0; '>" . _AM_PUBLISHER_FILE_EDITING . "</span>";
50: echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . _AM_PUBLISHER_FILE_EDITING_DSC . "</span>";
51: PublisherUtils::openCollapsableBar('editfile', 'editfileicon', _AM_PUBLISHER_FILE_INFORMATIONS);
52: } else {
53:
54: $fileObj = $publisher->getFileHandler()->create();
55: $fileObj->setVar('itemid', $itemid);
56: if ($showmenu) {
57:
58: }
59: echo "<span style='color: #2F5376; font-weight: bold; font-size: 16px; margin: 6px 06 0 0; '>" . _AM_PUBLISHER_FILE_ADDING . "</span>";
60: echo "<span style=\"color: #567; margin: 3px 0 12px 0; font-size: small; display: block; \">" . _AM_PUBLISHER_FILE_ADDING_DSC . "</span>";
61: PublisherUtils::openCollapsableBar('addfile', 'addfileicon', _AM_PUBLISHER_FILE_INFORMATIONS);
62: }
63:
64:
65: $files_form = $publisher->getForm($fileObj, 'file');
66: $files_form->display();
67:
68: if ($fileid != 0) {
69: PublisherUtils::closeCollapsableBar('editfile', 'editfileicon');
70: } else {
71: PublisherUtils::closeCollapsableBar('addfile', 'addfileicon');
72: }
73:
74: }
75:
76: $false = false;
77:
78: switch ($op) {
79: case "uploadfile":
80: PublisherUtils::uploadFile(false, true, $false);
81: exit;
82: break;
83:
84: case "uploadanother":
85: PublisherUtils::uploadFile(true, true, $false);
86: exit;
87: break;
88:
89: case "mod":
90: $fileid = isset($_GET['fileid']) ? $_GET['fileid'] : 0;
91: $itemid = isset($_GET['itemid']) ? $_GET['itemid'] : 0;
92: if (($fileid == 0) && ($itemid == 0)) {
93: $xoops->redirect("javascript:history.go(-1)", 3, _AM_PUBLISHER_NOITEMSELECTED);
94: }
95:
96: PublisherUtils::cpHeader();
97: publisher_editFile(true, $fileid, $itemid);
98: break;
99:
100: case "modify":
101: $fileid = isset($_POST['fileid']) ? (int)($_POST['fileid']) : 0;
102:
103:
104:
105: if ($fileid != 0) {
106: $fileObj = $publisher->getFileHandler()->get($fileid);
107: } else {
108: $fileObj = $publisher->getFileHandler()->create();
109: }
110:
111:
112: $fileObj->setVar('name', $_POST['name']);
113: $fileObj->setVar('description', $_POST['description']);
114: $fileObj->setVar('status', (int)($_POST['file_status']));
115:
116:
117: if (!$fileObj->store()) {
118: $xoops->redirect('item.php?op=mod&itemid=' . $fileObj->getVar('itemid'), 3, _AM_PUBLISHER_FILE_EDITING_ERROR . PublisherUtils::formatErrors($fileObj->getErrors()));
119: exit;
120: }
121:
122: $xoops->redirect('item.php?op=mod&itemid=' . $fileObj->getVar('itemid'), 2, _AM_PUBLISHER_FILE_EDITING_SUCCESS);
123: exit();
124: break;
125:
126: case "del":
127:
128: $fileid = isset($_POST['fileid']) ? (int)($_POST['fileid']) : 0;
129: $fileid = isset($_GET['fileid']) ? (int)($_GET['fileid']) : $fileid;
130:
131: $fileObj = $publisher->getFileHandler()->get($fileid);
132:
133: $confirm = isset($_POST['confirm']) ? $_POST['confirm'] : 0;
134: $title = isset($_POST['title']) ? $_POST['title'] : '';
135:
136: if ($confirm) {
137: if (!$publisher->getFileHandler()->delete($fileObj)) {
138: $xoops->redirect('item.php', 2, _AM_PUBLISHER_FILE_DELETE_ERROR);
139: }
140: $xoops->redirect('item.php', 2, sprintf(_AM_PUBLISHER_FILEISDELETED, $fileObj->getVar('name')));
141: } else {
142:
143: $fileid = isset($_GET['fileid']) ? (int)($_GET['fileid']) : 0;
144:
145: PublisherUtils::cpHeader();
146: echo $xoops->confirm(array('op' => 'del', 'fileid' => $fileObj->getVar('fileid'), 'confirm' => 1, 'name' => $fileObj->getVar('name')), 'file.php', _AM_PUBLISHER_DELETETHISFILE . " <br />" . $fileObj->getVar('name') . " <br /> <br />", _AM_PUBLISHER_DELETE);
147: $xoops->footer();
148: }
149: exit();
150: break;
151:
152: case "default":
153: default:
154: PublisherUtils::cpHeader();
155: break;
156: }
157: $xoops->footer();
158: