<?PHP
/******************************************************************************
 @Author:     Björn Brockmann, Paul Eppner (paul@twomoons.de)
                              Sven Bräutigam, Jürgen Brändle
 @Homepage    http://www.der-dirigent.de
  Last update : 2005-11-24       - Bugfix for multibyte charsets                        
  Part of     : Update to Version 01.00.02    
******************************************************************************/

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

include('inc/fnc.con.php');
/**
 * Class to check if a doublet/ clone Page of an idcatside exists
 * 
 *  (c) 2004 by Björn Brockmann
 */
class dediPageDoubletAudit{
	
	var $idsideStore = array();
	
	/**
	 * Construtor, generates data for idatsidecheking 
	 */
	function  dediPageDoubletAudit(){
		global $db, $dedi_db, $lang;
		
		$sql ="SELECT 
					CS.idcatside, SL.idside
					FROM ". $dedi_db['cat_side'] . " CS
					LEFT JOIN " . $dedi_db['side_lang']. " SL USING(idside)
					WHERE SL.idlang = $lang
					ORDER BY CS.idside";
		$db->query($sql);
		
		while($db->next_record()){
			if(! is_array($this->idsideStore[$db->f('idside')]))
				$this->idsideStore[$db->f('idside')] = array();
			
			array_push($this->idsideStore[$db->f('idside')], $db->f('idcatside'));
		}
		//print_r($this->idsideStore);		
	}
	
	/**
	 * Checks if a doublet/ clone of one idcatside exists
	 * 
	 * @parms int idside
	 * @return bool true/ false
	 */
	function pageDoubletExists($idside){
		
		if(! is_int($idside))
			return false;
		
		return (count($this->idsideStore[$idside]) > 1);
	}
}

$dediPDA = new dediPageDoubletAudit;

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

if($change_show_tree == 'delete_cache') $action = 'delete_cache';
if ($action && $view && $perm->have_perm(3, 'area_frontend', 3) ) {
	switch($action) {
		case 'side_delete':  // Seite löschen
			con_delete_side ($idcat, $idside);
			fire_event('con_side_delete', array('idcat' => $idcat, 'idside' => $idside));
			header ('Status: 302 Moved Temporarily');
			header ('Location:'.$sess->url($cfg_client['htmlpath'].$cfg_client['contentfile'].'?lang='.$lang.'&idcat='.$idcat.'&view='.$view));
			exit;
			break;
		case 'cat_delete':  // Ordner löschen
			// Event
			$errno = con_delete_cat ($idcat);
			fire_event('con_cat_delete', array('idcat' => $idcat,'errno' => $errno));
			header ('Status: 302 Moved Temporarily');
			header ('Location:'.$sess->url($cfg_client['htmlpath'].$cfg_client['contentfile'].'?lang='.$lang.'&view='.$view));
			exit;
			break;
		case 'side_visible':  // Seite online/offline schalten
			// change JB
			$bitmask = (($online & 0x02) == 0x02) ? 0xFC: 0xFC;
			$bit_to_clear = (($online & 0x01) == 0x01 || ($online & 0x05) == 0x05);
			$change = ($bit_to_clear) ? ($online & $bitmask): (($online & $bitmask) | 0x01);
			con_visible_side ($idside, $lang, $change);
			if ($bit_to_clear) fire_event('con_side_offline', array('idside' => $idside));
			else fire_event('con_side_online', array('idside' => $idside));
			header ('Status: 302 Moved Temporarily');
			header ('Location:'.$sess->url($cfg_client['htmlpath'].$cfg_client['contentfile'].'?lang='.$lang.'&idcatside='.$idcatside.'&view='.$view));
			exit;			
			break;

	}
}
$perm->check('area_con');
switch($action) {
	case 'side_start':  // Seite als Startseite festlegen
		con_make_start ($idcatside, !$is_start);
		fire_event('con_side_start', array('idcatside' => $idcatside));
		break;
	case 'side_delete':  // Seite löschen
		con_delete_side ($idcat, $idside);
		fire_event('con_side_delete', array('idcat' => $idcat, 'idside' => $idside));
		break;
	case 'side_visible':  // Seite online/offline schalten
		// change JB
		$bitmask = (($online & 0x02) == 0x02) ? 0xFC: 0xFC;
		$bit_to_clear = (($online & 0x01) == 0x01 || ($online & 0x05) == 0x05);
		$change = ($bit_to_clear) ? ($online & $bitmask): (($online & $bitmask) | 0x01);
		con_visible_side ($idside, $lang, $change);
		if ($bit_to_clear) fire_event('con_side_offline', array('idside' => $idside));
		else fire_event('con_side_online', array('idside' => $idside));
		break;
	case 'delete_cache':  // Cache löschen
		con_delete_cache($lang);
		fire_event('con_cache_delete', array());
		break;
	case 'cat_delete':  // Ordner löschen
		// Event
		$errno = con_delete_cat ($idcat);
		fire_event('con_cat_delete', array('idcat' => $idcat,'errno' => $errno));
		break;
	case 'cat_visible':  // Ordner online schalten
		$bit_to_clear = (($visible & 0x01) == 0x01);
		$change = ($bit_to_clear) ? ($visible & 0xFE): ($visible | 0x01);
		con_visible_cat ($idcat, $lang, $change);
		if ($bit_to_clear) fire_event('con_cat_offline', array('idcat' => $idcat));
		else fire_event('con_cat_online', array('idcat' => $idcat));
		break;
	case 'cat_lock':  // Ordner sperren
		con_lock ('cat', $idcat, $lock);
		if ($lock == '1') fire_event('con_cat_unlock', array('idcat' => $idcat));
		else fire_event('con_cat_lock', array('idcat' => $idcat));
		break;
	case 'side_lock':  // Seite sperren
//		con_lock ('side', $idcatside, $lock);
		con_lock ('side', $idside, $lock);
		if ($lock == '1') fire_event('con_side_unlock', array('idside' => $idside));
		else fire_event('con_side_lock', array('idside' => $idside));
		break;
	case 'expand':  // Ordner aufklappen
		con_expand ($idcat, $expanded);
		break;
	case 'sideup': // Seite eins nach oben schieben
		con_move_side ('up',$idcat,$idside,$sortindex);
		break;
	case 'sidedown': // Seite eins nach unten schieben
		con_move_side ('down',$idcat,$idside,$sortindex);
		break;
	case 'sidetop': // Seite ganz nach oben schieben
		con_move_top_bottom ('top',$idcat,$idcatside,$sortindex);
		break;
	case 'sidebottom': // Seite ganz nach unten schieben
		con_move_top_bottom ('bottom',$idcat,$idcatside,$sortindex);
		break;
	case 'quicksort': // schnelles Umsortieren
		con_quick_sort ($quicksort,$idcat);
		break;
	case 'movecat': // verschieben des Ordners
		con_move_cat ($idcat, $target, $client);
		break;
	case 'catupdown': // umsortieren der Ordner
		con_sort_cat ($dir,$idcat,$sortindex,$parent,$client);
		break;
}

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

