ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilObjLanguageExtGUI Class Reference

Class ilObjLanguageExtGUI. More...

+ Inheritance diagram for ilObjLanguageExtGUI:
+ Collaboration diagram for ilObjLanguageExtGUI:

Public Member Functions

 __construct ($a_data, int $a_id=0, bool $a_call_by_reference=false)
 Constructor. More...
 
 getId ()
 get the language object id (needed for filter serialization) Return language object id More...
 
 getUnsafeGetCommands ()
 Sent by GET (e.g. More...
 
 getSafePostCommands ()
 
 executeCommand ()
 execute command More...
 
 viewObject (int $changesSuccessBool=0, array $modules_with_unwritten_overlay=[], array $additional_failure_messages=[], array $posted_values=[], array $posted_remarks=[])
 Show the edit screen. More...
 
 applyFilterObject ()
 Apply filter. More...
 
 resetFilterObject ()
 Reset filter. More...
 
 saveObject ()
 Save the changed translations. More...
 
 importObject ()
 Show the screen to import a language file. More...
 
 uploadObject ()
 Process an uploaded language file. More...
 
 exportObject ()
 Show the screen to export a language file. More...
 
 downloadObject ()
 Download a language file. More...
 
 maintainObject ()
 Process the language maintenance. More...
 
 maintainExecuteObject ()
 
 settingsObject ()
 View the language settings. More...
 
 saveSettingsObject ()
 Set the language settings - see SetLanguageTranslationEnabled. More...
 
 statisticsObject ()
 Print out statistics about the language. More...
 
 getAdminTabs ()
 Get tabs for admin mode (Overwritten from ilObjectGUI, called by prepareOutput) More...
 
 addNewEntryObject (?ilPropertyFormGUI $a_form=null)
 
 saveNewEntryObject ()
 
- Public Member Functions inherited from ilObjectGUI
 getRefId ()
 
 setAdminMode (string $mode)
 
 getAdminMode ()
 
 getObject ()
 
 executeCommand ()
 
 withReferences ()
 determines whether objects are referenced or not (got ref ids or not) More...
 
 setCreationMode (bool $mode=true)
 If true, a creation screen is displayed the current [ref_id] does belong to the parent class The mode is determined in ilRepositoryGUI. More...
 
 getCreationMode ()
 
 prepareOutput (bool $show_sub_objects=true)
 
 getAdminTabs ()
 administration tabs show only permissions and trash folder More...
 
 getHTML ()
 
 confirmedDeleteObject ()
 confirmed deletion of object -> objects are moved to trash or deleted immediately, if trash is disabled More...
 
 cancelObject ()
 cancel action and go back to previous page More...
 
 createObject ()
 create new object form More...
 
 editAvailabilityPeriodObject ()
 
 saveAvailabilityPeriodObject ()
 
 cancelCreation ()
 cancel create action and go back to repository parent More...
 
 saveObject ()
 
 getDidacticTemplateVar (string $type)
 Get didactic template setting from creation screen. More...
 
 putObjectInTree (ilObject $obj, ?int $parent_node_id=null)
 Add object to tree at given position. More...
 
 editObject ()
 
 addExternalEditFormCustom (ilPropertyFormGUI $form)
 
 updateObject ()
 updates object entry in object_data More...
 
 getFormAction (string $cmd, string $default_form_action="")
 Get form action for command (command is method name without "Object", e.g. More...
 
 isVisible (int $ref_id, string $type)
 
 viewObject ()
 viewObject container presentation for "administration -> repository, trash, permissions" More...
 
 deleteObject (bool $error=false)
 Display deletion confirmation screen. More...
 
 setColumnSettings (ilColumnGUI $column_gui)
 
 addToDeskObject ()
 
 removeFromDeskObject ()
 
- Public Member Functions inherited from ILIAS\Object\ImplementsCreationCallback
 callCreationCallback (\ilObject $object, \ilObjectDefinition $obj_definition, int $requested_crtcb)
 
 getUnsafeGetCommands ()
 This method must return a list of unsafe GET commands. More...
 
 getSafePostCommands ()
 This method must return a list of safe POST commands. More...
 

Protected Member Functions

 assignObject ()
 Assign the extended language object. More...
 
 getViewTable ()
 Get the table to view language entries. More...
 
 initNewImportForm ()
 
 initNewSettingsForm ()
 
 addAdminLocatorItems (bool $do_not_add_object=false)
 Set the locator for admin mode (Overwritten from ilObjectGUI, called by prepareOutput) More...
 
 setTitleAndDescription ()
 Set the Title and the description (Overwritten from ilObjectGUI, called by prepareOutput) More...
 
 buildMissingEntries (?array $a_missing=null)
 
 initAddNewEntryForm (?string $a_id=null)
 
 getSuccessMessage ()
 Get success message after variables were saved. More...
 
- Protected Member Functions inherited from ilObjectGUI
 getObjectService ()
 
 assignObject ()
 
 setTitleAndDescription ()
 
 createActionDispatcherGUI ()
 
 initHeaderAction (?string $sub_type=null, ?int $sub_id=null)
 Add header action menu. More...
 
 insertHeaderAction (?ilObjectListGUI $list_gui=null)
 Insert header action into main template. More...
 
 addHeaderAction ()
 Add header action menu. More...
 
 redrawHeaderActionObject ()
 Ajax call: redraw action header only. More...
 
 setTabs ()
 set admin tabs More...
 
 setAdminTabs ()
 set admin tabs More...
 
 setLocator ()
 
 addLocatorItems ()
 should be overwritten to add object specific items (repository items are preloaded) More...
 
 omitLocator (bool $omit=true)
 
 addAdminLocatorItems (bool $do_not_add_object=false)
 should be overwritten to add object specific items (repository items are preloaded) More...
 
 getCreationFormsHTML (StandardForm|ilPropertyFormGUI|array $form)
 
 getTitleForCreationFormPage ()
 
 getCreationFormTitle ()
 
 initCreateForm (string $new_type)
 
 didacticTemplatesToForm ()
 
 initDidacticTemplate (ilPropertyFormGUI $form)
 
 retrieveAdditionalDidacticTemplateOptions ()
 
 addAdoptContentLinkToToolbar ()
 
 addImportButtonToToolbar ()
 
 addAvailabilityPeriodButtonToToolbar (ilToolbarGUI $toolbar)
 
 parseDidacticTemplateVar (string $var, string $type)
 
 afterSave (ilObject $new_object)
 Post (successful) object creation hook. More...
 
 initEditForm ()
 
 initEditCustomForm (ilPropertyFormGUI $a_form)
 Add custom fields to update form. More...
 
 getEditFormValues ()
 
 getEditFormCustomValues (array &$a_values)
 Add values to custom edit fields. More...
 
 validateCustom (ilPropertyFormGUI $form)
 Validate custom values (if not possible with checkInput()) More...
 
 updateCustom (ilPropertyFormGUI $form)
 Insert custom update form values into object. More...
 
 afterUpdate ()
 Post (successful) object update hook. More...
 
 routeImportCmdObject ()
 
 importFile (string $file_to_import, string $path_to_uploaded_file_in_temp_dir)
 
 deleteUploadedImportFile (string $path_to_uploaded_file_in_temp_dir)
 
 afterImport (ilObject $new_object)
 Post (successful) object import hook. More...
 
 setFormAction (string $cmd, string $form_action)
 
 getReturnLocation (string $cmd, string $default_location="")
 Get return location for command (command is method name without "Object", e.g. More...
 
 setReturnLocation (string $cmd, string $location)
 set specific return location for command More...
 
 getTargetFrame (string $cmd, string $default_target_frame="")
 get target frame for command (command is method name without "Object", e.g. More...
 
 setTargetFrame (string $cmd, string $target_frame)
 Set specific target frame for command. More...
 
 showPossibleSubObjects ()
 show possible sub objects (pull down menu) More...
 
 getTabs ()
 @abstract overwrite in derived GUI class of your object type More...
 
 redirectToRefId (int $ref_id, string $cmd="")
 redirects to (repository) view per ref id usually to a container and usually used at the end of a save/import method where the object gui type (of the new object) doesn't match with the type of the current ["ref_id"] value of the request More...
 
 getCenterColumnHTML ()
 Get center column. More...
 
 getRightColumnHTML ()
 Display right column. More...
 
 checkPermission (string $perm, string $cmd="", string $type="", ?int $ref_id=null)
 
 checkPermissionBool (string $perm, string $cmd="", string $type="", ?int $ref_id=null)
 
 enableDragDropFileUpload ()
 Enables the file upload into this object by dropping files. More...
 
 getCreatableObjectTypes ()
 
 buildAddNewItemElements (array $subtypes, string $create_target_class=ilRepositoryGUI::class, ?int $redirect_target_ref_id=null,)
 
 buildGroup (string $create_target_class, array $obj_types_in_group, string $title, array $subtypes)
 

Private Member Functions

 compareComments (string $compare, array $modules=[])
 Remarks (lng_data and overlay) plus, for PO modules without a remark, the shipped notes and "not translated yet" marker of the shipped .po (see ilObjLanguageExt::_getShippedMigratedComments()). More...
 
 remarkOf (array $comments, string $name)
 A form of a plural message without a comment of its own gets the one of its identifier (see PluralFormKey). More...
 
 clearLocalChanges ()
 Maintenance action "clear": the same RemoveLocalLanguageChanges as "remove local changes" in the language list. More...
 
 invalidMarkupMessage (array $invalid_values)
 The English violations go to the log, see InvalidMarkupMessage. More...
 
 duplicateIdentifierMessage (array $duplicates)
 Names each entry with the entries it would duplicate, the full list goes to the log. More...
 
 importedMessage (string $file_name)
 The client-supplied file name ends up in HTML, so it is escaped. More...
 
 setSuccessOrOverlayWarning (string $success_message, array $modules_with_unwritten_overlay)
 A success message, or a warning if PO/MO files could not be written (the database was written, the web server keeps serving the previous content). More...
 
 mergeMessages (array $result, bool $global_file_written, bool $global_file_not_written)
 Success, plus everything that failed or was left out in one failure message (setOnScreenMessage() keeps one per type), or an info if nothing was written at all; details are in the log. More...
 
 overlayNotWrittenMessage (array $modules_with_unwritten_overlay)
 
 getSession ()
 

Private Attributes

const string ILIAS_LANGUAGE_MODULE = "components/ILIAS/Language"
 
string $langmode
 
readonly AddLanguageEntry $add_language_entry
 
readonly SetLanguageTranslationEnabled $set_language_translation_enabled
 
readonly RemoveLocalLanguageChanges $remove_local_language_changes
 

Additional Inherited Members

- Static Public Member Functions inherited from ilObjectGUI
static _gotoRepositoryRoot (bool $raise_error=false)
 Goto repository root. More...
 
static _gotoRepositoryNode (int $ref_id, string $cmd="")
 
static _gotoSharedWorkspaceNode (int $wsp_id)
 
- Data Fields inherited from ilObjectGUI
const ADMIN_MODE_NONE = ""
 
const ADMIN_MODE_SETTINGS = "settings"
 
const ADMIN_MODE_REPOSITORY = "repository"
 
const UPLOAD_TYPE_LOCAL = 1
 
const UPLOAD_TYPE_UPLOAD_DIRECTORY = 2
 
const CFORM_NEW = 1
 
const CFORM_IMPORT = 2
 
const CFORM_CLONE = 3
 
const SUPPORTED_IMPORT_MIME_TYPES = [MimeType::APPLICATION__ZIP, MimeType::APPLICATION__X_ZIP_COMPRESSED]
 
- Protected Attributes inherited from ilObjectGUI
ILIAS Notes Service $notes_service
 
GlobalHttpState $http
 
ServerRequestInterface $request
 
ilLocatorGUI $locator
 
ilObjUser $user
 
ilAccessHandler $access
 
ilSetting $settings
 
ilToolbarGUI $toolbar
 
ilRbacAdmin $rbac_admin
 
ilRbacSystem $rbac_system
 
ilRbacReview $rbac_review
 
ilObjectService $object_service
 
ilObjectDefinition $obj_definition
 
ilGlobalTemplateInterface $tpl
 
ilTree $tree
 
ilCtrl $ctrl
 
ilErrorHandling $error
 
ilLanguage $lng
 
ilTabsGUI $tabs_gui
 
ILIAS $ilias
 
ArrayBasedRequestWrapper $post_wrapper
 
RequestWrapper $request_wrapper
 
Refinery $refinery
 
ilFavouritesManager $favourites
 
CustomIconFactory $custom_icon_factory
 
UIFactory $ui_factory
 
UIRenderer $ui_renderer
 
Filesystem $temp_file_system
 
ilObject $object = null
 
bool $creation_mode = false
 
 $data
 
int $id
 
bool $call_by_reference = false
 
bool $prepare_output
 
int $ref_id
 
int $obj_id
 
int $maxcount
 
array $form_action = []
 
array $return_location = []
 
array $target_frame = []
 
string $tmp_import_dir
 
string $sub_objects = ""
 
bool $omit_locator = false
 
string $type = ""
 
string $admin_mode = self::ADMIN_MODE_NONE
 
int $requested_ref_id = 0
 
int $requested_crtptrefid = 0
 
int $requested_crtcb = 0
 
string $requested_new_type = ""
 
string $link_params
 
string $html = ""
 

Detailed Description

Class ilObjLanguageExtGUI.

This class is a replacement for ilObjLanguageGUI which is currently not used in ILIAS.

Author
Fred Neumann fred..nosp@m.neum.nosp@m.ann@f.nosp@m.im.u.nosp@m.ni-er.nosp@m.lang.nosp@m.en.de
Version
Id
class.ilObjLanguageExtGUI.php

@ilCtrl_Calls ilObjLanguageExtGUI: @ilCtrl_IsCalledBy ilObjLanguageExtGUI: ilDashboardGUI

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

Constructor & Destructor Documentation

◆ __construct()

ilObjLanguageExtGUI::__construct (   $a_data,
int  $a_id = 0,
bool  $a_call_by_reference = false 
)

Constructor.

Note: The GET param 'obj_id' is the language object id The GET param 'ref_id' is the language folder (if present)

Parameters
mixed$a_data(ignored) $a_id id (ignored) $a_call_by_reference call-by-reference (ignored)

Definition at line 70 of file class.ilObjLanguageExtGUI.php.

71 {
72 global $DIC;
73 $ilClientIniFile = $DIC->clientIni();
74 $ilCtrl = $DIC->ctrl();
75 $lng = $DIC->language();
76 $this->http = $DIC['http'];
77 $this->refinery = $DIC['refinery'];
78 $this->add_language_entry = $DIC[AddLanguageEntry::class];
79 $this->set_language_translation_enabled = $DIC[SetLanguageTranslationEnabled::class];
80 $this->remove_local_language_changes = $DIC[RemoveLocalLanguageChanges::class];
81 // used by activityErrorMessage() (see RendersActivityErrors)
82 $this->activity_error_logger = $DIC->logger()->lang();
83
84 // language maintenance strings are defined in administration
85 $lng->loadLanguageModule("administration");
86 $lng->loadLanguageModule("meta");
88
89 // view mode ('translate' or empty) determins available table filters
90 $ilCtrl->saveParameter($this, "view_mode");
91
92 // type and id of get the bound object
93 $this->type = "lng";
94 $obj_id_get = 0;
95
96 if ($this->http->wrapper()->query()->has("obj_id")) {
97 $obj_id_get = $this->http->wrapper()->query()->retrieve("obj_id", $this->refinery->kindlyTo()->int());
98 } elseif ($this->http->wrapper()->query()->has("language_folder_obj_ids")) {
99 $obj_id_get = $this->http->wrapper()->query()->retrieve("language_folder_obj_ids", $this->refinery->kindlyTo()->int());
100 }
101
102 if (!$this->id = $obj_id_get) {
104 }
105
106 // do all generic GUI initialisations
107 parent::__construct($a_data, $this->id, false, true);
108
109 // initialize the array to store session variables for extended language maintenance
110 if (!is_array($this->getSession())) {
111 ilSession::set("lang_ext_maintenance", array());
112 }
113
114 // read the lang mode
115 $this->langmode = $ilClientIniFile->readVariable("system", "LANGMODE");
116 }
loadLanguageModule(string $a_module)
Load language module.
getUserLanguage()
Return language of user.
static _lookupId(string $a_key)
Lookup the object ID for a language key.
ilLanguage $lng
static set(string $a_var, $a_val)
Set a value.
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, ilObjectGUI\$lng, ILIAS\GlobalScreen\Provider\__construct(), ilObjLanguageAccess\_lookupId(), getSession(), ilLanguage\getUserLanguage(), ILIAS\FileDelivery\http(), ilLanguage\loadLanguageModule(), ILIAS\Repository\refinery(), and ilSession\set().

+ Here is the call graph for this function:

Member Function Documentation

◆ addAdminLocatorItems()

ilObjLanguageExtGUI::addAdminLocatorItems ( bool  $do_not_add_object = false)
protected

Set the locator for admin mode (Overwritten from ilObjectGUI, called by prepareOutput)

Reimplemented from ilObjectGUI.

Definition at line 1180 of file class.ilObjLanguageExtGUI.php.

1180 : void
1181 {
1182 global $DIC;
1183 $ilLocator = $DIC["ilLocator"];
1184
1186 parent::addAdminLocatorItems(true); // #13881
1187
1188 $ilLocator->addItem(
1189 $this->lng->txt("languages"),
1190 $this->ctrl->getLinkTargetByClass("ilobjlanguagefoldergui", "")
1191 );
1192
1193 $ilLocator->addItem(
1194 $this->lng->txt("meta_l_" . $this->object->getTitle()),
1195 $this->ctrl->getLinkTarget($this, "view")
1196 );
1197 }
1198 }
static _isPageTranslation()
Check if the current request is a page translation.

References $DIC, ilObjLanguageAccess\_isPageTranslation(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ addNewEntryObject()

ilObjLanguageExtGUI::addNewEntryObject ( ?ilPropertyFormGUI  $a_form = null)

Definition at line 1247 of file class.ilObjLanguageExtGUI.php.

1247 : void
1248 {
1249 global $DIC;
1250 $tpl = $DIC["tpl"];
1251
1252 $id = "";
1253 if ($this->http->wrapper()->query()->has("eid")) {
1254 $id = trim($this->http->wrapper()->query()->retrieve("eid", $this->refinery->kindlyTo()->string()));
1255 }
1256 if (!$a_form) {
1257 $a_form = $this->initAddNewEntryForm($id);
1258 }
1259
1260 $tpl->setContent($a_form->getHTML());
1261 }
initAddNewEntryForm(?string $a_id=null)
ilGlobalTemplateInterface $tpl
setContent(string $a_html)
Sets content for standard template.

References $DIC, $id, ILIAS\News\Common\Table\$tpl, ILIAS\FileDelivery\http(), and ILIAS\UICore\GlobalTemplate\setContent().

+ Here is the call graph for this function:

◆ applyFilterObject()

ilObjLanguageExtGUI::applyFilterObject ( )

Apply filter.

Definition at line 542 of file class.ilObjLanguageExtGUI.php.

542 : void
543 {
544 $table_gui = $this->getViewTable();
545 $table_gui->writeFilterToSession(); // writes filter to session
546 $table_gui->resetOffset(); // sets record offest to 0 (first page)
547 $this->viewObject();
548 }
getViewTable()
Get the table to view language entries.
viewObject()
viewObject container presentation for "administration -> repository, trash, permissions"

◆ assignObject()

ilObjLanguageExtGUI::assignObject ( )
protected

Assign the extended language object.

Overwritten from ilObjectGUI to use the extended language object. (Will be deleted when ilObjLanguageExt is merged with ilObjLanguage)

Reimplemented from ilObjectGUI.

Definition at line 124 of file class.ilObjLanguageExtGUI.php.

124 : void
125 {
126 $this->object = new ilObjLanguageExt($this->id);
127 }
Class ilObjLanguageExt.

◆ buildMissingEntries()

ilObjLanguageExtGUI::buildMissingEntries ( ?array  $a_missing = null)
protected

Definition at line 1220 of file class.ilObjLanguageExtGUI.php.

1220 : string
1221 {
1222 global $DIC;
1223 $ilCtrl = $DIC->ctrl();
1224
1225 if (!count($a_missing)) {
1226 return '';
1227 }
1228
1229 $res = array("<h3>" . $this->lng->txt("adm_missing_entries") . "</h3>", "<ul>");
1230
1231 foreach ($a_missing as $entry) {
1232 $entry = (string) $entry;
1233 // ilCtrl only escapes "&" of a parameter value
1234 $ilCtrl->setParameter($this, "eid", $this->refinery->encode()->url()->transform($entry));
1235 $link = $this->refinery->encode()->htmlAttributeValue()->transform($ilCtrl->getLinkTarget($this, "addNewEntry"));
1236 $res[] = '<li>' . $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform($entry) .
1237 ' <a href="' . $link .
1238 '">' . $this->lng->txt("adm_missing_entry_add_action") . '</a></li>';
1239 $ilCtrl->setParameter($this, "eid", "");
1240 }
1241
1242 $res[] = "</ul>";
1243
1244 return implode("\n", $res);
1245 }
foreach($_POST as $key=> $value) $res

References $DIC, $res, ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ clearLocalChanges()

ilObjLanguageExtGUI::clearLocalChanges ( )
private

Maintenance action "clear": the same RemoveLocalLanguageChanges as "remove local changes" in the language list.

Definition at line 496 of file class.ilObjLanguageExtGUI.php.

496 : void
497 {
498 $result = $this->remove_local_language_changes->maybePerformAs(
499 $this->ui_factory->input(),
500 $this->user->getId(),
501 ['language_keys' => [$this->object->key]]
502 );
503 if ($result->isError()) {
504 $this->tpl->setOnScreenMessage(
505 'failure',
506 $this->lng->txt("language_error_clear_local") . '<br />' . $this->activityErrorMessage($result->error()),
507 true
508 );
509 return;
510 }
511 $value = $result->value();
512
513 if ($value['removed_local_changes_language_keys'] === []) {
514 // not installed or an invalid language file/shipped .po: nothing was changed
515 $unreadable_modules = $this->object->getUnreadableShippedPoModules();
516 $this->tpl->setOnScreenMessage(
517 'failure',
518 $unreadable_modules !== []
519 ? sprintf($this->lng->txt("lng_error_clear_shipped_po_unreadable"), implode(', ', $unreadable_modules))
520 : $this->lng->txt("language_error_clear_local"),
521 true
522 );
523 return;
524 }
525 if (($value['overlay_write_failed_language_keys'] ?? []) !== []) {
526 $this->tpl->setOnScreenMessage(
527 'failure',
528 $this->lng->txt("language_cleared_local") . '<br />' . sprintf(
529 $this->lng->txt("lng_po_overlay_not_written_languages"),
530 $this->lng->txt("meta_l_" . $this->object->key)
531 ),
532 true
533 );
534 return;
535 }
536 $this->tpl->setOnScreenMessage('success', $this->lng->txt("language_cleared_local"), true);
537 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ compareComments()

ilObjLanguageExtGUI::compareComments ( string  $compare,
array  $modules = [] 
)
private

Remarks (lng_data and overlay) plus, for PO modules without a remark, the shipped notes and "not translated yet" marker of the shipped .po (see ilObjLanguageExt::_getShippedMigratedComments()).

Parameters
list<string>$modules the displayed modules, all if empty
Returns
array<string, string> module.separator.topic => comment

Definition at line 465 of file class.ilObjLanguageExtGUI.php.

465 : array
466 {
467 return array_merge(
469 array_filter(
471 static fn(?string $remark): bool => $remark !== null && $remark !== ''
472 )
473 );
474 }
static _getShippedMigratedComments(string $a_lang_key, array $a_modules=[])
For display only (like getShippedCommentsForDisplay()), e.g.
static _getRemarks(string $a_lang_key, bool $a_all_changed=false)
Get all remarks of a language.

References ilObjLanguageExt\_getRemarks(), and ilObjLanguageExt\_getShippedMigratedComments().

+ Here is the call graph for this function:

◆ downloadObject()

ilObjLanguageExtGUI::downloadObject ( )

Download a language file.

Definition at line 819 of file class.ilObjLanguageExtGUI.php.

819 : void
820 {
821 $post_scope = $this->http->request()->getParsedBody()['scope'] ?? "";
822 // save the selected scope
823 $tmp["export"]["scope"] = ilUtil::stripSlashes($post_scope);
824 ilSession::set("lang_ext_maintenance", $tmp);
825
826 $pos = strpos(ILIAS_VERSION, " ");
827 $pos = $pos === false ? null : $pos;
828 $filename = "ilias_" . $this->object->key . '_'
829 . str_replace(".", "_", substr(ILIAS_VERSION, 0, $pos))
830 . "-" . gmdate("Y-m-d")
831 . ".lang." . $this->getSession()["export"]["scope"];
832
833 $global_file_obj = $this->object->getGlobalLanguageFile();
834 $local_file_obj = new ilLanguageFile($filename, $this->object->key, $post_scope);
835
836 if ($post_scope === "global") {
837 $local_file_obj->setParam("author", $global_file_obj->getParam("author"));
838 $local_file_obj->setParam("version", $global_file_obj->getParam("version"));
839 $local_file_obj->setAllValues($this->object->getAllValues());
840 if ($this->langmode) {
841 $local_file_obj->setAllComments($this->object->getEffectiveRemarks());
842 }
843 } elseif ($post_scope === "local") {
844 $local_file_obj->setParam("based_on", $global_file_obj->getParam("version"));
845 $local_file_obj->setAllValues($this->object->getChangedValues());
846 if ($this->langmode) {
847 $local_file_obj->setAllComments($this->object->getEffectiveRemarks());
848 }
849 } elseif ($post_scope === "added") { // langmode only
850 $local_file_obj->setParam("author", $global_file_obj->getParam("author"));
851 $local_file_obj->setParam("version", $global_file_obj->getParam("version"));
852 $local_file_obj->setAllValues($this->object->getAddedValues());
853 $local_file_obj->setAllComments($this->object->getEffectiveRemarks());
854 } elseif ($post_scope === "unchanged") {
855 $local_file_obj->setParam("author", $global_file_obj->getParam("author"));
856 $local_file_obj->setParam("version", $global_file_obj->getParam("version"));
857 $local_file_obj->setAllValues($this->object->getUnchangedValues());
858 if ($this->langmode) {
859 $local_file_obj->setAllComments($this->object->getEffectiveRemarks());
860 }
861 } elseif ($post_scope === "merged") { // langmode only
862 $local_file_obj->setParam("author", $global_file_obj->getParam("author"));
863 $local_file_obj->setParam("version", $global_file_obj->getParam("version"));
864 $local_file_obj->setAllValues($this->object->getMergedValues());
865 $local_file_obj->setAllComments($this->object->getMergedRemarks());
866 }
867
868 ilUtil::deliverData($local_file_obj->build(), $filename);
869 }
$filename
Definition: buildRTE.php:78
Class ilLanguageFile.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static deliverData(string $a_data, string $a_filename, string $mime="application/octet-stream")
const ILIAS_VERSION

References $filename, ilUtil\deliverData(), ILIAS\FileDelivery\http(), ILIAS_VERSION, ILIAS\Repository\object(), ilSession\set(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ duplicateIdentifierMessage()

ilObjLanguageExtGUI::duplicateIdentifierMessage ( array  $duplicates)
private

Names each entry with the entries it would duplicate, the full list goes to the log.

Parameters
array<string,list<string>>$duplicates key => "<module>: <identifier>"

Definition at line 756 of file class.ilObjLanguageExtGUI.php.

756 : string
757 {
758 $entries = [];
759 foreach ($duplicates as $key => $existing) {
760 $entries[] = DuplicateIdentifierMessage::entry((string) $key, $existing);
761 }
762 $this->activity_error_logger->warning(DuplicateIdentifierMessage::forLog($entries));
763
764 return DuplicateIdentifierMessage::of($this->lng, $this->refinery, $entries);
765 }

References $duplicates, ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ executeCommand()

ilObjLanguageExtGUI::executeCommand ( )

execute command

Reimplemented from ilObjectGUI.

Definition at line 159 of file class.ilObjLanguageExtGUI.php.

159 : void
160 {
161 global $DIC;
162 $ilHelp = $DIC->help();
163
165 $this->error->raiseError($this->lng->txt("permission_denied"), $this->error->MESSAGE);
166 exit;
167 }
168
169 $cmd = $this->ctrl->getCmd("view");
170 // exact match: ilCtrl compares the unsafe commands case-sensitively, PHP method calls are not
171 match ($cmd) {
172 'applyFilter',
173 'resetFilter',
174 'save',
175 'import',
176 'upload',
177 'export',
178 'download',
179 'maintain',
180 'maintainExecute',
181 'settings',
182 'saveSettings',
183 'statistics',
184 'addNewEntry',
185 'saveNewEntry' => $this->{$cmd . 'Object'}(),
186 default => $this->viewObject(),
187 };
188
189 $ilHelp->setScreenIdComponent("lng");
190 }
static _checkMaintenance()
Permission check for language maintenance (import/export)
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $DIC, ilObjLanguageAccess\_checkMaintenance(), ILIAS\Repository\ctrl(), exit, ILIAS\Repository\lng(), and ilObjectGUI\viewObject().

+ Here is the call graph for this function:

◆ exportObject()

ilObjLanguageExtGUI::exportObject ( )

Show the screen to export a language file.

Definition at line 781 of file class.ilObjLanguageExtGUI.php.

781 : void
782 {
783 $form = new ilPropertyFormGUI();
784 $form->setFormAction($this->ctrl->getFormAction($this));
785 $form->setTitle($this->lng->txt("language_export_file"));
786 $form->setPreventDoubleSubmission(false);
787 $form->addCommandButton("download", $this->lng->txt("download"));
788
789 $rg = new ilRadioGroupInputGUI($this->lng->txt("language_file_scope"), "scope");
790 $ro = new ilRadioOption($this->lng->txt("language_scope_global"), "global");
791 $ro->setInfo($this->lng->txt("language_scope_global_info"));
792 $rg->addOption($ro);
793 $ro = new ilRadioOption($this->lng->txt("language_scope_local"), "local");
794 $ro->setInfo($this->lng->txt("language_scope_local_info"));
795 $rg->addOption($ro);
796 if ($this->langmode) {
797 $ro = new ilRadioOption($this->lng->txt("language_scope_added"), "added");
798 $ro->setInfo($this->lng->txt("language_scope_added_info"));
799 $rg->addOption($ro);
800 }
801 $ro = new ilRadioOption($this->lng->txt("language_scope_unchanged"), "unchanged");
802 $ro->setInfo($this->lng->txt("language_scope_unchanged_info"));
803 $rg->addOption($ro);
804 if ($this->langmode) {
805 $ro = new ilRadioOption($this->lng->txt("language_scope_merged"), "merged");
806 $ro->setInfo($this->lng->txt("language_scope_merged_info"));
807 $rg->addOption($ro);
808 }
809
810 $rg->setValue($this->getSession()["export"]["scope"] ?? "global");
811 $form->addItem($rg);
812
813 $this->tpl->setContent($form->getHTML());
814 }
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getAdminTabs()

ilObjLanguageExtGUI::getAdminTabs ( )

Get tabs for admin mode (Overwritten from ilObjectGUI, called by prepareOutput)

Reimplemented from ilObjectGUI.

Definition at line 1113 of file class.ilObjLanguageExtGUI.php.

1113 : void
1114 {
1115 global $DIC;
1116 $ilCtrl = $DIC->ctrl();
1117 $cmd = $ilCtrl->getCmd();
1118
1120 $this->tabs_gui->setBackTarget(
1121 $this->lng->txt("back"),
1122 $this->ctrl->getLinkTargetByClass("ilObjLanguageFolderGUI")
1123 );
1124
1125 $this->ctrl->setParameter($this, "obj_id", $this->id);
1126 $this->tabs_gui->addTab(
1127 "edit",
1128 $this->lng->txt("edit"),
1129 $this->ctrl->getLinkTarget($this, "view")
1130 );
1131
1132 $this->tabs_gui->addTab(
1133 "export",
1134 $this->lng->txt('export'),
1135 $this->ctrl->getLinkTarget($this, "export")
1136 );
1137
1138 $this->tabs_gui->addTab(
1139 "import",
1140 $this->lng->txt("import"),
1141 $this->ctrl->getLinkTarget($this, "import")
1142 );
1143
1144 $this->tabs_gui->addTab(
1145 "maintain",
1146 $this->lng->txt("language_maintain"),
1147 $this->ctrl->getLinkTarget($this, "maintain")
1148 );
1149
1150 $this->tabs_gui->addTab(
1151 "settings",
1152 $this->lng->txt("settings"),
1153 $this->ctrl->getLinkTarget($this, "settings")
1154 );
1155
1156 $this->tabs_gui->addTab(
1157 "statistics",
1158 $this->lng->txt("language_statistics"),
1159 $this->ctrl->getLinkTarget($this, "statistics")
1160 );
1161
1162 switch ($cmd) {
1163 case "":
1164 case "view":
1165 case "applyFilter":
1166 case "resetFilter":
1167 case "save":
1168 $this->tabs_gui->activateTab("edit");
1169 break;
1170 default:
1171 $this->tabs_gui->activateTab($cmd);
1172 }
1173 }
1174 }

References $DIC, ilObjLanguageAccess\_isPageTranslation(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getId()

ilObjLanguageExtGUI::getId ( )

get the language object id (needed for filter serialization) Return language object id

Definition at line 133 of file class.ilObjLanguageExtGUI.php.

133 : int
134 {
135 return $this->id;
136 }

References ilObjectGUI\$id.

◆ getSafePostCommands()

ilObjLanguageExtGUI::getSafePostCommands ( )
Returns
list<string>

Implements ilCtrlSecurityInterface.

Definition at line 151 of file class.ilObjLanguageExtGUI.php.

151 : array
152 {
153 return [];
154 }

◆ getSession()

ilObjLanguageExtGUI::getSession ( )
private

Definition at line 1463 of file class.ilObjLanguageExtGUI.php.

1463 : array
1464 {
1465 return ilSession::get("lang_ext_maintenance") ?? [];
1466 }
static get(string $a_var)

References ilSession\get().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSuccessMessage()

ilObjLanguageExtGUI::getSuccessMessage ( )
protected

Get success message after variables were saved.

Definition at line 1454 of file class.ilObjLanguageExtGUI.php.

1454 : string
1455 {
1456 global $DIC;
1457 $f = $DIC->ui()->factory();
1458 $renderer = $DIC->ui()->renderer();
1459
1460 return $renderer->render($f->messageBox()->success($this->lng->txt("language_variables_saved")));
1461 }
$renderer

References $DIC, Vendor\Package\$f, and $renderer.

◆ getUnsafeGetCommands()

ilObjLanguageExtGUI::getUnsafeGetCommands ( )

Sent by GET (e.g.

a crafted link) these commands need the CSRF token as well; ilCtrl appends it to their link targets.

Returns
list<string>

Implements ilCtrlSecurityInterface.

Definition at line 143 of file class.ilObjLanguageExtGUI.php.

143 : array
144 {
145 return ['save', 'upload', 'maintainExecute', 'saveSettings', 'saveNewEntry'];
146 }

◆ getViewTable()

ilObjLanguageExtGUI::getViewTable ( )
protected

Get the table to view language entries.

Definition at line 195 of file class.ilObjLanguageExtGUI.php.

196 {
197 // create and configure the table object
198 $table_gui = new ilLanguageExtTableGUI($this, "view", array(
199 "langmode" => $this->langmode,
200 "lang_key" => $this->object->key,
201 ));
202
203 return $table_gui;
204 }

References ILIAS\Repository\object().

+ Here is the call graph for this function:

◆ importedMessage()

ilObjLanguageExtGUI::importedMessage ( string  $file_name)
private

The client-supplied file name ends up in HTML, so it is escaped.

Definition at line 770 of file class.ilObjLanguageExtGUI.php.

770 : string
771 {
772 return sprintf(
773 $this->lng->txt("language_file_imported"),
774 $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform($file_name)
775 );
776 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ importObject()

ilObjLanguageExtGUI::importObject ( )

Show the screen to import a language file.

Definition at line 630 of file class.ilObjLanguageExtGUI.php.

630 : void
631 {
632 $form = $this->initNewImportForm();
633 $this->tpl->setContent($form->getHTML());
634 }

◆ initAddNewEntryForm()

ilObjLanguageExtGUI::initAddNewEntryForm ( ?string  $a_id = null)
protected

Definition at line 1263 of file class.ilObjLanguageExtGUI.php.

1264 {
1265 global $DIC;
1266 $ilCtrl = $DIC->ctrl();
1267
1268 if (!$a_id) {
1269 $a_id = $this->http->request()->getParsedBody()['id'] ?? "";
1270 }
1271
1272 if (!$a_id ||
1273 !in_array($a_id, ilObjLanguageAccess::_getSavedTopics())) {
1274 $ilCtrl->redirect($this, "view");
1275 }
1276
1277 $form = new ilPropertyFormGUI();
1278 $form->setFormAction($ilCtrl->getFormAction($this, "saveNewEntry"));
1279 $form->setTitle($this->lng->txt("adm_missing_entry_add"));
1280
1282 $options = array_combine($mods, $mods);
1283
1284 $mod = new ilSelectInputGUI(ucfirst($this->lng->txt("module")), "mod");
1285 $mod->setOptions(array("" => $this->lng->txt("please_select")) + $options);
1286 $mod->setRequired(true);
1287 $form->addItem($mod);
1288
1289 $id = new ilTextInputGUI(ucfirst($this->lng->txt("identifier")), "id");
1290 $id->setValue($a_id);
1291 $id->setDisabled(true);
1292 $form->addItem($id);
1293
1294 foreach ($this->lng->getInstalledLanguages() as $lang_key) {
1295 $trans = new ilTextInputGUI($this->lng->txt("meta_l_" . $lang_key), "trans_" . $lang_key);
1296 if (in_array($lang_key, array("de", "en"))) {
1297 $trans->setRequired(true);
1298 }
1299 $form->addItem($trans);
1300 }
1301
1302 $form->addCommandButton("saveNewEntry", $this->lng->txt("save"));
1303 $form->addCommandButton("view", $this->lng->txt("cancel"));
1304
1305 return $form;
1306 }
static _getSavedTopics()
Get the stored topics from the user session.
static _getSavedModules()
Get the stored modules from the user session.
This class represents a selection list property in a property form.
This class represents a text property in a property form.

References $DIC, $id, ILIAS\UI\Implementation\Component\Input\Field\$options, ilObjLanguageAccess\_getSavedModules(), ilObjLanguageAccess\_getSavedTopics(), ILIAS\FileDelivery\http(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ initNewImportForm()

ilObjLanguageExtGUI::initNewImportForm ( )
protected

Definition at line 636 of file class.ilObjLanguageExtGUI.php.

637 {
638 $form = new ilPropertyFormGUI();
639 $form->setFormAction($this->ctrl->getFormAction($this));
640 $form->setTitle($this->lng->txt("language_import_file"));
641 $form->addCommandButton("upload", $this->lng->txt("upload"));
642
643 $fu = new ilFileInputGUI($this->lng->txt("file"), "userfile");
644 $fu->setRequired(true);
645 $form->addItem($fu);
646
647 $rg = new ilRadioGroupInputGUI($this->lng->txt("language_mode_existing"), "mode_existing");
648 $ro = new ilRadioOption($this->lng->txt("language_mode_existing_keepall"), "keepall");
649 $ro->setInfo($this->lng->txt("language_mode_existing_keepall_info"));
650 $rg->addOption($ro);
651 $ro = new ilRadioOption($this->lng->txt("language_mode_existing_keepnew"), "keepnew");
652 $ro->setInfo($this->lng->txt("language_mode_existing_keepnew_info"));
653 $rg->addOption($ro);
654 $ro = new ilRadioOption($this->lng->txt("language_mode_existing_replace"), "replace");
655 $ro->setInfo($this->lng->txt("language_mode_existing_replace_info"));
656 $rg->addOption($ro);
657 $ro = new ilRadioOption($this->lng->txt("language_mode_existing_delete"), "delete");
658 $ro->setInfo($this->lng->txt("language_mode_existing_delete_info"));
659 $rg->addOption($ro);
660 $rg->setValue($this->getSession()["import"]["mode_existing"] ?? "keepall");
661 $form->addItem($rg);
662
663 return $form;
664 }
This class represents a file property in a property form.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ initNewSettingsForm()

ilObjLanguageExtGUI::initNewSettingsForm ( )
protected

Definition at line 1074 of file class.ilObjLanguageExtGUI.php.

1075 {
1076 global $DIC;
1077 $ilSetting = $DIC->settings();
1078 $translate_key = "lang_translate_" . $this->object->key;
1079 $translate = (bool) $ilSetting->get($translate_key, '0');
1080
1081 $form = new ilPropertyFormGUI();
1082 $form->setFormAction($this->ctrl->getFormAction($this));
1083 $form->setTitle($this->lng->txt("language_settings"));
1084 $form->setPreventDoubleSubmission(false);
1085 $form->addCommandButton('saveSettings', $this->lng->txt("language_change_settings"));
1086
1087 $ci = new ilCheckboxInputGUI($this->lng->txt("language_translation_enabled"), "translation");
1088 $ci->setChecked($translate);
1089 $ci->setInfo($this->lng->txt("language_note_translation"));
1090 $form->addItem($ci);
1091
1092 return $form;
1093 }
This class represents a checkbox property in a property form.
global $ilSetting
Definition: privfeed.php:26

References $DIC, $ilSetting, ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ invalidMarkupMessage()

ilObjLanguageExtGUI::invalidMarkupMessage ( array  $invalid_values)
private

The English violations go to the log, see InvalidMarkupMessage.

Parameters
array<string,list<string>>$invalid_values key => violations

Definition at line 735 of file class.ilObjLanguageExtGUI.php.

735 : string
736 {
737 global $DIC;
738
739 $logged = [];
740 foreach ($invalid_values as $key => $violations) {
741 $logged[] = $violations === [] ? (string) $key : sprintf('%s (%s)', $key, implode('; ', $violations));
742 }
743 $DIC->logger()->forComponent('lang')->warning(PlainLogText::of(sprintf(
744 'Language entries rejected or not applied, their value contains markup that is not allowed: %s',
745 implode(', ', $logged)
746 )));
747
748 return InvalidMarkupMessage::of($this->lng, $this->refinery, $invalid_values);
749 }

References $DIC, ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ maintainExecuteObject()

ilObjLanguageExtGUI::maintainExecuteObject ( )

Definition at line 909 of file class.ilObjLanguageExtGUI.php.

909 : void
910 {
911 $post_maintain = $this->http->request()->getParsedBody()['maintain'] ?? "";
912 if (isset($post_maintain)) {
913 $tmp["maintain"] = ilUtil::stripSlashes($post_maintain);
914 ilSession::set("lang_ext_maintenance", $tmp);
915 }
916
917 // developer-mode actions are also refused when sent directly
918 if (in_array($post_maintain, ['delete_added', 'merge', 'remove_local_file'], true) && !$this->langmode) {
919 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("permission_denied"), true);
920 $this->ctrl->redirect($this, "maintain");
921 return;
922 }
923
924 switch ($post_maintain) {
925 // save the global language file for merge after
926 case "save_dist":
927 // save a copy of the distributed language file
928 $orig_file = $this->object->getLangPath() . "/ilias_" . $this->object->key . ".lang";
929 $copy_file = $this->object->getDataPath() . "/ilias_" . $this->object->key . ".lang";
930 // the shipped .po of PO modules too, for the filter "conflicts"
931 if (@copy($orig_file, $copy_file) && $this->object->backupShippedPoFiles($this->object->getDataPath()) === []) {
932 $this->tpl->setOnScreenMessage('success', $this->lng->txt("language_saved_dist"), true);
933 } else {
934 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("language_save_dist_failed"), true);
935 }
936 break;
937
938 // load the content of the local language file
939 case "load":
940 $lang_file = $this->object->getCustLangPath() . "/ilias_" . $this->object->key . ".lang.local";
941 if (is_file($lang_file) and is_readable($lang_file)) {
942 // values with disallowed markup (like at installation) and duplicates are left out and named
943 $modules_with_unwritten_overlay = $this->object->importLanguageFile($lang_file, "replace", true);
944 $this->object->setLocal(true);
945 $skipped = [];
946 if ($this->object->getSkippedInvalidMarkupValues() !== []) {
947 $skipped[] = $this->invalidMarkupMessage($this->object->getSkippedInvalidMarkupValues());
948 }
949 if ($this->object->getSkippedDuplicateValues() !== []) {
950 $skipped[] = $this->duplicateIdentifierMessage($this->object->getSkippedDuplicateValues());
951 }
952 if ($skipped !== [] && $modules_with_unwritten_overlay === []) {
953 $this->tpl->setOnScreenMessage('success', $this->lng->txt("language_loaded_local"), true);
954 $this->tpl->setOnScreenMessage('failure', implode('<br />', $skipped), true);
955 } elseif ($skipped !== []) {
956 // one failure box only: overlay warning and left-out entries together
957 $this->tpl->setOnScreenMessage('failure', implode('<br />', [
958 $this->lng->txt("language_loaded_local"),
959 $this->overlayNotWrittenMessage($modules_with_unwritten_overlay),
960 ...$skipped,
961 ]), true);
962 } else {
963 $this->setSuccessOrOverlayWarning($this->lng->txt("language_loaded_local"), $modules_with_unwritten_overlay);
964 }
965 } else {
966 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("language_error_read_local"), true);
967 }
968 break;
969
970 // same Activity as ilObjLanguageFolderGUI::uninstallChangesObject()
971 case "clear":
972 $this->clearLocalChanges();
973 break;
974
975 // delete local additions in the datavase (langmode only)
976 case "delete_added":
977 $modules_with_unwritten_overlay = ilObjLanguageExt::_deleteValues(
978 $this->object->key,
979 $this->object->getAddedValues()
980 );
981 if ($modules_with_unwritten_overlay !== []) {
982 $this->tpl->setOnScreenMessage(
983 'failure',
984 $this->overlayNotWrittenMessage($modules_with_unwritten_overlay),
985 true
986 );
987 }
988 break;
989
990 // merge local changes into the global language file and the shipped .po (langmode only)
991 case "merge":
992 $orig_file = $this->object->getLangPath() . "/ilias_" . $this->object->key . ".lang";
993 $copy_file = $this->object->getCustLangPath() . "/ilias_" . $this->object->key . ".lang";
994
995 // ShippedPoMerger checks the shipped .po itself and reports the modules it cannot write
996 $global_file_writable = is_file($orig_file) && is_writable($orig_file);
997 if ($global_file_writable) {
998 @copy($orig_file, $copy_file);
999 }
1000 $result = $this->object->mergeLocalChangesIntoGlobalLanguageFile($global_file_writable);
1001 $this->mergeMessages(
1002 $result,
1003 $global_file_writable,
1004 // a read-only global file is only an error if there was something to write into it
1005 !$global_file_writable && $this->object->hasLocalChangesOutsidePoModules()
1006 );
1007 break;
1008
1009 // remove the local language file (langmode only)
1010 case "remove_local_file":
1011 $lang_file = $this->object->getCustLangPath() . "/ilias_" . $this->object->key . ".lang.local";
1012
1013 if (!is_file($lang_file)) {
1014 $this->object->setLocal(false);
1015 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("language_error_local_missed"), true);
1016 } elseif (@unlink($lang_file)) {
1017 $this->object->setLocal(false);
1018 $this->tpl->setOnScreenMessage('success', $this->lng->txt("language_local_file_deleted"), true);
1019 } else {
1020 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("language_error_delete_local"), true);
1021 }
1022 break;
1023 }
1024
1025 $this->ctrl->redirect($this, "maintain");
1026 }
mergeMessages(array $result, bool $global_file_written, bool $global_file_not_written)
Success, plus everything that failed or was left out in one failure message (setOnScreenMessage() kee...
duplicateIdentifierMessage(array $duplicates)
Names each entry with the entries it would duplicate, the full list goes to the log.
invalidMarkupMessage(array $invalid_values)
The English violations go to the log, see InvalidMarkupMessage.
setSuccessOrOverlayWarning(string $success_message, array $modules_with_unwritten_overlay)
A success message, or a warning if PO/MO files could not be written (the database was written,...
overlayNotWrittenMessage(array $modules_with_unwritten_overlay)
clearLocalChanges()
Maintenance action "clear": the same RemoveLocalLanguageChanges as "remove local changes" in the lang...
static _deleteValues(string $a_lang_key, array $a_values=array())
Delete a set of translation in the database.

References ilObjLanguageExt\_deleteValues(), ILIAS\UI\examples\Symbol\Glyph\Copy\copy(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilSession\set(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ maintainObject()

ilObjLanguageExtGUI::maintainObject ( )

Process the language maintenance.

Definition at line 874 of file class.ilObjLanguageExtGUI.php.

874 : void
875 {
876 $form = new ilPropertyFormGUI();
877 $form->setFormAction($this->ctrl->getFormAction($this));
878 $form->setTitle($this->lng->txt("language_maintenance"));
879 $form->setPreventDoubleSubmission(false);
880 $form->addCommandButton("maintainExecute", $this->lng->txt("language_process_maintenance"));
881
882 $rg = new ilRadioGroupInputGUI($this->lng->txt("language_maintain_local_changes"), "maintain");
883 $ro = new ilRadioOption($this->lng->txt("language_load_local_changes"), "load");
884 $ro->setInfo(sprintf($this->lng->txt("language_load_local_changes_info"), $this->object->key));
885 $rg->addOption($ro);
886 $ro = new ilRadioOption($this->lng->txt("language_clear_local_changes"), "clear");
887 $ro->setInfo(sprintf($this->lng->txt("language_clear_local_changes_info"), $this->object->key));
888 $rg->addOption($ro);
889 if ($this->langmode) {
890 $ro = new ilRadioOption($this->lng->txt("language_delete_local_additions"), "delete_added");
891 $ro->setInfo(sprintf($this->lng->txt("language_delete_local_additions_info"), $this->object->key));
892 $rg->addOption($ro);
893 $ro = new ilRadioOption($this->lng->txt("language_remove_local_file"), "remove_local_file");
894 $ro->setInfo(sprintf($this->lng->txt("language_remove_local_file_info"), $this->object->key));
895 $rg->addOption($ro);
896 $ro = new ilRadioOption($this->lng->txt("language_merge_local_changes"), "merge");
897 $ro->setInfo(sprintf($this->lng->txt("language_merge_local_changes_info"), $this->object->key));
898 $rg->addOption($ro);
899 }
900 $ro = new ilRadioOption($this->lng->txt("language_save_dist"), "save_dist");
901 $ro->setInfo(sprintf($this->lng->txt("language_save_dist_info"), $this->object->key));
902 $rg->addOption($ro);
903 $rg->setValue($this->getSession()["maintain"] ?? "load");
904 $form->addItem($rg);
905
906 $this->tpl->setContent($form->getHTML());
907 }

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ mergeMessages()

ilObjLanguageExtGUI::mergeMessages ( array  $result,
bool  $global_file_written,
bool  $global_file_not_written 
)
private

Success, plus everything that failed or was left out in one failure message (setOnScreenMessage() keeps one per type), or an info if nothing was written at all; details are in the log.

Parameters
array{writtenlist<string>, skipped: list<string>, invalid_markup: array<string, list<string>>, not_merged: list<string>, unwritten_database: list<string>} $result
bool$global_file_not_writtenthe global language file had local changes to take but is not writable

Definition at line 1399 of file class.ilObjLanguageExtGUI.php.

1399 : void
1400 {
1401 $escape = fn(string $text): string => $this->refinery->encode()->htmlSpecialCharsAsEntities()->transform($text);
1402 $successes = $global_file_written ? [$this->lng->txt("language_merged_global")] : [];
1403 if ($result['written'] !== []) {
1404 $successes[] = sprintf(
1405 $this->lng->txt("lng_merged_po_modules"),
1406 $escape(implode(', ', $result['written']))
1407 );
1408 }
1409 if ($successes !== []) {
1410 $this->tpl->setOnScreenMessage('success', implode('<br />', $successes), true);
1411 }
1412
1413 $failures = $global_file_not_written ? [$this->lng->txt("language_error_write_global")] : [];
1414 if ($result['skipped'] !== []) {
1415 // not written at all (e.g. no write permission): an error, not an intended skip
1416 $failures[] = sprintf(
1417 $this->lng->txt("lng_merge_po_not_written"),
1418 $escape(implode(', ', $result['skipped']))
1419 );
1420 }
1421 if ($result['invalid_markup'] !== []) {
1422 $failures[] = $this->invalidMarkupMessage($result['invalid_markup']);
1423 }
1424 if ($result['not_merged'] !== []) {
1425 $failures[] = $this->lng->txt("form_input_not_valid") . ' ' . $escape(PlainLogText::keyList($result['not_merged']));
1426 }
1427 if ($result['unwritten_database'] !== []) {
1428 $failures[] = sprintf(
1429 $this->lng->txt("lng_merge_database_not_updated"),
1430 $escape(implode(', ', $result['unwritten_database']))
1431 );
1432 }
1433 if ($failures !== []) {
1434 $this->tpl->setOnScreenMessage('failure', implode('<br />', $failures), true);
1435 } elseif ($successes === []) {
1436 $this->tpl->setOnScreenMessage('info', $this->lng->txt("lng_merge_nothing_to_merge"), true);
1437 }
1438 }
$text
Definition: xapiexit.php:21

References $text, ILIAS\Repository\lng(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ overlayNotWrittenMessage()

ilObjLanguageExtGUI::overlayNotWrittenMessage ( array  $modules_with_unwritten_overlay)
private
Parameters
list<string>$modules_with_unwritten_overlay

Definition at line 1443 of file class.ilObjLanguageExtGUI.php.

1443 : string
1444 {
1445 return sprintf(
1446 $this->lng->txt("lng_po_overlay_not_written"),
1447 implode(', ', $modules_with_unwritten_overlay)
1448 );
1449 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ remarkOf()

ilObjLanguageExtGUI::remarkOf ( array  $comments,
string  $name 
)
private

A form of a plural message without a comment of its own gets the one of its identifier (see PluralFormKey).

Parameters
array<string,string|null>$comments

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

482 : string
483 {
484 if (($comments[$name] ?? '') !== '') {
485 return (string) $comments[$name];
486 }
487 $keys = explode($this->lng->separator, $name, 2);
488 $identifier = PluralFormKey::parse($keys[1] ?? '')[0] ?? null;
489
490 return $identifier === null ? '' : (string) ($comments[$keys[0] . $this->lng->separator . $identifier] ?? '');
491 }
$comments

References $comments, and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ resetFilterObject()

ilObjLanguageExtGUI::resetFilterObject ( )

Reset filter.

Definition at line 553 of file class.ilObjLanguageExtGUI.php.

553 : void
554 {
555 $table_gui = $this->getViewTable();
556 $table_gui->resetOffset(); // sets record offest to 0 (first page)
557 $table_gui->resetFilter(); // clears filter
558 $this->viewObject();
559 }

◆ saveNewEntryObject()

ilObjLanguageExtGUI::saveNewEntryObject ( )

Definition at line 1308 of file class.ilObjLanguageExtGUI.php.

1308 : void
1309 {
1310 $ilCtrl = $this->ctrl;
1311 $ilUser = $this->user;
1312
1313 $form = $this->initAddNewEntryForm();
1314 if ($form->checkInput()) {
1315 $mod = $form->getInput("mod");
1316 $id = $form->getInput("id");
1317
1318 // a language left blank is skipped by AddLanguageEntry
1319 $translations = [];
1320 foreach ($this->lng->getInstalledLanguages() as $lang_key) {
1321 $translations[$lang_key] = trim((string) $form->getInput("trans_" . $lang_key));
1322 }
1323
1324 $result = $this->add_language_entry->maybePerformAs(
1325 $this->ui_factory->input(),
1326 $ilUser->getId(),
1327 [
1328 'module' => $mod,
1329 'identifier' => $id,
1330 'translations' => $translations,
1331 ]
1332 );
1333
1334 if ($result->isError()) {
1335 $error = $result->error();
1336 $error_message = $this->activityErrorMessage($error);
1337
1338 if ($this->isActivityInputError($error)) {
1339 // input rejection (e.g. blank "de"/"en"): re-render the form, keeping the entered values
1340 $this->tpl->setOnScreenMessage('failure', $error_message);
1341 $form->setValuesByPost();
1342 $this->addNewEntryObject($form);
1343 return;
1344 }
1345
1346 // unexpected failure (logged by activityErrorMessage()): redirect, like every other Activity error path
1347 $this->tpl->setOnScreenMessage('failure', $error_message, true);
1348 $ilCtrl->redirect($this, "view");
1349 return;
1350 }
1351
1352 $overlay_write_failed_language_keys = $result->value()['overlay_write_failed_language_keys'] ?? [];
1353 if ($overlay_write_failed_language_keys !== []) {
1354 $this->tpl->setOnScreenMessage(
1355 'failure',
1356 sprintf(
1357 $this->lng->txt("lng_po_overlay_not_written_languages"),
1358 implode(', ', $overlay_write_failed_language_keys)
1359 ),
1360 true
1361 );
1362 } else {
1363 $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
1364 }
1365 $ilCtrl->redirect($this, "view");
1366 return;
1367 }
1368
1369 $form->setValuesByPost();
1370 $this->addNewEntryObject($form);
1371 }
addNewEntryObject(?ilPropertyFormGUI $a_form=null)
ilErrorHandling $error
activityErrorMessage(\Throwable $error)
Turns a maybePerformAs() error into text for setOnScreenMessage() (which renders HTML unescaped):
isActivityInputError(\Throwable $error)
A 4xx other than 403: the call itself was rejected, its message is meant for the caller.

References $id, ILIAS\Language\activityErrorMessage(), ILIAS\Language\isActivityInputError(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ saveObject()

ilObjLanguageExtGUI::saveObject ( )

Save the changed translations.

Reimplemented from ilObjectGUI.

Definition at line 564 of file class.ilObjLanguageExtGUI.php.

564 : void
565 {
566 // no changes have been made yet
567 $changesSuccessBool = 0;
568 // prepare the values to be saved
569 $save_array = array();
570 $remarks_array = array();
571 $post = (array) ($this->http->request()->getParsedBody() ?? []);
572 foreach ($post as $key => $value) {
573 $orginal_key = $key;
574 // mantis #25237
575 // @see https://php.net/manual/en/language.variables.external.php
576 $key = str_replace(
577 ["_POSTDOT_", "_POSTSPACE_", "_POSTLBRACKET_", "_POSTRBRACKET_"],
578 [".", " ", "[", "]"],
579 $key
580 );
581
582 // example key of variable: 'common#:#access'
583 // example key of comment: 'common#:#access#:#comment'
584 $keys = explode($this->lng->separator, ilUtil::stripSlashes($key));
585
586 // only strings: a parameter sent as array (e.g. "common#:#access[]") is no value
587 if (count($keys) === 2 && is_string($value)) {
588 // avoid line breaks
589 $value = preg_replace("/(\015\012)|(\015)|(\012)/", "<br />", $value);
590 $value = str_replace("<<", "«", $value);
591 // markup is checked below (TranslationMarkupPolicy), not stripped
592 $save_array[$key] = $value;
593
594 // the comment has the key of the language with the suffix
595 $remark = $post[$orginal_key . $this->lng->separator . "comment"] ?? null;
596 $remarks_array[$key] = is_string($remark) ? $remark : null;
597 }
598 }
599
600 // nothing is saved if any changed value has disallowed markup; all affected keys are named
601 $invalid_values = ilObjLanguageExt::findInvalidMarkupOfChangedValues($this->object->key, $save_array);
602 if ($invalid_values !== []) {
603 // shown again with the input of this save, so nothing typed in is lost
604 $this->viewObject(
605 0,
606 [],
607 [$this->invalidMarkupMessage($invalid_values)],
608 $save_array,
609 array_map(
610 static fn(mixed $remark): string => (string) $remark,
611 array_filter($remarks_array, static fn(mixed $remark): bool => $remark !== null)
612 )
613 );
614 return;
615 }
616
617 // save the translations
618 $modules_with_unwritten_overlay = ilObjLanguageExt::_saveValues($this->object->key, $save_array, $remarks_array);
619
620 // set successful changes bool to true;
621 $changesSuccessBool = 1;
622
623 // view the list
624 $this->viewObject($changesSuccessBool, $modules_with_unwritten_overlay);
625 }
static findInvalidMarkupOfChangedValues(string $a_lang_key, array $values)
The values a save into $a_lang_key would change and that contain markup TranslationMarkupPolicy does ...
static _saveValues(string $a_lang_key, array $a_values=array(), array $a_remarks=array())
Save a set of translation in the database.

References ilObjLanguageExt\_saveValues(), ilObjLanguageExt\findInvalidMarkupOfChangedValues(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\object(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ saveSettingsObject()

ilObjLanguageExtGUI::saveSettingsObject ( )

Set the language settings - see SetLanguageTranslationEnabled.

An unchecked checkbox is not submitted, so a missing/empty "translation" means "disabled".

Definition at line 1042 of file class.ilObjLanguageExtGUI.php.

1042 : void
1043 {
1044 $ilUser = $this->user;
1045
1046 $post_translation = $this->http->request()->getParsedBody()['translation'] ?? null;
1047 $enabled = $post_translation !== null && $post_translation !== '';
1048
1049 $result = $this->set_language_translation_enabled->maybePerformAs(
1050 $this->ui_factory->input(),
1051 $ilUser->getId(),
1052 [
1053 'language_key' => $this->object->key,
1054 'enabled' => $enabled,
1055 ]
1056 );
1057
1058 if ($result->isError()) {
1059 $error = $result->error();
1060 $error_message = $this->activityErrorMessage($error);
1061
1062 $this->tpl->setOnScreenMessage('failure', $error_message);
1063 } elseif ($result->value()['changed']) {
1064 // only shown if the value changed
1065 $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"));
1066 }
1067
1068 $form = $this->initNewSettingsForm();
1069
1070 // rendered directly with a non-persisted message, no redirect (unlike installObject() & Co.)
1071 $this->tpl->setContent($form->getHTML());
1072 }

References ILIAS\Language\activityErrorMessage(), ILIAS\FileDelivery\http(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ setSuccessOrOverlayWarning()

ilObjLanguageExtGUI::setSuccessOrOverlayWarning ( string  $success_message,
array  $modules_with_unwritten_overlay 
)
private

A success message, or a warning if PO/MO files could not be written (the database was written, the web server keeps serving the previous content).

Parameters
list<string>$modules_with_unwritten_overlay

Definition at line 1379 of file class.ilObjLanguageExtGUI.php.

1379 : void
1380 {
1381 if ($modules_with_unwritten_overlay === []) {
1382 $this->tpl->setOnScreenMessage('success', $success_message, true);
1383 return;
1384 }
1385 $this->tpl->setOnScreenMessage(
1386 'failure',
1387 $success_message . '<br />' . $this->overlayNotWrittenMessage($modules_with_unwritten_overlay),
1388 true
1389 );
1390 }

◆ settingsObject()

ilObjLanguageExtGUI::settingsObject ( )

View the language settings.

Definition at line 1031 of file class.ilObjLanguageExtGUI.php.

1031 : void
1032 {
1033 $form = $this->initNewSettingsForm();
1034 $this->tpl->setContent($form->getHTML());
1035 }

◆ setTitleAndDescription()

ilObjLanguageExtGUI::setTitleAndDescription ( )
protected

Set the Title and the description (Overwritten from ilObjectGUI, called by prepareOutput)

Reimplemented from ilObjectGUI.

Definition at line 1204 of file class.ilObjLanguageExtGUI.php.

1204 : void
1205 {
1207 $this->tpl->setHeaderPageTitle($this->lng->txt("translation"));
1208 $this->tpl->setTitle($this->lng->txt("translation") . " " . $this->lng->txt("meta_l_" . $this->object->key));
1209 } else {
1210 $this->tpl->setTitle($this->lng->txt("meta_l_" . $this->object->key));
1211 }
1212 $this->tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_lngf.svg"), $this->lng->txt("obj_" . $this->object->getType()));
1213 }
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)

References ilObjLanguageAccess\_isPageTranslation(), ilUtil\getImagePath(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ statisticsObject()

ilObjLanguageExtGUI::statisticsObject ( )

Print out statistics about the language.

Definition at line 1098 of file class.ilObjLanguageExtGUI.php.

1098 : void
1099 {
1100 $statisticsTable = (new ilLanguageStatisticsTable(
1101 $this->object,
1102 $this->ui_factory,
1103 $this->lng
1104 ))->getTable();
1105
1106 $this->tpl->setContent($this->ui_renderer->render($statisticsTable->withRequest($this->request)));
1107 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ uploadObject()

ilObjLanguageExtGUI::uploadObject ( )

Process an uploaded language file.

Definition at line 669 of file class.ilObjLanguageExtGUI.php.

669 : void
670 {
671 global $DIC;
672
673 $form = $this->initNewImportForm();
674 if ($form->checkInput()) {
675 $post_mode_existing = $this->http->request()->getParsedBody()['mode_existing'] ?? "";
676 // save form inputs for next display
677 $tmp["import"]["mode_existing"] = ilUtil::stripSlashes($post_mode_existing);
678 ilSession::set("lang_ext_maintenance", $tmp);
679 try {
680 $upload = $DIC->upload();
681 //mantis #41617
682 if (!$upload->hasBeenProcessed()) {
683 $upload->process();
684 }
685
686
687 // code 400: shown escaped by activityErrorMessage()
688 if (!$upload->hasUploads()) {
689 throw new ilException($DIC->language()->txt("upload_error_file_not_found"), 400);
690 }
691 $UploadResult = $upload->getResults()[$_FILES["userfile"]["tmp_name"]];
692
693 $ProcessingStatus = $UploadResult->getStatus();
694 if ($ProcessingStatus->getCode() === ProcessingStatus::REJECTED) {
695 throw new ilException($ProcessingStatus->getMessage(), 400);
696 }
697
698 // todo: refactor when importLanguageFile() is able to work with the new Filesystem service
699 $tempfile = ilFileUtils::ilTempnam() . ".sec";
700 $upload->moveOneFileTo($UploadResult, '', Location::TEMPORARY, basename($tempfile), true);
701 try {
702 $modules_with_unwritten_overlay = $this->object->importLanguageFile($tempfile, $post_mode_existing);
703 } finally {
704 $tempfs = $DIC->filesystem()->temp();
705 $tempfs->delete(basename($tempfile));
706 }
708 $this->tpl->setOnScreenMessage('failure', $this->invalidMarkupMessage($e->getInvalidValues()), true);
709 $this->ctrl->redirect($this, 'import');
711 $this->tpl->setOnScreenMessage('failure', $this->duplicateIdentifierMessage($e->getDuplicates()), true);
712 $this->ctrl->redirect($this, 'import');
713 } catch (Exception $e) {
714 // anything else may carry SQL: logged, a generic message shown
715 $this->tpl->setOnScreenMessage('failure', $this->activityErrorMessage($e), true);
716 $this->ctrl->redirect($this, 'import');
717 }
718
720 $this->importedMessage((string) ($_FILES["userfile"]["name"] ?? '')),
721 $modules_with_unwritten_overlay
722 );
723 $this->ctrl->redirect($this, "import");
724 }
725
726 $form->setValuesByPost();
727 $this->tpl->setContent($form->getHTML());
728 }
Base class for ILIAS Exception handling.
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
Thrown by ilObjLanguageExt::importLanguageFile() before anything is written, when entries would dupli...
Thrown by a local write path of language entries (e.g.
importedMessage(string $file_name)
The client-supplied file name ends up in HTML, so it is escaped.

References $DIC, Vendor\Package\$e, ILIAS\Language\activityErrorMessage(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ilFileUtils\ilTempnam(), ilSession\set(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ viewObject()

ilObjLanguageExtGUI::viewObject ( int  $changesSuccessBool = 0,
array  $modules_with_unwritten_overlay = [],
array  $additional_failure_messages = [],
array  $posted_values = [],
array  $posted_remarks = [] 
)

Show the edit screen.

Parameters
list<string>$modules_with_unwritten_overlay after saving: modules whose PO/MO files could not be written (see ilObjLanguageExt::_saveValues()); a warning replaces the success message
list<string>$additional_failure_messages HTML, shown together with the failure messages of this view
array<string,string>$posted_values module.separator.topic => value shown instead of the stored one (rejected save)
array<string,string>$posted_remarks module.separator.topic => remark, like $posted_values

Definition at line 216 of file class.ilObjLanguageExtGUI.php.

222 : void {
223 global $DIC;
224 $tpl = $DIC["tpl"];
225
226 // get the view table
227 $table_gui = $this->getViewTable();
228
229 // see ilObjLanguageExt::getEffectiveRemarks()
230 $comments = $this->object->getEffectiveRemarks();
231
232 $compare_comments = [];
233 $missing_entries = [];
234
235 // set the language to compare with
236 // get the default values if the compare language is the same
237 $compare = $table_gui->getFilterItemByPostVar("compare")->getValue();
238 if ($compare == $this->object->key) {
239 $compare_content = $this->object->getShippedValues();
240 $compare_comments = $this->object->getShippedCommentsForDisplay();
241 }
242
243 // page translation mode:
244 // - the table is filtered by a list of modules and topics
246 // get the selection of modules and topics from request or session
249
250 $reset_offset_get = false;
251 if ($this->http->wrapper()->query()->has("reset_offset")) {
252 $reset_offset_get = $this->http->wrapper()->query()->retrieve(
253 "reset_offset",
254 $this->refinery->kindlyTo()->bool()
255 );
256 }
257
258 // first call for translation
259 if ($reset_offset_get) {
260 $table_gui->resetOffset();
261 }
262
263 if (!isset($compare_content)) {
264 $compare_content = ilObjLanguageExt::_getValues(
265 $compare,
266 $modules,
267 $topics
268 );
269
270 $compare_comments = $this->compareComments($compare, $modules);
271 }
272
273 $translations = ilObjLanguageExt::_getValues(
274 $this->object->key,
275 $modules,
276 $topics
277 );
278
279 // enable adding new entries
280 $db_found = array();
281 foreach ($translations as $name => $translation) {
282 $keys = explode($this->lng->separator, $name);
283 $db_found[] = $keys[1];
284 // the forms of a plural message are its topic (see PluralFormKey)
285 $db_found[] = PluralFormKey::parse($keys[1])[0] ?? $keys[1];
286 }
287 $missing_entries = array_diff($topics, $db_found);
288 // only offer what AddLanguageEntry accepts, a topic of another module would be a duplicate
289 $missing_entries = RepositoryProvider::filterAddable($DIC->database(), $modules, array_values($missing_entries));
290 } else { // normal view mode:
291 // - the table is filtered manually by module, mode and pattern
292 $filter_mode = $table_gui->getFilterItemByPostVar("mode")->getValue();
293 $filter_pattern = $table_gui->getFilterItemByPostVar("pattern")->getValue();
294 $filter_module = $table_gui->getFilterItemByPostVar("module")->getValue();
295 $filter_module = $filter_module === "all" ? "" : $filter_module;
296 $filter_modules = $filter_module ? array($filter_module) : array();
297 $filter_identifier = $table_gui->getFilterItemByPostVar("identifier")->getValue();
298 $filter_topics = $filter_identifier ? array($filter_identifier) : array();
299
300 if (!isset($compare_content)) {
301 $compare_content = ilObjLanguageExt::_getValues(
302 $compare,
303 $filter_modules,
304 $filter_topics
305 );
306
307 $compare_comments = $this->compareComments($compare, $filter_modules);
308 }
309
310 switch ($filter_mode) {
311 case "changed":
312 $translations = $this->object->getChangedValues(
313 $filter_modules,
314 $filter_pattern,
315 $filter_topics
316 );
317 break;
318
319 case "added": //langmode only
320 $translations = $this->object->getAddedValues(
321 $filter_modules,
322 $filter_pattern,
323 $filter_topics
324 );
325 break;
326
327 case "unchanged":
328 $translations = $this->object->getUnchangedValues(
329 $filter_modules,
330 $filter_pattern,
331 $filter_topics
332 );
333 break;
334
335 case "commented":
336 $translations = $this->object->getCommentedValues(
337 $filter_modules,
338 $filter_pattern,
339 $filter_topics
340 );
341 break;
342
343 case "dbremarks":
344 $translations = $this->object->getAllValues(
345 $filter_modules,
346 $filter_pattern,
347 $filter_topics
348 );
349
350 // only local remarks, no shipped notes
351 $local_remarks = $this->object->getAllRemarks();
352 $translations = array_filter(
353 $translations,
354 fn(int|string $name): bool => $this->remarkOf($local_remarks, (string) $name) !== '',
355 ARRAY_FILTER_USE_KEY
356 );
357 break;
358
359 case "equal":
360 $translations = $this->object->getAllValues(
361 $filter_modules,
362 $filter_pattern,
363 $filter_topics
364 );
365
366 $translations = array_intersect_assoc($translations, $compare_content);
367 break;
368
369 case "different":
370 $translations = $this->object->getAllValues(
371 $filter_modules,
372 $filter_pattern,
373 $filter_topics
374 );
375
376 $translations = array_diff_assoc($translations, $compare_content);
377 break;
378
379 case "conflicts":
380 $former_file = $this->object->getDataPath() . "/ilias_" . $this->object->key . ".lang";
381 if (!is_readable($former_file)) {
382 $this->tpl->setOnScreenMessage('failure', sprintf($this->lng->txt("language_former_file_missing"), $former_file)
383 . '<br />' . $this->lng->txt("language_former_file_description"), false);
384 $translations = array();
385 break;
386 }
387 $former_file_obj = new ilLanguageFile($former_file);
388 $former_file_obj->read();
389 // PO modules are compared with the backup of their shipped .po (written by "save_dist")
390 $global_changes = $this->object->getShippedChangesSinceBackup(
391 $former_file_obj,
392 $this->object->getDataPath()
393 );
394 if (!count($global_changes)) {
395 $this->tpl->setOnScreenMessage('info', sprintf($this->lng->txt("language_former_file_equal"), $former_file)
396 . '<br />' . $this->lng->txt("language_former_file_description"), false);
397 $translations = array();
398 break;
399 }
400 $translations = $this->object->getChangedValues(
401 $filter_modules,
402 $filter_pattern,
403 $filter_topics
404 );
405
406 $translations = array_intersect_key($translations, $global_changes);
407 break;
408
409 case "all":
410 default:
411 $translations = $this->object->getAllValues(
412 $filter_modules,
413 $filter_pattern,
414 $filter_topics
415 );
416 }
417 }
418
419 // prepare the the data for the table
420 $data = array();
421 foreach ($translations as $name => $translation) {
422 $keys = explode($this->lng->separator, $name);
423 $row = array();
424
425 $row["module"] = $keys[0];
426 $row["topic"] = $keys[1];
427 $row["name"] = $name;
428 $row["translation"] = $posted_values[$name] ?? $translation;
429 $row["comment"] = $posted_remarks[$name] ?? $this->remarkOf($comments, (string) $name);
430 $row["default"] = $compare_content[$name] ?? "";
431 $row["default_comment"] = $this->remarkOf($compare_comments, (string) $name);
432
433 $data[] = $row;
434 }
435
436 // one message: setOnScreenMessage() only keeps one per type
437 $failure_messages = $additional_failure_messages;
438 if ($changesSuccessBool && $modules_with_unwritten_overlay !== []) {
439 $failure_messages[] = $this->overlayNotWrittenMessage($modules_with_unwritten_overlay);
440 } elseif ($changesSuccessBool) {
441 $tpl->setVariable("MESSAGE", $this->getSuccessMessage());
442 }
443 if (($unreadable_modules = $this->object->getUnreadableShippedPoModules()) !== []) {
444 $failure_messages[] = sprintf(
445 $this->lng->txt("lng_shipped_po_unreadable_fallback"),
446 implode(', ', $unreadable_modules)
447 );
448 }
449 if ($failure_messages !== []) {
450 $this->tpl->setOnScreenMessage('failure', implode('<br />', $failure_messages));
451 }
452
453 // render and show the table
454 $table_gui->setData($data);
455 $tpl->setContent($table_gui->getHTML() . $this->buildMissingEntries($missing_entries));
456 }
remarkOf(array $comments, string $name)
A form of a plural message without a comment of its own gets the one of its identifier (see PluralFor...
getSuccessMessage()
Get success message after variables were saved.
compareComments(string $compare, array $modules=[])
Remarks (lng_data and overlay) plus, for PO modules without a remark, the shipped notes and "not tran...
static _getValues(string $a_lang_key, array $a_modules=array(), array $a_topics=array(), string $a_pattern='', string $a_state='')
Get the translations of specified topics.
setVariable(string $variable, $value='')
Sets the given variable to the given value.

Field Documentation

◆ $add_language_entry

readonly AddLanguageEntry ilObjLanguageExtGUI::$add_language_entry
private

Definition at line 55 of file class.ilObjLanguageExtGUI.php.

◆ $langmode

string ilObjLanguageExtGUI::$langmode
private

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

◆ $remove_local_language_changes

readonly RemoveLocalLanguageChanges ilObjLanguageExtGUI::$remove_local_language_changes
private

Definition at line 57 of file class.ilObjLanguageExtGUI.php.

◆ $set_language_translation_enabled

readonly SetLanguageTranslationEnabled ilObjLanguageExtGUI::$set_language_translation_enabled
private

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

◆ ILIAS_LANGUAGE_MODULE

const string ilObjLanguageExtGUI::ILIAS_LANGUAGE_MODULE = "components/ILIAS/Language"
private

Definition at line 53 of file class.ilObjLanguageExtGUI.php.


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