<?php
/**
* @category Anahita Social Engineâ¢
* @copyright Copyright (C) 2008 - 2010 rmdStudio 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
*/
class AnahitaLoaderAdapter extends KLoaderAdapterAbstract
{
/**
* The prefix
*
* @var string
*/
protected $_prefix = 'An';
/**
* Get the class prefix
*
* @return string Returns the class prefix
*/
public function getPrefix()
{
return $this->_prefix;
}
protected function _pathFromClassname($classname)
{
$path = false;
$word = preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $classname);
$parts = explode('_', $word);
// If class start with a 'K' it is a Koowa framework class and we handle it
if(array_shift($parts) == 'An')
{
$package = array_shift($parts);
$this->_setBasePath($package);
$basepath = $this->_basepath;
$path = strtolower(implode(DS, $parts));
if(count($parts) == 1) {
$path = $path.DS.$path;
}
if(!is_file($basepath.DS.$path.'.php')) {
$path = $path.DS.strtolower(array_pop($parts));
}
$path = $basepath.DS.$path.'.php';
}
return $path;
}
/**
* Get the path based on an identifier
*
* @param object An Identifier object - lib.joomla.[.path].name
* @return string|false Returns the path on success FALSE on failure
*/
protected function _pathFromIdentifier($identifier)
{
$path = false;
if($identifier->type == 'lib' && $identifier->package == 'anahita')
{
$path = $identifier->path;
$package = array_shift($path);
$this->_setBasePath( $package );
$path = implode(DS,$path);
if(!empty($identifier->name)) {
$path .= DS.$identifier->name;
}
$path = $this->_basepath.DS.$path.'.php';
}
return $path;
}
protected function _setBasePath($package)
{
$this->_basepath = dirname(__FILE__).DS.strtolower($package);
}
//end class
}