| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @file 4 * Used to import archive data as nodes 5 */ 6 7 // Include Drupal 8 require_once ('./includes/bootstrap.inc'); 9 drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); 10 11 12 //Define Config Variables 13 define("NODE_TYPE","fyeo_archive_item"); 14 define("JSON_LOCATION","http://bsd7.emax.local/fyeo/archive.json"); 15 16 /** 17 * Returns a node object from legacy json 18 * @param obj $legacy_obj a json pr object 19 * @param obj $node a node obj 20 * legacy_obj Data Definition 21 * $legacy_obj->TITLE 22 * $legacy_obj->SUMMARY 23 * $legacy_obj->CONTACT_ID 24 * $legacy_obj->CONTENT 25 * $legacy_obj->PUBLISH_ON 26 * $legacy_obj->SUBCAT1 27 * $legacy_obj->SUBCAT2 28 **/ 29 function legacyimporter_createnode($item) { 30 // $user = legacyimporter_contactid_to_user($legacy_obj->CONTACT_ID); //Function for mapping legacy User ID's to UID/NAME 31 $node = new stdClass(); 32 $node->type = NODE_TYPE; 33 $node->language = ''; 34 $node->uid = 77; // fyeo_staff 35 $node->status = 1; 36 // $node->created = $legacy_obj->PUBLISH_ON; 37 $node->title = $item->title; 38 //$node->name = $user["name"]; 39 //$node->body = $legacy_obj->CONTENT; 40 //Custom CCK Field 41 42 $url = str_replace("http://gatewave.org","",$item->url); 43 44 $node->field_fyeo_archive_filelen[0] = array("value" => $item->length); 45 $node->field_fyeo_archive_keywords[0] = array("value" => $item->keywords); 46 $node->field_fyeo_archive_pubdate[0] = array("value" => $item->pubDate); 47 $node->field_fyeo_archive_type [0] = array("value" => $item->type); 48 $node->field_fyeo_archive_description[0] = array("value" => $item->description); 49 $node->field_fyeo_archive_url[0] = array("value" => $url, "format" => 1); 50 $node->created=strtotime( $item->pubDate ); 51 52 53 print_r($node); 54 print "<br> <br>"; 55 //*/ 56 return $node; 57 } 58 59 /** 60 * Function for downloading a legacy JSON row 61 * @param int $id ID of article 62 * @return obj $node object 63 **/ 64 function legacyimporter_process_json($id) { 65 $url = JSON_LOCATION; // . "?id=" . $id; 66 $node = FALSE; 67 $result = drupal_http_request($url); 68 if($result->code == 200) { 69 $archive_obj = json_decode(trim($result->data)); 70 //$node = legacyimporter_createnode($archive_obj); 71 } 72 return $node; 73 } 74 75 print "Sample Node:<br>"; 76 print_r(node_load(170)); 77 print "<br> <br>"; 78 //*/ 79 80 $result = drupal_http_request(JSON_LOCATION); //Grab JSON 81 $article_tally = 0; 82 if($result->code == 200) { 83 $legacy_array = json_decode(trim($result->data)); 84 if(is_array($legacy_array)) { 85 $cnt=0; 86 foreach($legacy_array as $item) { 87 //print "Desc: ".$item->description . "<br>"; 88 $node = legacyimporter_createnode($item); 89 //$valid = legacyimporter_validatenode($node); 90 //This is a function to validate the node 91 node_save(&$node); 92 $node_cnt++; 93 } 94 print "Nodes created: $node_cnt <br>"; 95 } 96 } 97 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |