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


PHP Search::addCategory方法代码示例

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


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

示例1: array

 function related_listings()
 {
     View::newInstance()->_exportVariableToView('items', array());
     $mSearch = new Search();
     $mSearch->addCategory(osc_item_category_id());
     $mSearch->addRegion(osc_item_region());
     $mSearch->addItemConditions(sprintf("%st_item.pk_i_id < %s ", DB_TABLE_PREFIX, osc_item_id()));
     $mSearch->limit('0', '3');
     $aItems = $mSearch->doSearch();
     $iTotalItems = count($aItems);
     if ($iTotalItems == 3) {
         View::newInstance()->_exportVariableToView('items', $aItems);
         return $iTotalItems;
     }
     unset($mSearch);
     $mSearch = new Search();
     $mSearch->addCategory(osc_item_category_id());
     $mSearch->addItemConditions(sprintf("%st_item.pk_i_id != %s ", DB_TABLE_PREFIX, osc_item_id()));
     $mSearch->limit('0', '3');
     $aItems = $mSearch->doSearch();
     $iTotalItems = count($aItems);
     if ($iTotalItems > 0) {
         View::newInstance()->_exportVariableToView('items', $aItems);
         return $iTotalItems;
     }
     unset($mSearch);
     return 0;
 }
开发者ID:michaelxizhou,项目名称:myeden69-original-backup,代码行数:28,代码来源:functions.php

示例2: osc_query_item

/**
 * Perform a search based on custom filters and conditions
 * export the results to a variable to be able to manage it
 * from custom_items' helpers
 *
 *
 * @param params This could be a string or and array
 * Examples:
 *  Only one keyword
 *  osc_query_item("keyword=value1,value2,value3,...")
 *
 *  Multiple keywords
 *  osc_query_item(array(
 *      'keyword1' => 'value1,value2',
 *      'keyword2' => 'value3,value4'
 *  ))
 *
 * Real live examples:
 *  osc_query_item('category_name=cars,houses');
 *  osc_query_item(array(
 *      'category_name' => 'cars,houses',
 *      'city' => 'Madrid'
 *  ))
 *
 * Possible keywords:
 *  author
 *  country
 *  country_name
 *  region
 *  region_name
 *  city
 *  city_name
 *  city_area
 *  city_area_name
 *  category
 *  category_name
 *  results_per_page
 *  page
 *  offset
 *
 *  Any other keyword will be passed to the hook "custom_query"
 *   osc_run_hook("custom_query", $mSearch, $keyword, $value);
 *  A plugin could be created to handle those extra situation
 *
 * @since 3.0
 */
