From 4ca6c6bb67cf7996d6f7d2c393daddd66f2b3d66 Mon Sep 17 00:00:00 2001 From: Timon Amstutz Date: Mon, 22 Aug 2016 11:18:38 +0200 Subject: [PATCH 01/27] Language File changes for new System Styles component. --- lang/ilias_de.lang | 122 ++++++++++++++++++++++++++++++++++++++++++++- lang/ilias_en.lang | 122 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 242 insertions(+), 2 deletions(-) diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index d89e7ae8973f..9a957dae3e51 100644 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -15908,4 +15908,124 @@ glo#:#glo_select_source_glo#:#Please select a source glossary. glo#:#glo_referenced_term#:#Referenced Term glo#:#glo_term_reference#:#Term Reference glo#:#glo_reference#:#Reference -glo#:#glo_selected_terms_have_been_copied#:#The selected terms have been copied to the clipboard. Please open the target glossary and click "Paste". \ No newline at end of file +glo#:#glo_selected_terms_have_been_copied#:#The selected terms have been copied to the clipboard. Please open the target glossary and click "Paste". +style#:#add_system_style#:#Neuer System Style +style#:#add_substyle#:#Neuer Sub Style +style#:#skin_id#:#Skin ID +style#:#skin_name#:#Skin Name +style#:#skin#:#Skin +style#:#style_id#:#Style ID +style#:#Style#:#Style +style#:#style_name#:#Style Name +style#:#image_dir#:#Bildordner +style#:#font_dir#:#Schriftordner +style#:#sound_dir#:#Sound-Ordner +style#:#system_style_activation#:#System Style aktiviert +style#:#personal#:#Persönlich +style#:#system_styel_activation#:#aktiviere System Style +style#:#less#:#Less +style#:#icons#:#Symbole +style#:#documentation#:#Dokumentation +style#:#less_can_not_be_modified#:#Less kann nicht verändert werden. +style#:#no_less_path_set#:#Das Less Verzeichnis ist nicht gesetzt. +style#:#less_less_installation_detected#:#Less Installation gefunden: +style#:#grey_colors#:#Graue Farben +style#:#grey_color#:#Grauton +style#:#grey_colors_description#:#Grauton Beschreibung +style#:#red_colors#:#Rote Farben +style#:#red_color#:#Rotton +style#:#red_colors_description#:#Rotton Beschreibung +style#:#green_colors#:#Grüne Farben +style#:#green_color#:#Grünton +style#:#green_colors_description#:#Grünton Beschreibung +style#:#blue_colors#:#Blaue Farben +style#:#blue_color#:#Blauton +style#:#blue_colors_description#:#Blauton Beschreibung +style#:#reset_icons#:#Symbole zurücksetzten +style#:#update_colors#:#Farben aktualisieren +style#:#style_not_deleted#:#Der Style konnte aus folgenden Gründen nicht gelöscht werden: +style#:#styles_not_deleted#:#Die Styles konnten aus folgenden Gründen nicht gelöscht werden: +style#:#cant_delete_activated_style#:#Aktive Styles können nicht gelöscht werden. +style#:#style_deleted#:#Gelöschter Style: +style#:#dir_preserved_linked#:#Behaltene Links: +style#:#file_deleted#:#Folgende Datei wurde gelöscht: +style#:#skin_deleted#:#Folgender Skin wurde gelöscht: +style#:#msg_sys_style_update#:#System Styles wurden aktualisiert. +common#:#set_style_does_not_exist#:#Ausgewählter System Style existiert nicht mehr. In den persönlichen Einstellungen kann ein neuer System Style aktiviert oder ein Admin kontaktiert werden. Aktuelle Auswahl: +common#:#set_skin_does_not_exist#:#Ausgewählter Skin existiert nicht mehr. In den persönlichen Einstellungen kann ein neuer Skin aktiviert oder ein Admin kontaktiert werden. Aktuelle Auswahl: +style#:#cant_deactivate_default_style#:#Standard Styles können nicht deaktiviert werden. +style#:#cant_delete_if_users_assigned#:#Styles können nicht gelöscht werden, solange Benutzer ihnen zugewiesen sind. +style#:#default_style_set_to#:#Der Standard Style wurde geändert zu: +style#:#personal_style_set_to#:#Der persönliche Style wurde geändert zu: +style#:#refresh_entries#:#Einträge aktualisieren +style#:#entries_reloaded#:#Alle Einträge wurden aktualisiert +style#:#msg_sub_style_created#:#Der Sub Style wurde erstellt. +style#:#style#:#Style +style#:#sub_style_settings#:#Sub Style Zuweisung +style#:#parent#:#Parent Style +style#:#sty_substyle_of#:#Sub Style von +style#:#assignment#:#Zuweisung +style#:#remove_assignment#:#Zuweisung löschen +style#:#reset_variables#:#Variablen zurücksetzen +style#:#update_variables#:#Variablen aktualisieren +style#:#less_file_updated#:#Die Less Variablen wurden aktualisiert. +style#:#settings_of_substyle#:#Manage sub style +style#:#settings_of_style#:#Styles verwalten +style#:#of_parent#:#vom Parent: +style#:#from_skin#:#vom Skin: +style#:#dir_copied_from#:#Der Ordner wurde kopiert von: +style#:#to#:#nach: +style#:#dir_deleted#:#Der folgende Ordner wurde gelöscht: +style#:#sty_create_new_system_style#:#Erstelle einen neuen System Style. +style#:#sty_create_new_system_sub_style#:#Erstelle einen neuen System Sub Style. +style#:#sty_import_system_style#:#Importiere bestehenden System Style aus ZIP. +style#:#sty_copy_other_system_style#:#Klone einen bestehenden System Style. +style#:#sub_style_id#:#Sub Style ID +style#:#sub_style_name#:#Sub Style Name +style#:#less_variables_file_not_included#:#Die Less Variablen Datei: +style#:#in_main_less_file#:#ist nicht in der System Styles main Less Datei importiert: +style#:#can_not_read_less_file#:#Less Datei kann nicht gelesen werden. Pfad: +style#:#msg_sys_style_created#:#Die neue System Style Datei wurde erfolgreich erstellt. +style#:#skin_id_description#:#Skins sind Behälter für Styles und Sub Styles. Die Skin ID setzt den Namen des Ordners, welcher alle Informationen zu Styles und Sub Styles beinhaltet. Die Skin ID darf sich nur aus Buchstaben, Nummern sowie Bindestrichen zusammensetzen. +style#:#skin_name_description#:#Der Skin Name kann als Beschreibung für das Einsatzgebiet verwendet werden. Es wird in allen UI Elementen aufgelistet, welche eine Selektierung des Skins erlauben. +style#:#style_id_description#:#Die Style ID wird für Style spezifische css- und Lessdateien unterhalb des Skin Ordners verwendet. Die Style ID darf sich nur aus Buchstaben, Nummern sowie Bindestrichen zusammensetzen. +style#:#style_name_description#:#Der Style Name kann als Beschreibung für das Einsatzgebiet verwendet werden. Es wird in allen UI Elementen aufgelistet, welche eine Selektierung des Skins erlauben. +style#:#sub_style#:#Sub Style +style#:#image_dir_description#:#Ordner für das Speichern von Bildern (hauptsächlich Icons) vom betreffenden Skin. Dieser Ordner kann mit anderen Styles und Sub Styles geteilt werden. +style#:#font_dir_description#:#Ordner für das Speichern von Schriftarten vom betreffenden Skin. Dieser Ordner kann mit anderen Styles und Sub Styles geteilt werden. +style#:#sound_dir_description#:#Ordner für das Speichern von Tönen vom betreffenden Skin. Dieser Ordner kann mit anderen Styles und Sub Styles geteilt werden. +style#:#sub_style_parent_style_description#:#Sub Styles werden genau einem Parent Style zugewiesen. Sie werden nur den Usern angezeigt, welche auch Zugang zum Parent Style haben. Der Parent Style eines Sub Styles kann nur während der Erstellung des Sub Styles einmalig zugeordnet werden. +style#:#sub_style_id_description#:#Die Sub Style ID wird für die betreffenden css und less Dateien verwendet. Diese sind innerhalb des betreffenden Skin Ordners. Die Sub Style ID darf sich nur aus Buchstaben, Nummern sowie Bindestrichen zusammensetzen. +style#:#sub_style_name_description#:#Der Sub Style Name kann als Beschreibung für das Einsatzgebiet verwendet werden. Es wird in allen UI Elementen aufgelistet, welche eine Selektierung des Skins erlauben. +style#:#system_style_activation_description#:#Aktive System Styles können bestimmten Usern zugewiesen, oder durch diese selektiert werden wenn die betreffende Einstellung (Benutzer Verwaltung / Einstellungen / Standard Dateien / Standard Skin) aktiviert ist. +style#:#system_style_default_description#:#Setze diesen Style als Standard System Style fest. Der Standard System Style wird verwendet, sofern der User noch keinen eigenen System Style zugewiesen hat, oder der User nicht eingeloggt ist. +style#:#system_style_personal_description#:#Setze diesen Style als persönlichen Style. Das stellt eine gute Hilfe dar, wenn aktuelle Änderungen am Skin mitverfolgt werden möchten. +style#:#less_compile_failed#:#Die Less Datei konnte nicht kompiliert werden. Lessc muss dafür installiert und der Pfad im ILIAS setup richtig gesetzt sein. +style#:#zip_export_failed#:#Der ZIP Export ist mit folgender Error Meldung fehlgeschlagen: +style#:#no_style_selected#:#Es wurde kein Sub Style ausgewählt. +style#:#adapt_less#:#Anpassung der Less Datei +style#:#adapt_less_description#:#Dies ist die Darstellung aller less Variablen aus dem aktuellen Skin. Variablennamen und Beschreibungen sind direkt aus den Dateien ausgelesen und daher nur in Originalsprache vorhanden. Der ausgewählte Style wird bei einem update/reset der Variablen vollständig neu kompiliert. Das Zurücksetzten der Variablen erstellt eine exakte Kopie des ursprünglichen "delos style". +style#:#adapt_icons_description#:#Alle svg Symbole, welche im Ordner images gefunden wurden, werden hier aufgelistet. Wenn eine Farbe geändert wird, ist dies in allen hier enthaltentn Symbolen sofort ersichtlich. +style#:#adapt_icons#:#Anpassung der Symbolfarben +style#:#invalid_less_path#:#Der angegebene lessc Pfad ist ungültig: +style#:#provided_less_path#:#Angegebener lessc Pfad: +style#:#used_colors#:#Benutzte Farben: +style#:#style_imported#:#Style wurde erfolgreich importiert nach: +style#:#style_copied#:#Style wurde erfolgreich kopiert. +style#:#directory_created#:#Ordner erstellt: +style#:#color_changed_from#:#Farbe geändert von: +style#:#color_changed_to#:#nach: +style#:#edit_by_color#:#Bearbeitung nach Farbe +style#:#edit_by_icon#:#Bearbeitung nach Symbol +style#:#update_icon#:#Aktualisiere Symbol +style#:#select_icon#:#Selektieres Symbol +style#:#change_icon#:#Ändere Symbol +style#:#color#:#Farbe +style#:#adapt_icon#:#Anpassung der Symbole +style#:#adapt_icon_description#:#Passe die Symbolfarbe oder das Symbol an. +style#:#preview#:#Vorschau +style#:#icons_gallery#:#Symbol Gallerie +style#:#cant_delete_style_with_substyles#:#Styles mit Sub Styles können nicht gelöscht werden. +style#:#style_assignments_deleted#:#Style Zuweisungen des folgenden Sub Style wurden gelöscht: +style#:#skin_id_exists#:#Es existiert bereits ein Skin mit dieser ID. +style#:#usages#:#Verwendungen: \ No newline at end of file diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index 0edd66b682b9..98be579121bb 100644 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -15908,4 +15908,124 @@ glo#:#glo_referenced_term#:#Referenced Term glo#:#glo_term_reference#:#Term Reference glo#:#glo_reference#:#Reference glo#:#glo_selected_terms_have_been_copied#:#The selected terms have been copied to the clipboard. Please open the target glossary and click "Paste". -content#:#cont_permission_object#:#Permission Object \ No newline at end of file +content#:#cont_permission_object#:#Permission Object +style#:#add_system_style#:#Add System Style +style#:#add_substyle#:#Add Sub Style +style#:#skin_id#:#Skin ID +style#:#skin_name#:#Skin Name +style#:#skin#:#Skin +style#:#style_id#:#Style ID +style#:#Style#:#Style +style#:#style_name#:#Style Name +style#:#image_dir#:#Image Directory +style#:#font_dir#:#Font Directory +style#:#sound_dir#:#Sound Directory +style#:#system_style_activation#:#System Style Activated +style#:#personal#:#Personal +style#:#system_styel_activation#:#Activate System Style +style#:#less#:#Less +style#:#icons#:#Icons +style#:#documentation#:#Documentation +style#:#less_can_not_be_modified#:#Less cannot be modified +style#:#no_less_path_set#:#No Less Path set +style#:#less_less_installation_detected#:#Less installation detected at: +style#:#grey_colors#:#Gray Colors +style#:#grey_color#:#Gray Color +style#:#grey_colors_description#:#Gray Color Description +style#:#red_colors#:#Red Colors +style#:#red_color#:#Red Color +style#:#red_colors_description#:#Red Color Description +style#:#green_colors#:#Green Colors +style#:#green_color#:#Green Color +style#:#green_colors_description#:#Green Color Description +style#:#blue_colors#:#Blue Colors +style#:#blue_color#:#Blue Color +style#:#blue_colors_description#:#Blue Color Description +style#:#reset_icons#:#Reset Icons +style#:#update_colors#:#Update Colors +style#:#style_not_deleted#:#The style could not be deleted for the following reasons: +style#:#styles_not_deleted#:#The styles could not have been deleted for the following reasons: +style#:#cant_delete_activated_style#:#Active Styles cannot be deleted. +style#:#style_deleted#:#Deleted Style: +style#:#dir_preserved_linked#:#Preserved Link: +style#:#file_deleted#:#Following file has been deleted: +style#:#skin_deleted#:#Following skin has been deleted: +style#:#msg_sys_style_update#:#System Styles have been updated +common#:#set_style_does_not_exist#:#Your selected system style does not exist anymore. You may change your style in the personal settings or contact your administrator. Current selection: +common#:#set_skin_does_not_exist#:#Your selected skin does not exist anymore. You may change your style in the personal settings or contact your administrator. Current selection: +style#:#cant_deactivate_default_style#:#Default styles cannot be deactivated. +style#:#cant_delete_if_users_assigned#:#Styles can not be deleted if users are still assigned. +style#:#default_style_set_to#:#The default system style has been set to: +style#:#personal_style_set_to#:#Your personal style has been set to: +style#:#refresh_entries#:#Refresh Entries +style#:#entries_reloaded#:#All entries have been reloaded +style#:#msg_sub_style_created#:#The sub style has been created. +style#:#style#:#Style +style#:#sub_style_settings#:#Sub Style Assignment +style#:#parent#:#Parent Style +style#:#sty_substyle_of#:#Sub Style of +style#:#assignment#:#Assignment +style#:#remove_assignment#:#Remove Assignment +style#:#reset_variables#:#Reset Variables +style#:#update_variables#:#Update Variables +style#:#less_file_updated#:#The less variables have been updated. +style#:#settings_of_substyle#:#Manage sub style +style#:#settings_of_style#:#Manage style +style#:#of_parent#:#of parent: +style#:#from_skin#:#of skin: +style#:#dir_copied_from#:#The directory has been copied to from: +style#:#to#:#to: +style#:#dir_deleted#:#The following directory has been deleted: +style#:#sty_create_new_system_style#:#Create a new system style. +style#:#sty_create_new_system_sub_style#:#Create a new system sub style. +style#:#sty_import_system_style#:#Import an existing system style as zip. +style#:#sty_copy_other_system_style#:#Clone an existing system style. +style#:#sub_style_id#:#Sub Style ID +style#:#sub_style_name#:#Sub Style Name +style#:#less_variables_file_not_included#:#The less variables file: +style#:#in_main_less_file#:#is not imported inside the system styles main less file: +style#:#can_not_read_less_file#:#Cannot read less file. Path: +style#:#msg_sys_style_created#:#The new system style has successfully been created. +style#:#skin_id_description#:#Skins are container for styles and sub styles. The skin ID sets the name of the folder that holds all style and sub style information. Only letters, numbers as well as hyphens or underline characters are to be used in skin ID's. +style#:#skin_name_description#:#The skin name can be used to describe the area of application of the skin in human readable form. It will appear in all UI elements allowing the selection of skins. +style#:#style_id_description#:#The style id is used as name for style specific files such as css and less placed inside the skins folder. Only letters, numbers as well as hyphens or underline characters are to be used in style ID's. +style#:#style_name_description#:#The style name can be used to describe the area of application of the style in human readable form. It will appear in all UI elements allowing the selection of styles. +style#:#sub_style#:#Sub Style +style#:#image_dir_description#:#Folder to store images (mostly icons) of the skin into. This directory can be shared with other styles and sub styles of this skin. +style#:#font_dir_description#:#Folder to store fonts of the skin into. This directory can be shared with other styles and sub styles of this skin. +style#:#sound_dir_description#:#Folder to store sounds of the skin into. This directory can be shared with other styles and sub styles of this skin. +style#:#sub_style_parent_style_description#:#Sub styles are assigned to exactly one parent style. They are only displayed to a specific user if the parent style is assigned to a this exact user. The parent style of a substyle can not be changed after the creation of the sub style. +style#:#sub_style_id_description#:#The sub style id is used as name for sub style specific files such as css and less placed inside the skins folder. Only letters, numbers as well as hyphens or underline characters are to be used in skin ID's. +style#:#sub_style_name_description#:#The sub style name can be used to describe the area of application of the style in human readable form. It will appear in all UI elements allowing the selection of skins. +style#:#system_style_activation_description#:#Active system styles can be assigned to users or even selected by users if this setting is activated (see User Management / Settings / Standard Fields / Default Skin). +style#:#system_style_default_description#:#Set this style as the default system style. The default system style is used if the current user has not style assigned or if the user is not logged in. +style#:#system_style_personal_description#:#Set this style as your personal system style. This might be handy to see the changes that are currently performed. +style#:#less_compile_failed#:#Something in the compilation of the less file went wrong. Is lessc installed and the path set correctly in ILIAS setup? Original error: +style#:#zip_export_failed#:#The ZIP export failed. The following error occured: +style#:#no_style_selected#:#No sub style has been selected. +style#:#adapt_less#:#Adapt Less +style#:#adapt_less_description#:#This is a direct representation of all less variables from the variables.less file used in the selected skin. Variable names and descriptions are drawn directly from this file and are therefore only available in their original language. The selected style will be recompiled completely by updating/reseting the variables. Resetting variables will create a exact copy of the default delos style. +style#:#adapt_icons_description#:#All icons that could be found in svg icons in the skins images folder are listed here. If one color is changed, it will be changed in all icons containing this colors at once. +style#:#adapt_icons#:#Adapt Icon Colors +style#:#invalid_less_path#:#The provided lessc path is not valid. +style#:#provided_less_path#:#Provided lessc path: +style#:#used_colors#:#Used Colors: +style#:#style_imported#:#Style has been successfully imported into: +style#:#style_copied#:#Style has been successfully copied. +style#:#directory_created#:#Directory created: +style#:#color_changed_from#:#Color changed from: +style#:#color_changed_to#:#to: +style#:#edit_by_color#:#Edit by Color +style#:#edit_by_icon#:#Edit by Icon +style#:#update_icon#:#Update Icon +style#:#select_icon#:#Select Icon +style#:#change_icon#:#Change Icon +style#:#color#:#Color +style#:#adapt_icon#:#Adapt Icon +style#:#adapt_icon_description#:#Adapt icon colors or change the icon itself. +style#:#preview#:#Preview +style#:#icons_gallery#:#Icons Gallery +style#:#cant_delete_style_with_substyles#:#Styles with sub styles cannot be deleted. +style#:#style_assignments_deleted#:#Style assignments of the following Sub Style have been deleted: +style#:#skin_id_exists#:#There exists already a skin with this ID. +style#:#usages#:#Usages: \ No newline at end of file From ed706a88ca381d3bd6f904dd856d7e030c9ce54c Mon Sep 17 00:00:00 2001 From: Timon Amstutz Date: Mon, 22 Aug 2016 11:19:00 +0200 Subject: [PATCH 02/27] Language file changes for new System Style administration --- lang/setup_de.lang | 6 +++++- lang/setup_en.lang | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lang/setup_de.lang b/lang/setup_de.lang index b8748bdc35be..8024522c8267 100755 --- a/lang/setup_de.lang +++ b/lang/setup_de.lang @@ -622,4 +622,8 @@ cache_activated_components#:#Activated Components###30 08 2015 new variable cache_flush#:#Flush all caches###30 08 2015 new variable cache_activate_tpl_blocks#:#Template (Blocks)###30 08 2015 new variable cache_activate_tpl_variables#:#Template (Variablen###30 08 2015 new variable -cache_activate_all#:#Alle \ No newline at end of file +cache_activate_all#:#Alle +enable_system_styles_management#:#System Styles administrieren +enable_system_styles_management_info#:#Verwalten (hinzufügen, editieren, löschen) von System Styles im Layout and Styles Bereich der Administration. +lessc_path#:#Pfad zu lessc +lessc_path_comment#:#Lessc wird benötigt, um Less-Dateien zu CSS zu kompilieren. Dies ist eine Voraussetzung um neue System Styles in der Administration via GUI zu erstellen. \ No newline at end of file diff --git a/lang/setup_en.lang b/lang/setup_en.lang index 4a31b4b46c3b..5b9a7514a52a 100755 --- a/lang/setup_en.lang +++ b/lang/setup_en.lang @@ -612,4 +612,9 @@ cache_activated_components#:#Activated Components cache_flush#:#Flush all caches cache_activate_tpl_blocks#:#Template (Blocks) cache_activate_tpl_variables#:#Template (Variables) -cache_activate_all#:#All \ No newline at end of file +cache_activate_all#:#All +enable_system_styles_management#:#Manage System Styles +enable_system_styles_management_info#:#Manage (add, edit, delete) System Styles (Skins) in the Layout and Styles section of the Administration. +lessc_path#:#Path to lessc +lessc_path_comment#:#Lessc is needed to compile less files to CSS. This is a requirement for generating new css files for systems styles through manipulating less variables in the Administration. +lessc#:#Path to lessc From df0b5dde85473b516f90d90978c5373ffd27aab7 Mon Sep 17 00:00:00 2001 From: Timon Amstutz Date: Mon, 22 Aug 2016 11:21:42 +0200 Subject: [PATCH 03/27] Changed ilInitialisation for new System Styles --- Services/Init/classes/class.ilInitialisation.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Services/Init/classes/class.ilInitialisation.php b/Services/Init/classes/class.ilInitialisation.php index f4693385d901..1cf31f319eba 100644 --- a/Services/Init/classes/class.ilInitialisation.php +++ b/Services/Init/classes/class.ilInitialisation.php @@ -128,6 +128,7 @@ protected static function initIliasIniFile() define ("PATH_TO_JAVA",$ilIliasIniFile->readVariable("tools","java")); define ("URL_TO_LATEX",$ilIliasIniFile->readVariable("tools","latex")); define ("PATH_TO_FOP",$ilIliasIniFile->readVariable("tools","fop")); + define ("PATH_TO_LESSC",$ilIliasIniFile->readVariable("tools","lessc")); // read virus scanner settings switch ($ilIliasIniFile->readVariable("tools", "vscantype")) @@ -543,8 +544,6 @@ protected static function initStyle() $gui_class = $ui_plugin->getUIClassInstance(); $gui_class->modifyGUI("Services/Init", "init_style", array("styleDefinition" => $styleDefinition)); } - - $styleDefinition->startParsing(); } /** From f0e6e6ddbbe447b8a731dd0a6af24cadc56e52f3 Mon Sep 17 00:00:00 2001 From: Timon Amstutz Date: Mon, 22 Aug 2016 11:33:37 +0200 Subject: [PATCH 04/27] Renaming of entrance class to SystemStyles (adaption of routing) --- .../classes/class.ilObjStyleSettingsGUI.php | 47 +++++++++---------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/Services/Style/classes/class.ilObjStyleSettingsGUI.php b/Services/Style/classes/class.ilObjStyleSettingsGUI.php index b137b0a1c7bd..042d2118b20a 100755 --- a/Services/Style/classes/class.ilObjStyleSettingsGUI.php +++ b/Services/Style/classes/class.ilObjStyleSettingsGUI.php @@ -9,10 +9,10 @@ * * @author Alex Killing * @version $Id$ - * - * @ilCtrl_Calls ilObjStyleSettingsGUI: ilPermissionGUI, ilSystemStyleSettingsGUI, ilContentStyleSettingsGUI + * + * @ilCtrl_Calls ilObjStyleSettingsGUI: ilPermissionGUI, ilSystemStyleMainGUI, ilContentStyleSettingsGUI * @ilCtrl_Calls ilObjStyleSettingsGUI: ilPageLayoutAdministrationGUI - * + * * @ingroup ServicesStyle */ class ilObjStyleSettingsGUI extends ilObjectGUI @@ -51,7 +51,7 @@ class ilObjStyleSettingsGUI extends ilObjectGUI function __construct($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true) { global $DIC; - + $this->type = "stys"; $this->dic = $DIC; @@ -59,13 +59,11 @@ function __construct($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true $this->lng = $DIC->language(); $this->tabs = $DIC->tabs(); - $cmd = $this->ctrl->getCmd(); - parent::__construct($a_data,$a_id,$a_call_by_reference,$a_prepare_output); - + $this->lng->loadLanguageModule("style"); } - + /** * Execute command */ @@ -76,7 +74,7 @@ function executeCommand() if ($next_class == "" && in_array($cmd, array("view", ""))) { - $this->ctrl->redirectByClass("ilsystemstylesettingsgui", ""); + $this->ctrl->redirectByClass("ilSystemStyleMainGUI", ""); } switch($next_class) @@ -89,11 +87,11 @@ function executeCommand() $ret = $this->ctrl->forwardCommand($perm_gui); break; - case 'ilsystemstylesettingsgui': + case 'ilsystemstylemaingui': $this->prepareOutput(); $this->tabs->activateTab("system_styles"); - include_once("./Services/Style/System/classes/class.ilSystemStyleSettingsGUI.php"); - $gui = new ilSystemStyleSettingsGUI(); + include_once("./Services/Style/System/classes/class.ilSystemStyleMainGUI.php"); + $gui = new ilSystemStyleMainGUI(); $this->ctrl->forwardCommand($gui); break; @@ -124,7 +122,7 @@ function executeCommand() } return true; } - + /** * ??? * Save object @@ -137,19 +135,19 @@ function executeCommand() $newObj = parent::saveObject(); // put here object specific stuff - + // always send a message ilUtil::sendInfo($this->lng->txt("object_added"),true); - + ilUtil::redirect($this->getReturnLocation("save",$this->ctrl->getLinkTarget($this,"","",false,false))); }*/ - - + + function getAdminTabs() { $this->getTabs(); } - + /** * get tabs * @access public @@ -158,19 +156,19 @@ function getAdminTabs() function getTabs() { global $rbacsystem, $lng, $ilTabs; - + if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId())) - { + { $this->tabs_gui->addTab("system_styles", $this->lng->txt("system_styles"), - $this->ctrl->getLinkTargetByClass("ilsystemstylesettingsgui", "edit")); - + $this->ctrl->getLinkTargetByClass("ilsystemstylemaingui")); + $this->tabs_gui->addTab("content_styles", $this->lng->txt("content_styles"), $this->ctrl->getLinkTargetByClass("ilcontentstylesettingsgui", "edit")); - + $this->tabs_gui->addTab("page_layouts", $this->lng->txt("page_layouts"), $this->ctrl->getLinkTargetByClass("ilpagelayoutadministrationgui", "")); } - + if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId())) { $this->tabs_gui->addTab("perm_settings", $this->lng->txt("perm_settings"), @@ -179,4 +177,3 @@ function getTabs() } } -?> From dfc343b4fa3fad28b8f5dfef32f7253a48513e4b Mon Sep 17 00:00:00 2001 From: Timon Amstutz Date: Mon, 22 Aug 2016 11:34:26 +0200 Subject: [PATCH 05/27] Refatoring of System Style Top level classes --- .../classes/class.ilStyleDefinition.php | 799 +++++++++--------- .../class.ilSysStyleCatAssignmentTableGUI.php | 71 -- .../classes/class.ilSystemStyleHTMLExport.php | 19 +- .../classes/class.ilSystemStyleMainGUI.php | 228 +++++ .../classes/class.ilSystemStyleSettings.php | 242 +++++- .../class.ilSystemStyleSettingsGUI.php | 364 -------- .../classes/class.ilSystemStylesTableGUI.php | 160 ---- 7 files changed, 846 insertions(+), 1037 deletions(-) delete mode 100644 Services/Style/System/classes/class.ilSysStyleCatAssignmentTableGUI.php create mode 100644 Services/Style/System/classes/class.ilSystemStyleMainGUI.php delete mode 100644 Services/Style/System/classes/class.ilSystemStyleSettingsGUI.php delete mode 100644 Services/Style/System/classes/class.ilSystemStylesTableGUI.php diff --git a/Services/Style/System/classes/class.ilStyleDefinition.php b/Services/Style/System/classes/class.ilStyleDefinition.php index 4ba09f6da9bd..0b9541c5a1e9 100755 --- a/Services/Style/System/classes/class.ilStyleDefinition.php +++ b/Services/Style/System/classes/class.ilStyleDefinition.php @@ -1,352 +1,276 @@ + * @author Timon Amstutz * @version $Id$ * */ -require_once("./Services/Xml/classes/class.ilSaxParser.php"); -class ilStyleDefinition extends ilSaxParser +class ilStyleDefinition { /** - * currently selected skin - * @var string + * currently selected style, used for caching + * + * @var bool */ - static $current_skin; - - + static $current_style = false; + /** - * currently selected style - * @var string + * Skins available, used for caching + * @var ilSkinXML[] */ - static $current_style; - - static $current_master_style; - + static $skins = []; /** - * Constructor - * - * parse - * - * @access public - */ - function __construct($a_template_id = "") - { - if ($a_template_id == "") - { - // use function to get the current skin - $a_template_id = self::getCurrentSkin(); - } - - // remember the template id - $this->template_id = $a_template_id; - - if ($a_template_id == "default") - { - parent::__construct("./templates/".$a_template_id."/template.xml"); - } - else - { - parent::__construct("./Customizing/global/skin/".$a_template_id."/template.xml"); - } - } + * Sets the current skin. This is used by the global instance of this class. + * + * @var ilSkinXML + */ + protected $skin; + /** + * Used for caching. + * @var array|null + */ + protected static $cached_all_styles_information = null; - // PUBLIC METHODS + /** + * Used to wire this component up with the correct paths into the customizing directory. + * This is dynamic and not constant for this class to remain testable + * + * @var ilSystemStyleConfigMock + */ + protected $system_style_config; /** - * get translation type (sys, db or 0)s - * - * @param string object type - * @access public - */ - function getStyles() + * ilStyleDefinition constructor. + * @param string $skin_id + * @param ilSystemStyleConfig|null $system_style_config + */ + function __construct($skin_id = "", ilSystemStyleConfig $system_style_config = null) { -//echo ":".count($this->styles).":"; - if (is_array($this->styles)) - { - return $this->styles; + if($skin_id == ""){ + $skin_id = self::getCurrentSkin(); } - else - { - return array(); + + if(!$system_style_config){ + $this->setSystemStylesConf(new ilSystemStyleConfig()); + }else{ + $this->setSystemStylesConf($system_style_config); } - } - function getTemplateId() - { - return $this->template_id; - } + if ($skin_id != $this->getSystemStylesConf()->getDefaultSkinId()) + { + $this->setSkin(ilSkinXML::parseFromXML($this->getSystemStylesConf()->getCustomizingSkinPath().$skin_id."/template.xml")); - - function getTemplateName() - { - return $this->template_name; + }else{ + $this->setSkin(ilSkinXML::parseFromXML($this->getSystemStylesConf()->getDefaultTemplatePath())); + } } - - function getStyle($a_id) + /** + * get the current skin + * + * use always this function instead of getting the account's skin + * the current skin may be changed on the fly by setCurrentSkin() + * + * @return string|null skin id + */ + public static function getCurrentSkin() { - return $this->styles[$a_id]; - } + /** + * @var $ilias ILIAS + */ + global $DIC,$ilias; + $system_style_conf = new ilSystemStyleConfig(); - function getStyleName($a_id) - { - return $this->styles[$a_id]["name"]; - } + if (is_object($ilias)) { + $skin_id = $ilias->account->skin; + if(!self::skinExists($skin_id)){ + ilUtil::sendFailure($DIC->language()->txt("set_skin_does_not_exist")." ".$skin_id); + $skin_id = $system_style_conf->getDefaultSkinId(); + } + return $skin_id; + }else{ + return null; + } - function getImageDirectory($a_master_style, $a_substyle = "") - { - if ($a_substyle != $a_master_style && $a_substyle != "") - { - return $this->styles[$a_master_style]["substyle"][$a_substyle]["image_directory"]; - } - return $this->styles[$a_master_style]["image_directory"]; } - function getSoundDirectory($a_id) + /** + * @return ilSkinStyleXML[] + */ + public function getStyles() { - return $this->styles[$a_id]["sound_directory"]; + return $this->getSkin()->getStyles(); } - - public static function _getAllTemplates() - { - $skins = array(); - - $skins[] = array("id" => "default"); - if ($dp = @opendir("./Customizing/global/skin")) - { - while (($file = readdir($dp)) != false) - { - //is the file a directory? - if (is_dir("./Customizing/global/skin/".$file) && $file != "." && $file != ".." && $file != "CVS" - && $file != ".svn") - { - if (is_file("./Customizing/global/skin/".$file."/template.xml")) - { - $skins[] = array( - "id" => $file - ); - } - } - } // while - } - else - { - return $skins; - } - return $skins; - - } - function getAllTemplates() + /** + * @return string + */ + public function getTemplateName() { - return self::_getAllTemplates(); + return $this->getSkin()->getName(); } - - // PRIVATE METHODS /** - * set event handler - * - * @param ressouce internal xml_parser_handler - * @access private - */ - function setHandlers($a_xml_parser) + * @param $a_id + * @return ilSkinStyleXML + */ + public function getStyle($a_id) { - xml_set_object($a_xml_parser,$this); - xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag'); - xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData'); + return $this->getSkin()->getStyle($a_id); } /** - * start tag handler - * - * @param ressouce internal xml_parser_handler - * @param string element tag name - * @param array element attributes - * @access private - */ - function handlerBeginTag($a_xml_parser, $a_name, $a_attribs) + * @param $a_id + * @return string + */ + public function getStyleName($a_id) { - if (!isset($a_attribs["sound_directory"])) - { - $a_attribs["sound_directory"] = ""; - } - - if (!isset($a_attribs["browsers"])) - { - $a_attribs["browsers"] = ""; - } - - switch($a_name) - { - case "template" : - $this->template_name = $a_attribs["name"]; - break; - - case "style" : - $this->last_style_id = $a_attribs["id"]; - $this->styles[$a_attribs["id"]] = - array( "id" => $a_attribs["id"], - "name" => $a_attribs["name"], - "css_file" => $a_attribs["id"].".css", - "image_directory" => $a_attribs["image_directory"], - "sound_directory" => $a_attribs["sound_directory"] - ); - $browsers = - explode(",", $a_attribs["browsers"]); - foreach ($browsers as $val) - { - $this->styles[$a_attribs["id"]]["browsers"][] = trim($val); - } - break; - - case "substyle": - $this->styles[$this->last_style_id]["substyle"][$a_attribs["id"]] = - array( "id" => $a_attribs["id"], - "name" => $a_attribs["name"], - "css_file" => $a_attribs["id"].".css", - "image_directory" => $a_attribs["image_directory"], - "sound_directory" => $a_attribs["sound_directory"] - ); - break; - } + return $this->getSkin()->getStyle($a_id)->getName(); } - - + /** - * Check wheter a style exists - * - * @param string $skin skin id - * @param string $style style id - * - * @return boolean - */ - static function styleExists($skin, $style) + * @param $style_id + * @return string + * @throws ilSystemStyleException + */ + public function getImageDirectory($style_id) { - if ($skin == "default") - { - if (is_file("./templates/".$skin."/template.xml") && - is_file("./templates/".$skin."/".$style.".css") - ) - { - return true; - } + if(!$style_id){ + throw new ilSystemStyleException(ilSystemStyleException::NO_STYLE_ID,$style_id); } - else - { - if (is_file("./Customizing/global/skin/".$skin."/template.xml") && - is_file("./Customizing/global/skin/".$skin."/".$style.".css") - ) - { - return true; - } + if(!$this->getSkin()->getStyle($style_id)){ + throw new ilSystemStyleException(ilSystemStyleException::NOT_EXISTING_STYLE,$style_id); } - return false; + return $this->getSkin()->getStyle($style_id)->getImageDirectory(); } /** - * Check wheter a skin exists - * - * @param string $skin skin id - * - * @return boolean - */ - static function skinExists($skin) + * @param $style_id + * @return string + */ + public function getSoundDirectory($style_id) { - if ($skin == "default") - { - if (is_file("./templates/".$skin."/template.xml")) - { - return true; - } - } - else - { - if (is_file("./Customizing/global/skin/".$skin."/template.xml")) - { - return true; - } - } - return false; + return $this->getSkin()->getStyle($style_id)->getSoundDirectory(); } + /** - * end tag handler - * - * @param ressouce internal xml_parser_handler - * @param string data - * @access private - */ - function handlerCharacterData($a_xml_parser,$a_data) - { - // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA - $a_data = preg_replace("/\n/","",$a_data); - $a_data = preg_replace("/\t+/","",$a_data); + * @param ilSystemStyleConfig|null $system_style_config + * @return ilSkinXML[] + * @throws ilSystemStyleException + */ + public static function getAllSkins(ilSystemStyleConfig $system_style_config = null){ + if(!self::$skins){ + if(!$system_style_config){ + $system_style_config = new ilSystemStyleConfig(); + } - if(!empty($a_data)) - { - switch($this->current_tag) - { - default: - break; + /** + * @var $skins ilSkinXML[] + */ + $skins = []; + $skins[$system_style_config->getDefaultSkinId()] = ilSkinXML::parseFromXML($system_style_config->getDefaultTemplatePath()); + + + if(is_dir($system_style_config->getCustomizingSkinPath())){ + $cust_skins_directory = new RecursiveDirectoryIterator($system_style_config->getCustomizingSkinPath(),FilesystemIterator::SKIP_DOTS); + foreach ($cust_skins_directory as $skin_folder) { + if($skin_folder->isDir()){ + $template_path = $skin_folder->getRealPath()."/template.xml"; + if (file_exists($template_path)) + { + $skin = ilSkinXML::parseFromXML($template_path); + $skins[$skin->getId()] = $skin; + } + } + } } + + self::setSkins($skins); } + + return self::$skins; } /** - * end tag handler - * - * @param ressouce internal xml_parser_handler - * @param string element tag name - * @access private - */ - function handlerEndTag($a_xml_parser,$a_name) - { + * @deprecated due to bad naming. + * @return ilSkinXML[] + */ + public static function getAllTemplates(){ + return self::getAllSkins(); } - - + /** - * get the current skin - * - * use always this function instead of getting the account's skin - * the current skin may be changed on the fly by setCurrentSkin() - * - * @return string|null skin id + * Check whether a skin exists. Not using array_key_exists($skin_id,self::getAllSkins()); for performance reasons + * @param string $skin_id + * @param ilSystemStyleConfig|null $system_style_config + * @return bool */ - public static function getCurrentSkin() + public static function skinExists($skin_id, ilSystemStyleConfig $system_style_config = null) { - /** - * @var $ilias ILIAS - */ - global $ilias; - - if(isset(self::$current_skin)) - { - return self::$current_skin; + if(!$system_style_config){ + $system_style_config = new ilSystemStyleConfig(); } - if(is_object($ilias)) + if ($skin_id == $system_style_config->getDefaultSkinId()) + { + if (is_file($system_style_config->getDefaultTemplatePath())) + { + return true; + } + } + else { - return $ilias->account->skin; + if (is_file($system_style_config->getCustomizingSkinPath().$skin_id."/template.xml")) + { + return true; + } } - - return null; + return false; } /** - * get the current style + * get the current style or sub style * * use always this function instead of getting the account's style * the current style may be changed on the fly by setCurrentStyle() @@ -355,9 +279,14 @@ public static function getCurrentSkin() */ public static function getCurrentStyle() { - global $ilias, $tree, $styleDefinition, $tree; + global $DIC; + + /** + * @var ilStyleDefinition $styleDefinition + */ + global $ilias, $styleDefinition, $tree; - if (isset(self::$current_style)) + if (self::$current_style) { return self::$current_style; } @@ -367,33 +296,34 @@ public static function getCurrentStyle() return null; } - $cs = $ilias->account->prefs['style']; - - if (is_object($styleDefinition)) - { - // are there any substyles? - $styles = $styleDefinition->getStyles(); - if (is_array($styles[$cs]["substyle"])) - { + self::setCurrentStyle($ilias->account->prefs['style']); + + if (is_object($styleDefinition) && self::styleExistsForCurrentSkin(self::$current_style)) { + + if ($styleDefinition->getSkin()->hasStyleSubstyles(self::$current_style)) { // read assignments, if given - $assignmnts = self::getSystemStyleCategoryAssignments(self::getCurrentSkin(), $cs); - if (count($assignmnts) > 0) - { - $ref_ass = array(); - foreach ($assignmnts as $a) - { + $assignments = ilSystemStyleSettings::getSystemStyleCategoryAssignments(self::getCurrentSkin(), self::$current_style); + if (count($assignments) > 0) { + $ref_ass = []; + foreach ($assignments as $a) { + if($styleDefinition->getSkin()->hasStyle($a["substyle"])) $ref_ass[$a["ref_id"]] = $a["substyle"]; } + $ref_id = false; + if ($_GET["ref_id"]) { + $ref_id = $_GET["ref_id"]; + } else if ($_GET["target"]) { + $target_arr = explode("_", $_GET["target"]); + $ref_id = $target_arr[1]; + } + // check whether any ref id assigns a new style - if (is_object($tree) && $_GET["ref_id"] > 0 && - $tree->isInTree($_GET["ref_id"])) - { - $path = $tree->getPathId((int) $_GET["ref_id"]); - for ($i = count($path) - 1; $i >= 0; $i--) - { - if (isset($ref_ass[$path[$i]])) - { + if (is_object($tree) && $ref_id && $tree->isInTree($ref_id)) { + + $path = $tree->getPathId($ref_id); + for ($i = count($path) - 1; $i >= 0; $i--) { + if (isset($ref_ass[$path[$i]])) { self::$current_style = $ref_ass[$path[$i]]; return self::$current_style; } @@ -402,174 +332,199 @@ public static function getCurrentStyle() } } } - - if ($_GET["ref_id"] != "") - { - self::$current_style = $cs; + + if(!self::styleExistsForCurrentSkin(self::$current_style)){ + ilUtil::sendFailure($DIC->language()->txt("set_style_does_not_exist")." ".self::$current_style); + $system_style_config = new ilSystemStyleConfig(); + self::setCurrentSkin($system_style_config->getDefaultSkinId()); + self::setCurrentStyle($system_style_config->getDefaultStyleId()); } - - return $cs; + + return self::$current_style; } - - /** - * get the current style - * - * use always this function instead of getting the account's style - * the current style may be changed on the fly by setCurrentStyle() - * @return string style id + /** + * Get all skins/styles as array (convenient for tables) + * Attention: tempalte_name/template_id in this array is only used for legacy reasons an might be removed in future. + * + * @return array|null */ - public static function getCurrentMasterStyle() + public static function getAllSkinStyles() { - global $ilias; - - if (isset(self::$current_master_style)) - { - return self::$current_master_style; - } + /** + * @var ilStyleDefinition $styleDefinition + */ + global $styleDefinition; - $cs = $ilias->account->prefs['style']; - self::$current_master_style = $cs; - - return $cs; + + if(!self::getCachedAllStylesInformation()){ + $all_styles = []; + + $skins = $styleDefinition->getSkins(); + + foreach ($skins as $skin) + { + foreach ($skin->getStyles() as $style) + { + $num_users = ilObjUser::_getNumberOfUsersForStyle($skin->getId(), $style->getId()); + + $parent_name = ""; + if($style->getSubstyleOf()){ + $parent_name = $skin->getStyle($style->getSubstyleOf())->getName(); + } + + // default selection list + $all_styles[$skin->getId().":".$style->getId()] = [ + "title" => $skin->getName()." / ".$style->getName(), + "id" => $skin->getId().":". $style->getId(), + "skin_id" => $skin->getId(), + "skin_name" => $skin->getName(), + "template_id" => $skin->getId(), + "template_name" => $skin->getName(), + "style_id" => $style->getId(), + "style_name" => $style->getName(), + "substyle_of" => $style->getSubstyleOf(), + "substyle_of_name" => $parent_name, + "users" => $num_users + ]; + } + } + self::setCachedAllStylesInformation($all_styles); + + } + + return self::getCachedAllStylesInformation(); } - + /** - * set a new current skin - * - * @param string skin id + * @param $a_skin */ public static function setCurrentSkin($a_skin) { + /** + * @var ilStyleDefinition $styleDefinition + */ global $styleDefinition; - if (is_object($styleDefinition) - and $styleDefinition->getTemplateId() != $a_skin) + if (is_object($styleDefinition) && $styleDefinition->getSkin()->getName() != $a_skin) { $styleDefinition = new ilStyleDefinition($a_skin); - $styleDefinition->startParsing(); } - - self::$current_skin = $a_skin; } - - + + + /** + * @param $style_id + * @return bool + */ + public static function styleExists($style_id){ + foreach(self::getSkins() as $skin) + { + if($skin->hasStyle($style_id)){ + return true; + } + } + return false; + } + /** - * set a new current style - * - * @param string style id + * @param $skin_id + * @param $style_id + * @return bool + * @throws ilSystemStyleException + */ + public static function styleExistsForSkinId($skin_id,$style_id){ + if(!self::skinExists($skin_id)){ + return false; + } + $skin = ilSystemStyleSkinContainer::generateFromId($skin_id)->getSkin(); + return $skin->hasStyle($style_id); + } + + /** + * @param $style_id + * @return bool + */ + public static function styleExistsForCurrentSkin($style_id){ + /** + * @var ilStyleDefinition $styleDefinition + */ + global $styleDefinition; + + return $styleDefinition->getSkin()->hasStyle($style_id); + } + + /** + * @param $a_style */ public static function setCurrentStyle($a_style) { self::$current_style = $a_style; } - + /** - * Get all skins/styles - * - * @param - * @return + * @return ilSkinXML[] */ - public static function getAllSkinStyles() + public static function getSkins() { - global $styleDefinition; - - $all_styles = array(); - - $templates = $styleDefinition->getAllTemplates(); - - foreach ($templates as $template) - { - // get styles definition for template - $styleDef = new ilStyleDefinition($template["id"]); - $styleDef->startParsing(); - $styles = $styleDef->getStyles(); + return self::getAllSkins(); + } - foreach ($styles as $style) - { - $num_users = ilObjUser::_getNumberOfUsersForStyle($template["id"], $style["id"]); - - // default selection list - $all_styles[$template["id"].":".$style["id"]] = - array ( - "title" => $styleDef->getTemplateName()." / ".$style["name"], - "id" => $template["id"].":".$style["id"], - "template_id" => $template["id"], - "style_id" => $style["id"], - "template_name" => $styleDef->getTemplateName(), - "substyle" => $style["substyle"], - "style_name" => $style["name"], - "users" => $num_users - ); - } - } + /** + * @param ilSkinXML[] $skins + */ + public static function setSkins($skins) + { + self::$skins = $skins; + } - return $all_styles; + /** + * @return ilSkinXML + */ + public function getSkin() + { + return $this->skin; } - + /** - * Get all system style category assignments - * - * @param string $a_skin_id skin id - * @param string $a_style_id style id - * @return array ref ids + * @param ilSkinXML $skin */ - static function getSystemStyleCategoryAssignments($a_skin_id, $a_style_id) + public function setSkin($skin) { - global $ilDB; - - $assignmnts = array(); - $set = $ilDB->query("SELECT substyle, category_ref_id FROM syst_style_cat ". - " WHERE skin_id = ".$ilDB->quote($a_skin_id, "text"). - " AND style_id = ".$ilDB->quote($a_style_id, "text") - ); - while ($rec = $ilDB->fetchAssoc($set)) - { - $assignmnts[] = array("substyle" => $rec["substyle"], - "ref_id" => $rec["category_ref_id"]); - } - return $assignmnts; + $this->skin = $skin; } - + /** - * Write category assignment - * - * @param - * @return + * @return array|null */ - static function writeSystemStyleCategoryAssignment($a_skin_id, $a_style_id, - $a_substyle, $a_ref_id) + protected static function getCachedAllStylesInformation() { - global $ilDB; - - $ilDB->manipulate("INSERT INTO syst_style_cat ". - "(skin_id, style_id, substyle, category_ref_id) VALUES (". - $ilDB->quote($a_skin_id, "text").",". - $ilDB->quote($a_style_id, "text").",". - $ilDB->quote($a_substyle, "text").",". - $ilDB->quote($a_ref_id, "integer"). - ")"); + return self::$cached_all_styles_information; } - + /** - * Delete category style assignment - * - * @param - * @return + * @param array|null $cached_all_styles_information */ - static function deleteSystemStyleCategoryAssignment($a_skin_id, $a_style_id, - $a_substyle, $a_ref_id) + protected static function setCachedAllStylesInformation($cached_all_styles_information) { - global $ilDB; - - $ilDB->manipulate("DELETE FROM syst_style_cat WHERE ". - " skin_id = ".$ilDB->quote($a_skin_id, "text"). - " AND style_id = ".$ilDB->quote($a_style_id, "text"). - " AND substyle = ".$ilDB->quote($a_substyle, "text"). - " AND category_ref_id = ".$ilDB->quote($a_ref_id, "integer")); + self::$cached_all_styles_information = $cached_all_styles_information; } - -} -?> + + /** + * @return ilSystemStyleConfig + */ + public function getSystemStylesConf() + { + return $this->system_style_config; + } + + /** + * @param $system_style_config + */ + public function setSystemStylesConf($system_style_config) + { + $this->$system_style_config = $system_style_config; + } +} \ No newline at end of file diff --git a/Services/Style/System/classes/class.ilSysStyleCatAssignmentTableGUI.php b/Services/Style/System/classes/class.ilSysStyleCatAssignmentTableGUI.php deleted file mode 100644 index c8f10d1fe380..000000000000 --- a/Services/Style/System/classes/class.ilSysStyleCatAssignmentTableGUI.php +++ /dev/null @@ -1,71 +0,0 @@ - - * @version $Id$ - * - * @ingroup Services - */ -class ilSysStyleCatAssignmentTableGUI extends ilTable2GUI -{ - /** - * Constructor - */ - function __construct($a_parent_obj, $a_parent_cmd) - { - global $ilCtrl, $lng, $ilAccess, $lng; - - parent::__construct($a_parent_obj, $a_parent_cmd); - - - $style_arr = explode(":", $_GET["style_id"]); - $this->skin_id = $style_arr[0]; - $this->style_id = $style_arr[1]; - - $this->getStyleCatAssignments(); - $this->setTitle($lng->txt("sty_cat_assignments").", ". - $this->skin_id."/".$this->style_id); - - $this->addColumn("", "", "1"); - $this->addColumn($this->lng->txt("sty_substyle")); - $this->addColumn($this->lng->txt("obj_cat")); - - $this->setFormAction($ilCtrl->getFormAction($a_parent_obj)); - $this->setRowTemplate("tpl.sty_cat_ass_row.html", "Services/Style/System"); - - $this->addMultiCommand("deleteSysStyleCatAssignments", $lng->txt("delete")); - } - - /** - * Get style assignments - * - * @param - * @return - */ - function getStyleCatAssignments() - { - $this->setData(ilStyleDefinition::getSystemStyleCategoryAssignments($this->skin_id, $this->style_id)); - } - - - /** - * Fill table row - */ - protected function fillRow($a_set) - { - global $lng; - - $this->tpl->setVariable("REF_ID", $a_set["ref_id"]); - $this->tpl->setVariable("SUBSTYLE", $a_set["substyle"]); - $this->tpl->setVariable("CATEGORY", - ilObject::_lookupTitle(ilObject::_lookupObjId($a_set["ref_id"]))); - } - -} -?> diff --git a/Services/Style/System/classes/class.ilSystemStyleHTMLExport.php b/Services/Style/System/classes/class.ilSystemStyleHTMLExport.php index fa7f2735376d..59a234b11a77 100644 --- a/Services/Style/System/classes/class.ilSystemStyleHTMLExport.php +++ b/Services/Style/System/classes/class.ilSystemStyleHTMLExport.php @@ -11,7 +11,7 @@ class ilSystemStyleHTMLExport { private $exp_dir = ""; - private $images = array(); + private $images = []; /** * Initialisation @@ -53,20 +53,17 @@ function createDirectories() /** * Add (icon) image to the list of images to be exported * - * @param - * @return + * @param $a_file + * @param string $a_exp_file_name */ function addImage($a_file, $a_exp_file_name = "") { - $this->images[] = array("file" => $a_file, - "exp_file_name" => $a_file); + $this->images[] = ["file" => $a_file, + "exp_file_name" => $a_exp_file_name]; } - + /** * Export - * - * @param - * @return */ function export() { @@ -104,6 +101,4 @@ function export() } } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/Services/Style/System/classes/class.ilSystemStyleMainGUI.php b/Services/Style/System/classes/class.ilSystemStyleMainGUI.php new file mode 100644 index 000000000000..e2b8e2e776c9 --- /dev/null +++ b/Services/Style/System/classes/class.ilSystemStyleMainGUI.php @@ -0,0 +1,228 @@ + + * @author Timon Amstutz + + * @version $Id$ + * @ingroup ServicesStyle + * + * @ilCtrl_Calls ilSystemStyleMainGUI: ilSystemStyleOverviewGUI,ilSystemStyleSettingsGUI + * @ilCtrl_Calls ilSystemStyleMainGUI: ilSystemStyleLessGUI,ilSystemStyleIconsGUI,ilSystemStyleDocumentationGUI + * + */ +class ilSystemStyleMainGUI +{ + /** + * @var ilCtrl + */ + protected $ctrl; + + /** + * @var ilLanguage + */ + protected $lng; + + + /** + * @var ILIAS\DI\Container + */ + protected $DIC; + + /** + * @var ilTabsGUI + */ + protected $tabs; + + + /** + * @var ilRbacSystem + */ + protected $rbacsystem; + + /** + * @var int + */ + protected $ref_id; + + /** + * @var ilTemplate + */ + protected $tpl; + + /** + * Constructor + */ + function __construct() + { + global $DIC; + + $this->ctrl = $DIC->ctrl(); + $this->lng = $DIC->language(); + $this->tabs = $DIC->tabs(); + $this->rbacsystem = $DIC->rbac()->system(); + $this->tpl = $DIC["tpl"]; + + $this->ref_id = (int) $_GET["ref_id"]; + } + + + /** + * Main routing of the system styles. Resets ilCtrl Parameter for all subsequent generation of links. + * + * @throws ilCtrlException + * @throws ilObjectException + */ + function executeCommand() + { + $next_class = $this->ctrl->getNextClass($this); + + $this->ctrl->setParameterByClass('ilsystemstylesettingsgui','skin_id',$_GET["skin_id"]); + $this->ctrl->setParameterByClass('ilsystemstylesettingsgui','style_id',$_GET["style_id"]); + $this->ctrl->setParameterByClass('ilsystemstylelessgui','skin_id',$_GET["skin_id"]); + $this->ctrl->setParameterByClass('ilsystemstylelessgui','style_id',$_GET["style_id"]); + $this->ctrl->setParameterByClass('ilsystemstyleiconsgui','skin_id',$_GET["skin_id"]); + $this->ctrl->setParameterByClass('ilsystemstyleiconsgui','style_id',$_GET["style_id"]); + $this->ctrl->setParameterByClass('ilsystemstyledocumentationgui','skin_id',$_GET["skin_id"]); + $this->ctrl->setParameterByClass('ilsystemstyledocumentationgui','style_id',$_GET["style_id"]); + + try{ + switch ($next_class) + { + + case "ilsystemstylesettingsgui": + $this->checkPermission("sty_management"); + $this->setUnderworldTabs('settings'); + $this->setUnderworldTitle(); + include_once("Settings/class.ilSystemStyleSettingsGUI.php"); + $system_styles_settings = new ilSystemStyleSettingsGUI(); + $this->ctrl->forwardCommand($system_styles_settings); + break; + case "ilsystemstylelessgui": + $this->checkPermission("sty_management"); + $this->setUnderworldTabs('less'); + $this->setUnderworldTitle(); + include_once("Less/class.ilSystemStyleLessGUI.php"); + $system_styles_less = new ilSystemStyleLessGUI(); + $this->ctrl->forwardCommand($system_styles_less); + break; + case "ilsystemstyleiconsgui": + $this->checkPermission("sty_management"); + $this->setUnderworldTabs('icons'); + $this->setUnderworldTitle(); + include_once("Icons/class.ilSystemStyleIconsGUI.php"); + $system_styles_icons = new ilSystemStyleIconsGUI(); + $this->ctrl->forwardCommand($system_styles_icons); + break; + case "ilsystemstyledocumentationgui": + $this->checkPermission("sty_management"); + $this->setUnderworldTabs('documentation'); + $this->setUnderworldTitle(); + include_once("Documentation/class.ilSystemStyleDocumentationGUI.php"); + $system_styles_documentation = new ilSystemStyleDocumentationGUI(); + $this->ctrl->forwardCommand($system_styles_documentation); + break; + case "ilsystemstyleoverviewgui": + default: + $this->checkPermission("visible,read"); + include_once("Overview/class.ilSystemStyleOverviewGUI.php"); + $system_styles_overview = new ilSystemStyleOverviewGUI(!$this->checkPermission("sty_write_system",false) + ,$this->checkPermission("sty_management",false)); + $this->ctrl->forwardCommand($system_styles_overview); + break; + } + }catch(ilObjectException $e){ + ilUtil::sendFailure($e->getMessage()); + $this->checkPermission("visible,read"); + include_once("Overview/class.ilSystemStyleOverviewGUI.php"); + $this->ctrl->setCmd(""); + $system_styles_overview = new ilSystemStyleOverviewGUI(!$this->checkPermission("sty_write_system",false),$this->checkPermission("sty_management",false)); + $this->ctrl->forwardCommand($system_styles_overview); + } + } + + /** + * Checks permission for system styles. Permissions work on two levels, ordinary rbac and the + * 'enable_system_styles_management' setting in the tools section of the ilias.ini.php + * + * @param $a_perm + * @param bool|true $a_throw_exc + * @return bool + * @throws ilObjectException + */ + public function checkPermission($a_perm, $a_throw_exc = true) + { + global $ilIliasIniFile; + + $has_perm = true; + + if($a_perm == "sty_management"){ + $has_perm = $ilIliasIniFile->readVariable("tools","enable_system_styles_management")== "1" ? true:false; + $a_perm = "sty_write_system"; + } + + if($has_perm){ + $has_perm = $this->rbacsystem->checkAccess($a_perm, $this->ref_id); + } + + if (!$has_perm) + { + if ($a_throw_exc) + { + include_once "Services/Object/exceptions/class.ilObjectException.php"; + throw new ilObjectException($this->lng->txt("sty_permission_denied")); + } + return false; + } + return $has_perm; + } + + /** + * Sets the tab correctly if one system style is open (navigational underworld opened) + * + * @param string $active + */ + protected function setUnderworldTabs($active = "") { + $this->tabs->clearTargets(); + + $this->tabs->setBackTarget($this->lng->txt("back"),$this->ctrl->getLinkTarget($this)); + $this->tabs->addTab('settings', $this->lng->txt('settings'), $this->ctrl->getLinkTargetByClass('ilsystemstylesettingsgui')); + $this->tabs->addTab('less', $this->lng->txt('less'), $this->ctrl->getLinkTargetByClass('ilsystemstylelessgui')); + $this->tabs->addTab('icons', $this->lng->txt('icons'), $this->ctrl->getLinkTargetByClass('ilsystemstyleiconsgui')); + $this->tabs->addTab('documentation', $this->lng->txt('documentation'), $this->ctrl->getLinkTargetByClass('ilsystemstyledocumentationgui')); + + $this->tabs->activateTab($active); + } + + + /** + * Sets title correctly if one system style is opened + * + * @throws ilSystemStyleException + */ + protected function setUnderworldTitle() { + $skin_id = $_GET["skin_id"]; + $style_id = $_GET["style_id"]; + + $skin = ilSystemStyleSkinContainer::generateFromId($skin_id)->getSkin(); + $style = $skin->getStyle($style_id); + + $this->tpl->setTitle($style->getName()); + if($style->isSubstyle()){ + $this->tpl->setDescription($this->lng->txt("settings_of_substyle")." '".$style->getName()."' ". + $this->lng->txt("of_parent")." '".$skin->getStyle($style->getSubstyleOf())->getName()."' ". + $this->lng->txt("from_skin")." ".$skin->getName() + ); + }else{ + $this->tpl->setDescription($this->lng->txt("settings_of_style")." '".$style->getName()."' ". + $this->lng->txt("from_skin")." '".$skin->getName()."'" + ); + } + } +} \ No newline at end of file diff --git a/Services/Style/System/classes/class.ilSystemStyleSettings.php b/Services/Style/System/classes/class.ilSystemStyleSettings.php index e4b8fa12328c..4cb9d37ad0a7 100644 --- a/Services/Style/System/classes/class.ilSystemStyleSettings.php +++ b/Services/Style/System/classes/class.ilSystemStyleSettings.php @@ -3,17 +3,27 @@ /* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */ /** - * + * This class acts as Model for all system styles settings related settings + * such as activated or default system styles etc, be it in database or inifile. + * Do not use this class to get the current system style, use ilStyleDefinition insteaed. + * + * Semantics of terms style, sub style, skin, template --> see ilStyleDefinition * * @author Alex Killing + * @author Timon Amstutz + * * @version $Id$ * @ingroup ServicesStyle + * */ class ilSystemStyleSettings { /** - * SYSTEM * lookup if a style is activated + * + * @param $a_skin + * @param $a_style + * @return bool */ static function _lookupActivatedStyle($a_skin, $a_style) { @@ -37,8 +47,10 @@ static function _lookupActivatedStyle($a_skin, $a_style) } /** - * * SYSTEM - * deactivate style + * deactivate system style + * + * @param $a_skin + * @param $a_style */ static function _deactivateStyle($a_skin, $a_style) { @@ -54,8 +66,10 @@ static function _deactivateStyle($a_skin, $a_style) } /** - * * SYSTEM - * activate style + * activate system style + * + * @param $a_skin + * @param $a_style */ static function _activateStyle($a_skin, $a_style) { @@ -68,6 +82,218 @@ static function _activateStyle($a_skin, $a_style) $ilDB->manipulate($q); } -} + /** + * Get all system sub styles category assignments. This is used to check wheter a system sub style is to be used + * in a particular category. + * + * @param string $a_skin_id skin id + * @param string $a_style_id style id + * @return array ('substyle' => substyle_id, 'ref id' => cat_ref_id) + */ + static function getSystemStyleCategoryAssignments($a_skin_id, $a_style_id) + { + global $ilDB; + + $assignments = []; + $set = $ilDB->query("SELECT substyle, category_ref_id FROM syst_style_cat ". + " WHERE skin_id = ".$ilDB->quote($a_skin_id, "text"). + " AND style_id = ".$ilDB->quote($a_style_id, "text") + ); + while (($rec = $ilDB->fetchAssoc($set))) + { + $assignments[] = [ + "substyle" => $rec["substyle"], + "ref_id" => $rec["category_ref_id"] + ]; + } + return $assignments; + } + + /** + * Get all system category assignments of exactly one substyle. This is used to check wheter a system sub style is to be used + * in a particular category. + * + * @param $a_skin_id + * @param $a_style_id + * @param $a_sub_style_id + * @return array + */ + static function getSubStyleCategoryAssignments($a_skin_id, $a_style_id, $a_sub_style_id) + { + global $ilDB; + + $assignmnts = []; + + $set = $ilDB->query("SELECT substyle, category_ref_id FROM syst_style_cat ". + " WHERE skin_id = ".$ilDB->quote($a_skin_id, "text"). + " AND substyle = ".$ilDB->quote($a_sub_style_id, "text"). + " AND style_id = ".$ilDB->quote($a_style_id, "text") + ); + while (($rec = $ilDB->fetchAssoc($set))) + { + $assignmnts[] = [ + "substyle" => $rec["substyle"], + "ref_id" => $rec["category_ref_id"] + ]; + } + return $assignmnts; + } + + /** + * Sets a substyle category assignment. + * + * @param $a_skin_id + * @param $a_style_id + * @param $a_substyle + * @param $a_ref_id + * @throws ilSystemStyleException + */ + static function writeSystemStyleCategoryAssignment($a_skin_id, $a_style_id, + $a_substyle, $a_ref_id) + { + global $ilDB; + + $assignments = self::getSubStyleCategoryAssignments($a_skin_id, $a_style_id,$a_substyle); + + foreach($assignments as $assignment){ + if($assignment["ref_id"] == $a_ref_id){ + throw new ilSystemStyleException(ilSystemStyleException::SUBSTYLE_ASSIGNMENT_EXISTS,$a_substyle. ": ".$a_ref_id); + } + } + $ilDB->manipulate("INSERT INTO syst_style_cat ". + "(skin_id, style_id, substyle, category_ref_id) VALUES (". + $ilDB->quote($a_skin_id, "text").",". + $ilDB->quote($a_style_id, "text").",". + $ilDB->quote($a_substyle, "text").",". + $ilDB->quote($a_ref_id, "integer"). + ")"); + } + + /** + * Deletes all sub style category assignment of a system style. This is used if a system style is deleted + * completely + * + * @param $a_skin_id + * @param $a_style_id + * @param $a_substyle + * @param $a_ref_id + */ + static function deleteSystemStyleCategoryAssignment($a_skin_id, $a_style_id, + $a_substyle, $a_ref_id) + { + global $ilDB; + + $ilDB->manipulate("DELETE FROM syst_style_cat WHERE ". + " skin_id = ".$ilDB->quote($a_skin_id, "text"). + " AND style_id = ".$ilDB->quote($a_style_id, "text"). + " AND substyle = ".$ilDB->quote($a_substyle, "text"). + " AND category_ref_id = ".$ilDB->quote($a_ref_id, "integer")); + } -?> \ No newline at end of file + /** + * Delets a sub styles category assignment. + * + * @param $a_skin_id + * @param $a_style_id + * @param $a_substyle + */ + static function deleteSubStyleCategoryAssignments($a_skin_id, $a_style_id, $a_substyle) + { + global $ilDB; + + $ilDB->manipulate("DELETE FROM syst_style_cat WHERE ". + " skin_id = ".$ilDB->quote($a_skin_id, "text"). + " AND style_id = ".$ilDB->quote($a_style_id, "text"). + " AND substyle = ".$ilDB->quote($a_substyle, "text")); + } + + /** + * Sets a users preferred system skin/style by using the user object. + * + * @param $skin_id + * @param $style_id + */ + static function setCurrentUserPrefStyle($skin_id, $style_id){ + global $DIC; + + $DIC->user()->setPref("skin",$skin_id); + $DIC->user()->setPref("style",$style_id); + $DIC->user()->update(); + } + + /** + * Gets a users preferred skin by using the user object. + * + * @return bool + */ + static function getCurrentUserPrefSkin(){ + global $DIC; + + return $DIC->user()->getPref("skin"); + } + + /** + * Gets a users preferred style by using the user object. + * + * @return bool + */ + static function getCurrentUserPrefStyle(){ + global $DIC; + + return $DIC->user()->getPref("style"); + } + + /** + * Sets the default style of the system + * + * @param $skin_id + * @param $style_id + */ + static function setCurrentDefaultStyle($skin_id, $style_id){ + global $DIC; + + $DIC['ilias']->ini->setVariable("layout","skin", $skin_id); + $DIC['ilias']->ini->setVariable("layout","style",$style_id); + $DIC['ilias']->ini->write(); + self::_activateStyle($skin_id, $style_id); + + } + + static function resetDefaultToDelos(){ + $system_style_conf = new ilSystemStyleConfig(); + + self::setCurrentDefaultStyle($system_style_conf->getDefaultSkinId(),$system_style_conf->getDefaultSkinId()); + } + + /** + * Gets default Skin of the System + * + * @return string + */ + static function getCurrentDefaultSkin(){ + global $DIC; + $skin_id = $DIC['ilias']->ini->readVariable("layout","skin"); + + if(!ilStyleDefinition::skinExists($skin_id)){ + self::resetDefaultToDelos(); + $skin_id = $DIC['ilias']->ini->readVariable("layout","skin"); + } + return $skin_id; + } + + /** + * Gets default style of the system + * @return string + */ + static function getCurrentDefaultStyle(){ + global $DIC; + $skin_id = $DIC['ilias']->ini->readVariable("layout","skin"); + $style_id = $DIC['ilias']->ini->readVariable("layout","style"); + + if(!ilStyleDefinition::styleExistsForSkinId($skin_id,$style_id)){ + self::resetDefaultToDelos(); + $style_id = $DIC['ilias']->ini->readVariable("layout","style"); + } + return $style_id; + } +} \ No newline at end of file diff --git a/Services/Style/System/classes/class.ilSystemStyleSettingsGUI.php b/Services/Style/System/classes/class.ilSystemStyleSettingsGUI.php deleted file mode 100644 index 1639340a55f1..000000000000 --- a/Services/Style/System/classes/class.ilSystemStyleSettingsGUI.php +++ /dev/null @@ -1,364 +0,0 @@ - - * @version $Id$ - * @ingroup ServicesStyle - */ -class ilSystemStyleSettingsGUI -{ - /** - * @var ilCtrl - */ - protected $ctrl; - - /** - * @var ilRbacSystem - */ - protected $rbacsystem; - - /** - * @var ilToolbarGUI - */ - protected $toolbar; - - /** - * @var ilLanguage - */ - protected $lng; - - /** - * @var ilTemplate - */ - protected $tpl; - - /** - * @var ILIAS\DI\Container - */ - protected $DIC; - - /** - * @var int - */ - protected $ref_id; - - /** - * @var ilTree - */ - protected $tree; - - /** - * Constructor - */ - function __construct() - { - global $DIC, $ilIliasIniFile; - - $this->ini = $ilIliasIniFile; - $this->dic = $DIC; - $this->ctrl = $DIC->ctrl(); - $this->rbacsystem = $DIC->rbac()->system(); - $this->toolbar = $DIC->toolbar(); - $this->lng = $DIC->language(); - $this->tpl = $DIC["tpl"]; - $this->tree = $DIC["tree"]; - - $this->ref_id = (int) $_GET["ref_id"]; - } - - - /** - * Execute command - */ - function executeCommand() - { - $next_class = $this->ctrl->getNextClass($this); - $cmd = $this->ctrl->getCmd("edit"); - - switch ($next_class) - { - default: - if (in_array($cmd, array("edit", "moveUserStyles", "saveStyleSettings", - "assignStylesToCats", "addStyleCatAssignment", "saveStyleCatAssignment", "deleteSysStyleCatAssignments"))) - { - $this->$cmd(); - } - } - } - - /** - * Check permission - * - * @param string $a_perm permission(s) - * @return bool - * @throws ilObjectException - */ - function checkPermission($a_perm, $a_throw_exc = true) - { - if (!$this->rbacsystem->checkAccess($a_perm, $this->ref_id)) - { - if ($a_throw_exc) - { - include_once "Services/Object/exceptions/class.ilObjectException.php"; - throw new ilObjectException($this->lng->txt("permission_denied")); - } - return false; - } - return true; - } - - /** - * Edit - */ - function edit() - { - $this->checkPermission("visible,read"); - - // default skin/style - if ($this->checkPermission("sty_write_system", false)) - { - include_once("./Services/Form/classes/class.ilSelectInputGUI.php"); - $options = array(); - foreach (ilStyleDefinition::getAllSkinStyles() as $st) - { - $options[$st["id"]] = $st["title"]; - } - - // from styles selector - $si = new ilSelectInputGUI($this->lng->txt("sty_move_user_styles").": ".$this->lng->txt("sty_from"), "from_style"); - $si->setOptions($options + array("other" => $this->lng->txt("other"))); - $this->toolbar->addInputItem($si, true); - - // from styles selector - $si = new ilSelectInputGUI($this->lng->txt("sty_to"), "to_style"); - $si->setOptions($options); - $this->toolbar->addInputItem($si, true); - $this->toolbar->addFormButton($this->lng->txt("sty_move_style"), "moveUserStyles"); - - $this->toolbar->setFormAction($this->ctrl->getFormAction($this)); - } - - include_once("./Services/Style/System/classes/class.ilSystemStylesTableGUI.php"); - $tab = new ilSystemStylesTableGUI($this, "editSystemStyles"); - $this->tpl->setContent($tab->getHTML()); - - } - - /** - * Move user styles - */ - function moveUserStyles() - { - $this->checkPermission("sty_write_system"); - - $to = explode(":", $_POST["to_style"]); - - if ($_POST["from_style"] != "other") - { - $from = explode(":", $_POST["from_style"]); - ilObjUser::_moveUsersToStyle($from[0],$from[1],$to[0],$to[1]); - } - else - { - // get all user assigned styles - $all_user_styles = ilObjUser::_getAllUserAssignedStyles(); - - include_once("./Services/Style/System/classes/class.ilStyleDefinition.php"); - $all_styles = ilStyleDefinition::getAllSkinStyles(); - - // move users that are not assigned to - // currently existing style - foreach($all_user_styles as $style) - { - if (isset($all_styles[$style])) - { - $style_arr = explode(":", $style); - ilObjUser::_moveUsersToStyle($style_arr[0],$style_arr[1],$to[0],$to[1]); - } - } - } - - ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true); - $this->ctrl->redirect($this , "edit"); - } - - - /** - * Save skin and style settings - */ - function saveStyleSettings() - { - $this->checkPermission("sty_write_system"); - - // check if one style is activated - if (count($_POST["st_act"]) < 1) - { - ilUtil::sendFailure($this->lng->txt("at_least_one_style"), true); - $this->ctrl->redirect($this, "edit"); - } - - //set default skin and style - if ($_POST["default_skin_style"] != "") - { - $sknst = explode(":", $_POST["default_skin_style"]); - - if ($this->ini->readVariable("layout","style") != $sknst[1] || - $this->ini->readVariable("layout","skin") != $sknst[0]) - { - $this->ini->setVariable("layout","skin", $sknst[0]); - $this->ini->setVariable("layout","style",$sknst[1]); - } - $this->ini->write(); - } - - // check if a style should be deactivated, that still has - // a user assigned to - $all_styles = ilStyleDefinition::getAllSkinStyles(); - foreach ($all_styles as $st) - { - if (!isset($_POST["st_act"][$st["id"]])) - { - if (ilObjUser::_getNumberOfUsersForStyle($st["template_id"], $st["style_id"]) > 1) - { - ilUtil::sendFailure($this->lng->txt("cant_deactivate_if_users_assigned"), true); - $this->ctrl->redirect($this, "edit"); - } - else - { - include_once("./Services/Style/System/classes/class.ilSystemStyleSettings.php"); - ilSystemStyleSettings::_deactivateStyle($st["template_id"], $st["style_id"]); - } - } - else - { - include_once("./Services/Style/System/classes/class.ilSystemStyleSettings.php"); - ilSystemStyleSettings::_activateStyle($st["template_id"], $st["style_id"]); - } - } - - ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true); - $this->ctrl->redirect($this , "edit"); - } - - //// - //// Substyles - //// - - /** - * Assign styles to categories - * - * @param - * @return - */ - function assignStylesToCats() - { - $this->ctrl->setParameter($this, "style_id", urlencode($_GET["style_id"])); - - $this->checkPermission("sty_write_system"); - - $all_styles = ilStyleDefinition::getAllSkinStyles(); - $sel_style = $all_styles[$_GET["style_id"]]; - - $options = array(); - if (is_array($sel_style["substyle"])) - { - foreach ($sel_style["substyle"] as $subst) - { - $options[$subst["id"]] = $subst["name"]; - } - } - - // substyle - include_once("./Services/Form/classes/class.ilSelectInputGUI.php"); - $si = new ilSelectInputGUI($this->lng->txt("sty_substyle"), "substyle"); - $si->setOptions($options); - $this->toolbar->addInputItem($si, true); - - $this->toolbar->addFormButton($this->lng->txt("sty_add_assignment"), "addStyleCatAssignment"); - $this->toolbar->setFormAction($this->ctrl->getFormAction($this)); - - include_once("./Services/Style/System/classes/class.ilSysStyleCatAssignmentTableGUI.php"); - $tab = new ilSysStyleCatAssignmentTableGUI($this, "assignStylesToCats"); - - $this->tpl->setContent($tab->getHTML()); - } - - - /** - * Add style category assignment - * - * @param - * @return - */ - function addStyleCatAssignment() - { - $this->checkPermission("sty_write_system"); - - $this->ctrl->setParameter($this, "style_id", urlencode($_GET["style_id"])); - $this->ctrl->setParameter($this, "substyle", urlencode($_REQUEST["substyle"])); - - include_once 'Services/Search/classes/class.ilSearchRootSelector.php'; - $exp = new ilSearchRootSelector( - $this->ctrl->getLinkTarget($this,'addStyleCatAssignment')); - $exp->setExpand($_GET["search_root_expand"] ? $_GET["search_root_expand"] : $this->tree->readRootId()); - $exp->setExpandTarget($this->ctrl->getLinkTarget($this,'addStyleCatAssignment')); - $exp->setTargetClass(get_class($this)); - $exp->setCmd('saveStyleCatAssignment'); - $exp->setClickableTypes(array("cat")); - - // build html-output - $exp->setOutput(0); - $this->tpl->setContent($exp->getOutput()); - } - - - /** - * Save style category assignment - * - * @param - * @return - */ - function saveStyleCatAssignment() - { - $this->checkPermission("sty_write_system"); - - $this->ctrl->setParameter($this, "style_id", urlencode($_GET["style_id"])); - - $style_arr = explode(":", $_GET["style_id"]); - ilStyleDefinition::writeSystemStyleCategoryAssignment($style_arr[0], $style_arr[1], - $_GET["substyle"], $_GET["root_id"]); - ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true); - - $this->ctrl->redirect($this, "assignStylesToCats"); - } - - /** - * Delete system style to category assignments - */ - function deleteSysStyleCatAssignments() - { - $this->checkPermission("sty_write_system"); - - $this->ctrl->setParameter($this, "style_id", urlencode($_GET["style_id"])); - $style_arr = explode(":", $_GET["style_id"]); - if (is_array($_POST["id"])) - { - foreach ($_POST["id"] as $id) - { - $id_arr = explode(":", $id); - ilStyleDefinition::deleteSystemStyleCategoryAssignment($style_arr[0], $style_arr[1], - $id_arr[0], $id_arr[1]); - } - ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true); - } - - $this->ctrl->redirect($this, "assignStylesToCats"); - } - -} - -?> \ No newline at end of file diff --git a/Services/Style/System/classes/class.ilSystemStylesTableGUI.php b/Services/Style/System/classes/class.ilSystemStylesTableGUI.php deleted file mode 100644 index 084a1f4bde61..000000000000 --- a/Services/Style/System/classes/class.ilSystemStylesTableGUI.php +++ /dev/null @@ -1,160 +0,0 @@ - - * @version $Id$ - * - * @ingroup ServicesStyle - */ -class ilSystemStylesTableGUI extends ilTable2GUI -{ - /** - * Constructor - */ - function __construct($a_parent_obj, $a_parent_cmd) - { - global $ilCtrl, $lng, $ilAccess, $lng, $rbacsystem; - - parent::__construct($a_parent_obj, $a_parent_cmd); - $this->getStyles(); -// $this->setTitle($lng->txt("")); - - $this->setLimit(9999); - - $this->addColumn($this->lng->txt("title")); - $this->addColumn($this->lng->txt("default")); - $this->addColumn($this->lng->txt("users")); - $this->addColumn($this->lng->txt("active")); - $this->addColumn($this->lng->txt("sty_substyles")); - $this->addColumn($this->lng->txt("actions")); - - $this->setFormAction($ilCtrl->getFormAction($a_parent_obj)); - $this->setRowTemplate("tpl.sys_styles_row.html", "Services/Style/System"); - - if ($rbacsystem->checkAccess("sty_write_system", (int) $_GET["ref_id"])) - { - $this->addCommandButton("saveStyleSettings", $lng->txt("save")); - } - } - - /** - * Get styles - * - * @param - * @return - */ - function getStyles() - { - global $styleDefinition; - - $all_styles = ilStyleDefinition::getAllSkinStyles(); - - // get all user assigned styles - $all_user_styles = ilObjUser::_getAllUserAssignedStyles(); - - // output "other" row for all users, that are not assigned to - // any existing style - $users_missing_styles = 0; - foreach($all_user_styles as $style) - { - if (!isset($all_styles[$style])) - { - $style_arr = explode(":", $style); - $users_missing_styles += ilObjUser::_getNumberOfUsersForStyle($style_arr[0], $style_arr[1]); - } - } - - if ($users_missing_styles > 0) - { - $all_styles["other"] = - array ( - "title" => $this->lng->txt("other"), - "id" => "other", - "template_id" => "", - "style_id" => "", - "template_name" => "", - "style_name" => "", - "users" => $users_missing_styles - ); - } - - - $this->setData($all_styles); - } - - - /** - * Fill table row - */ - protected function fillRow($a_set) - { - global $lng, $ilClientIniFile, $ilCtrl; - - $cat_ass = ilStyleDefinition::getSystemStyleCategoryAssignments($a_set["template_id"], - $a_set["style_id"]); - - if (is_array($a_set["substyle"])) - { - foreach ($a_set["substyle"] as $substyle) - { - reset($cat_ass); - $cats = false; - foreach($cat_ass as $ca) - { - if ($ca["substyle"] == $substyle["id"]) - { - $this->tpl->setCurrentBlock("cat"); - $this->tpl->setVariable("CAT", ilObject::_lookupTitle( - ilObject::_lookupObjId($ca["ref_id"]))); - $this->tpl->parseCurrentBlock(); - $cats = true; - } - } - if ($cats) - { - $this->tpl->touchBlock("cats"); - } - - $this->tpl->setCurrentBlock("substyle"); - $this->tpl->setVariable("SUB_STYLE", $substyle["name"]); - $this->tpl->parseCurrentBlock(); - } - $this->tpl->touchBlock("substyles"); - - $ilCtrl->setParameter($this->parent_obj, "style_id", urlencode($a_set["id"])); - $this->tpl->setCurrentBlock("cmd"); - $this->tpl->setVariable("HREF_CMD", $ilCtrl->getLinkTarget($this->parent_obj, - "assignStylesToCats")); - $this->tpl->setVariable("TXT_CMD", $lng->txt("sty_assign_categories")); - $this->tpl->parseCurrentBlock(); - } - - $this->tpl->setVariable("TITLE", $a_set["title"]); - $this->tpl->setVariable("ID", $a_set["id"]); - - // number of users - $this->tpl->setVariable("USERS", $a_set["users"]); - - // activation - include_once("./Services/Style/System/classes/class.ilSystemStyleSettings.php"); - if (ilSystemStyleSettings::_lookupActivatedStyle($a_set["template_id"], $a_set["style_id"])) - { - $this->tpl->setVariable("CHECKED", ' checked="checked" '); - } - - if ($ilClientIniFile->readVariable("layout","skin") == $a_set["template_id"] && - $ilClientIniFile->readVariable("layout","style") == $a_set["style_id"]) - { - $this->tpl->setVariable("CHECKED_DEFAULT", ' checked="checked" '); - } - - } - -} -?> From ceccd0bc83326b23a3b0e51a973f4305339d0146 Mon Sep 17 00:00:00 2001 From: Timon Amstutz Date: Mon, 22 Aug 2016 11:35:08 +0200 Subject: [PATCH 06/27] System Styles Utility Classes --- .../Utilities/class.ilSkinStyleXML.php | 252 ++++++ .../classes/Utilities/class.ilSkinXML.php | 334 ++++++++ .../Utilities/class.ilSystemStyleConfig.php | 222 ++++++ .../Utilities/class.ilSystemStyleMessage.php | 91 +++ .../class.ilSystemStyleMessageStack.php | 96 +++ .../class.ilSystemStyleSkinContainer.php | 738 ++++++++++++++++++ 6 files changed, 1733 insertions(+) create mode 100644 Services/Style/System/classes/Utilities/class.ilSkinStyleXML.php create mode 100644 Services/Style/System/classes/Utilities/class.ilSkinXML.php create mode 100644 Services/Style/System/classes/Utilities/class.ilSystemStyleConfig.php create mode 100644 Services/Style/System/classes/Utilities/class.ilSystemStyleMessage.php create mode 100644 Services/Style/System/classes/Utilities/class.ilSystemStyleMessageStack.php create mode 100644 Services/Style/System/classes/Utilities/class.ilSystemStyleSkinContainer.php diff --git a/Services/Style/System/classes/Utilities/class.ilSkinStyleXML.php b/Services/Style/System/classes/Utilities/class.ilSkinStyleXML.php new file mode 100644 index 000000000000..ad02685a11cb --- /dev/null +++ b/Services/Style/System/classes/Utilities/class.ilSkinStyleXML.php @@ -0,0 +1,252 @@ + + * @version $Id$* + */ +class ilSkinStyleXML +{ + /** + * Id of the skin. Currently css and less files are named accordingely + * @var string + */ + protected $id = ""; + + /** + * Name of the style visible in all UI elements + * + * @var string + */ + protected $name = ""; + + /** + * Directory to store sound files into + * + * @var string + */ + protected $sound_directory = ""; + + /** + * Directory to store image files into + * + * @var string + */ + protected $image_directory = ""; + + /** + * Directory to store fonts into + * + * @var string + */ + protected $font_directory = ""; + + /** + * Css file name of the skin + * + * @var string + */ + protected $css_file = ""; + + /** + * Parent of the skin if set + * + * @var string + */ + protected $substyle_of = ""; + + /** + * ilSkinStyleXML constructor. + * @param $id + * @param $name + * @param string $css_file + * @param string $image_directory + * @param string $font_directory + * @param string $sound_directory + * @param string $parent_style + */ + public function __construct($id, $name, $css_file = "", $image_directory = "", $font_directory = "", $sound_directory = "",$parent_style = "") + { + $this->setId($id); + $this->setName($name); + + if($css_file == ""){ + $css_file = $this->getId(); + } + + if($image_directory == ""){ + $image_directory = "images"; + } + + if($font_directory == ""){ + $font_directory = "fonts"; + } + + if($sound_directory == ""){ + $sound_directory = "sound"; + } + + $this->setCssFile($css_file); + $this->setImageDirectory($image_directory); + $this->setFontDirectory($font_directory); + $this->setSoundDirectory($sound_directory); + $this->setSubstyleOf($parent_style); + } + + /** + * @param SimpleXMLElement $xml_element + * @return ilSkinStyleXML + */ + static function parseFromXMLElement(SimpleXMLElement $xml_element){ + $style = new self((string)$xml_element->attributes()["id"], + (string)$xml_element->attributes()["name"], + (string)$xml_element->attributes()["css_file"], + (string)$xml_element->attributes()["image_directory"], + (string)$xml_element->attributes()["font_directory"], + (string)$xml_element->attributes()["sound_directory"] + + ); + return $style; + } + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * @param $id + * @throws ilSystemStyleException + */ + public function setId($id) + { + if (strpos($id, ' ') !== false) { + throw new ilSystemStyleException(ilSystemStyleException::INVALID_CHARACTERS_IN_ID, $id); + } + $this->id = str_replace(" ","_",$id); + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getSoundDirectory() + { + return $this->sound_directory; + } + + /** + * @param string $sound_directory + */ + public function setSoundDirectory($sound_directory) + { + $this->sound_directory = $sound_directory; + } + + /** + * @return string + */ + public function getImageDirectory() + { + return $this->image_directory; + } + + /** + * @param string $image_directory + */ + public function setImageDirectory($image_directory) + { + $this->image_directory = $image_directory; + } + + /** + * @return string + */ + public function getCssFile() + { + return $this->css_file; + } + + /** + * @param string $css_file + */ + public function setCssFile($css_file) + { + $this->css_file = $css_file; + } + + /** + * @return string + */ + public function getFontDirectory() + { + return $this->font_directory; + } + + /** + * @param string $font_directory + */ + public function setFontDirectory($font_directory) + { + $this->font_directory = $font_directory; + } + + /** + * Returns the parent style of this style if set + * + * @return string + */ + public function getSubstyleOf() + { + return $this->substyle_of; + } + + /** + * Sets style as sub style of another + * + * @param string $substyle_of + */ + public function setSubstyleOf($substyle_of) + { + $this->substyle_of = $substyle_of; + } + + /** + * Return wheter this style is a substyle of another + * + * @return bool + */ + public function isSubstyle(){ + return $this->getSubstyleOf() != ""; + } + + /** + * Checks if a resource (folder) relative to the style is referenced by this style. Used to decide if folder can be deleted. + * + * @param $resource + * @return bool + */ + public function referencesResource($resource){ + return $this->getCssFile() == $resource + || $this->getImageDirectory() == $resource + || $this->getFontDirectory() == $resource + || $this->getSoundDirectory()== $resource; + } +} \ No newline at end of file diff --git a/Services/Style/System/classes/Utilities/class.ilSkinXML.php b/Services/Style/System/classes/Utilities/class.ilSkinXML.php new file mode 100644 index 000000000000..90df7166e1d9 --- /dev/null +++ b/Services/Style/System/classes/Utilities/class.ilSkinXML.php @@ -0,0 +1,334 @@ + + * @version $Id$* + */ +class ilSkinXML implements \Iterator, \Countable{ + + /** + * ID of the skin, equals the name of the folder this skin is stored in + * @var string + */ + protected $id = ""; + + + /** + * Name of the skin, as provided in the template + * @var string + */ + protected $name = ""; + + /** + * Styles that the xml of this string provides. + * + * @var ilSkinStyleXML[] + */ + protected $styles = array(); + + + /** + * ilSkinXML constructor. + * @param string $name + */ + public function __construct($id, $name) + { + $this->setId($id); + $this->setName($name); + } + + /** + * @param string $path + * @return ilSkinXML + * @throws ilSystemStyleException + */ + public static function parseFromXML($path = ""){ + try{ + $xml = new SimpleXMLElement(file_get_contents($path)); + }catch(Exception $e){ + throw new ilSystemStyleException(ilSystemStyleException::FILE_OPENING_FAILED, $path); + } + + $id = basename (dirname($path)); + $skin = new self($id,(string)$xml->attributes()["name"]); + + /** + * @var ilSkinStyleXML $last_style + */ + $last_style = null; + + + foreach($xml->children() as $style_xml){ + + $style = ilSkinStyleXML::parseFromXMLElement($style_xml); + + /** + * @var SimpleXMLElement $style_xml + */ + if($style_xml->getName() == "substyle") { + if(!$last_style){ + throw new ilSystemStyleException(ilSystemStyleException::NO_PARENT_STYLE, $style->getId()); + } + $style->setSubstyleOf($last_style->getId()); + } + $skin->addStyle($style); + $last_style = $style; + + } + return $skin; + } + + /** + * Stores the skin and all it's styles as xml. + * + * @return string + */ + public function asXML(){ + $xml = new SimpleXMLElement('