ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ()
 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 ()
 list childs of current object 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...
 

Protected Member Functions

 getViewTable ()
 Get the table to view language entries. More...
 
 buildMissingEntries (array $a_missing=null)
 
 initAddNewEntryForm ($a_id=null)
 
- 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...
 
 showMountWebfolderIcon ()
 
 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
 
 $settings
 
 $rbacreview
 
 $toolbar
 
 $tmp_import_dir
 
 $tabs_gui = null
 
 $ctrl
 
 $object_service
 

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, 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"]
global $DIC
Definition: saml.php:7
$_GET["client_id"]
static _lookupId($a_key)
Lookup the object ID for a language key.
global $ilCtrl
Definition: ilias.php:18
+ 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 853 of file class.ilObjLanguageExtGUI.php.

References $DIC, and ilObjLanguageAccess\_isPageTranslation().

854  {
855  global $DIC;
856  $ilLocator = $DIC['ilLocator'];
857 
859  parent::addAdminLocatorItems(true); // #13881
860 
861  $ilLocator->addItem(
862  $this->lng->txt("languages"),
863  $this->ctrl->getLinkTargetByClass("ilobjlanguagefoldergui", "")
864  );
865 
866  $ilLocator->addItem(
867  $this->lng->txt("meta_l_" . $this->object->getTitle()),
868  $this->ctrl->getLinkTarget($this, "view")
869  );
870  }
871  }
global $DIC
Definition: saml.php:7
static _isPageTranslation()
Check if the current request is a page translation.
+ Here is the call graph for this function:

◆ addNewEntryObject()

ilObjLanguageExtGUI::addNewEntryObject ( ilPropertyFormGUI  $a_form = null)

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

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

Referenced by saveNewEntryObject().

920  {
921  global $DIC;
922  $tpl = $DIC['tpl'];
923 
924  $id = trim($_GET["eid"]);
925 
926  if (!$a_form) {
927  $a_form = $this->initAddNewEntryForm($id);
928  }
929 
930  $tpl->setContent($a_form->getHTML());
931  }
global $DIC
Definition: saml.php:7
$_GET["client_id"]
if(!array_key_exists('StateId', $_REQUEST)) $id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ applyFilterObject()

ilObjLanguageExtGUI::applyFilterObject ( )

Apply filter.

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

References getViewTable(), and viewObject().

351  {
352  $table_gui = $this->getViewTable();
353  $table_gui->writeFilterToSession(); // writes filter to session
354  $table_gui->resetOffset(); // sets record offest to 0 (first page)
355  $this->viewObject();
356  }
viewObject()
Show the edit screen.
getViewTable()
Get the table to view language entries.
+ 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 894 of file class.ilObjLanguageExtGUI.php.

References $DIC, $ilCtrl, and $res.

Referenced by viewObject().

895  {
896  global $DIC;
897  $ilCtrl = $DIC->ctrl();
898 
899  if (!is_array($a_missing) ||
900  !sizeof($a_missing)) {
901  return;
902  }
903 
904  $res = array('<h3>' . $this->lng->txt("adm_missing_entries") . '</h3>', '<ul>');
905 
906  foreach ($a_missing as $entry) {
907  $ilCtrl->setParameter($this, "eid", $entry);
908  $res[] = '<li>' . $entry .
909  ' <a href="' . $ilCtrl->getLinkTarget($this, "addNewEntry") .
910  '">' . $this->lng->txt("adm_missing_entry_add_action") . '</a></li>';
911  $ilCtrl->setParameter($this, "eid", "");
912  }
913 
914  $res[] = '</ul>';
915 
916  return implode("\n", $res);
917  }
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18
foreach($_POST as $key=> $value) $res
+ 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 viewObject().

120  {
121  $this->viewObject();
122  }
viewObject()
Show the edit screen.
+ Here is the call graph for this function:

◆ downloadObject()

ilObjLanguageExtGUI::downloadObject ( )

Download a language file.

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

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

525  {
526  // save the selected scope
527  $this->session["export"]["scope"] = ilUtil::stripSlashes($_POST["scope"]);
528 
529  $filename = 'ilias_' . $this->object->key . '_'
530  . str_replace(".", "_", substr(ILIAS_VERSION, 0, strpos(ILIAS_VERSION, " ")))
531  . "-" . date('Y-m-d')
532  . ".lang." . $this->session["export"]["scope"];
533 
534  $global_file_obj = $this->object->getGlobalLanguageFile();
535  $local_file_obj = new ilLanguageFile($filename, $this->object->key, $_POST["scope"]);
536 
537  if ($_POST["scope"] == 'global') {
538  $local_file_obj->setParam("author", $global_file_obj->getParam('author'));
539  $local_file_obj->setParam("version", $global_file_obj->getParam('version'));
540  $local_file_obj->setAllValues($this->object->getAllValues());
541  if ($this->langmode) {
542  $local_file_obj->setAllComments($this->object->getAllRemarks());
543  }
544  } elseif ($_POST["scope"] == 'local') {
545  $local_file_obj->setParam("based_on", $global_file_obj->getParam('version'));
546  $local_file_obj->setAllValues($this->object->getChangedValues());
547  if ($this->langmode) {
548  $local_file_obj->setAllComments($this->object->getAllRemarks());
549  }
550  } elseif ($_POST["scope"] == 'added') { // langmode only
551  $local_file_obj->setParam("author", $global_file_obj->getParam('author'));
552  $local_file_obj->setParam("version", $global_file_obj->getParam('version'));
553  $local_file_obj->setAllValues($this->object->getAddedValues());
554  $local_file_obj->setAllComments($this->object->getAllRemarks());
555  } elseif ($_POST["scope"] == 'unchanged') {
556  $local_file_obj->setParam("author", $global_file_obj->getParam('author'));
557  $local_file_obj->setParam("version", $global_file_obj->getParam('version'));
558  $local_file_obj->setAllValues($this->object->getUnchangedValues());
559  if ($this->langmode) {
560  $local_file_obj->setAllComments($this->object->getAllRemarks());
561  }
562  } elseif ($_POST["scope"] == 'merged') { // langmode only
563  $local_file_obj->setParam("author", $global_file_obj->getParam('author'));
564  $local_file_obj->setParam("version", $global_file_obj->getParam('version'));
565  $local_file_obj->setAllValues($this->object->getMergedValues());
566  $local_file_obj->setAllComments($this->object->getMergedRemarks());
567  }
568 
569  ilUtil::deliverData($local_file_obj->build(), $filename);
570  }
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  }
global $DIC
Definition: saml.php:7
static _checkMaintenance()
Permission check for language maintenance (import/export)
exit
Definition: backend.php:16
+ Here is the call graph for this function:

◆ exportObject()

ilObjLanguageExtGUI::exportObject ( )

Show the screen to export a language file.

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

References $form, and ilFormPropertyGUI\setInfo().

485  {
486  require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
487  $form = new ilPropertyFormGUI();
488  $form->setFormAction($this->ctrl->getFormAction($this));
489  $form->setTitle($this->lng->txt("language_export_file"));
490  $form->setPreventDoubleSubmission(false);
491  $form->addCommandButton('download', $this->lng->txt("download"));
492 
493  $rg = new ilRadioGroupInputGUI($this->lng->txt("language_file_scope"), "scope");
494  $ro = new ilRadioOption($this->lng->txt("language_scope_global"), "global");
495  $ro->setInfo($this->lng->txt("language_scope_global_info"));
496  $rg->addOption($ro);
497  $ro = new ilRadioOption($this->lng->txt("language_scope_local"), "local");
498  $ro->setInfo($this->lng->txt("language_scope_local_info"));
499  $rg->addOption($ro);
500  if ($this->langmode) {
501  $ro = new ilRadioOption($this->lng->txt("language_scope_added"), "added");
502  $ro->setInfo($this->lng->txt("language_scope_added_info"));
503  $rg->addOption($ro);
504  }
505  $ro = new ilRadioOption($this->lng->txt("language_scope_unchanged"), "unchanged");
506  $ro->setInfo($this->lng->txt("language_scope_unchanged_info"));
507  $rg->addOption($ro);
508  if ($this->langmode) {
509  $ro = new ilRadioOption($this->lng->txt("language_scope_merged"), "merged");
510  $ro->setInfo($this->lng->txt("language_scope_merged_info"));
511  $rg->addOption($ro);
512  }
513 
514  $rg->setValue($this->session["export"]["scope"] ? $this->session["export"]["scope"] : "global");
515  $form->addItem($rg);
516 
517  $this->tpl->setContent($form->getHTML());
518  }
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.
if(isset($_POST['submit'])) $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 786 of file class.ilObjLanguageExtGUI.php.

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

