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


PHP Search::find方法代码示例

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


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

示例1: searchLogDestroy

 public function searchLogDestroy($id)
 {
     $input = Input::all();
     $sessionId = Common::checkSessionLogin($input);
     Search::find($id)->delete();
     return Common::returnData(200, DELETE_SUCCESS, $input['user_id'], $sessionId);
 }
开发者ID:trantung,项目名称:online_market,代码行数:7,代码来源:ApiSearchController.php

示例2: initContent

 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     $original_query = Tools::getValue('q');
     $query = Tools::replaceAccentedChars(urldecode($original_query));
     if ($this->ajax_search) {
         $searchResults = Search::find((int) Tools::getValue('id_lang'), $query, 1, 10, 'position', 'desc', true);
         if (is_array($searchResults)) {
             foreach ($searchResults as &$product) {
                 $product['product_link'] = $this->context->link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']);
             }
             Hook::exec('actionSearch', array('expr' => $query, 'total' => count($searchResults)));
         }
         $this->ajaxDie(Tools::jsonEncode($searchResults));
     }
     //Only controller content initialization when the user use the normal search
     parent::initContent();
     $product_per_page = isset($this->context->cookie->nb_item_per_page) ? (int) $this->context->cookie->nb_item_per_page : Configuration::get('PS_PRODUCTS_PER_PAGE');
     if ($this->instant_search && !is_array($query)) {
         $this->productSort();
         $this->n = abs((int) Tools::getValue('n', $product_per_page));
         $this->p = abs((int) Tools::getValue('p', 1));
         $search = Search::find($this->context->language->id, $query, 1, 10, 'position', 'desc');
         Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));
         $nbProducts = $search['total'];
         $this->pagination($nbProducts);
         $this->addColorsToProductList($search['result']);
         $this->context->smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $original_query, 'instant_search' => $this->instant_search, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
     } elseif (($query = Tools::getValue('search_query', Tools::getValue('ref'))) && !is_array($query)) {
         $this->productSort();
         $this->n = abs((int) Tools::getValue('n', $product_per_page));
         $this->p = abs((int) Tools::getValue('p', 1));
         $original_query = $query;
         $query = Tools::replaceAccentedChars(urldecode($query));
         $search = Search::find($this->context->language->id, $query, $this->p, $this->n, $this->orderBy, $this->orderWay);
         if (is_array($search['result'])) {
             foreach ($search['result'] as &$product) {
                 $product['link'] .= (strpos($product['link'], '?') === false ? '?' : '&') . 'search_query=' . urlencode($query) . '&results=' . (int) $search['total'];
             }
         }
         Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));
         $nbProducts = $search['total'];
         $this->pagination($nbProducts);
         $this->addColorsToProductList($search['result']);
         $this->context->smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $original_query, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
     } elseif (($tag = urldecode(Tools::getValue('tag'))) && !is_array($tag)) {
         $nbProducts = (int) Search::searchTag($this->context->language->id, $tag, true);
         $this->pagination($nbProducts);
         $result = Search::searchTag($this->context->language->id, $tag, false, $this->p, $this->n, $this->orderBy, $this->orderWay);
         Hook::exec('actionSearch', array('expr' => $tag, 'total' => count($result)));
         $this->addColorsToProductList($result);
         $this->context->smarty->assign(array('search_tag' => $tag, 'products' => $result, 'search_products' => $result, 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
     } else {
         $this->context->smarty->assign(array('products' => array(), 'search_products' => array(), 'pages_nb' => 1, 'nbProducts' => 0));
     }
     $this->context->smarty->assign(array('add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
     $this->setTemplate(_PS_THEME_DIR_ . 'search.tpl');
 }
开发者ID:prestanesia,项目名称:PrestaShop,代码行数:61,代码来源:SearchController.php

示例3: initContent

 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $query = Tools::replaceAccentedChars(urldecode(Tools::getValue('q')));
     if ($this->ajax_search) {
         $searchResults = Search::find((int) Tools::getValue('id_lang'), $query, 1, 10, 'position', 'desc', true);
         foreach ($searchResults as &$product) {
             $product['product_link'] = $this->context->link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']);
         }
         die(Tools::jsonEncode($searchResults));
     }
     if ($this->instant_search && !is_array($query)) {
         $this->productSort();
         $this->n = abs((int) Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')));
         $this->p = abs((int) Tools::getValue('p', 1));
         $search = Search::find($this->context->language->id, $query, 1, 10, 'position', 'desc');
         Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));
         $nbProducts = $search['total'];
         $this->pagination($nbProducts);
         $this->context->smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $query, 'instant_search' => $this->instant_search, 'homeSize' => Image::getSize('home_default')));
     } else {
         if (($query = Tools::getValue('search_query', Tools::getValue('ref'))) && !is_array($query)) {
             $this->productSort();
             $this->n = abs((int) Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')));
             $this->p = abs((int) Tools::getValue('p', 1));
             $search = Search::find($this->context->language->id, $query, $this->p, $this->n, $this->orderBy, $this->orderWay);
             Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));
             $nbProducts = $search['total'];
             $this->pagination($nbProducts);
             $this->context->smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $query, 'homeSize' => Image::getSize('home_default')));
         } else {
             if (($tag = urldecode(Tools::getValue('tag'))) && !is_array($tag)) {
                 $nbProducts = (int) Search::searchTag($this->context->language->id, $tag, true);
                 $this->pagination($nbProducts);
                 $result = Search::searchTag($this->context->language->id, $tag, false, $this->p, $this->n, $this->orderBy, $this->orderWay);
                 Hook::exec('actionSearch', array('expr' => $tag, 'total' => count($result)));
                 $this->context->smarty->assign(array('search_tag' => $tag, 'products' => $result, 'search_products' => $result, 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize('home_default')));
             } else {
                 $this->context->smarty->assign(array('products' => array(), 'search_products' => array(), 'pages_nb' => 1, 'nbProducts' => 0));
             }
         }
     }
     $this->context->smarty->assign(array('add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
     $this->setTemplate(_PS_THEME_DIR_ . 'search.tpl');
 }
开发者ID:rrameshsat,项目名称:Prestashop,代码行数:49,代码来源:SearchController.php

示例4: preProcess

 public function preProcess()
 {
     parent::preProcess();
     $query = urldecode(Tools::getValue('q'));
     if ($this->ajaxSearch) {
         self::$link = new Link();
         $searchResults = Search::find((int) Tools::getValue('id_lang'), $query, 1, 10, 'position', 'desc', true);
         if (is_array($searchResults)) {
             foreach ($searchResults as &$product) {
                 $product['product_link'] = self::$link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']);
             }
         }
         die(Tools::jsonEncode($searchResults));
     } elseif ($this->instantSearch && !is_array($query)) {
         $this->productSort();
         $this->n = abs((int) Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')));
         $this->p = abs((int) Tools::getValue('p', 1));
         $search = Search::find((int) self::$cookie->id_lang, $query, $this->p, $this->n, $this->orderBy, $this->orderWay);
         Module::hookExec('search', array('expr' => $query, 'total' => $search['total']));
         $nbProducts = $search['total'];
         $this->pagination($nbProducts);
         self::$smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $query, 'instantSearch' => $this->instantSearch, 'homeSize' => Image::getSize('home')));
     } elseif ($query = Tools::getValue('search_query', Tools::getValue('ref')) and !is_array($query)) {
         $this->productSort();
         $this->n = abs((int) Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')));
         $this->p = abs((int) Tools::getValue('p', 1));
         $search = Search::find((int) self::$cookie->id_lang, $query, $this->p, $this->n, $this->orderBy, $this->orderWay);
         Module::hookExec('search', array('expr' => $query, 'total' => $search['total']));
         $nbProducts = $search['total'];
         $this->pagination($nbProducts);
         self::$smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $query, 'homeSize' => Image::getSize('home')));
     } elseif ($tag = urldecode(Tools::getValue('tag')) and !is_array($tag)) {
         $this->productSort();
         $nbProducts = (int) Search::searchTag((int) self::$cookie->id_lang, $tag, true);
         $this->pagination($nbProducts);
         $result = Search::searchTag((int) self::$cookie->id_lang, $tag, false, $this->p, $this->n, $this->orderBy, $this->orderWay);
         Module::hookExec('search', array('expr' => $tag, 'total' => sizeof($result)));
         self::$smarty->assign(array('search_tag' => $tag, 'products' => $result, 'search_products' => $result, 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize('home')));
     } else {
         self::$smarty->assign(array('products' => array(), 'search_products' => array(), 'pages_nb' => 1, 'nbProducts' => 0));
     }
     self::$smarty->assign('add_prod_display', Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'));
 }
开发者ID:Evil1991,项目名称:PrestaShop-1.4,代码行数:43,代码来源:SearchController.php

示例5: manage

 /**
  * Management of search
  *
  */
 public function manage()
 {
     if (!isset($this->wsObject->urlFragments['query']) || !isset($this->wsObject->urlFragments['language'])) {
         throw new WebserviceException('You have to set both the \'language\' and \'query\' parameters to get a result', array(100, 400));
     }
     $objects_products = array();
     $objects_categories = array();
     $objects_products['empty'] = new Product();
     $objects_categories['empty'] = new Category();
     $this->_resourceConfiguration = $objects_products['empty']->getWebserviceParameters();
     if (!$this->wsObject->setFieldsToDisplay()) {
         return false;
     }
     $results = Search::find($this->wsObject->urlFragments['language'], $this->wsObject->urlFragments['query'], 1, 1, 'position', 'desc', true, false);
     $categories = array();
     foreach ($results as $result) {
         $current = new Product($result['id_product']);
         $objects_products[] = $current;
         $categories_result = $current->getWsCategories();
         foreach ($categories_result as $category_result) {
             foreach ($category_result as $id) {
                 $categories[] = $id;
             }
         }
     }
     $categories = array_unique($categories);
     foreach ($categories as $id) {
         $objects_categories[] = new Category($id);
     }
     $this->output .= $this->objOutput->getContent($objects_products, null, $this->wsObject->fieldsToDisplay, $this->wsObject->depth, WebserviceOutputBuilder::VIEW_LIST, false);
     // @todo allow fields of type category and product
     // $this->_resourceConfiguration = $objects_categories['empty']->getWebserviceParameters();
     // if (!$this->setFieldsToDisplay())
     // return false;
     $this->output .= $this->objOutput->getContent($objects_categories, null, $this->wsObject->fieldsToDisplay, $this->wsObject->depth, WebserviceOutputBuilder::VIEW_LIST, false);
 }
