/**
  *
  * Classical URI:
  * URI: /wiki/uploads/102/php-mode-1.1.0.tgz/1
  * <pre>
  * Array
  * (
  *    [0] =>
  *    [1] => plugins
  *    [2] => phpwiki               Service
  *    [3] => uploads               Call script
  *    [4] => 102                   Group id
  *    [5] => php-mode-1.1.0.tgz    Attachment
  *    [6] => 1                     Revision of attachement (optionnal)
  * )
  * </pre>
  * Important note: '[6] => 0' == '[6] => ""' == last version
  *
  *
  * URI: /wiki/uploads/102/1/php-mode-1.1.0.tgz
  * This URI format is requested in order to support InterWiki links.
  * <pre>
  * Array
  * (
  *    [0] =>
  *    [1] => plugins
  *    [2] => phpwiki               Service
  *    [3] => uploads               Call script
  *    [4] => 102                   Group id
  *    [5] => 1                     Revision of attachement
  *    [6] => php-mode-1.1.0.tgz    Attachment
  * )
  * </pre>
  *
  * @access public
  * @param  string $uri Uri to access to attachment
  */
 public function setUri($uri = "")
 {
     $uriExp = explode('/', $uri);
     $this->setGid($uriExp[4]);
     if (is_numeric($uriExp[5])) {
         $rev = (int) $uriExp[5];
         // Take care of possible arguments (if sth like '?' or '&' CUT!)
         if (preg_match('/([^&\\?]*)(\\?|&)/', $uriExp[6], $matches)) {
             $filename = $matches[1];
         } else {
             $filename = $uriExp[6];
         }
         $this->setFilename(urldecode($filename));
     } else {
         // Take care of possible arguments (if sth like '?' or '&' CUT!)
         if (preg_match('/([^&\\?]*)(\\?|&)/', $uriExp[5], $matches)) {
             $filename = $matches[1];
         } else {
             $filename = $uriExp[5];
         }
         $this->setFilename(urldecode($filename));
         // @TODO: prevent usage of '?' and '&' as behind. But with a
         // generical functions, in utils.php for instance.
         if (isset($uriExp[6]) && is_numeric($uriExp[6])) {
             $rev = (int) $uriExp[6];
         } else {
             $rev = $this->count();
         }
     }
     $rev -= 1;
     $this->revision = new PHPWikiAttachmentRevision();
     $this->revision->setGid($this->gid);
     $this->revision->setAttachmentId($this->getId());
     $this->revision->setRevision($rev);
     $this->revision->dbFetch();
     $this->revision->log(user_getid());
 }