当前位置: 首页>>代码示例>>PHP>>正文


PHP Validate::isValidSearch方法代码示例

本文整理汇总了PHP中Validate::isValidSearch方法的典型用法代码示例。如果您正苦于以下问题:PHP Validate::isValidSearch方法的具体用法?PHP Validate::isValidSearch怎么用?PHP Validate::isValidSearch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validate的用法示例。


在下文中一共展示了Validate::isValidSearch方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postProcess

 public function postProcess()
 {
     if (isset($_POST['submitAdd' . $this->table])) {
         $search = strval(Tools::getValue('search'));
         $string = strval(Tools::getValue('alias'));
         $aliases = explode(',', $string);
         if (empty($search) or empty($string)) {
             $this->_errors[] = $this->l('aliases and result are both required');
         }
         if (!Validate::isValidSearch($search)) {
             $this->_errors[] = $search . ' ' . $this->l('is not a valid result');
         }
         foreach ($aliases as $alias) {
             if (!Validate::isValidSearch($alias)) {
                 $this->_errors[] = $alias . ' ' . $this->l('is not a valid alias');
             }
         }
         if (!sizeof($this->_errors)) {
             foreach ($aliases as $alias) {
                 $obj = new Alias(NULL, trim($alias), trim($search));
                 $obj->save();
             }
         }
     } else {
         parent::postProcess();
     }
 }
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:27,代码来源:AdminAliases.php

示例2: __construct

    public function __construct($id = null, $alias = null, $search = null, $id_lang = null)
    {
        $this->def = Alias::getDefinition($this);
        $this->setDefinitionRetrocompatibility();
        if ($id) {
            parent::__construct($id);
        } elseif ($alias && Validate::isValidSearch($alias)) {
            if (!Alias::isFeatureActive()) {
                $this->alias = trim($alias);
                $this->search = trim($search);
            } else {
                $row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
				SELECT a.id_alias, a.search, a.alias
				FROM `' . _DB_PREFIX_ . 'alias` a
				WHERE `alias` LIKE \'' . pSQL($alias) . '\' AND `active` = 1');
                if ($row) {
                    $this->id = (int) $row['id_alias'];
                    $this->search = $search ? trim($search) : $row['search'];
                    $this->alias = $row['alias'];
                } else {
                    $this->alias = trim($alias);
                    $this->search = trim($search);
                }
            }
        }
    }
开发者ID:NathanGiesbrecht,项目名称:PrestaShopAutomationFramework,代码行数:26,代码来源:Alias.php

示例3: __construct

    function __construct($id = NULL, $alias = NULL, $search = NULL, $id_lang = NULL)
    {
        if ($id) {
            parent::__construct($id);
        } elseif ($alias and Validate::isValidSearch($alias)) {
            $row = Db::getInstance()->getRow('
			SELECT a.id_alias, a.search, a.alias
			FROM `' . _DB_PREFIX_ . 'alias` a
			WHERE `alias` LIKE \'' . pSQL($alias) . '\' AND `active` = 1');
            if ($row) {
                $this->id = intval($row['id_alias']);
                $this->search = $search ? trim($search) : $row['search'];
                $this->alias = $row['alias'];
            } else {
                $this->alias = trim($alias);
                $this->search = trim($search);
            }
        }
    }
开发者ID:sealence,项目名称:local,代码行数:19,代码来源:Alias.php

