ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilObjCertificateSettings.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24require_once "./Services/Object/classes/class.ilObject.php";
25
35{
36
43 function ilObjCertificateSettings($a_id = 0,$a_call_by_reference = true)
44 {
45 $this->ilObject($a_id,$a_call_by_reference);
46 $this->type = "cert";
47 }
48
49 public function hasBackgroundImage()
50 {
51 if (@file_exists($this->getBackgroundImagePath()) && (@filesize($this->getBackgroundImagePath()) > 0))
52 {
53 return TRUE;
54 }
55 else
56 {
57 return FALSE;
58 }
59 }
60
62 {
63 return CLIENT_WEB_DIR . "/certificates/default/";
64 }
65
71 public function getBackgroundImagePath()
72 {
74 }
75
81 public function getBackgroundImageName()
82 {
83 return "background.jpg";
84 }
85
92 {
93 return $this->getBackgroundImageDefaultFolder() . $this->getBackgroundImageName() . ".thumb.jpg";
94 }
95
102 {
103 return $this->getBackgroundImageDefaultFolder() . "background_upload.tmp";
104 }
105
112 {
113 include_once "./Services/Utilities/classes/class.ilUtil.php";
115 }
116
123 {
124 include_once "./Services/Utilities/classes/class.ilUtil.php";
126 }
127
135 public function uploadBackgroundImage($image_tempfilename)
136 {
137 if (!empty($image_tempfilename))
138 {
139 $convert_filename = $this->getBackgroundImageName();
140 $imagepath = $this->getBackgroundImageDefaultFolder();
141 if (!file_exists($imagepath))
142 {
143 ilUtil::makeDirParents($imagepath);
144 }
145 // upload the file
147 $image_tempfilename,
148 basename($this->getBackgroundImageTempfilePath()),
150 )) {
151 return FALSE;
152 }
153 // convert the uploaded file to JPEG
156 if (!file_exists($this->getBackgroundImagePath()))
157 {
158 // something went wrong converting the file. use the original file and hope, that PDF can work with it
159 if (!ilUtil::moveUploadedFile($this->getBackgroundImageTempfilePath(), $convert_filename, $this->getBackgroundImagePath()))
160 {
161 return FALSE;
162 }
163 }
164 unlink($this->getBackgroundImageTempfilePath());
165 if (file_exists($this->getBackgroundImagePath()) && (filesize($this->getBackgroundImagePath()) > 0))
166 {
167 return TRUE;
168 }
169 }
170 return FALSE;
171 }
172
178 public function deleteBackgroundImage()
179 {
180 $result = TRUE;
181 if (file_exists($this->getBackgroundImageThumbPath()))
182 {
183 $result = $result & unlink($this->getBackgroundImageThumbPath());
184 }
185 if (file_exists($this->getBackgroundImagePath()))
186 {
187 $result = $result & unlink($this->getBackgroundImagePath());
188 }
189 if (file_exists($this->getBackgroundImageTempfilePath()))
190 {
192 }
193 return $result;
194 }
195
196} // END class.ilObjCertificateSettings
197?>
$result
Class ilObjCertificateSettings.
getBackgroundImagePath()
Returns the filesystem path of the background image.
ilObjCertificateSettings($a_id=0, $a_call_by_reference=true)
Constructor @access public.
uploadBackgroundImage($image_tempfilename)
Uploads a background image for the certificate.
getBackgroundImageTempfilePath()
Returns the filesystem path of the background image temp file during upload.
getBackgroundImagePathWeb()
Returns the web path of the background image.
deleteBackgroundImage()
Deletes the background image of a certificate.
getBackgroundImageThumbPath()
Returns the filesystem path of the background image thumbnail.
getBackgroundImageThumbPathWeb()
Returns the web path of the background image thumbnail.
getBackgroundImageName()
Returns the filename of the background image.
Class ilObject Basic functions for all objects.
ilObject($a_id=0, $a_reference=true)
Constructor @access public.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static removeTrailingPathSeparators($path)
const ILIAS_ABSOLUTE_PATH