<?php
//  Last update : 2005-11-24     - Bugfix for multibyte charsets
//  Part of     : Update to Version 01.00.02
// +----------------------------------------------------------------------+
// | Der Dirigent 1.0                                                     |
// +----------------------------------------------------------------------+
// | Copyright (c) 2003-2004 the dedi-group <dedi-group@der-dirigent.de>  |
// +----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License                 |
// |                                                                      |
// | This program is subject to the GPL license, that is bundled with     |
// | this package in the file LICENSE.TXT.                                |
// | If you did not receive a copy of the GNU General Public License      |
// | along with this program write to the Free Software Foundation, Inc., |
// | 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA               |
// |                                                                      |
// | This program 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.                         |
// |                                                                      |
// +----------------------------------------------------------------------+
// | Authors: Roland Braband <stam@der-dirigent.de>,                      |
// |          Björn Brockmann <björn@der-dirigent.de>                     |
// |          Paul Eppner <paul@twomoons.de>                              |
// |          Sven Bräutigam <sven777b@der-dirigent.de>                   |
// +----------------------------------------------------------------------+

/**
 * 1. Benötigte Funktionen und Klassen includieren
 */

include('inc/fnc.tpl.php');
include('inc/fnc.mipforms.php');

/**
 * 2. Eventuelle Actions/ Funktionen abarbeiten
 */

// idcatside vorhanden, prüfen, ob Recht zum konfigurieren gegeben ist
if(is_numeric($idcatside))$perm->check(20, 'side', $idcatside, $idcat);
//Neue Seite, prüfen, ob recht auf neue Seite anlegen vorhanden ist
else $perm->check(18, 'cat', $idcat);


// Seitenkonfiguration speichern
switch($action) {
	case 'save':  // Template bearbeiten
		con_config_side_save($idcat, $idside, $idtpl, $idtplconf, $idsidelang, $idcatside, $idcatnew
                                       , $author, $title, $meta_keywords, $summary, $online, $user_protected
                                       , $view, $created, $lastmodified, $startdate, $starttime, $enddate, $endtime
                                       , $meta_author, $meta_description, $meta_robots, $meta_redirect_time
                                       , $meta_redirect, $meta_redirect_url, $idlay);
		break;
	case 'change':  // Layout oder Modul wechseln
		$cconfig = tpl_change($idlay);
		break;
}

/**
 * 3. Eventuelle Dateien zur Darstellung includieren
 */

// getrennte Header für Backend und Frontendbearbeitung
if (empty($view)) include('inc/inc.header.php');
else {
	echo "<html>\n";
	echo "<head>\n";
	echo "  <title>der-dirigent ".$cfg_dedi['version']."</title>\n";
	echo "  <link rel=\"stylesheet\" type=\"text/css\" href=\"tpl/".$cfg_dedi['skin']."/css/styles.css\">\n";
	echo "  <script src=\"tpl/".$cfg_dedi['skin']."/js/standard.js\" type=\"text/javascript\"></script>\n";
	echo "</head>\n";
	echo "<body marginheight=\"0\" marginwidth=\"0\" leftmargin=\"0\" topmargin=\"0\" onload=\"off();return true;\">\n";
}

