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

GUI class for object translation handling. More...

+ Collaboration diagram for ilObjectTranslationGUI:

Public Member Functions

 __construct ($a_obj_gui)
 Constructor.
 setTitleDescrOnlyMode ($a_val)
 Set enable title/description only mode.
 getTitleDescrOnlyMode ()
 Get enable title/description only mode.
 executeCommand ()
 Execute command.
 listTranslations ($a_get_post_values=false, $a_add=false)
 List translations.
 saveTranslations ()
 Save translations.
 deleteTranslations ()
 Remove translation.
 activateContentMultilinguality ()
 Activate multi language (-> master language selection)
 getMultiLangForm ($a_add=false)
 Get multi language form.
 saveContentTranslationActivation ()
 Save content translation activation.
 confirmDeactivateContentMultiLang ()
 Get multi lang info.
 deactivateContentMultiLang ()
 Deactivate multilanguage.
 addLanguages ()
 Add language.
 saveLanguages ()
 Save languages.
 confirmRemoveLanguages ()
 Confirm remove languages.
 removeLanguages ()
 Remove languages.

Protected Attributes

 $obj_trans
 $title_descr_only = true

Detailed Description

GUI class for object translation handling.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 12 of file class.ilObjectTranslationGUI.php.

Constructor & Destructor Documentation

ilObjectTranslationGUI::__construct (   $a_obj_gui)

Constructor.

Definition at line 20 of file class.ilObjectTranslationGUI.php.

References $ilCtrl, $lng, $tpl, and ilObjectTranslation\getInstance().

{
global $lng, $ilCtrl, $tpl;
$this->lng = $lng;
$this->ctrl = $ilCtrl;
$this->tpl = $tpl;
$this->obj_gui = $a_obj_gui;
$this->obj = $a_obj_gui->object;
include_once("./Services/Object/classes/class.ilObjectTranslation.php");
$this->obj_trans = ilObjectTranslation::getInstance($this->obj->getId());
}

+ Here is the call graph for this function:

Member Function Documentation

ilObjectTranslationGUI::activateContentMultilinguality ( )

Activate multi language (-> master language selection)

Definition at line 252 of file class.ilObjectTranslationGUI.php.

References $lng, $tpl, getMultiLangForm(), and ilUtil\sendInfo().

{
global $tpl, $lng;
ilUtil::sendInfo($lng->txt("obj_select_master_lang"));
$form = $this->getMultiLangForm();
$tpl->setContent($form->getHTML());
}

+ Here is the call graph for this function:

ilObjectTranslationGUI::addLanguages ( )

Add language.

Definition at line 426 of file class.ilObjectTranslationGUI.php.

References $tpl, and getMultiLangForm().

{
global $tpl;
$form = $this->getMultiLangForm(true);
$tpl->setContent($form->getHTML());
}

+ Here is the call graph for this function:

ilObjectTranslationGUI::confirmDeactivateContentMultiLang ( )

Get multi lang info.

Confirm page translation creation

Definition at line 375 of file class.ilObjectTranslationGUI.php.

References $ilCtrl, $lng, $tpl, and getTitleDescrOnlyMode().

{
global $ilCtrl, $tpl, $lng;
include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
$cgui = new ilConfirmationGUI();
$cgui->setFormAction($ilCtrl->getFormAction($this));
if ($this->getTitleDescrOnlyMode())
{
$cgui->setHeaderText($lng->txt("obj_deactivate_content_transl_conf"));
}
else
{
$cgui->setHeaderText($lng->txt("obj_deactivate_multilang_conf"));
}
$cgui->setCancel($lng->txt("cancel"), "listTranslations");
$cgui->setConfirm($lng->txt("confirm"), "deactivateContentMultiLang");
$tpl->setContent($cgui->getHTML());
}

+ Here is the call graph for this function:

ilObjectTranslationGUI::confirmRemoveLanguages ( )

Confirm remove languages.

Definition at line 465 of file class.ilObjectTranslationGUI.php.

References $_POST, $ilCtrl, $lng, $tpl, and ilUtil\sendInfo().

