X-Git-Url: https://git-public.kairo.at/?p=php-utility-classes.git;a=blobdiff_plain;f=include%2Fcbsm%2Futil%2Fdocument.php-class;h=c64d9a4a81c3f6e501036f9136beeca86bc4e962;hp=a10041a9dc6c2b2e9cfaeb02b5816978e694f680;hb=262e0bbb3441a51237f0330fa5ed7e53e70baf0e;hpb=645a7eb6de6a6b0ecdac1a9edb56fe18ce950829;ds=sidebyside diff --git a/include/cbsm/util/document.php-class b/include/cbsm/util/document.php-class index a10041a..c64d9a4 100755 --- a/include/cbsm/util/document.php-class +++ b/include/cbsm/util/document.php-class @@ -50,7 +50,11 @@ class ExtendedDocument extends DOMDocument { // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params) // returns the new child // - // function appendFormDiv($action, $method, $name) + // function appendForm($action, $method, $name, [$id]) + // appends an ExtendedDocument::createElementForm() as a child of this document (see there for params) + // returns the new child + // + // function appendFormDiv($action, $method, $name, [$id]) // appends an ExtendedDocument::createElementForm() as a child of this document (see there for params) // returns an HTML
that is a child of the new child // @@ -62,6 +66,10 @@ class ExtendedDocument extends DOMDocument { // appends an ExtendedDocument::createElementInputText() as a child of this document (see there for params) // returns the new child // + // function appendInputNumber($name, $maxlength, $size, [$id], [$value]) + // appends an ExtendedDocument::createElementInputNumber() as a child of this document (see there for params) + // returns the new child + // // function appendInputPassword($name, $maxlength, $size, [$id], [$value]) // appends an ExtendedDocument::createElementInputPassword() as a child of this document (see there for params) // returns the new child @@ -139,6 +147,10 @@ class ExtendedDocument extends DOMDocument { // returns an ExtendedElement that is an HTML of type 'text' with the given name, maxlength, size, // and optionally id and value // + // function createElementInputNumber($name, $maxlength, $size, [$id], [$value]) + // returns an ExtendedElement that is an HTML of type 'number' with the given name, maxlength, size, + // and optionally id and value + // // function createElementInputPassword($name, $maxlength, $size, [$id], [$value]) // returns an ExtendedElement that is an HTML of type 'password' with the given name, maxlength, size, // and optionally id and value @@ -187,7 +199,10 @@ class ExtendedDocument extends DOMDocument { } function appendElement($name, $value = '') { - return $this->appendChild($this->createElement($name, $value)); + // Adding the $value in createElement does NOT escape it, so use appendText to support that. + $aelem = $this->appendChild($this->createElement($name)); + $aelem->appendText($value); + return $aelem; } function appendElementXML($name, $xmldata) { $aelem = $this->appendChild($this->createElement($name)); @@ -201,8 +216,11 @@ class ExtendedDocument extends DOMDocument { function appendImage($src, $alt_text = '') { return $this->appendChild($this->createElementImage($src, $alt_text)); } - function appendFormDiv($action, $method, $name) { - $formelem = $this->appendChild($this->createElementForm($action, $method, $name)); + function appendForm($action, $method, $name, $id = null) { + return $this->appendChild($this->createElementForm($action, $method, $name, $id)); + } + function appendFormDiv($action, $method, $name, $id = null) { + $formelem = $this->appendChild($this->createElementForm($action, $method, $name, $id)); return $formelem->appendElement('div'); } function appendInputHidden($name, $value) { @@ -211,6 +229,9 @@ class ExtendedDocument extends DOMDocument { function appendInputText($name, $maxlength, $size, $id = null, $value = null) { return $this->appendChild($this->createElementInputText($name, $maxlength, $size, $id, $value)); } + function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) { + return $this->appendChild($this->createElementInputNumber($name, $maxlength, $size, $id, $value)); + } function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) { return $this->appendChild($this->createElementInputPassword($name, $maxlength, $size, $id, $value)); } @@ -270,23 +291,25 @@ class ExtendedDocument extends DOMDocument { } function createElementLink($target, $value = '') { - $link = $this->createElement('a', $value); + $link = $this->createElement('a'); + $link->appendText($value); $link->setAttribute('href', $target); // XXX: take care of & etc. in links return $link; } function createElementImage($src, $alt_text = '') { - $link = $this->createElement('img'); - $link->setAttribute('src', $src); - $link->setAttribute('alt', $alt_text); - return $link; + $img = $this->createElement('img'); + $img->setAttribute('src', $src); + $img->setAttribute('alt', $alt_text); + return $img; } - function createElementForm($action, $method, $name) { + function createElementForm($action, $method, $name, $id = null) { $formelem = $this->createElement('form'); $formelem->setAttribute('action', $action); $formelem->setAttribute('method', $method); $formelem->setAttribute('name', $name); + $formelem->setAttribute('id', $id); return $formelem; } @@ -309,9 +332,9 @@ class ExtendedDocument extends DOMDocument { return $txfield; } - function createElementInputPassword($name, $maxlength, $size, $id = null, $value = null) { + function createElementInputNumber($name, $maxlength, $size, $id = null, $value = null) { $txfield = $this->createElement('input'); - $txfield->setAttribute('type', 'password'); + $txfield->setAttribute('type', 'number'); if (!is_null($id)) { $txfield->setAttribute('id', $id); } $txfield->setAttribute('name', $name); $txfield->setAttribute('maxlength', $maxlength); @@ -320,6 +343,17 @@ class ExtendedDocument extends DOMDocument { return $txfield; } + function createElementInputPassword($name, $maxlength, $size, $id = null, $value = null) { + $pwfield = $this->createElement('input'); + $pwfield->setAttribute('type', 'password'); + if (!is_null($id)) { $pwfield->setAttribute('id', $id); } + $pwfield->setAttribute('name', $name); + $pwfield->setAttribute('maxlength', $maxlength); + $pwfield->setAttribute('size', $size); + if (!is_null($value)) { $pwfield->setAttribute('value', $value); } + return $pwfield; + } + function createElementInputRadio($name, $id, $value, $checked) { $radio = $this->createElement('input'); $radio->setAttribute('type', 'radio'); @@ -426,7 +460,11 @@ class ExtendedElement extends DOMElement { // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params) // returns the new child // - // function appendFormDiv($action, $method, $name) + // function appendForm($action, $method, $name, [$id]) + // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params) + // returns the new child + // + // function appendFormDiv($action, $method, $name, [$id]) // appends an ExtendedDocument::createElementForm() as a child of this element (see there for params) // returns an HTML
that is a child of the new child // @@ -438,6 +476,10 @@ class ExtendedElement extends DOMElement { // appends an ExtendedDocument::createElementInputText() as a child of this element (see there for params) // returns the new child // + // function appendInputNumber($name, $maxlength, $size, [$id], [$value]) + // appends an ExtendedDocument::createElementInputNumber() as a child of this element (see there for params) + // returns the new child + // // function appendInputPassword($name, $maxlength, $size, [$id], [$value]) // appends an ExtendedDocument::createElementInputPassword() as a child of this element (see there for params) // returns the new child @@ -499,7 +541,10 @@ class ExtendedElement extends DOMElement { // returns the new child function appendElement($name, $value = '') { - return $this->appendChild($this->ownerDocument->createElement($name, $value)); + // Adding the $value in createElement does NOT escape it, so use appendText to support that. + $aelem = $this->appendChild($this->ownerDocument->createElement($name)); + $aelem->appendText($value); + return $aelem; } function appendElementXML($name, $xmldata) { $aelem = $this->appendChild($this->ownerDocument->createElement($name)); @@ -512,8 +557,11 @@ class ExtendedElement extends DOMElement { function appendImage($src, $alt_text = '') { return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text)); } - function appendFormDiv($action, $method, $name) { - $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name)); + function appendForm($action, $method, $name, $id = null) { + return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id)); + } + function appendFormDiv($action, $method, $name, $id = null) { + $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id)); return $formelem->appendElement('div'); } function appendInputHidden($name, $value) { @@ -522,6 +570,9 @@ class ExtendedElement extends DOMElement { function appendInputText($name, $maxlength, $size, $id = null, $value = null) { return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value)); } + function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) { + return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value)); + } function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) { return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value)); } @@ -590,7 +641,11 @@ class ExtendedDocumentFragment extends DOMDocumentFragment { // appends an ExtendedDocument::createElementImage() as a child of this document (see there for params) // returns the new child // - // function appendFormDiv($action, $method, $name) + // function appendForm($action, $method, $name, [$id]) + // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params) + // returns the new child + // + // function appendFormDiv($action, $method, $name, [$id]) // appends an ExtendedDocument::createElementForm() as a child of this fragment (see there for params) // returns an HTML
that is a child of the new child // @@ -602,6 +657,10 @@ class ExtendedDocumentFragment extends DOMDocumentFragment { // appends an ExtendedDocument::createElementInputText() as a child of this fragment (see there for params) // returns the new child // + // function appendInputNumber($name, $maxlength, $size, [$id], [$value]) + // appends an ExtendedDocument::createElementInputNumber() as a child of this fragment (see there for params) + // returns the new child + // // function appendInputPassword($name, $maxlength, $size, [$id], [$value]) // appends an ExtendedDocument::createElementInputPassword() as a child of this fragment (see there for params) // returns the new child @@ -663,7 +722,10 @@ class ExtendedDocumentFragment extends DOMDocumentFragment { // returns the new child function appendElement($name, $value = '') { - return $this->appendChild($this->ownerDocument->createElement($name, $value)); + // Adding the $value in createElement does NOT escape it, so use appendText to support that. + $aelem = $this->appendChild($this->ownerDocument->createElement($name)); + $aelem->appendText($value); + return $aelem; } function appendElementXML($name, $xmldata) { $aelem = $this->appendChild($this->ownerDocument->createElement($name)); @@ -676,8 +738,11 @@ class ExtendedDocumentFragment extends DOMDocumentFragment { function appendImage($src, $alt_text = '') { return $this->appendChild($this->ownerDocument->createElementImage($src, $alt_text)); } - function appendFormDiv($action, $method, $name) { - $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name)); + function appendForm($action, $method, $name, $id = null) { + return $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id)); + } + function appendFormDiv($action, $method, $name, $id = null) { + $formelem = $this->appendChild($this->ownerDocument->createElementForm($action, $method, $name, $id)); return $formelem->appendElement('div'); } function appendInputHidden($name, $value) { @@ -686,6 +751,9 @@ class ExtendedDocumentFragment extends DOMDocumentFragment { function appendInputText($name, $maxlength, $size, $id = null, $value = null) { return $this->appendChild($this->ownerDocument->createElementInputText($name, $maxlength, $size, $id, $value)); } + function appendInputNumber($name, $maxlength, $size, $id = null, $value = null) { + return $this->appendChild($this->ownerDocument->createElementInputNumber($name, $maxlength, $size, $id, $value)); + } function appendInputPassword($name, $maxlength, $size, $id = null, $value = null) { return $this->appendChild($this->ownerDocument->createElementInputPassword($name, $maxlength, $size, $id, $value)); }