コード例 #1
0
    echo $cell;
    ?>
</code>
					</th>
					<td class="vertical-align-middle text-align-center column-equals"><strong>=</strong></td>
					<td class="vertical-align-middle">
						<select name="value_name[]">
							<option></option>
	<?php 
    foreach ($import->options as $option) {
        ?>
							<option value="<?php 
        echo $option['name'];
        ?>
"<?php 
        selected(woo_pi_search_column($option, woo_pi_format_column($cell)), woo_pi_format_column($cell));
        if (isset($option['disabled'])) {
            disabled($option['disabled'], 1);
        }
        ?>
><?php 
        echo $option['label'];
        ?>
</option>
	<?php 
    }
    ?>
						</select>
					</td>
					<td class="vertical-align-middle">
						<code><?php 
コード例 #2
0
ファイル: functions.php プロジェクト: GarryVeles/Artibaltika
function woo_pi_search_column($option = array(), $cell = '')
{
    $column = woo_pi_format_column($option['name']);
    // Check if the alias key exists
    if (isset($option['alias'])) {
        // Check if the cell name is within the alias list
        $key = array_search($cell, $option['alias']);
        if ($key !== false) {
            $column = $option['alias'][$key];
        }
    }
    return $column;
}
コード例 #3
0
 function woo_pi_html_page()
 {
     global $import;
     $action = woo_get_action();
     $title = __('Product Importer', 'woo_pi');
     if (in_array($action, array('upload', 'save')) && !$import->cancel_import) {
         if ($file = woo_pi_get_option('csv')) {
             $title .= ': <em>' . basename($file) . '</em>';
         }
     }
     $troubleshooting_url = 'http://www.visser.com.au/woocommerce/documentation/plugins/product-importer-deluxe/usage/';
     $woo_pd_url = 'http://www.visser.com.au/woocommerce/plugins/product-importer-deluxe/';
     $woo_pd_link = sprintf('<a href="%s" target="_blank">' . __('Product Importer Deluxe', 'woo_pi') . '</a>', $woo_pd_url);
     woo_pi_template_header($title);
     woo_pi_support_donate();
     woo_pi_upload_directories();
     switch ($action) {
         case 'upload':
             if (isset($import->file)) {
                 $file = $import->file;
             } else {
                 $file = array('size' => 0);
             }
             /*
             				if( $file['size'] == 0 ) {
             					$message = __( '', 'woo_pi' );
             					woo_pi_admin_notice( '' );
             					$import->cancel_import = true;
             				}
             */
             // Display the opening Import tab if the import fails
             if ($import->cancel_import) {
                 woo_pi_manage_form();
                 return;
             }
             $upload_dir = wp_upload_dir();
             if ($file) {
                 woo_pi_prepare_data();
                 $i = 0;
                 $products = woo_pi_return_product_count();
                 // Override the default import method if no Products exist
                 if (!$products) {
                     $import->import_method = 'new';
                 }
                 $import->options = woo_pi_product_fields();
                 $import->options_size = count($import->options);
                 $first_row = array();
                 $second_row = array();
                 if (isset($import->lines)) {
                     // Detect character encoding and compare to selected file encoding
                     $auto_encoding = mb_detect_encoding($import->raw);
                     if ($auto_encoding !== false) {
                         if (strtolower($auto_encoding) != strtolower($import->encoding)) {
                             woo_pi_update_option('encoding', $auto_encoding);
                             $message = sprintf(__('It seems the character encoding provided under General Settings on the Settings tab - <code>%s</code> - didn\'t match this import file so we automatically detected the character encoding for you to <code>%s</code>.', 'woo_pi'), $import->encoding, $auto_encoding);
                             // Force the message to the screen as we are post-init
                             woo_pi_admin_notice_html($message);
                         }
                     }
                     $first_row = str_getcsv($import->lines[0], $import->delimiter);
                     $import->columns = count($first_row);
                     // If we only detect a single column then the delimiter may be wrong
                     if ($import->columns == 1) {
                         $auto_delimiter = woo_pi_detect_file_delimiter((string) $first_row[0]);
                         if ($import->delimiter != $auto_delimiter) {
                             $import->delimiter = $auto_delimiter;
                             $first_row = str_getcsv($import->lines[0], $import->delimiter);
                             $import->columns = count($first_row);
                             // If the column count is unchanged then the CSV either has only a single column (which won't work) or we've failed our job
                             $priority = 'updated';
                             if ($import->columns > 1) {
                                 $message = sprintf(__('It seems the field delimiter provided under Import Options - <code>%s</code> - didn\'t match this CSV so we automatically detected the CSV delimiter for you to <code>%s</code>.', 'woo_pi'), woo_pi_get_option('delimiter', ','), $auto_delimiter);
                                 woo_pi_update_option('delimiter', $import->delimiter);
                             } else {
                                 $priority = 'error';
                                 $message = __('It seems either this CSV has only a single column or we were unable to automatically detect the CSV delimiter.', 'woo_pi') . ' <a href="' . $troubleshooting_url . '" target="_blank">' . __('Need help?', 'woo_pi') . '</a>';
                             }
                             // Force the message to the screen as we are post-init
                             woo_pi_admin_notice_html($message, $priority);
                         }
                         unset($auto_delimiter);
                     }
                     $second_row = str_getcsv($import->lines[1], $import->delimiter);
                     unset($import->lines);
                 }
                 foreach ($first_row as $key => $cell) {
                     for ($k = 0; $k < $import->options_size; $k++) {
                         if (woo_pi_format_column($import->options[$k]['label']) == woo_pi_format_column($cell)) {
                             $import->skip_first = true;
                             break;
                         }
                     }
                     if (!isset($second_row[$key])) {
                         $second_row[$key] = '';
                     }
                 }
                 include_once WOO_PI_PATH . 'templates/admin/import_upload.php';
             }
             break;
         case 'save':
             // Display the opening Import tab if the import fails
             if ($import->cancel_import == false) {
                 include_once WOO_PI_PATH . 'templates/admin/import_save.php';
             } else {
                 woo_pi_manage_form();
                 return;
             }
             break;
         default:
             woo_pi_manage_form();
             break;
     }
     woo_pi_template_footer();
 }