Location: PHPKode > projects > FarODP > farodp/includes/common/functions.php
<?php

class Action {
	var $action;
	
	function Action()
	{
	
	}

	function setAction($action)
	{
	   	$this->action = $action;
	}
	
	function getActions()
	{
	    return $this->action;
	}
	
	function getAction()
	{
	    return $this->action;
	}
	
	function hasAction($action) {
		return in_array($action, $this->action);
	}
}

if (!function_exists('htmlspecialchars_decode')) {
	function htmlspecialchars_decode($string,$style=ENT_COMPAT)
	{
	    $translation = array_flip(get_html_translation_table(HTML_SPECIALCHARS,$style));
	    if($style === ENT_QUOTES){ $translation['&#039;'] = '\''; }
	    return strtr($string,$translation);
	}
}

function dehtml($str) {
	return htmlspecialchars_decode($str);
}

function enhtml($str) {
	return htmlspecialchars($str);
}

function canonicalizePath($cat)
{
	$string = '';

	$cat = trim($cat, '/');

	for ($i = 0, $count = strlen($cat); $i < $count; $i++)
	{
		if (!($cat{$i} == '/' && (!isset($cat{$i+1}) || $cat{$i+1} == '/')))
		{
			$string .= $cat{$i};
		}
	}

	return $string;
}

function catURL($cat)
{
	return implode('/', array_map('urlencode', str_replace(' ', '_', $cat))) . '/';
}

function catPath($cat)
{
	return implode('/', str_replace(' ', '_', $cat));
}

function urlCat($cat)
{
	$cats = str_replace('_', ' ', array_map('urldecode', explode('/', canonicalizePath($cat))));
	
	if ($cats[0] == '') // explode() returns a zero array when it doesn't explode
	{
	    return array();
	}
	
	return $cats;
}

function pathCat($cat)
{
	$cats = str_replace('_', ' ', explode('/', canonicalizePath($cat)));

	if ($cats[0] == '') // explode() returns a zero array when it doesn't explode
	{
	    return array();
	}

	return $cats;
}

function readTpl($tpl)
{
	$fp = fopen('templates/' . $tpl . '.tpl', 'r');
	$content = fread($fp, filesize('templates/' . $tpl . '.tpl'));
	fclose($fp);
	return $content;
}

?>
Return current item: FarODP