function maintainExecuteObject() { 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 // 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 // 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) // 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) // 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) // 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"); }
/** * Process the language maintenance */ function maintainObject() { 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 // 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 // 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) // 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) // 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) // 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(); }