Project

General

Profile

Bug #19382 » 9439_new_v3.diff

Administrator Admin, 2008-11-30 21:19

View differences:

typo3/interfaces/interface.cms_newContentElementWiszardItemsHook.php (revision 0)
<?php
/***************************************************************
* Copyright notice
*
* (c) 2008 Steffen Kamper <info@sk-typo3.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* interface for classes which hook into SC_db_new_content_el and manipulater wizardItems array
*
* @author Steffen Kamper <info@sk-typo3.de>
* @package TYPO3
* @subpackage cms
*/
interface cms_newContentElementWiszardsHook {
/**
* modifies WizardItems array
*
* @param array array of Wizard Items
* @param SC_db_new_content_el parent object New Content element wizard
* @return void
*/
public function manipulateWizardItems(&$wizardItems, &$parentObject);
}
?>
typo3/sysext/cms/ext_localconf.php (working copy)
options.saveDocNew.pages_language_overlay = 0
');
t3lib_extMgm::addPageTSConfig('
mod.xMOD_db_new_content_el.wizardItems {
common.header = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:common
common.elements {
regularText {
icon = gfx/c_wiz/regular_text.gif
title = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:common_regularText_title
description = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:common_regularText_description
tt_content_defValues {
CType = text
}
}
textImage {
icon = gfx/c_wiz/text_image_right.gif
title = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:common_textImage_title
description = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:common_textImage_description
tt_content_defValues {
CType = textpic
imageorient = 17
}
}
imagesOnly {
icon = gfx/c_wiz/images_only.gif
title = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:common_imagesOnly_title
description = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:common_imagesOnly_description
tt_content_defValues {
CType = image
imagecols = 2
}
}
bulletList {
icon = gfx/c_wiz/bullet_list.gif
title = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:common_bulletList_title
description = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:common_bulletList_description
tt_content_defValues {
CType = bullets
}
}
table {
icon = gfx/c_wiz/table.gif
title = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:common_table_title
description = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:common_table_description
tt_content_defValues {
CType = table
}
}
}
common.show = regularText,textImage,imagesOnly,bulletList,table
special.header = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:special
special.elements {
filelinks {
icon = gfx/c_wiz/filelinks.gif
title = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:special_filelinks_title
description = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:special_filelinks_description
tt_content_defValues {
CType = uploads
}
}
multimedia {
icon = gfx/c_wiz/multimedia.gif
title = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:special_multimedia_title
description = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:special_multimedia_description
tt_content_defValues {
CType = multimedia
}
}
sitemap {
icon = gfx/c_wiz/sitemap2.gif
title = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:special_sitemap_title
description = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:special_sitemap_description
tt_content_defValues {
CType = menu
menu_type = 2
}
}
plainHTML {
icon = gfx/c_wiz/html.gif
title = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:special_plainHTML_title
description = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:special_plainHTML_description
tt_content_defValues {
CType = html
}
}
}
special.show = filelinks,multimedia,sitemap, plainHTML
forms.header = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:forms
forms.elements {
mail {
icon = gfx/c_wiz/mailform.gif
title = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:forms_mail_title
description = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:forms_mail_description
tt_content_defValues {
CType = mailform
bodytext (
# Example content:
Name: | *name = input,40 | Enter your name here
Email: | *email=input,40 |
Address: | address=textarea,40,5 |
Contact me: | tv=check | 1
|formtype_mail = submit | Send form!
|html_enabled=hidden | 1
|subject=hidden| This is the subject
)
}
}
search {
icon = gfx/c_wiz/searchform.gif
title = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:forms_search_title
description = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:forms_search_description
tt_content_defValues {
CType = search
}
}
login {
icon = gfx/c_wiz/login_form.gif
title = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:forms_login_title
description = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:forms_login_description
tt_content_defValues {
CType = login
}
}
}
forms.show = mail,search,login
plugins.header = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:plugins
plugins.elements {
general {
icon = gfx/c_wiz/user_defined.gif
title = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:plugins_general_title
description = LLL:EXT:cms/layout/locallang_db_new_content_el.xml:plugins_general_description
tt_content_defValues.CType = list
}
}
plugins.show = *
}
');
$TYPO3_CONF_VARS['SYS']['contentTable'] = 'tt_content';
$TYPO3_CONF_VARS['FE']['eID_include']['tx_cms_showpic'] = 'EXT:cms/tslib/showpic.php';
......
$TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['moveRecordClass'][] = 'EXT:cms/tslib/hooks/class.tx_cms_treelistcacheupdate.php:&tx_cms_treelistCacheUpdate';
?>
?>
typo3/sysext/cms/layout/db_new_content_el.php (working copy)
$this->doc->backPath = $BACK_PATH;
$this->doc->setModuleTemplate('templates/db_new_content_el.html');
$this->doc->JScode='';
$this->doc->JScodeLibArray['dyntabmenu'] = $this->doc->getDynTabMenuJScode();
$this->doc->form='<form action="" name="editForm"><input type="hidden" name="defValues" value="" />';
// Setting up the context sensitive menu:
......
} else {
$onClickEvent='';
}
$this->doc->inDocStylesArray[] = '
.typo3-dyntabmenu-divs {background-color: #fafafa; border: 1px solid #000; width: 680px;}
.typo3-dyntabmenu-divs table {margin: 15px;}
.typo3-dyntabmenu-divs table td {padding: 3px;}
';
$this->doc->JScode=$this->doc->wrapScriptTags('
function goToalt_doc() { //
'.$onClickEvent.'
}
if(top.refreshMenu) {
top.refreshMenu();
} else {
top.TYPO3ModuleMenu.refreshMenu();
}
if(top.shortcutFrame) {
top.shortcutFrame.refreshShortcuts();
}
');
// ***************************
// Creating content
// ***************************
$this->content='';
// use a wrapper div
$this->content .= '<div id="user-setup-wrapper">';
$this->content.=$this->doc->header($LANG->getLL('newContentElement'));
$this->content.=$this->doc->spacer(5);
// Wizard
$code='';
$lines=array();
$wizardItems = $this->getWizardItems();
// Hook for manipulating wizardItems
if(is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms']['db_new_content_el']['wizardItemsHook'])) {
foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms']['db_new_content_el']['wizardItemsHook'] as $classData) {
$hookObject = &t3lib_div::getUserObj($classData);
if(!($hookObject instanceof cms_newContentElementWiszardsHook)) {
throw new UnexpectedValueException('$hookObject must implement interface cms_newContentElementWiszardItemsHook', 1227834741);
}
$hookObject->manipulateWizardItems($wizardItems, $this);
}
}
// Traverse items for the wizard.
// An item is either a header or an item rendered with a radio button and title/description and icon:
$cc=0;
$key = 0;
foreach ($wizardItems as $k => $wInfo) {
if ($wInfo['header']) {
if ($cc>0) $lines[]='
<tr>
<td colspan="3"><br /></td>
</tr>';
$lines[]='
<tr class="bgColor5">
<td colspan="3"><strong>'.htmlspecialchars($wInfo['header']).'</strong></td>
</tr>';
$menuItems[] = array(
'label' => htmlspecialchars($wInfo['header']),
'content' => '<table border="0" cellpadding="1" cellspacing="2" >'
);
$key = count($menuItems) - 1;
} else {
$tL=array();
$content = '';
// Radio button:
$oC = "document.editForm.defValues.value=unescape('".rawurlencode($wInfo['params'])."');goToalt_doc();".(!$onClickEvent?"window.location.hash='#sel2';":'');
$tL[]='<input type="radio" name="tempB" value="'.htmlspecialchars($k).'" onclick="'.htmlspecialchars($this->doc->thisBlur().$oC).'" />';
$oC = "document.editForm.defValues.value=unescape('" . rawurlencode($wInfo['params']) . "');goToalt_doc();" . (!$onClickEvent ? "window.location.hash='#sel2';" : '');
$content .= '<td><input type="radio" name="tempB" value="' . htmlspecialchars($k) . '" onclick="' . htmlspecialchars($this->doc->thisBlur().$oC) . '" /></td>';
// Onclick action for icon/title:
$aOnClick = 'document.getElementsByName(\'tempB\')['.$cc.'].checked=1;'.$this->doc->thisBlur().$oC.'return false;';
$aOnClick = 'document.getElementsByName(\'tempB\')[' . $cc . '].checked=1;' . $this->doc->thisBlur() . $oC . 'return false;';
// Icon:
$iInfo = @getimagesize($wInfo['icon']);
$tL[]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><img'.t3lib_iconWorks::skinImg($this->doc->backPath,$wInfo['icon'],'').' alt="" /></a>';
$content .= '<td><a href="#" onclick="' . htmlspecialchars($aOnClick) . '"><img' . t3lib_iconWorks::skinImg($this->doc->backPath, $wInfo['icon'], '') . ' alt="" /></a></td>';
// Title + description:
$tL[]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'"><strong>'.htmlspecialchars($wInfo['title']).'</strong><br />'.nl2br(htmlspecialchars(trim($wInfo['description']))).'</a>';
$content .= '<td><a href="#" onclick="' . htmlspecialchars($aOnClick) . '"><strong>' . htmlspecialchars($wInfo['title']) . '</strong><br />' . nl2br(htmlspecialchars(trim($wInfo['description']))) . '</a></td>';
// Finally, put it together in a table row:
$lines[]='
<tr>
<td valign="top">'.implode('</td>
<td valign="top">',$tL).'</td>
</tr>';
$menuItems[$key]['content'] .= '<tr>' . $content . '</tr>';
$cc++;
}
}
// Add the wizard table to the content:
$code.=$LANG->getLL('sel1',1).'<br /><br />
// add closing table-tag
foreach ($menuItems as $key => $val) {
$menuItems[$key]['content'] .= '</table>';
}
// Add the wizard table to the content, wrapped in tabs:
$code = $LANG->getLL('sel1',1) . '<br /><br />' . $this->doc->getDynTabMenu($menuItems, 'new-content-element-wizard', false, false, 100);
$this->content.= $this->doc->section(!$onClickEvent ? $LANG->getLL('1_selectType') : '', $code, 0, 1);
<!--
Content Element wizard table:
-->
<table border="0" cellpadding="1" cellspacing="2" id="typo3-ceWizardTable">
'.implode('',$lines).'
</table>';
$this->content.= $this->doc->section(!$onClickEvent?$LANG->getLL('1_selectType'):'',$code,0,1);
// If the user must also select a column:
if (!$onClickEvent) {
......
$this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
$this->content.= $this->doc->endPage();
$this->content = $this->doc->insertStylesAndJS($this->content);
// end of wrapper div
$this->content .= '</div>';
}
/**
......
* @return array
*/
function wizardArray() {
global $LANG,$TBE_MODULES_EXT;
$config = t3lib_BEfunc::getPagesTSconfig($this->id);
$config = $config['mod.']['xMOD_db_new_content_el.'];
if (is_array($config)) {
$wizards = $config['wizardItems.'];
}
$appendWizards = $this->wizard_appendWizards($wizards['elements.']);
$wizardItems = array();
$wizardItems = array(
'common' => array('header'=>$LANG->getLL('common')),
'common_regularText' => array( // Regular text element
'icon'=>'gfx/c_wiz/regular_text.gif',
'title'=>$LANG->getLL('common_regularText_title'),
'description'=>$LANG->getLL('common_regularText_description'),
'tt_content_defValues' => array(
'CType' => 'text'
)
),
'common_textImage' => array( // Text with image
'icon'=>'gfx/c_wiz/text_image_right.gif',
'title'=>$LANG->getLL('common_textImage_title'),
'description'=>$LANG->getLL('common_textImage_description'),
'tt_content_defValues' => array(
'CType' => 'textpic',
'imageorient' => 17
)
),
'common_imagesOnly' => array( // Images only
'icon'=>'gfx/c_wiz/images_only.gif',
'title'=>$LANG->getLL('common_imagesOnly_title'),
'description'=>$LANG->getLL('common_imagesOnly_description'),
'tt_content_defValues' => array(
'CType' => 'image',
'imagecols' => 2
)
),
'common_bulletList' => array( // Bullet list
'icon'=>'gfx/c_wiz/bullet_list.gif',
'title'=>$LANG->getLL('common_bulletList_title'),
'description'=>$LANG->getLL('common_bulletList_description'),
'tt_content_defValues' => array(
'CType' => 'bullets',
)
),
'common_table' => array( // Table
'icon'=>'gfx/c_wiz/table.gif',
'title'=>$LANG->getLL('common_table_title'),
'description'=>$LANG->getLL('common_table_description'),
'tt_content_defValues' => array(
'CType' => 'table',
)
),
'special' => array('header'=>$LANG->getLL('special')),
'special_filelinks' => array( // Filelinks
'icon'=>'gfx/c_wiz/filelinks.gif',
'title'=>$LANG->getLL('special_filelinks_title'),
'description'=>$LANG->getLL('special_filelinks_description'),
'tt_content_defValues' => array(
'CType' => 'uploads',
)
),
'special_multimedia' => array( // Multimedia
'icon'=>'gfx/c_wiz/multimedia.gif',
'title'=>$LANG->getLL('special_multimedia_title'),
'description'=>$LANG->getLL('special_multimedia_description'),
'tt_content_defValues' => array(
'CType' => 'multimedia',
)
),
'special_sitemap' => array( // Sitemap
'icon'=>'gfx/c_wiz/sitemap2.gif',
'title'=>$LANG->getLL('special_sitemap_title'),
'description'=>$LANG->getLL('special_sitemap_description'),
'tt_content_defValues' => array(
'CType' => 'menu',
'menu_type' => 2
)
),
'special_plainHTML' => array( // Plain HTML
'icon'=>'gfx/c_wiz/html.gif',
'title'=>$LANG->getLL('special_plainHTML_title'),
'description'=>$LANG->getLL('special_plainHTML_description'),
'tt_content_defValues' => array(
'CType' => 'html',
)
),
'forms' => array('header'=>$LANG->getLL('forms')),
'forms_mail' => array( // Mail form
'icon'=>'gfx/c_wiz/mailform.gif',
'title'=>$LANG->getLL('forms_mail_title'),
'description'=>$LANG->getLL('forms_mail_description'),
'tt_content_defValues' => array(
'CType' => 'mailform',
'bodytext' => trim('
# Example content:
Name: | *name = input,40 | Enter your name here
Email: | *email=input,40 |
Address: | address=textarea,40,5 |
Contact me: | tv=check | 1
if (is_array($wizards)) {
foreach($wizards as $groupKey => $wizardGroup) {
$groupKey = preg_replace('/\.$/', '', $groupKey);
$showItems = t3lib_div::trimExplode(',', $wizardGroup['show'], true);
$showAll = strcmp($wizardGroup['show'], '*')?false:true;
$groupItems = array();
if (is_array($appendWizards[$groupKey . '.']['elements.'])) {
$wizardElements = array_merge((array) $wizardGroup['elements.'], $appendWizards[$groupKey . '.']['elements.']);
} else {
$wizardElements = $wizardGroup['elements.'];
}
if (is_array($wizardElements)) {
foreach ($wizardElements as $itemKey => $itemConf) {
$itemKey = preg_replace('/\.$/', '', $itemKey);
if ($showAll || in_array($itemKey, $showItems)) {
$tmpItem = $this->wizard_getItem($groupKey, $itemKey, $itemConf);
if ($tmpItem) {
$groupItems[$groupKey . '_' . $itemKey] = $tmpItem;
}
}
}
}
if (count($groupItems)) {
$wizardItems[$groupKey] = $this->wizard_getGroupHeader($groupKey, $wizardGroup);
$wizardItems = array_merge($wizardItems, $groupItems);
}
}
}
|formtype_mail = submit | Send form!
|html_enabled=hidden | 1
|subject=hidden| This is the subject
')
)
),
'forms_search' => array( // Search form
'icon'=>'gfx/c_wiz/searchform.gif',
'title'=>$LANG->getLL('forms_search_title'),
'description'=>$LANG->getLL('forms_search_description'),
'tt_content_defValues' => array(
'CType' => 'search',
)
),
'forms_login' => array( // Login form
'icon'=>'gfx/c_wiz/login_form.gif',
'title'=>$LANG->getLL('forms_login_title'),
'description'=>$LANG->getLL('forms_login_description'),
'tt_content_defValues' => array(
'CType' => 'login',
)
),
'plugins' => array('header'=>$LANG->getLL('plugins')),
'plugins_general' => array( // General plugin
'icon'=>'gfx/c_wiz/user_defined.gif',
'title'=>$LANG->getLL('plugins_general_title'),
'description'=>$LANG->getLL('plugins_general_description'),
'tt_content_defValues' => array(
'CType' => 'list',
)
),
);
// Remove elements where preset values are not allowed:
$this->removeInvalidElements($wizardItems);
return $wizardItems;
}
// PLUG-INS:
if (is_array($TBE_MODULES_EXT['xMOD_db_new_content_el']['addElClasses'])) {
reset($TBE_MODULES_EXT['xMOD_db_new_content_el']['addElClasses']);
while(list($class,$path)=each($TBE_MODULES_EXT['xMOD_db_new_content_el']['addElClasses'])) {
$modObj = t3lib_div::makeInstance($class);
$wizardItems = $modObj->proc($wizardItems);
function wizard_appendWizards($wizardElements) {
if (!is_array($wizardElements)) {
$wizardElements = array();
}
if (is_array($GLOBALS['TBE_MODULES_EXT']['xMOD_db_new_content_el']['addElClasses'])) {
foreach ($GLOBALS['TBE_MODULES_EXT']['xMOD_db_new_content_el']['addElClasses'] as $class => $path) {
require_once($path);
$modObj = t3lib_div::makeInstance($class);
$wizardElements = $modObj->proc($wizardElements);
}
}
$returnElements = array();
foreach ($wizardElements as $key => $wizardItem) {
preg_match('/^[a-zA-Z0-9]+_/', $key, $group);
$wizardGroup = $group[0] ? substr($group[0], 0, -1) . '.' : $key;
$returnElements[$wizardGroup]['elements.'][substr($key, strlen($wizardGroup)) . '.'] = $wizardItem;
}
return $returnElements;
}
// Remove elements where preset values are not allowed:
$this->removeInvalidElements($wizardItems);
return $wizardItems;
function wizard_getItem($groupKey, $itemKey, $itemConf) {
$itemConf['title'] = $GLOBALS['LANG']->sL($itemConf['title']);
$itemConf['description'] = $GLOBALS['LANG']->sL($itemConf['description']);
$itemConf['tt_content_defValues'] = $itemConf['tt_content_defValues.'];
unset($itemConf['tt_content_defValues.']);
return $itemConf;
}
function wizard_getGroupHeader($groupKey, $wizardGroup) {
return array(
'header' => $GLOBALS['LANG']->sL($wizardGroup['header'])
);
}
/**
* Checks the array for elements which might contain unallowed default values and will unset them!
* Looks for the "tt_content_defValues" key in each element and if found it will traverse that array as fieldname / value pairs and check. The values will be added to the "params" key of the array (which should probably be unset or empty by default).
......
$SOBE->main();
$SOBE->printContent();
?>
?>
(1-1/5)