db->fetchArray($query="SELECT *
FROM ".PX."objects
WHERE section_id=".$cat."
AND status=1
ORDER BY ord ASC");
if (!$exhibits) return $s;
$i=0;
foreach ($exhibits as $go)
{
$pictures = $OBJ->db->fetchArray($query="
SELECT *
FROM ".PX."media
WHERE media_ref_id = ".$go['id']."
AND media_obj_type = 'exhibit'
ORDER BY media_order ASC, media_id ASC
LIMIT 1");
if($i & 1){
$oe='even';
}
else{
$oe='odd';
}
if($imgs){$pic='
';}
$a .= '
'.$pic.'
'.word_limit($go, 30).'
';
$i++;
}
return $a;
}
function word_limit($go, $limit=40){
$words=explode(' ', $go['content']);
for($i=0; $i<$limit; $i++){
$return[]=$words[$i];
}
$return[]='...';
return closetags(implode($return, ' ')). 'READ THE REST';
}
function closetags ( $html )
{
#put all opened tags into an array
preg_match_all ( "#<([a-z]+)( .*)?(?!/)>#iU", $html, $result );
$openedtags = $result[1];
#put all closed tags into an array
preg_match_all ( "#([a-z]+)>#iU", $html, $result );
$closedtags = $result[1];
$len_opened = count ( $openedtags );
# all tags are closed
if( count ( $closedtags ) == $len_opened )
{
return $html;
}
$openedtags = array_reverse ( $openedtags );
# close tags
for( $i = 0; $i < $len_opened; $i++ )
{
if ( !in_array ( $openedtags[$i], $closedtags ) )
{
$html .= "" . $openedtags[$i] . ">";
}
else
{
unset ( $closedtags[array_search ( $openedtags[$i], $closedtags)] );
}
}
return $html;
}
?>