ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
56  public function uploadBackgroundImage($image_tempfilename)
57  {
58  if (!empty($image_tempfilename)) {
60  $imagepath = $this->getBackgroundImageDefaultFolder();
61  if (!file_exists($imagepath)) {
62  ilUtil::makeDirParents($imagepath);
63  }
64  // upload the file
66  $image_tempfilename,
67  basename($this->getDefaultBackgroundImageTempfilePath()),
69  )) {
70  return false;
71  }
72  // convert the uploaded file to JPEG
75  if (!file_exists($this->getDefaultBackgroundImagePath())) {
76  // something went wrong converting the file. use the original file and hope, that PDF can work with it
78  return false;
79  }
80  }
82  if (file_exists($this->getDefaultBackgroundImagePath()) && (filesize($this->getDefaultBackgroundImagePath()) > 0)) {
83  return true;
84  }
85  }
86  return false;
87  }
88 
94  public function deleteBackgroundImage()
95  {
96  $result = true;
97  if (file_exists($this->getDefaultBackgroundImageThumbPath())) {
99  }
100  if (file_exists($this->getDefaultBackgroundImagePath())) {
101  $result = $result & unlink($this->getDefaultBackgroundImagePath());
102  }
103  if (file_exists($this->getDefaultBackgroundImageTempfilePath())) {
105  }
106  return $result;
107  }
108 
110  {
111  return CLIENT_WEB_DIR . "/certificates/default/";
112  }
113 
119  private function getDefaultBackgroundImagePath()
120  {
122  }
123 
130  {
132  }
133 
140  {
142  }
143 
147  public function hasBackgroundImage() : bool
148  {
149  $filePath = $this->getDefaultBackgroundImagePath();
150  if (file_exists($filePath) && filesize($filePath) > 0) {
151  return true;
152  }
153 
154  return false;
155  }
156 
161  public function getDefaultBackgroundImagePathWeb() : string
162  {
163  return str_replace(
164  ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH),
167  );
168  }
169 
174  public function getBackgroundImageThumbPathWeb() : string
175  {
176  return str_replace(
177  ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH),
180  );
181  }
182 }
uploadBackgroundImage($image_tempfilename)
Uploads a background image for the certificate.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getDefaultBackgroundImageThumbPath()
Returns the filesystem path of the background image thumbnail.
$result
getBackgroundImageThumbPathWeb()
Returns the web path of the background image thumbnail.
__construct($a_id=0, $a_reference=true)
Constructor public.
getDefaultBackgroundImagePath()
Returns the filesystem path of the background image.
getDefaultBackgroundImageTempfilePath()
Returns the filesystem path of the background image temp file during upload.
Class ilObjCertificateSettings.
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 removeTrailingPathSeparators($path)
getDefaultBackgroundImagePathWeb()
Returns the web path of the background image.
deleteBackgroundImage()
Deletes the background image of a certificate.
__construct(Container $dic, ilPlugin $plugin)