function generateInputObjects() { $ret = array(); $tabindex_count = 0; foreach ($this->standard_options as $name => $values) { if (isset($values['value'])) { $value = $values['value']; } else { $value = ''; } if (isset($values['label'])) { $label = $values['label']; } else { $label = ''; } if ($this->item_link_class) { $secondary_get_vars = ArrayUtility::merge($this->secondary_get_vars, array($name => $value)); $href = Display::hrefString($this->item_link_class, $secondary_get_vars); $label = new FormLink($href, $label); } else { $label = new FormLabel($label); } switch ($this->type) { case ButtonGroup::CHECK: $obj = new Checkbox($name, $this->class, '', $value, $label, ''); break; case ButtonGroup::RADIO: $obj = new RadioButton($name, $this->class, '', $value, $label, ''); break; case ButtonGroup::NONE: $obj = $label; break; } if ($obj instanceof FormInput) { $obj->setTabindex($this->tabindex + $tabindex_count); } $tabindex_count++; } $selected = $this->selected; $primary_get_string = ''; $check_name = $this->name; if (!$this->options) { $this->options = array(); } foreach ($this->options as $opt) { $cur_check_name = $opt->formOptionName($check_name); $cur_check_value = $opt->formOptionValue(); $cur_check_label = $opt->toString(); $opt->formLinkGetVars($this->secondary_get_vars); $check_selected = ArrayUtility::arrayFromString($cur_check_name, false); if ($this->type == ButtonGroup::CHECK || $this->type == ButtonGroup::NONE) { $cur_check_name .= '[]'; } if ($this->item_link_class) { $href = Display::hrefString($this->item_link_class, $this->secondary_get_vars); $label = new FormLink($href, $cur_check_label); } else { $label = new FormLabel($cur_check_label); } switch ($this->type) { case ButtonGroup::CHECK: if (count($check_selected) && is_array($check_selected)) { $sel_array = ArrayUtility::getArrayValueMulti($selected, $check_selected); if (!is_array($sel_array)) { $sel_array = array(); } } else { $sel_array = $selected; } if (in_array($cur_check_value, $sel_array)) { $is_selected = true; } else { $is_selected = false; } $obj = new Checkbox($cur_check_name, $this->class, '', $cur_check_value, $label, $is_selected); break; case ButtonGroup::RADIO: if ($cur_check_value == $selected) { $is_selected = true; } else { $is_selected = false; } $obj = new RadioButton($cur_check_name, $this->class, '', $cur_check_value, $label, $is_selected); break; case ButtonGroup::NONE: $obj = new HiddenLabel($cur_check_name, $cur_check_value, $label, ''); break; } if ($obj instanceof FormInput) { $obj->setTabindex($this->tabindex + $tabindex_count); } $ret[] = $obj; $tabindex_count++; } return $ret; }
function getValueFromArray($name, $params) { if (is_array(ArrayUtility::arrayFromString($name, false))) { $value = ArrayUtility::getArrayValueMulti($params, ArrayUtility::arrayFromString($name)); } else { //$value = ArrayUtility::getArrayValue($params,$name); if (isset($params[$name])) { $value = $params[$name]; } else { $value = ''; } } return $value; }
/** * Create a value string from the fields and values * * This is the heart of the InsertQuery and is the function * that allows the user to have created 'jagged' value arrays, * that is, it is this function that eliminates the need for the * user to add a value for each field simultaneously when building * the query. * * The value string is created by looping through the number of * times corresponding to the field with the most values. If * a field does not have a value for a particular element, then * @access private */ function createValueString() { $value_array_counts = array_map('count', $this->values); sort($value_array_counts, SORT_NUMERIC); $max = ArrayUtility::lastElement($value_array_counts); $ret = array(); for ($i = 0; $i < $max; $i++) { $vals = array(); foreach ($this->fields as $name) { /*add the value for this field if it exists*/ if ($new_value = ArrayUtility::getArrayValueMulti($this->values, array($name, $i))) { $vals[] = $new_value; } else { if ($this->mode == InsertQuery::EMPTY_VALUE_MODE) { $vals[] = '\'\''; } else { if ($new_value = ArrayUtility::getArrayValueMulti($this->values, array($name, 0))) { $vals[] = $new_value; } else { $vals[] = '\'\''; } } } } $ret[] = '(' . implode(',', $vals) . ')'; } return implode(',', $ret); }