Location: PHPKode > scripts > Template Lite > template-lite/templite.php
<?
class templateadm {
	var $t = array();
	function templateadm($file) {
		$xdr = "";
		$tr = array('sta' => FALSE, 'name' => '');
		$f = file($file);
		foreach ($f as $l => $n) {
			if (isset($tr['sta']) and $tr['sta'] == TRUE and !eregi("^TEND",$n)) {
				$xdr .= $n;
			}
			elseif (eregi("^TEND",$n)) {
				$this->t[ eregi_replace("([^a-z0-9]+)","",$tr['name']) ] = $xdr;
				$tr['sta'] = FALSE;
				$xdr = "";
			}
			elseif (eregi("^TEMP (.+)",$n,$x)) {
				$tr['sta'] = TRUE;
				$tr['name'] = $x[1];
			}
		}
	}
	function generate_form($formname,$params, $array) {
		$this->generate_t("formtop", array('fname' => $formname, 'furl' => $params));
		foreach ($array as $a => $b) {
			if (is_array($b)) {
				if (eregi("hidden:",$b['value'])) $this->generate_t("formhidden",array('value' => str_replace("hidden:","",$b['value']), 'tname' => $a, 'tvt' => $b['fname'], 'hint' => $b['hint']));
				elseif (eregi("tarea:",$b['value'])) $this->generate_t("formta",array('value' => str_replace("tarea:","",$b['value']), 'tname' => $a, 'tvt' => $b['fname'], 'hint' => $b['hint']));
				elseif (eregi("tba:",$b['value'])) $this->generate_t("formtb",array('value' => str_replace("tba:","",$b['value']), 'tname' => $a, 'tvt' => $b['fname'], 'hint' => $b['hint']));
				else $this->generate_t("formline",array('tname' => $a, 'value' => $b['value'], 'tvt' => $b['fname'], 'hint' => $b['hint']));
			}
			else {
				$this->generate_t("formhidden",array('value' => str_replace("hidden:","",$b), 'tname' => $a));
			}
		}
		$this->generate_t("formbottom",array('fname' => $formname));
	}
	function generate_t($tname,$targ=array()) {
		if (!empty($this->t[ $tname ])) {
			$y = $this->t[ $tname ];
			foreach ($targ as $n => $l) $y = str_replace("^$n%",$l,$y);
		}
		else $y = "UnFound: $tname<br/>";
		echo $y;
	}
}
?>
Return current item: Template Lite