Location: PHPKode > scripts > CSS Briefcase > css-briefcase/index.php
<?php
	include('functions.php');
	
	// Generated
	if ($_POST['action'] == 'generate_briefcase') {
		$styles = getStylesData('css.xml');
		$num_styles = count($styles);
		$style_i = 0;
		while ($style_i <= $num_styles) {
			if ($_POST[$style_i] == 1) {
				//echo $styles[$style_i]['name'] . $style_i;
				$formatted_code_array_1 = explode ('{',$styles[$style_i]['code']);
				$formatted_code_array_2 = explode (';',$formatted_code_array_1[1]);
				$total_lines = count($formatted_code_array_2);
				$lines_i = 0;
				$formatted_code = '';
				while(($lines_i+1) < $total_lines) {
					$formatted_code .= '&nbsp;&nbsp;' . $formatted_code_array_2[$lines_i] . "<br />";
					$lines_i++;
				}
				$formatted_code = $formatted_code_array_1[0] . " { <br />" . $formatted_code . "}";
				$formatted_for_copy = $formatted_code;
				$formatted_for_copy = str_replace('<br />',"\n",$formatted_for_copy);
				$formatted_for_copy = str_replace('&nbsp;'," ",$formatted_for_copy) . "\n\n";
				$briefcase_code .= $formatted_for_copy;
				}
			$style_i++;
		}
		if ($formatted_for_copy != '') {
			$briefcase_code = '<div class="code-div"><form>Click the area below to highlight the code. Press CTL+C to copy and paste it into your CSS file or into &lt;style&gt; tags:<br /><textarea onclick="this.form.css_code.select()" cols="50" rows="3" name="css_code" id="css_code">' . $briefcase_code . '</textarea></form></div>';
		}
	}
	
	// Deleted
	if ($_GET['action'] == 'delete') {
		$styles = getStylesData('css.xml');
		$total = count($styles);
		$style_i = 0;
		while ($style_i < $total) {
			if ($style_i != $_GET['id'] && $styles[$style_i]['style_name'] != '') {
				$xml_entry .= 
'<style>
	<name>' . $styles[$style_i]['name'] . '</name>
	<style_code>' . $styles[$style_i]['code'] . '</style_code>
</style>
';
				echo $xml_entry;
			}
			$style_i++;
		}
		@unlink('css.xml');
		$file = fopen('css.xml','w+');
		fwrite($file,$xml_entry);
	}

	
	
	$contents = getFileContents('css.xml');
	
	$styles = getStylesData('css.xml');
	$briefcase = formatBriefcase($styles);
	$briefcase_block = $briefcase['display'];
	$briefcase_css = $briefcase['css'];
	
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="styles.css"></link>
<style>
	textarea {
		font-size:11px;
		font-family:"Courier New", Courier, mono;
		background-color:#FFFF00;
	}
	.code-div {
		border:1px solid silver;
		background-color: #FFFFFF;
		padding:10px;
		margin:10px;
		text-align:center;
		font-weight:bold;
	}
	.result-div {
		border:1px solid silver;
		padding:5px;
		text-align:center;
		margin:5px;
		color:#009900;
		font-weight:bold;
	}
</style>
<?php echo $briefcase_css; ?>
</head>
<body>
<?php echo $result_div; ?>
<h1>Your CSS Briefcase</h1>
<?php echo $briefcase_code; ?>
<p>To use the CSS briefcase, click the "Add styles" link below to add different style declarations that you might use on several projects. Then, to create the CSS code for new projects, select the checkbox next to the styles you want to include and click the "Generate Code" button.</p>
<p><a href="add-style.php"><strong>Add styles to your briefcase &gt;&gt;</strong></a></p>
<?php echo $briefcase_block; ?>
<p><a href="http://www.impliedbydesign.com/css-briefcase.html">CSS Briefcase</a> is a free script offered by <a href="http://www.impliedbydesign.com">Implied By Design LLC.</a></p>
</body>
</html>

<script type="text/javascript" src="wz_tooltip.js"></script>
Return current item: CSS Briefcase