commit a4277a8371f05183728f31fb26f91adcd3cae716
parent 2c4e1ee23423a7c876a7419cb63c19ac0a2f4120
Author: dankert <devnull@localhost>
Date: Thu, 21 Apr 2005 21:10:02 +0200
Bisher nicht einbebundene Testklassen fuer Formular-Validierungen
Diffstat:
2 files changed, 123 insertions(+), 0 deletions(-)
diff --git a/formClasses/AbstractForm.class.php b/formClasses/AbstractForm.class.php
@@ -0,0 +1,74 @@
+<?php
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// ---------------------------------------------------------------------------
+
+
+/**
+ * Abstrakte Formularklasse
+ *
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.forms
+ */
+
+class AbstractForm
+{
+ var $errors = array();
+ var $httpParameter = array();
+
+
+ function AbstractForm()
+ {
+ $vars = array_keys(get_class_vars(get_class($this)));
+ global $REQ;
+ foreach( $vars as $key )
+ if ( isset($REQ[$key]) )
+ $this->$key=$REQ[$key];
+ }
+
+
+ function addError( $feld,$error )
+ {
+ $this->errors[ $feld ] = $error;
+ }
+
+
+ function validate()
+ {
+ die( get_class($this).': method validate() must be implemented by subclass' );
+ }
+
+
+ function hasErrors()
+ {
+ return count($this->errors) == 0;
+ }
+
+
+ function getErrors()
+ {
+ global $inputErrors;
+ $inputErrors = $this->errors;
+
+ return $this->errors;
+ }
+}
+
+?>+
\ No newline at end of file
diff --git a/formClasses/LoginForm.class.php b/formClasses/LoginForm.class.php
@@ -0,0 +1,47 @@
+<?php
+// $Id$
+// ---------------------------------------------------------------------------
+// OpenRat Content Management System
+// Copyright (C) 2002 Jan Dankert, jandankert@jandankert.de
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// ---------------------------------------------------------------------------
+
+
+/**
+ * Login-Formular
+ *
+ * @author $Author$
+ * @version $Revision$
+ * @package openrat.forms
+ */
+
+class LoginForm extends AbstractForm
+{
+ var $login_name;
+ var $login_password;
+
+
+ function validate()
+ {
+ if ( $this->login_name == '' )
+ $this->addError('login_name','LOGIN_ERROR_LOGIN_NAME_REQUIRED');
+
+ if ( $this->login_password == '' )
+ $this->addError('login_password','LOGIN_ERROR_LOGIN_PASSWORD_REQUIRED');
+ }
+}
+
+?>+
\ No newline at end of file