if (!$action && $idside) {
	// Ordner der Seite suchen
	$sql = "SELECT idcat FROM ".$dedi_db['cat_side']." WHERE idside='$idside'";
	$db->query($sql);
	while ($db->next_record()) $idcatnew[] = $db->f('idcat');

	// Konfiguration suchen
	$sql = "SELECT * FROM ".$dedi_db['side_lang']." A, ".$dedi_db['users']." B WHERE idside='$idside' AND idlang='$lang' AND A.author=B.user_id";
	$db->query($sql);
	$db->next_record();
	$idsidelang    = $db->f('idsidelang');
	$title         = htmlspecialchars($db->f('title'));
	$author        = $db->f('author');
	$created       = $db->f('created');
	$summary       = htmlspecialchars($db->f('summary'));
	$lastmodified  = $db->f('lastmodified');
	$startdate     = date('d.m.Y', $db->f('start'));
	$starttime     = date('H:i', $db->f('start'));
	$enddate       = date('d.m.Y', $db->f('end'));
	$endtime       = date('H:i', $db->f('end'));
	$online        = $db->f('online');
	$userprotected = ($db->f('user_protected') == '1') ? 'selected' : '';
	$meta_author = htmlspecialchars($db->f('meta_author'));
	$meta_description = htmlspecialchars($db->f('meta_description'));
	$meta_keywords = htmlspecialchars($db->f('meta_keywords'));
	$meta_robots = $db->f('meta_robots');
	$meta_redirect = ($db->f('meta_redirect') == '1') ? ' checked' : '';
	$meta_robots_time = $db->f('meta_robots_time');
	$meta_redirect_url = ($db->f('meta_redirect_url') != '') ? $db->f('meta_redirect_url') : 'http://';
} elseif (!$action && !$idside) {
	$idcatnew['0'] = $idcat;
	$author = $auth->auth['uid'];
	$created = time();
	$online = '0';
	$startdate = date('d.m.Y', time());
	$starttime = '00:00';
	$enddate = date('d.m.Y', time());
	$endtime = '00:00';
	$lastmodified = $created;
	$sql = "SELECT * FROM ". $dedi_db['users'] ." WHERE user_id='".$auth->auth['uid']."'";
	$db->query($sql);
	$db->next_record();
	$meta_author = htmlspecialchars($db->f('name').' '.$db->f('surname'));
	$meta_description = htmlspecialchars($cfg_client['meta_description']);
	$meta_keywords = htmlspecialchars($cfg_client['meta_keywords']);
	$meta_robots = htmlspecialchars($cfg_client['meta_robots']);
	$meta_redirect_url = 'http://';
} else {
	if (!is_array($idcatnew)) $idcatnew['0'] = $idcat;
	$meta_redirect = ($meta_redirect == '1') ? ' checked' : '';
	$meta_redirect_url = ($meta_redirect_url != '') ? $meta_redirect_url : 'http://';
	$userprotected = ($user_protected == '1') ? 'selected' : '';
}


// Selectbox darf Seite sperren erzeugen
// DEPRECATED
//$have_sidelock_perm = (is_numeric($idcatside)) ? $perm->have_perm(31, 'side', $idcatside, $idcat): $perm -> have_perm(31, 'cat', $idcat) ;
//if($have_sidelock_perm) {
//	$select_lock_side = "<select name=\"user_protected\" size=\"1\">\n
//	<option value=\"\">".$dedi_lang['con_side_not_locked_for_other_editors']."</option>\n
//	<option value=\"1\" $userprotected>".$dedi_lang['con_side_locked_for_other_editors']."</option>\n
//	</select>\n";
//} else

$select_lock_side = '';

// Selectbox für Seiten verschieben, clonen
$select_sidemove = '<select name="idcatnew[]" multiple size="7" style="width:318px">';
$sql = "SELECT A.idcat, parent, sortindex, name, idtplconf
	FROM ".$dedi_db['cat']." A
	LEFT JOIN ".$dedi_db['cat_lang']." B USING(idcat)
	WHERE B.idlang='$lang'
	AND A.idclient='$client'
	ORDER BY parent, sortindex";
$db->query($sql);
while ($db->next_record()) {
	$con_tree[$db->f('idcat')]['name'] = $db->f('name');
	$con_tree[$db->f('idcat')]['idtplconf'] = $db->f('idtplconf');
	$tlo_tree[$db->f('parent')][$db->f('sortindex')] = $db->f('idcat');
}
tree_level_order('0', 'catlist');
$select_sidemove_hidden = '';
if (is_array($catlist)) {
	foreach ($catlist as $a) {
		if ($con_tree[$a]['idtplconf'] != '0' && $perm -> have_perm(1, 'cat', $a) || $a == $idcat) {
			$spaces = '';
			for ($i=0; $i<$catlist_level[$a]; $i++) $spaces = $spaces.'&nbsp;&nbsp;';
			if (!in_array($a,$idcatnew)) $select_sidemove .= "<option value=\"$a\">$spaces ".$con_tree[$a]['name']."&nbsp;&nbsp;</option>";
			else {
				$select_sidemove .= "<option value=\"$a\" selected>$spaces ".$con_tree[$a]['name']."&nbsp;&nbsp;</option>";
				$select_sidemove_hidden .= '<input type="hidden" name="idcatnew[]" value="'. $a .'">';
			}
		}
	}
}
$select_sidemove .= "</select>";

