本文整理汇总了PHP中TYPO3\CMS\Core\TypoScript\TemplateService类的典型用法代码示例。如果您正苦于以下问题:PHP TemplateService类的具体用法?PHP TemplateService怎么用?PHP TemplateService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TemplateService类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setOptions
/**
* Set the options for this object
*
* @param array $parameters Configuration array
* @return void
*/
protected function setOptions(array $parameters)
{
if (is_array($parameters)) {
$keys = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($parameters);
foreach ($keys as $key) {
$class = $parameters[$key];
if ((int) $key && strpos($key, '.') === false) {
if (isset($parameters[$key . '.']) && $class === 'OPTION') {
$childElementArguments = $parameters[$key . '.'];
if (isset($childElementArguments['selected'])) {
$childElementArguments['attributes']['selected'] = $childElementArguments['selected'];
unset($childElementArguments['selected']);
}
if (isset($childElementArguments['value'])) {
$childElementArguments['attributes']['value'] = $childElementArguments['value'];
unset($childElementArguments['value']);
}
if (isset($childElementArguments['data']) && !isset($childElementArguments['text'])) {
// preserve backward compatibility by rewriting data to text
$childElementArguments['text'] = $childElementArguments['data'];
}
$this->configuration['options'][] = $childElementArguments;
}
}
}
}
}
示例2: process
/**
* The main method called by the controller
*
* Iterates over the configured post processors and calls them with their
* own settings
*
* @return string HTML messages from the called processors
*/
public function process()
{
$html = '';
if (is_array($this->postProcessorTypoScript)) {
$keys = TemplateService::sortedKeyList($this->postProcessorTypoScript);
foreach ($keys as $key) {
if (!(int) $key || strpos($key, '.') !== false) {
continue;
}
$className = false;
$processorName = $this->postProcessorTypoScript[$key];
$processorArguments = array();
if (isset($this->postProcessorTypoScript[$key . '.'])) {
$processorArguments = $this->postProcessorTypoScript[$key . '.'];
}
if (class_exists($processorName, true)) {
$className = $processorName;
} else {
$classNameExpanded = 'TYPO3\\CMS\\Form\\PostProcess\\' . ucfirst(strtolower($processorName)) . 'PostProcessor';
if (class_exists($classNameExpanded, true)) {
$className = $classNameExpanded;
}
}
if ($className !== false) {
$processor = $this->objectManager->get($className, $this->form, $processorArguments);
if ($processor instanceof PostProcessorInterface) {
$processor->setControllerContext($this->controllerContext);
$html .= $processor->process();
}
}
}
}
return $html;
}
示例3: make
/**
* Generates a frameset based on input configuration in a TypoScript array.
*
* @param array $setup The TypoScript properties of the PAGE object property "frameSet.". See link.
* @return string A <frameset> tag.
* @see TSpagegen::renderContentWithHeader()
* @todo Define visibility
*/
public function make($setup)
{
$content = '';
if (is_array($setup)) {
$sKeyArray = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($setup);
foreach ($sKeyArray as $theKey) {
$theValue = $setup[$theKey];
if ((int) $theKey && ($conf = $setup[$theKey . '.'])) {
switch ($theValue) {
case 'FRAME':
$typeNum = (int) $GLOBALS['TSFE']->tmpl->setup[$conf['obj'] . '.']['typeNum'];
if (!$conf['src'] && !$typeNum) {
$typeNum = -1;
}
$content .= '<frame' . $this->frameParams($conf, $typeNum) . ' />' . LF;
break;
case 'FRAMESET':
$frameset = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\FramesetRenderer');
$content .= $frameset->make($conf) . LF;
break;
}
}
}
return '<frameset' . $this->framesetParams($setup) . '>' . LF . $content . '</frameset>';
}
}
示例4: setVarious
/**
* Set the various properties for the element
*
* For this element this is the prefix, suffix and middleName if they will
* be shown in the form
*
* @param array $parameters Configuration array
* @return void
*/
protected function setVarious(array $parameters)
{
if (is_array($parameters)) {
$keys = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($parameters);
foreach ($keys as $key) {
$class = $parameters[$key];
if ((int) $key && strpos($key, '.') === FALSE) {
if (isset($parameters[$key . '.'])) {
$childElementArguments = $parameters[$key . '.'];
if (in_array($childElementArguments['name'], array('prefix', 'suffix', 'middleName'))) {
$this->configuration['various'][$childElementArguments['name']] = TRUE;
}
}
}
}
}
}
示例5: getChildElementsByIntegerKey
/**
* Rendering of a "numerical array" of Form objects from TypoScript
* Creates new object for each element found
*
* @param AbstractJsonElement $parentElement Parent model object
* @param array $typoscript Configuration array
* @return void
*/
protected function getChildElementsByIntegerKey(AbstractJsonElement $parentElement, array $typoscript)
{
if (is_array($typoscript)) {
$keys = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($typoscript);
foreach ($keys as $key) {
$class = $typoscript[$key];
if ((int) $key && strpos($key, '.') === FALSE) {
if (isset($typoscript[$key . '.'])) {
$elementArguments = $typoscript[$key . '.'];
} else {
$elementArguments = array();
}
$this->setElementType($parentElement, $class, $elementArguments);
}
}
}
}
示例6: getChildElementsByIntegerKey
/**
* Rendering of a "numerical array" of Form objects from TypoScript
* Creates new object for each element found
*
* @param \TYPO3\CMS\Form\Domain\Model\Json\AbstractJsonElement $parentElement Parent model object
* @param array $arguments Configuration array
* @return void
*/
protected function getChildElementsByIntegerKey(\TYPO3\CMS\Form\Domain\Model\Json\AbstractJsonElement $parentElement, array $typoscript)
{
if (is_array($typoscript)) {
$keys = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($typoscript);
foreach ($keys as $key) {
$class = $typoscript[$key];
if (intval($key) && !strstr($key, '.')) {
if (isset($typoscript[$key . '.'])) {
$elementArguments = $typoscript[$key . '.'];
} else {
$elementArguments = array();
}
$this->setElementType($parentElement, $class, $elementArguments);
}
}
}
}
示例7: process
/**
* Check for the availability of processors, defined in TypoScript, and use them for data processing
*
* @param ContentObjectRenderer $cObject
* @param array $configuration Configuration array
* @param array $variables the variables to be processed
* @return array the processed data and variables as key/value store
* @throws \UnexpectedValueException If a processor class does not exist
*/
public function process(ContentObjectRenderer $cObject, array $configuration, array $variables)
{
if (!empty($configuration['dataProcessing.']) && is_array($configuration['dataProcessing.'])) {
$processors = $configuration['dataProcessing.'];
$processorKeys = TemplateService::sortedKeyList($processors);
foreach ($processorKeys as $key) {
$className = $processors[$key];
if (!class_exists($className)) {
throw new \UnexpectedValueException('Processor class name "' . $className . '" does not exist!', 1427455378);
}
if (!in_array(DataProcessorInterface::class, class_implements($className), true)) {
throw new \UnexpectedValueException('Processor with class name "' . $className . '" ' . 'must implement interface "' . DataProcessorInterface::class . '"', 1427455377);
}
$processorConfiguration = isset($processors[$key . '.']) ? $processors[$key . '.'] : array();
$variables = GeneralUtility::makeInstance($className)->process($cObject, $configuration, $processorConfiguration, $variables);
}
}
return $variables;
}
示例8: setOptions
/**
* Set the options for this object
*
* @param array $parameters Configuration array
* @return void
*/
protected function setOptions(array $parameters)
{
if (is_array($parameters)) {
$keys = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($parameters);
foreach ($keys as $key) {
$class = $parameters[$key];
if (intval($key) && !strstr($key, '.')) {
if (isset($parameters[$key . '.']) && $class === 'OPTION') {
$childElementArguments = $parameters[$key . '.'];
if (isset($childElementArguments['selected'])) {
$childElementArguments['attributes']['selected'] = $childElementArguments['selected'];
unset($childElementArguments['selected']);
}
$this->configuration['options'][] = $childElementArguments;
}
}
}
}
}
示例9: setOptions
/**
* Set the options for this object
*
* @param array $parameters Configuration array
* @return void
*/
protected function setOptions(array $parameters)
{
if (is_array($parameters)) {
$keys = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($parameters);
foreach ($keys as $key) {
$class = $parameters[$key];
if ((int) $key && strpos($key, '.') === FALSE) {
if (isset($parameters[$key . '.']) && $class === 'RADIO') {
$childElementArguments = $parameters[$key . '.'];
if (isset($childElementArguments['checked'])) {
$childElementArguments['attributes']['selected'] = 'selected';
unset($childElementArguments['checked']);
}
if (isset($childElementArguments['label.'])) {
$childElementArguments['data'] = $childElementArguments['label.']['value'];
unset($childElementArguments['label.']);
}
$this->configuration['options'][] = $childElementArguments;
}
}
}
}
}
示例10: buildRules
/**
* Build validation rules from typoscript.
* The old breakOnError property are no longer supported
*
* @param array $rawArgument
* @return void
*/
public function buildRules(array $rawArgument = array())
{
$userConfiguredFormTyposcript = $this->configuration->getTypoScript();
$rulesTyposcript = isset($userConfiguredFormTyposcript['rules.']) ? $userConfiguredFormTyposcript['rules.'] : null;
$this->rules[$this->configuration->getPrefix()] = array();
if (is_array($rulesTyposcript)) {
$keys = TemplateService::sortedKeyList($rulesTyposcript);
foreach ($keys as $key) {
$ruleName = $rulesTyposcript[$key];
$validatorClassName = $this->typoScriptRepository->getRegisteredClassName($ruleName, 'registeredValidators');
if ($validatorClassName === null) {
throw new \RuntimeException('Class "' . $validatorClassName . '" not registered via typoscript.');
}
if ((int) $key && strpos($key, '.') === false) {
$ruleArguments = $rulesTyposcript[$key . '.'];
$fieldName = $this->formUtility->sanitizeNameAttribute($ruleArguments['element']);
// remove unsupported validator options
$validatorOptions = $ruleArguments;
$validatorOptions['errorMessage'] = array($ruleArguments['error.'], $ruleArguments['error']);
$keysToRemove = array_flip(array('breakOnError', 'message', 'message.', 'error', 'error.', 'showMessage'));
$validatorOptions = array_diff_key($validatorOptions, $keysToRemove);
// Instantiate the validator to check if all required options are assigned
// and to use the validator message rendering function to pre-render the mandatory message
/** @var AbstractValidator $validator */
$validator = $this->objectManager->get($validatorClassName, $validatorOptions);
if ($validator instanceof AbstractValidator) {
$validator->setRawArgument($rawArgument);
$validator->setFormUtility($this->formUtility);
if ((int) $ruleArguments['showMessage'] === 1) {
$mandatoryMessage = $validator->renderMessage($ruleArguments['message.'], $ruleArguments['message']);
} else {
$mandatoryMessage = NULL;
}
$this->rules[$this->configuration->getPrefix()][$fieldName][] = array('validator' => $validator, 'validatorName' => $validatorClassName, 'validatorOptions' => $validatorOptions, 'mandatoryMessage' => $mandatoryMessage);
} else {
throw new \RuntimeException('Class "' . $validatorClassName . '" could not be loaded.');
}
}
}
}
}
示例11: stdWrap_orderedStdWrap
/**
* orderedStdWrap
* Calls stdWrap for each entry in the provided array
*
* @param string $content Input value undergoing processing in this function.
* @param array $conf stdWrap properties for orderedStdWrap.
* @return string The processed input value
*/
public function stdWrap_orderedStdWrap($content = '', $conf = array())
{
$sortedKeysArray = TemplateService::sortedKeyList($conf['orderedStdWrap.'], true);
foreach ($sortedKeysArray as $key) {
$content = $this->stdWrap($content, $conf['orderedStdWrap.'][$key . '.']);
}
return $content;
}
示例12: handleIncomingValues
/**
* Handles the incoming form data
*
* @param Element $element
* @param array $userConfiguredElementTypoScript
* @return array
*/
protected function handleIncomingValues(Element $element, array $userConfiguredElementTypoScript)
{
if (!$this->getIncomingData()) {
return;
}
$elementName = $element->getName();
if ($element->getHtmlAttribute('value') !== null) {
$modelValue = $element->getHtmlAttribute('value');
} else {
$modelValue = $element->getAdditionalArgument('value');
}
if ($this->getIncomingData()->getIncomingField($elementName) !== null) {
/* filter values and set it back to incoming fields */
/* remove xss every time */
$userConfiguredElementTypoScript['filters.'][-1] = 'removexss';
$keys = TemplateService::sortedKeyList($userConfiguredElementTypoScript['filters.']);
foreach ($keys as $key) {
$class = $userConfiguredElementTypoScript['filters.'][$key];
if ((int) $key && strpos($key, '.') === false) {
$filterArguments = $userConfiguredElementTypoScript['filters.'][$key . '.'];
$filterClassName = $this->typoScriptRepository->getRegisteredClassName((string) $class, 'registeredFilters');
if ($filterClassName !== null) {
// toDo: handel array values
if (is_string($this->getIncomingData()->getIncomingField($elementName))) {
if (is_null($filterArguments)) {
$filter = $this->objectManager->get($filterClassName);
} else {
$filter = $this->objectManager->get($filterClassName, $filterArguments);
}
if ($filter) {
$value = $filter->filter($this->getIncomingData()->getIncomingField($elementName));
$this->getIncomingData()->setIncomingField($elementName, $value);
} else {
throw new \RuntimeException('Class "' . $filterClassName . '" could not be loaded.');
}
}
} else {
throw new \RuntimeException('Class "' . $filterClassName . '" not registered via TypoScript.');
}
}
}
if ($element->getHtmlAttribute('value') !== null) {
$element->setHtmlAttribute('value', $this->getIncomingData()->getIncomingField($elementName));
} else {
$element->setAdditionalArgument('value', $this->getIncomingData()->getIncomingField($elementName));
}
}
$this->signalSlotDispatcher->dispatch(__CLASS__, 'txFormHandleIncomingValues', array($element, $this->getIncomingData(), $modelValue, $this));
}
示例13: sortTypoScriptKeyList
/**
* Wrapper method for \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList
* (makes unit testing possible)
*
* @return array
* @deprecated in TYPO3 CMS 7, does not trigger deprecation log in 6.2
*/
public function sortTypoScriptKeyList()
{
return \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($this->typoScript);
}
示例14: make
/**
* The actual rendering of the image file.
* Basically sets the dimensions, the background color, the traverses the array of GIFBUILDER objects and finally setting the transparent color if defined.
* Creates a GDlib resource in $this->im and works on that
* Called by gifBuild()
*
* @return void
* @access private
* @see gifBuild()
*/
public function make()
{
// Get trivial data
$XY = $this->XY;
// Reset internal properties
$this->saveAlphaLayer = false;
// Gif-start
$this->im = imagecreatetruecolor($XY[0], $XY[1]);
$this->w = $XY[0];
$this->h = $XY[1];
// Transparent layer as background if set and requirements are met
if (!empty($this->setup['backColor']) && $this->setup['backColor'] === 'transparent' && $this->png_truecolor && !$this->setup['reduceColors'] && (empty($this->setup['format']) || $this->setup['format'] === 'png')) {
// Set transparency properties
imagesavealpha($this->im, true);
// Fill with a transparent background
$transparentColor = imagecolorallocatealpha($this->im, 0, 0, 0, 127);
imagefill($this->im, 0, 0, $transparentColor);
// Set internal properties to keep the transparency over the rendering process
$this->saveAlphaLayer = true;
// Force PNG in case no format is set
$this->setup['format'] = 'png';
$BGcols = array();
} else {
// Fill the background with the given color
$BGcols = $this->convertColor($this->setup['backColor']);
$Bcolor = ImageColorAllocate($this->im, $BGcols[0], $BGcols[1], $BGcols[2]);
ImageFilledRectangle($this->im, 0, 0, $XY[0], $XY[1], $Bcolor);
}
// Traverse the GIFBUILDER objects an render each one:
if (is_array($this->setup)) {
$sKeyArray = TemplateService::sortedKeyList($this->setup);
foreach ($sKeyArray as $theKey) {
$theValue = $this->setup[$theKey];
if ((int) $theKey && ($conf = $this->setup[$theKey . '.'])) {
// apply stdWrap to all properties, except for TEXT objects
// all properties of the TEXT sub-object have already been stdWrap-ped
// before in ->checkTextObj()
if ($theValue !== 'TEXT') {
$isStdWrapped = array();
foreach ($conf as $key => $value) {
$parameter = rtrim($key, '.');
if (!$isStdWrapped[$parameter] && isset($conf[$parameter . '.'])) {
$conf[$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter . '.']);
$isStdWrapped[$parameter] = 1;
}
}
}
switch ($theValue) {
case 'IMAGE':
if ($conf['mask']) {
$this->maskImageOntoImage($this->im, $conf, $this->workArea);
} else {
$this->copyImageOntoImage($this->im, $conf, $this->workArea);
}
break;
case 'TEXT':
if (!$conf['hide']) {
if (is_array($conf['shadow.'])) {
$isStdWrapped = array();
foreach ($conf['shadow.'] as $key => $value) {
$parameter = rtrim($key, '.');
if (!$isStdWrapped[$parameter] && isset($conf[$parameter . '.'])) {
$conf['shadow.'][$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter . '.']);
$isStdWrapped[$parameter] = 1;
}
}
$this->makeShadow($this->im, $conf['shadow.'], $this->workArea, $conf);
}
if (is_array($conf['emboss.'])) {
$isStdWrapped = array();
foreach ($conf['emboss.'] as $key => $value) {
$parameter = rtrim($key, '.');
if (!$isStdWrapped[$parameter] && isset($conf[$parameter . '.'])) {
$conf['emboss.'][$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter . '.']);
$isStdWrapped[$parameter] = 1;
}
}
$this->makeEmboss($this->im, $conf['emboss.'], $this->workArea, $conf);
}
if (is_array($conf['outline.'])) {
$isStdWrapped = array();
foreach ($conf['outline.'] as $key => $value) {
$parameter = rtrim($key, '.');
if (!$isStdWrapped[$parameter] && isset($conf[$parameter . '.'])) {
$conf['outline.'][$parameter] = $this->cObj->stdWrap($conf[$parameter], $conf[$parameter . '.']);
$isStdWrapped[$parameter] = 1;
}
}
$this->makeOutline($this->im, $conf['outline.'], $this->workArea, $conf);
}
//.........这里部分代码省略.........
示例15: setRules
/**
* Set the validation rules
*
* Makes the validation object and adds rules to it
*
* @param array $typoscript TypoScript
* @return \TYPO3\CMS\Form\Utility\ValidatorUtility The validation object
*/
public function setRules(array $typoscript)
{
$rulesTyposcript = isset($typoscript['rules.']) ? $typoscript['rules.'] : NULL;
/** @var $rulesClass \TYPO3\CMS\Form\Utility\ValidatorUtility */
$rulesClass = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Form\\Utility\\ValidatorUtility', $rulesTyposcript);
// singleton
if (is_array($rulesTyposcript)) {
$keys = \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList($rulesTyposcript);
foreach ($keys as $key) {
$class = $rulesTyposcript[$key];
if (intval($key) && !strstr($key, '.')) {
$elementArguments = $rulesTyposcript[$key . '.'];
$rule = $rulesClass->createRule($class, $elementArguments);
$rule->setFieldName($elementArguments['element']);
$breakOnError = isset($elementArguments['breakOnError']) ? $elementArguments['breakOnError'] : FALSE;
$rulesClass->addRule($rule, $elementArguments['element'], $breakOnError);
}
}
}
return $rulesClass;
}