/** * Show didactic template types * @param ilPropertyFormGUI $form * @return ilPropertyFormGUI $form */ protected function initDidacticTemplate(ilPropertyFormGUI $form) { global $lng; $lng->loadLanguageModule('didactic'); $options = array(); $options['dtpl_0'] = array($this->lng->txt('didactic_default_type'), sprintf($this->lng->txt('didactic_default_type_info'), $this->lng->txt('objs_' . $this->type))); include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettings.php'; $templates = ilDidacticTemplateSettings::getInstanceByObjectType($this->type)->getTemplates(); if ($templates) { foreach ($templates as $template) { $options["dtpl_" . $template->getId()] = array($template->getTitle(), $template->getDescription()); } } $this->addDidacticTemplateOptions($options); if (sizeof($options) > 1) { $type = new ilRadioGroupInputGUI($this->lng->txt('type'), 'didactic_type'); // workaround for containers in edit mode if (!$this->getCreationMode()) { include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php'; $type->setValue('dtpl_' . ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId())); } else { $type->setValue('dtpl_0'); } $form->addItem($type); ilUtil::sortArray($options, 0); foreach ($options as $id => $data) { $option = new ilRadioOption($data[0], $id, $data[1]); $type->addOption($option); } } return $form; }
/** * Apply template * @param int $a_tpl_id */ public function applyDidacticTemplate($a_tpl_id) { if (!$a_tpl_id) { return true; } include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php'; ilDidacticTemplateObjSettings::assignTemplate($this->getRefId(), $this->getId(), (int) $a_tpl_id); include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateActionFactory.php'; foreach (ilDidacticTemplateActionFactory::getActionsByTemplateId($a_tpl_id) as $action) { $action->setRefId($this->getRefId()); $action->apply(); } }
/** * Switch Template */ protected function switchTemplate() { global $ilCtrl; $new_tpl_id = (int) $_REQUEST['tplid']; include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php'; $current_tpl_id = ilDidacticTemplateObjSettings::lookupTemplateId($this->getParentObject()->object->getRefId()); // Revert current template if ($current_tpl_id) { include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateActionFactory.php'; foreach (ilDidacticTemplateActionFactory::getActionsByTemplateId($current_tpl_id) as $action) { $action->setRefId($this->getParentObject()->object->getRefId()); $action->revert(); } } if ($new_tpl_id) { include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateActionFactory.php'; foreach (ilDidacticTemplateActionFactory::getActionsByTemplateId($new_tpl_id) as $action) { $action->setRefId($this->getParentObject()->object->getRefId()); $action->apply(); } } // Assign template id to object ilDidacticTemplateObjSettings::assignTemplate($this->getParentObject()->object->getRefId(), $this->getParentObject()->object->getId(), $new_tpl_id); ilUtil::sendSuccess($this->lng->txt('didactic_template_applied'), true); $ilCtrl->returnToParent($this); }
/** * check if course is of type main course * @param int ref_id * @return boolean */ protected function isMainCourse($a_course_ref_id) { if (!ilFhoevEventSettings::getInstance()->isActive()) { ilLoggerFactory::getLogger('fhoevevent')->debug('Plugin deactivated'); } $dtpl = ilFhoevEventSettings::getInstance()->getTemplateId(); if (!$dtpl) { ilLoggerFactory::getLogger('fhoevevent')->debug('no templated id given'); } include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php'; $current_dtpl_id = ilDidacticTemplateObjSettings::lookupTemplateId($a_course_ref_id); ilLoggerFactory::getLogger('fhoevevent')->debug('Current dtpl id is: ' . $current_dtpl_id); ilLoggerFactory::getLogger('fhoevevent')->debug('Current dtpl is: ' . $dtpl); ilLoggerFactory::getLogger('fhoevevent')->debug('Current ref_id is: ' . $a_course_ref_id); if ($current_dtpl_id != $dtpl) { ilLoggerFactory::getLogger('fhoevevent')->debug('Not main course'); return FALSE; } ilLoggerFactory::getLogger('fhoevevent')->debug('... is main course'); return TRUE; }
/** * */ protected function afterUpdate() { // check if template is changed include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php'; $current_tpl_id = (int) ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId()); $new_tpl_id = (int) $this->getDidacticTemplateVar('dtpl'); if ($new_tpl_id != $current_tpl_id) { $_REQUEST['tplid'] = $new_tpl_id; // redirect to didactic template confirmation include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateGUI.php'; $this->ctrl->setReturn($this, 'edit'); $this->ctrl->setCmdClass('ildidactictemplategui'); $this->ctrl->setCmd('confirmTemplateSwitch'); $dtpl_gui = new ilDidacticTemplateGUI($this); return $this->ctrl->forwardCommand($dtpl_gui); } parent::afterUpdate(); }
/** * Clone object dependencies * * This method allows to refresh any ref id references to other objects * that are affected in the same copy process. Ask ilCopyWizardOptions for * the mappings. * * @access public * @param int ref_id of target object * @param int copy_id * */ public function cloneDependencies($a_target_id, $a_copy_id) { include_once './Services/AccessControl/classes/class.ilConditionHandler.php'; include_once './Services/CopyWizard/classes/class.ilCopyWizardOptions.php'; $cwo = ilCopyWizardOptions::_getInstance($a_copy_id); $mappings = $cwo->getMappings(); $conditions = ilConditionHandler::_getConditionsOfTarget($this->getRefId(), $this->getId()); foreach ($conditions as $con) { if ($mappings[$con['trigger_ref_id']]) { $newCondition = new ilConditionHandler(); $target_obj = ilObject::_lookupObjId($a_target_id); $target_typ = ilObject::_lookupType($target_obj); $newCondition->setTargetRefId($a_target_id); $newCondition->setTargetObjId($target_obj); $newCondition->setTargetType($target_typ); $trigger_ref = $mappings[$con['trigger_ref_id']]; $trigger_obj = ilObject::_lookupObjId($trigger_ref); $trigger_typ = ilObject::_lookupType($trigger_obj); $newCondition->setTriggerRefId($trigger_ref); $newCondition->setTriggerObjId($trigger_obj); $newCondition->setTriggerType($trigger_typ); $newCondition->setOperator($con['operator']); $newCondition->setValue($con['value']); $newCondition->setReferenceHandlingType($con['ref_handling']); $newCondition->setObligatory($con['obligatory']); $newCondition->setHiddenStatus(ilConditionHandler::lookupHiddenStatusByTarget($this->getRefId())); $newCondition->storeCondition(); } } include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php'; $tpl_id = ilDidacticTemplateObjSettings::lookupTemplateId($this->getRefId()); if ($tpl_id) { include_once './Services/Object/classes/class.ilObjectFactory.php'; $factory = new ilObjectFactory(); $obj = $factory->getInstanceByRefId($a_target_id, FALSE); if ($obj instanceof ilObject) { $obj->applyDidacticTemplate($tpl_id); } } return true; }