singapore: the smallest big galery
home » forum » Mods » Auto Reindex - find images uploaded by FTP automatically

You are not logged in.

  • Index
  •  » Mods
  •  » Auto Reindex - find images uploaded by FTP automatically

#1 2010-01-11 13:47:38

tamlyn
Lead Developer

Auto Reindex - find images uploaded by FTP automatically

This mod automatically scans the number of image files in an album each time it is viewed. If the number is different from the number stored in the database then it triggers a reindex for that album.

I don't know why I didn't make this the default behaviour.

This mod requires some basic PHP knowledge and should take no more than 10 minutes. I haven't measured the performance implications but they should be pretty small for most galleries.

You may want to combine this with the delete images on reindex mod for proper synchronisation between database and file system.

First, open includes/admin.class.php and find the the reindexGallery() method (around line 930). Cut and paste the method into includes/singapore.class.php. Paste it in just before the closing brace. This doesn't change anything because the sgAdmin class inherits from the Singapore class but it allows the next part of the mod to work.

However you need to modify the reindexGallery() method just a little. Change the last line of the method from

Code:

return $this->pushError($this->translator->_g("Could not save gallery info"));

to simply

Code:

return false;

Next find the method selectGallery() in includes/singapore.class.php around line 200. Just before where it says //check if gallery was successfully insert the following:

Code:

    $dir = Singapore::getListing($this->config->base_path.$this->config->pathto_galleries.$galleryId."/", $this->config->recognised_extensions);    
    if (count($dir->files) != count($this->gallery->images)) {
        if ($this->reindexGallery($galleryId)) {
            echo 'hello!';
        }
        $this->gallery = $this->io->getGallery($galleryId, $this->gallery->parent, 1);
    }

That's it! Try adding, moving, deleting or renaming images using FTP and the changes should be visible immediately on the web.

Caveat: any extra info associated with the image such as a description or artist name will be lost if the image is moved or renamed.

Offline

 

#2 2010-01-20 01:56:41

DC
Administrator

Re: Auto Reindex - find images uploaded by FTP automatically

Very cool mod Tam, I will have to test it when I get some time.
Submit more mods when you can I would like to build this section up. I am sure you have seen the mods I have added as well.

DC


To code or not to code that is the question?

Did my response help you out? Consider donating by buying me a slice, Whats this? Read More!
http://www.clickcraft.net/slice.php

Offline

 
  • Index
  •  » Mods
  •  » Auto Reindex - find images uploaded by FTP automatically