}
if ($view == 'all' || $view == 'prettythumb') {
-
- /* No need to try to delete a hash we already removed */
- $deleted = array();
-
- /* Need to generate hashes for each possible style */
- // @TODO: Need to save the style hash to the share entry
- // since we don't require the use of predefined
- // style definitions now.
$styles = Horde::loadConfiguration('styles.php', 'styles', 'ansel');
- foreach ($styles as $style)
+ $hashes = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getHashes();
+ foreach ($hashes as $hash)
{
- $hash = md5($style['thumbstyle'] . '.' . $style['background']);
- if (empty($deleted[$hash]))
- {
- $GLOBALS['injector']->getInstance('Horde_Vfs')->getVfs('images')->deleteFile(
- $this->getVFSPath($hash), $this->getVFSName($hash));
- $deleted[$hash] = true;
- }
+ $GLOBALS['injector']->getInstance('Horde_Vfs')
+ ->getVfs('images')
+ ->deleteFile($this->getVFSPath($hash), $this->getVFSName($hash));
}
}
} catch (VFS_Exception $e) {}
return implode(', ', $fields);
}
+ /**
+ * Ensure the style hash is recorded in the database.
+ *
+ * @param string $hash The hash to record.
+ *
+ * @return void
+ */
+ public function ensureHash($hash)
+ {
+ $query = $this->_db->prepare('SELECT COUNT(*) FROM ansel_hashes WHERE style_hash = ?');
+ $results = $query->execute($hash);
+ if ($results instanceof PEAR_Error) {
+ throw new Ansel_Exception($results->getMessage());
+ }
+ if (!$results->fetchOne()) {
+ $query = $this->_db->prepare('INSERT INTO ansel_hashes (style_hash) VALUES(?)');
+ $results = $query->execute($hash);
+ if ($results instanceof PEAR_Error) {
+ throw new Ansel_Exception($results->getMessage());
+ }
+ }
+ }
+
+ /**
+ * Get a list of all known styleHashes.
+ *
+ * @return array An array of style hashes.
+ */
+ public function getHashes()
+ {
+ $hashes = $this->_db->query('SELECT style_hash FROM ansel_hashes;');
+ }
+
}
}
+ // Make sure that the style hash is recorded, ignoring non-styled thumbs
+ if ($style->thumbstyle != 'Thumb') {
+ $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->ensureHash($gallery->getViewHash('prettythumb'));
+ }
+
// Clear the OtherGalleries widget cache
if ($GLOBALS['conf']['ansel_cache']['usecache']) {
$GLOBALS['injector']->getInstance('Horde_Cache')->expire('Ansel_OtherGalleries' . $gallery->get('owner'));