function osc_query_item($params = null)
{
    $mSearch = new Search();
    if ($params == null) {
        $params = array();
    } else {
        if (is_string($params)) {
            $keyvalue = explode("=", $params);
            $params = array($keyvalue[0] => $keyvalue[1]);
        }
    }
    foreach ($params as $key => $value) {
        switch ($key) {
            case 'author':
                $tmp = explode(",", $value);
                foreach ($tmp as $t) {
                    $mSearch->fromUser($t);
                }
                break;
            case 'category':
            case 'category_name':
                $tmp = explode(",", $value);
                foreach ($tmp as $t) {
                    $mSearch->addCategory($t);
                }
                break;
            case 'country':
            case 'country_name':
                $tmp = explode(",", $value);
                foreach ($tmp as $t) {
                    $mSearch->addCountry($t);
                }
                break;
            case 'region':
            case 'region_name':
                $tmp = explode(",", $value);
                foreach ($tmp as $t) {
                    $mSearch->addRegion($t);
                }
                break;
            case 'city':
            case 'city_name':
                $tmp = explode(",", $value);
                foreach ($tmp as $t) {
                    $mSearch->addCity($t);
                }
                break;
            case 'city_area':
            case 'city_area_name':
                $tmp = explode(",", $value);
                foreach ($tmp as $t) {
                    $mSearch->addCityArea($t);
                }
            case 'results_per_page':
//.........这里部分代码省略.........
开发者ID:jmcclenon,项目名称:Osclass,代码行数:101,代码来源:hItems.php

示例3: postItemSearch

 /**
  * Search
  * 
  * @url POST /search/item
  */
 public function postItemSearch()
 {
     $id = $_POST['id'];
     $category = $_POST['category'];
     $country = $_POST['country'];
     $city = $_POST['city'];
     $lang = $_POST['lang'];
     $counter = 0;
     $mSearch = new Search();
     if ($id) {
         $mSearch->addItemId($id);
         $counter++;
     }
     if ($category) {
         if ($mSearch->addCategory($category)) {
             $counter++;
         }
     }
     if ($counter == 0) {
         return FALSE;
     }
     $items = $mSearch->doSearch(FALSE, TRUE);
     return $items;
 }
开发者ID:xop32,项目名称:aRestAPI4Osclass,代码行数:29,代码来源:apiServer.php

示例4: Search

 function __construct($params)
 {
     $this->_get = $params;
     $this->getDBParams();
     $mSearch = new Search(true);
     $mSearch->limit($this->start, $this->limit);
     $mSearch->order($this->order_by['column_name'], $this->order_by['type'], $this->order_by['table_name']);
     if (Params::getParam("catId") != "") {
         $mSearch->addCategory(Params::getParam("catId"));
     }
     if ($this->search) {
         //$mSearch->addConditions(sprintf("(d.s_title LIKE '%%%s%%' OR d.s_description LIKE '%%%s%%')", $this->search, $this->search));
         $mSearch->addConditions(sprintf("MATCH(d.s_title, d.s_description) AGAINST('%s' IN BOOLEAN MODE)", $this->search));
     }
     if (@$this->stat['spam']) {
         $this->extraCols++;
         $this->sExtraCol['i_num_spam'] = true;
         $mSearch->addField('SUM(s.`i_num_spam`) as i_num_spam');
         $mSearch->addConditions("s.`i_num_spam` > 0");
         $mSearch->addConditions(sprintf("%st_item.pk_i_id = s.fk_i_item_id", DB_TABLE_PREFIX));
         $mSearch->addTable(sprintf("%st_item_stats s", DB_TABLE_PREFIX));
     }
     if (@$this->stat['duplicated']) {
         $this->extraCols++;
         $this->sExtraCol['i_num_repeated'] = true;
         $mSearch->addField('SUM(s.`i_num_repeated`) as i_num_repeated');
         $mSearch->addConditions("s.`i_num_repeated` > 0");
         $mSearch->addConditions(sprintf(" %st_item.pk_i_id = s.fk_i_item_id", DB_TABLE_PREFIX));
         $mSearch->addTable(sprintf("%st_item_stats s", DB_TABLE_PREFIX));
     }
     if (@$this->stat['bad']) {
         $this->extraCols++;
         $this->sExtraCol['i_num_bad_classified'] = true;
         $mSearch->addField('SUM(s.`i_num_bad_classified`) as i_num_bad_classified');
         $mSearch->addConditions("s.`i_num_bad_classified` > 0");
         $mSearch->addConditions(sprintf(" %st_item.pk_i_id = s.fk_i_item_id", DB_TABLE_PREFIX));
         $mSearch->addTable(sprintf("%st_item_stats s", DB_TABLE_PREFIX));
     }
     if (@$this->stat['offensive']) {
         $this->extraCols++;
         $this->sExtraCol['i_num_offensive'] = true;
         $mSearch->addField('SUM(s.`i_num_offensive`) as i_num_offensive');
         $mSearch->addConditions("s.`i_num_offensive` > 0");
         $mSearch->addConditions(sprintf(" %st_item.pk_i_id = s.fk_i_item_id", DB_TABLE_PREFIX));
         $mSearch->addTable(sprintf("%st_item_stats s", DB_TABLE_PREFIX));
     }
     if (@$this->stat['expired']) {
         $this->extraCols++;
         $this->sExtraCol['i_num_expired'] = true;
         $mSearch->addField('SUM(s.`i_num_expired`) as i_num_expired');
         $mSearch->addConditions("s.`i_num_expired` > 0");
         $mSearch->addConditions(sprintf(" %st_item.pk_i_id = s.fk_i_item_id", DB_TABLE_PREFIX));
         $mSearch->addTable(sprintf("%st_item_stats s", DB_TABLE_PREFIX));
     }
     foreach ($this->filters as $aFilter) {
         $sFilter = "";
         if ($aFilter[1] == 'NULL') {
             $sFilter .= $aFilter[0] . " IS NULL";
         } else {
             $sFilter .= $aFilter[0] . " = '" . $aFilter[1] . "'";
         }
         $sFilter = sprintf($sFilter, DB_TABLE_PREFIX);
         $mSearch->addConditions($sFilter);
     }
     // do Search
     $list_items = $mSearch->doSearch(true);
     $this->result = Item::newInstance()->extendCategoryName(Item::newInstance()->extendData($list_items));
     $this->filtered_total = $mSearch->count();
     $this->total = count($list_items);
     //TEMPORARY FIX
     $this->toDatatablesFormat();
     $this->dumpToDatatables();
 }
开发者ID:acharei,项目名称:OSClass,代码行数:73,代码来源:items_processing.php

示例5: seo_sitemap_generator

function seo_sitemap_generator()
{
    $start_time = microtime(true);
    $min = 1;
    $show_items = '';
    if (Params::getParam('sitemap_items') != '') {
        $show_items = Params::getParam('sitemap_items');
    } else {
        $show_items = osc_get_preference('allSeo_sitemap_items', 'plugin-all_in_one') != '' ? osc_get_preference('allSeo_sitemap_items', 'plugin-all_in_one') : '';
    }
    $limit_items = '';
    if (Params::getParam('sitemap_items_limit') != '') {
        $limit_items = Params::getParam('sitemap_items_limit');
    } else {
        $limit_items = osc_get_preference('allSeo_sitemap_items_limit', 'plugin-all_in_one') != '' ? osc_get_preference('allSeo_sitemap_items_limit', 'plugin-all_in_one') : '';
    }
    $limit_items = intval($limit_items);
    $locales = osc_get_locales();
    $filename = osc_base_path() . 'sitemap.xml';
    //link sitemap
    @unlink($filename);
    //remove original sitemap
    $start_xml = '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL . '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL;
    file_put_contents($filename, $start_xml);
    // INDEX
    seo_sitemap_add_url(osc_base_url(), date('Y-m-d'), 'always');
    $categories = Category::newInstance()->listAll(false);
    $countries = Country::newInstance()->listAll();
    foreach ($categories as $c) {
        $search = new Search();
        $search->addCategory($c['pk_i_id']);
        if ($search->count() >= $min) {
            seo_sitemap_add_url(osc_search_url(array('sCategory' => $c['s_slug'])), date('Y-m-d'), 'hourly');
            foreach ($countries as $country) {
                if (count($countries) > 1) {
                    $search = new Search();
                    $search->addCategory($c['pk_i_id']);
                    $search->addCountry($country['pk_c_code']);
                    if ($search->count() > $min) {
                        seo_sitemap_add_url(osc_search_url(array('sCategory' => $c['s_slug'], 'sCountry' => $country['s_name'])), date('Y-m-d'), 'hourly');
                    }
                }
                $regions = Region::newInstance()->findByCountry($country['pk_c_code']);
                foreach ($regions as $region) {
                    $search = new Search();
                    $search->addCategory($c['pk_i_id']);
                    $search->addCountry($country['pk_c_code']);
                    $search->addRegion($region['pk_i_id']);
                    if ($search->count() > $min) {
                        seo_sitemap_add_url(osc_search_url(array('sCategory' => $c['s_slug'], 'sCountry' => $country['s_name'], 'sRegion' => $region['s_name'])), date('Y-m-d'), 'hourly');
                        $cities = City::newInstance()->findByRegion($region['pk_i_id']);
                        foreach ($cities as $city) {
                            $search = new Search();
                            $search->addCategory($c['pk_i_id']);
                            $search->addCountry($country['pk_c_code']);
                            $search->addRegion($region['pk_i_id']);
                            $search->addCity($city['pk_i_id']);
                            if ($search->count() > $min) {
                                seo_sitemap_add_url(osc_search_url(array('sCategory' => $c['s_slug'], 'sCountry' => $country['s_name'], 'sRegion' => $region['s_name'], 'sCity' => $city['s_name'])), date('Y-m-d'), 'hourly');
                            }
                        }
                    }
                }
            }
        }
    }
    foreach ($countries as $country) {
        $regions = Region::newInstance()->findByCountry($country['pk_c_code']);
        foreach ($regions as $region) {
            $cities = CityStats::newInstance()->listCities($region['pk_i_id']);
            $l = min(count($cities), 30);
            for ($k = 0; $k < $l; $k++) {
                if ($cities[$k]['items'] > $min) {
                    seo_sitemap_add_url(osc_search_url(array('sCountry' => $country['s_name'], 'sRegion' => $region['s_name'], 'sCity' => $cities[$k]['city_name'])), date('Y-m-d'), 'hourly');
                }
            }
        }
    }
    // ITEMS
    if ($show_items == 1) {
        $max_secure = 10000;
        $mSearch = new Search();
        $mSearch->limit(0, $limit_items);
        // fetch number of item for sitemap
        $aItems = $mSearch->doSearch();
        View::newInstance()->_exportVariableToView('items', $aItems);
        //exporting our searched item array
        if (osc_count_items() > 0) {
            $i = 0;
            while (osc_has_items() and $i < $limit_items and $i < $max_secure) {
                seo_sitemap_add_url(osc_item_url(), substr(osc_item_mod_date() != '' ? osc_item_mod_date() : osc_item_pub_date(), 0, 10), 'daily');
                $i++;
            }
        }
    }
    $end_xml = '</urlset>';
    file_put_contents($filename, $end_xml, FILE_APPEND);
    // PING SEARCH ENGINES
    seo_sitemap_ping_engines();
    $time_elapsed = microtime(true) - $start_time;
//.........这里部分代码省略.........
开发者ID:michaelxizhou,项目名称:myeden69-original-backup,代码行数:101,代码来源:sitemap.php


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