⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin-tech_functions.php

📁 jsp程序开发系统
💻 PHP
📖 第 1 页 / 共 4 页
字号:
	Create a table header.

-----ARGUMENTS: -------------------------------------
	title	Table title
	action	[Optional] If specified, generate a form start tag that submits to this file.
	hidden	[Optional] Associative array of hidden variables for a form
	show	[Optional] [T/F] Expand the table by default
	name	[Optional] Name of generated form
	binary	[Optional] [T/F] Form is a binary submission form.
	js		[Optional] JavaScript to fire on form submit.

-----RETURNS:----------------------------------------
	None; directly generates HTML.

*****************************************************/

function table_header ($title, $action='', $hidden = '', $show = '', $name = '', $binary = '', $js = '') {

	global $settings;

	$title = str_replace('<a href=', '<a class=\'titl\' href=', $title);

	$title2 = $title . "2";
	$js_title = addslashes_js($title);
	$js_title2 = addslashes_js($title2);
	if (!$name) {
		$name2 = explode(' ', $title);
		if ($name2 == ' ') {
			$name = $title;
		} else {
			$name = $name2[1];
		}
	}

	echo "\n\n<!-- Begin table $title -->\n\n";
	
	if ($action) {
		$form = "<form action=\"$action\" method=\"post\" name=\"$name\"" . iff($binary, "enctype=\"multipart/form-data\"") . iff($js, $js) . ">\n";
	}
	
	if (is_array($hidden)) {
		while (list ($key, $value) = each ($hidden)) {
			$form .= form_hidden($key, $value);
		}
	}

	echo $form;

	echo "
	<div id=\"$title2\">
	<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" height=\"21\" width=\"100%\">
	<tr>
    <td width=\"19\" bgcolor=\"#BF4343\" align=\"center\">" . 
		html_image('spacer.gif', 3) . 
		html_image('tech/bul040.gif', 13, 14) . 
		html_image('spacer.gif', 3) . 
	"</td>
	<td width=\"10\" align=\"center\" bgcolor=\"#727272\">" . 
		html_image('spacer.gif', 10) . 
	"</td>
    <td nowrap=\"nowrap\" bgcolor=\"#727272\"><div class=\"tit1\">
	<B>$title</B>&nbsp;<a href=\"javascript:void(0)\" onclick=\"oc('$js_title2');oc('$js_title');\">" .
		html_image('tech/bul100.gif') . 
	"</a></td>
	</tr>
	</table></div>";


	echo "

	<div id=\"$title\">
	<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" height=\"21\" width=\"100%\">
	<tr>
    <td width=\"19\" bgcolor=\"#BF4343\" align=\"center\"><img src=\"".constant('LOC_IMAGES')."spacer.gif\" width=\"3\"><img src=\"".constant('LOC_IMAGES')."tech/bul040.gif\" width=\"13\" height=\"14\"><img src=\"".constant('LOC_IMAGES')."spacer.gif\" width=\"3\"></td>
    <td width=\"10\" align=\"center\" bgcolor=\"#727272\"><img src=\"".constant('LOC_IMAGES')."spacer.gif\" width=\"10\"></td>
    <td nowrap=\"nowrap\" bgcolor=\"#727272\"><div class=\"tit1\">
		<b>$title</b>&nbsp;<a href=\"javascript:void(0)\" onclick=\"oc('$js_title2');oc('$js_title');\"><img src=\"".constant('LOC_IMAGES')."tech/bul101.gif\" border=0></a>
	</td>
    <td width=\"10\" align=\"center\" bgcolor=\"#727272\">&nbsp;</td>
	<td bgcolor=\"#A4A4A4\" width=\"100%\">
    </tr></table>
		
	<table border=\"0\" cellpadding=\"5\" width=\"100%\" align=\"center\" cellspacing=\"0\">
	";

	echo "<SCRIPT language=\"javascript\">";
	if (!$show) {
		echo "oc('$js_title2');";
	} else {
		echo "oc('$js_title');";
	}
	echo "</SCRIPT>";
	
}

function redirect_button($value, $url, $name="button") {
	return "<input type=\"button\" name=\"$name\" value=\"$value\" onclick=\"javascript:top.center.location='$url'\">";
}

/*****************************************************
	function table_footer

-----DESCRIPTION: -----------------------------------
	Produce the table footer to close a table started by table_header.

-----ARGUMENTS: -------------------------------------
	submit		[Optional] Displayed value of the submit button (if any)
	align		[Optional] Alignment of the button
	extra		[Optional] Additional text to show next to the Submit button
	nospace		[Optional] [T/F] Do NOT produce a <br /> tag after the table close tag
	js			[Optional] Additional JS to fire on form submission.
	submitname	[Optional] Name of the submit button.

-----RETURNS:----------------------------------------
	None; directly generates output.

*****************************************************/

function table_footer ($submit='', $align='center', $extra='', $nospace='', $js='', $submitname = 'submit') {

	if (!$align) {
		$align = 'center';
	}

	if ($submit OR $extra) {

		if ($submit) {
			$submit = "<input type=\"submit\" name=\"$submitname\" value=\"$submit\"$js>";
		}
	
		echo "<tr align=\"$align\"><td colspan=\"50\" class=\"footerCell\">";
		echo "&nbsp;&nbsp;$extra&nbsp;&nbsp;$submit</td></tr>" . iff($submit, "</form>") . "</table>";
	
	} else {
		echo "<tr align=\"$align\"><td colspan=\"50\">&nbsp;&nbsp;$extra</td></tr></table>";
	}

	echo "</div>";

	if (!$nospace) {
		echo "<br />";
	}

}

/*****************************************************
	function table_content

-----DESCRIPTION: -----------------------------------
	Generate HTML content of a table started by table_header

-----ARGUMENTS: -------------------------------------
	columns			An array containing the names of columns defined in the next argument
	rows			An array containing individual rows of data (each row should be an array)
	lines			[Optional] An array containing additional rows; row keys here matching row keys in 
					the "rows" argument are displayed as expandable detail rows
	class			*** Deprecated -- to be removed ***
	top_html		[Optional] Additional row of HTML to display before any rows (including the
					"columns" row
	bottomline		[Optional] Additional row of HTML to display as an expandable row at the bottom of the table.
	width			[Optional] An array of widths (element count should match the number of columns)
	secondrow		[Optional] Additional content below the columns

-----RETURNS:----------------------------------------
	None; directly generates output

*****************************************************/

function table_content($columns, $rows, $lines='', $class='', $top_html='', $bottomline='', $width='', $secondrow='') {
	
	// expand arrays if bottomline specified
	if (is_array($bottomline)) {
		$javascript = "<SCRIPT>\n";
		while (list ($key, $val) = each ($rows)) {
			if (count($rows[$key]) != 1) {
				if (trim($bottomline[$key]) != '') {
					$key_image1 = $key . 'image1';
					$key_image2 = $key . 'image2';
					array_unshift($rows[$key], "<img align=\"center\" id=\"$key_image1\" src=\"" . constant('LOC_IMAGES') . "tech/bul101.gif\" onclick=\"oc('$key');oc('$key_image1');oc('$key_image2');\"><img align=\"center\" id=\"$key_image2\" src=\"" . constant('LOC_IMAGES') . "tech/bul100.gif\" onclick=\"oc('$key');oc('$key_image1');oc('$key_image2');\">");
					$javascript .= "oc('$key');oc('$key_image1')\n";
				} else {
					array_unshift($rows[$key], "&nbsp;");
				}
			}
		}
		$javascript .= "</SCRIPT>";
		reset($rows);
	}
	
	// find max cols
	if (is_array($rows)) {
		while (list($key1,$val1) = each($rows)) {
			if (count($val1) > $cols) {
				$cols=count($val1);
			}
		}
		
		reset($rows);
	}

	// columns might be greater max cols
	if (count($columns) > $cols) {
		$cols = count($columns);
	}
	
	// allow something before start of internal table
	if ($top_html != "") {
		echo "<tr><td colspan=\"$cols\">$top_html</td></tr>";
	}
	
	// generate columns (top row)
	if (is_array($columns)) {
		echo "\n<tr class=\"headerRow\">\n	";
		// if we have bottom row add that
		if (is_array($bottomline)) {
			echo "<td width=\"15\" class=\"headerLeftCell\">&nbsp;</td>\n";
			$count = false;
		} else {
			$count = true;
		}
		while (list ($key, $val) = each ($columns)) {
			if ($count) {
				echo "<td class=\"headerLeftCell\"><span class=\"headerText\">$val</span></th>\n";
			} else {
				echo "<td class=\"headerCell\"><span class=\"headerText\">$val</span></th>\n";
			}
			$count = false;
		}

		echo "\n</tr>";
	}
	
	if (!$rows) {
		return;
	}
	
	// generate the rows
	while (list ($key, $val) = each ($rows)) {
		
		// create the row including extra row is $lines is specified
		if ($x==1) {
			if ($lines[$key]) {
				echo "\n<tr class=\"normalRow\">\n	<td colspan=\"$cols\" class=\"normalCellalt1\">$lines[$key]</td></tr>";
			}
			echo  "\n<tr class=\"normalRow\">";
			$x=0;
		} else {
			if ($lines[$key]) {
				echo "\n<tr class=\"normalRow\">\n	<td colspan=\"$cols\" class=\"normalCellalt2\">$lines[$key]</td></tr>";
			}
			echo "\n<tr class=\"normalRow\">\n	";
			$x=1;
		}
		
		// colspan if not all cols avaliable
		$col2 = count($val);
		if ($col2 < $cols) {
			$colspan = $cols/$col2;
		}

		if (is_array($val)) {
			while (list ($key2, $val2) = each ($val)) {
				// extra settings
				if (is_array($class)) {
					$td_extra .= " class = \"$class[$i]\"";
				} else {
					if ($x==1) {
						$td_extra .= " class=\"normalCellalt2\"";
					} else {
						$td_extra .= " class=\"normalCellalt1\"";
					}
				}
				if ($colspan) {
					$td_extra .= " colspan=\"$colspan\"";
				}

				if ((is_array($width)) AND ($cols != $colspan)) {
					$td_extra .= " width = \"$width[$td_count]\"";
				}
				
				$td_count++;
				give_default($val2, '&nbsp;');
				echo "\n<td$td_extra>$val2</td>";
				unset($td_extra);
				$i++;
				
			}
			unset($colspan);
			// just one column
		} else {
			if ($colspan) {
				$td_extra .= " colspan=\"$colspan\"";
			}
			$one_column = 1;
			echo "\n<td$td_extra" . iff($x, " class=\"normalCellalt1\">", " class=\"normalCellalt2\">") . "$val</td>";
		}
		
		echo "\n</tr>";

		$td_count = 0;

		// general second line if specified
		if ($secondrow[$key]) {
			
			if ($bottomline[$key]) { // extra table column
				$bottom_extra = "<td" . iff($x, " class=\"normalCellalt1\">", " class=\"normalCellalt2\">") . "></td>";
			}

			give_default($secondrow[$key], '&nbsp;');
			if ($x == 1) {
				echo "\n<tr>$bottom_extra\n	<td colspan=\"$cols\" class=\"normalCellalt2\">$secondrow[$key] sdsdf</td></tr>";
			} else {
				echo "\n<tr>$bottom_extra\n	<td colspan=\"$cols\" class=\"normalCellalt1\">$secondrow[$key]</td></tr>";
			}
		}

		// generate bottom line if specified
		if (trim($bottomline[$key]) != '') {
			if ($x == 1) {
				echo "\n<tr id=\"$key\" class=\"normalCellalt1\">\n<td colspan=\"$cols\" class=\"normalCellalt2\">$bottomline[$key]</td></tr>";
			} else {
				echo "\n<tr id=\"$key\" class=\"normalCellalt2\">\n<td colspan=\"$cols\" class=\"normalCellalt1\">$bottomline[$key]</td></tr>";
			}
		}

			echo "<tr class=\"borderCell\">";
			if ($one_column) {
			?>
				<td height="1" class="borderCell"><img src="<?php echo constant('LOC_IMAGES'); ?>spacer.gif" width="1" height="1"></td><?php
			} else {
				?>
				 <td height="1" class="borderCell" colspan="30"><img src="<?php echo constant('LOC_IMAGES'); ?>spacer.gif" width="1" height="1"></td>
				 <?php
			}
		
			echo "</tr>";
			unset($one_column);
	}
	
	// end table
	echo $javascript;
	
}

/*****************************************************
	function js_linespan

-----DESCRIPTION: -----------------------------------
	Correct line spanning issues in JS strings.

-----ARGUMENTS: -------------------------------------
	text	Text to correct

-----RETURNS:----------------------------------------
	Corrected text usable in JavaScript

*****************************************************/

function js_linespan($text) {

	$text = str_replace("\n\r","\\r\\n", $text);
	$text = str_replace("\r\n","\\r\\n", $text);
	$text = str_replace("\n","\\r\\n", $text);
	$text = str_replace("\r","\\r\\n", $text);

	return $text;
}

/*****************************************************
	function nopermission

-----DESCRIPTION: -----------------------------------
	Display a "no permission" error page

-----ARGUMENTS: -------------------------------------
	message		Message to display

-----RETURNS:----------------------------------------
	None; directly generates output and exits

*****************************************************/

function nopermission($message='') {

	if (defined('ADMIN_ZONE')) {
		admin_header();
	}

	if (defined('TECH_ZONE')) {
		tech_nav();
	}

	echo "<br /><br />";

	if ($message) {
		echo table_border("<center><b>You do not have permission to $message</b><br /><br />If you believe this is an error, please contact your helpdesk admin</center>");
	} else {
		echo table_border("<center><b>You do not have permission to complete that action</b><br /><br />If you believe this is an error, please contact your helpdesk admin</center>");
	}
	
	exit();
}

/*****************************************************
	function mistake

-----DESCRIPTION: -----------------------------------
	Display an general error page.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -