<?php
defined( '_VALID_MOS' ) or die( 'Прямой доступ к файлам по этому адресу запрещен!' );
if( !defined('__FUNCTION_loadMessage') ) {
define('__FUNCTION_loadMessage',1 );
function loadMessage( $query, $menuid, $url_size ) {
global $database, $mosConfig_absolute_path, $mosConfig_live_site;
$database->setQuery( $query );
if( $database->loadObject( $msg ) ) {
$itemid_ = $msg->model_itemid ? $msg->model_itemid : ( $msg->vendor_itemid ? $msg->vendor_itemid : $menuid );
$title = "Продам ".$msg->vendortitle.' '.$msg->modeltitle;
if( $url_size=='thumb' and file_exists ( $mosConfig_absolute_path."/components/com_autobb/photos/".$msg->id."/im_".$msg->photoid.".jpg" ) ) {
$img = $mosConfig_live_site."/components/com_autobb/photos/".$msg->id."/im_".$msg->photoid.".jpg";
}
else $img = "index2.php?option=com_autobb&task=photo&no_html=1&size=".$url_size."&id=".$msg->photoid;
echo '<div class="autobb_random"><a href="'.sefRelToAbs("index.php?option=com_autobb&Itemid=".$itemid_."&task=show&id=".$msg->id).'" title="'.$title.'">';
if(intval( $msg->photoid ) ) echo '<img style="background-color: #00b4ff; padding: 3px; border: solid 1px #737272" src="'.$img.'" border="0" title="'.$title.'" alt="'.$title.'" /><br />';
echo '<span class="autobb_vendor"><strong>'.$msg->vendortitle.' '.$msg->modeltitle.' '.$msg->modification.'</strong></span><br />';
/*echo ' <span class="autobb_year">'.$msg->year.' г/в</span><br />';*/
echo ' <span class="autobb_price">'.preg_replace('/(?<=[0-9])(?=(?:[0-9]{3})+(?![0-9]))/i', '.', $msg->price).' '.$msg->currency_title.'</span>';
echo '</a></div>';
}
}
}
global $database, $Itemid;
$moduleclass_sfx = $params->get( 'moduleclass_sfx' );
$menuid = intval( $params->get( 'menuid' ) ) ? intval( $params->get( 'menuid' ) ) : $Itemid;
$msgid = intval( $params->get( 'msgid' ) );
$randomly = intval( $params->get( 'randomly' ) ) || !$msgid;
$category = intval( $params->get( 'category' ) );
$with_photo_only = intval( $params->get( 'with_photo_only' ) );
$size = intval( $params->get( 'size' ) );
$msize = intval( $params->get( 'msize' ) );
switch( $size ) {
case '1' : $url_size = "middle"; break;
case '2' : $url_size = "custom&msize={$msize}"; break;
default : $url_size = 'thumb';
}
$where = array();
$where[] = "a.expirationDate>=NOW()";
$where[] = "a.published='1'";
if($randomly) {
if( $category ) $where[] = "a.category=".$category;
if($with_photo_only) $where[] = 'exists (select 1 from #__autobb_photos p1 where a.id=p1.msgid)';
$query = "SELECT count(a.id) FROM #__autobb_messages AS a"
.( count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : "" )
;
$database->setQuery( $query );
$count = intval( $database->loadResult() );
$limit = rand( 0, $count-1 );
$query = "SELECT a.*, v.title as vendortitle, m.title as modeltitle, v.itemid as vendor_itemid, "
."\n m.itemid as model_itemid, cur.title as currency_title, "
." (SELECT min(p.id) FROM #__autobb_photos AS p WHERE a.id=p.msgid) AS photoid"
."\n FROM #__autobb_messages AS a"
."\n LEFT JOIN #__autobb_vendors as v ON a.vendor=v.id"
."\n LEFT JOIN #__autobb_models as m ON a.model=m.id"
."\n LEFT JOIN #__autobb_currency as cur ON cur.id=a.currency"
.( count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : "" )
."\n LIMIT $limit,1"
;
} else {
$where[] = "a.id=".$msgid;
$query = "SELECT a.*, v.title as vendortitle, m.title as modeltitle, v.itemid as vendor_itemid, m.itemid as model_itemid, (SELECT min(p.id) FROM #__autobb_photos AS p WHERE a.id=p.msgid) AS photoid, cur.title as currency_title FROM #__autobb_messages AS a"
."\n LEFT JOIN #__autobb_vendors as v ON a.vendor=v.id"
."\n LEFT JOIN #__autobb_models as m ON a.model=m.id"
."\n LEFT JOIN #__autobb_currency as cur ON cur.id=a.currency"
.( count( $where ) ? "\n WHERE " . implode( ' AND ', $where ) : "" )
."\n LIMIT 1"
;
}
$cache =& mosCache::getCache( 'mod_autobb_random' );
$cache->call('loadMessage', $query, $menuid, $url_size );
?>
Где править? Помагите. Очень нуно
