Location: PHPKode > projects > phpDocMaker > Utils/functions.php
<?

	// a set of usefull functions

if(!isset($functionF))
{

	$functionF=1;


	function dispDebug($txt)
	{
		global $debug;
		if($debug)
			echo "<b>Debug:</b> $txt<br>\n";
	}

	function htmlHead($title="phpDocParser",$style="")
	{
	?>
	<html>
	<head>
	<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<META NAME="Author" CONTENT="phpDocParser">
	<?
	if($style!="")
		echo "$style";

		echo "<title>$titre</title>\n</head>";
		if(isset($bgImage) && $bgImage !="")
			$bg="background='$bgImage'";
		echo "<body text=#000000 bgcolor=#FFFFFF $bg>";


	}

	function parseDescription($descr,$connection)
	{
		$descr=parseDescForLink($descr,$connection);
		$descr=parseDescForInclude($descr);

		return $descr;
	}

	function parseDescForLink($descr,$connection)
	{
		global $templateDir,$phpDocParserDir;
		require($phpDocParserDir."Parser/balise.def");

		$strBegin="$beginTag link:";

		$Bbeg=strPos($descr,$strBegin,0);
		while(is_integer($Bbeg))
		{
			$Bend=strPos($descr,$endTag,$Bbeg+strLen($strBegin));
			$beginDescr=subStr($descr,0,$Bbeg); //extract all text before tag
			if(is_integer($Bend))
			{
				$beginSub=$Bend+strLen($endTag);
				$lengthSub=strLen($descr)-$beginSub;
				$endDescr=substr($descr,$beginSub,$lengthSub); // extract all text after
				$beginSub=$Bbeg+strLen($strBegin);
				$lengthSub=$Bend-$beginSub;
				$tag=subStr($descr,$beginSub,$lengthSub); // extract the tag param
				list($type,$name)=explode(":",$tag);
				$type=trim($type);
				$name=trim($name);

				$link="";
				$req="select * from $type where name='$name'";
				if($res=mysql_fetch_object(ExecRequest($req,$connection)))
				{
					eval("\$id=\$res->id_$type;");
					$link=" <a href='genDisp.php?type=$type&id=$id' style=\"color:#0000FF\">$res->name</a> ";
				}
				else
					$link=" <font style=\"color:#0000FF\">$name</font> ";
				$descr=$beginDescr.$link.$endDescr;

			}
			else
			{
				$beginSub=$Bbeg+strLen($strBegin);
				$lengthSub=strLen($descr)-$beginSub;
				$endDescr=substr($descr,$beginSub,$lengthSub); // extract all text after
				$descr=$beginDescr.$endDescr;
			}
			$Bbeg=strPos($descr,$strBegin,0);
		}

		return $descr;

	}

	function parseDescForInclude($descr)
	{
		global $templateDir,$phpDocParserDir;
		require($phpDocParserDir."Parser/balise.def");

		$strBegin="$beginTag include:";

		$Bbeg=strPos($descr,$strBegin,0);
		while(is_integer($Bbeg))
		{
			$Bend=strPos($descr,$endTag,$Bbeg+strLen($strBegin));
			$beginDescr=subStr($descr,0,$Bbeg); //extract all text before  tag
			if(is_integer($Bend))
			{
				$beginSub=$Bend+strLen($endTag);
				$lengthSub=strLen($descr)-$beginSub;
				$endDescr=substr($descr,$beginSub,$lengthSub); // extract all text after
				$beginSub=$Bbeg+strLen($strBegin);
				$lengthSub=$Bend-$beginSub;
				$tag=subStr($descr,$beginSub,$lengthSub); // extract the tag param

				if(file_exists($tag))
					$include=implode(file($tag),"\n");
				else
					$include=" <font style=\"color:#0000FF\">bad file name</font> ";


				$descr=$beginDescr.$include.$endDescr;

			}
			else
			{
				$beginSub=$Bbeg+strLen($strBegin);
				$lengthSub=strLen($descr)-$beginSub;
				$endDescr=substr($descr,$beginSub,$lengthSub); // extract all text after
				$descr=$beginDescr.$endDescr;
			}
			$Bbeg=strPos($descr,$strBegin,0);
		}

		return $descr;

	}

	function displayTxt ($m)
	{
		$nb=strLen($m);
		$str="";
		for ($i=0;$i<$nb;$i++)
		{
			if ($m[$i]=="\n")
			{
				$str.= "<BR>";
			}
			else
			{
				$str.= $m[$i];
			}
		}
		return $str;
	}

	function plurWord($str)
	{
		$endChr=$str[strLen($str)-1];
		if($endChr != "s" && $endChr != "z")
			$str.="s";
		return $str;
	}

}
?>
Return current item: phpDocMaker