Code Search for Developers
 
 
  

form.php from ECP (EliteCore Project) at Krugle


Show form.php syntax highlighted

<?php
interface FormObject {
	public function getID();
	public function generate();
}

abstract class FormInput implements FormObject {
	const TEXT = 1;
	const HIDDEN = 2;
	const SUBMIT = 3;
	const CHECKBOX = 4;
	const BUTTON = 5;
	const DATEPICKER = 6;

	protected $id = false;
	protected $name = false;
	protected $label = '&nbsp;';
	protected $value = false;
	protected $type = false;

	public function __construct($id) {
		$this->id = $id.'_'.FormManager::getID();
		$this->name = $id;
		$this->type = self :: TEXT;
	}

	public function getID() {
		return $this->id;
	}
	public function setLabel($label) {
		$this->label = $label;
	}

	public function setValue($value) {
		$this->value = $value;
	}

	public function setType($type) {
		$this->type = $type;
	}

	public function generate() {
		exit ("NOT IMPLEMENTED!");
	}

}

class FormSelect_Option {
	private $name = false;
	private $value = false;

	public function __construct($value, $name = false) {
		$this->name = $name;
		$this->value = $value;
	}

	public function getName() {
		return $this->name;
	}

	public function getValue() {
		if ($this->value === false)
			return $this->name;
		else
			return $this->value;
	}
}

abstract class FormSelect implements FormObject {
	protected $id = false;
	protected $name = false;
	protected $label = '&nbsp;';
	protected $options = array ();
	protected $selectedOption = false;

	public function __construct($id) {
		$this->id = $id.'_'.FormManager::getID();
		$this->name = $id;
	}

	public function getID() {
		return $this->id;
	}
	public function setLabel($label) {
		$this->label = $label;
	}

	public function selectedValue($value) {
		$this->selectedOption = $value;
	}

	public function isSelected($value) {
		if ($value == $this->selectedOption)
			return true;
		else
			return false;
	}

	public function addOption($value, $name = false) {
		$this->options[] = new FormSelect_Option($value, $name);
	}

	public function setType($type) {
		if ($type == self :: TEXT || $type == self :: HIDDEN || $type == self :: SUBMIT) {
			$this->type = $type;
		} else {
			$this->type = self :: TEXT;
		}
	}

	public function generate() {
		exit ("NOT IMPLEMENTED!");
	}

	public function generateOptions() {
		exit ("NOT IMPLEMENTED!");
	}

}
abstract class Form {
	const GET = 1;
	const POST = 2;

	protected $label = false;
	protected $method = false;
	protected $action = false;
	protected $submitButtonValue=false;
	protected $objects = array ();
	protected $id=0;

	public function __construct($label, $action = false, $method = false) {
		global $XCS;
		$thid->id=FormManager::createForm();
		$this->label = $label;
		$this->setAction($action);
		$this->setSubmitButtonValue($XCS->localeString("form", "submit"));
		if ($method === false || $method == self :: POST)
			$method = self :: POST;
		else
			$method = self :: GET;
		$this->method = $method;
	}

	public function setSubmitButtonValue($value) {
		$this->submitButtonValue=$value;
	}
	public function getSubmitButtonValue() {
		return $this->submitButtonValue;
	}

	protected function setAction($action) {
		$this->action = $action;
	}

	public function objectIDExists($id) {
		foreach ($this->objects as $object) {
			if ($object->getID() == $id)
				return true;
		}
		return false;
	}

	protected function addObject($id, $object) {
		$id .= '_'.FormManager::getID();
		if ($this->objectIDExists($id))
			return false;
		$this->objects[] = $object;
		return $object;
	}
	public function addRawOutput($rawOutput) {
		return $this->addObject($rawOutput, new FormRawOutput($rawOutput));
	}

	protected function generateHeader() {
		return '';
	}

	protected function generateFooter() {
		return '';
	}

	public function generate() {
		$output = $this->generateHeader();
		foreach ($this->objects as $object) {
			$output .= $object->generate();
		}
		$output = $output.$this->generateFooter();
		// get nice output with tabs etc.
		$output = String::cleanXHTML($output);
		return $output;
	}

}

class FormManager {
	public static $id=0;

	public static function getId() {
		return self::$id;
	}
	public static function createForm() {
		self::$id++;
		return self::$id-1;
	}
}

class FormRawOutput implements FormObject {
	protected $rawOutput = false;
	protected $id;

	public function __construct($rawOutput) {
		$this->id = String::getRandomWord(3).'_'.FormManager::getID();
		$this->rawOutput = $rawOutput;
	}
	public function generate() {
		return $this->rawOutput;
	}
	public function getID() {
		return $this->id;
	}
}

?>



See more files for this project here

ECP (EliteCore Project)

EliteCore Project is a PHP5.1/Javascript/AJAX/XHTML/CSS framework for creating WEB 2.0 applications and services.The basic open-source instalation can be also used as an interactive personal page or BLOG.This project uses the latest features available.

Project homepage: http://sourceforge.net/projects/elitecore
Programming language(s): JavaScript,PHP,XML
License: cpl

  encryption.php
  form.php
  module_class.php
  session_interface.php