ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilStudyProgrammeType Class Reference

Class ilStudyProgrammeType. More...

+ Collaboration diagram for ilStudyProgrammeType:

Public Member Functions

 __construct (int $id, ilStudyProgrammeTypeRepository $type_repo, ILIAS\Filesystem\Filesystem $webdir, ilPluginAdmin $plugin_admin, ilLanguage $lng, ilObjUser $user)
 
 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 ($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 WEB_DATA_FOLDER = 'prg_data'
 Folder in ILIAS webdir to store the icons. More...
 
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...
 

Protected Attributes

 $id = 0
 
 $default_lang = ''
 
 $owner
 
 $create_date
 
 $last_update
 
 $icon
 
 $amd_records_assigned
 
 $log
 
 $user
 
 $plugin_admin
 
 $active_plugins
 
 $lng
 
 $translations
 
 $changed_translations = array()
 

Static Protected Attributes

static $amd_records_available
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilStudyProgrammeType::__construct ( int  $id,
ilStudyProgrammeTypeRepository  $type_repo,
ILIAS\Filesystem\Filesystem  $webdir,
ilPluginAdmin  $plugin_admin,
ilLanguage  $lng,
ilObjUser  $user 
)
Parameters
int$a_id
Exceptions
ilStudyProgrammeTypeException

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

References $id, $lng, $plugin_admin, $user, and user().

107  {
108  $this->id = $id;
109  $this->type_repo = $type_repo;
110  $this->webdir = $webdir;
111  $this->plugin_admin = $plugin_admin;
112  $this->lng = $lng;
113  $this->user = $user;
114  }
user()
Definition: user.php:4
+ Here is the call graph for this function:

Member Function Documentation

◆ changedTranslations()

ilStudyProgrammeType::changedTranslations ( )

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

References $changed_translations.

629  : array
630  {
632  }

◆ getCreateDate()

ilStudyProgrammeType::getCreateDate ( )
Returns
string

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

References $create_date.

Referenced by ilStudyProgrammeTypeDBRepository\updateType().

605  {
606  return $this->create_date;
607  }
+ Here is the caller graph for this function:

◆ getDefaultLang()

ilStudyProgrammeType::getDefaultLang ( )
Returns
string

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

References $default_lang.

Referenced by ilStudyProgrammeTypeGUI\buildForm(), getTranslation(), setDescription(), setTitle(), and ilStudyProgrammeTypeDBRepository\updateType().

586  : string
587  {
588  return $this->default_lang;
589  }
+ 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.

Parameters
string$a_lang_code
Returns
null|string

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

References getTranslation().

Referenced by ilStudyProgrammeTypeGUI\buildLanguagesForms().

154  : string
155  {
156  return (string) $this->getTranslation('description', $lang_code);
157  }
getTranslation(string $member, string $lang_code)
Protected.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIcon()

ilStudyProgrammeType::getIcon ( )
Returns
string

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

References $icon.

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

549  {
550  return $this->icon;
551  }
+ 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
Returns
string

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

References getIcon(), and getId().

Referenced by ilStudyProgrammeTypeCustomIconsFormGUI\fillForm(), processAndStoreIconFile(), removeIconFile(), and ilStudyProgrammeTypeDBRepository\updateRowTypeTranslationDB().

562  {
563  $path = self::WEB_DATA_FOLDER . '/' . 'type_' . $this->getId() . '/';
564  if ($append_filename) {
565  $path .= $this->getIcon();
566  }
567 
568  return $path;
569  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

◆ getLastUpdate()

ilStudyProgrammeType::getLastUpdate ( )
Returns
string

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

References $last_update.

Referenced by ilStudyProgrammeTypeDBRepository\updateType().

510  {
511  return $this->last_update;
512  }
+ Here is the caller graph for this function:

◆ getOwner()

ilStudyProgrammeType::getOwner ( )
Returns
int

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

References $owner.

Referenced by ilStudyProgrammeTypeDBRepository\updateType().

492  {
493  return $this->owner;
494  }
+ Here is the caller graph for this function:

◆ getRepository()

ilStudyProgrammeType::getRepository ( )

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

References $active_plugins, XapiProxy\$plugin, and IL_COMP_MODULE.

610  {
611  return $this->type_repo;
612  }
Covers the persistence of sp-type related information.

◆ 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.

Parameters
string$a_lang_code
Returns
null|string

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

References getTranslation().

Referenced by ilStudyProgrammeTypeGUI\buildLanguagesForms().

125  : string
126  {
127  return (string) $this->getTranslation('title', $a_lang_code);
128  }
getTranslation(string $member, string $lang_code)
Protected.
+ Here is the call graph for this function:
+ Here is the caller 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

Parameters
$a_member
$a_lang_code
Returns
null|string

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

References $lang, getDefaultLang(), loadTranslation(), and user().

Referenced by getDescription(), getTitle(), and setTranslations().

346  {
347  $lang = ($lang_code) ? $lang_code : $this->user->getLanguage();
348 
349  $trans_obj = $this->loadTranslation($lang);
350  if (!is_null($trans_obj)) {
351  $translation = $trans_obj[$member];
352  // If the translation does exist but is an empty string and there was no lang code given,
353  // substitute default language anyway because an empty string provides no information
354  if (!$lang_code && !$translation) {
355  $trans_obj = $this->loadTranslation($this->getDefaultLang());
356 
357  return $trans_obj[$member];
358  }
359 
360  return $translation;
361  } else {
362  // If no lang code was given and there was no translation found, return string in default language
363  if (!$lang_code) {
364  $trans_obj = $this->loadTranslation($this->getDefaultLang());
365 
366  return $trans_obj[$member];
367  }
368 
369  return null;
370  }
371  }
user()
Definition: user.php:4
$lang
Definition: xapiexit.php:8
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTranslations()

ilStudyProgrammeType::getTranslations ( )

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

References $translations.

474  : ?array
475  {
476  return $this->translations;
477  }

◆ loadTranslation()

ilStudyProgrammeType::loadTranslation ( string  $lang_code)
protected

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

References getId().

Referenced by getTranslation().

374  {
375  if (isset($this->translations[$lang_code])) {
376  return $this->translations[$lang_code];
377  } else {
378  $trans_array = $this->type_repo->readTranslationsByTypeAndLang($this->getId(), $lang_code);
379 
380  //ilStudyProgrammeTypeTranslation::where(array('prg_type_id'=>$this->getId(), 'lang'=>$a_lang_code))->getArray('member', 'value');
381  if (count($trans_array)) {
382  $this->translations[$lang_code] = $trans_array;
383 
384  return $trans_array;
385  }
386  }
387 
388  return null;
389  }
+ 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
Returns
bool

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

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

Referenced by ilStudyProgrammeTypeCustomIconsFormGUI\fillForm().

289  : bool
290  {
291  if (!$this->updateable()) {
292  return false;
293  }
294  if (!count($file_data) || !$file_data['name']) {
295  return false;
296  }
297  if (!$this->webdir->hasDir($this->getIconPath())) {
298  $this->webdir->createDir($this->getIconPath());
299  }
300 
301  $filename = $this->getIcon() ? $this->getIcon() : $file_data['name'];
302 
303  if ($this->webdir->has($this->getIconPath(true))) {
304  $this->webdir->delete($this->getIconPath(true));
305  }
306 
307  $stream = ILIAS\Filesystem\Stream\Streams::ofResource(fopen($file_data["tmp_name"], "r"));
308  $this->webdir->writeStream($this->getIconPath(true), $stream);
309 
310  return true;
311  }
updateable()
Helper function to check if this type can be updated.
static ofResource($resource)
Wraps an already created resource with the stream abstraction.
Definition: Streams.php:52
$filename
Definition: buildRTE.php:89
getIconPath(bool $append_filename=false)
Return the path to the icon.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeIconFile()

ilStudyProgrammeType::removeIconFile ( )

Remove the icon file on disk.

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

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

Referenced by ilStudyProgrammeTypeCustomIconsFormGUI\fillForm().

318  {
319  if (!$this->updateable()) {
320  return;
321  }
322 
323  if (
324  !is_null($this->getIcon()) &&
325  $this->getIcon() !== ""
326  ) {
327  $this->webdir->delete($this->getIconPath(true));
328  $this->setIcon('');
329  }
330  }
updateable()
Helper function to check if this type can be updated.
setIcon(string $icon)
Set new Icon filename.
getIconPath(bool $append_filename=false)
Return the path to the icon.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCreateDate()

ilStudyProgrammeType::setCreateDate ( DateTime  $create_date)
Parameters
string$create_date

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

References $create_date.

596  {
597  $this->create_date = $create_date;
598  }

◆ setDefaultLang()

ilStudyProgrammeType::setDefaultLang ( string  $default_lang)
Parameters
string$default_lang
Exceptions
ilStudyProgrammeTypePluginException

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

References $default_lang.

Referenced by ilStudyProgrammeTypeGUI\update().

578  {
579  $this->default_lang = $default_lang;
580  }
+ Here is the caller graph for this function:

◆ setDescription()

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

Set description of StudyProgramme type.

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

Parameters
$a_description
string$a_lang_code

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

References $lang, and getDefaultLang().

Referenced by ilStudyProgrammeTypeGUI\update().

168  {
169  $lang = ($lang_code) ? $lang_code : $this->getDefaultLang();
170  $this->setTranslation('description', $description, $lang);
171  }
$lang
Definition: xapiexit.php:8
+ Here is the call graph for this function:
+ Here is the caller 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.

Parameters
string$icon
Exceptions
ilStudyProgrammeTypeException

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

References $icon.

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

537  {
538  if ($icon and !preg_match('/\.(svg)$/', $icon)) {
539  throw new ilStudyProgrammeTypeException('Icon must be set with file extension svg');
540  }
541  $this->icon = $icon;
542  }
Exception is thrown when errors occurs relating the subtype implementation.
+ Here is the caller graph for this function:

◆ setLastUpdate()

ilStudyProgrammeType::setLastUpdate (   $last_update)
Parameters
string$last_update

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

References $last_update.

501  {
502  $this->last_update = $last_update;
503  }

◆ setOwner()

ilStudyProgrammeType::setOwner ( int  $owner)
Parameters
int$owner

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

References $owner.

483  {
484  $this->owner = $owner;
485  }

◆ setTitle()

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

Set title of StudyProgramme type.

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

Parameters
$a_title
string$a_lang_code

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

References $lang, and getDefaultLang().

Referenced by ilStudyProgrammeTypeGUI\update().

139  {
140  $lang = ($lang_code) ? $lang_code : $this->getDefaultLang();
141  $this->setTranslation('title', $title, $lang);
142  }
$lang
Definition: xapiexit.php:8
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTranslations()

ilStudyProgrammeType::setTranslations ( array  $translations)

Getters & Setters.

Parameters
array$translations

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

References XapiProxy\$plugin, $translations, getId(), and getTranslation().

416  {
417  $this->translations = $translations;
418  }
+ Here is the call graph for this function:

◆ updateable()

ilStudyProgrammeType::updateable ( )
protected

Helper function to check if this type can be updated.

Returns
bool

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

References XapiProxy\$plugin.

Referenced by processAndStoreIconFile(), and removeIconFile().

396  : bool
397  {
398  foreach ($this->getActivePlugins() as $plugin) {
399  if (!$plugin->allowUpdate($this->getId())) {
400  return false;
401  }
402  }
403 
404  return true;
405  }
+ Here is the caller graph for this function:

◆ updateAssignedStudyProgrammesIcons()

ilStudyProgrammeType::updateAssignedStudyProgrammesIcons ( )

Update the Icons of assigned objects.

Returns
void

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

References $id, XapiProxy\$plugin, ilObject\_getAllReferences(), getId(), ilObjStudyProgramme\getInstanceByRefId(), and ilAdvancedMDRecord\saveObjRecSelection().

Referenced by ilStudyProgrammeTypeCustomIconsFormGUI\saveObject().

180  {
181  $obj_ids = $this->type_repo->readStudyProgrammeIdsByTypeId($this->getId());
182 
183  foreach ($obj_ids as $id) {
184  $ref_id = ilObject::_getAllReferences($id);
185  $osp = ilObjStudyProgramme::getInstanceByRefId(array_pop($ref_id));
186  $osp->updateCustomIcon();
187  }
188  }
static _getAllReferences($a_id)
get all reference ids of object
static getInstanceByRefId($a_ref_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $active_plugins

ilStudyProgrammeType::$active_plugins
protected

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

Referenced by getRepository().

◆ $amd_records_assigned

ilStudyProgrammeType::$amd_records_assigned
protected

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

◆ $amd_records_available

ilStudyProgrammeType::$amd_records_available
staticprotected

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

◆ $changed_translations

ilStudyProgrammeType::$changed_translations = array()
protected

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

Referenced by changedTranslations().

◆ $create_date

ilStudyProgrammeType::$create_date
protected

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

Referenced by getCreateDate(), and setCreateDate().

◆ $default_lang

ilStudyProgrammeType::$default_lang = ''
protected

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

Referenced by getDefaultLang(), and setDefaultLang().

◆ $icon

ilStudyProgrammeType::$icon
protected

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

Referenced by getIcon(), and setIcon().

◆ $id

ilStudyProgrammeType::$id = 0
protected

◆ $last_update

ilStudyProgrammeType::$last_update
protected

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

Referenced by getLastUpdate(), and setLastUpdate().

◆ $lng

ilStudyProgrammeType::$lng
protected

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

Referenced by __construct().

◆ $log

ilStudyProgrammeType::$log
protected

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

◆ $owner

ilStudyProgrammeType::$owner
protected

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

Referenced by getOwner(), and setOwner().

◆ $plugin_admin

ilStudyProgrammeType::$plugin_admin
protected

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

Referenced by __construct().

◆ $translations

ilStudyProgrammeType::$translations
protected

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

Referenced by getTranslations(), and setTranslations().

◆ $user

ilStudyProgrammeType::$user
protected

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

Referenced by __construct().

◆ DATE_FORMAT

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

Definition at line 19 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'

Folder in ILIAS webdir to store the icons.

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

Referenced by ilStudyProgrammeTypeTest\test_icon_path().


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