当前位置: 首页>>代码示例>>PHP>>正文


PHP parseCSV::parse_file方法代码示例

本文整理汇总了PHP中parseCSV::parse_file方法的典型用法代码示例。如果您正苦于以下问题:PHP parseCSV::parse_file方法的具体用法?PHP parseCSV::parse_file怎么用?PHP parseCSV::parse_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在parseCSV的用法示例。


在下文中一共展示了parseCSV::parse_file方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: mass_import_handler

function mass_import_handler()
{
    global $wpdb;
    $frmarr = get_me_all_forms();
    //add_action('admin_print_scripts', 'the_admin_scripts');
    //add_action('admin_print_styles', 'the_admin_styles');
    ?>
<div style="padding: 5px 0 20px 0;"><img style="float:left;padding-right: 20px;" src="http://aryanduntley.com/wp-content/plugins/gravityforms/images/gravity-edit-icon-32.png"><h1>Import CSV</h1>
<?php 
    $version_info = GFCommon::get_version_info(false);
    if (version_compare("1.9", $version_info['version'], '<')) {
        ?>
<h2>This plugin does not support your version of Gravity Forms.</h2><p>Since I no longer support this plugin and will not make changes to compensate for the code changes in Gravity Forms 1.9+, for those of you wishing to continue using Gravity Forms and need similar functionality, you can visit <a href="https://gravityview.co/extensions/gravity-forms-entry-importer/?ref=141" target="_blank">GravityView.Co</a>.  They have developed a 1.9+ importer for gravity forms, along with many other gravity forms addons.</p>
<?php 
    }
    ?>
<h2>choose which form you wish to import into:</h2></div>
<div style="clear:both;padding-bottom:20px"><form style="float: left; padding-left: 20px;" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"><input type="hidden" name="cmd" value="_s-xclick" /><input type="hidden" name="cpp_header_image" value="http://aryanduntley.com/donatemy.png" /><input type="hidden" name="page_style" value="paypal" /><input type="hidden" name="cpp_logo_image" value="http://aryanduntley.com/donatemy.png" /><input type="hidden" name="cpp_payflow_color" value="#FAFAFA" /><input type="hidden" name="cn" value="Feel free to add any notes or comments about the plugin! Please name the plugin you are donating to so I can keep track of which are most valuable to users." /><input type="hidden" name="cpp_headerback_color" value="#F0F0F0" /><input type="hidden" name="hosted_button_id" value="ZXSGVRM9DWEUY" /><input type="image" name="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" alt="PayPal - The safer, easier way to pay online!" /><img src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" alt="" width="1" height="1" border="0" /></form></div>
    <p>
            <label style="float:left;padding-top:3px;">Select which form you would like to import into</label>
            <select id="myList" style="float:left; margin-left: 20px">
			<option value = "" disabled="true" selected="true"> Select One...</option>
				<?php 
    for ($r = 0; $r < sizeof($frmarr); $r++) {
        echo '<option value=' . $frmarr[$r]['id'] . '>' . $frmarr[$r]['title'] . '</option>';
    }
    ?>
            </select>
    </p>
	<div style="clear:both"></div>
	<div class="showstuff"></div>
	<div style="clear:both"></div>
	<div id="up_load_er"></div>
<?php 
    if (isset($_POST['mode'])) {
        if ($_POST['mode'] == "submit") {
            require 'parsecsv.lib.php';
            if (isset($_POST['formnum'])) {
                //$arr_rows = file($_FILES['csv_file']['tmp_name']);//You can use file_get_contents() to return the contents of a file as a string.
                $entry_tracking_table = $wpdb->prefix . "rg_lead";
                //This first in order to track lead_id for rest.
                $entry_standard_stuff = $wpdb->prefix . "rg_lead_meta";
                $actual_entry_data = $wpdb->prefix . "rg_lead_detail";
                //$lastnum = $wpdb->get_col( $wpdb->prepare("SELECT * FROM $entry_tracking_table",0) );
                //CHange here provided by @eselk from wordpress.org on this plugin's support page
                $lastnum = $wpdb->get_col($wpdb->prepare("SELECT * FROM {$entry_tracking_table} order by id desc limit 1", 0));
                //print ($lastnum[sizeof($lastnum)-1]);
                $formnum = $_POST['formnum'];
                //echo ("<div class='updated'>All users appear to be have been imported successfully.<br/>".$formnum."</div>");
                $ararr = apply_filters('massimport_getfields', $formnum);
                //require('../../../wp-load.php');
                $csv = new parseCSV();
                $csv->last_form_id = max($lastnum);
                //$lastnum[sizeof($lastnum)-1];
                $csv->form_using = $formnum;
                $csv->actHeaders = $ararr;
                //$retarn = $csv->auto($_FILES['csv_file']['tmp_name'], true, null, ',', '"');
                $retarn = $csv->parse_file($_FILES['csv_file']['tmp_name']);
                //stuff here;
                echo '<div class="updated" style="padding-bottom:10px;">' . $retarn . '</div>';
            } else {
                echo '<div class="updated" style="color: red;">It seems the file was not uploaded correctly.</div>';
            }
        }
    }
}
开发者ID:timk85,项目名称:DIT,代码行数:66,代码来源:gravity-forms-mass-import.php

示例2: import

 function import($data_type, $formFields)
 {
     extract($formFields);
     //If you uploaded a file via browser, use that otherwise use whatever url was passed
     $file = $formFields['source'];
     $csv = new parseCSV($file);
     $csv->auto();
     $this->logger->debug("CSVImport: " . print_r($formFields, 1));
     if (isset($limit) && is_array($limit) && is_numeric($limit['x'])) {
         $this->logger->debug("Limit Range had been defined: {$limit['x']} - {$limit['y']}");
         $dataSet = array_slice((array) $csv->parse_file(), $limit['x'], $limit['y']);
     } elseif (is_numeric($limit)) {
         $this->logger->debug("Limit, return row {$limit}");
         $dataSet = array_slice((array) $csv->parse_file(), $limit, 1);
     } else {
         $this->logger->debug("No Limit set, return all");
         $dataSet = (array) $csv->parse_file();
     }
     $this->logger->debug('CSVImport::Importing:' . print_r($dataSet, 1));
     $this->runDataTypeImport($data_type, $dataSet);
 }
开发者ID:pankajsinghjarial,项目名称:SYLC,代码行数:21,代码来源:csvJobs.class.php


注:本文中的parseCSV::parse_file方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。