From 200046455459f3a8068d5667f1c69b02127475bb Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Wed, 26 Mar 2008 14:11:25 -0400 Subject: [PATCH] Add the ability to set the id attribute of all Printer elements * PrinterAbstract.php: New id ivar (BSPrinterAbstract::setId): New method (BSPrinterAbstract::_prepareStyle): Add the id attribute if it's present --- CHANGES | 2 +- PrinterAbstract.php | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index be3b505..8e8553e 100644 --- a/CHANGES +++ b/CHANGES @@ -2,4 +2,4 @@ =================== - Change: BSPrinterElementTable:__construct() can now take straight strings and convert them into BSPrinterElementLabel's - New: BSPrinterRootPage::setHeaderCode() allows injecting in between the tag of the root page element (creates BSPrinterRootPage::$headerCode) - +- New: BSPrinterAbstract::setId() allows all elements to have an id attribute added in _prepareStyle() diff --git a/PrinterAbstract.php b/PrinterAbstract.php index e8ad7d3..08a91ab 100644 --- a/PrinterAbstract.php +++ b/PrinterAbstract.php @@ -50,6 +50,12 @@ abstract class BSPrinterAbstract */ protected $cssClass = ':swap:'; + /** + * DOM ID of the element + * @var string + */ + protected $id; + /** * Fluent object instantiation */ @@ -86,6 +92,17 @@ abstract class BSPrinterAbstract return $this; } + /** + * Sets the DOM/CSS ID of the element + * + * @param string The ID + */ + public function setId($id) + { + $this->id = $id; + return $this; + } + /** * Returns a string of CSS style attributes * @@ -93,7 +110,7 @@ abstract class BSPrinterAbstract */ protected function _prepareStyle() { - if (empty($this->style) && empty($this->cssClass)) + if (empty($this->style) && empty($this->cssClass) && empty($this->id)) { return; } @@ -126,6 +143,10 @@ abstract class BSPrinterAbstract { $string .= ' style="' . $style . '"'; } + if ($this->id) + { + $string .= ' id="' . $this->id . '"'; + } return $string; } -- 2.22.5