<?php

// [wctform id="1" limit="50"] als ausgabe zu Form 1

$form = $wpdb->get_row("SELECT `e_setup`,`t_setup`,`rights`,`r_table`,`r_fields`,`r_filter`,`htmlview`,`smail` FROM `".$wpdb->prefix."wct_form` WHERE `id`='".$id."' LIMIT 1;");

if ($form->rights[3] == '1' AND $_GET['wctdfid'] != '') {
	if ($form->r_filter != '') { $filter = "AND ".$form->r_filter; } else { $filter = ''; }
	$wpdb->get_row("UPDATE `".$wpdb->prefix."wct".$form->r_table."` SET `status`='passive' WHERE `status` != 'passive' AND `id`='".mres($_GET['wctdfid'])."' ".$filter." LIMIT 1;");
	if ($form->smail == '1') {
		wp_mail(get_settings( 'admin_email' ), "Custom Forms - ".__('Entry was deleted','wct'),"Please check the if the Entry can be deleted (located in passive Section).\r\n\r\nLink ".admin_url('admin.php?page=wct_table_'.$form->r_table.'&wcttab=content&wcttab2=passive&action=edit&wcts=0&rid='.$_GET['wctdfid']));
	}
}
elseif ($_GET['wctefid'] == 'save') {
	foreach ($_POST as $var => $wert) {
		if ($var != 'submit' AND strpos($var,"wctf_") !== false) {
			if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$wert)) {
				$t = explode("-",$wert);
				$wert = mktime(1,1,1,$t[1],$t[2],$t[0]);
			}
			$sqlstring .= "`".mres(str_replace("wctf_","",$var))."`='".mres($wert)."',";
		}
	}
	$sqlstring = substr($sqlstring,0,strlen($sqlstring)-1);

	if ($_GET['wctfid'] == '' AND $form->rights[2] == '1') {
		if ($form->smail == '1') {
			$wpdb->get_row("INSERT INTO `".$wpdb->prefix."wct".$form->r_table."` SET ".$sqlstring.", `status`='draft';");
			$tableid = mysql_insert_id();
			wp_mail(get_settings( 'admin_email' ), "Custom Forms - ".__('Entry was created','wct'),"Please check the if the Entry can be published (located in draft Section).\r\n\r\nLink ".admin_url('admin.php?page=wct_table_'.$form->r_table.'&wcttab=content&wcttab2=draft&action=edit&wcts=0&rid='.$tableid));
		}
		else {
			$wpdb->get_row("INSERT INTO `".$wpdb->prefix."wct".$form->r_table."` SET ".$sqlstring.", `status`='active';");
		}
	}
	elseif ($_GET['wctfid'] != '' AND $form->rights[1] == '1') {
		if ($form->smail == '1') {
			$wpdb->get_row("UPDATE `".$wpdb->prefix."wct".$form->r_table."` SET ".$sqlstring.",`status`='draft' WHERE `status`!='passive' AND `id`='".mres($_GET['wctfid'])."' LIMIT 1;");
			$createid = mysql_insert_id();
			if ($createid != '0') { wp_mail(get_settings( 'admin_email' ), "Custom Forms - ".__('Entry was updated','wct'),"Please check the if the Entry can be published (located in draft Section).\r\n\r\nLink ".admin_url('admin.php?page=wct_table_'.$form->r_table.'&wcttab=content&wcttab2=draft&action=edit&wcts=0&rid='.$createid)); }
		}
		else {
			$wpdb->get_row("UPDATE `".$wpdb->prefix."wct".$form->r_table."` SET ".$sqlstring." WHERE `status`!='passive' AND `id`='".mres($_GET['wctfid'])."' LIMIT 1;");
		}
	}
}


// speichern bei änderung und neuer eintrag fehlt.


