ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 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 return true;
53 } else {
54 return false;
55 }
56 }
57
59 {
60 return CLIENT_WEB_DIR . "/certificates/default/";
61 }
62
68 public function getBackgroundImagePath()
69 {
71 }
72
78 public function getBackgroundImageName()
79 {
80 return "background.jpg";
81 }
82
89 {
90 return $this->getBackgroundImageDefaultFolder() . $this->getBackgroundImageName() . ".thumb.jpg";
91 }
92
99 {
100 return $this->getBackgroundImageDefaultFolder() . "background_upload.tmp";
101 }
102
109 {
110 include_once "./Services/Utilities/classes/class.ilUtil.php";
111 return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $this->getBackgroundImagePath());
112 }
113
120 {
121 include_once "./Services/Utilities/classes/class.ilUtil.php";
122 return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $this->getBackgroundImageThumbPath());
123 }
124
132 public function uploadBackgroundImage($image_tempfilename)
133 {
134 if (!empty($image_tempfilename)) {
135 $convert_filename = $this->getBackgroundImageName();
136 $imagepath = $this->getBackgroundImageDefaultFolder();
137 if (!file_exists($imagepath)) {
138 ilUtil::makeDirParents($imagepath);
139 }
140 // upload the file
141 if (!ilUtil::moveUploadedFile(
142 $image_tempfilename,
143 basename($this->getBackgroundImageTempfilePath()),
145 )) {
146 return false;
147 }
148 // convert the uploaded file to JPEG
151 if (!file_exists($this->getBackgroundImagePath())) {
152 // something went wrong converting the file. use the original file and hope, that PDF can work with it
153 if (!ilUtil::moveUploadedFile($this->getBackgroundImageTempfilePath(), $convert_filename, $this->getBackgroundImagePath())) {
154 return false;
155 }
156 }
157 unlink($this->getBackgroundImageTempfilePath());
158 if (file_exists($this->getBackgroundImagePath()) && (filesize($this->getBackgroundImagePath()) > 0)) {
159 return true;
160 }
161 }
162 return false;
163 }
164
170 public function deleteBackgroundImage()
171 {
172 $result = true;
173 if (file_exists($this->getBackgroundImageThumbPath())) {
174 $result = $result & unlink($this->getBackgroundImageThumbPath());
175 }
176 if (file_exists($this->getBackgroundImagePath())) {
177 $result = $result & unlink($this->getBackgroundImagePath());
178 }
179 if (file_exists($this->getBackgroundImageTempfilePath())) {
181 }
182 return $result;
183 }
184} // END class.ilObjCertificateSettings
$result
An exception for terminatinating execution or to throw for unit testing.
Class ilObjCertificateSettings.
getBackgroundImagePath()
Returns the filesystem path of the background image.
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.
__construct($a_id=0, $a_reference=true)
Constructor @access public.
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.
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)