Changeset 13895
- Timestamp:
- 12/14/07 11:40:47 (10 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/midcom/midcom.helper.filesync/importer/snippet.php
r13894 r13895 90 90 if ($encoding != 'UTF-8') 91 91 { 92 if ($encoding == 'ASCII')93 {94 $encoding = 'ISO-8859-1';95 }96 92 $file_contents = @iconv($encoding, 'UTF-8', $file_contents); 97 93 } trunk/midcom/midcom.helper.filesync/importer/style.php
r13894 r13895 64 64 65 65 // Deal with element 66 $element_contents = file_get_contents("{$path}/{$entry}"); 66 67 // Check file type 68 $filename_parts = explode('.', $entry); 69 if (count($filename_parts) < 2) 70 { 71 continue; 72 } 73 $element_name = $filename_parts[0]; 74 $field = false; 75 switch($filename_parts[count($filename_parts) - 1]) 76 { 77 case 'php': 78 $field = 'value'; 79 break; 80 } 81 if (!$field) 82 { 83 continue; 84 } 85 86 $file_contents = file_get_contents("{$path}/{$entry}"); 87 $encoding = mb_detect_encoding($file_contents); 88 if ($encoding != 'UTF-8') 89 { 90 $file_contents = @iconv($encoding, 'UTF-8', $file_contents); 91 } 92 67 93 $qb = midcom_db_element::new_query_builder(); 68 94 $qb->add_constraint('style', '=', $style->id); 69 $qb->add_constraint('name', '=', $e ntry);95 $qb->add_constraint('name', '=', $element_name); 70 96 if ($qb->count() == 0) 71 97 { … … 73 99 $element = new midcom_db_element(); 74 100 $element->style = $style->id; 75 $element->name = $e ntry;76 $element-> value = $element_contents;101 $element->name = $element_name; 102 $element->$field = $file_contents; 77 103 $element->create(); 78 104 continue; … … 83 109 84 110 // Update existing elements only if they have actually changed 85 if ($element-> value != $element_contents)111 if ($element->$field != $file_contents) 86 112 { 87 $element-> value = $element_contents;113 $element->$field = $file_contents; 88 114 $element->update(); 89 115 }
