コード例 #1
0
 /**
  * Render uri
  *
  * @param integer $after
  * @return string
  */
 public function render($after = 0)
 {
     $pid = $this->arguments['row']['pid'];
     $uid = $this->arguments['row']['uid'];
     $area = $this->arguments['area'];
     $sysLang = $this->arguments['row']['sys_language_uid'];
     $returnUri = rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'));
     if (FALSE === empty($area) && FALSE === empty($after)) {
         $after = '-' . $after;
     } else {
         $after = $pid;
     }
     $icon = MiscellaneousUtility::getIcon('actions-document-new');
     $uri = 'db_new_content_el.php?id=' . $pid . '&uid_pid=' . $after . '&colPos=' . ContentService::COLPOS_FLUXCONTENT . '&sys_language_uid=' . $sysLang . '&defVals[tt_content][tx_flux_parent]=' . $uid . '&defVals[tt_content][tx_flux_column]=' . $area . '&returnUrl=' . $returnUri;
     $title = LocalizationUtility::translate('new', 'Flux');
     return MiscellaneousUtility::wrapLink($icon, $uri, $title);
 }
コード例 #2
0
 /**
  * Render uri
  *
  * @param integer $after
  * @return string
  */
 public function render($after = 0)
 {
     $pid = $this->arguments['row']['pid'];
     $uid = $this->arguments['row']['uid'];
     $area = $this->arguments['area'];
     $sysLang = $this->arguments['row']['sys_language_uid'];
     $returnUri = urlencode($_SERVER['REQUEST_URI']);
     if ($area) {
         $returnUri .= '%23' . $area . '%3A' . $uid;
         if (0 < $after) {
             $returnUri .= '%3A-' . $after;
         }
     }
     $icon = MiscellaneousUtility::getIcon('actions-document-new', 'Insert new content element in this position');
     $uri = 'db_new_content_el.php?id=' . $pid . '&uid_pid=' . $pid . '&colPos=' . ContentService::COLPOS_FLUXCONTENT . '&sys_language_uid=' . $sysLang . '&defVals[tt_content][tx_flux_parent]=' . $uid . '&defVals[tt_content][tx_flux_column]=' . $area . '&returnUrl=' . $returnUri;
     return MiscellaneousUtility::wrapLink($icon, htmlspecialchars($uri));
 }
コード例 #3
0
ファイル: ClipBoardUtility.php プロジェクト: JostBaron/flux
 /**
  * @param string $relativeTo
  * @param boolean $reference
  * @return string
  */
 public static function createIconWithUrl($relativeTo, $reference = FALSE)
 {
     $reference = (bool) $reference;
     $data = self::getClipBoardData($reference);
     if (NULL === $data) {
         return '';
     }
     if (TRUE === $reference) {
         $icon = MiscellaneousUtility::getIcon('actions-insert-reference');
         $title = LocalizationUtility::translate('paste_reference', 'Flux');
     } else {
         $icon = MiscellaneousUtility::getIcon('actions-document-paste-after');
         $title = LocalizationUtility::translate('paste', 'Flux');
     }
     $clipBoard = new Clipboard();
     $clipBoard->initializeClipboard();
     $uri = $clipBoard->pasteUrl('tt_content', $relativeTo);
     return MiscellaneousUtility::wrapLink($icon, $uri, $title);
 }
