Ejemplo n.º 1
0
 /**
  * @param Configuration $configuration
  * @return FormBuilder
  */
 public static function create(Configuration $configuration)
 {
     /** @var FormBuilder $formBuilder */
     $formUtility = FormUtility::getObjectManager()->get(FormUtility::class);
     $formUtility->setConfiguration($configuration);
     return $formUtility;
 }
Ejemplo n.º 2
0
 /**
  * Revive the domain model of the accordant element.
  *
  * @param Element $element
  * @param array $userConfiguredElementTypoScript The configuration array
  * @param string $elementType The element type (e.g BUTTON)
  * @return void
  */
 protected function reviveElement(Element $element, array $userConfiguredElementTypoScript, $elementType = '')
 {
     // @todo Check $userConfiguredElementTypoScript
     if ($elementType === 'IMAGEBUTTON') {
         GeneralUtility::deprecationLog('EXT:form: The element IMAGEBUTTON is deprecated since TYPO3 CMS 7, will be removed with TYPO3 CMS 8.');
     }
     $element->setElementType($elementType);
     $element->setElementCounter($this->elementCounter->getElementId());
     $elementBuilder = ElementBuilder::create($this, $element, $userConfiguredElementTypoScript);
     $elementBuilder->setPartialPaths();
     $elementBuilder->setVisibility();
     if ($element->getElementType() == 'CONTENTELEMENT') {
         $attributeValue = '';
         if ($this->configuration->getContentElementRendering()) {
             $attributeValue = $this->formUtility->renderItem($userConfiguredElementTypoScript['cObj.'], $userConfiguredElementTypoScript['cObj']);
         }
         $element->setAdditionalArguments(array('content' => $attributeValue));
     } else {
         $this->setAttributes($elementBuilder, $element, $userConfiguredElementTypoScript);
         $userConfiguredElementTypoScript = $elementBuilder->getUserConfiguredElementTypoScript();
         $this->setValidationMessages($element);
         $this->signalSlotDispatcher->dispatch(__CLASS__, 'txFormAfterElementCreation', array($element, $this));
         // create all child elements
         $this->setChildElementsByIntegerKey($element, $userConfiguredElementTypoScript);
     }
 }
 /**
  * @param FormBuilder $formBuilder
  * @return CompatibilityLayerUtility
  */
 public static function create(FormBuilder $formBuilder)
 {
     /** @var CompatibilityLayerUtility $compatibilityService */
     $compatibilityService = \TYPO3\CMS\Form\Utility\FormUtility::getObjectManager()->get(CompatibilityLayerUtility::class);
     $compatibilityService->setFormBuilder($formBuilder);
     return $compatibilityService;
 }
Ejemplo n.º 4
0
 /**
  * @param FormBuilder $formBuilder
  * @param Element $element
  * @param array $userDefinedTypoScript
  * @return ElementBuilder
  */
 public static function create(FormBuilder $formBuilder, Element $element, array $userDefinedTypoScript)
 {
     /** @var ElementBuilder $elementBuilder */
     $elementBuilder = \TYPO3\CMS\Form\Utility\FormUtility::getObjectManager()->get(ElementBuilder::class);
     $elementBuilder->setFormBuilder($formBuilder);
     $elementBuilder->setElement($element);
     $elementBuilder->setUserConfiguredElementTyposcript($userDefinedTypoScript);
     return $elementBuilder;
 }
Ejemplo n.º 5
0
 /**
  * Extends a given default ControllerContext.
  *
  * @param \TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext
  * @return ControllerContext
  */
 public static function extend(\TYPO3\CMS\Extbase\Mvc\Controller\ControllerContext $source)
 {
     $controllerContext = \TYPO3\CMS\Form\Utility\FormUtility::getObjectManager()->get(ControllerContext::class);
     $propertyNames = ObjectAccess::getGettableProperties($source);
     foreach ($propertyNames as $propertyName => $propertyValue) {
         ObjectAccess::setProperty($controllerContext, $propertyName, $propertyValue);
     }
     return $controllerContext;
 }
