Index: /changelog
===================================================================
--- /changelog	(revision 7032)
+++ /changelog	(revision 7033)
@@ -127,2 +127,3 @@
 - Bugfix: PDF Dokumente im Backend nur verlinkt wenn auch aus einem Gutscheinprodukt erstellt
 - Bugfix: Start- und Enddatum der Gutscheine aus Gutscheinprodukt in der korrekten Zeitzone erstellt
+- Bugfix: Template fÃŒr die Listeansicht in Produktartikeln kann jetzt definiert werden 
Index: /mods/wpsg_mod_produktartikel.class.php
===================================================================
--- /mods/wpsg_mod_produktartikel.class.php	(revision 7032)
+++ /mods/wpsg_mod_produktartikel.class.php	(revision 7033)
@@ -1,928 +1,928 @@
 <?php
 
-
-	/**
-	 * Modul der die Produkte als eigene Artikeltypen speichert
-	 */
-	class wpsg_mod_produktartikel extends wpsg_mod_basic
-	{
-
-		var $lizenz = 1;
-		var $id = 15;
-		var $version = "9.9.9";
-		var $free = false;
-
-		/**
-		 * Constructor
-		 */
-		public function __construct()
-		{
-
-			parent::__construct();
-
-			$this->name = __('ProduktArtikel', 'wpsg');
-			$this->group = __('Produkte', 'wpsg');
-			$this->desc = __('Produkte sind ein eigener Wordpress Artikeltyp und erscheinen so als Artikel und in der Suche.', 'wpsg');
-
-		} // public function __construct()
-
-		public function init()
-		{
-
-			add_action('init', array($this, 'create_wpsg_post_types'));
-
-		} // public function init()
-
-		public function wpsg_enqueue_scripts()
-		{
-
-			if (is_admin()) return;
-
-			if (	(	$this->shop->get_option('wpsg_mod_produktartikel_facebook') == '1' ||
-						$this->shop->get_option('wpsg_mod_produktartikel_google') == '1' ||
-						$this->shop->get_option('wpsg_mod_produktartikel_twitter') == '1') &&
-						$this->shop->get_option('wpsg_mod_produktartikel_noJS') != '1')
-			{
-
-				wp_enqueue_script('wpsg_mod_produktartikel_shariff', $this->shop->getRessourceURL('js/shariff/shariff.min.js'));
-				wp_enqueue_style ('wpsg_mod_produktartikel_shariff', $this->shop->getRessourceURL('js/shariff/shariff.min.css'));
-
-			}
-
-		} // public function wpsg_enqueue_scripts()
-
-		public function install()
-		{
-
-			require_once(WPSG_PATH_WP.'/wp-admin/includes/upgrade.php');
-
-			/**
-			 * Produkt Tabelle erweitern
-			 */
-			$sql = "CREATE TABLE ".WPSG_TBL_PRODUCTS." (
-		   		ean VARCHAR(255) NOT NULL,
-				gtin VARCHAR (255) NOT NULL
-		   	) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
-
-			dbDelta($sql);
-
-			// Standard Path Key setzen
-			if ($this->shop->get_option('wpsg_mod_produktartikel_pathkey') === false || $this->shop->get_option('wpsg_mod_produktartikel_pathkey') == '')
-			{
-
-				$this->shop->update_option('wpsg_mod_produktartikel_pathkey', 'produkt');
-
-			}
-
+    
+    /**
+     * Modul der die Produkte als eigene Artikeltypen speichert
+     */
+    class wpsg_mod_produktartikel extends wpsg_mod_basic
+    {
+    
+        var $lizenz = 1;
+        var $id = 15;
+        var $version = "9.9.9";
+        var $free = false;
+    
+        /**
+         * Constructor
+         */
+        public function __construct()
+        {
+    
+            parent::__construct();
+    
+            $this->name = __('ProduktArtikel', 'wpsg');
+            $this->group = __('Produkte', 'wpsg');
+            $this->desc = __('Produkte sind ein eigener Wordpress Artikeltyp und erscheinen so als Artikel und in der Suche.', 'wpsg');
+    
+        } // public function __construct()
+    
+        public function init()
+        {
+    
+            add_action('init', array($this, 'create_wpsg_post_types'));
+    
+        } // public function init()
+    
+        public function wpsg_enqueue_scripts()
+        {
+    
+            if (is_admin()) return;
+    
+            if (	(	$this->shop->get_option('wpsg_mod_produktartikel_facebook') == '1' ||
+                    $this->shop->get_option('wpsg_mod_produktartikel_google') == '1' ||
+                    $this->shop->get_option('wpsg_mod_produktartikel_twitter') == '1') &&
+                $this->shop->get_option('wpsg_mod_produktartikel_noJS') != '1')
+            {
+    
+                wp_enqueue_script('wpsg_mod_produktartikel_shariff', $this->shop->getRessourceURL('js/shariff/shariff.min.js'));
+                wp_enqueue_style ('wpsg_mod_produktartikel_shariff', $this->shop->getRessourceURL('js/shariff/shariff.min.css'));
+    
+            }
+    
+        } // public function wpsg_enqueue_scripts()
+    
+        public function install()
+        {
+    
+            require_once(WPSG_PATH_WP.'/wp-admin/includes/upgrade.php');
+    
+            /**
+             * Produkt Tabelle erweitern
+             */
+            $sql = "CREATE TABLE ".WPSG_TBL_PRODUCTS." (
+                    ean VARCHAR(255) NOT NULL,
+                    gtin VARCHAR (255) NOT NULL
+                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
+    
+            dbDelta($sql);
+    
+            // Standard Path Key setzen
+            if ($this->shop->get_option('wpsg_mod_produktartikel_pathkey') === false || $this->shop->get_option('wpsg_mod_produktartikel_pathkey') == '')
+            {
+    
+                $this->shop->update_option('wpsg_mod_produktartikel_pathkey', 'produkt');
+    
+            }
+    
             // Standard Path Key (Kategorien) setzen
             if ($this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat') === false || $this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat') == '')
             {
-
+    
                 $this->shop->update_option('wpsg_mod_produktartikel_pathkey_cat', 'produkte');
-
-            }
-
-			$this->shop->checkDefault('wpsg_mod_produktartikel_showui', '0');
-			$this->shop->checkDefault('wpsg_mod_produktartikel_showHome', '0');
-			$this->shop->checkDefault('wpsg_mod_produktartikel_showCategory', '1');
-			$this->shop->checkDefault('wpsg_mod_produktartikel_showFeed', '0');
-			$this->shop->checkDefault('wpsg_mod_produktartikel_showSearch', '0');
-			$this->shop->checkDefault('wpsg_mod_produktartikel_rating', '10');
+    
+            }
+    
+            $this->shop->checkDefault('wpsg_mod_produktartikel_showui', '0');
+            $this->shop->checkDefault('wpsg_mod_produktartikel_showHome', '0');
+            $this->shop->checkDefault('wpsg_mod_produktartikel_showCategory', '1');
+            $this->shop->checkDefault('wpsg_mod_produktartikel_showFeed', '0');
+            $this->shop->checkDefault('wpsg_mod_produktartikel_showSearch', '0');
+            $this->shop->checkDefault('wpsg_mod_produktartikel_rating', '10');
             $this->shop->checkDefault('wpsg_mod_produktartikel_postthumbnail', '1');
-			/*
-			 * Posts Tabelle erweitern
-			 */
-			$sql = "CREATE TABLE ".$this->shop->prefix."posts (
-		   		wpsg_produkt_id INT(11) NOT NULL,
-		   		KEY wpsg_produkt_id (`wpsg_produkt_id`)
-		   	) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
-
-   			dbDelta($sql);
-
-		}
-
-		public function be_ajax()
-		{
-
-			if (wpsg_isSizedString($_REQUEST['do'], 'setWPMLPathKey'))
-			{
-
-				$icl_sitepress_settings = $this->shop->get_option('icl_sitepress_settings');
-
-				$icl_sitepress_settings['custom_posts_sync_option'][$this->shop->get_option('wpsg_mod_produktartikel_pathkey')] = '1';
-				$this->shop->update_option('icl_sitepress_settings', $icl_sitepress_settings);
-
-				$this->shop->addBackendMessage(__('Der Custom Post Type fÃŒr die Produkte kann nun ÃŒbersetzt werden.', 'wpsg'));
-				$this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&action=ueber&subaction=systemcheck');
-
-			}
-			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']);
-						
-						$this->shop->callMod('wpsg_mod_productvariants', 'produkt_save', array(&$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
-				));
-
-			}
-
-		}
-
-		public function the_excerpt(&$content)
-		{
-
-			global $post;
-
-			if (get_post_type($post) == $this->shop->get_option('wpsg_mod_produktartikel_pathkey'))
-			{
-
-				$produkt_id = $post->wpsg_produkt_id;
-				$content = $this->shop->renderProdukt($produkt_id);
-
-			}
-
-		} // public function the_excerpt(&$content)
-
-		public function content_filter(&$content)
-		{
-
-			global $post;
-
-			// Artikel ist ein Produkt, hier das Rendern des Templates ÃŒbernehmen
-			if (get_post_type($post) == $this->shop->get_option('wpsg_mod_produktartikel_pathkey'))
-			{
-
-				$produkt_id = $post->wpsg_produkt_id;
-				$content = $this->shop->renderProdukt($produkt_id);
-
-				return -2;
-
-			}
-
-		} // public function content_filter()
-
-		public function pre_get_posts(&$query)
-		{
-
-			if (wpsg_isSizedInt($this->shop->get_option('wpsg_mod_produktartikel_onlyMainQuery')) && !$query->is_main_query()) return;
-
-			if ($this->shop->get_option('wpsg_mod_produktartikel_showHome') == '1' && is_home())
-			{
-
-				$this->setPostType($query);
-
-			}
-
-			if ($this->shop->get_option('wpsg_mod_produktartikel_showCategory') == '1' && is_category())
-			{
-
-				$this->setPostType($query);
-
-			}
-
-			if ($this->shop->get_option('wpsg_mod_produktartikel_showFeed') == '1' && is_feed())
-			{
-
-				$this->setPostType($query);
-
-			}
-
-			if ($this->shop->get_option('wpsg_mod_produktartikel_showSearch') == '1' && is_search())
-			{
-
-				$this->setPostType($query);
-
-			}
-
-			if (is_single() && $query->is_main_query())
-			{
-
-				$this->setPostType($query);
-
-			}
-
-		} // public function pre_get_posts(&$query)
-
-		public function settings_edit()
-		{
-
-			// Rebuild
-			$this->shop->view['ToRebuild'] = $this->shop->get_option('wpsg_mod_produktartikel_rebuild');
-
-			// VerfÃŒgbare Produkttemplates
-			$this->shop->view['arTemplates'] = $this->shop->loadProduktTemplates(true);
-
-			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_produktartikel/settings_edit.phtml');
-
-		}
-
-		public function settings_save()
-		{
-
-			global $wpdb;
-
-			$this->shop->update_option('wpsg_mod_produktartikel_showHome', $_REQUEST['wpsg_mod_produktartikel_showHome']);
-			$this->shop->update_option('wpsg_mod_produktartikel_showCategory', $_REQUEST['wpsg_mod_produktartikel_showCategory']);
-			$this->shop->update_option('wpsg_mod_produktartikel_showFeed', $_REQUEST['wpsg_mod_produktartikel_showFeed']);
-			$this->shop->update_option('wpsg_mod_produktartikel_showSearch', $_REQUEST['wpsg_mod_produktartikel_showSearch']);
-			$this->shop->update_option('wpsg_mod_produktartikel_onlyMainQuery', $_REQUEST['wpsg_mod_produktartikel_onlyMainQuery']);
-
-			$this->shop->update_option('wpsg_mod_produktartikel_hometemplate', $_REQUEST['wpsg_mod_produktartikel_hometemplate']);
-			$this->shop->update_option('wpsg_mod_produktartikel_listtemplate', $_REQUEST['wpsg_mod_produktartikel_listtemplate']);
-			$this->shop->update_option('wpsg_mod_produktartikel_searchtemplate', $_REQUEST['wpsg_mod_produktartikel_searchtemplate']);
-
-			$this->shop->update_option('wpsg_mod_produktartikel_showui', $_REQUEST['wpsg_mod_produktartikel_showui']);
+            /*
+             * Posts Tabelle erweitern
+             */
+            $sql = "CREATE TABLE ".$this->shop->prefix."posts (
+                    wpsg_produkt_id INT(11) NOT NULL,
+                    KEY wpsg_produkt_id (`wpsg_produkt_id`)
+                ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;";
+    
+            dbDelta($sql);
+    
+        }
+    
+        public function be_ajax()
+        {
+    
+            if (wpsg_isSizedString($_REQUEST['do'], 'setWPMLPathKey'))
+            {
+    
+                $icl_sitepress_settings = $this->shop->get_option('icl_sitepress_settings');
+    
+                $icl_sitepress_settings['custom_posts_sync_option'][$this->shop->get_option('wpsg_mod_produktartikel_pathkey')] = '1';
+                $this->shop->update_option('icl_sitepress_settings', $icl_sitepress_settings);
+    
+                $this->shop->addBackendMessage(__('Der Custom Post Type fÃŒr die Produkte kann nun ÃŒbersetzt werden.', 'wpsg'));
+                $this->shop->redirect(WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&action=ueber&subaction=systemcheck');
+    
+            }
+            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']);
+    
+                        $this->shop->callMod('wpsg_mod_productvariants', 'produkt_save', array(&$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
+                ));
+    
+            }
+    
+        }
+    
+        public function the_excerpt(&$content)
+        {
+    
+            global $post;
+    
+            if (get_post_type($post) == $this->shop->get_option('wpsg_mod_produktartikel_pathkey'))
+            {
+    
+                $produkt_id = $post->wpsg_produkt_id;
+                $content = $this->shop->renderProdukt($produkt_id);
+    
+            }
+    
+        } // public function the_excerpt(&$content)
+    
+        public function content_filter(&$content)
+        {
+    
+            global $post;
+    
+            // Artikel ist ein Produkt, hier das Rendern des Templates ÃŒbernehmen
+            if (get_post_type($post) == $this->shop->get_option('wpsg_mod_produktartikel_pathkey'))
+            {
+    
+                $produkt_id = $post->wpsg_produkt_id;
+                $content = $this->shop->renderProdukt($produkt_id);
+    
+                return -2;
+    
+            }
+    
+        } // public function content_filter()
+    
+        public function pre_get_posts(&$query)
+        {
+    
+            if (wpsg_isSizedInt($this->shop->get_option('wpsg_mod_produktartikel_onlyMainQuery')) && !$query->is_main_query()) return;
+    
+            if ($this->shop->get_option('wpsg_mod_produktartikel_showHome') == '1' && is_home())
+            {
+    
+                $this->setPostType($query);
+    
+            }
+    
+            if ($this->shop->get_option('wpsg_mod_produktartikel_showCategory') == '1' && is_tax($this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat')))
+            {
+    
+                $this->setPostType($query);
+    
+            }
+    
+            if ($this->shop->get_option('wpsg_mod_produktartikel_showFeed') == '1' && is_feed())
+            {
+    
+                $this->setPostType($query);
+    
+            }
+    
+            if ($this->shop->get_option('wpsg_mod_produktartikel_showSearch') == '1' && is_search())
+            {
+    
+                $this->setPostType($query);
+    
+            }
+    
+            if (is_single() && $query->is_main_query())
+            {
+    
+                $this->setPostType($query);
+    
+            }
+    
+        } // public function pre_get_posts(&$query)
+    
+        public function settings_edit()
+        {
+    
+            // Rebuild
+            $this->shop->view['ToRebuild'] = $this->shop->get_option('wpsg_mod_produktartikel_rebuild');
+    
+            // VerfÃŒgbare Produkttemplates
+            $this->shop->view['arTemplates'] = $this->shop->loadProduktTemplates(true);
+    
+            $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_produktartikel/settings_edit.phtml');
+    
+        }
+    
+        public function settings_save()
+        {
+    
+            global $wpdb;
+    
+            $this->shop->update_option('wpsg_mod_produktartikel_showHome', $_REQUEST['wpsg_mod_produktartikel_showHome']);
+            $this->shop->update_option('wpsg_mod_produktartikel_showCategory', $_REQUEST['wpsg_mod_produktartikel_showCategory']);
+            $this->shop->update_option('wpsg_mod_produktartikel_showFeed', $_REQUEST['wpsg_mod_produktartikel_showFeed']);
+            $this->shop->update_option('wpsg_mod_produktartikel_showSearch', $_REQUEST['wpsg_mod_produktartikel_showSearch']);
+            $this->shop->update_option('wpsg_mod_produktartikel_onlyMainQuery', $_REQUEST['wpsg_mod_produktartikel_onlyMainQuery']);
+    
+            $this->shop->update_option('wpsg_mod_produktartikel_hometemplate', $_REQUEST['wpsg_mod_produktartikel_hometemplate']);
+            $this->shop->update_option('wpsg_mod_produktartikel_listtemplate', $_REQUEST['wpsg_mod_produktartikel_listtemplate']);
+            $this->shop->update_option('wpsg_mod_produktartikel_searchtemplate', $_REQUEST['wpsg_mod_produktartikel_searchtemplate']);
+    
+            $this->shop->update_option('wpsg_mod_produktartikel_showui', $_REQUEST['wpsg_mod_produktartikel_showui']);
             $this->shop->update_option('wpsg_mod_produktartikel_ean', $_REQUEST['wpsg_mod_produktartikel_ean']);
             $this->shop->update_option('wpsg_mod_produktartikel_gtin', $_REQUEST['wpsg_mod_produktartikel_gtin']);
             $this->shop->update_option('wpsg_mod_produktartikel_comment', $_REQUEST['wpsg_mod_produktartikel_comment']);
-
-			$this->shop->update_option('wpsg_mod_produktartikel_postthumbnail', $_REQUEST['wpsg_mod_produktartikel_postthumbnail']);
-
-			$pathkey_alt = $this->shop->get_option('wpsg_mod_produktartikel_pathkey');
-			$pathkey_new = $this->shop->clear($_REQUEST['wpsg_mod_produktartikel_pathkey']);
-
-			$this->shop->update_option('wpsg_mod_produktartikel_rating', $_REQUEST['wpsg_mod_produktartikel_rating']);
-			
-			if ($pathkey_alt != $_REQUEST['wpsg_mod_produktartikel_pathkey'] && $pathkey_new != '')
-			{
-
-				$this->db->UpdateQuery($this->shop->prefix."posts", array(
-					'post_type' => wpsg_q($pathkey_new)
-				), "`post_type` = '".wpsg_q($pathkey_alt)."'");
-
-				$this->shop->update_option('wpsg_mod_produktartikel_pathkey', $pathkey_new);
-
-				$this->shop->addBackendMessage(__('Path Key erfolgreich geÃ€ndert. Die Produkt URLs haben sich geÃ€ndert!', 'wpsg'));
-
-			}
-			else if (trim($_REQUEST['wpsg_mod_produktartikel_pathkey']) == '')
-			{
-
-				$this->shop->addBackendError(__('Der Path Key darf nicht leer sein!', 'wpsg'));
-
-			}
-
+    
+            $this->shop->update_option('wpsg_mod_produktartikel_postthumbnail', $_REQUEST['wpsg_mod_produktartikel_postthumbnail']);
+    
+            $pathkey_alt = $this->shop->get_option('wpsg_mod_produktartikel_pathkey');
+            $pathkey_new = $this->shop->clear($_REQUEST['wpsg_mod_produktartikel_pathkey']);
+    
+            $this->shop->update_option('wpsg_mod_produktartikel_rating', $_REQUEST['wpsg_mod_produktartikel_rating']);
+    
+            if ($pathkey_alt != $_REQUEST['wpsg_mod_produktartikel_pathkey'] && $pathkey_new != '')
+            {
+    
+                $this->db->UpdateQuery($this->shop->prefix."posts", array(
+                    'post_type' => wpsg_q($pathkey_new)
+                ), "`post_type` = '".wpsg_q($pathkey_alt)."'");
+    
+                $this->shop->update_option('wpsg_mod_produktartikel_pathkey', $pathkey_new);
+    
+                $this->shop->addBackendMessage(__('Path Key erfolgreich geÃ€ndert. Die Produkt URLs haben sich geÃ€ndert!', 'wpsg'));
+    
+            }
+            else if (trim($_REQUEST['wpsg_mod_produktartikel_pathkey']) == '')
+            {
+    
+                $this->shop->addBackendError(__('Der Path Key darf nicht leer sein!', 'wpsg'));
+    
+            }
+    
             $pathkey_cat_old = $this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat');
             $pathkey_cat_new = $this->shop->clear($_REQUEST['wpsg_mod_produktartikel_pathkey_cat']);
-
+    
             if ($pathkey_cat_old != $_REQUEST['wpsg_mod_produktartikel_pathkey_cat'] && $pathkey_cat_new != '')
             {
-
+    
                 $this->db->UpdateQuery($this->shop->prefix."term_taxonomy", array(
                     'taxonomy' => wpsg_q($pathkey_cat_new)
                 ), " `taxonomy` = '".wpsg_q($pathkey_cat_old)."' ");
-
+    
                 $this->db->UpdateQuery($this->shop->prefix."postmeta", array(
                     'meta_value' => wpsg_q($pathkey_cat_new)
                 ), " `meta_key` = '_menu_item_object' AND `meta_value` = '".wpsg_q($pathkey_cat_old)."' ");
-
+    
                 $this->shop->update_option('wpsg_mod_produktartikel_pathkey_cat', $pathkey_cat_new);
-
+    
                 $this->shop->addBackendMessage(__('Path Key (Kategorie) erfolgreich geÃ€ndert. Die Kategorie URLs haben sich geÃ€ndert!', 'wpsg'));
-
+    
             }
             else if (trim($_REQUEST['wpsg_mod_produktartikel_pathkey_cat']) == '')
             {
-
+    
                 $this->shop->addBackendError(__('Der Path Key (Kategorie) darf nicht leer sein!', 'wpsg'));
-
-            }
-
-			$this->create_wpsg_post_types();
-			flush_rewrite_rules();
-
-		} // public function settings_save()
-
-		public function wpsg_add_pages()
-		{
-
-			$callback = add_submenu_page('wpsg-Admin', __("Produktkategorien", "wpsg"), __("Produktkategorien", "wpsg"), 'wpsg_produkt', 'wpsg-Productcategories', 'callback');
-
-			add_action("load-".$callback, function() { header('Location: '.admin_url('edit-tags.php?taxonomy='.$this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat'))); exit; } );
-
-			add_filter('parent_file', array($this, 'setParentmenu'), 10, 1);
-			add_filter('submenu_file', array($this, 'setSubmenu'), 10, 1);
-
-		} // public function wpsg_add_pages()
-
-		function setParentmenu($parent_file)
-        {
-
-			if (wpsg_isSizedString($_REQUEST['taxonomy'], $this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat'))) $parent_file = 'wpsg-Admin';
-
-			return $parent_file;
-		}
-
-		function setSubmenu($submenu_file)
-        {
-
-			if ($submenu_file == 'edit-tags.php?taxonomy='.$this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat')) $submenu_file = 'wpsg-Productcategories';
-
-			return $submenu_file;
-
-		}
-
-		public function admin_includes()
-		{
-
-			echo wpsg_drawForm_Checkbox('wpsg_mod_produktartikel_noJS', __('Socialshareprivacy nicht einbinden (Produktartikel)', 'wpsg'), $this->shop->get_option('wpsg_mod_produktartikel_noJS'), array(
-				'hint' => wpsg_translate('nohspc_'.__('Ist diese Option aktiv, so wird die benÃ¶tigte JavaScript Bibliothek <u>nicht</u> eingebunden, auch wenn die Optionen im <a href="#1#">Produktartikelmodul</a> aktiv sind.', 'wpsg'), WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&action=module&modul=wpsg_mod_produktartikel')
-			));
-
-		} // function admin_includes()
-
-		public function admin_includes_save()
-		{
-
-			$this->shop->update_option('wpsg_mod_produktartikel_noJS', $_REQUEST['wpsg_mod_produktartikel_noJS']);
-
-		} // function admin_includes_save()
-
-		public function produkt_copy(&$produkt_id, &$copy_id)
-		{
-
-			global $current_user;
-
-			$product_source = $this->shop->cache->loadProduct($produkt_id);
-			$product_target = $this->shop->cache->loadProduct($copy_id);
-
-			$post_content = $this->renderProdukt($copy_id);
-			$post_content = $this->clear_post_content($post_content);
-
-			$post_data = $this->db->fetchRow("
-				SELECT
-					`id`, `comment_status`, `menu_order`
-				FROM
-					`".$this->shop->prefix."posts`
-				WHERE
-					`wpsg_produkt_id` = '".wpsg_q($produkt_id)."' AND
-					`post_type` = '".wpsg_q($this->shop->get_option('wpsg_mod_produktartikel_pathkey'))."'
-			");
-
-			$data = array(
-				"post_title" => wpsg_q($product_target['name']),
-				'post_author' => $current_user->ID,
-				'post_content' => wpsg_q($post_content),
-				"post_type" => wpsg_q($this->shop->get_option('wpsg_mod_produktartikel_pathkey')),
-				"wpsg_produkt_id" => wpsg_q($copy_id),
-				"comment_status" => wpsg_q($post_data['comment_status']),
-				"post_name" => wpsg_q($this->shop->clear($product_target['name'])),
-				"menu_order" => wpsg_q($post_data['menu_order']),
-				"post_modified" => "NOW()",
-				"post_modified_gmt" => "NOW()",
-				'post_date' => 'NOW()'
-			);
-
-			$post_id = $this->db->ImportQuery($this->shop->prefix.'posts', $data);
-
-			$this->updatePostThumbnail($copy_id);
-
-			// Taxonomie mit kopieren
-			$this->db->Query("DELETE FROM `".$this->shop->prefix."term_relationships` WHERE `object_id` = '".wpsg_q($post_id)."'");
-
-			$arTaxOriginalProduct = $this->db->fetchAssocField("SELECT `term_taxonomy_id` FROM `".$this->shop->prefix."term_relationships` WHERE `object_id` = '".wpsg_q($post_data['id'])."' ");
-
-			foreach ($arTaxOriginalProduct as $term_taxonomy_id)
-			{
-
-				$this->db->ImportQuery($this->shop->prefix.'term_relationships', array(
-					'object_id' => wpsg_q($post_id),
-					'term_taxonomy_id' => wpsg_q($term_taxonomy_id),
-					'term_order' => '0'
-				));
-
-				$count = $this->db->fetchOne("SELECT COUNT(*) FROM `".$this->shop->prefix."term_relationships` WHERE `term_taxonomy_id` = '".wpsg_q($term_taxonomy_id)."'");
-
-				$this->db->UpdateQuery($this->shop->prefix."term_taxonomy", array(
-					'count' => wpsg_q($count)
-				), "`term_taxonomy_id` = '".wpsg_q($term_taxonomy_id)."'");
-
-			}
-
-		} // public function produkt_copy(&$produkt_id, &$copy_id)
-
-		public function produkt_del($produkt_id)
-		{
-
-			global $wpdb;
-
-			$post_id = $this->db->fetchOne("
-				SELECT
-					`id`
-				FROM
-					`".$this->shop->prefix."posts`
-				WHERE
-					`wpsg_produkt_id` = '".wpsg_q($produkt_id)."' AND
-					`post_type` = '".wpsg_q($this->shop->get_option('wpsg_mod_produktartikel_pathkey'))."'
-			");
-
-			$this->db->Query("DELETE FROM `".$this->shop->prefix."posts` WHERE `wpsg_produkt_id` = '".wpsg_q($produkt_id)."'");
-
-			$this->db->Query("DELETE FROM `".$this->shop->prefix."term_relationships` WHERE `object_id` = '".wpsg_q($post_id)."'");
-
-			$this->db->Query("DELETE FROM `".$this->shop->prefix."postmeta` WHERE `post_id` = '".wpsg_q($post_id)."'");
-
-			$this->updateTaxonomieCount();
-
-		} // public function produkt_del($produkt_id)
-
-		public function wp_head()
-		{
-
-			global $post;
-
-			if (is_single($post) && get_post_type($post) == $this->shop->get_option('wpsg_mod_produktartikel_pathkey'))
-			{
-
-				$produkt_id = $post->wpsg_produkt_id;
-
-				$this->shop->view['data'] = $this->shop->loadProduktArray($produkt_id);
-				$this->shop->view['data']['url'] = '';
-				$this->getProduktlink($produkt_id, $this->shop->view['data']['url']);
-
-				$this->shop->view['data']['beschreibung'] = preg_replace("/\r|\n/", "", wpsg_hspc(strip_tags($this->shop->view['data']['beschreibung'])));
-
-				$arBilder = array();
-				$arBilder = $this->shop->imagehandler->getAttachmentIDs($produkt_id);
-				
-				if (isset($arBilder) && (sizeof($arBilder) > 0)) $this->shop->view['data']['bilder'] = $arBilder;
-
-				/*
-				if ($this->shop->get_option('wpsg_mod_produktartikel_facebook') == '1')
-				{
-					$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_produktartikel/header_facebook.phtml');
-				}
-				if ($this->shop->get_option('wpsg_mod_produktartikel_google') == '1')
-				{
-					$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_produktartikel/header_google.phtml');
-				}
-				*/
-
-			}
-
-		} // public function wp_head()
-
-		public function produkt_edit_allgemein(&$produkt_data)
-		{
-
-		    $post_id = $this->hasPostId($produkt_data['id']);
-
-			$this->shop->view['data'] = $produkt_data;
-
-            if (wpsg_isSizedInt($post_id))
-            {
-
-                $this->shop->view['data']['post_name'] = $this->db->fetchOne("
+    
+            }
+    
+            $this->create_wpsg_post_types();
+            flush_rewrite_rules();
+    
+        } // public function settings_save()
+    
+        public function wpsg_add_pages()
+        {
+    
+            $callback = add_submenu_page('wpsg-Admin', __("Produktkategorien", "wpsg"), __("Produktkategorien", "wpsg"), 'wpsg_produkt', 'wpsg-Productcategories', 'callback');
+    
+            add_action("load-".$callback, function() { header('Location: '.admin_url('edit-tags.php?taxonomy='.$this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat'))); exit; } );
+    
+            add_filter('parent_file', array($this, 'setParentmenu'), 10, 1);
+            add_filter('submenu_file', array($this, 'setSubmenu'), 10, 1);
+    
+        } // public function wpsg_add_pages()
+    
+        function setParentmenu($parent_file)
+        {
+    
+            if (wpsg_isSizedString($_REQUEST['taxonomy'], $this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat'))) $parent_file = 'wpsg-Admin';
+    
+            return $parent_file;
+        }
+    
+        function setSubmenu($submenu_file)
+        {
+    
+            if ($submenu_file == 'edit-tags.php?taxonomy='.$this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat')) $submenu_file = 'wpsg-Productcategories';
+    
+            return $submenu_file;
+    
+        }
+    
+        public function admin_includes()
+        {
+    
+            echo wpsg_drawForm_Checkbox('wpsg_mod_produktartikel_noJS', __('Socialshareprivacy nicht einbinden (Produktartikel)', 'wpsg'), $this->shop->get_option('wpsg_mod_produktartikel_noJS'), array(
+                'hint' => wpsg_translate('nohspc_'.__('Ist diese Option aktiv, so wird die benÃ¶tigte JavaScript Bibliothek <u>nicht</u> eingebunden, auch wenn die Optionen im <a href="#1#">Produktartikelmodul</a> aktiv sind.', 'wpsg'), WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&action=module&modul=wpsg_mod_produktartikel')
+            ));
+    
+        } // function admin_includes()
+    
+        public function admin_includes_save()
+        {
+    
+            $this->shop->update_option('wpsg_mod_produktartikel_noJS', $_REQUEST['wpsg_mod_produktartikel_noJS']);
+    
+        } // function admin_includes_save()
+    
+        public function produkt_copy(&$produkt_id, &$copy_id)
+        {
+    
+            global $current_user;
+    
+            $product_source = $this->shop->cache->loadProduct($produkt_id);
+            $product_target = $this->shop->cache->loadProduct($copy_id);
+    
+            $post_content = $this->renderProdukt($copy_id);
+            $post_content = $this->clear_post_content($post_content);
+    
+            $post_data = $this->db->fetchRow("
                     SELECT
-                        `post_name`
+                        `id`, `comment_status`, `menu_order`
                     FROM
                         `".$this->shop->prefix."posts`
                     WHERE
-                        `ID` = '".wpsg_q($post_id)."' 
+                        `wpsg_produkt_id` = '".wpsg_q($produkt_id)."' AND
+                        `post_type` = '".wpsg_q($this->shop->get_option('wpsg_mod_produktartikel_pathkey'))."'
                 ");
-
-            }
-
-			$this->shop->render(WPSG_PATH_VIEW.'/mods/mod_produktartikel/produkt_edit_allgemein.phtml');
-
-		} // public function produkt_edit_allgemein(&$produkt_data)
-
-		public function product_addedit_content(&$product_content, &$product_data)
-		{
-
-			global $wpdb;
-
-			// Bei Ãbersetzungen nichts machen
-			if (isset($_REQUEST['wpsg_lang'])) return;
-
-			if (wpsg_isSizedInt($product_data['id']))
-			{
-
-				$product_data = wpsg_array_merge($product_data, (array)$this->db->fetchRow("
-					SELECT
-						`id` AS `post_id`,
-						`comment_status`,
-						`menu_order`,
-						`post_name`
-					FROM
-						`".$this->shop->prefix."posts`
-					WHERE
-						`wpsg_produkt_id` = '".wpsg_q($product_data['id'])."' AND
-						`post_type` = '".wpsg_q($this->shop->get_option('wpsg_mod_produktartikel_pathkey'))."'
-				"));
-
-			}
-
-			$product_content['wpsg_mod_produktartikel'] = array(
-				'title' => __('Kategorie / Artikel', 'wpsg'),
-				'content' => $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_produktartikel/produkt_addedit_content.phtml', false)
-			);
-
-		} // public function product_addedit_content(&$product_content, &$product_data)
-
-		public function produkt_save_translation(&$product_id, &$trans_id)
-		{
-
-			if (function_exists('icl_object_id')) //if (is_plugin_active('sitepress-multilingual-cms/sitepress.php'))
-			{
-
-				// WPML
-				$post_id = $this->getPostIdFromProductId($product_id);
-
-				if (wpsg_isSizedInt($post_id))
-				{
-
-					$trans_product = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS."` WHERE `id` = '".wpsg_q($trans_id)."' ");
-					$post = $this->db->fetchRow("SELECT * FROM `".$this->shop->prefix."posts` WHERE `ID` = '".$post_id."' ");
-
+    
+            $data = array(
+                "post_title" => wpsg_q($product_target['name']),
+                'post_author' => $current_user->ID,
+                'post_content' => wpsg_q($post_content),
+                "post_type" => wpsg_q($this->shop->get_option('wpsg_mod_produktartikel_pathkey')),
+                "wpsg_produkt_id" => wpsg_q($copy_id),
+                "comment_status" => wpsg_q($post_data['comment_status']),
+                "post_name" => wpsg_q($this->shop->clear($product_target['name'])),
+                "menu_order" => wpsg_q($post_data['menu_order']),
+                "post_modified" => "NOW()",
+                "post_modified_gmt" => "NOW()",
+                'post_date' => 'NOW()'
+            );
+    
+            $post_id = $this->db->ImportQuery($this->shop->prefix.'posts', $data);
+    
+            $this->updatePostThumbnail($copy_id);
+    
+            // Taxonomie mit kopieren
+            $this->db->Query("DELETE FROM `".$this->shop->prefix."term_relationships` WHERE `object_id` = '".wpsg_q($post_id)."'");
+    
+            $arTaxOriginalProduct = $this->db->fetchAssocField("SELECT `term_taxonomy_id` FROM `".$this->shop->prefix."term_relationships` WHERE `object_id` = '".wpsg_q($post_data['id'])."' ");
+    
+            foreach ($arTaxOriginalProduct as $term_taxonomy_id)
+            {
+    
+                $this->db->ImportQuery($this->shop->prefix.'term_relationships', array(
+                    'object_id' => wpsg_q($post_id),
+                    'term_taxonomy_id' => wpsg_q($term_taxonomy_id),
+                    'term_order' => '0'
+                ));
+    
+                $count = $this->db->fetchOne("SELECT COUNT(*) FROM `".$this->shop->prefix."term_relationships` WHERE `term_taxonomy_id` = '".wpsg_q($term_taxonomy_id)."'");
+    
+                $this->db->UpdateQuery($this->shop->prefix."term_taxonomy", array(
+                    'count' => wpsg_q($count)
+                ), "`term_taxonomy_id` = '".wpsg_q($term_taxonomy_id)."'");
+    
+            }
+    
+        } // public function produkt_copy(&$produkt_id, &$copy_id)
+    
+        public function produkt_del($produkt_id)
+        {
+    
+            global $wpdb;
+    
+            $post_id = $this->db->fetchOne("
+                    SELECT
+                        `id`
+                    FROM
+                        `".$this->shop->prefix."posts`
+                    WHERE
+                        `wpsg_produkt_id` = '".wpsg_q($produkt_id)."' AND
+                        `post_type` = '".wpsg_q($this->shop->get_option('wpsg_mod_produktartikel_pathkey'))."'
+                ");
+    
+            $this->db->Query("DELETE FROM `".$this->shop->prefix."posts` WHERE `wpsg_produkt_id` = '".wpsg_q($produkt_id)."'");
+    
+            $this->db->Query("DELETE FROM `".$this->shop->prefix."term_relationships` WHERE `object_id` = '".wpsg_q($post_id)."'");
+    
+            $this->db->Query("DELETE FROM `".$this->shop->prefix."postmeta` WHERE `post_id` = '".wpsg_q($post_id)."'");
+    
+            $this->updateTaxonomieCount();
+    
+        } // public function produkt_del($produkt_id)
+    
+        public function wp_head()
+        {
+    
+            global $post;
+    
+            if (is_single($post) && get_post_type($post) == $this->shop->get_option('wpsg_mod_produktartikel_pathkey'))
+            {
+    
+                $produkt_id = $post->wpsg_produkt_id;
+    
+                $this->shop->view['data'] = $this->shop->loadProduktArray($produkt_id);
+                $this->shop->view['data']['url'] = '';
+                $this->getProduktlink($produkt_id, $this->shop->view['data']['url']);
+    
+                $this->shop->view['data']['beschreibung'] = preg_replace("/\r|\n/", "", wpsg_hspc(strip_tags($this->shop->view['data']['beschreibung'])));
+    
+                $arBilder = array();
+                $arBilder = $this->shop->imagehandler->getAttachmentIDs($produkt_id);
+    
+                if (isset($arBilder) && (sizeof($arBilder) > 0)) $this->shop->view['data']['bilder'] = $arBilder;
+    
+                /*
+                if ($this->shop->get_option('wpsg_mod_produktartikel_facebook') == '1')
+                {
+                    $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_produktartikel/header_facebook.phtml');
+                }
+                if ($this->shop->get_option('wpsg_mod_produktartikel_google') == '1')
+                {
+                    $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_produktartikel/header_google.phtml');
+                }
+                */
+    
+            }
+    
+        } // public function wp_head()
+    
+        public function produkt_edit_allgemein(&$produkt_data)
+        {
+    
+            $post_id = $this->hasPostId($produkt_data['id']);
+    
+            $this->shop->view['data'] = $produkt_data;
+    
+            if (wpsg_isSizedInt($post_id))
+            {
+    
+                $this->shop->view['data']['post_name'] = $this->db->fetchOne("
+                        SELECT
+                            `post_name`
+                        FROM
+                            `".$this->shop->prefix."posts`
+                        WHERE
+                            `ID` = '".wpsg_q($post_id)."' 
+                    ");
+    
+            }
+    
+            $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_produktartikel/produkt_edit_allgemein.phtml');
+    
+        } // public function produkt_edit_allgemein(&$produkt_data)
+    
+        public function product_addedit_content(&$product_content, &$product_data)
+        {
+    
+            global $wpdb;
+    
+            // Bei Ãbersetzungen nichts machen
+            if (isset($_REQUEST['wpsg_lang'])) return;
+    
+            if (wpsg_isSizedInt($product_data['id']))
+            {
+    
+                $product_data = wpsg_array_merge($product_data, (array)$this->db->fetchRow("
+                        SELECT
+                            `id` AS `post_id`,
+                            `comment_status`,
+                            `menu_order`,
+                            `post_name`
+                        FROM
+                            `".$this->shop->prefix."posts`
+                        WHERE
+                            `wpsg_produkt_id` = '".wpsg_q($product_data['id'])."' AND
+                            `post_type` = '".wpsg_q($this->shop->get_option('wpsg_mod_produktartikel_pathkey'))."'
+                    "));
+    
+            }
+    
+            $product_content['wpsg_mod_produktartikel'] = array(
+                'title' => __('Kategorie / Artikel', 'wpsg'),
+                'content' => $this->shop->render(WPSG_PATH_VIEW.'/mods/mod_produktartikel/produkt_addedit_content.phtml', false)
+            );
+    
+        } // public function product_addedit_content(&$product_content, &$product_data)
+    
+        public function produkt_save_translation(&$product_id, &$trans_id)
+        {
+    
+            if (function_exists('icl_object_id')) //if (is_plugin_active('sitepress-multilingual-cms/sitepress.php'))
+            {
+    
+                // WPML
+                $post_id = $this->getPostIdFromProductId($product_id);
+    
+                if (wpsg_isSizedInt($post_id))
+                {
+    
+                    $trans_product = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS."` WHERE `id` = '".wpsg_q($trans_id)."' ");
+                    $post = $this->db->fetchRow("SELECT * FROM `".$this->shop->prefix."posts` WHERE `ID` = '".$post_id."' ");
+    
                     if (wpsg_isSizedString($_REQUEST['wpsg_mod_produktartikel']['path'])) $path = $_REQUEST['wpsg_mod_produktartikel']['path'];
                     else $path = $trans_product['name'];
-
-					$trans_post_id = $this->getPostIdFromProductId($trans_id, $path, (($post['comment_status'] === 'open')?'1':'0'), $post['menu_order'], true);
-
-					// Gibt es zu dem Post schon eine trid?
-					$trid = $this->db->fetchOne("SELECT `trid` FROM `".$this->shop->prefix."icl_translations` WHERE `element_type` = '".wpsg_q('post_'.$this->shop->get_option('wpsg_mod_produktartikel_pathkey'))."' AND `element_id` = '".wpsg_q($post_id)."' ");
-					if (!wpsg_isSizedInt($trid))
-					{
-
-						$trid = 1 + $this->db->fetchOne("SELECT MAX(`trid`) FROM ".$this->shop->prefix."icl_translations");
-						$this->db->ImportQuery($this->shop->prefix."icl_translations", array(
-							'element_type' => wpsg_q('post_'.$this->shop->get_option('wpsg_mod_produktartikel_pathkey')),
-							'element_id' => wpsg_q($post_id),
-							'trid' => wpsg_q($trid),
-							'language_code' => wpsg_q($this->shop->getDefaultLanguageCode()),
-							'source_language_code' => 'NULL'
-						));
-
-					}
-
-					// Gibt es schon einen ICL Eintrag zur Ãbersetzung?
-					$icl_id = $this->db->fetchOne("SELECT `translation_id` FROM `".$this->shop->prefix."icl_translations` WHERE `element_type` = '".wpsg_q('post_'.$this->shop->get_option('wpsg_mod_produktartikel_pathkey'))."' AND `element_id` = '".wpsg_q($trans_post_id)."' ");
-					if (!wpsg_isSizedInt($icl_id))
-					{
-
-						$this->db->ImportQuery($this->shop->prefix."icl_translations", array(
-							'element_type' => wpsg_q('post_'.$this->shop->get_option('wpsg_mod_produktartikel_pathkey')),
-							'element_id' => wpsg_q($trans_post_id),
-							'trid' => wpsg_q($trid),
-							'language_code' => wpsg_q($_REQUEST['wpsg_lang']),
-							'source_language_code' => wpsg_q($this->shop->getDefaultLanguageCode())
-						));
-
-					}
-
-				} else throw new \Exception(wpsg_translate(__('Custom Post Type existiert zu Produkt (ID:#1#) noch nicht.', 'wpsg'), $product_id));
-
-			}
-			else
-			{
-
-				// qTranslate
-				// Da sich die Ãbersetzung geÃ€ndert hat muss das Produkt erneut gespeichert werden
-				$this->produkt_save($product_id);
-
-			}
-
-		} // public function produkt_save_translation(&$produkt_id, &$trans_id)
-
-		public function produkt_save_before(&$produkt_data)
-		{
-
-			$produkt_data['ean'] = wpsg_tf(wpsg_getStr($_REQUEST['wpsg_mod_produktartikel']['ean']));
-			$produkt_data['gtin'] = wpsg_tf(wpsg_getStr($_REQUEST['wpsg_mod_produktartikel']['gtin']));
-
-		} // public function produkt_save_before(&$produkt_data)
-
-		public function produkt_save(&$product_id)
-		{
-
-		    if (isset($_REQUEST['wpsg_mod_produktartikel'])) $comment = $_REQUEST['wpsg_mod_produktartikel']['kommentare']; else $comment = false;
-
-			$this->getPostIdFromProductId($product_id, $_REQUEST['wpsg_mod_produktartikel']['path'], $comment, $_REQUEST['wpsg_produktartikel_menuorder'], true, $_REQUEST['disabled']);
-
-		} // public function produkt_save($produkt_id)
-
-		public function create_wpsg_post_types()
-		{
-
-			$show_ui = false;
-
-			if ($this->shop->get_option('wpsg_mod_produktartikel_showui') == '1') $show_ui = true;
-
-			register_taxonomy($this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat'), $this->shop->get_option('wpsg_mod_produktartikel_pathkey'), array(
-				'label' => __('Produktkategorien', 'wpsg'),
-				'labels' => array(
-					'name' => __('Produktkategorien', 'wpsg'),
-					'add_new_item' => __('Neue Produktkategorie erstellen', 'wpsg'),
-					'edit_item' => __('Produktkategorie bearbeiten', 'wpsg')
-				),
-				'show_ui' => true,
-				'show_in_menu' => false,
-				'hierarchical' => true
-			));
-
-			register_post_type($this->shop->get_option('wpsg_mod_produktartikel_pathkey'),
-				array(
-					'public' => true, // steht auf "true", damit andere Module/ Plugins diesen Posttype "sehen" kÃ¶nnen
-					'publicly_queryable' => true,
-					'labels' => array(
-						'name' => __('wpShopGermany Produkte', 'wpsg')
-					),
-					'query_var' => false,
-					'rewrite' => array('slug' => $this->shop->get_option('wpsg_mod_produktartikel_pathkey')),
-					'show_ui' => $show_ui,
- 					'show_in_menu' => true,
-					'taxonomies' => array($this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat')),
-					'has_archive' => true,
-					'supports' => array('title', 'editor', 'thumbnail')
-				)
-			);
-
-		} // public function create_wpsg_post_types()
-
-		public function getProduktlink($product_id, &$url, $language_code = false) {
-
+    
+                    $trans_post_id = $this->getPostIdFromProductId($trans_id, $path, (($post['comment_status'] === 'open')?'1':'0'), $post['menu_order'], true);
+    
+                    // Gibt es zu dem Post schon eine trid?
+                    $trid = $this->db->fetchOne("SELECT `trid` FROM `".$this->shop->prefix."icl_translations` WHERE `element_type` = '".wpsg_q('post_'.$this->shop->get_option('wpsg_mod_produktartikel_pathkey'))."' AND `element_id` = '".wpsg_q($post_id)."' ");
+                    if (!wpsg_isSizedInt($trid))
+                    {
+    
+                        $trid = 1 + $this->db->fetchOne("SELECT MAX(`trid`) FROM ".$this->shop->prefix."icl_translations");
+                        $this->db->ImportQuery($this->shop->prefix."icl_translations", array(
+                            'element_type' => wpsg_q('post_'.$this->shop->get_option('wpsg_mod_produktartikel_pathkey')),
+                            'element_id' => wpsg_q($post_id),
+                            'trid' => wpsg_q($trid),
+                            'language_code' => wpsg_q($this->shop->getDefaultLanguageCode()),
+                            'source_language_code' => 'NULL'
+                        ));
+    
+                    }
+    
+                    // Gibt es schon einen ICL Eintrag zur Ãbersetzung?
+                    $icl_id = $this->db->fetchOne("SELECT `translation_id` FROM `".$this->shop->prefix."icl_translations` WHERE `element_type` = '".wpsg_q('post_'.$this->shop->get_option('wpsg_mod_produktartikel_pathkey'))."' AND `element_id` = '".wpsg_q($trans_post_id)."' ");
+                    if (!wpsg_isSizedInt($icl_id))
+                    {
+    
+                        $this->db->ImportQuery($this->shop->prefix."icl_translations", array(
+                            'element_type' => wpsg_q('post_'.$this->shop->get_option('wpsg_mod_produktartikel_pathkey')),
+                            'element_id' => wpsg_q($trans_post_id),
+                            'trid' => wpsg_q($trid),
+                            'language_code' => wpsg_q($_REQUEST['wpsg_lang']),
+                            'source_language_code' => wpsg_q($this->shop->getDefaultLanguageCode())
+                        ));
+    
+                    }
+    
+                } else throw new \Exception(wpsg_translate(__('Custom Post Type existiert zu Produkt (ID:#1#) noch nicht.', 'wpsg'), $product_id));
+    
+            }
+            else
+            {
+    
+                // qTranslate
+                // Da sich die Ãbersetzung geÃ€ndert hat muss das Produkt erneut gespeichert werden
+                $this->produkt_save($product_id);
+    
+            }
+    
+        } // public function produkt_save_translation(&$produkt_id, &$trans_id)
+    
+        public function produkt_save_before(&$produkt_data)
+        {
+    
+            $produkt_data['ean'] = wpsg_tf(wpsg_getStr($_REQUEST['wpsg_mod_produktartikel']['ean']));
+            $produkt_data['gtin'] = wpsg_tf(wpsg_getStr($_REQUEST['wpsg_mod_produktartikel']['gtin']));
+    
+        } // public function produkt_save_before(&$produkt_data)
+    
+        public function produkt_save(&$product_id)
+        {
+    
+            if (isset($_REQUEST['wpsg_mod_produktartikel'])) $comment = $_REQUEST['wpsg_mod_produktartikel']['kommentare']; else $comment = false;
+    
+            $this->getPostIdFromProductId($product_id, $_REQUEST['wpsg_mod_produktartikel']['path'], $comment, $_REQUEST['wpsg_produktartikel_menuorder'], true, $_REQUEST['disabled']);
+    
+        } // public function produkt_save($produkt_id)
+    
+        public function create_wpsg_post_types()
+        {
+    
+            $show_ui = false;
+    
+            if ($this->shop->get_option('wpsg_mod_produktartikel_showui') == '1') $show_ui = true;
+    
+            register_taxonomy($this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat'), $this->shop->get_option('wpsg_mod_produktartikel_pathkey'), array(
+                'label' => __('Produktkategorien', 'wpsg'),
+                'labels' => array(
+                    'name' => __('Produktkategorien', 'wpsg'),
+                    'add_new_item' => __('Neue Produktkategorie erstellen', 'wpsg'),
+                    'edit_item' => __('Produktkategorie bearbeiten', 'wpsg')
+                ),
+                'show_ui' => true,
+                'show_in_menu' => false,
+                'hierarchical' => true
+            ));
+    
+            register_post_type($this->shop->get_option('wpsg_mod_produktartikel_pathkey'),
+                array(
+                    'public' => true, // steht auf "true", damit andere Module/ Plugins diesen Posttype "sehen" kÃ¶nnen
+                    'publicly_queryable' => true,
+                    'labels' => array(
+                        'name' => __('wpShopGermany Produkte', 'wpsg')
+                    ),
+                    'query_var' => false,
+                    'rewrite' => array('slug' => $this->shop->get_option('wpsg_mod_produktartikel_pathkey')),
+                    'show_ui' => $show_ui,
+                    'show_in_menu' => true,
+                    'taxonomies' => array($this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat')),
+                    'has_archive' => true,
+                    'supports' => array('title', 'editor', 'thumbnail')
+                )
+            );
+    
+        } // public function create_wpsg_post_types()
+    
+        public function getProduktlink($product_id, &$url, $language_code = false) {
+    
             $product_id = $this->shop->getProduktId($product_id);
             $post_id = $this->hasPostId($product_id);
-
+    
             if (wpsg_isSizedInt($post_id)) {
-
+    
                 if (function_exists('qtrans_convertURL')) {
-
+    
                     $url = get_permalink($post_id);
                     $url = qtrans_convertURL($url);
-
+    
                 } else {
-
+    
                     if (function_exists('icl_object_id') && $language_code !== false) {
-
+    
                         $post_id = apply_filters('wpml_object_id', $post_id, $this->shop->get_option('wpsg_mod_produktartikel_pathkey'), true, $language_code);
-
+    
                     }
-
+    
                     $url = get_permalink($post_id);
-
-                }
-
+    
+                }
+    
                 return -1;
-
-            }
-
-		} // public function getProduktlink($produkt_id)
-
-		public function renderProdukt_templateSelect(&$produkt_data, &$template_file)
-		{
-
-			if (($GLOBALS['wp_the_query']->is_category || $GLOBALS['wp_the_query']->is_post_type_archive($this->shop->get_option('wpsg_mod_produktartikel_pathkey'))) && $this->shop->get_option('wpsg_mod_produktartikel_listtemplate') != '-1' && $this->shop->get_option('wpsg_mod_produktartikel_listtemplate') != false)
-			{
-
-				$template_file = WPSG_PATH_PRODUKTTEMPLATES.$this->shop->get_option('wpsg_mod_produktartikel_listtemplate');
-
-			}
-			else if ($GLOBALS['wp_the_query']->is_search && $this->shop->get_option('wpsg_mod_produktartikel_searchtemplate') != '-1' && $this->shop->get_option('wpsg_mod_produktartikel_searchtemplate') != false)
-			{
-
-				$template_file = WPSG_PATH_PRODUKTTEMPLATES.$this->shop->get_option('wpsg_mod_produktartikel_searchtemplate');
-
-			}
-			else if ($GLOBALS['wp_the_query']->is_home && $this->shop->get_option('wpsg_mod_produktartikel_hometemplate') != '-1' && $this->shop->get_option('wpsg_mod_produktartikel_hometemplate') != false)
-			{
-
-				$template_file = WPSG_PATH_PRODUKTTEMPLATES.$this->shop->get_option('wpsg_mod_produktartikel_hometemplate');
-
-			}
-
-		} // public function renderProdukt_templateSelect(&$produkt_data, &$template_file)
-
-		public function loadProduktArray(&$produkt_data)
-		{
-
-			global $wpdb;
-
-			$product_id = $this->shop->getProduktId($produkt_data['id']);
-
-			$post_data = $this->db->fetchRow("
-				SELECT
-					`id`, `menu_order`, `comment_status`
-				FROM
-					`".$this->shop->prefix."posts`
-				WHERE
-					`wpsg_produkt_id` = '".wpsg_q($product_id)."' AND
-					`post_type` = '".wpsg_q($this->shop->get_option('wpsg_mod_produktartikel_pathkey'))."'
-			");
-
-			$post_id = $post_data['id'];
-
-			$arCat = $this->db->fetchOne("
-				SELECT
-					GROUP_CONCAT(DISTINCT `term_taxonomy_id`)
-				FROM
-					".$this->shop->prefix."term_relationships
-				WHERE
-					`object_id` = '".wpsg_q($post_id)."'
-			");
-
-			$permalink = get_permalink($post_id);
-
-			if (wpsg_isSizedInt($post_id) && wpsg_isSizedString($permalink))
-			{
-				
-				if ($this->shop->get_option('wpsg_mod_produktartikel_comment') === '1') $comment_status = 'open';
-				else if ($this->shop->get_option('wpsg_mod_produktartikel_comment') === '2') $comment_status = 'closed';
-				else $comment_status = $post_data['comment_status'];
-
-				$produkt_data = wpsg_array_merge($produkt_data, array(
-					'post_id' => $post_id,
-					'pos' => $post_data['menu_order'],
-					'url' => get_permalink($post_id),
-					'comment_status' => $comment_status,
-					'arCat' => $arCat
-				));
-
-			}
-
-		} // public function loadProduktArray(&$produkt_data)
-
-		public function systemcheck(&$arData)
-		{
-
-			if (function_exists('icl_object_id'))
-			{
-
-				$icl_sitepress_settings = $this->shop->get_option('icl_sitepress_settings');
-
-				if (wpsg_getStr($icl_sitepress_settings['custom_posts_sync_option'][$this->shop->get_option('wpsg_mod_produktartikel_pathkey')]) !== '1')
-				{
-
-					$arData[] = array(
-						'wpsg_mod_produktartikel_wpml_custom_post_type',
-						wpsg_ShopController::CHECK_ERROR,
-						wpsg_translate(
-							__('Sie haben WPML aktiviert und den Custom Post Type der Produkte nicht ÃŒbersetzt. Die Ãbersetzung der Produkte kann so nicht korrekt arbeiten. Klicken Sie <a href="#1#">hier</a> um das Problem zu lÃ¶sen.', 'wpsg'),
-							WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&action=module&noheader=1&modul=wpsg_mod_produktartikel&do=setWPMLPathKey'
-						)
-					);
-
-				}
-
-			}
-
-		} // public function systemcheck($arData)
-
-		/* Modulfunktionen */
-
-		private function updateTaxonomieCount()
-		{
-
-			$arTermTaxonomyID = $this->db->fetchAssocField("SELECT `term_taxonomy_id` FROM `".$this->shop->prefix."term_taxonomy` ");
-
-			foreach ($arTermTaxonomyID as $term_taxonomy_id)
-			{
-
-				$count = $this->db->fetchOne("SELECT COUNT(*) FROM `".$this->shop->prefix."term_relationships` WHERE `term_taxonomy_id` = '".wpsg_q($term_taxonomy_id)."'");
-
-				$this->db->UpdateQuery($this->shop->prefix.'term_taxonomy', array(
-					'count' => wpsg_q($count)
-				), " `term_taxonomy_id` = '".wpsg_q($term_taxonomy_id)."' ");
-
-			}
-
-		} // private function updateTaxonomieCount()
-
-		/**
-		 * Aktualisiert das Post Thumbnail (Beitragsbild)
-		 * in dem zum Produkt gehÃ¶rendem Beitrag
-		 */
-		public function updatePostThumbnail($product_id)
-		{
-
-			// Wenn das Produktbildermodul inaktiv ist, muss ich hier nichts machen
-			// Oder wenn Option nicht aktiv
-			if (!wpsg_isSizedInt($this->shop->get_option('wpsg_mod_produktartikel_postthumbnail'))) return;
-
-			$post_id = $this->getPostIdFromProductId($product_id);	// Parent-ID
-
-			if ($post_id !== false)
-			{
-
-				// ID des bestehenden POST Thumbnail
-				$post_thumbnail_id = get_post_thumbnail_id($post_id);
-
-				// Eventuell bestehendes Thumbnail lÃ¶schen
-				if (wpsg_isSizedInt($post_thumbnail_id))
-				{
-
-					// Postmeta Typ _thumbnail_id lÃ¶schen
-					//delete_post_thumbnail($post_id);
-					// Postmeta Typ _wp_attachment_metadata und _wp_attached_file und Post lÃ¶schen
-					//wp_delete_attachment($post_thumbnail_id);
-
-				}
-
-				$attachs = $this->shop->imagehandler->getAttachmentIDs($product_id);
-				if (wpsg_isSizedArray($attachs))  
-				{
-					$attach_id = $attachs[0];
-				
-					// Postmeta Typ _thumbnail_id anlegen
-					set_post_thumbnail($post_id, $attach_id);
-				}
-			}
-
-		} // private function updatePostThumbnail($product_id)
-
+    
+            }
+    
+        } // public function getProduktlink($produkt_id)
+    
+        public function renderProdukt_templateSelect(&$produkt_data, &$template_file)
+        {
+    
+            if (($GLOBALS['wp_the_query']->is_tax || $GLOBALS['wp_the_query']->is_post_type_archive($this->shop->get_option('wpsg_mod_produktartikel_pathkey'))) && $this->shop->get_option('wpsg_mod_produktartikel_listtemplate') != '-1' && $this->shop->get_option('wpsg_mod_produktartikel_listtemplate') != false)
+            {
+    
+                $template_file = WPSG_PATH_PRODUKTTEMPLATES.$this->shop->get_option('wpsg_mod_produktartikel_listtemplate');
+    
+            }
+            else if ($GLOBALS['wp_the_query']->is_search && $this->shop->get_option('wpsg_mod_produktartikel_searchtemplate') != '-1' && $this->shop->get_option('wpsg_mod_produktartikel_searchtemplate') != false)
+            {
+    
+                $template_file = WPSG_PATH_PRODUKTTEMPLATES.$this->shop->get_option('wpsg_mod_produktartikel_searchtemplate');
+    
+            }
+            else if ($GLOBALS['wp_the_query']->is_home && $this->shop->get_option('wpsg_mod_produktartikel_hometemplate') != '-1' && $this->shop->get_option('wpsg_mod_produktartikel_hometemplate') != false)
+            {
+    
+                $template_file = WPSG_PATH_PRODUKTTEMPLATES.$this->shop->get_option('wpsg_mod_produktartikel_hometemplate');
+    
+            }
+    
+        } // public function renderProdukt_templateSelect(&$produkt_data, &$template_file)
+    
+        public function loadProduktArray(&$produkt_data)
+        {
+    
+            global $wpdb;
+    
+            $product_id = $this->shop->getProduktId($produkt_data['id']);
+    
+            $post_data = $this->db->fetchRow("
+                    SELECT
+                        `id`, `menu_order`, `comment_status`
+                    FROM
+                        `".$this->shop->prefix."posts`
+                    WHERE
+                        `wpsg_produkt_id` = '".wpsg_q($product_id)."' AND
+                        `post_type` = '".wpsg_q($this->shop->get_option('wpsg_mod_produktartikel_pathkey'))."'
+                ");
+    
+            $post_id = $post_data['id'];
+    
+            $arCat = $this->db->fetchOne("
+                    SELECT
+                        GROUP_CONCAT(DISTINCT `term_taxonomy_id`)
+                    FROM
+                        ".$this->shop->prefix."term_relationships
+                    WHERE
+                        `object_id` = '".wpsg_q($post_id)."'
+                ");
+    
+            $permalink = get_permalink($post_id);
+    
+            if (wpsg_isSizedInt($post_id) && wpsg_isSizedString($permalink))
+            {
+    
+                if ($this->shop->get_option('wpsg_mod_produktartikel_comment') === '1') $comment_status = 'open';
+                else if ($this->shop->get_option('wpsg_mod_produktartikel_comment') === '2') $comment_status = 'closed';
+                else $comment_status = $post_data['comment_status'];
+    
+                $produkt_data = wpsg_array_merge($produkt_data, array(
+                    'post_id' => $post_id,
+                    'pos' => $post_data['menu_order'],
+                    'url' => get_permalink($post_id),
+                    'comment_status' => $comment_status,
+                    'arCat' => $arCat
+                ));
+    
+            }
+    
+        } // public function loadProduktArray(&$produkt_data)
+    
+        public function systemcheck(&$arData)
+        {
+    
+            if (function_exists('icl_object_id'))
+            {
+    
+                $icl_sitepress_settings = $this->shop->get_option('icl_sitepress_settings');
+    
+                if (wpsg_getStr($icl_sitepress_settings['custom_posts_sync_option'][$this->shop->get_option('wpsg_mod_produktartikel_pathkey')]) !== '1')
+                {
+    
+                    $arData[] = array(
+                        'wpsg_mod_produktartikel_wpml_custom_post_type',
+                        wpsg_ShopController::CHECK_ERROR,
+                        wpsg_translate(
+                            __('Sie haben WPML aktiviert und den Custom Post Type der Produkte nicht ÃŒbersetzt. Die Ãbersetzung der Produkte kann so nicht korrekt arbeiten. Klicken Sie <a href="#1#">hier</a> um das Problem zu lÃ¶sen.', 'wpsg'),
+                            WPSG_URL_WP.'wp-admin/admin.php?page=wpsg-Admin&action=module&noheader=1&modul=wpsg_mod_produktartikel&do=setWPMLPathKey'
+                        )
+                    );
+    
+                }
+    
+            }
+    
+        } // public function systemcheck($arData)
+    
+        /* Modulfunktionen */
+    
+        private function updateTaxonomieCount()
+        {
+    
+            $arTermTaxonomyID = $this->db->fetchAssocField("SELECT `term_taxonomy_id` FROM `".$this->shop->prefix."term_taxonomy` ");
+    
+            foreach ($arTermTaxonomyID as $term_taxonomy_id)
+            {
+    
+                $count = $this->db->fetchOne("SELECT COUNT(*) FROM `".$this->shop->prefix."term_relationships` WHERE `term_taxonomy_id` = '".wpsg_q($term_taxonomy_id)."'");
+    
+                $this->db->UpdateQuery($this->shop->prefix.'term_taxonomy', array(
+                    'count' => wpsg_q($count)
+                ), " `term_taxonomy_id` = '".wpsg_q($term_taxonomy_id)."' ");
+    
+            }
+    
+        } // private function updateTaxonomieCount()
+    
+        /**
+         * Aktualisiert das Post Thumbnail (Beitragsbild)
+         * in dem zum Produkt gehÃ¶rendem Beitrag
+         */
+        public function updatePostThumbnail($product_id)
+        {
+    
+            // Wenn das Produktbildermodul inaktiv ist, muss ich hier nichts machen
+            // Oder wenn Option nicht aktiv
+            if (!wpsg_isSizedInt($this->shop->get_option('wpsg_mod_produktartikel_postthumbnail'))) return;
+    
+            $post_id = $this->getPostIdFromProductId($product_id);	// Parent-ID
+    
+            if ($post_id !== false)
+            {
+    
+                // ID des bestehenden POST Thumbnail
+                $post_thumbnail_id = get_post_thumbnail_id($post_id);
+    
+                // Eventuell bestehendes Thumbnail lÃ¶schen
+                if (wpsg_isSizedInt($post_thumbnail_id))
+                {
+    
+                    // Postmeta Typ _thumbnail_id lÃ¶schen
+                    //delete_post_thumbnail($post_id);
+                    // Postmeta Typ _wp_attachment_metadata und _wp_attached_file und Post lÃ¶schen
+                    //wp_delete_attachment($post_thumbnail_id);
+    
+                }
+    
+                $attachs = $this->shop->imagehandler->getAttachmentIDs($product_id);
+                if (wpsg_isSizedArray($attachs))
+                {
+                    $attach_id = $attachs[0];
+    
+                    // Postmeta Typ _thumbnail_id anlegen
+                    set_post_thumbnail($post_id, $attach_id);
+                }
+            }
+    
+        } // private function updatePostThumbnail($product_id)
+    
         /**
          * Gibt false zurÃŒck, wenn noch kein POST existiert oder die POST_ID
@@ -932,20 +932,20 @@
          */
         public function hasPostId($product_id) {
-
+    
             $post_id = $this->db->fetchOne("
-				SELECT
-					`id`
-				FROM
-					`".$this->shop->prefix."posts`
-				WHERE
-					`wpsg_produkt_id` = '".wpsg_q($product_id)."' AND
-					`post_type` = '".wpsg_q($this->shop->get_option('wpsg_mod_produktartikel_pathkey'))."'
-			");
-
+                    SELECT
+                        `id`
+                    FROM
+                        `".$this->shop->prefix."posts`
+                    WHERE
+                        `wpsg_produkt_id` = '".wpsg_q($product_id)."' AND
+                        `post_type` = '".wpsg_q($this->shop->get_option('wpsg_mod_produktartikel_pathkey'))."'
+                ");
+    
             if (wpsg_isSizedInt($post_id)) return $post_id;
             else return false;
-
+    
         } // public function hasPostId($product_id)
-
+    
         /**
          * Gibt die Ausgabe fÃŒr ein Produkt zurÃŒck
@@ -954,412 +954,412 @@
         public function renderProdukt($produkt_id, $force_template = false, $force_locale = false)
         {
-            
+    
             $oProduct = wpsg_product::getInstance($produkt_id);
-            
+    
             $content = $oProduct->getShortDescription().$this->shop->renderProdukt($produkt_id, $force_template, $force_locale);
-            
+    
             return $content;
-            
+    
         } // public function renderProdukt($produkt_id, $force_template = false, $force_locale = false)
-        
-		/**
-		 * Gibt die Post_ID anhand einer ProduktID zurÃŒck.
-		 * Wird kein Post gefunden, so wird der Post angelegt und zugeordnet
-		 */
-		private function getPostIdFromProductId($product_id, $path = false, $comment_status = false, $menu_order = false, $update = false, $disabled = false)
-		{
-
-			global $current_user;
-
-			$post_id = $this->db->fetchOne("
-				SELECT
-					`id`
-				FROM
-					`".$this->shop->prefix."posts`
-				WHERE
-					`wpsg_produkt_id` = '".wpsg_q($product_id)."' AND
-					`post_type` = '".wpsg_q($this->shop->get_option('wpsg_mod_produktartikel_pathkey'))."'
-			");
-
-			if (wpsg_isSizedInt($post_id) && $update !== true) return $post_id;
-			else
-			{
-
-				// Hier wird der CustomPost Type angelegt
-				$product = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS."` WHERE `id` = '".wpsg_q($product_id)."'");
-
-				$arLanguages = $this->shop->getStoreLanguages();
-
-				if (wpsg_isSizedArray($arLanguages) && sizeof($arLanguages) > 1)
-				{
-
-					if (function_exists('icl_object_id')) //if (is_plugin_active('sitepress-multilingual-cms/sitepress.php'))
-					{
-
-						// WPML speichert in extra Post, hier nichts machen
-						$post_title = $product['name'];
-						$post_content = $this->renderProdukt($product_id);
-
-					}
-					else
-					{
-
-						// Fallback fÃŒr qTranslate => Alle Sprachen in einen Post
-
-						$post_title = '';
-						$post_content = '';
-
-						// Titel der Ãbersetzten Produkte heraussuchen
-						foreach ($arLanguages as $l)
-						{
-
-							$produkt_trans = $this->db->fetchRow("SELECT `id`, `name` FROM `".WPSG_TBL_PRODUCTS."` WHERE `lang_code` = '".wpsg_q($l['lang'])."' AND `lang_parent` = '".wpsg_q($product_id)."'");
-
-							if ($produkt_trans['id'] > 0) // Ãbersetzung existiert					{
-							{
-							    
-								$post_title .= '<!--:'.$l['lang'].'-->'.$produkt_trans['name'].'<!--:-->';
-								$post_content .= '<!--:'.$l['lang'].'-->'.$this->renderProdukt($product_id, false, $l['locale']).'<!--:-->';
-                                
-							}
-							else // Ãbersetzung existiert nicht, hier trage ich einfach den Originaltext ein
-							{
-							    
-								$post_title .= '<!--:'.$l['lang'].'-->'.$product['name'].'<!--:-->';
-								$post_content .= '<!--:'.$l['lang'].'-->'.$this->renderProdukt($product_id).'<!--:-->';
-                                
-							}
-
-						}
-
-					}
-
-				}
-				else
-				{
-
-					$post_title = $product['name'];
-					$post_content = $this->renderProdukt($product_id);
-
-				}
-
-				$post_content = $this->clear_post_content($post_content);
-
-				$data = array(
-					"post_title" => wpsg_q($post_title),
-					'post_author' => $current_user->ID,
-					'post_status' => (($product['disabled'] === '1')?'private':'publish'),
-					'post_content' => wpsg_q($post_content),
-					"post_type" => wpsg_q($this->shop->get_option('wpsg_mod_produktartikel_pathkey')),
-					"wpsg_produkt_id" => wpsg_q($product_id),
-					"post_modified" => "NOW()",
-					"post_modified_gmt" => "NOW()"
-				);
-
-				if ($comment_status !== false) $data['comment_status'] = wpsg_q(((wpsg_isSizedInt($comment_status))?'open':'closed'));
-				if ($menu_order !== false) $data['menu_order'] = $menu_order;
-			    if ($disabled !== false)
-                {
-
+    
+        /**
+         * Gibt die Post_ID anhand einer ProduktID zurÃŒck.
+         * Wird kein Post gefunden, so wird der Post angelegt und zugeordnet
+         */
+        private function getPostIdFromProductId($product_id, $path = false, $comment_status = false, $menu_order = false, $update = false, $disabled = false)
+        {
+    
+            global $current_user;
+    
+            $post_id = $this->db->fetchOne("
+                    SELECT
+                        `id`
+                    FROM
+                        `".$this->shop->prefix."posts`
+                    WHERE
+                        `wpsg_produkt_id` = '".wpsg_q($product_id)."' AND
+                        `post_type` = '".wpsg_q($this->shop->get_option('wpsg_mod_produktartikel_pathkey'))."'
+                ");
+    
+            if (wpsg_isSizedInt($post_id) && $update !== true) return $post_id;
+            else
+            {
+    
+                // Hier wird der CustomPost Type angelegt
+                $product = $this->db->fetchRow("SELECT * FROM `".WPSG_TBL_PRODUCTS."` WHERE `id` = '".wpsg_q($product_id)."'");
+    
+                $arLanguages = $this->shop->getStoreLanguages();
+    
+                if (wpsg_isSizedArray($arLanguages) && sizeof($arLanguages) > 1)
+                {
+    
+                    if (function_exists('icl_object_id')) //if (is_plugin_active('sitepress-multilingual-cms/sitepress.php'))
+                    {
+    
+                        // WPML speichert in extra Post, hier nichts machen
+                        $post_title = $product['name'];
+                        $post_content = $this->renderProdukt($product_id);
+    
+                    }
+                    else
+                    {
+    
+                        // Fallback fÃŒr qTranslate => Alle Sprachen in einen Post
+    
+                        $post_title = '';
+                        $post_content = '';
+    
+                        // Titel der Ãbersetzten Produkte heraussuchen
+                        foreach ($arLanguages as $l)
+                        {
+    
+                            $produkt_trans = $this->db->fetchRow("SELECT `id`, `name` FROM `".WPSG_TBL_PRODUCTS."` WHERE `lang_code` = '".wpsg_q($l['lang'])."' AND `lang_parent` = '".wpsg_q($product_id)."'");
+    
+                            if ($produkt_trans['id'] > 0) // Ãbersetzung existiert					{
+                            {
+    
+                                $post_title .= '<!--:'.$l['lang'].'-->'.$produkt_trans['name'].'<!--:-->';
+                                $post_content .= '<!--:'.$l['lang'].'-->'.$this->renderProdukt($product_id, false, $l['locale']).'<!--:-->';
+    
+                            }
+                            else // Ãbersetzung existiert nicht, hier trage ich einfach den Originaltext ein
+                            {
+    
+                                $post_title .= '<!--:'.$l['lang'].'-->'.$product['name'].'<!--:-->';
+                                $post_content .= '<!--:'.$l['lang'].'-->'.$this->renderProdukt($product_id).'<!--:-->';
+    
+                            }
+    
+                        }
+    
+                    }
+    
+                }
+                else
+                {
+    
+                    $post_title = $product['name'];
+                    $post_content = $this->renderProdukt($product_id);
+    
+                }
+    
+                $post_content = $this->clear_post_content($post_content);
+    
+                $data = array(
+                    "post_title" => wpsg_q($post_title),
+                    'post_author' => $current_user->ID,
+                    'post_status' => (($product['disabled'] === '1')?'private':'publish'),
+                    'post_content' => wpsg_q($post_content),
+                    "post_type" => wpsg_q($this->shop->get_option('wpsg_mod_produktartikel_pathkey')),
+                    "wpsg_produkt_id" => wpsg_q($product_id),
+                    "post_modified" => "NOW()",
+                    "post_modified_gmt" => "NOW()"
+                );
+    
+                if ($comment_status !== false) $data['comment_status'] = wpsg_q(((wpsg_isSizedInt($comment_status))?'open':'closed'));
+                if ($menu_order !== false) $data['menu_order'] = $menu_order;
+                if ($disabled !== false)
+                {
+    
                     if ($disabled === '1') $data['post_status'] = 'draft';
                     else $data['post_status'] = 'publish';
-
-                }
-
-				if ($post_id <= 0)
-				{
-
-					$data['post_date'] = $product['cdate'];
-					$post_id = $this->db->ImportQuery($this->shop->prefix.'posts', $data);
-
-				}
-				else
-				{
- 
-					$this->db->UpdateQuery($this->shop->prefix.'posts', $data, "`id` = '".wpsg_q($post_id)."'");
-
-				}
-
-				if ($path !== false)
-				{
-
-					if (!wpsg_isSizedString($path)) $path = $product['name'];
-
-					// Pathkey
-					$data = array();
-					$data['post_name'] = wpsg_q($this->shop->clear($path, $post_id));
-					$this->db->UpdateQuery($this->shop->prefix.'posts', $data, "`id` = '".wpsg_q($post_id)."'");
-
-				}
-
-				// Kategorie speichern
-				if (!wpsg_isSizedString($_REQUEST['wpsg_lang']))
-				{
-
-					// Die Kategorie darf nur beim speichern in der Originalsprache gesetzt werden!
-
-					// Alte Zuordnung lÃ¶schen
-					$this->db->Query("DELETE FROM `".$this->shop->prefix."term_relationships` WHERE `object_id` = '".wpsg_q($post_id)."'");
-
-					// Neue Zuordnung speichern
-					if (wpsg_isSizedArray($_REQUEST['tax_input'][$this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat')]))
-					{
-
-						foreach ($_REQUEST['tax_input'][$this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat')] as $c)
-						{
-
-							$term_taxonomy_id = $this->db->fetchOne("SELECT `term_taxonomy_id` FROM `".$this->shop->prefix."term_taxonomy` WHERE `term_id` = '".wpsg_q($c)."'");
-
-							$this->db->ImportQuery($this->shop->prefix.'term_relationships', array(
-								'object_id' => wpsg_q($post_id),
-								'term_taxonomy_id' => wpsg_q($term_taxonomy_id),
-								'term_order' => '0'
-							));
-
-							$count = $this->db->fetchOne("SELECT COUNT(*) FROM `".$this->shop->prefix."term_relationships` WHERE `term_taxonomy_id` = '".wpsg_q($term_taxonomy_id)."'");
-
-							$this->db->UpdateQuery($this->shop->prefix."term_taxonomy", array(
-								'count' => wpsg_q($count)
-							), "`term_taxonomy_id` = '".wpsg_q($term_taxonomy_id)."'");
-
-						}
-
-					}
-
-					$this->updateTaxonomieCount();
-
-				}
-
-				$this->updatePostThumbnail($product_id);
-
-				flush_rewrite_rules();
-
-				return $post_id;
-
-			}
-
-		} // 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
-		 */
-		private function setPostType($query)
-		{
-
-			$post_type = $query->get('post_type');
-
-			if ($post_type == '' || !wpsg_isSizedArray($post_type))
-			{
-
-				$postType = array(
-					'post',
-					'page',
-					'attachment',
-					$this->shop->get_option('wpsg_mod_produktartikel_pathkey')
-				);
-
-				if (is_string($post_type) && strlen($post_type) > 0)
-				{
-					$postType[] = $post_type;
-				}
-
-				$query->set('post_type', $postType);
-
-			}
-			else
-			{
-
-				$post_type[] = $this->shop->get_option('wpsg_mod_produktartikel_pathkey');
-
-				$query->set('post_type', $post_type);
-
-			}
-
-		} // private function setPostType($query)
- 
-		/**
-		 * Gibt einen Array mit Kategorien zurÃŒck
-		 */
-		public function getCategorySelectArray($ref = 0, $ebene = 0, &$arReturn = array())
-		{
-
-			global $wpdb;
-
-			$arCat = $this->db->fetchAssoc("
-				SELECT
-					T.`term_id`, T.`name`
-				FROM
-					`".$this->shop->prefix."term_taxonomy` AS TT
-						LEFT JOIN `".$this->shop->prefix."terms` AS T ON (T.`term_id` = TT.`term_id`)
-				WHERE
-					TT.`parent` = '".wpsg_q($ref)."' AND
-					TT.`taxonomy` = '".wpsg_q($this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat'))."' AND
-					T.`term_id` > 0
-				ORDER BY
-					T.`name` ASC
-			");
-
-			foreach ($arCat as $c)
-			{
-
-				$cat_name = '';
-				for ($i = 0; $i < $ebene; $i ++) $cat_name .= '-';
-				$cat_name .= $c['name'];
-
-				$arReturn[$c['term_id']] = $cat_name;
-
-				$this->getCategorySelectArray($c['term_id'], $ebene + 1, $arReturn);
-
-			}
-
-			return $arReturn;
-
-		} // public function getCategorySelectArray($ref = 0)
-
-		/**
-		 * Gibt einen Array mit KategorieIDs die unter einer Kategorie liegen zurÃŒck
-		 */
-		public function getSubCategoryID($child_of = 0)
-		{
-
-			$arCat = get_categories(array(
-				'taxonomy' => $this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat'),
-				'child_of' => $child_of,
-				'hide_empty' => true,
-				'hierarchical' => true,
-				'fields' => 'ids'
-			));
-
-			$arCat[] = $child_of;
-
-			return $arCat;
-
-		} // public function getSubCategoryID($parent = 0)
-
-		/**
-		 * Gibt einen Array mit Kategorien unterhalb zurÃŒck
-		 */
-		public function getSubCategory($parent = 0)
-		{
-
-			$arCat = get_categories(array(
-				'taxonomy' => $this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat'),
-				'parent' => $parent,
-				'hide_empty' => true
-			));
-
-			return $arCat;
-
-		} // public function getSubCategory($parent = 0)
-
-		/**
-		 * Gibt einen Array mit Kategorien zurÃŒck
-		 */
-		public function getProductcategorySelect0($ref = 0, $ebene = 0, &$arReturn = array())
-		{
-
-			global $wpdb;
-
-			$arCat = $this->db->fetchAssoc("
-				SELECT
-					T.`term_id`, T.`name`, TT.`parent`, TT.`count`
-				FROM
-					`".$this->shop->prefix."term_taxonomy` AS TT
-						LEFT JOIN `".$this->shop->prefix."terms` AS T ON (T.`term_id` = TT.`term_id`)
-				WHERE
-					TT.`parent` = '".wpsg_q($ref)."' AND
-					TT.`taxonomy` = '".wpsg_q($this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat'))."' AND
-					T.`term_id` > 0
-				ORDER BY
-					T.`name` ASC
-			");
-
-			foreach ($arCat as $c)
-			{
-
-				$cat_name = '';
-				for ($i = 0; $i < $ebene; $i ++) $cat_name .= '-';
-				$cat_name .= $c['name'];
-
-				//$arReturn[$c['term_id']] = $cat_name;
-				$label = $c['name'].' ('.$c['count'].')';
-				$arReturn[] = array('term_id' => $c['term_id'],
-									'name' => $c['name'],
-									'label' => $label,
-									'cat_name' => $cat_name,
-									'parent' => $c['parent'],
-									'count' => $c['count']
-				);
-
-				$this->getProductcategorySelect($c['term_id'], $ebene + 1, $arReturn);
-
-			}
-
-			return $arReturn;
-
-		} // public function getProductcategorySelect($ref = 0)
-
-		public static function getProductcategorySelect($arProductFilter = array())
-		{
-
-			if (wpsg_isSizedArray($arProductFilter))
-			{
-
-				unset($arProductFilter['limit']);
-				unset($arProductFilter['page']);
-				unset($arProductFilter['status']);
-				unset($arProductFilter['productgroup_ids']);
-				unset($arProductFilter['productcategory_ids']);
-
-				list($strQuerySELECT, $strQueryWHERE, $strQueryJOIN, $strQueryHAVING, $strQueryORDER) = wpsg_product::getQueryParts($arProductFilter);
-
-				$strQuery = "
-					SELECT T.`term_id`, T.`name`, P.`name` AS pname, TR.`term_taxonomy_id`,
-					COUNT( T.`term_id` ) AS anzahl
-					FROM `".$GLOBALS['wpsg_sc']->prefix."terms` AS T, `".$GLOBALS['wpsg_sc']->prefix."term_taxonomy` AS TT,
-					`".$GLOBALS['wpsg_sc']->prefix."term_relationships` AS TR, `".$GLOBALS['wpsg_sc']->prefix."posts` AS PO, `".WPSG_TBL_PRODUCTS."` AS P
-					WHERE T.`term_id` = TT.`term_id` AND TT.`term_taxonomy_id` = TR.`term_taxonomy_id` AND TR.`object_id` = PO.`ID` AND
-					PO.`wpsg_produkt_id` = P.`id` ".$strQueryWHERE."
-					GROUP BY T.`term_id`, T.`name`
-				";
-
-				$temp = $GLOBALS['wpsg_db']->fetchAssoc($strQuery);
-				foreach ($temp AS &$v)
-					$v['label'] = $v['name'].' ('.$v['anzahl'].')';
-				return $temp;
-
-
-				//return $GLOBALS['wpsg_db']->fetchAssocField($strQuery, "id", "name");
-
-			}
-			else
-			{
-
-				$strQuery = "
-SELECT `wp_terms`.`term_id`, `wp_terms`.`name`, `wp_wpsg_products`.`name` AS pname,
-COUNT( `wp_terms`.`term_id` ) AS anzahl
-FROM `wp_terms`, `wp_term_taxonomy`, `wp_term_relationships`, `wp_posts`, `wp_wpsg_products`
-WHERE `wp_terms`.`term_id` = `wp_term_taxonomy`.`term_id` AND
-`wp_term_taxonomy`.`term_taxonomy_id` = `wp_term_relationships`.`term_taxonomy_id` AND
-`wp_term_relationships`.`object_id` = `wp_posts`.`ID` AND
-`wp_posts`.`wpsg_produkt_id` = `wp_wpsg_products`.`id` GROUP BY `wp_terms`.`term_id`, `wp_terms`.`name`
-				";
-
-				$temp = $GLOBALS['wpsg_db']->fetchAssoc($strQuery);
-				foreach ($temp AS &$v)
-					$v['label'] = $v['name'].' ('.$v['anzahl'].')';
-				return $temp;
-			}
-
-		} // public static function getProductcategorySelect()
-
-	} // class wpsg_mod_produktartikel extends wpsg_mod_basic
+    
+                }
+    
+                if ($post_id <= 0)
+                {
+    
+                    $data['post_date'] = $product['cdate'];
+                    $post_id = $this->db->ImportQuery($this->shop->prefix.'posts', $data);
+    
+                }
+                else
+                {
+    
+                    $this->db->UpdateQuery($this->shop->prefix.'posts', $data, "`id` = '".wpsg_q($post_id)."'");
+    
+                }
+    
+                if ($path !== false)
+                {
+    
+                    if (!wpsg_isSizedString($path)) $path = $product['name'];
+    
+                    // Pathkey
+                    $data = array();
+                    $data['post_name'] = wpsg_q($this->shop->clear($path, $post_id));
+                    $this->db->UpdateQuery($this->shop->prefix.'posts', $data, "`id` = '".wpsg_q($post_id)."'");
+    
+                }
+    
+                // Kategorie speichern
+                if (!wpsg_isSizedString($_REQUEST['wpsg_lang']))
+                {
+    
+                    // Die Kategorie darf nur beim speichern in der Originalsprache gesetzt werden!
+    
+                    // Alte Zuordnung lÃ¶schen
+                    $this->db->Query("DELETE FROM `".$this->shop->prefix."term_relationships` WHERE `object_id` = '".wpsg_q($post_id)."'");
+    
+                    // Neue Zuordnung speichern
+                    if (wpsg_isSizedArray($_REQUEST['tax_input'][$this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat')]))
+                    {
+    
+                        foreach ($_REQUEST['tax_input'][$this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat')] as $c)
+                        {
+    
+                            $term_taxonomy_id = $this->db->fetchOne("SELECT `term_taxonomy_id` FROM `".$this->shop->prefix."term_taxonomy` WHERE `term_id` = '".wpsg_q($c)."'");
+    
+                            $this->db->ImportQuery($this->shop->prefix.'term_relationships', array(
+                                'object_id' => wpsg_q($post_id),
+                                'term_taxonomy_id' => wpsg_q($term_taxonomy_id),
+                                'term_order' => '0'
+                            ));
+    
+                            $count = $this->db->fetchOne("SELECT COUNT(*) FROM `".$this->shop->prefix."term_relationships` WHERE `term_taxonomy_id` = '".wpsg_q($term_taxonomy_id)."'");
+    
+                            $this->db->UpdateQuery($this->shop->prefix."term_taxonomy", array(
+                                'count' => wpsg_q($count)
+                            ), "`term_taxonomy_id` = '".wpsg_q($term_taxonomy_id)."'");
+    
+                        }
+    
+                    }
+    
+                    $this->updateTaxonomieCount();
+    
+                }
+    
+                $this->updatePostThumbnail($product_id);
+    
+                flush_rewrite_rules();
+    
+                return $post_id;
+    
+            }
+    
+        } // 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
+         */
+        private function setPostType($query)
+        {
+    
+            $post_type = $query->get('post_type');
+    
+            if ($post_type == '' || !wpsg_isSizedArray($post_type))
+            {
+    
+                $postType = array(
+                    'post',
+                    'page',
+                    'attachment',
+                    $this->shop->get_option('wpsg_mod_produktartikel_pathkey')
+                );
+    
+                if (is_string($post_type) && strlen($post_type) > 0)
+                {
+                    $postType[] = $post_type;
+                }
+    
+                $query->set('post_type', $postType);
+    
+            }
+            else
+            {
+    
+                $post_type[] = $this->shop->get_option('wpsg_mod_produktartikel_pathkey');
+    
+                $query->set('post_type', $post_type);
+    
+            }
+    
+        } // private function setPostType($query)
+    
+        /**
+         * Gibt einen Array mit Kategorien zurÃŒck
+         */
+        public function getCategorySelectArray($ref = 0, $ebene = 0, &$arReturn = array())
+        {
+    
+            global $wpdb;
+    
+            $arCat = $this->db->fetchAssoc("
+                    SELECT
+                        T.`term_id`, T.`name`
+                    FROM
+                        `".$this->shop->prefix."term_taxonomy` AS TT
+                            LEFT JOIN `".$this->shop->prefix."terms` AS T ON (T.`term_id` = TT.`term_id`)
+                    WHERE
+                        TT.`parent` = '".wpsg_q($ref)."' AND
+                        TT.`taxonomy` = '".wpsg_q($this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat'))."' AND
+                        T.`term_id` > 0
+                    ORDER BY
+                        T.`name` ASC
+                ");
+    
+            foreach ($arCat as $c)
+            {
+    
+                $cat_name = '';
+                for ($i = 0; $i < $ebene; $i ++) $cat_name .= '-';
+                $cat_name .= $c['name'];
+    
+                $arReturn[$c['term_id']] = $cat_name;
+    
+                $this->getCategorySelectArray($c['term_id'], $ebene + 1, $arReturn);
+    
+            }
+    
+            return $arReturn;
+    
+        } // public function getCategorySelectArray($ref = 0)
+    
+        /**
+         * Gibt einen Array mit KategorieIDs die unter einer Kategorie liegen zurÃŒck
+         */
+        public function getSubCategoryID($child_of = 0)
+        {
+    
+            $arCat = get_categories(array(
+                'taxonomy' => $this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat'),
+                'child_of' => $child_of,
+                'hide_empty' => true,
+                'hierarchical' => true,
+                'fields' => 'ids'
+            ));
+    
+            $arCat[] = $child_of;
+    
+            return $arCat;
+    
+        } // public function getSubCategoryID($parent = 0)
+    
+        /**
+         * Gibt einen Array mit Kategorien unterhalb zurÃŒck
+         */
+        public function getSubCategory($parent = 0)
+        {
+    
+            $arCat = get_categories(array(
+                'taxonomy' => $this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat'),
+                'parent' => $parent,
+                'hide_empty' => true
+            ));
+    
+            return $arCat;
+    
+        } // public function getSubCategory($parent = 0)
+    
+        /**
+         * Gibt einen Array mit Kategorien zurÃŒck
+         */
+        public function getProductcategorySelect0($ref = 0, $ebene = 0, &$arReturn = array())
+        {
+    
+            global $wpdb;
+    
+            $arCat = $this->db->fetchAssoc("
+                    SELECT
+                        T.`term_id`, T.`name`, TT.`parent`, TT.`count`
+                    FROM
+                        `".$this->shop->prefix."term_taxonomy` AS TT
+                            LEFT JOIN `".$this->shop->prefix."terms` AS T ON (T.`term_id` = TT.`term_id`)
+                    WHERE
+                        TT.`parent` = '".wpsg_q($ref)."' AND
+                        TT.`taxonomy` = '".wpsg_q($this->shop->get_option('wpsg_mod_produktartikel_pathkey_cat'))."' AND
+                        T.`term_id` > 0
+                    ORDER BY
+                        T.`name` ASC
+                ");
+    
+            foreach ($arCat as $c)
+            {
+    
+                $cat_name = '';
+                for ($i = 0; $i < $ebene; $i ++) $cat_name .= '-';
+                $cat_name .= $c['name'];
+    
+                //$arReturn[$c['term_id']] = $cat_name;
+                $label = $c['name'].' ('.$c['count'].')';
+                $arReturn[] = array('term_id' => $c['term_id'],
+                    'name' => $c['name'],
+                    'label' => $label,
+                    'cat_name' => $cat_name,
+                    'parent' => $c['parent'],
+                    'count' => $c['count']
+                );
+    
+                $this->getProductcategorySelect($c['term_id'], $ebene + 1, $arReturn);
+    
+            }
+    
+            return $arReturn;
+    
+        } // public function getProductcategorySelect($ref = 0)
+    
+        public static function getProductcategorySelect($arProductFilter = array())
+        {
+    
+            if (wpsg_isSizedArray($arProductFilter))
+            {
+    
+                unset($arProductFilter['limit']);
+                unset($arProductFilter['page']);
+                unset($arProductFilter['status']);
+                unset($arProductFilter['productgroup_ids']);
+                unset($arProductFilter['productcategory_ids']);
+    
+                list($strQuerySELECT, $strQueryWHERE, $strQueryJOIN, $strQueryHAVING, $strQueryORDER) = wpsg_product::getQueryParts($arProductFilter);
+    
+                $strQuery = "
+                        SELECT T.`term_id`, T.`name`, P.`name` AS pname, TR.`term_taxonomy_id`,
+                        COUNT( T.`term_id` ) AS anzahl
+                        FROM `".$GLOBALS['wpsg_sc']->prefix."terms` AS T, `".$GLOBALS['wpsg_sc']->prefix."term_taxonomy` AS TT,
+                        `".$GLOBALS['wpsg_sc']->prefix."term_relationships` AS TR, `".$GLOBALS['wpsg_sc']->prefix."posts` AS PO, `".WPSG_TBL_PRODUCTS."` AS P
+                        WHERE T.`term_id` = TT.`term_id` AND TT.`term_taxonomy_id` = TR.`term_taxonomy_id` AND TR.`object_id` = PO.`ID` AND
+                        PO.`wpsg_produkt_id` = P.`id` ".$strQueryWHERE."
+                        GROUP BY T.`term_id`, T.`name`
+                    ";
+    
+                $temp = $GLOBALS['wpsg_db']->fetchAssoc($strQuery);
+                foreach ($temp AS &$v)
+                    $v['label'] = $v['name'].' ('.$v['anzahl'].')';
+                return $temp;
+    
+    
+                //return $GLOBALS['wpsg_db']->fetchAssocField($strQuery, "id", "name");
+    
+            }
+            else
+            {
+    
+                $strQuery = "
+    SELECT `wp_terms`.`term_id`, `wp_terms`.`name`, `wp_wpsg_products`.`name` AS pname,
+    COUNT( `wp_terms`.`term_id` ) AS anzahl
+    FROM `wp_terms`, `wp_term_taxonomy`, `wp_term_relationships`, `wp_posts`, `wp_wpsg_products`
+    WHERE `wp_terms`.`term_id` = `wp_term_taxonomy`.`term_id` AND
+    `wp_term_taxonomy`.`term_taxonomy_id` = `wp_term_relationships`.`term_taxonomy_id` AND
+    `wp_term_relationships`.`object_id` = `wp_posts`.`ID` AND
+    `wp_posts`.`wpsg_produkt_id` = `wp_wpsg_products`.`id` GROUP BY `wp_terms`.`term_id`, `wp_terms`.`name`
+                    ";
+    
+                $temp = $GLOBALS['wpsg_db']->fetchAssoc($strQuery);
+                foreach ($temp AS &$v)
+                    $v['label'] = $v['name'].' ('.$v['anzahl'].')';
+                return $temp;
+            }
+    
+        } // public static function getProductcategorySelect()
+    
+    } // class wpsg_mod_produktartikel extends wpsg_mod_basic
 
 ?>
