我看你的代码中有时有大段的HTML代码,又不喜欢在模板中用逻辑,不知这东东能否帮得上一点忙.
[PHP]
<?php
/*
$Id: block.php,v 1.1.1.1 2003/08/14 07:59:06 nickle Exp $
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
生成html代码之table代码类
整理:lwg888
*/
if ( !defined( "__CLASS_TABLEBLOCK__" ) ) {
define( "__CLASS_TABLEBLOCK__", 1 );
class TableBlock {
var $width;
var $cellspacing;
var $cellpadding;
var $border;
var $parameters;
var $row_parameters;
var $data_parameters;
function TableBlock( $width = '100%', $cellspacing = '2', $cellpadding = '1', $border = 0, $parameters = '',$row_parameters = '', $data_parameters = '' )
{
$this->width = $width;
$this->cellspacing = $cellspacing;
$this->cellpadding = $cellpadding;
$this->border = $border;
$this->parameters = $parameters;
$this->row_parameters = $row_parameters;
$this->data_parameters = $data_parameters;
}
function createTable( $contents )
{
$tableBox_string = '';
$form_set = false;
if ( isset( $contents['form'] ) ) {
$tableBox_string .= $contents['form'] . "\n";
$form_set = true;
array_shift( $contents );
}
$tableBox_string .= '
parameters ) ) $tableBox_string .= ' ' . $this->parameters;
$tableBox_string .= '>' . "\n";
for ( $i = 0, $n = sizeof( $contents ); $i < $n; $i++ ) {
$tableBox_string .= ' row_parameters ) ) $tableBox_string .= ' ' . $this->row_parameters;
if ( isset( $contents[$i]['params'] ) && !empty( $contents[$i]['params'] ) ) $tableBox_string .= ' ' . $contents[$i]['params'];
$tableBox_string .= '>' . "\n";
if ( isset( $contents[$i][0] ) && is_array( $contents[$i][0] ) ) {
for ( $x = 0, $y = sizeof( $contents[$i] ); $x < $y; $x++ ) {
if ( !empty( $contents[$i][$x]['text'] ) ) {
$tableBox_string .= ' | data_parameters ) ) {
$tableBox_string .= ' ' . $this->data_parameters;
}
$tableBox_string .= '>';
if ( !empty( $contents[$i][$x]['form'] ) ) $tableBox_string .= $contents[$i][$x]['form'];
$tableBox_string .= $contents[$i][$x]['text'];
if ( !empty( $contents[$i][$x]['form'] ) ) $tableBox_string .= '';
$tableBox_string .= ' | ' . "\n";
}
}
} else {
$tableBox_string .= ' data_parameters ) ) {
$tableBox_string .= ' ' . $this->data_parameters;
}
$tableBox_string .= '>' . $contents[$i]['text'] . ' | ' . "\n";
}
$tableBox_string .= '
' . "\n";
}
$tableBox_string .= '
' . "\n";
if ( $form_set == true ) $tableBox_string .= '' . "\n";
return $tableBox_string;
}
} //end function
} //end class
?>
[/PHP]