if ($_GET['wctfid'] == '' AND $_GET['wctnew'] == '1' AND $form->rights[2] == '1') {
	$url = $this->generate_pagelink("/[&?]+wctnew=[0-9]*/","");
	echo "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"".plugins_url('custom-tables/jscal/calendar-blue2.css')."\" title=\"blue\" />
		<script type=\"text/javascript\" src=\"".plugins_url('custom-tables/jscal/calendar.js')."\"></script>
		<script type=\"text/javascript\" src=\"".plugins_url('custom-tables/jscal/lang/calendar-en.js')."\"></script>
		<script type=\"text/javascript\" src=\"".plugins_url('custom-tables/jscal/calendar-setup.js')."\"></script>
		<script>function getY (el) {y = el.offsetTop;if (!el.offsetParent) { return y; } else return (y+getY(el.offsetParent)-35);}</script>";

	$table = $wpdb->get_row("SHOW CREATE TABLE `".$wpdb->prefix."wct".$form->r_table."`;");
	$array=array(); foreach($table as $member=>$data) { $array[$member]=$data; }
	$tmp = explode("PRIMARY KEY",$array['Create Table']);
	$felder = explode("\n",$tmp[0]);
	for ($i=2;$felder[$i] != '';$i++) {
		$x++;
		$feld[$x] =  preg_replace("/.*`(.*?)`.*/","$1",$felder[$i-1]);
		if (strpos ($felder[$i-1]," text") !== false) {
			$feld2[$feld[$x]] =  preg_replace("/.*`(.*)`\s(.*?)\s.*/","$2",str_replace(array(",","8 ,2","' ,'"),array(" ,","8.2","'.'"),$felder[$i-1]));
		}
		else {
			$feld2[$feld[$x]] =  preg_replace("/.*`(.*)`\s(.*\))\s.*/","$2",str_replace(array(",","8 ,2","' ,'"),array(" ,","8.2","'.'"),$felder[$i-1]));
		}
	}
	$out .= "<h3>".__('Create Entry','wct')."</h3><form action=\"".$url."wctfid=".$_GET['wctfid']."&wctefid=save\" method=\"POST\">";

	$inhalt = $form->e_setup;
	$rights = ",".$form->r_fields.",";

	preg_match_all("/\{(.*?)\}/", $inhalt, $matches);

	foreach ($matches[1] as $val => $wert) {
		if (strpos($rights,",".$wert.",") === false) {
			$addon = " style=\"background-color: grey;\" readonly";
		}
		else { $addon = ""; }

		if ($feld2[$wert] == "smallint(6)") { $inhalt = str_replace("{".$wert."}","<input size=\"7\" type=\"text\" name=\"".($addon != '' ? "wctn_" : "wctf_").$wert."\" value=\"\" maxsize=\"6\"".$addon."/>",$inhalt); }
		elseif ($feld2[$wert] == "int(10)") { 
			if (strpos($rights,",".$wert.",") === false) {
				$inhalt = str_replace("{".$wert."}","<input size=\"10\" type=\"text\" name=\"wctn_".$wert."\" value=\"".date("Y-m-d",time())."\" maxsize=\"10\"".$addon.">",$inhalt);
			}
			else {
				$inhalt = str_replace("{".$wert."}","<input size=\"10\" type=\"text\" name=\"wctf_".$wert."\" value=\"".date("Y-m-d",time())."\" maxsize=\"10\"".$addon."><img style=\"position:relative; bottom:-10px;\" src=\"".plugins_url('custom-tables/jscal/cal.jpg')."\" id=\"f_trigger_".$wert."\" title=\"Date selector\" onmouseover=\"this.style.background='red';\" onmouseout=\"this.style.background=''\" />".
				     "<script type=\"text/javascript\">Calendar.setup({inputField: \"f_date_".$wert."\",ifFormat: \"%Y-%m-%d\", button: \"f_trigger_".$wert."\", align: \"Tl\",firstDay:1,singleClick: true,position:[550,getY(document.getElementById('f_date_".$wert."'))]});</script>",$inhalt);
			}
		}
		elseif ($feld2[$wert] == "int(11)") { $inhalt = str_replace("{".$wert."}","<input size=\"12\" type=\"text\" name=\"".($addon != '' ? "wctn_" : "wctf_").$wert."\" value=\"\" maxsize=\"11\"".$addon."/>",$inhalt); }
		elseif ($feld2[$wert] == "varchar(32)") { $inhalt = str_replace("{".$wert."}","<input size=\"34\" type=\"text\" name=\"".($addon != '' ? "wctn_" : "wctf_").$wert."\" value=\"\" maxsize=\"32\"".$addon."/>",$inhalt); }
		elseif ($feld2[$wert] == "varchar(64)") { $inhalt = str_replace("{".$wert."}","<input size=\"65\" type=\"text\" name=\"".($addon != '' ? "wctn_" : "wctf_").$wert."\" value=\"\" maxsize=\"64\"".$addon."/>",$inhalt); }
		elseif ($feld2[$wert] == "varchar(128)") { $inhalt = str_replace("{".$wert."}","<input size=\"112\" type=\"text\" name=\"".($addon != '' ? "wctn_" : "wctf_").$wert."\" value=\"\" maxsize=\"128\"".$addon."/>",$inhalt); }
		elseif (substr($feld2[$wert],0,4) == "enum") {
			if ($addon == "") {
				$tmp = "<select style=\"width:120px;\" name=\"".($addon != '' ? "wctn_" : "wctf_").$wert."\">";
				$defs = explode(".",str_replace("'","",substr($feld2[$wert],6,(strlen(rtrim($feld2[$wert]))-8))));

				foreach ($defs as $posibility) {
					$tmp .= "<option value=\"".$posibility."\">".$posibility."</option>";
				}
				$tmp .= "</select>";
			}
			else {
				$tmp = "<input size=\"10\" type=\"text\" name=\"wctn_".$wert."\" value=\"".stripslashes($row->$wert)."\" maxsize=\"32\"".$addon."/>";
			}
			$inhalt = str_replace("{".$wert."}",$tmp,$inhalt);
		}
		elseif ($feld2[$wert] == "float(8.2)") { $inhalt = str_replace("{".$wert."}","<input size=\"12\" type=\"text\" name=\"".($addon != '' ? "wctn_" : "wctf_").$wert."\" value=\"\" maxsize=\"11\"".$addon."/>",$inhalt); }
		elseif ($feld2[$wert] == "text") {
			if ($addon != '') { $addon = " style=\"background-color: #CCC;\" readonly=\"readonly\""; } else { $mytextfelder .= "wctf_".$wert.","; }
			$inhalt = str_replace("{".$wert."}","<textarea id=\"wctf_".$wert."\" name=\"".($addon != '' ? "wctn_" : "wctf_").$wert."\" style=\"height: 155px;width: 100%;\"".$addon.">".stripslashes($row->$wert)."</textarea>",$inhalt);
		}
	}

	if ($mytextfelder != '') {
		$wct_elements = substr($mytextfelder,0,strlen($mytextfelder)-1);
		global $wuk_tinymce;
		$wuk_tinymce->tinymce_getInitJS($wct_elements,$form->htmlview);
	}

	$out .= rbr($inhalt)."<br/><input type=\"submit\" name=\"submit\" value=\"". __('Save all Changes', 'wct') ."\"></form>";
	$out = do_shortcode($out);

}
elseif ($_GET['wctfid'] == '' AND ($form->rights[0] == '1' OR $form->rights[3] == '1')) // Read rights needed
{
	$url = $this->generate_pagelink("/[&?]+wct[de]*fid=.*/","");
	if ($form->t_setup != '') {
		if ($_REQUEST['wctstart'] != '') {
			$start = (integer)$_REQUEST['wctstart'];
			$limit2 = $start.",".$limit;
		} else { $limit2 = $limit; }

		$out .= "<script type=\"text/javascript\">
			function chkconfirm() {
				var answer = confirm('". __ ('Do you really want to delete this record?', 'wct')."');
				if (answer) { return true; } else { return false; }
			}
			</script><h3>".__('draft','wct')." ".__('Entries','wct')."</h3><table name=\"wct-table\" id=\"wct-table\" class=\"wct-table\">";
		if ($form->r_filter != '') { $filter = "AND ".$form->r_filter; } else { $filter = ''; }
		$qry = $wpdb->get_results("SELECT * FROM `".$wpdb->prefix."wct".$form->r_table."` WHERE `status`='draft' ".$filter." LIMIT ".$limit2.";");
		if (count($qry) >= '1') {
			foreach ($qry as $row)
			{
				$inhalt = preg_replace(array('/<\/td>[\r\n]*<td>/','/<\/td>[\r]*<td>/','/<\/td>[\n]*<td>/'), array('</td><td>','</td><td>','</td><td>'), $form->t_setup);
				if ($color == "1") { $color = "2"; } else { $color = "1"; }
					$out .= "<tr class=\"wct-td".$color."\" id=\"wct_omaster".$row->id."\" ".
					 "onmouseover=\"this.setAttribute('class', 'wct-td-hover')\" onmouseout=\"this.setAttribute('class', 'wct-td".$color."')\" >".
					 rbr(preg_replace("/\{(.*?)\}/e","((\$row->$1 >= '797043723' AND \$row->$1 < '3428195723') ? date('Y-m-d',\$row->$1) : \$row->$1)",$inhalt));

				if ($form->rights[1] == '1') { $out .= "<td><a href=\"".$url."wctfid=".$row->id."\" style=\"text-decoration:none;\">[EDIT]</a></td>"; }
				if ($form->rights[3] == '1') { $out .= "<td><a href=\"".$url."wctdfid=".$row->id."\" onclick=\"return chkconfirm()\" style=\"text-decoration:none;\">[DEL]</a></td>"; }
				$out .= "</tr>";
			}
		}
		else {
			$out .= "<tr><td>".__('No entries found', 'wct')."</td></tr>";
		}
		$qry = $wpdb->get_row("SELECT count(id) as `anz` FROM `".$wpdb->prefix."wct".$form->r_table."` WHERE `status`='draft' ".$filter);
		$menge = ceil($qry->anz / $limit);
		if ($menge > '1') {
			$url = $this->generate_pagelink("/[&?]+wctstart=[0-9]*/","");
				$out .= "<tr><td colspan=\"500\" class=\"wct-errorfield\"><center><b>".__('Page', 'wct').":</b> ";
			for ($x=1;$x <= $menge;$x++) {
				$l = ($limit * ($x - 1)) + 1;
				if($_GET['wctstart'] == $l OR ($l == '1' AND $_GET['wctstart'] == '')) { $out .= $x."&nbsp;"; }
				else {	$out .= "<a href=\"".$url."wctstart=".$l."\">".$x."</a>&nbsp;"; }
			}
			$out .= "</center></td></tr>";
		}
		$out .= "</table>".__('Draft Entries need an approval from an Admin to get published.','wct');
		$out .= "<h3>".__('active','wct')." ".__('Entries','wct')."</h3><table name=\"wct-table\" id=\"wct-table\" class=\"wct-table\">";
		if ($form->r_filter != '') { $filter = "AND ".$form->r_filter; } else { $filter = ''; }
		$qry = $wpdb->get_results("SELECT * FROM `".$wpdb->prefix."wct".$form->r_table."` WHERE `status`='active' ".$filter." LIMIT ".$limit2.";");
		if (count($qry) >= '1') {
			foreach ($qry as $row)
			{
				$inhalt = preg_replace(array('/<\/td>[\r\n]*<td>/','/<\/td>[\r]*<td>/','/<\/td>[\n]*<td>/'), array('</td><td>','</td><td>','</td><td>'), $form->t_setup);
				if ($color == "1") { $color = "2"; } else { $color = "1"; }
					$out .= "<tr class=\"wct-td".$color."\" id=\"wct_omaster".$row->id."\" ".
					 "onmouseover=\"this.setAttribute('class', 'wct-td-hover')\" onmouseout=\"this.setAttribute('class', 'wct-td".$color."')\" >".
					 rbr(preg_replace("/\{(.*?)\}/e","((\$row->$1 >= '797043723' AND \$row->$1 < '3428195723') ? date('Y-m-d',\$row->$1) : \$row->$1)",$inhalt));

				if ($form->rights[1] == '1') { $out .= "<td><a href=\"".$url."wctfid=".$row->id."\" style=\"text-decoration:none;\">[EDIT]</a></td>"; }
				if ($form->rights[3] == '1') { $out .= "<td><a href=\"".$url."wctdfid=".$row->id."\" onclick=\"return chkconfirm()\" style=\"text-decoration:none;\">[DEL]</a></td>"; }
				$out .= "</tr>";
			}
		}
		else {
			$out .= "<tr><td>".__('No entries found', 'wct')."</td></tr>";
		}
			$qry = $wpdb->get_row("SELECT count(id) as `anz` FROM `".$wpdb->prefix."wct".$form->r_table."` WHERE `status`='active' ".$filter);
		$menge = ceil($qry->anz / $limit);
		if ($menge > '1') {
			$url = $this->generate_pagelink("/[&?]+wctstart=[0-9]*/","");
				$out .= "<tr><td colspan=\"500\" class=\"wct-errorfield\"><center><b>".__('Page', 'wct').":</b> ";
			for ($x=1;$x <= $menge;$x++) {
				$l = ($limit * ($x - 1)) + 1;
				if($_GET['wctstart'] == $l OR ($l == '1' AND $_GET['wctstart'] == '')) { $out .= $x."&nbsp;"; }
				else {	$out .= "<a href=\"".$url."wctstart=".$l."\">".$x."</a>&nbsp;"; }
			}
			$out .= "</center></td></tr>";
		}
		$out .= "</table>\n\n<!-- Custom Tables Plugin 05a1a29bdcae7b12229e651a9fd48b11 -->\n\n";
		if ($form->rights[2] == '1') { $out .= "<form action=\"".$url."wctnew=1\" method=\"POST\"><input type=\"submit\" name=\"submit\" value=\"". __('New Entry', 'wct') ."\"></form>"; }

		}
	else {
		$out = "<p>".__('Form Setup', 'wct')." ".__('not configured', 'wct')."</p>";
	}
	$out = do_shortcode($out);
}
elseif ($_GET['wctfid'] != '' AND $form->rights[1] == '1') { // write rights needed
	$entry = (integer)$_GET['wctfid'];
	$url = $this->generate_pagelink(array("/[&?]+wctfid=[0-9]/","/[&?]+wctnew=[0-9]*/"),array("","",""));

	echo "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"".plugins_url('custom-tables/jscal/calendar-blue2.css')."\" title=\"blue\" />
		<script type=\"text/javascript\" src=\"".plugins_url('custom-tables/jscal/calendar.js')."\"></script>
		<script type=\"text/javascript\" src=\"".plugins_url('custom-tables/jscal/lang/calendar-en.js')."\"></script>
		<script type=\"text/javascript\" src=\"".plugins_url('custom-tables/jscal/calendar-setup.js')."\"></script>
		<script>function getY (el) {y = el.offsetTop;if (!el.offsetParent) { return y; } else return (y+getY(el.offsetParent)-35);}</script>";

	$table = $wpdb->get_row("SHOW CREATE TABLE `".$wpdb->prefix."wct".$form->r_table."`;");
	$array=array(); foreach($table as $member=>$data) { $array[$member]=$data; }
	$tmp = explode("PRIMARY KEY",$array['Create Table']);
	$felder = explode("\n",$tmp[0]);
	for ($i=2;$felder[$i] != '';$i++) {
		$x++;
		$feld[$x] =  preg_replace("/.*`(.*?)`.*/","$1",$felder[$i-1]);
		if (strpos ($felder[$i-1]," text") !== false) {
			$feld2[$feld[$x]] =  preg_replace("/.*`(.*)`\s(.*?)\s.*/","$2",str_replace(array(",","8 ,2","' ,'"),array(" ,","8.2","'.'"),$felder[$i-1]));
		}
		else {
			$feld2[$feld[$x]] =  preg_replace("/.*`(.*)`\s(.*\))\s.*/","$2",str_replace(array(",","8 ,2","' ,'"),array(" ,","8.2","'.'"),$felder[$i-1]));
		}
	}

	if ($form->r_filter != '') { $filter = "AND ".$form->r_filter; } else { $filter = ''; }
	$row = $wpdb->get_row("SELECT * FROM `".$wpdb->prefix."wct".$form->r_table."` WHERE `status` != 'passive' AND `id`='".mres($entry)."' ".$filter." LIMIT 1;");
	$out .= "<h3>".__('Edit Entry','wct')."</h3><form action=\"".$url."wctfid=".$_GET['wctfid']."&wctefid=save\" method=\"POST\">";

	$inhalt = $form->e_setup;
	$rights = ",".$form->r_fields.",";

	preg_match_all("/\{(.*?)\}/", $inhalt, $matches);

	foreach ($matches[1] as $val => $wert) {
		if (strpos($rights,",".$wert.",") === false) {
			$addon = " style=\"background-color: #CCC;\" readonly";
		}
		else {
			$addon = "";
			if ($feld2[$wert] == "int(10)") {
				$addon = " id=\"f_date_".$wert."\" /><img style=\"position:relative; bottom:-10px;\" src=\"".plugins_url('custom-tables/jscal/cal.jpg')."\" id=\"f_trigger_".$wert."\" title=\"Date selector\" onmouseover=\"this.style.background='red';\" onmouseout=\"this.style.background=''\" />".
				     "<script type=\"text/javascript\">Calendar.setup({inputField: \"f_date_".$wert."\",ifFormat: \"%Y-%m-%d\", button: \"f_trigger_".$wert."\", align: \"Tl\",firstDay:1,singleClick: true,position:[550,getY(document.getElementById('f_date_".$wert."'))]});</script";
			}
		}

		if ($feld2[$wert] == "smallint(6)") { $inhalt = str_replace("{".$wert."}","<input size=\"7\" type=\"text\" name=\"".($addon != '' ? "wctn_" : "wctf_").$wert."\" value=\"".stripslashes($row->$wert)."\" maxsize=\"6\"".$addon."/>",$inhalt); }
		elseif ($feld2[$wert] == "int(10)") {
			if (strpos($rights,",".$wert.",") === false) {
				$inhalt = str_replace("{".$wert."}","<input size=\"10\" type=\"text\" name=\"wctn_".$wert."\" value=\"".date("Y-m-d",$row->$wert)."\" maxsize=\"10\"".$addon.">",$inhalt);
			}
			else {
				$inhalt = str_replace("{".$wert."}","<input size=\"10\" type=\"text\" name=\"wctf_".$wert."\" value=\"".date("Y-m-d",$row->$wert)."\" maxsize=\"10\"".$addon.">",$inhalt);
			}
		}
		elseif ($feld2[$wert] == "int(11)") { $inhalt = str_replace("{".$wert."}","<input size=\"12\" type=\"text\" name=\"".($addon != '' ? "wctn_" : "wctf_").$wert."\" value=\"".stripslashes($row->$wert)."\" maxsize=\"11\"".$addon."/>",$inhalt); }
		elseif ($feld2[$wert] == "varchar(32)") { $inhalt = str_replace("{".$wert."}","<input size=\"34\" type=\"text\" name=\"".($addon != '' ? "wctn_" : "wctf_").$wert."\" value=\"".stripslashes($row->$wert)."\" maxsize=\"32\"".$addon."/>",$inhalt); }
		elseif ($feld2[$wert] == "varchar(64)") { $inhalt = str_replace("{".$wert."}","<input size=\"65\" type=\"text\" name=\"".($addon != '' ? "wctn_" : "wctf_").$wert."\" value=\"".stripslashes($row->$wert)."\" maxsize=\"64\"".$addon."/>",$inhalt); }
		elseif ($feld2[$wert] == "varchar(128)") { $inhalt = str_replace("{".$wert."}","<input size=\"112\" type=\"text\" name=\"".($addon != '' ? "wctn_" : "wctf_").$wert."\" value=\"".stripslashes($row->$wert)."\" maxsize=\"128\"".$addon."/>",$inhalt); }
		elseif (substr($feld2[$wert],0,4) == "enum") {
			if ($addon == "") {
				$tmp = "<select style=\"width:120px;\" name=\"".($addon != '' ? "wctn_" : "wctf_").$wert."\">";
				$defs = explode(".",str_replace("'","",substr($feld2[$wert],6,(strlen(rtrim($feld2[$wert]))-8))));

				foreach ($defs as $posibility) {
					$tmp .= "<option value=\"".$posibility."\"";
					if ($posibility == stripslashes($row->$wert)) { $tmp .= " selected"; }
					$tmp .= ">".$posibility."</option>";
				}
				$tmp .= "</select>";
			}
			else {
				$tmp = "<input size=\"10\" type=\"text\" name=\"wctn_".$wert."\" value=\"".stripslashes($row->$wert)."\" maxsize=\"32\"".$addon."/>";
			}
			$inhalt = str_replace("{".$wert."}",$tmp,$inhalt);
		}
		elseif ($feld2[$wert] == "float(8.2)") { $inhalt = str_replace("{".$wert."}","<input size=\"12\" type=\"text\" name=\"".($addon != '' ? "wctn_" : "wctf_").$wert."\" value=\"".stripslashes($row->$wert)."\" maxsize=\"11\"".$addon."/>",$inhalt); }
		elseif ($feld2[$wert] == "text") {
			if ($addon != '') { $addon = " style=\"background-color: #CCC;\" readonly=\"readonly\""; } else { $mytextfelder .= "wctf_".$wert.","; }
			$inhalt = str_replace("{".$wert."}","<textarea id=\"wctf_".$wert."\" name=\"".($addon != '' ? "wctn_" : "wctf_").$wert."\" style=\"height: 155px;width: 100%;\"".$addon.">".stripslashes($row->$wert)."</textarea>",$inhalt);
		}
	}

	if ($mytextfelder != '') {
		$wct_elements = substr($mytextfelder,0,strlen($mytextfelder)-1);
		global $wuk_tinymce;
		$wuk_tinymce->tinymce_getInitJS($wct_elements,$form->htmlview);
	}

	$out .= rbr($inhalt)."<br/><input type=\"submit\" name=\"submit\" value=\"". __('Save all Changes', 'wct') ."\"></form>";
	$out = do_shortcode($out);
}

?>