Skip to content

Commit

Permalink
updated info file
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark committed Jun 12, 2017
0 parents commit 7b3cbec
Show file tree
Hide file tree
Showing 4 changed files with 253 additions and 0 deletions.
15 changes: 15 additions & 0 deletions mnn_show_import.features.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
/**
* @file
* mnn_show_import.features.inc
*/

/**
* Implements hook_ctools_plugin_api().
*/
function mnn_show_import_ctools_plugin_api() {
list($module, $api) = func_get_args();
if ($module == "feeds" && $api == "feeds_importer_default") {
return array("version" => "1");
}
}
156 changes: 156 additions & 0 deletions mnn_show_import.feeds_importer_default.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<?php
/**
* @file
* mnn_show_import.feeds_importer_default.inc
*/

/**
* Implements hook_feeds_importer_default().
*/
function mnn_show_import_feeds_importer_default() {
$export = array();

$feeds_importer = new stdClass;
$feeds_importer->disabled = FALSE; /* Edit this to true to make a default feeds_importer disabled initially */
$feeds_importer->api_version = 1;
$feeds_importer->id = 'mnn_show_import';
$feeds_importer->config = array(
'name' => 'Show Import',
'description' => '',
'fetcher' => array(
'plugin_key' => 'FeedsFileFetcher',
'config' => array(
'allowed_extensions' => 'txt csv tsv xml opml',
'direct' => FALSE,
),
),
'parser' => array(
'plugin_key' => 'FeedsCSVParser',
'config' => array(
'delimiter' => ';',
'no_headers' => 0,
),
),
'processor' => array(
'plugin_key' => 'FeedsNodeProcessor',
'config' => array(
'content_type' => 'cm_show',
'expire' => '-1',
'author' => '0',
'mappings' => array(
0 => array(
'source' => 'title',
'target' => 'title',
'unique' => 0,
),
1 => array(
'source' => 'created',
'target' => 'created',
'unique' => FALSE,
),
2 => array(
'source' => 'exec_producer_id',
'target' => 'uid',
'unique' => FALSE,
),
3 => array(
'source' => 'language',
'target' => 'taxonomy_pbcore_languages',
'unique' => FALSE,
),
4 => array(
'source' => 'device',
'target' => 'field_device',
'unique' => FALSE,
),
5 => array(
'source' => 'runtime',
'target' => 'field_runtime',
'unique' => FALSE,
),
6 => array(
'source' => 'content_type',
'target' => 'field_pbcore_genres',
'unique' => FALSE,
),
7 => array(
'source' => 'format',
'target' => 'field_format',
'unique' => FALSE,
),
8 => array(
'source' => 'topic',
'target' => 'field_topic',
'unique' => FALSE,
),
9 => array(
'source' => 'schedule_type',
'target' => 'taxonomy_cm_project_types',
'unique' => FALSE,
),
10 => array(
'source' => 'live_device',
'target' => 'field_device',
'unique' => FALSE,
),
11 => array(
'source' => 'reject_reason',
'target' => 'field_reject_reason',
'unique' => FALSE,
),
12 => array(
'source' => 'delivered_via',
'target' => 'field_delivered_via',
'unique' => FALSE,
),
13 => array(
'source' => 'episode_id',
'target' => 'guid',
'unique' => 1,
),
14 => array(
'source' => 'time_code_in',
'target' => 'field_timecode_in',
'unique' => FALSE,
),
15 => array(
'source' => 'time_code_out',
'target' => 'field_timecode_out',
'unique' => FALSE,
),
16 => array(
'source' => 'transcoded_time_code_in',
'target' => 'field_trans_timecode_in',
'unique' => FALSE,
),
17 => array(
'source' => 'transcoded_time_code_out',
'target' => 'field_trans_timecode_out',
'unique' => FALSE,
),
18 => array(
'source' => 'runtime_type',
'target' => 'field_runtime',
'unique' => FALSE,
),
19 => array(
'source' => 'episode_number',
'target' => 'field_episode_number',
'unique' => FALSE,
),
),
'update_existing' => '2',
'input_format' => 'plain_text',
),
),
'content_type' => '',
'update' => 0,
'import_period' => '-1',
'expire_period' => 3600,
'import_on_create' => 1,
'process_in_background' => 1,
);
$export['mnn_show_import'] = $feeds_importer;

return $export;
}
10 changes: 10 additions & 0 deletions mnn_show_import.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
core = "7.x"
dependencies[] = "feeds"
description = "Feed for Importing Show CSV"
features[ctools][] = "feeds:feeds_importer_default:1"
features[feeds_importer][] = "mnn_show_import"
name = "MNN Show Import"
package = "MNN Features"
php = "5.2.4"
project = "mnn_show_import"
version = "7.x-1.0-beta1"
72 changes: 72 additions & 0 deletions mnn_show_import.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/**
* @file
* Code for the MNN Show Import feature.
*/

include_once('mnn_show_import.features.inc');

/**
* Implements hook_menu()
*/
function mnn_show_import_menu() {

$items['admin/show/resave-all'] = array(
'title' => 'Resave All Shows',
'description' => 'Enable Active Projects',
'page callback' => 'mnn_show_import_resave_batch_init',
'access arguments' => array('administer group'),
'type' => MENU_CALLBACK
);

return $items;
}

function mnn_show_import_resave_batch_init() {

$batch = array(
'title' => t('Resaving Show Nodes...'),
'operations' => array(),
'init_message' => t('Starting Resave'),
'progress_message' => t('Processed @current out of @total.'),
'error_message' => t('An error occurred during processing'),
'finished' => 'mnn_show_import_resave_batch_finished',
'progressive' => FALSE
);

//query all show nodes

//SELECT nid, ogm.id FROM node n LEFT JOIN og_membership ogm ON etid = nid WHERE n.type = 'cm_show' and ogm.id IS NULL

$result = db_query('SELECT nid FROM {node} n LEFT JOIN {og_membership} ogm ON etid = nid WHERE n.type = :type AND ogm.id IS NULL', array(':type' => 'cm_show'));

//query show nodes without OG2 reference
//etid


$count = 0;
foreach ($result as $record) {
if ($count < 10000) {
$batch['operations'][] = array('mnn_show_import_resave_batch_worker', array($record->nid));
$count++;
}
}



batch_set($batch);

batch_process('admin/content');
}

function mnn_show_import_resave_batch_worker($nid, &$context) {

$node = node_load($nid);
if (isset($node->field_temp_project_id['und'][0]['value']) && $node->field_temp_project_id['und'][0]['value']) {
$node->og_node2['und'][0]['target_id'] = $node->field_temp_project_id['und'][0]['value'];
}
node_save($node);

$context['results']['processed']++;
$context['message'] = 'Successfully resaved Show #' . $array[0];
}

0 comments on commit 7b3cbec

Please sign in to comment.