ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilObjLanguageExtGUI Class Reference

Class ilObjLanguageExtGUI. More...

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

Public Member Functions

 __construct ($a_data, $a_id=0, $a_call_by_reference=false)
 Constructor. More...
 
 assignObject ()
 Assign the extended language object. More...
 
 getId ()
 get the language object id (needed for filter serialization) More...
 
 executeCommand ()
 execute command More...
 
 cancelObject ()
 Cancel the current action. More...
 
 viewObject ($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 ()
 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...
 
 addAdminLocatorItems ($a_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...
 
 addNewEntryObject (ilPropertyFormGUI $a_form=null)
 
 saveNewEntryObject ()
 
- Public Member Functions inherited from ilObjectGUI
 executeCommand ()
 execute command More...
 
 withReferences ()
 determines wether objects are referenced or not (got ref ids or not) More...
 
 setCreationMode ($a_mode=true)
 if true, a creation screen is displayed the current $_GET[ref_id] don't belong to the current class! the mode is determined in ilrepositorygui More...
 
 getCreationMode ()
 get creation mode More...
 
 prepareOutput ($a_show_subobjects=true)
 prepare output More...
 
 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...
 
 cancelDeleteObject ()
 cancel deletion of object More...
 
 cancelObject ()
 cancel action and go back to previous page public More...
 
 createObject ()
 create new object form More...
 
 cancelCreation ()
 cancel create action and go back to repository parent More...
 
 saveObject ()
 save object More...
 
 getDidacticTemplateVar ($a_type)
 Get didactic template setting from creation screen. More...
 
 putObjectInTree (ilObject $a_obj, $a_parent_node_id=null)
 Add object to tree at given position. More...
 
 editObject ()
 edit object More...
 
 addExternalEditFormCustom (ilPropertyFormGUI $a_form)
 
 updateObject ()
 updates object entry in object_data More...
 
 getFormAction ($a_cmd, $a_formaction="")
 get form action for command (command is method name without "Object", e.g. More...
 
 isVisible ($a_ref_id, $a_type)
 
 viewObject ()
 viewObject container presentation for "administration -> repository, trash, permissions" More...
 
 deleteObject ($a_error=false)
 Display deletion confirmation screen. More...
 
 cloneAllObject ()
 Clone single (not container object) Method is overwritten in ilContainerGUI. More...
 
 redirectAfterCreation ()
 Redirect after creation, see https://docu.ilias.de/goto_docu_wiki_wpage_5035_1357.html. More...
 
 addToDeskObject ()
 
 removeFromDeskObject ()
 

Protected Member Functions

 getViewTable ()
 Get the table to view language entries. More...
 
 buildMissingEntries (array $a_missing=null)
 
 initAddNewEntryForm ($a_id=null)
 
 getSuccessMessage ()
 Get success message after variables were saved. More...
 
- Protected Member Functions inherited from ilObjectGUI
 getObjectService ()
 Get object service. More...
 
 assignObject ()
 
 setTitleAndDescription ()
 called by prepare output More...
 
 initHeaderAction ($a_sub_type=null, $a_sub_id=null)
 Add header action menu. More...
 
 insertHeaderAction ($a_list_gui)
 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 public More...
 
 setAdminTabs ()
 set admin tabs public More...
 
 setLocator ()
 set Locator More...
 
 addLocatorItems ()
 should be overwritten to add object specific items (repository items are preloaded) More...
 
 omitLocator ($a_omit=true)
 
 addAdminLocatorItems ($a_do_not_add_object=false)
 should be overwritten to add object specific items (repository items are preloaded) More...
 
 initCreationForms ($a_new_type)
 Init creation froms. More...
 
 getCreationFormsHTML (array $a_forms)
 Get HTML for creation forms (accordion) More...
 
 initCreateForm ($a_new_type)
 Init object creation form. More...
 
 initDidacticTemplate (ilPropertyFormGUI $form)
 Show didactic template types. More...
 
 addDidacticTemplateOptions (array &$a_options)
 Add custom templates. More...
 
 afterSave (ilObject $a_new_object)
 Post (successful) object creation hook. More...
 
 initEditForm ()
 Init object edit form. More...
 
 initEditCustomForm (ilPropertyFormGUI $a_form)
 Add custom fields to update form. More...
 
 getEditFormValues ()
 Get values for edit form. More...
 
 getEditFormCustomValues (array &$a_values)
 Add values to custom edit fields. More...
 
 validateCustom (ilPropertyFormGUI $a_form)
 Validate custom values (if not possible with checkInput()) More...
 
 updateCustom (ilPropertyFormGUI $a_form)
 Insert custom update form values into object. More...
 
 afterUpdate ()
 Post (successful) object update hook. More...
 
 initImportForm ($a_new_type)
 Init object import form. More...
 
 importFileObject ($parent_id=null, $a_catch_errors=true)
 Import. More...
 
 afterImport (ilObject $a_new_object)
 Post (successful) object import hook. More...
 
 setFormAction ($a_cmd, $a_formaction)
 set specific form action for command More...
 
 getReturnLocation ($a_cmd, $a_location="")
 get return location for command (command is method name without "Object", e.g. More...
 
 setReturnLocation ($a_cmd, $a_location)
 set specific return location for command More...
 
 getTargetFrame ($a_cmd, $a_target_frame="")
 get target frame for command (command is method name without "Object", e.g. More...
 
 setTargetFrame ($a_cmd, $a_target_frame)
 set specific target frame for command More...
 
 showPossibleSubObjects ()
 show possible subobjects (pulldown menu) More...
 
 getTemplateFile ($a_cmd, $a_type="")
 get a template blockfile format: tpl. More...
 
 getTabs ()
 get tabs abstract method. More...
 
 __showButton ($a_cmd, $a_text, $a_target='')
 
 hitsperpageObject ()
 
__initTableGUI ()
 
 __setTableGUIBasicData (&$tbl, &$result_set, $a_from="")
 standard implementation for tables use 'from' variable use different initial setting of table More...
 
 redirectToRefId ($a_ref_id, $a_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 $_GET["ref_id"] value More...
 
 fillCloneTemplate ($a_tpl_varname, $a_type)
 Fill object clone template This method can be called from any object GUI class that wants to offer object cloning. More...
 
 getCenterColumnHTML ()
 Get center column. More...
 
 getRightColumnHTML ()
 Display right column. More...
 
 setColumnSettings (ilColumnGUI $column_gui)
 May be overwritten in subclasses. More...
 
 checkPermission ($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
 Check permission and redirect on error. More...
 
 checkPermissionBool ($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
 Check permission. More...
 
 enableDragDropFileUpload ()
 Enables the file upload into this object by dropping files. More...
 
 handleAutoRating (ilObject $a_new_obj)
 Activate rating automatically if parent container setting. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from ilObjectGUI
static _gotoRepositoryRoot ($a_raise_error=false)
 Goto repository root. More...
 
static _gotoRepositoryNode ($a_ref_id, $a_cmd="frameset")
 Goto repository root. More...
 
- Data Fields inherited from ilObjectGUI
const COPY_WIZARD_NEEDS_PAGE = 1
 
 $objDefinition
 
 $tpl
 
 $tree
 
 $lng
 
 $data
 
 $object
 
 $ref_id
 
 $obj_id
 
 $maxcount
 
 $formaction
 
 $return_location
 
 $target_frame
 
 $tab_target_script
 
 $actions
 
 $sub_objects
 
 $omit_locator = false
 
const CFORM_NEW = 1
 
const CFORM_IMPORT = 2
 
const CFORM_CLONE = 3
 
- Protected Attributes inherited from ilObjectGUI
 $ilErr
 
 $locator
 
 $user
 
 $access
 
 $rbacsystem
 
 $settings
 
 $rbacreview
 
 $toolbar
 
 $tmp_import_dir
 
 $tabs_gui = null
 
 $ctrl
 
 $object_service
 
 $favourites
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjLanguageExtGUI::__construct (   $a_data,
  $a_id = 0,
  $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
mixeddata (ignored)
intid (ignored)
booleancall-by-reference (ignored)

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

References $_GET, $_SESSION, $DIC, $ilCtrl, ilObjectGUI\$lng, ILIAS\GlobalScreen\Provider\__construct(), and ilObjLanguageAccess\_lookupId().

41  {
42  global $DIC;
43  $ilClientIniFile = $DIC->clientIni();
44  $ilCtrl = $DIC->ctrl();
45  $lng = $DIC->language();
46 
47  // language maintenance strings are defined in administration
48  $lng->loadLanguageModule("administration");
49  $lng->loadLanguageModule("meta");
50 
51  // view mode ('translate' or empty) determins available table filters
52  $ilCtrl->saveParameter($this, "view_mode");
53 
54  // type and id of get the bound object
55  $this->type = "lng";
56  if (!$this->id = $_GET['obj_id']) {
57  $this->id = ilObjLanguageAccess::_lookupId($lng->getUserLanguage());
58  }
59 
60  // do all generic GUI initialisations
61  parent::__construct($a_data, $this->id, false, true);
62 
63  // initialize the array to store session variables for extended language maintenance
64  if (!is_array($_SESSION['lang_ext_maintenance'])) {
65  $_SESSION['lang_ext_maintenance'] = array();
66  }
67  $this->session = &$_SESSION['lang_ext_maintenance'];
68 
69 
70  // read the lang mode
71  $this->langmode = $ilClientIniFile->readVariable("system", "LANGMODE");
72  }
$_SESSION["AccountId"]
$_GET["client_id"]
static _lookupId($a_key)
Lookup the object ID for a language key.
global $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

Member Function Documentation

◆ addAdminLocatorItems()

ilObjLanguageExtGUI::addAdminLocatorItems (   $a_do_not_add_object = false)

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

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

References $DIC, and ilObjLanguageAccess\_isPageTranslation().

864  {
865  global $DIC;
866  $ilLocator = $DIC['ilLocator'];
867 
869  parent::addAdminLocatorItems(true); // #13881
870 
871  $ilLocator->addItem(
872  $this->lng->txt("languages"),
873  $this->ctrl->getLinkTargetByClass("ilobjlanguagefoldergui", "")
874  );
875 
876  $ilLocator->addItem(
877  $this->lng->txt("meta_l_" . $this->object->getTitle()),
878  $this->ctrl->getLinkTarget($this, "view")
879  );
880  }
881  }
static _isPageTranslation()
Check if the current request is a page translation.
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

◆ addNewEntryObject()

ilObjLanguageExtGUI::addNewEntryObject ( ilPropertyFormGUI  $a_form = null)

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

References $_GET, $DIC, ilObjectGUI\$tpl, and initAddNewEntryForm().

Referenced by saveNewEntryObject().

930  {
931  global $DIC;
932  $tpl = $DIC['tpl'];
933 
934  $id = trim($_GET["eid"]);
935 
936  if (!$a_form) {
937  $a_form = $this->initAddNewEntryForm($id);
938  }
939 
940  $tpl->setContent($a_form->getHTML());
941  }
$_GET["client_id"]
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyFilterObject()

ilObjLanguageExtGUI::applyFilterObject ( )

Apply filter.

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

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

356  {
357  $table_gui = $this->getViewTable();
358  $table_gui->writeFilterToSession(); // writes filter to session
359  $table_gui->resetOffset(); // sets record offest to 0 (first page)
360  $this->viewObject();
361  }
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 ( )

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

82  {
83  require_once("Services/Language/classes/class.ilObjLanguageExt.php");
84  $this->object = new ilObjLanguageExt($this->id);
85  }
Class ilObjLanguageExt.

◆ buildMissingEntries()

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

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

References $DIC, $ilCtrl, and $res.

Referenced by viewObject().

905  {
906  global $DIC;
907  $ilCtrl = $DIC->ctrl();
908 
909  if (!is_array($a_missing) ||
910  !sizeof($a_missing)) {
911  return;
912  }
913 
914  $res = array('<h3>' . $this->lng->txt("adm_missing_entries") . '</h3>', '<ul>');
915 
916  foreach ($a_missing as $entry) {
917  $ilCtrl->setParameter($this, "eid", $entry);
918  $res[] = '<li>' . $entry .
919  ' <a href="' . $ilCtrl->getLinkTarget($this, "addNewEntry") .
920  '">' . $this->lng->txt("adm_missing_entry_add_action") . '</a></li>';
921  $ilCtrl->setParameter($this, "eid", "");
922  }
923 
924  $res[] = '</ul>';
925 
926  return implode("\n", $res);
927  }
global $ilCtrl
Definition: ilias.php:18
foreach($_POST as $key=> $value) $res
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ cancelObject()

ilObjLanguageExtGUI::cancelObject ( )

Cancel the current action.

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

References ilObjectGUI\viewObject().

120  {
121  $this->viewObject();
122  }
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 534 of file class.ilObjLanguageExtGUI.php.

References $_POST, $filename, ilUtil\deliverData(), ILIAS_VERSION, and ilUtil\stripSlashes().

535  {
536  // save the selected scope
537  $this->session["export"]["scope"] = ilUtil::stripSlashes($_POST["scope"]);
538 
539  $filename = 'ilias_' . $this->object->key . '_'
540  . str_replace(".", "_", substr(ILIAS_VERSION, 0, strpos(ILIAS_VERSION, " ")))
541  . "-" . date('Y-m-d')
542  . ".lang." . $this->session["export"]["scope"];
543 
544  $global_file_obj = $this->object->getGlobalLanguageFile();
545  $local_file_obj = new ilLanguageFile($filename, $this->object->key, $_POST["scope"]);
546 
547  if ($_POST["scope"] == 'global') {
548  $local_file_obj->setParam("author", $global_file_obj->getParam('author'));
549  $local_file_obj->setParam("version", $global_file_obj->getParam('version'));
550  $local_file_obj->setAllValues($this->object->getAllValues());
551  if ($this->langmode) {
552  $local_file_obj->setAllComments($this->object->getAllRemarks());
553  }
554  } elseif ($_POST["scope"] == 'local') {
555  $local_file_obj->setParam("based_on", $global_file_obj->getParam('version'));
556  $local_file_obj->setAllValues($this->object->getChangedValues());
557  if ($this->langmode) {
558  $local_file_obj->setAllComments($this->object->getAllRemarks());
559  }
560  } elseif ($_POST["scope"] == 'added') { // langmode only
561  $local_file_obj->setParam("author", $global_file_obj->getParam('author'));
562  $local_file_obj->setParam("version", $global_file_obj->getParam('version'));
563  $local_file_obj->setAllValues($this->object->getAddedValues());
564  $local_file_obj->setAllComments($this->object->getAllRemarks());
565  } elseif ($_POST["scope"] == 'unchanged') {
566  $local_file_obj->setParam("author", $global_file_obj->getParam('author'));
567  $local_file_obj->setParam("version", $global_file_obj->getParam('version'));
568  $local_file_obj->setAllValues($this->object->getUnchangedValues());
569  if ($this->langmode) {
570  $local_file_obj->setAllComments($this->object->getAllRemarks());
571  }
572  } elseif ($_POST["scope"] == 'merged') { // langmode only
573  $local_file_obj->setParam("author", $global_file_obj->getParam('author'));
574  $local_file_obj->setParam("version", $global_file_obj->getParam('version'));
575  $local_file_obj->setAllValues($this->object->getMergedValues());
576  $local_file_obj->setAllComments($this->object->getMergedRemarks());
577  }
578 
579  ilUtil::deliverData($local_file_obj->build(), $filename);
580  }
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
const ILIAS_VERSION
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$filename
Definition: buildRTE.php:89
Class ilLanguageFile.
$_POST["username"]
+ Here is the call graph for this function:

◆ executeCommand()

ilObjLanguageExtGUI::executeCommand ( )

execute command

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

References $DIC, ilObjLanguageAccess\_checkMaintenance(), and exit.

100  {
101  global $DIC;
102  $ilHelp = $DIC->help();
103 
105  $this->ilErr->raiseError($this->lng->txt("permission_denied"), $this->ilErr->MESSAGE);
106  exit;
107  }
108 
109  $cmd = $this->ctrl->getCmd("view") . "Object";
110  $this->$cmd();
111 
112  $ilHelp->setScreenIdComponent("lng");
113  }
exit
Definition: login.php:29
static _checkMaintenance()
Permission check for language maintenance (import/export)
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

◆ exportObject()

ilObjLanguageExtGUI::exportObject ( )

Show the screen to export a language file.

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

References ilFormPropertyGUI\setInfo().

495  {
496  require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
497  $form = new ilPropertyFormGUI();
498  $form->setFormAction($this->ctrl->getFormAction($this));
499  $form->setTitle($this->lng->txt("language_export_file"));
500  $form->setPreventDoubleSubmission(false);
501  $form->addCommandButton('download', $this->lng->txt("download"));
502 
503  $rg = new ilRadioGroupInputGUI($this->lng->txt("language_file_scope"), "scope");
504  $ro = new ilRadioOption($this->lng->txt("language_scope_global"), "global");
505  $ro->setInfo($this->lng->txt("language_scope_global_info"));
506  $rg->addOption($ro);
507  $ro = new ilRadioOption($this->lng->txt("language_scope_local"), "local");
508  $ro->setInfo($this->lng->txt("language_scope_local_info"));
509  $rg->addOption($ro);
510  if ($this->langmode) {
511  $ro = new ilRadioOption($this->lng->txt("language_scope_added"), "added");
512  $ro->setInfo($this->lng->txt("language_scope_added_info"));
513  $rg->addOption($ro);
514  }
515  $ro = new ilRadioOption($this->lng->txt("language_scope_unchanged"), "unchanged");
516  $ro->setInfo($this->lng->txt("language_scope_unchanged_info"));
517  $rg->addOption($ro);
518  if ($this->langmode) {
519  $ro = new ilRadioOption($this->lng->txt("language_scope_merged"), "merged");
520  $ro->setInfo($this->lng->txt("language_scope_merged_info"));
521  $rg->addOption($ro);
522  }
523 
524  $rg->setValue($this->session["export"]["scope"] ? $this->session["export"]["scope"] : "global");
525  $form->addItem($rg);
526 
527  $this->tpl->setContent($form->getHTML());
528  }
This class represents an option in a radio group.
This class represents a property form user interface.
setInfo($a_info)
Set Information Text.
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)

Parameters
objecttabs gui object

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

References $DIC, $ilCtrl, and ilObjLanguageAccess\_isPageTranslation().

797  {
798  global $DIC;
799  $ilCtrl = $DIC->ctrl();
800  $cmd = $ilCtrl->getCmd();
801 
803  $this->tabs_gui->setBackTarget(
804  $this->lng->txt('back'),
805  $this->ctrl->getLinkTargetByClass('ilObjLanguageFolderGUI')
806  );
807 
808  $this->tabs_gui->addTab(
809  "edit",
810  $this->lng->txt("edit"),
811  $this->ctrl->getLinkTarget($this, "view")
812  );
813 
814  $this->tabs_gui->addTab(
815  "export",
816  $this->lng->txt('export'),
817  $this->ctrl->getLinkTarget($this, "export")
818  );
819 
820  $this->tabs_gui->addTab(
821  "import",
822  $this->lng->txt('import'),
823  $this->ctrl->getLinkTarget($this, "import")
824  );
825 
826  $this->tabs_gui->addTab(
827  "maintain",
828  $this->lng->txt('language_maintain'),
829  $this->ctrl->getLinkTarget($this, "maintain")
830  );
831 
832  $this->tabs_gui->addTab(
833  "settings",
834  $this->lng->txt('settings'),
835  $this->ctrl->getLinkTarget($this, "settings")
836  );
837 
838  $this->tabs_gui->addTab(
839  "statistics",
840  $this->lng->txt("language_statistics"),
841  $this->ctrl->getLinkTarget($this, "statistics")
842  );
843 
844  switch ($cmd) {
845  case '':
846  case 'view':
847  case 'applyFilter':
848  case 'resetFilter':
849  case 'save':
850  $this->tabs_gui->activateTab('edit');
851  break;
852  default:
853  $this->tabs_gui->activateTab($cmd);
854  }
855  }
856  }
static _isPageTranslation()
Check if the current request is a page translation.
global $ilCtrl
Definition: ilias.php:18
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

◆ getId()

ilObjLanguageExtGUI::getId ( )

get the language object id (needed for filter serialization)

Returns
int language object id

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

92  {
93  return $this->id;
94  }

◆ getSuccessMessage()

ilObjLanguageExtGUI::getSuccessMessage ( )
protected

Get success message after variables were saved.

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

References $DIC, Vendor\Package\$f, and ilObjectGUI\$lng.

Referenced by viewObject().

1040  {
1041  global $DIC;
1042  $f = $DIC->ui()->factory();
1043  $renderer = $DIC->ui()->renderer();
1044  $lng = $this->lng;
1045 
1046  return $renderer->render($f->messageBox()->success($this->lng->txt("language_variables_saved")));
1047  }
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ getViewTable()

ilObjLanguageExtGUI::getViewTable ( )
protected

Get the table to view language entries.

Returns
ilLanguageExtTableGUI

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

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

130  {
131  // create and configure the table object
132  include_once './Services/Language/classes/class.ilLanguageExtTableGUI.php';
133  $table_gui = new ilLanguageExtTableGUI($this, 'view', array(
134  'langmode' => $this->langmode,
135  'lang_key' => $this->object->key,
136  ));
137 
138  return $table_gui;
139  }
+ Here is the caller graph for this function:

◆ importObject()

ilObjLanguageExtGUI::importObject ( )

Show the screen to import a language file.

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

References ilFormPropertyGUI\setInfo().

420  {
421  require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
422  $form = new ilPropertyFormGUI();
423  $form->setFormAction($this->ctrl->getFormAction($this));
424  $form->setTitle($this->lng->txt("language_import_file"));
425  $form->addCommandButton('upload', $this->lng->txt("upload"));
426 
427  $fu = new ilFileInputGUI($this->lng->txt("file"), "userfile");
428  $form->addItem($fu);
429 
430  $rg = new ilRadioGroupInputGUI($this->lng->txt("language_mode_existing"), "mode_existing");
431  $ro = new ilRadioOption($this->lng->txt("language_mode_existing_keepall"), "keepall");
432  $ro->setInfo($this->lng->txt("language_mode_existing_keepall_info"));
433  $rg->addOption($ro);
434  $ro = new ilRadioOption($this->lng->txt("language_mode_existing_keepnew"), "keepnew");
435  $ro->setInfo($this->lng->txt("language_mode_existing_keepnew_info"));
436  $rg->addOption($ro);
437  $ro = new ilRadioOption($this->lng->txt("language_mode_existing_replace"), "replace");
438  $ro->setInfo($this->lng->txt("language_mode_existing_replace_info"));
439  $rg->addOption($ro);
440  $ro = new ilRadioOption($this->lng->txt("language_mode_existing_delete"), "delete");
441  $ro->setInfo($this->lng->txt("language_mode_existing_delete_info"));
442  $rg->addOption($ro);
443  $rg->setValue($this->session["import"]["mode_existing"] ? $this->session["import"]["mode_existing"] : "keepall");
444  $form->addItem($rg);
445 
446  $this->tpl->setContent($form->getHTML());
447  }
This class represents an option in a radio group.
This class represents a property form user interface.
This class represents a file property in a property form.
setInfo($a_info)
Set Information Text.
This class represents a property in a property form.
+ Here is the call graph for this function:

◆ initAddNewEntryForm()

ilObjLanguageExtGUI::initAddNewEntryForm (   $a_id = null)
protected

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

References $_POST, $DIC, $ilCtrl, ilObjLanguageAccess\_getSavedModules(), and ilObjLanguageAccess\_getSavedTopics().

Referenced by addNewEntryObject(), and saveNewEntryObject().

944  {
945  global $DIC;
946  $ilCtrl = $DIC->ctrl();
947 
948  if (!$a_id) {
949  $a_id = $_POST["id"];
950  }
951 
952  if (!$a_id ||
953  !in_array($a_id, ilObjLanguageAccess::_getSavedTopics())) {
954  $ilCtrl->redirect($this, "view");
955  }
956 
957  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
958  $form = new ilPropertyFormGUI();
959  $form->setFormAction($ilCtrl->getFormAction($this, "saveNewEntry"));
960  $form->setTitle($this->lng->txt("adm_missing_entry_add"));
961 
963  $options = array_combine($mods, $mods);
964 
965  $mod = new ilSelectInputGUI(ucfirst($this->lng->txt("module")), "mod");
966  $mod->setOptions(array("" => $this->lng->txt("please_select")) + $options);
967  $mod->setRequired(true);
968  $form->addItem($mod);
969 
970  $id = new ilTextInputGUI(ucfirst($this->lng->txt("identifier")), "id");
971  $id->setValue($a_id);
972  $id->setDisabled(true);
973  $form->addItem($id);
974 
975  foreach ($this->lng->getInstalledLanguages() as $lang_key) {
976  $trans = new ilTextInputGUI($this->lng->txt("meta_l_" . $lang_key), "trans_" . $lang_key);
977  if (in_array($lang_key, array("de", "en"))) {
978  $trans->setRequired(true);
979  }
980  $form->addItem($trans);
981  }
982 
983  $form->addCommandButton("saveNewEntry", $this->lng->txt("save"));
984  $form->addCommandButton("view", $this->lng->txt("cancel"));
985 
986  return $form;
987  }
This class represents a property form user interface.
static _getSavedModules()
Get the stored modules from the user session.
global $ilCtrl
Definition: ilias.php:18
static _getSavedTopics()
Get the stored topics from the user session.
$DIC
Definition: xapitoken.php:46
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maintainExecuteObject()

ilObjLanguageExtGUI::maintainExecuteObject ( )

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

References $_POST, ilObjLanguageExt\_deleteValues(), ilUtil\sendFailure(), and ilUtil\stripSlashes().

624  {
625  if (isset($_POST["maintain"])) {
626  $this->session["maintain"] = ilUtil::stripSlashes($_POST["maintain"]);
627  }
628 
629  switch ($_POST["maintain"]) {
630  // save the global language file for merge after
631  case "save_dist":
632 
633  // save a copy of the distributed language file
634  $orig_file = $this->object->getLangPath() . '/ilias_' . $this->object->key . '.lang';
635  $copy_file = $this->object->getDataPath() . '/ilias_' . $this->object->key . '.lang';
636  if (@copy($orig_file, $copy_file)) {
637  ilUtil::sendSuccess($this->lng->txt("language_saved_dist"), true);
638  } else {
639  ilUtil::sendFailure($this->lng->txt("language_save_dist_failed"), true);
640  }
641  break;
642 
643  // load the content of the local language file
644  case "load":
645  $lang_file = $this->object->getCustLangPath() . '/ilias_' . $this->object->key . '.lang.local';
646  if (is_file($lang_file) and is_readable($lang_file)) {
647  $this->object->importLanguageFile($lang_file, 'replace');
648  $this->object->setLocal(true);
649  ilUtil::sendSuccess($this->lng->txt("language_loaded_local"), true);
650  } else {
651  ilUtil::sendFailure($this->lng->txt("language_error_read_local"), true);
652  }
653  break;
654 
655  // revert the database to the default language file
656  case "clear":
657  $lang_file = $this->object->getLangPath() . '/ilias_' . $this->object->key . '.lang';
658  if (is_file($lang_file) and is_readable($lang_file)) {
659  $this->object->importLanguageFile($lang_file, 'delete');
660  $this->object->setLocal(false);
661  ilUtil::sendSuccess($this->lng->txt("language_cleared_local"), true);
662  } else {
663  ilUtil::sendFailure($this->lng->txt("language_error_clear_local"), true);
664  }
665  break;
666 
667  // delete local additions in the datavase (langmode only)
668  case "delete_added":
669  ilObjLanguageExt::_deleteValues($this->object->key, $this->object->getAddedValues());
670  break;
671 
672  // merge local changes back to the global language file (langmode only)
673  case "merge":
674 
675  $orig_file = $this->object->getLangPath() . '/ilias_' . $this->object->key . '.lang';
676  $copy_file = $this->object->getCustLangPath() . '/ilias_' . $this->object->key . '.lang';
677 
678  if (is_file($orig_file) and is_writable($orig_file)) {
679  // save a copy of the global language file
680  @copy($orig_file, $copy_file);
681 
682  // modify and write the new global file
683  $global_file_obj = $this->object->getGlobalLanguageFile();
684  $global_file_obj->setAllValues($this->object->getMergedValues());
685  $global_file_obj->setAllComments($this->object->getMergedRemarks());
686  $global_file_obj->write();
687  ilUtil::sendSuccess($this->lng->txt("language_merged_global"), true);
688  } else {
689  ilUtil::sendFailure($this->lng->txt("language_error_write_global"), true);
690  }
691  break;
692 
693  // remove the local language file (langmode only)
694  case "remove_local_file":
695  $lang_file = $this->object->getCustLangPath() . '/ilias_' . $this->object->key . '.lang.local';
696 
697  if (!is_file($lang_file)) {
698  $this->object->setLocal(false);
699  ilUtil::sendFailure($this->lng->txt("language_error_local_missed"), true);
700  } elseif (@unlink($lang_file)) {
701  $this->object->setLocal(false);
702  ilUtil::sendSuccess($this->lng->txt("language_local_file_deleted"), true);
703  } else {
704  ilUtil::sendFailure($this->lng->txt("language_error_delete_local"), true);
705  }
706  break;
707  }
708 
709  $this->ctrl->redirect($this, "maintain");
710  }
static _deleteValues($a_lang_key, $a_values=array())
Delete a set of translation in the database.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:

◆ maintainObject()

ilObjLanguageExtGUI::maintainObject ( )

Process the language maintenance.

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

References ilFormPropertyGUI\setInfo().

587  {
588  require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
589  $form = new ilPropertyFormGUI();
590  $form->setFormAction($this->ctrl->getFormAction($this));
591  $form->setTitle($this->lng->txt("language_maintenance"));
592  $form->setPreventDoubleSubmission(false);
593  $form->addCommandButton('maintainExecute', $this->lng->txt("language_process_maintenance"));
594 
595  $rg = new ilRadioGroupInputGUI($this->lng->txt("language_maintain_local_changes"), "maintain");
596  $ro = new ilRadioOption($this->lng->txt("language_load_local_changes"), "load");
597  $ro->setInfo(sprintf($this->lng->txt("language_load_local_changes_info"), $this->object->key));
598  $rg->addOption($ro);
599  $ro = new ilRadioOption($this->lng->txt("language_clear_local_changes"), "clear");
600  $ro->setInfo(sprintf($this->lng->txt("language_clear_local_changes_info"), $this->object->key));
601  $rg->addOption($ro);
602  if ($this->langmode) {
603  $ro = new ilRadioOption($this->lng->txt("language_delete_local_additions"), "delete_added");
604  $ro->setInfo(sprintf($this->lng->txt("language_delete_local_additions_info"), $this->object->key));
605  $rg->addOption($ro);
606  $ro = new ilRadioOption($this->lng->txt("language_remove_local_file"), "remove_local_file");
607  $ro->setInfo(sprintf($this->lng->txt("language_remove_local_file_info"), $this->object->key));
608  $rg->addOption($ro);
609  $ro = new ilRadioOption($this->lng->txt("language_merge_local_changes"), "merge");
610  $ro->setInfo(sprintf($this->lng->txt("language_merge_local_changes_info"), $this->object->key));
611  $rg->addOption($ro);
612  }
613  $ro = new ilRadioOption($this->lng->txt("language_save_dist"), "save_dist");
614  $ro->setInfo(sprintf($this->lng->txt("language_save_dist_info"), $this->object->key));
615  $rg->addOption($ro);
616  $rg->setValue($this->session["maintain"]);
617  $form->addItem($rg);
618 
619  $this->tpl->setContent($form->getHTML());
620  }
This class represents an option in a radio group.
This class represents a property form user interface.
setInfo($a_info)
Set Information Text.
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 366 of file class.ilObjLanguageExtGUI.php.

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

367  {
368  $table_gui = $this->getViewTable();
369  $table_gui->resetOffset(); // sets record offest to 0 (first page)
370  $table_gui->resetFilter(); // clears filter
371  $this->viewObject();
372  }
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 989 of file class.ilObjLanguageExtGUI.php.

References $DIC, $ilCtrl, $ilDB, $ilUser, $lang, addNewEntryObject(), initAddNewEntryForm(), and ilObjLanguage\replaceLangEntry().

990  {
991  global $DIC;
992  $ilDB = $DIC->database();
993  $ilCtrl = $DIC->ctrl();
994  $ilUser = $DIC->user();
995 
996  $form = $this->initAddNewEntryForm();
997  if ($form->checkInput()) {
998  $mod = $form->getInput("mod");
999  $id = $form->getInput("id");
1000 
1001  $lang = array();
1002  foreach ($this->lng->getInstalledLanguages() as $lang_key) {
1003  $trans = trim($form->getInput("trans_" . $lang_key));
1004  if ($trans) {
1005  // add single entry
1007  $mod,
1008  $id,
1009  $lang_key,
1010  $trans,
1011  date("Y-m-d H:i:s"),
1012  $ilUser->getLogin()
1013  );
1014 
1015  // add to serialized module
1016  $set = $ilDB->query("SELECT lang_array FROM lng_modules" .
1017  " WHERE lang_key = " . $ilDB->quote($lang_key, "text") .
1018  " AND module = " . $ilDB->quote($mod, "text"));
1019  $row = $ilDB->fetchAssoc($set);
1020  $entries = unserialize($row["lang_array"]);
1021  if (is_array($entries)) {
1022  $entries[$id] = $trans;
1023  ilObjLanguage::replaceLangModule($lang_key, $mod, $entries);
1024  }
1025  }
1026  }
1027 
1028  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1029  $ilCtrl->redirect($this, "view");
1030  }
1031 
1032  $form->setValuesByPost();
1033  $this->addNewEntryObject($form);
1034  }
global $ilCtrl
Definition: ilias.php:18
$ilUser
Definition: imgupload.php:18
$lang
Definition: xapiexit.php:8
global $ilDB
$DIC
Definition: xapitoken.php:46
addNewEntryObject(ilPropertyFormGUI $a_form=null)
static replaceLangEntry( $a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null, $a_remarks=null)
Replace lang entry.
+ Here is the call graph for this function:

◆ saveObject()

ilObjLanguageExtGUI::saveObject ( )

Save the changed translations.

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

References $_POST, $keys, ilObjLanguageExt\_saveValues(), ilUtil\stripSlashes(), and ilObjectGUI\viewObject().

378  {
379  // no changes have been made yet
380  $changesSuccessBool = 0;
381  // prepare the values to be saved
382  $save_array = array();
383  $remarks_array = array();
384  foreach ($_POST as $key => $value) {
385  // mantis #25237
386  // @see https://php.net/manual/en/language.variables.external.php
387  $key = str_replace('_POSTDOT_', '.', $key);
388  $key = str_replace('_POSTSPACE_', ' ', $key);
389 
390  // example key of variable: 'common#:#access'
391  // example key of comment: 'common#:#access#:#comment'
392  $keys = explode($this->lng->separator, ilUtil::stripSlashes($key, false));
393 
394  if (count($keys) == 2) {
395  // avoid line breaks
396  $value = preg_replace("/(\015\012)|(\015)|(\012)/", "<br />", $value);
397  $value = ilUtil::stripSlashes($value, false);
398  $save_array[$key] = $value;
399 
400  // the comment has the key of the language with the suffix
401  $remarks_array[$key] = $_POST[$key . $this->lng->separator . "comment"];
402  }
403  }
404 
405  // save the translations
406  ilObjLanguageExt::_saveValues($this->object->key, $save_array, $remarks_array);
407 
408  // set successful changes bool to true;
409  $changesSuccessBool = 1;
410 
411  // view the list
412  $this->viewObject($changesSuccessBool);
413  }
viewObject()
viewObject container presentation for "administration -> repository, trash, permissions" ...
$keys
Definition: metadata.php:187
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static _saveValues($a_lang_key, $a_values=array(), $a_remarks=array())
Save a set of translation in the database.
$_POST["username"]
+ Here is the call graph for this function:

◆ settingsObject()

ilObjLanguageExtGUI::settingsObject ( )

Set the language settings.

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

References $_POST, $DIC, $ilSetting, and ilCheckboxInputGUI\setChecked().

716  {
717  global $DIC;
718  $ilSetting = $DIC->settings();
719 
720  $translate_key = "lang_translate_" . $this->object->key;
721 
722  // save and get the page translation setting
723  if (!empty($_POST)) {
724  $ilSetting->set($translate_key, (bool) $_POST["translation"]);
725  ilUtil::sendSuccess($this->lng->txt("settings_saved"));
726  }
727  $translate = $ilSetting->get($translate_key, false);
728 
729  require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
730  $form = new ilPropertyFormGUI();
731  $form->setFormAction($this->ctrl->getFormAction($this));
732  $form->setTitle($this->lng->txt("language_settings"));
733  $form->setPreventDoubleSubmission(false);
734  $form->addCommandButton('settings', $this->lng->txt("language_change_settings"));
735 
736  $ci = new ilCheckboxInputGUI($this->lng->txt("language_translation_enabled"), "translation");
737  $ci->setChecked((bool) $translate);
738  $ci->setInfo($this->lng->txt("language_note_translation"));
739  $form->addItem($ci);
740 
741  $this->tpl->setContent($form->getHTML());
742  }
This class represents a property form user interface.
This class represents a checkbox property in a property form.
setChecked($a_checked)
Set Checked.
global $ilSetting
Definition: privfeed.php:17
$DIC
Definition: xapitoken.php:46
$_POST["username"]
+ Here is the call graph for this function:

◆ setTitleAndDescription()

ilObjLanguageExtGUI::setTitleAndDescription ( )

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

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

References ilObjLanguageAccess\_isPageTranslation(), and ilUtil\getImagePath().

889  {
891  $this->tpl->setHeaderPageTitle($this->lng->txt("translation"));
892  $this->tpl->setTitle($this->lng->txt("translation") . " " . $this->lng->txt("meta_l_" . $this->object->key));
893  } else {
894  $this->tpl->setTitle($this->lng->txt("meta_l_" . $this->object->key));
895  }
896  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lngf.svg"), $this->lng->txt("obj_" . $this->object->getType()));
897  }
static _isPageTranslation()
Check if the current request is a page translation.
static getImagePath($img, $module_path="", $mode="output", $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 747 of file class.ilObjLanguageExtGUI.php.

References ilObjectGUI\$data, $total, ilObjLanguageExt\_getModules(), and ilTable2GUI\EXPORT_EXCEL.

748  {
749  $modules = ilObjLanguageExt::_getModules($this->object->key);
750 
751  $data = array();
752  $total = array("module" => '',"all" => 0,"changed" => 0, "unchanged" => 0);
753  foreach ($modules as $module) {
754  $row = array();
755  $row['module'] = $module;
756  $row['all'] = count($this->object->getAllValues(array($module)));
757  $row['changed'] = count($this->object->getChangedValues(array($module)));
758  $row['unchanged'] = $row['all'] - $row['changed'];
759  $total['all'] += $row['all'];
760  $total['changed'] += $row['changed'];
761  $total['unchanged'] += $row['unchanged'];
762  $data[] = $row;
763  }
764  $total['module'] = "<b>" . $this->lng->txt("language_all_modules") . "</b>";
765  $total['all'] = "<b>" . $total['all'] . "</b>";
766  $total['changed'] = "<b>" . $total['changed'] . "</b>";
767  $total['unchanged'] = "<b>" . $total['unchanged'] . "</b>";
768  $data[] = $total;
769 
770  // create and configure the table object
771  include_once 'Services/Table/classes/class.ilTable2GUI.php';
772  $table_gui = new ilTable2GUI($this, "statistics");
773  $table_gui->setRowTemplate("tpl.lang_statistics_row.html", "Services/Language");
774  $table_gui->setEnableTitle(false);
775  $table_gui->setEnableNumInfo(false);
776  $table_gui->setLimit(count($data));
777  $table_gui->setExportFormats(array(ilTable2GUI::EXPORT_EXCEL));
778 
779  $table_gui->addColumn(ucfirst($this->lng->txt("module")), "", "25%");
780  $table_gui->addColumn($this->lng->txt("language_scope_global"), "", "25%");
781  $table_gui->addColumn($this->lng->txt("language_scope_local"), "", "25%");
782  $table_gui->addColumn($this->lng->txt("language_scope_unchanged"), "", "25%");
783 
784  $table_gui->setData($data);
785 
786  $this->tpl->setContent($table_gui->getHTML());
787  }
$total
Definition: Utf8Test.php:87
static _getModules($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 453 of file class.ilObjLanguageExtGUI.php.

References $_POST, $DIC, Vendor\Package\$e, ilUtil\ilTempnam(), ilUtil\sendFailure(), and ilUtil\stripSlashes().

454  {
455  global $DIC;
456 
457  // save form inputs for next display
458  $this->session["import"]["mode_existing"] = ilUtil::stripSlashes($_POST['mode_existing']);
459 
460  try {
461  $upload = $DIC->upload();
462  $upload->process();
463 
464  if (!$upload->hasUploads()) {
465  throw new ilException($DIC->language()->txt("upload_error_file_not_found"));
466  }
467  $UploadResult = $upload->getResults()[$_FILES['userfile']['tmp_name']];
468 
469  $ProcessingStatus = $UploadResult->getStatus();
470  if ($ProcessingStatus->getCode() === ProcessingStatus::REJECTED) {
471  throw new ilException($ProcessingStatus->getMessage());
472  }
473 
474  // todo: refactor when importLanguageFile() is able to work with the new Filesystem service
475  $tempfile = ilUtil::ilTempnam() . '.sec';
476  $upload->moveOneFileTo($UploadResult, '', Location::TEMPORARY, basename($tempfile), true);
477  $this->object->importLanguageFile($tempfile, $_POST['mode_existing']);
478 
479  $tempfs = $DIC->filesystem()->temp();
480  $tempfs->delete(basename($tempfile));
481  } catch (Exception $e) {
482  ilUtil::sendFailure($e->getMessage(), true);
483  $this->ctrl->redirect($this, 'import');
484  }
485 
486  ilUtil::sendSuccess(sprintf($this->lng->txt("language_file_imported"), $_FILES['userfile']['name']), true);
487  $this->ctrl->redirect($this, 'import');
488  }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static ilTempnam($a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
$DIC
Definition: xapitoken.php:46
$_POST["username"]
+ Here is the call graph for this function:

◆ viewObject()

ilObjLanguageExtGUI::viewObject (   $changesSuccessBool = 0)

Show the edit screen.

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

References $_GET, ilObjectGUI\$data, $DIC, $keys, $name, ilObjectGUI\$tpl, ilObjLanguageExt\_getRemarks(), ilObjLanguageAccess\_getSavedModules(), ilObjLanguageAccess\_getSavedTopics(), ilObjLanguageExt\_getValues(), ilObjLanguageAccess\_isPageTranslation(), buildMissingEntries(), getSuccessMessage(), getViewTable(), ilUtil\sendFailure(), and ilUtil\sendInfo().

145  {
146  global $DIC;
147  $tpl = $DIC['tpl'];
148 
149  // get the view table
150  $table_gui = $this->getViewTable();
151 
152  // get the remarks in database
153  $comments = $this->object->getAllRemarks();
154 
155  // set the language to compare with
156  // get the default values if the compare language is the same
157  $compare = $table_gui->getFilterItemByPostVar('compare')->getValue();
158  if ($compare == $this->object->key) {
159  $compare_object = $this->object->getGlobalLanguageFile();
160  $compare_content = $compare_object->getAllValues();
161  $compare_comments = $compare_object->getAllComments();
162  }
163 
164  // page translation mode:
165  // - the table is filtered by a list of modules and topics
167  // get the selection of modules and topics from request or session
170 
171  // first call for translation
172  if ($_GET['reset_offset']) {
173  $table_gui->resetOffset();
174  }
175 
176  if (!isset($compare_content)) {
177  $compare_content = ilObjLanguageExt::_getValues(
178  $compare,
179  $modules,
180  $topics
181  );
182 
183  $compare_comments = ilObjLanguageExt::_getRemarks($compare);
184  }
185 
186  $translations = ilObjLanguageExt::_getValues(
187  $this->object->key,
188  $modules,
189  $topics
190  );
191 
192  // enable adding new entries
193  $db_found = array();
194  foreach ($translations as $name => $translation) {
195  $keys = explode($this->lng->separator, $name);
196  $db_found[] = $keys[1];
197  }
198  $missing_entries = array_diff($topics, $db_found);
199  }
200  // normal view mode:
201  // - the table is filtered manually by module, mode and pattern
202  else {
203  $filter_mode = $table_gui->getFilterItemByPostVar('mode')->getValue();
204  $filter_pattern = $table_gui->getFilterItemByPostVar('pattern')->getValue();
205  $filter_module = $table_gui->getFilterItemByPostVar('module')->getValue();
206  $filter_module = $filter_module == 'all' ? '' : $filter_module;
207  $filter_modules = $filter_module ? array($filter_module) : array();
208  $filter_identifier = $table_gui->getFilterItemByPostVar('identifier')->getValue();
209  $filter_topics = $filter_identifier ? array($filter_identifier) : array();
210 
211  if (!isset($compare_content)) {
212  $compare_content = ilObjLanguageExt::_getValues(
213  $compare,
214  $filter_modules,
215  $filter_topics
216  );
217 
218  $compare_comments = ilObjLanguageExt::_getRemarks($compare);
219  }
220 
221  switch ($filter_mode) {
222  case "changed":
223  $translations = $this->object->getChangedValues(
224  $filter_modules,
225  $filter_pattern,
226  $filter_topics
227  );
228  break;
229 
230  case "added": //langmode only
231  $translations = $this->object->getAddedValues(
232  $filter_modules,
233  $filter_pattern,
234  $filter_topics
235  );
236  break;
237 
238  case "unchanged":
239  $translations = $this->object->getUnchangedValues(
240  $filter_modules,
241  $filter_pattern,
242  $filter_topics
243  );
244  break;
245 
246  case "commented":
247  $translations = $this->object->getCommentedValues(
248  $filter_modules,
249  $filter_pattern,
250  $filter_topics
251  );
252  break;
253 
254  case "dbremarks":
255  $translations = $this->object->getAllValues(
256  $filter_modules,
257  $filter_pattern,
258  $filter_topics
259  );
260 
261  $translations = array_intersect_key($translations, $comments);
262  break;
263 
264  case "equal":
265  $translations = $this->object->getAllValues(
266  $filter_modules,
267  $filter_pattern,
268  $filter_topics
269  );
270 
271  $translations = array_intersect_assoc($translations, $compare_content);
272  break;
273 
274  case "different":
275  $translations = $this->object->getAllValues(
276  $filter_modules,
277  $filter_pattern,
278  $filter_topics
279  );
280 
281  $translations = array_diff_assoc($translations, $compare_content);
282  break;
283 
284  case "conflicts":
285  $former_file = $this->object->getDataPath() . '/ilias_' . $this->object->key . '.lang';
286  if (!is_readable($former_file)) {
287  ilUtil::sendFailure(sprintf($this->lng->txt("language_former_file_missing"), $former_file)
288  . '<br />' . $this->lng->txt("language_former_file_description"), false);
289  $translations = array();
290  break;
291  }
292  $global_file_obj = $this->object->getGlobalLanguageFile();
293  $former_file_obj = new ilLanguageFile($former_file);
294  $former_file_obj->read();
295  $global_changes = array_diff_assoc(
296  $global_file_obj->getAllValues(),
297  $former_file_obj->getAllValues()
298  );
299  if (!count($global_changes)) {
300  ilUtil::sendInfo(sprintf($this->lng->txt("language_former_file_equal"), $former_file)
301  . '<br />' . $this->lng->txt("language_former_file_description"), false);
302  $translations = array();
303  break;
304  }
305  $translations = $this->object->getChangedValues(
306  $filter_modules,
307  $filter_pattern,
308  $filter_topics
309  );
310 
311  $translations = array_intersect_key($translations, $global_changes);
312  break;
313 
314  case "all":
315  default:
316  $translations = $this->object->getAllValues(
317  $filter_modules,
318  $filter_pattern,
319  $filter_topics
320  );
321  }
322  }
323 
324  // prepare the the data for the table
325  $data = array();
326  foreach ($translations as $name => $translation) {
327  $keys = explode($this->lng->separator, $name);
328  $row = array();
329 
330  $row["module"] = $keys[0];
331  $row["topic"] = $keys[1];
332  $row["name"] = $name;
333  $row["translation"] = $translation;
334  $row["comment"] = $comments[$name];
335  $row["default"] = $compare_content[$name];
336  $row["default_comment"] = $compare_comments[$name];
337 
338  $data[] = $row;
339  }
340 
341  if ($changesSuccessBool) {
342  $tpl->setVariable("MESSAGE", $this->getSuccessMessage());
343  //ilUtil::sendSuccess("function getSuccess Message was called", true);
344  }
345 
346  // render and show the table
347  $table_gui->setData($data);
348  $tpl->setContent($table_gui->getHTML() .
349  $this->buildMissingEntries($missing_entries));
350  }
getSuccessMessage()
Get success message after variables were saved.
static _getRemarks($a_lang_key, $a_all_changed=false)
Get all remarks of a language.
static _isPageTranslation()
Check if the current request is a page translation.
$_GET["client_id"]
static _getSavedModules()
Get the stored modules from the user session.
getViewTable()
Get the table to view language entries.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
if($format !==null) $name
Definition: metadata.php:230
$keys
Definition: metadata.php:187
static _getValues( $a_lang_key, $a_modules=array(), $a_topics=array(), $a_pattern='', $a_state='')
Get the translations of specified topics.
buildMissingEntries(array $a_missing=null)
static _getSavedTopics()
Get the stored topics from the user session.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Class ilLanguageFile.
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

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