Ejemplo n.º 6
0
 /**
  * Create child object from the classname of the model
  *
  * @param object $modelChild The childs model
  * @return \TYPO3\CMS\Form\View\Form\Element\AbstractElementView
  */
 public function createChildElementFromModel($modelChild)
 {
     $childElement = NULL;
     $class = \TYPO3\CMS\Form\Utility\FormUtility::getInstance()->getLastPartOfClassName($modelChild);
     $className = 'TYPO3\\CMS\\Form\\View\\Form\\FormView_Element_' . ucfirst($class);
     if (class_exists($className)) {
         $childElement = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($className, $modelChild);
     }
     return $childElement;
 }
Ejemplo n.º 7
0
 /**
  * Create child object from the classname of the model
  *
  * @param AbstractElement $modelChild The childs model
  * @return \TYPO3\CMS\Form\View\Form\Element\AbstractElementView
  */
 public function createChildElementFromModel($modelChild)
 {
     $childElement = NULL;
     $class = \TYPO3\CMS\Form\Utility\FormUtility::getInstance()->getLastPartOfClassName($modelChild);
     $className = 'TYPO3\\CMS\\Form\\View\\Form\\Element\\' . ucfirst($class) . 'ElementView';
     if (class_exists($className)) {
         $childElement = ObjectFactory::createFormObject($className, $modelChild);
     }
     return $childElement;
 }
Ejemplo n.º 8
0
 /**
  * @param \TYPO3\CMS\Form\Domain\Model\Element\AbstractElement $modelChild
  * @param int $spaces
  * @return string
  */
 protected function renderChild(\TYPO3\CMS\Form\Domain\Model\Element\AbstractElement $modelChild, $spaces)
 {
     $content = '';
     $class = \TYPO3\CMS\Form\Utility\FormUtility::getInstance()->getLastPartOfClassName($modelChild);
     $className = 'TYPO3\\CMS\\Form\\View\\Mail\\Plain\\Element\\' . ucfirst($class) . 'ElementView';
     if (class_exists($className)) {
         /** @var $childElement \TYPO3\CMS\Form\View\Mail\Plain\Element\AbstractElementView */
         $childElement = ObjectFactory::createFormObject($className, $modelChild, $spaces);
         $elementContent = $childElement->render();
         if ($elementContent != '') {
             $content = $childElement->render() . LF;
         }
     }
     return $content;
 }
Ejemplo n.º 9
0
 /**
  * Handles confirmation action, presenting the user submitted
  * data again for final confirmation.
  *
  * @param \TYPO3\CMS\Form\Domain\Model\ValidationElement $model
  * @return void
  */
 public function confirmationAction(ValidationElement $model)
 {
     $this->skipForeignFormProcessing();
     if (count($model->getIncomingFields()) === 0) {
         $this->sessionUtility->destroySession();
         $this->forward('show');
     }
     $this->controllerContext->setValidationElement($model);
     $form = $this->formBuilder->buildModel();
     // store uploaded files
     $this->sessionUtility->storeSession();
     $this->view->assign('model', $form);
     $message = $this->formUtility->renderItem($this->typoscript['confirmation.']['message.'], $this->typoscript['confirmation.']['message'], LocalizationUtility::translate('tx_form_view_confirmation.message', 'form'));
     $this->view->assign('message', $message);
 }
Ejemplo n.º 10
0
 /**
  * @param \TYPO3\CMS\Form\Domain\Model\Element\AbstractElement $modelChild
  * @param integer $spaces
  * @return string
  */
 protected function renderChild(\TYPO3\CMS\Form\Domain\Model\Element\AbstractElement $modelChild, $spaces)
 {
     $content = '';
     $class = \TYPO3\CMS\Form\Utility\FormUtility::getInstance()->getLastPartOfClassName($modelChild);
     $className = 'TYPO3\\CMS\\Form\\View\\Mail\\MailView_Plain_Element_' . ucfirst($class);
     if (class_exists($className)) {
         /** @var $childElement \TYPO3\CMS\Form\View\Mail\Plain\Element\AbstractElementView */
         $childElement = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($className, $modelChild, $spaces);
         $elementContent = $childElement->render();
         if ($elementContent != '') {
             $content = $childElement->render() . chr(10);
         }
     }
     return $content;
 }
Ejemplo n.º 11
0
 /**
  * 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.');
                 }
             }
         }
     }
 }
Ejemplo n.º 12
0
 /**
  * Create and add element by type.
  * This can be a derived Typoscript object by "<",
  * a form element, or a regular Typoscript object.
  *
  * @param AbstractElement $parentElement The parent for the new element
  * @param string $class Classname for the element
  * @param array $arguments Configuration array
  * @return void
  */
 public function setElementType(AbstractElement $parentElement, $class, array $arguments)
 {
     if (in_array($class, \TYPO3\CMS\Form\Utility\FormUtility::getInstance()->getFormObjects())) {
         $this->addElement($parentElement, $class, $arguments);
     } elseif ($this->disableContentElement === FALSE) {
         if ($class[0] === '<') {
             $key = trim(substr($class, 1));
             /** @var $typoscriptParser \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser */
             $typoscriptParser = GeneralUtility::makeInstance(\TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::class);
             $oldArguments = $arguments;
             list($class, $arguments) = $typoscriptParser->getVal($key, $this->frontendController->tmpl->setup);
             if (is_array($oldArguments) && count($oldArguments)) {
                 $arguments = array_replace_recursive($arguments, $oldArguments);
             }
             $this->timeTracker->incStackPointer();
             $contentObject = array('cObj' => $class, 'cObj.' => $arguments);
             $this->addElement($parentElement, 'content', $contentObject);
             $this->timeTracker->decStackPointer();
         } else {
             $contentObject = array('cObj' => $class, 'cObj.' => $arguments);
             $this->addElement($parentElement, 'content', $contentObject);
         }
     }
 }
Ejemplo n.º 13
0
 /**
  * Returns the type for the element wraps,
  * like <li class="csc-form-element csc-form-element-abstract">...</li>
  *
  * @return string
  */
 public function getElementWrapType()
 {
     $elementType = strtolower(\TYPO3\CMS\Form\Utility\FormUtility::getInstance()->getLastPartOfClassName($this->model));
     $wrapType = 'csc-form-element csc-form-element-' . $elementType;
     return $wrapType;
 }
<?php

if (!defined('TYPO3_MODE')) {
    die('Access denied.');
}
require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('cdsrc_recaptcha_form') . 'Classes/Domain/Model/Element/RecaptchaElement.php';
require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('cdsrc_recaptcha_form') . 'Classes/Domain/Model/Json/RecaptchaJsonElement.php';
require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('cdsrc_recaptcha_form') . 'Classes/Validation/RecaptchaValidator.php';
require_once \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('cdsrc_recaptcha_form') . 'Classes/View/Form/Element/RecaptchaElementView.php';
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['form']['hooks']['renderWizard'][] = 'CDSRC\\CdsrcRecaptchaForm\\Hooks\\WizardView->render';
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['form']['hooks']['JsonToTypoScript'][] = 'CDSRC\\CdsrcRecaptchaForm\\Hooks\\JsonToTypoScript';
$GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['TYPO3\\CMS\\Form\\Domain\\Factory\\JsonToTypoScript'] = array('className' => 'CDSRC\\CdsrcRecaptchaForm\\Domain\\Factory\\JsonToTypoScript');
\TYPO3\CMS\Form\Utility\FormUtility::getInstance()->setFormObjects(array_merge(\TYPO3\CMS\Form\Utility\FormUtility::getInstance()->getFormObjects(), array('RECAPTCHA')));
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:' . $_EXTKEY . '/Configuration/TSconfig/modWizards.ts">');
Ejemplo n.º 15
0
 /**
  * Get the additional value
  *
  * @return string The value of the additional
  */
 public function getAdditionalValue()
 {
     return htmlspecialchars($this->model->getAdditionalValue(\TYPO3\CMS\Form\Utility\FormUtility::getInstance()->getLastPartOfClassName($this, TRUE)));
 }
