本文整理汇总了PHP中PMXI_Plugin::is_csv方法的典型用法代码示例。如果您正苦于以下问题:PHP PMXI_Plugin::is_csv方法的具体用法?PHP PMXI_Plugin::is_csv怎么用?PHP PMXI_Plugin::is_csv使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMXI_Plugin
的用法示例。
在下文中一共展示了PMXI_Plugin::is_csv方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toXML
function toXML($fixBrokenSymbols = false)
{
$c = 0;
$d = "" != $this->delimiter ? $this->delimiter : $this->settings['delimiter'];
$e = $this->settings['escape'];
$l = $this->settings['length'];
PMXI_Plugin::$is_csv = $d;
$res = fopen($this->_filename, 'rb');
$xmlWriter = new XMLWriter();
$xmlWriter->openURI($this->xml_path);
$xmlWriter->setIndent(true);
$xmlWriter->setIndentString("\t");
$xmlWriter->startDocument('1.0', $this->csv_encoding);
$xmlWriter->startElement('data');
$create_new_headers = false;
while ($keys = fgetcsv($res, $l, $d, $e)) {
if ($c == 0) {
$buf_keys = $keys;
foreach ($keys as $key => $value) {
if (!$create_new_headers and (preg_match('%\\W(http:|https:|ftp:)$%i', $value) or is_numeric($value))) {
$create_new_headers = true;
}
$value = trim(strtolower(preg_replace('/^[0-9]{1}/', 'el_', preg_replace('/[^a-z0-9_]/i', '', $value))));
$keys[$key] = !empty($value) ? $value : 'undefined' . $key;
}
$this->headers = $keys;
if ($create_new_headers) {
$this->createHeaders('column');
$keys = $buf_keys;
}
}
if ($c or $create_new_headers) {
if (!empty($keys)) {
$chunk = array();
foreach ($this->headers as $key => $header) {
$chunk[$header] = $this->fixEncoding($keys[$key]);
}
if (!empty($chunk)) {
$xmlWriter->startElement('node');
foreach ($chunk as $header => $value) {
$xmlWriter->startElement($header);
if ($fixBrokenSymbols) {
// Remove non ASCII symbols and write CDATA
$xmlWriter->writeCData(preg_replace('/[^\\x{0009}\\x{000a}\\x{000d}\\x{0020}-\\x{D7FF}\\x{E000}-\\x{FFFD}]+/u', ' ', $value));
} else {
$xmlWriter->writeCData($value);
}
$xmlWriter->endElement();
}
$xmlWriter->endElement();
}
}
}
$c++;
}
fclose($res);
$xmlWriter->endElement();
$xmlWriter->flush(true);
return true;
}
示例2: index
/**
* Step #1: Choose File
*/
public function index()
{
PMXI_Plugin::$session->clean_session();
$this->data['reimported_import'] = $import = new PMXI_Import_Record();
$this->data['id'] = $id = $this->input->get('id');
$this->data['parent_import'] = $parent_import = $this->input->get('parent_import', 0);
$parent_import_record = new PMXI_Import_Record();
$default = array('type' => 'upload', 'wizard_type' => 'new', 'custom_type' => 'post', 'show_hidden_cpt' => 0, 'feed_type' => '', 'url' => '', 'ftp' => array('url' => 'ftp://'), 'file' => '', 'reimport' => '', 'is_update_previous' => $id ? 1 : 0, 'update_previous' => $id, 'xpath' => '/', 'filepath' => '', 'root_element' => '', 'downloaded' => '', 'auto_generate' => 0, 'template' => false);
if ($parent_import and !$parent_import_record->getById($parent_import)->isEmpty()) {
$default['custom_type'] = $parent_import_record->options['custom_type'];
}
if ($id) {
// update requested but corresponding import is not found
if ($import->getById($id)->isEmpty()) {
if (!empty($_GET['deligate']) and $_GET['deligate'] == 'wpallexport') {
wp_redirect(add_query_arg('pmxi_nt', array('error' => urlencode(__('The import associated with this export has been deleted.', 'wp_all_import_plugin')), 'updated' => urlencode(__('Please re-run your export by clicking Run Export on the All Export -> Manage Exports page. Then try your import again.', 'wp_all_import_plugin'))), remove_query_arg('id', $this->baseUrl)));
die;
} else {
wp_redirect(add_query_arg('pmxi_nt', array('error' => urlencode(__('This import has been deleted.', 'wp_all_import_plugin'))), remove_query_arg('id', $this->baseUrl)));
die;
}
} else {
$default['custom_type'] = $import->options['custom_type'];
}
}
$this->data['post'] = $post = $this->input->post($default);
if (!class_exists('DOMDocument') or !class_exists('XMLReader')) {
$this->errors->add('form-validation', __('Required PHP components are missing.<br/><br/>WP All Import requires DOMDocument, XMLReader, and XMLWriter PHP modules to be installed.<br/>These are standard features of PHP, and are necessary for WP All Import to read the files you are trying to import.<br/>Please contact your web hosting provider and ask them to install and activate the DOMDocument, XMLReader, and XMLWriter PHP modules.', 'wp_all_import_plugin'));
}
if ($this->input->post('is_submitted') and !$this->errors->get_error_codes()) {
check_admin_referer('choose-file', '_wpnonce_choose-file');
if ('upload' == $this->input->post('type')) {
$uploader = new PMXI_Upload($post['filepath'], $this->errors, rtrim(str_replace(basename($post['filepath']), '', $post['filepath']), '/'));
$upload_result = $uploader->upload();
if ($upload_result instanceof WP_Error) {
$this->errors = $upload_result;
} else {
$source = $upload_result['source'];
$filePath = $upload_result['filePath'];
$post['template'] = $upload_result['template'];
PMXI_Plugin::$is_csv = $upload_result['is_csv'];
if (!empty($upload_result['root_element'])) {
$post['root_element'] = $upload_result['root_element'];
}
}
} elseif ('url' == $this->input->post('type')) {
if (!empty($post['downloaded'])) {
$downloaded = json_decode($post['downloaded'], true);
$source = $downloaded['source'];
$filePath = $downloaded['filePath'];
$post['template'] = $downloaded['template'];
PMXI_Plugin::$csv_path = $downloaded['csv_path'];
PMXI_Plugin::$is_csv = $downloaded['is_csv'];
if (!empty($downloaded['root_element'])) {
$post['root_element'] = $downloaded['root_element'];
}
$post['feed_type'] = $downloaded['feed_type'];
} else {
$uploader = new PMXI_Upload($post['url'], $this->errors);
$upload_result = $uploader->url($post['feed_type']);
if ($upload_result instanceof WP_Error) {
$this->errors = $upload_result;
} else {
$source = $upload_result['source'];
$filePath = $upload_result['filePath'];
$post['template'] = $upload_result['template'];
PMXI_Plugin::$csv_path = $upload_result['csv_path'];
PMXI_Plugin::$is_csv = $upload_result['is_csv'];
if (!empty($upload_result['root_element'])) {
$post['root_element'] = $upload_result['root_element'];
}
$post['feed_type'] = $upload_result['feed_type'];
}
}
} elseif ('file' == $this->input->post('type')) {
$uploader = new PMXI_Upload($post['file'], $this->errors);
$upload_result = $uploader->file();
if ($upload_result instanceof WP_Error) {
$this->errors = $upload_result;
} else {
$source = $upload_result['source'];
$filePath = $upload_result['filePath'];
$post['template'] = $upload_result['template'];
PMXI_Plugin::$is_csv = $upload_result['is_csv'];
if (!empty($upload_result['root_element'])) {
$post['root_element'] = $upload_result['root_element'];
}
}
}
if ($this->input->post('is_submitted') and '' == $this->input->post('custom_type')) {
$this->errors->add('form-validation', __('Select an item type to import the data', 'wp_all_import_plugin'));
}
if ($post['is_update_previous'] and empty($post['update_previous'])) {
$this->errors->add('form-validation', __('Previous import for update must be selected to proceed with a new one', 'wp_all_import_plugin'));
}
$this->data['detection_feed_extension'] = false;
$elements_cloud = array();
//.........这里部分代码省略.........
示例3: index
/**
* Step #1: Choose File
*/
public function index()
{
PMXI_Plugin::$session->clean_session();
$this->data['reimported_import'] = $import = new PMXI_Import_Record();
$this->data['id'] = $id = $this->input->get('id');
$this->data['parent_import'] = $parent_import = $this->input->get('parent_import', 0);
$parent_import_record = new PMXI_Import_Record();
$default = array('type' => 'upload', 'wizard_type' => 'new', 'custom_type' => 'post', 'show_hidden_cpt' => 0, 'feed_type' => '', 'url' => '', 'ftp' => array('url' => 'ftp://'), 'file' => '', 'reimport' => '', 'is_update_previous' => $id ? 1 : 0, 'update_previous' => $id, 'xpath' => '/', 'filepath' => '', 'root_element' => '', 'downloaded' => '');
if ($parent_import and !$parent_import_record->getById($parent_import)->isEmpty()) {
$default['custom_type'] = $parent_import_record->options['custom_type'];
}
if ($id and $import->getById($id)->isEmpty()) {
// update requested but corresponding import is not found
wp_redirect(remove_query_arg('id', $this->baseUrl));
die;
}
$this->data['post'] = $post = $this->input->post($default);
if ($this->input->post('is_submitted_continue')) {
if (!empty(PMXI_Plugin::$session->local_paths)) {
wp_redirect(add_query_arg('action', 'element', $this->baseUrl));
die;
}
} elseif ('upload' == $this->input->post('type')) {
$uploader = new PMXI_Upload($post['filepath'], $this->errors, rtrim(str_replace(basename($post['filepath']), '', $post['filepath']), '/'));
$upload_result = $uploader->upload();
if ($upload_result instanceof WP_Error) {
$this->errors = $upload_result;
} else {
$source = $upload_result['source'];
$filePath = $upload_result['filePath'];
PMXI_Plugin::$is_csv = $upload_result['is_csv'];
if (!empty($upload_result['root_element'])) {
$post['root_element'] = $upload_result['root_element'];
}
}
} elseif ('url' == $this->input->post('type')) {
if (!empty($post['downloaded'])) {
$downloaded = json_decode($post['downloaded'], true);
$source = $downloaded['source'];
$filePath = $downloaded['filePath'];
PMXI_Plugin::$csv_path = $downloaded['csv_path'];
PMXI_Plugin::$is_csv = $downloaded['is_csv'];
if (!empty($downloaded['root_element'])) {
$post['root_element'] = $downloaded['root_element'];
}
$post['feed_type'] = $downloaded['feed_type'];
} else {
$uploader = new PMXI_Upload($post['url'], $this->errors);
$upload_result = $uploader->url($post['feed_type']);
if ($upload_result instanceof WP_Error) {
$this->errors = $upload_result;
} else {
$source = $upload_result['source'];
$filePath = $upload_result['filePath'];
PMXI_Plugin::$csv_path = $upload_result['csv_path'];
PMXI_Plugin::$is_csv = $upload_result['is_csv'];
if (!empty($upload_result['root_element'])) {
$post['root_element'] = $upload_result['root_element'];
}
$post['feed_type'] = $upload_result['feed_type'];
}
}
} elseif ('file' == $this->input->post('type')) {
$uploader = new PMXI_Upload($post['file'], $this->errors);
$upload_result = $uploader->file();
if ($upload_result instanceof WP_Error) {
$this->errors = $upload_result;
} else {
$source = $upload_result['source'];
$filePath = $upload_result['filePath'];
PMXI_Plugin::$is_csv = $upload_result['is_csv'];
if (!empty($upload_result['root_element'])) {
$post['root_element'] = $upload_result['root_element'];
}
}
}
if ($this->input->post('is_submitted') and '' == $this->input->post('custom_type')) {
$this->errors->add('form-validation', __('Select an item type to import the data', 'pmxi_plugin'));
}
if ($post['is_update_previous'] and empty($post['update_previous'])) {
$this->errors->add('form-validation', __('Previous import for update must be selected to proceed with a new one', 'pmxi_plugin'));
}
$this->data['detection_feed_extension'] = false;
if (!class_exists('DOMDocument') or !class_exists('XMLReader')) {
$this->errors->add('form-validation', __('Required PHP components are missing.<br/><br/>WP All Import requires DOMDocument and XMLReader PHP classes to be installed.<br/>These are standard features of PHP, and are necessary for WP All Import to read the files you are trying to import.<br/>Please contact your web hosting provider and ask them to install and activate the DOMDocument and XMLReader PHP classes.', 'pmxi_plugin'));
}
if ($this->input->post('is_submitted') and !$this->errors->get_error_codes()) {
check_admin_referer('choose-file', '_wpnonce_choose-file');
$elements_cloud = array();
@set_time_limit(0);
$local_paths = !empty($local_paths) ? $local_paths : array($filePath);
foreach ($local_paths as $key => $path) {
if (@file_exists($path)) {
$file = new PMXI_Chunk($path, array('element' => $post['root_element']));
if (!empty($file->options['element'])) {
$xpath = "/" . $file->options['element'];
$elements_cloud = $file->cloud;
//.........这里部分代码省略.........