📄 xajaxgrid.inc.php
字号:
<?
/**
* xhtml.inc.php :: Main XajaxGrid class file
*
* XajaxGrid version 1.2.1
* copyright (c) 2006 by Jesus Velazquez ( jjvema@yahoo.com )
* http://geocities.com/jjvema/
*
* XajaxGrid is an open source PHP class library for easily creating a grid data
* on web-based Ajax Applications. Using XajaxGrid.
*
* xajax is released under the terms of the LGPL license
* http://www.gnu.org/copyleft/lesser.html#SEC3
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package XajaxGrid
* @version $Id: xajaxGrid.inc.php,v 1.2 2006/09/30 17:15:08 jjvema Exp $
* @copyright Copyright (c) 2006 by Jesus Velazquez
* @license http://www.gnu.org/copyleft/lesser.html#SEC3 LGPL License
*/
/*
* 2007-11-9 澧炲姞addRowSearchMore()鍑芥暟,澧炲姞鎼滅储閫夐」 by solo
*/
/** \brief Class to generate a table dynamically
*
* The ScrollTable class generate dynamically a table
*
* @package XajaxGrid
*/
require_once ('localization.class.php');
if (isset($_SESSION['curuser']['country'])){
$GLOBALS['local_grid']=new Localization($_SESSION['curuser']['country'],$_SESSION['curuser']['language'],'xajaxGrid');
}else
$GLOBALS['local_grid']=new Localization('en','US','xajaxGrid');
class ScrollTable{
/**
* <i>integer</i> Number of columns for the table.
*/
var $n_cols;
/**
* <i>string</i> Row of table to display the search form.
*/
var $search;
/**
* <i>string</i> Content of the table top
*/
var $top;
/**
* <i>string</i> Content of the table headers
*/
var $header;
/**
* <i>string</i> Content of each table row
*/
var $rows;
/**
* <i>string</i> Content of table footer
*/
var $footer;
/**
* <i>string</i> Style for table row
*/
var $rowStyle;
/**
* <i>string</i> Attributes for each table column
*/
var $colAttrib;
/**
* <i>integer</i> It contains the limit of records to show in the SQL sentence executed
*/
var $limit;
/**
* <i>integer</i> It contains the initial record to show in the SQL sentence executed
*/
var $start;
/**
* <i>string</i> It contains the filter of the SQL sentence executed
*/
var $filter;
/**
* <i>integer</i> It contains the total number of rows to show
*/
var $numRowsToShow;
/**
* <i>integer</i> It contains the total number of rows of the SQL sentence executed
*/
var $numRows;
/**
* <i>string</i> It is the content to search in a SQL sentence
*/
var $content;
/**
* <i>string</i> It is the field to organize the data of the table
*/
var $order;
var $exportFlag;
/**
* Constructor.
*
* @param integer $cols: Amount of columns of the table
* @param integer $start: initial record to show
* @param integer $limit: final record to show
* @param string $filter: field name of the database table.
* @param integer $numRows: number of total rows of the search
* @param string $content: content to search
* @param string $order: field to organize the data of the table
*/
function ScrollTable($cols, $start = 0, $limit, $filter = null, $numRows = 0, $content = null, $order = null){
$this->n_cols = $cols;
$this->limit = $limit;
$this->numRows = $numRows;
$this->numRowsToShow = ROWSXPAGE;
$this->start = $start;
$this->top = '<table class="adminlist" border="1">';
$this->rowStyle = "row1";
$this->filter = $filter;
$this->content = $content;
$this->order = $order;
$this->setFooter();
}
/**
* Set a header Table with attributes on the variable "header" of the class.
*
* @param string $class the clas style
* @param array $options array that contain the labels for the headers.
* @param array $attribs array that contain the attributes for the headers.
* @param array $events array that contain the events on this labels.
* @param boolean $edit Flag to determine if column Edit is showed.
* @param boolean $delete Flag to determine if column Delete is showed.
* @return none
*
*/
function setHeader($class,$headers,$attribs,$events,$edit=true,$delete=true,$detail=true){
global $local_grid;
$ind = 0;
$this->header = '
<tr>';
foreach($headers as $value){
$this->header .= '
<th '.$attribs[$ind].' class="'.$class.'">';
// if(!empty($events[$ind])){
// $this->header .= '<a href="?" '.$events[$ind].'>'.$value.'</a>';
// }else{
// $this->header .= $value;
// }
$this->header .= $value;
$this->header .= '
<img src="skin/default/images/asc.png" title="Ascendent" style="cursor: pointer;" '.str_replace("ORDERING","ASC",$events[$ind]).'>
<img src="skin/default/images/desc.png" title="Descendent" style="cursor: pointer;" '.str_replace("ORDERING","DESC",$events[$ind]).'>
</th>';
$ind++;
}
if($edit)
$this->header .= '
<th style="text-align: center" class="'.$class.'" width="5%" nowrap>
'.$local_grid->Translate("edit").'
</th>';
if($delete)
$this->header .= '
<th style="text-align: center" class="'.$class.'" width="5%" nowrap>
'.$local_grid->Translate("delete").'
</th>';
if($detail)
$this->header .= '
<th style="text-align: center" class="'.$class.'" width="5%" nowrap>
'.$local_grid->Translate("detail").'
</th>';
$this->header .= '
</tr>';
}
/**
* Set the attributes for the table columns.
*
* @param array $attribsCols array that contain the attributes for the headers.
* @return none
*
*/
function setAttribsCols($attribsCols){
$this->colAttrib = $attribsCols;
}
/**
* Add each row generates dynamically from database records obtained
*
* @param string $table Table name of data base
* @param array $arr Array with the data extracted in the SQL Sentence
* @param boolen $edit Flag to determine if column Edit is showed.
* @param boolen $delete Flag to determine if column Delete is showed.
* @param string $divName Name div to display the grid.
* @param array $fields Array with all field's name.
* @return none
*
*/
function addRow($table,$arr,$edit=true,$delete=true,$detail=true,$divName="grid",$fields=null){
global $local_grid;
$nameRow = $divName."Row".$arr[0];
$row = '<tr id="'.$nameRow.'" class="'.$this->rowStyle.'" >'."\n";
$ind = 0;
foreach ($arr as $key => $value) {
$nameCell = $nameRow."Col".$ind;
/*
if($key != 'id')
$row .= '<td id="'.$nameCell.'" style="cursor: pointer;" '.$this->colAttrib[$ind-1].' onDblClick="xajax_editField(\''.$table.'\',\''.$fields[$ind-1].'\',\''.$nameCell.'\',\''.$value.'\',\''.$arr[0].'\');return false">'.$value.'</td>'."\n";
$ind++;
}
*/
if($key != 'id')
$row .= '<td id="'.$nameCell.'" style="cursor: pointer;" '.$this->colAttrib[$ind-1].'>'.$value.'</td>'."\n";
$ind++;
}
if($edit)
$row .= '
<td align="center" width="5%" nowrap>
<a href="?" onClick="xajax_edit('.$arr[0].',\''.$table.'\');return false;"><img src="skin/default/images/edit.png" border="0"></a>
</td>';
if($delete)
$row .= '
<td align="center" width="5%" nowrap>
<a href="?" onClick="if (confirm(\''.$local_grid->Translate("delete_confirm").'\')){ xajax_searchFormSubmit(xajax.getFormValues(\'searchForm\'),0,5,\''.$arr[0].'\',\'delete\');}return false;"><img src="skin/default/images/trash.png" border="0"></a>
</td>';
if($detail)
$row .= '
<td align="center" width="5%" nowrap>
<a href="?" onClick="xajax_showDetail(\''.$arr[0].'\');return false;">'.$local_grid->Translate("detail").'</a>
</td>';
$row .= "</tr>\n";
$this->rows .= $row;
if($this->rowStyle == "row0") $this->rowStyle = "row1"; else $this->rowStyle = "row0";
}
/**
* Add each row generates dynamically from database records obtained without Edit and Delete columns
*
* @param string $table Table name of data base
* @param array $arr Array with the data extracted in the SQL Sentence
* @return none
*
*/
function addRow2($table,$arr){
$row = '<tr class="'.$this->rowStyle.'" >';
$ind = 0;
foreach ($arr as $key => $value) {
if($key != 'id')
$row .= '<td '.$this->colAttrib[$ind-1].'>'.$value.'</td>';
$ind++;
}
$row .= "</tr>";
$this->rows .= $row;
if($this->rowStyle == "row0") $this->rowStyle = "row1"; else $this->rowStyle = "row0";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -