1: <?php
2: 3: 4: 5: 6: 7: 8: 9:
10:
11: if (!defined('XOOPS_ROOT_PATH')) exit();
12:
13: require_once XOOPS_MODULE_PATH . "/legacy/class/AbstractEditAction.class.php";
14: require_once XOOPS_MODULE_PATH . "/legacy/admin/forms/ImageAdminEditForm.class.php";
15:
16: class Legacy_ImageCreateAction extends Legacy_AbstractEditAction
17: {
18: function _getId()
19: {
20: return 0;
21: }
22:
23: function &_getHandler()
24: {
25: $handler =& xoops_getmodulehandler('image', 'legacy');
26: return $handler;
27: }
28:
29: function _setupActionForm()
30: {
31: $this->mActionForm =new Legacy_ImageAdminCreateForm();
32: $this->mActionForm->prepare();
33: }
34:
35: function getDefaultView(&$controller, &$xoopsUser)
36: {
37: $flag = parent::getDefaultView($controller, $xoopsUser);
38:
39: if ($flag == LEGACY_FRAME_VIEW_INPUT && $this->_enableCatchImgcat()) {
40: $this->mActionForm->set('imgcat_id', xoops_getrequest('imgcat_id'));
41: }
42:
43: return $flag;
44: }
45:
46: function _enableCatchImgcat()
47: {
48: return true;
49: }
50:
51: function _doExecute()
52: {
53: $handler =& xoops_getmodulehandler('imagecategory', 'legacy');
54: $category =& $handler->get($this->mActionForm->get('imgcat_id'));
55:
56:
57:
58:
59:
60: if ($category->get('imgcat_storetype') == 'file') {
61: $this->_storeFile();
62: }
63: else {
64: $this->_storeDB();
65: }
66:
67: return parent::_doExecute();
68: }
69:
70: function _storeFile()
71: {
72: if ($this->mActionForm->mFormFile == null) {
73: return null;
74: }
75:
76:
77:
78:
79: if ($this->mActionForm->mOldFileName != null) {
80: @unlink(XOOPS_UPLOAD_PATH . "/" . $this->mActionForm->mOldFileName);
81:
82:
83: $match = array();
84: if (preg_match("/(.+)\.\w+$/", $this->mActionForm->mOldFileName, $match)) {
85: $this->mActionForm->mFormFile->setBodyName($match[1]);
86: }
87: }
88:
89: $this->mObject->set('image_name', $this->mActionForm->mFormFile->getFileName());
90:
91: return $this->mActionForm->mFormFile->saveAs(XOOPS_UPLOAD_PATH);
92: }
93:
94: function _storeDB()
95: {
96:
97: }
98:
99: function executeViewInput(&$controller, &$xoopsUser, &$render)
100: {
101: $this->mObject->loadImagecategory();
102:
103: $render->setTemplateName("image_edit.html");
104: $render->setAttribute('actionForm', $this->mActionForm);
105: $render->setAttribute('object', $this->mObject);
106:
107: $handler =& xoops_getmodulehandler('imagecategory', 'legacy');
108: $categoryArr =& $handler->getObjects();
109: $render->setAttribute('categoryArr', $categoryArr);
110: }
111:
112: function executeViewSuccess(&$controller, &$xoopsUser, &$render)
113: {
114: $controller->executeForward("./index.php?action=ImageList&imgcat_id=" . $this->mActionForm->get('imgcat_id'));
115: }
116:
117: function executeViewError(&$controller, &$xoopsUser, &$render)
118: {
119: $controller->executeRedirect("./index.php?action=ImagecategoryList", 1, _MD_LEGACY_ERROR_DBUPDATE_FAILED);
120: }
121:
122: function executeViewCancel(&$controller, &$xoopsUser, &$render)
123: {
124: $controller->executeForward("./index.php?action=ImagecategoryList");
125: }
126: }
127:
128: ?>
129: