aboutsummaryrefslogtreecommitdiff
path: root/h-source/admin/Library/Form
diff options
context:
space:
mode:
authorYuchen Pei <hi@ypei.me>2021-10-14 15:16:42 +1100
committerYuchen Pei <hi@ypei.me>2021-10-14 15:16:42 +1100
commit07f5140771388c9e0c8a99b0dd2e5d950bdb173b (patch)
tree323c00faef1edc7dea2e88ff581cc2258b2b6432 /h-source/admin/Library/Form
parente119be145500700f3c465e12664403a07530a421 (diff)
moving h-source subdir out.
Diffstat (limited to 'h-source/admin/Library/Form')
-rwxr-xr-xh-source/admin/Library/Form/Checkbox.php41
-rwxr-xr-xh-source/admin/Library/Form/Entry.php45
-rwxr-xr-xh-source/admin/Library/Form/Form.php116
-rwxr-xr-xh-source/admin/Library/Form/Hidden.php23
-rw-r--r--h-source/admin/Library/Form/Html.php23
-rwxr-xr-xh-source/admin/Library/Form/InputText.php30
-rw-r--r--h-source/admin/Library/Form/Password.php30
-rwxr-xr-xh-source/admin/Library/Form/Radio.php30
-rwxr-xr-xh-source/admin/Library/Form/Select.php30
-rwxr-xr-xh-source/admin/Library/Form/Textarea.php30
-rw-r--r--h-source/admin/Library/Form/index.html1
11 files changed, 0 insertions, 399 deletions
diff --git a/h-source/admin/Library/Form/Checkbox.php b/h-source/admin/Library/Form/Checkbox.php
deleted file mode 100755
index 5df1917..0000000
--- a/h-source/admin/Library/Form/Checkbox.php
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php
-
-/**
- * EasyGiant
- *
- * LICENSE
- *
- * All EasyGiant code 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 3 of the License, or (at your option)
- * any later version.
- * See COPYRIGHT.txt and LICENSE.txt.
- *
- * @package EasyGiant
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public License version 3 or any later version
- */
-
-if (!defined('EG')) die('Direct access not allowed!');
-
-/** create the HTML of an input text entry */
-class Form_Checkbox extends Form_Entry
-{
-
- public function __construct($entryName = null)
- {
- $this->entryName = $entryName;
- }
-
- public function render($value = null)
- {
- $wrap = $this->getWrapElements();
- $returnString = "<div class='".$this->getEntryClass()."'>\n\t";
- $returnString .= $wrap[0];
- $returnString .= $this->getLabelTag();
- $returnString .= $wrap[1];
- $returnString .= Html_Form::checkbox($this->entryName, $value, $this->options, $this->className,$this->idName);
- $returnString .= $wrap[2];
- $returnString .="</div>\n";
- return $returnString;
- }
-
-}
diff --git a/h-source/admin/Library/Form/Entry.php b/h-source/admin/Library/Form/Entry.php
deleted file mode 100755
index 725235a..0000000
--- a/h-source/admin/Library/Form/Entry.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-// All EasyGiant code 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 3 of the License, or (at your option) any later version.
-// See COPYRIGHT.txt and LICENSE.txt.
-
-if (!defined('EG')) die('Direct access not allowed!');
-
-//base class of the form entries
-abstract class Form_Entry {
-
- public $entryName = null; //the name of the entry
- public $entryClass = null; //the class of the entry
- public $idName = null; //the id of the input entry
- public $className = null; //the class of the input entry
- public $labelString = null; //label of the form
- public $labelClass = null; //the class of the tag of the label
- public $options = array(); //options (if the entry is a <select> entry or a radio button). Associative array or comma-divided list.
- public $defaultValue = '';
- public $wrap = array();
- public $type = null; //the type of the entry
-
- //create the label of each entry of the form
- public function getLabelTag()
- {
- $labelTagClass = isset($this->labelClass) ? $this->labelClass : 'entryLabel';
- return isset($this->labelString) ? "<label class='$labelTagClass'>".$this->labelString."</label>\n\t" : null;
- }
-
- //get the class of the entry
- public function getEntryClass()
- {
- return isset($this->entryClass) ? $this->entryClass : 'formEntry';
- }
-
- public function getWrapElements()
- {
- $wrap[0] = isset($this->wrap[0]) ? $this->wrap[0] : null;
- $wrap[1] = isset($this->wrap[1]) ? $this->wrap[1] : null;
- $wrap[2] = isset($this->wrap[2]) ? $this->wrap[2] : null;
- return $wrap;
- }
-
- abstract public function render($value = null);
-
-}
diff --git a/h-source/admin/Library/Form/Form.php b/h-source/admin/Library/Form/Form.php
deleted file mode 100755
index 00e27d4..0000000
--- a/h-source/admin/Library/Form/Form.php
+++ /dev/null
@@ -1,116 +0,0 @@
-<?php
-
-// All EasyGiant code 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 3 of the License, or (at your option) any later version.
-// See COPYRIGHT.txt and LICENSE.txt.
-
-if (!defined('EG')) die('Direct access not allowed!');
-
-//create the HTML of the whole form
-class Form_Form {
-
- public $entry = array(); //associative array containing the entries of the form (objects that inherit the class form_entryModel). Each element of the array corresponds to one field of the table
-
- public $action = null; //the action of the form
- public $name = null; //the name of the form
- public $className = 'formClass'; //the class of the form
- public $id = null;
- public $submit = array(); //the submit entries array('name'=>'value')
- public $method = 'POST'; //the transmission method: POST/GET
-
- public function __construct($action,$submit = array('generalAction'=>'save'),$method = 'POST')
- {
- $this->action = $action; //action of the form: controller/action
- $this->submit = $submit;
- $this->method = $method;
- }
-
- //method to manage the $this->entry associative array
- //entryType: the type of the object to be initialized, $entryName: the name of the entry
- //$options: the list of options (if the entry is a <select> entry)
- public function setEntry($entryName,$entryType,$options = null)
- {
- $entryObjName = 'Form_'.$entryType;
- if (!class_exists($entryObjName))
- {
- throw new Exception("class <b>$entryObjName</b> not defined: the entry <b>$entryName</b> can't be set");
- }
- $this->entry[$entryName] = new $entryObjName($entryName);
- $this->entry[$entryName]->labelString = $entryName.':';
- //set the type
- $this->entry[$entryName]->type = $entryType;
- if (isset($options))
- {
- $this->entry[$entryName]->options = $options;
- }
- }
-
- //set all the entries
- //$entryStruct : the struct of the entries
- public function setEntries($entryStruct = array())
- {
- foreach ($entryStruct as $name => $entry)
- {
- $type = array_key_exists('type',$entry) ? $entry['type'] : 'InputText';
- $options = array_key_exists('options',$entry) ? $entry['options'] : null;
- $this->setEntry($name,$type,$options);
-
- $entryClass = array_key_exists('entryClass',$entry) ? $entry['entryClass'] : null;
- $labelString = array_key_exists('labelString',$entry) ? $entry['labelString'] : "$name:";
- $idName = array_key_exists('idName',$entry) ? $entry['idName'] : null;
- $className = array_key_exists('className',$entry) ? $entry['className'] : null;
- $labelClass = array_key_exists('labelClass',$entry) ? $entry['labelClass'] : null;
- $defaultValue = array_key_exists('defaultValue',$entry) ? $entry['defaultValue'] : null;
- $wrap = array_key_exists('wrap',$entry) ? $entry['wrap'] : array();
-
- $this->entry[$name]->entryClass = $entryClass;
- $this->entry[$name]->labelString = $labelString;
- $this->entry[$name]->idName = $idName;
- $this->entry[$name]->className = $className;
- $this->entry[$name]->labelClass = $labelClass;
- $this->entry[$name]->defaultValue = $defaultValue;
- $this->entry[$name]->wrap = $wrap;
- }
- }
-
- //function to create the HTML of the form
- //$values: an associative array ('entryName'=>'value')
- //$subset: subset to print
- public function render($values = null, $subset = null)
- {
-
- if ($values === null)
- {
- $values = array();
- foreach ($this->entry as $key => $value)
- {
- $values[$key] = $value->defaultValue;
- }
- }
-
- $fid = isset($this->id) ? "id='".$this->id."'" : null;
- $fname = isset($this->name) ? "name='".$this->name."'" : null;
- $fclass = isset($this->className) ? "class='".$this->className."'" : null;
- $htmlForm = "<form $fname $fclass $fid action='".Url::getRoot($this->action)."' method='".$this->method."'>\n";
-
- $subset = (isset($subset)) ? explode(',',$subset) : array_keys($values);
-
- foreach ($subset as $entry)
- {
-
- if (array_key_exists($entry,$this->entry))
- {
- $value = array_key_exists($entry,$values) ? $values[$entry] : $this->entry[$entry]->defaultValue;
- $htmlForm .= $this->entry[$entry]->render($value);
- }
-
- }
-
- foreach ($this->submit as $name => $value)
- {
- $htmlForm .= "<div class='inputEntry'>\n<input id='".$name."' type='submit' name='$name' value='$value'>\n</div>\n";
- }
- $htmlForm .= "</form>\n";
- return $htmlForm;
- }
-
-}
diff --git a/h-source/admin/Library/Form/Hidden.php b/h-source/admin/Library/Form/Hidden.php
deleted file mode 100755
index fb81b30..0000000
--- a/h-source/admin/Library/Form/Hidden.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-
-// All EasyGiant code 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 3 of the License, or (at your option) any later version.
-// See COPYRIGHT.txt and LICENSE.txt.
-
-if (!defined('EG')) die('Direct access not allowed!');
-
-//create the HTML of an input hidden entry
-class Form_Hidden extends Form_Entry
-{
-
- public function __construct($entryName = null)
- {
- $this->entryName = $entryName;
- }
-
- public function render($value = null)
- {
- $returnString = Html_Form::hidden($this->entryName, $value);
- return $returnString;
- }
-
-}
diff --git a/h-source/admin/Library/Form/Html.php b/h-source/admin/Library/Form/Html.php
deleted file mode 100644
index dce91c6..0000000
--- a/h-source/admin/Library/Form/Html.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-
-// All EasyGiant code 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 3 of the License, or (at your option) any later version.
-// See COPYRIGHT.txt and LICENSE.txt.
-
-if (!defined('EG')) die('Direct access not allowed!');
-
-//create the HTML of an input text entry
-class Form_Html extends Form_Entry
-{
-
- public function __construct($entryName = null)
- {
- $this->entryName = $entryName;
- }
-
- public function render($value = null)
- {
- $returnString = "<div class='".$this->getEntryClass()."'>\n\t$value\n</div>\n";
- return $returnString;
- }
-
-}
diff --git a/h-source/admin/Library/Form/InputText.php b/h-source/admin/Library/Form/InputText.php
deleted file mode 100755
index fb98336..0000000
--- a/h-source/admin/Library/Form/InputText.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-// All EasyGiant code 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 3 of the License, or (at your option) any later version.
-// See COPYRIGHT.txt and LICENSE.txt.
-
-if (!defined('EG')) die('Direct access not allowed!');
-
-//create the HTML of an input text entry
-class Form_InputText extends Form_Entry
-{
-
- public function __construct($entryName = null)
- {
- $this->entryName = $entryName;
- }
-
- public function render($value = null)
- {
- $wrap = $this->getWrapElements();
- $returnString = "<div class='".$this->getEntryClass()."'>\n\t";
- $returnString .= $wrap[0];
- $returnString .= $this->getLabelTag();
- $returnString .= $wrap[1];
- $returnString .= Html_Form::input($this->entryName, $value, $this->className, $this->idName);
- $returnString .= $wrap[2];
- $returnString .="</div>\n";
- return $returnString;
- }
-
-}
diff --git a/h-source/admin/Library/Form/Password.php b/h-source/admin/Library/Form/Password.php
deleted file mode 100644
index 76bc735..0000000
--- a/h-source/admin/Library/Form/Password.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-// All EasyGiant code 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 3 of the License, or (at your option) any later version.
-// See COPYRIGHT.txt and LICENSE.txt.
-
-if (!defined('EG')) die('Direct access not allowed!');
-
-//create the HTML of an input text entry
-class Form_Password extends Form_Entry
-{
-
- public function __construct($entryName = null)
- {
- $this->entryName = $entryName;
- }
-
- public function render($value = null)
- {
- $wrap = $this->getWrapElements();
- $returnString = "<div class='".$this->getEntryClass()."'>\n\t";
- $returnString .= $wrap[0];
- $returnString .= $this->getLabelTag();
- $returnString .= $wrap[1];
- $returnString .= Html_Form::password($this->entryName, null, $this->className);
- $returnString .= $wrap[2];
- $returnString .="</div>\n";
- return $returnString;
- }
-
-}
diff --git a/h-source/admin/Library/Form/Radio.php b/h-source/admin/Library/Form/Radio.php
deleted file mode 100755
index fb20677..0000000
--- a/h-source/admin/Library/Form/Radio.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-// All EasyGiant code 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 3 of the License, or (at your option) any later version.
-// See COPYRIGHT.txt and LICENSE.txt.
-
-if (!defined('EG')) die('Direct access not allowed!');
-
-//create the HTML of a radio entry
-class Form_Radio extends Form_Entry
-{
-
- public function __construct($entryName = null)
- {
- $this->entryName = $entryName;
- }
-
- public function render($value = null)
- {
- $wrap = $this->getWrapElements();
- $returnString = "<div class='".$this->getEntryClass()."'>\n\t";
- $returnString .= $wrap[0];
- $returnString .= $this->getLabelTag();
- $returnString .= $wrap[1];
- $returnString .= Html_Form::radio($this->entryName,$value,$this->options,$this->className, 'after', $this->idName);
- $returnString .= $wrap[2];
- $returnString .="</div>\n";
- return $returnString;
- }
-
-}
diff --git a/h-source/admin/Library/Form/Select.php b/h-source/admin/Library/Form/Select.php
deleted file mode 100755
index 558fd57..0000000
--- a/h-source/admin/Library/Form/Select.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-// All EasyGiant code 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 3 of the License, or (at your option) any later version.
-// See COPYRIGHT.txt and LICENSE.txt.
-
-if (!defined('EG')) die('Direct access not allowed!');
-
-//create the HTML of an select entry
-class Form_Select extends Form_Entry
-{
-
- public function __construct($entryName = null)
- {
- $this->entryName = $entryName;
- }
-
- public function render($value = null)
- {
- $wrap = $this->getWrapElements();
- $returnString = "<div class='".$this->getEntryClass()."'>\n\t";
- $returnString .= $wrap[0];
- $returnString .= $this->getLabelTag();
- $returnString .= $wrap[1];
- $returnString .= Html_Form::select($this->entryName,$value,$this->options,$this->className, $this->idName);
- $returnString .= $wrap[2];
- $returnString .="</div>\n";
- return $returnString;
- }
-
-}
diff --git a/h-source/admin/Library/Form/Textarea.php b/h-source/admin/Library/Form/Textarea.php
deleted file mode 100755
index d81cc84..0000000
--- a/h-source/admin/Library/Form/Textarea.php
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-// All EasyGiant code 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 3 of the License, or (at your option) any later version.
-// See COPYRIGHT.txt and LICENSE.txt.
-
-if (!defined('EG')) die('Direct access not allowed!');
-
-//create the HTML of a textarea entry
-class Form_Textarea extends Form_Entry
-{
-
- public function __construct($entryName = null)
- {
- $this->entryName = $entryName;
- }
-
- public function render($value = null)
- {
- $wrap = $this->getWrapElements();
- $returnString = "<div class='".$this->getEntryClass()."'>\n\t";
- $returnString .= $wrap[0];
- $returnString .= $this->getLabelTag();
- $returnString .= $wrap[1];
- $returnString .= Html_Form::textarea($this->entryName, $value, $this->className, $this->idName);
- $returnString .= $wrap[2];
- $returnString .="</div>\n";
- return $returnString;
- }
-
-}
diff --git a/h-source/admin/Library/Form/index.html b/h-source/admin/Library/Form/index.html
deleted file mode 100644
index 8d1c8b6..0000000
--- a/h-source/admin/Library/Form/index.html
+++ /dev/null
@@ -1 +0,0 @@
-