예제 #1
1
function google_cars()
{
    echo '<rss version ="2.0" xmlns:g="http://base.google.com/ns/1.0"> 
     
    <channel> 
	    <title>' . osc_page_title() . '</title> 
	    <description>' . osc_page_description() . '</description> 
	    <link>' . osc_base_url() . '</link>';
    if (osc_count_items()) {
        while (osc_has_items()) {
            $item = feed_get_car_data(osc_item());
            $date = date('d/m/Y');
            $time = date('H:i');
            if (preg_match('|([0-9]{4})-([0-9]{2})-([0-9]{2})|', osc_item_pub_date(), $tmp)) {
                $date = $tmp[3] . "/" . $tmp[2] . "/" . $tmp[1];
            }
            echo '<item> 
            <title>' . osc_item_title() . '</title> 
            <description>' . osc_item_description() . '</description> 
            <g:id>' . osc_item_id() . '</g:id> 
            <link>' . osc_item_url() . '</link> 
            <g:location>' . (osc_item_address() != '' ? osc_item_address() : '') . ', ' . (osc_item_city() != '' ? osc_item_city() : '') . ', ' . (osc_item_region() != '' ? osc_item_region() : '') . ', ' . (osc_item_zip() != '' ? osc_item_zip() : '') . ' ' . (osc_item_country() != '' ? osc_item_country() : '') . '</g:location> 
            <g:publish_date>' . $date . '</g:publish_date> 
            <g:color>' . (isset($item['s_color']) ? $item['s_color'] : '') . '</g:color> 
            <g:condition>' . (isset($item['b_new']) && $item['b_new'] == 1 ? 'new' : 'used') . '</g:condition>';
            if (osc_count_item_resources() > 0) {
                while (osc_has_item_resources()) {
                    if (strpos(osc_resource_type(), 'image') !== FALSE) {
                        echo '<g:image_link>' . osc_resource_path() . '</g:image_link>';
                    }
                }
            }
            echo '<g:make>' . (isset($item['s_make']) ? $item['s_make'] : '') . '</g:make> 
            <g:mileage>' . (isset($item['i_mileage']) ? $item['i_mileage'] : '') . '</g:mileage> 
            <g:model>' . (isset($item['s_model']) ? $item['s_model'] : '') . '</g:model> 
            <g:price>' . (osc_item_price() != '' ? osc_item_price() : '') . '</g:price> 
            <g:vehicle_type>' . (isset($item['s_name']) ? $item['s_name'] : '') . '</g:vehicle_type> 
            <g:year>' . (isset($item['i_year']) ? $item['i_year'] : '') . '</g:year>
            </item>';
        }
    }
    echo '</channel> 
    </rss>';
}
예제 #2
1
파일: oodle.php 프로젝트: oanav/closetshare
function oodle_realstate()
{
    echo '<?xml version="1.0" encoding="utf-8"?><listings>';
    if (osc_count_items()) {
        while (osc_has_items()) {
            $item = feed_get_house_data(osc_item());
            $time = explode(" ", osc_item_pub_date());
            if (isset($item['s_square_meters'])) {
                $lot_size = $item['s_square_meters'] * 10.7639104;
            } else {
                $lot_size = 0;
            }
            $amenities = array();
            if (isset($item['b_heating']) && $item['b_heating']) {
                $amenities[] = __('Heating', 'extra_feeds');
            }
            if (isset($item['b_air_condition']) && $item['b_air_condition']) {
                $amenities[] = __('Air condition', 'extra_feeds');
            }
            if (isset($item['b_elevator']) && $item['b_elevator']) {
                $amenities[] = __('Elevator', 'extra_feeds');
            }
            if (isset($item['b_terrace']) && $item['b_terrace']) {
                $amenities[] = __('Terrace', 'extra_feeds');
            }
            if (isset($item['b_parking']) && $item['b_parking']) {
                $amenities[] = __('Parking', 'extra_feeds');
            }
            echo '<listing>
                <category>' . osc_item_category() . '</category> 
                <description><![CDATA[' . osc_item_description() . ']]></description> 
                <id>' . osc_item_id() . '</id> 
                <title><![CDATA[' . osc_item_title() . ']]></title> 
                <url>' . osc_item_url() . '</url> 
                <address>' . osc_item_address() . '</address> 
                <city>' . osc_item_city() . '</city> 
                <country>' . osc_item_country_code() . '</country> 
                <neighborhood>' . osc_item_city_area() . '</neighborhood> 
                <state>' . osc_item_region() . '</state> 
                <zip_code>' . osc_item_zip() . '</zip_code> 
                <longitude>' . osc_item_longitude() . '</longitude>
                <latitude>' . osc_item_latitude() . '</latitude>
                <amenities>' . implode(", ", $amenities) . '</amenities>
                <bathrooms>' . @$item['i_num_bathrooms'] . '</bathrooms>
                <bedrooms>' . @$item['i_num_rooms'] . '</bedrooms>
                <condition>' . @$item['e_status'] . '</condition>
                <create_time>' . $time[0] . '</create_time>
                <currency>' . osc_item_currency() . '</currency>
                <furnished>' . (@$item['b_furnished'] ? 'Furnished' : '') . '</furnished>';
            if (osc_count_item_resources() > 0) {
                if (strpos(osc_resource_type(), 'image') !== FALSE) {
                    echo '<image_url><![CDATA[' . osc_resource_path() . ']]></image_url>';
                }
            }
            echo '<lot_size>' . $lot_size . '</lot_size>
                <lot_size_units>square feet</lot_size_units>
                <price>' . osc_item_price() . '</price>
                <seller_email>' . osc_item_contact_email() . '</seller_email> 
                <seller_name><![CDATA[' . osc_item_contact_name() . ']]></seller_name> 
                <year>' . @$item['i_year'] . '</year>
        </listing>';
        }
    }
    echo '</listings>';
}
예제 #3
1
function trovit_cars()
{
    echo '<?xml version="1.0" encoding="utf-8"?>
            <trovit>';
    if (osc_count_items()) {
        while (osc_has_items()) {
            $item = feed_get_car_data(osc_item());
            $date = date('d/m/Y');
            $time = date('H:i');
            if (preg_match('|([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2})|', osc_item_pub_date(), $tmp)) {
                $date = $tmp[3] . "/" . $tmp[2] . "/" . $tmp[1];
                $time = $tmp[4] . ":" . $tmp[5];
            }
            echo '<ad>
                    <id><![CDATA[' . osc_item_id() . ']]></id>
                    <url><![CDATA[' . osc_item_url() . ']]></url>
                    <title><![CDATA[' . osc_item_title() . ']]></title>

                    <content><![CDATA[' . osc_item_description() . ']]></content>

                    <price><![CDATA[' . osc_item_price() . ']]></price>

                    <make><![CDATA[' . (isset($item['s_make']) ? $item['s_make'] : '') . ']]></make>
                    <model><![CDATA[' . (isset($item['s_model']) ? $item['s_model'] : '') . ']]></model>
                    <color><![CDATA[' . (isset($item['s_color']) ? $item['s_color'] : '') . ']]></color>

                    <mileage><![CDATA[' . (isset($item['i_mileage']) ? $item['i_mileage'] : '') . ']]></mileage>
                    <doors><![CDATA[' . (isset($item['i_doors']) ? $item['i_doors'] : '') . ']]></doors>
                    <fuel><![CDATA[' . (isset($item['e_fuel']) ? $item['e_fuel'] : '') . ']]></fuel>
                    <transmission><![CDATA[' . (isset($item['e_transmission']) ? $item['e_transmission'] : '') . ']]></transmission>
                    <engine_size><![CDATA[' . (isset($item['i_engine_size']) ? $item['i_engine_size'] : '') . ']]></engine_size>
                    <cylinders><![CDATA[' . (isset($item['i_cylinders']) ? $item['i_cylinders'] : '') . ']]></cylinders>
                    <power unit="' . (isset($item['e_power_unit']) ? $item['e_power_unit'] : '') . '"><![CDATA[' . (isset($item['i_power']) ? $item['i_power'] : '') . ']]></power>
                    <seats><![CDATA[' . (isset($item['i_seats']) ? $item['i_seats'] : '') . ']]></seats>
                    <gears><![CDATA[' . (isset($item['i_gears']) ? $item['i_gears'] : '') . ']]></gears>

                    <address><![CDATA[' . (osc_item_address() != '' ? osc_item_address() : '') . ']]></address>
                    <city><![CDATA[' . (osc_item_city() != '' ? osc_item_city() : '') . ']]></city>

                    <city_area><![CDATA[' . (osc_item_city_area() != '' ? osc_item_city_area() : '') . ']]></city_area>
                    <postcode><![CDATA[' . (osc_item_zip() != '' ? osc_item_zip() : '') . ']]></postcode>
                    <region><![CDATA[' . (osc_item_region() != '' ? osc_item_region() : '') . ']]></region>

                    <latitude><![CDATA[' . (osc_item_latitude() != '' ? osc_item_latitude() : '') . ']]></latitude>
                    <longitude><![CDATA[' . (osc_item_longitude() != '' ? osc_item_longitude() : '') . ']]></longitude>';
            $res_string = '';
            if (osc_count_item_resources() > 0) {
                while (osc_has_item_resources()) {
                    if (strpos(osc_resource_type(), 'image') !== FALSE) {
                        $res_string .= '<picture>
                                            <picture_url><![CDATA[' . osc_resource_path() . ']]></picture_url>
                                            <picture_title><![CDATA[' . osc_resource_name() . ']]></picture_title>
                                        </picture>';
                    }
                }
            }
            if ($res_string != '') {
                echo '<pictures>' . $res_string . '</pictures>';
            }
            echo '
                <date><![CDATA[' . $date . ']]></date>
                <time><![CDATA[' . $time . ']]></time>
            </ad>';
        }
    }
    echo '</trovit>';
}
예제 #4
0
function indeed()
{
    echo '<?xml version="1.0" encoding="utf-8"?>
    <source>
    <publisher>' . osc_page_title() . '</publisher>
    <publisherurl>' . osc_base_url() . '</publisherurl>
    <lastBuildDate>' . date("D, j M Y G:i:s T") . '</lastBuildDate>';
    if (osc_count_items()) {
        while (osc_has_items()) {
            $item = feed_get_job_data(osc_item());
            $salary = "";
            if (isset($item['i_salary_min']) && $item['i_salary_min'] != '') {
                $salary = $item['i_salary_min'];
            }
            if (isset($item['i_salary_max']) && $item['i_salary_max'] != '') {
                if ($salary != "") {
                    $salary .= ' - ';
                }
                $salary .= $item['i_salary_max'];
            }
            if (isset($item['e_salary_period']) && $item['e_slary_period'] != '') {
                if ($salary != "") {
                    $salary .= ' ';
                    $salary .= $item['e_salary_period'];
                }
            }
            $locale = current($item['locale']);
            if (isset($locale['s_desired_exp']) && $locale['s_desired_exp'] != '') {
                $experience = $locale['s_desired_exp'];
            } else {
                $experience = '';
            }
            if (isset($locale['s_studies']) && $locale['s_studies'] != '') {
                $education = $locale['s_studies'];
            } else {
                $education = '';
            }
            echo '<job>
            <title><![CDATA[' . osc_item_title() . ']]></title>
            <date><![CDATA[' . osc_item_pub_date() . ']]></date>
            <referencenumber><![CDATA[' . osc_item_id() . ']]></referencenumber>
            <url><![CDATA[' . osc_item_url() . ']]></url>
            <company><![CDATA[' . (isset($item['s_company_name']) && $item['s_company_name'] != NULL ? $item['s_company_name'] : '') . ']]></company>
            <city><![CDATA[' . (osc_item_city() != NULL ? osc_item_city() : '') . ']]></city>
            <state><![CDATA[' . (osc_item_region() != NULL ? osc_item_region() : '') . ']]></state>
            <country><![CDATA[' . (osc_item_country() != NULL ? osc_item_country() : '') . ']]></country>
            <postalcode><![CDATA[' . (osc_item_zip() != NULL ? osc_item_zip() : '') . ']]></postalcode>
            <description><![CDATA[' . (osc_item_description() != NULL ? osc_item_description() : '') . ']]></description>
            <salary><![CDATA[' . $salary . ']]></salary>
            <education><![CDATA[' . $education . ']]></education>
            <jobtype><![CDATA[' . (isset($item['e_position_type']) && $item['e_position_type'] != NULL ? $item['e_position_type'] : '') . ']]></jobtype>
            <category><![CDATA[]]></category>
            <experience><![CDATA[' . $experience . ']]></experience>
            </job>';
        }
    }
    echo '</source>';
}
예제 #5
0
파일: search.php 프로젝트: semul/Osclass
 function doModel()
 {
     osc_run_hook('before_search');
     $mCategories = Category::newInstance();
     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:
                         break;
                 }
                 $_REQUEST[$m[1][$k]] = $m[2][$k];
                 $_GET[$m[1][$k]] = $m[2][$k];
                 unset($_REQUEST['sParams']);
                 unset($_GET['sParams']);
                 unset($_POST['sParams']);
             }
         }
     }
     ////////////////////////////////
     //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_sPattern = strip_tags(Params::getParam('sPattern'));
     // ADD TO THE LIST OF LAST SEARCHES
     if (osc_save_latest_searches()) {
         if (trim($p_sPattern) != '') {
             LatestSearches::newInstance()->insert(array('s_search' => trim($p_sPattern), 'd_date' => date('Y-m-d H:i:s')));
         }
     }
     $p_bPic = Params::getParam('bPic');
     $p_bPic == 1 ? $p_bPic = 1 : ($p_bPic = 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;
     if (count($p_sCategory) > 0) {
         foreach ($p_sCategory as $category) {
             $this->mSearch->addCategory($category);
         }
     } 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 IF WE ONLY WANT ITEMS WITH PICS
     if ($p_bPic) {
         $this->mSearch->withPicture(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
     $this->mSearch->page($p_iPage, $p_iPageSize);
     osc_run_hook('search_conditions', Params::getParamsAsArray());
     if (!Params::existParam('sFeed')) {
         // RETRIEVE ITEMS AND TOTAL
         $aItems = $this->mSearch->doSearch();
         $iTotalItems = $this->mSearch->count();
         $iStart = $p_iPage * $p_iPageSize;
         $iEnd = min(($p_iPage + 1) * $p_iPageSize, $iTotalItems);
         $iNumPages = ceil($iTotalItems / $p_iPageSize);
         osc_run_hook('search', $this->mSearch);
         //preparing variables...
         $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('non_empty_categories', $aCategories) ;
         $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_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();
         $this->_exportVariableToView('search_alert', base64_encode($json));
         //calling the view...
         $this->doView('search.php');
     } else {
         $this->mSearch->page(0, osc_num_rss_items());
         // RETRIEVE ITEMS AND TOTAL
         $iTotalItems = $this->mSearch->count();
         $aItems = $this->mSearch->doSearch();
         $this->_exportVariableToView('items', $aItems);
         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(), '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(), 'dt_pub_date' => osc_item_pub_date()));
                     }
                 }
             }
             osc_run_hook('feed', $feed);
             $feed->dumpXML();
         } else {
             osc_run_hook('feed_' . $p_sFeed, $aItems);
         }
     }
 }
예제 #6
0
        ?>
        <?php 
    }
    ?>
    </tbody>
</table>
<?php 
}
?>
<table border="0" cellspacing="0">
    <tbody>
        <?php 
$class = "even";
?>
        <?php 
while (osc_has_items()) {
    ?>
            <tr class="<?php 
    echo $class;
    ?>
">
                <?php 
    if (osc_images_enabled_at_items()) {
        ?>
                 <td class="photo">
                     <?php 
        if (osc_count_item_resources()) {
            ?>
                        <a href="<?php 
            echo osc_item_url();
            ?>
예제 #7
0
 function meta_description()
 {
     $location = Rewrite::newInstance()->get_location();
     $section = Rewrite::newInstance()->get_section();
     $text = '';
     switch ($location) {
         case 'item':
             switch ($section) {
                 case 'item_add':
                     $text = '';
                     break;
                 case 'item_edit':
                     $text = '';
                     break;
                 case 'send_friend':
                     $text = '';
                     break;
                 case 'contact':
                     $text = '';
                     break;
                 default:
                     $text = osc_item_category() . ', ' . osc_highlight(strip_tags(osc_item_description()), 140) . '..., ' . osc_item_category();
                     break;
             }
             break;
         case 'page':
             $text = osc_highlight(strip_tags(osc_static_page_text()), 140);
             break;
         case 'search':
             $result = '';
             if (osc_count_items() == 0) {
                 $text = '';
             }
             if (osc_has_items()) {
                 $result = osc_item_category() . ', ' . osc_highlight(strip_tags(osc_item_description()), 140) . '..., ' . osc_item_category();
             }
             osc_reset_items();
             $text = $result;
         case '':
             // home
             $result = '';
             if (osc_count_latest_items() == 0) {
                 $text = '';
             }
             if (osc_has_latest_items()) {
                 $result = osc_item_category() . ', ' . osc_highlight(strip_tags(osc_item_description()), 140) . '..., ' . osc_item_category();
             }
             osc_reset_items();
             $text = $result;
             break;
     }
     $text = str_replace('"', "'", $text);
     return $text;
 }
예제 #8
0
파일: search.php 프로젝트: acharei/OSClass
 function doModel()
 {
     osc_run_hook('before_search');
     $mCategories = new Category();
     ////////////////////////////////
     //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_sPattern = strip_tags(Params::getParam('sPattern'));
     $p_sUser = strip_tags(Params::getParam('sUser'));
     // ADD TO THE LIST OF LAST SEARCHES
     if (osc_save_latest_searches()) {
         if (trim($p_sPattern) != '') {
             LatestSearches::newInstance()->insert(array('s_search' => trim($p_sPattern), 'd_date' => date('Y-m-d H:i:s')));
         }
     }
     $p_bPic = Params::getParam('bPic');
     $p_bPic == 1 ? $p_bPic = 1 : ($p_bPic = 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();
     }
     //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 = intval(Params::getParam('iPage'));
     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;
     if (count($p_sCategory) > 0) {
         foreach ($p_sCategory as $category) {
             $this->mSearch->addCategory($category);
         }
     } 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->addConditions(sprintf("MATCH(d.s_title, d.s_description) AGAINST('%s' IN BOOLEAN MODE)", $p_sPattern));
         $osc_request['sPattern'] = $p_sPattern;
     }
     // FILTERING USER
     if ($p_sUser != '') {
         $this->mSearch->fromUser(explode(",", $p_sUser));
     }
     // FILTERING IF WE ONLY WANT ITEMS WITH PICS
     if ($p_bPic) {
         $this->mSearch->withPicture(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
     $this->mSearch->page($p_iPage, $p_iPageSize);
     osc_run_hook('search_conditions', Params::getParamsAsArray());
     if (!Params::existParam('sFeed')) {
         // RETRIEVE ITEMS AND TOTAL
         $aItems = $this->mSearch->doSearch();
         $iTotalItems = $this->mSearch->count();
         $iStart = $p_iPage * $p_iPageSize;
         $iEnd = min(($p_iPage + 1) * $p_iPageSize, $iTotalItems);
         $iNumPages = ceil($iTotalItems / $p_iPageSize);
         osc_run_hook('search', $this->mSearch);
         //preparing variables...
         //$this->_exportVariableToView('non_empty_categories', $aCategories) ;
         $this->_exportVariableToView('search_start', $iStart);
         $this->_exportVariableToView('search_end', $iEnd);
         $this->_exportVariableToView('search_category', $p_sCategory);
         $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_region', $p_sRegion);
         $this->_exportVariableToView('search_city', $p_sCity);
         $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);
         $this->_exportVariableToView('search_alert', base64_encode(serialize($this->mSearch)));
         //calling the view...
         $this->doView('search.php');
     } else {
         $this->mSearch->page(0, osc_num_rss_items());
         // RETRIEVE ITEMS AND TOTAL
         $iTotalItems = $this->mSearch->count();
         $aItems = $this->mSearch->doSearch();
         $this->_exportVariableToView('items', $aItems);
         if ($p_sFeed == '' || $p_sFeed == 'rss') {
             // FEED REQUESTED!
             header('Content-type: text/xml; charset=utf-8');
             $feed = new RSSFeed();
             $feed->setTitle(__('Latest items added') . ' - ' . osc_page_title());
             $feed->setLink(osc_base_url());
             $feed->setDescription(__('Latest items 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()), 'description' => osc_item_description(), 'dt_pub_date' => osc_item_pub_date(), 'image' => array('url' => htmlentities(osc_resource_thumbnail_url()), 'title' => osc_item_title(), 'link' => htmlentities(osc_item_url()))));
                     } else {
                         $feed->addItem(array('title' => osc_item_title(), 'link' => htmlentities(osc_item_url()), 'description' => osc_item_description(), 'dt_pub_date' => osc_item_pub_date()));
                     }
                 }
             }
             osc_run_hook('feed', $feed);
             $feed->dumpXML();
         } else {
             osc_run_hook('feed_' . $p_sFeed, $aItems);
         }
     }
 }
function _pop_print_listing_card($aItems = null)
{
    ob_end_flush();
    ob_start();
    if (Params::getParam('_page') == 'search' || Params::getParam('_page') == '') {
        // get premium ads
        $max = osc_get_preference('pop_max_premium', 'pop_theme');
        osc_get_premiums($max);
        if (osc_count_premiums() > 0) {
            while (osc_has_premiums()) {
                pop_draw_item('', false, true);
            }
        }
    }
    if ($aItems !== null) {
        View::newInstance()->_exportVariableToView('items', $aItems);
    }
    while (osc_has_items()) {
        $admin = false;
        if (View::newInstance()->_exists("listAdmin")) {
            $admin = true;
        }
        pop_draw_item('', $admin);
    }
    $html = ob_get_contents();
    ob_clean();
    return $html;
}
예제 #10
0
 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);
         }
     }
 }