{
global $ilCtrl, $tpl, $lng;
$lng->loadLanguageModule("meta");
if (!is_array($_POST["lang"]) || count($_POST["lang"]) == 0)
{
ilUtil::sendInfo($lng->txt("no_checkbox"), true);
$ilCtrl->redirect($this, "listTranslations");
}
else
{
include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
$cgui = new ilConfirmationGUI();
$cgui->setFormAction($ilCtrl->getFormAction($this));
$cgui->setHeaderText($lng->txt("obj_conf_delete_lang"));
$cgui->setCancel($lng->txt("cancel"), "listTranslations");
$cgui->setConfirm($lng->txt("remove"), "removeLanguages");
foreach ($_POST["lang"] as $i)
{
$cgui->addItem("lang[]", $i, $lng->txt("meta_l_".$i));
}
$tpl->setContent($cgui->getHTML());
}
}

+ Here is the call graph for this function:

ilObjectTranslationGUI::deactivateContentMultiLang ( )

Deactivate multilanguage.

Definition at line 399 of file class.ilObjectTranslationGUI.php.

References $ilCtrl, $lng, getTitleDescrOnlyMode(), and ilUtil\sendSuccess().

{
global $lng, $ilCtrl;
if (!$this->getTitleDescrOnlyMode())
{
$this->obj_trans->setMasterLanguage("");
$this->obj_trans->setLanguages(array());
$this->obj_trans->save();
}
$this->obj_trans->deactivateContentTranslation();
if ($this->getTitleDescrOnlyMode())
{
ilUtil::sendSuccess($lng->txt("obj_cont_transl_deactivated"), true);
}
else
{
ilUtil::sendSuccess($lng->txt("obj_multilang_deactivated"), true);
}
$ilCtrl->redirect($this, "listTranslations");
}

+ Here is the call graph for this function:

ilObjectTranslationGUI::deleteTranslations ( )

Remove translation.

Definition at line 221 of file class.ilObjectTranslationGUI.php.

References $_POST, listTranslations(), saveTranslations(), and ilUtil\sendFailure().

{
foreach($_POST["title"] as $k => $v)
{
if ($_POST["check"][$k])
{
// default translation cannot be deleted
if($k != $_POST["default"])
{
unset($_POST["title"][$k]);
unset($_POST["desc"][$k]);
unset($_POST["lang"][$k]);
}
else
{
ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
$this->listTranslations();
return;
}
}
}
$this->saveTranslations();
}

+ Here is the call graph for this function:

ilObjectTranslationGUI::executeCommand ( )

Execute command.

Definition at line 57 of file class.ilObjectTranslationGUI.php.

References $cmd.

{
$next_class = $this->ctrl->getNextClass($this);
switch ($next_class)
{
default:
$cmd = $this->ctrl->getCmd("listTranslations");
if (in_array($cmd, array("listTranslations", "saveTranslations",
"addTranslation", "deleteTranslations", "activateContentMultilinguality",
"confirmRemoveLanguages", "removeLanguages", "confirmDeactivateContentMultiLang", "saveLanguages",
"saveContentTranslationActivation", "deactivateContentMultiLang", "addLanguages")))
{
$this->$cmd();
}
break;
}
}
ilObjectTranslationGUI::getMultiLangForm (   $a_add = false)

Get multi language form.

Definition at line 265 of file class.ilObjectTranslationGUI.php.

References $ilCtrl, $ilUser, $lng, $options, $si, $tpl, ilMDLanguageItem\_getLanguages(), getTitleDescrOnlyMode(), and ilSelectInputGUI\setOptions().

Referenced by activateContentMultilinguality(), addLanguages(), saveContentTranslationActivation(), and saveLanguages().

