Example #1
0
                 if ($item_attribute_type_r['s_field_type'] == 'UPDATE_ON') {
                     $value = $item_r['update_on'];
                 } else {
                     if (is_multivalue_attribute_type($item_attribute_type_r['s_attribute_type'])) {
                         $value = fetch_attribute_val_r($item_r['item_id'], $item_r['instance_no'], $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']);
                     } else {
                         $value = fetch_attribute_val($item_r['item_id'], $item_r['instance_no'], $item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']);
                     }
                 }
             }
             if (is_not_empty_array($value) || !is_array($value) && strlen($value) > 0) {
                 $item_attribute_type_r['display_type'] = $display_type;
                 $item_attribute_type_r['compulsory_ind'] = 'N';
                 $field = get_item_display_field($item_r, $item_attribute_type_r, $value, FALSE);
                 if (strlen($field) > 0) {
                     echo format_item_data_field($item_attribute_type_r, $field, $prompt_mask, NULL);
                     // field mask
                 }
             }
         }
     }
     db_free_result($results);
     echo "\n</table>";
 }
 echo get_site_plugin_links($page_title, $item_r);
 echo "</div>";
 $instance_info_links_r = array();
 echo "<div class=\"{$otherTabsClass}\" id=\"instance_info\">";
 echo get_instance_info_block($item_r, $HTTP_VARS, $instance_info_links_r);
 echo get_related_items_block($item_r, $HTTP_VARS, $instance_info_links_r);
 echo format_footer_links($instance_info_links_r);