예제 #11
0
function meta_keywords()
{
    $text = '';
    // search
    if (osc_is_search_page()) {
        if (osc_has_items()) {
            $keywords = array();
            $keywords[] = osc_item_category();
            if (osc_item_city() != '') {
                $keywords[] = osc_item_city();
                $keywords[] = sprintf('%s %s', osc_item_category(), osc_item_city());
            }
            if (osc_item_region() != '') {
                $keywords[] = osc_item_region();
                $keywords[] = sprintf('%s %s', osc_item_category(), osc_item_region());
            }
            if (osc_item_city() != '' && osc_item_region() != '') {
                $keywords[] = sprintf('%s %s %s', osc_item_category(), osc_item_region(), osc_item_city());
                $keywords[] = sprintf('%s %s', osc_item_region(), osc_item_city());
            }
            $text = implode(', ', $keywords);
        }
        osc_reset_items();
    }
    // listing
    if (osc_is_ad_page()) {
        $keywords = array();
        $keywords[] = osc_item_category();
        if (osc_item_city() != '') {
            $keywords[] = osc_item_city();
            $keywords[] = sprintf('%s %s', osc_item_category(), osc_item_city());
        }
        if (osc_item_region() != '') {
            $keywords[] = osc_item_region();
            $keywords[] = sprintf('%s %s', osc_item_category(), osc_item_region());
        }
        if (osc_item_city() != '' && osc_item_region() != '') {
            $keywords[] = sprintf('%s %s %s', osc_item_category(), osc_item_region(), osc_item_city());
            $keywords[] = sprintf('%s %s', osc_item_region(), osc_item_city());
        }
        $text = implode(', ', $keywords);
    }
    return osc_apply_filter('meta_keywords_filter', $text);
}
예제 #12
0
function osc_has_latest_items()
{
    if (!View::newInstance()->_exists('items')) {
        View::newInstance()->_exportVariableToView('items', Item::newInstance()->listLatest(osc_max_latest_items()));
    }
    return osc_has_items();
}
예제 #13
0
 function doModel()
 {
     $mCategories = new Category();
     $aCategories = $mCategories->findRootCategories();
     $mCategoryStats = new CategoryStats();
     ////////////////////////////////
     //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_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_sPattern = strip_tags(Params::getParam('sPattern'));
     $p_bPic = Params::getParam('bPic');
     $p_bPic == 1 ? $p_bPic = 1 : ($p_bPic = 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();
     }
     //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 = intval(Params::getParam('iPage'));
     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;
     if (count($p_sCategory) > 0) {
         foreach ($p_sCategory as $category) {
             $this->mSearch->addCategory($category);
         }
     } else {
         $bAllCategoriesChecked = true;
     }
     //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->addConditions(sprintf("(d.s_title LIKE '%%%s%%' OR d.s_description LIKE '%%%s%%')", $p_sPattern, $p_sPattern));
         $osc_request['sPattern'] = $p_sPattern;
     }
     // FILTERING IF WE ONLY WANT ITEMS WITH PICS
     if ($p_bPic) {
         $this->mSearch->withPicture(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
     $this->mSearch->page($p_iPage, $p_iPageSize);
     osc_run_hook('search_conditions', Params::getParamsAsArray());
     $this->mSearch->addConditions(sprintf("%st_item.e_status = 'ACTIVE' ", DB_TABLE_PREFIX));
     // RETRIEVE ITEMS AND TOTAL
     $iTotalItems = $this->mSearch->count();
     $aItems = $this->mSearch->doSearch();
     if (!Params::existParam('sFeed')) {
         $iStart = $p_iPage * $p_iPageSize;
         $iEnd = min(($p_iPage + 1) * $p_iPageSize, $iTotalItems);
         //Static data, which is the point?
         /*$aOrders   = array(
               __('Newly listed')       => array('sOrder' => 'dt_pub_date', 'iOrderType' => 'desc')
              ,__('Lower price first')  => array('sOrder' => 'f_price', 'iOrderType' => 'asc')
              ,__('Higher price first') => array('sOrder' => 'f_price', 'iOrderType' => 'desc')
           );*/
         $iNumPages = ceil($iTotalItems / $p_iPageSize);
         //Categories for select at view "search.php"
         $mCategories = new Category();
         $aCategories = $mCategories->findRootCategories();
         $mCategoryStats = new CategoryStats();
         $aCategories = $mCategories->toTree();
         foreach ($aCategories as $k => $v) {
             $iCategoryNumItems = CategoryStats::newInstance()->getNumItems($v);
             if ($iCategoryNumItems > 0) {
                 $aCategories[$k]['total'] = $iCategoryNumItems;
             } else {
                 unset($aCategories[$k]);
             }
         }
         osc_run_hook('search', $this->mSearch);
         //preparing variables...
         $this->_exportVariableToView('categories', $aCategories);
         $this->_exportVariableToView('search_start', $iStart);
         $this->_exportVariableToView('search_end', $iEnd);
         $this->_exportVariableToView('search_category', $p_sCategory);
         $this->_exportVariableToView('search_order_type', $p_iOrderType);
         $this->_exportVariableToView('search_order', $p_sOrder);
         $this->_exportVariableToView('search_pattern', $p_sPattern);
         $this->_exportVariableToView('search_total_pages', $iNumPages);
         $this->_exportVariableToView('search_page', $p_iPage);
         $this->_exportVariableToView('search_has_pic', $p_bPic);
         $this->_exportVariableToView('search_city', $p_sCity);
         $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);
         //calling the view...
         $this->doView('search.php');
     } else {
         $this->_exportVariableToView('items', $aItems);
         if ($p_sFeed == '' || $p_sFeed == 'rss') {
             // FEED REQUESTED!
             header('Content-type: text/xml; charset=utf-8');
             $feed = new RSSFeed();
             $feed->setTitle(__('Latest items added') . ' - ' . osc_page_title());
             $feed->setLink(osc_base_url());
             $feed->setDescription(__('Latest items added in') . ' ' . osc_page_title());
             if (osc_count_items() > 0) {
                 while (osc_has_items()) {
                     $feed->addItem(array('title' => osc_item_title(), 'link' => htmlentities(osc_item_url()), 'description' => osc_item_description()));
                 }
             }
             osc_run_hook('feed', $feed);
             $feed->dumpXML();
         } else {
             osc_run_hook('feed_' . $p_sFeed, $aItems);
         }
     }
 }
