<?php $category = osc_get_category('id', osc_item_category_id()); $category_url = osc_search_url(array('sCategory' => $category['s_slug'])); ?> <div class="item <?php echo $class; if (osc_item_is_premium()) { echo ' premium'; } ?> "> <?php if (osc_images_enabled_at_items()) { ?> <?php if (osc_count_item_resources()) { ?> <a class="" href="<?php echo osc_item_url(); ?> " title="<?php echo osc_esc_html(osc_item_title()); ?> "><img src="<?php echo osc_resource_original_url(); ?> " title="" alt="<?php echo osc_esc_html(osc_item_title()); ?> " width="220" ></a>
function pop_ajax_load_more() { $array = Params::getParamsAsArray(); if ($array['_page'] == 'user') { if ($array['_action'] == 'pub_profile') { if ($array['username'] != '') { $_user = User::newInstance()->findByUsername($array['username']); $array['id'] = $_user['pk_i_id']; } $params['author'] = $array['id']; $params['results_per_page'] = isset($array['_offset']) ? $array['_offset'] : osc_default_results_per_page_at_search(); $params['page'] = isset($array['iPage']) ? $array['iPage'] - 1 : 0; } if ($array['_action'] == 'items') { $params['author'] = osc_logged_user_id(); $params['results_per_page'] = 10; // core default $params['page'] = isset($array['iPage']) ? $array['iPage'] - 1 : 0; } osc_query_item($params); $result = View::newInstance()->_get('customItems'); echo _pop_print_listing_card($result); exit; } if ($array['_page'] == 'search' || $array['_page'] == '') { if (osc_rewrite_enabled()) { if (REL_WEB_URL != '/') { $base_url = str_replace(REL_WEB_URL, '', osc_base_url()); } else { $base_url = osc_base_url(); } $_SERVER['REQUEST_URI'] = preg_replace('|^' . $base_url . '|', '', osc_search_url(Params::getParamsAsArray())); osc_add_hook('before_html', 'pop_ob_start_'); osc_add_hook('after_html', 'pop_ob_clean_'); osc_add_hook('after_search', 'pop_echo_pop_print_listing_card'); } require_once osc_lib_path() . 'osclass/controller/search.php'; $do = new CWebSearch(); $do->doModel(); exit; } }
/** * Gets the url of current "list city"" * * @return string */ function osc_list_city_url() { if (osc_rewrite_enabled()) { $url = osc_base_url(); if (osc_get_preference('seo_url_search_prefix') != '') { $url .= osc_get_preference('seo_url_search_prefix') . '/'; } $url .= osc_sanitizeString(osc_list_city_name()) . '-c' . osc_list_city_id(); return $url; } else { return osc_search_url(array('sCity' => osc_list_city_id())); } }
function doModel() { osc_run_hook('before_search'); if (osc_rewrite_enabled()) { // IF rewrite is not enabled, skip this part, preg_match is always time&resources consuming task $p_sParams = "/" . Params::getParam('sParams', false, false); if (preg_match_all('|\\/([^,]+),([^\\/]*)|', $p_sParams, $m)) { $l = count($m[0]); for ($k = 0; $k < $l; $k++) { switch ($m[1][$k]) { case osc_get_preference('rewrite_search_country'): $m[1][$k] = 'sCountry'; break; case osc_get_preference('rewrite_search_region'): $m[1][$k] = 'sRegion'; break; case osc_get_preference('rewrite_search_city'): $m[1][$k] = 'sCity'; break; case osc_get_preference('rewrite_search_city_area'): $m[1][$k] = 'sCityArea'; break; case osc_get_preference('rewrite_search_category'): $m[1][$k] = 'sCategory'; break; case osc_get_preference('rewrite_search_user'): $m[1][$k] = 'sUser'; break; case osc_get_preference('rewrite_search_pattern'): $m[1][$k] = 'sPattern'; break; default: // custom fields if (preg_match("/meta(\\d+)-?(.*)?/", $m[1][$k], $results)) { $meta_key = $m[1][$k]; $meta_value = $m[2][$k]; $array_r = array(); if (Params::existParam('meta')) { $array_r = Params::getParam('meta'); } if ($results[2] == '') { // meta[meta_id] = meta_value $meta_key = $results[1]; $array_r[$meta_key] = $meta_value; } else { // meta[meta_id][meta_key] = meta_value $meta_key = $results[1]; $meta_key2 = $results[2]; $array_r[$meta_key][$meta_key2] = $meta_value; } $m[1][$k] = 'meta'; $m[2][$k] = $array_r; } break; } Params::setParam($m[1][$k], $m[2][$k]); } Params::unsetParam('sParams'); } } $uriParams = Params::getParamsAsArray(); $searchUri = osc_search_url($uriParams); if ($this->uri != 'feed') { if (str_replace("%20", '+', $searchUri) != str_replace("%20", '+', WEB_PATH . $this->uri)) { $this->redirectTo($searchUri, 301); } } //////////////////////////////// //GETTING AND FIXING SENT DATA// //////////////////////////////// $p_sCategory = Params::getParam('sCategory'); if (!is_array($p_sCategory)) { if ($p_sCategory == '') { $p_sCategory = array(); } else { $p_sCategory = explode(",", $p_sCategory); } } $p_sCityArea = Params::getParam('sCityArea'); if (!is_array($p_sCityArea)) { if ($p_sCityArea == '') { $p_sCityArea = array(); } else { $p_sCityArea = explode(",", $p_sCityArea); } } $p_sCity = Params::getParam('sCity'); if (!is_array($p_sCity)) { if ($p_sCity == '') { $p_sCity = array(); } else { $p_sCity = explode(",", $p_sCity); } } $p_sRegion = Params::getParam('sRegion'); if (!is_array($p_sRegion)) { if ($p_sRegion == '') { $p_sRegion = array(); } else { $p_sRegion = explode(",", $p_sRegion); } } $p_sCountry = Params::getParam('sCountry'); if (!is_array($p_sCountry)) { if ($p_sCountry == '') { $p_sCountry = array(); } else { $p_sCountry = explode(",", $p_sCountry); } } $p_sUser = Params::getParam('sUser'); if (!is_array($p_sUser)) { if ($p_sUser == '') { $p_sUser = ''; } else { $p_sUser = explode(",", $p_sUser); } } $p_sLocale = Params::getParam('sLocale'); if (!is_array($p_sLocale)) { if ($p_sLocale == '') { $p_sLocale = ''; } else { $p_sLocale = explode(",", $p_sLocale); } } $p_sPattern = trim(strip_tags(Params::getParam('sPattern'))); // ADD TO THE LIST OF LAST SEARCHES if (osc_save_latest_searches() && (!Params::existParam('iPage') || Params::getParam('iPage') == 1)) { $savePattern = osc_apply_filter('save_latest_searches_pattern', $p_sPattern); if ($savePattern != '') { LatestSearches::newInstance()->insert(array('s_search' => $savePattern, 'd_date' => date('Y-m-d H:i:s'))); } } $p_bPic = Params::getParam('bPic'); $p_bPic = $p_bPic == 1 ? 1 : 0; $p_bPremium = Params::getParam('bPremium'); $p_bPremium = $p_bPremium == 1 ? 1 : 0; $p_sPriceMin = Params::getParam('sPriceMin'); $p_sPriceMax = Params::getParam('sPriceMax'); //WE CAN ONLY USE THE FIELDS RETURNED BY Search::getAllowedColumnsForSorting() $p_sOrder = Params::getParam('sOrder'); if (!in_array($p_sOrder, Search::getAllowedColumnsForSorting())) { $p_sOrder = osc_default_order_field_at_search(); } $old_order = $p_sOrder; //ONLY 0 ( => 'asc' ), 1 ( => 'desc' ) AS ALLOWED VALUES $p_iOrderType = Params::getParam('iOrderType'); $allowedTypesForSorting = Search::getAllowedTypesForSorting(); $orderType = osc_default_order_type_at_search(); foreach ($allowedTypesForSorting as $k => $v) { if ($p_iOrderType == $v) { $orderType = $k; break; } } $p_iOrderType = $orderType; $p_sFeed = Params::getParam('sFeed'); $p_iPage = 0; if (is_numeric(Params::getParam('iPage')) && Params::getParam('iPage') > 0) { $p_iPage = intval(Params::getParam('iPage')) - 1; } if ($p_sFeed != '') { $p_sPageSize = 1000; } $p_sShowAs = Params::getParam('sShowAs'); $aValidShowAsValues = array('list', 'gallery'); if (!in_array($p_sShowAs, $aValidShowAsValues)) { $p_sShowAs = osc_default_show_as_at_search(); } // search results: it's blocked with the maxResultsPerPage@search defined in t_preferences $p_iPageSize = intval(Params::getParam('iPagesize')); if ($p_iPageSize > 0) { if ($p_iPageSize > osc_max_results_per_page_at_search()) { $p_iPageSize = osc_max_results_per_page_at_search(); } } else { $p_iPageSize = osc_default_results_per_page_at_search(); } //FILTERING CATEGORY $bAllCategoriesChecked = false; $successCat = false; if (count($p_sCategory) > 0) { foreach ($p_sCategory as $category) { $successCat = $this->mSearch->addCategory($category) || $successCat; } } else { $bAllCategoriesChecked = true; } //FILTERING CITY_AREA foreach ($p_sCityArea as $city_area) { $this->mSearch->addCityArea($city_area); } $p_sCityArea = implode(", ", $p_sCityArea); //FILTERING CITY foreach ($p_sCity as $city) { $this->mSearch->addCity($city); } $p_sCity = implode(", ", $p_sCity); //FILTERING REGION foreach ($p_sRegion as $region) { $this->mSearch->addRegion($region); } $p_sRegion = implode(", ", $p_sRegion); //FILTERING COUNTRY foreach ($p_sCountry as $country) { $this->mSearch->addCountry($country); } $p_sCountry = implode(", ", $p_sCountry); // FILTERING PATTERN if ($p_sPattern != '') { $this->mSearch->addPattern($p_sPattern); $osc_request['sPattern'] = $p_sPattern; } else { // hardcoded - if there isn't a search pattern, order by dt_pub_date desc if ($p_sOrder == 'relevance') { $p_sOrder = 'dt_pub_date'; foreach ($allowedTypesForSorting as $k => $v) { if ($p_iOrderType == 'desc') { $orderType = $k; break; } } $p_iOrderType = $orderType; } } // FILTERING USER if ($p_sUser != '') { $this->mSearch->fromUser($p_sUser); } // FILTERING LOCALE $this->mSearch->addLocale($p_sLocale); // FILTERING IF WE ONLY WANT ITEMS WITH PICS if ($p_bPic) { $this->mSearch->withPicture(true); } // FILTERING IF WE ONLY WANT PREMIUM ITEMS if ($p_bPremium) { $this->mSearch->onlyPremium(true); } //FILTERING BY RANGE PRICE $this->mSearch->priceRange($p_sPriceMin, $p_sPriceMax); //ORDERING THE SEARCH RESULTS $this->mSearch->order($p_sOrder, $allowedTypesForSorting[$p_iOrderType]); //SET PAGE if ($p_sFeed == 'rss') { // If param sFeed=rss, just output last 'osc_num_rss_items()' $this->mSearch->page(0, osc_num_rss_items()); } else { $this->mSearch->page($p_iPage, $p_iPageSize); } // CUSTOM FIELDS $custom_fields = Params::getParam('meta'); $fields = Field::newInstance()->findIDSearchableByCategories($p_sCategory); $table = DB_TABLE_PREFIX . 't_item_meta'; if (is_array($custom_fields)) { foreach ($custom_fields as $key => $aux) { if (in_array($key, $fields)) { $field = Field::newInstance()->findByPrimaryKey($key); switch ($field['e_type']) { case 'TEXTAREA': case 'TEXT': case 'URL': if ($aux != '') { $aux = "%{$aux}%"; $sql = "SELECT fk_i_item_id FROM {$table} WHERE "; $str_escaped = Search::newInstance()->dao->escape($aux); $sql .= $table . '.fk_i_field_id = ' . $key . ' AND '; $sql .= $table . ".s_value LIKE " . $str_escaped; $this->mSearch->addConditions(DB_TABLE_PREFIX . 't_item.pk_i_id IN (' . $sql . ')'); } break; case 'DROPDOWN': case 'RADIO': if ($aux != '') { $sql = "SELECT fk_i_item_id FROM {$table} WHERE "; $str_escaped = Search::newInstance()->dao->escape($aux); $sql .= $table . '.fk_i_field_id = ' . $key . ' AND '; $sql .= $table . ".s_value = " . $str_escaped; $this->mSearch->addConditions(DB_TABLE_PREFIX . 't_item.pk_i_id IN (' . $sql . ')'); } break; case 'CHECKBOX': if ($aux != '') { $sql = "SELECT fk_i_item_id FROM {$table} WHERE "; $sql .= $table . '.fk_i_field_id = ' . $key . ' AND '; $sql .= $table . ".s_value = 1"; $this->mSearch->addConditions(DB_TABLE_PREFIX . 't_item.pk_i_id IN (' . $sql . ')'); } break; case 'DATE': if ($aux != '') { $y = (int) date('Y', $aux); $m = (int) date('n', $aux); $d = (int) date('j', $aux); $start = mktime('0', '0', '0', $m, $d, $y); $end = mktime('23', '59', '59', $m, $d, $y); $sql = "SELECT fk_i_item_id FROM {$table} WHERE "; $sql .= $table . '.fk_i_field_id = ' . $key . ' AND '; $sql .= $table . ".s_value >= " . $start . " AND "; $sql .= $table . ".s_value <= " . $end; $this->mSearch->addConditions(DB_TABLE_PREFIX . 't_item.pk_i_id IN (' . $sql . ')'); } break; case 'DATEINTERVAL': if (is_array($aux) && (!empty($aux['from']) && !empty($aux['to']))) { $from = $aux['from']; $to = $aux['to']; $start = $from; $end = $to; $sql = "SELECT fk_i_item_id FROM {$table} WHERE "; $sql .= $table . '.fk_i_field_id = ' . $key . ' AND '; $sql .= $start . " >= " . $table . ".s_value AND s_multi = 'from'"; $sql1 = "SELECT fk_i_item_id FROM {$table} WHERE "; $sql1 .= $table . ".fk_i_field_id = " . $key . " AND "; $sql1 .= $end . " <= " . $table . ".s_value AND s_multi = 'to'"; $sql_interval = "select a.fk_i_item_id from (" . $sql . ") a where a.fk_i_item_id IN (" . $sql1 . ")"; $this->mSearch->addConditions(DB_TABLE_PREFIX . 't_item.pk_i_id IN (' . $sql_interval . ')'); } break; default: break; } } } } osc_run_hook('search_conditions', Params::getParamsAsArray()); // RETRIEVE ITEMS AND TOTAL $key = md5(osc_base_url() . $this->mSearch->toJson()); $found = null; $cache = osc_cache_get($key, $found); $aItems = null; $iTotalItems = null; if ($cache) { $aItems = $cache['aItems']; $iTotalItems = $cache['iTotalItems']; } else { $aItems = $this->mSearch->doSearch(); $iTotalItems = $this->mSearch->count(); $_cache['aItems'] = $aItems; $_cache['iTotalItems'] = $iTotalItems; osc_cache_set($key, $_cache, OSC_CACHE_TTL); } $iStart = $p_iPage * $p_iPageSize; $iEnd = min(($p_iPage + 1) * $p_iPageSize, $iTotalItems); $iNumPages = ceil($iTotalItems / $p_iPageSize); // works with cache enabled ? osc_run_hook('search', $this->mSearch); //preparing variables... $countryName = $p_sCountry; if (strlen($p_sCountry) == 2) { $c = Country::newInstance()->findByCode($p_sCountry); if ($c) { $countryName = $c['s_name']; } } $regionName = $p_sRegion; if (is_numeric($p_sRegion)) { $r = Region::newInstance()->findByPrimaryKey($p_sRegion); if ($r) { $regionName = $r['s_name']; } } $cityName = $p_sCity; if (is_numeric($p_sCity)) { $c = City::newInstance()->findByPrimaryKey($p_sCity); if ($c) { $cityName = $c['s_name']; } } $this->_exportVariableToView('search_start', $iStart); $this->_exportVariableToView('search_end', $iEnd); $this->_exportVariableToView('search_category', $p_sCategory); // hardcoded - non pattern and order by relevance $p_sOrder = $old_order; $this->_exportVariableToView('search_order_type', $p_iOrderType); $this->_exportVariableToView('search_order', $p_sOrder); $this->_exportVariableToView('search_pattern', $p_sPattern); $this->_exportVariableToView('search_from_user', $p_sUser); $this->_exportVariableToView('search_total_pages', $iNumPages); $this->_exportVariableToView('search_page', $p_iPage); $this->_exportVariableToView('search_has_pic', $p_bPic); $this->_exportVariableToView('search_only_premium', $p_bPremium); $this->_exportVariableToView('search_country', $countryName); $this->_exportVariableToView('search_region', $regionName); $this->_exportVariableToView('search_city', $cityName); $this->_exportVariableToView('search_price_min', $p_sPriceMin); $this->_exportVariableToView('search_price_max', $p_sPriceMax); $this->_exportVariableToView('search_total_items', $iTotalItems); $this->_exportVariableToView('items', $aItems); $this->_exportVariableToView('search_show_as', $p_sShowAs); $this->_exportVariableToView('search', $this->mSearch); // json $json = $this->mSearch->toJson(); $encoded_alert = base64_encode(osc_encrypt_alert($json)); // Create the HMAC signature and convert the resulting hex hash into base64 $stringToSign = osc_get_alert_public_key() . $encoded_alert; $signature = hex2b64(hmacsha1(osc_get_alert_private_key(), $stringToSign)); $server_signature = Session::newInstance()->_set('alert_signature', $signature); $this->_exportVariableToView('search_alert', $encoded_alert); // calling the view... if (count($aItems) === 0) { header('HTTP/1.1 404 Not Found'); } osc_run_hook("after_search"); if (!Params::existParam('sFeed')) { $this->doView('search.php'); } else { if ($p_sFeed == '' || $p_sFeed == 'rss') { // FEED REQUESTED! header('Content-type: text/xml; charset=utf-8'); $feed = new RSSFeed(); $feed->setTitle(__('Latest listings added') . ' - ' . osc_page_title()); $feed->setLink(osc_base_url()); $feed->setDescription(__('Latest listings added in') . ' ' . osc_page_title()); if (osc_count_items() > 0) { while (osc_has_items()) { if (osc_count_item_resources() > 0) { osc_has_item_resources(); $feed->addItem(array('title' => osc_item_title(), 'link' => htmlentities(osc_item_url(), ENT_COMPAT, "UTF-8"), 'description' => osc_item_description(), 'country' => osc_item_country(), 'region' => osc_item_region(), 'city' => osc_item_city(), 'city_area' => osc_item_city_area(), 'category' => osc_item_category(), 'dt_pub_date' => osc_item_pub_date(), 'image' => array('url' => htmlentities(osc_resource_thumbnail_url(), ENT_COMPAT, "UTF-8"), 'title' => osc_item_title(), 'link' => htmlentities(osc_item_url(), ENT_COMPAT, "UTF-8")))); } else { $feed->addItem(array('title' => osc_item_title(), 'link' => htmlentities(osc_item_url(), ENT_COMPAT, "UTF-8"), 'description' => osc_item_description(), 'country' => osc_item_country(), 'region' => osc_item_region(), 'city' => osc_item_city(), 'city_area' => osc_item_city_area(), 'category' => osc_item_category(), 'dt_pub_date' => osc_item_pub_date())); } } } osc_run_hook('feed', $feed); $feed->dumpXML(); } else { osc_run_hook('feed_' . $p_sFeed, $aItems); } } }
/** * Gets city area's url * * @return string */ function osc_city_area_url() { return osc_search_url(array('sCityArea' => osc_city_area_name())); }
function osc_footer_link_url($f = null) { if ($f == null) { if (View::newInstance()->_exists('footer_link')) { $f = View::newInstance()->_get('footer_link'); } else { return ''; } } else { View::newInstance()->_exportVariableToView('footer_link', $f); } $params = array(); $tmp = osc_search_category_id(); if (!empty($tmp)) { $params['sCategory'] = $f['fk_i_category_id']; } if (osc_search_region() == '') { $params['sRegion'] = $f['fk_i_region_id']; } else { $params['sCity'] = $f['fk_i_city_id']; } return osc_search_url($params); }
<div id="sidebar"> <div class="navigation"> <?php if (osc_count_list_regions() > 0) { ?> <div class="box location"> <h3><strong><?php _e("Location", 'modern'); ?> </strong></h3> <ul> <?php while (osc_has_list_regions()) { ?> <li><a href="<?php echo osc_search_url(array('sRegion' => osc_list_region_name())); ?> "><?php echo osc_list_region_name(); ?> </a> <em>(<?php echo osc_list_region_items(); ?> )</em></li> <?php } ?> </ul> </div> <?php }
function breadcrumbs($separator = '/') { $text = ''; $location = Rewrite::newInstance()->get_location(); $section = Rewrite::newInstance()->get_section(); $separator = ' ' . trim($separator) . ' '; $page_title = '<a href="' . osc_base_url() . '"><span class="bc_root">' . osc_page_title() . '</span></a>'; switch ($location) { case 'item': switch ($section) { case 'item_add': break; default: $aCategories = Category::newInstance()->toRootTree((string) osc_item_category_id()); $category = ''; if (count($aCategories) == 0) { break; } $deep = 1; foreach ($aCategories as $aCategory) { $list[] = '<a href="' . breadcrumbs_category_url($aCategory['pk_i_id']) . '"><span class="bc_level_' . $deep . '">' . $aCategory['s_name'] . '</span></a>'; $deep++; } $category = implode($separator, $list) . $separator; $category = preg_replace('|' . trim($separator) . '\\s*$|', '', $category); break; } switch ($section) { case 'item_add': $text = $page_title . $separator . '<span class="bc_last">' . __('Publish an item', 'breadcrumbs'); break; case 'item_edit': $text = $page_title . $separator . $category . $separator . '<a href="' . osc_item_url() . '"><span class="bc_item">' . osc_item_title() . '</span></a>' . $separator . '<span class="bc_last">' . __('Edit your item', 'breadcrumbs') . '</span>'; break; case 'send_friend': $text = $page_title . $separator . $category . $separator . '<a href="' . osc_item_url() . '"><span class="bc_item">' . osc_item_title() . '</span></a>' . $separator . '<span class="bc_last">' . __('Send to a friend', 'breadcrumbs') . '</span>'; break; case 'contact': $text = $page_title . $separator . $category . $separator . '<a href="' . osc_item_url() . '"><span class="bc_item">' . osc_item_title() . '</span></a>' . $separator . '<span class="bc_last">' . __('Contact seller', 'breadcrumbs') . '</span>'; break; default: $text = $page_title . $separator . $category . $separator . '<span class="bc_last">' . osc_item_title() . '</span>'; break; } break; case 'page': $text = $page_title . $separator . '<span class="bc_last">' . osc_static_page_title() . '</span>'; break; case 'search': $region = osc_search_region(); $city = osc_search_city(); $pattern = osc_search_pattern(); $category = osc_search_category_id(); $category = count($category) == 1 ? $category[0] : ''; $b_show_all = $pattern == '' && $category == '' && $region == '' && $city == ''; $b_category = $category != ''; $b_pattern = $pattern != ''; $b_region = $region != ''; $b_city = $city != ''; $b_location = $b_region || $b_city; if ($b_show_all) { $text = $page_title . $separator . '<span class="bc_last">' . __('Search', 'breadcrumbs') . '</span>'; break; } // init $result = $page_title . $separator; if ($b_category) { $list = array(); $aCategories = Category::newInstance()->toRootTree($category); if (count($aCategories) > 0) { $deep = 1; foreach ($aCategories as $single) { $list[] = '<a href="' . breadcrumbs_category_url($single['pk_i_id']) . '"><span class="bc_level_' . $deep . '">' . $single['s_name'] . '</span></a>'; $deep++; } // remove last link if (!$b_pattern && !$b_location) { $list[count($list) - 1] = preg_replace('|<a href.*?>(.*?)</a>|', '$01', $list[count($list) - 1]); } $result .= implode($separator, $list) . $separator; } } if ($b_location) { $list = array(); $params = array(); if ($b_category) { $params['sCategory'] = $category; } if ($b_city) { $aCity = City::newInstance()->findByName($city); if (count($aCity) == 0) { $params['sCity'] = $city; $list[] = '<a href="' . osc_search_url($params) . '"><span class="bc_city">' . $city . '</span></a>'; } else { $aRegion = Region::newInstance()->findByPrimaryKey($aCity['fk_i_region_id']); $params['sRegion'] = $aRegion['s_name']; $list[] = '<a href="' . osc_search_url($params) . '"><span class="bc_region">' . $aRegion['s_name'] . '</span></a>'; $params['sCity'] = $aCity['s_name']; $list[] = '<a href="' . osc_search_url($params) . '"><span class="bc_city">' . $aCity['s_name'] . '</span></a>'; } if (!$b_pattern) { $list[count($list) - 1] = preg_replace('|<a href.*?>(.*?)</a>|', '$01', $list[count($list) - 1]); } $result .= implode($separator, $list) . $separator; } else { if ($b_region) { $params['sRegion'] = $region; $list[] = '<a href="' . osc_search_url($params) . '"><span class="bc_region">' . $region . '</span></a>'; if (!$b_pattern) { $list[count($list) - 1] = preg_replace('|<a href.*?>(.*?)</a>|', '$01', $list[count($list) - 1]); } $result .= implode($separator, $list) . $separator; } } } if ($b_pattern) { $result .= '<span class="bc_last">' . __('Search Results', 'breadcrumbs') . ': ' . $pattern . '</span>' . $separator; } // remove last separator $result = preg_replace('|' . trim($separator) . '\\s*$|', '', $result); $text = $result; break; case 'login': switch ($section) { case 'recover': $text = $page_title . $separator . '<span class="bc_last">' . __('Recover your password', 'breadcrumbs') . '</span>'; default: $text = $page_title . $separator . '<span class="bc_last">' . __('Login', 'breadcrumbs') . '</span>'; } break; case 'register': $text = $page_title . $separator . '<span class="bc_last">' . __('Create a new account', 'breadcrumbs') . '</span>'; break; case 'user': $user_dashboard = '<a href="' . osc_user_dashboard_url() . '"><span class="bc_user">' . __('My account', 'breadcrumbs') . '</span></a>'; switch ($section) { case 'dashboard': $text = $page_title . $separator . $user_dashboard . $separator . '<span class="bc_last">' . __('Dashboard', 'breadcrumbs') . '</span>'; break; case 'items': $text = $page_title . $separator . $user_dashboard . $separator . '<span class="bc_last">' . __('Manage my items', 'breadcrumbs') . '</span>'; break; case 'alerts': $text = $page_title . $separator . $user_dashboard . $separator . '<span class="bc_last">' . __('Manage my alerts', 'breadcrumbs') . '</span>'; break; case 'profile': $text = $page_title . $separator . $user_dashboard . $separator . '<span class="bc_last">' . __('Update my profile', 'breadcrumbs') . '</span>'; break; case 'change_email': $text = $page_title . $separator . $user_dashboard . $separator . '<span class="bc_last">' . __('Change my email', 'breadcrumbs') . '</span>'; break; case 'change_password': $text = $page_title . $separator . $user_dashboard . $separator . '<span class="bc_last">' . __('Change my password', 'breadcrumbs') . '</span>'; break; case 'forgot': $text = $page_title . $separator . $user_dashboard . $separator . '<span class="bc_last">' . __('Recover my password', 'breadcrumbs') . '</span>'; break; } break; case 'contact': $text = $page_title . $separator . '<span class="bc_last">' . __('Contact', 'breadcrumbs') . '</span>'; break; default: break; } echo $text; return true; }
/** * Create automatically the url of a category * * @param string $pattern * @return string the url */ function osc_search_category_url() { return osc_search_url(array('sCategory' => osc_category_id())); }
echo '<div class="price">' . osc_item_formated_price() . '</div>'; } if (osc_item_country() != "" || osc_item_region() != '') { echo '<div class="has-icon"><div class="ico-location ico"></div>'; if (osc_item_region() != "") { $tempData = osc_item_region(); if (osc_item_field("fk_i_region_id") != "") { $tempData = '<a href="' . osc_search_url(array('sRegion' => osc_item_field("fk_i_region_id"))) . '">' . osc_item_region() . '</a>'; } echo $tempData; } echo '<div class="mini">'; if (osc_item_city() != "") { $tempData = osc_item_city(); if (osc_item_field("fk_i_city_id") != "") { $tempData = '<a href="' . osc_search_url(array('sCity' => osc_item_field("fk_i_city_id"))) . '">' . osc_item_city() . '</a>'; } echo $tempData; } echo '</div>'; echo '</div>'; } //echo join(', ',$regionData); ?> <div class="has-icon dates"> <div class="ico-dates ico"></div> <div><?php if (osc_item_pub_date() != '') { echo __('Published', 'realestate') . ': ' . osc_format_date(osc_item_pub_date()); } ?>
<img src="<?php echo nc_osc_get_public_picture_link(osc_item_user_id()); ?> " class="img-responsive"> </div> <div class="row"> <?php if (osc_logged_user_id() != osc_item_user_id()) { ?> <!--<a href="<?php echo osc_route_url('seller-items', array('seller' => osc_item_user_id())); ?> " >--> <a href="<?php echo osc_search_url(array('seller_post' => osc_item_user_id())); ?> ">See other items from seller</a> <?php } ?> </div> <div class="row"> <?php if (osc_is_web_user_logged_in()) { ?> <?php if (osc_logged_user_id() != osc_item_user_id()) { ?> <?php osc_current_web_theme_path('seller-ratings.php');
<div id="sidebar"> <div class="navigation"> <?php if (osc_count_list_cities() > 0) { ?> <div class="box location"> <h3><strong><?php _e("Location", 'modern'); ?> </strong></h3> <ul> <?php while (osc_has_list_cities()) { ?> <li><a href="<?php echo osc_search_url(array('sCity' => osc_list_city_name())); ?> "><?php echo osc_list_city_name(); ?> </a> <em>(<?php echo osc_list_city_items(); ?> )</em></li> <?php } ?> </ul> </div> <?php }
public function init() { if (in_array($this->getLocation(), array('item', 'page', 'search', 'login', 'register', 'user', 'contact'))) { $l = array('url' => osc_base_url(), 'title' => osc_page_title()); $this->addLevel($l); } switch ($this->getLocation()) { case 'item': if ($this->getSection() == 'item_add') { $l = array('title' => $this->title['item_add']); $this->addLevel($l); break; } $aCategory = osc_get_category('id', osc_item_category_id()); // remove View::newInstance()->_erase('categories'); View::newInstance()->_erase('subcategories'); View::newInstance()->_exportVariableToView('category', $aCategory); $l = array('url' => osc_search_category_url(), 'title' => osc_category_name()); $this->addLevel($l); switch ($this->getSection()) { case 'item_edit': $l = array('url' => osc_item_url(), 'title' => osc_item_title()); $this->addLevel($l); $l = array('title' => $this->title['item_edit']); $this->addLevel($l); break; case 'send_friend': $l = array('url' => osc_item_url(), 'title' => osc_item_title()); $this->addLevel($l); $l = array('title' => $this->title['item_send_friend']); $this->addLevel($l); break; case 'contact': $l = array('url' => osc_item_url(), 'title' => osc_item_title()); $this->addLevel($l); $l = array('title' => $this->title['item_contact']); $this->addLevel($l); break; case '': $l = array('title' => osc_item_title()); $this->addLevel($l); break; } break; case 'search': $region = osc_search_region(); $city = osc_search_city(); $pattern = osc_search_pattern(); $category = osc_search_category_id(); $category = count($category) == 1 ? $category[0] : ''; $b_show_all = $pattern == '' && $category == '' && $region == '' && $city == ''; $b_category = $category != ''; $b_pattern = $pattern != ''; $b_region = $region != ''; $b_city = $city != ''; $b_location = $b_region || $b_city; // show all if ($b_show_all) { $l = array('title' => $this->title['search']); $this->addLevel($l); break; } // category if ($b_category) { $aCategories = Category::newInstance()->toRootTree($category); foreach ($aCategories as $c) { View::newInstance()->_erase('categories'); View::newInstance()->_erase('subcategories'); View::newInstance()->_exportVariableToView('category', $c); $l = array('url' => osc_search_category_url(), 'title' => osc_category_name()); $this->addLevel($l); } } // location if ($b_location) { $params = array(); if ($b_category) { $params['sCategory'] = $category; } if ($b_city) { //print_r("~~~~~~~~~~~~~~~~~~~".$city."~~~~~~~~~~~~~~~~~~~~"); $aCity = City::newInstance()->findByName($city); if (count($aCity) == 0) { $params['sCity'] = $city; $l = array('url' => osc_search_url($params), 'title' => $city); $this->addLevel($l); } else { $aRegion = Region::newInstance()->findByPrimaryKey($aCity['fk_i_region_id']); $params['sRegion'] = $aRegion['s_name']; $l = array('url' => osc_search_url($params), 'title' => $aRegion['s_name']); $this->addLevel($l); $params['sCity'] = $aCity['s_name']; $l = array('url' => osc_search_url($params), 'title' => $aCity['s_name']); $this->addLevel($l); } } else { if ($b_region) { $params['sRegion'] = $region; $l = array('url' => osc_search_url($params), 'title' => $region); $this->addLevel($l); } } } // pattern if ($b_pattern) { $l = array('title' => sprintf($this->title['search_pattern'], $pattern)); $this->addLevel($l); } // remove url from the last node $nodes = $this->getaLevel(); if ($nodes > 0) { if (array_key_exists('url', $nodes[count($nodes) - 1])) { unset($nodes[count($nodes) - 1]['url']); } } $this->setaLevel($nodes); break; case 'user': // use dashboard without url if you're in the dashboards if ($this->getSection() == 'dashboard') { $l = array('title' => $this->title['user_dashboard']); $this->addLevel($l); break; } // use dashboard without url if you're in the dashboards if ($this->getSection() == 'pub_profile') { $l = array('title' => sprintf($this->title['user_dashboard_profile'], osc_user_name())); $this->addLevel($l); break; } $l = array('url' => osc_user_dashboard_url(), 'title' => $this->title['user_account']); $this->addLevel($l); switch ($this->getSection()) { case 'items': $l = array('title' => $this->title['user_items']); $this->addLevel($l); break; case 'alerts': $l = array('title' => $this->title['user_alerts']); $this->addLevel($l); break; case 'profile': $l = array('title' => $this->title['user_profile']); $this->addLevel($l); break; case 'change_email': $l = array('title' => $this->title['user_change_email']); $this->addLevel($l); break; case 'change_password': $l = array('title' => $this->title['user_change_password']); $this->addLevel($l); break; case 'change_username': $l = array('title' => $this->title['user_change_username']); $this->addLevel($l); break; } break; case 'login': switch ($this->getSection()) { case 'recover': $l = array('title' => $this->title['login_recover']); $this->addLevel($l); break; case 'forgot': $l = array('title' => $this->title['login_forgot']); $this->addLevel($l); break; case '': $l = array('title' => $this->title['login']); $this->addLevel($l); break; } break; case 'register': $l = array('title' => $this->title['register']); $this->addLevel($l); break; case 'page': $l = array('title' => osc_static_page_title()); $this->addLevel($l); break; case 'contact': $l = array('title' => $this->title['contact']); $this->addLevel($l); break; } }
function twitter_breadcrumb($separator = '/') { $breadcrumb = array(); $text = ''; $location = Rewrite::newInstance()->get_location(); $section = Rewrite::newInstance()->get_section(); $separator = '<span class="divider">' . trim($separator) . '</span>'; $page_title = '<li><a href="' . osc_base_url() . '">' . osc_page_title() . '</a>' . $separator . '</li>'; switch ($location) { case 'item': switch ($section) { case 'item_add': break; default: $aCategories = Category::newInstance()->toRootTree((string) osc_item_category_id()); $category = ''; if (count($aCategories) == 0) { break; } foreach ($aCategories as $aCategory) { $list[] = '<li><a href="' . osc_item_category_url($aCategory['pk_i_id']) . '">' . $aCategory['s_name'] . '</a>' . $separator . '</li>'; } $category = implode('', $list); break; } switch ($section) { case 'item_add': $text = $page_title . '<li>' . __('Publish an item', 'twitter') . '</li>'; break; case 'item_edit': $text = $page_title . '<li><a href="' . osc_item_url() . '">' . osc_item_title() . '</a>' . $separator . '</li><li>' . __('Edit your item', 'twitter') . '</li>'; break; case 'send_friend': $text = $page_title . $category . '<li><a href="' . osc_item_url() . '">' . osc_item_title() . '</a>' . $separator . '</li><li>' . __('Send to a friend', 'twitter') . '</li>'; break; case 'contact': $text = $page_title . $category . '<li><a href="' . osc_item_url() . '">' . osc_item_title() . '</a>' . $separator . '<li><li>' . __('Contact seller', 'twitter') . '</li>'; break; default: $text = $page_title . $category . '<li>' . osc_item_title() . '</li>'; break; } break; case 'page': $text = $page_title . '<li>' . osc_static_page_title() . '</li>'; break; case 'search': $region = Params::getParam('sRegion'); $city = Params::getParam('sCity'); $pattern = Params::getParam('sPattern'); $category = osc_search_category_id(); $category = count($category) == 1 ? $category[0] : ''; $b_show_all = $pattern == '' && $category == '' && $region == '' && $city == ''; $b_category = $category != ''; $b_pattern = $pattern != ''; $b_region = $region != ''; $b_city = $city != ''; $b_location = $b_region || $b_city; if ($b_show_all) { $text = $page_title . '<li>' . __('Search', 'twitter') . '</li>'; break; } // init $result = $page_title; if ($b_category) { $list = array(); $aCategories = Category::newInstance()->toRootTree($category); if (count($aCategories) > 0) { $deep = 1; foreach ($aCategories as $single) { $list[] = '<li><a href="' . osc_item_category_url($single['pk_i_id']) . '">' . $single['s_name'] . '</a>' . $separator . '</li>'; $deep++; } // remove last link if (!$b_pattern && !$b_location) { $list[count($list) - 1] = preg_replace('|<li><a href.*?>(.*?)</a>.*?</li>|', '$01', $list[count($list) - 1]); } $result .= implode('', $list); } } if ($b_location) { $list = array(); $params = array(); if ($b_category) { $params['sCategory'] = $category; } if ($b_city) { $aCity = City::newInstance()->findByName($city); if (count($aCity) == 0) { $params['sCity'] = $city; $list[] = '<li><a href="' . osc_search_url($params) . '">' . $city . '</a>' . $separator . '</li>'; } else { $aRegion = Region::newInstance()->findByPrimaryKey($aCity['fk_i_region_id']); $params['sRegion'] = $aRegion['s_name']; $list[] = '<li><a href="' . osc_search_url($params) . '">' . $aRegion['s_name'] . '</a>' . $separator . '</li>'; $params['sCity'] = $aCity['s_name']; $list[] = '<li><a href="' . osc_search_url($params) . '">' . $aCity['s_name'] . '</a>' . $separator . '</li>'; } if (!$b_pattern) { $list[count($list) - 1] = preg_replace('|<li><a href.*?>(.*?)</a>.*?</li>|', '$01', $list[count($list) - 1]); } $result .= implode('', $list); } else { if ($b_region) { $params['sRegion'] = $region; $list[] = '<li><a href="' . osc_search_url($params) . '">' . $region . '</a>' . $separator . '</li>'; if (!$b_pattern) { $list[count($list) - 1] = preg_replace('|<li><a href.*?>(.*?)</a>.*?</li>|', '$01', $list[count($list) - 1]); } $result .= implode('', $list); } } } if ($b_pattern) { $result .= '<li>' . __('Search Results', 'twitter') . ': ' . $pattern . '</li>'; } // remove last separator $result = preg_replace('|' . trim($separator) . '\\s*$|', '', $result); $text = $result; break; case 'login': switch ($section) { case 'recover': $text = $page_title . '<li>' . __('Recover your password', 'twitter') . '</li>'; break; default: $text = $page_title . '<li>' . __('Login', 'twitter') . '</li>'; } break; case 'register': $text = $page_title . '<li>' . __('Create a new account', 'twitter') . '</li>'; break; case 'contact': $text = $page_title . '<li>' . __('Contact', 'twitter') . '</li>'; break; default: break; } return '<ul class="breadcrumb">' . $text . '</ul>'; }
} ?> <?php if (osclasswizards_show_popular_cities()) { ?> <section id='Cities'> <div class="popular_cities"> <?php $cities = osclasswizards_popular_cities(osclasswizards_popular_cities_limit()); ?> <ul> <?php foreach ($cities as $city => $count) { ?> <li><a href="<?php echo osc_search_url(array('sCity' => $city)); ?> "><i class="fa fa-map-marker"></i><?php echo $city; ?> <em>(<?php echo $count; ?> )</em></a></li> <?php } ?> </ul> </div> </section> <?php
/** * Gets the url of current "list city"" * * @return string */ function osc_list_city_url() { return osc_search_url(array('sCity' => osc_list_city_name())); }
function ping_search_engines($bool) { $mPreference = Preference::newInstance(); if ($bool == 1) { $mPreference->insert(array('s_section' => 'osclass', 's_name' => 'ping_search_engines', 's_value' => '1', 'e_type' => 'BOOLEAN')); // GOOGLE osc_doRequest('http://www.google.com/webmasters/sitemaps/ping?sitemap=' . urlencode(osc_search_url(array('sFeed' => 'rss'))), array()); // BING osc_doRequest('http://www.bing.com/webmaster/ping.aspx?siteMap=' . urlencode(osc_search_url(array('sFeed' => 'rss'))), array()); // YAHOO! osc_doRequest('http://search.yahooapis.com/SiteExplorerService/V1/ping?sitemap=' . urlencode(osc_search_url(array('sFeed' => 'rss'))), array()); } else { $mPreference->insert(array('s_section' => 'osclass', 's_name' => 'ping_search_engines', 's_value' => '0', 'e_type' => 'BOOLEAN')); } }
?> " + this.value ); } }); }); </script> <?php } ?> <button class="btn btn-default"><i class="fa fa-search fa-lg"></i><?php //_e("Search", 'flatter'); ?> </button> </form> <span><a href="<?php echo osc_search_url(); ?> " id="#advsrch" class="nav-toggle"><?php _e('Advanced search', 'flatter'); ?> <i class="fa fa-caret-right"></i></a></span> </div> </div> </div> </div> <!-- Big Search --> <?php if (osc_get_preference('position1_enable', 'flatter_theme') != '0') { ?> <div id="position_widget"><!------ Home page widget 1--------------------->
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; return $time_elapsed; }