Example #1
0
    protected function displaySortCriteriaPanel($objCrit = false)
    {
        if (Tools::getValue('pm_load_function') != 'displaySortCriteriaPanel') {
            $this->_html .= '<div id="sortCriteriaPanel">';
        } else {
            $objCrit = new AdvancedSearchCriterionGroupClass(Tools::getValue('id_criterion_group'), Tools::getValue('id_search'));
            if (Tools::getValue('sort_way')) {
                $objCrit->sort_by = Tools::getValue('sort_by');
                $objCrit->sort_way = Tools::getValue('sort_way');
                $objCrit->save();
                $msgConfirm = $this->l('Specific sort apply');
                if ($objCrit->sort_by == 'position') {
                    $msgConfirm .= '<br />' . $this->l('Now, you can sort criteria by drag n drop');
                }
                $this->_html .= '<script type="text/javascript">show_info("' . addcslashes($msgConfirm, '"') . '");</script>';
            }
        }
        $criterions = AdvancedSearchClass::getCriterionsFromCriterionGroup($objCrit->criterion_group_type, $objCrit->id_criterion_group_linked, $objCrit->id_search, $objCrit->sort_by, $objCrit->sort_way, $this->_cookie->id_lang);
        $this->_html .= '
		<div class="clear"></div>
		<div class="criterionGroupActions">
			<ul>
				<li><a href="' . $this->_base_config_url . '&pm_load_function=processEnableAllCriterions&id_criterion_group=' . $objCrit->id . '&id_search=' . $objCrit->id_search . '" class="ajax_script_load activeAllCriterions" title="' . $this->l('Activate all criterions') . '">' . $this->l('Activate all criterions') . '</a></li>
				<li><a href="' . $this->_base_config_url . '&pm_load_function=processDisableAllCriterions&id_criterion_group=' . $objCrit->id . '&id_search=' . $objCrit->id_search . '" class="ajax_script_load disableAllCriterions" title="' . $this->l('Disable all criterions') . '">' . $this->l('Disable all criterions') . '</a></li>
			</ul>
		</div>
		';
        $this->_html .= '<div class="clear"></div><ul class="sortableCriterion" id="sortableCriterion_' . (int) $objCrit->id_criterion_group_linked . '">';
        foreach ($criterions as $row) {
            $objCritClass = new AdvancedSearchCriterionClass($row['id_criterion'], $objCrit->id_search);
            $this->_html .= '<li class="ui-state-highlight' . (isset($row['is_custom']) && $row['is_custom'] ? ' customCriterionLi' : '') . '" id="criterion_' . $row['id_criterion'] . '" style="height:30px;">';
            $this->_html .= '<span class="ui-icon ui-icon-arrow-4-diag dragIcon dragIconCriterion" style="float:left;margin:0!important;' . ($objCrit->sort_by == 'position' ? '' : ' visibility:hidden') . '">
							</span>';
            $this->_html .= '<span class="critName">' . $row['value'] . '</span>';
            if ($objCrit->display_type == 2) {
                $this->_html .= '<div class="criterionImageContainer">';
                $this->_html .= '<form class="criterionForm" action="' . $this->_base_config_url . '" method="post" enctype="multipart/form-data" target="dialogIframePostForm">';
                $this->displayInlineUploadFile($objCritClass, 'icon' . $row['id_criterion'], 'icon', $this->l('Image'), '/search_files/criterions/');
                $this->_html .= '<input name="id_search" value="' . (int) $objCrit->id_search . '" type="hidden" />';
                $this->_html .= '<input name="id_criterion" value="' . (int) $row['id_criterion'] . '" type="hidden" />';
                $this->_html .= '<input name="key_criterions_group" value="' . $objCrit->criterion_group_type . '-' . (int) $objCrit->id_criterion_group_linked . '-' . (int) $objCrit->id_search . '" type="hidden" />';
                $this->_html .= '<a href="' . $this->_base_config_url . '&pm_load_function=processActiveCriterion&id_criterion=' . $row['id_criterion'] . '&id_search=' . $objCrit->id_search . '" class="ajax_script_load activeCriterion">
									<img src="../img/admin/' . ($row['visible'] ? 'enabled' : 'disabled') . '.gif" id="imgActiveCriterion' . $row['id_criterion'] . '" class="imgActiveCrit" />
								</a>';
                $this->_html .= '</form>';
                $this->_html .= '</div>';
            } else {
                if ($objCrit->criterion_group_type == 'attribute' && AdvancedSearchClass::isColorAttributesGroup($objCrit->id_criterion_group_linked) && isset($row['is_custom']) && $row['is_custom']) {
                    $this->_html .= '<div class="criterionCustomLiveEditContainer" data-id-criterion="' . (int) $row['id_criterion'] . '" data-id-search="' . (int) $objCrit->id_search . '">';
                    $this->_html .= '<div class="criterionCustomLiveField">';
                    $this->_displayInputTextLang(array('obj' => $objCritClass, 'key' => 'value', 'label' => $this->l('Criterion label:')));
                    $this->_html .= '</div>';
                    $this->_html .= '<div class="criterionCustomLiveField">';
                    $this->_displayInputColor(array('obj' => $objCritClass, 'key' => 'color', 'label' => $this->l('Color:')));
                    $this->_html .= '</div>';
                    $this->_html .= '<div style="float: right;">';
                    $this->_displaySubmit($this->l('Save'), 'submitCustomCriterionForm');
                    $this->_html .= '</div>';
                    $this->_html .= '</div>';
                    $this->_html .= '<a href="' . $this->_base_config_url . '&pm_load_function=processActiveCriterion&id_criterion=' . $row['id_criterion'] . '&id_search=' . $objCrit->id_search . '" class="ajax_script_load activeCriterion"><img src="../img/admin/' . ($row['visible'] ? 'enabled' : 'disabled') . '.gif" id="imgActiveCriterion' . $row['id_criterion'] . '" /></a>';
                    $this->_html .= '<a href="javascript:void(0)" class="editCustomCriterion"><img src="../img/admin/edit.gif" id="imgEditCriterion' . $row['id_criterion'] . '" class="imgEditCriterion" /></a>';
                    $this->_html .= '<a href="' . $this->_base_config_url . '&pm_load_function=processDeleteCustomCriterion&id_criterion=' . $row['id_criterion'] . '&id_search=' . $objCrit->id_search . '" class="ajax_script_load deleteCustomCriterion"><img src="../img/admin/delete.gif" id="imgDeleteCriterion' . $row['id_criterion'] . '" class="imgDeleteCriterion" /></a>';
                } else {
                    if ($objCrit->criterion_group_type == 'attribute' && AdvancedSearchClass::isColorAttributesGroup($objCrit->id_criterion_group_linked) && (!isset($row['is_custom']) || isset($row['is_custom']) && !$row['is_custom'])) {
                        $this->_html .= '<a href="' . $this->_base_config_url . '&pm_load_function=processActiveCriterion&id_criterion=' . $row['id_criterion'] . '&id_search=' . $objCrit->id_search . '" class="ajax_script_load activeCriterion"><img src="../img/admin/' . ($row['visible'] ? 'enabled' : 'disabled') . '.gif" id="imgActiveCriterion' . $row['id_criterion'] . '" /></a>';
                        $customCriterionsList = AdvancedSearchCriterionClass::getCustomCriterions($objCrit->id_search, $objCrit->id, $this->_cookie->id_lang);
                        $customCriterionsIdsList = AdvancedSearchCriterionClass::getCustomMasterIdCriterion((int) $objCrit->id_search, $row['id_criterion']);
                        if (is_array($customCriterionsList) && sizeof($customCriterionsList)) {
                            $customCriterionsList = array(0 => $this->l('None')) + $customCriterionsList;
                            $this->_html .= '<div class="addCriterionToCustomGroupContainer">';
                            $this->_displaySelect(array('obj' => (object) array('custom_group_link_id_' . (int) $row['id_criterion'] => AdvancedSearchCriterionClass::getCustomMasterIdCriterion((int) $objCrit->id_search, $row['id_criterion'])), 'label' => $this->l('Add to a group of custom criterion:'), 'key' => 'custom_group_link_id_' . (int) $row['id_criterion'], 'options' => $customCriterionsList, 'defaultvalue' => false, 'onchange' => 'processAddCustomCriterionToGroup($jqPm(this), ' . (int) $objCrit->id_search . ', ' . (int) Tools::getValue('id_criterion_group') . ')'));
                            $this->_html .= '</div>';
                        }
                    } else {
                        $this->_html .= '<a href="' . $this->_base_config_url . '&pm_load_function=processActiveCriterion&id_criterion=' . $row['id_criterion'] . '&id_search=' . $objCrit->id_search . '" class="ajax_script_load activeCriterion"><img src="../img/admin/' . ($row['visible'] ? 'enabled' : 'disabled') . '.gif" id="imgActiveCriterion' . $row['id_criterion'] . '" /></a>';
                    }
                }
            }
            $this->_html .= '</li>';
        }
        $this->_html .= '</ul>';
        if ($objCrit->sort_by == 'position') {
            $this->_html .= '<script type="text/javascript">$jqPm("#sortableCriterion_' . (int) $objCrit->id_criterion_group_linked . '").sortable({
					        handle : ".dragIconCriterion",
					                update: function(event, ui) {
					           var order = $jqPm(this).sortable("toArray");
					                saveOrder(order.join(","),"orderCriterion",' . (int) $objCrit->id_search . ');
					              }
					      });</script>';
        }
        if (Tools::getValue('pm_load_function') != 'displaySortCriteriaPanel') {
            $this->_html .= '</div>';
        }
    }
