" . __( 'Please select', 'wpsc' ) . "";
$country_data = $wpdb->get_results( "SELECT * FROM `" . WPSC_TABLE_CURRENCY_LIST . "` ORDER BY `country` ASC", ARRAY_A );
foreach ( $country_data as $country ) {
$selected = '';
if ( $selected_country == $country['isocode'] )
$selected = "selected='selected'";
$output .= "";
}
return $output;
}
function nzshpcrt_region_list( $selected_country = null, $selected_region = null ) {
global $wpdb;
if ( $selected_region == null )
$selected_region = get_option( 'base_region' );
$output = "";
$region_list = $wpdb->get_results( "SELECT `" . WPSC_TABLE_REGION_TAX . "`.* FROM `" . WPSC_TABLE_REGION_TAX . "`, `" . WPSC_TABLE_CURRENCY_LIST . "` WHERE `" . WPSC_TABLE_CURRENCY_LIST . "`.`isocode` IN('" . $selected_country . "') AND `" . WPSC_TABLE_CURRENCY_LIST . "`.`id` = `" . WPSC_TABLE_REGION_TAX . "`.`country_id`", ARRAY_A );
if ( $region_list != null ) {
$output .= "";
foreach ( $region_list as $region ) {
if ( $selected_region == $region['id'] ) {
$selected = "selected='selected'";
} else {
$selected = "";
}
$output .= "\r\n";
}
} else {
$output .= "\r\n";
}
return $output;
}
function nzshpcrt_form_field_list( $selected_field = null ) {
global $wpdb;
$output = "";
$form_sql = "SELECT * FROM `" . WPSC_TABLE_CHECKOUT_FORMS . "` WHERE `active` = '1';";
$form_data = $wpdb->get_results( $form_sql, ARRAY_A );
foreach ( (array)$form_data as $form ) {
$selected = '';
if ( $selected_field == $form['id'] ) {
$selected = "selected='selected'";
}
$output .= "";
}
return $output;
}
function wpsc_parent_category_list( $taxonomies, $args, $parent, $current_term_id ) {
$myterms = get_terms( $taxonomies, $args );
$output = "";
return $output;
}
/*
* Displays the category forms for adding and editing products
* Recurses to generate the branched view for subcategories
*/
function wpsc_category_options( $group_id, $this_category = null, $category_id = null, $iteration = 0, $selected_id = null ) {
global $wpdb;
$siteurl = get_option( 'siteurl' );
$selected_term = get_term($selected_id,'wpsc_product_category');
$values = get_terms( 'wpsc_product_category', 'hide_empty=0&parent=' . $group_id );
$selected = "";
$output = "";
foreach ( (array)$values as $option ) {
if ( $option->term_id != $this_category ) {
if ( isset($selected_term->parent) && $selected_term->parent == $option->term_id ) {
$selected = "selected='selected'";
}
$output .= "\r\n";
$output .= wpsc_category_options( $option->term_id, $this_category, $option->term_id, $iteration + 1, $selected_id );
$selected = "";
}
}
return $output;
}
/*
* TODO: If the uploads directory of wordpress doesn't have the right permissions there
* is a memory exhausting problem in this function.
*/
function wpsc_uploaded_files() {
global $wpdb, $wpsc_uploaded_file_cache;
$dir = @opendir( WPSC_FILE_DIR );
$num = 0;
$dirlist = array( );
if ( count( $wpsc_uploaded_file_cache ) > 0 ) {
$dirlist = $wpsc_uploaded_file_cache;
} elseif ( $dir ) {
while ( ($file = @readdir( $dir )) !== false ) {
//filter out the dots, macintosh hidden files and any backup files
if ( ($file != "..") && ($file != ".") && ($file != "product_files") && ($file != "preview_clips") && !stristr( $file, "~" ) && !( strpos( $file, "." ) === 0 ) && !strpos( $file, ".old" ) ) {
$file_data = null;
$args = array(
'post_type' => 'wpsc-product-file',
'post_name' => $file,
'numberposts' => 1,
'post_status' => 'all'
);
//// @TODO broken, does not select by post_name, need to loop at wordpress API to fix.
//$file_data = (array)get_posts($args);
if ( $file_data[0] != null ) {
$dirlist[$num]['display_filename'] = $file_data[0]->post_title;
$dirlist[$num]['file_id'] = $file_data[0]->ID;
} else {
$dirlist[$num]['display_filename'] = $file;
$dirlist[$num]['file_id'] = null;
}
$dirlist[$num]['real_filename'] = $file;
$num++;
}
}
if ( count( $dirlist ) > 0 ) {
$wpsc_uploaded_file_cache = $dirlist;
}
}
$dirlist = apply_filters( 'wpsc_downloadable_file_list', $dirlist );
return $dirlist;
}
// JS - For 3.8, function re-worked to only show files attached to product, separate thickbox with all products, to be associated with product.
function wpsc_select_product_file( $product_id = null ) {
global $wpdb;
$product_id = absint( $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 );
$output = "" . __( 'File(s) attached: ', 'wpsc' ) . "
";
$output .= "
\r\n"; $output .= " \r\n"; $output .= " \r\n"; $output .= "
\r\n"; foreach ( (array)$file_list as $file ) { $num++; $output .= "\r\n"; $output .= " \r\n"; $output .= " \r\n"; $output .= "
\r\n"; } $output .= "