ILIAS  release_8 Revision v8.24
ilStudyProgrammeType Class Reference

Class ilStudyProgrammeType. More...

+ Collaboration diagram for ilStudyProgrammeType:

Public Member Functions

 __construct (int $id, ilStudyProgrammeTypeRepository $type_repo, ILIAS\Filesystem\Filesystem $webdir, ilLanguage $lng, ilObjUser $user, ilComponentFactory $component_factory)
 
 getTitle (string $a_lang_code='')
 Get the title of an StudyProgramme type. More...
 
 setTitle (string $title, string $lang_code='')
 Set title of StudyProgramme type. More...
 
 getDescription (string $lang_code='')
 Get the description of an StudyProgramme type. More...
 
 setDescription (string $description, string $lang_code='')
 Set description of StudyProgramme type. More...
 
 updateAssignedStudyProgrammesIcons ()
 Update the Icons of assigned objects. More...
 
 processAndStoreIconFile (array $file_data)
 Resize and store an icon file for this object. More...
 
 removeIconFile ()
 Remove the icon file on disk. More...
 
 setTranslations (array $translations)
 Getters & Setters. More...
 
 getTranslations ()
 
 setOwner (int $owner)
 
 getOwner ()
 
 setLastUpdate (DateTime $last_update)
 
 getLastUpdate ()
 
 getId ()
 
 setIcon (string $icon)
 Set new Icon filename. More...
 
 getIcon ()
 
 getIconPath (bool $append_filename=false)
 Return the path to the icon. More...
 
 setDefaultLang (string $default_lang)
 
 getDefaultLang ()
 
 setCreateDate (DateTime $create_date)
 
 getCreateDate ()
 
 getRepository ()
 
 changedTranslations ()
 

Data Fields

const DATE_TIME_FORMAT = 'Y-m-d H:i:s'
 
const DATE_FORMAT = 'Y-m-d'
 

Protected Member Functions

 getTranslation (string $member, string $lang_code)
 Protected. More...
 
 loadTranslation (string $lang_code)
 
 updateable ()
 Helper function to check if this type can be updated. More...
 
 getActivePlugins ()
 

Protected Attributes

string $default_lang = ''
 
int $owner
 
DateTime $create_date
 
DateTime $last_update
 
string $icon
 
ilObjUser $user
 
array $active_plugins
 
ilLanguage $lng
 
array $translations
 
array $changed_translations = array()
 
int $id = 0
 
ilStudyProgrammeTypeRepository $type_repo
 
Filesystem $webdir
 
ilComponentFactory $component_factory
 

Private Attributes

const WEB_DATA_FOLDER = 'prg_data'
 Folder in ILIAS webdir to store the icons. More...
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilStudyProgrammeType::__construct ( int  $id,
ilStudyProgrammeTypeRepository  $type_repo,
ILIAS\Filesystem\Filesystem  $webdir,
ilLanguage  $lng,
ilObjUser  $user,
ilComponentFactory  $component_factory 
)

Definition at line 57 of file class.ilStudyProgrammeType.php.

64 {
65 $this->id = $id;
66 $this->type_repo = $type_repo;
67 $this->webdir = $webdir;
68 $this->lng = $lng;
69 $this->user = $user;
70 $this->component_factory = $component_factory;
71 }
ilComponentFactory $component_factory
ilStudyProgrammeTypeRepository $type_repo