Example #2
0
 public function process()
 {
     $seo_url = Tools::getValue('seo_url', false);
     if ($seo_url == 'products-comparison') {
         ob_end_clean();
         header("Status: 301 Moved Permanently", false, 301);
         Tools::redirect('products-comparison.php?ajax=' . (int) Tools::getValue('ajax') . '&action=' . Tools::getValue('action') . '&id_product=' . (int) Tools::getValue('id_product'));
         die;
     }
     if ($seo_url && $this->id_seo && !Tools::getValue('getShareBlock')) {
         $resultSeoUrl = AdvancedSearchSeoClass::getSeoSearchByIdSeo((int) $this->id_seo, (int) $this->context->cookie->id_lang);
         if (!$resultSeoUrl) {
             Tools::redirect('404.php');
             die;
         }
         if ($resultSeoUrl[0]['deleted']) {
             header("Status: 301 Moved Permanently", false, 301);
             Tools::redirect('index.php');
             die;
         }
         $currentUri = explode('?', $_SERVER['REQUEST_URI']);
         $currentUri = $currentUri[0];
         $this->realURI = __PS_BASE_URI__ . (Language::countActiveLanguages() > 1 ? Language::getIsoById($this->context->cookie->id_lang) . '/' : '') . 's/' . $resultSeoUrl[0]['id_seo'] . '/' . $resultSeoUrl[0]['seo_url'];
         if (!preg_match('#([a-z]{2})?/?s/([0-9]+)/([a-zA-Z0-9/_-]*)#', $_SERVER['REQUEST_URI'])) {
             header("Status: 301 Moved Permanently", false, 301);
             header("Location: " . $this->realURI . ((int) Tools::getValue('p') > 1 ? '?p=' . (int) Tools::getValue('p') : ''));
             die;
         }
         if (!Tools::getValue('id_seo_id_search') && ($resultSeoUrl[0]['seo_url'] != $seo_url || $currentUri != $this->realURI)) {
             header("Status: 301 Moved Permanently", false, 301);
             header("Location: " . $this->realURI);
             die;
         }
         $this->id_search = $resultSeoUrl[0]['id_search'];
         $AdvancedSearchClass = new AdvancedSearchClass((int) $this->id_search, (int) $this->context->cookie->id_lang);
         if (!$AdvancedSearchClass->active) {
             header("Status: 302 Moved Temporarily", false, 302);
             Tools::redirect('index.php');
             die;
         }
         $criteria = unserialize($resultSeoUrl[0]['criteria']);
         if (is_array($criteria) && sizeof($criteria)) {
             $this->criterions = PM_AdvancedSearch4::getArrayCriteriaFromSeoArrayCriteria($criteria);
         }
         $_GET['id_seo_id_search'] = (int) $this->id_search;
         $_GET['as4c'] = $this->criterions;
         $this->hookName = AdvancedSearchClass::getHookName($AdvancedSearchClass->id_hook);
         $hasPriceCriterionGroup = false;
         if (is_array($this->criterions) && sizeof($this->criterions)) {
             $selected_criteria_groups_type = AdvancedSearchClass::getCriterionGroupsTypeAndDisplay((int) $this->id_search, array_keys($this->criterions));
             if (is_array($selected_criteria_groups_type) && sizeof($selected_criteria_groups_type)) {
                 foreach ($selected_criteria_groups_type as $criterionGroup) {
                     if ($criterionGroup['criterion_group_type'] == 'price') {
                         $hasPriceCriterionGroup = true;
                         break;
                     }
                 }
             }
         }
         if ($hasPriceCriterionGroup && $resultSeoUrl[0]['id_currency'] && $this->context->cookie->id_currency != (int) $resultSeoUrl[0]['id_currency']) {
             $this->context->cookie->id_currency = $resultSeoUrl[0]['id_currency'];
             header('Refresh: 1; URL=' . $_SERVER['REQUEST_URI']);
             die;
         }
         $this->context->smarty->assign('as_cross_links', AdvancedSearchSeoClass::getCrossLinksSeo($this->context->cookie->id_lang, $resultSeoUrl[0]['id_seo']));
     } else {
         if (Tools::getValue('setCollapseGroup')) {
             ob_end_clean();
             $this->id_search = (int) Tools::getValue('id_search');
             $id_criterion_group = (int) Tools::getValue('id_criterion_group');
             $state = (int) Tools::getValue('state');
             $id_criterion_group = $this->id_search . '_' . $id_criterion_group;
             $criterion_state = array($id_criterion_group => $state);
             $previous_criterion = array();
             if (isset($this->context->cookie->criterion_group_state)) {
                 $previous_criterion = unserialize($this->context->cookie->criterion_group_state);
                 if (is_array($previous_criterion) && sizeof($previous_criterion)) {
                     foreach ($previous_criterion as $k => $v) {
                         if ($k == $id_criterion_group) {
                             $criterion_state[$k] = (int) $state;
                         } else {
                             $criterion_state[$k] = (int) $v;
                         }
                     }
                     $this->context->cookie->criterion_group_state = serialize($criterion_state);
                     die;
                 } else {
                     $this->context->cookie->criterion_group_state = serialize($criterion_state);
                 }
                 die;
             } else {
                 $this->context->cookie->criterion_group_state = serialize($criterion_state);
             }
             die;
         } elseif (Tools::getValue('setHideCriterionStatus')) {
             ob_end_clean();
             $this->id_search = (int) Tools::getValue('id_search');
             $state = (int) Tools::getValue('state');
             if (isset($this->context->cookie->hidden_criteria_state)) {
                 $hidden_criteria_state = unserialize($this->context->cookie->hidden_criteria_state);
                 if (is_array($hidden_criteria_state)) {
                     $hidden_criteria_state[$this->id_search] = $state;
                 } else {
                     $hidden_criteria_state = array();
                 }
                 $this->context->cookie->hidden_criteria_state = serialize($hidden_criteria_state);
             } else {
                 $this->context->cookie->hidden_criteria_state = serialize(array($this->id_search => $state));
             }
             die;
         } elseif (Tools::getValue('getShareBlock')) {
             ob_end_clean();
             echo Module::getInstanceByName('pm_advancedsearch4')->getShareBlock(Tools::safeOutput(Tools::getValue('ASSearchTitle')), Tools::safeOutput(Tools::getValue('ASSearchUrl')));
             die;
         } else {
             if (Tools::getValue('resetSearchSelection')) {
                 ob_end_clean();
                 $this->id_search = (int) Tools::getValue('id_search');
                 Module::getInstanceByName('pm_advancedsearch4')->resetSearchSelection($this->id_search);
                 die('1');
             }
         }
         $this->criterions = Tools::getValue('as4c', array());
         if (is_array($this->criterions)) {
             $this->criterions = AdvancedSearchClass::cleanArrayCriterion($this->criterions);
         } else {
             $this->criterions = array();
         }
         $this->criterions_hidden = Tools::getValue('as4c_hidden', array());
         if (is_array($this->criterions_hidden)) {
             $this->criterions_hidden = AdvancedSearchClass::cleanArrayCriterion($this->criterions_hidden);
         } else {
             $this->criterions_hidden = array();
         }
         $this->next_id_criterion_group = (int) Tools::getValue('next_id_criterion_group', false);
         $this->reset = (int) Tools::getValue('reset', false);
         $this->reset_group = (int) Tools::getValue('reset_group', false);
         if ($this->reset) {
             $this->criterions = array();
         }
         if ($this->reset_group && isset($this->criterions[$this->reset_group])) {
             unset($this->criterions[$this->reset_group]);
         }
         $this->hookName = Tools::getValue('hookName');
         if (!Validate::isHookName($this->hookName)) {
             die('Invalid hook name');
         }
         $this->id_search = (int) Tools::getValue('id_search');
         $this->context->cookie->{'next_id_criterion_group_' . (int) $this->id_search} = $this->next_id_criterion_group;
     }
 }
Example #3
0
 public static function isSPAHideColorSquares()
 {
     if (self::$pm_spa_hide_color_squares === null) {
         self::$pm_spa_hide_color_squares = false;
         if (self::isSPAModuleActive()) {
             $module = Module::getInstanceByName('pm_productsbyattributes');
             self::$pm_spa_hide_color_squares = $module->getHideColorSquaresConf();
         }
     }
     return self::$pm_spa_hide_color_squares;
 }