include('inc/inc.header.php');

/******************************************************************************
 4. Bildschirmausgabe aufbereiten und ausgeben
******************************************************************************/
// Aufbau des Arrays $con_tree
// jb_todo: sperren category
$sql = "SELECT 
         B.idcat, B.parent, B.sortindex, C.idcatlang, C.author, C.created, C.lastmodified,
		 C.visible, C.idtplconf, C.name, E.name AS tplname, F.idcat AS expanded
		FROM "       . $dedi_db['cat']        . " B
		 LEFT JOIN " . $dedi_db['cat_lang']   . " C USING(idcat)
		 LEFT JOIN " . $dedi_db['tpl_conf']   . " D USING(idtplconf)
		 LEFT JOIN " . $dedi_db['tpl']        . " E USING(idtpl)
		 LEFT JOIN " . $dedi_db['cat_expand'] . " F ON B.idcat = F.idcat AND F.idusers = '" . $auth->auth['uid'] . "'
		WHERE B.idclient = $client
		 AND  C.idlang   = $lang
		ORDER BY B.parent, B.sortindex";
$db->query($sql);
while($db->next_record()) {
	$idcat_loop = $db->f('idcat');

	$con_tree[$idcat_loop]['link']         = $sess->url($cfg_client['htmlpath'].$cfg_client['contentfile']."?lang=$lang&idcat=".$idcat_loop."&view=preview");
	$con_tree[$idcat_loop]['idcat']        = $idcat_loop;
	$con_tree[$idcat_loop]['idcatlang']    = $db->f('idcatlang');
	$con_tree[$idcat_loop]['author']       = $db->f('author');
	$con_tree[$idcat_loop]['created']      = $db->f('created');
	$con_tree[$idcat_loop]['lastmodified'] = $db->f('lastmodified');
	$con_tree[$idcat_loop]['parent']       = $db->f('parent');
	$con_tree[$idcat_loop]['visible']      = $db->f('visible');
	$con_tree[$idcat_loop]['idtplconf']    = $db->f('idtplconf');
	$con_tree[$idcat_loop]['name']         = htmlspecialchars($db->f('name'));
	$con_tree[$idcat_loop]['tplname']      = $db->f('tplname');
	$con_tree[$idcat_loop]['sortindex']    = $db->f('sortindex');
	$con_tree[$idcat_loop]['offline']      = (($db->f('visible') & 0x04) == 0x04);  // change JB: ($db->f('perm') == '0');

	$tlo_tree['expanded'][$idcat_loop]               = $db->f('expanded');
	$tlo_tree[$db->f('parent')][$db->f('sortindex')] = $idcat_loop;
}

// neuen Hauptordner anlegen
if ($change_show_tree == 'new_folder') {
	header ('Status: 302 Moved Temporarily');
	header ('Location: '.$sess->url('main.php?area=con_configcat&parent=0&idtplconf=0'));
	exit;
} elseif ($change_show_tree == 'publish') {
	$action = 'all_publish';
	unset($change_show_tree);
}

// Ordner, der angezeigt werden soll, bestimmen
if (!isset($show_tree)) {
	$sess->register('show_tree');
	$show_tree = '0';
}
if (isset($change_show_tree))                  $show_tree = $change_show_tree;
if (!$perm->have_perm(1, 'area_con', 0)) $show_tree = '0';
if (!$con_tree[$show_tree])                    $show_tree = '0';

// Ordner sortieren
if ($show_tree == '0') tree_level_order('0', 'catlist');
else {
	if ($perm -> have_perm(1, 'cat', $show_tree)) $catlist[] = $show_tree;
	if ($tlo_tree['expanded'][$show_tree] == $show_tree || !$perm -> have_perm(1, 'cat', $show_tree)) tree_level_order($show_tree, 'catlist', 'false', '1');
}

$tpl->loadTemplatefile('con_main.tpl');

$tpl_data['AREA'] = $dedi_lang['area_con'];

if(! empty($errno)){
	$tpl -> setCurrentBlock('ERROR');
	$tpl_error['ERRORMESSAGE'] = $dedi_lang['err_' . $errno];
	$tpl->setVariable($tpl_error);
	$tpl->parseCurrentBlock();
}

//Generate selectbox ACTIONS...
$tpl -> setCurrentBlock('SELECT_ACTIONS');

$show_action_select = false;
// neuen Ordner erstellen
if ($perm -> have_perm(2, 'area_con', $show_tree)){
	$tpl_folderlist['ACTIONS_VALUE'] = 'new_folder';
	$tpl_folderlist['ACTIONS_ENTRY'] = $dedi_lang['con_folder_new'];
	$tpl_folderlist['ACTIONS_SELECTED'] = '';
	$tpl->setVariable($tpl_folderlist);
	$tpl->parseCurrentBlock();
	unset($tpl_folderlist);
	$show_action_select = true;
}

// Webseite publizieren
if ($cfg_client['publish'] == '1' && $perm->have_perm('7', 'area_con', 0) && $perm->have_perm('23', 'area_con', 0)){
	$tpl_folderlist['ACTIONS_VALUE'] = 'publish';
	$tpl_folderlist['ACTIONS_ENTRY'] = $dedi_lang['con_folder_publish'];
	$tpl_folderlist['ACTIONS_SELECTED'] = '';
	$tpl->setVariable($tpl_folderlist);
	$tpl->parseCurrentBlock();
	unset($tpl_folderlist);
	$show_action_select = true;
}

// Cache löschen
if ( $perm ->is_admin() ){
	$tpl_folderlist['ACTIONS_VALUE'] = 'delete_cache';
	$tpl_folderlist['ACTIONS_ENTRY'] = $dedi_lang['con_delete_cache'];
	$tpl_folderlist['ACTIONS_SELECTED'] = '';
	$tpl->setVariable($tpl_folderlist);
	$tpl->parseCurrentBlock();
	unset($tpl_folderlist);
	$show_action_select = true;
}

if($show_action_select){
	$tpl -> setCurrentBlock('FORM_SELECT_ACTIONS');
	$entry['FORM_URL_ACTIONS'] = $sess->url('main.php');
	$entry['LANG_SELECT_ACTIONS'] = $dedi_lang['gen_select_actions'];
	$tpl->setVariable($entry);
	$tpl->parseCurrentBlock();
	unset($entry, $show_action_select);
}



//Generate Selectbox VIEW...
$tpl -> setCurrentBlock('SELECT_FOLDERLIST');

