Skip to content

Commit

Permalink
UI: adjust Icon Renderer and Standards for new ...
Browse files Browse the repository at this point in the history
...images directory structure. Also adjust image path in ilObject and AdministrationMainBarProvider. (#35768)
  • Loading branch information
lukastocker committed Sep 26, 2023
1 parent f3c42b5 commit dcb6d05
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,17 @@ public function getStaticSubItems(): array
protected function getIconForGroup(string $group, string $title): Icon
{
$icon_map = array(
"maintenance" => "standard/icon_sysa",
"maintenance" => "icon_sysa",
"layout_and_navigation" => "icon_laya",
"repository_and_objects" => "standard/icon_repa",
"personal_workspace" => "standard/icon_pwsa",
"achievements" => "standard/icon_achva",
"communication" => "standard/icon_coma",
"user_administration" => "standard/icon_usra",
"search_and_find" => "standard/icon_safa",
"extending_ilias" => "standard/icon_exta"
"repository_and_objects" => "icon_repa",
"personal_workspace" => "icon_pwsa",
"achievements" => "icon_achva",
"communication" => "icon_coma",
"user_administration" => "icon_usra",
"search_and_find" => "icon_safa",
"extending_ilias" => "icon_exta"
);
$icon_path = \ilUtil::getImagePath($icon_map[$group] . ".svg");
$icon_path = \ilUtil::getImagePath("standard/" . $icon_map[$group] . ".svg");
return $this->dic->ui()->factory()->symbol()->icon()->custom($icon_path, $title);
}

Expand Down
4 changes: 2 additions & 2 deletions Services/Object/classes/class.ilObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -1819,9 +1819,9 @@ public static function getIconForReference(
return ilUtil::getImagePath("standard/icon_cmps.svg");
}

return ilUtil::getImagePath("icon_" . $type . ".svg");
return ilUtil::getImagePath("standard/icon_" . $type . ".svg");
} else {
return "./images/icon_" . $type . ".svg";
return "./images/standard/icon_" . $type . ".svg";
}
}

Expand Down
13 changes: 11 additions & 2 deletions src/UI/Implementation/Component/Symbol/Icon/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,22 @@ protected function renderLabel(Component\Component $component, Template $tpl): T
protected function getStandardIconPath(Component\Symbol\Icon\Icon $icon): string
{
$name = $icon->getName();
if (!in_array($name, $icon->getAllStandardHandles())) {
$is_in_standard_icon_list = in_array($name, $icon->getAllStandardHandles());
$is_in_page_editor_icon_list = in_array($name, $icon->getAllStandardPageEditorHandles());
if (!$is_in_standard_icon_list && !$is_in_page_editor_icon_list) {
$name = self::DEFAULT_ICON_NAME;
}
$pattern = self::ICON_NAME_PATTERN;

$icon_path_name = '';
$icon_name = sprintf($pattern, $name);
return $this->getImagePathResolver()->resolveImagePath($icon_name);
if ($is_in_page_editor_icon_list) {
$icon_path_name = 'page_editor/' . $icon_name;
} else {
$icon_path_name = 'standard/' . $icon_name;
}

return $this->getImagePathResolver()->resolveImagePath($icon_path_name);
}

/**
Expand Down
28 changes: 20 additions & 8 deletions src/UI/Implementation/Component/Symbol/Icon/Standard.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,17 @@ class Standard extends Icon implements C\Symbol\Icon\Standard
self::CMIS,
self::TASK,
self::REP,
self::LSO,
self::LSOS,
self::ADN,
self::NOTA,
self::GCON,
self::CON,
self::FILS,
self::TALA
];

private static array $standard_page_editor_icons = [
self::PEAC,
self::PEADL,
self::PEADT,
Expand All @@ -165,14 +176,6 @@ class Standard extends Icon implements C\Symbol\Icon\Standard
self::PESC,
self::PETMP,
self::PEUSR,
self::LSO,
self::LSOS,
self::ADN,
self::NOTA,
self::GCON,
self::CON,
self::FILS,
self::TALA
];

public function __construct(string $name, string $label, string $size, bool $is_disabled)
Expand All @@ -198,4 +201,13 @@ public function getAllStandardHandles(): array
{
return self::$standard_icons;
}

/**
* get all defined constants
* @return string[]
*/
public function getAllStandardPageEditorHandles(): array
{
return self::$standard_page_editor_icons;
}
}
2 changes: 1 addition & 1 deletion tests/UI/Component/Symbol/Icon/IconTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
class IconTest extends ILIAS_UI_TestBase
{
public const ICON_PATH = __DIR__ . '/../../../../../templates/default/images/';
public const ICON_PATH = __DIR__ . '/../../../../../templates/default/images/standard/';
public const ICON_PATH_REL = './templates/default/images/';

private function getIconFactory(): I\Component\Symbol\Icon\Factory
Expand Down

0 comments on commit dcb6d05

Please sign in to comment.