Index: /controller/wpsg_ProduktController.class.php
===================================================================
--- /controller/wpsg_ProduktController.class.php	(revision 6210)
+++ /controller/wpsg_ProduktController.class.php	(revision 6216)
@@ -26,4 +26,10 @@
 			{
 				$this->exportAction();				
+			}
+			else if (wpsg_isSizedString($_REQUEST['action'], 'exportMedia')) 
+			{
+				
+				$this->exportMediaAction();
+				
 			}
 			else if (wpsg_isSizedString($_REQUEST['action'], 'import'))
@@ -127,5 +133,5 @@
 		 * Wird beim exportieren der Produkte aufgerufen
 		 */
-		public function exportAction()
+		public function exportAction($bReturnData = false)
 		{
 			
@@ -159,4 +165,7 @@
 			$fp = fopen($path.'/wpsg_productexport.csv', 'w');
 			fputcsv($fp, array_keys($arData[0]));;
+			
+			$arDataExport = array();
+			
 			foreach ($arData as $e)
 			{
@@ -165,6 +174,10 @@
 				if (get_option('wpsg_impexp_clearlinebreak') === '1')
 				{
-					foreach ($e as $k => $v) { $e[$k] = preg_replace('/\r|\n/', '', $v); }										
-				}
+					
+					foreach ($e as $k => $v) { $e[$k] = preg_replace('/\r|\n/', '', $v); }
+					
+				}
+				
+				$arDataExport[] = $e;
 				
 				fputcsv($fp, $e, ',', '"');
@@ -173,15 +186,80 @@
 			fclose($fp);
 			
-			header('Content-type: application/download');
-			header('Content-Disposition:inline; filename="wpsg_productexport.csv"');
-			header('Expires: 0');
-			header('Cache-Control:must-revalidate, post-check=0, pre-check=0');
-			header('Pragma:public');
-				 
-			readfile($path.'/wpsg_productexport.csv');
-			die(); 
+			if ($bReturnData) return array($path.'/wpsg_productexport.csv', $arDataExport);
+			else
+			{
+			
+				header('Content-type: application/download');
+				header('Content-Disposition:inline; filename="wpsg_productexport.csv"');
+				header('Expires: 0');
+				header('Cache-Control:must-revalidate, post-check=0, pre-check=0');
+				header('Pragma:public');
+					 
+				readfile($path.'/wpsg_productexport.csv');
+				die(); 
+				
+			}
 			
 		} // public function exportAction()
 		
+		public function exportMediaAction()
+		{
+			
+			@ini_set('memory_limit', '2000M');			
+			@set_time_limit(3600);
+            
+			$zip_file = tempnam(sys_get_temp_dir(), 'wpsg');			
+			$zip = new ZipArchive();
+			
+			if ($zip->open($zip_file, ZIPARCHIVE::CREATE) == true) 
+			{
+				
+				// Produktdaten, wie normaler Export
+				list($product_export_file, $arData) = $this->exportAction(true);				
+				$zip->addFile($product_export_file, 'productdata.csv');
+			
+				// Bilddaten
+				if ($this->shop->hasMod('wpsg_mod_produktbilder'))
+				{
+				
+					foreach ($arData as $d)
+					{
+											
+						$arImages = $this->shop->callMod('wpsg_mod_produktbilder', 'getProduktBilder_MT', array($d['id'], 'full'));
+						 
+						if (wpsg_isSizedArray($arImages))
+						{
+						 
+							$zip->addEmptyDir($d['id']); 
+							
+							foreach ($arImages as $i)
+							{
+								
+								$zip->addFile($i['path'], $d['id'].'/'.$i['basename']);
+								
+							}
+														
+						}
+                        					
+					}
+				
+				}
+				
+				$zip->close();
+				
+				wpsg_header::ZIP($zip_file, 'wpsg_export.zip');
+				
+			}
+			else
+			{
+				
+				$this->addBackendError(_('Konnte ZIP Archiv nicht erstellen.', 'wpsg'));
+				
+			}
+			
+			$this->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Produkt');
+			
+		} // public function exportMediaAction()
+		
 		/**
 		 * Wird beim importieren der Produkte aufgerufen. Zeichnet das Upload Formular und fÃŒhrt auch den Import durch 
@@ -190,4 +268,7 @@
 		{
 			 
+            @ini_set('memory_limit', '2000M');			
+			@set_time_limit(3600);
+            
 			if (isset($_REQUEST['wpsg_import']) && file_exists($_FILES['wpsg_importfile']['tmp_name']))
 			{
@@ -196,7 +277,76 @@
  
 				$nImported = 0;
-				
+				$arImages = array();
 				$keys = array();
-				$handle = fopen($_FILES['wpsg_importfile']['tmp_name'], "r");  
+                $extract_dir = '';
+                
+                if (preg_match('/\.zip$/i', $_FILES['wpsg_importfile']['name']))
+				{
+                    
+                    $zip = new ZipArchive();
+										
+					if ($zip->open($_FILES['wpsg_importfile']['tmp_name']) === true) 
+					{
+						
+						$extract_dir = sys_get_temp_dir().'/'.time();
+						
+						$zip->extractTo($extract_dir);
+    					$zip->close();
+													
+						if (!file_exists($extract_dir) || !is_dir($extract_dir))
+						{
+							
+							$this->shop->addBackendError(__('Konnte ZIP Archiv nicht entpacken.', 'wpsg'));
+							$this->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Produkt');
+							
+						}
+						else
+						{
+							
+							$arZIPData = scandir($extract_dir);
+							 
+							foreach ($arZIPData as $z)
+							{
+								
+								if (is_numeric($z))
+								{
+									
+									$arImages[$z] = array();
+									$arImageFiles = scandir($extract_dir.'/'.$z);
+									
+									foreach ($arImageFiles as $if) { if (is_file($extract_dir.'/'.$z.'/'.$if)) { $arImages[$z][] = $if; } }
+									
+								}
+								
+							}
+							
+						}
+                        
+                        if (!file_exists($extract_dir.'/productdata.csv'))
+                        {
+                            
+                            $this->shop->addBackendError(__('Keine Produktdaten im ZIP Archiv gefunden.', 'wpsg'));
+							$this->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Produkt');
+                            
+                        }
+
+						$handle = fopen($extract_dir.'/productdata.csv', "r");
+						
+					}
+					else
+					{
+					
+						$this->shop->addBackendError(__('Konnte ZIP Archiv nicht Ã¶ffnen.', 'wpsg'));
+						$this->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Produkt');
+						
+					}
+                    
+                }
+                else
+                {
+                 
+				    $handle = fopen($_FILES['wpsg_importfile']['tmp_name'], "r");
+                    
+                }
 				
 				$i = 0;
@@ -227,5 +377,5 @@
 						}
 						
-						$nImported ++;
+                        if (!isset($data['lang_parent']) || $data['lang_parent'] <= 0) $nImported ++;
 						
 						unset($data['v_id']);
@@ -267,4 +417,27 @@
 							
 						}
+                        
+                        // Bilder?
+						if (wpsg_isSizedInt($data['id']) && wpsg_isSizedArray($arImages[$data['id']]) && $this->shop->hasMod('wpsg_mod_produktbilder') && $this->shop->hasMod('wpsg_mod_produktbilder'))
+                        {
+                            
+                            foreach (array_reverse($arImages[$data['id']]) as $img)
+                            {
+                                
+                                // PrÃŒfen ob ein Bild anhand des Namens schon im Produkt existiert
+                                $arImagesExists = $this->shop->callMod('wpsg_mod_produktbilder', 'getProduktBilder_MT', array($data['id'], 'full')); $exists = false;
+                                
+                                foreach ($arImagesExists as $k => $v)
+                                {
+                                
+                                    if (strtolower($v['basename']) === strtolower($img)) { $exists = true; break; }
+                                    
+                                }
+                                
+                                if (!$exists) $this->shop->callMod('wpsg_mod_produktbilder', 'addImageToProduct', array($extract_dir.'/'.$data['id'].'/'.$img, $data['id']));
+                                
+                            }
+                                                           
+                        }
 						
 					}
Index: /lib/wpsg_header.class.php
===================================================================
--- /lib/wpsg_header.class.php	(revision 6210)
+++ /lib/wpsg_header.class.php	(revision 6216)
@@ -41,4 +41,23 @@
 		} // public static function JSONData()
 		
+		public static function ZIP($file, $filename = false)
+		{
+			
+			if ($filename === false) $filename = basename($file);
+			
+			header("Pragma: public");
+			header("Expires: 0");
+			header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
+			header("Cache-Control: public");
+			header("Content-Description: File Transfer");
+			header("Content-type: application/octet-stream");
+			header("Content-Disposition: attachment; filename=\"".$filename."\"");
+			header("Content-Transfer-Encoding: binary");
+			header("Content-Length: ".filesize($file));
+		
+			readfile($file);
+			
+		}
+		
 	} // class wpsg_header
 
Index: /mods/wpsg_mod_produktbilder.class.php
===================================================================
--- /mods/wpsg_mod_produktbilder.class.php	(revision 6210)
+++ /mods/wpsg_mod_produktbilder.class.php	(revision 6216)
@@ -203,6 +203,6 @@
 			else if ($_REQUEST['cmd'] == 'upload_mt')
 			{
-				// Mediathek
-				
+				
+				// Mediathek				
 				$fname = $_FILES['userfile']['name'][0];
 
@@ -210,11 +210,11 @@
 				$wp_upload_dir = wp_upload_dir();
 				$attachment = array(
-						'guid'           => $wp_upload_dir['url'] . '/' . basename( $fname ),
-						'post_mime_type' => $filetype['type'],
-						'post_title'     => preg_replace( '/\.[^.]+$/', '', basename( $fname ) ),
-						'post_excerpt'   => wpsg_q($fname),
-						'post_parent'	 => '0',
-						'wpsg_produkt_id'=> '6',
-						'post_status'    => 'inherit'
+					'guid' => wpsg_q($wp_upload_dir['url'] . '/' . basename($fname)),
+					'post_mime_type' => wpsg_q($filetype['type']),
+					'post_title' => wpsg_q(preg_replace('/\.[^.]+$/', '', basename($fname))),
+					'post_excerpt' => wpsg_q($fname),
+					'post_parent' => '0',
+					'wpsg_produkt_id' => '6',
+					'post_status' => 'inherit'
 				);
 				
@@ -307,10 +307,23 @@
 		} // public function produkt_ajax()
 		
-		public function diverse_array($vector) {
+		public function diverse_array($vector) 
+		{
+			
 			$result = array();
+			
 			foreach($vector as $key1 => $value1)
+			{
+				
 				foreach($value1 as $key2 => $value2)
+				{
+					
 					$result[$key2][$key1] = $value2;
+					
+				}
+				
+			}
+			
 			return $result;
+			
 		}
 		
@@ -425,5 +438,44 @@
 		
 		/* Modulfunktionen */
- 
+
+		/**
+		 * Mediatheksfunktion
+		 * FÃŒgt ein neues Bild zu einem Produkt hinzu
+		 * 
+		 * @param String $file Absoluter Pfad zu dem Bild
+		 * @param $product_id ID des Produktes zu dem das Bild zugeordnet werden soll
+		 */
+		public function addImageToProduct($file, $product_id)
+		{
+			
+			// Siehe
+			// https://codex.wordpress.org/Function_Reference/wp_insert_attachment
+			
+			$wp_upload_dir = wp_upload_dir();
+			
+			$mt_filetype = wp_check_filetype(basename($file), null);
+			$mt_filename = $wp_upload_dir['path'].'/'.basename($file);
+			
+			copy($file, $mt_filename);
+			
+			$attachment = array(
+				'guid' => wpsg_q($wp_upload_dir['url'].'/'.basename($file)),
+				'post_mime_type' => wpsg_q($mt_filetype['type']),
+				'post_title' => wpsg_q(preg_replace('/\.[^.]+$/', '', basename($file))),
+				'post_excerpt' => wpsg_q(basename($file)),
+				'post_status' => 'inherit'
+			);
+			
+			$attachment_id = wp_insert_attachment($attachment, $mt_filename, '0');
+			
+			require_once(ABSPATH.'wp-admin/includes/image.php');
+			
+			$attach_data = wp_generate_attachment_metadata($attachment_id, $mt_filename);
+			wp_update_attachment_metadata($attachment_id, $attach_data);
+			
+			add_post_meta($attachment_id, 'wpsg_produkt_id', $product_id);
+						
+		} // public function addImageToProduct($file, $product_id)
+		
 		/**
 		 * Wird vom Template produkt_edit_content.phtml aufgerufen und per Ajax aktualisiert.
@@ -579,28 +631,41 @@
 		/**
 		 * Gibt ein Array mit den Produktbildern zurÃŒck
+		 * $size = 'full' sollte OriginalgrÃ¶Ãe zurÃŒckgeben
 		 */
 		public function getProduktBilder_MT($produkt_id, $size = 'thumbnail')
 		{
-				
-			$arFiles = array();
-		
+			
 			global $wpdb;
-			$data = $this->db->fetchAssoc("SELECT * FROM `".$wpdb->prefix."postmeta` WHERE `meta_key`='".wpsg_q('wpsg_produkt_id')."' AND `meta_value`='".wpsg_q($produkt_id)."' ");
+				
+			$arFiles = array();		
+			
+			$data = $this->db->fetchAssoc("SELECT * FROM `".$wpdb->prefix."postmeta` WHERE `meta_key` = 'wpsg_produkt_id' AND `meta_value` = '".wpsg_q($produkt_id)."' ");
+			$ud = wp_upload_dir(); 
 			
 			$i = 0;
-			foreach ($data as $key => $val) {
+			
+			foreach ($data as $key => $val) 
+			{
+				
 				$p = wp_get_attachment_image_src($val['post_id'], $size);	// Array mit Full-Path, Width, Height
+				 
 				$guid = $p[0];
 				$arrf = pathinfo($guid);
+				
 				//$this->shop->view['ProduktBilder_MT'][$i]['pid'] = $val['post_id'];
 				//$this->shop->view['ProduktBilder_MT'][$i]['fname'] = $arrf['basename'];
 				//$this->shop->view['ProduktBilder_MT'][$i]['guid'] = $guid;
+				
 				$arFiles[$i]['guid'] = $guid;
 				$arFiles[$i]['post_id'] = $val['post_id'];
 				$arFiles[$i]['basename'] = $arrf['basename'];
+				$arFiles[$i]['url'] = $guid;
+				$arFiles[$i]['path'] = str_replace($ud['baseurl'], $ud['basedir'], $guid);				
 				
 				$i++;
-			}
-			/*	
+				
+			}
+			
+			/*
 			wpsg_asort($arFiles);
 				
@@ -610,4 +675,5 @@
 			return $arReturn;
 			*/
+			
 			return $arFiles;
 			
Index: /views/produkt/index.phtml
===================================================================
--- /views/produkt/index.phtml	(revision 6210)
+++ /views/produkt/index.phtml	(revision 6216)
@@ -21,7 +21,10 @@
 				</ul>
 				<ul class="nav navbar-nav navbar-right">
-					<li role="presentation" class="<?php echo ((wpsg_isSizedString($_REQUEST['action'], 'import'))?'active':''); ?>"><a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Produkt&action=import&noheader=1"><span class="glyphicon glyphicon-import"></span><?php echo __("Import", "wpsg"); ?></a></li>
+					<li role="presentation" class="<?php echo ((wpsg_isSizedString($_REQUEST['action'], 'import'))?'active':''); ?>"><a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Produkt&action=import"><span class="glyphicon glyphicon-import"></span><?php echo __("Import", "wpsg"); ?></a></li>
 					<?php if (wpsg_isSizedArray($this->view['arData'])) { ?>
 					<li role="presentation" class="<?php echo ((wpsg_isSizedString($_REQUEST['action'], 'export'))?'active':''); ?>"><a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Produkt&action=export&noheader=1"><span class="glyphicon glyphicon-export"></span><?php echo __("Export", "wpsg"); ?></a></li>
+                    <?php if ($this->hasMod('wpsg_mod_produktbilder')) { ?>
+                    <li role="presentation" class="<?php echo ((wpsg_isSizedString($_REQUEST['action'], 'export'))?'active':''); ?>"><a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Produkt&action=exportMedia&noheader=1"><span class="glyphicon glyphicon-export"></span><?php echo __("Export mit Medien", "wpsg"); ?></a></li>
+                    <?php } ?>
 					<?php } ?>
 			 	</ul>			 	