// radiobox online, offline, zeitgesteuert
$radio_visibllity  =  sprintf('<input type="radio" name="online" value="0" id="0" %s><label for="0">'.$dedi_lang['con_side_offline'].'&nbsp;</label>', (((int)$online & 0x03) == 0x00) ? 'checked' : '');
$radio_visibllity .=  sprintf('<input type="radio" name="online" value="1" id="1" %s><label for="1">'.$dedi_lang['con_side_online'].'&nbsp;</label>', (((int)$online & 0x03) == 0x01) ? 'checked' : '');
$radio_visibllity .=  sprintf('<input type="radio" name="online" value="2" id="2" %s><label for="2">'.$dedi_lang['con_side_time'].'&nbsp;</label>', (((int)$online & 0x03) == 0x02) ? 'checked' : '');
$radio_visibllity_hidden =  sprintf('<input type="hidden" name="online" value="%s">', $online);

// Datumsangaben für Ausgabe formatieren
$print_created = date($cfg_dedi['FormatDate'].' '.$cfg_dedi['FormatTime'],$created);
$print_lastmodified = date($cfg_dedi['FormatDate'].' '.$cfg_dedi['FormatTime'],$lastmodified);

// Zeitsteuerung Startdatum
$html_startdate = '<input type="text" name="startdate" onchange="document.editform.online[2].checked=true" value="'. $startdate .'" size="10" maxlength="10" style="width: 65px;">
	&nbsp;' . $dedi_lang['con_timemanagement_starttime'] . '&nbsp;
	<input type="text" name="starttime" value="'. $starttime .'" size="5" maxlength="5"  onchange="document.editform.online[2].checked=true;" style="width:35px;">&nbsp;
	<script language="JavaScript1.2">
	  calendar1 = new dynCalendar("calendar1", "callback_startdate");
	  calendar1.setMonthCombo(true);
	  calendar1.setYearCombo(true);
	</script>';

$html_startdate_hidden = '<input type="hidden" name="startdate" value="'. $startdate .'">
<input type="hidden" name="starttime" value="'. $starttime .'">';

// Zeitsteuerung Enddatum
$html_enddate = '<input type="text" name="enddate" value="'. $enddate .'" size="10" maxlength="10"  onchange="document.editform.online[2].checked=true;" style="width: 65px;">
	&nbsp;' . $dedi_lang['con_timemanagement_endtime'] . '&nbsp;
	<input type="text" name="endtime" value="'. $endtime .'" size="5" maxlength="5"  onchange="document.editform.online[2].checked=true;" style="width:35px;">&nbsp;
	<script language="JavaScript1.2">
	  calendar2 = new dynCalendar("calendar2", "callback_enddate");
	  calendar2.setMonthCombo(true);
	  calendar2.setYearCombo(true);
	</script>';
$html_enddate_hidden = '<input type="hidden" name="enddate" value="'. $enddate .'">
						  <input type="hidden" name="endtime" value="'. $endtime .'">';


// Auswahl robtos
$html_robots = '<select name="meta_robots" size="1" style="width:318px">'."\n";
$html_robots .= sprintf('          <option value="index, follow"%s>'.$dedi_lang['con_metarobotsif'].'</option>'."\n", ($meta_robots == 'index, follow') ? ' selected' : '');
$html_robots .= sprintf('          <option value="index, nofollow"%s>'.$dedi_lang['con_metarobotsin'].'</option>'."\n", ($meta_robots == 'index, nofollow') ? ' selected' : '');
$html_robots .= sprintf('          <option value="noindex, follow"%s>'.$dedi_lang['con_metarobotsnf'].'</option>'."\n", ($meta_robots == 'noindex, follow') ? ' selected' : '');
$html_robots .= sprintf('          <option value="noindex, nofollow"%s>'.$dedi_lang['con_metarobotsnn'].'</option>'."\n", ($meta_robots == 'noindex, nofollow') ? ' selected' : '');
$html_robots .= '        </select>';

$html_robots_hidden = '<input type="hidden" name="meta_robots" value="'. $meta_robots .'">';

/**
 * 4. Bildschirmausgabe aufbereiten und ausgeben
 */

$tpl->loadTemplatefile('side_config.tpl', false);

