Location: PHPKode > projects > Anahita Social Engine > dependencies/plg_system_socialengine/socialengine/util/storage/adapter/abstract.php
<?php 
/**
* @version	0.93
* @category	Anahita Plugin
* @package	File
* @copyright	Copyright (C) 2007 - 2009 rmd Studio Inc. and Peerglobe Technology Inc. All rights reserved.
* @license	GNU GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
* @link http://www.anahitapolis.com
*/

abstract class AnUtilStorageAdapterAbstract extends KObject
{
	protected $_options;
	
	public function __construct($options = array())
	{
		if ( !isset($options['root_folder']) ) {
			$options['root_folder'] = 'anahita_assets';
		}
		
		$this->_options = $options;
	}
	
	/**
	 * reads the content of a file given its path
	 * @return string
	 * @param  $path string
	 */
	public function read($path, $public = true)
	{
		$path = $this->_appendPath($path, $public);
		return $this->_read($path);
	}

	public function write($path, $data, $public = true)
	{
		$path = $this->_appendPath($path, $public);
		$this->_write($path, $data, $public);
	}
	
	public function delete($path, $public = true)
	{
		$path = $this->_appendPath($path, $public);	
		$this->_delete($path);
	}
	
	public function exists($path, $public = true)
	{
		$path = $this->_appendPath($path, $public);	
		return $this->_exists($path);
	}
	
	public function getUrl($path, $public = true)
	{	
		$path = $this->_appendPath($path, $public);
		return $this->_getUrl($path);
	}
	
	protected function _appendPath($path, $public)
	{
		return $this->getOption('root_folder').'/'.($public ? "public/$path" : "private/$path");
	}
	
	public function getOption($key, $default = null)
	{		
		return isset($this->_options[$key]) ? $this->_options[$key] : $default;
	}
		
	abstract protected function _read($path);
	
	abstract protected function _write($path, $data, $public);
	
	abstract protected function _delete($path);
	
	abstract protected function _exists($path);			
	
	abstract protected function _getUrl($path);

}
Return current item: Anahita Social Engine