diff --git a/src/Cloud/Decorator/HTMLCloud.php b/src/Cloud/Decorator/HTMLCloud.php deleted file mode 100644 index c2a4cef..0000000 --- a/src/Cloud/Decorator/HTMLCloud.php +++ /dev/null @@ -1,156 +0,0 @@ - array('class' => 'Zend_Tag_Cloud') - ); - - /** - * Separator for the single tags - * - * @var string - */ - protected $_separator = ' '; - - /** - * Get encoding - * - * @return string - */ - public function getEncoding() - { - return $this->_encoding; - } - - /** - * Set encoding - * - * @param string - * @return \Zend\Tag\Cloud\Decorator\HTMLCloud - */ - public function setEncoding($value) - { - $this->_encoding = (string) $value; - return $this; - } - - /** - * Set the HTML tags surrounding all tags - * - * @param array $htmlTags - * @return \Zend\Tag\Cloud\Decorator\HTMLCloud - */ - public function setHTMLTags(array $htmlTags) - { - $this->_htmlTags = $htmlTags; - return $this; - } - - /** - * Retrieve HTML tag map - * - * @return array - */ - public function getHTMLTags() - { - return $this->_htmlTags; - } - - /** - * Set the separator between the single tags - * - * @param string - * @return \Zend\Tag\Cloud\Decorator\HTMLCloud - */ - public function setSeparator($separator) - { - $this->_separator = $separator; - return $this; - } - - /** - * Get tag separator - * - * @return string - */ - public function getSeparator() - { - return $this->_separator; - } - - /** - * Defined by Zend_Tag_Cloud_Decorator_Cloud - * - * @param array $tags - * @return string - */ - public function render(array $tags) - { - $cloudHTML = implode($this->getSeparator(), $tags); - - $enc = $this->getEncoding(); - foreach ($this->getHTMLTags() as $key => $data) { - if (is_array($data)) { - $htmlTag = $key; - $attributes = ''; - - foreach ($data as $param => $value) { - $attributes .= ' ' . $param . '="' . htmlspecialchars($value, ENT_COMPAT, $enc) . '"'; - } - } else { - $htmlTag = $data; - $attributes = ''; - } - - $cloudHTML = sprintf('<%1$s%3$s>%2$s', $htmlTag, $cloudHTML, $attributes); - } - - return $cloudHTML; - } -} diff --git a/src/Cloud/Decorator/HTMLTag.php b/src/Cloud/Decorator/HTMLTag.php deleted file mode 100644 index c88d3eb..0000000 --- a/src/Cloud/Decorator/HTMLTag.php +++ /dev/null @@ -1,303 +0,0 @@ -_classList = $classList; - return $this; - } - - /** - * Get class list - * - * @return array - */ - public function getClassList() - { - return $this->_classList; - } - - /** - * Get encoding - * - * @return string - */ - public function getEncoding() - { - return $this->_encoding; - } - - /** - * Set encoding - * - * @param string $value - * @return \Zend\Tag\Cloud\Decorator\HTMLTag - */ - public function setEncoding($value) - { - $this->_encoding = (string) $value; - return $this; - } - - /** - * Set the font size unit - * - * Possible values are: em, ex, px, in, cm, mm, pt, pc and % - * - * @param string $fontSizeUnit - * @throws \Zend\Tag\Cloud\Decorator\Exception When an invalid fontsize unit is specified - * @return \Zend\Tag\Cloud\Decorator\HTMLTag - */ - public function setFontSizeUnit($fontSizeUnit) - { - if (!in_array($fontSizeUnit, $this->_alloweFontSizeUnits)) { - throw new Exception('Invalid fontsize unit specified'); - } - - $this->_fontSizeUnit = (string) $fontSizeUnit; - $this->setClassList(null); - return $this; - } - - /** - * Retrieve font size unit - * - * @return string - */ - public function getFontSizeUnit() - { - return $this->_fontSizeUnit; - } - /** - * Set the HTML tags surrounding the element - * - * @param array $htmlTags - * @return \Zend\Tag\Cloud\Decorator\HTMLTag - */ - public function setHTMLTags(array $htmlTags) - { - $this->_htmlTags = $htmlTags; - return $this; - } - - /** - * Get HTML tags map - * - * @return array - */ - public function getHTMLTags() - { - return $this->_htmlTags; - } - - /** - * Set maximum font size - * - * @param integer $maxFontSize - * @throws \Zend\Tag\Cloud\Decorator\Exception When fontsize is not numeric - * @return \Zend\Tag\Cloud\Decorator\HTMLTag - */ - public function setMaxFontSize($maxFontSize) - { - if (!is_numeric($maxFontSize)) { - throw new Exception('Fontsize must be numeric'); - } - - $this->_maxFontSize = (int) $maxFontSize; - $this->setClassList(null); - return $this; - } - - /** - * Retrieve maximum font size - * - * @return int - */ - public function getMaxFontSize() - { - return $this->_maxFontSize; - } - - /** - * Set minimum font size - * - * @param int $minFontSize - * @throws \Zend\Tag\Cloud\Decorator\Exception When fontsize is not numeric - * @return \Zend\Tag\Cloud\Decorator\HTMLTag - */ - public function setMinFontSize($minFontSize) - { - if (!is_numeric($minFontSize)) { - throw new Exception('Fontsize must be numeric'); - } - - $this->_minFontSize = (int) $minFontSize; - $this->setClassList(null); - return $this; - } - - /** - * Retrieve minimum font size - * - * @return int - */ - public function getMinFontSize() - { - return $this->_minFontSize; - } - - /** - * Defined by Zend_Tag_Cloud_Decorator_Tag - * - * @param \Zend\Tag\ItemList $tags - * @return array - */ - public function render(\Zend\Tag\ItemList $tags) - { - if (null === ($weightValues = $this->getClassList())) { - $weightValues = range($this->getMinFontSize(), $this->getMaxFontSize()); - } - - $tags->spreadWeightValues($weightValues); - - $result = array(); - - $enc = $this->getEncoding(); - foreach ($tags as $tag) { - if (null === ($classList = $this->getClassList())) { - $attribute = sprintf('style="font-size: %d%s;"', $tag->getParam('weightValue'), $this->getFontSizeUnit()); - } else { - $attribute = sprintf('class="%s"', htmlspecialchars($tag->getParam('weightValue'), ENT_COMPAT, $enc)); - } - - $tagHTML = sprintf('%s', htmlSpecialChars($tag->getParam('url'), ENT_COMPAT, $enc), $attribute, $tag->getTitle()); - - foreach ($this->getHTMLTags() as $key => $data) { - if (is_array($data)) { - $htmlTag = $key; - $attributes = ''; - - foreach ($data as $param => $value) { - $attributes .= ' ' . $param . '="' . htmlspecialchars($value, ENT_COMPAT, $enc) . '"'; - } - } else { - $htmlTag = $data; - $attributes = ''; - } - - $tagHTML = sprintf('<%1$s%3$s>%2$s', $htmlTag, $tagHTML, $attributes); - } - - $result[] = $tagHTML; - } - - return $result; - } -}