787  {
788  global $DIC;
789  $ilCtrl = $DIC->ctrl();
790  $cmd = $ilCtrl->getCmd();
791 
793  $this->tabs_gui->setBackTarget(
794  $this->lng->txt('back'),
795  $this->ctrl->getLinkTargetByClass('ilObjLanguageFolderGUI')
796  );
797 
798  $this->tabs_gui->addTab(
799  "edit",
800  $this->lng->txt("edit"),
801  $this->ctrl->getLinkTarget($this, "view")
802  );
803 
804  $this->tabs_gui->addTab(
805  "export",
806  $this->lng->txt('export'),
807  $this->ctrl->getLinkTarget($this, "export")
808  );
809 
810  $this->tabs_gui->addTab(
811  "import",
812  $this->lng->txt('import'),
813  $this->ctrl->getLinkTarget($this, "import")
814  );
815 
816  $this->tabs_gui->addTab(
817  "maintain",
818  $this->lng->txt('language_maintain'),
819  $this->ctrl->getLinkTarget($this, "maintain")
820  );
821 
822  $this->tabs_gui->addTab(
823  "settings",
824  $this->lng->txt('settings'),
825  $this->ctrl->getLinkTarget($this, "settings")
826  );
827 
828  $this->tabs_gui->addTab(
829  "statistics",
830  $this->lng->txt("language_statistics"),
831  $this->ctrl->getLinkTarget($this, "statistics")
832  );
833 
834  switch ($cmd) {
835  case '':
836  case 'view':
837  case 'applyFilter':
838  case 'resetFilter':
839  case 'save':
840  $this->tabs_gui->activateTab('edit');
841  break;
842  default:
843  $this->tabs_gui->activateTab($cmd);
844  }
845  }
846  }
global $DIC
Definition: saml.php:7
static _isPageTranslation()
Check if the current request is a page translation.
global $ilCtrl
Definition: ilias.php:18
+ 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.

References $id.

92  {
93  return $this->id;
94  }
if(!array_key_exists('StateId', $_REQUEST)) $id

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

References $form, and ilFormPropertyGUI\setInfo().

410  {
411  require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
412  $form = new ilPropertyFormGUI();
413  $form->setFormAction($this->ctrl->getFormAction($this));
414  $form->setTitle($this->lng->txt("language_import_file"));
415  $form->addCommandButton('upload', $this->lng->txt("upload"));
416 
417  $fu = new ilFileInputGUI($this->lng->txt("file"), "userfile");
418  $form->addItem($fu);
419 
420  $rg = new ilRadioGroupInputGUI($this->lng->txt("language_mode_existing"), "mode_existing");
421  $ro = new ilRadioOption($this->lng->txt("language_mode_existing_keepall"), "keepall");
422  $ro->setInfo($this->lng->txt("language_mode_existing_keepall_info"));
423  $rg->addOption($ro);
424  $ro = new ilRadioOption($this->lng->txt("language_mode_existing_keepnew"), "keepnew");
425  $ro->setInfo($this->lng->txt("language_mode_existing_keepnew_info"));
426  $rg->addOption($ro);
427  $ro = new ilRadioOption($this->lng->txt("language_mode_existing_replace"), "replace");
428  $ro->setInfo($this->lng->txt("language_mode_existing_replace_info"));
429  $rg->addOption($ro);
430  $ro = new ilRadioOption($this->lng->txt("language_mode_existing_delete"), "delete");
431  $ro->setInfo($this->lng->txt("language_mode_existing_delete_info"));
432  $rg->addOption($ro);
433  $rg->setValue($this->session["import"]["mode_existing"] ? $this->session["import"]["mode_existing"] : "keepall");
434  $form->addItem($rg);
435 
436  $this->tpl->setContent($form->getHTML());
437  }
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.
if(isset($_POST['submit'])) $form
+ Here is the call graph for this function:

◆ initAddNewEntryForm()

ilObjLanguageExtGUI::initAddNewEntryForm (   $a_id = null)
protected

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

References $_POST, $DIC, $form, $id, $ilCtrl, PHPMailer\PHPMailer\$options, ilObjLanguageAccess\_getSavedModules(), ilObjLanguageAccess\_getSavedTopics(), and ilFormPropertyGUI\setRequired().

Referenced by addNewEntryObject(), and saveNewEntryObject().

934  {
935  global $DIC;
936  $ilCtrl = $DIC->ctrl();
937 
938  if (!$a_id) {
939  $a_id = $_POST["id"];
940  }
941 
942  if (!$a_id ||
943  !in_array($a_id, ilObjLanguageAccess::_getSavedTopics())) {
944  $ilCtrl->redirect($this, "view");
945  }
946 
947  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
948  $form = new ilPropertyFormGUI();
949  $form->setFormAction($ilCtrl->getFormAction($this, "saveNewEntry"));
950  $form->setTitle($this->lng->txt("adm_missing_entry_add"));
951 
953  $options = array_combine($mods, $mods);
954 
955  $mod = new ilSelectInputGUI(ucfirst($this->lng->txt("module")), "mod");
956  $mod->setOptions(array("" => $this->lng->txt("please_select")) + $options);
957  $mod->setRequired(true);
958  $form->addItem($mod);
959 
960  $id = new ilTextInputGUI(ucfirst($this->lng->txt("identifier")), "id");
961  $id->setValue($a_id);
962  $id->setDisabled(true);
963  $form->addItem($id);
964 
965  foreach ($this->lng->getInstalledLanguages() as $lang_key) {
966  $trans = new ilTextInputGUI($this->lng->txt("meta_l_" . $lang_key), "trans_" . $lang_key);
967  if (in_array($lang_key, array("de", "en"))) {
968  $trans->setRequired(true);
969  }
970  $form->addItem($trans);
971  }
972 
973  $form->addCommandButton("saveNewEntry", $this->lng->txt("save"));
974  $form->addCommandButton("view", $this->lng->txt("cancel"));
975 
976  return $form;
977  }
This class represents a selection list property in a property form.
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
static _getSavedModules()
Get the stored modules from the user session.
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
This class represents a text property in a property form.
static _getSavedTopics()
Get the stored topics from the user session.
$_POST["username"]
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ maintainExecuteObject()

ilObjLanguageExtGUI::maintainExecuteObject ( )

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

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

