function generate_site_plugin_sql($site_type_r) { $CRLF = get_user_browser_crlf(); $buffer = "#########################################################" . $CRLF . "# OpenDb " . get_opendb_version() . " " . $site_type_r['title'] . " (" . $site_type_r['site_type'] . ") Site Plugin" . $CRLF . "#########################################################"; $buffer .= $CRLF . $CRLF . "#" . $CRLF . "# Site Plugin." . $CRLF . "#" . $CRLF; $buffer .= $CRLF . "INSERT INTO s_site_plugin ( site_type, classname, title, image, description, external_url, items_per_page, more_info_url ) " . "VALUES ( " . "'" . $site_type_r['site_type'] . "', " . "'" . $site_type_r['classname'] . "', " . "'" . addslashes($site_type_r['title']) . "', " . "'" . addslashes($site_type_r['image']) . "', " . "'" . addslashes($site_type_r['description']) . "', " . "'" . addslashes($site_type_r['external_url']) . "', " . "" . $site_type_r['items_per_page'] . ", " . "'" . addslashes($site_type_r['more_info_url']) . "' );"; $results = fetch_site_plugin_conf_rs($site_type_r['site_type']); if ($results) { $buffer .= $CRLF . $CRLF . "#" . $CRLF . "# Site Plugin Configuration" . $CRLF . "#" . $CRLF; while ($site_plugin_conf_r = db_fetch_assoc($results)) { $buffer .= $CRLF . "INSERT INTO s_site_plugin_conf ( site_type, name, keyid, description, value ) " . "VALUES ( " . "'" . $site_plugin_conf_r['site_type'] . "', " . "'" . addslashes($site_plugin_conf_r['name']) . "', " . "'" . addslashes($site_plugin_conf_r['keyid']) . "', " . "'" . addslashes($site_plugin_conf_r['description']) . "', " . "'" . addslashes($site_plugin_conf_r['value']) . "' );"; } db_fetch_assoc($results); } $results = fetch_site_plugin_input_field_rs($site_type_r['site_type']); if ($results) { $buffer .= $CRLF . $CRLF . "#" . $CRLF . "# Site Plugin Input Fields" . $CRLF . "#" . $CRLF; while ($site_plugin_input_field_r = db_fetch_assoc($results)) { $buffer .= $CRLF . "INSERT INTO s_site_plugin_input_field ( site_type, field, order_no, description, prompt, field_type, default_value, refresh_mask ) " . "VALUES ( " . "'" . $site_plugin_input_field_r['site_type'] . "', " . "'" . $site_plugin_input_field_r['field'] . "', " . "" . $site_plugin_input_field_r['order_no'] . ", " . "'" . addslashes($site_plugin_input_field_r['description']) . "', " . "'" . addslashes($site_plugin_input_field_r['prompt']) . "', " . "'" . $site_plugin_input_field_r['field_type'] . "', " . "'" . addslashes($site_plugin_input_field_r['default_value']) . "', " . "'" . addslashes($site_plugin_input_field_r['refresh_mask']) . "' );"; } db_fetch_assoc($results); } $results = fetch_site_plugin_link_rs($site_type_r['site_type']); if ($results) { $buffer .= $CRLF . $CRLF . "#" . $CRLF . "# Site Plugin Links" . $CRLF . "#" . $CRLF; while ($fetch_site_plugin_link_r = db_fetch_assoc($results)) { $buffer .= $CRLF . "INSERT INTO s_site_plugin_link ( site_type, s_item_type_group, s_item_type, order_no, description, url, title_url ) " . "VALUES ( " . "'" . $fetch_site_plugin_link_r['site_type'] . "', " . "'" . $fetch_site_plugin_link_r['s_item_type_group'] . "', " . "'" . $fetch_site_plugin_link_r['s_item_type'] . "', " . "" . $fetch_site_plugin_link_r['order_no'] . ", " . "'" . addslashes($fetch_site_plugin_link_r['description']) . "', " . "'" . addslashes($fetch_site_plugin_link_r['url']) . "', " . "'" . addslashes($fetch_site_plugin_link_r['title_url']) . "' );"; } db_fetch_assoc($results); } $results = fetch_site_plugin_s_attribute_type_map_rs($site_type_r['site_type']); if ($results) { $buffer .= $CRLF . $CRLF . "#" . $CRLF . "# Site Plugin System Attribute Type Map" . $CRLF . "#" . $CRLF; while ($site_plugin_s_attribute_type_map_r = db_fetch_assoc($results)) { $buffer .= $CRLF . "INSERT INTO s_site_plugin_s_attribute_type_map ( site_type, s_item_type_group, s_item_type, variable, s_attribute_type, lookup_attribute_val_restrict_ind ) " . "VALUES ( " . "'" . $site_plugin_s_attribute_type_map_r['site_type'] . "', " . "'" . $site_plugin_s_attribute_type_map_r['s_item_type_group'] . "', " . "'" . $site_plugin_s_attribute_type_map_r['s_item_type'] . "', " . "'" . addslashes($site_plugin_s_attribute_type_map_r['variable']) . "', " . "'" . $site_plugin_s_attribute_type_map_r['s_attribute_type'] . "', " . "'" . $site_plugin_s_attribute_type_map_r['lookup_attribute_val_restrict_ind'] . "' );"; } db_fetch_assoc($results); } $results = fetch_site_plugin_s_attribute_type_lookup_map_rs($site_type_r['site_type']); if ($results) { $buffer .= $CRLF . $CRLF . "#" . $CRLF . "# Site Plugin System Attribute Type Lookup Map" . $CRLF . "#" . $CRLF; while ($site_plugin_s_attribute_type_lookup_map_r = db_fetch_assoc($results)) { $buffer .= $CRLF . "INSERT INTO s_site_plugin_s_attribute_type_lookup_map ( site_type, s_attribute_type, value, lookup_attribute_val ) " . "VALUES ( " . "'" . $site_plugin_s_attribute_type_lookup_map_r['site_type'] . "', " . "'" . $site_plugin_s_attribute_type_lookup_map_r['s_attribute_type'] . "', " . "'" . addslashes($site_plugin_s_attribute_type_lookup_map_r['value']) . "', " . "'" . addslashes($site_plugin_s_attribute_type_lookup_map_r['lookup_attribute_val']) . "' ); "; } db_fetch_assoc($results); } $results = fetch_site_attribute_type_rs($site_type_r['site_type']); if ($results) { $buffer .= $CRLF . $CRLF . "####################################################################################################" . $CRLF . "# Item Type / Attribute Type relationships" . $CRLF . "####################################################################################################"; $attr_inserts = ""; $list_of_attribute_types = NULL; while ($site_attribute_type_r = db_fetch_assoc($results)) { $list_of_attribute_types[] = $site_attribute_type_r['s_attribute_type']; $attr_inserts .= $CRLF . "INSERT INTO s_attribute_type ( s_attribute_type, description, prompt, input_type, display_type, s_field_type, site_type ) " . "VALUES ( " . "'" . $site_attribute_type_r['s_attribute_type'] . "', " . "'" . addslashes($site_attribute_type_r['description']) . "', " . "'" . addslashes($site_attribute_type_r['prompt']) . "', " . "'" . addslashes($site_attribute_type_r['input_type']) . "', " . "'" . addslashes($site_attribute_type_r['display_type']) . "', " . "'" . $site_attribute_type_r['s_field_type'] . "', " . "'" . $site_attribute_type_r['site_type'] . "' );"; } db_fetch_assoc($results); $buffer .= $CRLF . $CRLF . "#" . $CRLF . "# Site Plugin Attribute Type(s)" . $CRLF . "#" . $CRLF; $buffer .= $attr_inserts; $results = fetch_site_item_attribute_type_rs($site_type_r['site_type']); if ($results) { $buffer .= $CRLF . $CRLF . "#" . $CRLF . "# Site Plugin Item Attribute Type Relationship(s)" . $CRLF . "#" . $CRLF; while ($site_item_attribute_type_r = db_fetch_assoc($results)) { $buffer .= $CRLF . "INSERT INTO s_item_attribute_type ( s_item_type, s_attribute_type, order_no, prompt, compulsory_ind ) " . "VALUES ( " . "'" . $site_item_attribute_type_r['s_item_type'] . "', " . "'" . $site_item_attribute_type_r['s_attribute_type'] . "', " . " " . $site_item_attribute_type_r['order_no'] . ", " . "'" . addslashes($site_item_attribute_type_r['prompt']) . "', " . "'" . ifempty($site_item_attribute_type_r['compulsory_ind'], 'N') . "' );"; } db_fetch_assoc($results); } } $buffer .= $CRLF; return $buffer; }
/** * Will return a complete array structure of configuration information for a * $site_type. */ function get_site_plugin_conf_r($site_type) { $results = fetch_site_plugin_conf_rs($site_type); if ($results) { $site_plugin_conf_rs = array(); $name = NULL; $value = NULL; while ($site_plugin_conf_r = db_fetch_assoc($results)) { if ($name == NULL || $name != $site_plugin_conf_r['name']) { // need to process entries added to $value if ($name != NULL) { if (is_array($value)) { if (count($value) == 1 && isset($value[0])) { $site_plugin_conf_rs[$name] = $value[0]; } else { $site_plugin_conf_rs[$name] = $value; } } } $value = NULL; $name = $site_plugin_conf_r['name']; } $value[$site_plugin_conf_r['keyid']] = $site_plugin_conf_r['value']; } if (is_array($value)) { if (count($value) > 1) { $site_plugin_conf_rs[$name] = $value; } else { $site_plugin_conf_rs[$name] = $value[0]; } } db_free_result($results); return $site_plugin_conf_rs; } else { return FALSE; } }