ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\Style\Content\CharacteristicManager Class Reference

Main business logic for characteristics. More...

+ Collaboration diagram for ILIAS\Style\Content\CharacteristicManager:

Public Member Functions

 __construct (int $style_id, Access\StyleAccessManager $access_manager, CharacteristicDBRepo $char_repo, CharacteristicCopyPasteSessionRepo $char_copy_paste_repo, ColorDBRepo $color_repo, ilObjUser $user)
 
 addCharacteristic (string $type, string $char, bool $hidden=false)
 
 exists (string $type, string $char)
 Check if characteristic exists. More...
 
 getByKey (string $type, string $characteristic)
 Get characteristic by key. More...
 
 getByType (string $type)
 Get characteristics by type. More...
 
 getByTypes (array $types, bool $include_hidden=true, bool $include_outdated=true)
 Get characteristics by type. More...
 
 getBySuperType (string $supertype)
 Get characteristics by supertype. More...
 
 getPresentationTitle (string $type, string $characteristic, bool $fallback_to_characteristic=true)
 Get characteristic by key. More...
 
 saveTitles (string $type, string $characteristic, array $titles)
 Save titles for characteristic. More...
 
 saveHidden (string $type, string $characteristic, bool $hide)
 Save characteristic hidden status. More...
 
 saveOutdated (string $type, string $characteristic, bool $outdated)
 Save characteristic outdated status. More...
 
 isOutdated (string $type, string $characteristic)
 
 saveOrderNrs (string $type, array $order_nrs)
 Save characteristics order. More...
 
 deleteCharacteristic (string $type, string $class)
 Delete Characteristic. More...
 
 setCopyCharacteristics (string $style_type, array $characteristics)
 
 hasCopiedCharacteristics (string $style_type)
 Is in copy process? More...
 
 clearCopyCharacteristics ()
 
 getCopyCharacteristicStyleId ()
 
 getCopyCharacteristicStyleType ()
 
 getCopyCharacteristics ()
 
 copyCharacteristicFromSource (int $source_style_id, string $source_style_type, string $source_char, string $new_char, array $new_titles)
 Copy characteristic. More...
 
 replaceParameter (string $a_tag, string $a_class, string $a_par, string $a_val, string $a_type, int $a_mq_id=0, bool $a_custom=false)
 
 deleteParameter (string $a_tag, string $a_class, string $a_par, string $a_type, int $a_mq_id=0, bool $a_custom=false)
 

Protected Attributes

CharacteristicDBRepo $repo
 
ColorDBRepo $color_repo
 
ilObjUser $user
 
Access StyleAccessManager $access_manager
 
CharacteristicCopyPasteSessionRepo $session
 
int $style_id
 

Detailed Description

Main business logic for characteristics.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 31 of file class.CharacteristicManager.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Style\Content\CharacteristicManager::__construct ( int  $style_id,
Access\StyleAccessManager  $access_manager,
CharacteristicDBRepo  $char_repo,
CharacteristicCopyPasteSessionRepo  $char_copy_paste_repo,
ColorDBRepo  $color_repo,
ilObjUser  $user 
)

Member Function Documentation

◆ addCharacteristic()

ILIAS\Style\Content\CharacteristicManager::addCharacteristic ( string  $type,
string  $char,
bool  $hidden = false 
)

Definition at line 56 of file class.CharacteristicManager.php.

References ilObjStyleSheet\_writeUpToDate().

Referenced by ILIAS\Style\Content\CharacteristicManager\copyCharacteristicFromSource().

60  : void {
61  $this->repo->addCharacteristic(
62  $this->style_id,
63  $type,
64  $char,
65  $hidden
66  );
67 
68  ilObjStyleSheet::_writeUpToDate($this->style_id, false);
69  }
$type
static _writeUpToDate(int $a_id, bool $a_up_to_date)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clearCopyCharacteristics()

ILIAS\Style\Content\CharacteristicManager::clearCopyCharacteristics ( )

Definition at line 302 of file class.CharacteristicManager.php.

302  : void
303  {
304  $this->session->clear();
305  }

◆ copyCharacteristicFromSource()

ILIAS\Style\Content\CharacteristicManager::copyCharacteristicFromSource ( int  $source_style_id,
string  $source_style_type,
string  $source_char,
string  $new_char,
array  $new_titles 
)

Copy characteristic.

Exceptions
ContentStyleNoPermissionException

Definition at line 329 of file class.CharacteristicManager.php.

References $c, ilObjStyleSheet\_determineTag(), ILIAS\Style\Content\CharacteristicManager\addCharacteristic(), ILIAS\Style\Content\CharacteristicManager\deleteCharacteristic(), ILIAS\Style\Content\CharacteristicManager\exists(), ILIAS\Style\Content\CharacteristicManager\getByKey(), ILIAS\Style\Content\CharacteristicManager\replaceParameter(), and ILIAS\Style\Content\CharacteristicManager\saveTitles().

335  : void {
336  if (!$this->access_manager->checkWrite()) {
337  throw new ContentStyleNoPermissionException("No write permission for style.");
338  }
339 
340  if ($this->exists($source_style_type, $new_char)) {
341  $target_char = $this->getByKey($source_style_type, $new_char);
342  if (count($new_titles) == 0) {
343  $new_titles = $target_char->getTitles();
344  }
345  $this->deleteCharacteristic($source_style_type, $new_char);
346  }
347 
348  $this->addCharacteristic($source_style_type, $new_char);
349  $this->saveTitles($source_style_type, $new_char, $new_titles);
350 
351  $from_style = new ilObjStyleSheet($source_style_id);
352 
353  // todo fix using mq_id
354  $pars = $from_style->getParametersOfClass($source_style_type, $source_char);
355 
356  $colors = array();
357  foreach ($pars as $p => $v) {
358  if (substr($v, 0, 1) == "!") {
359  $colors[] = substr($v, 1);
360  }
361  $this->replaceParameter(
362  ilObjStyleSheet::_determineTag($source_style_type),
363  $new_char,
364  $p,
365  $v,
366  $source_style_type
367  );
368  }
369 
370  // copy colors
371  foreach ($colors as $c) {
372  if (!$this->color_repo->colorExists($this->style_id, $c)) {
373  $this->color_repo->addColor(
374  $this->style_id,
375  $c,
376  $from_style->getColorCodeForName($c)
377  );
378  }
379  }
380  }
deleteCharacteristic(string $type, string $class)
Delete Characteristic.
$c
Definition: cli.php:38
exists(string $type, string $char)
Check if characteristic exists.
replaceParameter(string $a_tag, string $a_class, string $a_par, string $a_val, string $a_type, int $a_mq_id=0, bool $a_custom=false)
addCharacteristic(string $type, string $char, bool $hidden=false)
getByKey(string $type, string $characteristic)
Get characteristic by key.
static _determineTag(string $a_type)
saveTitles(string $type, string $characteristic, array $titles)
Save titles for characteristic.
+ Here is the call graph for this function:

◆ deleteCharacteristic()

ILIAS\Style\Content\CharacteristicManager::deleteCharacteristic ( string  $type,
string  $class 
)

Delete Characteristic.

Exceptions
ContentStyleNoPermissionException

Definition at line 264 of file class.CharacteristicManager.php.

References ilObjStyleSheet\_determineTag(), ilObjStyleSheet\_getCoreStyles(), and ilObjStyleSheet\_writeUpToDate().

Referenced by ILIAS\Style\Content\CharacteristicManager\copyCharacteristicFromSource().

267  : void {
268  if (!$this->access_manager->checkWrite()) {
269  throw new ContentStyleNoPermissionException("No write permission for style.");
270  }
272 
273  // check, if characteristic is not a core style
274  $core_styles = ilObjStyleSheet::_getCoreStyles();
275  if (empty($core_styles[$type . "." . $tag . "." . $class])) {
276  $this->repo->deleteCharacteristic(
277  $this->style_id,
278  $type,
279  $tag,
280  $class
281  );
282  }
283 
284  ilObjStyleSheet::_writeUpToDate($this->style_id, false);
285  }
$type
static _writeUpToDate(int $a_id, bool $a_up_to_date)
static _determineTag(string $a_type)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteParameter()

ILIAS\Style\Content\CharacteristicManager::deleteParameter ( string  $a_tag,
string  $a_class,
string  $a_par,
string  $a_type,
int  $a_mq_id = 0,
bool  $a_custom = false 
)

Definition at line 414 of file class.CharacteristicManager.php.

Referenced by ILIAS\Style\Content\CharacteristicManager\replaceParameter().

421  : void {
422  $this->repo->deleteParameter(
423  $this->style_id,
424  $a_tag,
425  $a_class,
426  $a_par,
427  $a_type,
428  $a_mq_id,
429  $a_custom
430  );
431  }
+ Here is the caller graph for this function:

◆ exists()