开发者ID:IngenioContenidoDigital,项目名称:americana,代码行数:40,代码来源:WebserviceSpecificManagementSearch.php

示例6: initContent

    /**
     * Assign template vars related to page content
     * @see FrontController::initContent()
     */
    public function initContent()
    {
        $query = Tools::replaceAccentedChars(urldecode(Tools::getValue('q')));
        $query_loc = Tools::replaceAccentedChars(urldecode(Tools::getValue('search_loc')));
        $query_state = Tools::replaceAccentedChars(urldecode(Tools::getValue('search_state')));
        $query_city = Tools::replaceAccentedChars(urldecode(Tools::getValue('search_city')));
        $query_cat = Tools::replaceAccentedChars(urldecode(Tools::getValue('search_cat')));
        $query_words = Tools::replaceAccentedChars(urldecode(Tools::getValue('search_words')));
        $original_query = Tools::getValue('q');
        $original_query_loc = Tools::getValue('search_original');
        $query_original = Tools::getValue('search_original');
        $original_query_cat = Tools::getValue('search_cat');
        $original_query_words = Tools::getValue('search_words');
        if ($this->ajax_search) {
            // die(Tools::jsonEncode(array('key' => 'value')));
            $searchresult = array();
            $sqlcountry = 'SELECT *, country as countryflg FROM ' . _DB_PREFIX_ . 'product_lang where country LIKE "' . $query . '%" Group by country';
            $resultcountry = Db::getInstance()->ExecuteS($sqlcountry);
            $sqlstate = 'SELECT *, state as stateflg FROM ' . _DB_PREFIX_ . 'product_lang where state LIKE "' . $query . '%" Group by state';
            $resultstate = Db::getInstance()->ExecuteS($sqlstate);
            $sqlcity = 'SELECT *, city as cityflg FROM ' . _DB_PREFIX_ . 'product_lang where city LIKE "' . $query . '%" Group by city ';
            $resultcity = Db::getInstance()->ExecuteS($sqlcity);
            array_push($searchresult, $resultcountry);
            array_push($searchresult, $resultstate);
            array_push($searchresult, $resultcity);
            if ($resultcity == null && $resultstate == null && $resultcountry == null) {
                $sqlplace = 'SELECT *, concat_ws(" ",country,state) as allflg,country as country FROM ' . _DB_PREFIX_ . 'product_lang	
					where concat_ws(" ",country,state) LIKE "' . $query . '%" AND id_lang = 1 Group by state limit 5 ';
                $resultplace = Db::getInstance()->ExecuteS($sqlplace);
                $sqlplacecity = 'SELECT *, city as cityflg,country as country FROM ' . _DB_PREFIX_ . 'product_lang	
					where concat_ws(" ",country,city) LIKE "' . $query . '%" AND id_lang = 1 Group by city limit 5 ';
                $resultplacecity = Db::getInstance()->ExecuteS($sqlplacecity);
                array_push($searchresult, $resultplace);
                array_push($searchresult, $resultplacecity);
            }
            $searchresult = array_filter($searchresult);
            $searchresult = array_values($searchresult);
            // foreach ($results as $key => $values){
            // 	$results[$key]['cityflag'] = $resultscity;
            // }
            die(Tools::jsonEncode($searchresult));
            // die('<pre>'.print_r($searchresult,true));
        }
        //Only controller content initialization when the user use the normal search
        parent::initContent();
        if ($this->instant_search && !is_array($query)) {
            $this->productSort();
            $this->n = abs((int) Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')));
            $this->p = abs((int) Tools::getValue('p', 1));
            $search = Search::find($this->context->language->id, $query, 1, 10, 'position', 'desc');
            Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));
            $nbProducts = $search['total'];
            $this->pagination($nbProducts);
            $this->addColorsToProductList($search['result']);
            $this->context->smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $original_query, 'instant_search' => $this->instant_search, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
        } elseif (($query = Tools::getValue('search_query', Tools::getValue('ref'))) && !is_array($query)) {
            $this->productSort();
            $this->n = abs((int) Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')));
            $this->p = abs((int) Tools::getValue('p', 1));
            $original_query = $query;
            $query = Tools::replaceAccentedChars(urldecode($query));
            $search = Search::find($this->context->language->id, $query, $this->p, $this->n, $this->orderBy, $this->orderWay);
            foreach ($search['result'] as &$product) {
                $product['link'] .= (strpos($product['link'], '?') === false ? '?' : '&') . 'search_query=' . urlencode($query) . '&results=' . (int) $search['total'];
            }
            Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));
            $nbProducts = $search['total'];
            $this->pagination($nbProducts);
            $this->addColorsToProductList($search['result']);
            $this->context->smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $original_query, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
        } elseif (($tag = urldecode(Tools::getValue('tag'))) && !is_array($tag)) {
            $nbProducts = (int) Search::searchTag($this->context->language->id, $tag, true);
            $this->pagination($nbProducts);
            $result = Search::searchTag($this->context->language->id, $tag, false, $this->p, $this->n, $this->orderBy, $this->orderWay);
            Hook::exec('actionSearch', array('expr' => $tag, 'total' => count($result)));
            $this->addColorsToProductList($result);
            $this->context->smarty->assign(array('search_tag' => $tag, 'products' => $result, 'search_products' => $result, 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
        } elseif ($query_loc !== "" || $query_cat !== "" || $query_words !== "" || $query_state !== "" || $query_city !== "" || $query_original !== "") {
            $this->productSort();
            $this->n = abs((int) Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')));
            $this->p = abs((int) Tools::getValue('p', 1));
            $query_arr = array('words' => $query_words, 'location' => $query_loc, 'city' => $query_city, 'state' => $query_state, 'original' => $query_original, 'category' => $query_cat);
            $search = Search::find($this->context->language->id, $query_arr, $this->p, $this->n, $this->orderBy, $this->orderWay);
            foreach ($search['result'] as &$product) {
                $product['link'] .= (strpos($product['link'], '?') === false ? '?' : '&') . 'search_query=' . urlencode($query) . '&results=' . (int) $search['total'];
            }
            Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));
            $nbProducts = $search['total'];
            $this->pagination($nbProducts);
            /*foreach($search['result'] as $k => $v) {
            			$country = $v['country'];
            			$flagId = Country::getIdByName(1, $country);
            			$search['result'][$k]['img_exist']	= file_exists(_PS_ROOT_DIR_ . DS . 'flag' . DS . 'mini'. DS . $flagId . '.jpg')? 1 : 0;
            			$search['result'][$k]['img_name']	= $flagId . '.jpg';
            		}*/
            foreach ($search['result'] as $key => $value) {
//.........这里部分代码省略.........
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:101,代码来源:SearchController.php

示例7: parseSearch

function parseSearch($intElmntId, $strCommand)
{
    global $_PATHS, $objLang, $DBAConn;
    $objTpl = new HTML_Template_IT($_PATHS['templates']);
    $objTpl->loadTemplatefile("search.tpl.htm");
    $objTpl->setVariable("TITLE", $objLang->get("pageTitle"));
    $objTpl->setVariable("MAINTITLE", $objLang->get("pcmsSearch", "menu"));
    $objTpl->setVariable("BUTTON_INDEX_HREF", "?cid=" . NAV_PCMS_SEARCH . "&amp;cmd=" . CMD_BUILD_INDEX);
    $objTpl->setVariable("BUTTON_INDEX", $objLang->get("searchIndex", "button"));
    $objTpl->setVariable("SEARCH_BUTTON", $objLang->get("search", "button"));
    $objTpl->setVariable("SEARCH_ALL", $objLang->get("searchall", "label"));
    //*** Perform query if submitted.
    $objSearch = new Search();
    $strQuery = request('query');
    $strExact = request('search_all');
    $strCache = request('cache');
    $intPosition = request("pos");
    $blnExact = false;
    $blnCache = false;
    if ($strExact == 'on') {
        $blnExact = true;
    }
    if ($strCache == 'true') {
        $blnCache = true;
    }
    if ($strCommand == CMD_BUILD_INDEX) {
        //*** Rebuild search index.
        set_time_limit(60 * 60);
        $objSearch->clearIndex();
        $objSearch->updateIndex();
        $objTpl->setVariable("SEARCH_DESCRIPTION", $objLang->get("searchIndexed", "form"));
    }
    if (!empty($strQuery)) {
        $objResults = $objSearch->find($strQuery, $blnExact);
        //*** Cache results in the current session.
        $_SESSION["searchresult"] = serialize($objResults);
    } else {
        if ($blnCache && isset($_SESSION["searchresult"]) && is_object(unserialize($_SESSION["searchresult"]))) {
            $objResults = unserialize($_SESSION["searchresult"]);
        }
    }
    if (isset($objResults) && is_object($objResults)) {
        $objTpl->setVariable("RESULT_LABEL", $objLang->get("searchresult", "label"));
        $objTpl->setVariable("SEARCH_STRING", $objResults->getQuery());
        if ($objResults->count() > 0) {
            $listCount = 0;
            $intPosition = !empty($intPosition) && is_numeric($intPosition) ? $intPosition : 0;
            $intPosition = floor($intPosition / $_SESSION["listCount"]) * $_SESSION["listCount"];
            $objResults->seek($intPosition);
            //*** Render results.
            foreach ($objResults as $objResult) {
                $objElement = Element::selectByPK($objResult->id);
                if (is_object($objElement)) {
                    $strPath = "<b>" . $objLang->get("path", "label") . "</b>" . Element::recursivePath($objElement->getParentId());
                } else {
                    $strPath = "";
                }
                $objTpl->setCurrentBlock("searchresult");
                $objTpl->setVariable("EID", $objResult->id);
                $objTpl->setVariable("CID", NAV_PCMS_ELEMENTS);
                $objTpl->setVariable("CMD", CMD_EDIT);
                $objTpl->setVariable("RESULT_NAME", $objResult->name);
                $objTpl->setVariable("RESULT_RATIO", $objResult->ratio);
                $strValue = strip_tags($objResult->value);
                if (!empty($strValue)) {
                    $objTpl->setVariable("RESULT_VALUE", $strValue);
                }
                if (!empty($strPath)) {
                    $objTpl->setVariable("RESULT_PATH", $strPath);
                }
                $objTpl->parseCurrentBlock();
            }
            //*** Render page navigation.
            $pageCount = ceil($objResults->count() / $_SESSION["listCount"]);
            if ($pageCount > 0) {
                $currentPage = ceil(($intPosition + 1) / $_SESSION["listCount"]);
                $previousPos = $intPosition - $_SESSION["listCount"] > 0 ? $intPosition - $_SESSION["listCount"] : 0;
                $nextPos = $intPosition + $_SESSION["listCount"] < $objResults->count() ? $intPosition + $_SESSION["listCount"] : $intPosition;
                $objTpl->setVariable("PAGENAV_PAGE", sprintf($objLang->get("pageNavigation", "label"), $currentPage, $pageCount));
                $objTpl->setVariable("PAGENAV_PREVIOUS", $objLang->get("previous", "button"));
                $objTpl->setVariable("PAGENAV_PREVIOUS_HREF", "?cid=" . NAV_PCMS_SEARCH . "&amp;pos={$previousPos}&amp;cache=true");
                $objTpl->setVariable("PAGENAV_NEXT", $objLang->get("next", "button"));
                $objTpl->setVariable("PAGENAV_NEXT_HREF", "?cid=" . NAV_PCMS_SEARCH . "&amp;pos={$nextPos}&amp;cache=true");
                //*** Bottom page navigation.
                for ($intCount = 0; $intCount < $pageCount; $intCount++) {
                    $objTpl->setCurrentBlock("pagenavitem");
                    $position = $intCount * $_SESSION["listCount"];
                    if ($intCount != $intPosition / $_SESSION["listCount"]) {
                        $objTpl->setVariable("PAGENAV_HREF", "href=\"?cid=" . NAV_PCMS_SEARCH . "&amp;pos={$position}&amp;cache=true\"");
                    }
                    $objTpl->setVariable("PAGENAV_VALUE", $intCount + 1);
                    $objTpl->parseCurrentBlock();
                }
            }
        } else {
            $objTpl->setCurrentBlock("searchresult");
            $objTpl->setVariable("RESULT_VALUE", $objLang->get("search_noresult", "label"));
            $objTpl->parseCurrentBlock();
        }
    }
//.........这里部分代码省略.........
开发者ID:laiello,项目名称:punchcms,代码行数:101,代码来源:inc.tplparse_search.php

示例8: define

<?php

if (isset($_GET['q'])) {
    require_once 'config.php';
    define('ID_LANG', 1);
    $q = $_GET['q'];
    $results = Search::find($q);
    $response = "";
    foreach ($results as $result) {
        $response .= '<a href="index.php?page=bookings&id=' . $result->id . '">Reserva: #' . $result->id . '&nbsp;- ' . $result->name . '&nbsp;' . $result->email . '&nbsp;' . $result->dni . '</a><br>';
    }
    if ($response == "") {
        $response = "no encontrado";
    }
    echo $response;
}
开发者ID:erseco,项目名称:ugr_sistemas_de_informacion_basados_en_web,代码行数:16,代码来源:livesearch.php

示例9: searchFormData

 public static function searchFormData($searchId = 0)
 {
     $priceArray = self::priceFormArray();
     $categoryArray = self::categoryFormArray();
     // $categoryArray = CommonCategory::categoryArray();
     // $typeArray = selectProductType();
     $typeArray = CommonCategory::typeArray();
     $timeArray = CommonCategory::timeArray();
     $cityArray = Common::listCity();
     $id = null;
     $name = null;
     $lat = null;
     $long = null;
     $price_id = null;
     $category_id = null;
     $type_id = null;
     $time_id = null;
     $city_id = null;
     if ($searchId > 0) {
         $search = Search::find($searchId);
         if (count($search) > 0) {
             $id = $searchId;
             $name = $search->name;
             $lat = $search->lat;
             $long = $search->long;
             $city_id = $search->city_id;
             $price_id = $search->price_id;
             $category_id = $search->category_id;
             $type_id = $search->type_id;
             $time_id = $search->time_id;
             $city = $search->city;
         }
     }
     $data = array('id' => $id, 'name' => $name, 'lat' => $lat, 'long' => $long, 'city_id' => $city_id, 'price_id' => $price_id, 'category_id' => $category_id, 'type_id' => $type_id, 'time_id' => $time_id, 'categoryArray' => $categoryArray, 'typeArray' => $typeArray, 'timeArray' => $timeArray, 'cityArray' => $cityArray);
     return $data;
 }
开发者ID:trantung,项目名称:online_market,代码行数:36,代码来源:CommonSearch.php

示例10: dirname

<?php

include dirname(__FILE__) . '/config/config.inc.php';
if (Tools::getValue('ajaxSearch') and $query = urldecode(Tools::getValue('q')) and !is_array($query)) {
    include dirname(__FILE__) . '/init.php';
    $link = new Link();
    $search = Search::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 ($query = Tools::getValue('search_query', Tools::getValue('tag', Tools::getValue('ref'))) and !is_array($query)) {
    $n = abs(intval(Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE'))));
    $p = abs(intval(Tools::getValue('p', 1)));
    $search = Search::find(intval($cookie->id_lang), $query, $p, $n, $orderBy, $orderWay);
    $nbProducts = $search['total'];
    include dirname(__FILE__) . '/pagination.php';
    $smarty->assign(array('products' => $search['result'], 'nbProducts' => $search['total'], 'query' => $query));
} else {
    $smarty->assign(array('products' => array(), 'pages_nb' => 1, 'nbProducts' => 0));
}
$smarty->display(_PS_THEME_DIR_ . 'search.tpl');
include dirname(__FILE__) . '/footer.php';
开发者ID:Bruno-2M,项目名称:prestashop,代码行数:26,代码来源:search.php

示例11: initContent

 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $this->context->smarty->assign(array('HOOK_LEFT_COLUMN' => Hook::exec('displayLeftColumn')));
     $query = Tools::replaceAccentedChars(urldecode(Tools::getValue('q')));
     $original_query = Tools::getValue('q');
     if ($this->ajax_search) {
         $searchResults = Search::find((int) Tools::getValue('id_lang'), $query, 1, 10, 'position', 'desc', true);
         foreach ($searchResults as &$product) {
             $product['product_link'] = $this->context->link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']);
         }
         die(Tools::jsonEncode($searchResults));
     }
     if ($this->instant_search && !is_array($query)) {
         $this->productSort();
         $this->n = abs((int) Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')));
         $this->p = abs((int) Tools::getValue('p', 1));
         $search = Search::find($this->context->language->id, $query, 1, 10, 'position', 'desc');
         Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));
         $nbProducts = $search['total'];
         $this->pagination($nbProducts);
         $this->addColorsToProductList($search['result']);
         $products = $search['result'];
         $this->context->smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $original_query, 'instant_search' => $this->instant_search, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
     } elseif (($query = Tools::getValue('search_query', Tools::getValue('ref'))) && !is_array($query)) {
         $this->productSort();
         $this->n = abs((int) Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')));
         $this->p = abs((int) Tools::getValue('p', 1));
         $original_query = $query;
         $query = Tools::replaceAccentedChars(urldecode($query));
         $search = Search::find($this->context->language->id, $query, $this->p, $this->n, $this->orderBy, $this->orderWay);
         foreach ($search['result'] as &$product) {
             $product['link'] .= (strpos($product['link'], '?') === false ? '?' : '&') . 'search_query=' . urlencode($query) . '&results=' . (int) $search['total'];
         }
         Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));
         $nbProducts = $search['total'];
         $this->pagination($nbProducts);
         $this->addColorsToProductList($search['result']);
         $products = $search['result'];
         $this->context->smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $original_query, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
     } elseif (($tag = urldecode(Tools::getValue('tag'))) && !is_array($tag)) {
         $nbProducts = (int) Search::searchTag($this->context->language->id, $tag, true);
         $this->pagination($nbProducts);
         $result = Search::searchTag($this->context->language->id, $tag, false, $this->p, $this->n, $this->orderBy, $this->orderWay);
         Hook::exec('actionSearch', array('expr' => $tag, 'total' => count($result)));
         $this->addColorsToProductList($result);
         $products = $result;
         $this->context->smarty->assign(array('search_tag' => $tag, 'products' => $result, 'search_products' => $result, 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
     } else {
         $products = array();
         $this->context->smarty->assign(array('products' => array(), 'search_products' => array(), 'pages_nb' => 1, 'nbProducts' => 0));
     }
     $this->context->smarty->assign(array('add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
     if ($this->ajax) {
         $product_list = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'product-list.tpl');
         $pagination = $this->context->smarty->fetch(_PS_THEME_DIR_ . 'pagination.tpl');
         $nbLeftProducts = $nbProducts - ($this->n * ($this->p - 1) + count($products));
         $nbLeftProductsPercentage = ($nbProducts - $nbLeftProducts) / $nbProducts * 100;
         echo Tools::jsonEncode(array('productList' => utf8_encode($product_list), 'pagination' => $pagination, 'nbRenderedProducts' => $nbProducts, 'nbLeftProducts' => $nbLeftProducts, 'nbLeftProductsPercentage' => $nbLeftProductsPercentage));
         die;
     } else {
         $this->setTemplate(_PS_THEME_DIR_ . 'search.tpl');
     }
 }
开发者ID:WhisperingTree,项目名称:etagerca,代码行数:68,代码来源:SearchController.php

示例12: generateHtml

<?php

//namespace Klarschiff;
require_once dirname(__FILE__) . "/conf/config.php";
require_once dirname(__FILE__) . "/Search.php";
$search = new Search($solrConf);
$result = $search->find(isset($_GET["searchtext"]) ? $_GET["searchtext"] : "*");
$backend = isset($_GET["backend"]) && strtolower($_GET["backend"]) === 'true';
$resultJson = array("result" => "", "array" => array());
function generateHtml($href, $name, $type, $title, $backend)
{
    $class = $backend ? "resultElement" : "result-element";
    return '<div class="' . $class . '">&nbsp;<a href="' . $href . '" name="' . $name . '" class="gotoBBOX">' . $title . '</a><span>' . $type . '</span></div>';
}
function generateJson($bbox_array, $type, $title)
{
    return array("label" => $title, "bbox" => $bbox_array);
}
foreach ($result->documents as $doc) {
    $data = json_decode($doc->json, true);
    $type = strtolower($data["type"]);
    $bbox_array = array();
    if (substr($data['geom'], 0, 3) == "BOX") {
        foreach (explode(",", substr($data['geom'], 4, -1)) as $i) {
            foreach (explode(" ", $i) as $j) {
                $bbox_array[] = $j;
            }
        }
    }
    if ($type === "ort") {
        $title = $data['ort_name'];
开发者ID:bfpi,项目名称:klarschiff-frontend,代码行数:31,代码来源:server.php

示例13: assign

 /**
  * Assign search template
  */
 public function assign()
 {
     $query = Tools::replaceAccentedChars(urldecode(Tools::getValue('q')));
     $original_query = Tools::getValue('q');
     $id_category = Tools::getValue('id_category');
     if (Tools::getValue('ajax_Search')) {
         $searchResults = Search::find((int) Tools::getValue('id_lang'), $query, 1, (int) Tools::getValue('limit', 10), 'position', 'desc', true);
         $results = array();
         foreach ($searchResults as $product) {
             $cover = Product::getCover($product['id_product']);
             $product['product_link'] = $this->context->link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']);
             $product['product_image'] = $this->context->link->getImageLink($product['prewrite'], $cover['id_image'], 'home_default');
             $product['id_category'] = $id_category;
             $product['categories'] = Product::getProductCategories($product['id_product']);
             if ($id_category == 'all' || in_array((int) $id_category, Product::getProductCategories($product['id_product']))) {
                 $results[] = $product;
             }
         }
         die(Tools::jsonEncode($results));
     }
     if (Tools::getValue('instantSearch') && !is_array($query)) {
         $this->productSort();
         $this->n = abs((int) Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')));
         $this->p = abs((int) Tools::getValue('p', 1));
         $search = Search::find($this->context->language->id, $query, 1, 10, 'position', 'desc');
         Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));
         $results = array();
         $index = 0;
         foreach ($search['result'] as $product) {
             $categories_id = Product::getProductCategories($product['id_product']);
             if (in_array((int) $id_category, Product::getProductCategories($product['id_product']))) {
                 if (($this->p - 1) * $this->n <= $index && $index < $this->p * $this->n) {
                     $results[] = $product;
                 }
                 $index++;
             }
         }
         $nbProducts = $index;
         $this->pagination($nbProducts);
         $this->addColorsToProductList($results);
         $this->context->smarty->assign(array('products' => $results, 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $original_query, 'instant_search' => $this->instant_search, 'request' => $this->context->link->getModuleLink('categorysearch', 'catesearch'), 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
     } elseif (($query = Tools::getValue('search_query', Tools::getValue('ref'))) && !is_array($query)) {
         $this->productSort();
         $this->n = abs((int) Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')));
         $this->p = abs((int) Tools::getValue('p', 1));
         $original_query = $query;
         $query = Tools::replaceAccentedChars(urldecode($query));
         $search = Search::find($this->context->language->id, $query, $this->p, $this->n, $this->orderBy, $this->orderWay);
         //if($this->orderBy == 'price') $search['result'] = Tools::orderbyPrice($search['result'], $this->orderWay);
         //print_r($search['result']);
         //die;
         foreach ($search['result'] as &$product) {
             $product['link'] .= (strpos($product['link'], '?') === false ? '?' : '&') . 'search_query=' . urlencode($query) . '&results=' . (int) $search['total'];
         }
         $results = array();
         $id_category = Tools::getValue('search_category', 'all');
         Hook::exec('actionSearch', array('expr' => $query, 'total' => $search['total']));
         $nbProducts = $search['total'];
         $this->context->smarty->assign(array('search_query' => $original_query, 'homeSize' => Image::getSize(ImageType::getFormatedName('home'))));
         if ($id_category == 'all') {
             $this->pagination($nbProducts);
             $this->addColorsToProductList($search['result']);
             $this->context->smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'nbp' => $this->p, 'nbn' => $this->n, 'orderby' => $this->orderBy, 'orderWay' => $this->orderWay, 'request' => $this->context->link->getModuleLink('categorysearch', 'catesearch')));
         } else {
             $search = Search::find($this->context->language->id, $query, 1, $nbProducts, $this->orderBy, $this->orderWay);
             $results = array();
             $index = 0;
             foreach ($search['result'] as $product) {
                 $categories_id = Product::getProductCategories($product['id_product']);
                 if (in_array((int) $id_category, Product::getProductCategories($product['id_product']))) {
                     if (($this->p - 1) * $this->n <= $index && $index < $this->p * $this->n) {
                         $results[] = $product;
                     }
                     $index++;
                 }
             }
             $nbProducts = $index;
             foreach ($results as &$product) {
                 $product['link'] .= (strpos($product['link'], '?') === false ? '?' : '&') . 'search_query=' . urlencode($query) . '&results=' . (int) $nbProducts;
             }
             $this->pagination($nbProducts);
             $this->addColorsToProductList($results);
             $this->context->smarty->assign(array('products' => $results, 'search_products' => $results, 'nbProducts' => $nbProducts, 'nbp' => $this->p, 'nbn' => $this->n, 'orderby' => $this->orderBy, 'orderWay' => $this->orderWay, 'request' => $this->context->link->getModuleLink('categorysearch', 'catesearch')));
         }
     } else {
         $this->context->smarty->assign(array('products' => array(), 'search_products' => array(), 'pages_nb' => 1, 'nbProducts' => 0));
     }
     $this->context->smarty->assign(array('add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'comparator_max_item' => Configuration::get('PS_COMPARATOR_MAX_ITEM')));
     $this->setTemplate('searchresult.tpl');
 }
开发者ID:habypk,项目名称:zocart,代码行数:93,代码来源:catesearch.php

示例14: preProcess

 public function preProcess()
 {
     parent::preProcess();
     $query = urldecode(Tools::getValue('q'));
     if ($this->ajaxSearch) {
         self::$link = new Link();
         $searchResults = Search::find((int) Tools::getValue('id_lang'), $query, 1, 10, 'position', 'desc', true);
         foreach ($searchResults as &$product) {
             $product['product_link'] = self::$link->getProductLink($product['id_product'], $product['prewrite'], $product['crewrite']);
         }
         die(Tools::jsonEncode($searchResults));
     }
     if ($this->instantSearch && !is_array($query)) {
         $this->productSort();
         $this->n = abs((int) Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')));
         $this->p = abs((int) Tools::getValue('p', 1));
         $search = Search::find((int) self::$cookie->id_lang, $query, $this->p, $this->n, 'position', 'desc');
         Module::hookExec('search', array('expr' => $query, 'total' => $search['total']));
         $nbProducts = $search['total'];
         $this->pagination($nbProducts);
         self::$smarty->assign(array('products' => $search['result'], 'search_products' => $search['result'], 'nbProducts' => $search['total'], 'search_query' => $query, 'instantSearch' => $this->instantSearch, 'homeSize' => Image::getSize('home')));
     } elseif ($query = Tools::getValue('search_query', Tools::getValue('ref')) and !is_array($query)) {
         $this->productSort();
         $this->n = abs((int) Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE')));
         $this->p = abs((int) Tools::getValue('p', 1));
         //$search = Search::find((int)(self::$cookie->id_lang), $query, $this->p, $this->n, 'position', 'desc');
         $other_results = false;
         try {
             //get the right address for this cart
             global $cart, $cookie;
             $id_country = (int) Country::getDefaultCountryId();
             if ($cart->id_address_delivery) {
                 $address = new Address($cart->id_address_delivery);
                 if ($address->id_country) {
                     $id_country = $address->id_country;
                 } elseif (isset($cookie->id_country)) {
                     $id_country = (int) $cookie->id_country;
                 }
             }
             self::$smarty->assign('price_tax_country', $id_country);
             $resultSet = Search::searchProducts($query, $this->p, $this->n, $other_results);
             $products = $resultSet->getData();
             $products = $products['response']['docs'];
             $total_results = $resultSet->getNumFound();
         } catch (Exception $e) {
             self::$smarty->assign('fetch_error', 1);
         }
         Module::hookExec('search', array('expr' => $query, 'total' => $total_results));
         $this->pagination($total_results);
         self::$smarty->assign(array('products' => $products, 'search_products' => $products, 'nbProducts' => $total_results, 'search_query' => $query, 'homeSize' => Image::getSize('home'), 'ssResults' => $other_results));
         $generic_description = "Buy the widest range of sarees, salwar kameez, kurtis, tunics and ghaghra cholis by shopping online at IndusDiva.com, India's leading online store for buying #phrase#. All products are double-checked for quality before they get shipped and we take extra care to ensure the safety of your order. We deliver products all over the world through leading courier service providers to ensure timely and hassle-free deliveries.\n\t\t\t\t\t\t\t\t\t<br><br>\n\t\t\t\t\t\t\t\t\tTo buy #phrase#, all you need to do is review your shopping cart and provide the address details and phone number at checkout. IndusDiva.com offers the best available price across all online shopping sites and provides the best collection of Indian wear online. Shopping for Indian saris, blouse and salwar kurta online just turned more fun as getting your hands on #phrase# has never been so easy.";
         $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS("select description from ps_seo_keywords where keyword = '" . $query . "'");
         if (count($res) > 0) {
             self::$smarty->assign('search_description', str_replace('#phrase#', $query, $res[0]['description']));
         } else {
             self::$smarty->assign('search_description', str_replace('#phrase#', $query, $generic_description));
         }
     } elseif ($tag = urldecode(Tools::getValue('tag')) and !is_array($tag)) {
         $nbProducts = (int) Search::searchTag((int) self::$cookie->id_lang, $tag, true);
         $this->pagination($nbProducts);
         $result = Search::searchTag((int) self::$cookie->id_lang, $tag, false, $this->p, $this->n, $this->orderBy, $this->orderWay);
         Module::hookExec('search', array('expr' => $tag, 'total' => sizeof($result)));
         self::$smarty->assign(array('search_tag' => $tag, 'products' => $result, 'search_products' => $result, 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize('home')));
     } else {
         self::$smarty->assign(array('products' => array(), 'search_products' => array(), 'pages_nb' => 1, 'nbProducts' => 0));
     }
     self::$smarty->assign('add_prod_display', Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'));
     self::$smarty->assign('lazy', 1);
 }
开发者ID:priyankajsr19,项目名称:indusdiva2,代码行数:69,代码来源:SearchController.php

示例15: process_ticket

 function process_ticket()
 {
     $this->load->model('search');
     $data['main_content'] = 'backend/bookings/process_ticket';
     $data['title'] = 'Book a ticket';
     $data['db_data'] = Search::find($this->input->get());
     $data['get_data'] = $this->input->get();
     $this->load->view('includes/template', $data);
 }
开发者ID:FalconDev91,项目名称:tripexpress,代码行数:9,代码来源:bookings.php


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