$str_index = "";
if($this->use_index) $str_index = " use index ({$this->use_index}) ";
$sql = "select distinct ".TABLE_ADS.".*$mlang_vars, ".TABLE_ADS.".id as adid, date_format(".TABLE_ADS.".`date_added`,'$date_format') as date_nice, date_format(".TABLE_ADS.".`date_expires`,'$date_format') as date_expires_nice, UNIX_TIMESTAMP(".TABLE_ADS.".`date_added`) as `time_added`, (".TABLE_ADS.".date_expires < '$timestamp' and ".TABLE_ADS.".date_expires!='0000-00-00 00:00:00' and ".TABLE_ADS.".active=0) as expired
$str_slugs
$q_vars
from ".TABLE_ADS." $str_index
$q_join $join_pictures $join_cat $join_users
$join_slugs
".$where.$where_slugs." ".$order_by." ".$order_way." ";
if($ads_per_page>0) $sql .= " limit ".$general_row.", ".$ads_per_page;
// echo $sql."<br/><br/>";
$arr = $db->fetchAssocList($sql);
//_print_r($arr);
$i=0;
$result=array();
$pictures=new pictures();
if($is_mobile) {
global $mobile_settings;
$nopic = $mobile_settings['mobile_nopic'];
$medNopic = $mobile_settings['mobile_nopic'];
} else {
$nopic=$ads_settings["nopic"];
$medNopic=$ads_settings["med_nopic"];
}
".TABLE_ADS.".id as adid,
$where="where explain ".TABLE_ADS.".active = 1".$where.$locations_str;
function getLatest($no_latest, $where = '') {
global $db, $settings;
$locations_str="";
if($settings['enable_locations'])
$locations_str = locations::makeQueryStr();
$where="where ".TABLE_ADS.".active = 1".$where.$locations_str;
$order_by_str="order by date_added desc";
$order_way='';
$start=0;
$ads_per_page=$no_latest;
$result=$this->getShortListings($where,$order_by_str,$order_way,$start,$ads_per_page);
return $result;
}
{* logo *}
{foreach $special_user_fields.logo as $logo}
{capture name=pb assign=pb}pb_{$logo.caption}{/capture}
{if (isset($listing.user[$logo]) && $listing.user[$logo])}
<div class="mb10"><img style="object-fit:cover;width: 100px;height: 97px;border-radius: 50%;" src="{$live_site}/uploads/{$logo}/{$listing.user[$logo]}" /></div>
{/if}
{/foreach}
здесь по другому немного код написан, как здесь сменить можно на is_array?
{* logo *}
{foreach $special_listing_fields.logo as $logo}
{if (is_array($listing[$logo.caption]) && $listing[$logo.caption])}
<div class="mb10"><img src="{$live_site}/uploads/{$logo.caption}/{$listing[$logo.caption]}" /></div>
{/if}
{/foreach}
function getNoShortListings($where, $q_join='', $noloc = 0){
global $db, $settings;
$join_pictures = "";
$count = "*";
$locations_str="";
global $admin_side;
if(!$noloc && $settings['enable_locations'] && !isset($admin_side)) {
$locations_str = locations::makeQueryStr();
if(!$where) $locations_str = " where ".substr($locations_str, 4);
}
do_action("search_listing_query", array(&$where));
// count(*) faster than count(val) **********
$sql = "select count($count)
from ".TABLE_ADS."
$join_pictures $join_users $join_ext $join_options $join_pe
$q_join
".$where.$locations_str;
//echo $sql;
$no_ads = $db->fetchRow($sql);
return $no_ads;
}
function getShortListings($where, $order_by, $order_way, $general_row, $ads_per_page, $search='', $q_vars='', $q_join='', $join_cat='') { ....
$join_ext = "";
if (strstr($where, TABLE_ADS_EXTENSION)) {
$join_ext = " left join " . TABLE_ADS_EXTENSION . " on " . TABLE_ADS . ".id = " . TABLE_ADS_EXTENSION . ".`id` ";
}
$join_options = "";
if (strstr($where, TABLE_OPTIONS)) {
$join_options = " left join " . TABLE_OPTIONS . " on " . TABLE_ADS . ".`id` = " . TABLE_OPTIONS . ".`object_id` and `option` like 'video' ";
}
$join_cat = "";
if (strstr($where, TABLE_CATEGORIES)) {
$join_users = "left join " . TABLE_CATEGORIES . "_lang on " . TABLE_ADS . ".category_id=" . TABLE_CATEGORIES . "_lang.id ";
}
$join_pe = "";
if (strstr($where, TABLE_PENDING_EDITED)) {
$join_pe = " left join " . TABLE_PENDING_EDITED . " on " . TABLE_ADS . ".id = " . TABLE_PENDING_EDITED . ".`ad_id` ";
}
$join_pictures = '';
if(strstr($where, TABLE_ADS_PICTURES))
$join_pictures = "inner join ".TABLE_ADS_PICTURES." on ".TABLE_ADS.".id=".TABLE_ADS_PICTURES.".ad_id ";
$join_users = '';
if(strstr($where, TABLE_USERS))
$join_users = "inner join ".TABLE_USERS." on ".TABLE_ADS.".user_id=".TABLE_USERS.".id ";
function getLatest($no_latest, $where = '') {
global $db, $settings;
$locations_str="";
if($settings['enable_locations'])
$locations_str = locations::makeQueryStr();
$where="where ".TABLE_ADS.".active = 1".$where.$locations_str;
$order_by_str="order by date_added desc";
$order_way='';
$start=0;
$ads_per_page=$no_latest;
$result=$this->getShortListings($where,$order_by_str,$order_way,$start,$ads_per_page);
return $result;
}
function getFeatured($no_featured, $where = '') {
global $db, $settings;
$locations_str="";
if($settings['enable_locations'])
$locations_str = locations::makeQueryStr();
$where="where ".TABLE_ADS.".featured>0 and ".TABLE_ADS.".active = 1".$where.$locations_str;
// solution to avoid order by rand()
$total_featured = $db->fetchRow("select count(*) from ".TABLE_ADS." ".$where);
if($total_featured<=$no_featured) {
$result=$this->getShortListings($where,"","",0,0);
shuffle ( $result );
return $result;
}
// more than $no_featured results
$t = $total_featured - $no_featured;
$start = rand(0,$t);
$result=$this->getShortListings($where,"","",$start,$no_featured);
return $result;
}