<modification>
	<id>Improved Search</id>
	<version>1.1</version>
	<vqmver>2.1.5</vqmver>
  <author>OpenCartWorld.com</author>
	<email>support@opencartworld.com</email>
  <website>http://www.opencartworld.com</website>

  <!-- ******************************************* START: OCW LIBRARY -->

  <!-- Add OpenCartWorld helper library -->
  <file name="system/startup.php">
    <operation error="skip"> <!-- VERSION: All -->
      <search position="before"><![CDATA[
        ?>
      ]]></search>
      <add><![CDATA[
        require_once(DIR_SYSTEM . 'library/ocw.php');
      ]]></add>
    </operation>
  </file>
  <file name="system/engine/front.php">
    <operation error="skip"> <!-- VERSION: All -->
      <search position="before"><![CDATA[
        $this->registry = $registry;
      ]]></search>
      <add><![CDATA[
        $ocw = new OCW($registry);
        $registry->set('ocw', $ocw);
      ]]></add>
    </operation>
  </file>

  <!-- ******************************************* END: OCW LIBRARY -->

	<!-- ******************************************* START: ADMIN COMMON -->

  <!-- Add configuration check -->
	<file name="admin/language/english/common/home.php">
		<operation error="skip"> <!-- VERSION: All -->
			<search position="before"><![CDATA[
        ?>
      ]]></search>
			<add><![CDATA[
        $_['error_improved_search'] = 'Improved Search extension has not been configured yet! <a href="%s">Configure Now</a>';
      ]]></add>
		</operation>
	</file>
	<file name="admin/controller/common/home.php">
		<operation error="skip"> <!-- VERSION: All -->
			<search position="before"><![CDATA[
        if (is_dir(dirname(DIR_APPLICATION) . '/install')) {
      ]]></search>
			<add><![CDATA[
			  $this->load->model('setting/extension');

		    $extensions = $this->model_setting_extension->getInstalled('module');

			  if (in_array('improved_search', $extensions) && $this->config->get('improved_search_ajax_status') == null) {
				  $this->data['error_improved_search'] = sprintf($this->language->get('error_improved_search'), $this->ocw->buildURL('module/improved_search', 'token=' . $this->session->data['token'], 'SSL'));;
			  } else {
				  $this->data['error_improved_search'] = '';
			  }
      ]]></add>
		</operation>
	</file>
  <file name="admin/view/template/common/home.tpl">
    <operation error="skip"> <!-- VERSION: 1.4.x -->
      <search position="before"><![CDATA[
        <?php if ($error_warning) { ?>
      ]]></search>
      <add><![CDATA[
        <?php if ($error_improved_search) { ?>
      	  <div class="warning"><?php echo $error_improved_search; ?></div>
      	<?php } ?>
      ]]></add>
    </operation>
    <operation error="skip"> <!-- VERSION: 1.5.x -->
      <search position="before"><![CDATA[
        <?php if ($error_install) { ?>
      ]]></search>
      <add><![CDATA[
        <?php if ($error_improved_search) { ?>
      	  <div class="warning"><?php echo $error_improved_search; ?></div>
      	<?php } ?>
      ]]></add>
    </operation>
  </file>


  <!-- Add reporting menu items -->
  <file name="admin/language/english/common/header.php">
    <operation error="skip"> <!-- VERSION: All -->
      <search position="before"><![CDATA[
        ?>
      ]]></search>
      <add><![CDATA[
        $_['text_report_searches'] = 'Searches';
        $_['text_report_search_top_searches'] = 'Top Searches';
      ]]></add>
    </operation>
  </file>
  <file name="admin/controller/common/header.php">
    <operation error="skip"> <!-- VERSION: All -->
      <search position="after"><![CDATA[
    	  $this->data['text_reports'] = $this->language->get('text_reports');
      ]]></search>
      <add><![CDATA[
  			$this->data['text_report_searches'] = $this->language->get('text_report_searches');
  			$this->data['text_report_search_top_searches'] = $this->language->get('text_report_search_top_searches');
   	  ]]></add>
    </operation>
    <operation error="skip"> <!-- VERSION: All -->
      <search position="before"><![CDATA[
        $this->data['stores'] = array();
      ]]></search>
      <add><![CDATA[
        $this->data['report_search_top_searches'] = $this->ocw->buildURL('report/search_top_searches', 'token=' . $this->session->data['token'], 'SSL');
      ]]></add>
    </operation>
  </file>
  <file name="admin/view/template/common/header.tpl">
    <operation error="skip"> <!-- VERSION: All -->
      <search position="after" offset="1"><![CDATA[
        <li id="reports"><a class="top"><?php echo $text_reports; ?></a>
      ]]></search>
      <add><![CDATA[
        <li><a class="parent"><?php echo $text_report_searches; ?></a>
          <ul>
            <li><a href="<?php echo $report_search_top_searches; ?>"><?php echo $text_report_search_top_searches; ?></a></li>
          </ul>
        </li>
      ]]></add>
    </operation>
  </file>

	<!-- ******************************************* END: ADMIN COMMON -->

	<!-- ******************************************* START: CATALOG HEADER  -->
  <file name="catalog/view/theme/*/template/common/footer.tpl">

    <!-- Add new javascript -->
    <operation error="skip"> <!-- VERSION: All -->
      <search position="after"><![CDATA[
        <link rel="stylesheet" type="text/css" href="catalog/view/theme/<?php echo $template; ?>/stylesheet/stylesheet.css" />
      ]]></search>
      <add><![CDATA[
        <?php if ($this->ocw->getVersion() < 1.5) { ?>
        <link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/improved_search_v14x.css" />
        <?php } else { ?>
        <link rel="stylesheet" type="text/css" href="catalog/view/theme/default/stylesheet/improved_search.css" />
        <?php } ?>
      ]]></add>
    </operation>
  </file>

	<file name="catalog/view/theme/*/template/common/footer.tpl">

    <!-- Add new javascript -->
		<operation error="skip"> <!-- VERSION: All -->
			<search position="before"><![CDATA[
				<?php echo $google_analytics; ?>
			]]></search>
			<add><![CDATA[

				<script type="text/javascript"><!--
				  var OPENCART_VERSION = <?php echo $this->ocw->getVersion(); ?>;
				  var IMPROVED_SEARCH_ENHANCED_STATUS = <?php echo $this->config->get('improved_search_enhanced_status') ? 1 : 0; ?>;
			  	var IMPROVED_SEARCH_AJAX_STATUS = <?php echo $this->config->get('improved_search_ajax_status') ? 1 : 0; ?>;
			  	var IMPROVED_SEARCH_AJAX_THUMBNAILS = <?php echo $this->config->get('improved_search_ajax_thumbnails') ? 1 : 0; ?>;
			  	var IMPROVED_SEARCH_AJAX_DESCRIPTIONS = <?php echo $this->config->get('improved_search_ajax_descriptions') ? 1 : 0; ?>;
			  	var IMPROVED_SEARCH_AJAX_DESCRIPTIONS_LENGTH = <?php echo $this->config->get('improved_search_ajax_descriptions_length') ? $this->config->get('improved_search_ajax_descriptions_length') : 0; ?>;
			  	var IMPROVED_SEARCH_AJAX_MODEL = <?php echo $this->config->get('improved_search_ajax_model') ? 1 : 0; ?>;
			  	var IMPROVED_SEARCH_AJAX_PRICE = <?php echo $this->config->get('improved_search_ajax_price') ? 1 : 0; ?>;
			  	var IMPROVED_SEARCH_AJAX_MAX_RESULTS = <?php echo $this->config->get('improved_search_ajax_max_results') ? $this->config->get('improved_search_ajax_max_results') : 0; ?>;
			  	var IMPROVED_SEARCH_SEARCH_WITHIN_DESCRIPTION = <?php echo $this->config->get('improved_search_search_within_description') ? 1 : 0; ?>;
			  	var IMPROVED_SEARCH_SEARCH_WITHIN_MODEL = <?php echo $this->config->get('improved_search_search_within_model') ? 1 : 0; ?>;
			  	var TEXT_TAX = '<?php echo $text_tax; ?>';
				//--></script>
		   	<script type="text/javascript" src="catalog/view/javascript/improved_search.js"></script>
			]]></add>
		</operation>
	</file>

  <!-- Add new language variables -->
  <file name="catalog/controller/common/header.php">
    <operation error="skip"> <!-- VERSION: All -->
      <search position="before"><![CDATA[
    		$this->data['text_home'] = $this->language->get('text_home');
    	]]></search>
      <add><![CDATA[
    		$this->data['text_tax'] = $this->language->get('text_tax');
    	]]></add>
    </operation>
  </file>
  <file name="catalog/language/english/common/header.php">
    <operation error="skip"> <!-- VERSION: All -->
      <search position="before"><![CDATA[
    	?>
    ]]></search>
      <add><![CDATA[
  			$_['text_tax']          = 'Ex Tax:';
   	]]></add>
    </operation>
  </file>

	<!-- ******************************************* END: CATALOG HEADER  -->

	<!-- ******************************************* START: SEARCH CONTROLLER  -->

	<file name="catalog/controller/product/search.php">

    <!-- Add cache rebuild function -->
    <operation error="skip"> <!-- VERSION: All -->
      <search position="after"><![CDATA[
        class ControllerProductSearch extends Controller {
      ]]></search>
      <add><![CDATA[
        public function rebuild() {
          $this->load->model('catalog/improved_search');

          $this->cache->delete('improved_search.products.' . $this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id'));
          $this->cache->delete('improved_search.manufacturers.' . $this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id'));
          $this->cache->delete('improved_search.categories.' . $this->config->get('config_language_id') . '.' . (int)$this->config->get('config_store_id'));

          $num_entries = 0;

          $data = array('search_type' => 'products', 'rebuild_cache_only' => true);
          $num_entries += count($this->model_catalog_improved_search->search($data));

          $data = array('search_type' => 'manufacturers', 'rebuild_cache_only' => true);
          $num_entries += count($this->model_catalog_improved_search->search($data));

          $data = array('search_type' => 'categories', 'rebuild_cache_only' => true);
          $num_entries += count($this->model_catalog_improved_search->search($data));

          $output = array('num_entries'=>number_format($num_entries));

          if ($this->ocw->getVersion() < 1.5)
          {
            $this->load->library('json');
		        $this->response->setOutput(Json::encode($output));
		      } else {
            $this->response->setOutput(json_encode($output));
          }
        }
      ]]></add>
    </operation>

    <!-- Add new language variables -->
    <operation error="skip"> <!-- VERSION: All -->
      <search position="after"><![CDATA[
    		$this->language->load('product/search');
    	]]></search>
      <add><![CDATA[
    		$this->language->load('product/improved_search');
    		$this->data['heading_corrected'] = $this->language->get('heading_corrected');
    		$this->data['text_search_manufacturers'] = $this->language->get('text_search_manufacturers');
    		$this->data['text_search_categories'] = $this->language->get('text_search_categories');
    		$this->data['text_corrected'] = $this->language->get('text_corrected');
    		$this->data['text_search_without'] = $this->language->get('text_search_without');
    		$this->data['text_misspelling'] = $this->language->get('text_misspelling');
    		$this->data['text_similar_sounding'] = $this->language->get('text_similar_sounding');
    		$this->data['show_additional_criteria'] = $this->config->get('improved_search_enhanced_show_additional_criteria');

    		// pre-load image tool
    		$this->load->model('tool/image');
    	]]></add>
    </operation>

    <!-- Revert back to original search functionality if extension is disabled -->
    <operation error="skip"> <!-- VERSION: All -->
			<search position="before"><![CDATA[
				_total =
			]]></search>
			<add><![CDATA[
				if (!$this->config->get('improved_search_enhanced_status') || (isset($this->request->get['disable_additional']) && $this->request->get['disable_additional'])) {
			]]></add>
		</operation>
		<operation error="skip"> <!-- VERSION: All -->
			<search position="after"><![CDATA[
				_total =
			]]></search>
			<add><![CDATA[
				}
			]]></add>
		</operation>
		<operation error="skip"> <!-- VERSION: All -->
			<search position="before"><![CDATA[
				results = $this->model_catalog_product
			]]></search>
			<add><![CDATA[
				if (!$this->config->get('improved_search_enhanced_status') || (isset($this->request->get['disable_additional']) && $this->request->get['disable_additional'])) {
			]]></add>
		</operation>
		<operation error="skip"> <!-- VERSION: All -->
			<search position="after"><![CDATA[
				results = $this->model_catalog_product
			]]></search>
			<add><![CDATA[
				}
			]]></add>
		</operation>

    <!-- Apply ajax output tweaks if searching via Ajax -->
    <operation error="skip"> <!-- VERSION: All -->
      <search position="replace" offset="4"><![CDATA[
        if ($result['image']) {
      ]]></search>
      <add><![CDATA[
        if ($result['image'])
        {
          if (isset($this->request->get['ajax']) && $this->config->get('improved_search_ajax_thumbnails')) {
            $image = $this->model_tool_image->resize($result['image'], $this->config->get('improved_search_ajax_thumbnails_width'), $this->config->get('improved_search_ajax_thumbnails_height'));
          } else {
					  $image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
					}
				} else {
					$image = $this->ocw->getVersion() < 1.5 ? 'no_image.jpg' : false;
			  }

			  $description = isset($this->request->get['ajax']) ?
			    substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, $this->config->get('improved_search_ajax_descriptions_length')) . '..' :
			    substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..';
      ]]></add>
    </operation>

    <!-- Remove default description settings, since this will be overridden later -->
    <operation error="skip"> <!-- VERSION: 1.5.x -->
      <search position="replace"><![CDATA[
    		'description' => substr(strip_tags(html_entity_decode($result['description'], ENT_QUOTES, 'UTF-8')), 0, 100) . '..',
    	]]></search>
      <add><![CDATA[]]></add>
    </operation>

    <!-- Make sure older version is using the new image logic -->
    <operation error="skip"> <!-- VERSION: 1.4.x -->
      <search position="replace"><![CDATA[
        'thumb'   => $this->model_tool_image->resize($image, $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height')),
      ]]></search>
      <add><![CDATA[
        'thumb' => $image,
      ]]></add>
    </operation>

    <!-- Make sure product data contains all required fields -->
    <operation error="skip"> <!-- VERSION: All -->
      <search position="after"><![CDATA[
        $this->data['products'][] = array(
      ]]></search>
      <add><![CDATA[
        'product_id'  => $result['product_id'],
        'description' => $description,
        'model'       => $result['model'],
      ]]></add>
    </operation>

    <!-- Add anchors for placing Pre-Search code -->
    <operation error="skip"> <!-- VERSION: 1.4.x -->
      <search position="after" offset="1"><![CDATA[
        $this->data['model'] = '';
      ]]></search>
      <add><![CDATA[
        /* <!-- OpenCartWorld.com Improved Search "Pre-Search" Anchor --> */
        ]]></add>
    </operation>
    <operation error="skip"> <!-- VERSION: 1.5.x -->
      <search position="before"><![CDATA[
        if (isset($this->request->get['filter_name']) || isset($this->request->get['filter_tag'])) {
      ]]></search>
      <add><![CDATA[
        /* <!-- OpenCartWorld.com Improved Search "Pre-Search" Anchor --> */
      ]]></add>
    </operation>

    <!-- Add pre-search code -->
    <operation error="skip"> <!-- VERSION: All -->
      <search position="after"><![CDATA[
        /* <!-- OpenCartWorld.com Improved Search "Pre-Search" Anchor --> */
      ]]></search>
      <add><![CDATA[

        $this->session->data['corrected_data'] = array();

        if ($this->ocw->getVersion() < 1.5)
        {
          $data['filter_name'] = $this->data['keyword'];
          $data['filter_tag'] = '';
          $data['filter_category_id'] = (isset($this->data['category_id'])) ? $this->data['category_id'] : 0;
          $data['filter_sub_category'] = true;
          $this->data['filter_name'] = $this->data['keyword'];
        }
        else
        {
          $data['filter_name'] = $filter_name;
        }

        $data['within_model']       = (isset($this->request->get['model']) && $this->request->get['model']) ? 1 : $this->config->get('improved_search_search_within_model');
        $data['within_description'] = (isset($this->request->get['filter_description']) && $this->request->get['filter_description']) || (isset($this->request->get['description']) && $this->request->get['description']) ? 1 : 0;
        $data['within_tags']        = $this->config->get('improved_search_search_within_tags');
        $data['within_sku']         = $this->config->get('improved_search_search_within_sku');
        $data['within_upc']         = $this->config->get('improved_search_search_within_upc') && $this->ocw->getVersion() >= 1.5;
        $data['disable_additional'] = (isset($this->request->get['disable_additional']) && $this->request->get['disable_additional']) ? 1 : 0;
        $data['is_ajax']            = (isset($this->request->get['ajax']) && $this->request->get['ajax']) ? 1 : 0;

			  $this->data['matching_manufacturers'] = array();

		  	if ($this->config->get('improved_search_enhanced_status') && $this->config->get('improved_search_enhanced_show_matching_manufacturers') && strlen($data['filter_name']) > 0)
				{
          $this->load->model('catalog/improved_search');

          $data['search_type'] = 'manufacturers';

          $results = $this->model_catalog_improved_search->search($data);

          foreach ($results as $result) {
            if ($result['image']) {
              $image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
            } else {
              $image = false;
            }

            $this->data['matching_manufacturers'][] = array(
              'manufacturer_id'  => $result['manufacturer_id'],
              'thumb'       => $image,
              'name'        => $result['name'],
              'href'        => $this->ocw->getVersion() < 1.5 ?
                $this->ocw->buildURL('product/manufacturer', $url . '&manufacturer_id=' . $result['manufacturer_id'], 'NONSSL') :
                $this->ocw->buildURL('product/manufacturer/product', $url . '&manufacturer_id=' . $result['manufacturer_id'], 'NONSSL')
            );
          }
				}

				$this->data['matching_categories'] = array();

				if ($this->config->get('improved_search_enhanced_status') && $this->config->get('improved_search_enhanced_show_matching_categories') && strlen($data['filter_name']) > 0)
				{
          $this->load->model('catalog/improved_search');

          $data['search_type'] = 'categories';

          $results = $this->model_catalog_improved_search->search($data);

          foreach ($results as $result) {
            if ($result['image']) {
              $image = $this->model_tool_image->resize($result['image'], $this->config->get('config_image_product_width'), $this->config->get('config_image_product_height'));
            } else {
              $image = false;
            }

            $path = $this->model_catalog_improved_search->getBreadcrumbs($result['category_id']);

            $this->data['matching_categories'][] = array(
              'category_id'  => $result['category_id'],
              'thumb'       => $image,
              'name'        => $result['name'],
              'path'        => $path,
              'href'        => $this->ocw->buildURL('product/category', $url . '&path=' . $this->model_catalog_improved_search->getPath($result['category_id']), 'NONSSL')
            );
          }
				}
        ]]></add>
    </operation>

    <!-- Override default search functionality -->
		<operation error="skip"> <!-- VERSION: v.1.4.x -->
			<search position="replace"><![CDATA[
				if ($product_total) {
			]]></search>
			<add><![CDATA[
				if ($this->config->get('improved_search_enhanced_status') && !isset($this->request->get['disable_additional'])) {
					$this->load->model('catalog/improved_search');

					$limit = ($this->config->get('config_catalog_limit')) ? $this->config->get('config_catalog_limit') : 20;

					$data['filter_name'] = $this->data['keyword'];
					$data['filter_tag'] = '';
					$data['filter_category_id'] = (isset($this->data['category_id'])) ? $this->data['category_id'] : 0;
					$data['filter_sub_category'] = true;
					$data['sort'] = $sort;
					$data['order'] = $order;
					$data['start'] = ($page - 1) * $limit;
					$data['limit'] = $limit;
					$data['total_only'] = 1;
          $data['search_type'] = 'products';
          $data['car'] = (isset($this->data['car'])) ? $this->data['car'] : '';

					$product_total = $this->model_catalog_improved_search->search($data);
				}

				if ($product_total || true) {
					if ($this->config->get('improved_search_enhanced_status') && !isset($this->request->get['disable_additional'])) {
						unset($data['total_only']);
						$results = $this->model_catalog_improved_search->search($data);
						$tag_results = array();
					}
			]]></add>
		</operation>
    <operation error="skip"> <!-- VERSION: v.1.5.x -->
      <search position="replace" offset="1"><![CDATA[
        if (isset($this->request->get['filter_name']) || isset($this->request->get['filter_tag'])) {
      ]]></search>
      <add><![CDATA[
        if (isset($this->request->get['filter_name']) || isset($this->request->get['filter_tag'])) {
          $old_data = array(
      ]]></add>
    </operation>
    <operation error="skip"> <!-- VERSION: v.1.5.x -->
			<search position="after" offset="2"><![CDATA[
				'limit'               => $limit
			]]></search>
			<add><![CDATA[

        $data = array_merge($data, $old_data);

				if ($this->config->get('improved_search_enhanced_status'))
				{
					$this->load->model('catalog/improved_search');

          $data['search_type'] = 'products';

					$results = $this->model_catalog_improved_search->search($data);

					$data['total_only'] = '1';

					$product_total = $this->model_catalog_improved_search->search($data);
				}
				else
				{
				  $product_total = $this->model_catalog_product->getTotalProducts($data);

				  $results = $this->model_catalog_product->getProducts($data);
				}
			]]></add>
		</operation>

    <!-- Make new variables available to the view -->
    <operation error="skip"> <!-- VERSION: All -->
      <search position="before"><![CDATA[
    		$this->children = array(
    	]]></search>
      <add><![CDATA[
        $this->data['corrected_data'] = $this->session->data['corrected_data'];
    		$this->data['search_again'] = $this->ocw->buildURL('product/search', $url . '&disable_additional=1', 'NONSSL');
    	]]></add>
    </operation>

    <!-- Handle output if searching from ajax -->
    <operation error="skip"> <!-- VERSION: v.1.4.x -->
      <search position="replace"><![CDATA[
    		$this->response->setOutput($this->render(TRUE), $this->config->get('config_compression'));
    	]]></search>
      <add><![CDATA[
        // make sure products don't show up if there aren't any results
        if (!isset($product_total) || $product_total == 0) unset($this->data['products']);

     	  if (isset($this->request->get['ajax'])) {
          foreach ($this->data['products'] as &$product) $product['href'] = str_replace('&amp;', '&', $product['href']);
          $this->load->library('json');
          $this->response->setOutput(Json::encode($this->data['products']));
        } else {
          $this->response->setOutput($this->render(true), $this->config->get('config_compression'));
        }
    	]]></add>
    </operation>
    <operation error="skip"> <!-- VERSION: v.1.5.x -->
      <search position="replace"><![CDATA[
    		$this->response->setOutput($this->render());
    	]]></search>
      <add><![CDATA[
     	  if (isset($this->request->get['ajax'])) {
     	    foreach ($this->data['products'] as &$product) $product['href'] = str_replace('&amp;', '&', $product['href']);
          $this->response->setOutput(json_encode($this->data['products']));
        } else {
          $this->response->setOutput($this->render());
        }
    	]]></add>
    </operation>
	</file>

	<!-- ******************************************* END: SEARCH CONTROLLER  -->

  <!-- ******************************************* START: SEARCH TEMPLATE  -->

  <file name="catalog/view/theme/*/template/product/search.tpl">

    <!-- Add additional criteria display -->
    <operation error="skip"> <!-- VERSION: 1.4.x -->
      <search position="before"><![CDATA[
    	  <div class="heading"><?php echo $text_search; ?></div>
     ]]></search>
      <add><![CDATA[
      <?php if ($show_additional_criteria && isset($corrected_data) && count($corrected_data)) { ?>
      <div class="heading"><?php echo $heading_corrected; ?></div>
  		 <div class="corrected_data" style="background: #F7F7F7; border: 1px solid #DDDDDD; padding: 10px; margin-top: 3px; margin-bottom: 10px;">
  		  <p><?php echo sprintf($text_corrected, $filter_name); ?> </p>
  		  <ul>
        <?php foreach ($corrected_data as $data) { ?>
          <li>
            <strong><a href="<?php echo $data['corrected_word_href']; ?>"><?php echo $data['corrected_word']; ?></a></strong>
            <?php if ($data['type'] == 'misspelling') { ?>
              <?php echo sprintf($text_misspelling, $data['original_word']); ?>
            <?php } ?>
            <?php if ($data['type'] == 'similar_sounding') { ?>
              <?php echo sprintf($text_similar_sounding, $data['original_word']); ?>
            <?php } ?>
          </li>
        <?php } ?>
        </ul>
        <a href="<?php echo $search_again; ?>"><?php echo $text_search_without; ?></a>
  		 </div>
  		 <?php } ?>
   	  ]]></add>
    </operation>
    <operation error="skip"> <!-- VERSION: 1.5.x -->
      <search position="before"><![CDATA[
    	  <h2><?php echo $text_search; ?></h2>
     ]]></search>
      <add><![CDATA[
      <?php if ($show_additional_criteria && isset($corrected_data) && count($corrected_data)) { ?>
      <h2><?php echo $heading_corrected; ?></h2>
  		 <div class="corrected_data">
  		  <p><?php echo sprintf($text_corrected, $filter_name); ?> </p>
  		  <ul>
        <?php foreach ($corrected_data as $data) { ?>
          <li>
            <strong><a href="<?php echo $data['corrected_word_href']; ?>"><?php echo $data['corrected_word']; ?></a></strong>
            <?php if ($data['type'] == 'misspelling') { ?>
              <?php echo sprintf($text_misspelling, $data['original_word']); ?>
            <?php } ?>
            <?php if ($data['type'] == 'similar_sounding') { ?>
              <?php echo sprintf($text_similar_sounding, $data['original_word']); ?>
            <?php } ?>
          </li>
        <?php } ?>
        </ul>
        <p><a href="<?php echo $search_again; ?>"><?php echo $text_search_without; ?></a></p>
  		 </div>
  		 <?php } ?>
   	  ]]></add>
    </operation>

    <!-- Add matching manufacturers/categories display -->
    <operation error="skip"> <!-- VERSION: 1.4.x -->
      <search position="before" offset="1"><![CDATA[
    		<div class="bottom">
    	]]></search>
      <add><![CDATA[
        <?php if ($matching_manufacturers) { ?>
          <div class="enhanced-manufacturer-list">
          <div class="heading"><?php echo $text_search_manufacturers; ?></div>
            <?php foreach ($matching_manufacturers as $manufacturer) { ?>
              <div>
                <?php if ($manufacturer['thumb']) { ?>
                <div class="image"><a href="<?php echo $manufacturer['href']; ?>"><img src="<?php echo $manufacturer['thumb']; ?>" title="<?php echo $manufacturer['name']; ?>" alt="<?php echo $manufacturer['name']; ?>" /></a></div>
                <?php } ?>
                <div class="name"><a href="<?php echo $manufacturer['href']; ?>"><?php echo $manufacturer['name']; ?></a></div>
                <div class="clear"></div>
              </div>
            <?php } ?>
          </div>
        <? } ?>

        <?php if ($matching_categories) { ?>
          <div class="enhanced-category-list">
          <div class="heading"><?php echo $text_search_categories; ?></div>
            <?php foreach ($matching_categories as $category) { ?>
              <div>
                <?php if ($category['thumb']) { ?>
                <div class="image"><a href="<?php echo $category['href']; ?>"><img src="<?php echo $category['thumb']; ?>" title="<?php echo $category['name']; ?>" alt="<?php echo $category['name']; ?>" /></a></div>
                <?php } ?>
                <div class="name"><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></div>
                <div class="path"><?php echo $category['path']; ?></div>
                <div class="clear"></div>
              </div>
            <?php } ?>
          </div>
        <? } ?>
    	]]></add>
    </operation>
    <operation error="skip"> <!-- VERSION: 1.5.x -->
      <search position="before"><![CDATA[
    		<?php echo $content_bottom; ?></div>
    	]]></search>
      <add><![CDATA[
        <?php if ($matching_manufacturers) { ?>
          <div class="enhanced-manufacturer-list">
          <h2><?php echo $text_search_manufacturers; ?></h2>
            <?php foreach ($matching_manufacturers as $manufacturer) { ?>
              <div>
                <?php if ($manufacturer['thumb']) { ?>
                <div class="image"><a href="<?php echo $manufacturer['href']; ?>"><img src="<?php echo $manufacturer['thumb']; ?>" title="<?php echo $manufacturer['name']; ?>" alt="<?php echo $manufacturer['name']; ?>" /></a></div>
                <?php } ?>
                <div class="name"><a href="<?php echo $manufacturer['href']; ?>"><?php echo $manufacturer['name']; ?></a></div>
                <div class="clear"></div>
              </div>
            <?php } ?>
          </div>
        <?php } ?>

        <?php if ($matching_categories) { ?>
          <div class="enhanced-category-list">
          <h2><?php echo $text_search_categories; ?></h2>
            <?php foreach ($matching_categories as $category) { ?>
              <div>
                <?php if ($category['thumb']) { ?>
                <div class="image"><a href="<?php echo $category['href']; ?>"><img src="<?php echo $category['thumb']; ?>" title="<?php echo $category['name']; ?>" alt="<?php echo $category['name']; ?>" /></a></div>
                <?php } ?>
                <div class="name"><a href="<?php echo $category['href']; ?>"><?php echo $category['name']; ?></a></div>
                <div class="path"><?php echo $category['path']; ?></div>
                <div class="clear"></div>
              </div>
            <?php } ?>
          </div>
        <?php } ?>
    	]]></add>
    </operation>
  </file>

  <!-- ******************************************* END: SEARCH TEMPLATE  -->  

</modification>