ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilObjLanguageExtGUI Class Reference

Class ilObjLanguageExtGUI. More...

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

Public Member Functions

 ilObjLanguageExtGUI ($a_data, $a_id=0, $a_call_by_reference=false)
 Constructor.
 assignObject ()
 Assign the extended language object.
 getId ()
 get the language object id (needed for filter serialization)
executeCommand ()
 execute command
 cancelObject ()
 Cancel the current action.
 viewObject ()
 Show the edit screen.
 applyFilterObject ()
 Apply filter.
 resetFilterObject ()
 Reset filter.
 saveObject ()
 Save the changed translations.
 importObject ()
 Show the screen to import a language file.
 uploadObject ()
 Process an uploaded language file.
 exportObject ()
 Show the screen to export a language file.
 downloadObject ()
 Download a language file.
 maintainObject ()
 Process the language maintenance.
 maintainExecuteObject ()
 settingsObject ()
 Set the language settings.
 statisticsObject ()
 Print out statistics about the language.
 getAdminTabs (&$tabs_gui)
 
 Get tabs for admin mode

(Overwritten from ilObjectGUI, called by prepareOutput)

 addAdminLocatorItems ()
 Set the locator for admin mode (Overwritten from ilObjectGUI, called by prepareOutput)
 setTitleAndDescription ()
 Set the Title and the description (Overwritten from ilObjectGUI, called by prepareOutput)
 addNewEntryObject (ilPropertyFormGUI $a_form=null)
 saveNewEntryObject ()