示例4: searchTag

    public static function searchTag($id_lang, $tag, $count = false, $pageNumber = 0, $pageSize = 10, $orderBy = false, $orderWay = false, $useCookie = true, Context $context = null)
    {
        if (!$context) {
            $context = Context::getContext();
        }
        if (!Module::isInstalled('agilemultipleseller') and !Module::isInstalled('agilesellerlistoptions')) {
            return parent::searchTag($id_lang, $expr, $pageNumber, $pageSize, $orderBy, $orderWay, $ajax, $useCookie, $context);
        }
        $agile_sql_parts = AgileSellerManager::getAdditionalSqlForProducts("p");
        if ($useCookie) {
            $id_customer = (int) $context->customer->id;
        } else {
            $id_customer = 0;
        }
        if (!is_numeric($pageNumber) || !is_numeric($pageSize) || !Validate::isBool($count) || !Validate::isValidSearch($tag) || $orderBy && !$orderWay || $orderBy && !Validate::isOrderBy($orderBy) || $orderWay && !Validate::isOrderBy($orderWay)) {
            return false;
        }
        if ($pageNumber < 1) {
            $pageNumber = 1;
        }
        if ($pageSize < 1) {
            $pageSize = 10;
        }
        $id = Context::getContext()->shop->id;
        $id_shop = $id ? $id : Configuration::get('PS_SHOP_DEFAULT');
        if ($count) {
            $sql = 'SELECT COUNT(DISTINCT pt.`id_product`) nb
					FROM `' . _DB_PREFIX_ . 'product` p
		            ' . $agile_sql_parts['joins'] . '
					' . Shop::addSqlAssociation('product', 'p') . '
					LEFT JOIN `' . _DB_PREFIX_ . 'product_tag` pt ON (p.`id_product` = pt.`id_product`)
					LEFT JOIN `' . _DB_PREFIX_ . 'tag` t ON (pt.`id_tag` = t.`id_tag` AND t.`id_lang` = ' . (int) $id_lang . ')
					LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_product` = p.`id_product`)
					LEFT JOIN `' . _DB_PREFIX_ . 'category_shop` cs ON (cp.`id_category` = cs.`id_category` AND cs.`id_shop` = ' . (int) $id_shop . ')
					LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cg.`id_category` = cp.`id_category`)
					WHERE product_shop.`active` = 1
						' . $agile_sql_parts['wheres'] . '
						AND cs.`id_shop` = ' . (int) Context::getContext()->shop->id . '
						AND cg.`id_group` ' . (!$id_customer ? '= ' . (int) Configuration::get('PS_UNIDENTIFIED_GROUP') : 'IN (
							SELECT id_group FROM ' . _DB_PREFIX_ . 'customer_group
							WHERE id_customer = ' . (int) $id_customer . ')') . '
						AND t.`name` LIKE \'%' . pSQL($tag) . '%\'';
            return (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
        }
        $sql = 'SELECT DISTINCT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description_short`, pl.`link_rewrite`, pl.`name`,
					MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` manufacturer_name, 1 position,
					DATEDIFF(
						p.`date_add`,
						DATE_SUB(
							NOW(),
							INTERVAL ' . (Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . ' DAY
						)
					) > 0 new
	            ' . $agile_sql_parts['selects'] . '
				FROM `' . _DB_PREFIX_ . 'product` p
	            ' . $agile_sql_parts['joins'] . '
				INNER JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (
					p.`id_product` = pl.`id_product`
					AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . '
				)
				' . Shop::addSqlAssociation('product', 'p', false) . '
				LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product`)' . Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1') . '		
				LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $id_lang . ')
				LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
				LEFT JOIN `' . _DB_PREFIX_ . 'product_tag` pt ON (p.`id_product` = pt.`id_product`)
				LEFT JOIN `' . _DB_PREFIX_ . 'tag` t ON (pt.`id_tag` = t.`id_tag` AND t.`id_lang` = ' . (int) $id_lang . ')
				LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_product` = p.`id_product`)
				LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cg.`id_category` = cp.`id_category`)
				LEFT JOIN `' . _DB_PREFIX_ . 'category_shop` cs ON (cg.`id_category` = cs.`id_category` AND cs.`id_shop` = ' . (int) $id_shop . ')
				' . Product::sqlStock('p', 0) . '
				WHERE product_shop.`active` = 1
					' . $agile_sql_parts['wheres'] . '
					AND cs.`id_shop` = ' . (int) Context::getContext()->shop->id . '
					AND cg.`id_group` ' . (!$id_customer ? '= ' . (int) Configuration::get('PS_UNIDENTIFIED_GROUP') : 'IN (
						SELECT id_group FROM ' . _DB_PREFIX_ . 'customer_group
						WHERE id_customer = ' . (int) $id_customer . ')') . '
					AND t.`name` LIKE \'%' . pSQL($tag) . '%\'
					GROUP BY product_shop.id_product
				ORDER BY position DESC' . ($orderBy ? ', ' . $orderBy : '') . ($orderWay ? ' ' . $orderWay : '') . '
				LIMIT ' . (int) (($pageNumber - 1) * $pageSize) . ',' . (int) $pageSize;
        if (!($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql))) {
            return false;
        }
        $results = Product::getProductsProperties((int) $id_lang, $result);
        $results = AgileSellerManager::prepareSellerRattingInfo($results);
        return $results;
    }
开发者ID:evilscripts,项目名称:gy,代码行数:87,代码来源:Search.php

示例5: add_alias

 public static function add_alias($alias, $search)
 {
     $configuration = PS_CLI_CONFIGURE::getConfigurationInstance();
     if (!Validate::isValidSearch($alias)) {
         echo "Error, {$alias} is not a valid search string\n";
         return false;
     }
     if (!Validate::isValidSearch($search)) {
         echo "Error, {$search} is not a valid search string\n";
         return false;
     }
     $obj = new Alias(NULL, trim($alias), trim($search));
     if ($obj->save()) {
         if ($configuration->porcelain) {
             echo "{$obj->id}\n";
         } else {
             echo "Successfully added alias {$alias} => {$search}\n";
         }
         return true;
     } else {
         echo "Error, could not add alias {$alias} => {$search} !\n";
         return false;
     }
 }
开发者ID:rodrisan,项目名称:ps-cli,代码行数:24,代码来源:search.php

示例6: find_adv

    public static function find_adv($id_lang, $expr, $pageNumber = 1, $pageSize = 10, $orderBy = false, $orderWay = false)
    {
        if (!is_numeric($pageNumber) or !is_numeric($pageSize) or !Validate::isValidSearch($expr) or $orderBy and !$orderWay) {
            die(Tools::displayError());
        }
        global $link;
        global $cookie;
        if ($orderBy == 'position') {
            $orderBy = 'name';
        }
        if (!is_numeric($pageNumber) or !is_numeric($pageSize) or $orderBy and !$orderWay) {
            die(Tools::displayError());
        }
        $alias = new Alias(NULL, $expr);
        if (Validate::isLoadedObject($alias)) {
            $expr = $alias->search;
        }
        if (!Validate::isValidSearch($expr)) {
            die(Tools::displayError());
        }
        if ($pageNumber < 1) {
            $pageNumber = 1;
        }
        if ($pageSize < 1) {
            $pageSize = 10;
        }
        $expr = str_replace(' ', ' ', pSQL(str_replace('\'', ' ', $expr))) . '';
        $words = explode(' ', AdvSearch::sanitize($expr, $id_lang));
        /* else we search for the expression */
        //$search_query=(Tools::getValue('search_queryy')!=null)?', '.$this->_getScore($expr).'':'';
        ///$search_query2=(Tools::getValue('search_queryy')!=null)?'AND '.$this->_getFilter($expr):'';
        ///////////////////////////////
        foreach ($words as $key => $word) {
            if (!empty($word)) {
                $word = str_replace('%', '\\%', $word);
                $word = str_replace('_', '\\_', $word);
                $whereArray[] = ' p.id_product ' . ($word[0] == '-' ? 'NOT' : '') . ' IN (
					SELECT id_product
					FROM ' . _DB_PREFIX_ . 'search_word sw
					LEFT JOIN ' . _DB_PREFIX_ . 'search_index si ON sw.id_word = si.id_word
					WHERE sw.id_lang = ' . intval($id_lang) . '
					AND sw.word LIKE ' . ($word[0] == '-' ? ' \'' . pSQL(substr($word, 1, PS_SEARCH_MAX_WORD_LENGTH)) . '%\'' : '\'' . pSQL(substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)) . '%\'') . '
				) ';
                if ($word[0] != '-') {
                    $scoreArray[] = 'sw.word LIKE \'' . pSQL(substr($word, 0, PS_SEARCH_MAX_WORD_LENGTH)) . '%\'';
                }
            } else {
                unset($words[$key]);
            }
        }
        if (!sizeof($words)) {
            $searchbywords = '';
        } else {
            $searchbywords = 'AND ' . implode(' AND ', $whereArray);
        }
        ///////////////////////////////
        $displaysupp = AdvSearch::getSuppliers(Tools::getValue('supply'), 'id_supplier');
        $displaymanuf = AdvSearch::getSuppliers(Tools::getValue('manufacturer'), 'id_manufacturer');
        $attributes = '';
        $attributes_val = '';
        if ($attribu = Tools::getValue('atrybut_opcja')) {
            if (!is_array($attribu)) {
                $attrib = urldecode($attribu);
                $attrib = urldecode($attrib);
                $pos = strpos($attrib, ',');
                if ($pos === false) {
                    $att = array($attrib);
                } else {
                    $att = explode(",", $attrib);
                }
                $attributes = AdvSearch::attributesQuery($id_lang, $att, true);
                $attributes_val = AdvSearch::attributesQuery($id_lang, $att, false);
            } else {
                if ($attribu[0] > 0) {
                    $attributes = AdvSearch::attributesQuery($id_lang, $attribu, true);
                    $attributes_val = AdvSearch::attributesQuery($id_lang, $attribu, false);
                }
            }
        }
        $displaycategories = AdvSearch::queryCategories(Tools::getValue('categories'));
        $price_brutto = "CASE WHEN t.rate>0 THEN\n\tCASE WHEN pp.reduction_from!=pp.reduction_to THEN\n\t\tCASE WHEN pp.reduction_to>='" . date("Y-m-d") . "' and pp.reduction_from<='" . date("Y-m-d") . "' THEN\n\t\t\tCASE WHEN pp.reduction_price>0 THEN\n\t\t\t\tROUND(((pp.price*(1+(t.rate/100)))-pp.reduction_price)*cu.conversion_rate,2)\n\t\t\tWHEN pp.reduction_percent>0 THEN\n\t\t\t\tROUND(((pp.price*(1+(t.rate/100)))-((pp.price*(1+(t.rate/100)))*(pp.reduction_percent/100)))*cu.conversion_rate,2)\n\t\t\tELSE\n\t\t\t\tROUND((pp.price*(1+t.rate/100))*cu.conversion_rate,2)\n\t\t\tEND \n\t\tELSE\n\t\t\tROUND((pp.price*(1+t.rate/100))*cu.conversion_rate,2)\n\t\tEND  \n\tELSE\n\t\tCASE WHEN pp.reduction_price>0 THEN\n\t\t\tROUND(((pp.price*(1+t.rate/100))-pp.reduction_price)*cu.conversion_rate,2)\n\t\tWHEN pp.reduction_percent>0 THEN\n\t\t\tROUND(((pp.price*(1+t.rate/100))-((pp.price*(1+(t.rate/100)))*(pp.reduction_percent/100)))*cu.conversion_rate,2)\n\t\tELSE\n\t\t\tROUND((pp.price*(1+t.rate/100))*cu.conversion_rate,2)\n\t\tEND \n\tEND \nELSE\n\tCASE WHEN pp.reduction_from!=pp.reduction_to THEN\n\t\tCASE WHEN pp.reduction_to>='" . date("Y-m-d") . "' and pp.reduction_from<='" . date("Y-m-d") . "' THEN\n\t\t\tCASE WHEN pp.reduction_price>0 THEN\n\t\t\t\tROUND((pp.price-pp.reduction_price)*cu.conversion_rate,2)\n\t\t\tWHEN pp.reduction_percent>0 THEN\n\t\t\t\tROUND((pp.price-(pp.price*(pp.reduction_percent/100)))*cu.conversion_rate,2)\n\t\t\tELSE\n\t\t\t\tROUND((pp.price)*cu.conversion_rate,2)\n\t\t\tEND \n\t\tELSE\n\t\t\tROUND((pp.price)*cu.conversion_rate,2)\n\t\tEND \t\n\tELSE\t\n\t\tCASE WHEN pp.reduction_price>0 THEN\n\t\t\tROUND((pp.price-pp.reduction_price)*cu.conversion_rate,2)\n\t\tWHEN pp.reduction_percent>0 THEN\n\t\t\tROUND((pp.price-(pp.price*(pp.reduction_percent/100)))*cu.conversion_rate,2)\n\t\tELSE\n\t\t\tROUND((pp.price)*cu.conversion_rate,2)\n\t\tEND \t\t\t\n\tEND \n\nEND  ";
        $price_sql = str_replace('PREFIX_', _DB_PREFIX_, Product::getProductPriceSql('p.id_product', 'pp'));
        $sql = 'SELECT DISTINCT p.id_product,0 as `new`, ' . (Tools::getValue('price_from') > 0 || Tools::getValue('price_to') > 0 ? $price_brutto . ' as price_brutto,' : '') . ' p.*, pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`name`, t.`rate`, i.`id_image`, il.`legend`, pp.*
		FROM `' . _DB_PREFIX_ . 'product` p
		' . $attributes . $displaycategories . '
		' . (Tools::getValue('price_from') > 0 || Tools::getValue('price_to') > 0 ? 'JOIN `' . _DB_PREFIX_ . 'currency` cu ' : '') . '
		LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . intval($id_lang) . ')
		LEFT OUTER JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
		LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . intval($id_lang) . ')
		' . $price_sql . '
		LEFT JOIN `' . _DB_PREFIX_ . 'tax` t ON pp.`id_tax` = t.`id_tax` 		 
		WHERE p.`active` = 1 ' . $searchbywords . ' 
		' . (Tools::getValue('price_from') > 0 || Tools::getValue('price_to') > 0 ? 'AND cu.id_currency=' . intval($cookie->id_currency) : '') . ' 
		' . (Tools::getValue('price_from') > 0 ? 'AND ' . $price_brutto . ' >= ' . intval(Tools::getValue('price_from')) : '') . '
		' . (Tools::getValue('price_to') > 0 ? 'AND ' . $price_brutto . ' <= ' . intval(Tools::getValue('price_to')) : '') . '
		' . $displaysupp . $displaymanuf . $attributes_val . '
		' . ($orderBy ? ' ORDER BY ' . $orderBy : '') . ($orderWay ? ' ' . $orderWay : '') . '
		LIMIT ' . intval(($pageNumber - 1) * $pageSize) . ',' . intval($pageSize);
        $sql_count = 'SELECT DISTINCT p.id_product,' . (Tools::getValue('price_from') > 0 || Tools::getValue('price_to') > 0 ? $price_brutto . ' as price_brutto,' : '') . ' p.*, pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`link_rewrite`, pl.`name`, t.`rate`, i.`id_image`, il.`legend`, pp.* 
		FROM `' . _DB_PREFIX_ . 'product` p
//.........这里部分代码省略.........
开发者ID:redb,项目名称:prestashop,代码行数:101,代码来源:AdvSearch.php

示例7: processSave

 public function processSave()
 {
     $search = strval(Tools::getValue('search'));
     $string = strval(Tools::getValue('alias'));
     $aliases = explode(',', $string);
     if (empty($search) || empty($string)) {
         $this->errors[] = $this->l('Aliases and results are both required.');
     }
     if (!Validate::isValidSearch($search)) {
         $this->errors[] = $search . ' ' . $this->l('Is not a valid result');
     }
     foreach ($aliases as $alias) {
         if (!Validate::isValidSearch($alias)) {
             $this->errors[] = $alias . ' ' . $this->l('Is not a valid alias');
         }
     }
     if (!count($this->errors)) {
         foreach ($aliases as $alias) {
             $obj = new Alias(null, trim($alias), trim($search));
             $obj->save();
         }
     }
     if (empty($this->errors)) {
         $this->confirmations[] = $this->l('Creation successful');
     }
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:26,代码来源:AdminSearchConfController.php

示例8: searchTag

    public static function searchTag($id_lang, $tag, $count = false, $pageNumber = 0, $pageSize = 10, $orderBy = false, $orderWay = false, $useCookie = true, Context $context = null)
    {
        if (!$context) {
            $context = Context::getContext();
        }
        // Only use cookie if id_customer is not present
        if ($useCookie) {
            $id_customer = (int) $context->customer->id;
        } else {
            $id_customer = 0;
        }
        if (!is_numeric($pageNumber) || !is_numeric($pageSize) || !Validate::isBool($count) || !Validate::isValidSearch($tag) || $orderBy && !$orderWay || $orderBy && !Validate::isOrderBy($orderBy) || $orderWay && !Validate::isOrderBy($orderWay)) {
            return false;
        }
        if ($pageNumber < 1) {
            $pageNumber = 1;
        }
        if ($pageSize < 1) {
            $pageSize = 10;
        }
        $id = Context::getContext()->shop->id;
        $id_shop = $id ? $id : Configuration::get('PS_SHOP_DEFAULT');
        $sql_groups = '';
        if (Group::isFeatureActive()) {
            $groups = FrontController::getCurrentCustomerGroups();
            $sql_groups = 'AND cg.`id_group` ' . (count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1');
        }
        if ($count) {
            return (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('SELECT COUNT(DISTINCT pt.`id_product`) nb
			FROM `' . _DB_PREFIX_ . 'product` p
			' . Shop::addSqlAssociation('product', 'p') . '
			LEFT JOIN `' . _DB_PREFIX_ . 'product_tag` pt ON (p.`id_product` = pt.`id_product`)
			LEFT JOIN `' . _DB_PREFIX_ . 'tag` t ON (pt.`id_tag` = t.`id_tag` AND t.`id_lang` = ' . (int) $id_lang . ')
			LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_product` = p.`id_product`)
			LEFT JOIN `' . _DB_PREFIX_ . 'category_shop` cs ON (cp.`id_category` = cs.`id_category` AND cs.`id_shop` = ' . (int) $id_shop . ')
			' . (Group::isFeatureActive() ? 'LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cg.`id_category` = cp.`id_category`)' : '') . '
			WHERE product_shop.`active` = 1
			AND p.visibility IN (\'both\', \'search\')
			AND cs.`id_shop` = ' . (int) Context::getContext()->shop->id . '
			' . $sql_groups . '
			AND t.`name` LIKE \'%' . pSQL($tag) . '%\'');
        }
        $sql = 'SELECT DISTINCT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description_short`, pl.`link_rewrite`, pl.`name`,
					MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` manufacturer_name, 1 position,
					DATEDIFF(
						p.`date_add`,
						DATE_SUB(
							NOW(),
							INTERVAL ' . (Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . ' DAY
						)
					) > 0 new
				FROM `' . _DB_PREFIX_ . 'product` p
				INNER JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (
					p.`id_product` = pl.`id_product`
					AND pl.`id_lang` = ' . (int) $id_lang . Shop::addSqlRestrictionOnLang('pl') . '
				)
				' . Shop::addSqlAssociation('product', 'p', false) . '
				LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product`)' . Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1') . '		
				LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $id_lang . ')
				LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
				LEFT JOIN `' . _DB_PREFIX_ . 'product_tag` pt ON (p.`id_product` = pt.`id_product`)
				LEFT JOIN `' . _DB_PREFIX_ . 'tag` t ON (pt.`id_tag` = t.`id_tag` AND t.`id_lang` = ' . (int) $id_lang . ')
				LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_product` = p.`id_product`)
				' . (Group::isFeatureActive() ? 'LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cg.`id_category` = cp.`id_category`)' : '') . '
				LEFT JOIN `' . _DB_PREFIX_ . 'category_shop` cs ON (cp.`id_category` = cs.`id_category` AND cs.`id_shop` = ' . (int) $id_shop . ')
				' . Product::sqlStock('p', 0) . '
				WHERE product_shop.`active` = 1
					AND cs.`id_shop` = ' . (int) Context::getContext()->shop->id . '
					' . $sql_groups . '
					AND t.`name` LIKE \'%' . pSQL($tag) . '%\'
					GROUP BY product_shop.id_product
				ORDER BY position DESC' . ($orderBy ? ', ' . $orderBy : '') . ($orderWay ? ' ' . $orderWay : '') . '
				LIMIT ' . (int) (($pageNumber - 1) * $pageSize) . ',' . (int) $pageSize;
        if (!($result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql))) {
            return false;
        }
        return Product::getProductsProperties((int) $id_lang, $result);
    }
开发者ID:WhisperingTree,项目名称:etagerca,代码行数:78,代码来源:Search.php

示例9: searchTag

    public static function searchTag($id_lang, $tag, $count = false, $pageNumber = 0, $pageSize = 10, $orderBy = false, $orderWay = false, $useCookie = true)
    {
        global $link, $cookie;
        // Only use cookie if id_customer is not present
        if ($useCookie) {
            $id_customer = (int) $cookie->id_customer;
        } else {
            $id_customer = 0;
        }
        if (!is_numeric($pageNumber) or !is_numeric($pageSize) or !Validate::isBool($count) or !Validate::isValidSearch($tag) or $orderBy and !$orderWay or $orderBy and !Validate::isOrderBy($orderBy) or $orderWay and !Validate::isOrderBy($orderWay)) {
            return false;
        }
        if ($pageNumber < 1) {
            $pageNumber = 1;
        }
        if ($pageSize < 1) {
            $pageSize = 10;
        }
        if ($count) {
            $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
			SELECT COUNT(DISTINCT pt.`id_product`) nb
			FROM `' . _DB_PREFIX_ . 'product` p
			LEFT JOIN `' . _DB_PREFIX_ . 'product_tag` pt ON (p.`id_product` = pt.`id_product`)
			LEFT JOIN `' . _DB_PREFIX_ . 'tag` t ON (pt.`id_tag` = t.`id_tag` AND t.`id_lang` = ' . (int) $id_lang . ')
			LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_product` = p.`id_product`)
			LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cg.`id_category` = cp.`id_category`)
			WHERE p.`active` = 1
			AND cg.`id_group` ' . (!$id_customer ? '= 1' : 'IN (
				SELECT id_group FROM ' . _DB_PREFIX_ . 'customer_group
				WHERE id_customer = ' . (int) $id_customer . ')') . '
			AND t.`name` LIKE \'%' . pSQL($tag) . '%\'');
            return isset($result['nb']) ? $result['nb'] : 0;
        }
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
		SELECT DISTINCT p.*, pl.`description_short`, pl.`link_rewrite`, pl.`name`, tax.`rate`, i.`id_image`, il.`legend`, m.`name` manufacturer_name, 1 position,
			DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL ' . (Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20) . ' DAY)) > 0 new
		FROM `' . _DB_PREFIX_ . 'product` p
		INNER JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . (int) $id_lang . ')
		LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
		LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . (int) $id_lang . ')
		LEFT JOIN `' . _DB_PREFIX_ . 'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
		                                           AND tr.`id_country` = ' . (int) Country::getDefaultCountryId() . '
	                                           	   AND tr.`id_state` = 0)
	    LEFT JOIN `' . _DB_PREFIX_ . 'tax` tax ON (tax.`id_tax` = tr.`id_tax`)
		LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
		LEFT JOIN `' . _DB_PREFIX_ . 'product_tag` pt ON (p.`id_product` = pt.`id_product`)
		LEFT JOIN `' . _DB_PREFIX_ . 'tag` t ON (pt.`id_tag` = t.`id_tag` AND t.`id_lang` = ' . (int) $id_lang . ')
		LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_product` = p.`id_product`)
		LEFT JOIN `' . _DB_PREFIX_ . 'category_group` cg ON (cg.`id_category` = cp.`id_category`)
		WHERE p.`active` = 1
		AND cg.`id_group` ' . (!$id_customer ? '= 1' : 'IN (
			SELECT id_group FROM ' . _DB_PREFIX_ . 'customer_group
			WHERE id_customer = ' . (int) $id_customer . ')') . '
		AND t.`name` LIKE \'%' . pSQL($tag) . '%\'
		ORDER BY position DESC' . ($orderBy ? ', ' . $orderBy : '') . ($orderWay ? ' ' . $orderWay : '') . '
		LIMIT ' . (int) (($pageNumber - 1) * $pageSize) . ',' . (int) $pageSize);
        if (!$result) {
            return false;
        }
        return Product::getProductsProperties((int) $id_lang, $result);
    }
