コード例 #1
0
 /**
  *	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);
 }
コード例 #2
0
 /**
  *	create html form 
  *
  *	@param array $errors	array with error messages
  *	@return null			FALSE on failure
  */
 function create_html_form(&$errors)
 {
     parent::create_html_form($errors);
     $this->get_form_elements();
     $js_elements = array();
     foreach ($this->form_elements as $k => $v) {
         if (!isset($this->session['f_values'][$v['name']])) {
             if (isset($v['initial'])) {
                 $this->session['f_values'][$v['name']] = $v['initial'];
             } else {
                 $this->session['f_values'][$v['name']] = null;
             }
         }
         /* pre set the value */
         if ($v['type'] == "checkbox") {
             $v['checked'] = $this->session['f_values'][$v['name']];
             if (empty($v['value'])) {
                 $v['value'] = 1;
             }
             //if value is not set
         } else {
             $v['value'] = $this->session['f_values'][$v['name']];
         }
         $js_el = array();
         $js_el["name"] = $v['name'];
         $js_el["type"] = $v['type'];
         /* do specific actions for each type */
         switch ($v['type']) {
             case "text":
                 if (!isset($v['maxlength'])) {
                     $v['maxlength'] = 32;
                 }
                 if ($v['value']) {
                     $this->filter_applied = true;
                 }
                 break;
             case "checkbox":
                 /* add the hidden element in order to it not depend 
                    if checkbox is displayed by the template or not */
                 $this->f->add_element(array("name" => $v['name'] . "_hidden", "type" => "hidden", "value" => $v['checked'] ? 1 : 0));
                 $onclick = "if (this.checked) this.form." . $v['name'] . "_hidden" . ".value=1; else this.form." . $v['name'] . "_hidden" . ".value=0;";
                 if (!empty($v['3state'])) {
                     $js_el["three_state"] = true;
                     $v['disabled'] = empty($this->session['f_spec'][$v['name']]['enabled']);
                     /* add the chcekbox element enabling or disabling the first one */
                     $this->f->add_element(array("name" => $v['name'] . "_en", "type" => "checkbox", "value" => 1, "checked" => !$v['disabled'], "extrahtml" => "title='enable filtering by this flag' onclick='if (this.checked) this.form." . $v['name'] . ".disabled=false; else this.form." . $v['name'] . ".disabled=true;'"));
                     //					$onchange .= "if (this.checked) this.form.".$v['name'].".disable=false; else this.form.".$v['name'].".disable=true;";
                     if (!$v['disabled']) {
                         $this->filter_applied = true;
                     }
                 } else {
                     if ($v['checked']) {
                         $this->filter_applied = true;
                     }
                 }
                 if (empty($v['extrahtml'])) {
                     $v['extrahtml'] = "";
                 }
                 $v['extrahtml'] .= " onclick='" . $onclick . "'";
                 break;
         }
         $this->f->add_element($v);
         $this->form_elements[$k] = $v;
         if (isset($v['label'])) {
             $this->labels[$v['name']] = $v['label'];
         }
         $js_elements[] = $js_el;
     }
     $this->opt['form_clear']['extra_html'] = "onclick='filter_form_ctl.filter_clear(); return false;'";
     $this->f->add_extra_submit("f_clear", $this->opt['form_clear']);
     $onload_js = "\n\t\t\tfilter_form_ctl = new Filter_Form('" . $this->opt['form_name'] . "', " . my_JSON_encode($js_elements) . ");\n\t\t";
     $this->controler->set_onload_js($onload_js);
 }
コード例 #3
0
 function action_suggest_query(&$errors)
 {
     $this->controler->disable_html_output();
     header("Content-Type: text/plain");
     $uname = $_GET['al_uname'];
     $did = $_GET['al_did'];
     // check whether user have access to the did of the uri
     if (!$this->check_did($did)) {
         return true;
     }
     //finish the action execution
     if (false === ($uris = URI_functions::suggest_uri($uname, $did))) {
         return false;
     }
     $response = new stdClass();
     $response->suggested_uris = $uris;
     echo my_JSON_encode($response);
     return true;
 }