ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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.

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 }
static _writeUpToDate(int $a_id, bool $a_up_to_date)

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

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 foreach (["", ":hover", ":before"] as $char_extension) {
355 $colors = array();
356 //foreach ($pars as $p => $v) {
357 foreach ($this->repo->getAllParametersOfCharacteristic(
358 $from_style->getId(),
359 $source_style_type,
360 $source_char . $char_extension
361 ) as $param) {
362 $p = $param["parameter"];
363 $v = $param["value"];
364 if (substr($v, 0, 1) == "!") {
365 $colors[] = substr($v, 1);
366 }
367 if ($param["mq_id"] > 0) {
368 continue;
369 }
370 $this->replaceParameter(
371 ilObjStyleSheet::_determineTag($source_style_type),
372 $new_char . $char_extension,
373 $p,
374 $v,
375 $source_style_type,
376 0,
377 (bool) $param["custom"]
378 );
379 }
380
381 // copy colors
382 foreach ($colors as $c) {
383 if (!$this->color_repo->colorExists($this->style_id, $c)) {
384 $this->color_repo->addColor(
385 $this->style_id,
386 $c,
387 $from_style->getColorCodeForName($c)
388 );
389 }
390 }
391 }
392 }
exists(string $type, string $char)
Check if characteristic exists.
addCharacteristic(string $type, string $char, bool $hidden=false)
deleteCharacteristic(string $type, string $class)
Delete Characteristic.
getByKey(string $type, string $characteristic)
Get characteristic by key.
saveTitles(string $type, string $characteristic, array $titles)
Save titles for characteristic.
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)
Class ilObjStyleSheet.
static _determineTag(string $a_type)
$c
Definition: deliver.php:25
$param
Definition: xapitoken.php:46

◆ deleteCharacteristic()

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

Delete Characteristic.

Exceptions
ContentStyleNoPermissionException

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

267 : void {
268 if (!$this->access_manager->checkWrite()) {
269 throw new ContentStyleNoPermissionException("No write permission for style.");
270 }
271 $tag = ilObjStyleSheet::_determineTag($type);
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 }

◆ 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 426 of file class.CharacteristicManager.php.

433 : void {
434 $this->repo->deleteParameter(
435 $this->style_id,
436 $a_tag,
437 $a_class,
438 $a_par,
439 $a_type,
440 $a_mq_id,
441 $a_custom
442 );
443 }

◆ exists()

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

Check if characteristic exists.

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

77 : bool {
78 return $this->repo->exists(
79 $this->style_id,
80 $type,
81 $char
82 );
83 }

◆ getByKey()

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

Get characteristic by key.

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

91 : ?Characteristic {
92 return $this->repo->getByKey(
93 $this->style_id,
94 $type,
95 $characteristic
96 );
97 }

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

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

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

References $data.

◆ getCopyCharacteristicStyleId()

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

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

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

References $data.

◆ getCopyCharacteristicStyleType()

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

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

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

References $data.

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

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 }
$lang
Definition: xapiexit.php:25

References $lang.

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

◆ 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 394 of file class.CharacteristicManager.php.

402 : void {
403 if ($a_val != "") {
404 $this->repo->replaceParameter(
405 $this->style_id,
406 $a_tag,
407 $a_class,
408 $a_par,
409 $a_val,
410 $a_type,
411 $a_mq_id,
412 $a_custom
413 );
414 } else {
415 $this->deleteParameter(
416 $a_tag,
417 $a_class,
418 $a_par,
419 $a_type,
420 $a_mq_id,
421 $a_custom
422 );
423 }
424 }
deleteParameter(string $a_tag, string $a_class, string $a_par, string $a_type, int $a_mq_id=0, bool $a_custom=false)

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

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

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

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

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 }

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