- Public Member Functions inherited from ilObjectGUI
 ilObjectGUI ($a_data, $a_id=0, $a_call_by_reference=true, $a_prepare_output=true)
 Constructor public.
 withReferences ()
 determines wether objects are referenced or not (got ref ids or not)
 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
 getCreationMode ()
 get creation mode
 getHTML ()
 confirmedDeleteObject ()
 confirmed deletion of object -> objects are moved to trash or deleted immediately, if trash is disabled
 cancelDeleteObject ()
 cancel deletion of object
 cancelObject ($in_rep=false)
 cancel action and go back to previous page public
 createObject ()
 create new object form
 cancelCreation ()
 cancel create action and go back to repository parent
 editObject ()
 edit object
 updateObject ()
 updates object entry in object_data
 getFormAction ($a_cmd, $a_formaction="")
 get form action for command (command is method name without "Object", e.g.
 isVisible ($a_ref_id, $a_type)
 deleteObject ($a_error=false)
 Display deletion confirmation screen.
 cloneAllObject ()
 Clone single (not container object) Method is overwritten in ilContainerGUI.

Protected Member Functions

 getViewTable ()
 Get the table to view language entries.
 buildMissingEntries (array $a_missing=null)
 initAddNewEntryForm ($a_id=null)
- Protected Member Functions inherited from ilObjectGUI
 prepareOutput ()
 prepare output
 initHeaderAction ($a_sub_type=null, $a_sub_id=null)
 Add header action menu.
 insertHeaderAction ($a_list_gui)
 Insert header action into main template.
 addHeaderAction ()
 Add header action menu.
 redrawHeaderActionObject ()
 Ajax call: redraw action header only.
 showMountWebfolderIcon ()
 setTabs ()
 set admin tabs public
 setAdminTabs ()
 set admin tabs public
 setLocator ()
 set Locator
 addLocatorItems ()
 should be overwritten to add object specific items (repository items are preloaded)
 omitLocator ($a_omit=true)
 addAdminLocatorItems ($a_do_not_add_object=false)
 should be overwritten to add object specific items (repository items are preloaded)
 initCreationForms ($a_new_type)
 Init creation froms.
 getCreationFormsHTML (array $a_forms)
 Get HTML for creation forms (accordion)
 initCreateForm ($a_new_type)
 Init object creation form.
 initDidacticTemplate (ilPropertyFormGUI $form)
 Show didactic template types.
 addDidacticTemplateOptions (array &$a_options)
 Add custom templates.
 getDidacticTemplateVar ($a_type)
 Get didactic template setting from creation screen.
 putObjectInTree (ilObject $a_obj, $a_parent_node_id=null)
 Add object to tree at given position.
 afterSave (ilObject $a_new_object)
 Post (successful) object creation hook.
 initEditForm ()
 Init object edit form.
 initEditCustomForm (ilPropertyFormGUI $a_form)
 Add custom fields to update form.
 getEditFormValues ()
 Get values for edit form.
 getEditFormCustomValues (array &$a_values)
 Add values to custom edit fields.
 validateCustom (ilPropertyFormGUI $a_form)
 Validate custom values (if not possible with checkInput())
 updateCustom (ilPropertyFormGUI $a_form)
 Insert custom update form values into object.
 afterUpdate ()
 Post (successful) object update hook.
 initImportForm ($a_new_type)
 Init object import form.
 importFileObject ($parent_id=null)
 Import.
 afterImport (ilObject $a_new_object)
 Post (successful) object import hook.
 setFormAction ($a_cmd, $a_formaction)
 set specific form action for command
 getReturnLocation ($a_cmd, $a_location="")
 get return location for command (command is method name without "Object", e.g.
 setReturnLocation ($a_cmd, $a_location)
 set specific return location for command
 getTargetFrame ($a_cmd, $a_target_frame="")
 get target frame for command (command is method name without "Object", e.g.
 setTargetFrame ($a_cmd, $a_target_frame)
 set specific target frame for command
 showPossibleSubObjects ()
 show possible subobjects (pulldown menu)
 getTemplateFile ($a_cmd, $a_type="")
 get a template blockfile format: tpl.
 getTitlesByRefId ($a_ref_ids)
 get Titles of objects this method is used for error messages in methods cut/copy/paste
 getTabs (&$tabs_gui)
 get tabs abstract method.
 __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
 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
 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.
 getCenterColumnHTML ()
 Get center column.
 getRightColumnHTML ()
 Display right column.
 setColumnSettings ($column_gui)
 May be overwritten in subclasses.
 checkPermission ($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
 Check permission and redirect on error.
 checkPermissionBool ($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
 Check permission.
 enableDragDropFileUpload ()
 Enables the file upload into this object by dropping files.
 handleAutoRating (ilObject $a_new_obj)
 Activate rating automatically if parent container setting.

Additional Inherited Members

- Static Public Member Functions inherited from ilObjectGUI
static _gotoRepositoryRoot ($a_raise_error=false)
 Goto repository root.
static _gotoRepositoryNode ($a_ref_id, $a_cmd="frameset")
 Goto repository root.
- Data Fields inherited from ilObjectGUI
const COPY_WIZARD_NEEDS_PAGE = 1
 $ilias
 $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

Detailed Description

Member Function Documentation

ilObjLanguageExtGUI::addAdminLocatorItems ( )

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

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

References ilObjLanguageAccess\_isPageTranslation().

{
global $ilLocator;
{
$ilLocator->addItem($this->lng->txt("languages"),
$this->ctrl->getLinkTargetByClass("ilobjlanguagefoldergui", ""));
$ilLocator->addItem($this->lng->txt("meta_l_". $this->object->getTitle()),
$this->ctrl->getLinkTarget($this, "view"));
}
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::addNewEntryObject ( ilPropertyFormGUI  $a_form = null)

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

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

Referenced by saveNewEntryObject().

{
global $tpl;
$id = trim($_GET["eid"]);
if(!$a_form)
{
$a_form = $this->initAddNewEntryForm($id);
}
$tpl->setContent($a_form->getHTML());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjLanguageExtGUI::applyFilterObject ( )

Apply filter.

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

References getViewTable(), and viewObject().

{
$table_gui = $this->getViewTable();
$table_gui->writeFilterToSession(); // writes filter to session
$table_gui->resetOffset(); // sets record offest to 0 (first page)
$this->viewObject();
}

+ Here is the call graph for this function:

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)

Reimplemented from ilObjectGUI.

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

{
require_once("Services/Language/classes/class.ilObjLanguageExt.php");
$this->object =& new ilObjLanguageExt($this->id);
}
ilObjLanguageExtGUI::buildMissingEntries ( array  $a_missing = null)
protected

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

References $ilCtrl, and $res.

Referenced by viewObject().

{
global $ilCtrl;
if(!is_array($a_missing) ||
!sizeof($a_missing))
{
return;
}
$res = array('<h3>'.$this->lng->txt("adm_missing_entries").'</h3>', '<ul>');
foreach($a_missing as $entry)
{
$ilCtrl->setParameter($this, "eid", $entry);
$res[] = '<li>'.$entry.
' <a href="'.$ilCtrl->getLinkTarget($this, "addNewEntry").
'">'.$this->lng->txt("adm_missing_entry_add_action").'</a></li>';
$ilCtrl->setParameter($this, "eid", "");
}
$res[] = '</ul>';
return implode("\n", $res);
}

+ Here is the caller graph for this function:

ilObjLanguageExtGUI::cancelObject ( )

Cancel the current action.

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

References viewObject().

{
$this->viewObject();
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::downloadObject ( )

Download a language file.

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

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

{
// save the selected scope
$this->session["export"]["scope"] = ilUtil::stripSlashes($_POST["scope"]);
$filename = 'ilias_' . $this->object->key . '_'
. str_replace(".", "_", substr(ILIAS_VERSION, 0, strpos(ILIAS_VERSION, " ")))
. "-" . date('Y-m-d')
. ".lang.".$this->session["export"]["scope"];
$global_file_obj = $this->object->getGlobalLanguageFile();
$local_file_obj = new ilLanguageFile($filename, $this->object->key, $_POST["scope"]);
if ($_POST["scope"] == 'global')
{
$local_file_obj->setParam("author", $global_file_obj->getParam('author'));
$local_file_obj->setParam("version", $global_file_obj->getParam('version'));
$local_file_obj->setAllValues($this->object->getAllValues());
if ($this->langmode)
{
$local_file_obj->setAllComments($this->object->getAllRemarks());
}
}
elseif ($_POST["scope"] == 'local')
{
$local_file_obj->setParam("based_on", $global_file_obj->getParam('version'));
$local_file_obj->setAllValues($this->object->getChangedValues());
if ($this->langmode)
{
$local_file_obj->setAllComments($this->object->getAllRemarks());
}
}
elseif ($_POST["scope"] == 'added') // langmode only
{
$local_file_obj->setParam("author", $global_file_obj->getParam('author'));
$local_file_obj->setParam("version", $global_file_obj->getParam('version'));
$local_file_obj->setAllValues($this->object->getAddedValues());
$local_file_obj->setAllComments($this->object->getAllRemarks());
}
elseif ($_POST["scope"] == 'unchanged')
{
$local_file_obj->setParam("author", $global_file_obj->getParam('author'));
$local_file_obj->setParam("version", $global_file_obj->getParam('version'));
$local_file_obj->setAllValues($this->object->getUnchangedValues());
if ($this->langmode)
{
$local_file_obj->setAllComments($this->object->getAllRemarks());
}
}
elseif ($_POST["scope"] == 'merged') // langmode only
{
$local_file_obj->setParam("author", $global_file_obj->getParam('author'));
$local_file_obj->setParam("version", $global_file_obj->getParam('version'));
$local_file_obj->setAllValues($this->object->getMergedValues());
$local_file_obj->setAllComments($this->object->getMergedRemarks());
}
ilUtil::deliverData($local_file_obj->build(), $filename);
}

+ Here is the call graph for this function:

& ilObjLanguageExtGUI::executeCommand ( )

execute command

Reimplemented from ilObjectGUI.

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

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

{
global $ilHelp;
{
$this->ilErr->raiseError($this->lng->txt("permission_denied"),$this->ilErr->MESSAGE);
}
$cmd = $this->ctrl->getCmd("view")."Object";
$this->$cmd();
$ilHelp->setScreenIdComponent("lng");
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::exportObject ( )

Show the screen to export a language file.

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

References ilFormPropertyGUI\setInfo().

{
require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
$form = new ilPropertyFormGUI();
$form->setFormAction($this->ctrl->getFormAction($this));
$form->setTitle($this->lng->txt("language_export_file"));
$form->setPreventDoubleSubmission(false);
$form->addCommandButton('download',$this->lng->txt("download"));
$rg = new ilRadioGroupInputGUI($this->lng->txt("language_file_scope"), "scope");
$ro = new ilRadioOption($this->lng->txt("language_scope_global"), "global");
$ro->setInfo($this->lng->txt("language_scope_global_info"));
$rg->addOption($ro);
$ro = new ilRadioOption($this->lng->txt("language_scope_local"), "local");
$ro->setInfo($this->lng->txt("language_scope_local_info"));
$rg->addOption($ro);
if ($this->langmode)
{
$ro = new ilRadioOption($this->lng->txt("language_scope_added"), "added");
$ro->setInfo($this->lng->txt("language_scope_added_info"));
$rg->addOption($ro);
}
$ro = new ilRadioOption($this->lng->txt("language_scope_unchanged"), "unchanged");
$ro->setInfo($this->lng->txt("language_scope_unchanged_info"));
$rg->addOption($ro);
if ($this->langmode)
{
$ro = new ilRadioOption($this->lng->txt("language_scope_merged"), "merged");
$ro->setInfo($this->lng->txt("language_scope_merged_info"));
$rg->addOption($ro);
}
$rg->setValue($this->session["export"]["scope"] ? $this->session["export"]["scope"] : "global");
$form->addItem($rg);
$this->tpl->setContent($form->getHTML());
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::getAdminTabs ( $tabs_gui)

 Get tabs for admin mode

(Overwritten from ilObjectGUI, called by prepareOutput)

Parameters
objecttabs gui object

Reimplemented from ilObjectGUI.

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

References ilObjLanguageAccess\_isPageTranslation().

{
{
$tabs_gui->addTarget("edit",
$this->ctrl->getLinkTarget($this, "view"),
array("","view","cancel","save"));
$tabs_gui->addTarget("export",
$this->ctrl->getLinkTarget($this, "export"),
array("export","download"));
$tabs_gui->addTarget("import",
$this->ctrl->getLinkTarget($this, "import"),
array("import","upload"));
$tabs_gui->addTarget("language_maintain",
$this->ctrl->getLinkTarget($this, "maintain"),
array("maintain"));
$tabs_gui->addTarget("settings",
$this->ctrl->getLinkTarget($this, "settings"),
array("settings"));
$tabs_gui->addTarget("language_statistics",
$this->ctrl->getLinkTarget($this, "statistics"),
array("statistics"));
}
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::getId ( )

get the language object id (needed for filter serialization)

Returns
int language object id

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

{
return $this->id;
}
ilObjLanguageExtGUI::getViewTable ( )
protected

Get the table to view language entries.

Returns
ilLanguageExtTableGUI

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

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

{
// create and configure the table object
include_once './Services/Language/classes/class.ilLanguageExtTableGUI.php';
$table_gui = new ilLanguageExtTableGUI($this, 'view', array(
'langmode' => $this->langmode,
'lang_key'=> $this->object->key,
));
return $table_gui;
}

+ Here is the caller graph for this function:

ilObjLanguageExtGUI::ilObjLanguageExtGUI (   $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 37 of file class.ilObjLanguageExtGUI.php.

References $_GET, $_SESSION, $ilCtrl, ilObjectGUI\$lng, ilObjLanguageAccess\_lookupId(), and ilObjectGUI\ilObjectGUI().

{
global $lng, $ilCtrl, $ilClientIniFile;
// language maintenance strings are defined in administration
$lng->loadLanguageModule("administration");
$lng->loadLanguageModule("meta");
// view mode ('translate' or empty) determins available table filters
$ilCtrl->saveParameter($this, "view_mode");
// type and id of get the bound object
$this->type = "lng";
if (! $this->id = $_GET['obj_id'])
{
$this->id = ilObjLanguageAccess::_lookupId($lng->getUserLanguage());
}
// do all generic GUI initialisations
$this->ilObjectGUI($a_data, $this->id, false, true);
// initialize the array to store session variables for extended language maintenance
if (!is_array($_SESSION['lang_ext_maintenance']))
{
$_SESSION['lang_ext_maintenance'] = array();
}
$this->session =& $_SESSION['lang_ext_maintenance'];
// read the lang mode
$this->langmode = $ilClientIniFile->readVariable("system","LANGMODE");
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::importObject ( )

Show the screen to import a language file.

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

References ilFormPropertyGUI\setInfo().

{
require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
$form = new ilPropertyFormGUI();
$form->setFormAction($this->ctrl->getFormAction($this));
$form->setTitle($this->lng->txt("language_import_file"));
$form->addCommandButton('upload',$this->lng->txt("upload"));
$fu = new ilFileInputGUI($this->lng->txt("file"), "userfile");
$form->addItem($fu);
$rg = new ilRadioGroupInputGUI($this->lng->txt("language_mode_existing"), "mode_existing");
$ro = new ilRadioOption($this->lng->txt("language_mode_existing_keepall"), "keepall");
$ro->setInfo($this->lng->txt("language_mode_existing_keepall_info"));
$rg->addOption($ro);
$ro = new ilRadioOption($this->lng->txt("language_mode_existing_keepnew"), "keepnew");
$ro->setInfo($this->lng->txt("language_mode_existing_keepnew_info"));
$rg->addOption($ro);
$ro = new ilRadioOption($this->lng->txt("language_mode_existing_replace"), "replace");
$ro->setInfo($this->lng->txt("language_mode_existing_replace_info"));
$rg->addOption($ro);
$ro = new ilRadioOption($this->lng->txt("language_mode_existing_delete"), "delete");
$ro->setInfo($this->lng->txt("language_mode_existing_delete_info"));
$rg->addOption($ro);
$rg->setValue($this->session["import"]["mode_existing"] ? $this->session["import"]["mode_existing"] : "keepall");
$form->addItem($rg);
$this->tpl->setContent($form->getHTML());
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::initAddNewEntryForm (   $a_id = null)
protected

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

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

Referenced by addNewEntryObject(), and saveNewEntryObject().

{
global $ilCtrl;
if(!$a_id)
{
$a_id = $_POST["id"];
}
if(!$a_id ||
{
$ilCtrl->redirect($this, "view");
}
include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
$form = new ilPropertyFormGUI();
$form->setFormAction($ilCtrl->getFormAction($this, "saveNewEntry"));
$form->setTitle($this->lng->txt("adm_missing_entry_add"));
$options = array_combine($mods, $mods);
$mod = new ilSelectInputGUI(ucfirst($this->lng->txt("module")), "mod");
$mod->setOptions(array(""=>$this->lng->txt("please_select"))+$options);
$mod->setRequired(true);
$form->addItem($mod);
$id = new ilTextInputGUI(ucfirst($this->lng->txt("identifier")), "id");
$id->setValue($a_id);
$id->setDisabled(true);
$form->addItem($id);
foreach ($this->lng->getInstalledLanguages() as $lang_key)
{
$trans = new ilTextInputGUI($this->lng->txt("meta_l_".$lang_key), "trans_".$lang_key);
if(in_array($lang_key, array("de", "en")))
{
$trans->setRequired(true);
}
$form->addItem($trans);
}
$form->addCommandButton("saveNewEntry", $this->lng->txt("save"));
$form->addCommandButton("view", $this->lng->txt("cancel"));
return $form;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjLanguageExtGUI::maintainExecuteObject ( )

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

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

{
if (isset($_POST["maintain"]))
{
$this->session["maintain"] = ilUtil::stripSlashes($_POST["maintain"]);
}
switch ($_POST["maintain"])
{
// save the local changes to the local language file
case "save":
$lang_file = $this->object->getCustLangPath() . '/ilias_' . $this->object->key . '.lang.local';
if ((is_file($lang_file) and is_writable($lang_file))
or (!file_exists($lang_file) and is_writable($this->object->getCustLangPath())))
{
// save a copy of the distributed language file
$orig_file = $this->object->getLangPath() . '/ilias_' . $this->object->key . '.lang';
$copy_file = $this->object->getCustLangPath() . '/ilias_' . $this->object->key . '.lang';
@copy($orig_file, $copy_file);
// save a backup of the old local language file
@rename($lang_file, $lang_file.".bak");
// create and write the new local language file
$global_file_obj = $this->object->getGlobalLanguageFile();
$local_file_obj = new ilLanguageFile($lang_file, $this->object->key, 'local');
$local_file_obj->setParam('based_on', $global_file_obj->getParam('version'));
$local_file_obj->setAllValues($this->object->getChangedValues());
if ($this->langmode)
{
$local_file_obj->setAllComments($this->object->getAllRemarks());
}
$local_file_obj->write();
$this->object->setLocal(true);
ilUtil::sendSuccess($this->lng->txt("language_saved_local") , true);
}
else
{
ilUtil::sendFailure($this->lng->txt("language_error_write_local") , true);
}
break;
// load the content of the local language file
case "load":
$lang_file = $this->object->getCustLangPath() . '/ilias_' . $this->object->key . '.lang.local';
if (is_file($lang_file) and is_readable($lang_file))
{
$this->object->importLanguageFile($lang_file, 'replace');
$this->object->setLocal(true);
ilUtil::sendSuccess($this->lng->txt("language_loaded_local") , true);
}
else
{
ilUtil::sendFailure($this->lng->txt("language_error_read_local") , true);
}
break;
// revert the database to the default language file
case "clear":
$lang_file = $this->object->getLangPath() . '/ilias_' . $this->object->key . '.lang';
if (is_file($lang_file) and is_readable($lang_file))
{
$this->object->importLanguageFile($lang_file, 'delete');
$this->object->setLocal(false);
ilUtil::sendSuccess($this->lng->txt("language_cleared_local") , true);
}
else
{
ilUtil::sendFailure($this->lng->txt("language_error_clear_local") , true);
}
break;
// delete local additions in the datavase (langmode only)
case "delete_added":
ilObjLanguageExt::_deleteValues($this->object->key, $this->object->getAddedValues());
break;
// merge local changes back to the global language file (langmode only)
case "merge":
$orig_file = $this->object->getLangPath() . '/ilias_' . $this->object->key . '.lang';
$copy_file = $this->object->getCustLangPath() . '/ilias_' . $this->object->key . '.lang';
if (is_file($orig_file) and is_writable($orig_file))
{
// save a copy of the global language file
@copy($orig_file, $copy_file);
// modify and write the new global file
$global_file_obj = $this->object->getGlobalLanguageFile();
$global_file_obj->setAllValues($this->object->getMergedValues());
$global_file_obj->setAllComments($this->object->getMergedRemarks());
$global_file_obj->write();
ilUtil::sendSuccess($this->lng->txt("language_merged_global") , true);
}
else
{
ilUtil::sendFailure($this->lng->txt("language_error_write_global") , true);
}
break;
// remove the local language file (langmode only)
case "remove_local_file":
$lang_file = $this->object->getCustLangPath() . '/ilias_' . $this->object->key . '.lang.local';
if (!is_file($lang_file))
{
$this->object->setLocal(false);
ilUtil::sendFailure($this->lng->txt("language_error_local_missed") , true);
}
elseif (@unlink($lang_file))
{
$this->object->setLocal(false);
ilUtil::sendSuccess($this->lng->txt("language_local_file_deleted") , true);
}
else
{
ilUtil::sendFailure($this->lng->txt("language_error_delete_local") , true);
}
break;
}
$this->ctrl->redirect($this,"maintain");
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::maintainObject ( )

Process the language maintenance.

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

References ilFormPropertyGUI\setInfo().

{
require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
$form = new ilPropertyFormGUI();
$form->setFormAction($this->ctrl->getFormAction($this));
$form->setTitle($this->lng->txt("language_maintenance"));
$form->setPreventDoubleSubmission(false);
$form->addCommandButton('maintainExecute',$this->lng->txt("language_process_maintenance"));
$rg = new ilRadioGroupInputGUI($this->lng->txt("language_maintain_local_changes"), "maintain");
$ro = new ilRadioOption($this->lng->txt("language_save_local_changes"), "save");
$ro->setInfo(sprintf($this->lng->txt("language_save_local_changes_info"),$this->object->key));
$rg->addOption($ro);
$ro = new ilRadioOption($this->lng->txt("language_load_local_changes"), "load");
$ro->setInfo(sprintf($this->lng->txt("language_load_local_changes_info"),$this->object->key));
$rg->addOption($ro);
$ro = new ilRadioOption($this->lng->txt("language_clear_local_changes"), "clear");
$ro->setInfo(sprintf($this->lng->txt("language_clear_local_changes_info"),$this->object->key));
$rg->addOption($ro);
if ($this->langmode)
{
$ro = new ilRadioOption($this->lng->txt("language_delete_local_additions"), "delete_added");
$ro->setInfo(sprintf($this->lng->txt("language_delete_local_additions_info"), $this->object->key));
$rg->addOption($ro);
$ro = new ilRadioOption($this->lng->txt("language_merge_local_changes"), "merge");
$ro->setInfo(sprintf($this->lng->txt("language_merge_local_changes_info"), $this->object->key));
$rg->addOption($ro);
$ro = new ilRadioOption($this->lng->txt("language_remove_local_file"), "remove_local_file");
$ro->setInfo(sprintf($this->lng->txt("language_remove_local_file_info"), $this->object->key));
$rg->addOption($ro);
}
$rg->setValue($this->session["maintain"]);
$form->addItem($rg);
$this->tpl->setContent($form->getHTML());
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::resetFilterObject ( )

Reset filter.

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

References getViewTable(), and viewObject().

{
$table_gui = $this->getViewTable();
$table_gui->resetOffset(); // sets record offest to 0 (first page)
$table_gui->resetFilter(); // clears filter
$this->viewObject();
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::saveNewEntryObject ( )

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

References $ilCtrl, $ilDB, $ilUser, $lang, $row, addNewEntryObject(), initAddNewEntryForm(), ilObjLanguage\replaceLangEntry(), ilObjLanguage\replaceLangModule(), and ilUtil\sendSuccess().

{
global $ilCtrl, $ilUser, $ilDB;
$form = $this->initAddNewEntryForm();
if($form->checkInput())
{
$mod = $form->getInput("mod");
$id = $form->getInput("id");
$lang = array();
foreach ($this->lng->getInstalledLanguages() as $lang_key)
{
$trans = trim($form->getInput("trans_".$lang_key));
if($trans)
{
// add single entry
$mod,
$id,
$lang_key,
$trans,
date("Y-m-d H:i:s"),
$ilUser->getLogin()
);
// add to serialized module
$set = $ilDB->query("SELECT lang_array FROM lng_modules".
" WHERE lang_key = ".$ilDB->quote($lang_key, "text").
" AND module = ".$ilDB->quote($mod, "text"));
$row = $ilDB->fetchAssoc($set);
$entries = unserialize($row["lang_array"]);
if(is_array($entries))
{
$entries[$id] = $trans;
ilObjLanguage::replaceLangModule($lang_key, $mod, $entries);
}
}
}
ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
$ilCtrl->redirect($this, "view");
}
$form->setValuesByPost();
$this->addNewEntryObject($form);
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::saveObject ( )

Save the changed translations.

Reimplemented from ilObjectGUI.

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

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

{
// prepare the values to be saved
$save_array = array();
$remarks_array = array();
foreach ($_POST as $key => $value)
{
$keys = explode($this->lng->separator, ilUtil::stripSlashes($key, false));
if (count($keys) == 2)
{
// avoid line breaks
$value = preg_replace("/(\015\012)|(\015)|(\012)/","<br />",$value);
$value = ilUtil::stripSlashes($value, false);
$save_array[$key] = $value;
$remarks_array[$key] = $_POST[$key.$this->lng->separator."comment"];
}
}
// save the translations
ilObjLanguageExt::_saveValues($this->object->key, $save_array, $remarks_array);
// view the list
$this->viewObject();
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::settingsObject ( )

Set the language settings.

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

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

{
global $ilSetting;
$translate_key = "lang_translate_". $this->object->key;
// save and get the page translation setting
if (!empty($_POST))
{
$ilSetting->set($translate_key, (bool) $_POST["translation"]);
ilUtil::sendSuccess($this->lng->txt("settings_saved"));
}
$translate = $ilSetting->get($translate_key, false);
require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
$form = new ilPropertyFormGUI();
$form->setFormAction($this->ctrl->getFormAction($this));
$form->setTitle($this->lng->txt("language_settings"));
$form->setPreventDoubleSubmission(false);
$form->addCommandButton('settings',$this->lng->txt("language_change_settings"));
$ci = new ilCheckboxInputGUI($this->lng->txt("language_translation_enabled"), "translation");
$ci->setChecked((bool) $translate);
$ci->setInfo($this->lng->txt("language_note_translation"));
$form->addItem($ci);
$this->tpl->setContent($form->getHTML());
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::setTitleAndDescription ( )

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

Reimplemented from ilObjectGUI.

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

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

{
{
$this->tpl->setHeaderPageTitle($this->lng->txt("translation"));
$this->tpl->setTitle($this->lng->txt("translation"). " ".$this->lng->txt("meta_l_".$this->object->key));
}
else
{
$this->tpl->setTitle($this->lng->txt("meta_l_".$this->object->key));
}
$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lngf.svg"), $this->lng->txt("obj_" . $this->object->getType()));
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::statisticsObject ( )

Print out statistics about the language.

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

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

{
$modules = ilObjLanguageExt::_getModules($this->object->key);
$data = array();
$total = array("module"=>'',"all"=>0,"changed"=>0, "unchanged"=>0);
foreach($modules as $module)
{
$row = array();
$row['module'] = $module;
$row['all'] = count($this->object->getAllValues(array($module)));
$row['changed'] = count($this->object->getChangedValues(array($module)));
$row['unchanged'] = $row['all']-$row['changed'];
$total['all'] += $row['all'];
$total['changed'] += $row['changed'];
$total['unchanged'] += $row['unchanged'];
$data[] = $row;
}
$total['module'] = "<b>".$this->lng->txt("language_all_modules")."</b>";
$total['all'] = "<b>".$total['all']."</b>";
$total['changed'] = "<b>".$total['changed']."</b>";
$total['unchanged'] = "<b>".$total['unchanged']."</b>";
// create and configure the table object
include_once 'Services/Table/classes/class.ilTable2GUI.php';
$table_gui = new ilTable2GUI($this, "statistics");
$table_gui->setRowTemplate("tpl.lang_statistics_row.html","Services/Language");
$table_gui->setEnableTitle(false);
$table_gui->setEnableNumInfo(false);
$table_gui->setLimit(count($data));
$table_gui->setExportFormats(array(ilTable2GUI::EXPORT_EXCEL));
$table_gui->addColumn(ucfirst($this->lng->txt("module")), "", "25%");
$table_gui->addColumn($this->lng->txt("language_scope_global"), "", "25%");
$table_gui->addColumn($this->lng->txt("language_scope_local"), "", "25%");
$table_gui->addColumn($this->lng->txt("language_scope_unchanged"), "", "25%");
$table_gui->setData($data);
$this->tpl->setContent($table_gui->getHTML());
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::uploadObject ( )

Process an uploaded language file.

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

References $_POST, $file, ilUtil\moveUploadedFile(), ilUtil\sendSuccess(), and ilUtil\stripSlashes().

{
// save form inputs for next display
$this->session["import"]["mode_existing"] = ilUtil::stripSlashes($_POST['mode_existing']);
if ($_POST['cmd']['upload'])
{
$file = $_FILES['userfile']['tmp_name'].'x';
if (ilUtil::moveUploadedFile($_FILES['userfile']['tmp_name'],
$_FILES['userfile']['name'],
{
$this->object->importLanguageFile($file,$_POST['mode_existing']);
ilUtil::sendSuccess(sprintf($this->lng->txt("language_file_imported"), $_FILES['userfile']['name']) , true);
}
}
$this->ctrl->redirect($this, 'import');
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::viewObject ( )

Show the edit screen.

Reimplemented from ilObjectGUI.

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

References $_GET, ilObjectGUI\$data, $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().

{
global $tpl;
// get the view table
$table_gui = $this->getViewTable();
// get the remarks in database
$comments = $this->object->getAllRemarks();
// set the language to compare with
// get the default values if the compare language is the same
$compare = $table_gui->getFilterItemByPostVar('compare')->getValue();
if ($compare == $this->object->key)
{
$compare_object = $this->object->getGlobalLanguageFile();
$compare_content = $compare_object->getAllValues();
$compare_comments = $compare_object->getAllComments();
}
// page translation mode:
// - the table is filtered by a list of modules and topics
{
// get the selection of modules and topics from request or session
// first call for translation
if ($_GET['reset_offset'])
{
$table_gui->resetOffset();
}
if (!isset($compare_content))
{
$compare_content = ilObjLanguageExt::_getValues(
$compare, $modules, $topics);
$compare_comments = ilObjLanguageExt::_getRemarks($compare);
}
$this->object->key, $modules, $topics);
// enable adding new entries
$db_found = array();
foreach($translations as $name => $translation)
{
$keys = explode($this->lng->separator, $name);
$db_found[] = $keys[1];
}
$missing_entries = array_diff($topics, $db_found);
}
// normal view mode:
// - the table is filtered manually by module, mode and pattern
else
{
$filter_mode = $table_gui->getFilterItemByPostVar('mode')->getValue();
$filter_pattern = $table_gui->getFilterItemByPostVar('pattern')->getValue();
$filter_module = $table_gui->getFilterItemByPostVar('module')->getValue();
$filter_module = $filter_module == 'all' ? '' : $filter_module;
$filter_modules = $filter_module ? array($filter_module) : array();
if (!isset($compare_content))
{
$compare_content = ilObjLanguageExt::_getValues(
$compare, $filter_modules);
$compare_comments = ilObjLanguageExt::_getRemarks($compare);
}
switch ($filter_mode)
{
case "changed":
$translations = $this->object->getChangedValues(
$filter_modules, $filter_pattern);
break;
case "added": //langmode only
$translations = $this->object->getAddedValues(
$filter_modules, $filter_pattern);
break;
case "unchanged":
$translations = $this->object->getUnchangedValues(
$filter_modules, $filter_pattern);
break;
case "commented":
$translations = $this->object->getCommentedValues(
$filter_modules, $filter_pattern);
break;
case "dbremarks":
$translations = $this->object->getAllValues(
$filter_modules, $filter_pattern);
$translations = array_intersect_key($translations, $remarks);
break;
case "equal":
$translations = $this->object->getAllValues(
$filter_modules, $filter_pattern);
$translations = array_intersect_assoc($translations, $compare_content);
break;
case "different":
$translations = $this->object->getAllValues(
$filter_modules, $filter_pattern);
$translations = array_diff_assoc($translations, $compare_content);
break;
case "conflicts":
$former_file = $this->object->getCustLangPath() . '/ilias_' . $this->object->key . '.lang';
if (!is_readable($former_file))
{
ilUtil::sendFailure(sprintf($this->lng->txt("language_former_file_missing"), $former_file)
.'<br />'. $this->lng->txt("language_former_file_description") , false);
$translations = array();
break;
}
$global_file_obj = $this->object->getGlobalLanguageFile();
$former_file_obj = new ilLanguageFile($former_file);
$former_file_obj->read();
$global_changes = array_diff_assoc(
$global_file_obj->getAllValues(),
$former_file_obj->getAllValues());
if (!count($global_changes))
{
ilUtil::sendInfo(sprintf($this->lng->txt("language_former_file_equal"), $former_file)
.'<br />'. $this->lng->txt("language_former_file_description") , false);
$translations = array();
break;
}
$translations = $this->object->getChangedValues(
$filter_modules, $filter_pattern);
$translations = array_intersect_key($translations, $global_changes);
break;
case "all":
default:
$translations = $this->object->getAllValues(
$filter_modules, $filter_pattern);
}
}
// prepare the the data for the table
$data = array();
foreach($translations as $name => $translation)
{
$keys = explode($this->lng->separator, $name);
$row = array();
$row["module"] = $keys[0];
$row["topic"] = $keys[1];
$row["name"] = $name;
$row["translation"] = $translation;
$row["comment"] = $comments[$name];
$row["default"] = $compare_content[$name];
$row["default_comment"] = $compare_comments[$name];
$data[] = $row;
}
// render and show the table
$table_gui->setData($data);
$tpl->setContent($table_gui->getHTML().
$this->buildMissingEntries($missing_entries));
}

+ 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: