Back to PhocaGalleryFbSystem class

Method getImageFromCat

public static
getImageFromCat
(mixed $idCat, mixed $idImg = 0)

Method getImageFromCat - Source code

public static function getImageFromCat($idCat, $idImg = 0)
{
    $db = Factory::getDBO();
    $nextImg = '';
    if ($idImg > 0) {
        $nextImg = ' AND a.id > ' . (int) $idImg;
    }
    $query = 'SELECT a.*' . ' FROM #__phocagallery AS a' . ' WHERE a.catid = ' . (int) $idCat . ' AND a.published = 1' . ' AND a.approved = 1' . $nextImg . ' ORDER BY a.id ASC LIMIT 1';
    $db->setQuery($query);
    $item = $db->loadObject();
    if (!isset($item->id) || isset($item->id) && $item->id < 1) {
        $img['end'] = 1;
        return $img;
    }
    if (isset($item->description) && $item->description != '') {
        $img['caption'] = $item->title . ' - ' . $item->description;
    } else {
        $img['caption'] = $item->title;
    }
    //TO DO TEST EXT IMAGE
    if (isset($item->extid) && $item->extid != '') {
        $img['extid'] = $item->extid;
    }
    $img['id'] = $item->id;
    $img['title'] = $item->title;
    $img['filename'] = PhocaGalleryFile::getTitleFromFile($item->filename, 1);
    $img['fileorigabs'] = PhocaGalleryFile::getFileOriginal($item->filename);
    return $img;
}