ILIAS  release_8 Revision v8.23
ilPreviewSettings Class Reference
+ Collaboration diagram for ilPreviewSettings:

Static Public Member Functions

static setPreviewEnabled (bool $a_value)
 Sets whether the preview functionality is enabled. More...
 
static isPreviewEnabled ()
 Gets whether the preview functionality is enabled. More...
 
static setMaximumPreviews (int $a_value)
 Sets the maximum number of preview pictures per object. More...
 
static getMaximumPreviews ()
 Gets the maximum number of preview pictures per object. More...
 
static setImageSize (int $a_value)
 Sets the size of the preview images in pixels. More...
 
static getImageSize ()
 Gets the size of the preview images in pixels. More...
 
static setImageQuality (int $a_value)
 Sets the quality (compression) of the preview images (1-100). More...
 
static getImageQuality ()
 Gets the quality (compression) of the preview images (1-100). More...
 

Data Fields

const MAX_PREVIEWS_DEFAULT = 5
 
const MAX_PREVIEWS_MIN = 1
 
const MAX_PREVIEWS_MAX = 20
 

Private Member Functions

 __construct ()
 Private constructor. More...
 

Static Private Member Functions

static getInstance ()
 Gets the instance of the ilPreviewSettings. More...
 
static adjustNumeric ($value, int $min, int $max, int $default)
 

Private Attributes

const IMAGE_SIZE_DEFAULT = 280
 
const IMAGE_SIZE_MIN = 50
 
const IMAGE_SIZE_MAX = 600
 
const IMAGE_QUALITY_DEFAULT = 85
 
const IMAGE_QUALITY_MIN = 20
 
const IMAGE_QUALITY_MAX = 100
 
ilSetting $settings = null
 Settings object. More...
 
bool $preview_enabled = true
 Indicates whether the preview functionality is enabled. More...
 
int $max_previews = self::MAX_PREVIEWS_DEFAULT
 Defines the maximum number of previews pictures per object. More...
 
int $image_size = self::IMAGE_SIZE_DEFAULT
 Defines the maximum width and height of the preview images. More...
 
int $image_quality = self::IMAGE_QUALITY_DEFAULT
 Defines the quality (compression) of the preview images (1-100). More...
 

Static Private Attributes

static ilPreviewSettings $instance = null
 The instance of the ilPreviewSettings. More...
 

Detailed Description

Definition at line 27 of file class.ilPreviewSettings.php.

Constructor & Destructor Documentation

◆ __construct()

ilPreviewSettings::__construct ( )
private

Private constructor.

Definition at line 74 of file class.ilPreviewSettings.php.

References ILIAS\Repository\settings().

75  {
76  $this->settings = new ilSetting("preview");
77  $this->preview_enabled = (bool) $this->settings->get('preview_enabled', '0') === true;
78  $this->max_previews = $this->settings->get('max_previews_per_object', self::MAX_PREVIEWS_DEFAULT);
79  }
+ Here is the call graph for this function:

Member Function Documentation

◆ adjustNumeric()

static ilPreviewSettings::adjustNumeric (   $value,
int  $min,
int  $max,
int  $default 
)
staticprivate

Definition at line 181 of file class.ilPreviewSettings.php.

References ILIAS\Repository\int().

181  : int
182  {
183  // is number?
184  if (is_numeric($value)) {
185  // don't allow to large numbers
186  $value = (int) $value;
187  if ($value < $min) {
188  $value = $min;
189  } elseif ($value > $max) {
190  $value = $max;
191  }
192  } else {
193  $value = $default;
194  }
195 
196  return $value;
197  }
+ Here is the call graph for this function:

◆ getImageQuality()

static ilPreviewSettings::getImageQuality ( )
static

Gets the quality (compression) of the preview images (1-100).

Returns
int The current value

Definition at line 164 of file class.ilPreviewSettings.php.

Referenced by ilPreviewRenderer\getImageQuality().

164  : int
165  {
166  return self::getInstance()->image_quality;
167  }
+ Here is the caller graph for this function:

◆ getImageSize()

static ilPreviewSettings::getImageSize ( )
static

Gets the size of the preview images in pixels.

Returns
int The current value

Definition at line 142 of file class.ilPreviewSettings.php.

Referenced by ilPreviewRenderer\getImageSize(), and ilPreviewGUI\initPreview().

142  : int
143  {
144  return self::getInstance()->image_size;
145  }
+ Here is the caller graph for this function:

◆ getInstance()

static ilPreviewSettings::getInstance ( )
staticprivate

Gets the instance of the ilPreviewSettings.

Definition at line 172 of file class.ilPreviewSettings.php.

173  {
174  if (self::$instance === null) {
175  self::$instance = new ilPreviewSettings();
176  }
177 
178  return self::$instance;
179  }

◆ getMaximumPreviews()

static ilPreviewSettings::getMaximumPreviews ( )
static

Gets the maximum number of preview pictures per object.

Returns
int The current value

Definition at line 120 of file class.ilPreviewSettings.php.

Referenced by ilPreviewRenderer\getMaximumNumberOfPreviews(), and ilObjFileAccessSettingsGUI\initSettingsForm().

120  : int
121  {
122  return self::getInstance()->max_previews;
123  }
+ Here is the caller graph for this function:

◆ isPreviewEnabled()

static ilPreviewSettings::isPreviewEnabled ( )
static

Gets whether the preview functionality is enabled.

Returns
bool The current value

Definition at line 98 of file class.ilPreviewSettings.php.

Referenced by ilPreview\copyPreviews(), ilPreview\create(), ilPreview\hasPreview(), and ilObjFileAccessSettingsGUI\initSettingsForm().

98  : bool
99  {
100  return self::getInstance()->preview_enabled;
101  }
+ Here is the caller graph for this function:

◆ setImageQuality()

static ilPreviewSettings::setImageQuality ( int  $a_value)
static

Sets the quality (compression) of the preview images (1-100).

Parameters
int$a_valueThe new value

Definition at line 152 of file class.ilPreviewSettings.php.

152  : void
153  {
154  $instance = self::getInstance();
155  $instance->image_quality = self::adjustNumeric($a_value, self::IMAGE_QUALITY_MIN, self::IMAGE_QUALITY_MAX, self::IMAGE_QUALITY_DEFAULT);
156  $instance->settings->set('preview_image_quality', $instance->image_quality);
157  }
static ilPreviewSettings $instance
The instance of the ilPreviewSettings.

◆ setImageSize()

static ilPreviewSettings::setImageSize ( int  $a_value)
static

Sets the size of the preview images in pixels.

Parameters
int$a_valueThe new value

Definition at line 130 of file class.ilPreviewSettings.php.

130  : void
131  {
132  $instance = self::getInstance();
133  $instance->image_size = self::adjustNumeric($a_value, self::IMAGE_SIZE_MIN, self::IMAGE_SIZE_MAX, self::IMAGE_SIZE_DEFAULT);
134  $instance->settings->set('preview_image_size', $instance->image_size);
135  }
static ilPreviewSettings $instance
The instance of the ilPreviewSettings.

◆ setMaximumPreviews()

static ilPreviewSettings::setMaximumPreviews ( int  $a_value)
static

Sets the maximum number of preview pictures per object.

Parameters
int$a_valueThe new value

Definition at line 108 of file class.ilPreviewSettings.php.

Referenced by ilObjFileAccessSettingsGUI\saveSettings().

108  : void
109  {
110  $instance = self::getInstance();
111  $instance->max_previews = self::adjustNumeric($a_value, self::MAX_PREVIEWS_MIN, self::MAX_PREVIEWS_MAX, self::MAX_PREVIEWS_DEFAULT);
112  $instance->settings->set('max_previews_per_object', $instance->max_previews);
113  }
static ilPreviewSettings $instance
The instance of the ilPreviewSettings.
+ Here is the caller graph for this function:

◆ setPreviewEnabled()

static ilPreviewSettings::setPreviewEnabled ( bool  $a_value)
static

Sets whether the preview functionality is enabled.

Parameters
bool$a_valueThe new value

Definition at line 86 of file class.ilPreviewSettings.php.

Referenced by ilObjFileAccessSettingsGUI\saveSettings().

86  : void
87  {
88  $instance = self::getInstance();
89  $instance->preview_enabled = $a_value === true;
90  $instance->settings->set('preview_enabled', $instance->preview_enabled);
91  }
static ilPreviewSettings $instance
The instance of the ilPreviewSettings.
+ Here is the caller graph for this function:

Field Documentation

◆ $image_quality

int ilPreviewSettings::$image_quality = self::IMAGE_QUALITY_DEFAULT
private

Defines the quality (compression) of the preview images (1-100).

Definition at line 69 of file class.ilPreviewSettings.php.

◆ $image_size

int ilPreviewSettings::$image_size = self::IMAGE_SIZE_DEFAULT
private

Defines the maximum width and height of the preview images.

Definition at line 64 of file class.ilPreviewSettings.php.

◆ $instance

ilPreviewSettings ilPreviewSettings::$instance = null
staticprivate

The instance of the ilPreviewSettings.

Definition at line 44 of file class.ilPreviewSettings.php.

◆ $max_previews

int ilPreviewSettings::$max_previews = self::MAX_PREVIEWS_DEFAULT
private

Defines the maximum number of previews pictures per object.

Definition at line 59 of file class.ilPreviewSettings.php.

◆ $preview_enabled

bool ilPreviewSettings::$preview_enabled = true
private

Indicates whether the preview functionality is enabled.

Definition at line 54 of file class.ilPreviewSettings.php.

◆ $settings

ilSetting ilPreviewSettings::$settings = null
private

Settings object.

Definition at line 49 of file class.ilPreviewSettings.php.

◆ IMAGE_QUALITY_DEFAULT

const ilPreviewSettings::IMAGE_QUALITY_DEFAULT = 85
private

Definition at line 37 of file class.ilPreviewSettings.php.

◆ IMAGE_QUALITY_MAX

const ilPreviewSettings::IMAGE_QUALITY_MAX = 100
private

Definition at line 39 of file class.ilPreviewSettings.php.

◆ IMAGE_QUALITY_MIN

const ilPreviewSettings::IMAGE_QUALITY_MIN = 20
private

Definition at line 38 of file class.ilPreviewSettings.php.

◆ IMAGE_SIZE_DEFAULT

const ilPreviewSettings::IMAGE_SIZE_DEFAULT = 280
private

Definition at line 33 of file class.ilPreviewSettings.php.

◆ IMAGE_SIZE_MAX

const ilPreviewSettings::IMAGE_SIZE_MAX = 600
private

Definition at line 35 of file class.ilPreviewSettings.php.

◆ IMAGE_SIZE_MIN

const ilPreviewSettings::IMAGE_SIZE_MIN = 50
private

Definition at line 34 of file class.ilPreviewSettings.php.

◆ MAX_PREVIEWS_DEFAULT

const ilPreviewSettings::MAX_PREVIEWS_DEFAULT = 5

Definition at line 29 of file class.ilPreviewSettings.php.

◆ MAX_PREVIEWS_MAX

const ilPreviewSettings::MAX_PREVIEWS_MAX = 20

◆ MAX_PREVIEWS_MIN

const ilPreviewSettings::MAX_PREVIEWS_MIN = 1

Definition at line 30 of file class.ilPreviewSettings.php.


The documentation for this class was generated from the following file: