/**
  * Create a new type from a model
  * 
  * @param string	model name (= sub directory of models)
  * @param string	title of the new type
  * 
  * @return int		type id
  */
 static function _createTypeFromModel($a_model_name, $a_type_name)
 {
     if ($xml = file_get_contents(self::$builtin_path . "/" . $a_model_name . "/interface.xml")) {
         $type = new ilExternalContentType();
         if ($type->setXML($xml, $message)) {
             $type->setName($a_type_name);
             $type->create();
             return $type->getTypeId();
         }
     }
 }
 /**
  * Get data and put it into an array
  */
 function getMyDataFromDb()
 {
     $this->plugin_object->includeClass('class.ilExternalContentType.php');
     // get types data with usage info
     $data = ilExternalContentType::_getTypesData(true);
     $this->setDefaultOrderField('type_id');
     $this->setDefaultOrderDirection('asc');
     $this->setData($data);
 }
 /**
  * Init properties form
  *
  * @param        int        $a_mode        Form Edit Mode (IL_FORM_EDIT | IL_FORM_CREATE)
  * @param		 array		(assoc) form values
  * @access       protected
  */
 protected function initForm($a_mode, $a_values = array())
 {
     if (is_object($this->form)) {
         return true;
     }
     include_once "./Services/Form/classes/class.ilPropertyFormGUI.php";
     $this->form = new ilPropertyFormGUI();
     $this->form->setFormAction($this->ctrl->getFormAction($this));
     if ($a_mode != "create") {
         $item = new ilCustomInputGUI($this->lng->txt('type'), '');
         $item->setHtml($this->object->typedef->getTitle());
         $item->setInfo($this->object->typedef->getDescription());
         $this->form->addItem($item);
     }
     $item = new ilTextInputGUI($this->lng->txt('title'), 'title');
     $item->setSize(40);
     $item->setMaxLength(128);
     $item->setRequired(true);
     $item->setInfo($this->txt('xxco_title_info'));
     $item->setValue($a_values['title']);
     $this->form->addItem($item);
     $item = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
     $item->setInfo($this->txt('xxco_description_info'));
     $item->setRows(2);
     $item->setCols(80);
     $item->setValue($a_values['description']);
     $this->form->addItem($item);
     if ($a_mode == "create") {
         $item = new ilRadioGroupInputGUI($this->lng->txt('type'), 'type_id');
         $item->setRequired(true);
         $types = ilExternalContentType::_getTypesData(false, ilExternalContentType::AVAILABILITY_CREATE);
         foreach ($types as $type) {
             $option = new ilRadioOption($type['title'], $type['type_id'], $type['description']);
             $item->addOption($option);
         }
         $this->form->addItem($item);
         $this->form->setTitle($this->txt('xxco_new'));
         $this->form->addCommandButton(!$this->checkCreationMode() ? 'update' : 'save', $this->lng->txt('save'));
         $this->form->addCommandButton('cancelCreate', $this->lng->txt("cancel"));
     } else {
         $item = new ilCheckboxInputGUI($this->lng->txt('online'), 'online');
         $item->setInfo($this->txt("xxco_online_info"));
         $item->setValue("1");
         if ($a_values['online']) {
             $item->setChecked(true);
         }
         $this->form->addItem($item);
         // add the type specific fields
         $this->object->typedef->addFormElements($this->form, $a_values, "object");
         $this->form->setTitle($this->lng->txt('settings'));
         $this->form->addCommandButton("update", $this->lng->txt("save"));
         $this->form->addCommandButton("view", $this->lng->txt("cancel"));
         if ($this->object->typedef->getMetaDataUrl()) {
             $this->form->addCommandButton("refreshMeta", $this->lng->txt("xxco_refresh_meta_data"));
         }
     }
 }