<modification>
	<id>DRESSCODE</id>
	<version>2.0</version>
	<vqmver>2.0</vqmver>
	<author>eTheme</author>
    <file name="admin/controller/setting/setting.php">
        <operation>
            <search position="after"><![CDATA[
                $this->model_setting_setting->editSetting('config', $this->request->post);
                ]]></search>
            <add><![CDATA[
                /*function*/
            function loo_parse_queries($file) {
                $sql_file = $file;
                $contents = file_get_contents($sql_file);
                $comment_patterns = array('/\/\*.*(\n)*.*(\*\/)?/', // comments
                    '/\s*--.*\n/', //inline comments start with --
                    '/\s*#.*\n/', //inline comments start with #
                );
                $contents = preg_replace($comment_patterns, "\n", $contents);
                $contents = preg_replace('/(?<=t);(?=\n)/', "{{semicolon_in_text}}", $contents);
                $statements = explode(";\n", $contents);
                $queries = array();
                foreach ($statements as $query) {
                    if (trim($query) != '') {
                        $query = str_replace("{{semicolon_in_text}}", ";", $query);
                        //apply db prefix parametr
                        preg_match("/\?:\w*/i", $query, $matches);
                        $table_name = str_replace('?:', DB_PREFIX, $matches[0]);
                        if ( !empty($table_name) ) {
                            $query = str_replace(array($matches[0], 'key = '), array($table_name, '`key` = '), $query);
                        }
                        $queries[] = $query;
                    }
                }
                return $queries;
            }
            /*function*/
            if(file_exists(DIR_CATALOG . 'view/theme/' . $this->request->post['config_template'] . '/install.sql')) {
				$tmpl_dir = dirname(DIR_CATALOG . 'view/theme/' . $this->request->post['config_template'] . '/install.sql');

				if((bool)stristr($tmpl_dir, $this->config->get('config_template')) == false) {
					// Parse and Run sql
					$sql = loo_parse_queries(DIR_CATALOG . 'view/theme/' . $this->request->post['config_template'] . '/install.sql');
					foreach ($sql as $query) {
						$this->db->query($query);
					}
				}
			}
            // LOO (end)
                ]]></add>
        </operation>
    </file>
    <file name="admin/controller/setting/store.php">
        <operation>
            <search position="after"><![CDATA[
                $this->model_setting_setting->editSetting('config', $this->request->post, $store_id);
                ]]></search>
            <add><![CDATA[
                 /*function*/
            function loo_parse_queries($file) {
                $sql_file = $file;
                $contents = file_get_contents($sql_file);
                $comment_patterns = array('/\/\*.*(\n)*.*(\*\/)?/', // comments
                    '/\s*--.*\n/', //inline comments start with --
                    '/\s*#.*\n/', //inline comments start with #
                );
                $contents = preg_replace($comment_patterns, "\n", $contents);
                $contents = preg_replace('/(?<=t);(?=\n)/', "{{semicolon_in_text}}", $contents);
                $statements = explode(";\n", $contents);
                $queries = array();
                foreach ($statements as $query) {
                    if (trim($query) != '') {
                        $query = str_replace("{{semicolon_in_text}}", ";", $query);
                        //apply db prefix parametr
                        preg_match("/\?:\w*/i", $query, $matches);
                        $table_name = str_replace('?:', DB_PREFIX, $matches[0]);
                        if ( !empty($table_name) ) {
                            $query = str_replace(array($matches[0], 'key = '), array($table_name, '`key` = '), $query);
                        }
                        $queries[] = $query;
                    }
                }
                return $queries;
            }
			// LOO
			if(file_exists(DIR_CATALOG . 'view/theme/' . $this->request->post['config_template'] . '/install.sql')) {
				$tmpl_dir = dirname(DIR_CATALOG . 'view/theme/' . $this->request->post['config_template'] . '/install.sql');
				if((bool)stristr($tmpl_dir, $this->config->get('config_template')) == false) {
					// Parse and Run sql
					$sql = loo_parse_queries(DIR_CATALOG . 'view/theme/' . $this->request->post['config_template'] . '/install.sql');
					foreach ($sql as $query) {
						$this->db->query($query);
					}
				}
			}
            // LOO (end)
                ]]></add>
        </operation>
        <operation>
            <search position="after"><![CDATA[
                $this->model_setting_setting->editSetting('config', $this->request->post, $this->request->get['store_id']);
                ]]></search>
            <add><![CDATA[
                 // LOO
			if(file_exists(DIR_CATALOG . 'view/theme/' . $this->request->post['config_template'] . '/install.sql')) {
				$tmpl_dir = dirname(DIR_CATALOG . 'view/theme/' . $this->request->post['config_template'] . '/install.sql');
				if((bool)stristr($tmpl_dir, $this->config->get('config_template')) == false) {
					// Parse and Run sql
					$sql = loo_parse_queries(DIR_CATALOG . 'view/theme/' . $this->request->post['config_template'] . '/install.sql');
					foreach ($sql as $query) {
						$this->db->query($query);
					}
				}
			}
			// LOO (end)
                ]]></add>
        </operation>
    </file>

    <file name="catalog/controller/product/category.php">
        <operation>
            <search position="before"><![CDATA[
                if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
                ]]></search>
            <add><![CDATA[
                $results_images = $this->model_catalog_product->getProductImages($result['product_id']);
                if ($results_images) {
                    $first = true;
                    foreach ($results_images as $results_image) {
                        if ( $first ) {
                            $popup = $this->model_tool_image->resize($results_image['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
                            $first = false;
                        }
                    }
                } else {
                    $popup = false;
                }
                ]]></add>
        </operation>
        <operation>
            <search position="after"><![CDATA[
                'product_id'  => $result['product_id'],
                ]]></search>
            <add><![CDATA[
                    'popup'   	 => $popup,
                    'name-main'        => strlen($result['name']) > 43 ? utf8_substr(strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8')), 0, 43) . '..' : $result['name'],
                ]]></add>
        </operation>
    </file>
    <file name="catalog/controller/product/manufacturer.php">
        <operation>
            <search position="before"><![CDATA[
                if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
                ]]></search>
            <add><![CDATA[
                $results_images = $this->model_catalog_product->getProductImages($result['product_id']);
                if ($results_images) {
                    $first = true;
                    foreach ($results_images as $results_image) {
                        if ( $first ) {
                            $popup = $this->model_tool_image->resize($results_image['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
                            $first = false;
                        }
                    }
                } else {
                    $popup = false;
                }
                ]]></add>
        </operation>
        <operation>
            <search position="after"><![CDATA[
                'product_id'  => $result['product_id'],
                ]]></search>
            <add><![CDATA[
                    'popup'   	 => $popup,
                    'name-main'        => strlen($result['name']) > 43 ? utf8_substr(strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8')), 0, 43) . '..' : $result['name'],
                ]]></add>
        </operation>
    </file>
    <file name="catalog/controller/product/search.php">
        <operation>
            <search position="before"><![CDATA[
                if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
                ]]></search>
            <add><![CDATA[
                $results_images = $this->model_catalog_product->getProductImages($result['product_id']);
                if ($results_images) {
                    $first = true;
                    foreach ($results_images as $results_image) {
                        if ( $first ) {
                            $popup = $this->model_tool_image->resize($results_image['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
                            $first = false;
                        }
                    }
                } else {
                    $popup = false;
                }
                ]]></add>
        </operation>
        <operation>
            <search position="after"><![CDATA[
                'product_id'  => $result['product_id'],
                ]]></search>
            <add><![CDATA[
                    'popup'   	 => $popup,
                    'name-main'        => strlen($result['name']) > 43 ? utf8_substr(strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8')), 0, 43) . '..' : $result['name'],
                ]]></add>
        </operation>
    </file>
    <file name="catalog/controller/product/special.php">
        <operation>
            <search position="before"><![CDATA[
                if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
                ]]></search>
            <add><![CDATA[
                $results_images = $this->model_catalog_product->getProductImages($result['product_id']);
                if ($results_images) {
                    $first = true;
                    foreach ($results_images as $results_image) {
                        if ( $first ) {
                            $popup = $this->model_tool_image->resize($results_image['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
                            $first = false;
                        }
                    }
                } else {
                    $popup = false;
                }
                ]]></add>
        </operation>
        <operation>
            <search position="after"><![CDATA[
                'product_id'  => $result['product_id'],
                ]]></search>
            <add><![CDATA[
                    'popup'   	 => $popup,
                    'name-main'        => strlen($result['name']) > 43 ? utf8_substr(strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8')), 0, 43) . '..' : $result['name'],
                ]]></add>
        </operation>
    </file>
    <file name="catalog/controller/product/product.php">
        <operation>
            <search position="after"><![CDATA[
                $data['product_id'] = (int)$this->request->get['product_id'];
                ]]></search>
            <add><![CDATA[
                $data['rollover_text'] = $this->language->get('rollover_text');
                $data['no_rating'] = $this->language->get('no_rating');
                $data['tab_youtube'] = $this->language->get('tab_youtube');
                $data['youtube_empty'] = $this->language->get('youtube_empty');
                ]]></add>
        </operation>
        <operation>
            <search position="before" index="2"><![CDATA[
                if (($this->config->get('config_customer_price') && $this->customer->isLogged()) || !$this->config->get('config_customer_price')) {
                ]]></search>
            <add><![CDATA[
                $results_images = $this->model_catalog_product->getProductImages($result['product_id']);
                if ($results_images) {
                    $first = true;
                    foreach ($results_images as $results_image) {
                        if ( $first ) {
                            $popup = $this->model_tool_image->resize($results_image['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
                            $first = false;
                        }
                    }
                } else {
                    $popup = false;
                }
                ]]></add>
        </operation>
        <operation>
            <search position="after"><![CDATA[
                'product_id'  => $result['product_id'],
                ]]></search>
            <add><![CDATA[
                    'popup'   	 => $popup,
                    'name-main'        => strlen($result['name']) > 43 ? utf8_substr(strip_tags(html_entity_decode($result['name'], ENT_QUOTES, 'UTF-8')), 0, 43) . '..' : $result['name'],
                ]]></add>
        </operation>
    </file>
    <file name="catalog/controller/module/carousel.php">
        <operation>
            <search position="after"><![CDATA[
                static $module = 0;
                ]]></search>
            <add><![CDATA[
                $data['title_brands'] = $this->language->get('title_brands');
                ]]></add>
        </operation>
        <operation>
            <search position="replace"><![CDATA[
                $this->document->addScript('catalog/view/javascript/jquery/owl-carousel/owl.carousel.min.js');
                ]]></search>
            <add><![CDATA[
                $this->document->addScript('catalog/view/theme/'. $this->config->get('config_template') .'/js/jquery.carouFredSel-6.2.1-packed.js');
                ]]></add>
        </operation>

    </file>

    <!--new changes-->
    <file name="admin/view/template/design/layout_form.tpl">
        <operation>
            <search position="before"><![CDATA[<?php if ($layout_module['position'] == 'content_top') { ?>]]></search>
            <add><![CDATA[
            <option <?php if ($layout_module['position'] == 'custom_menu') : ?> selected="selected" <?php endif; ?> value="custom_menu">Custom block in Top menu</option>
            <option <?php if ($layout_module['position'] == 'content_footer') : ?> selected="selected" <?php endif; ?> value="content_footer">Deal block</option>
            <option <?php if ($layout_module['position'] == 'content_blog') : ?> selected="selected" <?php endif; ?> value="content_blog">Blog slider</option>

                    ]]></add>
        </operation>
        <operation>
            <search position="before"><![CDATA[html += '    <option value="content_top"><?php echo $text_content_top; ?></option>';]]></search>
            <add><![CDATA[
            html += '    <option value="custom_menu">Custom block in Top menu</option>';
            html += '    <option value="content_footer">Deal block</option>';
            html += '    <option value="content_blog">Blog slider</option>';
            ]]></add>
        </operation>
    </file>
    <file name="catalog/controller/common/home.php">
        <operation>
            <search position="before"><![CDATA[
                $data['column_left'] = $this->load->controller('common/column_left');
                ]]></search>
            <add><![CDATA[
                $data['text_original_products'] = $this->language->get('text_original_products');
                $data['text_free_shipping'] = $this->language->get('text_free_shipping');
                $data['text_cash_delivery'] = $this->language->get('text_cash_delivery');
                $data['text_day_returns'] = $this->language->get('text_day_returns');
                $data['original_products'] = $this->url->link('information/information&amp;information_id=7');
                $data['free_shipping'] = $this->url->link('information/information&amp;information_id=8');
                $data['cash_delivery'] = $this->url->link('information/information&amp;information_id=9');
                $data['day_returns'] = $this->url->link('information/information&amp;information_id=10');

                $data['text_new_products'] = $this->language->get('text_new_products');
                $data['text_sale'] = $this->language->get('text_sale');
                $data['text_bestsellers'] = $this->language->get('text_bestsellers');

                $data['text_shopping_cart'] = $this->language->get('text_shopping_cart');
                $data['shopping_cart'] = $this->url->link('checkout/cart');
                $data['checkout'] = $this->url->link('checkout/checkout', '', 'SSL');
                $data['logged'] = $this->customer->isLogged();
                $data['account'] = $this->url->link('account/account', '', 'SSL');
                $data['text_welcome'] = sprintf($this->language->get('text_welcome'), $this->url->link('account/login', '', 'SSL'), $this->url->link('account/register', '', 'SSL'));
                $data['text_logged'] = sprintf($this->language->get('text_logged'), $this->url->link('account/logout', '', 'SSL'));
                ]]></add>
        </operation>
    </file>


</modification>