ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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...
 
 executeCommand ()
 execute command More...
 
 cancelObject ()
 Cancel the current action. More...
 
 viewObject (int $changesSuccessBool=0)
 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. 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
 __construct ($data, int $id=0, bool $call_by_reference=true, bool $prepare_output=true)
 
 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)
 
 redirectAfterCreation ()
 Redirect after creation, see https://docu.ilias.de/goto_docu_wiki_wpage_5035_1357.html Should be overwritten and redirect to settings screen. More...
 
 addToDeskObject ()
 
 removeFromDeskObject ()
 
- Public Member Functions inherited from ILIAS\Object\ImplementsCreationCallback
 callCreationCallback (\ilObject $object, \ilObjectDefinition $obj_definition, int $requested_crtcb)
 

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...
 
 initCreationForms (string $new_type)
 Init creation forms. More...
 
 getCreationFormsHTML (array $forms)
 Get HTML for creation forms (accordion) More...
 
 initCreateForm (string $new_type)
 
 initDidacticTemplate (ilPropertyFormGUI $form)
 
 addDidacticTemplateOptions (array &$a_options)
 Add custom templates. More...
 
 addAdoptContentLinkToToolbar ()
 
 addAvailabilityPeriodButtonToToolbar (ilToolbarGUI $toolbar)
 
 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...
 
 initImportForm (string $new_type)
 
 importFileObject (int $parent_id=null)
 
 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 ()
 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...
 

Protected Attributes

HTTPServices $http
 
Refinery $refinery
 
- Protected Attributes inherited from ilObjectGUI
ILIAS Notes Service $notes_service
 
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
 
Factory $refinery
 
ilFavouritesManager $favourites
 
ilObjectCustomIconFactory $custom_icon_factory
 
UIFactory $ui_factory
 
UIRenderer $ui_renderer
 
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 = ""
 

Private Member Functions

 getSession ()
 

Private Attributes

const ILIAS_LANGUAGE_MODULE = "Services/Language"
 
string $langmode
 

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 ALLOWED_TAGS_IN_TITLE_AND_DESCRIPTION
 
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
 

Detailed Description

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 62 of file class.ilObjLanguageExtGUI.php.

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

63  {
64  global $DIC;
65  $ilClientIniFile = $DIC->clientIni();
66  $ilCtrl = $DIC->ctrl();
67  $lng = $DIC->language();
68  $this->http = $DIC->http();
69  $this->refinery = $DIC->refinery();
70 
71  // language maintenance strings are defined in administration
72  $lng->loadLanguageModule("administration");
73  $lng->loadLanguageModule("meta");
74 
75  // view mode ('translate' or empty) determins available table filters
76  $ilCtrl->saveParameter($this, "view_mode");
77 
78  // type and id of get the bound object
79  $this->type = "lng";
80  $obj_id_get = 0;
81  if ($this->http->wrapper()->query()->has("obj_id")) {
82  $obj_id_get = $this->http->wrapper()->query()->retrieve("obj_id", $this->refinery->kindlyTo()->int());
83  }
84  if (!$this->id = $obj_id_get) {
86  }
87 
88  // do all generic GUI initialisations
89  parent::__construct($a_data, $this->id, false, true);
90 
91  // initialize the array to store session variables for extended language maintenance
92  if (!is_array($this->getSession())) {
93  ilSession::set("lang_ext_maintenance", array());
94  }
95  // $this->session = &$_SESSION["lang_ext_maintenance"];// Todo-PHP8-Review This property is not defined, here and in other methods in this class
96 
97  // read the lang mode
98  $this->langmode = $ilClientIniFile->readVariable("system", "LANGMODE");
99  }
getUserLanguage()
Return language of user.
static _lookupId(string $a_key)
Lookup the object ID for a language key.
loadLanguageModule(string $a_module)
Load language module.
global $DIC
Definition: feed.php:28
ilLanguage $lng
static http()
Fetches the global http state from ILIAS.
__construct(VocabulariesInterface $vocabularies)
static set(string $a_var, $a_val)
Set a value.
+ 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)

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

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

930  : void
931  {
932  global $DIC;
933  $ilLocator = $DIC["ilLocator"];
934 
936  parent::addAdminLocatorItems(true); // #13881
937 
938  $ilLocator->addItem(
939  $this->lng->txt("languages"),
940  $this->ctrl->getLinkTargetByClass("ilobjlanguagefoldergui", "")
941  );
942 
943  $ilLocator->addItem(
944  $this->lng->txt("meta_l_" . $this->object->getTitle()),
945  $this->ctrl->getLinkTarget($this, "view")
946  );
947  }
948  }
static _isPageTranslation()
Check if the current request is a page translation.
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ addNewEntryObject()

ilObjLanguageExtGUI::addNewEntryObject ( ilPropertyFormGUI  $a_form = null)

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

References $DIC, ilObjectGUI\$id, ilObjectGUI\$tpl, ILIAS\FileDelivery\http(), initAddNewEntryForm(), ILIAS\Repository\refinery(), and ilGlobalTemplateInterface\setContent().

Referenced by saveNewEntryObject().

994  : void
995  {
996  global $DIC;
997  $tpl = $DIC["tpl"];
998 
999  $id = "";
1000  if ($this->http->wrapper()->query()->has("eid")) {
1001  $id = trim($this->http->wrapper()->query()->retrieve("eid", $this->refinery->kindlyTo()->string()));
1002  }
1003  if (!$a_form) {
1004  $a_form = $this->initAddNewEntryForm($id);
1005  }
1006 
1007  $tpl->setContent($a_form->getHTML());
1008  }
initAddNewEntryForm(string $a_id=null)
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
ilGlobalTemplateInterface $tpl
setContent(string $a_html)
Sets content for standard template.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyFilterObject()

ilObjLanguageExtGUI::applyFilterObject ( )

Apply filter.

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

References getViewTable(), and ilObjectGUI\viewObject().

385  : void
386  {
387  $table_gui = $this->getViewTable();
388  $table_gui->writeFilterToSession(); // writes filter to session
389  $table_gui->resetOffset(); // sets record offest to 0 (first page)
390  $this->viewObject();
391  }
getViewTable()
Get the table to view language entries.
viewObject()
viewObject container presentation for "administration -> repository, trash, permissions" ...
+ Here is the call graph for this function:

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

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

107  : void
108  {
109  require_once("Services/Language/classes/class.ilObjLanguageExt.php");
110  $this->object = new ilObjLanguageExt($this->id);
111  }
Class ilObjLanguageExt.

◆ buildMissingEntries()

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

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

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

Referenced by viewObject().

970  : string
971  {
972  global $DIC;
973  $ilCtrl = $DIC->ctrl();
974 
975  if (!count($a_missing)) {
976  return '';
977  }
978 
979  $res = array("<h3>" . $this->lng->txt("adm_missing_entries") . "</h3>", "<ul>");
980 
981  foreach ($a_missing as $entry) {
982  $ilCtrl->setParameter($this, "eid", $entry);
983  $res[] = '<li>' . $entry .
984  ' <a href="' . $ilCtrl->getLinkTarget($this, "addNewEntry") .
985  '">' . $this->lng->txt("adm_missing_entry_add_action") . '</a></li>';
986  $ilCtrl->setParameter($this, "eid", "");
987  }
988 
989  $res[] = "</ul>";
990 
991  return implode("\n", $res);
992  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cancelObject()

ilObjLanguageExtGUI::cancelObject ( )

Cancel the current action.

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

References ilObjectGUI\viewObject().

144  : void
145  {
146  $this->viewObject();
147  }
viewObject()
viewObject container presentation for "administration -> repository, trash, permissions" ...
+ Here is the call graph for this function:

◆ downloadObject()

ilObjLanguageExtGUI::downloadObject ( )

Download a language file.

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

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

584  : void
585  {
586  $post_scope = $this->http->request()->getParsedBody()['scope'] ?? "";
587  // save the selected scope
588  $tmp["export"]["scope"] = ilUtil::stripSlashes($post_scope);
589  ilSession::set("lang_ext_maintenance", $tmp);
590 
591  $filename = "ilias_" . $this->object->key . '_'
592  . str_replace(".", "_", substr(ILIAS_VERSION, 0, strpos(ILIAS_VERSION, " ")))
593  . "-" . date("Y-m-d")
594  . ".lang." . $this->getSession()["export"]["scope"];
595 
596  $global_file_obj = $this->object->getGlobalLanguageFile();
597  $local_file_obj = new ilLanguageFile($filename, $this->object->key, $post_scope);
598 
599  if ($post_scope === "global") {
600  $local_file_obj->setParam("author", $global_file_obj->getParam("author"));
601  $local_file_obj->setParam("version", $global_file_obj->getParam("version"));
602  $local_file_obj->setAllValues($this->object->getAllValues());
603  if ($this->langmode) {
604  $local_file_obj->setAllComments($this->object->getAllRemarks());
605  }
606  } elseif ($post_scope === "local") {
607  $local_file_obj->setParam("based_on", $global_file_obj->getParam("version"));
608  $local_file_obj->setAllValues($this->object->getChangedValues());
609  if ($this->langmode) {
610  $local_file_obj->setAllComments($this->object->getAllRemarks());
611  }
612  } elseif ($post_scope === "added") { // langmode only
613  $local_file_obj->setParam("author", $global_file_obj->getParam("author"));
614  $local_file_obj->setParam("version", $global_file_obj->getParam("version"));
615  $local_file_obj->setAllValues($this->object->getAddedValues());
616  $local_file_obj->setAllComments($this->object->getAllRemarks());
617  } elseif ($post_scope === "unchanged") {
618  $local_file_obj->setParam("author", $global_file_obj->getParam("author"));
619  $local_file_obj->setParam("version", $global_file_obj->getParam("version"));
620  $local_file_obj->setAllValues($this->object->getUnchangedValues());
621  if ($this->langmode) {
622  $local_file_obj->setAllComments($this->object->getAllRemarks());
623  }
624  } elseif ($post_scope === "merged") { // langmode only
625  $local_file_obj->setParam("author", $global_file_obj->getParam("author"));
626  $local_file_obj->setParam("version", $global_file_obj->getParam("version"));
627  $local_file_obj->setAllValues($this->object->getMergedValues());
628  $local_file_obj->setAllComments($this->object->getMergedRemarks());
629  }
630 
631  ilUtil::deliverData($local_file_obj->build(), $filename);
632  }
const ILIAS_VERSION
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")
static http()
Fetches the global http state from ILIAS.
$filename
Definition: buildRTE.php:78
Class ilLanguageFile.
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:

◆ executeCommand()

ilObjLanguageExtGUI::executeCommand ( )

execute command

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

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

125  : void
126  {
127  global $DIC;
128  $ilHelp = $DIC->help();
129 
131  $this->error->raiseError($this->lng->txt("permission_denied"), $this->error->MESSAGE);
132  exit;
133  }
134 
135  $cmd = $this->ctrl->getCmd("view") . "Object";
136  $this->$cmd();
137 
138  $ilHelp->setScreenIdComponent("lng");
139  }
exit
Definition: login.php:29
static _checkMaintenance()
Permission check for language maintenance (import/export)
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ exportObject()

ilObjLanguageExtGUI::exportObject ( )

Show the screen to export a language file.

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

References ILIAS\Repository\ctrl(), getSession(), ILIAS\Repository\lng(), and ilFormPropertyGUI\setInfo().

545  : void
546  {
547  require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
548  $form = new ilPropertyFormGUI();
549  $form->setFormAction($this->ctrl->getFormAction($this));
550  $form->setTitle($this->lng->txt("language_export_file"));
551  $form->setPreventDoubleSubmission(false);
552  $form->addCommandButton("download", $this->lng->txt("download"));
553 
554  $rg = new ilRadioGroupInputGUI($this->lng->txt("language_file_scope"), "scope");
555  $ro = new ilRadioOption($this->lng->txt("language_scope_global"), "global");
556  $ro->setInfo($this->lng->txt("language_scope_global_info"));
557  $rg->addOption($ro);
558  $ro = new ilRadioOption($this->lng->txt("language_scope_local"), "local");
559  $ro->setInfo($this->lng->txt("language_scope_local_info"));
560  $rg->addOption($ro);
561  if ($this->langmode) {
562  $ro = new ilRadioOption($this->lng->txt("language_scope_added"), "added");
563  $ro->setInfo($this->lng->txt("language_scope_added_info"));
564  $rg->addOption($ro);
565  }
566  $ro = new ilRadioOption($this->lng->txt("language_scope_unchanged"), "unchanged");
567  $ro->setInfo($this->lng->txt("language_scope_unchanged_info"));
568  $rg->addOption($ro);
569  if ($this->langmode) {
570  $ro = new ilRadioOption($this->lng->txt("language_scope_merged"), "merged");
571  $ro->setInfo($this->lng->txt("language_scope_merged_info"));
572  $rg->addOption($ro);
573  }
574 
575  $rg->setValue($this->getSession()["export"]["scope"] ?? "global");
576  $form->addItem($rg);
577 
578  $this->tpl->setContent($form->getHTML());
579  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property in a property form.
+ Here is the call graph for this function:

◆ getAdminTabs()

ilObjLanguageExtGUI::getAdminTabs ( )

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

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

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

864  : void
865  {
866  global $DIC;
867  $ilCtrl = $DIC->ctrl();
868  $cmd = $ilCtrl->getCmd();
869 
871  $this->tabs_gui->setBackTarget(
872  $this->lng->txt("back"),
873  $this->ctrl->getLinkTargetByClass("ilObjLanguageFolderGUI")
874  );
875 
876  $this->tabs_gui->addTab(
877  "edit",
878  $this->lng->txt("edit"),
879  $this->ctrl->getLinkTarget($this, "view")
880  );
881 
882  $this->tabs_gui->addTab(
883  "export",
884  $this->lng->txt('export'),
885  $this->ctrl->getLinkTarget($this, "export")
886  );
887 
888  $this->tabs_gui->addTab(
889  "import",
890  $this->lng->txt("import"),
891  $this->ctrl->getLinkTarget($this, "import")
892  );
893 
894  $this->tabs_gui->addTab(
895  "maintain",
896  $this->lng->txt("language_maintain"),
897  $this->ctrl->getLinkTarget($this, "maintain")
898  );
899 
900  $this->tabs_gui->addTab(
901  "settings",
902  $this->lng->txt("settings"),
903  $this->ctrl->getLinkTarget($this, "settings")
904  );
905 
906  $this->tabs_gui->addTab(
907  "statistics",
908  $this->lng->txt("language_statistics"),
909  $this->ctrl->getLinkTarget($this, "statistics")
910  );
911 
912  switch ($cmd) {
913  case "":
914  case "view":
915  case "applyFilter":
916  case "resetFilter":
917  case "save":
918  $this->tabs_gui->activateTab("edit");
919  break;
920  default:
921  $this->tabs_gui->activateTab($cmd);
922  }
923  }
924  }
static _isPageTranslation()
Check if the current request is a page translation.
global $DIC
Definition: feed.php:28
+ 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 117 of file class.ilObjLanguageExtGUI.php.

References ilObjectGUI\$id.

117  : int
118  {
119  return $this->id;
120  }

◆ getSession()

ilObjLanguageExtGUI::getSession ( )
private

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

References ilSession\get().

Referenced by __construct(), downloadObject(), exportObject(), initNewImportForm(), and maintainObject().

1115  : array
1116  {
1117  return ilSession::get("lang_ext_maintenance") ?? [];
1118  }
static get(string $a_var)
+ 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 1106 of file class.ilObjLanguageExtGUI.php.

References $DIC, Vendor\Package\$f, and ILIAS\Repository\lng().

Referenced by viewObject().