예제 #14
0
function seo_meta_keywords_filter()
{
    $text = '';
    //home page
    if (osc_is_home_page()) {
        if (osc_get_preference('seo_metakeywords_home', 'seo_plugin')) {
            $text = osc_get_preference('seo_metakeywords_home', 'seo_plugin');
        }
    }
    // static page
    if (osc_is_static_page()) {
        if (osc_get_preference('seo_metakeywords_page_' . osc_static_page_id(), 'seo_plugin')) {
            $text = osc_get_preference('seo_metakeywords_page_' . osc_static_page_id(), 'seo_plugin');
        }
    }
    //contact page
    if (osc_is_contact_page()) {
        if (osc_get_preference('seo_metakeywords_page_contact', 'seo_plugin')) {
            $text = osc_get_preference('seo_metakeywords_page_contact', 'seo_plugin');
        }
    }
    // search
    if (osc_is_search_page()) {
        if (osc_has_items()) {
            $keywords = array();
            $keywords[] = osc_item_category();
            if (osc_item_city() != '') {
                $keywords[] = osc_item_city();
                $keywords[] = sprintf('%s %s', osc_item_category(), osc_item_city());
            }
            if (osc_item_region() != '') {
                $keywords[] = osc_item_region();
                $keywords[] = sprintf('%s %s', osc_item_category(), osc_item_region());
            }
            if (osc_item_city() != '' && osc_item_region() != '') {
                $keywords[] = sprintf('%s %s %s', osc_item_category(), osc_item_region(), osc_item_city());
                $keywords[] = sprintf('%s %s', osc_item_region(), osc_item_city());
            }
            $text = implode(', ', $keywords);
        }
        osc_reset_items();
    }
    // listing
    if (osc_is_ad_page()) {
        $detail = seo_get_row(osc_item_id());
        if (empty($detail['seo_item_meta_keywords'])) {
            $keywords = array();
            $keywords[] = osc_item_category();
            if (osc_item_city() != '') {
                $keywords[] = osc_item_city();
                $keywords[] = sprintf('%s %s', osc_item_category(), osc_item_city());
            }
            if (osc_item_region() != '') {
                $keywords[] = osc_item_region();
                $keywords[] = sprintf('%s %s', osc_item_category(), osc_item_region());
            }
            if (osc_item_city() != '' && osc_item_region() != '') {
                $keywords[] = sprintf('%s %s %s', osc_item_category(), osc_item_region(), osc_item_city());
                $keywords[] = sprintf('%s %s', osc_item_region(), osc_item_city());
            }
            $text = implode(', ', $keywords);
        } else {
            $text = $detail['seo_item_meta_keywords'];
        }
    }
    return $text;
}
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;
}
예제 #16
0
파일: hItems.php 프로젝트: acharei/OSClass
/**
 * Gets next item of last items
 *
 * @return array
 */
function osc_has_latest_items()
{
    if (!View::newInstance()->_exists('items')) {
        $search = new Search();
        $search->limit(0, osc_max_latest_items());
        View::newInstance()->_exportVariableToView('items', $search->getLatestItems());
    }
    return osc_has_items();
}