// alle Ordner anzeigen
$tpl_folderlist['FOLDERLIST_VALUE'] = '0';
$tpl_folderlist['FOLDERLIST_ENTRY'] = $dedi_lang['con_folder_view'];
$tpl_folderlist['FOLDERLIST_SELECTED'] = '';
$tpl->setVariable($tpl_folderlist);
$tpl->parseCurrentBlock();
unset($tpl_folderlist);

// Leerzeile
$tpl_folderlist['FOLDERLIST_VALUE'] = '';
$tpl_folderlist['FOLDERLIST_ENTRY'] = '---------------------------------------';
$tpl_folderlist['FOLDERLIST_SELECTED'] = '';
$tpl->setVariable($tpl_folderlist);
$tpl->parseCurrentBlock();
unset($tpl_folderlist);

// Ordner auflisten
tree_level_order('0', 'folderlist', 'true');
if (is_array($folderlist)) {
	foreach ($folderlist as $a) {
		$spaces = '';
		if (! $perm -> have_perm(1, 'cat', $a)) continue;
		
		for ($i=0; $i<$folderlist_level[$a]; $i++) $spaces = $spaces.'&nbsp;&nbsp;';
		$tpl_folderlist['FOLDERLIST_VALUE'] = $a;
		$tpl_folderlist['FOLDERLIST_ENTRY'] = $spaces.'&nbsp;-&nbsp;'.$con_tree[$a]['name'];

		$catmove_list[$a]['level'] = $folderlist_level[$a];
		$catmove_list[$a]['name'] = $tpl_folderlist['FOLDERLIST_ENTRY'];
		$catmove_list[$a]['idcat'] = $a;


		if ($show_tree == $a) $tpl_folderlist['FOLDERLIST_SELECTED'] = 'selected';
		else $tpl_folderlist['FOLDERLIST_SELECTED'] = '';
		$tpl->setVariable($tpl_folderlist);
		$tpl->parseCurrentBlock();
	}
	unset($tpl_folderlist);
}

//Generate Selectbox VIEW...
$tpl -> setCurrentBlock('FORM_SELECT_VIEW');
$entry['LANG_SELECT_VIEW'] = $dedi_lang['gen_select_view'];
$entry['FORM_URL_VIEW'] = $sess->url('main.php');
$tpl->setVariable($entry);
$tpl->parseCurrentBlock();
unset($entry);



//Generate Selectbox CHANGE TO...
//print_r( $perm->get_group() );
if($perm->have_perm(9, 'area_con',0) || $perm->have_perm(25, 'area_con',0)
   || $perm->is_any_perm_set('cat', 9, $perm->get_group(), $lang)
   || $perm->is_any_perm_set('side', 25, $perm->get_group(), $lang)) {
	$tpl -> setCurrentBlock('SELECT_CHANGE_TO');
	// Webseite publizieren
	if ($sort){
		$tpl_folderlist['CHANGE_TO_VALUE'] = '';
		$tpl_folderlist['CHANGE_TO_ENTRY'] = $dedi_lang['con_view_normal'];
		$tpl_folderlist['CHANGE_TO_SELECTED'] = '';
		$tpl->setVariable($tpl_folderlist);
		$tpl->parseCurrentBlock();
		unset($tpl_folderlist);
	} else{
		$tpl_folderlist['CHANGE_TO_VALUE'] = 'true';
		$tpl_folderlist['CHANGE_TO_ENTRY'] = $dedi_lang['con_sort'];
		$tpl_folderlist['CHANGE_TO_SELECTED'] = '';
		$tpl->setVariable($tpl_folderlist);
		$tpl->parseCurrentBlock();
		unset($tpl_folderlist);	
	}
	$tpl -> setCurrentBlock('FORM_CHANGE_TO');
	$entry['FORM_URL_CHANGE_TO'] = $sess->url('main.php');
	$entry['LANG_CHANGE_TO'] = $dedi_lang['gen_select_change_to'];
	$tpl->setVariable($entry);
	$tpl->parseCurrentBlock();
	unset($entry);
}



$tpl -> setCurrentBlock('__GLOBAL__');
$tpl_data['CELLPADDING'] = $cellpadding;
$tpl_data['CELLSPACING'] = $cellspacing;
$tpl_data['BORDER'] = $border;
$tpl_data['LANG_STRUCTURE_AND_SIDE'] = $dedi_lang['con_structureandsides'];
$tpl_data['BUTTON_EXPAND'] = make_image_link('main.php?area=con&action=expand&expanded=3&idcat='.$show_tree, 'but_plus.gif', $dedi_lang['con_allexpanded'], '16', '11');
$tpl_data['BUTTON_MINIMIZE'] = make_image_link('main.php?area=con&action=expand&expanded=2&idcat='.$show_tree, 'but_minus.gif', $dedi_lang['con_nooneexpanded'], '16', '11');
$tpl_data['LANG_ACTIONS'] = $dedi_lang['con_action'];
$tpl->setVariable($tpl_data);
unset($tpl_data);