ILIAS\Style\Content\CharacteristicManager::exists ( string  $type,
string  $char 
)

Check if characteristic exists.

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

Referenced by ILIAS\Style\Content\CharacteristicManager\copyCharacteristicFromSource().

77  : bool {
78  return $this->repo->exists(
79  $this->style_id,
80  $type,
81  $char
82  );
83  }
$type
+ Here is the caller graph for this function:

◆ getByKey()

ILIAS\Style\Content\CharacteristicManager::getByKey ( string  $type,
string  $characteristic 
)

Get characteristic by key.

Definition at line 88 of file class.CharacteristicManager.php.

Referenced by ILIAS\Style\Content\CharacteristicManager\copyCharacteristicFromSource().

91  : ?Characteristic {
92  return $this->repo->getByKey(
93  $this->style_id,
94  $type,
95  $characteristic
96  );
97  }
$type
+ Here is the caller graph for this function:

◆ getBySuperType()

ILIAS\Style\Content\CharacteristicManager::getBySuperType ( string  $supertype)

Get characteristics by supertype.

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

132  : array {
133  return $this->repo->getBySuperType(
134  $this->style_id,
135  $supertype
136  );
137  }

◆ getByType()

ILIAS\Style\Content\CharacteristicManager::getByType ( string  $type)

Get characteristics by type.

Definition at line 102 of file class.CharacteristicManager.php.

104  : array {
105  return $this->repo->getByType(
106  $this->style_id,
107  $type
108  );
109  }
$type

◆ getByTypes()

ILIAS\Style\Content\CharacteristicManager::getByTypes ( array  $types,
bool  $include_hidden = true,
bool  $include_outdated = true 
)

Get characteristics by type.

Definition at line 114 of file class.CharacteristicManager.php.

118  : array {
119  return $this->repo->getByTypes(
120  $this->style_id,
121  $types,
122  $include_hidden,
123  $include_outdated
124  );
125  }

◆ getCopyCharacteristics()

ILIAS\Style\Content\CharacteristicManager::getCopyCharacteristics ( )

Definition at line 319 of file class.CharacteristicManager.php.

References $data.

319  : array
320  {
321  $data = $this->session->getData();
322  return $data->characteristics;
323  }

◆ getCopyCharacteristicStyleId()

ILIAS\Style\Content\CharacteristicManager::getCopyCharacteristicStyleId ( )

Definition at line 307 of file class.CharacteristicManager.php.

References $data.

307  : int
308  {
309  $data = $this->session->getData();
310  return (int) $data->style_id;
311  }

◆ getCopyCharacteristicStyleType()

ILIAS\Style\Content\CharacteristicManager::getCopyCharacteristicStyleType ( )

Definition at line 313 of file class.CharacteristicManager.php.

References $data.

313  : string
314  {
315  $data = $this->session->getData();
316  return $data->style_type;
317  }

◆ getPresentationTitle()

ILIAS\Style\Content\CharacteristicManager::getPresentationTitle ( string  $type,
string  $characteristic,
bool  $fallback_to_characteristic = true 
)

Get characteristic by key.

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

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

146  : string {
147  $char = $this->repo->getByKey(
148  $this->style_id,
149  $type,
150  $characteristic
151  );
152 
153  $titles = $char ? $char->getTitles() : [];
154 
155  $lang = $this->user->getLanguage();
156 
157  if (($titles[$lang] ?? "") != "") {
158  return $titles[$lang];
159  }
160  if ($fallback_to_characteristic) {
161  return $characteristic;
162  }
163  return "";
164  }
$type
$lang
Definition: xapiexit.php:26
+ Here is the call graph for this function:

◆ hasCopiedCharacteristics()

ILIAS\Style\Content\CharacteristicManager::hasCopiedCharacteristics ( string  $style_type)

Is in copy process?

Definition at line 297 of file class.CharacteristicManager.php.

297  : bool
298  {
299  return $this->session->hasEntries($style_type);
300  }

◆ isOutdated()

ILIAS\Style\Content\CharacteristicManager::isOutdated ( string  $type,
string  $characteristic 
)

Definition at line 224 of file class.CharacteristicManager.php.

227  : bool {
228  return $this->repo->isOutdated(
229  $this->style_id,
230  $type,
231  $characteristic
232  );
233  }
$type

◆ replaceParameter()

ILIAS\Style\Content\CharacteristicManager::replaceParameter ( string  $a_tag,
string  $a_class,
string  $a_par,
string  $a_val,
string  $a_type,
int  $a_mq_id = 0,
bool  $a_custom = false 
)