// Zeitsteuerung
$have_online_offline_perm = ( is_numeric($idcatside) ) ? $perm->have_perm(23, 'side', $idcatside, $idcat): $perm -> have_perm(23, 'cat', $idcat) ;
if($have_online_offline_perm) {
	$tpl->setCurrentBlock('TIMER_BLOCK');
	$tpl_data['VISBILITY_DESC'] = $dedi_lang['con_visibility'];
	$tpl_data['LANG_SIDE_IS'] = $dedi_lang['con_side_is'];
	$tpl_data['VISIBILITY'] = $radio_visibllity;
	$tpl_data['LANG_ONLINE'] = $dedi_lang['con_side_is_online_at'];
	$tpl_data['STARTDATE'] = $html_startdate;
	$tpl_data['LANG_OFFLINE'] = $dedi_lang['con_side_is_offline_at'];
	$tpl_data['ENDDATE'] = $html_enddate;
	$tpl->setVariable($tpl_data);
	$tpl->parseCurrentBlock();
	unset($tpl_data);
} else {
	$tpl->setCurrentBlock('HIDDEN_FIELDS');
	$tpl_data['HIDDEN_FIELDS'] = $radio_visibllity_hidden . $html_startdate_hidden . $html_enddate_hidden;
	$tpl->setVariable($tpl_data);
	$tpl->parseCurrentBlock();
	unset($tpl_data);
}

// Darf Seiten verschieben
$have_move_perm = (is_numeric($idcatside)) ? $perm->have_perm(30, 'side', $idcatside, $idcat): $perm -> have_perm(30, 'cat', $idcat);
if ($have_move_perm) {
	$tpl->setCurrentBlock('CLONE_AND_NOTICE');
	$tpl_data['LANG_MOVE_SIDE'] = $dedi_lang['con_move_side'];
	$tpl_data['SELECT_SIDEMOVE'] = $select_sidemove;
	$tpl_data['LANG_NOTICES'] = $dedi_lang['con_notices'];
	$tpl_data['SUMMARY'] = empty($summary) ? '' : $summary;
	$tpl->setVariable($tpl_data);
	$tpl->parseCurrentBlock();
	unset($tpl_data);
} else {
	$tpl->setCurrentBlock('NOTICE');
	$tpl_data['LANG_NOTICES'] = $dedi_lang['con_notices'];
	$tpl_data['SUMMARY'] = empty($summary) ? '' : $summary;
	$tpl_data['HIDDEN_CLONES'] = $select_sidemove_hidden;
	$tpl->setVariable($tpl_data);
	$tpl->parseCurrentBlock();
	unset($tpl_data);
}

// Metaangaben bearbeiten
$have_meta_perm = (is_numeric($idcatside)) ? $perm->have_perm(29, 'side', $idcatside, $idcat): $perm -> have_perm(29, 'cat', $idcat);
if ($have_meta_perm) {
	$tpl->setCurrentBlock('META');
	$tpl_data['LANG_CON_METACONFIG'] = $dedi_lang['con_metaconfig'];
	$tpl_data['LANG_META_DESC'] = $dedi_lang['con_metadescription'];
	$tpl_data['META_DESC'] = $meta_description;
	$tpl_data['LANG_META_KEYWORDS'] = $dedi_lang['con_metakeywords'];
	$tpl_data['META_KEYWORDS'] = $meta_keywords;
	$tpl_data['LANG_META_AUTHOR'] = $dedi_lang['con_metaauthor'];
	$tpl_data['LANG_META_ROBOTS'] = $dedi_lang['con_metarobots'];
	$tpl_data['META_AUTHOR'] = $meta_author;
	$tpl_data['META_ROBOTS'] = $html_robots;
	$tpl_data['LANG_META_REDIRECT'] = $dedi_lang['con_metaredirect'];
	$tpl_data['META_REDIRECT'] = $meta_redirect;
	$tpl_data['META_REDIRECT_URL'] = $meta_redirect_url;
	$tpl->setVariable($tpl_data);
	$tpl->parseCurrentBlock();
	unset($tpl_data);
} else {
	$tpl->setCurrentBlock('HIDDEN_FIELDS');
	$tpl_data['HIDDEN_FIELDS'] = '<input type="hidden" name="meta_description" value="'. $meta_description .'">
	  <input type="hidden" name="meta_keywords" value="'. $meta_keywords .'">
	  <input type="hidden" name="meta_author" value="'. $meta_author .'">
	  <input type="hidden" name="meta_redirect_url" value="'. $meta_redirect_url .'">'
      . $html_robots_hidden;
     if($meta_redirect != '')
     	$tpl_data['HIDDEN_FIELDS'] .= '<input type="hidden" name="meta_redirect" value="1">';
	$tpl->setVariable($tpl_data);
	$tpl->parseCurrentBlock();
	unset($tpl_data);
}

// Rechtemanagement
if (!empty($idcatside) && $perm->have_perm(22, 'side', $idcatside, $idcat)) {
	$panel = $perm->get_right_panel('side', $idcatside, array( 'formname'=>'editform' ), 'text', false, false, $idcat );
	if (!empty($panel)) {
		$tpl->setCurrentBlock('USER_RIGHTS');
		$tpl_data['LANG_RIGHTS'] = '';
		$tpl_data['RIGHTS'] = implode("", $panel);
		$tpl->setVariable($tpl_data);
		$tpl->parseCurrentBlock();
		unset($tpl_data);
	}
}

// Outputbuffering für das Backend temporär beenden, um Content aus den Modulen in Variablen speichern zu können
$temp_output_for_backend = ob_get_contents();
ob_end_clean();
ob_start();

// Darf Templatekonfiguration betreten
$have_enter_tpl_perm = (is_numeric($idcatside)) ? $perm->have_perm(26, 'side', $idcatside, $idcat): $perm -> have_perm(26, 'cat', $idcat);
if ($have_enter_tpl_perm) {
	echo "<tr>\n";
	echo "<td class=\"head\" width=\"110\" nowrap>&nbsp;".$dedi_lang['con_template']."&nbsp;</td>\n";

	// Darf Templates konfigurieren?
	$have_config_tpl_perm = ( is_numeric($idcatside) ) ? $perm->have_perm(27, 'side', $idcatside, $idcat): $perm -> have_perm(27, 'cat', $idcat) ;
	if ($have_config_tpl_perm) {
		echo "<td class=\"content\" colspan=\"3\" nowrap><select name=\"idtpl\" size=\"1\" onchange=\"document.editform.action.value='changetpl';document.editform.submit();\">\n";
	} else echo "<td class=\"content\" colspan=\"3\" nowrap><select name=\"idtpl\" size=\"1\">\n";

	// konfiguriertes Template und Layout suchen
	if ($idtplconf != '0' && !$idtpl && !$configtpl) {
		$sql = "SELECT B.idlay, B.idtpl
			FROM $dedi_db[tpl_conf] A
                         LEFT JOIN $dedi_db[tpl] B USING(idtpl)
			WHERE idtplconf='$idtplconf'";
		$db->query($sql);
		$db->next_record();
		$idlay = $db->f('idlay');
		$idtpl = $db->f('idtpl');
		$configtpl = $idtpl;
	} else {
		$sql = "SELECT idlay, idtpl FROM $dedi_db[tpl] WHERE idtpl='$idtpl'";
		$db->query($sql);
		$db->next_record();
		$idlay = $db->f('idlay');
	}
	echo "        <option value=\"0\" selected>Ordnertemplate</option>";

	// Templates Auflisten
	$sql = "SELECT idtpl, name FROM $dedi_db[tpl] WHERE idclient='$client' ORDER BY name";
	$db->query($sql);
	while ($db->next_record()) {
		if ($db->f('idtpl') == $idtpl){
			 echo "<option value=\"".$db->f('idtpl')."\" selected>".$db->f('name')."</option>";
		}
		else if ($perm -> have_perm(1, 'tpl', $db->f('idtpl'))) {
			echo "<option value=\"".$db->f('idtpl')."\">".$db->f('name')."</option>";
		}
	}
	echo "      </select></td>\n";
	echo "    </tr>\n";
	echo "    <input type=hidden name=\"configtpl\" VALUE=\"$configtpl\">";
	echo "         <tr valign=\"top\">\n";
	echo "      <td>&nbsp;</td>\n";
	echo "      <td>&nbsp;</td>\n";
	echo "    </tr>\n";

// Darf Templateauswahl nicht betreten
} else {
	$sql = "SELECT B.idtpl
		FROM $dedi_db[tpl_conf] A
        LEFT JOIN $dedi_db[tpl] B USING(idtpl)
		WHERE idtplconf='$idtplconf'";
	$db->query($sql);
	if ($db->next_record())
		$idtpl = $db->f('idtpl');
	else $idtpl = 0;

	if($idtplconf != '0')
		$configtpl = $idtpl;


	echo '<input type="hidden" name="idtpl" value="'. $idtpl .'">
	      <input type="hidden" name="configtpl" value="'. $configtpl .'">';
}

