ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
24 require_once "./Services/Object/classes/class.ilObject.php";
25 
35 {
36 
43  public function __construct($a_id = 0, $a_reference = true)
44  {
45  parent::__construct($a_id, $a_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 
91  public function getBackgroundImageThumbPath()
92  {
93  return $this->getBackgroundImageDefaultFolder() . $this->getBackgroundImageName() . ".thumb.jpg";
94  }
95 
102  {
103  return $this->getBackgroundImageDefaultFolder() . "background_upload.tmp";
104  }
105 
111  public function getBackgroundImagePathWeb()
112  {
113  include_once "./Services/Utilities/classes/class.ilUtil.php";
114  return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $this->getBackgroundImagePath());
115  }
116 
123  {
124  include_once "./Services/Utilities/classes/class.ilUtil.php";
125  return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $this->getBackgroundImageThumbPath());
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  {
191  $result = $result & unlink($this->getBackgroundImageTempfilePath());
192  }
193  return $result;
194  }
195 
196 } // END class.ilObjCertificateSettings
197 ?>
uploadBackgroundImage($image_tempfilename)
Uploads a background image for the certificate.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
$result
Class ilObject Basic functions for all objects.
getBackgroundImagePath()
Returns the filesystem path of the background image.
getBackgroundImageThumbPathWeb()
Returns the web path of the background image thumbnail.
__construct($a_id=0, $a_reference=true)
Constructor public.
Class ilObjCertificateSettings.
getBackgroundImageTempfilePath()
Returns the filesystem path of the background image temp file during upload.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static removeTrailingPathSeparators($path)
deleteBackgroundImage()
Deletes the background image of a certificate.
getBackgroundImageName()
Returns the filename of the background image.
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
getBackgroundImagePathWeb()
Returns the web path of the background image.
getBackgroundImageThumbPath()
Returns the filesystem path of the background image thumbnail.