<?php
defined('_JEXEC') or die('Restricted access');
GalleryHeader();
if (!$ad_search) {
$app->redirect(JRoute::_('index.php?option=com_datsogallery&view=datsogallery'.$itemid, false),
JText::_('COM_DATSOGALLERY_SEARCH_DISABLED'));
}
$sstring = $app->getUserStateFromRequest('datsogallery.sstring', 'sstring', '', 'string');
$where = array();
if ($sstring) {
$searchEscaped = $db->Quote('%'.$db->getEscaped($sstring, true).'%', false);
$where[] = '( a.imgtitle LIKE '.$searchEscaped
.' OR a.imgtext LIKE '.$searchEscaped
.' OR a.imgauthor LIKE '.$searchEscaped.' )'
;
}
$where[] = 'a.catid = c.cid';
$where[] = 'a.published = 1';
$where[] = 'a.approved = 1';
$where[] = 'a.language IN ('.$db->Quote($language).','.$db->Quote('*').')';
$where[] = 'c.approved = 1';
$where[] = 'c.published = 1';
$where[] = 'c.access IN ('.$groups.')';
$where[] = 'c.language IN ('.$db->Quote($language).','.$db->Quote('*').')';
$where[] = 'a.id NOT IN (SELECT b.image FROM #__datsogallery_catg AS b WHERE b.cid = a.catid AND b.cover = 0)';
$images = count($where) ? ' WHERE '.implode(' AND ', $where) : '';
$limitstart = JRequest::getVar('limitstart', 0, 'int');
$db->setQuery('SELECT SQL_CALC_FOUND_ROWS a.*'
.' FROM #__datsogallery AS a,'
.' #__datsogallery_catg AS c'
. $images
.' ORDER BY a.id DESC'
.' LIMIT '.$limitstart.', '.$ad_toplist);
$db->query();
$rows = $db->loadObjectList();
$db->setQuery('SELECT FOUND_ROWS();');
jimport('joomla.html.pagination');
$pagination = new JPagination($db->loadResult(), $limitstart, $ad_toplist);
$pw_title = JText::_('COM_DATSOGALLERY_SEARCH_RESULTS').' '.$sstring;
$document->setTitle($pw_title);
?>
<div class="datso_pgn">
<?php echo $pagination->getPagesLinks('index.php?option=com_datsogallery&view=search'.$itemid); ?>
</div>
<div style="clear:both"></div>
<div class="dg_head_background"><?php echo $pw_title; ?></div>
<table width="100%" border="0" cellspacing="1" cellpadding="0" class="dg_body_background">
<?php
$rowcounter = 0;
if (count($rows) > 0) {
foreach ($rows as $row) {
if ($ad_ncsc)
$cw = 100 / $ad_cp."%";
if ($rowcounter % $ad_cp == 0)
echo '<tr>';
echo '<td width="'.$cw.'" class="dg_body_background_td" align="center" valign="top">';
$ld = "<a href='".JRoute::_("index.php?option=com_datsogallery&view=image&catid=".$row->catid."&id=".$row->id.$itemid)
."' title='".$row->imgtitle."'>";
echo $ld;
echo "<img src=\"".resize($row->imgoriginalname, $ad_thumbwidth, $ad_thumbheight, $ad_crop, $ad_cropratio, 0, $row->catid)
."\" ".get_width_height($row->imgoriginalname, $ad_thumbwidth, $ad_thumbheight, $row->catid, $ad_cropratio)
." class=\"dgimg\" title=\"".$row->imgtitle."\" alt=\"".$row->imgtitle."\" /></a>";
if ($ad_showdetail){
echo "<div style=\"width:".$ad_thumbwidth."px;margin:10px auto 0 auto;text-align:left;text-transform: uppercase;\">";
echo ($ad_showimgtitle) ? $ld.'<span>'.$row->imgtitle.'</span></a><br />':'';
echo "<span>";
echo ($ad_showfimgdate) ? '<strong>'.JText::_('COM_DATSOGALLERY_DATE_ADD').'</strong>: '.strftime($ad_datef=='customdate'?$ad_datefc:$ad_datef, strtotime($row->imgdate)).'<br />':'';
echo ($ad_showimgcounter) ? '<strong>'.JText::_('COM_DATSOGALLERY_HITS').'</strong>: '.$row->imgcounter.'<br />':'';
echo ($ad_showdownloads) ? '<strong>'.JText::_('COM_DATSOGALLERY_DOWNLOADS').'</strong>: '.$row->imgdownloaded.'<br />':'';
echo ($ad_showrating) ? showVote ($row->id, $row->imgvotes, $row->imgvotesum, false, $row->catid) : '';
if($ad_showcomments) {
$db->setQuery('SELECT COUNT(cmtid) FROM #__datsogallery_comments WHERE cmtpic = '.$row->id.' AND published = 1');
$comments = $db->loadResult();
$comments = ($comments) ? $comments : JText::_('COM_DATSOGALLERY_NO');
echo "<strong>".JText::_('COM_DATSOGALLERY_COMMENTS')."</strong>: $comments";
}
echo "</span>";
echo '</div>';
}
echo '</td>';
$rowcounter++;
}
if ($rowcounter % $ad_cp <> 0) {
for ($i = 1; $i <= ($ad_cp - ($rowcounter % $ad_cp)); $i++) {
echo '<td width="'.$cw.'" class="dg_body_background_td" align="center" valign="top"> </td>';
}
}
echo '</tr>';
}
else {
echo '<tr><td class="dg_body_background_td">'.JText::_('COM_DATSOGALLERY_NO_RESULTS').'</td></tr>';
}
?>
</table>
<div class="datso_pgn">
<?php echo $pagination->getPagesLinks('index.php?option=com_datsogallery&view=search'.$itemid); ?>
</div>
<?php
GalleryFooter();