1106  : string
1107  {
1108  global $DIC;
1109  $f = $DIC->ui()->factory();
1110  $renderer = $DIC->ui()->renderer();
1111 
1112  return $renderer->render($f->messageBox()->success($this->lng->txt("language_variables_saved")));
1113  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getViewTable()

ilObjLanguageExtGUI::getViewTable ( )
protected

Get the table to view language entries.

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

References ILIAS\Repository\object().

Referenced by applyFilterObject(), resetFilterObject(), and viewObject().

153  {
154  // create and configure the table object
155  include_once "./Services/Language/classes/class.ilLanguageExtTableGUI.php";
156  $table_gui = new ilLanguageExtTableGUI($this, "view", array(
157  "langmode" => $this->langmode,
158  "lang_key" => $this->object->key,
159  ));
160 
161  return $table_gui;
162  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importObject()

ilObjLanguageExtGUI::importObject ( )

Show the screen to import a language file.

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

References initNewImportForm().

450  : void
451  {
452  $form = $this->initNewImportForm();
453  $this->tpl->setContent($form->getHTML());
454  }
+ Here is the call graph for this function:

◆ initAddNewEntryForm()

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

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

References $DIC, ilObjectGUI\$id, ilObjLanguageAccess\_getSavedModules(), ilObjLanguageAccess\_getSavedTopics(), ILIAS\FileDelivery\http(), and ILIAS\Repository\lng().

Referenced by addNewEntryObject(), and saveNewEntryObject().

1011  {
1012  global $DIC;
1013  $ilCtrl = $DIC->ctrl();
1014 
1015  if (!$a_id) {
1016  $a_id = $this->http->request()->getParsedBody()['id'] ?? "";
1017  }
1018 
1019  if (!$a_id ||
1020  !in_array($a_id, ilObjLanguageAccess::_getSavedTopics())) {
1021  $ilCtrl->redirect($this, "view");
1022  }
1023 
1024  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
1025  $form = new ilPropertyFormGUI();
1026  $form->setFormAction($ilCtrl->getFormAction($this, "saveNewEntry"));
1027  $form->setTitle($this->lng->txt("adm_missing_entry_add"));
1028 
1030  $options = array_combine($mods, $mods);
1031 
1032  $mod = new ilSelectInputGUI(ucfirst($this->lng->txt("module")), "mod");
1033  $mod->setOptions(array("" => $this->lng->txt("please_select")) + $options);
1034  $mod->setRequired(true);
1035  $form->addItem($mod);
1036 
1037  $id = new ilTextInputGUI(ucfirst($this->lng->txt("identifier")), "id");
1038  $id->setValue($a_id);
1039  $id->setDisabled(true);
1040  $form->addItem($id);
1041 
1042  foreach ($this->lng->getInstalledLanguages() as $lang_key) {
1043  $trans = new ilTextInputGUI($this->lng->txt("meta_l_" . $lang_key), "trans_" . $lang_key);
1044  if (in_array($lang_key, array("de", "en"))) {
1045  $trans->setRequired(true);
1046  }
1047  $form->addItem($trans);
1048  }
1049 
1050  $form->addCommandButton("saveNewEntry", $this->lng->txt("save"));
1051  $form->addCommandButton("view", $this->lng->txt("cancel"));
1052 
1053  return $form;
1054  }
This class represents a selection list property in a property form.
static _getSavedModules()
Get the stored modules from the user session.
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
static _getSavedTopics()
Get the stored topics from the user session.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initNewImportForm()

ilObjLanguageExtGUI::initNewImportForm ( )
protected

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

References ILIAS\Repository\ctrl(), getSession(), ILIAS\Repository\lng(), ilFormPropertyGUI\setInfo(), and ilFormPropertyGUI\setRequired().

Referenced by importObject(), and uploadObject().

457  {
458  require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
459  $form = new ilPropertyFormGUI();
460  $form->setFormAction($this->ctrl->getFormAction($this));
461  $form->setTitle($this->lng->txt("language_import_file"));
462  $form->addCommandButton("upload", $this->lng->txt("upload"));
463 
464  $fu = new ilFileInputGUI($this->lng->txt("file"), "userfile");
465  $fu->setRequired(true);
466  $form->addItem($fu);
467 
468  $rg = new ilRadioGroupInputGUI($this->lng->txt("language_mode_existing"), "mode_existing");
469  $ro = new ilRadioOption($this->lng->txt("language_mode_existing_keepall"), "keepall");
470  $ro->setInfo($this->lng->txt("language_mode_existing_keepall_info"));
471  $rg->addOption($ro);
472  $ro = new ilRadioOption($this->lng->txt("language_mode_existing_keepnew"), "keepnew");
473  $ro->setInfo($this->lng->txt("language_mode_existing_keepnew_info"));
474  $rg->addOption($ro);
475  $ro = new ilRadioOption($this->lng->txt("language_mode_existing_replace"), "replace");
476  $ro->setInfo($this->lng->txt("language_mode_existing_replace_info"));
477  $rg->addOption($ro);
478  $ro = new ilRadioOption($this->lng->txt("language_mode_existing_delete"), "delete");
479  $ro->setInfo($this->lng->txt("language_mode_existing_delete_info"));
480  $rg->addOption($ro);
481  $rg->setValue($this->getSession()["import"]["mode_existing"] ?? "keepall");
482  $form->addItem($rg);
483 
484  return $form;
485  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a file property in a property form.
This class represents a property in a property form.
setRequired(bool $a_required)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initNewSettingsForm()

ilObjLanguageExtGUI::initNewSettingsForm ( )
protected

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

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

Referenced by saveSettingsObject(), and settingsObject().

794  {
795  global $DIC;
796  $ilSetting = $DIC->settings();
797  $translate_key = "lang_translate_" . $this->object->key;
798  $translate = (bool) $ilSetting->get($translate_key, '0');
799 
800  require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
801  $form = new ilPropertyFormGUI();
802  $form->setFormAction($this->ctrl->getFormAction($this));
803  $form->setTitle($this->lng->txt("language_settings"));
804  $form->setPreventDoubleSubmission(false);
805  $form->addCommandButton('saveSettings', $this->lng->txt("language_change_settings"));
806 
807  $ci = new ilCheckboxInputGUI($this->lng->txt("language_translation_enabled"), "translation");
808  $ci->setChecked($translate);
809  $ci->setInfo($this->lng->txt("language_note_translation"));
810  $form->addItem($ci);
811 
812  return $form;
813  }
global $DIC
Definition: feed.php:28
global $ilSetting
Definition: privfeed.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maintainExecuteObject()

ilObjLanguageExtGUI::maintainExecuteObject ( )

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

References ilObjLanguageExt\_deleteValues(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilSession\set(), and ilUtil\stripSlashes().

673  : void
674  {
675  $post_maintain = $this->http->request()->getParsedBody()['maintain'] ?? "";
676  if (isset($post_maintain)) {
677  $tmp["maintain"] = ilUtil::stripSlashes($post_maintain);
678  ilSession::set("lang_ext_maintenance", $tmp);
679  }
680 
681  switch ($post_maintain) {
682  // save the global language file for merge after
683  case "save_dist":
684  // save a copy of the distributed language file
685  $orig_file = $this->object->getLangPath() . "/ilias_" . $this->object->key . ".lang";
686  $copy_file = $this->object->getDataPath() . "/ilias_" . $this->object->key . ".lang";
687  if (@copy($orig_file, $copy_file)) {
688  $this->tpl->setOnScreenMessage('success', $this->lng->txt("language_saved_dist"), true);
689  } else {
690  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("language_save_dist_failed"), true);
691  }
692  break;
693 
694  // load the content of the local language file
695  case "load":
696  $lang_file = $this->object->getCustLangPath() . "/ilias_" . $this->object->key . ".lang.local";
697  if (is_file($lang_file) and is_readable($lang_file)) {
698  $this->object->importLanguageFile($lang_file, "replace");
699  $this->object->setLocal(true);
700  $this->tpl->setOnScreenMessage('success', $this->lng->txt("language_loaded_local"), true);
701  } else {
702  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("language_error_read_local"), true);
703  }
704  break;
705 
706  // revert the database to the default language file
707  case "clear":
708  $lang_file = $this->object->getLangPath() . "/ilias_" . $this->object->key . ".lang";
709  if (is_file($lang_file) and is_readable($lang_file)) {
710  $this->object->importLanguageFile($lang_file, "replace");
711  $this->object->setLocal(false);
712  $this->tpl->setOnScreenMessage('success', $this->lng->txt("language_cleared_local"), true);
713  } else {
714  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("language_error_clear_local"), true);
715  }
716  break;
717 
718  // delete local additions in the datavase (langmode only)
719  case "delete_added":
720  ilObjLanguageExt::_deleteValues($this->object->key, $this->object->getAddedValues());
721  break;
722 
723  // merge local changes back to the global language file (langmode only)
724  case "merge":
725  $orig_file = $this->object->getLangPath() . "/ilias_" . $this->object->key . ".lang";
726  $copy_file = $this->object->getCustLangPath() . "/ilias_" . $this->object->key . ".lang";
727 
728  if (is_file($orig_file) and is_writable($orig_file)) {
729  // save a copy of the global language file
730  @copy($orig_file, $copy_file);
731 
732  // modify and write the new global file
733  $global_file_obj = $this->object->getGlobalLanguageFile();
734  $global_file_obj->setAllValues($this->object->getMergedValues());
735  $global_file_obj->setAllComments($this->object->getMergedRemarks());
736  $global_file_obj->write();
737  $this->tpl->setOnScreenMessage('success', $this->lng->txt("language_merged_global"), true);
738  } else {
739  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("language_error_write_global"), true);
740  }
741  break;
742 
743  // remove the local language file (langmode only)
744  case "remove_local_file":
745  $lang_file = $this->object->getCustLangPath() . "/ilias_" . $this->object->key . ".lang.local";
746 
747  if (!is_file($lang_file)) {
748  $this->object->setLocal(false);
749  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("language_error_local_missed"), true);
750  } elseif (@unlink($lang_file)) {
751  $this->object->setLocal(false);
752  $this->tpl->setOnScreenMessage('success', $this->lng->txt("language_local_file_deleted"), true);
753  } else {
754  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("language_error_delete_local"), true);
755  }
756  break;
757  }
758 
759  $this->ctrl->redirect($this, "maintain");
760  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static http()
Fetches the global http state from ILIAS.
static _deleteValues(string $a_lang_key, array $a_values=array())
Delete a set of translation in the database.
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:

◆ maintainObject()

ilObjLanguageExtGUI::maintainObject ( )

Process the language maintenance.

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

References ILIAS\Repository\ctrl(), getSession(), ILIAS\Repository\lng(), and ilFormPropertyGUI\setInfo().

637  : void
638  {
639  require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
640  $form = new ilPropertyFormGUI();
641  $form->setFormAction($this->ctrl->getFormAction($this));
642  $form->setTitle($this->lng->txt("language_maintenance"));
643  $form->setPreventDoubleSubmission(false);
644  $form->addCommandButton("maintainExecute", $this->lng->txt("language_process_maintenance"));
645 
646  $rg = new ilRadioGroupInputGUI($this->lng->txt("language_maintain_local_changes"), "maintain");
647  $ro = new ilRadioOption($this->lng->txt("language_load_local_changes"), "load");
648  $ro->setInfo(sprintf($this->lng->txt("language_load_local_changes_info"), $this->object->key));
649  $rg->addOption($ro);
650  $ro = new ilRadioOption($this->lng->txt("language_clear_local_changes"), "clear");
651  $ro->setInfo(sprintf($this->lng->txt("language_clear_local_changes_info"), $this->object->key));
652  $rg->addOption($ro);
653  if ($this->langmode) {
654  $ro = new ilRadioOption($this->lng->txt("language_delete_local_additions"), "delete_added");
655  $ro->setInfo(sprintf($this->lng->txt("language_delete_local_additions_info"), $this->object->key));
656  $rg->addOption($ro);
657  $ro = new ilRadioOption($this->lng->txt("language_remove_local_file"), "remove_local_file");
658  $ro->setInfo(sprintf($this->lng->txt("language_remove_local_file_info"), $this->object->key));
659  $rg->addOption($ro);
660  $ro = new ilRadioOption($this->lng->txt("language_merge_local_changes"), "merge");
661  $ro->setInfo(sprintf($this->lng->txt("language_merge_local_changes_info"), $this->object->key));
662  $rg->addOption($ro);
663  }
664  $ro = new ilRadioOption($this->lng->txt("language_save_dist"), "save_dist");
665  $ro->setInfo(sprintf($this->lng->txt("language_save_dist_info"), $this->object->key));
666  $rg->addOption($ro);
667  $rg->setValue($this->getSession()["maintain"] ?? "load");
668  $form->addItem($rg);
669 
670  $this->tpl->setContent($form->getHTML());
671  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property in a property form.
+ Here is the call graph for this function:

◆ resetFilterObject()

ilObjLanguageExtGUI::resetFilterObject ( )

Reset filter.

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

References getViewTable(), and ilObjectGUI\viewObject().

396  : void
397  {
398  $table_gui = $this->getViewTable();
399  $table_gui->resetOffset(); // sets record offest to 0 (first page)
400  $table_gui->resetFilter(); // clears filter
401  $this->viewObject();
402  }
getViewTable()
Get the table to view language entries.
viewObject()
viewObject container presentation for "administration -> repository, trash, permissions" ...
+ Here is the call graph for this function:

◆ saveNewEntryObject()

ilObjLanguageExtGUI::saveNewEntryObject ( )

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

References $DIC, ilObjectGUI\$id, $ilDB, $lang, addNewEntryObject(), initAddNewEntryForm(), ILIAS\Repository\lng(), and ilObjLanguage\replaceLangEntry().

1056  : void
1057  {
1058  global $DIC;
1059  $ilDB = $DIC->database();
1060  $ilCtrl = $DIC->ctrl();
1061  $ilUser = $DIC->user();
1062 
1063  $form = $this->initAddNewEntryForm();
1064  if ($form->checkInput()) {
1065  $mod = $form->getInput("mod");
1066  $id = $form->getInput("id");
1067 
1068  $lang = array();
1069  foreach ($this->lng->getInstalledLanguages() as $lang_key) {
1070  $trans = trim($form->getInput("trans_" . $lang_key));
1071  if ($trans) {
1072  // add single entry
1074  $mod,
1075  $id,
1076  $lang_key,
1077  $trans,
1078  date("Y-m-d H:i:s"),
1079  $ilUser->getLogin()
1080  );
1081 
1082  // add to serialized module
1083  $set = $ilDB->query("SELECT lang_array FROM lng_modules" .
1084  " WHERE lang_key = " . $ilDB->quote($lang_key, "text") .
1085  " AND module = " . $ilDB->quote($mod, "text"));
1086  $row = $ilDB->fetchAssoc($set);
1087  $entries = unserialize($row["lang_array"], ["allowed_classes" => false]);
1088  if (is_array($entries)) {
1089  $entries[$id] = $trans;
1090  ilObjLanguage::replaceLangModule($lang_key, $mod, $entries);
1091  }
1092  }
1093  }
1094 
1095  $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"), true);
1096  $ilCtrl->redirect($this, "view");
1097  }
1098 
1099  $form->setValuesByPost();
1100  $this->addNewEntryObject($form);
1101  }
initAddNewEntryForm(string $a_id=null)
global $DIC
Definition: feed.php:28
static replaceLangEntry(string $a_module, string $a_identifier, string $a_lang_key, string $a_value, string $a_local_change=null, string $a_remarks=null)
Replace lang entry.
$lang
Definition: xapiexit.php:26
addNewEntryObject(ilPropertyFormGUI $a_form=null)
+ Here is the call graph for this function:

◆ saveObject()

ilObjLanguageExtGUI::saveObject ( )

Save the changed translations.

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

References ILIAS\LTI\ToolProvider\$key, $post, ilObjLanguageExt\_saveValues(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ilUtil\stripSlashes(), and ilObjectGUI\viewObject().

407  : void
408  {
409  // no changes have been made yet
410  $changesSuccessBool = 0;
411  // prepare the values to be saved
412  $save_array = array();
413  $remarks_array = array();
414  $post = (array) ($this->http->request()->getParsedBody() ?? []);
415  foreach ($post as $key => $value) {
416  $orginal_key = $key;
417  // mantis #25237
418  // @see https://php.net/manual/en/language.variables.external.php
419  $key = str_replace(["_POSTDOT_", "_POSTSPACE_"], [".", " "], $key);
420 
421  // example key of variable: 'common#:#access'
422  // example key of comment: 'common#:#access#:#comment'
423  $keys = explode($this->lng->separator, ilUtil::stripSlashes($key));
424 
425  if (count($keys) === 2) {
426  // avoid line breaks
427  $value = preg_replace("/(\015\012)|(\015)|(\012)/", "<br />", $value);
428  $value = str_replace("<<", "«", $value);
429  $value = ilUtil::stripSlashes($value, true, "<strong><em><u><strike><ol><li><ul><p><div><i><b><code><sup><pre><gap><a><img><bdo><br><span>");
430  $save_array[$key] = $value;
431 
432  // the comment has the key of the language with the suffix
433  $remarks_array[$key] = $post[$orginal_key . $this->lng->separator . "comment"];
434  }
435  }
436 
437  // save the translations
438  ilObjLanguageExt::_saveValues($this->object->key, $save_array, $remarks_array);
439 
440  // set successful changes bool to true;
441  $changesSuccessBool = 1;
442 
443  // view the list
444  $this->viewObject($changesSuccessBool);
445  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
viewObject()
viewObject container presentation for "administration -> repository, trash, permissions" ...
static http()
Fetches the global http state from ILIAS.
string $key
Consumer key/client ID value.
Definition: System.php:193
$post
Definition: ltitoken.php:49
static _saveValues(string $a_lang_key, array $a_values=array(), array $a_remarks=array())
Save a set of translation in the database.
+ Here is the call graph for this function:

◆ saveSettingsObject()

ilObjLanguageExtGUI::saveSettingsObject ( )

Set the language settings.

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

References $DIC, $ilSetting, ILIAS\FileDelivery\http(), initNewSettingsForm(), and ILIAS\Repository\lng().

774  : void
775  {
776  global $DIC;
777  $ilSetting = $DIC->settings();
778 
779  $translate_key = "lang_translate_" . $this->object->key;
780 
781  $post_translation = $this->http->request()->getParsedBody()['translation'] ?? "";
782  // save and get the page translation setting
783  $translate = $ilSetting->get($translate_key, '0');
784  if (!is_null($post_translation) && $post_translation != $translate) {
785  $ilSetting->set($translate_key, $post_translation);
786  $this->tpl->setOnScreenMessage('success', $this->lng->txt("settings_saved"));
787  }
788  $form = $this->initNewSettingsForm();
789 
790  $this->tpl->setContent($form->getHTML());
791  }
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
global $ilSetting
Definition: privfeed.php:18
+ Here is the call graph for this function:

◆ settingsObject()

ilObjLanguageExtGUI::settingsObject ( )

View the language settings.

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

References initNewSettingsForm().

765  : void
766  {
767  $form = $this->initNewSettingsForm();
768  $this->tpl->setContent($form->getHTML());
769  }
+ Here is the call graph for this function:

◆ setTitleAndDescription()

ilObjLanguageExtGUI::setTitleAndDescription ( )
protected

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

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

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

954  : void
955  {
957  $this->tpl->setHeaderPageTitle($this->lng->txt("translation"));
958  $this->tpl->setTitle($this->lng->txt("translation") . " " . $this->lng->txt("meta_l_" . $this->object->key));
959  } else {
960  $this->tpl->setTitle($this->lng->txt("meta_l_" . $this->object->key));
961  }
962  $this->tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_lngf.svg"), $this->lng->txt("obj_" . $this->object->getType()));
963  }
static _isPageTranslation()
Check if the current request is a page translation.
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
+ Here is the call graph for this function:

◆ statisticsObject()

ilObjLanguageExtGUI::statisticsObject ( )

Print out statistics about the language.

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

References ilObjectGUI\$data, ilObjLanguageExt\_getModules(), ilTable2GUI\EXPORT_EXCEL, ILIAS\Repository\lng(), and ILIAS\Repository\object().

818  : void
819  {
820  $modules = ilObjLanguageExt::_getModules($this->object->key);
821 
822  $data = [];
823  $total = [];
824  foreach ($modules as $module) {
825  $row = [];
826  $row["module"] = $module;
827  $row["all"] = count($this->object->getAllValues(array($module)));
828  $row["changed"] = count($this->object->getChangedValues(array($module)));
829  $row["unchanged"] = $row["all"] - $row["changed"];
830  isset($total["all"]) ? $total["all"] += $row["all"] : $total["all"] = $row["all"];
831  isset($total["changed"]) ? $total["changed"] += $row["changed"] : $total["changed"] = $row["changed"];
832  isset($total["unchanged"]) ? $total["unchanged"] += $row["unchanged"] : $total["unchanged"] = $row["unchanged"];
833  $data[] = $row;
834  }
835  $total["module"] = "<b>" . $this->lng->txt("language_all_modules") . "</b>";
836  $total["all"] = "<b>" . $total["all"] . "</b>";
837  $total["changed"] = "<b>" . $total["changed"] . "</b>";
838  $total["unchanged"] = "<b>" . $total["unchanged"] . "</b>";
839  $data[] = $total;
840 
841  // create and configure the table object
842  include_once "Services/Table/classes/class.ilTable2GUI.php";
843  $table_gui = new ilTable2GUI($this, "statistics");
844  $table_gui->setRowTemplate("tpl.lang_statistics_row.html", "Services/Language");
845  $table_gui->setEnableTitle(false);
846  $table_gui->setEnableNumInfo(false);
847  $table_gui->setLimit(count($data));
848  $table_gui->setExportFormats(array(ilTable2GUI::EXPORT_EXCEL));
849 
850  $table_gui->addColumn(ucfirst($this->lng->txt("module")), "", "25%");
851  $table_gui->addColumn($this->lng->txt("language_scope_global"), "", "25%");
852  $table_gui->addColumn($this->lng->txt("language_scope_local"), "", "25%");
853  $table_gui->addColumn($this->lng->txt("language_scope_unchanged"), "", "25%");
854 
855  $table_gui->setData($data);
856 
857  $this->tpl->setContent($table_gui->getHTML());
858  }
static _getModules(string $a_lang_key)
Get all modules of a language.
+ Here is the call graph for this function:

◆ uploadObject()

ilObjLanguageExtGUI::uploadObject ( )

Process an uploaded language file.

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

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

490  : void
491  {
492  global $DIC;
493 
494  $form = $this->initNewImportForm();
495  if ($form->checkInput()) {
496  $post_mode_existing = $this->http->request()->getParsedBody()['mode_existing'] ?? "";
497  // save form inputs for next display
498  $tmp["import"]["mode_existing"] = ilUtil::stripSlashes($post_mode_existing);
499  ilSession::set("lang_ext_maintenance", $tmp);
500  try {
501  $upload = $DIC->upload();
502  //mantis #41617
503  if (!$upload->hasBeenProcessed()) {
504  $upload->process();
505  }
506 
507 
508  if (!$upload->hasUploads()) {
509  throw new ilException($DIC->language()->txt("upload_error_file_not_found"));
510  }
511  $UploadResult = $upload->getResults()[$_FILES["userfile"]["tmp_name"]];
512 
513  $ProcessingStatus = $UploadResult->getStatus();
514  if ($ProcessingStatus->getCode() === ProcessingStatus::REJECTED) {
515  throw new ilException($ProcessingStatus->getMessage());
516  }
517 
518  // todo: refactor when importLanguageFile() is able to work with the new Filesystem service
519  $tempfile = ilFileUtils::ilTempnam() . ".sec";
520  $upload->moveOneFileTo($UploadResult, '', Location::TEMPORARY, basename($tempfile), true);
521  $this->object->importLanguageFile($tempfile, $post_mode_existing);
522 
523  $tempfs = $DIC->filesystem()->temp();
524  $tempfs->delete(basename($tempfile));
525  } catch (Exception $e) {
526  $this->tpl->setOnScreenMessage('failure', $e->getMessage(), true);
527  $this->ctrl->redirect($this, 'import');
528  }
529 
530  $this->tpl->setOnScreenMessage(
531  'success',
532  sprintf($this->lng->txt("language_file_imported"), $_FILES["userfile"]["name"]),
533  true
534  );
535  $this->ctrl->redirect($this, "import");
536  }
537 
538  $form->setValuesByPost();
539  $this->tpl->setContent($form->getHTML());
540  }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
global $DIC
Definition: feed.php:28
static http()
Fetches the global http state from ILIAS.
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:

◆ viewObject()

ilObjLanguageExtGUI::viewObject ( int  $changesSuccessBool = 0)

Show the edit screen.

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

References $comments, ilObjectGUI\$data, $DIC, ilObjectGUI\$tpl, ilObjLanguageExt\_getRemarks(), ilObjLanguageAccess\_getSavedModules(), ilObjLanguageAccess\_getSavedTopics(), ilObjLanguageExt\_getValues(), ilObjLanguageAccess\_isPageTranslation(), buildMissingEntries(), getSuccessMessage(), getViewTable(), ILIAS\FileDelivery\http(), ILIAS\Repository\lng(), ILIAS\Repository\object(), ILIAS\Repository\refinery(), ilGlobalTemplateInterface\setContent(), and ilGlobalTemplateInterface\setVariable().

167  : void
168  {
169  global $DIC;
170  $tpl = $DIC["tpl"];
171 
172  // get the view table
173  $table_gui = $this->getViewTable();
174 
175  // get the remarks in database
176  $comments = $this->object->getAllRemarks();
177 
178  $compare_comments = [];
179  $missing_entries = [];
180 
181  // set the language to compare with
182  // get the default values if the compare language is the same
183  $compare = $table_gui->getFilterItemByPostVar("compare")->getValue();
184  if ($compare == $this->object->key) {
185  $compare_object = $this->object->getGlobalLanguageFile();
186  $compare_content = $compare_object->getAllValues();
187  $compare_comments = $compare_object->getAllComments();
188  }
189 
190  // page translation mode:
191  // - the table is filtered by a list of modules and topics
193  // get the selection of modules and topics from request or session
196 
197  $reset_offset_get = false;
198  if ($this->http->wrapper()->query()->has("reset_offset")) {
199  $reset_offset_get = $this->http->wrapper()->query()->retrieve(
200  "reset_offset",
201  $this->refinery->kindlyTo()->bool()
202  );
203  }
204 
205  // first call for translation
206  if ($reset_offset_get) {
207  $table_gui->resetOffset();
208  }
209 
210  if (!isset($compare_content)) {
211  $compare_content = ilObjLanguageExt::_getValues(
212  $compare,
213  $modules,
214  $topics
215  );
216 
217  $compare_comments = ilObjLanguageExt::_getRemarks($compare);
218  }
219 
220  $translations = ilObjLanguageExt::_getValues(
221  $this->object->key,
222  $modules,
223  $topics
224  );
225 
226  // enable adding new entries
227  $db_found = array();
228  foreach ($translations as $name => $translation) {
229  $keys = explode($this->lng->separator, $name);
230  $db_found[] = $keys[1];
231  }
232  $missing_entries = array_diff($topics, $db_found);
233  } else { // normal view mode:
234  // - the table is filtered manually by module, mode and pattern
235  $filter_mode = $table_gui->getFilterItemByPostVar("mode")->getValue();
236  $filter_pattern = $table_gui->getFilterItemByPostVar("pattern")->getValue();
237  $filter_module = $table_gui->getFilterItemByPostVar("module")->getValue();
238  $filter_module = $filter_module === "all" ? "" : $filter_module;
239  $filter_modules = $filter_module ? array($filter_module) : array();
240  $filter_identifier = $table_gui->getFilterItemByPostVar("identifier")->getValue();
241  $filter_topics = $filter_identifier ? array($filter_identifier) : array();
242 
243  if (!isset($compare_content)) {
244  $compare_content = ilObjLanguageExt::_getValues(
245  $compare,
246  $filter_modules,
247  $filter_topics
248  );
249 
250  $compare_comments = ilObjLanguageExt::_getRemarks($compare);
251  }
252 
253  switch ($filter_mode) {
254  case "changed":
255  $translations = $this->object->getChangedValues(
256  $filter_modules,
257  $filter_pattern,
258  $filter_topics
259  );
260  break;
261 
262  case "added": //langmode only
263  $translations = $this->object->getAddedValues(
264  $filter_modules,
265  $filter_pattern,
266  $filter_topics
267  );
268  break;
269 
270  case "unchanged":
271  $translations = $this->object->getUnchangedValues(
272  $filter_modules,
273  $filter_pattern,
274  $filter_topics
275  );
276  break;
277 
278  case "commented":
279  $translations = $this->object->getCommentedValues(
280  $filter_modules,
281  $filter_pattern,
282  $filter_topics
283  );
284  break;
285 
286  case "dbremarks":
287  $translations = $this->object->getAllValues(
288  $filter_modules,
289  $filter_pattern,
290  $filter_topics
291  );
292 
293  $translations = array_intersect_key($translations, $comments);
294  break;
295 
296  case "equal":
297  $translations = $this->object->getAllValues(
298  $filter_modules,
299  $filter_pattern,
300  $filter_topics
301  );
302 
303  $translations = array_intersect_assoc($translations, $compare_content);
304  break;
305 
306  case "different":
307  $translations = $this->object->getAllValues(
308  $filter_modules,
309  $filter_pattern,
310  $filter_topics
311  );
312 
313  $translations = array_diff_assoc($translations, $compare_content);
314  break;
315 
316  case "conflicts":
317  $former_file = $this->object->getDataPath() . "/ilias_" . $this->object->key . ".lang";
318  if (!is_readable($former_file)) {
319  $this->tpl->setOnScreenMessage('failure', sprintf($this->lng->txt("language_former_file_missing"), $former_file)
320  . '<br />' . $this->lng->txt("language_former_file_description"), false);
321  $translations = array();
322  break;
323  }
324  $global_file_obj = $this->object->getGlobalLanguageFile();
325  $former_file_obj = new ilLanguageFile($former_file);
326  $former_file_obj->read();
327  $global_changes = array_diff_assoc(
328  $global_file_obj->getAllValues(),
329  $former_file_obj->getAllValues()
330  );
331  if (!count($global_changes)) {
332  $this->tpl->setOnScreenMessage('info', sprintf($this->lng->txt("language_former_file_equal"), $former_file)
333  . '<br />' . $this->lng->txt("language_former_file_description"), false);
334  $translations = array();
335  break;
336  }
337  $translations = $this->object->getChangedValues(
338  $filter_modules,
339  $filter_pattern,
340  $filter_topics
341  );
342 
343  $translations = array_intersect_key($translations, $global_changes);
344  break;
345 
346  case "all":
347  default:
348  $translations = $this->object->getAllValues(
349  $filter_modules,
350  $filter_pattern,
351  $filter_topics
352  );
353  }
354  }
355 
356  // prepare the the data for the table
357  $data = array();
358  foreach ($translations as $name => $translation) {
359  $keys = explode($this->lng->separator, $name);
360  $row = array();
361 
362  $row["module"] = $keys[0];
363  $row["topic"] = $keys[1];
364  $row["name"] = $name;
365  $row["translation"] = $translation;
366  $row["comment"] = $comments[$name] ?? "";
367  $row["default"] = $compare_content[$name] ?? "";
368  $row["default_comment"] = $compare_comments[$name] ?? "";
369 
370  $data[] = $row;
371  }
372 
373  if ($changesSuccessBool) {
374  $tpl->setVariable("MESSAGE", $this->getSuccessMessage());
375  }
376 
377  // render and show the table
378  $table_gui->setData($data);
379  $tpl->setContent($table_gui->getHTML() . $this->buildMissingEntries($missing_entries));
380  }
getSuccessMessage()
Get success message after variables were saved.
static _isPageTranslation()
Check if the current request is a page translation.
static _getSavedModules()
Get the stored modules from the user session.
getViewTable()
Get the table to view language entries.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
global $DIC
Definition: feed.php:28
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.
static http()
Fetches the global http state from ILIAS.
ilGlobalTemplateInterface $tpl
setContent(string $a_html)
Sets content for standard template.
$comments
buildMissingEntries(array $a_missing=null)
static _getSavedTopics()
Get the stored topics from the user session.
Class ilLanguageFile.
static _getRemarks(string $a_lang_key, bool $a_all_changed=false)
Get all remarks of a language.
+ Here is the call graph for this function:

Field Documentation

◆ $http

HTTPServices ilObjLanguageExtGUI::$http
protected

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

◆ $langmode

string ilObjLanguageExtGUI::$langmode
private

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

◆ $refinery

Refinery ilObjLanguageExtGUI::$refinery
protected

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

◆ ILIAS_LANGUAGE_MODULE

const ilObjLanguageExtGUI::ILIAS_LANGUAGE_MODULE = "Services/Language"
private

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


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