// Template konfigurieren
if ($have_config_tpl_perm) {
	echo "    <input type=hidden name=\"idlay\" VALUE=\"$idlay\">\n";

	// Module auflisten
	$list = browse_layout_for_containers($idlay);

	// Einstellungen suchen
	if ($configtpl == $idtpl){
		$sql = "SELECT A.config, A.view, A.edit, B.container, C.name, C.input, C.idmod, C.version, C.verbose, C.cat, C.source_id, C.idmod
			FROM $dedi_db[container_conf] A
			LEFT JOIN $dedi_db[container] B USING(idcontainer)
			LEFT JOIN $dedi_db[mod] C USING(idmod)
			WHERE A.idtplconf='$idtplconf'";
	} else {
		$sql = "SELECT A.config, A.view, A.edit, B.container, C.name, C.input, C.idmod, C.version, C.verbose, C.cat, C.source_id, C.idmod
			FROM $dedi_db[container_conf] A
			LEFT JOIN $dedi_db[container] B USING(idcontainer)
			LEFT JOIN $dedi_db[mod] C USING(idmod)
			WHERE A.idtplconf='0' AND B.idtpl='$idtpl'";
	}
	$db->query($sql);
	while ($db->next_record()) {
		$container[$db->f('container')] = array ( $db->f('config'),      // value 0
		                                          $db->f('view'),        // value 1
		                                          $db->f('edit'),        // value 2
		                                          htmlspecialchars($db->f('name')),        // value 3
		                                          $db->f('input'),       // value 4
		                                          htmlspecialchars($db->f('idmod')),       // value 5
		                                          htmlspecialchars($db->f('version')),     // value 6
                                                          htmlspecialchars($db->f('verbose')),     // value 7
                                                          htmlspecialchars($db->f('cat')),         // value 8
                                                          htmlspecialchars($db->f('source_id')),   // value 9
                                                          htmlspecialchars($db->f('idmod')));      // value 10
	}
	if (is_array($container)) {
		ksort($container);
		foreach ($container as $key => $value) {
			if (is_array($list['id'])) {
				if (in_array($key, $list['id'])) {
					$input = $value['4'];
					// Containername
					$modname = ( (($value['7'] != '') ? $value['7'] : $value['3']) . ((empty($value['6'])) ? '' : ' (' . $value['6'] . ')') );
					$modtitel = ( ' ++ ' .$dedi_lang['gen_description'] . ' ++ &#10;' . (($value['8'] != '') ? $dedi_lang['gen_cat'] . ': ' . $value['8'] . ' &#10;' : '') .
                                                    (($value['7'] != '') ? $dedi_lang['gen_verbosename'] . ': ' . $value['7'] . ' &#10;' : '') .
                                                    (empty($value['9']) ? $dedi_lang['gen_name'] : $dedi_lang['gen_original']) . ': ' . $value['3'] . ' &#10;' .
                                                    (($value['6'] != '') ? $dedi_lang['gen_version'] . ': ' . $value['6'] . ' &#10;' : '') . 'IdMod: ' . $value['10'] );
					$modcursor = strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE 5') ? 'hand' : 'pointer';
                                        echo "    <input type=\"hidden\" name=\"c$key\" value=\"".$value['5']."\">";
					echo "    <tr valign=\"top\">\n";
                                        printf ("        <td class=\"head\" rowspan=\"2\">&nbsp;%s&nbsp;</td>\n", (!empty($list[$key]['title'])) ? $list[$key]['title']:"$key. ".$dedi_lang['tpl_container']."");
					echo "      <td class=\"head\" colspan=\"3\"><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"640\">\n";
					echo "        <tr>";
					echo "          <td class=\"head\"><img style=\"cursor:$modcursor\" src=\"tpl/" . $cfg_dedi['skin'] . "/img/about.gif\" border=\"0\" alt=\"" . $modtitel .
                                                "\" title=\"" . $modtitel . "\" width=\"16\" height=\"16\">&nbsp;".$modname."&nbsp;</td>";
					echo "          <td class=\"head\" align=\"right\">&nbsp;";
					echo "        <select name=\"cview$key\" size=\"1\">\n";
					printf ("          <option value=\"0\"%s>". $dedi_lang['gen_mod_active'] ."</option>\n", ($value['1'] == '0' || !$value['1']) ? ' selected':'');
					printf ("          <option value=\"-1\"%s>". $dedi_lang['gen_mod_deactive'] ."</option>\n", ($value['1'] == '-1') ? ' selected':'');
					echo "        </select>&nbsp;";
					echo "        <select name=\"cedit$key\" size=\"1\">\n";
					printf ("          <option value=\"0\"%s>". $dedi_lang['gen_mod_edit_allow'] ."</option>\n", ($value['2'] == '0' || !$value['2']) ? ' selected':'');
					printf ("          <option value=\"-1\"%s>". $dedi_lang['gen_mod_edit_disallow'] ."</option>\n", ($value['2'] == '-1') ? ' selected':'');
				   	echo "        </select>\n";
					echo "        </td></tr>";
					echo "      </table></td>\n";
					echo "    </tr>\n";
					echo "    <tr valign=\"top\">\n";
					echo "      <td class=\"content\" colspan=\"4\">";

					// Developer-Modul
					if (strpos($value['6'], 'dev') != false && $value['6'] != '') {
						$input = '<p align="center" class="errormsg">'.$dedi_lang['tpl_devmessage']."</p>\n".$input;
					}

					// Modulkonfiguration einlesen
					if ($cconfig) $tmp1 = preg_split("/&/", $cconfig[$key]);
					else $tmp1 = preg_split("/&/", $value['0']);
					$varstring = array();
					foreach ($tmp1 as $key1=>$value1) {
						$tmp2 = explode('=', $value1);
						foreach ($tmp2 as $key2=>$value2) $varstring["$tmp2[0]"]=$tmp2[1];
					}
					foreach ($varstring as $key3=>$value3) $dedi_mod['value'][$key3] = dedi_stripslashes(urldecode($value3));
					foreach ($value as $key4=>$value4) $dedi_mod['info'][$key4] = dedi_stripslashes(urldecode($value4));
					$input = str_replace("MOD_VAR", "C".$key."MOD_VAR" , $input);
					eval(' ?>'.$input);
					unset($dedi_mod['value']);
					echo "</td>\n";
					echo "    </tr>\n";
				}
			}
		}
	}
}

