<?php
////////////////////////////////////////////////////////////////////////
// Breeze Website Builder
// Copyright Silver Dolphin Solutions, LLC, Edward Lemmers, P.E.
// For licensing, see license.txt.
// Created: 8/27/2014	ELL
// Modified: 12/2/2016	ELL
// Consolidated all class tables into site_classes table indexed by style_sheet field.
// Consolidated all CSS tables into site_css table indexed by style_sheet field.

	include ("check_session.php");
	
	$goto_class = $_REQUEST['goto_class'];
	$sort_alpha = $_REQUEST['sort_alpha'];
	$style_sheet = $_REQUEST['style_sheet'];
	
	$_SESSION['class_sort_method'] = $sort_alpha;

	$html = "\n<select name='goto_class' id='goto_class' onChange='PopulateForm(this);'>\n";
	$html .= "<option value=''>-not selected-</option>\n";

	$search = array("PERIOD", "POUND", "SPACE", "COMMA", "GREATERTHAN", "GREATERTHAN", "PLUS", "TILDA");
	$replace = array(".", "#", " ", ",", ">", "&gt;", "+", "~");
	$goto_class_cmp = str_replace($search, $replace, $goto_class);
	if ($sort_alpha == 1)
		$query = "SELECT * FROM `" . BWB_TABLE_PREFIX . "site_classes` WHERE `style_sheet` = '$style_sheet' ORDER BY `class`";
	else
		$query = "SELECT * FROM `" . BWB_TABLE_PREFIX . "site_classes` WHERE `style_sheet` = '$style_sheet' ORDER BY `sort_order`";
		
	$result = $bwb_dbh->query($query);
	while ($row = $result->fetch(PDO::FETCH_ASSOC))
	{
		$tmp_class = $row['class'];
		$tmp_desc = $row['description'];
		$tmp_class_val = str_replace($replace, $search, $tmp_class);
		if ($tmp_class == $goto_class_cmp)
			$html .= "<option value='$tmp_class_val' selected='selected'>$tmp_class ----- $tmp_desc</option>\n";
		else
			$html .= "<option value='$tmp_class_val'>$tmp_class ----- $tmp_desc</option>\n";
	}
	$html .= "</select>\n";
	
	echo $html;
?>