<?php
/**
* PWF Path object
* @copyright Copyright (c) 2012, PWF
* @license http://phpwebframework.com/License
* @version PWF_0.3.0
*/
class _Core_Path
{
/**
* The server's path of the directory where index.php is
* @var string
*/
private $publicPath;
/**
* The root url of the application (where the index.php is)
* @var string
*/
private $rootUrl;
/**
* The url after the current Controller url delimited by "/" into array.
* @var array
*/
private $pathVars;
/**
* The url after the root url
* @var string
*/
private $afterRootUrl;
/**
* The class name of the current controller
* @var string
*/
private $controllerClass;
/**
* The url of the current controller (after the root url)
* @var string
*/
private $controllerUrl;
/**
* The part after the first dot (if any) of the current controller in url
* @var string
*/
private $controllerExtension;
/**
* The path of the current controller (it may differ to controllerUrl if PATH_MAPS have been used)
* @var string
*/
private $controllerPath;
public function __construct($publicPath,$rootUrl,$pathVars,$afterRootUrl,$controllerClass,$controllerPath,$controllerUrl,$controllerExtension)
{
$this->publicPath = $publicPath;
$this->rootUrl = $rootUrl;
$this->pathVars = $pathVars;
$this->afterRootUrl = $afterRootUrl;
$this->controllerClass = $controllerClass;
$this->controllerPath = $controllerPath;
$this->controllerUrl = $controllerUrl;
$this->controllerExtension = $controllerExtension;
}
/**
* The url of the current controller (after the root url)
* @return string
*/
public function getControllerUrl()
{
return $this->controllerUrl;
}
/**
* The class name of the current controller
* @return string
*/
public function getControllerClass()
{
return $this->controllerClass;
}
/**
* The path of the current controller (it may differ to controllerUrl if PATH_MAPS have been used)
* @return string
*/
public function getControllerPath()
{
return $this->controllerPath;
}
/**
* The url after the root url
* @return string
*/
public function getAfterRootUrl()
{
return $this->afterRootUrl;
}
/**
* The server's path of the directory where index.php is
* @return string
*/
public function getPublicPath()
{
return $this->publicPath;
}
/**
* Returns if in the array of the url after the current Controller url delimited by "/"
* is and index same with one provided
* @param integer $index
*/
public function containsVar($index)
{
return isset($this->vars[$index]);
}
/**
* The url after the current Controller url delimited by "/" into array.
* @return array
*/
public function getVars()
{
return $this->pathVars;
}
/**
* Returns if in the array of the url after the current Controller url delimited by "/"
* is an index same with one provided the value of that else null.
* @param unknown_type $index
* @return Ambigous <NULL, multitype:>
*/
public function getVar($index)
{
return isset($this->pathVars[$index])?$this->pathVars[$index]:null;
}
/**
* Returns if there is defined array of the url after the current Controller url delimited by "/"
* @return boolean
*/
public function hasVars()
{
return count($this->pathVars) > 0;
}
/**
* Return the size of the array of the url after the current Controller url delimited by "/"
* @return number
*/
public function getVarsSize()
{
return count($this->pathVars);
}
/**
* The root url of the application (where the index.php is)
* @return string
*/
public function getRootUrl()
{
return $this->rootUrl;
}
}
?>