Index: /controller/wpsg_ProduktController.class.php
===================================================================
--- /controller/wpsg_ProduktController.class.php	(revision 6333)
+++ /controller/wpsg_ProduktController.class.php	(revision 6334)
@@ -126,4 +126,7 @@
 			$this->shop->view['arData'] = wpsg_product::find($this->shop->view['arFilter']);
 
+			if (isset($_REQUEST['submit-button'])) $this->shop->view['submit'] = true;
+			else $this->shop->view['submit'] = false;
+			
 			$this->shop->render(WPSG_PATH_VIEW.'/produkt/index.phtml');
  
Index: /lib/functions.inc.php
===================================================================
--- /lib/functions.inc.php	(revision 6333)
+++ /lib/functions.inc.php	(revision 6334)
@@ -83,5 +83,5 @@
 	 * PrÃŒft die Eingabe eines Geburtsdatums auf GÃŒltigkeit
 	 * @param String $val
-	 */
+	 */  
 	function wpsg_isValidGeb(&$val)
 	{
Index: /lib/wpsg_basket.class.php
===================================================================
--- /lib/wpsg_basket.class.php	(revision 6333)
+++ /lib/wpsg_basket.class.php	(revision 6334)
@@ -1177,5 +1177,5 @@
 				}
 				
-				// Geburtsdatum
+				// Geburtsdatum 
 				if (
 						($custom_config['geb'] != '1' && !wpsg_isValidGeb($this->arCheckout['geb'])) ||
Index: /model/wpsg_product.class.php
===================================================================
--- /model/wpsg_product.class.php	(revision 6333)
+++ /model/wpsg_product.class.php	(revision 6334)
@@ -541,5 +541,5 @@
 					".$strQueryHAVING."
 			";
-				
+			
 			return $GLOBALS['wpsg_db']->fetchOne($strQuery);
 			
@@ -592,5 +592,5 @@
 					) AS innerSelect
 			";
-
+ 			
 			return $GLOBALS['wpsg_db']->fetchOne($strQuery);
 
@@ -634,5 +634,5 @@
 			// Wenn ich die nicht kaufbaren Produkte rausfiltern will, kann ich es nicht auf einen DB Query beschrÃ€nken, da ich die Module anfragen muss
 			//if (wpsg_isSizedInt($arFilter['hideNotBuyable'])) $force_load = true;
