/** * Implements hook_feeds_processor_targets_alter(). */ function my_module_feeds_feeds_processor_targets_alter(array &$targets, $entity_type, $bundle) { if( $entity_type=="node"&&$bundle=="chinese_word"){ $field_info = field_info_instances("node", "chinese_word") ; if( array_key_exists('field_ch_word_sentences', $field_info ) && field_info_field( 'field_ch_word_sentences' )['type'] == "entityreference" ){ $targets["field_ch_word_sentences:drills_hander"] = array( 'name' => check_plain( $field_info['field_ch_word_sentences']['label'] ).t(' (Import multiple value instance field)'), 'callback' => 'drills_custom_feeds_set_target_entity_reference', 'description' => t('This filed for converting Chinese Examples to word reference only.Do not use it for other fields!!'), ); } } }
function drills_custom_feeds_set_target_entity_reference($source, &$entity, $target, $value, $mapping){ if (empty($value)) { return; } $target = str_replace(':drills_hander', '', $target); $query = db_query("select title, nid, CHAR_LENGTH(title) as char_num from node where title like '%".$value[0]."%' and type='example_sentences' order by char_num limit 100"); $sentences = $query->fetchAll(); $field = array(); foreach( $sentences as $i => $sentence ){ $field[LANGUAGE_NONE][$i]['target_id'] = $sentence->nid; } $entity->{$target} = $field; }
/** * Encode the field and return the encoded value. */ function feeds_tamper_utf8_encode_callback($result, $item_key, $element_key, &$field, $settings, $source) { // $field = utf8_encode($field); $field = iconv(null, 'utf-8', $field); }
/** * Encode the field and return the encoded value. */ function feeds_tamper_utf8_encode_callback($result, $item_key, $element_key, &$field, $settings, $source) { // $field = utf8_encode($field); $field = iconv(null, 'utf-8', $field); }
添付 | サイズ |
---|---|
feeds_tamper_utf_8_encode.zip (11.18 KB) | 11.18 KB |
添付 | サイズ |
---|---|
feeds_entity_processor-1033202-217.patch_.txt (16.03 KB) | 16.03 KB |
The user bear is not authorized to update content of type chinese_word. To import this item, either the user "bear" (author of the item) must be given the permission to update content of type chinese_word, or the option "Authorize" on the Node processor settings must be turned off.
/** * Implements hook_cron_job_scheduler_info(). */ function drills_custom_feeds_cron_job_scheduler_info() { $schedulers = array(); $schedulers['chinese_sentence_import_scheduler'] = array( 'worker callback' => 'chinese_sentence_import', // タスク内容のコールバック ); return $schedulers; }
function chinese_sentence_import($job) { // 実際のタスク処理ロジック }
//Add a job. $job = array( 'type' => 'story', // 任意の識別名 'id' => 20170309, // 任意のID(例:日付) 'period' => 3600, // 実行開始時間(例:3600秒後から実行) 'periodic' => FALSE, // 周期的に実行か(FALSE:一回のみ、TRUE:周期的) ); JobScheduler::get('chinese_sentence_import_scheduler')->set($job);
JobScheduler::get('chinese_sentence_import_scheduler')->dispath($job);
// バッチ定義の配列 $batch=array{ 'title' => t('バッチのタイトル'), // バッチの名前 'operations' => array(), // オペレーション配列 'finished' => 'import_finished_callback', //終了時のコールバック関数 'progress_message' => t('Finished @current out of @total.'), // 状態表示 } // オペレーション配列の定義 $batch['operations'][] = array('batch_operation_function_1', array( [引数が無ければ、空の配列] ) ); $batch['operations'][] = array('batch_operation_function_2', array( $arg_1, $arg_2 ) ); ・・・・・・ // バッチの実行 batch_set($batch); // オペレーション関数 function batch_operation_function($arg_1, $arg_2, &$context){ // バッチ内の処理 }
/** * Implements hook_cron_job_scheduler_info(). */ function drills_custom_feeds_cron_job_scheduler_info() { $schedulers = array(); $schedulers['chinese_sentence_import_scheduler'] = array( 'worker callback' => 'chinese_sentence_import', // タスク内容のコールバック ); return $schedulers; }
function chinese_sentence_import($job) { // 実際のタスク処理ロジック }
//Add a job. $job = array( 'type' => 'story', // 任意の識別名 'id' => 20170309, // 任意のID(例:日付) 'period' => 3600, // 実行開始時間(例:3600秒後から実行) 'periodic' => FALSE, // 周期的に実行か(FALSE:一回のみ、TRUE:周期的) ); JobScheduler::get('chinese_sentence_import_scheduler')->set($job);
JobScheduler::get('chinese_sentence_import_scheduler')->dispath($job);
// バッチ定義の配列 $batch=array{ 'title' => t('バッチのタイトル'), // バッチの名前 'operations' => array(), // オペレーション配列 'finished' => 'import_finished_callback', //終了時のコールバック関数 'progress_message' => t('Finished @current out of @total.'), // 状態表示 } // オペレーション配列の定義 $batch['operations'][] = array('batch_operation_function_1', array( [引数が無ければ、空の配列] ) ); $batch['operations'][] = array('batch_operation_function_2', array( $arg_1, $arg_2 ) ); ・・・・・・ // バッチの実行 batch_set($batch); // オペレーション関数 function batch_operation_function($arg_1, $arg_2, &$context){ // バッチ内の処理 }
/** * Implements hook_cron_job_scheduler_info(). */ function drills_custom_feeds_cron_job_scheduler_info() { $schedulers = array(); $schedulers['chinese_sentence_import_scheduler'] = array( 'worker callback' => 'chinese_sentence_import', // タスク内容のコールバック ); return $schedulers; }
function chinese_sentence_import($job) { // 実際のタスク処理ロジック }
//Add a job. $job = array( 'type' => 'story', // 任意の識別名 'id' => 20170309, // 任意のID(例:日付) 'period' => 3600, // 実行開始時間(例:3600秒後から実行) 'periodic' => FALSE, // 周期的に実行か(FALSE:一回のみ、TRUE:周期的) ); JobScheduler::get('chinese_sentence_import_scheduler')->set($job);
JobScheduler::get('chinese_sentence_import_scheduler')->dispath($job);
// バッチ定義の配列 $batch=array{ 'title' => t('バッチのタイトル'), // バッチの名前 'operations' => array(), // オペレーション配列 'finished' => 'import_finished_callback', //終了時のコールバック関数 'progress_message' => t('Finished @current out of @total.'), // 状態表示 } // オペレーション配列の定義 $batch['operations'][] = array('batch_operation_function_1', array( [引数が無ければ、空の配列] ) ); $batch['operations'][] = array('batch_operation_function_2', array( $arg_1, $arg_2 ) ); ・・・・・・ // バッチの実行 batch_set($batch); // オペレーション関数 function batch_operation_function($arg_1, $arg_2, &$context){ // バッチ内の処理 }
/** * Implements hook_cron_job_scheduler_info(). */ function drills_custom_feeds_cron_job_scheduler_info() { $schedulers = array(); $schedulers['chinese_sentence_import_scheduler'] = array( 'worker callback' => 'chinese_sentence_import', // タスク内容のコールバック ); return $schedulers; }
function chinese_sentence_import($job) { // 実際のタスク処理ロジック }
//Add a job. $job = array( 'type' => 'story', // 任意の識別名 'id' => 20170309, // 任意のID(例:日付) 'period' => 3600, // 実行開始時間(例:3600秒後から実行) 'periodic' => FALSE, // 周期的に実行か(FALSE:一回のみ、TRUE:周期的) ); JobScheduler::get('chinese_sentence_import_scheduler')->set($job);
JobScheduler::get('chinese_sentence_import_scheduler')->dispath($job);
// バッチ定義の配列 $batch=array{ 'title' => t('バッチのタイトル'), // バッチの名前 'operations' => array(), // オペレーション配列 'finished' => 'import_finished_callback', //終了時のコールバック関数 'progress_message' => t('Finished @current out of @total.'), // 状態表示 } // オペレーション配列の定義 $batch['operations'][] = array('batch_operation_function_1', array( [引数が無ければ、空の配列] ) ); $batch['operations'][] = array('batch_operation_function_2', array( $arg_1, $arg_2 ) ); ・・・・・・ // バッチの実行 batch_set($batch); // オペレーション関数 function batch_operation_function($arg_1, $arg_2, &$context){ // バッチ内の処理 }
/** * Implements hook_cron_job_scheduler_info(). */ function drills_custom_feeds_cron_job_scheduler_info() { $schedulers = array(); $schedulers['chinese_sentence_import_scheduler'] = array( 'worker callback' => 'chinese_sentence_import', // タスク内容のコールバック ); return $schedulers; }
function chinese_sentence_import($job) { // 実際のタスク処理ロジック }
//Add a job. $job = array( 'type' => 'story', // 任意の識別名 'id' => 20170309, // 任意のID(例:日付) 'period' => 3600, // 実行開始時間(例:3600秒後から実行) 'periodic' => FALSE, // 周期的に実行か(FALSE:一回のみ、TRUE:周期的) ); JobScheduler::get('chinese_sentence_import_scheduler')->set($job);
JobScheduler::get('chinese_sentence_import_scheduler')->dispath($job);
// バッチ定義の配列 $batch=array{ 'title' => t('バッチのタイトル'), // バッチの名前 'operations' => array(), // オペレーション配列 'finished' => 'import_finished_callback', //終了時のコールバック関数 'progress_message' => t('Finished @current out of @total.'), // 状態表示 } // オペレーション配列の定義 $batch['operations'][] = array('batch_operation_function_1', array( [引数が無ければ、空の配列] ) ); $batch['operations'][] = array('batch_operation_function_2', array( $arg_1, $arg_2 ) ); ・・・・・・ // バッチの実行 batch_set($batch); // オペレーション関数 function batch_operation_function($arg_1, $arg_2, &$context){ // バッチ内の処理 }
/** * Implements hook_cron_job_scheduler_info(). */ function drills_custom_feeds_cron_job_scheduler_info() { $schedulers = array(); $schedulers['chinese_sentence_import_scheduler'] = array( 'worker callback' => 'chinese_sentence_import', // タスク内容のコールバック ); return $schedulers; }
function chinese_sentence_import($job) { // 実際のタスク処理ロジック }
//Add a job. $job = array( 'type' => 'story', // 任意の識別名 'id' => 20170309, // 任意のID(例:日付) 'period' => 3600, // 実行開始時間(例:3600秒後から実行) 'periodic' => FALSE, // 周期的に実行か(FALSE:一回のみ、TRUE:周期的) ); JobScheduler::get('chinese_sentence_import_scheduler')->set($job);
JobScheduler::get('chinese_sentence_import_scheduler')->dispath($job);
// バッチ定義の配列 $batch=array{ 'title' => t('バッチのタイトル'), // バッチの名前 'operations' => array(), // オペレーション配列 'finished' => 'import_finished_callback', //終了時のコールバック関数 'progress_message' => t('Finished @current out of @total.'), // 状態表示 } // オペレーション配列の定義 $batch['operations'][] = array('batch_operation_function_1', array( [引数が無ければ、空の配列] ) ); $batch['operations'][] = array('batch_operation_function_2', array( $arg_1, $arg_2 ) ); ・・・・・・ // バッチの実行 batch_set($batch); // オペレーション関数 function batch_operation_function($arg_1, $arg_2, &$context){ // バッチ内の処理 }
/** * Implements hook_cron_job_scheduler_info(). */ function drills_custom_feeds_cron_job_scheduler_info() { $schedulers = array(); $schedulers['chinese_sentence_import_scheduler'] = array( 'worker callback' => 'chinese_sentence_import', // タスク内容のコールバック ); return $schedulers; }
function chinese_sentence_import($job) { // 実際のタスク処理ロジック }
//Add a job. $job = array( 'type' => 'story', // 任意の識別名 'id' => 20170309, // 任意のID(例:日付) 'period' => 3600, // 実行開始時間(例:3600秒後から実行) 'periodic' => FALSE, // 周期的に実行か(FALSE:一回のみ、TRUE:周期的) ); JobScheduler::get('chinese_sentence_import_scheduler')->set($job);
JobScheduler::get('chinese_sentence_import_scheduler')->dispath($job);
// バッチ定義の配列 $batch=array{ 'title' => t('バッチのタイトル'), // バッチの名前 'operations' => array(), // オペレーション配列 'finished' => 'import_finished_callback', //終了時のコールバック関数 'progress_message' => t('Finished @current out of @total.'), // 状態表示 } // オペレーション配列の定義 $batch['operations'][] = array('batch_operation_function_1', array( [引数が無ければ、空の配列] ) ); $batch['operations'][] = array('batch_operation_function_2', array( $arg_1, $arg_2 ) ); ・・・・・・ // バッチの実行 batch_set($batch); // オペレーション関数 function batch_operation_function($arg_1, $arg_2, &$context){ // バッチ内の処理 }
/** * Implements hook_cron_job_scheduler_info(). */ function drills_custom_feeds_cron_job_scheduler_info() { $schedulers = array(); $schedulers['chinese_sentence_import_scheduler'] = array( 'worker callback' => 'chinese_sentence_import', // タスク内容のコールバック ); return $schedulers; }
function chinese_sentence_import($job) { // 実際のタスク処理ロジック }
//Add a job. $job = array( 'type' => 'story', // 任意の識別名 'id' => 20170309, // 任意のID(例:日付) 'period' => 3600, // 実行開始時間(例:3600秒後から実行) 'periodic' => FALSE, // 周期的に実行か(FALSE:一回のみ、TRUE:周期的) ); JobScheduler::get('chinese_sentence_import_scheduler')->set($job);
JobScheduler::get('chinese_sentence_import_scheduler')->dispath($job);
// バッチ定義の配列 $batch=array{ 'title' => t('バッチのタイトル'), // バッチの名前 'operations' => array(), // オペレーション配列 'finished' => 'import_finished_callback', //終了時のコールバック関数 'progress_message' => t('Finished @current out of @total.'), // 状態表示 } // オペレーション配列の定義 $batch['operations'][] = array('batch_operation_function_1', array( [引数が無ければ、空の配列] ) ); $batch['operations'][] = array('batch_operation_function_2', array( $arg_1, $arg_2 ) ); ・・・・・・ // バッチの実行 batch_set($batch); // オペレーション関数 function batch_operation_function($arg_1, $arg_2, &$context){ // バッチ内の処理 }
/** * Implements hook_cron_job_scheduler_info(). */ function drills_custom_feeds_cron_job_scheduler_info() { $schedulers = array(); $schedulers['chinese_sentence_import_scheduler'] = array( 'worker callback' => 'chinese_sentence_import', // タスク内容のコールバック ); return $schedulers; }
function chinese_sentence_import($job) { // 実際のタスク処理ロジック }
//Add a job. $job = array( 'type' => 'story', // 任意の識別名 'id' => 20170309, // 任意のID(例:日付) 'period' => 3600, // 実行開始時間(例:3600秒後から実行) 'periodic' => FALSE, // 周期的に実行か(FALSE:一回のみ、TRUE:周期的) ); JobScheduler::get('chinese_sentence_import_scheduler')->set($job);
JobScheduler::get('chinese_sentence_import_scheduler')->dispath($job);
// バッチ定義の配列 $batch=array{ 'title' => t('バッチのタイトル'), // バッチの名前 'operations' => array(), // オペレーション配列 'finished' => 'import_finished_callback', //終了時のコールバック関数 'progress_message' => t('Finished @current out of @total.'), // 状態表示 } // オペレーション配列の定義 $batch['operations'][] = array('batch_operation_function_1', array( [引数が無ければ、空の配列] ) ); $batch['operations'][] = array('batch_operation_function_2', array( $arg_1, $arg_2 ) ); ・・・・・・ // バッチの実行 batch_set($batch); // オペレーション関数 function batch_operation_function($arg_1, $arg_2, &$context){ // バッチ内の処理 }
/** * Implements hook_cron_job_scheduler_info(). */ function drills_custom_feeds_cron_job_scheduler_info() { $schedulers = array(); $schedulers['chinese_sentence_import_scheduler'] = array( 'worker callback' => 'chinese_sentence_import', // タスク内容のコールバック ); return $schedulers; }
function chinese_sentence_import($job) { // 実際のタスク処理ロジック }
//Add a job. $job = array( 'type' => 'story', // 任意の識別名 'id' => 20170309, // 任意のID(例:日付) 'period' => 3600, // 実行開始時間(例:3600秒後から実行) 'periodic' => FALSE, // 周期的に実行か(FALSE:一回のみ、TRUE:周期的) ); JobScheduler::get('chinese_sentence_import_scheduler')->set($job);
JobScheduler::get('chinese_sentence_import_scheduler')->dispath($job);
// バッチ定義の配列 $batch=array{ 'title' => t('バッチのタイトル'), // バッチの名前 'operations' => array(), // オペレーション配列 'finished' => 'import_finished_callback', //終了時のコールバック関数 'progress_message' => t('Finished @current out of @total.'), // 状態表示 } // オペレーション配列の定義 $batch['operations'][] = array('batch_operation_function_1', array( [引数が無ければ、空の配列] ) ); $batch['operations'][] = array('batch_operation_function_2', array( $arg_1, $arg_2 ) ); ・・・・・・ // バッチの実行 batch_set($batch); // オペレーション関数 function batch_operation_function($arg_1, $arg_2, &$context){ // バッチ内の処理 }