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


PHP PMXI_Import_Record::getById方法代码示例

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


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

示例1: pmxi_wp_ajax_delete_import

function pmxi_wp_ajax_delete_import()
{
    if (!check_ajax_referer('wp_all_import_secure', 'security', false)) {
        exit(json_encode(array('result' => false, 'msg' => __('Security check', 'wp_all_import_plugin'))));
    }
    if (!current_user_can('manage_options')) {
        exit(json_encode(array('result' => false, 'msg' => __('Security check', 'wp_all_import_plugin'))));
    }
    $input = new PMXI_Input();
    $post = $input->post(array('data' => ''));
    $get = $input->get(array('iteration' => 1));
    $params = array();
    parse_str($post['data'], $params);
    $response = array('result' => false, 'msg' => '', 'redirect' => add_query_arg('pmxi_nt', urlencode(__('Import deleted', 'wp_all_import_plugin')), $params['base_url']));
    if (!empty($params['import_ids'])) {
        foreach ($params['import_ids'] as $key => $id) {
            $import = new PMXI_Import_Record();
            $import->getById($id);
            if (!$import->isEmpty()) {
                if ((int) $get['iteration'] === 1) {
                    $import->set(array('deleted' => 0))->update();
                }
                $is_all_records_deleted = $import->deletePostsAjax(!$params['is_delete_posts'], $params['is_delete_images'], $params['is_delete_attachments']);
                $response['result'] = empty($params['import_ids'][$key + 1]) ? $is_all_records_deleted : false;
                $response['msg'] = sprintf(__('Import #%d - %d records deleted', 'wp_all_import_plugin'), $import->id, $import->deleted);
                if ($is_all_records_deleted === true) {
                    $import->delete(!$params['is_delete_posts'], $params['is_delete_images'], $params['is_delete_attachments']);
                }
            }
        }
    }
    exit(json_encode($response));
}
开发者ID:lizbur10,项目名称:js_finalproject,代码行数:33,代码来源:wp_ajax_delete_import.php

示例2: index

 /**
  * Step #1: Choose File
  */
 public function index($post_type = 'post')
 {
     $default = PMAI_Plugin::get_default_import_options();
     $this->data['id'] = $id = $this->input->get('id');
     $this->data['import'] = $import = new PMXI_Import_Record();
     if (!$id or $import->getById($id)->isEmpty()) {
         // specified import is not found
         $post = $this->input->post((isset(PMXI_Plugin::$session->options) ? PMXI_Plugin::$session->options : array()) + $default);
     } else {
         $post = $this->input->post($this->data['import']->options + $default);
     }
     $this->data['is_loaded_template'] = !empty(PMXI_Plugin::$session->is_loaded_template) ? PMXI_Plugin::$session->is_loaded_template : false;
     $load_options = $this->input->post('load_template');
     if ($load_options) {
         // init form with template selected
         $template = new PMXI_Template_Record();
         if (!$template->getById($this->data['is_loaded_template'])->isEmpty()) {
             $post = (!empty($template->options) ? $template->options : array()) + $default;
         }
     } elseif ($load_options == -1) {
         $post = $default;
     }
     $this->data['post_type'] = $post_type;
     $this->data['post'] =& $post;
     $this->render();
 }
开发者ID:ryan2407,项目名称:Vision,代码行数:29,代码来源:import.php

示例3: pmwi_pmxi_after_xml_import

function pmwi_pmxi_after_xml_import($import_id)
{
    $import = new PMXI_Import_Record();
    $import->getById($import_id);
    if (!$import->isEmpty() and in_array($import->options['custom_type'], array('product', 'product_variation')) and $import->options['is_keep_former_posts'] == 'no' and ($import->options['update_all_data'] == 'yes' or $import->options['is_update_categories'])) {
        $product_cats = get_terms('product_cat', array('hide_empty' => false, 'fields' => 'id=>parent'));
        _wc_term_recount($product_cats, get_taxonomy('product_cat'), true, false);
        $product_tags = get_terms('product_tag', array('hide_empty' => false, 'fields' => 'id=>parent'));
        _wc_term_recount($product_tags, get_taxonomy('product_tag'), true, false);
    }
}
开发者ID:soflyy,项目名称:woocommerce-xml-csv-product-import,代码行数:11,代码来源:pmxi_after_xml_import.php

示例4: delete

 /**
  * @see parent::delete()	 
  */
 public function delete()
 {
     $this->deletePosts();
     if (!empty($this->options['import_id']) and wp_all_export_is_compatible()) {
         $import = new PMXI_Import_Record();
         $import->getById($this->options['import_id']);
         if (!$import->isEmpty() and $import->parent_import_id == 99999) {
             $import->delete();
         }
     }
     $export_file_path = wp_all_export_get_absolute_path($this->options['filepath']);
     if (@file_exists($export_file_path)) {
         wp_all_export_remove_source($export_file_path);
     }
     if (!empty($this->attch_id)) {
         wp_delete_attachment($this->attch_id, true);
     }
     $wp_uploads = wp_upload_dir();
     $file_for_remote_access = $wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXE_Plugin::UPLOADS_DIRECTORY . DIRECTORY_SEPARATOR . md5(PMXE_Plugin::getInstance()->getOption('cron_job_key') . $this->id) . '.' . $this->options['export_to'];
     if (@file_exists($file_for_remote_access)) {
         @unlink($file_for_remote_access);
     }
     return parent::delete();
 }
