Added Donns Fix for gain mill and bakery
[travianx.git] / GameEngine / Form.php
blob81dd49e517e1dc6238ca0451b4dfdf8aa5dc775e
1 <?php
3 #################################################################################
4 ## -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =- ##
5 ## --------------------------------------------------------------------------- ##
6 ## Filename Form.php ##
7 ## License: TravianX Project ##
8 ## Copyright: TravianX (c) 2010-2011. All rights reserved. ##
9 ## ##
10 #################################################################################
12 class Form {
14 private $errorarray = array();
15 public $valuearray = array();
16 private $errorcount;
18 public function Form() {
19 if(isset($_SESSION['errorarray']) && isset($_SESSION['valuearray'])) {
20 $this->errorarray = $_SESSION['errorarray'];
21 $this->valuearray = $_SESSION['valuearray'];
22 $this->errorcount = count($this->errorarray);
24 unset($_SESSION['errorarray']);
25 unset($_SESSION['valuearray']);
27 else {
28 $this->errorcount = 0;
32 public function addError($field,$error) {
33 $this->errorarray[$field] = $error;
34 $this->errorcount = count($this->errorarray);
37 public function getError($field) {
38 if(array_key_exists($field,$this->errorarray)) {
39 return $this->errorarray[$field];
41 else {
42 return "";
46 public function getValue($field) {
47 if(array_key_exists($field,$this->valuearray)) {
48 return $this->valuearray[$field];
50 else {
51 return "";
55 public function getDiff($field,$cookie) {
56 if(array_key_exists($field,$this->valuearray) && $this->valuearray[$field] != $cookie) {
57 return $this->valuearray[$field];
59 else {
60 return $cookie;
64 public function getRadio($field,$value) {
65 if(array_key_exists($field,$this->valuearray) && $this->valuearray[$field] == $value) {
66 return "checked";
68 else {
69 return "";
73 public function returnErrors() {
74 return $this->errorcount;
77 public function getErrors() {
78 return $this->errorarray;