ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilFileDataShop Class Reference

This class handles all operations on files in directory data/shop. More...

+ Inheritance diagram for ilFileDataShop:
+ Collaboration diagram for ilFileDataShop:

Public Member Functions

 __construct ($a_pobject_id)
 
 getCurrentImageWebPath ()
 
 getCurrentImageServerPath ()
 
 storeUploadedFile ($a_http_post_file)
 
 assignFileToPaymentObject ()
 
 deassignFileFromPaymentObject ()
 
 unlinkFile ($a_filename)
 
 checkFilesExist ($a_files)
 
- Public Member Functions inherited from ilFileData
 ilFileData ()
 Constructor class bas constructor and read path of directory from ilias.ini setup an mail object @access public. More...
 
 checkPath ($a_path)
 check if path exists and is writable More...
 
 getPath ()
 get Path @access public More...
 
- Public Member Functions inherited from ilFile
 ilFile ()
 Constructor get ilias object @access public. More...
 
 deleteTrailingSlash ($a_path)
 delete trailing slash of path variables More...
 

Data Fields

const SHOPPATH = 'shop'
 
- Data Fields inherited from ilFile
 $path
 
 $ilias
 

Private Member Functions

 __read ()
 
 initDirectory ()
 
 checkReadWrite ()
 

Private Attributes

 $pobject_id = 0
 
 $shop_path = ''
 
 $image_current = ''
 
 $image_new = ''
 
 $db = null
 

Detailed Description

This class handles all operations on files in directory data/shop.

Currently it handles only one image per shop object...

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de

Definition at line 13 of file class.ilFileDataShop.php.

Constructor & Destructor Documentation

◆ __construct()

ilFileDataShop::__construct (   $a_pobject_id)

Definition at line 23 of file class.ilFileDataShop.php.

24 {
25 global $ilDB;
26
27 $this->db = $ilDB;
28 $this->pobject_id = $a_pobject_id;
29
30 parent::__construct();
31 $this->shop_path = ilUtil::getWebspaceDir().'/'.self::SHOPPATH.'/'.$this->pobject_id;
32 $this->initDirectory();
33 $this->checkReadWrite();
34
35 $this->__read();
36 }
static getWebspaceDir($mode="filesystem")
get webspace directory
global $ilDB

References $ilDB, $pobject_id, __read(), checkReadWrite(), ilUtil\getWebspaceDir(), and initDirectory().

+ Here is the call graph for this function:

Member Function Documentation

◆ __read()

ilFileDataShop::__read ( )
private

Definition at line 38 of file class.ilFileDataShop.php.

39 {
40 $result = $this->db->queryf('SELECT image FROM payment_objects WHERE pobject_id = %s',
41 array('integer'),array($this->pobject_id));
42
43 while($record = $this->db->fetchAssoc($result))
44 {
45 $this->image_current = $record['image'];
46 break;
47 }
48 }
$result

References $result.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ assignFileToPaymentObject()

ilFileDataShop::assignFileToPaymentObject ( )

Definition at line 115 of file class.ilFileDataShop.php.

116 {
117 $statement = $this->db->manipulateF(
118 'UPDATE payment_objects
119 SET
120 image = %s
121 WHERE pobject_id = %s',
122 array('text', 'integer'),
123 array($this->image_new, $this->pobject_id));
124
125
126 $this->image_current = $this->image_new;
127
128 return true;
129 }

References $image_new.

◆ checkFilesExist()

ilFileDataShop::checkFilesExist (   $a_files)

Definition at line 158 of file class.ilFileDataShop.php.

159 {
160 if($a_files)
161 {
162 foreach($a_files as $file)
163 {
164 if(!file_exists($this->shop_path.'/'.$file))
165 {
166 return false;
167 }
168 }
169 return true;
170 }
171 return true;
172 }
print $file

References $file.

Referenced by getCurrentImageServerPath(), and getCurrentImageWebPath().

+ Here is the caller graph for this function:

◆ checkReadWrite()

ilFileDataShop::checkReadWrite ( )
private

Definition at line 85 of file class.ilFileDataShop.php.

86 {
87 if(is_writable($this->shop_path) && is_readable($this->shop_path))
88 {
89 return true;
90 }
91 else
92 {
93 $this->ilias->raiseError('Shop directory is not readable/writable by webserver', $this->ilias->error_obj->FATAL);
94 }
95 }
redirection script todo: (a better solution should control the processing via a xml file)

Referenced by __construct().

+ Here is the caller graph for this function:

◆ deassignFileFromPaymentObject()

ilFileDataShop::deassignFileFromPaymentObject ( )

Definition at line 131 of file class.ilFileDataShop.php.

132 {
133 $statement = $this->db->manipulateF(
134 'UPDATE payment_objects
135 SET
136 image = %s
137 WHERE pobject_id = %s',
138 array('text', 'integer'),
139 //array('', $this->pobject_id));
140 array(NULL, $this->pobject_id));
141
142 if($this->image_current != '') $this->unlinkFile($this->image_current);
143 ilUtil::delDir($this->shop_path);
144 $this->image_current = '';
145
146 return true;
147 }
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

References ilUtil\delDir(), and unlinkFile().

+ Here is the call graph for this function:

◆ getCurrentImageServerPath()

ilFileDataShop::getCurrentImageServerPath ( )

Definition at line 61 of file class.ilFileDataShop.php.

62 {
63 if($this->image_current != "" &&
64 $this->checkFilesExist(array($this->image_current)))
65 {
66 return $this->shop_path.'/'.$this->image_current;
67 }
68
69 return false;
70 }

References $image_current, and checkFilesExist().

+ Here is the call graph for this function:

◆ getCurrentImageWebPath()

ilFileDataShop::getCurrentImageWebPath ( )

Definition at line 50 of file class.ilFileDataShop.php.

51 {
52 if($this->image_current != '' &&
53 $this->checkFilesExist(array($this->image_current)))
54 {
55 return ilUtil::getWebspaceDir('output').'/'.self::SHOPPATH.'/'.$this->pobject_id.'/'.$this->image_current;
56 }
57
58 return false;
59 }

References $image_current, checkFilesExist(), and ilUtil\getWebspaceDir().

+ Here is the call graph for this function:

◆ initDirectory()

ilFileDataShop::initDirectory ( )
private

Definition at line 72 of file class.ilFileDataShop.php.

73 {
74 if(is_writable($this->getPath()))
75 {
76 if(ilUtil::makeDirParents($this->shop_path))
77 {
78 return true;
79 }
80 }
81
82 return false;
83 }
getPath()
get Path @access public
static makeDirParents($a_dir)
Create a new directory and all parent directories.

References ilFileData\getPath(), and ilUtil\makeDirParents().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ storeUploadedFile()

ilFileDataShop::storeUploadedFile (   $a_http_post_file)

Definition at line 97 of file class.ilFileDataShop.php.

98 {
99 if($this->image_current != '') $this->unlinkFile($this->image_current);
100
101 if(isset($a_http_post_file) && $a_http_post_file['size'])
102 {
103 if(ilUtil::moveUploadedFile($a_http_post_file['tmp_name'], $a_http_post_file['name'],
104 $this->shop_path.'/'.$a_http_post_file['name']))
105 {
106 ilUtil::resizeImage('"'.$this->shop_path.'/'.$a_http_post_file['name'].'"', '"'.$this->shop_path.'/'.$a_http_post_file['name'].'"', 100, 75);
107 return $this->image_new = $a_http_post_file['name'];
108
109 }
110 }
111
112 return false;
113 }
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static resizeImage($a_from, $a_to, $a_width, $a_height, $a_constrain_prop=false)
resize image

References ilUtil\moveUploadedFile(), ilUtil\resizeImage(), and unlinkFile().

+ Here is the call graph for this function:

◆ unlinkFile()

ilFileDataShop::unlinkFile (   $a_filename)

Definition at line 150 of file class.ilFileDataShop.php.

151 {
152 if(file_exists($this->shop_path.'/'.$a_filename))
153 {
154 return unlink($this->shop_path.'/'.$a_filename);
155 }
156 }

Referenced by deassignFileFromPaymentObject(), and storeUploadedFile().

+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilFileDataShop::$db = null
private

Definition at line 21 of file class.ilFileDataShop.php.

◆ $image_current

ilFileDataShop::$image_current = ''
private

Definition at line 19 of file class.ilFileDataShop.php.

Referenced by getCurrentImageServerPath(), and getCurrentImageWebPath().

◆ $image_new

ilFileDataShop::$image_new = ''
private

Definition at line 20 of file class.ilFileDataShop.php.

Referenced by assignFileToPaymentObject().

◆ $pobject_id

ilFileDataShop::$pobject_id = 0
private

Definition at line 17 of file class.ilFileDataShop.php.

Referenced by __construct().

◆ $shop_path

ilFileDataShop::$shop_path = ''
private

Definition at line 18 of file class.ilFileDataShop.php.

◆ SHOPPATH

const ilFileDataShop::SHOPPATH = 'shop'

Definition at line 15 of file class.ilFileDataShop.php.


The documentation for this class was generated from the following file: