Code suggenstion

adventure
adventure's picture

Joined: 2004-03-21
Posts: 59
Posted: Wed, 2004-04-28 20:09

Before i make some complain. Gallery is great ;-)

There are some calls in gallery which are not nessarcy.

good example 1.4.3

    
Album classe file:

function getPhotoId($index) {
                $photo = $this->getPhoto($index);
                return $photo->getPhotoId($this->getAlbumDirURL("full"));
}

Albumitem class file:

function getPhotoId($dir) {
                if ($this->image) {
                        return $this->image->getId($dir);
                } else {
                        return "unknown";
                }
}

Image class file:

function getId($dir) {
                return $this->name;
}

As you can see the argument made in album is pointless.

I made a smart mirror system which does a lot in getAlbumDirURL().
Don't say "full" if you only need a number or something like that. I believe that you should only call the methode with a argument when you really intent to show the picture. Else my mirror engine does not what is going on.

In my version I changed some code to "real_full"

All methode like this need to be checked.

I volunteer for this job.

Login or register to post comments
h0bbel
h0bbel's picture

Joined: 2002-07-28
Posts: 13452
Posted: Wed, 2004-04-28 21:24

adventure, i'll forward this to the developers. BUT, you really should pop into IRC #gallery on freenode.net - I'm sure you will be very welcome!! :)

Login or register to post comments
signe
signe's picture

Joined: 2003-07-27
Posts: 2322
Posted: Wed, 2004-04-28 21:38
adventure wrote:
As you can see the argument made in album is pointless.

I made a smart mirror system which does a lot in getAlbumDirURL().
Don't say "full" if you only need a number or something like that. I believe that you should only call the methode with a argument when you really intent to show the picture. Else my mirror engine does not what is going on.

In my version I changed some code to "real_full"

All methode like this need to be checked.

I volunteer for this job.

       function getAlbumDirURL($type) {
                global $gallery;

                if (!empty($this->transient->mirrorUrl)) {
                        return $this->transient->mirrorUrl;
                }

                $albumPath = "/".urlencode ($this->fields['name']);

                /* 
                 * Highlights are typically shown for many albums at once,
                 * and it's slow to check each different album just for one
                 * image.  Highlights are also typically pretty small.  So,
                 * if this is for a highlight, don't mirror it.
                 */
                if ($gallery->app->feature["mirror"] &&
                    strcmp($type, "highlight")) {
                        foreach(split("[[:space:]]+", $gallery->app->mirrorSites) as $base_url) {
                                $base_url .= $albumPath;
                                $serial = $base_url . "/serial.{$this->fields['serial_number']}.dat";

                                /* Don't use fs_fopen here since we're opening a url */
                                if ($fd = @fopen($serial, "r")) {
                                        $serialContents = fgets($fd, strlen($this->tsilb)+1);
                                        if (!strcmp($serialContents, $this->tsilb)) {
                                                $this->transient->mirrorUrl = $base_url;
                                                return $this->transient->mirrorUrl;
                                        }
                                }
                        }

                        /* All mirrors are out of date */
                        $this->transient->mirrorUrl =
                                $gallery->app->albumDirURL . $albumPath;
                        return $this->transient->mirrorUrl;
                }

                return $gallery->app->albumDirURL . $albumPath;
        }

If you notice, however, the only $type which actually does anything special is "highlight", and only if mirroring is also enabled.

Passing "full" may not be accurate, since it's completely ignored, but it doesn't do anything different.

Login or register to post comments
adventure
adventure's picture

Joined: 2004-03-21
Posts: 59
Posted: Thu, 2004-04-29 07:50

signe, only when mirror is active and it is NOT a highlight.

(strcmp return 0 if it's equal. )

With my smart mirror patch I do load balancing. So every call should get a different mirror.

And when the are calls which do not really show the image. The solution becomes crap.

So an argument should tell the methode wheter it's a real going to show.

Login or register to post comments
adventure
adventure's picture

Joined: 2004-03-21
Posts: 59
Posted: Thu, 2004-04-29 07:53

h0bbel, i will join IRC this evening/night. Thanks for inviting :-)

Login or register to post comments
h0bbel
h0bbel's picture

Joined: 2002-07-28
Posts: 13452
Posted: Thu, 2004-04-29 08:19

adventure, great! Looking forward to talking to you. :)

Login or register to post comments