XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
CustomBlockEditAction.class.php
1<?php
11
12if (!defined('XOOPS_ROOT_PATH')) {
13 exit();
14}
15
16require_once XOOPS_MODULE_PATH . '/legacy/class/AbstractEditAction.class.php';
17require_once XOOPS_MODULE_PATH . '/legacy/admin/actions/BlockEditAction.class.php';
18require_once XOOPS_MODULE_PATH . '/legacy/admin/forms/CustomBlockEditForm.class.php';
19require_once XOOPS_ROOT_PATH . '/class/xoopsblock.php';
20
22{
23 public function _setupActionForm()
24 {
25 $this->mActionForm =new Legacy_CustomBlockEditForm();
26 $this->mActionForm->prepare();
27 }
28
29 public function isEnableCreate()
30 {
31 return true;
32 }
33
34 public function _isEditable()
35 {
36 return true;
37 }
38
39 public function executeViewInput(&$controller, &$xoopsUser, &$render)
40 {
41 $moduleArr = [];
42 $render->setTemplateName('customblock_edit.html');
43 $render->setAttribute('actionForm', $this->mActionForm);
44
45 //
46 // lazy loading
47 //
48 $this->mObject->loadModule();
49
50 $render->setAttribute('object', $this->mObject);
51
52 //
53 // Build active modules list and set.
54 //
55 $handler =& xoops_gethandler('module');
56 $moduleArr[0] =& $handler->create();
57 $moduleArr[0]->set('mid', -1);
58 $moduleArr[0]->set('name', _AD_LEGACY_LANG_TOPPAGE);
59
60 $moduleArr[1] =& $handler->create();
61 $moduleArr[1]->set('mid', 0);
62 $moduleArr[1]->set('name', _AD_LEGACY_LANG_ALL_MODULES);
63
64 $criteria =new CriteriaCompo();
65 $criteria->add(new Criteria('hasmain', 1));
66 $criteria->add(new Criteria('isactive', 1));
67
68 $t_Arr =& $handler->getObjects($criteria);
69 $moduleArr = array_merge($moduleArr, $t_Arr);
70 $render->setAttribute('moduleArr', $moduleArr);
71
72 $handler =& xoops_getmodulehandler('columnside');
73 $columnSideArr =& $handler->getObjects();
74 $render->setAttribute('columnSideArr', $columnSideArr);
75
76 $handler =& xoops_gethandler('group');
77 $groupArr =& $handler->getObjects();
78 $render->setAttribute('groupArr', $groupArr);
79
80 //
81 // Build cachetime list and set.
82 //
83 $handler =& xoops_gethandler('cachetime');
84 $cachetimeArr =& $handler->getObjects();
85 $render->setAttribute('cachetimeArr', $cachetimeArr);
86
87 //
88 // Build ctype list and set.
89 //
90 $handler =& xoops_getmodulehandler('blockctype');
91 $ctypeArr =& $handler->getObjects();
92 $render->setAttribute('ctypeArr', $ctypeArr);
93 }
94
95 public function executeViewCancel(&$controller, &$xoopsUser, &$render)
96 {
97 if ($this->mObject->isNew()) {
98 $controller->executeForward('./index.php?action=BlockInstallList');
99 } else {
100 $controller->executeForward('./index.php?action=BlockList');
101 }
102 }
103
104 public function execute(&$controller, &$xoopsUser)
105 {
106 if (null === $this->mObject) {
107 return LEGACY_FRAME_VIEW_ERROR;
108 }
109
110 if (null !== xoops_getrequest('_form_control_preview')) {
111 $this->mActionForm->load($this->mObject);
112
113 $this->mActionForm->fetch();
114 $this->mActionForm->validate();
115
116 return LEGACY_FRAME_VIEW_PREVIEW;
117 }
118 return parent::execute($controller, $xoopsUser);
119 }
120
121 public function executeViewPreview(&$controller, &$xoopsUser, &$render)
122 {
123 $this->executeViewInput($controller, $xoopsUser, $render);
124
125 $bid = !empty(xoops_getrequest('bid')) ? intval(xoops_getrequest('bid')) : 0;
126 if (!empty($bid)) {
127 $myblock = new XoopsBlock($bid);
128 } else {
129 $myblock = new XoopsBlock();
130 $myblock->setVar('block_type', 'C');
131 }
133 $myblock->setVar('content', $myts->stripSlashesGPC(xoops_getrequest('content')));
134 restore_error_handler();
135 $original_level = error_reporting( E_ALL );
136 $preview = $myblock->getContent('S', xoops_getrequest('c_type'));
137 error_reporting( $original_level );
138 $render->setAttribute('content_preview', $preview);
139 }
140}