References $component_factory, $id, $lng, $type_repo, $user, $webdir, ILIAS\Repository\lng(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ changedTranslations()

ilStudyProgrammeType::changedTranslations ( )

Definition at line 484 of file class.ilStudyProgrammeType.php.

484 : array
485 {
487 }

References $changed_translations.

◆ getActivePlugins()

ilStudyProgrammeType::getActivePlugins ( )
protected

Definition at line 479 of file class.ilStudyProgrammeType.php.

479 : Iterator
480 {
481 return $this->component_factory->getActivePluginsInSlot("prgtypehk");
482 }

Referenced by updateable().

+ Here is the caller graph for this function:

◆ getCreateDate()

ilStudyProgrammeType::getCreateDate ( )

Definition at line 469 of file class.ilStudyProgrammeType.php.

469 : DateTime
470 {
471 return $this->create_date;
472 }

References $create_date.

◆ getDefaultLang()

ilStudyProgrammeType::getDefaultLang ( )

Definition at line 459 of file class.ilStudyProgrammeType.php.

459 : string
460 {
461 return $this->default_lang;
462 }

References $default_lang.

Referenced by getTranslation(), setDescription(), and setTitle().

+ Here is the caller graph for this function:

◆ getDescription()

ilStudyProgrammeType::getDescription ( string  $lang_code = '')

Get the description of an StudyProgramme type.

If no language code is given, a translation in the user-language is returned. If no such translation exists, the description of the default language is substituted. If a language code is provided, returns description for the given language or null.

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

98 : string
99 {
100 return (string) $this->getTranslation('description', $lang_code);
101 }
getTranslation(string $member, string $lang_code)
Protected.

References getTranslation().

+ Here is the call graph for this function:

◆ getIcon()

ilStudyProgrammeType::getIcon ( )

Definition at line 434 of file class.ilStudyProgrammeType.php.

434 : string
435 {
436 return $this->icon;
437 }

References $icon.

Referenced by ilStudyProgrammeTypeCustomIconsFormGUI\fillForm(), getIconPath(), and removeIconFile().

+ Here is the caller graph for this function:

◆ getIconPath()

ilStudyProgrammeType::getIconPath ( bool  $append_filename = false)

Return the path to the icon.

Parameters
bool$append_filenameIf true, append filename of icon

Definition at line 444 of file class.ilStudyProgrammeType.php.

444 : string
445 {
446 $path = self::WEB_DATA_FOLDER . '/' . 'type_' . $this->getId() . '/';
447 if ($append_filename) {
448 $path .= $this->getIcon();
449 }
450
451 return $path;
452 }
$path
Definition: ltiservices.php:32

References $path, getIcon(), and getId().

Referenced by processAndStoreIconFile(), and removeIconFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilStudyProgrammeType::getId ( )

Definition at line 411 of file class.ilStudyProgrammeType.php.

411 : int
412 {
413 return $this->id;
414 }

References $id.

Referenced by getIconPath(), loadTranslation(), and updateAssignedStudyProgrammesIcons().

+ Here is the caller graph for this function:

◆ getLastUpdate()

ilStudyProgrammeType::getLastUpdate ( )

Definition at line 406 of file class.ilStudyProgrammeType.php.

406 : DateTime
407 {
408 return $this->last_update;
409 }

References $last_update.

◆ getOwner()

ilStudyProgrammeType::getOwner ( )

Definition at line 396 of file class.ilStudyProgrammeType.php.

396 : int
397 {
398 return $this->owner;
399 }

References $owner.

◆ getRepository()

ilStudyProgrammeType::getRepository ( )

Definition at line 474 of file class.ilStudyProgrammeType.php.

475 {
476 return $this->type_repo;
477 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $type_repo.

◆ getTitle()

ilStudyProgrammeType::getTitle ( string  $a_lang_code = '')

Get the title of an StudyProgramme type.

If no language code is given, a translation in the user-language is returned. If no such translation exists, the translation of the default language is substituted. If a language code is provided, returns title for the given language or null.

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

78 : string
79 {
80 return (string) $this->getTranslation('title', $a_lang_code);
81 }

References getTranslation().

+ Here is the call graph for this function:

◆ getTranslation()

ilStudyProgrammeType::getTranslation ( string  $member,
string  $lang_code 
)
protected

Protected.

Helper method to return a translation for a given member and language

Definition at line 266 of file class.ilStudyProgrammeType.php.

266 : ?string
267 {
268 $lang = ($lang_code) ?: $this->user->getLanguage();
269
270 $trans_obj = $this->loadTranslation($lang);
271 if (!is_null($trans_obj)) {
272 $translation = $trans_obj[$member] ?? null;
273 // If the translation does exist but is an empty string and there was no lang code given,
274 // substitute default language anyway because an empty string provides no information
275 if (!$lang_code && !$translation) {
276 $trans_obj = $this->loadTranslation($this->getDefaultLang());
277
278 return $trans_obj[$member] ?? null;
279 }
280
281 return $translation;
282 }
283
284 // If no lang code was given and there was no translation found, return string in default language
285 if (!$lang_code) {
286 $trans_obj = $this->loadTranslation($this->getDefaultLang());
287
288 return $trans_obj[$member] ?? null;
289 }
290
291 return null;
292 }
$lang
Definition: xapiexit.php:26

References $lang, getDefaultLang(), loadTranslation(), and ILIAS\Repository\user().

Referenced by getDescription(), and getTitle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTranslations()

ilStudyProgrammeType::getTranslations ( )

Definition at line 386 of file class.ilStudyProgrammeType.php.

386 : ?array
387 {
388 return $this->translations;
389 }

References $translations.

◆ loadTranslation()

ilStudyProgrammeType::loadTranslation ( string  $lang_code)
protected

Definition at line 294 of file class.ilStudyProgrammeType.php.

294 : ?array
295 {
296 if (isset($this->translations[$lang_code])) {
297 return $this->translations[$lang_code];
298 } else {
299 $trans_array = $this->type_repo->getTranslationsByTypeAndLang($this->getId(), $lang_code);
300
301 //ilStudyProgrammeTypeTranslation::where(array('prg_type_id'=>$this->getId(), 'lang'=>$a_lang_code))->getArray('member', 'value');
302 if (count($trans_array)) {
303 $this->translations[$lang_code] = $trans_array;
304
305 return $trans_array;
306 }
307 }
308
309 return null;
310 }

References getId().

Referenced by getTranslation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processAndStoreIconFile()

ilStudyProgrammeType::processAndStoreIconFile ( array  $file_data)

Resize and store an icon file for this object.

Parameters
array$file_dataThe array containing file information from the icon from PHPs $_FILES array

Definition at line 219 of file class.ilStudyProgrammeType.php.

219 : bool
220 {
221 if (!$this->updateable()) {
222 return false;
223 }
224 if (!count($file_data) || !$file_data['name']) {
225 return false;
226 }
227 if (!$this->webdir->hasDir($this->getIconPath())) {
228 $this->webdir->createDir($this->getIconPath());
229 }
230
231 if ($this->webdir->has($this->getIconPath(true))) {
232 $this->webdir->delete($this->getIconPath(true));
233 }
234
235 $stream = ILIAS\Filesystem\Stream\Streams::ofResource(fopen($file_data["tmp_name"], 'rb'));
236 $this->webdir->writeStream($this->getIconPath(true), $stream);
237
238 return true;
239 }
static ofResource($resource)
Wraps an already created resource with the stream abstraction.
Definition: Streams.php:65
updateable()
Helper function to check if this type can be updated.
getIconPath(bool $append_filename=false)
Return the path to the icon.

References getIconPath(), ILIAS\Filesystem\Stream\Streams\ofResource(), and updateable().

+ Here is the call graph for this function:

◆ removeIconFile()

ilStudyProgrammeType::removeIconFile ( )

Remove the icon file on disk.

Definition at line 244 of file class.ilStudyProgrammeType.php.

244 : void
245 {
246 if (!$this->updateable()) {
247 return;
248 }
249
250 if (
251 !is_null($this->getIcon()) &&
252 $this->getIcon() !== ""
253 ) {
254 $this->webdir->delete($this->getIconPath(true));
255 $this->setIcon('');
256 }
257 }
setIcon(string $icon)
Set new Icon filename.

References getIcon(), getIconPath(), setIcon(), and updateable().

+ Here is the call graph for this function:

◆ setCreateDate()

ilStudyProgrammeType::setCreateDate ( DateTime  $create_date)

Definition at line 464 of file class.ilStudyProgrammeType.php.

464 : void
465 {
466 $this->create_date = $create_date;
467 }

References $create_date.

◆ setDefaultLang()

ilStudyProgrammeType::setDefaultLang ( string  $default_lang)

Definition at line 454 of file class.ilStudyProgrammeType.php.

454 : void
455 {
456 $this->default_lang = $default_lang;
457 }

References $default_lang.

◆ setDescription()

ilStudyProgrammeType::setDescription ( string  $description,
string  $lang_code = '' 
)

Set description of StudyProgramme type.

If no lang code is given, sets description for default language.

Definition at line 107 of file class.ilStudyProgrammeType.php.

107 : void
108 {
109 $lang = ($lang_code) ?: $this->getDefaultLang();
110 $this->setTranslation('description', $description, $lang);
111 }

References $lang, and getDefaultLang().

+ Here is the call graph for this function:

◆ setIcon()

ilStudyProgrammeType::setIcon ( string  $icon)

Set new Icon filename.

Note that if you did also send a new icon image file with a form, make sure to call ilStudyProgrammeType::processAndStoreIconFile() to store the file additionally on disk.

If you want to delete the icon, set call ilStudyProgrammeType::removeIconFile() first and set an empty string here.

Exceptions
ilStudyProgrammeTypeException

Definition at line 426 of file class.ilStudyProgrammeType.php.

426 : void
427 {
428 if ($icon && !preg_match('/\.(svg)$/', $icon)) {
429 throw new ilStudyProgrammeTypeException('Icon must be set with file extension svg');
430 }
431 $this->icon = $icon;
432 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $icon.

Referenced by removeIconFile().

+ Here is the caller graph for this function:

◆ setLastUpdate()

ilStudyProgrammeType::setLastUpdate ( DateTime  $last_update)

Definition at line 401 of file class.ilStudyProgrammeType.php.

401 : void
402 {
403 $this->last_update = $last_update;
404 }

References $last_update.

◆ setOwner()

ilStudyProgrammeType::setOwner ( int  $owner)

Definition at line 391 of file class.ilStudyProgrammeType.php.

391 : void
392 {
393 $this->owner = $owner;
394 }

References $owner.

◆ setTitle()

ilStudyProgrammeType::setTitle ( string  $title,
string  $lang_code = '' 
)

Set title of StudyProgramme type.

If no lang code is given, sets title for default language.

Definition at line 87 of file class.ilStudyProgrammeType.php.

87 : void
88 {
89 $lang = ($lang_code) ?: $this->getDefaultLang();
90 $this->setTranslation('title', $title, $lang);
91 }

References $lang, and getDefaultLang().

+ Here is the call graph for this function:

◆ setTranslations()

ilStudyProgrammeType::setTranslations ( array  $translations)

Getters & Setters.

Definition at line 330 of file class.ilStudyProgrammeType.php.

330 : void
331 {
332 $this->translations = $translations;
333 }

References $translations.

◆ updateable()

ilStudyProgrammeType::updateable ( )
protected

Helper function to check if this type can be updated.

Definition at line 315 of file class.ilStudyProgrammeType.php.

315 : bool
316 {
317 foreach ($this->getActivePlugins() as $plugin) {
318 if (!$plugin->allowUpdate($this->getId())) {
319 return false;
320 }
321 }
322
323 return true;
324 }

References XapiProxy\$plugin, and getActivePlugins().

Referenced by processAndStoreIconFile(), and removeIconFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateAssignedStudyProgrammesIcons()

ilStudyProgrammeType::updateAssignedStudyProgrammesIcons ( )

Update the Icons of assigned objects.

Definition at line 116 of file class.ilStudyProgrammeType.php.

116 : void
117 {
118 $obj_ids = $this->type_repo->getStudyProgrammeIdsByTypeId($this->getId());
119
120 foreach ($obj_ids as $id) {
123 $osp->updateCustomIcon();
124 }
125 }
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:67

References $id, $ref_id, ilObject\_getAllReferences(), getId(), and ilObjStudyProgramme\getInstanceByRefId().

+ Here is the call graph for this function:

Field Documentation

◆ $active_plugins

array ilStudyProgrammeType::$active_plugins
protected

Definition at line 45 of file class.ilStudyProgrammeType.php.

◆ $changed_translations

array ilStudyProgrammeType::$changed_translations = array()
protected

Definition at line 48 of file class.ilStudyProgrammeType.php.

Referenced by changedTranslations().

◆ $component_factory

ilComponentFactory ilStudyProgrammeType::$component_factory
protected

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

Referenced by __construct().

◆ $create_date

DateTime ilStudyProgrammeType::$create_date
protected

Definition at line 41 of file class.ilStudyProgrammeType.php.

Referenced by getCreateDate(), and setCreateDate().

◆ $default_lang

string ilStudyProgrammeType::$default_lang = ''
protected

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

Referenced by getDefaultLang(), and setDefaultLang().

◆ $icon

string ilStudyProgrammeType::$icon
protected

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

Referenced by getIcon(), and setIcon().

◆ $id

int ilStudyProgrammeType::$id = 0
protected

◆ $last_update

DateTime ilStudyProgrammeType::$last_update
protected

Definition at line 42 of file class.ilStudyProgrammeType.php.

Referenced by getLastUpdate(), and setLastUpdate().

◆ $lng

ilLanguage ilStudyProgrammeType::$lng
protected

Definition at line 46 of file class.ilStudyProgrammeType.php.

Referenced by __construct().

◆ $owner

int ilStudyProgrammeType::$owner
protected

Definition at line 40 of file class.ilStudyProgrammeType.php.

Referenced by getOwner(), and setOwner().

◆ $translations

array ilStudyProgrammeType::$translations
protected

Definition at line 47 of file class.ilStudyProgrammeType.php.

Referenced by getTranslations(), and setTranslations().

◆ $type_repo

ilStudyProgrammeTypeRepository ilStudyProgrammeType::$type_repo
protected

Definition at line 51 of file class.ilStudyProgrammeType.php.

Referenced by __construct(), and getRepository().

◆ $user

ilObjUser ilStudyProgrammeType::$user
protected

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

Referenced by __construct().

◆ $webdir

Filesystem ilStudyProgrammeType::$webdir
protected

Definition at line 52 of file class.ilStudyProgrammeType.php.

Referenced by __construct().

◆ DATE_FORMAT

const ilStudyProgrammeType::DATE_FORMAT = 'Y-m-d'

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

◆ DATE_TIME_FORMAT

const ilStudyProgrammeType::DATE_TIME_FORMAT = 'Y-m-d H:i:s'

◆ WEB_DATA_FOLDER

const ilStudyProgrammeType::WEB_DATA_FOLDER = 'prg_data'
private

Folder in ILIAS webdir to store the icons.

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


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