first commit
This commit is contained in:
commit
1218dd1517
12716 files changed
+989233
No files matched your search
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Install\ViewHelpers;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* Render value of a constant
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ConstantViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* Initialize arguments
|
||||
*/
|
||||
public function initializeArguments()
|
||||
{
|
||||
$this->registerArgument('name', 'string', 'Name of the constant', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a constant
|
||||
*
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
*
|
||||
* @return string Value of constant
|
||||
*/
|
||||
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
|
||||
{
|
||||
return constant($arguments['name']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Install\ViewHelpers;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
/**
|
||||
* A ViewHelper exception
|
||||
*/
|
||||
class Exception extends \TYPO3\CMS\Install\Exception
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,353 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
namespace TYPO3\CMS\Install\ViewHelpers\Form;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Localization\LanguageService;
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Fluid\ViewHelpers\FormViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractTagBasedViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\TagBuilder;
|
||||
|
||||
/**
|
||||
* ViewHelper for rendering extension configuration forms
|
||||
* @internal
|
||||
*/
|
||||
class TypoScriptConstantsViewHelper extends AbstractTagBasedViewHelper
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
public $viewHelperMapping = [
|
||||
'int' => 'renderIntegerField',
|
||||
'int+' => 'renderPositiveIntegerField',
|
||||
'integer' => 'renderIntegerField',
|
||||
'color' => 'renderColorPicker',
|
||||
'wrap' => 'renderWrapField',
|
||||
'offset' => 'renderOffsetField',
|
||||
'options' => 'renderOptionSelect',
|
||||
'boolean' => 'renderCheckbox',
|
||||
'user' => 'renderUserFunction',
|
||||
'small' => 'renderSmallTextField',
|
||||
'string' => 'renderTextField',
|
||||
'input' => 'renderTextField', // only for backwards compatibility, many extensions depend on that
|
||||
'default' => 'renderTextField' // only for backwards compatibility, many extensions depend on that
|
||||
];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $tagName = 'input';
|
||||
|
||||
/**
|
||||
* Initialize arguments of this ViewHelper
|
||||
*/
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
$this->registerArgument('name', 'string', 'Name of input tag');
|
||||
$this->registerArgument('value', 'mixed', 'Value of input tag');
|
||||
$this->registerArgument('configuration', 'array', '', true);
|
||||
$this->registerUniversalTagAttributes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a fresh instance of $this->tag each time this VH is called.
|
||||
*/
|
||||
public function initialize()
|
||||
{
|
||||
$this->setTagBuilder(new TagBuilder($this->tagName));
|
||||
parent::initialize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render
|
||||
*
|
||||
* @return string the rendered tag
|
||||
*/
|
||||
public function render(): string
|
||||
{
|
||||
/** @var array $configuration */
|
||||
$configuration = $this->arguments['configuration'];
|
||||
if (isset($this->viewHelperMapping[$configuration['type']]) && method_exists($this, $this->viewHelperMapping[$configuration['type']])) {
|
||||
$input = $this->{$this->viewHelperMapping[$configuration['type']]}($configuration);
|
||||
} else {
|
||||
$input = $this->{$this->viewHelperMapping['default']}($configuration);
|
||||
}
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render field of type color picker
|
||||
*
|
||||
* @param array $configuration
|
||||
* @return string
|
||||
*/
|
||||
protected function renderColorPicker(array $configuration): string
|
||||
{
|
||||
$elementName = $this->getName($configuration);
|
||||
|
||||
// configure the field
|
||||
$this->tag->setTagName('input');
|
||||
$this->tag->addAttribute('type', 'text');
|
||||
$this->addIdAttribute($configuration);
|
||||
$this->tag->addAttribute('name', $elementName);
|
||||
$this->tag->addAttribute('data-formengine-input-name', $elementName);
|
||||
$this->tag->addAttribute('class', 'form-control');
|
||||
if ($configuration['value'] !== null) {
|
||||
$this->tag->addAttribute('value', $configuration['value']);
|
||||
}
|
||||
|
||||
$output = '
|
||||
<div class="form-wizards-element">
|
||||
<input class="form-control t3js-color-input formengine-colorpickerelement t3js-color-picker" type="text"
|
||||
name="' . htmlspecialchars($elementName) . '" value="' . $this->tag->getAttribute('value') . '"/>
|
||||
<script type="text/javascript">
|
||||
require([\'TYPO3/CMS/Backend/ColorPicker\'], function(ColorPicker){ColorPicker.initialize()});
|
||||
</script>
|
||||
</div>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render field of type "offset"
|
||||
*
|
||||
* @param array $configuration
|
||||
* @return string
|
||||
*/
|
||||
protected function renderOffsetField(array $configuration): string
|
||||
{
|
||||
$this->tag->setTagName('input');
|
||||
$this->tag->addAttribute('type', 'text');
|
||||
$this->addIdAttribute($configuration);
|
||||
$this->tag->addAttribute('name', $this->getName($configuration));
|
||||
$this->tag->addAttribute('class', 'form-control t3js-emconf-offset');
|
||||
if ($configuration['value'] !== null) {
|
||||
$this->tag->addAttribute('value', $configuration['value']);
|
||||
}
|
||||
return $this->tag->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render field of type "wrap"
|
||||
*
|
||||
* @param array $configuration
|
||||
* @return string
|
||||
*/
|
||||
protected function renderWrapField(array $configuration): string
|
||||
{
|
||||
$this->tag->setTagName('input');
|
||||
$this->tag->addAttribute('type', 'text');
|
||||
$this->addIdAttribute($configuration);
|
||||
$this->tag->addAttribute('name', $this->getName($configuration));
|
||||
$this->tag->addAttribute('class', 'form-control t3js-emconf-wrap');
|
||||
if ($configuration['value'] !== null) {
|
||||
$this->tag->addAttribute('value', $configuration['value']);
|
||||
}
|
||||
return $this->tag->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render field of type "option"
|
||||
*
|
||||
* @param array $configuration
|
||||
* @return string
|
||||
*/
|
||||
protected function renderOptionSelect(array $configuration): string
|
||||
{
|
||||
$this->tag->setTagName('select');
|
||||
$this->addIdAttribute($configuration);
|
||||
$this->tag->addAttribute('name', $this->getName($configuration));
|
||||
$this->tag->addAttribute('class', 'form-control');
|
||||
$optionValueArray = $configuration['generic'];
|
||||
$output = '';
|
||||
$languageService = $this->getLanguageService();
|
||||
foreach ($optionValueArray as $label => $value) {
|
||||
$output .= '<option value="' . htmlspecialchars($value) . '"';
|
||||
if ($configuration['value'] == $value) {
|
||||
$output .= ' selected="selected"';
|
||||
}
|
||||
$output .= '>' . htmlspecialchars($languageService->sL($label)) . '</option>';
|
||||
}
|
||||
$this->tag->setContent($output);
|
||||
return $this->tag->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render field of type "int+"
|
||||
*
|
||||
* @param array $configuration
|
||||
* @return string
|
||||
*/
|
||||
protected function renderPositiveIntegerField(array $configuration): string
|
||||
{
|
||||
$this->tag->setTagName('input');
|
||||
$this->tag->addAttribute('type', 'number');
|
||||
$this->addIdAttribute($configuration);
|
||||
$this->tag->addAttribute('name', $this->getName($configuration));
|
||||
$this->tag->addAttribute('class', 'form-control');
|
||||
$this->tag->addAttribute('min', '0');
|
||||
if ($configuration['value'] !== null) {
|
||||
$this->tag->addAttribute('value', $configuration['value']);
|
||||
}
|
||||
return $this->tag->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render field of type "integer"
|
||||
*
|
||||
* @param array $configuration
|
||||
* @return string
|
||||
*/
|
||||
protected function renderIntegerField(array $configuration): string
|
||||
{
|
||||
$this->tag->setTagName('input');
|
||||
$this->tag->addAttribute('type', 'number');
|
||||
$this->addIdAttribute($configuration);
|
||||
$this->tag->addAttribute('name', $this->getName($configuration));
|
||||
$this->tag->addAttribute('class', 'form-control');
|
||||
if ($configuration['value'] !== null) {
|
||||
$this->tag->addAttribute('value', $configuration['value']);
|
||||
}
|
||||
return $this->tag->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render field of type "text"
|
||||
*
|
||||
* @param array $configuration
|
||||
* @return string
|
||||
*/
|
||||
protected function renderTextField(array $configuration): string
|
||||
{
|
||||
$this->tag->setTagName('input');
|
||||
$this->tag->addAttribute('type', 'text');
|
||||
$this->addIdAttribute($configuration);
|
||||
$this->tag->addAttribute('name', $this->getName($configuration));
|
||||
$this->tag->addAttribute('class', 'form-control');
|
||||
if ($configuration['value'] !== null) {
|
||||
$this->tag->addAttribute('value', $configuration['value']);
|
||||
}
|
||||
return $this->tag->render();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render field of type "small text"
|
||||
*
|
||||
* @param array $configuration
|
||||
* @return string
|
||||
*/
|
||||
protected function renderSmallTextField(array $configuration): string
|
||||
{
|
||||
return $this->renderTextField($configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render field of type "checkbox"
|
||||
*
|
||||
* @param array $configuration
|
||||
* @return string
|
||||
*/
|
||||
public function renderCheckbox(array $configuration): string
|
||||
{
|
||||
$this->tag->addAttribute('type', 'checkbox');
|
||||
$this->tag->addAttribute('name', $this->getName($configuration));
|
||||
$this->tag->addAttribute('value', 1);
|
||||
$this->addIdAttribute($configuration);
|
||||
if ($configuration['value'] == 1) {
|
||||
$this->tag->addAttribute('checked', 'checked');
|
||||
}
|
||||
$hiddenField = $this->renderHiddenFieldForEmptyValue($configuration);
|
||||
return '<div class="checkbox">' . $hiddenField . '<label>' . $this->tag->render() . '</label></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Render field of type "userFunc"
|
||||
*
|
||||
* @param array $configuration
|
||||
* @return string
|
||||
*/
|
||||
protected function renderUserFunction(array $configuration): string
|
||||
{
|
||||
$userFunction = $configuration['generic'];
|
||||
$userFunctionParams = [
|
||||
'fieldName' => $this->getName($configuration),
|
||||
'fieldValue' => $configuration['value'],
|
||||
'propertyName' => $configuration['name']
|
||||
];
|
||||
return (string)GeneralUtility::callUserFunction($userFunction, $userFunctionParams, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Field Name
|
||||
*
|
||||
* @param array $configuration
|
||||
* @return string
|
||||
*/
|
||||
protected function getName(array $configuration): string
|
||||
{
|
||||
return $configuration['name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a hidden field for empty values
|
||||
*
|
||||
* @param array $configuration
|
||||
* @return string
|
||||
*/
|
||||
protected function renderHiddenFieldForEmptyValue(array $configuration): string
|
||||
{
|
||||
$hiddenFieldNames = [];
|
||||
|
||||
// check for already set hidden field within current extension
|
||||
$variableKey = 'renderedHiddenFields-' . $configuration['extensionKey'];
|
||||
if ($this->viewHelperVariableContainer->exists(FormViewHelper::class, $variableKey)) {
|
||||
$hiddenFieldNames = $this->viewHelperVariableContainer->get(FormViewHelper::class, $variableKey);
|
||||
}
|
||||
$fieldName = $this->getName($configuration);
|
||||
if (substr($fieldName, -2) === '[]') {
|
||||
$fieldName = substr($fieldName, 0, -2);
|
||||
}
|
||||
if (!in_array($fieldName, $hiddenFieldNames)) {
|
||||
$hiddenFieldNames[] = $fieldName;
|
||||
$this->viewHelperVariableContainer->addOrUpdate(FormViewHelper::class, $variableKey, $hiddenFieldNames);
|
||||
return '<input type="hidden" name="' . htmlspecialchars($fieldName) . '" value="0" />';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return LanguageService|null Returns null if we are in the install tool standalone mode
|
||||
*/
|
||||
protected function getLanguageService()
|
||||
{
|
||||
return $GLOBALS['LANG'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Build and add id-attribute from $configuration
|
||||
*
|
||||
* @param array $configuration
|
||||
*/
|
||||
protected function addIdAttribute(array $configuration): void
|
||||
{
|
||||
$this->tag->addAttribute(
|
||||
'id',
|
||||
'em-' . $configuration['extensionKey'] . '-' . $this->getName($configuration)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Install\ViewHelpers\Format;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* Remove all spaces in a string
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class NoSpaceViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* Initialize arguments
|
||||
*/
|
||||
public function initializeArguments()
|
||||
{
|
||||
parent::initializeArguments();
|
||||
$this->registerArgument('value', 'string', '', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a string with whitespaces stripped
|
||||
*
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
|
||||
{
|
||||
return str_replace(' ', '', $arguments['value']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Install\ViewHelpers\Format;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* Transform PHP error code to readable text
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class PhpErrorCodeViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $levelNames = [
|
||||
E_ERROR => 'E_ERROR',
|
||||
E_WARNING => 'E_WARNING',
|
||||
E_PARSE => 'E_PARSE',
|
||||
E_NOTICE => 'E_NOTICE',
|
||||
E_CORE_ERROR => 'E_CORE_ERROR',
|
||||
E_CORE_WARNING => 'E_CORE_WARNING',
|
||||
E_COMPILE_ERROR => 'E_COMPILE_ERROR',
|
||||
E_COMPILE_WARNING => 'E_COMPILE_WARNING',
|
||||
E_USER_ERROR => 'E_USER_ERROR',
|
||||
E_USER_WARNING => 'E_USER_WARNING',
|
||||
E_USER_NOTICE => 'E_USER_NOTICE',
|
||||
E_STRICT => 'E_STRICT',
|
||||
E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR',
|
||||
E_DEPRECATED => 'E_DEPRECATED',
|
||||
E_USER_DEPRECATED => 'E_USER_DEPRECATED',
|
||||
];
|
||||
|
||||
/**
|
||||
* Initialize arguments
|
||||
*/
|
||||
public function initializeArguments()
|
||||
{
|
||||
$this->registerArgument('phpErrorCode', 'int', '', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a readable string for PHP error code
|
||||
*
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
|
||||
{
|
||||
$phpErrorCode = (int)$arguments['phpErrorCode'];
|
||||
$levels = [];
|
||||
if (($phpErrorCode & E_ALL) == E_ALL) {
|
||||
$levels[] = 'E_ALL';
|
||||
$phpErrorCode &= ~E_ALL;
|
||||
}
|
||||
foreach (self::$levelNames as $level => $name) {
|
||||
if (($phpErrorCode & $level) == $level) {
|
||||
$levels[] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
$output = '';
|
||||
if (!empty($levels)) {
|
||||
$output = implode(' | ', $levels);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Install\ViewHelpers;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* Utility class for phpinfo()
|
||||
* @internal
|
||||
*/
|
||||
class PhpInfoViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $escapeOutput = false;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $escapeChildren = false;
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
|
||||
{
|
||||
return self::removeAllHtmlOutsideBody(
|
||||
self::changeHtmlToHtml5(
|
||||
self::getPhpInfo()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about PHP's configuration
|
||||
*
|
||||
* @return string HTML page with the configuration options
|
||||
*/
|
||||
protected static function getPhpInfo()
|
||||
{
|
||||
ob_start();
|
||||
phpinfo();
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all HTML outside the body tag from HTML string
|
||||
*
|
||||
* @param string $html Complete HTML markup for page
|
||||
* @return string Content of the body tag
|
||||
*/
|
||||
protected static function removeAllHtmlOutsideBody($html)
|
||||
{
|
||||
// Delete anything outside of the body tag and the body tag itself
|
||||
$html = preg_replace('/^.*?<body.*?>/is', '', $html);
|
||||
$html = preg_replace('/<\/body>.*?$/is', '', $html);
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change HTML markup to HTML5
|
||||
*
|
||||
* @param string $html HTML markup to be cleaned
|
||||
* @return string
|
||||
*/
|
||||
protected static function changeHtmlToHtml5($html)
|
||||
{
|
||||
// Delete obsolete attributes
|
||||
$html = preg_replace('#\s(cellpadding|border|width)="[^"]+"#', '', $html);
|
||||
|
||||
// Replace font tag with span
|
||||
return str_replace(['<font', '</font>'], ['<span', '</span>'], $html);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
namespace TYPO3\CMS\Install\ViewHelpers\Uri;
|
||||
|
||||
/*
|
||||
* This file is part of the TYPO3 CMS project.
|
||||
*
|
||||
* It is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, either version 2
|
||||
* of the License, or any later version.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*
|
||||
* The TYPO3 project - inspiring people to share!
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Core\Utility\HttpUtility;
|
||||
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* A ViewHelper for creating URIs to install tool actions.
|
||||
*
|
||||
* = Examples =
|
||||
*
|
||||
* <code title="URI to the show-action of the current controller">
|
||||
* <f:uri.action action="importantActions" />
|
||||
* </code>
|
||||
* <output>
|
||||
* install.php?install[action]=importantActions&install[context]=
|
||||
* </output>
|
||||
* @internal
|
||||
*/
|
||||
class ActionViewHelper extends AbstractViewHelper
|
||||
{
|
||||
use CompileWithRenderStatic;
|
||||
|
||||
/**
|
||||
* Initialize arguments
|
||||
*/
|
||||
public function initializeArguments()
|
||||
{
|
||||
$this->registerArgument('action', 'string', 'Target action', '');
|
||||
$this->registerArgument('controller', 'string', 'Target controller.', false, 'maintenance');
|
||||
$this->registerArgument('arguments', 'array', 'Arguments', false, []);
|
||||
$this->registerArgument('section', 'string', 'The anchor to be added to the URI', false, '');
|
||||
$this->registerArgument('additionalParams', 'array', 'additional query parameters that won\'t be prefixed like $arguments (overrule $arguments)', false, []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $arguments
|
||||
* @param \Closure $renderChildrenClosure
|
||||
* @param RenderingContextInterface $renderingContext
|
||||
* @return string
|
||||
*/
|
||||
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
|
||||
{
|
||||
$action = $arguments['action'];
|
||||
|
||||
if ($action === 'backend') {
|
||||
return GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir . 'index.php';
|
||||
}
|
||||
if ($action === 'frontend') {
|
||||
return GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . 'index.php';
|
||||
}
|
||||
|
||||
$section = $arguments['section'];
|
||||
$additionalParams = $arguments['additionalParams'];
|
||||
$controller = $arguments['controller'];
|
||||
$arguments = $arguments['arguments'];
|
||||
|
||||
if (!empty($arguments['action'])) {
|
||||
$arguments['action'] = $action;
|
||||
}
|
||||
$arguments['controller'] = $controller;
|
||||
if (!empty(GeneralUtility::_GET('install')['context'])) {
|
||||
$arguments['context'] = GeneralUtility::_GET('install')['context'];
|
||||
}
|
||||
|
||||
return GeneralUtility::getIndpEnv('TYPO3_REQUEST_SCRIPT')
|
||||
. HttpUtility::buildQueryString(
|
||||
array_merge(
|
||||
['install' => $arguments],
|
||||
$additionalParams
|
||||
),
|
||||
'?'
|
||||
)
|
||||
. ($section ? '#' . $section : '');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user