コード例 #1
0
ファイル: item_display.php プロジェクト: horrabin/opendb
/**
	This function will return a complete table of all links valid
	for this item_type.

	This is useful because it allows the use of a site plugin for
	generating links only, by specifying as the default site type.
*/
function get_site_plugin_links($page_title, $item_r)
{
    $pageContents = '';
    $results = fetch_site_plugin_rs($item_r['s_item_type']);
    if ($results) {
        $titleMaskCfg = new TitleMask();
        $pageContents = "<ul class=\"sitepluginLinks\">";
        while ($site_plugin_type_r = db_fetch_assoc($results)) {
            if (is_exists_site_plugin($site_plugin_type_r['site_type'])) {
                $site_plugin_conf_rs = get_site_plugin_conf_r($site_plugin_type_r['site_type']);
                if (strlen($site_plugin_type_r['image']) > 0) {
                    $link_text = theme_image("images/site/" . $site_plugin_type_r['image'], htmlspecialchars($site_plugin_type_r['title']));
                } else {
                    $link_text = $site_plugin_type_r['title'];
                }
                $results2 = fetch_site_plugin_link_rs($site_plugin_type_r['site_type'], $item_r['s_item_type']);
                if ($results2) {
                    while ($site_plugin_link_r = db_fetch_assoc($results2)) {
                        $parse_url = NULL;
                        if (strlen($site_plugin_link_r['url']) > 0 && is_exists_site_item_attribute($site_plugin_type_r['site_type'], $item_r['item_id'], $item_r['instance_no'])) {
                            $parse_url = $site_plugin_link_r['url'];
                        } else {
                            if (strlen($site_plugin_link_r['title_url']) > 0) {
                                $parse_url = $site_plugin_link_r['title_url'];
                            }
                        }
                        if ($parse_url != NULL) {
                            $titleMaskCfg->reset();
                            $parse_url = trim($titleMaskCfg->expand_title($item_r, $parse_url, $site_plugin_conf_rs));
                            if (strlen($parse_url) > 0) {
                                $pageContents .= "<li><a href=\"" . $parse_url . "\" target=\"_new\">{$link_text}";
                                $pageContents .= "<span class=\"sitePluginDescription\">" . $site_plugin_link_r['description'] . "</span>";
                                $pageContents .= "</a></li>";
                            }
                        }
                    }
                    //while
                    db_free_result($results2);
                }
            }
        }
        //while
        db_free_result($results);
        $pageContents .= "</ul>";
        return $pageContents;
    }
}
コード例 #2
0
ファイル: index.php プロジェクト: horrabin/opendb
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;
}