// Outputbuffering wieder aufnehmen
$temp_tpl_conf = ob_get_contents();
ob_end_clean();
ob_start();
echo $temp_output_for_backend;
unset($temp_output_for_backend);
$tpl->setCurrentBlock('__global__');
$tpl_data['TABLE_PADDING'] = $cellpadding;
$tpl_data['TABLE_SPACING'] = $cellspacing;
$tpl_data['TABLE_BORDER'] = $border;
$tpl_data['SKIN'] = $cfg_dedi['skin'];
if (empty($view)) {
	$tpl_data['FORM_ACTION'] = $sess->url("main.php?idside=$idside&idcat=$idcat&idsidelang=$idsidelang");
	$tpl_data['ABORT'] = $sess->url("main.php?area=con");
	$tpl_data['AREA_TITLE'] = $dedi_lang['area_con_configside'];
} else {
	$tpl_data['FORM_ACTION'] = $sess->url("main.php?area=con_configside&idside=$idside&idcat=$idcat&idsidelang=$idsidelang&view=$view");
	$tpl_data['ABORT'] = $sess->url($cfg_client['htmlpath'].$cfg_client['contentfile']."?lang=$lang&idcatside=$idcatside&idcat=$idcat&view=$view");
	$tpl_data['AREA_TITLE'] = '';
}
$tpl_data['IDTPLCONF'] = $idtplconf;
$tpl_data['LASTMODIFIED'] = $lastmodified;
$tpl_data['AUTHOR'] = $author;
$tpl_data['CREATED'] = $created;
$tpl_data['IDCATSIDE'] = $idcatside;
$tpl_data['CON_SIDECONFIG'] = $dedi_lang['con_sideconfig'];
$tpl_data['SIDE_TITLE_DESC'] = $dedi_lang['con_title'];
$tpl_data['SIDE_TITLE'] = empty($title) ? '' : $title;
$tpl_data['SELECT_LOCK_SIDE'] = $select_lock_side;
$tpl_data['TPL_CONF'] = $temp_tpl_conf;
$tpl->setVariable($tpl_data);
unset($tpl_data);
// Look for Errors
if (!empty($errno)) {
	$tpl->setCurrentBlock('ERROR_BLOCK');
	$tpl_error['ERR_MSG'] = $dedi_lang['err_' . $errno];
	$tpl->setVariable($tpl_data);
	$tpl->parseCurrentBlock();
	unset($tpl_data);
}
?>