/**
  * gets the DB rows for all images and calls the HTML output function
  *
  */
 function Joom_ShowMinis()
 {
     $user =& JFactory::getUser();
     $mainframe =& JFactory::getApplication('site');
     // selected category
     $this->catid = $mainframe->getUserStateFromRequest('joom.button.catid', 'catid', 0, 'int');
     // pagination
     $limitstart = JRequest::getInt('limitstart', 0);
     $limit = $mainframe->getUserStateFromRequest('joom.button.limit', 'limit', 50, 'int');
     // ensure that image can be seen later on
     $where = "WHERE \n                   jgc.published = '1'\n                AND jgc.access  <= " . $user->get('aid') . "\n                AND jg.published = '1'\n                AND jg.approved  = '1'";
     if ($this->catid) {
         $where .= "\n                AND jg.catid = '" . $this->catid . "'";
         $this->catpath = Joom_getCatPath($this->catid);
     }
     // query
     $query = "  SELECT \n                  jg.id, \n                  jg.catid, \n                  jg.imgtitle, \n                  jg.imgthumbname, \n                  jgc.name \n                FROM \n                  #__joomgallery AS jg\n                LEFT JOIN \n                  #__joomgallery_catg AS jgc ON jgc.cid = jg.catid\n              " . $where;
     // execute the query if list_limit = 0 -> all pictures
     if ($limit == 0) {
         $this->_db->setQuery($query);
         $rows = $this->_db->loadObjectList();
         $total = count($rows);
     } else {
         // take the query and replace the 'select *' with 'select count(jg.id)' -> $querycount
         // to count total rows for navigation
         $countquery = str_replace('SELECT jg.id, jg.catid, jg.imgtitle, jg.imgthumbname, jgc.name', 'SELECT COUNT(id)', $query);
         $this->_db->setQuery($countquery);
         $total = $this->_db->loadResult();
         if ($total <= $limit) {
             $limitstart = 0;
         }
         $this->_db->setQuery($query, $limitstart, $limit);
         $rows = $this->_db->loadObjectList();
     }
     jimport('joomla.html.pagination');
     $this->_pagination = new JPagination($total, $limitstart, $limit);
     Joom_ShowMiniJoom_HTML::Joom_ShowMinis_HTML($rows);
 }