Class ilUnitConfigurationGUI .
More...
◆ addCategory()
ilUnitConfigurationGUI::addCategory |
( |
| ) |
|
|
protected |
Definition at line 749 of file class.ilUnitConfigurationGUI.php.
References getDefaultCommand(), getUnitCategoryOverviewCommand(), initUnitCategoryForm(), isCRUDContext(), ilUtil\sendFailure(), and ilUtil\sendSuccess().
757 if ($this->unit_cat_form->checkInput()) {
760 $category->setCategory($this->unit_cat_form->getInput(
'category_name'));
761 $this->repository->saveNewUnitCategory($category);
767 $this->unit_cat_form->getItemByPostVar(
'category_name')->setAlert($this->lng->txt($e->getMessage()));
772 $this->unit_cat_form->setValuesByPost();
774 $this->tpl->setContent($this->unit_cat_form->getHtml());
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
getUnitCategoryOverviewCommand()
initUnitCategoryForm(assFormulaQuestionUnitCategory $cat=null)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
◆ addUnit()
ilUnitConfigurationGUI::addUnit |
( |
| ) |
|
|
protected |
Adds a new unit.
Definition at line 368 of file class.ilUnitConfigurationGUI.php.
References $_GET, getCategoryById(), isCRUDContext(), and ilUtil\sendSuccess().
371 $this->showUnitsOfCategory();
377 $this->initUnitForm($category);
378 if ($this->unit_form->checkInput()) {
380 $unit->setUnit($this->unit_form->getInput(
'unit_title'));
381 $unit->setCategory($category->getId());
383 $this->repository->createNewUnit($unit);
385 $unit->setBaseUnit((
int) $this->unit_form->getInput(
'base_unit'));
386 $unit->setFactor((
float) $this->unit_form->getInput(
'factor'));
388 $this->repository->saveUnit($unit);
391 $this->showUnitsOfCategory();
395 $this->unit_form->setValuesByPost();
397 $this->tpl->setContent($this->unit_form->getHtml());
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
getCategoryById($id, $for_CRUD=true)
◆ checkPermissions()
ilUnitConfigurationGUI::checkPermissions |
( |
|
$cmd | ) |
|
|
protected |
◆ confirmDeleteCategories()
ilUnitConfigurationGUI::confirmDeleteCategories |
( |
| ) |
|
|
protected |
Definition at line 585 of file class.ilUnitConfigurationGUI.php.
References $_POST, $errors, $message, array, getDefaultCommand(), getUnitCategoryOverviewCommand(), isCRUDContext(), and ilUtil\sendFailure().
Referenced by confirmDeleteCategory().
592 if (!isset(
$_POST[
'category_ids']) || !is_array(
$_POST[
'category_ids'])) {
597 require_once
'Services/Utilities/classes/class.ilConfirmationGUI.php';
599 $confirmation->setFormAction($this->ctrl->getFormAction($this,
'deleteCategories'));
600 $confirmation->setConfirm($this->lng->txt(
'confirm'),
'deleteCategories');
605 foreach (
$_POST[
'category_ids'] as $category_id) {
607 $category = $this->repository->getUnitCategoryById((
int) $category_id);
612 if (!$this->repository->isCRUDAllowed((
int) $category_id)) {
613 $errors[] = $category->getDisplayString() .
' - ' . $this->lng->txt(
'change_adm_categories_not_allowed');
617 $possible_error = $this->repository->checkDeleteCategory($category_id);
618 if (strlen($possible_error)) {
619 $errors[] = $category->getDisplayString() .
' - ' . $possible_error;
623 $confirmation->addItem(
'category_ids[]', $category->getId(), $category->getDisplayString());
630 $error_message = array_map(
function (
$message) {
633 if ($num_errors == 1) {
634 ilUtil::sendFailure($this->lng->txt(
'un_cat_deletion_errors_f_s') .
'<ul>' . implode(
'', $error_message) .
'<ul>');
636 ilUtil::sendFailure($this->lng->txt(
'un_cat_deletion_errors_f') .
'<ul>' . implode(
'', $error_message) .
'<ul>');
640 if ($num_to_confirm) {
641 if ($num_to_confirm == 1) {
642 $confirmation->setHeaderText($this->lng->txt(
'un_sure_delete_categories_s'));
644 $confirmation->setHeaderText($this->lng->txt(
'un_sure_delete_categories'));
647 $this->tpl->setContent($confirmation->getHTML());
getUnitCategoryOverviewCommand()
catch(Exception $e) $message
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Confirmation screen class.
◆ confirmDeleteCategory()
ilUnitConfigurationGUI::confirmDeleteCategory |
( |
| ) |
|
|
protected |
◆ confirmDeleteUnit()
ilUnitConfigurationGUI::confirmDeleteUnit |
( |
| ) |
|
|
protected |
◆ confirmDeleteUnits()
ilUnitConfigurationGUI::confirmDeleteUnits |
( |
| ) |
|
|
protected |
Definition at line 156 of file class.ilUnitConfigurationGUI.php.
References $_POST, $errors, $message, array, isCRUDContext(), and ilUtil\sendFailure().
Referenced by confirmDeleteUnit().
159 $this->showUnitsOfCategory();
163 if (!isset(
$_POST[
'unit_ids']) || !is_array(
$_POST[
'unit_ids'])) {
164 $this->showUnitsOfCategory();
168 require_once
'Services/Utilities/classes/class.ilConfirmationGUI.php';
170 $confirmation->setFormAction($this->ctrl->getFormAction($this,
'deleteUnits'));
171 $confirmation->setConfirm($this->lng->txt(
'confirm'),
'deleteUnits');
172 $confirmation->setCancel($this->lng->txt(
'cancel'),
'showUnitsOfCategory');
176 foreach (
$_POST[
'unit_ids'] as $unit_id) {
178 $unit = $this->repository->getUnit((
int) $unit_id);
183 if ($check_result = $this->repository->checkDeleteUnit($unit->getId())) {
184 $errors[] = $unit->getDisplayString() .
' - ' . $check_result;
188 $confirmation->addItem(
'unit_ids[]', $unit->getId(), $unit->getDisplayString());
198 $error_message = array_map(
function (
$message) {
201 if ($num_errors == 1) {
202 ilUtil::sendFailure($this->lng->txt(
'un_unit_deletion_errors_f_s') .
'<ul>' . implode(
'', $error_message) .
'<ul>');
204 ilUtil::sendFailure($this->lng->txt(
'un_unit_deletion_errors_f') .
'<ul>' . implode(
'', $error_message) .
'<ul>');
208 if ($num_to_confirm) {
209 if ($num_to_confirm == 1) {
210 $confirmation->setHeaderText($this->lng->txt(
'un_sure_delete_units_s'));
212 $confirmation->setHeaderText($this->lng->txt(
'un_sure_delete_units'));
215 $this->tpl->setContent($confirmation->getHTML());
217 $this->showUnitsOfCategory();
catch(Exception $e) $message
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Confirmation screen class.
◆ deleteCategories()
ilUnitConfigurationGUI::deleteCategories |
( |
| ) |
|
|
protected |
Definition at line 656 of file class.ilUnitConfigurationGUI.php.
References $_POST, $errors, $message, array, getDefaultCommand(), getUnitCategoryOverviewCommand(), isCRUDContext(), ilUtil\sendFailure(), and ilUtil\sendSuccess().
663 if (!is_array(
$_POST[
'category_ids']) || !
$_POST[
'category_ids']) {
670 foreach (
$_POST[
'category_ids'] as $category_id) {
672 $category = $this->repository->getUnitCategoryById((
int) $category_id);
677 if (!$this->repository->isCRUDAllowed((
int) $category_id)) {
678 $errors[] = $category->getDisplayString() .
' - ' . $this->lng->txt(
'change_adm_categories_not_allowed');
682 $possible_error = $this->repository->deleteCategory($category_id);
683 if (strlen($possible_error)) {
684 $errors[] = $category->getDisplayString() .
' - ' . $possible_error;
694 $error_message = array_map(
function (
$message) {
697 if ($num_errors == 1) {
698 ilUtil::sendFailure($this->lng->txt(
'un_cat_deletion_errors_p_s') .
'<ul>' . implode(
'', $error_message) .
'<ul>');
700 ilUtil::sendFailure($this->lng->txt(
'un_cat_deletion_errors_p') .
'<ul>' . implode(
'', $error_message) .
'<ul>');
705 if ($num_deleted == 1) {
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
getUnitCategoryOverviewCommand()
catch(Exception $e) $message
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
◆ deleteUnits()
ilUnitConfigurationGUI::deleteUnits |
( |
| ) |
|
Definition at line 224 of file class.ilUnitConfigurationGUI.php.
References $_POST, $errors, $message, array, isCRUDContext(), ilUtil\sendFailure(), and ilUtil\sendSuccess().
227 $this->showUnitsOfCategory();
231 if (!is_array(
$_POST[
'unit_ids']) || !
$_POST[
'unit_ids']) {
232 $this->showUnitsOfCategory();
238 foreach (
$_POST[
'unit_ids'] as $unit_id) {
240 $unit = $this->repository->getUnit((
int) $unit_id);
245 $check_result = $this->repository->deleteUnit($unit->getId());
246 if (!is_null($check_result)) {
247 $errors[] = $unit->getDisplayString() .
' - ' . $check_result;
260 $error_message = array_map(
function (
$message) {
263 if ($num_errors == 1) {
264 ilUtil::sendFailure($this->lng->txt(
'un_unit_deletion_errors_p_s') .
'<ul>' . implode(
'', $error_message) .
'<ul>');
266 ilUtil::sendFailure($this->lng->txt(
'un_unit_deletion_errors_p') .
'<ul>' . implode(
'', $error_message) .
'<ul>');
271 if ($num_deleted == 1) {
278 $this->showUnitsOfCategory();
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
catch(Exception $e) $message
Create styles array
The data for the language used.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
◆ executeCommand()
ilUnitConfigurationGUI::executeCommand |
( |
| ) |
|
◆ getCategoryById()
ilUnitConfigurationGUI::getCategoryById |
( |
|
$id, |
|
|
|
$for_CRUD = true |
|
) |
| |
|
protected |
◆ getDefaultCommand()
ilUnitConfigurationGUI::getDefaultCommand |
( |
| ) |
|
|
abstractprotected |
◆ getUniqueId()
ilUnitConfigurationGUI::getUniqueId |
( |
| ) |
|
|
abstract |
◆ getUnitCategoryOverviewCommand()
ilUnitConfigurationGUI::getUnitCategoryOverviewCommand |
( |
| ) |
|
|
abstract |
◆ handleSubtabs()
ilUnitConfigurationGUI::handleSubtabs |
( |
| ) |
|
|
protected |
◆ initUnitCategoryForm()
- Parameters
-
- Returns
- ilPropertyFormGUI
Definition at line 719 of file class.ilUnitConfigurationGUI.php.
References $title, $unit_cat_form, and getUnitCategoryOverviewCommand().
Referenced by addCategory(), saveCategory(), showUnitCategoryCreationForm(), and showUnitCategoryModificationForm().
725 $this->unit_cat_form =
new ilPropertyFormGUI();
728 $title->setRequired(
true);
729 $this->unit_cat_form->addItem(
$title);
732 $this->unit_cat_form->setTitle($this->lng->txt(
'new_category'));
733 $this->unit_cat_form->setFormAction($this->ctrl->getFormAction($this,
'addCategory'));
734 $this->unit_cat_form->addCommandButton(
'addCategory', $this->lng->txt(
'save'));
736 $this->ctrl->setParameter($this,
'category_id', $cat->
getId());
737 $this->unit_cat_form->addCommandButton(
'saveCategory', $this->lng->txt(
'save'));
738 $this->unit_cat_form->setFormAction($this->ctrl->getFormAction($this,
'saveCategory'));
739 $this->unit_cat_form->setTitle(sprintf($this->lng->txt(
'selected_category'), $cat->getDisplayString()));
getUnitCategoryOverviewCommand()
This class represents a text property in a property form.
◆ isCRUDContext()
ilUnitConfigurationGUI::isCRUDContext |
( |
| ) |
|
|
abstract |
- Returns
- boolean
Referenced by addCategory(), addUnit(), confirmDeleteCategories(), confirmDeleteUnits(), deleteCategories(), deleteUnits(), saveCategory(), saveOrder(), saveUnit(), showUnitCategoryCreationForm(), showUnitCategoryModificationForm(), showUnitCreationForm(), and showUnitModificationForm().
◆ saveCategory()
ilUnitConfigurationGUI::saveCategory |
( |
| ) |
|
|
protected |
Definition at line 795 of file class.ilUnitConfigurationGUI.php.
References $_GET, getCategoryById(), getDefaultCommand(), getUnitCategoryOverviewCommand(), initUnitCategoryForm(), isCRUDContext(), ilUtil\sendFailure(), and ilUtil\sendSuccess().
805 if ($this->unit_cat_form->checkInput()) {
807 $category->setCategory($this->unit_cat_form->getInput(
'category_name'));
808 $this->repository->saveCategory($category);
814 $this->unit_cat_form->getItemByPostVar(
'category_name')->setAlert($this->lng->txt($e->getMessage()));
819 $this->unit_cat_form->setValuesByPost();
821 $this->tpl->setContent($this->unit_cat_form->getHtml());
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
getCategoryById($id, $for_CRUD=true)
getUnitCategoryOverviewCommand()
initUnitCategoryForm(assFormulaQuestionUnitCategory $cat=null)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
◆ saveOrder()
ilUnitConfigurationGUI::saveOrder |
( |
| ) |
|
|
protected |
Definition at line 284 of file class.ilUnitConfigurationGUI.php.
References $_POST, $id, isCRUDContext(), and ilUtil\sendSuccess().
287 $this->showUnitsOfCategory();
291 if (!isset(
$_POST[
'sequence']) || !is_array(
$_POST[
'sequence'])) {
292 $this->showUnitsOfCategory();
296 foreach (
$_POST[
'sequence'] as
$id => $sequence) {
297 $sorting_value = str_replace(
',',
'.', $sequence);
298 $sorting_value = (int) $sorting_value * 100;
299 $this->repository->saveUnitOrder((
int)
$id, $sorting_value);
303 $this->showUnitsOfCategory();
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
if(!array_key_exists('StateId', $_REQUEST)) $id
◆ saveUnit()
ilUnitConfigurationGUI::saveUnit |
( |
| ) |
|
|
protected |
Save a unit.
Definition at line 310 of file class.ilUnitConfigurationGUI.php.
References $_GET, getCategoryById(), isCRUDContext(), ilUtil\sendSuccess(), and showUnitModificationForm().
313 $this->showUnitsOfCategory();
318 $unit = $this->repository->getUnit((
int)
$_GET[
'unit_id']);
320 if ($this->repository->isUnitInUse($unit->getId())) {
325 $this->initUnitForm($category, $unit);
326 if ($this->unit_form->checkInput()) {
327 $unit->setUnit($this->unit_form->getInput(
'unit_title'));
328 $unit->setFactor((
float) $this->unit_form->getInput(
'factor'));
329 $unit->setBaseUnit((
int) $this->unit_form->getInput(
'base_unit') != $unit->getId() ? (int) $this->unit_form->getInput(
'base_unit') : 0);
330 $unit->setCategory($category->getId());
331 $this->repository->saveUnit($unit);
333 $this->showUnitsOfCategory();
336 $this->unit_form->setValuesByPost();
339 $this->tpl->setContent($this->unit_form->getHtml());
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
getCategoryById($id, $for_CRUD=true)
showUnitModificationForm()
◆ showUnitCategories()
ilUnitConfigurationGUI::showUnitCategories |
( |
array |
$categories | ) |
|
|
abstractprotected |
◆ showUnitCategoryCreationForm()
ilUnitConfigurationGUI::showUnitCategoryCreationForm |
( |
| ) |
|
|
protected |
◆ showUnitCategoryModificationForm()
ilUnitConfigurationGUI::showUnitCategoryModificationForm |
( |
| ) |
|
|
protected |
◆ showUnitCreationForm()
ilUnitConfigurationGUI::showUnitCreationForm |
( |
| ) |
|
|
protected |
Definition at line 403 of file class.ilUnitConfigurationGUI.php.
References $_GET, $data, $options, $table, $title, $unit_form, array, getCategoryById(), assFormulaQuestionUnit\getId(), getUnitCategoryOverviewCommand(), isCRUDContext(), ilFormPropertyGUI\setRequired(), and showUnitCategories().
406 $this->showUnitsOfCategory();
412 $this->initUnitForm($category);
413 $this->unit_form->setValuesByArray(
array(
415 'unit_title' => $this->lng->txt(
'unit_placeholder')
418 $this->tpl->setContent($this->unit_form->getHtml());
getCategoryById($id, $for_CRUD=true)
Create styles array
The data for the language used.
◆ showUnitModificationForm()
ilUnitConfigurationGUI::showUnitModificationForm |
( |
| ) |
|
|
protected |
Definition at line 345 of file class.ilUnitConfigurationGUI.php.
References $_GET, array, getCategoryById(), and isCRUDContext().
Referenced by saveUnit().
348 $this->showUnitsOfCategory();
353 $unit = $this->repository->getUnit((
int)
$_GET[
'unit_id']);
355 $this->initUnitForm($category, $unit);
356 $this->unit_form->setValuesByArray(
array(
357 'factor' => $unit->getFactor(),
358 'unit_title' => $unit->getUnit(),
359 'base_unit' => ($unit->getBaseUnit() != $unit->getId() ? $unit->getBaseUnit() : 0)
362 $this->tpl->setContent($this->unit_form->getHtml());
getCategoryById($id, $for_CRUD=true)
Create styles array
The data for the language used.
◆ $ctrl
ilUnitConfigurationGUI::$ctrl |
|
protected |
◆ $lng
ilUnitConfigurationGUI::$lng |
|
protected |
◆ $repository
ilUnitConfigurationGUI::$repository = null |
|
protected |
◆ $tpl
ilUnitConfigurationGUI::$tpl |
|
protected |
◆ $unit_cat_form
ilUnitConfigurationGUI::$unit_cat_form |
|
protected |
◆ $unit_form
ilUnitConfigurationGUI::$unit_form |
|
protected |
The documentation for this class was generated from the following file: