作者:punktd
项目:pt_extlis
/**
* Setup test by loading some demo ts settings
*/
public function setup()
{
$this->tsConfigString = "plugin.tx_ptextlist.settings {\n\t\t\t\n\t\t\t prototype {\n\t\t\t \n\t\t\t pager.pagerConfigs.default.pagerClassName = Tx_PtExtlist_Domain_Model_Pager_DefaultPager\n\t \t\t\t pager.pagerConfigs.default.enabled = 1\n\t \t\t\t pager.pagerConfigs.default.templatePath = EXT:pt_extlist/\n\t\t\t \n\t\t\t }\n\t\t\t\n\t\t\t # This comes from flexform!\n\t\t\t listIdentifier = list1\n\t\t\t\n\t\t\t listConfig.list1 {\n\t\t\t \n\t\t\t backendConfig {\n\t\t\t\n\t\t\t dataBackendClass = Tx_PtExtlist_Domain_DataBackend_MySqlDataBackend_MySqlDataBackend\n\t\t\t dataSourceClass = Tx_PtExtlist_Domain_DataBackend_DataSource_Typo3DataSource\n\t\t\t dataMapperClass = Tx_PtExtlist_Domain_DataBackend_Mapper_ArrayMapper\n\t\t\t queryInterpreterClass = Tx_PtExtlist_Domain_DataBackend_MySqlDataBackend_MySqlInterpreter_MySqlInterpreter\n\t\t\t \n\t\t\t datasource {\n\t\t\t host = " . TYPO3_db_host . "\n\t\t\t username = " . TYPO3_db_username . "\n\t\t\t password = " . TYPO3_db_password . "\n\t\t\t database = " . TYPO3_db . "\n\t\t\t }\n\t\t\t \n\t\t\t tables (\n\t\t\t static_countries, \n\t\t\t static_territories st_continent, \n\t\t\t static_territories st_subcontinent\n\t\t\t )\n\t\t\t \n\t\t\t baseFromClause (\n\t\t\t )\n\t\t\t \n\t\t\t baseWhereClause (\n\t\t\t ) \n\t\t\t \n\t\t\t useEnableFields = 1\n\t\t\t \n\t\t\t }\n\t\t\t \n\t\t\t fields {\n\t\t\t \tfieldIndentifier1 {\n\t\t\t \t\ttable = table1\n\t\t\t \t\tfield = field1\n\t\t\t \t}\n\t\t\t }\n\t\t\t }\n\t\t\t}";
$this->typoScriptParser = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser');
$this->typoScriptParser->parse($this->tsConfigString);
$this->tsConfig = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService')->convertTypoScriptArrayToPlainArray($this->typoScriptParser->setup);
$this->configurationBuilder = new Tx_PtExtlist_Domain_Configuration_ConfigurationBuilder($this->tsConfig['plugin']['tx_ptextlist']['settings'], 'list1');
}
作者:chrmue0
项目:typo3-starter-ki
/**
* Render a Flexible Content Element type selection field
*
* @param array $parameters
* @param mixed $parentObject
* @return string
*/
public function renderField(array &$parameters, &$parentObject)
{
/** @var \TYPO3\CMS\Core\Cache\CacheManager $cacheManager */
$cacheManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager')->get('TYPO3\\CMS\\Core\\Cache\\CacheManager');
/** @var StringFrontend $cache */
$cache = $cacheManager->getCache('fluidcontent');
$pageTypoScript = TRUE === $cache->has('pageTsConfig') ? $cache->get('pageTsConfig') : array();
$tsParser = new TypoScriptParser();
$conditions = new ConditionMatcher();
$pageUid = GeneralUtility::_GET('id');
$pageUid = intval($pageUid);
if (0 === $pageUid) {
$pageUid = intval($parameters['row']['pid']);
}
$conditions->setPageId($pageUid);
$tsParser->parse($pageTypoScript, $conditions);
$setup = $tsParser->setup['mod.']['wizards.']['newContentElement.']['wizardItems.'];
if (FALSE === is_array($setup)) {
return LocalizationUtility::translate('pages.no_content_types', 'Fluidcontent');
}
$setup = GeneralUtility::removeDotsFromTS($setup);
$name = $parameters['itemFormElName'];
$value = $parameters['itemFormElValue'];
$select = '<div><select name="' . htmlspecialchars($name) . '" class="formField select" onchange="if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };">' . LF;
$select .= '<option value="">' . $GLOBALS['LANG']->sL('LLL:EXT:fluidcontent/Resources/Private/Language/locallang.xml:tt_content.tx_fed_fcefile', TRUE) . '</option>' . LF;
foreach ($setup as $groupLabel => $configuration) {
$select .= '<optgroup label="' . htmlspecialchars($groupLabel) . '">' . LF;
foreach ($configuration['elements'] as $elementConfiguration) {
$optionValue = $elementConfiguration['tt_content_defValues']['tx_fed_fcefile'];
$selected = $optionValue === $value ? ' selected="selected"' : '';
$label = $elementConfiguration['title'];
$label = $GLOBALS['LANG']->sL($label);
$select .= '<option value="' . htmlspecialchars($optionValue) . '"' . $selected . '>' . htmlspecialchars($label) . '</option>' . LF;
}
$select .= '</optgroup>' . LF;
}
$select .= '</select></div>' . LF;
unset($parentObject);
return $select;
}
作者:TYPO3Incubato
项目:TYPO3.CM
/**
* Process template row before saving
*
* @param array $tplRow Template row
* @return array Preprocessed template row
*/
public function processTemplateRowBeforeSaving(array $tplRow)
{
if ($this->pObj->MOD_SETTINGS['includeTypoScriptFileContent']) {
$tplRow = TypoScriptParser::extractIncludes_array($tplRow);
}
return $tplRow;
}
作者:grauru
项目:testgit_t3
/**
* Returns the Page TSconfig for page with id, $id
*
* @param int $id Page uid for which to create Page TSconfig
* @param array $rootLine If $rootLine is an array, that is used as rootline, otherwise rootline is just calculated
* @param bool $returnPartArray If $returnPartArray is set, then the array with accumulated Page TSconfig is returned non-parsed. Otherwise the output will be parsed by the TypoScript parser.
* @return array Page TSconfig
* @see \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser
*/
public static function getPagesTSconfig($id, $rootLine = null, $returnPartArray = false)
{
static $pagesTSconfig_cacheReference = array();
static $combinedTSconfig_cache = array();
$id = (int) $id;
if ($returnPartArray === false && $rootLine === null && isset($pagesTSconfig_cacheReference[$id])) {
return $combinedTSconfig_cache[$pagesTSconfig_cacheReference[$id]];
} else {
$TSconfig = array();
if (!is_array($rootLine)) {
$useCacheForCurrentPageId = true;
$rootLine = self::BEgetRootLine($id, '', true);
} else {
$useCacheForCurrentPageId = false;
}
// Order correctly
ksort($rootLine);
$TSdataArray = array();
// Setting default configuration
$TSdataArray['defaultPageTSconfig'] = $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'];
foreach ($rootLine as $k => $v) {
if (trim($v['tsconfig_includes'])) {
$includeTsConfigFileList = GeneralUtility::trimExplode(',', $v['tsconfig_includes'], true);
// Traversing list
foreach ($includeTsConfigFileList as $key => $includeTsConfigFile) {
if (StringUtility::beginsWith($includeTsConfigFile, 'EXT:')) {
list($includeTsConfigFileExtensionKey, $includeTsConfigFilename) = explode('/', substr($includeTsConfigFile, 4), 2);
if ((string) $includeTsConfigFileExtensionKey !== '' && ExtensionManagementUtility::isLoaded($includeTsConfigFileExtensionKey) && (string) $includeTsConfigFilename !== '') {
$includeTsConfigFileAndPath = ExtensionManagementUtility::extPath($includeTsConfigFileExtensionKey) . $includeTsConfigFilename;
if (file_exists($includeTsConfigFileAndPath)) {
$TSdataArray['uid_' . $v['uid'] . '_static_' . $key] = GeneralUtility::getUrl($includeTsConfigFileAndPath);
}
}
}
}
}
$TSdataArray['uid_' . $v['uid']] = $v['TSconfig'];
}
$TSdataArray = static::emitGetPagesTSconfigPreIncludeSignal($TSdataArray, $id, $rootLine, $returnPartArray);
$TSdataArray = TypoScriptParser::checkIncludeLines_array($TSdataArray);
if ($returnPartArray) {
return $TSdataArray;
}
// Parsing the page TS-Config
$pageTS = implode(LF . '[GLOBAL]' . LF, $TSdataArray);
/* @var $parseObj \TYPO3\CMS\Backend\Configuration\TsConfigParser */
$parseObj = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Configuration\TsConfigParser::class);
$res = $parseObj->parseTSconfig($pageTS, 'PAGES', $id, $rootLine);
if ($res) {
$TSconfig = $res['TSconfig'];
}
$cacheHash = $res['hash'];
// Get User TSconfig overlay
$userTSconfig = static::getBackendUserAuthentication()->userTS['page.'];
if (is_array($userTSconfig)) {
ArrayUtility::mergeRecursiveWithOverrule($TSconfig, $userTSconfig);
$cacheHash .= '_user' . $GLOBALS['BE_USER']->user['uid'];
}
if ($useCacheForCurrentPageId) {
if (!isset($combinedTSconfig_cache[$cacheHash])) {
$combinedTSconfig_cache[$cacheHash] = $TSconfig;
}
$pagesTSconfig_cacheReference[$id] = $cacheHash;
}
}
return $TSconfig;
}
作者:nicksergi
项目:TYPO3v4-Cor
/**
* Returns the Page TSconfig for page with id, $id
* Requires class "t3lib_TSparser"
*
* @param $id integer Page uid for which to create Page TSconfig
* @param $rootLine array If $rootLine is an array, that is used as rootline, otherwise rootline is just calculated
* @param boolean $returnPartArray If $returnPartArray is set, then the array with accumulated Page TSconfig is returned non-parsed. Otherwise the output will be parsed by the TypoScript parser.
* @return array Page TSconfig
* @see t3lib_TSparser
*/
public static function getPagesTSconfig($id, $rootLine = '', $returnPartArray = 0)
{
$id = intval($id);
if (!is_array($rootLine)) {
$rootLine = self::BEgetRootLine($id, '', TRUE);
}
// Order correctly
ksort($rootLine);
$TSdataArray = array();
// Setting default configuration
$TSdataArray['defaultPageTSconfig'] = $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'];
foreach ($rootLine as $k => $v) {
$TSdataArray['uid_' . $v['uid']] = $v['TSconfig'];
}
$TSdataArray = \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::checkIncludeLines_array($TSdataArray);
if ($returnPartArray) {
return $TSdataArray;
}
// Parsing the page TS-Config (or getting from cache)
$pageTS = implode(LF . '[GLOBAL]' . LF, $TSdataArray);
if ($GLOBALS['TYPO3_CONF_VARS']['BE']['TSconfigConditions']) {
/* @var $parseObj t3lib_TSparser_TSconfig */
$parseObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Configuration\\TsConfigParser');
$res = $parseObj->parseTSconfig($pageTS, 'PAGES', $id, $rootLine);
if ($res) {
$TSconfig = $res['TSconfig'];
}
} else {
$hash = md5('pageTS:' . $pageTS);
$cachedContent = self::getHash($hash);
$TSconfig = array();
if (isset($cachedContent)) {
$TSconfig = unserialize($cachedContent);
} else {
$parseObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser');
$parseObj->parse($pageTS);
$TSconfig = $parseObj->setup;
self::storeHash($hash, serialize($TSconfig), 'PAGES_TSconfig');
}
}
// Get User TSconfig overlay
$userTSconfig = $GLOBALS['BE_USER']->userTS['page.'];
if (is_array($userTSconfig)) {
$TSconfig = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($TSconfig, $userTSconfig);
}
return $TSconfig;
}
作者:amazing
项目:TYPO3.CM
/**
* Returns the parsed TSconfig for the fe_user
* The TSconfig will be cached in $this->userTS.
*
* @return array TSconfig array for the fe_user
*/
public function getUserTSconf()
{
if (!$this->userTSUpdated) {
// Parsing the user TS (or getting from cache)
$this->TSdataArray = TypoScriptParser::checkIncludeLines_array($this->TSdataArray);
$userTS = implode(LF . '[GLOBAL]' . LF, $this->TSdataArray);
$parseObj = GeneralUtility::makeInstance(TypoScriptParser::class);
$parseObj->parse($userTS);
$this->userTS = $parseObj->setup;
$this->userTSUpdated = true;
}
return $this->userTS;
}
作者:nicksergi
项目:TYPO3v4-Cor
/**
* Returns the pages TSconfig array based on the currect ->rootLine
*
* @return array
* @todo Define visibility
*/
public function getPagesTSconfig()
{
if (!is_array($this->pagesTSconfig)) {
$TSdataArray = array();
// Setting default configuration:
$TSdataArray[] = $this->TYPO3_CONF_VARS['BE']['defaultPageTSconfig'];
foreach ($this->rootLine as $k => $v) {
$TSdataArray[] = $v['TSconfig'];
}
// Parsing the user TS (or getting from cache)
$TSdataArray = \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::checkIncludeLines_array($TSdataArray);
$userTS = implode(LF . '[GLOBAL]' . LF, $TSdataArray);
$hash = md5('pageTS:' . $userTS);
$cachedContent = $this->sys_page->getHash($hash);
if (isset($cachedContent)) {
$this->pagesTSconfig = unserialize($cachedContent);
} else {
$parseObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser');
$parseObj->parse($userTS);
$this->pagesTSconfig = $parseObj->setup;
$this->sys_page->storeHash($hash, serialize($this->pagesTSconfig), 'PAGES_TSconfig');
}
}
return $this->pagesTSconfig;
}
作者:Andreas
项目:commerc
/**
* Returns the category TSconfig array based on the currect->rootLine
*
* @todo Make recursiv category TS merging
* @return array
*/
public function getTyposcriptConfig()
{
if (!is_array($this->categoryTSconfig)) {
$tSdataArray[] = $this->tsConfig;
$tSdataArray = \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::checkIncludeLines_array($tSdataArray);
$categoryTs = implode(chr(10) . '[GLOBAL]' . chr(10), $tSdataArray);
/**
* Typoscript parser
*
* @var \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser $parseObj
*/
$parseObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser');
$parseObj->parse($categoryTs);
$this->categoryTSconfig = $parseObj->setup;
}
return $this->categoryTSconfig;
}
作者:nicksergi
项目:TYPO3v4-Cor
/**
* Main
*
* @return string
* @todo Define visibility
*/
public function main()
{
// Initializes the module. Done in this function because we may need to re-initialize if data is submitted!
// Checking for more than one template an if, set a menu...
$manyTemplatesMenu = $this->pObj->templateMenu();
$template_uid = 0;
if ($manyTemplatesMenu) {
$template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
}
// BUGBUG: Should we check if the uset may at all read and write template-records???
$existTemplate = $this->initialize_editor($this->pObj->id, $template_uid);
// initialize
if ($existTemplate) {
$theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('currentTemplate', TRUE), \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('sys_template', $GLOBALS['tplRow']) . '<strong>' . $this->pObj->linkWrapTemplateTitle($GLOBALS['tplRow']['title']) . '</strong>' . htmlspecialchars(trim($GLOBALS['tplRow']['sitetitle']) ? ' (' . $GLOBALS['tplRow']['sitetitle'] . ')' : ''));
}
if ($manyTemplatesMenu) {
$theOutput .= $this->pObj->doc->section('', $manyTemplatesMenu);
}
$GLOBALS['tmpl']->clearList_const_temp = array_flip($GLOBALS['tmpl']->clearList_const);
$GLOBALS['tmpl']->clearList_setup_temp = array_flip($GLOBALS['tmpl']->clearList_setup);
$pointer = count($GLOBALS['tmpl']->hierarchyInfo);
$GLOBALS['tmpl']->hierarchyInfoArr = $GLOBALS['tmpl']->ext_process_hierarchyInfo(array(), $pointer);
$GLOBALS['tmpl']->processIncludes();
$hierarArr = array();
$head = '<tr class="t3-row-header">';
$head .= '<td>' . $GLOBALS['LANG']->getLL('title', TRUE) . '</td>';
$head .= '<td>' . $GLOBALS['LANG']->getLL('rootlevel', TRUE) . '</td>';
$head .= '<td>' . $GLOBALS['LANG']->getLL('clearSetup', TRUE) . '</td>';
$head .= '<td>' . $GLOBALS['LANG']->getLL('clearConstants', TRUE) . '</td>';
$head .= '<td>' . $GLOBALS['LANG']->getLL('pid', TRUE) . '</td>';
$head .= '<td>' . $GLOBALS['LANG']->getLL('rootline', TRUE) . '</td>';
$head .= '<td>' . $GLOBALS['LANG']->getLL('nextLevel', TRUE) . '</td>';
$head .= '</tr>';
$hierar = implode(array_reverse($GLOBALS['tmpl']->ext_getTemplateHierarchyArr($GLOBALS['tmpl']->hierarchyInfoArr, '', array(), 1)), '');
$hierar = '<table id="ts-analyzer" cellpadding="0" cellspacing="0">' . $head . $hierar . '</table>';
$theOutput .= $this->pObj->doc->spacer(5);
$theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('templateHierarchy', TRUE), $hierar, 0, 1);
$urlParameters = array('id' => $GLOBALS['SOBE']->id, 'template' => 'all');
$aHref = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_ts', $urlParameters);
$completeLink = '<p><a href="' . htmlspecialchars($aHref) . '">' . $GLOBALS['LANG']->getLL('viewCompleteTS', TRUE) . '</a></p>';
$theOutput .= $this->pObj->doc->spacer(5);
$theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('completeTS', TRUE), $completeLink, 0, 1);
$theOutput .= $this->pObj->doc->spacer(15);
// Output options
$theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('displayOptions', TRUE), '', FALSE, TRUE);
$addParams = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('template') ? '&template=' . \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('template') : '';
$theOutput .= '<div class="tst-analyzer-options">' . \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_analyzer_checkLinenum]', $this->pObj->MOD_SETTINGS['ts_analyzer_checkLinenum'], '', $addParams, 'id="checkTs_analyzer_checkLinenum"') . '<label for="checkTs_analyzer_checkLinenum">' . $GLOBALS['LANG']->getLL('lineNumbers', TRUE) . '</label> ' . \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_analyzer_checkSyntax]', $this->pObj->MOD_SETTINGS['ts_analyzer_checkSyntax'], '', $addParams, 'id="checkTs_analyzer_checkSyntax"') . '<label for="checkTs_analyzer_checkSyntax">' . $GLOBALS['LANG']->getLL('syntaxHighlight', TRUE) . '</label> ' . (!$this->pObj->MOD_SETTINGS['ts_analyzer_checkSyntax'] ? \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_analyzer_checkComments]', $this->pObj->MOD_SETTINGS['ts_analyzer_checkComments'], '', $addParams, 'id="checkTs_analyzer_checkComments"') . '<label for="checkTs_analyzer_checkComments">' . $GLOBALS['LANG']->getLL('comments', TRUE) . '</label> ' . \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id, 'SET[ts_analyzer_checkCrop]', $this->pObj->MOD_SETTINGS['ts_analyzer_checkCrop'], '', $addParams, 'id="checkTs_analyzer_checkCrop"') . '<label for="checkTs_analyzer_checkCrop">' . $GLOBALS['LANG']->getLL('cropLines', TRUE) . '</label> ' : '') . '</div>';
$theOutput .= $this->pObj->doc->spacer(25);
// Output Constants
if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('template')) {
$theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('constants', TRUE), '', 0, 1);
$theOutput .= $this->pObj->doc->sectionEnd();
$theOutput .= '
<table class="ts-typoscript" border="0" cellpadding="1" cellspacing="0">
';
// Don't know why -2 and not 0... :-) But works.
$GLOBALS['tmpl']->ext_lineNumberOffset = -2;
$GLOBALS['tmpl']->ext_lineNumberOffset_mode = 'const';
$GLOBALS['tmpl']->ext_lineNumberOffset += count(explode(LF, \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::checkIncludeLines('' . $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_constants']))) + 1;
reset($GLOBALS['tmpl']->clearList_const);
foreach ($GLOBALS['tmpl']->constants as $key => $val) {
$cVal = current($GLOBALS['tmpl']->clearList_const);
if ($cVal == \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('template') || \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('template') == 'all') {
$theOutput .= '
<tr>
</td><td class="bgColor2"><strong>' . htmlspecialchars($GLOBALS['tmpl']->templateTitles[$cVal]) . '</strong></td></tr>
<tr>
<td class="bgColor2"><table border="0" cellpadding="0" cellspacing="0" class="bgColor0" width="100%"><tr><td nowrap="nowrap">' . $GLOBALS['tmpl']->ext_outputTS(array($val), $this->pObj->MOD_SETTINGS['ts_analyzer_checkLinenum'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkComments'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkCrop'], $this->pObj->MOD_SETTINGS['ts_analyzer_checkSyntax'], 0) . '</td></tr></table>
</td>
</tr>
';
if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('template') != 'all') {
break;
}
}
$GLOBALS['tmpl']->ext_lineNumberOffset += count(explode(LF, $val)) + 1;
next($GLOBALS['tmpl']->clearList_const);
}
$theOutput .= '
</table>
';
}
// Output setup
if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('template')) {
$theOutput .= $this->pObj->doc->spacer(15);
$theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('setup', TRUE), '', 0, 1);
$theOutput .= $this->pObj->doc->sectionEnd();
$theOutput .= '
<table class="ts-typoscript" border="0" cellpadding="1" cellspacing="0">
';
$GLOBALS['tmpl']->ext_lineNumberOffset = 0;
$GLOBALS['tmpl']->ext_lineNumberOffset_mode = 'setup';
$GLOBALS['tmpl']->ext_lineNumberOffset += count(explode(LF, \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::checkIncludeLines('' . $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup']))) + 1;
reset($GLOBALS['tmpl']->clearList_setup);
//.........这里部分代码省略.........
作者:punktd
项目:pt_extbas
/**
* @static
* @throws Exception if file not found
* @param string $tsSetupFilePath path to typoscript file
* @return array ts-Config
*/
public static function loadTypoScriptFromFile($tsSetupFilePath)
{
if (!file_exists($tsSetupFilePath)) {
throw new Exception('No Typoscript file found at path ' . $tsSetupFilePath . ' 1316733309');
}
$rawTsConfig = file_get_contents($tsSetupFilePath);
$tsParser = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser');
/** @var $tsParser \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser */
$tsLines = explode(LF, $rawTsConfig);
foreach ($tsLines as &$value) {
$includeData = \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::checkIncludeLines($value, 1, true);
$value = $includeData['typoscript'];
}
$rawTsConfig = implode(LF, $tsLines);
$tsParser->parse($rawTsConfig);
$tsArray = $tsParser->setup;
return $tsArray;
}
作者:IchHabRech
项目:sitemap_generato
/**
* SitemapRepository constructor.
* @SuppressWarnings(superglobals)
*/
public function __construct()
{
$this->typoScriptParser = GeneralUtility::makeInstance(TypoScriptParser::class);
$this->pluginConfig = $this->typoScriptParser->getVal('plugin.tx_sitemapgenerator', $GLOBALS['TSFE']->tmpl->setup);
}
作者:rabe6
项目:mm_foru
/**
* Initializes the cronjob.
* This function initializes the cronjob object. The initialization of a
* cronjob consists of:
*
* 1. Load the default settings from static constants
* 2. Load user settings from tx_mmforum_config.ts
* 3. Join default and user settings and parse into an array
* 4. Load language file for the cronjob
* 5. Validate settings and exit with error if something is missing
*
* @author Martin Helmich <m.helmich@mittwald.de>
* @version 2008-06-22
* @return void
*/
function initialize()
{
$this->MMFORUMPATH = ExtensionManagementUtility::extPath('mm_forum');
// Load default constants file
$conf = file_get_contents($this->MMFORUMPATH . 'ext_typoscript_constants.txt');
// Load user settings file
$localSettings_filename = PATH_typo3conf . 'tx_mmforum_config.ts';
if (file_exists($localSettings_filename)) {
$conf .= "\n#LOCAL SETTINGS\n" . file_get_contents($localSettings_filename);
}
// Parse setup
$parser = new TypoScriptParser();
$parser->parse($conf);
$this->conf = $parser->setup['plugin.']['tx_mmforum.'];
// Load language files
$this->loadLanguageFile();
// Validate configuration
$this->validateConfig();
}
作者:khanhdeu
项目:typo3tes
/**
* Returns the parsed TSconfig for the fe_user
* The TSconfig will be cached in $this->userTS.
*
* @return array TSconfig array for the fe_user
* @todo Define visibility
*/
public function getUserTSconf()
{
if (!$this->userTSUpdated) {
// Parsing the user TS (or getting from cache)
$this->TSdataArray = \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::checkIncludeLines_array($this->TSdataArray);
$userTS = implode(LF . '[GLOBAL]' . LF, $this->TSdataArray);
$parseObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser');
$parseObj->parse($userTS);
$this->userTS = $parseObj->setup;
$this->userTSUpdated = TRUE;
}
return $this->userTS;
}
作者:Torsten8
项目:TYPO3.CM
/**
* Returns the pages TSconfig array based on the currect ->rootLine
*
* @return array
*/
public function getPagesTSconfig()
{
if (!is_array($this->pagesTSconfig)) {
$TSdataArray = array();
foreach ($this->rootLine as $k => $v) {
$TSdataArray[] = $v['TSconfig'];
}
// Adding the default configuration:
$TSdataArray[] = $this->TYPO3_CONF_VARS['BE']['defaultPageTSconfig'];
// Bring everything in the right order. Default first, then the Rootline down to the current page
$TSdataArray = array_reverse($TSdataArray);
// Parsing the user TS (or getting from cache)
$TSdataArray = TypoScriptParser::checkIncludeLines_array($TSdataArray);
$userTS = implode(LF . '[GLOBAL]' . LF, $TSdataArray);
$hash = md5('pageTS:' . $userTS);
$cachedContent = $this->sys_page->getHash($hash);
if (is_array($cachedContent)) {
$this->pagesTSconfig = $cachedContent;
} else {
$parseObj = GeneralUtility::makeInstance(TypoScriptParser::class);
$parseObj->parse($userTS);
$this->pagesTSconfig = $parseObj->setup;
$this->sys_page->storeHash($hash, $this->pagesTSconfig, 'PAGES_TSconfig');
}
}
return $this->pagesTSconfig;
}
作者:TrueTyp
项目:caretake
/**
* @param $strategy
* @return array
*/
protected function getStrategyConfig($strategy)
{
if ($this->strategyConfig[$strategy['uid']] === NULL) {
$parseObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser');
$config = \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::checkIncludeLines($strategy['config']);
$parseObj->parse($config);
$config = $parseObj->setup;
$this->strategyConfig[$strategy['uid']] = $config;
}
return $this->strategyConfig[$strategy['uid']];
}
作者:rob-ot-dot-b
项目:ggallkeysecurit
/**
* Loads Page TSconfig until the outermost template record and parses the configuration - if TSFE.constants object path is found it is merged with the default data in here!
*
* @param array $constArray Constants array, default input.
* @return array Constants array, modified
* @todo Apply caching to the parsed Page TSconfig. This is done in the other similar functions for both frontend and backend. However, since this functions works for BOTH frontend and backend we will have to either write our own local caching function or (more likely) detect if we are in FE or BE and use caching functions accordingly. Not having caching affects mostly the backend modules inside the "Template" module since the overhead in the frontend is only seen when TypoScript templates are parsed anyways (after which point they are cached anyways...)
* @todo Define visibility
*/
public function mergeConstantsFromPageTSconfig($constArray)
{
$TSdataArray = array();
// Setting default configuration:
$TSdataArray[] = $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'];
for ($a = 0; $a <= $this->outermostRootlineIndexWithTemplate; $a++) {
$TSdataArray[] = $this->absoluteRootLine[$a]['TSconfig'];
}
// Parsing the user TS (or getting from cache)
$TSdataArray = \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::checkIncludeLines_array($TSdataArray);
$userTS = implode(LF . '[GLOBAL]' . LF, $TSdataArray);
/** @var $parseObj \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser */
$parseObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser');
$parseObj->parse($userTS);
if (is_array($parseObj->setup['TSFE.']['constants.'])) {
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($constArray, $parseObj->setup['TSFE.']['constants.']);
}
return $constArray;
}
作者:TYPO3Incubato
项目:TYPO3.CM
/**
* Loads Page TSconfig until the outermost template record and parses the configuration - if TSFE.constants object path is found it is merged with the default data in here!
*
* @param array $constArray Constants array, default input.
* @return array Constants array, modified
* @todo Apply caching to the parsed Page TSconfig. This is done in the other similar functions for both frontend and backend. However, since this functions works for BOTH frontend and backend we will have to either write our own local caching function or (more likely) detect if we are in FE or BE and use caching functions accordingly. Not having caching affects mostly the backend modules inside the "Template" module since the overhead in the frontend is only seen when TypoScript templates are parsed anyways (after which point they are cached anyways...)
*/
public function mergeConstantsFromPageTSconfig($constArray)
{
$TSdataArray = array();
// Setting default configuration:
$TSdataArray[] = $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'];
for ($a = 0; $a <= $this->outermostRootlineIndexWithTemplate; $a++) {
if (trim($this->absoluteRootLine[$a]['tsconfig_includes'])) {
$includeTsConfigFileList = GeneralUtility::trimExplode(',', $this->absoluteRootLine[$a]['tsconfig_includes'], true);
$TSdataArray = $this->mergeConstantsFromIncludedTsConfigFiles($includeTsConfigFileList, $TSdataArray);
}
$TSdataArray[] = $this->absoluteRootLine[$a]['TSconfig'];
}
// Parsing the user TS (or getting from cache)
$TSdataArray = Parser\TypoScriptParser::checkIncludeLines_array($TSdataArray);
$userTS = implode(LF . '[GLOBAL]' . LF, $TSdataArray);
/** @var $parseObj Parser\TypoScriptParser */
$parseObj = GeneralUtility::makeInstance(Parser\TypoScriptParser::class);
$parseObj->parse($userTS);
if (is_array($parseObj->setup['TSFE.']['constants.'])) {
ArrayUtility::mergeRecursiveWithOverrule($constArray, $parseObj->setup['TSFE.']['constants.']);
}
return $constArray;
}
作者:samuweis
项目:TYPO3-Sit
/**
* Returns the Page TSconfig for page with id, $id
*
* @param $id integer Page uid for which to create Page TSconfig
* @param $rootLine array If $rootLine is an array, that is used as rootline, otherwise rootline is just calculated
* @param boolean $returnPartArray If $returnPartArray is set, then the array with accumulated Page TSconfig is returned non-parsed. Otherwise the output will be parsed by the TypoScript parser.
* @return array Page TSconfig
* @see \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser
*/
public static function getPagesTSconfig($id, $rootLine = NULL, $returnPartArray = FALSE)
{
static $pagesTSconfig_cache = array();
$id = (int) $id;
if ($returnPartArray === FALSE && $rootLine === NULL && isset($pagesTSconfig_cache[$id])) {
return $pagesTSconfig_cache[$id];
} else {
$TSconfig = array();
if (!is_array($rootLine)) {
$useCacheForCurrentPageId = TRUE;
$rootLine = self::BEgetRootLine($id, '', TRUE);
} else {
$useCacheForCurrentPageId = FALSE;
}
// Order correctly
ksort($rootLine);
$TSdataArray = array();
// Setting default configuration
$TSdataArray['defaultPageTSconfig'] = $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'];
foreach ($rootLine as $k => $v) {
$TSdataArray['uid_' . $v['uid']] = $v['TSconfig'];
}
$TSdataArray = static::emitGetPagesTSconfigPreIncludeSignal($TSdataArray, $id, $rootLine, $returnPartArray);
$TSdataArray = TypoScriptParser::checkIncludeLines_array($TSdataArray);
if ($returnPartArray) {
return $TSdataArray;
}
// Parsing the page TS-Config
$pageTS = implode(LF . '[GLOBAL]' . LF, $TSdataArray);
/* @var $parseObj \TYPO3\CMS\Backend\Configuration\TsConfigParser */
$parseObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Configuration\\TsConfigParser');
$res = $parseObj->parseTSconfig($pageTS, 'PAGES', $id, $rootLine);
if ($res) {
$TSconfig = $res['TSconfig'];
}
// Get User TSconfig overlay
$userTSconfig = $GLOBALS['BE_USER']->userTS['page.'];
if (is_array($userTSconfig)) {
\TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($TSconfig, $userTSconfig);
}
if ($useCacheForCurrentPageId) {
$pagesTSconfig_cache[$id] = $TSconfig;
}
}
return $TSconfig;
}
作者:Mr-Robot
项目:TYPO3.CM
/**
* Initializes a lot of stuff like the access-lists, database-mountpoints and filemountpoints
* This method is called by ->backendCheckLogin() (from extending BackendUserAuthentication)
* if the backend user login has verified OK.
* Generally this is required initialization of a backend user.
*
* @return void
* @access private
* @see \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser
* @todo Define visibility
*/
public function fetchGroupData()
{
if ($this->user['uid']) {
// Get lists for the be_user record and set them as default/primary values.
// Enabled Backend Modules
$this->dataLists['modList'] = $this->user['userMods'];
// Add Allowed Languages
$this->dataLists['allowed_languages'] = $this->user['allowed_languages'];
// Set user value for workspace permissions.
$this->dataLists['workspace_perms'] = $this->user['workspace_perms'];
// User mount points are only added if the user is not an admin as admins do not have visible
// mountpoints fields. Processing them loads mountpoints defined when the user was a non-admin.
if (!$this->isAdmin()) {
// Database mountpoints
$this->dataLists['webmount_list'] = $this->user['db_mountpoints'];
// File mountpoints
$this->dataLists['filemount_list'] = $this->user['file_mountpoints'];
}
// Fileoperation permissions
$this->dataLists['file_permissions'] = $this->user['file_permissions'];
// Setting default User TSconfig:
$this->TSdataArray[] = $this->addTScomment('From $GLOBALS["TYPO3_CONF_VARS"]["BE"]["defaultUserTSconfig"]:') . $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultUserTSconfig'];
// Default TSconfig for admin-users
if ($this->isAdmin()) {
$this->TSdataArray[] = $this->addTScomment('"admin" user presets:') . '
admPanel.enable.all = 1
';
if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('sys_note')) {
$this->TSdataArray[] = '
// Setting defaults for sys_note author / email...
TCAdefaults.sys_note.author = ' . $this->user['realName'] . '
TCAdefaults.sys_note.email = ' . $this->user['email'] . '
';
}
}
// BE_GROUPS:
// Get the groups...
// 240203: Since the group-field never contains any references to groups with a prepended table name
// we think it's safe to just intExplode and re-implode - which should be much faster than the other function call.
$grList = $this->db->cleanIntList($this->user[$this->usergroup_column]);
if ($grList) {
// Fetch groups will add a lot of information to the internal arrays: modules, accesslists, TSconfig etc.
// Refer to fetchGroups() function.
$this->fetchGroups($grList);
}
// Populating the $this->userGroupsUID -array with the groups in the order in which they were LAST included.!!
$this->userGroupsUID = array_reverse(array_unique(array_reverse($this->includeGroupArray)));
// Finally this is the list of group_uid's in the order they are parsed (including subgroups!)
// and without duplicates (duplicates are presented with their last entrance in the list,
// which thus reflects the order of the TypoScript in TSconfig)
$this->groupList = implode(',', $this->userGroupsUID);
$this->setCachedList($this->groupList);
// Add the TSconfig for this specific user:
$this->TSdataArray[] = $this->addTScomment('USER TSconfig field') . $this->user['TSconfig'];
// Check include lines.
$this->TSdataArray = \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser::checkIncludeLines_array($this->TSdataArray);
// Imploding with "[global]" will make sure that non-ended confinements with braces are ignored.
$this->userTS_text = implode(LF . '[GLOBAL]' . LF, $this->TSdataArray);
if (!$this->userTS_dontGetCached) {
// Perform TS-Config parsing with condition matching
$parseObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Configuration\\TsConfigParser');
$res = $parseObj->parseTSconfig($this->userTS_text, 'userTS');
if ($res) {
$this->userTS = $res['TSconfig'];
$this->userTSUpdated = (bool) $res['cached'];
}
} else {
// Parsing the user TSconfig (or getting from cache)
$hash = md5('userTS:' . $this->userTS_text);
$cachedContent = BackendUtility::getHash($hash);
if (is_array($cachedContent) && !$this->userTS_dontGetCached) {
$this->userTS = $cachedContent;
} else {
$parseObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser');
$parseObj->parse($this->userTS_text);
$this->userTS = $parseObj->setup;
BackendUtility::storeHash($hash, $this->userTS, 'BE_USER_TSconfig');
// Update UC:
$this->userTSUpdated = TRUE;
}
}
// Processing webmounts
// Admin's always have the root mounted
if ($this->isAdmin() && !$this->getTSConfigVal('options.dontMountAdminMounts')) {
$this->dataLists['webmount_list'] = '0,' . $this->dataLists['webmount_list'];
}
// The lists are cleaned for duplicates
$this->groupData['webmounts'] = GeneralUtility::uniqueList($this->dataLists['webmount_list']);
$this->groupData['pagetypes_select'] = GeneralUtility::uniqueList($this->dataLists['pagetypes_select']);
//.........这里部分代码省略.........
作者:grauru
项目:testgit_t3
/**
* Render a TypoScript and resolve all references (eg. " < plugin.tx_form...") recursively
*
* @param array $typoScript
* @return array
* @todo Extract to core then...
*/
protected function resolveTypoScriptReferences(array $typoScript)
{
$ignoreKeys = array();
foreach ($typoScript as $key => $value) {
if (isset($ignoreKeys[$key])) {
continue;
}
// i am a reference
if ($value[0] === '<') {
if (isset($typoScript[$key . '.'])) {
$oldTypoScript = $typoScript[$key . '.'];
} else {
$oldTypoScript = array();
}
// detect search level
$referencePath = trim(substr($value, 1));
$dotPosition = strpos($referencePath, '.');
if ($dotPosition === 0) {
// same position x =< .y
list($flatValue, $arrayValue) = $this->typoScriptParser->getVal(substr($referencePath, 1), $typoScript);
} else {
list($flatValue, $arrayValue) = $this->typoScriptParser->getVal($referencePath, $GLOBALS['TSFE']->tmpl->setup);
}
if (is_array($arrayValue)) {
$typoScript[$key . '.'] = array_replace_recursive($arrayValue, $oldTypoScript);
}
if ($flatValue[0] === '<') {
$temporaryTypoScript = array('temp' => $flatValue, 'temp.' => $typoScript[$key . '.']);
$temporaryTypoScript = $this->resolveTypoScriptReferences($temporaryTypoScript);
$arrayValue = array_replace_recursive($temporaryTypoScript['temp.'], $arrayValue, $oldTypoScript);
}
if (is_array($arrayValue)) {
$typoScript[$key . '.'] = array_replace_recursive($arrayValue, $oldTypoScript);
} elseif (isset($flatValue)) {
$typoScript[$key] = $flatValue;
} else {
$typoScript[$key . '.'] = $oldTypoScript;
}
}
// if array, then look deeper
if (isset($typoScript[$key . '.'])) {
$ignoreKeys[$key . '.'] = true;
$typoScript[$key . '.'] = $this->resolveTypoScriptReferences($typoScript[$key . '.']);
} elseif (is_array($typoScript[$key])) {
// if array, then look deeper
$typoScript[$key] = $this->resolveTypoScriptReferences($typoScript[$key]);
}
}
return $typoScript;
}