开发者ID:priyankajsr19,项目名称:shalu,代码行数:61,代码来源:Search.php

示例10: searchTag

    public static function searchTag($id_lang, $tag, $count = false, $pageNumber = 0, $pageSize = 10, $orderBy = false, $orderWay = false)
    {
        global $link;
        if (!is_numeric($pageNumber) or !is_numeric($pageSize) or !Validate::isBool($count) or !Validate::isValidSearch($tag) or $orderBy and !$orderWay or $orderBy and !Validate::isOrderBy($orderBy) or $orderWay and !Validate::isOrderBy($orderWay)) {
            die(Tools::displayError());
        }
        if ($pageNumber < 1) {
            $pageNumber = 1;
        }
        if ($pageSize < 1) {
            $pageSize = 10;
        }
        if ($count) {
            $result = Db::getInstance()->getRow('
			SELECT COUNT(pt.`id_product`) AS nb
			FROM `' . _DB_PREFIX_ . 'product` p
			LEFT JOIN `' . _DB_PREFIX_ . 'product_tag` pt ON (p.`id_product` = pt.`id_product`)
			LEFT JOIN `' . _DB_PREFIX_ . 'tag` t ON (pt.`id_tag` = t.`id_tag` AND t.`id_lang` = ' . intval($id_lang) . ')
			WHERE p.`active` = 1
			AND t.`name` LIKE \'%' . pSQL($tag) . '%\'');
            return isset($result['nb']) ? $result['nb'] : 0;
        }
        $result = Db::getInstance()->ExecuteS('
		SELECT p.*, pl.`description_short`, pl.`link_rewrite`, pl.`name`, tax.`rate`, i.`id_image`, il.`legend`, m.`name` AS manufacturer_name, 1 as position
		FROM `' . _DB_PREFIX_ . 'product` p
		LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = ' . intval($id_lang) . ')
		LEFT JOIN `' . _DB_PREFIX_ . 'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
		LEFT JOIN `' . _DB_PREFIX_ . 'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = ' . intval($id_lang) . ')
		LEFT JOIN `' . _DB_PREFIX_ . 'tax` tax ON (p.`id_tax` = tax.`id_tax`)
		LEFT JOIN `' . _DB_PREFIX_ . 'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
		LEFT JOIN `' . _DB_PREFIX_ . 'product_tag` pt ON (p.`id_product` = pt.`id_product`)
		LEFT JOIN `' . _DB_PREFIX_ . 'tag` t ON (pt.`id_tag` = t.`id_tag` AND t.`id_lang` = ' . intval($id_lang) . ')
		WHERE p.`active` = 1
		AND t.`name` LIKE \'%' . pSQL($tag) . '%\'
		GROUP BY pt.`id_product`
		ORDER BY position DESC' . ($orderBy ? ', ' . $orderBy : '') . ($orderWay ? ' ' . $orderWay : '') . '
		LIMIT ' . intval(($pageNumber - 1) * $pageSize) . ',' . intval($pageSize));
        if (!$result) {
            return false;
        }
        return Product::getProductsProperties($id_lang, $result);
    }
开发者ID:vincent,项目名称:theinvertebrates,代码行数:42,代码来源:Search.php

示例11: searchTag

 public static function searchTag($id_lang, $tag, $count = false, $pageNumber = 0, $pageSize = 10, $orderBy = false, $orderWay = false, $useCookie = true, JeproshopContext $context = null)
 {
     if (!$context) {
         $context = JeproshopContext::getContext();
     }
     // Only use cookie if id_customer is not present
     if ($useCookie) {
         $customer_id = (int) $context->customer->customer_id;
     } else {
         $customer_id = 0;
     }
     if (!is_numeric($pageNumber) || !is_numeric($pageSize) || !Validate::isBool($count) || !Validate::isValidSearch($tag) || $orderBy && !$orderWay || $orderBy && !Validate::isOrderBy($orderBy) || $orderWay && !Validate::isOrderBy($orderWay)) {
         return false;
     }
     if ($pageNumber < 1) {
         $pageNumber = 1;
     }
     if ($pageSize < 1) {
         $pageSize = 10;
     }
     $shop_id = JeproshopContext::getContext()->shop->shop_id;
     $shop_id = $shop_id ? $shop_id : JeproshopSettingModelSetting::getValue('default_shop');
     $sql_groups = '';
     if (JeproshopGroupModelGroup::isFeaturePublished()) {
         $groups = JeproshopController::getCurrentCustomerGroups();
         $sql_groups = " AND customer_group." . $db->quoteName('group_id') . (count($groups) ? " IN (" . implode(',', $groups) . ")" : "= 1");
     }
     if ($count) {
         $query = "SELECT COUNT(DISTINCT product_tag." . $db->quoteName('product_id') . ") nb FROM " . $db->quoteName('#__jeproshop_product');
         $query .= " AS product " . JeproshopShopModelShop::addSqlAssociation('product') . "\tLEFT JOIN " . $db->quoteName('#__jeproshop_product_tag');
         $query .= " AS product_tag ON (product." . $db->quoteName('product_id') . " = product_tag." . $db->quoteName('product_id') . ") LEFT JOIN ";
         $query .= $db->quoteName('#__jeproshop_tag') . " AS tag ON (product_tag." . $db->quoteName('tag_id') . " = tag." . $db->quoteName('tag_id');
         $query .= " AND tag." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ") LEFT JOIN " . $db->quoteName('#__jeproshop_product_category');
         $query .= " AS product_category ON (product_category." . $db->quoteName('product_id') . " = product." . $db->quoteName('product_id') . ") LEFT JOIN ";
         $query .= $db->quoteName('#__jeproshop_category_shop') . " AS category_shop ON (product_category." . $db->quoteName('category_id') . " = category_shop.";
         $query .= $db->quoteName('category_id') . " AND category_shop." . $db->quoteName('shop_id') . " = " . (int) $shop_id . ") ";
         $query .= JeproshopGroupModelGroup::isFeaturePublished() ? " LEFT JOIN " . $db->quoteName('#__jeproshop_category_group') . " AS category_group ON (category_group." . $db->quoteName('category_id') . " = product_category." . $db->quoteName('category_id') . ")" : "";
         $query .= "\tWHERE product_shop." . $db->quoteName('publishd') . " = 1 AND product.visibility IN ('both', 'search') AND category_shop." . $db->quoteName('shop_id');
         $query .= " = " . (int) JeproshopContext::getContext()->shop->shop_id . $sql_groups . " AND tag." . $db->quoteName('name') . " LIKE '%'" . $db->quote($tag) . "'%')";
         /*$query .= " } 
         	
         				$sql = 'SELECT DISTINCT p.*, product_shop.*, stock.out_of_stock, IFNULL(stock.quantity, 0) as quantity, pl.`description_short`, pl.`link_rewrite`, pl.`name`,
         					MAX(image_shop.`id_image`) id_image, il.`legend`, m.`name` manufacturer_name, 1 position,
         					DATEDIFF(
         						p.`date_add`,
         						DATE_SUB(
         							NOW(),
         							INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY
         						)
         					) > 0 new
         				FROM `' $db->quoteName('#__jeproshop_product` p
         				INNER JOIN `'.$db->quoteName('#__jeproshop_product_lang` pl ON (
         					p.`id_product` = pl.`id_product`
         					AND pl.`id_lang` = '.(int)$id_lang.Shop::addSqlRestrictionOnLang('pl').'
         				)'.Shop::addSqlAssociation('product', 'p', false).'
         				LEFT JOIN `'.$db->quoteName('#__jeproshop_image` i ON (i.`id_product` = p.`id_product`)'.
         					Shop::addSqlAssociation('image', 'i', false, 'image_shop.cover=1').'
         				LEFT JOIN `' . $db->quoteName('#__jeproshop_image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)$id_lang.')
         				LEFT JOIN `'. $db->quoteName('#__jeproshop_manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
         				LEFT JOIN `'. $db->quoteName('#__jeproshop_product_tag` pt ON (p.`id_product` = pt.`id_product`)
         				LEFT JOIN `'. $db->quoteName('#__jeproshop_tag` t ON (pt.`id_tag` = t.`id_tag` AND t.`id_lang` = '.(int)$id_lang.')
         				LEFT JOIN `'. $db->quoteName('#__jeproshop_category_product` cp ON (cp.`id_product` = p.`id_product`)
         				'.(Group::isFeatureActive() ? 'LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = cp.`id_category`)' : '').'
         				LEFT JOIN `'. $db->quoteName('#__jeproshop_category_shop` cs ON (cp.`id_category` = cs.`id_category` AND cs.`id_shop` = '.(int)$id_shop.')
         				'.Product::sqlStock('p', 0).'
         				WHERE product_shop.`active` = 1
         					AND cs.`id_shop` = '.(int)Context::getContext()->shop->id.'
         					'.$sql_groups.'
         					AND t.`name` LIKE \'%'.pSQL($tag).'%\'
         					return (int)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue(
         			
         				
         					GROUP BY product_shop.id_product
         				ORDER BY position DESC'.($orderBy ? ', '.$orderBy : '').($orderWay ? ' '.$orderWay : '').'
         				LIMIT '.(int)(($pageNumber - 1) * $pageSize).','.(int)$pageSize;
         				$db->setQuery($query);
         				$result = $db->loadObjectList();
         				if (!$result)
         					return false; */
     }
     return JeproshopProductModelProduct::getProductsProperties((int) $lang_id, $result);
 }
