1<?php 2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */ 3 4include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSetting.php'; 5 6/** 7 * Settings for a single didactic template 8 * 9 * @author Stefan Meyer <meyer@leifos.com> 10 * @ingroup ServicesDidacticTemplate 11 * @ilCtrl_IsCalledBy ilDidacticTemplateSettingsGUI: ilObjRoleFolderGUI 12 * @ilCtrl_Calls ilDidacticTemplateSettingsGUI: ilMultilingualismGUI, ilPropertyFormGUI 13 */ 14class ilDidacticTemplateSettingsGUI 15{ 16 private $parent_object; 17 18 /** 19 * @var null|ilDidacticTemplateSetting 20 */ 21 private $object = null; 22 23 private $lng; 24 25 /** 26 * Constructor 27 */ 28 public function __construct($a_parent_obj) 29 { 30 global $DIC; 31 32 $lng = $DIC['lng']; 33 34 $this->parent_object = $a_parent_obj; 35 $this->lng = $lng; 36 37 if (isset($_REQUEST["tplid"])) { 38 $this->initObject($_REQUEST["tplid"]); 39 } 40 } 41 42 /** 43 * @param int $a_id 44 * @return ilDidacticTemplateSetting 45 */ 46 protected function initObject($a_id) 47 { 48 return $this->object = new ilDidacticTemplateSetting($a_id); 49 } 50 51 /** 52 * Execute command 53 * @return <type> 54 */ 55 public function executeCommand() 56 { 57 /** 58 * @var ilAccessHandler $ilAccess 59 */ 60 global $DIC; 61 62 $ilCtrl = $DIC['ilCtrl']; 63 $ilAccess = $DIC['ilAccess']; 64 65 $next_class = $ilCtrl->getNextClass($this); 66 $cmd = $ilCtrl->getCmd(); 67 68 switch ($next_class) { 69 case "ilpropertyformgui": 70 $settings = new ilDidacticTemplateSetting((int) $_REQUEST['tplid']); 71 $form = $this->initEditTemplate($settings); 72 $ilCtrl->forwardCommand($form); 73 // no break 74 case 'ilmultilingualismgui': 75 if (!$ilAccess->checkAccess('write', '', $_REQUEST["ref_id"]) || 76 !isset($this->object) || 77 $this->object->isAutoGenerated()) { 78 $ilCtrl->redirect($this, "overview"); 79 } 80 //$this->tabs_gui->setTabActive('export'); 81 $this->setEditTabs("settings_trans"); 82 include_once("./Services/Multilingualism/classes/class.ilMultilingualismGUI.php"); 83 $transgui = new ilMultilingualismGUI($_REQUEST["tplid"], 'dtpl'); 84 $defaultl = $this->object->getTranslationObject()->getDefaultLanguage(); 85 86 $transgui->setStartValues( 87 $this->object->getPresentationTitle($defaultl), 88 $this->object->getPresentationDescription($defaultl) 89 ); 90 91 $ilCtrl->forwardCommand($transgui); 92 break; 93 default: 94 if (!$cmd) { 95 $cmd = 'overview'; 96 } 97 $this->$cmd(); 98 99 break; 100 } 101 return true; 102 } 103 104 /** 105 * Show didactic template administration 106 * 107 * @global ilToolbarGUI $ilToolbar 108 */ 109 protected function overview() 110 { 111 global $DIC; 112 113 $ilToolbar = $DIC['ilToolbar']; 114 $lng = $DIC['lng']; 115 $ilCtrl = $DIC['ilCtrl']; 116 $ilAccess = $DIC['ilAccess']; 117 118 if ($ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) { 119 $ilToolbar->addButton( 120 $lng->txt('didactic_import_btn'), 121 $ilCtrl->getLinkTarget($this, 'showImportForm') 122 ); 123 } 124 125 126 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettingsTableGUI.php'; 127 $table = new ilDidacticTemplateSettingsTableGUI($this, 'overview'); 128 $table->init(); 129 $table->parse(); 130 131 $GLOBALS['DIC']['tpl']->setContent($table->getHTML()); 132 } 133 134 /** 135 * Show template import form 136 * 137 * @global ilTabsGUI $ilTabs 138 */ 139 protected function showImportForm(ilPropertyFormGUI $form = null) 140 { 141 global $DIC; 142 143 $ilTabs = $DIC['ilTabs']; 144 $ilCtrl = $DIC['ilCtrl']; 145 146 if (isset($_REQUEST["tplid"])) { 147 $this->setEditTabs('import'); 148 } else { 149 $ilTabs->clearTargets(); 150 $ilTabs->setBackTarget( 151 $this->lng->txt('didactic_back_to_overview'), 152 $ilCtrl->getLinkTarget($this, 'overview') 153 ); 154 } 155 156 if (!$form instanceof ilPropertyFormGUI) { 157 $form = $this->createImportForm(); 158 } 159 $GLOBALS['DIC']['tpl']->setContent($form->getHTML()); 160 } 161 162 /** 163 * Create template import form 164 * @return ilPropertyFormGUI $form 165 */ 166 protected function createImportForm() 167 { 168 global $DIC; 169 170 $ilCtrl = $DIC['ilCtrl']; 171 172 include_once './Services/Form/classes/class.ilPropertyFormGUI.php'; 173 $form = new ilPropertyFormGUI(); 174 $form->setShowTopButtons(false); 175 $form->setFormAction($ilCtrl->getFormAction($this)); 176 $form->setTitle($this->lng->txt('didactic_import_table_title')); 177 $form->addCommandButton('importTemplate', $this->lng->txt('import')); 178 $form->addCommandButton('overview', $this->lng->txt('cancel')); 179 180 $file = new ilFileInputGUI($this->lng->txt('import_file'), 'file'); 181 $file->setSuffixes(array('xml')); 182 $file->setRequired(true); 183 $form->addItem($file); 184 185 $created = true; 186 187 return $form; 188 } 189 190 /** 191 * Import template 192 */ 193 protected function importTemplate() 194 { 195 global $DIC; 196 197 $ilCtrl = $DIC['ilCtrl']; 198 $ilAccess = $DIC['ilAccess']; 199 200 if (!$ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) { 201 $ilCtrl->redirect($this, "overview"); 202 } 203 204 $edit = isset($_REQUEST['tplid']); 205 206 if ($edit) { 207 $form = $this->createImportForm(); 208 } else { 209 $form = $this->editImportForm(); 210 } 211 212 213 if (!$form->checkInput()) { 214 ilUtil::sendFailure($this->lng->txt('err_check_input')); 215 $form->setValuesByPost(); 216 217 if ($edit) { 218 $this->showEditImportForm(); 219 } else { 220 $this->showImportForm($form); 221 } 222 } 223 224 // Do import 225 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateImport.php'; 226 227 $import = new ilDidacticTemplateImport(ilDidacticTemplateImport::IMPORT_FILE); 228 229 $file = $form->getInput('file'); 230 $tmp = ilUtil::ilTempnam() . '.xml'; 231 232 // move uploaded file 233 ilUtil::moveUploadedFile( 234 $file['tmp_name'], 235 $file['name'], 236 $tmp 237 ); 238 $import->setInputFile($tmp); 239 240 try { 241 $settings = $import->import(); 242 243 if ($edit) { 244 $this->editImport($settings); 245 } 246 } catch (ilDidacticTemplateImportException $e) { 247 ilLoggerFactory::getLogger('otpl')->error('Import failed with message: ' . $e->getMessage()); 248 ilUtil::sendFailure($this->lng->txt('didactic_import_failed') . ': ' . $e->getMessage()); 249 } 250 251 ilUtil::sendSuccess($this->lng->txt('didactic_import_success'), true); 252 253 if ($edit) { 254 $ilCtrl->redirect($this, 'editTemplate'); 255 } else { 256 $ilCtrl->redirect($this, 'overview'); 257 } 258 } 259 260 /** 261 * Edit template 262 * @return void 263 */ 264 protected function editTemplate(ilPropertyFormGUI $form = null) 265 { 266 global $DIC; 267 268 $ilCtrl = $DIC['ilCtrl']; 269 $ilTabs = $DIC['ilTabs']; 270 271 $this->setEditTabs("edit"); 272 273 if (!$_REQUEST['tplid']) { 274 ilUtil::sendFailure($this->lng->txt('select_one'), true); 275 $ilCtrl->redirect($this, 'overview'); 276 } 277 278 //$ilTabs->clearTargets(); 279 //$ilTabs->setBackTarget( 280 // $this->lng->txt('didactic_back_to_overview'), 281 // $ilCtrl->getLinkTarget($this,'overview') 282 //); 283 284 285 $ilCtrl->saveParameter($this, 'tplid'); 286 287 if (!$form instanceof ilPropertyFormGUI) { 288 $form = $this->initEditTemplate($this->object); 289 } 290 $GLOBALS['DIC']['tpl']->setContent($form->getHTML()); 291 } 292 293 /** 294 * Update template 295 */ 296 protected function updateTemplate() 297 { 298 global $DIC; 299 300 $ilCtrl = $DIC['ilCtrl']; 301 $ilAccess = $DIC['ilAccess']; 302 303 if (!$ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) { 304 $this->ctrl->redirect($this, "overview"); 305 } 306 307 $temp = new ilDidacticTemplateSetting((int) $_REQUEST['tplid']); 308 $form = $this->initEditTemplate($temp); 309 310 if ($form->checkInput()) { 311 //change default entrys if translation is active 312 if (count($lang = $temp->getTranslationObject()->getLanguages())) { 313 $temp->getTranslationObject()->setDefaultTitle($form->getInput('title')); 314 $temp->getTranslationObject()->setDefaultDescription($form->getInput('description')); 315 $temp->getTranslationObject()->save(); 316 } 317 318 if (!$temp->isAutoGenerated()) { 319 $temp->setTitle($form->getInput('title')); 320 $temp->setDescription($form->getInput('description')); 321 } 322 323 $temp->setInfo($form->getInput('info')); 324 $temp->enable($form->getInput('enable')); 325 326 if (!$temp->isAutoGenerated()) { 327 $temp->setAssignments(array($form->getInput('type'))); 328 } 329 330 if ($form->getInput('local_template') && count($form->getInput('effective_from')) > 0) { 331 $temp->setEffectiveFrom($form->getInput('effective_from')); 332 } else { 333 $temp->setEffectiveFrom(array()); 334 } 335 336 $temp->setExclusive((bool) $form->getInput('exclusive_template')); 337 338 $temp->update(); 339 340 ilUtil::sendSuccess($this->lng->txt('settings_saved'), true); 341 $ilCtrl->redirect($this, 'overview'); 342 } 343 344 ilUtil::sendFailure($this->lng->txt('err_check_input')); 345 $form->setValuesByPost(); 346 $this->editTemplate($form); 347 } 348 349 /** 350 * Init edit template form 351 * 352 * @param ilDidacticTemplateSetting $set 353 * @return ilPropertyFormGUI 354 */ 355 protected function initEditTemplate(ilDidacticTemplateSetting $set) 356 { 357 global $DIC; 358 359 $ilCtrl = $DIC['ilCtrl']; 360 $objDefinition = $DIC['objDefinition']; 361 362 include_once './Services/Form/classes/class.ilPropertyFormGUI.php'; 363 $form = new ilPropertyFormGUI(); 364 $form->setShowTopButtons(false); 365 $form->setFormAction($ilCtrl->getFormAction($this, 'updateTemplate')); 366 $form->setTitle($this->lng->txt('didactic_edit_tpl')); 367 $form->addCommandButton('updateTemplate', $this->lng->txt('save')); 368 $form->addCommandButton('overview', $this->lng->txt('cancel')); 369 370 // title 371 $title = new ilTextInputGUI($this->lng->txt('title'), 'title'); 372 $title->setSize(40); 373 $title->setMaxLength(64); 374 $title->setRequired(true); 375 //use presentation title if autogenerated is set 376 $title->setDisabled($set->isAutoGenerated()); 377 378 if (!$set->isAutoGenerated()) { 379 $trans = $set->getTranslations(); 380 $def = $trans[0]; // default 381 382 if (sizeof($trans) > 1) { 383 include_once('Services/MetaData/classes/class.ilMDLanguageItem.php'); 384 $languages = ilMDLanguageItem::_getLanguages(); 385 $title->setInfo($this->lng->txt("language") . ": " . $languages[$def["lang_code"]] . 386 ' <a href="' . $ilCtrl->getLinkTargetByClass("ilmultilingualismgui", "listTranslations") . 387 '">» ' . $this->lng->txt("more_translations") . '</a>'); 388 } 389 } 390 391 if ($set->isAutoGenerated()) { 392 $title->setValue($set->getPresentationTitle()); 393 } else { 394 $title->setValue($def["title"]); 395 } 396 397 $form->addItem($title); 398 399 // desc 400 $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'description'); 401 //use presentation title if autogenerated is set 402 if ($set->isAutoGenerated()) { 403 $desc->setValue($set->getPresentationDescription()); 404 } else { 405 $desc->setValue($def["description"]); 406 } 407 $desc->setRows(3); 408 $desc->setDisabled($set->isAutoGenerated()); 409 $form->addItem($desc); 410 411 // info 412 $info = new ilTextAreaInputGUI($this->lng->txt('didactic_install_info'), 'info'); 413 $info->setValue($set->getInfo()); 414 $info->setRows(6); 415 $form->addItem($info); 416 417 //activate 418 $enable = new ilCheckboxInputGUI($this->lng->txt('active'), 'enable'); 419 $enable->setChecked($set->isEnabled()); 420 $enable->setRequired(true); 421 $form->addItem($enable); 422 423 // object type 424 if (!$set->isAutoGenerated()) { 425 $type = new ilSelectInputGUI($this->lng->txt('obj_type'), 'type'); 426 $type->setRequired(true); 427 $type->setInfo($this->lng->txt('dtpl_obj_type_info')); 428 $assigned = $set->getAssignments(); 429 $type->setValue(isset($assigned[0]) ? $assigned[0] : ''); 430 $subs = $objDefinition->getSubObjectsRecursively('root', false); 431 $options = array(); 432 foreach (array_merge($subs, array('fold' => 1)) as $obj => $null) { 433 ilLoggerFactory::getLogger('root')->dump($null); 434 if ($objDefinition->isPlugin($obj)) { 435 $options[$obj] = ilObjectPlugin::lookupTxtById($obj, "obj_" . $obj); 436 } elseif ($objDefinition->isAllowedInRepository($obj)) { 437 $options[$obj] = $this->lng->txt('obj_' . $obj); 438 } 439 } 440 asort($options); 441 442 $type->setOptions($options); 443 $form->addItem($type); 444 445 $lokal_templates = new ilCheckboxInputGUI($this->lng->txt("activate_local_didactic_template"), "local_template"); 446 $lokal_templates->setChecked(count($set->getEffectiveFrom()) > 0); 447 $lokal_templates->setInfo($this->lng->txt("activate_local_didactic_template_info")); 448 449 //effective from (multinode) 450 include_once("./Services/Form/classes/class.ilRepositorySelector2InputGUI.php"); 451 $effrom = new ilRepositorySelector2InputGUI($this->lng->txt("effective_form"), "effective_from", true); 452 //$effrom->setMulti(true); 453 $definition = $GLOBALS['DIC']['objDefinition']; 454 $white_list = []; 455 foreach ($definition->getAllRepositoryTypes() as $type) { 456 if ($definition->isContainer($type)) { 457 $white_list[] = $type; 458 } 459 } 460 $effrom->getExplorerGUI()->setTypeWhiteList($white_list); 461 $effrom->setValue($set->getEffectiveFrom()); 462 463 $lokal_templates->addSubItem($effrom); 464 $form->addItem($lokal_templates); 465 466 $excl = new ilCheckboxInputGUI($this->lng->txt("activate_exclusive_template"), "exclusive_template"); 467 $excl->setInfo($this->lng->txt("activate_exclusive_template_info")); 468 $excl->setChecked($set->isExclusive()); 469 470 $form->addItem($excl); 471 } 472 473 474 475 return $form; 476 } 477 478 /** 479 * Copy on template 480 */ 481 protected function copyTemplate() 482 { 483 global $DIC; 484 485 $ilErr = $DIC['ilErr']; 486 $ilCtrl = $DIC['ilCtrl']; 487 $ilAccess = $DIC['ilAccess']; 488 489 if (!$ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) { 490 $this->ctrl->redirect($this, "overview"); 491 } 492 493 if (!$_REQUEST['tplid']) { 494 ilUtil::sendFailure($this->lng->txt('select_one')); 495 return $ilCtrl->redirect($this, 'overview'); 496 } 497 498 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateCopier.php'; 499 500 $copier = new ilDidacticTemplateCopier((int) $_REQUEST['tplid']); 501 $copier->start(); 502 503 ilUtil::sendSuccess($this->lng->txt('didactic_copy_suc_message'), true); 504 $ilCtrl->redirect($this, 'overview'); 505 } 506 507 /** 508 * Export one template 509 */ 510 protected function exportTemplate() 511 { 512 global $DIC; 513 514 $ilErr = $DIC['ilErr']; 515 $ilCtrl = $DIC['ilCtrl']; 516 517 if (!$_REQUEST['tplid']) { 518 ilUtil::sendFailure($this->lng->txt('select_one')); 519 return $ilCtrl->redirect($this, 'overview'); 520 } 521 522 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateXmlWriter.php'; 523 $writer = new ilDidacticTemplateXmlWriter((int) $_REQUEST['tplid']); 524 $writer->write(); 525 526 ilUtil::deliverData( 527 $writer->xmlDumpMem(true), 528 $writer->getSetting()->getTitle() . '.xml', 529 'application/xml' 530 ); 531 } 532 533 /** 534 * Show delete confirmation screen 535 * 536 * @global ilCtrl $ilCtrl 537 */ 538 protected function confirmDelete() 539 { 540 /** 541 * @var ilCtrl $ilCtrl 542 */ 543 global $DIC; 544 545 $ilErr = $DIC['ilErr']; 546 $ilCtrl = $DIC['ilCtrl']; 547 548 if (!$_REQUEST['tpls']) { 549 ilUtil::sendFailure($this->lng->txt('select_one')); 550 return $ilCtrl->redirect($this, 'overview'); 551 } 552 553 include_once './Services/Utilities/classes/class.ilConfirmationGUI.php'; 554 555 $confirm = new ilConfirmationGUI(); 556 $confirm->setFormAction($ilCtrl->getFormAction($this)); 557 $confirm->setConfirm($this->lng->txt('delete'), 'deleteTemplates'); 558 $confirm->setCancel($this->lng->txt('cancel'), 'overview'); 559 560 $forbidden = array(); 561 562 foreach ((array) $_REQUEST['tpls'] as $tplid) { 563 $tpl = new ilDidacticTemplateSetting($tplid); 564 565 if (!$tpl->isAutoGenerated()) { 566 $confirm->addItem('tpls[]', $tpl->getId(), $tpl->getPresentationTitle()); 567 } else { 568 $forbidden[] = $tpl->getId(); 569 } 570 } 571 572 if (count($forbidden) > 0 && count($_REQUEST['tpls']) == 1) { 573 ilUtil::sendFailure($this->lng->txt('didactic_cannot_delete_auto_generated'), true); 574 $ilCtrl->redirect($this, "overview"); 575 } elseif (count($forbidden) > 0 && count($_REQUEST['tpls']) > 1) { 576 ilUtil::sendInfo($this->lng->txt('didactic_cannot_delete_auto_generated_confirmation')); 577 } 578 579 ilUtil::sendQuestion($this->lng->txt('didactic_confirm_delete_msg')); 580 $GLOBALS['DIC']['tpl']->setContent($confirm->getHTML()); 581 } 582 583 /** 584 * Delete chosen didactic templates 585 * @global ilErrorHandling $ilErr 586 * @global ilCtrl $ilCtrl 587 * @return void 588 */ 589 protected function deleteTemplates() 590 { 591 global $DIC; 592 593 $ilErr = $DIC['ilErr']; 594 $ilCtrl = $DIC['ilCtrl']; 595 $ilAccess = $DIC['ilAccess']; 596 597 if (!$ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) { 598 $this->ctrl->redirect($this, "overview"); 599 } 600 601 if (!$_REQUEST['tpls']) { 602 ilUtil::sendFailure($this->lng->txt('select_one')); 603 return $ilCtrl->redirect($this, 'overview'); 604 } 605 606 foreach ((array) $_REQUEST['tpls'] as $tplid) { 607 $tpl = new ilDidacticTemplateSetting($tplid); 608 $tpl->delete(); 609 } 610 611 ilUtil::sendSuccess($this->lng->txt('didactic_delete_msg'), true); 612 $ilCtrl->redirect($this, 'overview'); 613 } 614 615 /** 616 * Activate didactic templates 617 * @global ilErrorHandling $ilErr 618 * @global ilCtrl $ilCtrl 619 * @return void 620 */ 621 protected function activateTemplates() 622 { 623 global $DIC; 624 625 $ilErr = $DIC['ilErr']; 626 $ilCtrl = $DIC['ilCtrl']; 627 $ilAccess = $DIC['ilAccess']; 628 629 if (!$ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) { 630 $this->ctrl->redirect($this, "overview"); 631 } 632 if (!$_REQUEST['tpls']) { 633 ilUtil::sendFailure($this->lng->txt('select_one')); 634 return $ilCtrl->redirect($this, 'overview'); 635 } 636 637 foreach ($_REQUEST['tpls'] as $tplid) { 638 $tpl = new ilDidacticTemplateSetting($tplid); 639 $tpl->enable(true); 640 $tpl->update(); 641 } 642 643 ilUtil::sendSuccess($this->lng->txt('didactic_activated_msg'), true); 644 $ilCtrl->redirect($this, 'overview'); 645 } 646 647 /** 648 * Activate didactic templates 649 * @global ilErrorHandling $ilErr 650 * @global ilCtrl $ilCtrl 651 * @return void 652 */ 653 protected function deactivateTemplates() 654 { 655 global $DIC; 656 657 $ilErr = $DIC['ilErr']; 658 $ilCtrl = $DIC['ilCtrl']; 659 $ilAccess = $DIC['ilAccess']; 660 661 if (!$ilAccess->checkAccess('write', '', $_REQUEST["ref_id"])) { 662 $this->ctrl->redirect($this, "overview"); 663 } 664 665 if (!$_REQUEST['tpls']) { 666 ilUtil::sendFailure($this->lng->txt('select_one')); 667 $ilCtrl->redirect($this, 'overview'); 668 } 669 670 foreach ($_REQUEST['tpls'] as $tplid) { 671 $tpl = new ilDidacticTemplateSetting($tplid); 672 $tpl->enable(false); 673 $tpl->update(); 674 } 675 676 ilUtil::sendSuccess($this->lng->txt('didactic_deactivated_msg'), true); 677 $ilCtrl->redirect($this, 'overview'); 678 } 679 680 /** 681 * @param string $a_tab_active 682 */ 683 protected function setEditTabs($a_tab_active = "edit") 684 { 685 /** 686 * @var ilTabsGUI $ilTabs 687 * @var ilCtrl $ilCtrl 688 */ 689 global $DIC; 690 691 $ilCtrl = $DIC['ilCtrl']; 692 $ilTabs = $DIC['ilTabs']; 693 694 695 $ilTabs->clearTargets(); 696 $ilTabs->setBackTarget( 697 $this->lng->txt('didactic_back_to_overview'), 698 $ilCtrl->getLinkTarget($this, 'overview') 699 ); 700 $ilCtrl->saveParameter($this, "tplid"); 701 702 if (!$this->object->isAutoGenerated()) { 703 $ilTabs->addTab('edit', $this->lng->txt('settings'), $ilCtrl->getLinkTarget($this, 'editTemplate')); 704 $ilTabs->addTab('import', $this->lng->txt('import'), $ilCtrl->getLinkTarget($this, 'showEditImportForm')); 705 706 if (in_array($a_tab_active, array('edit', 'settings_trans'))) { 707 $ilTabs->addSubTab('edit', $this->lng->txt('settings'), $ilCtrl->getLinkTarget($this, 'editTemplate')); 708 $ilTabs->addSubTab('settings_trans', $this->lng->txt("obj_multilinguality"), $ilCtrl->getLinkTargetByClass(array( "ilmultilingualismgui"), 'listTranslations')); 709 $ilTabs->setTabActive('edit'); 710 $ilTabs->setSubTabActive($a_tab_active); 711 } else { 712 $ilTabs->setTabActive($a_tab_active); 713 } 714 } 715 } 716 717 public function showEditImportForm() 718 { 719 $this->setEditTabs("import"); 720 721 $form = $this->editImportForm(); 722 723 $GLOBALS['DIC']['tpl']->setContent($form->getHTML()); 724 } 725 726 public function editImportForm() 727 { 728 global $DIC; 729 730 $ilCtrl = $DIC['ilCtrl']; 731 732 include_once './Services/Form/classes/class.ilPropertyFormGUI.php'; 733 $form = new ilPropertyFormGUI(); 734 $form->setShowTopButtons(false); 735 $form->setFormAction($ilCtrl->getFormAction($this)); 736 $form->setTitle($this->lng->txt('didactic_import_table_title')); 737 $form->addCommandButton('importTemplate', $this->lng->txt('import')); 738 $form->addCommandButton('overview', $this->lng->txt('cancel')); 739 740 $file = new ilFileInputGUI($this->lng->txt('didactic_template_update_import'), 'file'); 741 $file->setSuffixes(array('xml')); 742 $file->setInfo($this->lng->txt('didactic_template_update_import_info')); 743 $form->addItem($file); 744 745 return $form; 746 } 747 748 /** 749 * @global ilCtrl $ilCtrl 750 * @param ilDidacticTemplateSetting $a_settings 751 */ 752 public function editImport($a_settings) 753 { 754 global $DIC; 755 756 $ilCtrl = $DIC['ilCtrl']; 757 $tplid = $_REQUEST['tplid']; 758 759 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php'; 760 ilDidacticTemplateObjSettings::transferAutoGenerateStatus($tplid, $a_settings->getId()); 761 762 $assignments = ilDidacticTemplateObjSettings::getAssignmentsByTemplateID($tplid); 763 764 $this->object->delete(); 765 766 foreach ($assignments as $obj) { 767 ilDidacticTemplateObjSettings::assignTemplate($obj["ref_id"], $obj["obj_id"], $a_settings->getId()); 768 } 769 770 $ilCtrl->setParameter($this, "tplid", $a_settings->getId()); 771 } 772} 773