[TYPO3-german] Woher bezieht der TinyRTE seine Javascripts?

Steffen Kern steffenkern at googlemail.com
Fri Jul 6 18:19:39 CEST 2007


Hallo an alle :-)

Ich habe im Moment das Problem, dass ich keinen blassen Schimmer habe,
woher der TinyRTE seine Javascript bezieht, geschweige denn, von wo
aus die eingebunden werden.
Ich versuche im Moment den TinyRTE in ein eigenes BE-Modul zu
integrieren, bekomme aber nur ein Textfeld, ohne die typischen
Word-Editierfunktionen mit bunten Bildchen.
Nachdem ich jetzt schon mehrere Wochen an dem Problem sitzte, hoffe
ich, dass mir hier weitergeholfen werden kann.

01.html ist meine aktuelle Ausgabe noch mit ein paar debugs.
02.txt ist meine aktuelle mod1/index.php
03.jpg ist ein Bild, wie es gerade aussieht :-)

Ich habe glaube ich, so ziemlich alles von TCEForms, über rteapi, bis
hin zu pagegen und weiteren codedateien durchsucht, nur um mein
Problem zu lösen, aber bisher kein Erfolg.

Ich würde mich über Hilfe wirklich sehr freuen und wäre sehr, sehr dankbar.

Steffen
-------------- next part --------------
<?php
/***************************************************************
*  Copyright notice
*
*  (c) 2007 Steffen Kern <SteffenKern at web.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.
*
*  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!
***************************************************************/


	// DEFAULT initialization of a module [BEGIN]
unset($MCONF);
require_once('conf.php');
require_once($BACK_PATH.'init.php');
require_once($BACK_PATH.'template.php');

$LANG->includeLLFile('EXT:user_productmanager/mod1/locallang.xml');
require_once(PATH_t3lib.'class.t3lib_scbase.php');
require_once(PATH_t3lib.'class.t3lib_basicfilefunc.php');
require_once(PATH_t3lib.'class.t3lib_extfilefunc.php');
require_once(PATH_t3lib.'class.t3lib_tcemain.php');
require_once(PATH_t3lib.'class.t3lib_befunc.php');
require_once(PATH_t3lib.'class.t3lib_tceforms.php');
//require_once(PATH_tslib.'class.tslib_pibase.php');
require_once(t3lib_extMgm::extPath('tinyrte').'class.tx_tinyrte_base.php');

$BE_USER->modAccess($MCONF,1);	// This checks permissions and exits if the users has no permission for entry.
	// DEFAULT initialization of a module [END]



/**
 * Module 'Productmanager' for the 'user_productmanager' extension.
 *
 * @author	Steffen Kern <SteffenKern at web.de>
 * @package	TYPO3
 * @subpackage	user_productmanager
 */
class  user_productmanager_module1 extends t3lib_SCbase {



				/**
				* General Information
				*/
				var $pageinfo;
				var $elementsDBTable = 'user_productmanager_elements';	// Table in which elements are stored in the DB.
				var $rowsDBTable = 'user_productmanager_rows';			// Table in which rows are stored in the DB.
				
				/**
				* RTE variables
				*/
				var $RTEObj;
				var $strEntryField;
				var $docLarge = 0;
				var $RTEcounter = 0;
				var $formName;
				var $additionalJS_initial = '';          // Initial JavaScript to be printed before the form (should be in head, but cannot due to IE6 timing bug)
				var $additionalJS_pre = array();        // Additional JavaScript to be printed before the form
				var $additionalJS_post = array();       // Additional JavaScript to be printed after the form
				var $additionalJS_submit = array();     // Additional JavaScript to be executed on submit
				
				/**
				 * Initializes the Module
				 * @return	void
				 */
				function init()	{
					global $TSFE,$BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
					
						// Linefeeds for visual beauty.
					define("LF_lmnt1",'"\t"');
					define("LF_lmnt2",'"\t\t"');
					define("LF_lmnt3",'"\t\t\t"');
					define("LF_tbl1",'"\t"');
					define("LF_row1",'"\t"');
					define("LF_row2",'"\t\t"');
					define("LF_row3",'"\t\t\t"');
					define("LF_row4",'"\t\t\t"');

						// Other constants.
					define("btn_IMG_Folder",'"../../../../typo3/sysext/t3skin/icons/gfx/"');
					
						// Init instances of classes.
					$this->TCEForms = t3lib_div::makeInstance('t3lib_TCEforms');

					parent::init();

					/*
					if (t3lib_div::_GP('clear_all_cache'))	{
						$this->include_once[] = PATH_t3lib.'class.t3lib_tcemain.php';
					}
					*/
				}

				/**
				 * Adds items to the ->MOD_MENU array. Used for the function menu selector.
				 *
				 * @return	void
				 */
				function menuConfig()	{
					global $LANG;
					$this->MOD_MENU = Array (
						'function' => Array (
							'1' => $LANG->getLL('function1'),
							'2' => $LANG->getLL('function2'),
							'3' => $LANG->getLL('function3'),
						)
					);
					parent::menuConfig();
				}

				/**
				 * Main function of the module. Write the content to $this->content
				 * If you chose "web" as main module, you will need to consider the $this->id parameter which will contain the uid-number of the page clicked in the page tree
				 *
				 * @return	[type]		...
				 */
				function main()	{
					global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;

					// Access check!
					// The page will show only if there is a valid page and if this page may be viewed by the user
					$this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause);
					$access = is_array($this->pageinfo) ? 1 : 0;

					if (($this->id && $access) || ($BE_USER->user['admin'] && !$this->id))	{

							// Draw the header.
						$this->doc = t3lib_div::makeInstance('mediumDoc');
						$this->doc->docType = 'xhtml_strict';
						$this->doc->backPath = $BACK_PATH;
						$this->doc->form='<form action="" method="post" name="editform" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'">';

							// JavaScript
						$this->doc->JScode = '
							<script language="javascript" type="text/javascript">
								script_ended = 0;
								function jumpToUrl(URL)	{
									document.location = URL;
								}
							</script>
						';
						$this->doc->postCode='
							<script language="javascript" type="text/javascript">
								script_ended = 1;
								if (top.fsMod) top.fsMod.recentIds["web"] = 0;
							</script>
						';

						$headerSection = $this->doc->getHeader('pages',$this->pageinfo,$this->pageinfo['_thePath']).'<br />'.$LANG->sL('LLL:EXT:lang/locallang_core.xml:labels.path').': '.t3lib_div::fixed_lgd_pre($this->pageinfo['_thePath'],50);

						$this->content.=$this->doc->startPage($LANG->getLL('title'));
						$this->content.=$this->doc->header($LANG->getLL('title'));
						$this->content.=$this->doc->spacer(5);
						$this->content.=$this->doc->section('',$this->doc->funcMenu($headerSection,t3lib_BEfunc::getFuncMenu($this->id,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function'])));
						$this->content.=$this->doc->divider(5);


						// Render content:
						$this->moduleContent();


						// ShortCut
						if ($BE_USER->mayMakeShortcut())	{
							$this->content.=$this->doc->spacer(20).$this->doc->section('',$this->doc->makeShortcutIcon('id',implode(',',array_keys($this->MOD_MENU)),$this->MCONF['name']));
						}

						$this->content.=$this->doc->spacer(10);
					} else {
							// If no access or if ID == zero

						$this->doc = t3lib_div::makeInstance('mediumDoc');
						$this->doc->backPath = $BACK_PATH;

						$this->content.=$this->doc->startPage($LANG->getLL('title'));
						$this->content.=$this->doc->header($LANG->getLL('title'));
						$this->content.=$this->doc->spacer(5);
						$this->content.=$this->doc->spacer(10);
					}
				}

				/**
				 * Prints out the module HTML
				 *
				 * @return	void
				 */
				function printContent()	{

					
					$this->content.= $this->doc->endPage();
					$this->content = $this->doc->insertStylesAndJS($this->content);
					
					echo $this->content;
				}


				/**
				 * Generates the module content
				 *
				 * @return	void
				 */
				function moduleContent()	{
					global $TCA,$GLOBALS,$TYPO3_CONF_VARS,$TCA,$BE_USER;
					
					switch((string)$this->MOD_SETTINGS['function'])	{
						case 1:
							$content='GET:'.t3lib_div::view_array($_GET).'<br />'.
								'POST:'.t3lib_div::view_array($_POST).'<br />'.
								'';
							$this->content.=$this->doc->section('Message #1:',$content,0,1);
						break;
						case 2:

								// Get the variables needed.
							$thePidValue = $this->id;
							$RTEtypeVal = 'text';
							$RTErelPath = '';
							$table = $this->elementsDBTable;
							$field = 'rtecontent';
							$uid = 3;
							$row = t3lib_BEfunc::getRecord($table,$uid,'*','');
							
								// Get value for RTE from DB.
							$trData = t3lib_div::makeInstance('t3lib_transferData');
							$trData->lockRecords=1;
							$trData->fetchRecord($table,$uid,'');
							
								// Create the $PA[]-Array.
							t3lib_div::loadTCA($table);
							$PA = array(
								'altName'		=> '',
								'palette'		=> 0,
								'extra'			=> "richtext:rte_transform[flag=rte_enabled|mode=ts_css]",
								'pal'			=> '9',
								'fieldConf'		=> $TCA[$table]['columns'][$field],
								'fieldTSConfig'		=> '',
								'itemFormElName'	=> 'data['.$table.']['.$thePidValue.']['.$RTEtypeVal.']',
								'itemFormElName_file'	=> '',
								'itemFormElValue'	=> $trData->regTableItems_data["user_productmanager_elements_$uid"]["$field"],
								'itemFormElID'		=> 'data_'.$table.'_'.$thePidValue.'_bodytext',
								'onFocus'		=> '',
								'label'			=> '',
								'fieldChangeFunc'	=> array(
									'TBE_EDITOR_fieldChanged'	=> "TBE_EDITOR.fieldChanged('".$table."','".$thePidValue."','bodytext','data[".$table."][".$thePidValue."][bodytext]');",
									'alert'				=> ''
								)
							);
							
								// Customize the Array.
							unset($PA['fieldConf']['exclude']);
							
							$PA['fieldConf']['l10n_mode']	= 'prefixLangTitle';
							$PA['fieldConf']['l10n_cat']	= 'text';
							$PA['fieldConf']['label']	= 'LLL:EXT:lang/locallang_general.php:LGL.text';
							
							$PA['fieldConf']['config']['wizards']['_PADDING']	= 4;
							$PA['fieldConf']['config']['wizards']['RTE']['icon']	= "../../../../typo3/sysext/t3skin/icons/gfx/wizard_rte2.gif";
							$PA['fieldConf']['config']['wizards']['RTE']['script']	= "../../../../typo3/wizard_rte.php";
							/*
							$PA['fieldConf']['config']['wizards']['table']	= array(
													'notNewRecords'		=> 1,
													'enableByTypeConfig'	=> 1,
													'type'			=> 'script',
													'title'			=> 'Table wizard',
													'icon'			=> "../../../../typo3/wizard_table.gif",
													'script'		=> "../../../../typo3/wizard_table.php",
													'params'		=> array(
																	xmlOutput	=> 0
																)
												);
							$PA['fieldConf']['config']['wizards']['forms']	= array(
													'notNewRecords'		=> 1,
													'enableByTypeConfig'	=> 1,
													'type'			=> 'script',
													'title'			=> 'Forms wizard',
													'icon'			=> "../../../../typo3/wizard_forms.gif",
													'script'		=> "../../../../typo3/wizard_forms.php",
													'params'		=> array(
																	xmlOutput	=> 0
																)
												);
							*/
							$PA['fieldConf']['config']['softref']	= 'typolink_tag,images,email[subst],url';
							$PA['fieldConf']['config']['form_type']= 'text';
							
							
								// Create the special configuration.
							$specConf = array(
								'richtext'	=> 1,
								'rte_transform'	=> array(
									'parameters'	=> array(
										'flag=rte_enabled',
										'mode=ts_css'
									)
								)
							);
							
								// Get the RTE-Configuration from TSConfig.
							$TS=t3lib_befunc::getPagesTSconfig($thePidValue);
							$thisConfig = $TS['RTE.']['default.'];
							unset($TS);
							
								// Setting up the altItem form field, which is a hidden field containing the value
							$altItem = '<input type="hidden" name="'.htmlspecialchars($PA['itemFormElName']).'" value="'.htmlspecialchars($PA['itemFormElValue']).'" />';
							
								// Draw the RTE.
							$this->TCEForms->RTEcounter++;
							$RTEobj = &t3lib_BEfunc::RTEgetObj();
							$RTEobj->ID = 'rte';
							$RTEForm = $RTEobj->drawRTE($this->TCEForms,$table,$field,$row,$PA,$specConf,$thisConfig,$RTEtypeVal,$RTErelPath,$thePidValue);
							$item = $this->TCEForms->renderWizards(array($RTEForm,$altItem),$PA["fieldConf"]["config"]["wizards"],$table,$row,$field,$PA,$PA['itemFormElName'],$specConf,1);
								// Add needed JS functions.
							$this->formName = 'editform';
							$content = $this->TCEForms->printNeededJSFunctions_top().
								   $item.
								   $this->TCEForms->printNeededJSFunctions();
							
							
							t3lib_div::debug($table);
							t3lib_div::debug($field);
							t3lib_div::debug($row);
							t3lib_div::debug($PA);
							t3lib_div::debug($specConf);
							t3lib_div::debug($thisConfig);
							t3lib_div::debug($RTEtypeVal);
							t3lib_div::debug($RTErelPath);
							t3lib_div::debug($thePidValue);
							
							
							$this->content.=$this->doc->section('Message #2:',$content,0,1);
						break;
						case 3:

							$this->content.=$this->doc->section('Message #3:',$content,0,1);
						break;
					}
				}
			}



if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/user_productmanager/mod1/index.php'])	{
	include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/user_productmanager/mod1/index.php']);
}




// Make instance:
$SOBE = t3lib_div::makeInstance('user_productmanager_module1');
$SOBE->init();

// Include files?
foreach($SOBE->include_once as $INC_FILE)	include_once($INC_FILE);

$SOBE->main();
$SOBE->printContent();

?>


More information about the TYPO3-german mailing list