/** * Show create/edit single link * @param int form mode * @return */ protected function initFormLink($a_mode) { global $ilTabs; $ilTabs->activateTab("id_content"); include_once './Services/Form/classes/class.ilPropertyFormGUI.php'; $this->form = new ilPropertyFormGUI(); switch ($a_mode) { case self::LINK_MOD_CREATE: // Header $this->ctrl->setParameter($this, 'new_type', 'webr'); $this->form->setTitle($this->lng->txt('webr_new_link')); $this->form->setTableWidth('600px'); // Buttons $this->form->addCommandButton('save', $this->lng->txt('webr_add')); $this->form->addCommandButton('cancel', $this->lng->txt('cancel')); break; case self::LINK_MOD_ADD: // Header $this->form->setTitle($this->lng->txt('webr_new_link')); // Buttons $this->form->addCommandButton('saveAddLink', $this->lng->txt('webr_add')); $this->form->addCommandButton('view', $this->lng->txt('cancel')); break; case self::LINK_MOD_EDIT: // Header $this->ctrl->setParameter($this, 'link_id', (int) $_REQUEST['link_id']); $this->form->setTitle($this->lng->txt('webr_edit')); // Buttons $this->form->addCommandButton('updateLink', $this->lng->txt('save')); $this->form->addCommandButton('view', $this->lng->txt('cancel')); break; } $this->form->setFormAction($this->ctrl->getFormAction($this)); if ($a_mode == self::LINK_MOD_ADD and $this->isContainerMetaDataRequired()) { ilUtil::sendInfo($this->lng->txt('webr_container_info')); $this->form->setTitle($this->lng->txt('webr_edit_list')); // List Title $title = new ilTextInputGUI($this->lng->txt('webr_list_title'), 'lti'); $title->setRequired(true); $title->setSize(40); $title->setMaxLength(127); $this->form->addItem($title); // List Description $desc = new ilTextAreaInputGUI($this->lng->txt('webr_list_desc'), 'tde'); $desc->setRows(3); $desc->setCols(40); $this->form->addItem($desc); // Addtional section $sect = new ilFormSectionHeaderGUI(); $sect->setTitle($this->lng->txt('webr_add')); $this->form->addItem($sect); } // Target /* $tar = new ilTextInputGUI($this->lng->txt('webr_link_target'),'tar'); $tar->setValue("http://"); $tar->setSize(40); $tar->setMaxLength(500); */ include_once 'Services/Form/classes/class.ilLinkInputGUI.php'; $tar = new ilLinkInputGUI($this->lng->txt('webr_link_target'), 'tar'); $tar->setInternalLinkFilterTypes(array("PageObject", "GlossaryItem", "RepositoryItem")); $tar->setRequired(true); $this->form->addItem($tar); // Title $tit = new ilTextInputGUI($this->lng->txt('webr_link_title'), 'tit'); $tit->setRequired(true); $tit->setSize(40); $tit->setMaxLength(127); $this->form->addItem($tit); // Description $des = new ilTextAreaInputGUI($this->lng->txt('description'), 'des'); $des->setRows(3); $des->setCols(40); $this->form->addItem($des); if ($a_mode != self::LINK_MOD_CREATE) { // Active $act = new ilCheckboxInputGUI($this->lng->txt('active'), 'act'); $act->setChecked(true); $act->setValue(1); $this->form->addItem($act); // Check $che = new ilCheckboxInputGUI($this->lng->txt('webr_disable_check'), 'che'); $che->setValue(1); $this->form->addItem($che); } // Valid if ($a_mode == self::LINK_MOD_EDIT) { $val = new ilCheckboxInputGUI($this->lng->txt('valid'), 'vali'); $this->form->addItem($val); } if (ilParameterAppender::_isEnabled() && $a_mode != self::LINK_MOD_CREATE) { $dyn = new ilNonEditableValueGUI($this->lng->txt('links_dyn_parameter')); $dyn->setInfo($this->lng->txt('links_dynamic_info')); if (count($links = ilParameterAppender::_getParams((int) $_GET['link_id']))) { $ex = new ilCustomInputGUI($this->lng->txt('links_existing_params'), 'ex'); $dyn->addSubItem($ex); foreach ($links as $id => $link) { $p = new ilCustomInputGUI(); $ptpl = new ilTemplate('tpl.link_dyn_param_edit.html', true, true, 'Modules/WebResource'); $ptpl->setVariable('INFO_TXT', ilParameterAppender::parameterToInfo($link['name'], $link['value'])); $this->ctrl->setParameter($this, 'param_id', $id); $ptpl->setVariable('LINK_DEL', $this->ctrl->getLinkTarget($this, 'deleteParameterForm')); $ptpl->setVariable('LINK_TXT', $this->lng->txt('delete')); $p->setHtml($ptpl->get()); $dyn->addSubItem($p); } } // Existing parameters // New parameter if ($a_mode != self::LINK_MOD_CREATE) { #$new = new ilCustomInputGUI($this->lng->txt('links_add_param'),''); #$dyn->addSubItem($new); } // Dynyamic name $nam = new ilTextInputGUI($this->lng->txt('links_name'), 'nam'); $nam->setSize(12); $nam->setMaxLength(128); $dyn->addSubItem($nam); // Dynamic value $val = new ilSelectInputGUI($this->lng->txt('links_value'), 'val'); $val->setOptions(ilParameterAppender::_getOptionSelect()); $val->setValue(0); $dyn->addSubItem($val); $this->form->addItem($dyn); } }
/** * @see ilTable2GUI::fillRow() */ protected function fillRow($a_set) { global $ilCtrl, $lng; if (!stristr($a_set['target'], '|')) { $this->tpl->setCurrentBlock('external'); $this->tpl->setVariable('VAL_ID', $a_set['id']); $this->tpl->setVariable('VAL_TARGET', $a_set['target']); $this->tpl->parseCurrentBlock(); } else { $ilCtrl->setParameterByClass('ilinternallinkgui', 'postvar', 'tar_' . $a_set['id']); $trigger_link = array(get_class($this->parent_obj), 'ilinternallinkgui'); $trigger_link = $ilCtrl->getLinkTargetByClass($trigger_link, '', false, true, false); $ilCtrl->setParameterByClass('ilinternallinkgui', 'postvar', ''); $this->tpl->setCurrentBlock('internal'); $this->tpl->setVariable('VAL_ID', $a_set['id']); $this->tpl->setVariable('VAL_TRIGGER_INTERNAL', $trigger_link); $this->tpl->setVariable('TXT_TRIGGER_INTERNAL', $this->lng->txt('edit')); // info about current link if ($a_set['target']) { $parts = explode('|', $a_set['target']); $this->tpl->setVariable('VAL_INTERNAL_TYPE', $parts[0]); $this->tpl->setVariable('VAL_INTERNAL_ID', $parts[1]); $parts = ilLinkInputGUI::getTranslatedValue($a_set['target']); $this->tpl->setVariable('TXT_TRIGGER_INFO', $parts['type'] . ' "' . $parts['name'] . '"'); } $this->tpl->parseCurrentBlock(); } $this->tpl->setVariable('TXT_LAST_CHECK', $this->lng->txt('webr_last_check_table')); $this->tpl->setVariable('LAST_CHECK', $a_set['last_check'] ? ilDatePresentation::formatDate(new ilDateTime($a_set['last_check'], IL_CAL_UNIX)) : $this->lng->txt('no_date')); // Valid $this->tpl->setVariable('VAL_VALID', ilUtil::formCheckbox($a_set['valid'], 'links[' . $a_set['id'] . '][vali]', 1)); // Active $this->tpl->setVariable('VAL_ACTIVE', ilUtil::formCheckbox($a_set['active'], 'links[' . $a_set['id'] . '][act]', 1)); // Valid $this->tpl->setVariable('VAL_CHECK', ilUtil::formCheckbox($a_set['disable_check'], 'links[' . $a_set['id'] . '][che]', 1)); // Dynamic parameters foreach ($a_set['params'] as $param_id => $param) { $this->tpl->setCurrentBlock('dyn_del_row'); $this->tpl->setVariable('TXT_DYN_DEL', $this->lng->txt('delete')); $ilCtrl->setParameterByClass(get_class($this->getParentObject()), 'param_id', $param_id); $this->tpl->setVariable('DYN_DEL_LINK', $ilCtrl->getLinkTarget($this->getParentObject(), 'deleteParameter')); $this->tpl->setVariable('VAL_DYN', ilParameterAppender::parameterToInfo($param['name'], $param['value'])); $this->tpl->parseCurrentBlock(); } if ($a_set['params']) { $this->tpl->setCurrentBlock('dyn_del_rows'); $this->tpl->setVariable('TXT_EXISTING', $this->lng->txt('links_existing_params')); $this->tpl->parseCurrentBlock(); } if (ilParameterAppender::_isEnabled()) { $this->tpl->setCurrentBlock('dyn_add'); $this->tpl->setVariable('TXT_DYN_ADD', $this->lng->txt('links_add_param')); $this->tpl->setVariable('TXT_DYN_NAME', $this->lng->txt('links_name')); $this->tpl->setVariable('TXT_DYN_VALUE', $this->lng->txt('links_value')); $this->tpl->setVariable('VAL_DYN_NAME', $a_set['name']); $this->tpl->setVariable('DYN_ID', $a_set['id']); $this->tpl->setVariable('SEL_DYN_VAL', ilUtil::formSelect($a_set['value'] ? $a_set['value'] : 0, 'links[' . $a_set['id'] . '][val]', ilParameterAppender::_getOptionSelect(), false, true)); $this->tpl->parseCurrentBlock(); } if (in_array($a_set['id'], $this->getInvalidLinks())) { $this->tpl->setVariable('CSS_ROW', 'warn'); } // Check $this->tpl->setVariable('VAL_ID', $a_set['id']); $this->tpl->setVariable('VAL_CHECKBOX', ilUtil::formCheckbox(false, 'link_ids[]', $a_set['id'])); // Column title $this->tpl->setVariable('TXT_TITLE', $this->lng->txt('title')); $this->tpl->setVariable('VAL_TITLE', ilUtil::prepareFormOutput($a_set['title'])); $this->tpl->setVariable('TXT_DESC', $this->lng->txt('description')); $this->tpl->setVariable('VAL_DESC', ilUtil::prepareFormOutput($a_set['description'])); // Column Target $this->tpl->setVariable('TXT_TARGET', $this->lng->txt('target')); }