function wpsc_select_variation_file($file_id, $variation_ids, $variation_combination_id = null)
{
    global $wpdb;
    $file_list = wpsc_uploaded_files();
    $unique_id_component = (int) $variation_combination_id . "_" . str_replace(",", "_", $variation_ids);
    $output = "<div class='variation_settings_contents'>\r\n";
    $output .= "<span class='admin_product_notes select_product_note '>" . __('Choose a downloadable file for this variation', 'wp-e-commerce') . "</span>\r\n";
    $output .= "<div class='select_variation_file'>\r\n";
    $num = 0;
    $output .= "  <p>\r\n";
    $output .= "    <input type='radio' name='variation_priceandstock[{$variation_ids}][file]' value='0' id='select_variation_file{$unique_id_component}_{$num}' " . (!is_numeric($file_id) || $file_id < 1 ? "checked='checked'" : "") . " />\r\n";
    $output .= "    <label for='select_variation_file{$unique_id_component}_{$num}'>" . __('No Product', 'wp-e-commerce') . "</label>\r\n";
    $output .= "  </p>\r\n";
    foreach ((array) $file_list as $file) {
        $num++;
        $output .= "  <p>\r\n";
        $output .= "    <input type='radio' name='variation_priceandstock[{$variation_ids}][file]' value='" . $file['file_id'] . "' id='select_variation_file{$unique_id_component}_{$num}' " . (is_numeric($file_id) && $file_id == $file['file_id'] ? "checked='checked'" : "") . " />\r\n";
        $output .= "    <label for='select_variation_file{$unique_id_component}_{$num}'>" . $file['display_filename'] . "</label>\r\n";
        $output .= "  </p>\r\n";
    }
    $output .= "</div>\r\n";
    $output .= "</div>\r\n";
    return $output;
}
function wpsc_select_variation_file($file_id, $variation_ids, $variation_combination_id = null)
{
    global $wpdb;
    //return false;
    $file_list = wpsc_uploaded_files();
    $unique_id_component = (int) $variation_combination_id . "_" . str_replace(",", "_", $variation_ids);
    $output = "<div class='variation_settings_contents'>\n\r";
    $output .= "<span class='admin_product_notes select_product_note '>" . TXT_WPSC_CHOOSE_DOWNLOADABLE_VARIATIONS . "</span>\n\r";
    $output .= "<div class='select_variation_file'>\n\r";
    $num = 0;
    $output .= "  <p>\n\r";
    $output .= "    <input type='radio' name='variation_priceandstock[{$variation_ids}][file]' value='0' id='select_variation_file{$unique_id_component}_{$num}' " . (!is_numeric($file_id) || $file_id < 1 ? "checked='checked'" : "") . " />\n\r";
    $output .= "    <label for='select_variation_file{$unique_id_component}_{$num}'>" . TXT_WPSC_SHOW_NO_PRODUCT . "</label>\n\r";
    $output .= "  </p>\n\r";
    foreach ((array) $file_list as $file) {
        $num++;
        $output .= "  <p>\n\r";
        $output .= "    <input type='radio' name='variation_priceandstock[{$variation_ids}][file]' value='" . $file['file_id'] . "' id='select_variation_file{$unique_id_component}_{$num}' " . (is_numeric($file_id) && $file_id == $file['file_id'] ? "checked='checked'" : "") . " />\n\r";
        $output .= "    <label for='select_variation_file{$unique_id_component}_{$num}'>" . $file['display_filename'] . "</label>\n\r";
        $output .= "  </p>\n\r";
    }
    $output .= "</div>\n\r";
    $output .= "</div>\n\r";
    return $output;
}
Example #3
0
function wpsc_product_files_existing()
{
    //List all product_files, with checkboxes
    $product_id = absint($_GET["product_id"]);
    $file_list = wpsc_uploaded_files();
    $args = array('post_type' => 'wpsc-product-file', 'post_parent' => $product_id, 'numberposts' => -1, 'post_status' => 'all');
    $attached_files = (array) get_posts($args);
    foreach ($attached_files as $key => $attached_file) {
        $attached_files_by_file[$attached_file->post_title] =& $attached_files[$key];
    }
    $output = "<span class='admin_product_notes select_product_note '>" . esc_html__('Choose a downloadable file for this product:', 'wpsc') . "</span><br>";
    $output .= "<form method='post' class='product_upload'>";
    $output .= '<div class="ui-widget-content multiple-select select_product_file" style="width:100%">';
    $num = 0;
    foreach ((array) $file_list as $file) {
        $num++;
        $checked_curr_file = "";
        if (isset($attached_files_by_file[$file['display_filename']])) {
            $checked_curr_file = "checked='checked'";
        }
        $output .= "<p " . ($num % 2 > 0 ? '' : "class='alt'") . " id='select_product_file_row_{$num}'>\n";
        $output .= "  <input type='checkbox' name='select_product_file[]' value='" . $file['real_filename'] . "' id='select_product_file_{$num}' " . $checked_curr_file . " />\n";
        $output .= "  <label for='select_product_file_{$num}'>" . $file['display_filename'] . "</label>\n";
        $output .= "</p>\n";
    }
    $output .= "</div>";
    $output .= "<input type='hidden' id='hidden_id' value='{$product_id}' />";
    $output .= "<input data-nonce='" . _wpsc_create_ajax_nonce('upload_product_file') . "' type='submit' name='save' name='product_files_submit' class='button-primary prdfil' value='" . esc_html__('Save Product Files', 'wpsc') . "' />";
    $output .= "</form>";
    $output .= "<div class='" . (is_numeric($product_id) ? "edit_" : "") . "select_product_handle'><div></div></div>";
    $output .= "<script type='text/javascript'>\n\r";
    $output .= "var select_min_height = " . 25 * 3 . ";\n\r";
    $output .= "var select_max_height = " . 25 * ($num + 1) . ";\n\r";
    $output .= "</script>";
    echo $output;
}
function wpsc_select_product_file($product_id = null)
{
    global $wpdb;
    //return false;
    $file_list = wpsc_uploaded_files();
    $file_id = $wpdb->get_var("SELECT `file` FROM `" . $wpdb->prefix . "product_list` WHERE `id` = '" . $product_id . "' LIMIT 1");
    $output = "<span class='admin_product_notes select_product_note '>" . TXT_WPSC_CHOOSE_DOWNLOADABLE_PRODUCT . "</span>";
    $output .= "<div class='" . (is_numeric($product_id) ? "edit_" : "") . "select_product_file'>";
    //$output .= "<div class='select_product_file'>";
    $num = 0;
    $output .= "<p " . ($num % 2 > 0 ? '' : "class='alt'") . "><input type='radio' name='select_product_file' value='.none.' id='select_product_file_{$num}' " . (!is_numeric($file_id) || $file_id < 1 ? "checked='checked'" : "") . " /><label for='select_product_file_{$num}'>" . TXT_WPSC_SHOW_NO_PRODUCT . "</label></p>";
    //$output .= "<pre>".print_r($file_list,true)."</pre>";
    foreach ((array) $file_list as $file) {
        $num++;
        $output .= "<p " . ($num % 2 > 0 ? '' : "class='alt'") . "><input type='radio' name='select_product_file' value='" . $file['real_filename'] . "' id='select_product_file_{$num}' " . (is_numeric($file_id) && $file_id == $file['file_id'] ? "checked='checked'" : "") . " /><label for='select_product_file_{$num}'>" . $file['display_filename'] . "</label></p>";
    }
    $output .= "</div>";
    $output .= "<div class='" . (is_numeric($product_id) ? "edit_" : "") . "select_product_handle'><div></div></div>";
    $output .= "<script type='text/javascript'>\n\r";
    $output .= "var select_min_height = " . 25 * 3 . ";\n\r";
    $output .= "var select_max_height = " . 25 * ($num + 1) . ";\n\r";
    $output .= "</script>";
    return $output;
}