/** * create html form * * @param array $errors array with error messages * @return null FALSE on failure */ function create_html_form(&$errors) { global $lang_str, $sess; parent::create_html_form($errors); /* get list of attributes */ $this->attrs =& Attr_types::singleton(); if (false === ($at = $this->attrs->get_attr_types())) { return false; } if (false === ($grp = $this->attrs->get_attr_groups())) { return false; } $this->attr_groups = $grp; $grp[] = array("label" => "< " . $lang_str['attr_grp_create_new'] . " >", "value" => "__new__"); $grp_cnt = count($grp) - 1; /* default values for form elements */ if ($this->edit_id and isset($at[$this->edit_id])) { $atr =& $at[$this->edit_id]; } else { $atr = new Attr_type("", 2, "string", "", "", 0, 0, 0, 0, 0); } $this->f->add_element(array("type" => "text", "name" => "attr_name", "size" => 16, "maxlength" => 32, "value" => $atr->get_name(), "minlength" => 1, "length_e" => $lang_str['fe_not_filled_name_of_attribute'])); $this->f->add_element(array("type" => "select", "name" => "attr_type", "size" => 1, "options" => Attr_types::get_all_types(), "value" => $atr->get_type())); $this->f->add_element(array("type" => "text", "name" => "attr_order", "size" => 16, "maxlength" => 5, "value" => $atr->get_order(), "valid_regex" => "^[0-9]+\$", "valid_e" => $lang_str['fe_order_is_not_number'])); $this->f->add_element(array("type" => "text", "name" => "attr_label", "size" => 16, "maxlength" => 255, "value" => $atr->get_raw_description())); $this->f->add_element(array("type" => "select", "name" => "attr_access", "size" => 1, "options" => $atr->get_access_options(), "value" => $atr->get_access())); $this->f->add_element(array("type" => "select", "name" => "attr_group", "size" => 1, "options" => $grp, "value" => $atr->get_group(), "extrahtml" => "onchange='if (this.selectedIndex==" . $grp_cnt . "){this.form.attr_new_group.disabled=false; this.form.attr_new_group.focus();}else{this.form.attr_new_group.disabled=true;}'")); $this->f->add_element(array("type" => "text", "name" => "attr_new_group", "size" => 16, "value" => "", "disabled" => true)); $this->f->add_element(array("type" => "checkbox", "name" => "for_ser", "value" => "1", "checked" => $atr->is_for_ser())); $this->f->add_element(array("type" => "checkbox", "name" => "for_serweb", "value" => "1", "checked" => $atr->is_for_serweb())); $this->f->add_element(array("type" => "checkbox", "name" => "pr_uri", "value" => "1", "checked" => $atr->is_for_URIs())); $this->f->add_element(array("type" => "checkbox", "name" => "pr_user", "value" => "1", "checked" => $atr->is_for_users())); $this->f->add_element(array("type" => "checkbox", "name" => "pr_domain", "value" => "1", "checked" => $atr->is_for_domains())); $this->f->add_element(array("type" => "checkbox", "name" => "pr_global", "value" => "1", "checked" => $atr->is_for_globals())); $this->f->add_element(array("type" => "checkbox", "name" => "multivalue", "value" => "1", "checked" => $atr->is_multivalue())); $this->f->add_element(array("type" => "checkbox", "name" => "registration", "value" => "1", "checked" => $atr->fill_on_register())); $this->f->add_element(array("type" => "checkbox", "name" => "required", "value" => "1", "checked" => $atr->is_required())); $this->f->add_element(array("type" => "hidden", "name" => "edit_id", "value" => $this->edit_id)); if ($atr->apu_edit()) { $this->f->add_extra_submit('extended_settings', $this->opt['form_submit_extended']); } /* Instantiate page controler object */ $onload_js = "\n var at_ctl;\n at_ctl = new Attr_types_ctl('at_ctl', " . my_JSON_encode($lang_str) . ", '" . js_escape($sess->url($_SERVER['PHP_SELF'] . "?kvrk=" . uniqID("") . "&rename_group=1")) . "');"; $this->controler->set_onload_js($onload_js); }