Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
services
T
t3o sites
extensions.typo3.org
extensions.typo3.org
Commits
36b88f12
Commit
36b88f12
authored
Oct 19, 2017
by
Thomas Löffler
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'removeTypoScriptParser' into 'develop'
Remove TypoScript parser See merge request t3o/ter!255
parents
05b83338
d5e27f74
Pipeline
#2573
passed with stages
in 3 minutes and 10 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
200 deletions
+1
-200
html/typo3conf/ext/ter_fe2/Classes/Controller/AbstractController.php
...onf/ext/ter_fe2/Classes/Controller/AbstractController.php
+1
-2
html/typo3conf/ext/ter_fe2/Classes/Utility/TypoScript.php
html/typo3conf/ext/ter_fe2/Classes/Utility/TypoScript.php
+0
-198
No files found.
html/typo3conf/ext/ter_fe2/Classes/Controller/AbstractController.php
View file @
36b88f12
...
...
@@ -34,7 +34,7 @@ abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\Acti
}
/**
*
Pre-parse TypoScript setup
*
Check, if TS Template was included
*
* @return void
* @throws \Exception
...
...
@@ -45,7 +45,6 @@ abstract class AbstractController extends \TYPO3\CMS\Extbase\Mvc\Controller\Acti
if
(
!
is_array
(
$this
->
settings
))
{
throw
new
\
Exception
(
'Static template "Default Configuration" of ter_fe2 has to be inserted before this plugin can be shown in frontend'
);
}
$this
->
settings
=
\
T3o\TerFe2\Utility\TypoScript
::
parse
(
$this
->
settings
);
}
/**
...
...
html/typo3conf/ext/ter_fe2/Classes/Utility/TypoScript.php
View file @
36b88f12
<?php
namespace
T3o\TerFe2\Utility
;
/*
* 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!
*/
/**
* Utilities to manage and convert Typoscript Code
*/
class
TypoScript
{
/**
* @var object
*/
protected
static
$frontend
;
/**
* @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
*/
protected
static
$contentObject
;
/**
* @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManager
*/
protected
static
$configurationManager
;
/**
* Initialize configuration manager and content object
*
* @return void
*/
protected
static
function
initialize
()
{
// Get configuration manager
$objectManager
=
\
TYPO3\CMS\Core\Utility\GeneralUtility
::
makeInstance
(
\
TYPO3\CMS\Extbase\Object\ObjectManager
::
class
);
self
::
$configurationManager
=
$objectManager
->
get
(
\
TYPO3\CMS\Extbase\Configuration\ConfigurationManager
::
class
);
// Simulate Frontend
if
(
TYPO3_MODE
!=
'FE'
)
{
self
::
simulateFrontend
();
self
::
$configurationManager
->
setContentObject
(
$GLOBALS
[
'TSFE'
]
->
cObj
);
}
// Get content object
self
::
$contentObject
=
self
::
$configurationManager
->
getContentObject
();
if
(
empty
(
self
::
$contentObject
))
{
self
::
$contentObject
=
\
TYPO3\CMS\Core\Utility\GeneralUtility
::
makeInstance
(
\
TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
::
class
);
}
}
/**
* Simulate a frontend environment
*
* @param \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj Instance of an content object
* @return void
*/
public
static
function
simulateFrontend
(
\
TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
$cObj
=
null
)
{
// Make backup of current frontend
self
::
$frontend
=
(
!
empty
(
$GLOBALS
[
'TSFE'
])
?
$GLOBALS
[
'TSFE'
]
:
null
);
// Create new frontend instance
$GLOBALS
[
'TSFE'
]
=
new
\
stdClass
();
$GLOBALS
[
'TSFE'
]
->
cObjectDepthCounter
=
100
;
$GLOBALS
[
'TSFE'
]
->
cObj
=
(
!
empty
(
$cObj
)
?
$cObj
:
\
TYPO3\CMS\Core\Utility\GeneralUtility
::
makeInstance
(
\
TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
::
class
));
if
(
empty
(
$GLOBALS
[
'TSFE'
]
->
sys_page
))
{
$GLOBALS
[
'TSFE'
]
->
sys_page
=
\
TYPO3\CMS\Core\Utility\GeneralUtility
::
makeInstance
(
\
TYPO3\CMS\Frontend\Page\PageRepository
::
class
);
}
if
(
empty
(
$GLOBALS
[
'TSFE'
]
->
tmpl
))
{
$GLOBALS
[
'TSFE'
]
->
tmpl
=
\
TYPO3\CMS\Core\Utility\GeneralUtility
::
makeInstance
(
\
TYPO3\CMS\Core\TypoScript\TemplateService
::
class
);
$GLOBALS
[
'TSFE'
]
->
tmpl
->
getFileName_backPath
=
PATH_site
;
$GLOBALS
[
'TSFE'
]
->
tmpl
->
init
();
}
if
(
empty
(
$GLOBALS
[
'TT'
]))
{
$GLOBALS
[
'TT'
]
=
\
TYPO3\CMS\Core\Utility\GeneralUtility
::
makeInstance
(
\
TYPO3\CMS\Core\TimeTracker\NullTimeTracker
::
class
);
}
if
(
empty
(
$GLOBALS
[
'TSFE'
]
->
config
))
{
$GLOBALS
[
'TSFE'
]
->
config
=
\
TYPO3\CMS\Core\Utility\GeneralUtility
::
removeDotsFromTS
(
self
::
getSetup
());
}
}
/**
* Reset an existing frontend environment
*
* @param object $frontend Instance of a frontend environemnt
* @return void
*/
public
static
function
resetFrontend
(
$frontend
=
null
)
{
$frontend
=
(
!
empty
(
$frontend
)
?
$frontend
:
self
::
$frontend
);
if
(
!
empty
(
$frontend
))
{
$GLOBALS
[
'TSFE'
]
=
$frontend
;
}
}
/**
* Returns unparsed TypoScript setup
*
* @param string $typoScriptPath TypoScript path
* @return array TypoScript setup
*/
public
static
function
getSetup
(
$typoScriptPath
=
''
)
{
if
(
empty
(
self
::
$configurationManager
))
{
self
::
initialize
();
}
$setup
=
self
::
$configurationManager
->
getConfiguration
(
\
TYPO3\CMS\Extbase\Configuration\ConfigurationManager
::
CONFIGURATION_TYPE_FULL_TYPOSCRIPT
);
if
(
empty
(
$typoScriptPath
))
{
return
$setup
;
}
$path
=
explode
(
'.'
,
$typoScriptPath
);
foreach
(
$path
as
$segment
)
{
if
(
empty
(
$setup
[
$segment
.
'.'
]))
{
return
array
();
}
$setup
=
$setup
[
$segment
.
'.'
];
}
return
$setup
;
}
/**
* Parse given TypoScript configuration
*
* @param array $configuration TypoScript configuration
* @param boolean $isPlain Is a plain "Fluid like" configuration array
* @return array Parsed configuration
*/
public
static
function
parse
(
array
$configuration
,
$isPlain
=
true
)
{
if
(
empty
(
self
::
$contentObject
))
{
self
::
initialize
();
}
// Convert to classic TypoScript array
if
(
$isPlain
)
{
/** @var \TYPO3\CMS\Core\TypoScript\TypoScriptService $typoScriptService */
$typoScriptService
=
\
TYPO3\CMS\Core\Utility\GeneralUtility
::
makeInstance
(
\
TYPO3\CMS\Core\TypoScript\TypoScriptService
::
class
);
$configuration
=
$typoScriptService
->
convertPlainArrayToTypoScriptArray
(
$configuration
);
}
// Parse configuration
return
self
::
parseTypoScriptArray
(
$configuration
);
}
/**
* Parse TypoScript array
*
* @param array $configuration TypoScript configuration array
* @return array Parsed configuration
* @api
*/
public
static
function
parseTypoScriptArray
(
array
$configuration
)
{
$typoScriptArray
=
array
();
if
(
is_array
(
$configuration
))
{
foreach
(
$configuration
as
$key
=>
$value
)
{
$ident
=
rtrim
(
$key
,
'.'
);
if
(
is_array
(
$value
))
{
if
(
!
empty
(
$configuration
[
$ident
]))
{
$typoScriptArray
[
$ident
]
=
self
::
$contentObject
->
cObjGetSingle
(
$configuration
[
$ident
],
$value
);
}
else
{
$typoScriptArray
[
$ident
]
=
self
::
parseTypoScriptArray
(
$value
);
}
unset
(
$configuration
[
$key
]);
}
elseif
(
is_string
(
$value
)
&&
$key
===
$ident
)
{
$typoScriptArray
[
$key
]
=
$value
;
}
}
}
return
$typoScriptArray
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment