WordPress.org

Plugin Directory

Changeset 568545


Ignore:
Timestamp:
07/07/12 04:04:53 (22 months ago)
Author:
wpsmith
Message:

WordPress Coding standards. Updated to use shopp_loaded hook.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • shopp-importer/trunk/index.php

    r562733 r568545  
    11<?php 
    2 /** 
    3     Plugin Name: Shopp Importer 
    4     Plugin URI: http://wpsmith.net 
    5     Version: 0.9.7 
    6     Description: Shopp Product Importer Plugin provides a mechanisim to import Products from a specifically formatted CSV file into the shopp product database. 
    7     Author: wpsmith, intimidate 
    8     Author URI: http://wpsmith.net 
    9     Copyright: Copyright \xA9 2010 WPSmith     
    10 **/ 
    11  
    12 //Get helper classes       
    13 define('SHOPP_IMPORTER_DEBUG',false); 
    14  
    15 include_once("spi_admin.php"); 
    16 include_once("spi_data.php"); 
    17 include_once("spi_db.php"); 
    18 include_once("spi_files.php"); 
    19 include_once("spi_images.php"); 
    20 include_once("spi_model.php"); 
    21  
    22 $spi = new shopp_product_importer(); 
     2/* 
     3Plugin Name: Shopp Importer 
     4Plugin URI: http://wpsmith.net/ 
     5Description: Shopp Product Importer Plugin provides a mechanisim to import Products from a specifically formatted CSV file into the shopp product database. 
     6Version: 0.9.8 
     7Author: Travis Smith, Tim Eijnden 
     8Author URI: http://www.wpsmith.net/ 
     9License: GPLv2 
     10 
     11    Copyright 2012  Travis Smith  (email : t@wpsmith.net) 
     12 
     13    This program is free software; you can redistribute it and/or modify 
     14    it under the terms of the GNU General Public License, version 2, as  
     15    published by the Free Software Foundation. 
     16 
     17    This program is distributed in the hope that it will be useful, 
     18    but WITHOUT ANY WARRANTY; without even the implied warranty of 
     19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     20    GNU General Public License for more details. 
     21 
     22    You should have received a copy of the GNU General Public License 
     23    along with this program; if not, write to the Free Software 
     24    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
     25*/ 
     26 
     27add_action( 'shopp_loaded', 'shopp_importer_init' ); 
     28 
     29function shopp_importer_init() { 
     30    //Get helper classes       
     31    define( 'SHOPP_IMPORTER_DEBUG', false ); 
     32 
     33    include_once( 'spi_admin.php' ); 
     34    include_once( 'spi_data.php' ); 
     35    include_once( 'spi_db.php' ); 
     36    include_once( 'spi_files.php' ); 
     37    include_once( 'spi_images.php' ); 
     38    include_once( 'spi_model.php' ); 
     39 
     40    $spi = new shopp_product_importer(); 
     41} 
    2342 
    2443class shopp_product_importer { 
     
    5978    );   
    6079     
    61     function spi_errors($errno, $errstr,$errfile, $errline) 
     80    function spi_errors( $errno, $errstr, $errfile, $errline ) 
    6281    { 
    63         if (dirname($errfile)==dirname(__FILE__)) { 
    64             error_log("Error: [$errno] $errstr in $errfile on $errline ",0); 
     82        if ( dirname( $errfile ) == dirname( __FILE__ ) ) { 
     83            error_log( "Error: [$errno] $errstr in $errfile on $errline ", 0 ); 
    6584        } 
    6685    }        
    6786     
    6887    function report_errors() { 
    69         if (isset($_SESSION['spi_errors'])) {  
     88        if ( isset( $_SESSION['spi_errors'] ) ) {  
    7089            echo $_SESSION['spi_errors']; 
    71             unset($_SESSION['spi_errors']); 
     90            unset( $_SESSION['spi_errors'] ); 
    7291        }    
    7392    } 
     
    7594    function __construct() { 
    7695        global $Shopp; 
    77         if (class_exists('Shopp')) { 
     96        if ( class_exists( 'Shopp' ) ) { 
    7897            $this->Shopp = $Shopp; 
    7998            $this->set_paths(); 
    80             add_action('admin_menu', array(&$this, 'on_admin_menu')); 
    81             add_action('wp_ajax_upload_spi_csv_file', array(&$this, 'ajax_upload_spi_csv_file')); 
    82             add_action('wp_ajax_import_csv', array(&$this, 'ajax_import_csv')); 
    83             add_action('wp_ajax_import_products', array(&$this, 'ajax_import_products')); 
    84             add_action('wp_ajax_import_images', array(&$this, 'ajax_import_images')); 
    85             add_action('wp_ajax_next_image', array(&$this, 'ajax_next_image'));          
    86             set_error_handler(array(&$this, 'spi_errors')); 
     99            add_action( 'admin_menu', array( &$this, 'on_admin_menu' ) ); 
     100            add_action( 'wp_ajax_upload_spi_csv_file', array( &$this, 'ajax_upload_spi_csv_file' ) ); 
     101            add_action( 'wp_ajax_import_csv', array( &$this, 'ajax_import_csv' ) ); 
     102            add_action( 'wp_ajax_import_products', array( &$this, 'ajax_import_products' ) ); 
     103            add_action( 'wp_ajax_import_images', array( &$this, 'ajax_import_images' ) ); 
     104            add_action( 'wp_ajax_next_image', array( &$this, 'ajax_next_image' ) );          
     105            set_error_handler( array( &$this, 'spi_errors' ) ); 
    87106            $this->ajax_load_file(); 
    88107        }    
     
    90109 
    91110    function set_paths() { 
    92         $this->basepath = WP_PLUGIN_DIR; 
    93         $this->path = WP_PLUGIN_DIR . '/' . array_pop(explode('/',dirname(__FILE__))); 
    94         $this->directory = basename($this->path);  
    95         $this->csv_get_path = WP_CONTENT_DIR.'/csvs/'; 
    96         $this->html_get_path = WP_CONTENT_DIR.'/product_htmls/'; 
     111        $this->basepath       = WP_PLUGIN_DIR; 
     112        $this->path           = WP_PLUGIN_DIR . '/' . array_pop(explode( '/', dirname( __FILE__ ) ) ); 
     113        $this->directory      = basename( $this->path );  
     114        $this->csv_get_path   = WP_CONTENT_DIR.'/csvs/'; 
     115        $this->html_get_path  = WP_CONTENT_DIR.'/product_htmls/'; 
    97116        $this->image_put_path = WP_CONTENT_DIR.'/products/'; 
    98117    }    
    99118     
    100     function on_admin_menu($args) {  
    101         if (SHOPP_VERSION < '1.1') { 
    102             $page = add_submenu_page($this->Shopp->Flow->Admin->default,__('Importer','Shopp'), __('Importer','Shopp'), SHOPP_USERLEVEL, "shopp-importer", array(&$this,'shopp_importer_settings_page')); 
    103             $spi_admin = new spi_admin($this); 
     119    function on_admin_menu( $args ) {    
     120        if ( SHOPP_VERSION < '1.1' ) { 
     121            $page = add_submenu_page( $this->Shopp->Flow->Admin->default, __( 'Importer', 'Shopp' ), __( 'Importer', 'Shopp' ), SHOPP_USERLEVEL, "shopp-importer", array( &$this, 'shopp_importer_settings_page' ) ); 
     122            $spi_admin = new spi_admin( $this ); 
    104123            $help_content = $spi_admin->set_help(); 
    105             unset($spi_admin); 
    106             add_contextual_help($page,$help_content); 
    107         } 
    108         if (SHOPP_VERSION >= '1.1') { 
     124            unset( $spi_admin ); 
     125            add_contextual_help( $page, $help_content ); 
     126        } 
     127        if ( SHOPP_VERSION >= '1.1' ) { 
    109128            global $wp_importers; 
    110             register_importer("shopp_product_importer2","CSV Importer for Shopp 1.21","CSV Import for Shopp 1.21",array(&$this,'shopp_importer_settings_page')); 
    111             //exit("The Importers: ".print_r($wp_importers,true)); 
     129            register_importer( "shopp_product_importer2", "CSV Importer for Shopp 1.21", "CSV Import for Shopp 1.21", array( &$this,'shopp_importer_settings_page' ) ); 
     130            //exit("The Importers: ".print_r($wp_importers,true) ); 
    112131        } 
    113132    }    
     
    115134    function shopp_importer_settings_page () { 
    116135        global $wpdb; 
    117         if (!empty($_POST['save'])) { 
    118             check_admin_referer('shopp-importer'); 
    119             if (SHOPP_VERSION < '1.1') { 
     136        if ( ! empty( $_POST['save'] ) ) { 
     137            check_admin_referer( 'shopp-importer' ); 
     138            if ( SHOPP_VERSION < '1.1' ) { 
    120139                $this->Shopp->Flow->settings_save(); 
    121140            } else { 
    122141                $this->Shopp->Settings->saveform(); 
    123142            } 
    124             $updated = __('Importer settings saved.'); 
     143            $updated = __( 'Importer settings saved.', 'spi' ); 
    125144        }        
    126         if (!empty($_POST['perform_import'])) { 
    127             check_admin_referer('shopp-importer'); 
    128             set_time_limit(86400); 
     145        if ( ! empty( $_POST['perform_import'] ) ) { 
     146            check_admin_referer( 'shopp-importer' ); 
     147            set_time_limit( 86400 ); 
    129148            $this->map_columns_from_saved_options(); 
    130149            $this->ajax_load_file(); 
     
    132151            global $importing_now; 
    133152            $importing_now = "perform_import"; 
    134             $updated = __('Running Importer - Please Wait.....'); 
    135         } 
    136         include("{$this->basepath}/{$this->directory}/settings.php"); 
     153            $updated       = __( 'Running Importer - Please Wait.....', 'spi' ); 
     154        } 
     155        include( "{$this->basepath}/{$this->directory}/settings.php" ); 
    137156    }    
    138157     
    139158    function trunctate_all_prior_to_import() { 
    140159        global $wpdb; 
    141         if ($this->Shopp->Settings->get('catskin_importer_empty_first') == 'yes') { 
    142             $query = "  TRUNCATE TABLE `{$wpdb->prefix}shopp_price`;"; 
     160        if ( $this->Shopp->Settings->get( 'catskin_importer_empty_first' ) == 'yes' ) { 
     161            $query  = " TRUNCATE TABLE `{$wpdb->prefix}shopp_price`;"; 
    143162            $result = $wpdb->query($query); 
    144             $query = "  DELETE FROM `{$wpdb->prefix}posts` WHERE post_type = 'shopp_product'"; 
     163            $query  = " DELETE FROM `{$wpdb->prefix}posts` WHERE post_type = 'shopp_product'"; 
    145164            $result = $wpdb->query($query); 
    146             $query = "  DELETE FROM `{$wpdb->prefix}shopp_meta` WHERE type='spec' OR type='image';"; 
     165            $query  = " DELETE FROM `{$wpdb->prefix}shopp_meta` WHERE type='spec' OR type='image';"; 
    147166            $result = $wpdb->query($query);     
    148             $query = "DELETE FROM `{$wpdb->prefix}terms` WHERE term_id in (SELECT term_id FROM `{$wpdb->prefix}term_taxonomy` WHERE taxonomy = 'shopp_category') ";  
     167            $query  = "DELETE FROM `{$wpdb->prefix}terms` WHERE term_id in (SELECT term_id FROM `{$wpdb->prefix}term_taxonomy` WHERE taxonomy = 'shopp_category') ";  
    149168            $result = $wpdb->query($query);     
    150             $query = "DELETE FROM `{$wpdb->prefix}term_taxonomy` WHERE taxonomy = 'shopp_category'";  
     169            $query  = "DELETE FROM `{$wpdb->prefix}term_taxonomy` WHERE taxonomy = 'shopp_category'";  
    151170            $result = $wpdb->query($query); 
    152171        }        
     
    155174    function clean_shopp_settings() { 
    156175        global $wpdb; 
    157         $query = "  DELETE FROM `{$wpdb->prefix}shopp_setting` WHERE `name` LIKE 'catskin%';"; 
    158         $result = $wpdb->query($query);  
    159          
    160         if (!mysql_error()) exit(" Shopp settings cleaned"); else exit(mysql_error()); 
     176        $query  = " DELETE FROM `{$wpdb->prefix}shopp_setting` WHERE `name` LIKE 'catskin%';"; 
     177        $result = $wpdb->query( $query );    
     178         
     179        if ( ! mysql_error() ) exit( "Shopp settings cleaned" ); else exit( mysql_error() ); 
    161180        return false; 
    162181    }    
     
    164183    function trunctate_prices_for_product($product_id) { 
    165184        global $wpdb; 
    166         if ($this->Shopp->Settings->get('catskin_importer_clear_prices') == 'yes') { 
     185        if ( $this->Shopp->Settings->get( 'catskin_importer_clear_prices' ) == 'yes' ) { 
    167186            $query = " DELETE FROM wp_shopp_price WHERE product='{$product_id}'"; 
    168             $result = $wpdb->get_var($query); 
     187            $result = $wpdb->get_var( $query ); 
    169188        }        
    170189    }    
     
    173192    { 
    174193        // Quote if not a number or a numeric string 
    175         if (!is_numeric($value)) { 
     194        if (!is_numeric($value) ) { 
    176195            $value = "'" . mysql_real_escape_string($value) . "'"; 
    177196        } 
     
    182201        global $wpdb;                
    183202         
    184      
    185203        //echo '<pre>'.print_r($this->column_map,1).'</pre>'; 
    186204        $has_headers = $this->Shopp->Settings->get('catskin_importer_has_headers'); 
    187205        $this->ajax_load_file(); 
    188         $query = "  DROP TABLE IF EXISTS {$wpdb->prefix}shopp_importer; "; 
     206        $query  = "  DROP TABLE IF EXISTS {$wpdb->prefix}shopp_importer; "; 
    189207        $result = $wpdb->query($query); 
    190         $query = "  CREATE TABLE {$wpdb->prefix}shopp_importer ( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), product_id TEXT NULL, price_options TEXT NULL, price_optionkey TEXT NULL, price_label TEXT NULL, processing_status INT NULL DEFAULT 0 "; 
    191             foreach ($this->column_map as $key=>$value)  
     208        $query  = "  CREATE TABLE {$wpdb->prefix}shopp_importer ( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), product_id TEXT NULL, price_options TEXT NULL, price_optionkey TEXT NULL, price_label TEXT NULL, processing_status INT NULL DEFAULT 0 "; 
     209            foreach ( $this->column_map as $key => $value )  
    192210            {  
    193211                $query .= ", spi_" . $key . " TEXT NULL";  
     
    196214        $result = $wpdb->query($query); 
    197215         
    198         $query = " INSERT INTO {$wpdb->prefix}shopp_importer ("; 
     216        $query        = " INSERT INTO {$wpdb->prefix}shopp_importer ("; 
    199217        $column_index = 0; 
    200         foreach ($this->column_map as $key=>$value) {  
    201             if ($column_index > 0) $query .= ", "; 
     218        foreach ( $this->column_map as $key => $value ) {  
     219            if ( $column_index > 0 ) $query .= ", "; 
    202220            $query .= " spi_" . $key . " "; 
    203221            $column_index ++;  
    204222        } 
    205223        $query .= ") VALUES "; 
    206         if ($has_headers) array_shift($this->examine_data); 
     224        if ( $has_headers ) array_shift( $this->examine_data ); 
    207225        $row_index = 0; 
    208         foreach ($this->examine_data as $row) { 
     226        foreach ( $this->examine_data as $row ) { 
    209227            $field_index = 0; 
    210             if ($row_index > 0) $query .= ","; 
     228            if ( $row_index > 0 ) $query .= ","; 
    211229            $query .= "("; 
    212             foreach ($this->column_map as $key=>$value) { 
    213                 if ($field_index > 0) $query .= ", "; 
    214                 $query .= $this->quote_smart($row[$value]);  
     230            foreach ( $this->column_map as $key => $value ) { 
     231                if ( $field_index > 0 ) $query .= ", "; 
     232                $query .= $this->quote_smart( $row[$value] );  
    215233                $field_index ++;  
    216234            }            
     
    221239        $query .= "; ";    
    222240        //echo $query; 
    223         $result = $wpdb->query($query); 
     241        $result = $wpdb->query( $query ); 
    224242        $this->map_columns_from_saved_options(); 
    225         $ajax_result = json_encode($result); 
     243        $ajax_result = json_encode( $result ); 
    226244        echo "<h2 style='border-bottom:1px dotted #333;'>CSV imported to database table {$wpdb->prefix}shopp_importer</h2>"; 
    227245        exit(); 
     
    232250          
    233251        $first_id_sql = "SELECT max(id) FROM {$wpdb->prefix}posts LIMIT 1";  
    234         $first_id = $wpdb->get_var($wpdb->prepare($first_id_sql)); 
    235         $model = new spi_model($this); 
     252        $first_id     = $wpdb->get_var($wpdb->prepare($first_id_sql) ); 
     253        $model        = new spi_model($this); 
    236254        $model_result = $model->execute(); 
    237255        echo $model->execute_mega_query(); 
    238256        $this->report_errors(); 
    239         unset($model); 
     257        unset( $model ); 
    240258        exit();   
    241259         
     
    245263        global $wpdb, $Shopp; 
    246264         
    247         $model = new spi_model($this); 
     265        $model = new spi_model( $this ); 
    248266        echo $model->execute_images(); 
    249         unset($model); 
     267        unset( $model ); 
    250268        exit(); 
    251269    }    
    252270     
    253271    function ajax_next_image() { 
    254         $model = new spi_model($this); 
     272        $model = new spi_model( $this ); 
    255273        echo $model->execute_images(); 
    256274        $this->report_errors(); 
    257         unset($model);       
     275        unset( $model );         
    258276        exit(); 
    259277    }            
     
    261279    function get_next_product() { 
    262280        global $wpdb; 
    263         $query = "SELECT * FROM {$wpdb->prefix}shopp_importer ORDER BY id limit 1"; 
     281        $query  = "SELECT * FROM {$wpdb->prefix}shopp_importer ORDER BY id limit 1"; 
    264282        $result = $wpdb->get_row($query,OBJECT); 
    265283        return $result; 
    266284    } 
    267285     
    268     function get_next_set($id) { 
    269         global $wpdb; 
    270         $id = trim($id); 
    271         $query = "SELECT * FROM {$wpdb->prefix}shopp_importer WHERE spi_id = '{$id}' ORDER BY id "; 
    272         $result = $wpdb->get_results($query,OBJECT); 
     286    function get_next_set( $id ) { 
     287        global $wpdb; 
     288        $id     = trim( $id ); 
     289        $query  = "SELECT * FROM {$wpdb->prefix}shopp_importer WHERE spi_id = '{$id}' ORDER BY id "; 
     290        $result = $wpdb->get_results( $query, OBJECT ); 
    273291        return $result; 
    274292    }                                                                                        
    275293     
    276294    function ajax_upload_spi_csv_file() {    
    277         $csvs_path = realpath(dirname(dirname(dirname(__FILE__)))).'/csvs/'; 
    278         if (file_exists($csvs_path.$_POST['file_name'])) { 
    279             unlink($csvs_path.$_POST['file_name']); 
     295        $csvs_path = realpath( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/csvs/'; 
     296        if ( file_exists( $csvs_path . $_POST['file_name'] ) ) { 
     297            unlink( $csvs_path . $_POST['file_name'] ); 
    280298        }  
    281299        $file_name = $_POST['file_name']; 
    282         $path_info = pathinfo($_FILES[$upload_name]['name']); 
    283         if (is_uploaded_file($_FILES['csvupload']['tmp_name'])) { 
    284             if (!file_exists($csvs_path)) mkdir($csvs_path); 
    285             chmod($csvs_path,0755); 
    286             $uploaded_file = file_get_contents($_FILES['csvupload']['tmp_name']); 
    287             $handle = fopen($csvs_path.$file_name, "w"); 
    288             fwrite($handle, $uploaded_file ); 
    289             echo "File uploaded successfully: ".$csvs_path.$file_name; 
    290             fclose($handle); 
     300        $path_info = pathinfo( $_FILES[$upload_name]['name'] ); 
     301        if ( is_uploaded_file( $_FILES['csvupload']['tmp_name'] ) ) { 
     302            if ( ! file_exists( $csvs_path ) ) mkdir( $csvs_path ); 
     303            chmod( $csvs_path, 0755 ); 
     304            $uploaded_file = file_get_contents( $_FILES['csvupload']['tmp_name'] ); 
     305            $handle = fopen( $csvs_path . $file_name, "w" ); 
     306            fwrite( $handle, $uploaded_file ); 
     307            echo "File uploaded successfully: " . $csvs_path.$file_name; 
     308            fclose( $handle ); 
    291309             
    292310        } else { 
     
    298316     
    299317    function ajax_load_file() { 
    300         $spi_files = new spi_files($this); 
    301         $filename = $this->Shopp->Settings->get('catskin_importer_file'); 
    302         if (strlen($filename) != 0 && $filename != 'no-file-selected') { 
    303             $this->examine_data = $spi_files->load_examine_csv($filename,true);      
     318        $spi_files = new spi_files( $this ); 
     319        $filename  = $this->Shopp->Settings->get( 'catskin_importer_file' ); 
     320        if ( strlen( $filename ) != 0 && $filename != 'no-file-selected' ) { 
     321            $this->examine_data = $spi_files->load_examine_csv( $filename, true );       
    304322            $this->map_columns_from_saved_options(); 
    305323            $start_at = 1; 
    306             $has_headers = $this->Shopp->Settings->get('catskin_importer_has_headers'); 
    307             $has_headers = ($has_headers == 'yes'); 
    308             $rows = $this->Shopp->Settings->get('catskin_importer_row_count'); 
    309             if (strlen($filename) > 0 && strlen($rows) > 0 && strlen($has_headers) > 0) {  
    310                 $data = $spi_files->load_csv($filename,$start_at,$rows,$has_headers); 
     324            $has_headers = $this->Shopp->Settings->get( 'catskin_importer_has_headers' ); 
     325            $has_headers = ( $has_headers == 'yes' ); 
     326            $rows = $this->Shopp->Settings->get( 'catskin_importer_row_count' ); 
     327            if ( strlen( $filename ) > 0 && strlen( $rows ) > 0 && strlen( $has_headers ) > 0) {  
     328                $data = $spi_files->load_csv( $filename, $start_at, $rows, $has_headers ); 
    311329                $_SESSION['spi_product_importer_data'] = $data; 
    312                 $spi_data = new spi_data($this); 
     330                $spi_data = new spi_data( $this ); 
    313331                $spi_data->map_product_ids(); 
    314                 unset($spi_data); 
     332                unset( $spi_data ); 
    315333                 
    316334            } else { 
     
    318336            } 
    319337        } 
    320         unset($spi_files); 
     338        unset( $spi_files ); 
    321339        return $data;    
    322340    } 
     
    324342    function map_columns_from_saved_options() { 
    325343        //update mappings 
    326         $this->column_map = null; 
     344        $this->column_map    = null; 
    327345        $this->variation_map = null; 
    328         $this->tag_map = null; 
    329         $this->category_map = null; 
    330         $this->image_map = null; 
    331         $tag_counter = 0; 
    332         $category_counter = 0; 
    333         $variation_counter = 0; 
    334         $image_counter = 0;   
    335         $spec_counter = 0;  
    336         $addon_counter = 0; 
    337         $saved_column_map = $this->Shopp->Settings->get('catskin_importer_column_map'); 
    338         for ($col_index = 0; $col_index < $this->Shopp->Settings->get('catskin_importer_column_count'); $col_index++) {      
    339             if ($saved_column_map[$col_index]["type"] == 'tag') { 
    340                 $tag_counter++; 
    341                 $this->column_map[$col_index] = $saved_column_map[$col_index]["type"].$tag_counter; 
    342                 $this->tag_map[] = $saved_column_map[$col_index]["type"].$tag_counter; 
    343              }else if ($saved_column_map[$col_index]["type"] == 'spec') {  
    344                 //echo $saved_column_map[$col_index]["type"].'<br/>'; 
    345                 $spec_counter++; 
    346                 $this->column_map[$col_index] = $saved_column_map[$col_index]["type"].$spec_counter; 
    347                 $this->spec_map[] = $saved_column_map[$col_index]["type"].$spec_counter;    
    348             } else if (strpos($saved_column_map[$col_index]["type"],'variation') !== false) { 
    349                 $variation_counter++; 
    350                 $this->column_map[$col_index] = $saved_column_map[$col_index]["type"].$variation_counter; 
    351                 $this->variation_map[] = $saved_column_map[$col_index]["type"].$variation_counter; 
    352             } else if (strpos($saved_column_map[$col_index]["type"],'addon') !== false) { 
    353                 $addon_counter++; 
    354                 $this->column_map[$col_index] = $saved_column_map[$col_index]["type"].$addon_counter; 
    355                 $this->variation_map[] = $saved_column_map[$col_index]["type"].$addon_counter;               
    356             } else if ($saved_column_map[$col_index]["type"] == 'category') { 
    357                 $category_counter++; 
    358                 $this->column_map[$col_index] = $saved_column_map[$col_index]["type"].$category_counter; 
    359                 $this->category_map[] = $saved_column_map[$col_index]["type"].$category_counter;     
    360             } else if ($saved_column_map[$col_index]["type"] == 'image') { 
    361                 $image_counter++; 
    362                 $this->column_map[$col_index] = $saved_column_map[$col_index]["type"].$image_counter; 
    363                 $this->image_map[] = $saved_column_map[$col_index]["type"].$image_counter;   
    364             } else if ($saved_column_map[$col_index]["type"] != '') {                        
    365                 $this->column_map[$col_index] = $saved_column_map[$col_index]["type"]; 
     346        $this->tag_map       = null; 
     347        $this->category_map  = null; 
     348        $this->image_map     = null; 
     349        $tag_counter         = 0; 
     350        $category_counter    = 0; 
     351        $variation_counter   = 0; 
     352        $image_counter       = 0;   
     353        $spec_counter        = 0;  
     354        $addon_counter       = 0; 
     355        $saved_column_map = $this->Shopp->Settings->get( 'catskin_importer_column_map' ); 
     356        for ( $col_index = 0; $col_index < $this->Shopp->Settings->get( 'catskin_importer_column_count' ); $col_index++ ) { 
     357            switch ( $saved_column_map[$col_index]['type'] ) { 
     358                case 'tag': 
     359                    $tag_counter++; 
     360                    $this->column_map[$col_index] = $saved_column_map[$col_index]['type'] . $tag_counter; 
     361                    $this->tag_map[]              = $saved_column_map[$col_index]['type'] . $tag_counter; 
     362                    break; 
     363                case 'spec': 
     364                    //echo $saved_column_map[$col_index]['type'].'<br/>'; 
     365                    $spec_counter++; 
     366                    $this->column_map[$col_index] = $saved_column_map[$col_index]['type'] . $spec_counter; 
     367                    $this->spec_map[]             = $saved_column_map[$col_index]['type'] . $spec_counter;    
     368                    break; 
     369                case 'category': 
     370                    $category_counter++; 
     371                    $this->column_map[$col_index] = $saved_column_map[$col_index]['type'] . $category_counter; 
     372                    $this->category_map[]         = $saved_column_map[$col_index]['type'] . $category_counter;   
     373                    break; 
     374                case 'image': 
     375                    $image_counter++; 
     376                    $this->column_map[$col_index] = $saved_column_map[$col_index]['type'] . $image_counter; 
     377                    $this->image_map[]            = $saved_column_map[$col_index]['type'] . $image_counter;  
     378                    break; 
     379                default: 
     380                    if ( strpos( $saved_column_map[$col_index]['type'], 'variation' ) !== false) { 
     381                        $variation_counter++; 
     382                        $this->column_map[$col_index] = $saved_column_map[$col_index]['type'] . $variation_counter; 
     383                        $this->variation_map[]        = $saved_column_map[$col_index]['type'] . $variation_counter; 
     384                    } elseif ( strpos( $saved_column_map[$col_index]['type'], 'addon' ) !== false ) { 
     385                        $addon_counter++; 
     386                        $this->column_map[$col_index] = $saved_column_map[$col_index]['type'] . $addon_counter; 
     387                        $this->variation_map[]        = $saved_column_map[$col_index]['type'] . $addon_counter;              
     388                    } else if ( '' != $saved_column_map[$col_index]['type'] ) {                      
     389                        $this->column_map[$col_index] = $saved_column_map[$col_index]['type']; 
     390                    } 
     391                    break; 
    366392            } 
    367         } 
    368         $this->column_map = array_flip($this->column_map);           
     393                         
     394             
     395        } 
     396        $this->column_map = array_flip( $this->column_map );             
    369397    }    
    370398} 
    371 ?> 
Note: See TracChangeset for help on using the changeset viewer.