614  {
615  if (isset($_POST["maintain"])) {
616  $this->session["maintain"] = ilUtil::stripSlashes($_POST["maintain"]);
617  }
618 
619  switch ($_POST["maintain"]) {
620  // save the global language file for merge after
621  case "save_dist":
622 
623  // save a copy of the distributed language file
624  $orig_file = $this->object->getLangPath() . '/ilias_' . $this->object->key . '.lang';
625  $copy_file = $this->object->getDataPath() . '/ilias_' . $this->object->key . '.lang';
626  if (@copy($orig_file, $copy_file)) {
627  ilUtil::sendSuccess($this->lng->txt("language_saved_dist"), true);
628  } else {
629  ilUtil::sendFailure($this->lng->txt("language_save_dist_failed"), true);
630  }
631  break;
632 
633  // load the content of the local language file
634  case "load":
635  $lang_file = $this->object->getCustLangPath() . '/ilias_' . $this->object->key . '.lang.local';
636  if (is_file($lang_file) and is_readable($lang_file)) {
637  $this->object->importLanguageFile($lang_file, 'replace');
638  $this->object->setLocal(true);
639  ilUtil::sendSuccess($this->lng->txt("language_loaded_local"), true);
640  } else {
641  ilUtil::sendFailure($this->lng->txt("language_error_read_local"), true);
642  }
643  break;
644 
645  // revert the database to the default language file
646  case "clear":
647  $lang_file = $this->object->getLangPath() . '/ilias_' . $this->object->key . '.lang';
648  if (is_file($lang_file) and is_readable($lang_file)) {
649  $this->object->importLanguageFile($lang_file, 'delete');
650  $this->object->setLocal(false);
651  ilUtil::sendSuccess($this->lng->txt("language_cleared_local"), true);
652  } else {
653  ilUtil::sendFailure($this->lng->txt("language_error_clear_local"), true);
654  }
655  break;
656 
657  // delete local additions in the datavase (langmode only)
658  case "delete_added":
659  ilObjLanguageExt::_deleteValues($this->object->key, $this->object->getAddedValues());
660  break;
661 
662  // merge local changes back to the global language file (langmode only)
663  case "merge":
664 
665  $orig_file = $this->object->getLangPath() . '/ilias_' . $this->object->key . '.lang';
666  $copy_file = $this->object->getCustLangPath() . '/ilias_' . $this->object->key . '.lang';
667 
668  if (is_file($orig_file) and is_writable($orig_file)) {
669  // save a copy of the global language file
670  @copy($orig_file, $copy_file);
671 
672  // modify and write the new global file
673  $global_file_obj = $this->object->getGlobalLanguageFile();
674  $global_file_obj->setAllValues($this->object->getMergedValues());
675  $global_file_obj->setAllComments($this->object->getMergedRemarks());
676  $global_file_obj->write();
677  ilUtil::sendSuccess($this->lng->txt("language_merged_global"), true);
678  } else {
679  ilUtil::sendFailure($this->lng->txt("language_error_write_global"), true);
680  }
681  break;
682 
683  // remove the local language file (langmode only)
684  case "remove_local_file":
685  $lang_file = $this->object->getCustLangPath() . '/ilias_' . $this->object->key . '.lang.local';
686 
687  if (!is_file($lang_file)) {
688  $this->object->setLocal(false);
689  ilUtil::sendFailure($this->lng->txt("language_error_local_missed"), true);
690  } elseif (@unlink($lang_file)) {
691  $this->object->setLocal(false);
692  ilUtil::sendSuccess($this->lng->txt("language_local_file_deleted"), true);
693  } else {
694  ilUtil::sendFailure($this->lng->txt("language_error_delete_local"), true);
695  }
696  break;
697  }
698 
699  $this->ctrl->redirect($this, "maintain");
700  }
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 576 of file class.ilObjLanguageExtGUI.php.

References $form, and ilFormPropertyGUI\setInfo().

577  {
578  require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
579  $form = new ilPropertyFormGUI();
580  $form->setFormAction($this->ctrl->getFormAction($this));
581  $form->setTitle($this->lng->txt("language_maintenance"));
582  $form->setPreventDoubleSubmission(false);
583  $form->addCommandButton('maintainExecute', $this->lng->txt("language_process_maintenance"));
584 
585  $rg = new ilRadioGroupInputGUI($this->lng->txt("language_maintain_local_changes"), "maintain");
586  $ro = new ilRadioOption($this->lng->txt("language_load_local_changes"), "load");
587  $ro->setInfo(sprintf($this->lng->txt("language_load_local_changes_info"), $this->object->key));
588  $rg->addOption($ro);
589  $ro = new ilRadioOption($this->lng->txt("language_clear_local_changes"), "clear");
590  $ro->setInfo(sprintf($this->lng->txt("language_clear_local_changes_info"), $this->object->key));
591  $rg->addOption($ro);
592  if ($this->langmode) {
593  $ro = new ilRadioOption($this->lng->txt("language_delete_local_additions"), "delete_added");
594  $ro->setInfo(sprintf($this->lng->txt("language_delete_local_additions_info"), $this->object->key));
595  $rg->addOption($ro);
596  $ro = new ilRadioOption($this->lng->txt("language_remove_local_file"), "remove_local_file");
597  $ro->setInfo(sprintf($this->lng->txt("language_remove_local_file_info"), $this->object->key));
598  $rg->addOption($ro);
599  $ro = new ilRadioOption($this->lng->txt("language_merge_local_changes"), "merge");
600  $ro->setInfo(sprintf($this->lng->txt("language_merge_local_changes_info"), $this->object->key));
601  $rg->addOption($ro);
602  }
603  $ro = new ilRadioOption($this->lng->txt("language_save_dist"), "save_dist");
604  $ro->setInfo(sprintf($this->lng->txt("language_save_dist_info"), $this->object->key));
605  $rg->addOption($ro);
606  $rg->setValue($this->session["maintain"]);
607  $form->addItem($rg);
608 
609  $this->tpl->setContent($form->getHTML());
610  }
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.
if(isset($_POST['submit'])) $form
+ Here is the call graph for this function:

◆ resetFilterObject()

ilObjLanguageExtGUI::resetFilterObject ( )

Reset filter.

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

References getViewTable(), and viewObject().

362  {
363  $table_gui = $this->getViewTable();
364  $table_gui->resetOffset(); // sets record offest to 0 (first page)
365  $table_gui->resetFilter(); // clears filter
366  $this->viewObject();
367  }
viewObject()
Show the edit screen.
getViewTable()
Get the table to view language entries.
+ Here is the call graph for this function:

◆ saveNewEntryObject()

ilObjLanguageExtGUI::saveNewEntryObject ( )

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

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

980  {
981  global $DIC;
982  $ilDB = $DIC->database();
983  $ilCtrl = $DIC->ctrl();
984  $ilUser = $DIC->user();
985 
986  $form = $this->initAddNewEntryForm();
987  if ($form->checkInput()) {
988  $mod = $form->getInput("mod");
989  $id = $form->getInput("id");
990 
991  $lang = array();
992  foreach ($this->lng->getInstalledLanguages() as $lang_key) {
993  $trans = trim($form->getInput("trans_" . $lang_key));
994  if ($trans) {
995  // add single entry
997  $mod,
998  $id,
999  $lang_key,
1000  $trans,
1001  date("Y-m-d H:i:s"),
1002  $ilUser->getLogin()
1003  );
1004 
1005  // add to serialized module
1006  $set = $ilDB->query("SELECT lang_array FROM lng_modules" .
1007  " WHERE lang_key = " . $ilDB->quote($lang_key, "text") .
1008  " AND module = " . $ilDB->quote($mod, "text"));
1009  $row = $ilDB->fetchAssoc($set);
1010  $entries = unserialize($row["lang_array"]);
1011  if (is_array($entries)) {
1012  $entries[$id] = $trans;
1013  ilObjLanguage::replaceLangModule($lang_key, $mod, $entries);
1014  }
1015  }
1016  }
1017 
1018  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1019  $ilCtrl->redirect($this, "view");
1020  }
1021 
1022  $form->setValuesByPost();
1023  $this->addNewEntryObject($form);
1024  }
global $DIC
Definition: saml.php:7
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
if(isset($_POST['submit'])) $form
$ilUser
Definition: imgupload.php:18
$row
global $ilDB
addNewEntryObject(ilPropertyFormGUI $a_form=null)
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
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 372 of file class.ilObjLanguageExtGUI.php.

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

373  {
374  // prepare the values to be saved
375  $save_array = array();
376  $remarks_array = array();
377  foreach ($_POST as $key => $value) {
378  // mantis #25237
379  // @see https://php.net/manual/en/language.variables.external.php
380  $key = str_replace('_POSTDOT_', '.', $key);
381  $key = str_replace('_POSTSPACE_', ' ', $key);
382 
383  // example key of variable: 'common#:#access'
384  // example key of comment: 'common#:#access#:#comment'
385  $keys = explode($this->lng->separator, ilUtil::stripSlashes($key, false));
386 
387  if (count($keys) == 2) {
388  // avoid line breaks
389  $value = preg_replace("/(\015\012)|(\015)|(\012)/", "<br />", $value);
390  $value = ilUtil::stripSlashes($value, false);
391  $save_array[$key] = $value;
392 
393  // the comment has the key of the language with the suffix
394  $remarks_array[$key] = $_POST[$key . $this->lng->separator . "comment"];
395  }
396  }
397 
398  // save the translations
399  ilObjLanguageExt::_saveValues($this->object->key, $save_array, $remarks_array);
400 
401  // view the list
402  $this->viewObject();
403  }
viewObject()
Show the edit screen.
$keys
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.
$key
Definition: croninfo.php:18
$_POST["username"]
+ Here is the call graph for this function:

◆ settingsObject()

ilObjLanguageExtGUI::settingsObject ( )

Set the language settings.

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

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