-				 			
+				  			
 			foreach ($arID as $id)
 			{
Index: /mods/mod_productgroups/wpsg_productgroup.php
===================================================================
--- /mods/mod_productgroups/wpsg_productgroup.php	(revision 6333)
+++ /mods/mod_productgroups/wpsg_productgroup.php	(revision 6334)
@@ -41,20 +41,54 @@
         /* Statische Funktionen */
 
-	    public static function getProductgroupSelect()
+	    public static function getProductgroupSelect($arProductFilter)
 	    {
-
-		    return $GLOBALS['wpsg_db']->fetchAssocField("
-		        SELECT
-		            PG.`id`, CONCAT(PG.`name`,' (', (
-		            	SELECT COUNT(*) FROM `".WPSG_TBL_PRODUCTS."` AS P WHERE (P.`pgruppe` = PG.`id` AND P.`deleted` = 0)
-		            ), ')') AS `name` ,
-		            (SELECT COUNT(*) FROM `".WPSG_TBL_PRODUCTS."` AS P WHERE (P.`pgruppe` = PG.`id` AND P.`deleted` = 0)) AS `product_count`
-		        FROM
-		        	`".WPSG_TBL_PRODUCTS_GROUP."` AS PG
-		        HAVING
-		            `product_count` > 0
-		        ORDER BY
-		            `name` ASC
-		    ", "id", "name");
+						
+			if (wpsg_isSizedArray($arProductFilter))
+			{
+								
+				unset($arProductFilter['limit']);
+				unset($arProductFilter['page']);
+				unset($arProductFilter['status']);
+				unset($arProductFilter['productgroup_ids']);
+				
+				list($strQuerySELECT, $strQueryWHERE, $strQueryJOIN, $strQueryHAVING, $strQueryORDER) = wpsg_product::getQueryParts($arProductFilter);
+						 				
+				$strQuery = "
+					SELECT
+						PG.`id`, CONCAT(PG.`name`,' (', (
+							SELECT COUNT(*) FROM `".WPSG_TBL_PRODUCTS."` AS P WHERE (P.`pgruppe` = PG.`id` AND P.`deleted` = 0 ".$strQueryWHERE.")
+						), ')') AS `name` ,
+						(
+							SELECT COUNT(*) FROM `".WPSG_TBL_PRODUCTS."` AS P WHERE (P.`pgruppe` = PG.`id` AND P.`deleted` = 0 ".$strQueryWHERE.")
+					  	) AS `product_count`
+					FROM
+						`".WPSG_TBL_PRODUCTS_GROUP."` AS PG
+					HAVING
+						`product_count` > 0
+					ORDER BY
+						`name` ASC
+				"; 
+				
+				return $GLOBALS['wpsg_db']->fetchAssocField($strQuery, "id", "name");
+				
+			}
+			else
+			{
+			
+				return $GLOBALS['wpsg_db']->fetchAssocField("
+					SELECT
+						PG.`id`, CONCAT(PG.`name`,' (', (
+							SELECT COUNT(*) FROM `".WPSG_TBL_PRODUCTS."` AS P WHERE (P.`pgruppe` = PG.`id` AND P.`deleted` = 0)
+						), ')') AS `name` ,
+						(SELECT COUNT(*) FROM `".WPSG_TBL_PRODUCTS."` AS P WHERE (P.`pgruppe` = PG.`id` AND P.`deleted` = 0)) AS `product_count`
+					FROM
+						`".WPSG_TBL_PRODUCTS_GROUP."` AS PG
+					HAVING
+						`product_count` > 0
+					ORDER BY
+						`name` ASC
+				", "id", "name");
+				
+			}
 
 	    } // public static function getProductgroupSelect()
Index: /mods/wpsg_mod_produktartikel.class.php
===================================================================
--- /mods/wpsg_mod_produktartikel.class.php	(revision 6333)
+++ /mods/wpsg_mod_produktartikel.class.php	(revision 6334)
@@ -97,5 +97,5 @@
 		{ 
 			 
-			if (wpsg_getStr($_REQUEST['do'], 'setWPMLPathKey'))
+			if (wpsg_isSizedString($_REQUEST['do'], 'setWPMLPathKey'))
 			{
 				
@@ -109,4 +109,104 @@
 				
 			}
+			else if (wpsg_isSizedString($_REQUEST['do'], 'index_rebuild'))
+			{
+				
+				$arProductIDs = $this->db->fetchAssocField("SELECT `id` FROM `".WPSG_TBL_PRODUCTS."` ", "id");
+				
+				if (wpsg_isSizedArray($arProductIDs))
+				{
+				
+					// Ich lÃ¶sche alle Posts zu denen es die Produkte nicht mehr gibt
+					$this->db->Query("
+						DELETE FROM 
+							`".$this->shop->prefix."posts` 
+						WHERE  
+							`wpsg_produkt_id` NOT IN (".wpsg_q(implode(',', $arProductIDs)).") AND
+							`wpsg_produkt_id` > 0
+					");
+					
+					$this->shop->update_option('wpsg_mod_produktartikel_rebuild', array(
+						'max' => sizeof($arProductIDs),
+						'product_ids' => $arProductIDs
+					));
+					 					
+					$this->shop->addBackendMessage(__('Zuordnungen werden neu aufgebaut. Bitte schlieÃen Sie die Seite nicht bis der Vorgang abgeschlossen ist.', 'wpsg'));				
+									
+				}
+				else
+				{
+									
+					$this->shop->update_option('wpsg_mod_produktartikel_rebuild', null);
+					
+					$this->shop->addBackendMessage(__('Ein Aufbau der Zuordnung nicht nicht notwendig.', 'wpsg'));
+					
+				}
+				
+				$this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&action=module&modul=wpsg_mod_produktartikel');
+				
+			}
+			else if (wpsg_isSizedString($_REQUEST['do'], 'rebuild'))
+			{
+				
+				$arToDo = $this->shop->get_option('wpsg_mod_produktartikel_rebuild');				
+				$arProductIDs = $arToDo['product_ids'];
+				
+				$i = 0;
+				$limit = 20; 
+				 
+				foreach ($arProductIDs as $k => $product_id)
+				{
+					
+					$product_data = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS."` WHERE `id` = '".wpsg_q($product_id)."' ");
+					$post_data = $this->db->fetchRow("SELECT * FROM `".$this->shop->prefix."posts` WHERE `wpsg_produkt_id` = '".wpsg_q($product_id)."' ");
+					
+					$_REQUEST['wpsg_mod_produktartikel']['path'] = wpsg_getStr($post_data['post_name'], '');
+					$_REQUEST['wpsg_mod_produktartikel']['kommentare'] = wpsg_getStr($post_data['comment_status'], '');
+					$_REQUEST['wpsg_produktartikel_menuorder'] = wpsg_getStr($post_data['menu_order'], '');
+					
+					if (wpsg_isSizedInt($product_data['lang_parent']))
+					{
+						
+						$_REQUEST['wpsg_lang'] = $product_data['lang_code'];
+						
+						$this->produkt_save_translation($product_data['lang_parent'], $product_data['id']);
+						
+					}
+					else
+					{
+					
+						$this->produkt_save($product_data['id']);
+						
+					}
+					
+					unset($arProductIDs[$k]);
+					
+					$i ++;
+					
+					if ($i >= $limit) break;
+					
+				}
+				
+				if (wpsg_isSizedArray($arProductIDs))
+				{
+					
+					$arToDo['product_ids'] = $arProductIDs;
+					$this->shop->update_option('wpsg_mod_produktartikel_rebuild', $arToDo);
+					$done = 1 - (sizeof($arProductIDs) / $arToDo['max']); 
+						
+				}
+				else
+				{
+					
+					$this->shop->update_option('wpsg_mod_produktartikel_rebuild', null);
+					$done = 1;
+					
+				}
+				
+				wpsg_header::JSONData(array(
+					'done' => $done
+				));
+				
+			}
 			
 		}
@@ -136,11 +236,6 @@
 			{
 				 
-				$product_id = $post->wpsg_produkt_id;
-				
-				$oProduct = wpsg_product::getInstance($product_id); 
-				
-				if (!$oProduct->canDisplay()) return -2;
-				
-				$content = $this->shop->renderProdukt($product_id);
+				$produkt_id = $post->wpsg_produkt_id;  
+				$content = $this->shop->renderProdukt($produkt_id);
 				
 				return -2;
@@ -194,4 +289,7 @@
 		public function settings_edit()
 		{
+			
+			// Rebuild
+			$this->shop->view['ToRebuild'] = $this->shop->get_option('wpsg_mod_produktartikel_rebuild');
 			
 			// VerfÃŒgbare Produkttemplates
@@ -309,4 +407,5 @@
 			
 			$post_content = $this->shop->renderProdukt($copy_id);
+			$post_content = $this->clear_post_content($post_content);
 			
 			$post_data = $this->db->fetchRow("
@@ -919,4 +1018,6 @@
 				}
 				
+				$post_content = $this->clear_post_content($post_content);
+				
 				$data = array(
 					"post_title" => wpsg_q($post_title), 
@@ -1006,4 +1107,11 @@
 		} // private function getPostIdFromProductId($product_id)
 		
+		private function clear_post_content($post_content) 
+		{
+			
+			return strip_tags(preg_replace('#<script(.*?)>(.*?)</script>#is', '', $post_content)); 
+			
+		} // private function clear_post_content($post_content)
+		
 		/**
 		 * FÃŒgt die Abfrage fÃŒr den PostType an den Wordpress Query
Index: /views/admin/form/input_submit.phtml
===================================================================
--- /views/admin/form/input_submit.phtml	(revision 6333)
+++ /views/admin/form/input_submit.phtml	(revision 6334)
@@ -4,5 +4,5 @@
 	
 	<div class="col-sm-6">
-		<input type="submit" value="<?php echo $this->view['field_label']; ?>" class="button button-primary" />		
+		<input name="submit-button" type="submit" value="<?php echo $this->view['field_label']; ?>" class="button button-primary" />		
 	</div>
 	
Index: /views/produkt/index.phtml
===================================================================
--- /views/produkt/index.phtml	(revision 6333)
+++ /views/produkt/index.phtml	(revision 6334)
@@ -17,5 +17,5 @@
 				<ul class="nav navbar-nav">
 					<li role="presentation" class="<?php echo ((!isset($_REQUEST['action']))?'active':''); ?>"><a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Produkt"><?php echo wpsg_translate(__("ProduktÃŒbersicht (#1# Produkte)", "wpsg"), $this->view['countAll']); ?></a></li>
-					<li role="presentation" class="wpsg_showhide_filter <?php echo (($this->view['hasFilter'] === true)?'active':''); ?>"><a href="#" onclick="return false;"><span class="glyphicon glyphicon-search"></span><?php echo __("Suche", "wpsg"); ?></a></li>
+					<li role="presentation" class="wpsg_showhide_filter <?php echo (($this->view['submit'] === true)?'active':''); ?>"><a href="#" onclick="return false;"><span class="glyphicon glyphicon-search"></span><?php echo __("Suche", "wpsg"); ?></a></li>
 			 		<li role="presentation" class="<?php echo ((wpsg_isSizedString($_REQUEST['action'], 'add'))?'active':''); ?>"><a href="<?php echo WPSG_URL_WP; ?>wp-admin/admin.php?page=wpsg-Produkt&action=add"><span class="glyphicon glyphicon-plus"></span><?php echo __("HinzufÃŒgen", "wpsg"); ?></a></li>
 				</ul>
@@ -31,5 +31,5 @@
 			</div>
 		</div>
-		<div class="wpsg-filter container-fluid form-horizontal" style="display:<?php echo (($this->view['hasFilter'] === true)?'block':'none'); ?>;">
+		<div class="wpsg-filter container-fluid form-horizontal" style="display:<?php echo (($this->view['submit'] === true)?'block':'none'); ?>;">
 			<div class="row">
 				<div class="col-lg-4">
@@ -42,8 +42,14 @@
 						<?php echo wpsg_drawForm_Input('filter[s]', __('Suchfeld', 'wpsg'), wpsg_getStr($this->view['arFilter']['s'])); ?>
                         
+                        <?php $filterAll = $this->view['arFilter']; unset($filterAll['productgroup_ids']); ?>
+                        
                         <?php if ($this->hasMod('wpsg_mod_productgroups')) { ?>
-                        <?php echo wpsg_drawForm_Select('filter[productgroup_ids]', __('Produktgruppe', 'wpsg'), wpsg_array_merge(array('-1' => wpsg_translate(__('Alle Produktgruppen (#1#)', 'wpsg'), wpsg_product::count())), wpsg_productgroup::getProductgroupSelect()), @$this->view['arFilter']['productgroup_ids']); ?>
+                        <?php echo wpsg_drawForm_Select('filter[productgroup_ids]', __('Produktgruppe', 'wpsg'), wpsg_array_merge(array('-1' => wpsg_translate(__('Alle Produktgruppen (#1#)', 'wpsg'), wpsg_product::count($filterAll))), wpsg_productgroup::getProductgroupSelect($this->view['arFilter'])), @$this->view['arFilter']['productgroup_ids']); ?>
                         <?php } ?>
 						
+                        <?php if (wpsg_istrue($this->view['submit'])) { ?>
+                        <input type="hidden" name="submit-button" value="1" />
+                        <?php } ?>
+                        
 						<?php echo wpsg_drawForm_SubmitButton(__('Produkte suchen')); ?><br />
 						
@@ -54,10 +60,12 @@
 	</nav>
 
-    <?php if ($this->hasMod('wpsg_mod_productgroups')) { $arProductgroupSelect = wpsg_productgroup::getProductgroupSelect(); ?>
+    <?php if ($this->hasMod('wpsg_mod_productgroups')) { $arProductgroupSelect = wpsg_productgroup::getProductgroupSelect($this->view['arFilter']); ?>
         <?php if (wpsg_isSizedArray($arProductgroupSelect)) { ?>
             <div class="pagination_wrap wpsg_productgroup_link_wrap">
-
+                
+                <?php $filterAll = $this->view['arFilter']; unset($filterAll['productgroup_ids']); ?>
+                
                 <ul class="pagination">
-                    <li class="<?php echo ((wpsg_getStr($this->view['arFilter']['productgroup_ids']) == '-1' || !isset($this->view['arFilter']['productgroup_ids']))?'active':''); ?>"><a href="#" onclick="jQuery('#filterproductgroup_ids').val('-1'); jQuery('#filter_form').submit(); return false;"><?php echo wpsg_translate(__('Alle (#1#)', 'wpsg'), wpsg_product::count()); ?></a></li>
+                    <li class="<?php echo ((wpsg_getStr($this->view['arFilter']['productgroup_ids']) == '-1' || !isset($this->view['arFilter']['productgroup_ids']))?'active':''); ?>"><a href="#" onclick="jQuery('#filterproductgroup_ids').val('-1'); jQuery('#filter_form').submit(); return false;"><?php echo wpsg_translate(__('Alle (#1#)', 'wpsg'), wpsg_product::count($filterAll)); ?></a></li>
                     <?php foreach ($arProductgroupSelect as $pg_id => $pg_name) { ?>
                     <li class="<?php echo ((wpsg_getStr($this->view['arFilter']['productgroup_ids']) == $pg_id)?'active':''); ?>"><a href="#" onclick="jQuery('#filterproductgroup_ids').val('<?php echo $pg_id; ?>'); jQuery('#wpsg_seite').val('1'); jQuery('#filter_form').submit(); return false;"><?php echo $pg_name; ?></a></li>
