ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilPreviewSettings Class Reference
+ Collaboration diagram for ilPreviewSettings:

Static Public Member Functions

static setPreviewEnabled ($a_value)
 Sets whether the preview functionality is enabled. More...
 
static isPreviewEnabled ()
 Gets whether the preview functionality is enabled. More...
 
static setMaximumPreviews ($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 ($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 ($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
 
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
 

Private Member Functions

 __construct ()
 Private constructor. More...
 

Static Private Member Functions

static getInstance ()
 Gets the instance of the ilPreviewSettings. More...
 
static adjustNumeric ($value, $min, $max, $default)
 Adjusts the numeric value to fit between the specified minimum and maximum. More...
 

Private Attributes

 $settings = null
 
 $preview_enabled = true
 
 $max_previews = self::MAX_PREVIEWS_DEFAULT
 
 $image_size = self::IMAGE_SIZE_DEFAULT
 
 $image_quality = self::IMAGE_QUALITY_DEFAULT
 

Static Private Attributes

static $instance = null
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilPreviewSettings::__construct ( )
private

Private constructor.

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

References settings().

67  {
68  $this->settings = new ilSetting("preview");
69  $this->preview_enabled = $this->settings->get('preview_enabled', false) == true;
70  $this->max_previews = $this->settings->get('max_previews_per_object', self::MAX_PREVIEWS_DEFAULT);
71  }
settings()
Definition: settings.php:2
+ Here is the call graph for this function:

Member Function Documentation

◆ adjustNumeric()

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

Adjusts the numeric value to fit between the specified minimum and maximum.

If the value is not numeric the default value is returned.

Parameters
object$valueThe value to adjust.
int$minThe allowed minimum (inclusive).
int$maxThe allowed maximum (inclusive).
int$defaultThe default value if the specified value is not numeric.
Returns
The adjusted value.

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

185  {
186  // is number?
187  if (is_numeric($value)) {
188  // don't allow to large numbers
189  $value = (int) $value;
190  if ($value < $min) {
191  $value = $min;
192  } elseif ($value > $max) {
193  $value = $max;
194  }
195  } else {
196  $value = $default;
197  }
198 
199  return $value;
200  }

◆ getImageQuality()

static ilPreviewSettings::getImageQuality ( )
static

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

Returns
int The current value

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

Referenced by ilPreviewRenderer\getImageQuality().

157  {
158  return self::getInstance()->image_quality;
159  }
+ 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 134 of file class.ilPreviewSettings.php.

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

135  {
136  return self::getInstance()->image_size;
137  }
+ Here is the caller graph for this function:

◆ getInstance()

static ilPreviewSettings::getInstance ( )
staticprivate

Gets the instance of the ilPreviewSettings.

Returns
ilPreviewSettings

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

166  {
167  if (self::$instance == null) {
168  self::$instance = new ilPreviewSettings();
169  }
170 
171  return self::$instance;
172  }

◆ getMaximumPreviews()

static ilPreviewSettings::getMaximumPreviews ( )
static

Gets the maximum number of preview pictures per object.

Returns
int The current value

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

Referenced by ilObjFileAccessSettingsGUI\editPreviewSettings(), ilPreviewRenderer\getMaximumNumberOfPreviews(), and ilObjFileAccessSettingsGUI\initPreviewSettingsForm().

113  {
114  return self::getInstance()->max_previews;
115  }
+ 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 90 of file class.ilPreviewSettings.php.

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

91  {
92  return self::getInstance()->preview_enabled;
93  }
+ Here is the caller graph for this function:

◆ setImageQuality()

static ilPreviewSettings::setImageQuality (   $a_value)
static

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

Parameters
int$a_valueThe new value

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

References $instance.

145  {
146  $instance = self::getInstance();
147  $instance->image_quality = self::adjustNumeric($a_value, self::IMAGE_QUALITY_MIN, self::IMAGE_QUALITY_MAX, self::IMAGE_QUALITY_DEFAULT);
148  $instance->settings->set('preview_image_quality', $instance->image_quality);
149  }

◆ setImageSize()

static ilPreviewSettings::setImageSize (   $a_value)
static

Sets the size of the preview images in pixels.

Parameters
int$a_valueThe new value

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

References $instance.

123  {
124  $instance = self::getInstance();
125  $instance->image_size = self::adjustNumeric($a_value, self::IMAGE_SIZE_MIN, self::IMAGE_SIZE_MAX, self::IMAGE_SIZE_DEFAULT);
126  $instance->settings->set('preview_image_size', $instance->image_size);
127  }

◆ setMaximumPreviews()

static ilPreviewSettings::setMaximumPreviews (   $a_value)
static

Sets the maximum number of preview pictures per object.

Parameters
int$a_valueThe new value

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

References $instance.

Referenced by ilObjFileAccessSettingsGUI\savePreviewSettings().

101  {
102  $instance = self::getInstance();
103  $instance->max_previews = self::adjustNumeric($a_value, self::MAX_PREVIEWS_MIN, self::MAX_PREVIEWS_MAX, self::MAX_PREVIEWS_DEFAULT);
104  $instance->settings->set('max_previews_per_object', $instance->max_previews);
105  }
+ Here is the caller graph for this function:

◆ setPreviewEnabled()

static ilPreviewSettings::setPreviewEnabled (   $a_value)
static

Sets whether the preview functionality is enabled.

Parameters
bool$a_valueThe new value

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

References $instance.

Referenced by ilObjFileAccessSettingsGUI\savePreviewSettings().

79  {
80  $instance = self::getInstance();
81  $instance->preview_enabled = $a_value == true;
82  $instance->settings->set('preview_enabled', $instance->preview_enabled);
83  }
+ Here is the caller graph for this function:

Field Documentation

◆ $image_quality

ilPreviewSettings::$image_quality = self::IMAGE_QUALITY_DEFAULT
private

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

◆ $image_size

ilPreviewSettings::$image_size = self::IMAGE_SIZE_DEFAULT
private

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

◆ $instance

ilPreviewSettings::$instance = null
staticprivate

◆ $max_previews

ilPreviewSettings::$max_previews = self::MAX_PREVIEWS_DEFAULT
private

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

◆ $preview_enabled

ilPreviewSettings::$preview_enabled = true
private

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

◆ $settings

ilPreviewSettings::$settings = null
private

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

◆ IMAGE_QUALITY_DEFAULT

const ilPreviewSettings::IMAGE_QUALITY_DEFAULT = 85

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

◆ IMAGE_QUALITY_MAX

const ilPreviewSettings::IMAGE_QUALITY_MAX = 100

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

◆ IMAGE_QUALITY_MIN

const ilPreviewSettings::IMAGE_QUALITY_MIN = 20

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

◆ IMAGE_SIZE_DEFAULT

const ilPreviewSettings::IMAGE_SIZE_DEFAULT = 280

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

◆ IMAGE_SIZE_MAX

const ilPreviewSettings::IMAGE_SIZE_MAX = 600

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

◆ IMAGE_SIZE_MIN

const ilPreviewSettings::IMAGE_SIZE_MIN = 50

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

◆ MAX_PREVIEWS_DEFAULT

const ilPreviewSettings::MAX_PREVIEWS_DEFAULT = 5

Definition at line 15 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 16 of file class.ilPreviewSettings.php.


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