/**
  * @param Icon $icon
  * @param array $options
  * @return string
  * @throws \InvalidArgumentException
  */
 protected function generateMarkup(Icon $icon, array $options)
 {
     if (empty($options['source'])) {
         throw new \InvalidArgumentException('[' . $icon->getIdentifier() . '] The option "source" is required and must not be empty', 1440754980);
     }
     $source = $options['source'];
     if (StringUtility::beginsWith($source, 'EXT:') || !StringUtility::beginsWith($source, '/')) {
         $source = GeneralUtility::getFileAbsFileName($source);
     }
     $source = PathUtility::getAbsoluteWebPath($source);
     return '<img src="' . htmlspecialchars($source) . '" width="' . $icon->getDimension()->getWidth() . '" height="' . $icon->getDimension()->getHeight() . '" />';
 }
Example #2
0
 /**
  *
  * @param Icon $icon
  * @param array $options
  * @author Benjamin Butschell <*****@*****.**>
  */
 public function prepareIconMarkup(Icon $icon, array $options = array())
 {
     // error checking
     if (empty($options['contentElementKey'])) {
         throw new \InvalidArgumentException('The option "contentElementKey" is required and must not be empty', 1440754978);
     }
     $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
     $this->storageRepository = $this->objectManager->get("MASK\\Mask\\Domain\\Repository\\StorageRepository");
     $this->extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['mask']);
     $this->contentElement = $this->storageRepository->loadElement("tt_content", $options["contentElementKey"]);
     $icon->setMarkup($this->generateMarkup($icon, $options));
 }
Example #3
0
 /**
  * Render the icon as HTML code
  *
  * @param string $alternativeMarkupIdentifier
  *
  * @return string
  */
 public function render($alternativeMarkupIdentifier = null)
 {
     $overlayIconMarkup = '';
     if ($this->overlayIcon !== null) {
         $overlayIconMarkup = '<span class="icon-overlay icon-' . htmlspecialchars($this->overlayIcon->getIdentifier()) . '">' . $this->overlayIcon->getMarkup() . '</span>';
     }
     return str_replace('{overlayMarkup}', $overlayIconMarkup, $this->wrappedIcon($alternativeMarkupIdentifier));
 }
 /**
  * @param Icon $icon
  * @param array $options
  */
 public function prepareIconMarkup(Icon $icon, array $options = array())
 {
     $icon->setMarkup($this->generateMarkup($icon, $options));
 }
 /**
  * @test
  */
 public function getIconWithInlineOptionReturnsCleanSvgMarkup()
 {
     $this->subject->prepareIconMarkup($this->icon, array('source' => $this->testFileName));
     $this->assertEquals('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill="#CD201F" d="M11 12l3-2v6H2v-6l3 2 3-2 3 2z"/></svg>', $this->icon->getMarkup(SvgIconProvider::MARKUP_IDENTIFIER_INLINE));
 }
Example #6
0
 /**
  * @test
  */
 public function getStateReturnsCorrectIdentifier()
 {
     $this->assertTrue($this->subject->getState()->equals(IconState::STATE_DISABLED));
 }
 /**
  * @test
  */
 public function prepareIconMarkupEXTSourceReferenceReturnsInstanceOfIconWithCorrectMarkup()
 {
     $this->subject->prepareIconMarkup($this->icon, array('source' => 'EXT:core/Resources/Public/Images/foo.png'));
     $this->assertEquals('<img src="typo3/sysext/core/Resources/Public/Images/foo.png" width="16" height="16" />', $this->icon->getMarkup());
 }
 /**
  * @test
  */
 public function prepareIconMarkupWithNameReturnsInstanceOfIconWithCorrectMarkup()
 {
     $this->subject->prepareIconMarkup($this->icon, array('name' => 'times'));
     $this->assertEquals('<span class="icon-unify"><i class="fa fa-times"></i></span>', $this->icon->getMarkup());
 }