Whistik

Untitled

Jul 30th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.70 KB | None | 0 0
  1. <?php
  2.  
  3. class FormManager{
  4.  
  5.     private $FormElementStructure = [
  6.         "action",
  7.         "method",
  8.         "class",
  9.         "autocomplete"];
  10.     private $InputElementStructure = [
  11.         "type",
  12.         "name",
  13.         "placeholder",
  14.         "value",
  15.         "class",
  16.         "id",
  17.         "style"];
  18.     private $SelectElementStructure = [
  19.         "name",
  20.         "class",
  21.         "id",
  22.         "style"];
  23.     private $SelectOptionStructure = [
  24.         "value",
  25.         "class",
  26.         "id"];
  27.  
  28.     public function CreateForm( $Form )
  29.     {
  30.         for($i=0;$i<count($Form);$i++){
  31.             $FormElement[] = $this->FormElementStructure[$i] . "='" . $Form[$i]."' ";
  32.         }
  33.         $FormHeader = "<form ".join(" ", $FormElement)." >";
  34.         print( $FormHeader );
  35.     }
  36.     public function CreateSelect( $Select )
  37.     {
  38.         for($i=0;$i<count($Select);$i++){
  39.             $SelectElement[] = $this->SelectElementStructure[$i] . "='" .$Select[$i]. "' ";
  40.         }  
  41.  
  42.         print( $electHeader = "<select ".join(" ", $SelectElement)." >" );
  43.     }
  44.  
  45.     public function AddOption( $SelectOption, $SelectOptionText, $SelectOptionSelected = false, $SelectOptionDisabled = false )
  46.     {
  47.         for($i=0;$i<count($SelectOption);$i++){
  48.             $SelectOptionElement[] = $this->SelectOptionStructure[$i] . "='" .$SelectOption[$i]. "' ";
  49.         }
  50.         $SelectOptionHeader = "<option ".join(" ", $SelectOptionElement);
  51.         $SelectOptionFooter = "</option>";
  52.        
  53.         if($SelectOptionSelected != true && $SelectOptionDisabled != true){
  54.             print( $SelectOptionHeader." >".$SelectOptionText.$SelectOptionFooter );
  55.         }elseif($SelectOptionSelected != false && $SelectOptionDisabled != true){
  56.             print( $SelectOptionHeader." selected >".$SelectOptionText.$SelectOptionFooter );
  57.         }elseif($SelectOptionSelected != true && $SelectOptionDisabled != false){
  58.             print( $SelectOptionHeader." disabled >".$SelectOptionText.$SelectOptionFooter );
  59.         }elseif($SelectOptionSelected == true && $SelectOptionDisabled == true){
  60.             print( $SelectOptionHeader." selected disabled >".$SelectOptionText.$SelectOptionFooter );
  61.         }
  62.         $SelectOptionElement = null;
  63.     }
  64.    
  65.     public function AddInput( $Input, $InputRequired = false, $InputDisabled = false )
  66.     {
  67.         for($i=0;$i<count($Input);$i++){
  68.             $InputElement[$i] = $this->InputElementStructure[$i] . "='" . $Input[$i]."' ";
  69.         }
  70.         $InputHeader = "<input ".join(" ", $InputElement);
  71.         $InputFooter = ">";
  72.         if($InputRequired != true && $InputDisabled != true){
  73.             print( $InputHeader.$InputFooter );
  74.         }elseif($InputRequired != false && $InputDisabled != true){
  75.             print( $InputHeader." required ".$InputFooter );
  76.         }elseif($InputRequired != true && $InputDisabled != false){
  77.             print( $InputHeader." disabled ".$InputFooter );
  78.         }
  79.         $InputElement = null;
  80.     }
  81.  
  82.     public function FinishForm( )
  83.     {
  84.         print( "</form>" );
  85.     }
  86.  
  87.     public function FinishSelect( )
  88.     {
  89.         print( "</select>" );
  90.     }
  91.    
  92. }
Add Comment
Please, Sign In to add comment