コード例 #4
0
    /**
     * Builds a single Wizard item (one FCE) based on the
     * tab id, element id, configuration array and special
     * template identity (groupName:Relative/Path/File.html)
     *
     * @param string $tabId
     * @param string $id
     * @param Form $form
     * @param string $templateFileIdentity
     * @return string
     */
    protected function buildWizardTabItem($tabId, $id, $form, $templateFileIdentity)
    {
        if (TRUE === method_exists('FluidTYPO3\\Flux\\Utility\\MiscellaneousUtility', 'getIconForTemplate')) {
            $icon = MiscellaneousUtility::getIconForTemplate($form);
            $icon = $icon ? $icon : $this->defaultIcon;
        } else {
            $icon = $this->defaultIcon;
        }
        $description = $form->getDescription();
        if (0 === strpos($icon, '../')) {
            $icon = substr($icon, 2);
        }
        if ('/' === $icon[0]) {
            $icon = realpath(PATH_site . $icon);
        }
        if (TRUE === file_exists($icon) && TRUE === method_exists('FluidTYPO3\\Flux\\Utility\\MiscellaneousUtility', 'createIcon')) {
            $icon = '../..' . MiscellaneousUtility::createIcon($icon, $this->extConf['iconWidth'], $this->extConf['iconHeight']);
        }
        return sprintf('
			mod.wizards.newContentElement.wizardItems.%s.elements.%s {
				icon = %s
				title = %s
				description = %s
				tt_content_defValues {
					CType = fluidcontent_content
					tx_fed_fcefile = %s
				}
			}
			', $tabId, $id, $icon, $form->getLabel(), $description, $templateFileIdentity);
    }
コード例 #5
0
ファイル: PreviewView.php プロジェクト: busynoggin/flux
 /**
  * @codeCoverageIgnore
  * @param integer $contentElementUid
  * @param string $areaName
  * @return integer
  */
 protected function registerTargetContentAreaInSession($contentElementUid, $areaName)
 {
     if ('' === session_id()) {
         session_start();
     }
     $integer = MiscellaneousUtility::generateUniqueIntegerForFluxArea($contentElementUid, $areaName);
     $_SESSION['target' . $integer] = array($contentElementUid, $areaName);
     return $integer;
 }
コード例 #6
0
 /**
  * @param string $relativeTo
  * @param boolean $reference
  * @return string
  */
 public static function createIconWithUrl($relativeTo, $reference = FALSE)
 {
     $data = self::getClipBoardData($reference);
     if (NULL === $data) {
         return '';
     }
     $reference = (bool) $reference;
     $clipBoard = new \TYPO3\CMS\Backend\Clipboard\Clipboard();
     if (TRUE === $reference) {
         $label = 'Paste as reference in this position';
         $icon = 'actions-insert-reference';
     } else {
         $label = 'Paste in this position';
         $icon = 'actions-document-paste-after';
     }
     $icon = MiscellaneousUtility::getIcon($icon, $label);
     $uri = "javascript:top.content.list_frame.location.href=top.TS.PATH_typo3+'";
     $uri .= $clipBoard->pasteUrl('tt_content', $relativeTo);
     $uri .= "';";
     return MiscellaneousUtility::wrapLink($icon, $uri);
 }
コード例 #7
0
 /**
  * @dataProvider getGenerateUniqueIntegerForFluxAreaTestValues
  * @param integer $uid
  * @param string $name
  * @param integer $expected
  */
 public function testGenerateUniqueIntegerForFluxArea($uid, $name, $expected)
 {
     $result = MiscellaneousUtility::generateUniqueIntegerForFluxArea($uid, $name);
     $this->assertEquals($expected, $result);
 }
コード例 #8
0
 /**
  * @param array $configuration
  * @param string $groupLabel
  * @param mixed $value
  * @return string
  */
 protected function renderOptionGroup(array $configuration, $groupLabel, $value)
 {
     $optionGroup = '';
     foreach ($configuration as $form) {
         /** @var Form $form */
         $optionValue = $form->getOption('contentElementId');
         $selected = $optionValue === $value ? ' selected="selected"' : '';
         $label = $form->getLabel();
         $icon = MiscellaneousUtility::getIconForTemplate($form);
         $label = 0 === strpos($label, 'LLL:') ? $GLOBALS['LANG']->sL($label) : $label;
         $valueString = htmlspecialchars($optionValue);
         $labelString = htmlspecialchars($label);
         $optionGroup .= sprintf($this->templates['option'], $icon, $valueString, $selected, $labelString) . LF;
     }
     return sprintf($this->templates['optgroup'], htmlspecialchars($groupLabel), $optionGroup);
 }
コード例 #9
0
 /**
  * @param Form $form
  * @param array $parameters
  * @return string
  */
 protected function renderOption(Form $form, array $parameters)
 {
     $name = $parameters['itemFormElName'];
     $value = $parameters['itemFormElValue'];
     $fieldTSConfig = $parameters['fieldTSConfig'];
     $keepItems = isset($fieldTSConfig['keepItems']) ? explode(',', $fieldTSConfig['keepItems']) : NULL;
     $removeItems = isset($fieldTSConfig['removeItems']) ? explode(',', $fieldTSConfig['removeItems']) : NULL;
     $default = isset($fieldTSConfig['default']) ? $fieldTSConfig['default'] : NULL;
     $onChange = 'onclick="if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };"';
     $selector = '';
     try {
         $extension = $form->getExtensionName();
         $thumbnail = MiscellaneousUtility::getIconForTemplate($form);
         $template = pathinfo($form->getOption(Form::OPTION_TEMPLATEFILE), PATHINFO_FILENAME);
         $label = $form->getLabel();
         $optionValue = $extension . '->' . lcfirst($template);
         $selected = FALSE;
         if (TRUE === empty($value)) {
             if (FALSE === empty($default)) {
                 $selected = $optionValue == $default ? ' checked="checked"' : NULL;
             }
         } else {
             $selected = $optionValue == $value ? ' checked="checked"' : NULL;
         }
         $option = $this->getField($selected, $thumbnail, $label, $optionValue, $name, $onChange);
         if (FALSE === empty($keepItems)) {
             if (TRUE === in_array($optionValue, $keepItems)) {
                 $selector .= $option . LF;
             }
         } elseif (FALSE === empty($removeItems)) {
             if (FALSE === in_array($optionValue, $removeItems)) {
                 $selector .= $option . LF;
             }
         } else {
             $selector .= $option . LF;
         }
     } catch (\RuntimeException $error) {
         $this->configurationService->debug($error);
     }
     return $selector;
 }
コード例 #10
0
 /**
  * @param string $xml
  * @param array $removals
  * @param string $expected
  * @dataProvider getCleanFlexFormXmlTestValues
  * @test
  */
 public function testCleanFlexFormXml($xml, array $removals, $expected)
 {
     $result = MiscellaneousUtility::cleanFlexFormXml($xml, $removals);
     $this->assertEquals($expected, $result);
 }
コード例 #11
0
 /**
  * @param string $extension
  * @param string $template
  * @param array $parameters
  * @return string
  */
 protected function renderOption($extension, $template, array $parameters)
 {
     $name = $parameters['itemFormElName'];
     $value = $parameters['itemFormElValue'];
     $onChange = 'onclick="if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };"';
     $selector = '';
     try {
         $extensionName = ExtensionNamingUtility::getExtensionKey($extension);
         $paths = $this->configurationService->getPageConfiguration($extensionName);
         $templatePaths = new TemplatePaths($paths);
         $templatePathAndFilename = $templatePaths->resolveTemplateFileForControllerAndActionAndFormat('Page', $template);
         if (FALSE === file_exists($templatePathAndFilename)) {
             $this->configurationService->message('Missing template file: ' . $templatePathAndFilename, GeneralUtility::SYSLOG_SEVERITY_WARNING);
             return '';
         }
         $viewContext = new ViewContext($templatePathAndFilename, $extensionName);
         $viewContext->setTemplatePaths($templatePaths);
         $viewContext->setSectionName('Configuration');
         $form = $this->configurationService->getFormFromTemplateFile($viewContext);
         if (FALSE === $form instanceof Form) {
             $this->configurationService->message('Template file ' . $templatePathAndFilename . ' contains an unparsable Form definition', GeneralUtility::SYSLOG_SEVERITY_FATAL);
             return '';
         }
         if (FALSE === $form->getEnabled()) {
             $this->configurationService->message('Template file ' . $templatePathAndFilename . ' is disabled by configuration', GeneralUtility::SYSLOG_SEVERITY_NOTICE);
             return '';
         }
         $thumbnail = MiscellaneousUtility::getIconForTemplate($form);
         $label = $form->getLabel();
         $optionValue = $extension . '->' . $template;
         $selected = $optionValue == $value ? ' checked="checked"' : '';
         $option = '<label style="padding: 0.5em; border: 1px solid #CCC; display: inline-block; vertical-align: bottom; margin: 0 1em 1em 0; cursor: pointer; ' . ($selected ? 'background-color: #DDD;' : '') . '">';
         $option .= '<img src="' . $thumbnail . '" alt="' . $label . '" style="margin: 0.5em 0 0.5em 0; max-width: 196px; max-height: 128px;"/><br />';
         $option .= '<input type="radio" value="' . $optionValue . '"' . $selected . ' name="' . $name . '" ' . $onChange . ' /> ' . $label;
         $option .= '</label>';
         $selector .= $option . LF;
     } catch (\RuntimeException $error) {
         $this->configurationService->debug($error);
     }
     return $selector;
 }
コード例 #12
0
    /**
     * Builds a single Wizard item (one FCE) based on the
     * tab id, element id, configuration array and special
     * template identity (groupName:Relative/Path/File.html)
     *
     * @param string $tabId
     * @param string $id
     * @param Form $form
     * @param string $templateFileIdentity
     * @return string
     */
    protected function buildWizardTabItem($tabId, $id, $form, $templateFileIdentity)
    {
        if (TRUE === method_exists('FluidTYPO3\\Flux\\Utility\\MiscellaneousUtility', 'getIconForTemplate')) {
            $icon = MiscellaneousUtility::getIconForTemplate($form);
            $icon = $icon ? $icon : $this->defaultIcon;
        } else {
            $icon = $this->defaultIcon;
        }
        $description = $form->getDescription();
        if (0 === strpos($icon, '../')) {
            $icon = substr($icon, 2);
        }
        $iconIdentifier = NULL;
        if (TRUE === method_exists('FluidTYPO3\\Flux\\Utility\\MiscellaneousUtility', 'createIcon')) {
            if ('/' === $icon[0]) {
                $icon = realpath(PATH_site . $icon);
            }
            if (TRUE === file_exists($icon) && TRUE === is_file($icon)) {
                $extension = pathinfo($icon, PATHINFO_EXTENSION);
                switch (strtolower($extension)) {
                    case 'svg':
                    case 'svgz':
                        $iconProvider = SvgIconProvider::class;
                        break;
                    default:
                        $iconProvider = BitmapIconProvider::class;
                }
                $iconIdentifier = 'fluidcontent-' . $id;
                $iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
                $iconRegistry->registerIcon($iconIdentifier, $iconProvider, array('source' => $icon));
            }
        }
        $defaultValues = array();
        if ($form->hasOption(Form::OPTION_DEFAULT_VALUES)) {
            foreach ($form->getOption(Form::OPTION_DEFAULT_VALUES) as $key => $value) {
                $defaultValues[] = $key . ' = ' . $value;
            }
        }
        return sprintf('
			mod.wizards.newContentElement.wizardItems.%s.elements.%s {
				iconIdentifier = %s
				title = %s
				description = %s
				tt_content_defValues {
					%s
					CType = fluidcontent_content
					tx_fed_fcefile = %s
				}
			}
			', $tabId, $id, $iconIdentifier, $form->getLabel(), $description, implode(chr(10), $defaultValues), $templateFileIdentity);
    }
コード例 #13
0
 /**
  * @param string $extension
  * @param string $contentType
  * @param string $version
  * @return string
  */
 public function getIconFromVersion($extension, $contentType, $version = NULL)
 {
     $extensionKey = ExtensionNamingUtility::getExtensionKey($extension);
     $templatePathAndFilename = $this->resolveTemplateFileForVariant($extensionKey, $contentType, $extension, $version);
     $paths = $this->getViewConfigurationForExtensionName($extensionKey);
     $templatePaths = new TemplatePaths($paths);
     $viewContext = new ViewContext($templatePathAndFilename, $extensionKey);
     $viewContext->setTemplatePaths($templatePaths);
     $viewContext->setSectionName('Configuration');
     $form = FluxService::getFormFromTemplateFile($viewContext);
     if (FALSE === $form instanceof Form) {
         return '';
     } else {
         return MiscellaneousUtility::getIconForTemplate($form);
     }
 }
コード例 #14
0
 /**
  * @param string $qualifiedExtensionName
  * @param Form $form
  * @return void
  * @throws \RuntimeException
  */
 public function registerModuleBasedOnFluxForm($qualifiedExtensionName, Form $form)
 {
     $extensionKey = ExtensionNamingUtility::getExtensionKey($qualifiedExtensionName);
     $signature = ExtensionNamingUtility::getExtensionSignature($qualifiedExtensionName);
     $options = $form->getOption('Fluidbackend');
     $formId = $form->getName();
     $module = 'web';
     if (TRUE === isset($options[Constants::FORM_OPTION_MODULE_GROUP])) {
         $module = $options[Constants::FORM_OPTION_MODULE_GROUP];
     }
     $position = 'before:help';
     if (TRUE === isset($options[Constants::FORM_OPTION_MODULE_POSITION])) {
         $position = $options[Constants::FORM_OPTION_MODULE_POSITION];
     }
     $navigationComponent = '';
     if (TRUE === isset($options[Constants::FORM_OPTION_MODULE_PAGE_TREE]) && TRUE === (bool) $options[Constants::FORM_OPTION_MODULE_PAGE_TREE]) {
         $navigationComponent = 'typo3-pagetree';
     }
     $icon = MiscellaneousUtility::getIconForTemplate($form);
     if (TRUE === empty($icon)) {
         $icon = 'EXT:' . $extensionKey . '/ext_icon.gif';
     }
     if (NULL === $this->getResolver()->resolveFluxControllerClassNameByExtensionKeyAndAction($qualifiedExtensionName, 'render', 'Backend')) {
         throw new \RuntimeException('Attempt to register a Backend controller without an associated BackendController. Extension key: ' . $extensionKey, 1368826271);
     }
     $moduleConfiguration = array('access' => 'user,group', 'icon' => $icon, 'labels' => 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang_module_' . $formId . '.xlf');
     if (FALSE === empty($navigationComponent)) {
         $moduleConfiguration['navigationComponentId'] = $navigationComponent;
     }
     $moduleSignature = 'tx_' . $signature . '_' . ucfirst($formId);
     if (FALSE === isset($GLOBALS['TBE_MODULES'][$module])) {
         if (FALSE === strpos($position, ':')) {
             if ('top' === $position) {
                 $temp_TBE_MODULES = array($module => '');
                 $temp_TBE_MODULES = RecursiveArrayUtility::mergeRecursiveOverrule($temp_TBE_MODULES, $GLOBALS['TBE_MODULES']);
             } else {
                 $temp_TBE_MODULES = (array) $GLOBALS['TBE_MODULES'];
                 $temp_TBE_MODULES[$module] = '';
             }
         } else {
             list($command, $relativeKey) = explode(':', $position);
             foreach ($GLOBALS['TBE_MODULES'] as $key => $val) {
                 if ($key === $relativeKey) {
                     if ('before' === $command) {
                         $temp_TBE_MODULES[$module] = '';
                         $temp_TBE_MODULES[$key] = $val;
                     } else {
                         $temp_TBE_MODULES[$key] = $val;
                         $temp_TBE_MODULES[$module] = '';
                     }
                 } else {
                     $temp_TBE_MODULES[$key] = $val;
                 }
             }
         }
         $GLOBALS['TBE_MODULES'] = (array) $temp_TBE_MODULES;
         // register pseudo-module acting as group header
         $moduleConfiguration['labels'] = 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang_modulegroup.xlf';
         ExtensionUtility::registerModule($qualifiedExtensionName, $module, '', $position, array('Backend' => 'render,save'), $moduleConfiguration);
     }
     // register individual module in group
     $moduleConfiguration['labels'] = 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang_module_' . $formId . '.xlf';
     ExtensionUtility::registerModule($qualifiedExtensionName, $module, $moduleSignature, $position, array('Backend' => 'render,save'), $moduleConfiguration);
 }
コード例 #15
0
    /**
     * Builds a single Wizard item (one FCE) based on the
     * tab id, element id, configuration array and special
     * template identity (groupName:Relative/Path/File.html)
     *
     * @param string $tabId
     * @param string $id
     * @param Form $form
     * @param string $templateFileIdentity
     * @return string
     */
    protected function buildWizardTabItem($tabId, $id, $form, $templateFileIdentity)
    {
        $icon = MiscellaneousUtility::getIconForTemplate($form);
        $description = $form->getDescription();
        $iconFileRelativePath = $icon ? $icon : $this->defaultIcon;
        return sprintf('
			mod.wizards.newContentElement.wizardItems.%s.elements.%s {
				icon = %s
				title = %s
				description = %s
				tt_content_defValues {
					CType = fluidcontent_content
					tx_fed_fcefile = %s
				}
			}
			', $tabId, $id, $iconFileRelativePath, $form->getLabel(), $description, $templateFileIdentity);
    }
コード例 #16
0
ファイル: AbstractProvider.php プロジェクト: busynoggin/flux
 /**
  * Post-process record data for the table that this ConfigurationProvider
  * is attached to.
  *
  * @param string $operation TYPO3 operation identifier, i.e. "update", "new" etc.
  * @param integer $id The ID of the current record (which is sometimes now included in $row
  * @param array $row the record data, by reference. Changing fields' values changes the record's values just before saving
  * @param DataHandler $reference A reference to the \TYPO3\CMS\Core\DataHandling\DataHandler object that is currently saving the record
  * @param array $removals Allows overridden methods to pass an additional array of field names to remove from the stored Flux value
  * @return void
  */
 public function postProcessRecord($operation, $id, array &$row, DataHandler $reference, array $removals = array())
 {
     if ('update' === $operation) {
         $record = $reference->datamap[$this->tableName][$id];
         $stored = $this->recordService->getSingle($this->tableName, '*', $record['uid']);
         $fieldName = $this->getFieldName((array) $record);
         $dontProcess = NULL === $fieldName || FALSE === isset($row[$fieldName]) || FALSE === isset($record[$fieldName]['data']) || FALSE === is_array($record[$fieldName]['data']);
         if (TRUE === $dontProcess) {
             return;
         }
         $data = $record[$fieldName]['data'];
         foreach ($data as $sheetName => $sheetFields) {
             foreach ($sheetFields['lDEF'] as $sheetFieldName => $fieldDefinition) {
                 if ('_clear' === substr($sheetFieldName, -6)) {
                     array_push($removals, $sheetFieldName);
                 } else {
                     $clearFieldName = $sheetFieldName . '_clear';
                     $clearFieldValue = (bool) (TRUE === isset($data[$sheetName]['lDEF'][$clearFieldName]['vDEF']) ? $data[$sheetName]['lDEF'][$clearFieldName]['vDEF'] : 0);
                     $shouldClearField = 0 < $data[$sheetName]['lDEF'][$clearFieldName]['vDEF'];
                     if (TRUE === $shouldClearField || TRUE === $clearFieldValue) {
                         array_push($removals, $sheetFieldName);
                     }
                 }
             }
         }
         $stored[$fieldName] = MiscellaneousUtility::cleanFlexFormXml($row[$fieldName], $removals);
         $row[$fieldName] = $stored[$fieldName];
         $reference->datamap[$this->tableName][$id][$fieldName] = $row[$fieldName];
         $this->recordService->update($this->tableName, $stored);
     }
 }
コード例 #17
0
    /**
     * @param array $parameters
     * @param PageLayoutView|DatabaseRecordList $caller
     * @return string
     */
    public function addSubIcon(array $parameters, $caller = NULL)
    {
        $this->attachAssets();
        list($table, $uid, $record) = $parameters;
        $icon = NULL;
        if (NULL !== $caller) {
            $record = NULL === $record && 0 < $uid ? BackendUtility::getRecord($table, $uid) : $record;
            $cacheIdentity = $table . $uid . sha1(serialize($record));
            // filter 1: icon must not already be cached and both record and caller must be provided.
            if (TRUE === $this->cache->has($cacheIdentity)) {
                $icon = $this->cache->get($cacheIdentity);
            } elseif (NULL !== $record) {
                $field = $this->detectFirstFlexTypeFieldInTableFromPossibilities($table, array_keys($record));
                // filter 2: table must have one field defined as "flex" and record must include it.
                if (NULL !== $field && TRUE === isset($record[$field])) {
                    // we check the cache here because at this point, the cache key is decidedly
                    // unique and we have not yet consulted the (potentially costly) Provider.
                    $provider = $this->fluxService->resolvePrimaryConfigurationProvider($table, $field, $record);
                    // filter 3: a Provider must be resolved for the record.
                    if (NULL !== $provider) {
                        $form = $provider->getForm((array) $record);
                        if (NULL !== $form) {
                            $icon = MiscellaneousUtility::getIconForTemplate($form);
                            if (NULL !== $icon) {
                                $label = trim($form->getLabel());
                                $icon = '<img width="16" height="16" src="' . $icon . '" alt="' . $label . '"
									title="' . $label . '" class="" />';
                                $icon = sprintf($this->templates['iconWrapper'], $icon);
                            }
                        }
                    }
                }
                $this->cache->set($cacheIdentity, $icon);
            }
        }
        return $icon;
    }
コード例 #18
0
 /**
  * @param Form $form
  * @param array $parameters
  * @return string
  */
 protected function renderOption(Form $form, array $parameters)
 {
     $name = $parameters['itemFormElName'];
     $value = $parameters['itemFormElValue'];
     $onChange = 'onclick="if (confirm(TBE_EDITOR.labels.onChangeAlert) 
     && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };"';
     $selector = '';
     try {
         $extension = $form->getExtensionName();
         $thumbnail = MiscellaneousUtility::getIconForTemplate($form);
         $template = pathinfo($form->getOption(Form::OPTION_TEMPLATEFILE), PATHINFO_FILENAME);
         $formLabel = $form->getLabel();
         if (strpos($formLabel, 'LLL:') === 0) {
             $label = LocalizationUtility::translate($formLabel, $extension);
         } else {
             $label = $formLabel;
         }
         $optionValue = $extension . '->' . lcfirst($template);
         $selected = $optionValue == $value ? ' checked="checked"' : '';
         $option = '<label style="padding: 0.5em; border: 1px solid #CCC; display: inline-block; ' . 'vertical-align: bottom; margin: 0 1em 1em 0; cursor: pointer; ' . ($selected ? 'background-color: #DDD;' : '') . '">';
         $option .= '<img src="' . $thumbnail . '" alt="' . $label . '" style="margin: 0.5em 0 0.5em 0; ' . 'max-width: 196px; max-height: 128px;"/><br />';
         $option .= '<input type="radio" value="' . $optionValue . '"' . $selected . ' name="' . $name . '" ' . $onChange . ' /> ' . $label;
         $option .= '</label>';
         $selector .= $option . LF;
     } catch (\RuntimeException $error) {
         $this->configurationService->debug($error);
     }
     return $selector;
 }