• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

XOOPS Cube Legacy base repository


Commit MetaInfo

Revision6586001ffbd57fa84dbec5c33f5c01b4ec034dc0 (tree)
Time2012-07-31 18:15:17
AuthorHIKAWA Kilica <kilica.hikawa@gmai...>
CommiterHIKAWA Kilica

Log Message

#8 AbstractClientObjectHandler fixation is wrong.

Change Summary

Incremental Difference

--- a/html/modules/legacy/class/interface/AbstractClientObjectHandler.class.php
+++ b/html/modules/legacy/class/interface/AbstractClientObjectHandler.class.php
@@ -1,416 +1,412 @@
1-<?php
2-/**
3- * @file
4- * @package legacy
5- * @version $Id$
6-**/
7-
8-if(!defined('XOOPS_ROOT_PATH'))
9-{
10- exit;
11-}
12-
13-/**
14- * Legacy_AbstractClientObjectHandler
15-**/
16-abstract class Legacy_AbstractClientObjectHandler extends XoopsObjectGenericHandler
17-{
18- protected $_mClientField = array('title'=>'title', 'category'=>'category_id', 'posttime'=>'posttime');
19- protected $_mClientConfig = array('tag'=>'tag_dirname', 'image'=>'use_image', 'workflow'=>'use_workflow', 'activity'=>'use_activity', 'map'=>'use_map');
20-
21- /**
22- * _getTagList
23- *
24- * @param XoopsSimpleObject $obj
25- *
26- * @return string[]
27- */
28- protected function _getTagList(/*** XoopsSimpleObject ***/ $obj)
29- {
30- return $obj->mTag;
31- }
32-
33- /**
34- * insert data to table
35- *
36- * @param XoopsSimpleObject $obj
37- * @param bool $force
38- *
39- * @return bool
40- */
41- public function insert(/*** XoopsSimpleObject ***/ $obj, /*** bool ***/ $force=false)
42- {
43- $ret = parent::insert($obj, $force);
44- if ($ret == true)
45- {
46- $ret = $this->_setClientData($obj);
47- }
48-
49- return $ret;
50- }
51-
52- /**
53- * delete data from table
54- *
55- * @param XoopsSimpleObject $obj
56- * @param bool $force
57- *
58- * @return bool
59- */
60- public function delete(/*** XoopsSimpleObject ***/ $obj, /*** bool ***/ $force=false)
61- {
62- $ret = parent::delete($obj, $force);
63- $this->_deleteClientData($obj);
64-
65- return $ret;
66- }
67-
68- /**
69- * set client data: tag, image, activity, workflow
70- *
71- * @param XoopsSimpleObject $obj
72- *
73- * @return bool
74- */
75- protected function _setClientData(/*** XoopsSimpleObject ***/ $obj)
76- {
77- $handler = xoops_gethandler('config');
78- $conf = $handler->getConfigsByDirname($obj->getDirname());
79-
80- $ret = true;
81- if($this->_isActivityClient($conf)===true){
82- if($this->_saveActivity($obj)===false){
83- $ret = false;
84- }
85- }
86-
87- if($this->_isTagClient($conf)===true){
88- if($this->_saveTags($obj, $conf[$this->_mClientConfig['tag']])===false){
89- $ret = false;
90- }
91- }
92-
93- if($this->_isWorkflowClient($conf)===true){
94- $this->_saveWorkflow($obj);
95- }
96-
97- if($this->_isImageClient($conf)===true){
98- if($this->_saveImages($obj)===false){
99- $ret = false;
100- }
101- }
102-
103- if($this->_isMapClient($conf)===true){
104- if($this->_saveMap($obj)===false){
105- $ret = false;
106- }
107- }
108-
109- return $ret;
110- }
111-
112- /**
113- * delete client data: tag, activity, workflow, image
114- *
115- * @param XoopsSimpleObject $obj
116- *
117- * @return bool
118- */
119- protected function _deleteClientData(/*** XoopsSimpleObject ***/ $obj)
120- {
121- $handler = xoops_gethandler('config');
122- $conf = $handler->getConfigsByDirname($obj->getDirname());
123-
124- $ret = true;
125- if($this->_isActivityClient($conf)===true){
126- if($this->_deleteActivity($obj)===false){
127- $ret = false;
128- }
129- }
130-
131- if($this->_isTagClient($conf)===true){
132- if($this->_deleteTags($obj, $tagDirname)===false){
133- $ret = false;
134- }
135- }
136-
137- if($this->_isWorkflowClient($conf)===true){
138- $ret = $this->_deleteWorkflow($obj);
139- }
140-
141- if($this->_isImageClient($conf)===true){
142- if($this->_deleteImages($obj)===false){
143- $ret = false;
144- }
145- }
146- return $ret;
147- }
148-
149- /**
150- * save activity
151- *
152- * @param XoopsSimpleObject $obj
153- *
154- * @return bool
155- */
156- protected function _saveActivity(/*** XoopsSimpleObject ***/ $obj)
157- {
158- $ret = false;
159- XCube_DelegateUtils::call(
160- 'Legacy_Activity.AddActivity',
161- new XCube_Ref($ret),
162- $obj->get('uid'),
163- $obj->get($this->_mClientField['category']),
164- $obj->getDirname(),
165- $this->getDataname(),
166- $obj->get($this->mPrimary),
167- $obj->get($this->_mClientField['posttime'])
168- );
169- return $ret;
170- }
171-
172- /**
173- * save tags
174- *
175- * @param XoopsSimpleObject $obj
176- * @param string $tagDirname
177- *
178- * @return bool
179- */
180- protected function _saveTags(/*** XoopsSimpleObject ***/ $obj, /*** string ***/ $tagDirname)
181- {
182- $ret = false;
183- XCube_DelegateUtils::call('Legacy_Tag.'.$tagDirname.'.SetTags',
184- new XCube_Ref($ret),
185- $tagDirname,
186- $obj->getDirname(),
187- $this->getDataname(),
188- $obj->get($this->mPrimary),
189- $obj->get($this->_mClientField['posttime']),
190- $this->_getTagList($obj)
191- );
192- return $ret;
193- }
194-
195- /**
196- * save workflow
197- *
198- * @param XoopsSimpleObject $obj
199- *
200- * @return void
201- */
202- protected function _saveWorkflow(/*** XoopsSimpleObject ***/ $obj)
203- {
204- XCube_DelegateUtils::call(
205- 'Legacy_Workflow.AddItem',
206- $obj->getShow($this->mPrimary),
207- $obj->getDirname(),
208- $this->getDataname(),
209- $obj->get($obj->getPrimary()),
210- Legacy_Utils::renderUri($obj->getDirname(), $this->getDataname(), $obj->get($this->mPrimary))
211- );
212- }
213-
214- /**
215- * upload and save images
216- *
217- * @param XoopsSimpleObject $obj
218- *
219- * @return bool
220- */
221- protected function _saveImages(/*** Legacy_AbstractObject ***/ $obj)
222- {
223- $ret = true;
224- $obj->setupImages();
225- foreach($obj->mImage as $image){
226- $result = false;
227- if($image->isDeleted()===true){ //delete image
228- XCube_DelegateUtils::call('Legacy_Image.DeleteImage', new XCube_Ref($result), $image);
229- }
230- else{ //save image
231- XCube_DelegateUtils::call('Legacy_Image.SaveImage', new XCube_Ref($result), $image);
232- }
233- if($result===false){
234- $ret = false;
235- }
236- }
237-
238- return $ret;
239- }
240-
241- /**
242- * save map data
243- *
244- * @param XoopsSimpleObject $obj
245- *
246- * @return bool
247- */
248- protected function _saveMap($obj)
249- {
250- $result = array();
251- XCube_DelegateUtils::call(
252- 'Legacy_Map.SetPlace',
253- new XCube_Ref($result),
254- $obj->getDirname(),
255- $obj->getDataname(),
256- $obj->get($obj->getPrimary()),
257- $obj->mLatlng,
258- $obj->get($this->_mClientField['posttime'])
259- );
260-
261- return $result;
262- }
263-
264- /**
265- * delete activity
266- *
267- * @param XoopsSimpleObject $obj
268- *
269- * @return bool
270- */
271- protected function _deleteActivity(/*** XoopsSimpleObject ***/ $obj)
272- {
273- $ret = false;
274- XCube_DelegateUtils::call('Legacy_Activity.DeleteActivity', new XCube_Ref($ret), $obj->getDirname(), $this->getDataname(), $obj->get($this->mPrimary));
275- return $ret;
276- }
277-
278- /**
279- * delete tags
280- *
281- * @param XoopsSimpleObject $obj
282- * @param string $tagDirname
283- *
284- * @return bool
285- */
286- protected function _deleteTags(/*** XoopsSimpleObject ***/ $obj, /*** string ***/ $tagDirname)
287- {
288- $ret = false;
289- XCube_DelegateUtils::call(
290- 'Legacy_Tag.'.$tagDirname.'.SetTags',
291- new XCube_Ref($ret),
292- $tagDirname,
293- $obj->getDirname(),
294- $this->getDataname(),
295- $obj->get($this->mPrimary),
296- $obj->get($this->_mClientField['posttime']),
297- array()
298- );
299- return $ret;
300- }
301-
302- /**
303- * delete workflow
304- *
305- * @param XoopsSimpleObject $obj
306- *
307- * @return void
308- */
309- protected function _deleteWorkflow(/*** XoopsSimpleObject ***/ $obj)
310- {
311- XCube_DelegateUtils::call('Legacy_Workflow.DeleteItem', $obj->getDirname(), $this->getDataname(), $obj->get($this->mPrimary));
312- }
313-
314- /**
315- * delete images
316- *
317- * @param XoopsSimpleObject $obj
318- *
319- * @return bool
320- */
321- protected function _deleteImages(/*** XoopsSimpleObject ***/ $obj)
322- {
323- $ret = true;
324- $isPost = false;
325- $obj->setupImages($isPost);
326- foreach($obj->mImage as $image){
327- if(!($image instanceof Legacy_AbstractImageObject)){
328- continue;
329- }
330- $result = false;
331- XCube_DelegateUtils::call('Legacy_Image.DeleteImage', new XCube_Ref($result), $image);
332- if($result===false){
333- $ret = false;
334- }
335- }
336- return $ret;
337- }
338-
339- /**
340- * check if use Legacy_Activity
341- *
342- * @param mixed[] $conf
343- *
344- * @return bool
345- */
346- protected function _isActivityClient(/*** mixed[] ***/ $conf)
347- {
348- return $conf[$this->_mClientConfig['activity']]==1 ? true : false;
349- }
350-
351- /**
352- * check if use Legacy_Tag
353- *
354- * @param mixed[] $conf
355- *
356- * @return bool
357- */
358- protected function _isTagClient(/*** mixed[] ***/ $conf)
359- {
360- $flag = isset($conf[$this->_mClientConfig['tag']]) ? $conf[$this->_mClientConfig['tag']] : 0 ;
361- return $flag && $flag==1 ? true : false;
362- }
363-
364- /**
365- * check if use Legacy_Workflow
366- *
367- * @param mixed[] $conf
368- *
369- * @return bool
370- */
371- protected function _isWorkflowClient(/*** mixed[] ***/ $conf)
372- {
373- $flag = isset($conf[$this->_mClientConfig['workflow']]) ? $conf[$this->_mClientConfig['workflow']] : 0 ;
374- return $flag==1 ? true : false;
375- }
376-
377- /**
378- * check if use Legacy_Image
379- *
380- * @param mixed[] $conf
381- *
382- * @return bool
383- */
384- protected function _isImageClient(/*** mixed[] ***/ $conf)
385- {
386- $flag = isset($conf[$this->_mClientConfig['image']]) ? $conf[$this->_mClientConfig['image']] : 0;
387- return $flag && $flag==1 ? true : false;
388- }
389-
390- /**
391- * check if use Legacy_Map
392- *
393- * @param mixed[] $conf
394- *
395- * @return bool
396- */
397- protected function _isMapClient(/*** mixed[] ***/ $conf)
398- {
399- $flag = isset($conf[$this->_mClientConfig['map']]) ? $conf[$this->_mClientConfig['map']] : 0;
400- return $flag && $flag==1 ? true : false;
401- }
402-
403- /**
404- * get client field name
405- *
406- * @param string $key
407- *
408- * @return string
409- */
410- public function getClientField(/*** string ***/ $key)
411- {
412- return $this->_mClientField[$key];
413- }
414-}
415-
416-?>
1+<?php
2+/**
3+ * @file
4+ * @package legacy
5+ * @version $Id$
6+**/
7+
8+if(!defined('XOOPS_ROOT_PATH'))
9+{
10+ exit;
11+}
12+
13+/**
14+ * Legacy_AbstractClientObjectHandler
15+**/
16+abstract class Legacy_AbstractClientObjectHandler extends XoopsObjectGenericHandler
17+{
18+ protected $_mClientField = array('title'=>'title', 'category'=>'category_id', 'posttime'=>'posttime');
19+ protected $_mClientConfig = array('tag'=>'tag_dirname', 'image'=>'use_image', 'workflow'=>'use_workflow', 'activity'=>'use_activity', 'map'=>'use_map');
20+
21+ /**
22+ * _getTagList
23+ *
24+ * @param XoopsSimpleObject $obj
25+ *
26+ * @return string[]
27+ */
28+ protected function _getTagList(/*** XoopsSimpleObject ***/ $obj)
29+ {
30+ return $obj->mTag;
31+ }
32+
33+ /**
34+ * insert data to table
35+ *
36+ * @param XoopsSimpleObject $obj
37+ * @param bool $force
38+ *
39+ * @return bool
40+ */
41+ public function insert(/*** XoopsSimpleObject ***/ $obj, /*** bool ***/ $force=false)
42+ {
43+ $ret = parent::insert($obj, $force);
44+ if ($ret == true)
45+ {
46+ $ret = $this->_setClientData($obj);
47+ }
48+
49+ return $ret;
50+ }
51+
52+ /**
53+ * delete data from table
54+ *
55+ * @param XoopsSimpleObject $obj
56+ * @param bool $force
57+ *
58+ * @return bool
59+ */
60+ public function delete(/*** XoopsSimpleObject ***/ $obj, /*** bool ***/ $force=false)
61+ {
62+ $ret = parent::delete($obj, $force);
63+ $this->_deleteClientData($obj);
64+
65+ return $ret;
66+ }
67+
68+ /**
69+ * set client data: tag, image, activity, workflow
70+ *
71+ * @param XoopsSimpleObject $obj
72+ *
73+ * @return bool
74+ */
75+ protected function _setClientData(/*** XoopsSimpleObject ***/ $obj)
76+ {
77+ $handler = xoops_gethandler('config');
78+ $conf = $handler->getConfigsByDirname($obj->getDirname());
79+
80+ $ret = true;
81+ if($this->_isActivityClient($conf)===true){
82+ if($this->_saveActivity($obj)===false){
83+ $ret = false;
84+ }
85+ }
86+
87+ if($this->_isTagClient($conf)===true){
88+ if($this->_saveTags($obj, $conf[$this->_mClientConfig['tag']])===false){
89+ $ret = false;
90+ }
91+ }
92+
93+ if($this->_isWorkflowClient($conf)===true){
94+ $this->_saveWorkflow($obj);
95+ }
96+
97+ if($this->_isImageClient($conf)===true){
98+ if($this->_saveImages($obj)===false){
99+ $ret = false;
100+ }
101+ }
102+
103+ if($this->_isMapClient($conf)===true){
104+ if($this->_saveMap($obj)===false){
105+ $ret = false;
106+ }
107+ }
108+
109+ return $ret;
110+ }
111+
112+ /**
113+ * delete client data: tag, activity, workflow, image
114+ *
115+ * @param XoopsSimpleObject $obj
116+ *
117+ * @return bool
118+ */
119+ protected function _deleteClientData(/*** XoopsSimpleObject ***/ $obj)
120+ {
121+ $handler = xoops_gethandler('config');
122+ $conf = $handler->getConfigsByDirname($obj->getDirname());
123+
124+ $ret = true;
125+ if($this->_isActivityClient($conf)===true){
126+ if($this->_deleteActivity($obj)===false){
127+ $ret = false;
128+ }
129+ }
130+
131+ if($this->_isTagClient($conf)===true){
132+ if($this->_deleteTags($obj, $tagDirname)===false){
133+ $ret = false;
134+ }
135+ }
136+
137+ if($this->_isWorkflowClient($conf)===true){
138+ $ret = $this->_deleteWorkflow($obj);
139+ }
140+
141+ if($this->_isImageClient($conf)===true){
142+ if($this->_deleteImages($obj)===false){
143+ $ret = false;
144+ }
145+ }
146+ return $ret;
147+ }
148+
149+ /**
150+ * save activity
151+ *
152+ * @param XoopsSimpleObject $obj
153+ *
154+ * @return bool
155+ */
156+ protected function _saveActivity(/*** XoopsSimpleObject ***/ $obj)
157+ {
158+ $ret = false;
159+ XCube_DelegateUtils::call(
160+ 'Legacy_Activity.AddActivity',
161+ new XCube_Ref($ret),
162+ $obj->get('uid'),
163+ $obj->get($this->_mClientField['category']),
164+ $obj->getDirname(),
165+ $this->getDataname(),
166+ $obj->get($this->mPrimary),
167+ $obj->get($this->_mClientField['posttime'])
168+ );
169+ return $ret;
170+ }
171+
172+ /**
173+ * save tags
174+ *
175+ * @param XoopsSimpleObject $obj
176+ * @param string $tagDirname
177+ *
178+ * @return bool
179+ */
180+ protected function _saveTags(/*** XoopsSimpleObject ***/ $obj, /*** string ***/ $tagDirname)
181+ {
182+ $ret = false;
183+ XCube_DelegateUtils::call('Legacy_Tag.'.$tagDirname.'.SetTags',
184+ new XCube_Ref($ret),
185+ $tagDirname,
186+ $obj->getDirname(),
187+ $this->getDataname(),
188+ $obj->get($this->mPrimary),
189+ $obj->get($this->_mClientField['posttime']),
190+ $this->_getTagList($obj)
191+ );
192+ return $ret;
193+ }
194+
195+ /**
196+ * save workflow
197+ *
198+ * @param XoopsSimpleObject $obj
199+ *
200+ * @return void
201+ */
202+ protected function _saveWorkflow(/*** XoopsSimpleObject ***/ $obj)
203+ {
204+ XCube_DelegateUtils::call(
205+ 'Legacy_Workflow.AddItem',
206+ $obj->getShow($this->mPrimary),
207+ $obj->getDirname(),
208+ $this->getDataname(),
209+ $obj->get($obj->getPrimary()),
210+ Legacy_Utils::renderUri($obj->getDirname(), $this->getDataname(), $obj->get($this->mPrimary))
211+ );
212+ }
213+
214+ /**
215+ * upload and save images
216+ *
217+ * @param XoopsSimpleObject $obj
218+ *
219+ * @return bool
220+ */
221+ protected function _saveImages(/*** Legacy_AbstractObject ***/ $obj)
222+ {
223+ $ret = true;
224+ $obj->setupImages();
225+ foreach($obj->mImage as $image){
226+ $result = false;
227+ if($image->isDeleted()===true){ //delete image
228+ XCube_DelegateUtils::call('Legacy_Image.DeleteImage', new XCube_Ref($result), $image);
229+ }
230+ else{ //save image
231+ XCube_DelegateUtils::call('Legacy_Image.SaveImage', new XCube_Ref($result), $image);
232+ }
233+ if($result===false){
234+ $ret = false;
235+ }
236+ }
237+
238+ return $ret;
239+ }
240+
241+ /**
242+ * save map data
243+ *
244+ * @param XoopsSimpleObject $obj
245+ *
246+ * @return bool
247+ */
248+ protected function _saveMap($obj)
249+ {
250+ $result = array();
251+ XCube_DelegateUtils::call(
252+ 'Legacy_Map.SetPlace',
253+ new XCube_Ref($result),
254+ $obj->getDirname(),
255+ $obj->getDataname(),
256+ $obj->get($obj->getPrimary()),
257+ $obj->mLatlng,
258+ $obj->get($this->_mClientField['posttime'])
259+ );
260+
261+ return $result;
262+ }
263+
264+ /**
265+ * delete activity
266+ *
267+ * @param XoopsSimpleObject $obj
268+ *
269+ * @return bool
270+ */
271+ protected function _deleteActivity(/*** XoopsSimpleObject ***/ $obj)
272+ {
273+ $ret = false;
274+ XCube_DelegateUtils::call('Legacy_Activity.DeleteActivity', new XCube_Ref($ret), $obj->getDirname(), $this->getDataname(), $obj->get($this->mPrimary));
275+ return $ret;
276+ }
277+
278+ /**
279+ * delete tags
280+ *
281+ * @param XoopsSimpleObject $obj
282+ * @param string $tagDirname
283+ *
284+ * @return bool
285+ */
286+ protected function _deleteTags(/*** XoopsSimpleObject ***/ $obj, /*** string ***/ $tagDirname)
287+ {
288+ $ret = false;
289+ XCube_DelegateUtils::call(
290+ 'Legacy_Tag.'.$tagDirname.'.SetTags',
291+ new XCube_Ref($ret),
292+ $tagDirname,
293+ $obj->getDirname(),
294+ $this->getDataname(),
295+ $obj->get($this->mPrimary),
296+ $obj->get($this->_mClientField['posttime']),
297+ array()
298+ );
299+ return $ret;
300+ }
301+
302+ /**
303+ * delete workflow
304+ *
305+ * @param XoopsSimpleObject $obj
306+ *
307+ * @return void
308+ */
309+ protected function _deleteWorkflow(/*** XoopsSimpleObject ***/ $obj)
310+ {
311+ XCube_DelegateUtils::call('Legacy_Workflow.DeleteItem', $obj->getDirname(), $this->getDataname(), $obj->get($this->mPrimary));
312+ }
313+
314+ /**
315+ * delete images
316+ *
317+ * @param XoopsSimpleObject $obj
318+ *
319+ * @return bool
320+ */
321+ protected function _deleteImages(/*** XoopsSimpleObject ***/ $obj)
322+ {
323+ $ret = true;
324+ $isPost = false;
325+ $obj->setupImages($isPost);
326+ foreach($obj->mImage as $image){
327+ if(!($image instanceof Legacy_AbstractImageObject)){
328+ continue;
329+ }
330+ $result = false;
331+ XCube_DelegateUtils::call('Legacy_Image.DeleteImage', new XCube_Ref($result), $image);
332+ if($result===false){
333+ $ret = false;
334+ }
335+ }
336+ return $ret;
337+ }
338+
339+ /**
340+ * check if use Legacy_Activity
341+ *
342+ * @param mixed[] $conf
343+ *
344+ * @return bool
345+ */
346+ protected function _isActivityClient(/*** mixed[] ***/ $conf)
347+ {
348+ return $conf[$this->_mClientConfig['activity']]==1 ? true : false;
349+ }
350+
351+ /**
352+ * check if use Legacy_Tag
353+ *
354+ * @param mixed[] $conf
355+ *
356+ * @return bool
357+ */
358+ protected function _isTagClient(/*** mixed[] ***/ $conf)
359+ {
360+ return isset($conf[$this->_mClientConfig['tag']]) ? true : false;
361+ }
362+
363+ /**
364+ * check if use Legacy_Workflow
365+ *
366+ * @param mixed[] $conf
367+ *
368+ * @return bool
369+ */
370+ protected function _isWorkflowClient(/*** mixed[] ***/ $conf)
371+ {
372+ return isset($conf[$this->_mClientConfig['workflow']]) ? true : false;
373+ }
374+
375+ /**
376+ * check if use Legacy_Image
377+ *
378+ * @param mixed[] $conf
379+ *
380+ * @return bool
381+ */
382+ protected function _isImageClient(/*** mixed[] ***/ $conf)
383+ {
384+ return isset($conf[$this->_mClientConfig['image']]) ? true : false;
385+ }
386+
387+ /**
388+ * check if use Legacy_Map
389+ *
390+ * @param mixed[] $conf
391+ *
392+ * @return bool
393+ */
394+ protected function _isMapClient(/*** mixed[] ***/ $conf)
395+ {
396+ return isset($conf[$this->_mClientConfig['map']]) ? true : false;
397+ }
398+
399+ /**
400+ * get client field name
401+ *
402+ * @param string $key
403+ *
404+ * @return string
405+ */
406+ public function getClientField(/*** string ***/ $key)
407+ {
408+ return $this->_mClientField[$key];
409+ }
410+}
411+
412+?>