开发者ID:GarryVeles,项目名称:Artibaltika,代码行数:27,代码来源:record.php

示例5: array

 function helper_current_field_values($default = array())
 {
     if (empty($default)) {
         $options = array('mapping' => array(), 'xpaths' => array());
         foreach ($this->fields as $field_slug => $field_params) {
             $options[$field_slug] = '';
             if (!empty($field_params['enum_values'])) {
                 foreach ($field_params['enum_values'] as $key => $value) {
                     $options[$field_slug] = is_numeric($key) ? (int) $key : $key;
                     break;
                 }
             }
         }
         $default = array($this->slug => $options);
     }
     $input = new PMXI_Input();
     $id = $input->get('id');
     $import = new PMXI_Import_Record();
     if (!$id or $import->getById($id)->isEmpty()) {
         // specified import is not found
         $post = $input->post($default);
     } else {
         $post = $input->post($import->options + $default);
     }
     $is_loaded_template = !empty(PMXI_Plugin::$session->is_loaded_template) ? PMXI_Plugin::$session->is_loaded_template : false;
     $load_options = $input->post('load_template');
     if ($load_options) {
         // init form with template selected
         $template = new PMXI_Template_Record();
         if (!$template->getById($is_loaded_template)->isEmpty()) {
             $post = (!empty($template->options) ? $template->options : array()) + $default;
         }
     } elseif ($load_options == -1) {
         $post = $default;
     }
     return $post;
 }
开发者ID:ANJUM795,项目名称:jobify-xml-csv-listings-import,代码行数:37,代码来源:rapid-addon.php

示例6: pmxi_wp_loaded

