I think it will be easy to make it work with OpenTibia, because all queries to database will be executed by new classes, not POT. These classes will be more compatible with TFS 0.2, 0.3, 0.4 then POT.Make it for OpenTibia SVN too
Today I finished and tested new class:
PHP:
<?PHP
class Link extends Errors
{
private $page = '';
private $parameters = array();
private $customParameters = array();
public function __construct($page = '', $parameters = array(), $custom_parameters = array())
{
if(isset($page))
$this->page = $page;
if(isset($parameters))
$this->parameters = $parameters;
if(isset($custom_parameters))
$this->customParameters = $custom_parameters;
}
public static function getURI()
{
static $URI;
if(!isset($URI))
$URI = Website::getInstance()->getURI();
return $URI;
}
public static function getUseRewrite()
{
static $useRewrite;
if(!isset($useRewrite))
$useRewrite = Website::getInstance()->getWebsiteConfig()->getValue('useRewrite');
return $useRewrite;
}
public function setPage(string $page)
{
$this->page = $page;
}
public function setParameters(Array $parameters)
{
$this->parameters = $parameters;
}
public function setCustomParameters(Array $custom_parameters)
{
$this->customParameters = $custom_parameters;
}
public function setParameter($number, $parameter = '')
{
$this->parameter[$number] = $parameter;
}
public function setCustomParameter($number, $custom_parameter = '')
{
$this->customParameter[$number] = $custom_parameter;
}
public function getPage()
{
return $this->page;
}
public function getParameters()
{
return $this->parameters;
}
public function getCustomParameters()
{
return $this->customParameters;
}
public function getParameter($number)
{
if(isset($this->parameter[$number]))
return $this->parameter[$number];
else
{
self::addError('#C-6', 'ERROR: Class::Link - getParameter(\$number) Param: <b>' . htmlspecialchars($number) . '</b>');
return false;
}
}
public function getCustomParameter($number)
{
if(isset($this->customParameter[$number]))
return $this->customParameter[$number];
else
{
self::addError('#C-7', 'ERROR: Class::Link - getCustomParameter(\$number) Param: <b>' . htmlspecialchars($number) . '</b>');
return false;
}
}
public function getString()
{
$ret = $this->getURI();
if($this->page == '')
$this->page = PAGE;
if($this->getUseRewrite())
{
$ret .= urlencode($this->page) . '/';
if(count($this->parameters) > 0)
{
foreach($this->parameters as &$value)
$value = urlencode($value);
$ret .= implode('/', $this->parameters);
}
$ret .= '/';
$tmp_params = array();
if(count($this->customParameters) > 0)
foreach($this->customParameters as $key => $value)
$tmp_params[] = urlencode($key) . '=' . urlencode($value);
if(!empty($tmp_params))
$ret .= '?' . implode('&', $tmp_params);
}
else
{
$tmp_params[] = 'page=' . urlencode($this->page);
$tmp_params = array();
if(count($this->parameters) > 0)
foreach($this->parameters as $key => $value)
$tmp_params[] = 'amp' . urlencode($key) . '=' . urlencode($value);
if(count($this->customParameters) > 0)
foreach($this->customParameters as $key => $value)
$tmp_params[] = urlencode($key) . '=' . urlencode($value);
if(!empty($tmp_params))
$ret .= '?' . implode('&', $tmp_params);
}
return $ret;
}
public function __toString()
{
return $this->getString();
}
}
?>
PHP:
echo new Link('acco +unt', array('log in')) . '<br>';
echo new Link('account', array('login')) . '<br>';
echo new Link('account', array('login')) . '<br>';