Zum Inhalt springen

Probleme mit Verlinkung im Backend Modul

Erstellt am 19. Oktober 2011 · 1 Antwort · letzte Antwort am 19. Oktober 2011

Tags: PHP, Frage

auxiliumseeker ·

Hallo zusammen,

Ich habe eine einfache Extension geschrieben, die ich gerne um weitere Funktionalitäten ergänzen möchte. Diese sollen per GET-Parameter jeweils aufrufbar sein.

Dazu habe ich in der Extension beispielsweise einen entsprechenden Link gesetzt, um ein neues Element hinzuzufügen.:

<br><a href='index.php?new=true'>Neues Hinzu</a><br>";

Das Problem ist nun, dass er dabei nicht auf die "index.php von meinem modul verlinkt", sodass ich die parameter dann verarbeiten kann, sondern auf die allgemeine index.php vom backend.
Gebe ich dann den absoluten Pfad an und rufen diese Dateien auf, so zeigt er die Fehlermeldungen an:
Notice: Undefined variable: LANG in pfadname/mod1/index.php on line 31

Fatal error: Call to a member function includeLLFile() on a non-object in pfadname/mode1/index.php on line 31

$LANG->includeLLFile('EXT:test/mod1/locallang.xml');
require_once(PATH_t3lib . 'class.t3lib_scbase.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 'test2' for the 'test' extension.

 */
class  tx_daniel_module1 extends t3lib_SCbase {
				var $pageinfo;

				/**
				 * Initializes the Module
				 * @return	void
				 */
				function init()	{
					global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;

					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->backPath = $BACK_PATH;
						$this->doc->form='<form action="" method="post" enctype="multipart/form-data">';

							// 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_cs($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();
					echo $this->content;
				}

				/**
				 * Generates the module content
				 *
				 * @return	void
				 */
				function moduleContent()	{
			
		if(isset($_GET["new"])) {
			// Eintrag bearbeiten
			$content = $this -> create_change();

				
		}
		else{ $content = $this->showOverview();

			
		}
		$this->content.=$this->doc->section('',$content,0,1);

	}

	function showOverview(){
		$str 		= "<h1>Aktuelle Eintr&auml;ge der Datenbank:</h1><br>";
		$str		.= "<table border='solid'><tr>";
		$str 		.= "<td><b>Spale1</b></td><td><b>Spalte 2</b></td><td><b>Ergaenzung</b></td><td><b>Spalte3</b></td><td><b>Spalte4</b></td><td><b>Ergaenzung</b></td></tr>";
		$query	 	= "SELECT * FROM `test";
		$result 	= $GLOBALS['TYPO3_DB']->sql_query($query);
		while ($row =  $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
			$str .= "<tr><td>";
			$str .=$row['name']."</td><td>".$row['gram']."</td><td> ".$row['angabe']."</td>";
			$str .="<td>";
			$str .=$row['name2']." </td><td>".$row['gram2']."</td><td> ".$row['angabe2']."</td>";
			$str .="</td></tr>";
		}
		$str .= "</table>";
		[b]$str .= "<br><a href='../typo3conf/ext/testdaniel/mod1/index.php?new=true'>Neues Hinzu</a><br>";[/b]
		$str .= $this->create_change();
		return $str;
	}


function create_change(){
	$myPOST = t3lib_div::_POST();
	if(empty($myPOST)) {
	
	$query	 	= "SELECT * FROM `tx_testdaniel_vokabeln";
	$result 	= $GLOBALS['TYPO3_DB']->sql_query($query);
	$row =  $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
	$deu = $row['name'];
	$rus = $row['name2'];
	 
	
		// kurzes Formular zum eingeben des neuen Wertes
		$str  = "<b>Neuen Wert eingeben:</b><br><form method='POST' action='index.php'><input name='deut' type='text' value= '".$deu."' size='30' maxlength='30'>";
		$str .= "<input name='rus' type='text' value= '".$rus."' size='30' maxlength='30'>";
		$str .= "<input type='submit' value='ok'></form>";
		return $str;
	}
	else {
		$query ="INSERT INTO `tx_testdaniel_vokabeln` ( `name` , `name2` )
														VALUES (
														'". $_POST[deut]."', '".$_POST[rus]."'
														);";
			

		$msg = "";
		$result = $GLOBALS['TYPO3_DB'] -> sql_query($query);
		if("" == ($error = $GLOBALS['TYPO3_DB'] -> sql_error($result))) {
			$msg .= "Neuer Eintrag ---> [ok]<br><br>";
		}
		else {
			$msg .= "<font color='red'>FEHLER: ".$error."</font><br><br>";
		}
		return $msg;
	}
}
				
		}



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




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

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

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

?>