}
/**
- * Create and initialize the VFS object
- *
- * @return VFS object.
- */
- static public function getVFS()
- {
- // @TODO: need to refactor the Vfs binder to a factory so we can handle
- // vfs objects for different scopes.
- $v_params = Horde::getVFSConfig('images');
- return VFS::singleton($v_params['type'], $v_params['params']);
- }
-
- /**
* Return a string containing an <option> listing of the given
* gallery array.
*
// Create db, share, and vfs instances.
$GLOBALS['ansel_db'] = Ansel::getDb();
$GLOBALS['ansel_storage'] = new Ansel_Storage();
- $GLOBALS['ansel_vfs'] = Ansel::getVFS();
+ $GLOBALS['ansel_vfs'] = $GLOBALS['injector']->getInstance('Horde_Vfs')->getVfs('images');
// Get list of available styles for this client.
$GLOBALS['ansel_styles'] = Ansel::getAvailableStyles();
}
/**
- * Load VFS Backend
- *
- * @throws Horde_Exception
- */
- protected function _loadVFS()
- {
- $v_params = Horde::getVFSConfig('images');
- try {
- return VFS::singleton($v_params['type'], $v_params['params']);
- } catch (VFS_Exception $e) {
- return PEAR::raiseError($e->getMessage());
- }
- }
-
- /**
* Store image
*
* @param string $file Image file
{
global $conf;
- try {
- $vfs = $this->_loadVFS();
- if ($vfs instanceof PEAR_Error) {
- return $vfs;
- }
-
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs')->getVfs('images');
$p = hash('md5', $user);
$vfspath = Folks::VFS_PATH . '/' . substr(str_pad($p, 2, 0, STR_PAD_LEFT), -2) . '/';
$vfs_name = $p . '.' . $conf['images']['image_type'];
*/
public function deleteImage($user)
{
- $vfs = $this->_loadVFS();
- if ($vfs instanceof PEAR_Error) {
- return $vfs;
- }
-
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs')->getVfs('images');
$p = hash('md5', $user);
$vfspath = Folks::VFS_PATH . '/' . substr(str_pad($p, 2, 0, STR_PAD_LEFT), -2) . '/';
$vfs_name = $p . '.' . $GLOBALS['conf']['images']['image_type'];
}
/**
- * Load VFS Backend
- *
- * @throws Horde_Exception
- * @throws VFS_Exception
- */
- static public function loadVFS()
- {
- static $vfs;
-
- if ($vfs) {
- return $vfs;
- }
-
- $v_params = Horde::getVFSConfig('images');
- return VFS::singleton($v_params['type'], $v_params['params']);
- }
-
- /**
* Store image
*
* @param $id Image owner record id
{
global $conf;
- $vfs = self::loadVFS();
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs')->getVfs('images');
$vfspath = self::VFS_PATH . '/images/' . $type;
$vfs_name = $id . '.' . $conf['images']['image_type'];
*/
static public function deleteImage($id)
{
- $vfs = self::loadVFS();
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs')->getVfs('images');
$vfs_name = $id . '.' . $GLOBALS['conf']['images']['image_type'];
$vfs->deleteFile(self::VFS_PATH . '/images/news/full', $vfs_name);
$vfs->deleteFile(self::VFS_PATH . '/images/news/small', $vfs_name);
*/
static public function saveFile($file_id, $file_src)
{
- $vfs = self::loadVFS();
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs')->getVfs('images');
$vfs->writeData(self::VFS_PATH . '/files/', $file_id, file_get_contents($file_src), true);
}
*/
static public function getFile($file_id)
{
- $vfs = self::loadVFS();
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs')->getVfs('images');
$vfs->read(self::VFS_PATH . '/files/', $file_id);
}
*/
static public function deleteFile($file_id)
{
- $vfs = self::loadVFS();
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs')->getVfs('images');
if ($vfs->exists(self::VFS_PATH . '/files/', $file_id)) {
$vfs->deleteFile(self::VFS_PATH . '/files/', $file_id);
}
if ($this->_vfs->exists(TURBA_VFS_PATH, $this->getValue('__uid'))) {
return $this->_vfs->listFolder(TURBA_VFS_PATH . '/' . $this->getValue('__uid'));
}
- } catch (VFS_Exception $e) {}
+ } catch (Turba_Exception $e) {}
return array();
}
{
if (!isset($this->_vfs)) {
try {
- $v_params = Horde::getVFSConfig('documents');
+ $this->_vfs = $GLOBALS['injector']->getInstance('Horde_Vfs')->getVfs('documents');
} catch (Horde_Exception $e) {
throw new Turba_Exception($e);
}
-
- try {
- $this->_vfs = VFS::singleton($v_params['type'], $v_params['params']);
- } catch (VFS_Exception $e) {
- throw new Turba_Exception($e);
- }
}
}
}
try {
- $v_params = Horde::getVFSConfig('documents');
+ $vfs = $GLOBALS['injector']->getInstance('Horde_Vfs')->getVfs('documents');
} catch (Horde_Exception $e) {
throw new Turba_Exception($e);
}
-try {
- $vfs = VFS::singleton($v_params['type'], $v_params['params']);
-} catch (VFS_Exception $e) {
- throw new Turba_Exception($e);
-}
try {
$data = $vfs->read(TURBA_VFS_PATH . '/' . $object->getValue('__uid'), $filename);