public function getListWithCounter($gid = null, $uid = null, $limit = null)
 {
     if ($gid !== null) {
         $gid = (int) $gid;
     } else {
         $gid = $this->gid;
     }
     $uid = (int) $uid;
     $offset = 0;
     $max = null;
     if (is_array($limit)) {
         // Due to permissions, we cannot use SQL limit
         // This will be possible when whe will have the
         // possibility to join the permission table and
         // the attachement table
         /*$qry .= sprintf(' LIMIT %d,%d',
           $limit['offset'],
           $limit['nb']);*/
         if (array_key_exists('offset', $limit)) {
             $offset = (int) $limit['offset'];
         }
         if (array_key_exists('nb', $limit)) {
             $max = (int) $limit['nb'];
         }
     }
     $dao =& PHPWikiAttachment::getDao();
     $dar =& $dao->getListWithCounterOrderedByRevDate($gid);
     $i = 0;
     $j = 0;
     // count viewable attch for offset
     $waArray = array();
     $stop = false;
     while (($row = $dar->getRow()) && !$stop) {
         if ($max !== null && $i >= $max) {
             $stop = true;
             break;
         }
         $wa = new PHPWikiAttachment($gid);
         $wa->setFromRow($row);
         // Check for user rights
         $isAllowedToSee = false;
         if (!$wa->permissionExist() || $wa->isAutorized($uid)) {
             if ($j >= $offset) {
                 $wa->setRevisionCounter($row['nb']);
                 $waArray[] =& $wa;
                 $i++;
             }
             $j++;
         }
         unset($wa);
     }
     return new ArrayIterator($waArray);
 }