ILIAS  release_4-3 Revision
 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.
executeCommand ()
 execute command
 cancelObject ()
 Cancel the current action.
 viewObject ()
 Show the edit screen.
 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.
 settingsObject ()
 Set the language settings.
 statisticsObject ()
 Print out statistics about the language.
 getPar ($a_request_name, $a_default_value)
 Read a param that is either coming from GET, POST or is taken from the session variables of this GUI.
 getAdminTabs (&$tabs_gui)
 Get tabs for admin mode.
 prepareOutput ()
 Prepare the standard template for output (Overwritten from ilObjectGUI)
 addAdminLocatorItems ()
 Set the locator for admin mode (called from prepareOutput in parent class)
 setTitleAndDescription ()
 Set the Title and the description (Overwritten from ilObjectGUI, called by prepareOutput)
- 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.

Static Public Member Functions

static _isPageTranslation ()
 Check if the GUI is in page translation mode.
static _getTranslationLink ()
 Get the HTML code for calling the page translation.
- 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.

Private Attributes

 $inputsize = 50
 $commentsize = 30

Additional Inherited Members

- 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
- Protected Member Functions inherited from ilObjectGUI
 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.
 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)
 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.
 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
 __showClipboardTable ($a_result_set, $a_from="")
 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.

Detailed Description

Member Function Documentation

static ilObjLanguageExtGUI::_getTranslationLink ( )
static

Get the HTML code for calling the page translation.

Returns a hidden form with a link to the translation screen The HTML code can be added to the footer of every ILIAS page

static

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

References $ilSetting, ilObjectGUI\$lng, ilObjectGUI\$tpl, and ilUtil\prepareFormOutput().

Referenced by ilTemplate\addILIASFooter().

