XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
AbstractEditAction.class.php
1<?php
2
3if (!defined('XOOPS_ROOT_PATH')) {
4 exit();
5}
6
8{
9 public $mObject = null;
10 public $mObjectHandler = null;
11 public $mActionForm = null;
12
13 public function _getId()
14 {
15 }
16
17 public function &_getHandler()
18 {
19 }
20
21 public function _setupActionForm()
22 {
23 }
24
25 public function _setupObject()
26 {
27 $id = $this->_getId();
28
29 $this->mObjectHandler = $this->_getHandler();
30
31 $this->mObject =& $this->mObjectHandler->get($id);
32
33 if (null == $this->mObject && $this->isEnableCreate()) {
34 $this->mObject =& $this->mObjectHandler->create();
35 }
36 }
37
38 public function isEnableCreate()
39 {
40 return true;
41 }
42 public function prepare(&$controller, &$xoopsUser, $moduleConfig)
43 {
44 $this->_setupActionForm();
45 $this->_setupObject();
46 }
47
48 public function getDefaultView(&$controller, &$xoopsUser)
49 {
50 if (null == $this->mObject) {
51 return LEGACYRENDER_FRAME_VIEW_ERROR;
52 }
53
54 $this->mActionForm->load($this->mObject);
55
56 return LEGACYRENDER_FRAME_VIEW_INPUT;
57 }
58
59 public function execute(&$controller, &$xoopsUser)
60 {
61 if (null == $this->mObject) {
62 return LEGACYRENDER_FRAME_VIEW_ERROR;
63 }
64
65 if (null != xoops_getrequest('_form_control_cancel')) {
66 return LEGACYRENDER_FRAME_VIEW_CANCEL;
67 }
68
69 $this->mActionForm->load($this->mObject);
70
71 $this->mActionForm->fetch();
72 $this->mActionForm->validate();
73
74 if ($this->mActionForm->hasError()) {
75 return LEGACYRENDER_FRAME_VIEW_INPUT;
76 }
77
78 $this->mActionForm->update($this->mObject);
79//return $this->_doExecute($this->mObject) ? LEGACYRENDER_FRAME_VIEW_SUCCESS
80 return $this->_doExecute() ? LEGACYRENDER_FRAME_VIEW_SUCCESS
81 : LEGACYRENDER_FRAME_VIEW_ERROR;
82 }
83
84 public function _doExecute()
85 {
86 return $this->mObjectHandler->insert($this->mObject);
87 }
88}