Example #2
0
function get_item_input_field($fieldname, $item_attribute_type_r, $item_r, $value = NULL, $dowrap = TRUE, $prompt_mask = NULL, $onchange_event = NULL, $disabled = FALSE)
{
    if (is_array($item_attribute_type_r)) {
        $s_attribute_type = $item_attribute_type_r['s_attribute_type'];
        $order_no = $item_attribute_type_r['order_no'];
        $prompt = $item_attribute_type_r['prompt'];
        $input_type = $item_attribute_type_r['input_type'];
        $compulsory_ind = $item_attribute_type_r['compulsory_ind'];
        $widget['type'] = $item_attribute_type_r['input_type'];
        $widget['args'][0] = $item_attribute_type_r['input_type_arg1'];
        $widget['args'][1] = $item_attribute_type_r['input_type_arg2'];
        $widget['args'][2] = $item_attribute_type_r['input_type_arg3'];
        $widget['args'][3] = $item_attribute_type_r['input_type_arg4'];
        $widget['args'][4] = $item_attribute_type_r['input_type_arg5'];
    }
    if ($item_attribute_type_r['multi_attribute_ind'] == 'Y') {
        $multi_value = TRUE;
        if (!is_array($value)) {
            $old_value = ifempty($value, "");
            unset($value);
            $value[] = $old_value;
        }
    } else {
        $multi_value = FALSE;
        // an array will be a lookup value
        if (!is_array($value)) {
            // Escape all html entities so they are displayed correctly!
            if (strlen($value) > 0) {
                $value = htmlspecialchars($value);
            }
        }
    }
    $field = NULL;
    $field_mask = NULL;
    // Now we have to work out how to parse the input_type
    if ($item_attribute_type_r['input_type'] == 'hidden') {
        return hidden_field($fieldname, $value);
    } else {
        if ($item_attribute_type_r['input_type'] == 'readonly') {
            $field = readonly_field($fieldname, $value);
        } else {
            if ($item_attribute_type_r['input_type'] == 'textarea' || $item_attribute_type_r['input_type'] == 'htmlarea') {
                // arg[0] = rows, arg[1] = cols, arg[2] = length
                $field = textarea_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $widget['widget']['2'], $compulsory_ind, $value, $onchange_event, $disabled);
            } else {
                if ($item_attribute_type_r['input_type'] == 'text') {
                    // arg[0] = length of field, arg[1] = maxlength of field
                    $field = text_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value);
                } else {
                    if ($item_attribute_type_r['input_type'] == 'password') {
                        // arg[0] = length of field, arg[1] = maxlength of field
                        $field = password_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value);
                    } else {
                        if ($item_attribute_type_r['input_type'] == 'email') {
                            // arg[0] = length of field, arg[1] = maxlength of field
                            $field = email_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value);
                        } else {
                            if ($item_attribute_type_r['input_type'] == 'filtered') {
                                // arg[0] = length of field, arg[1] = maxlength of field, arg[2] = legalChars
                                $field = filtered_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $widget['args']['2'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value);
                            } else {
                                if ($item_attribute_type_r['input_type'] == 'datetime') {
                                    // arg[0] = datetime mask, arg[1] = auto_datetime
                                    $field = datetime_field($fieldname, $prompt, ifempty($widget['args']['0'], 'DD/MM/YYYY'), $widget['args']['1'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value);
                                } else {
                                    if ($item_attribute_type_r['input_type'] == 'number') {
                                        // arg[0] = length of field, arg[0] = maxlength of field
                                        $field = number_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['0'], $compulsory_ind, $value, $onchange_event, $disabled, $multi_value);
                                    } else {
                                        if ($item_attribute_type_r['input_type'] == 'simple_checkbox') {
                                            // arg[0] = checked
                                            $field = checkbox_field($fieldname, $prompt, strcasecmp(trim($widget['args']['0']), 'CHECKED') === 0, $value, $onchange_event, $disabled);
                                        } else {
                                            if ($item_attribute_type_r['input_type'] == 'checkbox') {
                                                // arg[0] = checked, arg[1] = unchecked
                                                $field = enhanced_checkbox_field($fieldname, $prompt, $widget['args']['0'], $widget['args']['1'], $value, $onchange_event, $disabled);
                                            } else {
                                                if ($item_attribute_type_r['input_type'] == 'checkbox_grid') {
                                                    $lookup_results = fetch_attribute_type_lookup_rs($s_attribute_type, 'order_no, ' . get_lookup_order_by($widget['args']['0']) . ' ASC');
                                                    if ($lookup_results) {
                                                        //arg[0] = display_mask, arg[1] = orientation
                                                        $field = checkbox_grid($fieldname, $lookup_results, $widget['args']['0'], $widget['args']['1'], $value, $disabled);
                                                    }
                                                } else {
                                                    if ($item_attribute_type_r['input_type'] == 'radio_grid') {
                                                        $lookup_results = fetch_attribute_type_lookup_rs($s_attribute_type, 'order_no, ' . get_lookup_order_by($widget['args']['0']) . ' ASC');
                                                        if ($lookup_results) {
                                                            //arg[0] = display_mask, arg[1] = orientation
                                                            $field = radio_grid($fieldname, $lookup_results, $widget['args']['0'], $widget['args']['1'], $value, $disabled);
                                                        }
                                                    } else {
                                                        if ($item_attribute_type_r['input_type'] == 'value_radio_grid') {
                                                            //arg[0] = "comma delimited list of values"
                                                            $field = value_radio_grid($fieldname, explode(',', $widget['args']['0']), $value, $disabled);
                                                        } else {
                                                            if ($item_attribute_type_r['input_type'] == 'single_select') {
                                                                $lookup_results = fetch_attribute_type_lookup_rs($s_attribute_type, 'order_no, ' . get_lookup_order_by($widget['args']['0']) . ' ASC');
                                                                if ($lookup_results) {
                                                                    //arg[0] = display mask, arg[1] = max value length
                                                                    $field = single_select($fieldname, $lookup_results, $widget['args']['0'], $widget['args']['1'], $value, $onchange_event, $disabled);
                                                                }
                                                            } else {
                                                                if ($item_attribute_type_r['input_type'] == 'multi_select') {
                                                                    $lookup_results = fetch_attribute_type_lookup_rs($s_attribute_type, 'order_no, ' . get_lookup_order_by($widget['args']['0']) . ' ASC');
                                                                    if ($lookup_results) {
                                                                        //arg[0] = display mask, arg[1] = max value length, arg[2] = select box number of visible rows
                                                                        $field = multi_select($fieldname, $lookup_results, $widget['args']['0'], $widget['args']['1'], $widget['args']['2'], $value, $onchange_event, $disabled);
                                                                    }
                                                                } else {
                                                                    if ($item_attribute_type_r['input_type'] == 'value_select') {
                                                                        //arg[0] = "comma delimited list of values"; arg[1] = number of visible rows (Defaults to single select
                                                                        $field = value_select($fieldname, explode(',', $widget['args']['0']), $widget['args']['1'], $value, $onchange_event, $disabled);
                                                                    } else {
                                                                        if ($item_attribute_type_r['input_type'] == 'review_options') {
                                                                            //arg[1] = display_mask, arg[1] = orientation
                                                                            $lookup_results = fetch_attribute_type_lookup_rs($s_attribute_type, 'value DESC');
                                                                            //We want the rows highest value first.
                                                                            if ($lookup_results) {
                                                                                $field = review_options($fieldname, $lookup_results, $widget['args']['0'], $widget['args']['1'], $value, $disabled);
                                                                            }
                                                                        } else {
                                                                            if ($item_attribute_type_r['input_type'] == 'url') {
                                                                                //arg[0] = length of field, arg[1] = maxlength of field, arg[2] = extensions
                                                                                $field = url($fieldname, $item_r, $item_attribute_type_r, $prompt, $widget['args']['0'], $widget['args']['1'], $widget['args']['2'], $value, $onchange_event, $disabled, $multi_value);
                                                                            } else {
                                                                                $field = ">>> ERROR (input_type = {$input_type}) <<<";
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if ($dowrap) {
        return format_item_data_field($item_attribute_type_r, $field, $prompt_mask);
    } else {
        return $field;
    }
}
Example #3
0
function get_item_form_row($op, $item_r, $item_attribute_type_r, $old_value, $new_value)
{
    if ($item_attribute_type_r['s_field_type'] == 'TITLE') {
        $fieldname = 'title';
    } else {
        $fieldname = get_field_name($item_attribute_type_r['s_attribute_type'], $item_attribute_type_r['order_no']);
    }
    $is_multi_value = is_multivalue_attribute_type($item_attribute_type_r['s_attribute_type']);
    $refresh_field = FALSE;
    // Hidden cannot be involved in a refresh operation directly, but refreshed hidden fields, will still be updated.
    if (strcasecmp($item_attribute_type_r['input_type'], 'hidden') !== 0 && $old_value !== FALSE && (is_not_empty_array($new_value) || !is_array($new_value) && strlen($new_value) > 0) && is_value_refreshed($item_attribute_type_r['s_attribute_type'], $new_value, $old_value) && (is_not_empty_array($old_value) || !is_array($old_value) && strlen($old_value) > 0)) {
        $refresh_field = TRUE;
        $new_value = get_array_for_value($new_value);
    }
    if ($refresh_field && count($new_value) > 0 || is_array($new_value) && !$is_multi_value) {
        // -------------
        // REFRESH FIELD
        // -------------
        // If we are doing a complete refresh block, and display_type is set to
        // hidden, overwrite to display it.
        if ($item_attribute_type_r['display_type'] == 'hidden') {
            $item_attribute_type_r['display_type'] = 'display(%value%)';
            $item_attribute_type_r['display_type_arg1'] = '%value%';
        }
        $field .= "<ul class=\"tabMenu\" id=\"{$fieldname}-tab-menu\">";
        if (!$is_multi_value) {
            $new_value = deduplicate_array($new_value, $old_value);
            $count = count($new_value) - 1;
        } else {
            $count = 0;
        }
        $key = array_keys($new_value);
        for ($i = 0; $i <= $count; $i++) {
            is_numeric($key[$i]) ? $label_description = "" : ($label_description = " : {$key[$i]}");
            $field .= "<li id=\"menu-{$fieldname}_new{$i}\"" . ($i == 0 ? " class=\"first activeTab\"" : "") . ">\n\t\t\t\t\t<label for=\"menu-{$fieldname}_new{$i}-cbox\">" . $item_attribute_type_r['prompt'] . "{$label_description}</label>" . "<input type=\"radio\" class=\"radio\" name=\"" . $fieldname . "\" id=\"menu-{$fieldname}_new{$i}-cbox\" value=\"new{$i}\" onclick=\"return activateTab('{$fieldname}_new{$i}', '{$fieldname}-tab-menu', '{$fieldname}-tab-content');\"" . ($i == 0 ? " CHECKED" : "") . "></li>";
        }
        if ($refresh_field) {
            $field .= "<li id=\"menu-{$fieldname}_old\" >\n\t\t\t\t<label for=\"menu-{$fieldname}_old-cbox\">" . get_opendb_lang_var('old_prompt', 'prompt', $item_attribute_type_r['prompt']) . "</label>" . "<input type=\"radio\" class=\"radio\" id=\"menu-{$fieldname}_old-cbox\" name=\"" . $fieldname . "\" value=\"old\" onclick=\"return activateTab('{$fieldname}_old', '{$fieldname}-tab-menu', '{$fieldname}-tab-content');\"></li>";
        }
        $field .= "</ul>";
        $field .= "<div class=\"tabContentContainer\" id=\"{$fieldname}-tab-content\">";
        for ($i = 0; $i <= $count; $i++) {
            if ($is_multi_value) {
                $value = $new_value;
            } else {
                $value = $new_value[$key[$i]];
            }
            $field .= "<div class=\"tabContent" . ($i > 0 ? "Hidden" : "") . "\" id=\"{$fieldname}_new{$i}\">" . get_item_input_field($fieldname . "_new{$i}", $item_attribute_type_r, $item_r, $value, FALSE) . "</div>";
        }
        if ($refresh_field) {
            $field .= "<div class=\"tabContentHidden\" id=\"{$fieldname}_old\">" . get_item_input_field($fieldname . "_old", $item_attribute_type_r, $item_r, $old_value, FALSE) . "</div>";
        }
        $field .= "</div>";
        $prompt_mask = NULL;
        if ($refresh_field) {
            $prompt_mask = theme_image('rs.gif', get_opendb_lang_var('refreshed')) . "%prompt%";
        }
        return format_item_data_field($item_attribute_type_r, $field, $prompt_mask, NULL);
        // field mask
    } else {
        // not a choose attribute
        if (is_multivalue_attribute_type($item_attribute_type_r['s_attribute_type'])) {
            // if new_value is empty!
            if (is_empty_or_not_array($new_value)) {
                if ($old_value !== FALSE) {
                    $value = $old_value;
                } else {
                    $value = NULL;
                }
            } else {
                $value =& $new_value;
            }
            return get_item_input_field($fieldname, $item_attribute_type_r, $item_r, $value);
        } else {
            $value = ifempty($new_value, $old_value === FALSE ? NULL : $old_value);
            // If this is an edit operation - the value must be NOT NULL
            // for some widgets to work properly.
            if ($op != 'new' && $op != 'site' && $value === NULL) {
                $value = '';
            }
            return get_item_input_field($fieldname, $item_attribute_type_r, $item_r, $value);
        }
    }
}