XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
Legacy_BlockProcedure.class.php
1<?php
11
12if (!defined('XOOPS_ROOT_PATH')) {
13 die();
14}
15
22{
26 public $mRender = null;
27
28 public function __construct()
29 {
30 }
31
36 public function prepare()
37 {
38 return true;
39 }
40
45 public function &getRenderTarget()
46 {
47 if (!is_object($this->mRender)) {
48 $this->_createRenderTarget();
49 }
50
51 return $this->mRender;
52 }
53
58 public function getRenderSystemName()
59 {
60 $root =& XCube_Root::getSingleton();
61 return $root->mContext->mBaseRenderSystemName;
62 }
63
69 public function &_createRenderTarget()
70 {
71 $this->mRender = new XCube_RenderTarget();
72 $this->mRender->setType(XCUBE_RENDER_TARGET_TYPE_BLOCK);
73
74 return $this->mRender;
75 }
76
81 public function getId()
82 {
83 }
84
89 public function getName()
90 {
91 }
92
97 public function isEnableCache()
98 {
99 }
100
105 public function getCacheTime()
106 {
107 }
108
113 public function getTitle()
114 {
115 return $this->_mBlock->get('title');
116 }
117
118 // TODO @gigamaster gettemplate (block dropdown edit)
119 public function getTemplate()
120 {
121 // return $this->_mBlock->get('template');
122 }
127 public function getEntryIndex()
128 {
129 }
130
135 public function getWeight()
136 {
137 }
138
143 public function isDisplay()
144 {
145 return true;
146 }
147
148 public function &createCacheInfo()
149 {
150 $cacheInfo = new Legacy_BlockCacheInformation();
151 $cacheInfo->setBlock($this);
152 return $cacheInfo;
153 }
154
155 public function execute()
156 {
157 }
158}
159
166{
170 public $_mBlock = null;
171
175 public $mRender = null;
176
177 public function __construct(&$block)
178 {
179 $this->_mBlock =& $block;
180 }
181
182 public function prepare()
183 {
184 return true;
185 }
186
187 public function getId()
188 {
189 return $this->_mBlock->get('bid');
190 }
191
192 public function getName()
193 {
194 return $this->_mBlock->get('name');
195 }
196
197 public function isEnableCache()
198 {
199 return $this->_mBlock->get('bcachetime') > 0;
200 }
201
202 public function getCacheTime()
203 {
204 return $this->_mBlock->get('bcachetime');
205 }
206
207 public function getTitle()
208 {
209 return $this->_mBlock->get('title');
210 }
211
212 // @gigamaster gettemplate (block dropdown edit)
213 public function getTemplate()
214 {
215 return $this->_mBlock->get('template');
216 }
217
218 public function getEntryIndex()
219 {
220 return $this->_mBlock->getVar('side');
221 }
222
223 public function getWeight()
224 {
225 return $this->_mBlock->get('weight');
226 }
227
233 public function _hasVisibleOptionForm()
234 {
235 return true;
236 }
237
242 public function getOptionForm()
243 {
244 return null;
245 }
246}
247
253{
254 public $_mDisplayFlag = true;
255
256 public function execute()
257 {
258
259 $result =& $this->_mBlock->buildBlock();
260
261 if (empty($result)) {
262 $this->_mDisplayFlag = false;
263 return;
264 }
265
266 $render =& $this->getRenderTarget();
267 $render->setAttribute('mid', $this->_mBlock->get('mid'));
268 $render->setAttribute('bid', $this->_mBlock->get('bid'));
269
270
271 if (null == $this->_mBlock->get('template')) {
272 $render->setTemplateName('system_dummy.html');
273 $render->setAttribute('dummy_content', $result['content']);
274 } else {
275 $render->setTemplateName($this->_mBlock->get('template'));
276 $render->setAttribute('block', $result);
277 }
278
279 $root =& XCube_Root::getSingleton();
280 $renderSystem =& $root->getRenderSystem($this->getRenderSystemName());
281
282 $renderSystem->renderBlock($render);
283 }
284
285 public function isDisplay()
286 {
287 return $this->_mDisplayFlag;
288 }
289
290 public function _hasVisibleOptionForm()
291 {
292 return ($this->_mBlock->get('func_file') && $this->_mBlock->get('edit_func'));
293 }
294
295 public function getOptionForm()
296 {
297 if ($this->_mBlock->get('func_file') && $this->_mBlock->get('edit_func')) {
298 $func_file = XOOPS_MODULE_PATH . '/' . $this->_mBlock->get('dirname') . '/blocks/' . $this->_mBlock->get('func_file');
299 if (file_exists($func_file)) {
300 require $func_file;
301 $edit_func = $this->_mBlock->get('edit_func');
302
303 $options = explode('|', $this->_mBlock->get('options'));
304
305 if (function_exists($edit_func)) {
306 //
307 // load language file.
308 //
309 $root =& XCube_Root::getSingleton();
310 $langManager =& $root->getLanguageManager();
311 $langManager->loadBlockMessageCatalog($this->_mBlock->get('dirname'));
312
313 return call_user_func($edit_func, $options);
314 }
315 }
316 }
317
318 //
319 // The block may have options, even it doesn't have end_func
320 //
321 if ($this->_mBlock->get('options')) {
322 $root =& XCube_Root::getSingleton();
323 $textFilter =& $root->getTextFilter();
324
325 $buf = '';
326 $options = explode('|', $this->_mBlock->get('options'));
327 foreach ($options as $val) {
328 $val = $textFilter->ToEdit($val);
329 $buf .= "<input type='hidden' name='options[]' value='{$val}'>";
330 }
331
332 return $buf;
333 }
334
335 return null;
336 }
337}