{
global $ilSetting, $lng;
// prevent translation link on translation screen
// check setting of translation mode
if (self::_isPageTranslation()
or !$ilSetting->get("lang_translate_".$lng->getLangKey()))
{
return "";
}
// set the target for translation
// ref id must be given to prevent params being deleted by ilAdministrtionGUI
$action = "ilias.php"
."?ref_id=".ilobjLanguageAccess::_lookupLangFolderRefId()
."&baseClass=ilAdministrationGUI"
."&cmdClass=ilobjlanguageextgui"
."&view_mode=translate";
$tpl = new ilTemplate("tpl.translation_link.html",true,true, "Services/Language");
foreach($lng->getUsedModules() as $module => $dummy)
{
$tpl->setCurrentBlock("hidden");
$tpl->setVariable("NAME", "page_modules[]");
$tpl->setVariable("VALUE", ilUtil::prepareFormOutput($module));
$tpl->parseCurrentBlock();
}
foreach($lng->getUsedTopics() as $topic => $dummy)
{
$tpl->setCurrentBlock("hidden");
$tpl->setVariable("NAME", "page_topics[]");
$tpl->setVariable("VALUE", ilUtil::prepareFormOutput($topic));
$tpl->parseCurrentBlock();
}
$tpl->setVariable("ACTION", $action);
$tpl->setVariable("TXT_TRANSLATE",$lng->txt("translation"));
return $tpl->get();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilObjLanguageExtGUI::_isPageTranslation ( )
static

Check if the GUI is in page translation mode.

The page translation mode is used when the translation of a single page is called by the translation link on a page footer. The page translation screen is shown in a separate window. On this screen only the topics used on the calling page are shown for translation and only a save function for these topics is offered.

static

Returns
bool page translation (true or false)

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

References $_GET.

Referenced by prepareOutput(), and viewObject().

{
return ($_GET['view_mode'] == "translate");
}

+ Here is the caller graph for this function:

ilObjLanguageExtGUI::addAdminLocatorItems ( )

Set the locator for admin mode (called from prepareOutput in parent class)

Reimplemented from ilObjectGUI.

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

References ilObjectGUI\$tpl, and ilFrameTargetInfo\_getFrame().

{
global $ilLocator, $tpl;
$ilLocator->addItem($this->lng->txt("administration"),
$this->ctrl->getLinkTargetByClass("iladministrationgui", "frameset"),
$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::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 84 of file class.ilObjLanguageExtGUI.php.

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

Cancel the current action.

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

References viewObject().

Referenced by uploadObject().

{
$this->viewObject();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjLanguageExtGUI::downloadObject ( )

Download a language file.

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

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

{
$filename = 'ilias_' . $this->object->key . '_'
. str_replace(".", "_", substr(ILIAS_VERSION, 0, strpos(ILIAS_VERSION, " ")))
. "-" . date('Y-m-d')
. ".lang.".$_POST["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 94 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");
// exit;
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::exportObject ( )

Show the screen to export a language file.

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

References $_POST.

{
$scope = $_POST["scope"] ? $_POST["scope"] : "global";
$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lang_file_export.html", "Services/Language");
$this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
$this->tpl->setVariable("TXT_HEADER",$this->lng->txt("language_export_file"));
$this->tpl->setVariable("TXT_SCOPE",$this->lng->txt("language_file_scope"));
$this->tpl->setVariable("TXT_SCOPE_GLOBAL",$this->lng->txt("language_scope_global"));
$this->tpl->setVariable("TXT_SCOPE_LOCAL",$this->lng->txt("language_scope_local"));
$this->tpl->setVariable("TXT_SCOPE_UNCHANGED",$this->lng->txt("language_scope_unchanged"));
$this->tpl->setVariable("CHECKED_GLOBAL",$scope == 'global' ? 'checked="checked"' : '');
$this->tpl->setVariable("CHECKED_LOCAL",$scope == 'local' ? 'checked="checked"' : '');
$this->tpl->setVariable("CHECKED_UNCHANGED",$scope == 'unchanged' ? 'checked="checked"' : '');
if ($this->langmode)
{
$this->tpl->setVariable("TXT_SCOPE_ADDED",$this->lng->txt("language_scope_added"));
$this->tpl->setVariable("CHECKED_ADDED",$scope == 'added' ? 'checked="checked"' : '');
$this->tpl->setVariable("TXT_SCOPE_MERGED",$this->lng->txt("language_scope_merged"));
$this->tpl->setVariable("CHECKED_MERGED",$scope == 'merged' ? 'checked="checked"' : '');
}
$this->tpl->setVariable("TXT_DOWNLOAD",$this->lng->txt("download"));
$this->tpl->setVariable("CMD_DOWNLOAD","download");
// $this->tpl->show();
}
ilObjLanguageExtGUI::getAdminTabs ( $tabs_gui)

Get tabs for admin mode.

Parameters
objecttabs gui object

Reimplemented from ilObjectGUI.

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

{
global $rbacsystem;
$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"));
}
ilObjLanguageExtGUI::getPar (   $a_request_name,
  $a_default_value 
)

Read a param that is either coming from GET, POST or is taken from the session variables of this GUI.

A request value is automatically saved in the session variables. Slashes are stripped from request values.

Parameters
stringname of the GET or POST or variable
mixeddefault value

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

References $_GET, $_POST, and ilUtil\stripSlashes().

Referenced by viewObject().

{
// get the parameter value
if (isset($_GET[$a_request_name]))
{
$param = $_GET[$a_request_name];
$from_request = true;
}
elseif (isset($_POST[$a_request_name]))
{
$param = $_POST[$a_request_name];
$from_request = true;
}
elseif (isset($this->session[$a_request_name]))
{
$param = $this->session[$a_request_name];
$from_request = false;
}
else
{
$param = $a_default_value;
$from_request = false;
}
// strip slashes from request parameters
if ($from_request)
{
if (is_array($param))
{
foreach ($param as $key => $value)
{
$param[$key] = ilUtil::stripSlashes($value);
}
}
else
{
$param = ilUtil::stripSlashes($param);
}
}
// make the parameter available to further requests
$this->session[$a_request_name] = $param;
return $param;
}

+ Here is the call graph for this function:

+ 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 44 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) needed for prepareOutput()
$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 GUI session variables
if (!is_array($_SESSION[get_class($this)]))
{
$_SESSION[get_class($this)] = array();
}
$this->session =& $_SESSION[get_class($this)];
// 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 477 of file class.ilObjLanguageExtGUI.php.

Referenced by uploadObject().

{
$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lang_file_import.html", "Services/Language");
$this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
$this->tpl->setVariable("TXT_HEADER",$this->lng->txt("language_import_file"));
$this->tpl->setVariable("TXT_FILE",$this->lng->txt("file"));
$this->tpl->setVariable("TXT_MODE",$this->lng->txt("language_mode_existing"));
$this->tpl->setVariable("TXT_MODE_KEEPALL",$this->lng->txt("language_mode_existing_keepall"));
$this->tpl->setVariable("TXT_MODE_KEEPNEW",$this->lng->txt("language_mode_existing_keepnew"));
$this->tpl->setVariable("TXT_MODE_REPLACE",$this->lng->txt("language_mode_existing_replace"));
$this->tpl->setVariable("TXT_MODE_DELETE",$this->lng->txt("language_mode_existing_delete"));
$this->tpl->setVariable("TXT_UPLOAD",$this->lng->txt("upload"));
$this->tpl->setVariable("CMD_UPLOAD","upload");
// $this->tpl->show();
}

+ Here is the caller graph for this function:

ilObjLanguageExtGUI::maintainObject ( )

Process the language maintenance.

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

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

{
global $ilUser;
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") , false);
}
else
{
ilUtil::sendFailure($this->lng->txt("language_error_write_local") , false);
}
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") , false);
}
else
{
ilUtil::sendFailure($this->lng->txt("language_error_read_local") , false);
}
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") , false);
}
else
{
ilUtil::sendFailure($this->lng->txt("language_error_clear_local") , false);
}
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") , false);
}
else
{
ilUtil::sendFailure($this->lng->txt("language_error_write_global") , false);
}
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") , false);
}
elseif (@unlink($lang_file))
{
$this->object->setLocal(false);
ilUtil::sendSuccess($this->lng->txt("language_local_file_deleted") , false);
}
else
{
ilUtil::sendFailure($this->lng->txt("language_error_delete_local") , false);
}
break;
}
$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lang_maintenance.html", "Services/Language");
$this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
$this->tpl->setVariable("TXT_MAINTENANCE",$this->lng->txt("language_maintenance"));
$this->tpl->setVariable("TXT_MAINTAIN_LOCAL",$this->lng->txt("language_maintain_local_changes"));
$this->tpl->setVariable("TXT_SELECT",$this->lng->txt("please_select"));
$this->tpl->setVariable("TXT_SAVE",$this->lng->txt("language_save_local_changes"));
$this->tpl->setVariable("TXT_LOAD",$this->lng->txt("language_load_local_changes"));
$this->tpl->setVariable("TXT_CLEAR",$this->lng->txt("language_clear_local_changes"));
if ($this->langmode)
{
$this->tpl->setVariable("TXT_DELETE_ADDED",$this->lng->txt("language_delete_local_additions"));
$this->tpl->setVariable("TXT_MERGE",$this->lng->txt("language_merge_local_changes"));
$this->tpl->setVariable("TXT_REMOVE_LOCAL_FILE",$this->lng->txt("language_remove_local_file"));
}
$this->tpl->setVariable("TXT_NOTE_SAVE",$this->lng->txt("language_note_save_local"));
$this->tpl->setVariable("TXT_MAINTAIN",$this->lng->txt("language_process_maintenance"));
$this->tpl->setVariable("VAR_MAINTAIN", "maintain");
$this->tpl->setVariable("CMD_MAINTAIN", "maintain");
// $this->tpl->show();
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::prepareOutput ( )

