XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
image.php
1<?php
10
11if (!defined('XOOPS_ROOT_PATH')) {
12 exit();
13}
14
16{
17 public $mImageCategory = null;
18 public $_mImageCategoryLoadedFlag = false;
19 public $mImageBody = null;
20 public $_mImageBodyLoadedFlag = false;
21
22 public function __construct()
23 {
24 static $initVars;
25 if (isset($initVars)) {
26 $this->mVars = $initVars;
27 return;
28 }
29 $this->initVar('image_id', XOBJ_DTYPE_INT, '', false);
30 $this->initVar('image_name', XOBJ_DTYPE_STRING, '', true, 30);
31 $this->initVar('image_nicename', XOBJ_DTYPE_STRING, '', true, 191);
32 $this->initVar('image_mimetype', XOBJ_DTYPE_STRING, '', true, 30);
33 $this->initVar('image_created', XOBJ_DTYPE_INT, time(), true);
34 $this->initVar('image_display', XOBJ_DTYPE_BOOL, '1', true);
35 $this->initVar('image_weight', XOBJ_DTYPE_INT, '0', true);
36 $this->initVar('imgcat_id', XOBJ_DTYPE_INT, '0', true);
37 $initVars=$this->mVars;
38 }
39
40 public function loadImagecategory()
41 {
42 if (false === $this->_mImageCategoryLoadedFlag) {
43 $handler =& xoops_getmodulehandler('imagecategory', 'legacy');
44 $this->mImageCategory =& $handler->get($this->get('imgcat_id'));
45 $this->_mImageCategoryLoadedFlag = true;
46 }
47 }
48
49 public function loadImagebody()
50 {
51 if (false === $this->_mImageBodyLoadedFlag) {
52 $handler =& xoops_getmodulehandler('imagebody', 'legacy');
53 $this->mImageBody =& $handler->get($this->get('image_id'));
54 $this->_mImageBodyLoadedFlag = true;
55 }
56 }
57
58 public function &createImagebody()
59 {
60 $handler =& xoops_getmodulehandler('imagebody', 'legacy');
61 $obj =& $handler->create();
62 $obj->set('image_id', $this->get('image_id'));
63 return $obj;
64 }
65}
66
68{
69 public $mTable = 'image';
70 public $mPrimary = 'image_id';
71 public $mClass = 'LegacyImageObject';
72
73 public function insert(&$obj, $force = false)
74 {
75 if (parent::insert($obj, $force)) {
76 if (is_object($obj->mImageBody)) {
77 $obj->mImageBody->set('image_id', $obj->get('image_id'));
78 $handler =& xoops_getmodulehandler('imagebody', 'legacy');
79 return $handler->insert($obj->mImageBody, $force);
80 }
81
82 return true;
83 }
84
85 return false;
86 }
87
96 public function delete(&$obj, $force = false)
97 {
98 $obj->loadImagebody();
99
100 if (parent::delete($obj, $force)) {
101 $filepath = XOOPS_UPLOAD_PATH . '/' . $obj->get('image_name');
102 if (file_exists($filepath)) {
103 @unlink($filepath);
104 }
105
106 if (is_object($obj->mImageBody)) {
107 $handler =& xoops_getmodulehandler('imagebody', 'legacy');
108 $handler->delete($obj->mImageBody, $force);
109 }
110
111 return true;
112 }
113
114 return false;
115 }
116}