// Ordner
if (is_array($catlist)) {
	// Aufbau des Arrays $con_side
	$sql = "SELECT A.idcatside, A.idcat, A.sortindex, changed
         	FROM "       . $dedi_db['cat_side']. " A
             LEFT JOIN " . $dedi_db['cat']     . " B USING(idcat)
             LEFT JOIN " . $dedi_db['code']    . " C ON A.idcatside = C.idcatside AND idlang = $lang
            WHERE B.idclient = $client
            ORDER BY idcatside";
	$db->query($sql);
	while($db->next_record()) {
		$con_side[$db->f('idcat')][$db->f('idcatside')]['idcatside'] = $db->f('idcatside');
		$con_side[$db->f('idcat')][$db->f('idcatside')]['idcat'] = $db->f('idcat');
		if ($db->f('changed') == '2' && $perm->have_perm('19', 'side', $db->f('idcatside'), $db->f('idcat'))) {
			$con_side[$db->f('idcat')][$db->f('idcatside')]['status'] = 'true';
			$con_tree[$db->f('idcat')]['status'] = 'true';
		}

		// Sortindex einfügen
		if($db->f('sortindex') > 0) {
			if(!empty($sidelist[$db->f('idcat')][$db->f('sortindex')])) {
				array_push($sidelist[$db->f('idcat')], $db->f('idcatside'));
				$reindex[$db->f('idcat')] = 1;
			} else $sidelist[$db->f('idcat')][$db->f('sortindex')] = $db->f('idcatside');
		} elseif (is_array($sidelist[$db->f('idcat')])) {
			array_push($sidelist[$db->f('idcat')], $db->f('idcatside'));
			$reindex[$db->f('idcat')] = 1;
		} else {
			$sidelist[$db->f('idcat')] = array($db->f('idcatside'));
			$reindex[$db->f('idcat')] = 1;
		}
	}

	// neue Seiten einsortieren
	if($reindex) reindex_sort($sidelist);

	// Seiten publizieren
	if ($action == 'side_publish' && $perm->have_perm('23', 'side', $idcatside, $idcat)) con_publish($idcatside, 'side');
	if ($action == 'cat_publish'  && $perm->have_perm('7', 'cat', $idcat)) con_publish($idcat, 'cat');
	if ($action == 'all_publish'  && $perm->have_perm('7', 'area_con', 0) && $perm->have_perm('23', 'area_con', 0)) con_publish($show_tree);

	// Ordner anzeigen
	foreach ($catlist as $a) {
		//darf Ordner sehen?
		if(! $perm->have_perm(1, 'cat', $con_tree[$a]['idcat']) ) continue;
		
		$spaces = '';
		for ($i='0'; $i<$catlist_level[$a]; $i++) $spaces = $spaces.'&nbsp;&nbsp;&nbsp;&nbsp;';

		// Platzhalter zwischen Hauptordnern
		if ($catlist_level[$a] == '0' && $catlist['0'] != $a) $tpl_cat_values['EMPTY_ROW'] = "<tr><td colspan=\"4\">&nbsp;</td></tr>";

		// Ordner auf-/zuklappen
		if ($con_tree[$a]['idcat'] == $idcat) $tpl_cat_values['EXPAND_ANCHOR'] = "<a name=\"catanchor\">\n";
		$tpl_cat_values['SPACES_BEFORE'] = $spaces;

		// Link Expand öffnen
		if ($tlo_tree['expanded'][$a] != '') $tpl_cat_values['BUTTON_CAT_EXPAND'] = make_image_link('main.php?area=con&action=expand&idcat='.$con_tree[$a]['idcat'].'&expanded=1', 'but_minus.gif', $dedi_lang['con_noexpanded'], '16', '11','','','#catanchor');

		// Link Expand schliessen
		else $tpl_cat_values['BUTTON_CAT_EXPAND'] = make_image_link('main.php?area=con&action=expand&idcat='.$con_tree[$a]['idcat'].'&expanded=0', 'but_plus.gif', $dedi_lang['con_expanded'], '16', '11','','','#catanchor');

		// Ordner konfigurieren Infotextpopup/ Link
		// konfiguriert
		if ($con_tree[$a]['tplname']) {
			$con_catinfo = '<b>'.$dedi_lang['con_template'].":</b> ".$con_tree[$a]['tplname'];
			$folder_popup = "'$con_catinfo','".$dedi_lang['con_category_information']."', 'Id:&nbsp;$a', 'folderinfo'";

			// Konfigurationslink
			if($perm->have_perm(3, 'cat', $con_tree[$a]['idcat'])){
				$tpl_cat_values['BUTTON_CAT_CONFIG'] = make_image_link('main.php?area=con_configcat&idcat='.$con_tree[$a]['idcat'].'&idtplconf='.$con_tree[$a]['idtplconf'], 'but_folder_info.gif', $dedi_lang['con_cat_config'], '20', '17', '', $folder_popup);
			}
			else{ 
				$tpl_cat_values['BUTTON_CAT_CONFIG'] = make_image('but_folder_info.gif', $dedi_lang['con_cat_config'], '20', '17',$folder_popup);
			}

		// unkonfiguriert
		} else {
			$con_catinfo = "<b>".$dedi_lang['con_template'].":</b><font color=#AF0F0F> ".$dedi_lang['con_unconfigured']."</font>";
			$folder_popup = "'$con_catinfo','".$dedi_lang['con_category_information']."', 'Id:&nbsp;$a', 'folderinfo'";
			
			// Konfigurationslink
			if($perm->have_perm(3, 'cat', $con_tree[$a]['idcat'])){
				$tpl_cat_values['BUTTON_CAT_CONFIG'] = make_image_link('main.php?area=con_configcat&idcat='.$con_tree[$a]['idcat'].'&idtplconf='.$con_tree[$a]['idtplconf'], 'but_folder_off.gif', $dedi_lang['con_cat_config'], '20', '17', '', $folder_popup);
			}
			else{
				$tpl_cat_values['BUTTON_CAT_CONFIG'] = make_image('but_folder_off.gif', $dedi_lang['con_cat_config'], '20', '17',$folder_popup);
			}
		}

		// Ordnername
		$tpl_cat_values['CAT_NAME'] = $con_tree[$a]['name'];

		// Ordner: Seiten ordnen
		if ($sort) {
			if($perm->have_perm(9, 'cat', $con_tree[$a]['idcat'])){
				$qs_url = "main.php?area=con&sort=true&action=quicksort&idcat=$a";
				$mv_url = "main.php?area=con&action=movecat&idcat=$a";
				$cat_actions = '<select onChange="if(this.options[this.selectedIndex].value != \'\'){window.location.href = this.options[this.selectedIndex].value}" size="1">'."\n";
				if(count($con_side[$a]) > 1) {
					$cat_actions .= '          <option value="">Quicksort...</option>\n';
					$cat_actions .= '          <option value="">---------------</option>\n';
					$cat_actions .= '          <option value="'.$sess->url($qs_url."&quicksort=title:ASC").'#catanchor">'.$dedi_lang['con_sidename_up'].'</option>'."\n";
					$cat_actions .= '          <option value="'.$sess->url($qs_url."&quicksort=title:DESC").'#catanchor">'.$dedi_lang['con_sidename_down'].'</option>'."\n";
					$cat_actions .= '          <option value="'.$sess->url($qs_url."&quicksort=created:ASC").'#catanchor">'.$dedi_lang['con_created_up'].'</option>'."\n";
					$cat_actions .= '          <option value="'.$sess->url($qs_url."&quicksort=created:DESC").'#catanchor">'.$dedi_lang['con_created_down'].'</option>'."\n";
					$cat_actions .= '          <option value="'.$sess->url($qs_url."&quicksort=lastmodified:ASC").'#catanchor">'.$dedi_lang['con_changed_up'].'</option>'."\n";
					$cat_actions .= '          <option value="'.$sess->url($qs_url."&quicksort=lastmodified:DESC").'">'.$dedi_lang['con_changed_down'].'</option>'."\n";
					$cat_actions .= '          <option value="'.$sess->url($qs_url."&quicksort=author:ASC").'#catanchor">'.$dedi_lang['con_changed_up'].'</option>'."\n";
					$cat_actions .= '          <option value="'.$sess->url($qs_url."&quicksort=author:DESC").'#catanchor">'.$dedi_lang['con_changed_down'].'</option>'."\n";
					$cat_actions .= '          <option value="">---------------</option>'."\n";
				}
				$cat_actions .= '                <option value="">'.$dedi_lang['con_move_cat'].'</option>'."\n";
				$cat_actions .= '                <option value="">---------------</option>'."\n";
				if($catlist_level[$a] != '0' && $perm->have_perm(9, 'area_con', 0) ){
					$cat_actions .= '<option value="'.$sess->url($mv_url."&target=0").'">'.$dedi_lang['con_rootfolder'].'</option>';
				}
				foreach ($catmove_list as $b)
				{
					$optspaces = '';
					if($b['idcat'] == $a) {
						$hideit = 1;
						$showit = $b['level'];
					} 
				    else if ($b['level'] <= $showit){ 
						$hideit = 0; $showit=0;
				    }
						//echo $b['name']. " reallevel: ".$b['level'] ."showit: $showit <br>";
					if($hideit != 1 && $perm->have_perm(9, 'cat', $b['idcat'])  && $b['idcat']!=$con_tree[$a]['parent']) 
						$cat_actions .= '<option value="'.$sess->url($mv_url."&target=".$b['idcat']). '#catanchor">'.$b['name'].'</option>';
				}
				$hideit=0; $showit=0;
				$cat_actions .= '        </select>&nbsp;';

				// Ordner: nach oben verschieben
				if ($con_tree[$a]['sortindex'] > 1) $cat_actions .= make_image_link('main.php?area=con&action=catupdown&dir=up&sort=true&sortindex='.$con_tree[$a]['sortindex'].'&idcat='.$a.'&parent='.$con_tree[$a]['parent'], 'but_sideup.gif', $dedi_lang['con_sideup'], '13', '13','','','#catanchor')."\n";
				else $cat_actions .= "<img src=\"tpl/".$cfg_dedi['skin']."/img/space.gif\" border=\"0\" width=\"14\" height=\"13\"> \n";

				// Ordner: nach unten verschieben
				if (end($tlo_tree[$con_tree[$a]['parent']]) != $a) $cat_actions .= make_image_link('main.php?area=con&action=catupdown&dir=down&sort=true&sortindex='.$con_tree[$a]['sortindex'].'&idcat='.$a.'&parent='.$con_tree[$a]['parent'], 'but_sidedown.gif', $dedi_lang['con_sidedown'], '13', '13','','','#catanchor')."\n";
				else $cat_actions .= "<img src=\"tpl/".$cfg_dedi['skin']."/img/space.gif\" border=\"0\" width=\"14\" height=\"13\"> \n";

				// Ordner: nach ganz oben verschieben
				if ($con_tree[$a]['sortindex'] > 1) $cat_actions .= make_image_link("main.php?area=con&action=catupdown&dir=top&sort=true&idcat=$a&sortindex=".$con_tree[$a]['sortindex'].'&parent='.$con_tree[$a]['parent'], 'but_sidetop.gif', $dedi_lang['con_sideup'], '13', '13','','','#catanchor')."\n";
				else $cat_actions .= "<img src=\"tpl/".$cfg_dedi['skin']."/img/space.gif\" border=\"0\" width=\"14\" height=\"13\">\n";

				// Ordner: nach ganz unten verschieben
				if (end($tlo_tree[$con_tree[$a]['parent']]) != $a) $cat_actions .= make_image_link("main.php?area=con&action=catupdown&dir=bottom&sort=true&idcat=$a&sortindex=".$con_tree[$a]['sortindex'].'&parent='.$con_tree[$a]['parent'], 'but_sidebottom.gif', $dedi_lang['con_sidedown'], '13', '13','','','#catanchor')."&nbsp;\n";
				else $cat_actions .= "<img src=\"tpl/".$cfg_dedi['skin']."/img/space.gif\" border=\"0\" width=\"14\" height=\"13\">&nbsp;\n";
			}
		// Normale Ansicht
		} else{
			$cat_actions = '';

			// Ordner: neue Seite erstellen
			if ($con_tree[$a]['idtplconf'] != '0' && $perm -> have_perm(18, 'cat', $con_tree[$a]['idcat']) ) $tpl_cat_values['BUTTON_NEWSIDE'] = make_image_link('main.php?area=con_configside&idcat='.$con_tree[$a]['idcat'].'&idtplconf=0', 'but_newside.gif', $dedi_lang['con_actions']['20'], '14', '14');
			else $tpl_cat_values['BUTTON_NEWSIDE'] = make_image('space.gif', '', '14', '14');

			// Ordner: anlegen
			if ($perm -> have_perm(2, 'cat', $con_tree[$a]['idcat']) ){
				$tpl_cat_values['BUTTON_NEWCAT'] = make_image_link('main.php?area=con_configcat&parent='.$con_tree[$a]['idcat'].'&idtplconf=0', 'but_newcat.gif', $dedi_lang['con_folder_new'], '14', '14');
			}
			else{
				$tpl_cat_values['BUTTON_NEWCAT'] = make_image('space.gif', '', '14', '14');
			}

			// Ordner: online/offline/publish schalten
			if ($perm->have_perm( 7, 'cat', $con_tree[$a]['idcat'])) {
				$tmp_link = 'main.php?area=con&action=cat_visible&idcat='.$con_tree[$a]['idcat'].'&visible='.$con_tree[$a]['visible'];
				$tmp_link2 = 'main.php?area=con&action=cat_publish&idcat='.$a;
				$tmp_descr = $dedi_lang['con_folder_visible'][$con_tree[$a]['visible']];
				$tmp_descr2 = $dedi_lang['con_publish'];

				if (((int)$con_tree[$a]['visible'] & 0x03) == 0x00) {
					if ($cfg_client['publish'] == '1' && $con_tree[$a]['status'] == 'true') {
						$tmp_pic = 'but_offpublish.gif';
						$tmp_descr = $tmp_descr2;
						$tmp_link = $tmp_link2;
					} else $tmp_pic = 'but_offline.gif';
				} else {
					if ($cfg_client['publish'] == '1' && $con_tree[$a]['status'] == 'true') {
						$tmp_pic = 'but_onpublish.gif';
						$tmp_descr = $tmp_descr2;
						$tmp_link = $tmp_link2;
					} else $tmp_pic = 'but_online.gif';
				}
				$tpl_cat_values['BUTTON_PUBLISH'] = make_image_link($tmp_link, $tmp_pic, $tmp_descr, '13', '13','','','#sideanchor');
				unset($tmp_link);
				unset($tmp_pic);
				unset($tmp_descr);
			} else $tpl_cat_values['BUTTON_PUBLISH'] = make_image('space.gif', '', '13', '13');

			// Ordner: löschen
			if ($perm -> have_perm(5, 'cat', $con_tree[$a]['idcat'])) $tpl_cat_values['BUTTON_DELETE'] = "<a href=\"".$sess->url('main.php?area=con&action=cat_delete&idcat='.$con_tree[$a]['idcat']). "\" onMouseOver=\"on('".$dedi_lang['con_folder_delete']."');return true;\" onMouseOut=\"off();return true;\" onClick=\"return delete_confirm()\"><img src=\"tpl/".$cfg_dedi['skin']."/img/but_deleteside.gif\" width=\"13\" height=\"13\" border=\"0\" alt=\"".$dedi_lang['con_folder_delete']."\" title=\"".$dedi_lang['con_folder_delete']."\"></a>";
			else $tpl_cat_values['BUTTON_DELETE'] = make_image('space.gif', '', '13', '13');

			// Ordner: sperren
			if ($perm -> have_perm(8, 'cat', $con_tree[$a]['idcat'])) {
				if ($con_tree[$a]['offline']) {
					$lock_val = 0;
					$lock_icon = 'but_lock.gif';
					$lock_text = $dedi_lang['con_unlock'];
				} else {
					$lock_val  = 1;
					$lock_icon = 'but_unlock.gif';
					$lock_text = $dedi_lang['con_lock'];
				}
				$tpl_cat_values['BUTTON_LOCK'] = make_image_link('main.php?area=con&action=cat_lock&idcat='.$con_tree[$a]['idcat'].'&lock='.$lock_val, $lock_icon, $lock_text, '12', '13','','','#sideanchor');
			} else $tpl_cat_values['BUTTON_LOCK'] = make_image('space.gif', '', '12', '13');
			// Ordner: Vorschau
			$tpl_cat_values['BUTTON_PREVIEW'] = make_image_link($con_tree[$a]['link'], 'but_preview.gif', $dedi_lang['con_preview'], '13', '13', '_blank');
		}

		// Tabellenfarbwerte
		if ($con_tree[$a]['offline']) {
        	$tpl_cat_values['TABLE_COLOR']     = '#E9CFBD';
            $tpl_cat_values['TABLE_OVERCOLOR'] = '#EAC1A6';
		} else {
            $tpl_cat_values['TABLE_COLOR']     = '#C7D5EB';
            $tpl_cat_values['TABLE_OVERCOLOR'] = '#A8BADE';
		}
		$tpl_cat_values['CAT_ACTIONS'] = $cat_actions;
		unset($cat_actions);
		$spaces = $spaces . "&nbsp;&nbsp;&nbsp;&nbsp;";
		$tpl -> setCurrentBlock('SIDES');

		// Seiten anzeigen
		if ($tlo_tree['expanded'][$a] != '' && $con_side[$a]) {
			ksort($sidelist[$a]);
			$tmp_count = count($con_side[$a]);
			$sql = "SELECT 
					 D.idcatside, D.idcat, E.idside, D.is_start, D.sortindex, J.username,
					 F.created, F.lastmodified, F.title, F.summary, F.online, F.meta_redirect, F.meta_redirect_url,
					 F.idsidelang, F.idtplconf, H.name, I.changed
					FROM "       . $dedi_db['cat_side'] . " D
					 LEFT JOIN " . $dedi_db['side']     . " E USING(idside)
                     LEFT JOIN " . $dedi_db['side_lang']. " F USING(idside)
					 LEFT JOIN " . $dedi_db['tpl_conf'] . " G using(idtplconf)
					 LEFT JOIN " . $dedi_db['tpl']      . " H using(idtpl)
					 LEFT JOIN " . $dedi_db['code']     . " I ON D.idcatside = I.idcatside AND F.idlang=I.idlang
                     LEFT JOIN " . $dedi_db['users']    . " J ON F.author=J.user_id
                    WHERE D.idcat        = $a
					 AND  E.idclient     = $client
					 AND  F.idlang       = $lang
					ORDER BY D.sortindex";	
			$db->query($sql);
			$format_datetime = $cfg_dedi['FormatDate'].' '.$cfg_dedi['FormatTime'];
			while($db->next_record()) {
				if ( $perm->have_perm(17, 'side', $db->f('idcatside'), $db->f('idcat'))) { 
						$tmp_side['idcatside']    = $db->f('idcatside');
						$tmp_side['link']         = $sess->url($cfg_client['htmlpath'].$cfg_client['contentfile']."?lang=$lang&idcatside=".$db->f('idcatside')."&view=preview");
						$tmp_side['idcat']        = $db->f('idcat');
						$tmp_side['idside']       = $db->f('idside');
						$tmp_side['is_start']     = $db->f('is_start');
						$tmp_side['author']       = $db->f('username');
						$tmp_side['created']      = date($format_datetime, $db->f('created'));
						$tmp_side['lastmodified'] = date($format_datetime, $db->f('lastmodified'));
						$tmp_side['name']         = htmlspecialchars($db->f('title'));
						$tmp_side['online']       = (int) $db->f('online');
						$tmp_side['meta_redirect']= $db->f('meta_redirect');
						$tmp_side['meta_redirect_url'] = $db->f('meta_redirect_url');
						$tmp_side['summary']      = htmlspecialchars($db->f('summary'));
						$tmp_side['idsidelang']   = $db->f('idsidelang');
						$tmp_side['idtplconf']    = $db->f('idtplconf');
						$tmp_side['tplname']      = htmlspecialchars($db->f('name'));
						// offline ist "Seite gesperrt"
						$tmp_side['offline']      = (($db->f('online') & 0x04) == 0x04);  // change JB: ($db->f('perm') == '0');
						$tmp_side['sortindex']    = $db->f('sortindex');
	
						// Seite: konfigurieren
						$tplname = ($tmp_side['idtplconf'] != '0') ? $tmp_side['tplname'] : $dedi_lang['gen_default'];
						$tpl_side_values['SPACES_BEFORE_SIDENAME'] = $spaces;

						// Popupinformationen Seite
						$con_sideinfo = '<b>'.$dedi_lang['con_created'].":</b> ".$tmp_side['created']."<br><b>".$dedi_lang['con_lastmodified'].":</b> ".$tmp_side['lastmodified']."<br>";

						if ($tmp_side['tplname']) 
							$con_sideinfo .= "<b>".$dedi_lang['con_template'].":</b> ".$tmp_side['tplname']."<br>";
						else 
							$con_sideinfo .= "<b>".$dedi_lang['con_template'].":</b><font color=#A8A8A8> ".$con_tree[$a]['tplname']."</font><br>";

						$con_sideinfo = $con_sideinfo."<b>".$dedi_lang['con_author'].":</b> ".$tmp_side['author'];
						$con_summary = str_replace("\n", "<br>", $tmp_side['summary']);
						$con_summary = str_replace("\r", '', $con_summary);
						$con_summary = str_replace("'", "\'", $con_summary);//'
						if ($tmp_side['summary'] != '') $con_sideinfo = $con_sideinfo."<br><b>".$dedi_lang['con_summary'].":</b><br>".$con_summary;
						if ($tmp_side['meta_redirect'] == '1') $con_sideinfo = $con_sideinfo."<br><b>".$dedi_lang['con_metaredirect_url'].":</b><br>".$tmp_side['meta_redirect_url'];
						$side_popup = "'$con_sideinfo','".$dedi_lang['con_side_information']."', 'Id:&nbsp;".$tmp_side['idcatside']."', 'sideinfo'";

						// Seite: konfigurieren
						if($perm->have_perm(20, 'side', $tmp_side['idcatside'], $tmp_side['idcat'])) {
							$tmp_side_idtplconf = ($tmp_side['tplname']) ? $tmp_side['idtplconf']: '0';
							if($dediPDA->pageDoubletExists( (int) $tmp_side['idside']))
								$tpl_side_values['SIDECONFIG'] =  make_image_link('main.php?area=con_configside&idside='.$tmp_side['idside'].'&idcat='.$con_tree[$a]['idcat'].'&idcatside='.$tmp_side['idcatside'].'&idtplconf='.$tmp_side_idtplconf, 'but_sideinfo_doublet.gif', $dedi_lang['con_actions']['30'], '15', '14', '', $side_popup).'&nbsp;';
							else
							$tpl_side_values['SIDECONFIG'] =  make_image_link('main.php?area=con_configside&idside='.$tmp_side['idside'].'&idcat='.$con_tree[$a]['idcat'].'&idcatside='.$tmp_side['idcatside'].'&idtplconf='.$tmp_side_idtplconf, 'but_sideinfo.gif', $dedi_lang['con_actions']['30'], '15', '14', '', $side_popup).'&nbsp;';
						} else {
							if($dediPDA->pageDoubletExists( (int) $tmp_side['idside']))
								$tpl_side_values['SIDECONFIG'] =  make_image('but_sideinfo_doublet.gif', $dedi_lang['con_actions']['30'], '15', '14', $side_popup).'&nbsp;';
							else
							$tpl_side_values['SIDECONFIG'] =  make_image('but_sideinfo.gif', $dedi_lang['con_actions']['30'], '15', '14', $side_popup).'&nbsp;';
						}

						// Seite: bearbeiten
						$tpl_side_values['SIDENAME'] =   "<a href=\"".$sess->url('main.php?area=con_editframe&idcatside='.$tmp_side['idcatside'])."\" class=\"action\" onMouseOver=\"on('".$dedi_lang['con_editside']."');return true;\" onMouseOut=\"off();return true;\" title=\"".$dedi_lang['con_editside']."\">".$tmp_side['name']."</a>";

						// Anker
						if ($tmp_side['idcatside'] == $idcatside || $tmp_side['idside'] == $idside) $tpl_side_values['SIDEANCHOR'] =   "<a name=\"sideanchor\">";

						// Seite: Aktionen
						// Sortieransicht
						if ($sort) {
							if($perm->have_perm(25, 'side', $tmp_side['idcatside'], $tmp_side['idcat'])){
								$sort_actions = '';

								// Seite: nach oben verschieben
								if ($sidelist[$a]['1'] != $tmp_side['idcatside']) $sort_actions .= make_image_link('main.php?area=con&action=sideup&sort=true&sortindex='.$tmp_side['sortindex'].'&idcat='.$tmp_side['idcat'].'&idside='.$tmp_side['idside'].'&idside='.$tmp_side['idside'], 'but_sideup.gif', $dedi_lang['con_sideup'], '13', '13','','','#catanchor')."\n";
								elseif ($tmp_count > 1) $sort_actions .= "<img src=\"tpl/".$cfg_dedi['skin']."/img/space.gif\" border=\"0\" width=\"14\" height=\"13\"> \n";

								// Seite: nach unten verschieben
								if (end($sidelist[$a]) != $tmp_side['idcatside']) $sort_actions .= make_image_link('main.php?area=con&action=sidedown&sort=true&sortindex='.$tmp_side['sortindex'].'&idcat='.$tmp_side['idcat'].'&idside='.$tmp_side['idside'], 'but_sidedown.gif', $dedi_lang['con_sidedown'], '13', '13','','','#catanchor')."\n";
								elseif ($tmp_count > 1) $sort_actions .= "<img src=\"tpl/".$cfg_dedi['skin']."/img/space.gif\" border=\"0\" width=\"14\" height=\"13\"> \n";

								// Seite: nach ganz oben verschieben
								if ($sidelist[$a]['1'] != $tmp_side['idcatside']) $sort_actions .= make_image_link("main.php?area=con&action=sidetop&sort=true&idcat=$a&idcatside=".$tmp_side['idcatside']."&sortindex=".$tmp_side['sortindex'], 'but_sidetop.gif', $dedi_lang['con_sideup'], '13', '13','','','#catanchor')."\n";
								elseif ($tmp_count > 1) $sort_actions .= "<img src=\"tpl/".$cfg_dedi['skin']."/img/space.gif\" border=\"0\" width=\"14\" height=\"13\">\n";

								// Seite: nach ganz unten verschieben
								if (end($sidelist[$a]) != $tmp_side['idcatside']) $sort_actions .= make_image_link("main.php?area=con&action=sidebottom&sort=true&idcat=$a&idcatside=".$tmp_side['idcatside']."&sortindex=".$tmp_side['sortindex'], 'but_sidebottom.gif', $dedi_lang['con_sidedown'], '13', '13','','','#catanchor')."&nbsp;\n";
								elseif ($tmp_count > 1) $sort_actions .= "<img src=\"tpl/".$cfg_dedi['skin']."/img/space.gif\" border=\"0\" width=\"14\" height=\"13\">\n";

								$tpl_side_values['SIDE_ACTIONS'] = $sort_actions;
								unset($sort_actions);
							}
						// Standardansicht
						} else {
							$side_actions = '';
	
							// Seite: Startseite festlegen
							if($perm->have_perm(28, 'side', $tmp_side['idcatside'], $tmp_side['idcat'])) {
								if ($tmp_side['is_start'] == '1') $tpl_side_values['BUTTON_STARTPAGE'] = "<img src=\"tpl/".$cfg_dedi['skin']."/img/but_start_yes.gif\" border=\"0\" alt=\"".$dedi_lang['con_actions']['10'][$tmp_side['is_start']]."\" title=\"".$dedi_lang['con_actions']['10'][$tmp_side['is_start']]."\" width=\"19\" height=\"14\">";
								else $tpl_side_values['BUTTON_STARTPAGE'] = make_image_link('main.php?area=con&action=side_start&idcatside='.$tmp_side['idcatside'].'&is_start='.$tmp_side['is_start'], 'but_start_no.gif', $dedi_lang['con_actions']['10'][$tmp_side['is_start']], '19', '14','','','#sideanchor');
							}

							// Seite: online/offline/publish schalten
							if ($perm->have_perm(23, 'side', $tmp_side['idcatside'], $tmp_side['idcat'])) {
								$tmp_link   = 'main.php?area=con&action=side_visible&idside=' . $tmp_side['idside'] . '&idcat=' . $tmp_side['idcat'] . '&online=' . $tmp_side['online'];
								$tmp_link2  = 'main.php?area=con&action=side_publish&idcatside='.$tmp_side['idcatside'].'&idcat='.$a;
								$tmp_descr  = $dedi_lang['con_side_visible'][$tmp_side['online']];
								$tmp_descr2 = $dedi_lang['con_publish'];
	
								if (($tmp_side['online'] & 0x03) == 0x00) {
									// ist geschützt, 
									if ($cfg_client['publish'] == '1' && $con_side[$a][$tmp_side['idcatside']]['status'] == 'true') {
										$tmp_pic = 'but_offpublish.gif';
										$tmp_descr = $tmp_descr2;
										$tmp_link = $tmp_link2;
									} else $tmp_pic = 'but_offline.gif';
								} else {
									// online oder zeitgesteuert
									if (((int)$con_tree[$a]['visible'] & 0x03) == 0x00) {
										if ($cfg_client['publish'] == '1' && $con_side[$a][$tmp_side['idcatside']]['status'] == 'true') {
											$tmp_pic = 'but_offpublish.gif';
											$tmp_descr = $tmp_descr2;
											$tmp_link = $tmp_link2;
										} else $tmp_pic = 'but_onoffline.gif';
									} else {
										if ($cfg_client['publish'] == '1' && $con_side[$a][$tmp_side['idcatside']]['status'] == 'true') {
											$tmp_pic = 'but_onpublish.gif';
											$tmp_descr = $tmp_descr2;
											$tmp_link = $tmp_link2;
										} else {
					                 		$tmp_pic = (((int)$tmp_side['online'] & 0x02) == 0x02) ? 'but_time.gif': 'but_online.gif';
										}
									}
								}
								$tpl_side_values['BUTTON_PUBLISH'] = make_image_link($tmp_link, $tmp_pic, $tmp_descr, '13', '13','','','#sideanchor');
								unset($tmp_link);
								unset($tmp_pic);
								unset($tmp_description);
							} else $tpl_side_values['BUTTON_PUBLISH'] = make_image('space.gif', '', '13', '13');
	
							// Seite: bearbeiten
							if($perm->have_perm(19, 'side', $tmp_side['idcatside'], $tmp_side['idcat'])) $tpl_side_values['BUTTON_EDIT'] =   "<a href=\"".$sess->url('main.php?area=con_editframe&idcatside='.$tmp_side['idcatside'])."\" onMouseOver=\"on('".$dedi_lang['con_editside']."');return true;\" onMouseOut=\"off();return true;\"><img src=\"tpl/".$cfg_dedi['skin']."/img/but_edit.gif\" border=\"0\" alt=\"".$dedi_lang['con_editside']."\" title=\"".$dedi_lang['con_editside']."\" width=\"18\" height=\"14\"></a>";
							else $tpl_side_values['BUTTON_EDIT'] = make_image('space.gif', '', '18', '14');

							// Seite: löschen
							if($perm -> have_perm(21, 'side', $tmp_side['idcatside'], $tmp_side['idcat'])) 
								if($dediPDA->pageDoubletExists( (int) $tmp_side['idside']))								
									$tpl_side_values['BUTTON_DELETE'] = "<a href=\"".$sess->url('main.php?action=side_delete&idcat='.$tmp_side['idcat'].'&idside='.$tmp_side['idside']). "#catanchor\" onMouseOver=\"on('".$dedi_lang['con_actions']['40']."');return true;\" onMouseOut=\"off();return true;\" onClick='return confirm(\"".$dedi_lang['gen_deletedoublet']."\")'><img src=\"tpl/".$cfg_dedi['skin']."/img/but_deleteside.gif\" width=\"13\" height=\"13\" border=\"0\" alt=\"".$dedi_lang['con_actions']['40']."\" title=\"".$dedi_lang['con_actions']['40']."\"></a>";
								else
									$tpl_side_values['BUTTON_DELETE'] = "<a href=\"".$sess->url('main.php?action=side_delete&idcat='.$tmp_side['idcat'].'&idside='.$tmp_side['idside']). "#catanchor\" onMouseOver=\"on('".$dedi_lang['con_actions']['40']."');return true;\" onMouseOut=\"off();return true;\" onClick=\"return delete_confirm()\"><img src=\"tpl/".$cfg_dedi['skin']."/img/but_deleteside.gif\" width=\"13\" height=\"13\" border=\"0\" alt=\"".$dedi_lang['con_actions']['40']."\" title=\"".$dedi_lang['con_actions']['40']."\"></a>";
							else $tpl_side_values['BUTTON_DELETE'] = make_image('space.gif', '', '13', '13');
	
							// Seite: schützen
							if ($perm -> have_perm(24, 'side', $tmp_side['idcatside'], $tmp_side['idcat'])) {
				                if ($tmp_side['offline']) {
									$lock_val = 0;
									$lock_icon = 'but_lock.gif';
									$lock_text = $dedi_lang['con_unlock_side'];
								} else {
									$lock_val  = 1;
									$lock_icon = 'but_unlock.gif';
									$lock_text = $dedi_lang['con_lock_side'];
								}
								$tpl_side_values['BUTTON_LOCK'] = make_image_link('main.php?action=side_lock&idcatside='.$tmp_side['idcatside'].'&idside='.$tmp_side['idside'].'&lock='.$lock_val, $lock_icon, $lock_text, '12', '13','','','#sideanchor');
							} else {
								$tpl_side_values['BUTTON_LOCK'] = make_image('space.gif', '', '12', '13');
							}
	
							// Seite: Vorschau
							$tpl_side_values['BUTTON_PREVIEW'] = make_image_link($tmp_side['link'], 'but_preview.gif', $dedi_lang['con_preview'], '13', '13', '_blank');
							$tpl_side_values['SIDE_ACTIONS'] = $side_actions;
							unset($side_actions);
						}

						// Tabellenfarbwerte
						if ($con_tree[$a]['offline'] || $tmp_side['offline']) {
							$tpl_side_values['TABLE_COLOR'] = '#EFE3DB';
							$tpl_side_values['TABLE_OVERCOLOR'] = '#EBD5C7';
						} else {
							$tpl_side_values['TABLE_COLOR'] = '#DBE3EF';
							$tpl_side_values['TABLE_OVERCOLOR'] = '#C7D5EB';
						}
						// Seitentemplate parsen
						$tpl->setVariable($tpl_side_values);
						$tpl->parse('SIDES');
						unset($tpl_side_values, $tmp_side);
					}
				}
			}

		// Ordnertemplate parsen
		$tpl -> setCurrentBlock('TREE');
		$tpl->setVariable($tpl_cat_values);
		$tpl->parse('TREE');
		unset($tpl_cat_values);
	}

// Es gibt keine Ordner
} else {
	$tpl -> setCurrentBlock('EMPTY');
	$tpl_empty_values['LANG_NOCATS'] = $dedi_lang['con_nofolder'];
	$tpl->setVariable($tpl_empty_values);
	$tpl->parse('EMPTY');
	unset($tpl_empty_values);
}
?>
