From c1e5c9b1b1f864bee6533cc2278e390a8f0916d0 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Mon, 25 Dec 2006 22:58:46 +0000 Subject: [PATCH] Add accesskey support to BSPrinterBaseElement --- PrinterBaseElement.php | 24 +++++++++++++++++++++--- PrinterTableElement.php | 2 ++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/PrinterBaseElement.php b/PrinterBaseElement.php index 8586540..79359a0 100644 --- a/PrinterBaseElement.php +++ b/PrinterBaseElement.php @@ -72,6 +72,12 @@ class BSPrinterBaseElement extends BSPrinterElement */ private $onClick; + /** + * Accesskey attribute + * @var string + */ + private $accessKey; + /** * Constructor */ @@ -115,6 +121,17 @@ class BSPrinterBaseElement extends BSPrinterElement $this->onClick = $onClick; } + // ################################################################### + /** + * Sets the accesskey attribute value + * + * @param string Access key + */ + public function setAccessKey($accessKey) + { + $this->accessKey = $accessKey; + } + // ################################################################### /** * Returns the type @@ -159,8 +176,9 @@ class BSPrinterBaseElement extends BSPrinterElement $name = ' name="' . $this->name . '"'; $value = ' value="' . $this->value . '"'; $onclick = ($this->onClick ? ' onclick="' . $this->onClick . '"' : ''); + $accesskey = ($this->accessKey ? ' accesskey="' . $this->accessKey . '"' : ''); - $attrs = $name . $value . $onclick; + $attrs = $name . $value . $onclick . $accesskey; switch ($this->type) { @@ -190,7 +208,7 @@ class BSPrinterBaseElement extends BSPrinterElement break; case 'select': - return '_prepareStyle() . '>' . $this->value . ''; + return '_prepareStyle() . $accesskey . '>' . $this->value . ''; break; case 'textarea': @@ -199,7 +217,7 @@ class BSPrinterBaseElement extends BSPrinterElement trigger_error('BSPrinterBaseElement of type "textarea" require a "height" and "width" style attribute'); } - return '_prepareStyle() . '>' . $this->value . ''; + return '_prepareStyle() . $accesskey . '>' . $this->value . ''; break; default: diff --git a/PrinterTableElement.php b/PrinterTableElement.php index 2e5d33e..d1c5e0c 100644 --- a/PrinterTableElement.php +++ b/PrinterTableElement.php @@ -136,12 +136,14 @@ class BSPrinterTableElement extends BSPrinterElement if (!is_null($save)) { $elm = new BSPrinterBaseElement('submit', '__submit__', " $save "); + $elm->setAccessKey('s'); $build .= "\n\t\t\t" . $elm->paint(); } if (!is_null($reset)) { $elm = new BSPrinterBaseElement('reset', '__reset__', " $reset "); + $elm->setAccessKey('r'); $build .= "\n\t\t\t" . $elm->paint() . "\n\t\t"; } -- 2.43.5