<?php
/////////////////////////////////////////////
// EB Content Management System
// Copyright EB Dynamics, Inc., Edward Lemmers, P.E.
// Build string for site.css file /////
// Created: 7/6/2009	ELL
// Revised: 8/3/2009	ELL
// Added ability to operate using different class tables and different CSS tables.  This was done to give the ability
// to style calendar grids and event grids without adding 14 more classes to the site style list.
// 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.
//
	
	$style_sheet = $_REQUEST['style_sheet'];
	
	$xml_string = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
	$xml_string .= "<Styles>\n";
	$query = "SELECT * FROM `" . "site_classes` WHERE `custom` = 1 ORDER BY `sort_order`";
	$result = mysql_query($query);
	while ($row = mysql_fetch_array($result))
	{
		$class = $row["class"];
		$description = $row["description"];
		$class_type = substr($class, 0, 1);
		if ($class_type == "#")
			$attrib_name = "id";
		else
			$attrib_name = "class";
		$class = str_replace(".", "", $class);
		$class = str_replace("#", "", $class);
	
		$xml_string .= "   <Style name=\"" . $description . "\" element=\"span\">\n";
		$xml_string .= "      <Attribute name=\"" . $attrib_name . "\" value=\"" . $class . "\" />\n";
		$xml_string .= "   </Style>\n";
	}	// end while
	
	// Add FCKEditor stock example styles.
	$xml_string .= "\n   <!-- FCKEditor Stock Example Styles -->\n\n";
	$xml_string .= "   <Style name=\"Marker: Yellow\" element=\"span\">\n";
	$xml_string .= "      <Style name=\"background-color\" value=\"Yellow\" />\n";
	$xml_string .= "   </Style>\n";
	$xml_string .= "   <Style name=\"Marker: Green\" element=\"span\">\n";
	$xml_string .= "      <Style name=\"background-color\" value=\"Lime\" />\n";
	$xml_string .= "   </Style>\n\n";

	$xml_string .= "   <Style name=\"Big\" element=\"big\" />\n";
	$xml_string .= "   <Style name=\"Small\" element=\"small\" />\n";
	$xml_string .= "   <Style name=\"Typewriter\" element=\"tt\" />\n\n";

	$xml_string .= "   <Style name=\"Computer Code\" element=\"code\" />\n";
	$xml_string .= "   <Style name=\"Keyboard Phrase\" element=\"kbd\" />\n";
	$xml_string .= "   <Style name=\"Sample Text\" element=\"samp\" />\n";
	$xml_string .= "   <Style name=\"Variable\" element=\"var\" />\n\n";

	$xml_string .= "   <Style name=\"Deleted Text\" element=\"del\" />\n";
	$xml_string .= "   <Style name=\"Inserted Text\" element=\"ins\" />\n\n";

	$xml_string .= "   <Style name=\"Cited Work\" element=\"cite\" />\n";
	$xml_string .= "   <Style name=\"Inline Quotation\" element=\"q\" />\n\n";

	$xml_string .= "   <Style name=\"Language: RTL\" element=\"span\">\n";
	$xml_string .= "      <Attribute name=\"dir\" value=\"rtl\" />\n";
	$xml_string .= "   </Style>\n";
	$xml_string .= "   <Style name=\"Language: LTR\" element=\"span\">\n";
	$xml_string .= "      <Attribute name=\"dir\" value=\"ltr\" />\n";
	$xml_string .= "   </Style>\n";
	$xml_string .= "   <Style name=\"Language: RTL Strong\" element=\"bdo\">\n";
	$xml_string .= "      <Attribute name=\"dir\" value=\"rtl\" />\n";
	$xml_string .= "   </Style>\n";
	$xml_string .= "   <Style name=\"Language: LTR Strong\" element=\"bdo\">\n";
	$xml_string .= "      <Attribute name=\"dir\" value=\"ltr\" />\n";
	$xml_string .= "   </Style>\n\n";

	$xml_string .= "   <Style name=\"Image on Left\" element=\"img\">\n";
	$xml_string .= "      <Attribute name=\"style\" value=\"padding: 5px; margin-right: 5px\" />\n";
	$xml_string .= "      <Attribute name=\"border\" value=\"2\" />\n";
	$xml_string .= "      <Attribute name=\"align\" value=\"left\" />\n";
	$xml_string .= "   </Style>\n";
	$xml_string .= "   <Style name=\"Image on Right\" element=\"img\">\n";
	$xml_string .= "      <Attribute name=\"style\" value=\"padding: 5px; margin-left: 5px\" />\n";
	$xml_string .= "      <Attribute name=\"border\" value=\"2\" />\n";
	$xml_string .= "      <Attribute name=\"align\" value=\"right\" />\n";
	$xml_string .= "   </Style>\n";
	
	// Close style tag.
	$xml_string .= "</Styles>\n";
?>