Ejemplo n.º 16
0
 /**
  * Create and add element by type.
  * This can be a derived Typoscript object by "<",
  * a form element, or a regular Typoscript object.
  *
  * @param \TYPO3\CMS\Form\Domain\Model\Element\AbstractElement $parentElement The parent for the new element
  * @param string $class Classname for the element
  * @param array $arguments Configuration array
  * @return void
  */
 public function setElementType(\TYPO3\CMS\Form\Domain\Model\Element\AbstractElement $parentElement, $class, array $arguments)
 {
     if (in_array($class, \TYPO3\CMS\Form\Utility\FormUtility::getInstance()->getFormObjects())) {
         $this->addElement($parentElement, $class, $arguments);
     } elseif ($this->disableContentElement === FALSE) {
         if (substr($class, 0, 1) == '<') {
             $key = trim(substr($class, 1));
             /** @var $typoscriptParser \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser */
             $typoscriptParser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser');
             $oldArguments = $arguments;
             list($class, $arguments) = $typoscriptParser->getVal($key, $GLOBALS['TSFE']->tmpl->setup);
             if (is_array($oldArguments) && count($oldArguments)) {
                 $arguments = $this->getLocalConentObject()->joinTSarrays($arguments, $oldArguments);
             }
             $GLOBALS['TT']->incStackPointer();
             $contentObject = array('cObj' => $class, 'cObj.' => $arguments);
             $this->addElement($parentElement, 'content', $contentObject);
             $GLOBALS['TT']->decStackPointer();
         } else {
             $contentObject = array('cObj' => $class, 'cObj.' => $arguments);
             $this->addElement($parentElement, 'content', $contentObject);
         }
     }
 }
Ejemplo n.º 17
0
 /**
  * Render the processor message
  *
  * @param string $messageType
  * @return string
  */
 protected function renderMessage($messageType)
 {
     return $this->formUtility->renderItem($this->typoScript['messages.'][$messageType . '.'], $this->typoScript['messages.'][$messageType], $this->getLocalLanguageLabel($messageType));
 }
Ejemplo n.º 18
0
 /**
  * @return Configuration
  */
 public static function create()
 {
     return \TYPO3\CMS\Form\Utility\FormUtility::getObjectManager()->get(Configuration::class);
 }
Ejemplo n.º 19
0
 /**
  * Set the message, like 'required' for the validation rule
  * and substitutes markers for values, like %maximum
  *
  *
  * @param mixed $message Message as string or TS
  * @param NULL|string $type Name of the cObj
  * @param string $messageType message or error
  * @return string
  */
 public function renderMessage($message = null, $type = null, $messageType = 'message')
 {
     $message = $this->formUtility->renderItem($message, $type, $this->getLocalLanguageLabel($messageType));
     return $this->substituteMarkers($message);
 }
		show :=addToList(login)
	}
	');
}
// Page module hook
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'][$_EXTKEY] = 'EXT:' . $_EXTKEY . '/Classes/Hooks/CmsLayout.php:TYPO3\\CMS\\Felogin\\Hooks\\CmsLayout';
/**
 * Extension: form
 * File: C:/xampp/htdocs/typo3_6.2.14/typo3/sysext/form/ext_localconf.php
 */
$_EXTKEY = 'form';
$_EXTCONF = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY];
if (!defined('TYPO3_MODE')) {
    die('Access denied.');
}
\TYPO3\CMS\Form\Utility\FormUtility::getInstance()->initializeFormObjects()->initializePageTsConfig();
/**
 * Extension: impexp
 * File: C:/xampp/htdocs/typo3_6.2.14/typo3/sysext/impexp/ext_localconf.php
 */
$_EXTKEY = 'impexp';
$_EXTCONF = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$_EXTKEY];
if (!defined('TYPO3_MODE')) {
    die('Access denied.');
}
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/backend.php']['constructPostProcess'][] = 'TYPO3\\CMS\\Impexp\\Hook\\BackendControllerHook->addJavaScript';
/**
 * Extension: lowlevel
 * File: C:/xampp/htdocs/typo3_6.2.14/typo3/sysext/lowlevel/ext_localconf.php
 */
$_EXTKEY = 'lowlevel';
Ejemplo n.º 21
0
 /**
  * Set the element type of the object
  *
  * Checks if the typoscript object is part of the FORM or has a predefined
  * class for name or header object
  *
  * @param AbstractJsonElement $parentElement The parent object
  * @param string $class A predefined class
  * @param array $arguments Configuration array
  * @return void
  */
 private function setElementType(AbstractJsonElement $parentElement, $class, array $arguments)
 {
     if (in_array($class, \TYPO3\CMS\Form\Utility\FormUtility::getInstance()->getFormObjects())) {
         if (strstr($arguments['class'], 'predefined-name')) {
             $class = 'NAME';
         }
         $this->addElement($parentElement, $class, $arguments);
     }
 }