ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCertificateBackgroundImageFileService.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
8 {
9  const BACKGROUND_IMAGE_NAME = 'background.jpg';
10  const BACKGROUND_TEMPORARY_UPLOAD_FILE_NAME = 'background_upload.tmp';
11  const BACKGROUND_THUMBNAIL_FILE_ENDING = '.thumb.jpg';
12  const PLACEHOLDER_CLIENT_WEB_DIRECTORY = '[CLIENT_WEB_DIR]';
13 
17  private $fileSystem;
18 
23 
27  private $webDirectory;
28 
34  public function __construct(
35  string $certificatePath,
36  \ILIAS\Filesystem\Filesystem $filesystem,
37  $webDirectory = CLIENT_WEB_DIR
38  ) {
39  $this->certificatePath = $certificatePath;
40  $this->fileSystem = $filesystem;
41  $this->webDirectory = $webDirectory;
42  }
43 
49  public function hasBackgroundImage(ilCertificateTemplate $template)
50  {
51  $backgroundImagePath = $template->getBackgroundImagePath();
52  if ($backgroundImagePath === '') {
53  return false;
54  }
55 
56  if ($this->fileSystem->has($backgroundImagePath)) {
57  return true;
58  }
59 
60  return false;
61  }
62 
68  {
69  $backgroundImagePath = $template->getThumbnailImagePath();
70  if ($backgroundImagePath === '') {
71  return false;
72  }
73 
74  if ($this->fileSystem->has($backgroundImagePath)) {
75  return true;
76  }
77 
78  return false;
79  }
80 
85  public function getBackgroundImageThumbPath()
86  {
87  return $this->webDirectory . $this->certificatePath . self::BACKGROUND_IMAGE_NAME . self::BACKGROUND_THUMBNAIL_FILE_ENDING;
88  }
89 
95  public function getBackgroundImageDirectory($backgroundImagePath = '')
96  {
97  return str_replace(
98  array($this->webDirectory, '//'),
99  array(self::PLACEHOLDER_CLIENT_WEB_DIRECTORY, '/'),
100  $backgroundImagePath
101  );
102  }
103 
110  {
111  return $this->webDirectory . $this->certificatePath . self::BACKGROUND_TEMPORARY_UPLOAD_FILE_NAME;
112  }
113 }
hasBackgroundImage(ilCertificateTemplate $template)
Checks for the background image of the certificate.
Class ChatMainBarProvider .
__construct(string $certificatePath, \ILIAS\Filesystem\Filesystem $filesystem, $webDirectory=CLIENT_WEB_DIR)
getBackgroundImageThumbPath()
Returns the filesystem path of the background image thumbnail.
getBackgroundImageTempfilePath()
Returns the filesystem path of the background image temp file during upload.
getBackgroundImageDirectory($backgroundImagePath='')
Returns the filesystem path of the background image.
Class FlySystemFileAccessTest.