function pmxi_wp_loaded()
{
    @ini_set("max_input_time", PMXI_Plugin::getInstance()->getOption('max_input_time'));
    @ini_set("max_execution_time", PMXI_Plugin::getInstance()->getOption('max_execution_time'));
    $table = PMXI_Plugin::getInstance()->getTablePrefix() . 'imports';
    global $wpdb;
    $imports = $wpdb->get_results("SELECT `id`, `name`, `path` FROM {$table} WHERE `path` IS NULL", ARRAY_A);
    if (!empty($imports)) {
        $importRecord = new PMXI_Import_Record();
        $importRecord->clear();
        foreach ($imports as $imp) {
            $importRecord->getById($imp['id']);
            if (!$importRecord->isEmpty()) {
                $importRecord->delete(true);
            }
            $importRecord->clear();
        }
    }
    /* Check if cron is manualy, then execute import */
    $cron_job_key = PMXI_Plugin::getInstance()->getOption('cron_job_key');
    if (!empty($cron_job_key) and !empty($_GET['import_id']) and !empty($_GET['import_key']) and $_GET['import_key'] == $cron_job_key and !empty($_GET['action']) and in_array($_GET['action'], array('processing', 'trigger', 'pipe'))) {
        $logger = create_function('$m', 'echo "<p>$m</p>\\n";');
        $import = new PMXI_Import_Record();
        $ids = explode(',', $_GET['import_id']);
        if (!empty($ids) and is_array($ids)) {
            foreach ($ids as $id) {
                if (empty($id)) {
                    continue;
                }
                $import->getById($id);
                if (!$import->isEmpty()) {
                    if (!in_array($import->type, array('url', 'ftp', 'file'))) {
                        $logger and call_user_func($logger, sprintf(__('Scheduling update is not working with "upload" import type. Import #%s.', 'wp_all_import_plugin'), $id));
                    }
                    switch ($_GET['action']) {
                        case 'trigger':
                            if ((int) $import->executing) {
                                $logger and call_user_func($logger, sprintf(__('Import #%s is currently in manually process. Request skipped.', 'wp_all_import_plugin'), $id));
                            } elseif (!$import->processing and !$import->triggered) {
                                $import->set(array('triggered' => 1, 'imported' => 0, 'created' => 0, 'updated' => 0, 'skipped' => 0, 'deleted' => 0, 'queue_chunk_number' => 0, 'last_activity' => date('Y-m-d H:i:s')))->update();
                                $history_log = new PMXI_History_Record();
                                $history_log->set(array('import_id' => $import->id, 'date' => date('Y-m-d H:i:s'), 'type' => 'trigger', 'summary' => __("triggered by cron", "wp_all_import_plugin")))->save();
                                $logger and call_user_func($logger, sprintf(__('#%s Cron job triggered.', 'wp_all_import_plugin'), $id));
                            } elseif ($import->processing and !$import->triggered) {
                                $logger and call_user_func($logger, sprintf(__('Import #%s currently in process. Request skipped.', 'wp_all_import_plugin'), $id));
                            } elseif (!$import->processing and $import->triggered) {
                                $logger and call_user_func($logger, sprintf(__('Import #%s already triggered. Request skipped.', 'wp_all_import_plugin'), $id));
                            }
                            break;
                        case 'processing':
                            if ($import->processing == 1 and time() - strtotime($import->registered_on) > (PMXI_Plugin::getInstance()->getOption('cron_processing_time_limit') ? PMXI_Plugin::getInstance()->getOption('cron_processing_time_limit') : 120)) {
                                // it means processor crashed, so it will reset processing to false, and terminate. Then next run it will work normally.
                                $import->set(array('processing' => 0))->update();
                            }
                            // start execution imports that is in the cron process
                            if (!(int) $import->triggered) {
                                $logger and call_user_func($logger, sprintf(__('Import #%s is not triggered. Request skipped.', 'wp_all_import_plugin'), $id));
                            } elseif ((int) $import->executing) {
                                $logger and call_user_func($logger, sprintf(__('Import #%s is currently in manually process. Request skipped.', 'wp_all_import_plugin'), $id));
                            } elseif ((int) $import->triggered and !(int) $import->processing) {
                                $log_storage = (int) PMXI_Plugin::getInstance()->getOption('log_storage');
                                // unlink previous logs
                                $by = array();
                                $by[] = array(array('import_id' => $id, 'type NOT LIKE' => 'trigger'), 'AND');
                                $historyLogs = new PMXI_History_List();
                                $historyLogs->setColumns('id', 'import_id', 'type', 'date')->getBy($by, 'id ASC');
                                if ($historyLogs->count() and $historyLogs->count() >= $log_storage) {
                                    $logsToRemove = $historyLogs->count() - $log_storage;
                                    foreach ($historyLogs as $i => $file) {
                                        $historyRecord = new PMXI_History_Record();
                                        $historyRecord->getBy('id', $file['id']);
                                        if (!$historyRecord->isEmpty()) {
                                            $historyRecord->delete();
                                        }
                                        // unlink history file only
                                        if ($i == $logsToRemove) {
                                            break;
                                        }
                                    }
                                }
                                $history_log = new PMXI_History_Record();
                                $history_log->set(array('import_id' => $import->id, 'date' => date('Y-m-d H:i:s'), 'type' => 'processing', 'summary' => __("cron processing", "wp_all_import_plugin")))->save();
                                if ($log_storage) {
                                    $wp_uploads = wp_upload_dir();
                                    $log_file = wp_all_import_secure_file($wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::LOGS_DIRECTORY, $history_log->id) . DIRECTORY_SEPARATOR . $history_log->id . '.html';
                                    if (@file_exists($log_file)) {
                                        wp_all_import_remove_source($log_file, false);
                                    }
                                }
                                ob_start();
                                $import->set(array('canceled' => 0, 'failed' => 0))->execute($logger, true, $history_log->id);
                                $log_data = ob_get_clean();
                                if ($log_storage) {
                                    $log = @fopen($log_file, 'a+');
                                    @fwrite($log, $log_data);
                                    @fclose($log);
                                }
                                if (!(int) $import->queue_chunk_number) {
                                    $logger and call_user_func($logger, sprintf(__('Import #%s complete', 'wp_all_import_plugin'), $import->id));
                                } else {
//.........这里部分代码省略.........
开发者ID:jamesaveryw,项目名称:mississippi-staging,代码行数:101,代码来源:wp_loaded.php

示例7: delete

 /**
  * Delete an import
  */
 public function delete()
 {
     $id = $this->input->get('id');
     $this->data['item'] = $item = new PMXI_Import_Record();
     if (!$id or $item->getById($id)->isEmpty()) {
         wp_redirect($this->baseUrl);
         die;
     }
     if ($this->input->post('is_confirmed')) {
         check_admin_referer('delete-import', '_wpnonce_delete-import');
         do_action('pmxi_before_import_delete', $item, $this->input->post('is_delete_posts'));
         $item->delete(!$this->input->post('is_delete_posts'));
         wp_redirect(add_query_arg('pmxi_nt', urlencode(__('Import deleted', 'wp_all_import_plugin')), $this->baseUrl));
         die;
     }
     $this->render();
 }
开发者ID:GolgoSoft,项目名称:KeenerWP,代码行数:20,代码来源:manage.php

示例8: delete

 /**
  * Delete an import
  */
 public function delete()
 {
     $id = $this->input->get('id');
     $this->data['item'] = $item = new PMXI_Import_Record();
     if (!$id or $item->getById($id)->isEmpty()) {
         wp_redirect($this->baseUrl);
         die;
     }
     if ($this->input->post('is_confirmed')) {
         check_admin_referer('delete-import', '_wpnonce_delete-import');
         $is_deleted_images = $this->input->post('is_delete_images');
         $is_delete_attachments = $this->input->post('is_delete_attachments');
         $is_delete_import = $this->input->post('is_delete_import', false);
         $is_delete_posts = $this->input->post('is_delete_posts', false);
         if (!$is_delete_import and !$is_delete_posts) {
             wp_redirect(add_query_arg('pmxi_nt', urlencode(__('Nothing to delete.', 'wp_all_import_plugin')), $this->baseUrl));
             die;
         }
         do_action('pmxi_before_import_delete', $item, $is_delete_posts);
         $item->delete(!$is_delete_posts, $is_deleted_images, $is_delete_attachments, $is_delete_import);
         $redirect_msg = '';
         if ($is_delete_import and !$is_delete_posts) {
             $redirect_msg = __('Import deleted', 'wp_all_import_plugin');
         } elseif (!$is_delete_import and $is_delete_posts) {
             $redirect_msg = __('All associated posts deleted.', 'wp_all_import_plugin');
         } elseif ($is_delete_import and $is_delete_posts) {
             $redirect_msg = __('Import and all associated posts deleted.', 'wp_all_import_plugin');
         }
         wp_redirect(add_query_arg('pmxi_nt', urlencode($redirect_msg), $this->baseUrl));
         die;
     }
     $postList = new PMXI_Post_List();
     $this->data['associated_posts'] = count($postList->getBy(array('import_id' => $item->id)));
     $this->render();
 }
开发者ID:TakenCdosG,项目名称:chefs,代码行数:38,代码来源:manage.php

示例9: get_xml

 protected function get_xml($tagno = 0, $debug = false)
 {
     $xml = '';
     $update_previous = new PMXI_Import_Record();
     if (!empty(PMXI_Plugin::$session->update_previous)) {
         $update_previous->getById(PMXI_Plugin::$session->update_previous);
     }
     $local_paths = empty(PMXI_Plugin::$session->local_paths) ? array() : PMXI_Plugin::$session->local_paths;
     if (empty($local_paths) and !$update_previous->isEmpty()) {
         $history_file = new PMXI_File_Record();
         $history_file->getBy(array('import_id' => $update_previous->id), 'id DESC');
         $local_paths = !$history_file->isEmpty() ? array(wp_all_import_get_absolute_path($history_file->path)) : array();
     }
     if (!empty($local_paths)) {
         $loop = 0;
         foreach ($local_paths as $key => $path) {
             if (@file_exists($path)) {
                 $root_element = !$update_previous->isEmpty() ? $update_previous->root_element : PMXI_Plugin::$session->source['root_element'];
                 $file = new PMXI_Chunk($path, array('element' => $root_element, 'encoding' => PMXI_Plugin::$session->encoding));
                 while ($xml = $file->read()) {
                     if (!empty($xml)) {
                         PMXI_Import_Record::preprocessXml($xml);
                         $xml = "<?xml version=\"1.0\" encoding=\"" . PMXI_Plugin::$session->encoding . "\"?>" . "\n" . $xml;
                         if (PMXI_Plugin::$session->xpath) {
                             $dom = new DOMDocument('1.0', PMXI_Plugin::$session->encoding);
                             $old = libxml_use_internal_errors(true);
                             $dom->loadXML($xml);
                             libxml_use_internal_errors($old);
                             $xpath = new DOMXPath($dom);
                             if ($elements = $xpath->query(PMXI_Plugin::$session->xpath) and $elements->length) {
                                 $this->data['dom'] = $dom;
                                 $loop++;
                                 if (!$tagno or $loop == $tagno) {
                                     break;
                                 }
                             }
                         } else {
                             break;
                         }
                     }
                 }
                 unset($file);
             }
         }
     }
     return $xml;
 }
开发者ID:hikaram,项目名称:wee,代码行数:47,代码来源:import.php

示例10: cleanup

 public function cleanup()
 {
     $removedFiles = 0;
     $wp_uploads = wp_upload_dir();
     $dir = $wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::TEMP_DIRECTORY;
     $cacheDir = PMXI_Plugin::ROOT_DIR . '/libraries/cache';
     $files = array_diff(@scandir($dir), array('.', '..'));
     $cacheFiles = @array_diff(@scandir($cacheDir), array('.', '..'));
     $msg = __('Files not found', 'wp_all_import_plugin');
     if (count($files) or count($cacheFiles)) {
         wp_all_import_clear_directory($dir);
         wp_all_import_clear_directory($cacheDir);
         $msg = __('Clean Up has been successfully completed.', 'wp_all_import_plugin');
     }
     // clean logs files
     $table = PMXI_Plugin::getInstance()->getTablePrefix() . 'history';
     global $wpdb;
     $histories = $wpdb->get_results("SELECT * FROM {$table}", ARRAY_A);
     if (!empty($histories)) {
         $importRecord = new PMXI_Import_Record();
         $importRecord->clear();
         foreach ($histories as $history) {
             $importRecord->getById($history['import_id']);
             if ($importRecord->isEmpty()) {
                 $historyRecord = new PMXI_History_Record();
                 $historyRecord->getById($history['id']);
                 if (!$historyRecord->isEmpty()) {
                     $historyRecord->delete();
                 }
             }
             $importRecord->clear();
         }
     }
     // clean uploads folder
     $table = PMXI_Plugin::getInstance()->getTablePrefix() . 'files';
     $files = $wpdb->get_results("SELECT * FROM {$table}", ARRAY_A);
     $required_dirs = array();
     if (!empty($files)) {
         $importRecord = new PMXI_Import_Record();
         $importRecord->clear();
         foreach ($files as $file) {
             $importRecord->getById($file['import_id']);
             if ($importRecord->isEmpty()) {
                 $fileRecord = new PMXI_File_Record();
                 $fileRecord->getById($file['id']);
                 if (!$fileRecord->isEmpty()) {
                     $fileRecord->delete();
                 }
             } else {
                 $path_parts = pathinfo(wp_all_import_get_absolute_path($file['path']));
                 if (!empty($path_parts['dirname'])) {
                     $path_all_parts = explode('/', $path_parts['dirname']);
                     $dirname = array_pop($path_all_parts);
                     if (wp_all_import_isValidMd5($dirname)) {
                         $required_dirs[] = $path_parts['dirname'];
                     }
                 }
             }
             $importRecord->clear();
         }
     }
     $uploads_dir = $wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXI_Plugin::UPLOADS_DIRECTORY;
     if (($dir = @opendir($uploads_dir . DIRECTORY_SEPARATOR)) !== false or ($dir = @opendir($uploads_dir)) !== false) {
         while (($file = @readdir($dir)) !== false) {
             $filePath = $uploads_dir . DIRECTORY_SEPARATOR . $file;
             if (is_dir($filePath) and !in_array($filePath, $required_dirs) and !in_array($file, array('.', '..'))) {
                 wp_all_import_rmdir($filePath);
             }
         }
     }
     wp_redirect(add_query_arg('pmxi_nt', urlencode($msg), $this->baseUrl));
     die;
 }
开发者ID:lizbur10,项目名称:js_finalproject,代码行数:73,代码来源:settings.php

示例11: process

 /**
  * Step #3: Export
  */
 public function process()
 {
     @set_time_limit(0);
     $export = $this->data['update_previous'];
     if (!PMXE_Plugin::is_ajax()) {
         if ("" == PMXE_Plugin::$session->friendly_name) {
             $friendly_name = '';
             $post_types = PMXE_Plugin::$session->get('cpt');
             if (!empty($post_types)) {
                 if (!in_array('users', $post_types)) {
                     $post_type_details = get_post_type_object(array_shift($post_types));
                     $friendly_name = $post_type_details->labels->name . ' Export - ' . date("Y F d H:i");
                 } else {
                     $friendly_name = 'Users Export - ' . date("Y F d H:i");
                 }
             } else {
                 $friendly_name = 'WP_Query Export - ' . date("Y F d H:i");
             }
             PMXE_Plugin::$session->set('friendly_name', $friendly_name);
         }
         PMXE_Plugin::$session->set('file', '');
         PMXE_Plugin::$session->save_data();
         $export->set(array('triggered' => 0, 'processing' => 0, 'exported' => 0, 'executing' => 1, 'canceled' => 0, 'options' => PMXE_Plugin::$session->get_clear_session_data(), 'friendly_name' => PMXE_Plugin::$session->friendly_name, 'scheduled' => PMXE_Plugin::$session->is_scheduled ? PMXE_Plugin::$session->scheduled_period : '', 'registered_on' => date('Y-m-d H:i:s'), 'last_activity' => date('Y-m-d H:i:s')))->save();
         $options = $export->options;
         if ($options['is_generate_import'] and wp_all_export_is_compatible()) {
             $import = new PMXI_Import_Record();
             if (!empty($options['import_id'])) {
                 $import->getById($options['import_id']);
             }
             if ($import->isEmpty()) {
                 $import->set(array('parent_import_id' => 99999, 'xpath' => '/', 'type' => 'upload', 'options' => array('empty'), 'root_element' => 'root', 'path' => 'path', 'imported' => 0, 'created' => 0, 'updated' => 0, 'skipped' => 0, 'deleted' => 0, 'iteration' => 1))->save();
                 PMXE_Plugin::$session->set('import_id', $import->id);
                 $options['import_id'] = $import->id;
                 $export->set(array('options' => $options))->save();
             } else {
                 if ($import->parent_import_id != 99999) {
                     $newImport = new PMXI_Import_Record();
                     $newImport->set(array('parent_import_id' => 99999, 'xpath' => '/', 'type' => 'upload', 'options' => array('empty'), 'root_element' => 'root', 'path' => 'path', 'imported' => 0, 'created' => 0, 'updated' => 0, 'skipped' => 0, 'deleted' => 0, 'iteration' => 1))->save();
                     PMXE_Plugin::$session->set('import_id', $newImport->id);
                     $options['import_id'] = $newImport->id;
                     $export->set(array('options' => $options))->save();
                 }
             }
         }
         PMXE_Plugin::$session->set('update_previous', $export->id);
         PMXE_Plugin::$session->save_data();
     }
     $this->render();
 }
开发者ID:hikaram,项目名称:wee,代码行数:52,代码来源:export.php

示例12: import

 /**
  *
  *	Fires after wp_insert_post/wp_update_post
  *
  */
 public function import($post_id, $data, $import, $articleData, $logger)
 {
     // return if this is a basic post ( not a translation )
     if (empty($import['options']['wpml_addon']['matching_logic']) or empty($import['options']['wpml_addon']['import'])) {
         return;
     }
     // search for post to translate
     $parentImport = new PMXI_Import_Record();
     $parentImport->getById($import['options']['wpml_addon']['import']);
     if (!$parentImport->isEmpty()) {
         // post is that must be translated
         $parent_post_id = false;
         $postRecord = new PMXI_Post_Record();
         $postRecord->clear();
         $postRecord->getBy(array('unique_key' => $data['unique_key'], 'import_id' => $import['options']['wpml_addon']['import']));
         if (!$postRecord->isEmpty()) {
             $parent_post_id = $postRecord->post_id;
         }
         if ($parent_post_id) {
             $post_type = in_array(get_post_type($post_id), array('product', 'product_variation')) ? 'post_product' : 'post_' . get_post_type($post_id);
             $trid = $this->wpml->get_element_trid($parent_post_id, $post_type);
             if ($trid) {
                 global $wpdb;
                 // sync translation slug
                 $parent_post = get_post($parent_post_id);
                 if (!empty($parent_post) and $parent_post->post_title == $articleData['post_title']) {
                     $wpdb->update($wpdb->posts, array('post_name' => $parent_post->post_name), array('ID' => $post_id));
                 }
                 // create a translation
                 $tid = $this->wpml->set_element_language_details($post_id, $post_type, $trid, $import->options['wpml_addon']['lng'], $parentImport->options['wpml_addon']['lng']);
                 if (is_wp_error($tid)) {
                     $logger and call_user_func($logger, __('<b>ERROR</b>', 'wpml-all-import') . ': ' . $tid->get_error_message());
                 } else {
                     $logger and call_user_func($logger, sprintf(__('- Created `%s` translation for `%s`', 'wpml-all-import'), $import->options['wpml_addon']['lng'], $parent_post->post_title));
                 }
             }
         }
     }
 }
开发者ID:OnTheGoSystems,项目名称:wpml-all-import,代码行数:44,代码来源:wpml-all-import.php

示例13: link_template_to_import

 public static function link_template_to_import(&$export, $file_path, $foundPosts)
 {
     $exportOptions = $export->options;
     // associate exported posts with new import
     if (wp_all_export_is_compatible()) {
         $options = self::$templateOptions + PMXI_Plugin::get_default_import_options();
         $import = new PMXI_Import_Record();
         $import->getById($exportOptions['import_id']);
         if (!$import->isEmpty() and $import->parent_import_id == 99999) {
             $xmlPath = $file_path;
             $root_element = '';
             $historyPath = $file_path;
             if ('csv' == $exportOptions['export_to']) {
                 $is_secure_import = PMXE_Plugin::getInstance()->getOption('secure');
                 $options['delimiter'] = $exportOptions['delimiter'];
                 include_once PMXI_Plugin::ROOT_DIR . '/libraries/XmlImportCsvParse.php';
                 $path_info = pathinfo($xmlPath);
                 $path_parts = explode(DIRECTORY_SEPARATOR, $path_info['dirname']);
                 $security_folder = array_pop($path_parts);
                 $wp_uploads = wp_upload_dir();
                 $target = $is_secure_import ? $wp_uploads['basedir'] . DIRECTORY_SEPARATOR . PMXE_Plugin::UPLOADS_DIRECTORY . DIRECTORY_SEPARATOR . $security_folder : $wp_uploads['path'];
                 $csv = new PMXI_CsvParser(array('filename' => $xmlPath, 'targetDir' => $target));
                 if (!in_array($xmlPath, $exportOptions['attachment_list'])) {
                     $exportOptions['attachment_list'][] = $csv->xml_path;
                 }
                 $historyPath = $csv->xml_path;
                 $root_element = 'node';
             } else {
                 $root_element = apply_filters('wp_all_export_record_xml_tag', $exportOptions['record_xml_tag'], $export->id);
             }
             $import->set(array('xpath' => '/' . $root_element, 'type' => 'upload', 'options' => $options, 'root_element' => $root_element, 'path' => $xmlPath, 'name' => basename($xmlPath), 'imported' => 0, 'created' => 0, 'updated' => 0, 'skipped' => 0, 'deleted' => 0, 'iteration' => 1, 'count' => $foundPosts))->save();
             $history_file = new PMXI_File_Record();
             $history_file->set(array('name' => $import->name, 'import_id' => $import->id, 'path' => $historyPath, 'registered_on' => date('Y-m-d H:i:s')))->save();
             $exportOptions['import_id'] = $import->id;
             $export->set(array('options' => $exportOptions))->save();
         }
     }
 }
开发者ID:soflyy,项目名称:wp-all-export,代码行数:38,代码来源:wpallimport.php

示例14: pmxe_wp_ajax_wpallexport

/**
*	AJAX action export processing
*/
function pmxe_wp_ajax_wpallexport()
{
    if (!check_ajax_referer('wp_all_export_secure', 'security', false)) {
        exit(__('Security check', 'wp_all_export_plugin'));
    }
    if (!current_user_can('manage_options')) {
        exit(__('Security check', 'wp_all_export_plugin'));
    }
    $input = new PMXE_Input();
    $export_id = $input->get('id', 0);
    if (empty($export_id)) {
        $export_id = !empty(PMXE_Plugin::$session->update_previous) ? PMXE_Plugin::$session->update_previous : 0;
    }
    $wp_uploads = wp_upload_dir();
    $export = new PMXE_Export_Record();
    $export->getById($export_id);
    if ($export->isEmpty()) {
        exit(__('Export is not defined.', 'wp_all_export_plugin'));
    }
    $exportOptions = $export->options + PMXE_Plugin::get_default_import_options();
    wp_reset_postdata();
    XmlExportEngine::$exportOptions = $exportOptions;
    XmlExportEngine::$is_user_export = $exportOptions['is_user_export'];
    XmlExportEngine::$exportID = $export_id;
    $posts_per_page = $exportOptions['records_per_iteration'];
    if ('advanced' == $exportOptions['export_type']) {
        if (XmlExportEngine::$is_user_export) {
            exit(json_encode(array('html' => __('Upgrade to the professional edition of WP All Export to export users.', 'wp_all_export_plugin'))));
        } else {
            $exportQuery = eval('return new WP_Query(array(' . $exportOptions['wp_query'] . ', \'offset\' => ' . $export->exported . ', \'posts_per_page\' => ' . $posts_per_page . ' ));');
        }
    } else {
        XmlExportEngine::$post_types = $exportOptions['cpt'];
        if (!in_array('users', $exportOptions['cpt'])) {
            $exportQuery = new WP_Query(array('post_type' => $exportOptions['cpt'], 'post_status' => 'any', 'orderby' => 'ID', 'order' => 'ASC', 'offset' => $export->exported, 'posts_per_page' => $posts_per_page));
        } else {
            exit(json_encode(array('html' => __('Upgrade to the professional edition of WP All Export to export users.', 'wp_all_export_plugin'))));
        }
    }
    XmlExportEngine::$exportQuery = $exportQuery;
    $foundPosts = !XmlExportEngine::$is_user_export ? $exportQuery->found_posts : $exportQuery->get_total();
    $postCount = !XmlExportEngine::$is_user_export ? $exportQuery->post_count : count($exportQuery->get_results());
    if (!$export->exported) {
        $attachment_list = $export->options['attachment_list'];
        if (!empty($attachment_list)) {
            foreach ($attachment_list as $attachment) {
                if (!is_numeric($attachment)) {
                    @unlink($attachment);
                }
            }
        }
        $exportOptions['attachment_list'] = array();
        $export->set(array('options' => $exportOptions))->save();
        $is_secure_import = PMXE_Plugin::getInstance()->getOption('secure');
        if ($is_secure_import and !empty($exportOptions['filepath'])) {
            // if 'Create a new file each time export is run' disabled remove all previously generated source files
            // if ( ! $exportOptions['creata_a_new_export_file'] or ! $export->iteration ){
            // 	wp_all_export_remove_source(wp_all_export_get_absolute_path($exportOptions['filepath']));
            // }
            $exportOptions['filepath'] = '';
        }
        PMXE_Plugin::$session->set('count', $foundPosts);
        PMXE_Plugin::$session->save_data();
    }
    // if posts still exists then export them
    if ($postCount) {
        switch ($exportOptions['export_to']) {
            case 'xml':
                pmxe_export_xml($exportQuery, $exportOptions);
                break;
            case 'csv':
                pmxe_export_csv($exportQuery, $exportOptions);
                break;
            default:
                # code...
                break;
        }
        wp_reset_postdata();
    }
    if ($postCount) {
        $export->set(array('exported' => $export->exported + $postCount))->save();
    }
    if ($posts_per_page != -1 and $postCount) {
        wp_send_json(array('exported' => $export->exported, 'percentage' => ceil($export->exported / $foundPosts * 100), 'done' => false, 'records_per_request' => $exportOptions['records_per_iteration']));
    } else {
        wp_reset_postdata();
        if (file_exists(PMXE_Plugin::$session->file)) {
            if ($exportOptions['export_to'] == 'xml') {
                file_put_contents(PMXE_Plugin::$session->file, '</' . $exportOptions['main_xml_tag'] . '>', FILE_APPEND);
            }
            $is_secure_import = PMXE_Plugin::getInstance()->getOption('secure');
            if (!$is_secure_import) {
                if (!$export->isEmpty()) {
                    $wp_filetype = wp_check_filetype(basename(PMXE_Plugin::$session->file), null);
                    $attachment_data = array('guid' => $wp_uploads['baseurl'] . '/' . _wp_relative_upload_path(PMXE_Plugin::$session->file), 'post_mime_type' => $wp_filetype['type'], 'post_title' => preg_replace('/\\.[^.]+$/', '', basename(PMXE_Plugin::$session->file)), 'post_content' => '', 'post_status' => 'inherit');
                    if (empty($export->attch_id)) {
                        $attach_id = wp_insert_attachment($attachment_data, PMXE_Plugin::$session->file);
//.........这里部分代码省略.........
开发者ID:GarryVeles,项目名称:Artibaltika,代码行数:101,代码来源:wp_ajax_wpallexport.php

示例15: __construct

 /**
  * __construct
  * 
  * Builds the Chunk object
  *
  * @param string $file The filename to work with
  * @param array $options The options with which to parse the file
  * @author Dom Hastings
  * @access public
  */
 public function __construct($file, $options = array(), $parser_type = false)
 {
     // merge the options together
     $this->options = array_merge($this->options, is_array($options) ? $options : array());
     $this->options['chunkSize'] *= PMXI_Plugin::getInstance()->getOption('chunk_size');
     // set the filename
     $this->file = $file;
     $this->parser_type = empty($parser_type) ? 'xmlreader' : $parser_type;
     $is_html = false;
     $f = @fopen($file, "rb");
     while (!@feof($f)) {
         $chunk = @fread($f, 1024);
         if (strpos($chunk, "<!DOCTYPE") === 0) {
             $is_html = true;
         }
         break;
     }
     @fclose($f);
     if ($is_html) {
         $path = $this->get_file_path();
         $this->is_404 = true;
         $this->reader = new XMLReader();
         @$this->reader->open($path);
         @$this->reader->setParserProperty(XMLReader::VALIDATE, false);
         return;
     }
     if (PMXI_Plugin::getInstance()->getOption('force_stream_reader')) {
         $this->parser_type = 'xmlstreamer';
     } else {
         $input = new PMXI_Input();
         $import_id = $input->get('id', 0);
         if (empty($import_id)) {
             $import_id = $input->get('import_id', 0);
         }
         if (!empty($import_id)) {
             $this->parser_type = empty($parser_type) ? 'xmlreader' : $parser_type;
             $import = new PMXI_Import_Record();
             $import->getById($import_id);
             if (!$import->isEmpty()) {
                 $this->parser_type = empty($import->options['xml_reader_engine']) ? 'xmlreader' : 'xmlstreamer';
             }
         } else {
             $this->parser_type = empty($parser_type) ? get_option('wpai_parser_type', 'xmlreader') : $parser_type;
         }
     }
     if (empty($this->options['element']) or $this->options['get_cloud']) {
         $path = $this->get_file_path();
         if ($this->parser_type == 'xmlreader') {
             $reader = new XMLReader();
             $reader->open($path);
             $reader->setParserProperty(XMLReader::VALIDATE, false);
             while (@$reader->read()) {
                 switch ($reader->nodeType) {
                     case XMLREADER::ELEMENT:
                         $localName = str_replace("_colon_", ":", $reader->localName);
                         if (array_key_exists(str_replace(":", "_", $localName), $this->cloud)) {
                             $this->cloud[str_replace(":", "_", $localName)]++;
                         } else {
                             $this->cloud[str_replace(":", "_", $localName)] = 1;
                         }
                         break;
                     default:
                         break;
                 }
             }
             unset($reader);
         } else {
             $CHUNK_SIZE = 1024;
             $streamProvider = new Prewk\XmlStringStreamer\Stream\File($path, $CHUNK_SIZE);
             $parseroptions = array("extractContainer" => false);
             // Works like an XmlReader, and walks the XML tree node by node. Captures by node depth setting.
             $parser = new Parser\StringWalker($parseroptions);
             // Create the streamer
             $streamer = new XmlStringStreamer($parser, $streamProvider);
             while ($node = $streamer->getNode()) {
                 // $simpleXmlNode = simplexml_load_string($node);
                 // echo (string)$simpleXmlNode->firstName;
             }
             $this->cloud = $parser->cloud;
         }
         if (!empty($this->cloud) and empty($this->options['element'])) {
             arsort($this->cloud);
             $main_elements = array('node', 'product', 'job', 'deal', 'entry', 'item', 'property', 'listing', 'hotel', 'record', 'article', 'post', 'book', 'item_0');
             foreach ($this->cloud as $element_name => $value) {
                 if (in_array(strtolower($element_name), $main_elements)) {
                     $this->options['element'] = $element_name;
                     break;
                 }
             }
             if (empty($this->options['element'])) {
//.........这里部分代码省略.........
开发者ID:estrategasdigitales,项目名称:rufiatta,代码行数:101,代码来源:chunk.php


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