Prepare the standard template for output (Overwritten from ilObjectGUI)

Reimplemented from ilObjectGUI.

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

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

{
if ($this->_isPageTranslation())
{
// show the pure translation page without menu, tabs etc.
$this->tpl->addBlockFile("CONTENT","content","tpl.adm_translate.html","Services/Language");
$this->tpl->setHeaderPageTitle($this->lng->txt("translation"));
$this->tpl->setTitle($this->lng->txt("translation"). " "
.$this->lng->txt("meta_l_".$this->object->key));
$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_lng_b.png"),
$this->lng->txt("obj_" . $this->object->getType()));
}
else
{
// show the full page framework
}
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::saveObject ( )

Save the changed translations.

Reimplemented from ilObjectGUI.

Definition at line 446 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 772 of file class.ilObjLanguageExtGUI.php.

References $_POST, and $ilSetting.

{
global $ilSetting;
$translate_key = "lang_translate_". $this->object->key;
// save and get the page translation setting
switch ($_POST["translation"])
{
case "enable":
$ilSetting->set($translate_key, true);
break;
case "disable":
$ilSetting->set($translate_key, false);
}
$translate = $ilSetting->get($translate_key, false);
$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lang_settings.html", "Services/Language");
$this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
$this->tpl->setVariable("TXT_SETTINGS",$this->lng->txt("language_settings"));
$this->tpl->setVariable("TXT_TRANSLATION",$this->lng->txt("language_translation_mode"));
$this->tpl->setVariable("TXT_TRANSLATION_ENABLED",$this->lng->txt("language_translation_enabled"));
$this->tpl->setVariable("TXT_TRANSLATION_DISABLED",$this->lng->txt("language_translation_disabled"));
$this->tpl->setVariable("CHECKED_ENABLE", $translate ? 'checked="checked"': '');
$this->tpl->setVariable("CHECKED_DISABLE", $translate ? '' : 'checked="checked"');
$this->tpl->setVariable("TXT_NOTE_TRANSLATION",$this->lng->txt("language_note_translation"));
$this->tpl->setVariable("TXT_CHANGE_SETTINGS",$this->lng->txt("language_change_settings"));
$this->tpl->setVariable("CMD_SETTINGS", "settings");
// $this->tpl->show();
}
ilObjLanguageExtGUI::setTitleAndDescription ( )

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

Reimplemented from ilObjectGUI.

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

References ilUtil\getImagePath().

{
$this->tpl->setTitle($this->lng->txt("meta_l_".$this->object->getTitle()));
// $this->tpl->setDescription($this->object->getLongDescription());
$this->tpl->setTitleIcon(ilUtil::getImagePath("icon_".$this->object->getType()."_b.png"), $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 807 of file class.ilObjLanguageExtGUI.php.

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

{
$modules = ilObjLanguageExt::_getModules($this->object->key);
$data = array();
$total = array("",0,0,0);
foreach($modules as $module)
{
$row = array();
$row[0] = $module;
$row[1] = count($this->object->getAllValues(array($module)));
$row[2] = count($this->object->getChangedValues(array($module)));
$row[3] = $row[1]-$row[2];
$total[1] += $row[1];
$total[2] += $row[2];
$total[3] += $row[3];
$data[] = $row;
}
$total[0] = "<b>".$this->lng->txt("language_all_modules")."</b>";
$total[1] = "<b>".$total[1]."</b>";
$total[2] = "<b>".$total[2]."</b>";
$total[3] = "<b>".$total[3]."</b>";
// prepare the templates for output
$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lang_statistics.html", "Services/Language");
$this->tpl->addBlockFile("TABLE_STATISTICS", "table_statistics", "tpl.table.html");
$this->tpl->addBlockFile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
// create and configure the table object
include_once 'Services/Table/classes/class.ilTableGUI.php';
$tbl = new ilTableGUI();
$tbl->disable('title');
$tbl->disable('sort');
$tbl->disable('numinfo');
$tbl->setHeaderNames(array($this->lng->txt("module"),
$this->lng->txt("language_scope_global"),
$this->lng->txt("language_scope_local"),
$this->lng->txt("language_scope_unchanged")));
$tbl->setColumnWidth(array( "25%", "25%", "25%", "25%"));
$tbl->setLimit(count($data));
$tbl->setData($data);
// show the table
$tbl->render();
// $this->tpl->show();
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::uploadObject ( )

Process an uploaded language file.

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

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

{
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']) , false);
$this->importObject();
}
else
{
$this->importObject();
}
}
else
{
$this->cancelObject();
}
}

+ Here is the call graph for this function:

ilObjLanguageExtGUI::viewObject ( )

Show the edit screen.

Reimplemented from ilObjectGUI.

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

References ilObjectGUI\$data, $ilUser, ilObjectGUI\$tpl, ilObjLanguageExt\_getModules(), ilObjLanguageExt\_getRemarks(), ilObjLanguageExt\_getValues(), _isPageTranslation(), ilUtil\formSelect(), getPar(), ilUtil\prepareFormOutput(), ilUtil\sendFailure(), ilUtil\sendInfo(), and ilUtil\sortArray().

Referenced by cancelObject(), and saveObject().

{
global $ilUser;
$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lang_edit_items.html", "Services/Language");
// set the language to compare with
$compare = $this->getPar('compare', $this->lng->getDefaultLanguage());
// get the default values if the compare language is the same
if ($compare == $this->object->key)
{
$compare_object = $this->object->getGlobalLanguageFile();
$compare_content = $compare_object->getAllValues();
$compare_comments = $compare_object->getAllComments();
$compare_note = " ". $this->lng->txt("language_default_entries");
}
// get the remarks in database
$remarks = $this->object->getAllRemarks();
// page translation mode:
// - the table is filtered by a list of modules and topics
// - all found entries are shown on the same page
if ($this->_isPageTranslation())
{
$offset = 0;
$limit = 0;
$modules = $this->getPar("page_modules", array());
$topics = $this->getPar("page_topics", array());
if (!isset($compare_content))
{
$compare_content = ilObjLanguageExt::_getValues(
$compare, $modules, $topics);
$compare_comments = ilObjLanguageExt::_getRemarks($compare);
}
$this->object->key, $modules, $topics);
}
// normal view mode:
// - the table is filtered manually by module, mode and pattern
// - found entries are paged by maximum list length
// - the filter selection is shown
else
{
$offset = $this->getPar('offset','0');
$limit = $ilUser->getPref("hits_per_page");
$filter_mode = $this->getPar('filter_mode','all');
$filter_pattern = $this->getPar('filter_pattern','');
$filter_module = $this->getPar('filter_module','administration');
$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);
}
// show the filter section
$this->tpl->setCurrentBlock("filter");
// filter by language module
$options = array();
$options[""] = $this->lng->txt("language_all_modules");
$modules = ilObjLanguageExt::_getModules($this->object->key);
foreach ($modules as $mod)
{
$options[$mod] = $mod;
}
$this->tpl->setVariable("SELECT_MODULE",
ilUtil::formSelect($filter_module, "filter_module", $options, false, true));
// filter by mode
$options = array();
$options["all"] = $this->lng->txt("language_scope_global");
$options["changed"] = $this->lng->txt("language_scope_local");
if ($this->langmode)
{
$options["added"] = $this->lng->txt("language_scope_added");
}
$options["unchanged"] = $this->lng->txt("language_scope_unchanged");
$options["equal"] = $this->lng->txt("language_scope_equal");
$options["different"] = $this->lng->txt("language_scope_different");
$options["commented"] = $this->lng->txt("language_scope_commented");
if ($this->langmode)
{
$options["dbremarks"] = $this->lng->txt("language_scope_dbremarks");
}
$options["conflicts"] = $this->lng->txt("language_scope_conflicts");
$this->tpl->setVariable("SELECT_MODE",
ilUtil::formSelect($filter_mode, "filter_mode", $options, false, true));
// filter by pattern
$this->tpl->setVariable("PATTERN_NAME", "filter_pattern");
$this->tpl->setVariable("PATTERN_VALUE", ilUtil::prepareFormOutput($filter_pattern));
// and general filter variables
$this->tpl->setVariable("FILTER_ACTION", $this->ctrl->getFormAction($this));
$this->tpl->setVariable("TXT_FILTER", $this->lng->txt("filter"));
$this->tpl->setVariable("OFFSET_NAME", "offset");
$this->tpl->setVariable("OFFSET_VALUE", "0");
$this->tpl->setVariable("TXT_APPLY_FILTER", $this->lng->txt("apply_filter"));
$this->tpl->setVariable("CMD_FILTER", "view");
$this->tpl->parseCurrentBlock();
}
// show the compare section
$this->tpl->setCurrentBlock("compare");
$this->tpl->setVariable("COMPARE_ACTION", $this->ctrl->getFormAction($this));
$this->tpl->setVariable("TXT_COMPARE", $this->lng->txt("language_compare"));
$this->tpl->setVariable("TXT_CHANGE", $this->lng->txt("change"));
$options = array();
$langlist = $this->lng->getInstalledLanguages();
foreach ($langlist as $lang_key)
{
$options[$lang_key] = $this->lng->txt("meta_l_".$lang_key);
}
$this->tpl->setVariable("SELECT_COMPARE",
ilUtil::formSelect($compare, "compare", $options, false, true,1));
$this->tpl->setVariable("CMD_COMPARE", "view");
$this->tpl->parseCurrentBlock();
// prepare the dataset for the output table
$sort_by = $this->getPar('sort_by','translation');
$sort_order = $this->getPar('sort_order','asc');
$list = array();
foreach($translations as $name => $translation)
{
$keys = explode($this->lng->separator, $name);
$data = array();
$data["module"] = $keys[0];
$data["topic"] = $keys[1];
$data["name"] = $name;
$data["translation"] = $translation;
$data["default"] = $compare_content[$name];
$data["default_comment"] = $compare_comments[$name];
$list[] = $data;
}
$list = ilUtil::sortArray($list, $sort_by, $sort_order);
if ($limit > 0)
{
$list = array_slice($list, $offset, $limit);
}
// create and configure the table object
include_once 'Services/Table/classes/class.ilTableGUI.php';
$tbl = new ilTableGUI();
$tbl->disable('title');
$tbl->setHeaderNames(array($this->lng->txt("module"),
$this->lng->txt("identifier"),
$this->lng->txt("meta_l_".$this->object->key),
$this->lng->txt("meta_l_".$compare).$compare_note));
$tbl->setHeaderVars(array("module",
"topic",
"translation",
"default"),
$this->ctrl->getParameterArray($this));
$tbl->setColumnWidth(array( "10%",
"20%",
"40%",
"30%"));
$tbl->setOrderColumn($sort_by);
$tbl->setOrderDirection($sort_order);
$tbl->setLimit($limit);
$tbl->setOffset($offset);
$tbl->setMaxCount(count($translations));
// prepare the table template
$tpl =& new ilTemplate("tpl.table.html", true, true);
$tpl->setCurrentBlock("tbl_form_header");
$tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
$tpl->parseCurrentBlock();
$tpl->setCurrentBlock("tbl_action_btn");
$tpl->setVariable("BTN_NAME",'save');
$tpl->setVariable("BTN_VALUE",$this->lng->txt('save'));
$tpl->parseCurrentBlock();
$tpl->setCurrentBlock("tbl_action_row");
$tpl->setVariable("COLUMN_COUNTS","4");
$tpl->parseCurrentBlock();
// render the table rows
$tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.lang_items_row.html", "Services/Language");
foreach ($list as $data)
{
if ($this->langmode)
{
$tpl->setCurrentBlock('comment');
$tpl->setVariable("COM_ID", ilUtil::prepareFormOutput($data["name"].$this->lng->separator."comment"));
$tpl->setVariable("COM_NAME", ilUtil::prepareFormOutput($data["name"].$this->lng->separator."comment"));
$tpl->setVariable("COM_VALUE", ilUtil::prepareFormOutput($remarks[$data["name"]]));
$tpl->setVariable("COM_SIZE", $this->commentsize);
$tpl->setVariable("COM_MAX", 250);
$tpl->setVariable("TXT_COMMENT", $this->lng->txt('comment'));
$tpl->parseCurrentBlock();
}
else
{
$tpl->setCurrentBlock('hidden_comment');
$tpl->setVariable("COM_NAME", ilUtil::prepareFormOutput($data["name"].$this->lng->separator."comment"));
$tpl->setVariable("COM_VALUE", ilUtil::prepareFormOutput($remarks[$data["name"]]));
$tpl->parseCurrentBlock();
}
$tpl->setCurrentBlock("row");
$tpl->setVariable("T_ROWS", ceil(strlen($data["translation"]) / $this->inputsize));
$tpl->setVariable("T_SIZE", $this->inputsize);
$tpl->setVariable("T_NAME", ilUtil::prepareFormOutput($data["name"]));
$tpl->setVariable("T_USER_VALUE", ilUtil::prepareFormOutput($data["translation"]));
$tpl->setVariable("MODULE", ilUtil::prepareFormOutput($data["module"]));
$tpl->setVariable("TOPIC", ilUtil::prepareFormOutput($data["topic"]));
$tpl->setVariable("DEFAULT_VALUE", ilUtil::prepareFormOutput($data["default"]));
$tpl->setVariable("COMMENT", ilUtil::prepareFormOutput($data["default_comment"]));
$tpl->parseCurrentBlock();
}
// render and show the table
$tbl->setTemplate($tpl);
$tbl->render();
$this->tpl->setVariable("TRANSLATION_TABLE", $tpl->get());
// $this->tpl->show();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation

ilObjLanguageExtGUI::$commentsize = 30
private

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

ilObjLanguageExtGUI::$inputsize = 50
private

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


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