29 $this->db = XoopsDatabaseFactory::getDatabaseConnection();
30 $this->_dbtable = $this->db->prefix(
"rmc_images");
43 return $this->
getVar(
'id_img');
53 if($params==
'')
return false;
54 $p = explode(
":", $params);
56 if(intval(
$p[0])<=0)
return false;
59 $this->selected_size = intval(
$p[1]);
61 $p[2] =
$p[2]!=
'' ? urldecode(
$p[2]) :
'';
62 $p[3] =
$p[3]!=
'' ? urldecode(
$p[3]) :
'';
73 if(empty($this->sizes)){
75 if(
$cat->isNew())
return false;
77 $this->sizes =
$cat->getVar(
'sizes');
88 public function url($size=-1){
90 if($size<0 && $this->selected_size>0)
93 if($this->
isNew())
return false;
97 $url = XOOPS_UPLOAD_URL.
'/'.date(
'Y', $this->
getVar(
'date')).
'/'.date(
'm',$this->
getVar(
'date')).
'/';
98 if($size>=count($this->sizes)){
103 $info = pathinfo($this->
getVar(
'file'));
105 $url .=
'sizes/'.$info[
'filename'].
'_'.$this->sizes[$size][
'width'].
'x'.(isset($this->sizes[$size][
'height'])?$this->sizes[$size][
'height']:
'');
106 $url .=
'.'.$info[
'extension'];
113 if($this->
isNew())
return false;
119 foreach($this->sizes as $k => $size){
120 $ps = $ps==0?$size[
'width']:$ps;
121 if($size[
'width']<$ps){
122 $ps = $size[
'width'];
128 return $this->
url($small);
138 if($this->
isNew())
return false;
142 foreach($this->sizes as $k => $size){
143 $ret[$size[
'name']] = $this->
url($k);
151 if($this->
isNew())
return false;
155 foreach($this->sizes as $k => $size){
156 if($size[
'name'] == $name)
157 return $this->
url($k);
165 $url = XOOPS_UPLOAD_URL.
'/'.date(
'Y', $this->
getVar(
'date')).
'/'.date(
'm',$this->
getVar(
'date')).
'/';
180 public function delete(){
181 $path = XOOPS_UPLOAD_PATH.
'/'.date(
'Y', $this->
getVar(
'date')).
'/'.date(
'm',$this->
getVar(
'date')).
'/';
184 $info = pathinfo($this->
getVar(
'file'));
186 unlink(
$path.
'sizes/'.$info[
'filename'].
'_'.$this->sizes[$size][
'width'].
'x'.(isset($this->sizes[$size][
'height'])?$this->sizes[$size][
'height']:
'').
'.'.$info[
'extension']);
188 unlink(
$path.$this->getVar(
'file'));