Feature #22388 » 14015.diff
t3lib/class.t3lib_extmgm.php (working copy) | ||
---|---|---|
}
|
||
return $out;
|
||
}
|
||
/**
|
||
* Adds a new content element to the TCA and new content wizard. Type, title, description, icon, and wizard icon can be provided or will be set based on convention.
|
||
*
|
||
* @param string The extension key providing the content element.
|
||
* @param string The unique key for the content element.
|
||
* @param string Optional path to the flexform file. If not set, EXT:{extensionKey}/{key}/flexform.xml will be used.
|
||
* @param string Optional type for use in the new content wizard.
|
||
* @param string Optional title. If not set, LLL:EXT:{extensionKey}/{key}/locallang.xml:tt_content.{key}.title will be used.
|
||
* @param string Optional description. If not set, LLL:EXT:{extensionKey}/{key}/locallang.xml:tt_content.{key}.description will be used.
|
||
* @param string Option icon path. If not set, EXT:{extensionKey}/{key}/icon.gif will be used.
|
||
* @param string Option icon path. If not set, EXT:{extensionKey}/{key}/wizard-icon.gif will be used.
|
||
* @return void
|
||
*/
|
||
public function addContentElement($extensionKey, $key, $flexformPath = '', $type = '', $title = '', $description = '', $icon = '', $wizardIcon = '') {
|
||
t3lib_div::loadTCA('tt_content');
|
||
// Set defaults for title, description, icons, and content element type.
|
||
$locallangPath = 'LLL:EXT:' . $extensionKey . '/' . $key . '/locallang.xml:tt_content.' . $key . '.';
|
||
if (!$title) {
|
||
$title = $locallangPath . 'title';
|
||
}
|
||
if (!$description) {
|
||
$description = $locallangPath . 'description';
|
||
}
|
||
if (!$icon) {
|
||
$icon = 'EXT:' . $extensionKey . '/' . $key . '/icon.gif';
|
||
}
|
||
if (!$wizardIcon) {
|
||
$wizardIcon = t3lib_extMgm::extRelPath($extensionKey) . $key . '/wizard-icon.gif';
|
||
}
|
||
if (!$type) {
|
||
$type = 'special';
|
||
}
|
||
if (!$flexformPath && @file_exists(t3lib_extMgm::extPath($extensionKey) . $key . '/flexform.xml')) {
|
||
$flexformPath = 'FILE:EXT:' . $extensionKey . '/' . $key . '/flexform.xml';
|
||
}
|
||
if ($flexformPath) {
|
||
$GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds']['*,' . $key] = $flexformPath;
|
||
$GLOBALS['TCA']['tt_content']['types'][$key] = array(
|
||
'showitem' => 'CType;;4;;1-1-1, hidden, header;;3;;2-2-2, linkToTop;;;;3-3-3, --div--;' . $title . ', pi_flexform;;;;1-1-1, --div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.access, starttime, endtime'
|
||
);
|
||
} else {
|
||
$GLOBALS['TCA']['tt_content']['types'][$key] = array(
|
||
'showitem' => 'CType;;4;;1-1-1, hidden, header;;3;;2-2-2, linkToTop;;;;3-3-3, --div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.access, starttime, endtime'
|
||
);
|
||
}
|
||
t3lib_extMgm::addPlugin(array(
|
||
$title,
|
||
$key,
|
||
$icon
|
||
), 'CType');
|
||
$TSConfig =
|
||
'wizards.newContentElement.wizardItems.' . $type . ' {
|
||
elements {
|
||
' . $key . ' {
|
||
icon = ' . $wizardIcon . '
|
||
title = ' . $title . '
|
||
description = ' . $description . '
|
||
tt_content_defValues {
|
||
CType = ' . $key .'
|
||
}
|
||
}
|
||
}
|
||
show := addToList(' . $key .')
|
||
}';
|
||
t3lib_extMgm::addPageTSConfig(
|
||
'mod.' . $TSConfig . chr(10) .
|
||
'templavoila.' . $TSConfig . chr(10)
|
||
);
|
||
}
|
||
/**
|
||
* Adds content to the default TypoScript setup by reading from a file.
|
||
*
|
||
* @param string The extension key providing the content element.
|
||
* @param string The unique key for the content element.
|
||
* @param string The path to the TypoScript file. If not set, EXT:{extensionKey}/{key}/content.ts will be used.
|
||
* @return void
|
||
*/
|
||
public function addTypoScriptFromFile($extensionKey, $key, $typoScriptPath = '') {
|
||
if (!$typoScriptPath) {
|
||
$typoScriptPath = t3lib_extMgm::extPath($extensionKey) . $key . '/content.ts';
|
||
}
|
||
$type = 'CType';
|
||
$typoScriptContent = t3lib_div::getURL($typoScriptPath);
|
||
if ($typoScriptContent) {
|
||
t3lib_extMgm::addTypoScript($key, 'setup', '
|
||
# Setting ' . $key . ' TypoScript
|
||
' . $typoScriptContent . '
|
||
', 43);
|
||
}
|
||
}
|
||
}
|
||
?>
|
typo3/sysext/cms/tslib/class.tslib_content.php (working copy) | ||
---|---|---|
case 'QTOBJECT':
|
||
$content.=$this->QTOBJECT($conf);
|
||
break;
|
||
case 'FFSECTION':
|
||
$content.=$this->FFSECTION($conf);
|
||
break;
|
||
case 'HEADERDATA':
|
||
$content.=$this->HEADERDATA($conf);
|
||
break;
|
||
default:
|
||
// call hook functions for extra processing
|
||
if($name && is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'])) {
|
||
... | ... | |
return $content;
|
||
}
|
||
/**
|
||
* Iterates over a flexform section, returning the combined output of all
|
||
* elements within the specified section.
|
||
*
|
||
* @param array $conf: The TypoScript configuration.
|
||
* @return string
|
||
*
|
||
*
|
||
* Example:
|
||
*
|
||
* 20 = FFSECTION
|
||
* 20.rootPath = t3datastructure : pi_flexform->images/el
|
||
* 20 {
|
||
* wrap = <ul id="gallery"> | </ul>
|
||
* 20 = IMAGE
|
||
* 20.file.import.data = flexformSection : image/el/path
|
||
* 20.wrap = <li> | </li>
|
||
* }
|
||
*
|
||
*
|
||
*/
|
||
public function FFSECTION(array $conf) {
|
||
$sectionArray = $this->getData($conf['rootPath'], $this->data);
|
||
$content = '';
|
||
if ($this->checkIf($conf['if.'])) {
|
||
foreach ($sectionArray as $index => $section) {
|
||
$this->sectionRootPath = $conf['rootPath'] . '/' . $index;
|
||
$content .= $this->cObjGet($conf);
|
||
}
|
||
if ($conf['wrap']) {
|
||
$content = $this->wrap($content, $conf['wrap']);
|
||
}
|
||
if ($conf['stdWrap.']) {
|
||
$content = $this->stdWrap($content, $conf['stdWrap.']);
|
||
}
|
||
}
|
||
return $content;
|
||
}
|
||
/**
|
||
* Rendering the cObject HEADERDATA.
|
||
* The result will not be outputted but added to the HTML HEAD section.
|
||
*
|
||
* @param array $conf: The TypoScript configuration.
|
||
* @return void
|
||
*/
|
||
public function HEADERDATA(array $conf) {
|
||
$additionalHeaderData = $this->stdWrap($conf['value'], $conf);
|
||
if ($additionalHeaderData !== '') {
|
||
$identifier = 'cObj.' . md5(trim($additionalHeaderData));
|
||
if (!isset($GLOBALS['TSFE']->additionalHeaderData[$identifier])) {
|
||
$GLOBALS['TSFE']->additionalHeaderData[$identifier] = $additionalHeaderData;
|
||
}
|
||
}
|
||
}
|
||
/************************************
|
||
*
|
||
* Various helper functions for content objects:
|
||
... | ... | |
break;
|
||
}
|
||
break;
|
||
case 't3datastructure':
|
||
list($fieldName, $path) = explode('->', $key, 2);
|
||
$flexFormArray = t3lib_div::xml2array($fieldArray[$fieldName]);
|
||
$retVal = $this->getFlexformValue($flexFormArray, $path);
|
||
break;
|
||
case 'flexformsection':
|
||
$rootPath = $this->sectionRootPath;
|
||
$retVal = $this->getData($rootPath . '/' . $key, $fieldArray);
|
||
break;
|
||
case 'debug':
|
||
switch((string)$key) {
|
||
case 'rootLine':
|
||
... | ... | |
return $returnValue;
|
||
}
|
||
/**
|
||
* Return value from somewhere inside a FlexForm structure
|
||
*
|
||
* @param array FlexForm data
|
||
* @param string Field name to extract. Can be given like "test/el/2/test/el/field_templateObject" where each part will dig a level deeper in the FlexForm data.
|
||
* @param string Sheet pointer, eg. "sDEF"
|
||
* @param string Language pointer, eg. "lDEF"
|
||
* @param string Value pointer, eg. "vDEF"
|
||
* @return string The content.
|
||
* @see tslib_pibase->pi_getFFvalue()
|
||
*/
|
||
protected function getFlexFormValue($flexFormArray, $fieldName, $sheet='sDEF', $lang='lDEF', $value='vDEF') {
|
||
$sheetArray = is_array($flexFormArray) ? $flexFormArray['data'][$sheet][$lang] : '';
|
||
if (is_array($sheetArray)) {
|
||
return $this->getFlexFormValueFromSheetArray($sheetArray, explode('/',$fieldName), $value);
|
||
}
|
||
}
|
||
/**
|
||
* Returns part of $sheetArray pointed to by the keys in $fieldNameArray
|
||
*
|
||
* @param array Multidimensiona array, typically FlexForm contents
|
||
* @param array Array where each value points to a key in the FlexForms content - the input array will have the value returned pointed to by these keys. All integer keys will not take their integer counterparts, but rather traverse the current position in the array an return element number X (whether this is right behavior is not settled yet...)
|
||
* @param string Value for outermost key, typ. "vDEF" depending on language.
|
||
* @return mixed The value, typ. string.
|
||
* @access private
|
||
* @see pi_getFFvalueFromSheetArray()
|
||
*/
|
||
protected function getFlexFormValueFromSheetArray($sheetArray, $fieldNameArr, $value) {
|
||
$tempArr = $sheetArray;
|
||
foreach($fieldNameArr as $k => $v) {
|
||
if (t3lib_div::testInt($v)) {
|
||
if (is_array($tempArr)) {
|
||
foreach($tempArr as $index => $values) {
|
||
if ($index==$v) {
|
||
$tempArr=$values;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
} else {
|
||
$tempArr = $tempArr[$v];
|
||
}
|
||
}
|
||
if (isset($tempArr[$value])) {
|
||
return $tempArr[$value];
|
||
} else {
|
||
return $tempArr;
|
||
}
|
||
}
|
||
- « Previous
- 1
- 2
- Next »