{
global $tpl, $lng, $ilCtrl, $ilUser;
include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
$form = new ilPropertyFormGUI();
// master language
if (!$a_add)
{
include_once("./Services/MetaData/classes/class.ilMDLanguageItem.php");
$si = new ilSelectInputGUI($lng->txt("obj_master_lang"), "master_lang");
$si->setOptions($options);
$si->setValue($ilUser->getLanguage());
$form->addItem($si);
}
// additional languages
if ($a_add)
{
include_once("./Services/MetaData/classes/class.ilMDLanguageItem.php");
$options = array("" => $lng->txt("please_select")) + $options;
$si = new ilSelectInputGUI($lng->txt("obj_additional_langs"), "additional_langs");
$si->setMulti(true);
$form->addItem($si);
}
if ($a_add)
{
$form->setTitle($lng->txt("obj_add_languages"));
$form->addCommandButton("saveLanguages", $lng->txt("save"));
$form->addCommandButton("listTranslations", $lng->txt("cancel"));
}
else
{
if ($this->getTitleDescrOnlyMode())
{
$form->setTitle($lng->txt("obj_activate_content_lang"));
}
else
{
$form->setTitle($lng->txt("obj_activate_multilang"));
}
$form->addCommandButton("saveContentTranslationActivation", $lng->txt("save"));
$form->addCommandButton("listTranslations", $lng->txt("cancel"));
}
$form->setFormAction($ilCtrl->getFormAction($this));
return $form;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjectTranslationGUI::getTitleDescrOnlyMode ( )

Get enable title/description only mode.

Returns
bool enable title/description only mode

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

References $title_descr_only.

Referenced by confirmDeactivateContentMultiLang(), deactivateContentMultiLang(), getMultiLangForm(), and listTranslations().

+ Here is the caller graph for this function:

ilObjectTranslationGUI::listTranslations (   $a_get_post_values = false,
  $a_add = false 
)

List translations.

Definition at line 79 of file class.ilObjectTranslationGUI.php.

References $_POST, ilObject\_lookupType(), getTitleDescrOnlyMode(), and ilUtil\sendInfo().

Referenced by deleteTranslations(), and saveTranslations().

{
global $ilToolbar;
$this->lng->loadLanguageModule(ilObject::_lookupType($this->obj->getId()));
if ($this->getTitleDescrOnlyMode() || $this->obj_trans->getContentActivated())
{
$ilToolbar->addButton($this->lng->txt("obj_add_languages"),
$this->ctrl->getLinkTarget($this, "addLanguages"));
}
if ($this->getTitleDescrOnlyMode())
{
if (!$this->obj_trans->getContentActivated())
{
ilUtil::sendInfo($this->lng->txt("obj_multilang_title_descr_only"));
$ilToolbar->addButton($this->lng->txt("obj_activate_content_lang"),
$this->ctrl->getLinkTarget($this, "activateContentMultilinguality"));
}
else
{
$ilToolbar->addButton($this->lng->txt("obj_deactivate_content_lang"),
$this->ctrl->getLinkTarget($this, "confirmDeactivateContentMultiLang"));
}
}
else
{
if ($this->obj_trans->getContentActivated())
{
$ilToolbar->addButton($this->lng->txt("obj_deactivate_multilang"),
$this->ctrl->getLinkTarget($this, "confirmDeactivateContentMultiLang"));
}
else
{
$ilToolbar->addButton($this->lng->txt("obj_activate_multilang"),
$this->ctrl->getLinkTarget($this, "activateContentMultilinguality"));
return;
}
}
include_once("./Services/Object/classes/class.ilObjectTranslation2TableGUI.php");
$table = new ilObjectTranslation2TableGUI($this, "listTranslations", true,
"Translation", $this->obj_trans->getMasterLanguage());
if ($a_get_post_values)
{
$vals = array();
foreach($_POST["title"] as $k => $v)
{
$vals[] = array("title" => $v,
"desc" => $_POST["desc"][$k],
"lang" => $_POST["lang"][$k],
"default" => ($_POST["default"] == $k));
}
$table->setData($vals);
}
else
{
$data = $this->obj_trans->getLanguages();
foreach($data as $k => $v)
{
$data[$k]["default"] = $v["lang_default"];
$data[$k]["desc"] = $v["description"];
$data[$k]["lang"] = $v["lang_code"];
}
/* if($a_add)
{
$data["Fobject"][++$k]["title"] = "";
}*/
$table->setData($data);
}
$this->tpl->setContent($table->getHTML());
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjectTranslationGUI::removeLanguages ( )

Remove languages.

Definition at line 497 of file class.ilObjectTranslationGUI.php.

References $_POST, $ilCtrl, $lng, and ilUtil\sendInfo().

{
global $lng, $ilCtrl;
if (is_array($_POST["lang"]))
{
$langs = $this->obj_trans->getLanguages();
foreach ($langs as $k => $l)
{
if (in_array($l, $_POST["lang"]))
{
$this->obj_trans->removeLanguage();
}
}
$this->obj_trans->save();
ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
}
$ilCtrl->redirect($this, "listTranslations");
}

+ Here is the call graph for this function:

ilObjectTranslationGUI::saveContentTranslationActivation ( )

Save content translation activation.

Definition at line 322 of file class.ilObjectTranslationGUI.php.

References $ilCtrl, and getMultiLangForm().

{
global $ilCtrl;
// include_once("./Services/COPage/classes/class.ilPageMultiLang.php");
$form = $this->getMultiLangForm();
if ($form->checkInput())
{
$ml = $form->getInput("master_lang");
$this->obj_trans->setMasterLanguage($ml);
$this->obj_trans->addLanguage($ml,
$this->obj->getTitle(),
$this->obj->getDescription(),
true
);
$this->obj_trans->setDefaultTitle($this->obj->getTitle());
$this->obj_trans->setDefaultDescription($this->obj->getDescription());
$this->obj_trans->save();
}
$ilCtrl->redirect($this, "listTranslations");
}

+ Here is the call graph for this function:

ilObjectTranslationGUI::saveLanguages ( )

Save languages.

Definition at line 437 of file class.ilObjectTranslationGUI.php.

References $ilCtrl, $lng, getMultiLangForm(), and ilUtil\sendInfo().

{
global $ilCtrl, $lng;
$form = $this->getMultiLangForm();
if ($form->checkInput())
{
$ad = $form->getInput("additional_langs");
if (is_array($ad))
{
$ml = $this->obj_trans->getMasterLanguage();
foreach ($ad as $l)
{
if ($l != $ml && $l != "")
{
$this->obj_trans->addLanguage($l, false, "", "");
}
}
}
}
$this->obj_trans->save();
ilUtil::sendInfo($lng->txt("msg_obj_modified"), true);
$ilCtrl->redirect($this, "listTranslations");
}

+ Here is the call graph for this function:

ilObjectTranslationGUI::saveTranslations ( )

Save translations.

Definition at line 159 of file class.ilObjectTranslationGUI.php.

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

Referenced by deleteTranslations().

{
// default language set?
if (!isset($_POST["default"]) && $this->obj_trans->getMasterLanguage() == "")
{
ilUtil::sendFailure($this->lng->txt("msg_no_default_language"));
$this->listTranslations(true);
return;
}
// all languages set?
if (array_key_exists("",$_POST["lang"]))
{
ilUtil::sendFailure($this->lng->txt("msg_no_language_selected"));
$this->listTranslations(true);
return;
}
// no single language is selected more than once?
if (count(array_unique($_POST["lang"])) < count($_POST["lang"]))
{
ilUtil::sendFailure($this->lng->txt("msg_multi_language_selected"));
$this->listTranslations(true);
return;
}
// save the stuff
$this->obj_trans->setLanguages(array());
foreach($_POST["title"] as $k => $v)
{
// update object data if default
$is_default = ($_POST["default"] == $k);
// ensure master language is set as default
if ($this->obj_trans->getMasterLanguage() != "")
{
$is_default = ($this->obj_trans->getMasterLanguage() == $_POST["lang"][$k]);
}
if($is_default)
{
$this->obj->setTitle(ilUtil::stripSlashes($v));
$this->obj->setDescription(ilUtil::stripSlashes($_POST["desc"][$k]));
$this->obj->update();
}
$this->obj_trans->addLanguage(ilUtil::stripSlashes($_POST["lang"][$k]),
$is_default
);
}
$this->obj_trans->save();
ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
$this->ctrl->redirect($this, "listTranslations");
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjectTranslationGUI::setTitleDescrOnlyMode (   $a_val)

Set enable title/description only mode.

Parameters
bool$a_valenable title/description only mode

Definition at line 39 of file class.ilObjectTranslationGUI.php.

{
$this->title_descr_only = $a_val;
}

Field Documentation

ilObjectTranslationGUI::$obj_trans
protected

Definition at line 14 of file class.ilObjectTranslationGUI.php.

ilObjectTranslationGUI::$title_descr_only = true
protected

Definition at line 15 of file class.ilObjectTranslationGUI.php.

Referenced by getTitleDescrOnlyMode().


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