706  {
707  global $DIC;
708  $ilSetting = $DIC->settings();
709 
710  $translate_key = "lang_translate_" . $this->object->key;
711 
712  // save and get the page translation setting
713  if (!empty($_POST)) {
714  $ilSetting->set($translate_key, (bool) $_POST["translation"]);
715  ilUtil::sendSuccess($this->lng->txt("settings_saved"));
716  }
717  $translate = $ilSetting->get($translate_key, false);
718 
719  require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
720  $form = new ilPropertyFormGUI();
721  $form->setFormAction($this->ctrl->getFormAction($this));
722  $form->setTitle($this->lng->txt("language_settings"));
723  $form->setPreventDoubleSubmission(false);
724  $form->addCommandButton('settings', $this->lng->txt("language_change_settings"));
725 
726  $ci = new ilCheckboxInputGUI($this->lng->txt("language_translation_enabled"), "translation");
727  $ci->setChecked((bool) $translate);
728  $ci->setInfo($this->lng->txt("language_note_translation"));
729  $form->addItem($ci);
730 
731  $this->tpl->setContent($form->getHTML());
732  }
This class represents a property form user interface.
global $DIC
Definition: saml.php:7
This class represents a checkbox property in a property form.
setChecked($a_checked)
Set Checked.
if(isset($_POST['submit'])) $form
global $ilSetting
Definition: privfeed.php:17
$_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 878 of file class.ilObjLanguageExtGUI.php.

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

879  {
881  $this->tpl->setHeaderPageTitle($this->lng->txt("translation"));
882  $this->tpl->setTitle($this->lng->txt("translation") . " " . $this->lng->txt("meta_l_" . $this->object->key));
883  } else {
884  $this->tpl->setTitle($this->lng->txt("meta_l_" . $this->object->key));
885  }
886  $this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lngf.svg"), $this->lng->txt("obj_" . $this->object->getType()));
887  }
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 737 of file class.ilObjLanguageExtGUI.php.

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

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

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

444  {
445  global $DIC;
446 
447  // save form inputs for next display
448  $this->session["import"]["mode_existing"] = ilUtil::stripSlashes($_POST['mode_existing']);
449 
450  try {
451  $upload = $DIC->upload();
452  $upload->process();
453 
454  if (!$upload->hasUploads()) {
455  throw new ilException($DIC->language()->txt("upload_error_file_not_found"));
456  }
457  $UploadResult = $upload->getResults()[$_FILES['userfile']['tmp_name']];
458 
459  $ProcessingStatus = $UploadResult->getStatus();
460  if ($ProcessingStatus->getCode() === ProcessingStatus::REJECTED) {
461  throw new ilException($ProcessingStatus->getMessage());
462  }
463 
464  // todo: refactor when importLanguageFile() is able to work with the new Filesystem service
465  $tempfile = ilUtil::ilTempnam() . '.sec';
466  $upload->moveOneFileTo($UploadResult, '', Location::TEMPORARY, basename($tempfile), true);
467  $this->object->importLanguageFile($tempfile, $_POST['mode_existing']);
468 
469  $tempfs = $DIC->filesystem()->temp();
470  $tempfs->delete(basename($tempfile));
471  } catch (Exception $e) {
472  ilUtil::sendFailure($e->getMessage(), true);
473  $this->ctrl->redirect($this, 'import');
474  }
475 
476  ilUtil::sendSuccess(sprintf($this->lng->txt("language_file_imported"), $_FILES['userfile']['name']), true);
477  $this->ctrl->redirect($this, 'import');
478  }
global $DIC
Definition: saml.php:7
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.
$_POST["username"]
+ Here is the call graph for this function:

◆ viewObject()

ilObjLanguageExtGUI::viewObject ( )

Show the edit screen.

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

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

Referenced by applyFilterObject(), cancelObject(), resetFilterObject(), and saveObject().

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  // render and show the table
342  $table_gui->setData($data);
343  $tpl->setContent($table_gui->getHTML() .
344  $this->buildMissingEntries($missing_entries));
345  }
static _getRemarks($a_lang_key, $a_all_changed=false)
Get all remarks of a language.
global $DIC
Definition: saml.php:7
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.
$keys
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
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.
$row
Class ilLanguageFile.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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