Definition at line 382 of file class.CharacteristicManager.php.

References ILIAS\Style\Content\CharacteristicManager\deleteParameter().

Referenced by ILIAS\Style\Content\CharacteristicManager\copyCharacteristicFromSource().

390  : void {
391  if ($a_val != "") {
392  $this->repo->replaceParameter(
393  $this->style_id,
394  $a_tag,
395  $a_class,
396  $a_par,
397  $a_val,
398  $a_type,
399  $a_mq_id,
400  $a_custom
401  );
402  } else {
403  $this->deleteParameter(
404  $a_tag,
405  $a_class,
406  $a_par,
407  $a_type,
408  $a_mq_id,
409  $a_custom
410  );
411  }
412  }
deleteParameter(string $a_tag, string $a_class, string $a_par, string $a_type, int $a_mq_id=0, bool $a_custom=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveHidden()

ILIAS\Style\Content\CharacteristicManager::saveHidden ( string  $type,
string  $characteristic,
bool  $hide 
)

Save characteristic hidden status.

Definition at line 189 of file class.CharacteristicManager.php.

193  : void {
194  if (!$this->access_manager->checkWrite()) {
195  throw new ContentStyleNoPermissionException("No write permission for style.");
196  }
197  $this->repo->saveHidden(
198  $this->style_id,
199  $type,
200  $characteristic,
201  $hide
202  );
203  }
$type

◆ saveOrderNrs()

ILIAS\Style\Content\CharacteristicManager::saveOrderNrs ( string  $type,
array  $order_nrs 
)

Save characteristics order.

Parameters
array$order_nrs(key is characteristic value is order nr)

Definition at line 239 of file class.CharacteristicManager.php.

242  : void {
243  if (!$this->access_manager->checkWrite()) {
244  throw new ContentStyleNoPermissionException("No write permission for style.");
245  }
246 
247  asort($order_nrs, SORT_NUMERIC);
248 
249  foreach ($order_nrs as $char => $nr) {
250  $this->repo->saveOrderNr(
251  $this->style_id,
252  $type,
253  $char,
254  (int) $nr
255  );
256  }
257  }
$type

◆ saveOutdated()

ILIAS\Style\Content\CharacteristicManager::saveOutdated ( string  $type,
string  $characteristic,
bool  $outdated 
)

Save characteristic outdated status.

Definition at line 208 of file class.CharacteristicManager.php.

212  : void {
213  if (!$this->access_manager->checkWrite()) {
214  throw new ContentStyleNoPermissionException("No write permission for style.");
215  }
216  $this->repo->saveOutdated(
217  $this->style_id,
218  $type,
219  $characteristic,
220  $outdated
221  );
222  }
$type

◆ saveTitles()

ILIAS\Style\Content\CharacteristicManager::saveTitles ( string  $type,
string  $characteristic,
array  $titles 
)

Save titles for characteristic.

Exceptions
ContentStyleNoPermissionException

Definition at line 170 of file class.CharacteristicManager.php.

Referenced by ILIAS\Style\Content\CharacteristicManager\copyCharacteristicFromSource().

174  : void {
175  if (!$this->access_manager->checkWrite()) {
176  throw new ContentStyleNoPermissionException("No write permission for style.");
177  }
178  $this->repo->saveTitles(
179  $this->style_id,
180  $type,
181  $characteristic,
182  $titles
183  );
184  }
$type
+ Here is the caller graph for this function:

◆ setCopyCharacteristics()

ILIAS\Style\Content\CharacteristicManager::setCopyCharacteristics ( string  $style_type,
array  $characteristics 
)

Definition at line 287 of file class.CharacteristicManager.php.

290  : void {
291  $this->session->set($this->style_id, $style_type, $characteristics);
292  }

Field Documentation

◆ $access_manager

Access StyleAccessManager ILIAS\Style\Content\CharacteristicManager::$access_manager
protected

◆ $color_repo

ColorDBRepo ILIAS\Style\Content\CharacteristicManager::$color_repo
protected

◆ $repo

CharacteristicDBRepo ILIAS\Style\Content\CharacteristicManager::$repo
protected

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

◆ $session

CharacteristicCopyPasteSessionRepo ILIAS\Style\Content\CharacteristicManager::$session
protected

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

◆ $style_id

int ILIAS\Style\Content\CharacteristicManager::$style_id
protected

◆ $user

ilObjUser ILIAS\Style\Content\CharacteristicManager::$user
protected

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