Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class FormManager{
- private $FormElementStructure = [
- "action",
- "method",
- "class"];
- private $InputElementStructure = [
- "type",
- "name",
- "placeholder",
- "value",
- "class",
- "id"];
- private $SelectElementStructure = [
- "name",
- "class",
- "id"];
- private $SelectOptionStructure = [
- "value",
- "class",
- "id"];
- public function CreateForm( $Form )
- {
- for($i=0;$i<count($Form);$i++){
- $FormElement[] = $this->FormElementStructure[$i] . "='" . $Form[$i]."' ";
- }
- $FormHeader = "<form ".join(" ", $FormElement)." >";
- print( $FormHeader );
- }
- public function CreateSelect( $Select )
- {
- for($i=0;$i<count($Select);$i++){
- $SelectElement[] = $this->SelectElementStructure[$i] . "='" .$Select[$i]. "' ";
- }
- print( $electHeader = "<select ".join(" ", $SelectElement)." >" );
- }
- public function AddOption( $SelectOption, $SelectOptionText, $SelectOptionSelected = false, $SelectOptionDisabled = false )
- {
- for($i=0;$i<count($SelectOption);$i++){
- $SelectOptionElement[] = $this->SelectOptionStructure[$i] . "='" .$SelectOption[$i]. "' ";
- }
- $SelectOptionHeader = "<option ".join(" ", $SelectOptionElement);
- $SelectOptionFooter = "</option>";
- if($SelectOptionSelected != true && $SelectOptionDisabled != true){
- print( $SelectOptionHeader." >".$SelectOptionText.$SelectOptionFooter );
- }elseif($SelectOptionSelected != false && $SelectOptionDisabled != true){
- print( $SelectOptionHeader." selected >".$SelectOptionText.$SelectOptionFooter );
- }elseif($SelectOptionSelected != true && $SelectOptionDisabled != false){
- print( $SelectOptionHeader." disabled >".$SelectOptionText.$SelectOptionFooter );
- }
- $SelectOptionElement = null;
- }
- public function AddInput( $Input, $InputRequired = false, $InputDisabled = false )
- {
- for($i=0;$i<count($Input);$i++){
- $InputElement[$i] = $this->InputElementStructure[$i] . "='" . $Input[$i]."' ";
- }
- $InputHeader = "<input ".join(" ", $InputElement);
- $InputFooter = ">";
- if($InputRequired != true && $InputDisabled != true){
- print( $InputHeader.$InputFooter );
- }elseif($InputRequired != false && $InputDisabled != true){
- print( $InputHeader." required ".$InputFooter );
- }elseif($InputRequired != true && $InputDisabled != false){
- print( $InputHeader." disabled ".$InputFooter );
- }
- $InputElement = null;
- }
- public function FinishForm( )
- {
- print( "</form>" );
- }
- public function FinishSelect( )
- {
- print( "</select>" );
- }
- }
Add Comment
Please, Sign In to add comment