<modification>
	<id>Additional Product Tabs</id>
	<version>1.0.3</version>
	<vqmver>2.2.1</vqmver>
	<author>Godfrey Livinstone</author>

	<file name="catalog/controller/product/product.php" error="log">
    <operation error="log">
			<search position="before"><![CDATA[
				$results = $this->model_catalog_product->getProductRelated($this->request->get['product_id']);
				]]>
			</search>
			<add trim="true"><![CDATA[

				for( $i=1; $i< 6; $i++) {
					$data['product_tabs_' . $i] = array();
				}

				$product_tabs = $this->model_catalog_product->getProductTabs($this->request->get['product_id']);

				foreach ($product_tabs as $product_tab) {

					$data['product_tabs_' . $product_tab['position']][] = array(
						'tab_id' 	=> $product_tab['tab_id'],
						'name'    => $product_tab['name'],
						'text'    => html_entity_decode($product_tab['text'], ENT_QUOTES, 'UTF-8')
					);
				}
				]]>
			</add>
		</operation>
	</file>

	<file name="catalog/model/catalog/product.php" error="log">
		<operation error="log">
			<search position="bottom" offset="2"></search>
			<add trim="true"><![CDATA[
				public function getProductTabs($product_id) {
					$product_tab_data = array();
					$product_tab_query = $this->db->query("SELECT t.tab_id, td.name, pt.text, t.position, t.show_empty FROM " . DB_PREFIX . "product_tab pt LEFT JOIN " . DB_PREFIX . "tab t ON (pt.tab_id = t.tab_id) LEFT JOIN " . DB_PREFIX . "tab_description td ON (t.tab_id = td.tab_id) WHERE pt.product_id = '" . (int)$product_id . "' AND td.language_id = '" . (int)$this->config->get('config_language_id') . "' AND pt.language_id = '" . (int)$this->config->get('config_language_id') . "' AND t.status = '1' AND ( t.show_empty = '1' OR NOT pt.text REGEXP '^[[:space:]]*$' ) ORDER BY t.position, t.sort_order, td.name");
					foreach ($product_tab_query->rows as $product_tab) {
						$product_tab_data[] = array(
								'tab_id' 				=> $product_tab['tab_id'],
								'name'      		=> $product_tab['name'],
								'text'      		=> $product_tab['text'],
								'position' 			=> $product_tab['position']
							);
					}
					return $product_tab_data;
				}
				]]>
			</add>
		</operation>
	</file>
</modification>