开发者ID:jeprodev,项目名称:jeproshop,代码行数:82,代码来源:search.php

示例12: dirname

include_once dirname(__FILE__) . '/classes/AdvLink.php';
include_once dirname(__FILE__) . '/classes/AdvSearch.php';
include_once dirname(__FILE__) . '/yasearch.php';
if (Tools::getValue('ajaxSearch') and $query = urldecode(Tools::getValue('q')) and !is_array($query)) {
    include dirname(__FILE__) . '/../../init.php';
    $link = new AdvLink();
    $search = AdvSearch::find(intval(Tools::getValue('id_lang')), $query, 1, 10, 'position', 'desc', true);
    foreach ($search as $product) {
        echo $product['id_product'] . '|' . $product['pname'] . '|' . $product['cname'] . '|' . $link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']) . "\n";
    }
    die;
}
include dirname(__FILE__) . '/../../header.php';
include dirname(__FILE__) . '/../../product-sort.php';
if (Tools::getValue('advSearch') == 1) {
    if (Tools::getValue('search_queryy') == null and Tools::getValue('price_from') == null and Tools::getValue('price_to') == null and !Tools::getValue('atrybut_opcja') and !Tools::getValue('categories') and !Tools::getValue('supply') and !Tools::getValue('manufacturer') and !Tools::getValue('tags') or !Validate::isValidSearch(Tools::getValue('search_queryy')) or Tools::getValue('price_from') != null and !is_numeric(Tools::getValue('price_from')) or Tools::getValue('price_to') != null and !is_numeric(Tools::getValue('price_to'))) {
        $smarty->assign('errors', array(Tools::displayError('invalid search')));
    } else {
        $n = abs(intval(Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE'))));
        $p = abs(intval(Tools::getValue('p', 1)));
        $search = AdvSearch::find_adv(intval($cookie->id_lang), Tools::getValue('search_queryy'), $p, $n, $orderBy, $orderWay);
        $nbProducts = $search['total'];
        include dirname(__FILE__) . '/../../pagination.php';
        /*$smarty->assign(array(
        			'products' => $search->find_adv(intval($cookie->id_lang),Tools::getValue('search_queryy'), $p, $n, $orderBy,$orderWay),
        			'nbProducts' => $nbProducts,
        			'advSearch' => 'Advanced Search'));
        		*/
        $smarty->assign(array('products' => $search['result'], 'nbProducts' => $search['total'], 'query' => 'Advanced Search'));
    }
} else {
开发者ID:redb,项目名称:prestashop,代码行数:31,代码来源:results.php


注:本文中的Validate::isValidSearch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。