Location: PHPKode > projects > SiteX > admin/themes.php
<?PHP
ob_start();
session_start();
include("../includes/globals.php.inc");
include("../includes/functions.php");
include("../lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("../lang/".$sxSetup['Language'].".php");
include("../themes/$THEME_FOLDER/config.php.inc");

if(!userAdmin())
	loginError($sxLang['LoginRequired']);

if($scheme)
{
	$query = "UPDATE $DB_Themes_Setup SET selected='0' WHERE selected='1' AND themeid='$THEME'";
	$result = mysql_query($query, $Link) or queryError("57", mysql_error());
	
	$query = "UPDATE $DB_Themes_Setup SET selected='1' WHERE id='$scheme'";
	$result = mysql_query($query, $Link) or queryError("58", mysql_error());
	
	header("Location:$PHP_SELF?message=".str_replace(" ","_",$sxLang['MessageThemesDesignUpdated']));
	die();
}

if($changeTheme)
{
	$query = "UPDATE $DB_Themes SET selected='0' WHERE selected='1'";
	$result = mysql_query($query, $Link) or queryError("57", mysql_error());
	
	$query = "UPDATE $DB_Themes SET selected='1' WHERE id='$changeTheme'";
	$result = mysql_query($query, $Link) or queryError("58", mysql_error());
	
	header("Location:$PHP_SELF?message=".str_replace(" ","_",$sxLang['MessageThemesDesignUpdated']));
	die();
}

if($scheme_delete)
{
	$query = "SELECT * FROM $DB_Themes_Setup";
	$result = mysql_query($query, $Link) or queryError("58", mysql_error());
	if(mysql_num_rows($result) > 1)
	{
		$query = "SELECT * FROM $DB_Themes_Setup WHERE id='$scheme_delete'";
		$result = mysql_query($query, $Link) or queryError("58", mysql_error());
		$ROW = mysql_fetch_object($result);
		if($ROW->selected == 1)
		{
			$query = "SELECT * FROM $DB_Themes_Setup WHERE selected='0' LIMIT 0,1";
			$result = mysql_query($query, $Link) or queryError("58", mysql_error());
			$ROW = mysql_fetch_object($result);
			$query2 = "UPDATE $DB_Themes_Setup SET selected='1' WHERE id='$ROW->id'";
			$result2 = mysql_query($query2, $Link) or queryError("58", mysql_error());
		}
		$query = "DELETE FROM $DB_Themes_Setup WHERE id='$scheme_delete'";
		$result = mysql_query($query, $Link) or queryError("57", mysql_error());
		
		header("Location:$PHP_SELF?message=".str_replace(" ","_",$sxLang['MessageThemesSchemeDeleted']));
		die();
	}
	else
		$message = $sxLang['MessageThemesSchemeDeleteError'];
}

if($sxThemeDelete == 1)
{
	// Delete schemes
	$query = "DELETE FROM $DB_Themes_Setup WHERE themeid='$THEME'";
	$result = mysql_query($query, $Link) or queryError("45732", mysql_error());
	
	// Delete title pictures
	$query = "SELECT * FROM $DB_Title_Pictures WHERE themeid='$THEME'";
	$result = mysql_query($query, $Link) or queryError("2397", mysql_error());
	while($sxTitle = mysql_fetch_object($result))
		unlink(sxPathToRoot().$sxContentDir['TitleImage'].$sxTitle->filename);
	
	$query = "DELETE FROM $DB_Title_Pictures WHERE themeid='$THEME'";
	$result = mysql_query($query, $Link) or queryError("5325", mysql_error());
	
	// Delete theme folder & files
	sxDirDelete('themes/'.$THEME_FOLDER);
	
	// Delete theme
	$query = "DELETE FROM $DB_Themes WHERE id='$THEME'";
	$result = mysql_query($query, $Link) or queryError("345", mysql_error());
	
	// Select exsiting theme
	$query = "SELECT id FROM $DB_Themes LIMIT 0,1";
	$result = mysql_query($query, $Link) or queryError("141", mysql_error());
	$sxNewTheme = mysql_fetch_object($result);

	$query = "UPDATE $DB_Themes SET selected='1' WHERE id='$sxNewTheme->id'";
	$result = mysql_query($query, $Link) or queryError("5812", mysql_error());
	
	header("Location: themes.php?message=".urlencode($sxLang['MessageThemesThemeDeleted']));
	die();
}

// Clone color scheme
if( ($sxSchemeClone) AND (intval($sxSchemeClone) > 0) )
{
	$sxSchemeID = $sxSchemeClone;
	
	$query = "SELECT * FROM $DB_Themes_Setup WHERE id='$sxSchemeID' LIMIT 0,1";
	$result = mysql_query($query, $Link) or queryError("2362", mysql_error());
	$sxThisScheme = mysql_fetch_object($result);
	
	$sxNewSchemeName = $sxThisScheme->name." Clone";
	$query = "INSERT INTO $DB_Themes_Setup (name, themeid, color_primary, color_secondary, color_background, color_table, color_table_row, color_text, color_text_secondary, color_text_table, color_links, color_links_hover, color_links_visited, color_sitename, show_sitename, selected) VALUES ('$sxNewSchemeName', '$THEME', '$sxThisScheme->color_primary', '$sxThisScheme->color_secondary', '$sxThisScheme->color_background', '$sxThisScheme->color_table', '$sxThisScheme->color_table_row', '$sxThisScheme->color_text', '$sxThisScheme->color_text_secondary', '$sxThisScheme->color_text_table', '$sxThisScheme->color_links', '$sxThisScheme->color_links_hover', '$sxThisScheme->color_links_visited', '$sxThisScheme->color_sitename', '$sxThisScheme->show_sitename', '0')";
	$result = mysql_query($query, $Link) or queryError("46328", mysql_error());
}

$sxTitleAddendum = $sxLang['AdminHeading'];
include("../themes/$THEME_FOLDER/header.php");

if($sxWarningText)
	$sxWarnings = array($sxLang['WarningTitle'], urldecode($sxWarningText));

?> 
<script language="JavaScript" type="text/JavaScript">
<!--
function confirmDelete(theID,theName){
	if(confirm("<?PHP echo $sxLang['ThemesJSDeleteScheme']; ?> '"+theName+"' <?PHP echo $sxLang['GeneralJSDeleteEntry2']; ?>")){
		window.location='<?PHP print $PHP_SELF."?scheme_delete="; ?>'+theID;
	}
}
function confirmDeleteTheme(){
	if(confirm("<?PHP echo $sxLang['MessageThemesThemeDelete']; ?>")){
		window.location='<?PHP print $PHP_SELF."?sxThemeDelete=1"; ?>';
	}
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>    
<div class="bodyWrapper">
   <h1 class="sxAdminHeading"><?PHP echo $sxLang['ThemesHeadingSiteDesign']; ?></h1>
   <div class="sxAdminBreadcrumbs"><?PHP if(userAdmin()) { ?><a href="index.php"><?PHP echo $sxLang['AdminBreadcrumb']; ?><?PHP }?><?PHP if(userEditor()) { ?><a href="editor_index.php"><?PHP echo $sxLang['EditorBreadcrumb']; ?><?PHP }?></a> > <?PHP echo $sxLang['ThemesHeadingSiteDesign']; ?></div>   
   <?PHP echoMessage($message); sxEchoWarning($sxWarnings); ?>
<form name="sxFormTheme" method="post" action="<?PHP echo $PHP_SELF; ?>">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" valign="top">
<p><strong><?PHP echo $sxLang['ThemesItemTheme']; ?>:</strong> <select name="theme" onChange="MM_jumpMenu('parent',this,0)">
<?PHP
	$query = "SELECT * FROM $DB_Themes ORDER BY name";
	$result = mysql_query($query, $Link) or queryError("58", mysql_error());
	while($ROW = mysql_fetch_object($result))
	{
		if($ROW->id == $THEME)
		{
			$selected = " selected";
			$sxSelectedTheme = $ROW;
		}
		else
			$selected = "";
			
		echo '<option value="' . "$PHP_SELF?changeTheme=$ROW->id" . '"' . $selected . '>' . $ROW->name . '</option>';
	}
?>
</select></p>
<p><strong><?PHP echo $sxLang['ThemesItemColorSchemes']; ?>:</strong></p> 
<table cellpadding="5" cellspacing="2" border="0">
<tr>
	<td class="tableColumn"><?PHP echo $sxLang['GeneralItemSelected']; ?></td>
	<td class="tableColumn"><?PHP echo $sxLang['GeneralItemName']; ?></td>
	<td class="tableColumn"><?PHP echo $sxLang['ThemesItemColors']; ?></td>
	<td class="tableColumn"><?PHP echo $sxLang['GeneralItemOptions']; ?></td>
 </tr>
<?PHP
	$query = "SELECT * FROM $DB_Themes_Setup WHERE themeid='$THEME' ORDER BY name";
	$result = mysql_query($query, $Link) or queryError("58", mysql_error());
	while($ROW = mysql_fetch_object($result))
	{
		if($ROW->selected == 1)
			$selected = "check.gif";
		else
			$selected = 'x.gif" title="'.$sxLang['ButtonSelect'].'"';
		
		echo '<tr bgcolor="' . $sxTheme['ColorTableRow'] . '"><td><a href="' . $PHP_SELF . '?scheme=' . $ROW->id . '"><img src="../images/' . $selected . '" style="border: 0;" /></a></td>';
		
		echo '<td>' . htmlspecialchars($ROW->name) . '</td>';
		
		echo '<td>';
		echo '<table style="width:60px;height:20px;" border="0" cellpadding="0" cellspacing="0"><tr>';
		echo '<td style="width:20px; background-color:' . $ROW->color_primary . ';">&nbsp;</td>';
		echo '<td style="width:20px; background-color:' . $ROW->color_secondary . ';">&nbsp;</td>';
		echo '<td style="width:20px; background-color:' . $ROW->color_text_secondary . ';">&nbsp;</td>';
		echo '</tr></table>';
		echo '</td>';
		
		echo '<td>';
		
		if($sxThemeConfig['AdminSchemeClone'] == 1)
			echo '<a href="' . $PHP_SELF . '?sxSchemeClone=' . $ROW->id . '" title="' . $sxLang['ThemesButtonSchemeClone'] .' -> '. htmlspecialchars($ROW->name) . ' +1"><img src="../images/admin_clone.gif" style="border: 0;" alt="' . $sxLang['ThemesButtonSchemeClone'].' -> '. htmlspecialchars($ROW->name) . ' +1" /></a> ';
		
		echo '<a href="themes_scheme_edit.php?schemeid=' . $ROW->id . '" title="' . $sxLang['ButtonEdit'] . '"><img src="../images/admin_edit.gif" style="border: 0;" alt="' . $sxLang['ButtonEdit'] . '" /></a>';
		echo '    <a href="#" onclick="confirmDelete(' . $ROW->id . ',\'' . htmlspecialchars(addslashes($ROW->name)) . '\')" title="' . $sxLang['ButtonDelete'] . '"><img src="../images/admin_delete.gif" style="border: 0;" alt="' . $sxLang['ButtonDelete'] . '" /></a></td></tr>';
	}
?></table><br /><br />
<input name="edit" type="button" value="<?PHP echo $sxLang['ThemesButtonSchemeAdd']; ?>" onclick="window.location='themes_scheme_add.php?themeid=<?PHP echo $THEME; ?>'" />
</td><td width="50%" valign="top">
<fieldset>
<legend><strong><?PHP echo $sxLang['ThemesInfo']; ?></strong></legend>
	<div style="padding: 10px;">
	<strong><?PHP echo $sxLang['ThemesInfoName'] . ':</strong> '. $sxSelectedTheme->name; ?><br />
	<strong><?PHP echo $sxLang['ThemesInfoCompat'] . ':</strong> '. $sxSelectedTheme->sitex_version; ?><br />
	<strong><?PHP echo $sxLang['ThemesInfoAuthor'] . ':</strong> <a target="_blank" href="http://sitex.bjsintay.com/">'. $sxSelectedTheme->creator . '</a>'; ?><br />
	<strong><?PHP echo $sxLang['ThemesInfoFolder'] . ':</strong> ./themes/'. $sxSelectedTheme->folder; ?><br /><br />
	<div align="right">
		<input style="width: 125px; cursor: pointer;" name="sxThemeDelete" title="<?php echo $sxLang['ThemesTooltipThemeDelete']; ?>" type="button" value="<?PHP echo $sxLang['ThemesButtonThemeDelete']; ?>" onclick="confirmDeleteTheme()" />
	</div>
	</div>
</fieldset>
<fieldset>
<legend><strong><?PHP echo $sxLang['ThemesInfoNotes']; ?></strong></legend>
<ul>
	<li><?PHP echo $sxLang['ThemesInfoTitle'] . ': ' . $sxSelectedTheme->title_width . ' (' . substr($sxLang['Width'],0,1) . ') x ' . $sxSelectedTheme->title_height . ' (' . substr($sxLang['Height'],0,1) . ')'; ?>
	<?PHP echo $sxSelectedTheme->notes; ?>
</ul>
</fieldset>
</td>
</tr></table>
</form>
</div>
<?PHP
include("../themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>
Return current item: SiteX