index e7e7417577007c38224de3bf252150a3777dbb4c..a3ecfb8d5ed2f5f7ef04e1afe34b04e43a008166 100644 (file)
var $a_entries;
var $a_header;
var $b_displayPageNums;
- var $summary;
+ var $s_summary;
var $cols;
var $pageid;
-
+ //FIXME: Ignoring the fact, that they were missing - height and width are numeric...
+ var $s_height;
+ var $s_width;
+
// Members for page managment
var $i_currentPage;
var $i_entriesPerPage;
+ var $force_height = false;
+
// Added php 4 constructor
function divlist($pageid){
$this->i_currentPage = 0;
$this->i_entriesPerPage = 10;
- $this->s_summary = "";
- $this->a_entries = array();
- $this->a_header = array();
+ $this->s_height = "450";
+ $this->s_width = "600";
+ $this->s_summary = "";
+ $this->a_entries = array();
+ $this->a_header = array();
$this->b_displayPageNums= true;
- $this->cols = 0;
- $this->pageid = $pageid ;
-
+ $this->cols = 0;
+ $this->pageid = $pageid;
}
function __destruct(){
function SetHeader($a_headerdata) {
$this->a_header[] = $a_headerdata ;
}
+
+ function SetHeight($s_height) {
+ $this->s_height= $s_height;
+ $this->force_height = true;
+ }
+
+ function SetWidth($s_width) {
+ $this->s_width= $s_width;
+ }
function SetEntriesPerPage($i_num){
$this->i_entriesPerPage=$i_num;
}
function DrawList(){
-
$s_return = "";
-
- $s_return.= "<table summary='".$this->s_summary."' width='600' cellspacing='0'>";
-
- if($this->i_entriesPerPage==0) {
-
- $s_return.= "<thead>".$this->_generateHeader()."</thead>";
-
- // Define an alternate style for IE
- $s_return.= "<!--[if IE]><style type='text/css'>tbody.scrollcontent {overflow-y:scroll;max-height:480px;}</style><![endif]-->";
-
- $s_return.= "<tbody class='scrollcontent'>".$this->_generatePage()."</tbody>";
+ if(!$this->force_height){
+ $s_return.= "<table summary='".$this->s_summary."' style='width:".
+ $this->s_width."px;height:".$this->s_height.
+ "px;' cellspacing='0' id='t_scrolltable'>";
} else {
- $s_return.=$this->_generateHeader();
-
- $s_return.=$this->_generatePage();
+ $s_return.= "<table summary='".$this->s_summary."' style='width:".
+ $this->s_width."px;height:".$this->s_height.
+ "px;' cellspacing='0' id='t_scrolltable_onlywidth'>";
}
- //$s_return.= nl2br(htmlentities($this->_generatePage()));
+
+ $s_return.= $this->_generateHeader();
+ $s_return.=$this->_generatePage();
$s_return.= "</table>";
function _numpages(){
$cnt = count($this->a_entries);
- $tmp = $cnt % $this->i_entriesPerPage;
$pages = (int) ($cnt / $this->i_entriesPerPage);
- if($tmp) $pages ++;
+ if($cnt % $this->i_entriesPerPage){
+ $pages++;
+ }
return $pages;
}
function _numentries(){
- $cnt = count($this->a_entries);
- return $cnt;
+ return count($this->a_entries);
}
function _generateHeader(){
-
$s_return = "";
-
$s_value = "";
$s_key = "";
-
- $s_return .= "\n<tr>";
+
+ // Using scrolltable?
+ if($this->i_entriesPerPage == 0) {
+ if(!$this->force_height) {
+ $s_return.= "\n<tr><td class='scrollhead'><table summary='' style='width:".$this->s_width."px;' cellspacing='0' id='t_scrollhead'>";
+ } else {
+ $s_return.= "\n<tr><td class='scrollhead'><table summary='' style='width:".$this->s_width."px;' cellspacing='0' id='t_scrollhead_onlywidth'>";
+ }
+ }
+
+ $s_return.= "\n<tr>";
- $i_count = count($this->a_header[0])-1;
foreach($this->a_header[0] as $s_key => $s_value ){
if(!isset($s_value['attach'])){
$s_value['attach'] = "";
}
-
- if($i_count == 0) {
- $s_return .= "\n<td class='listheader' style='border-right:0px;border-bottom:1px solid #b0b0b0;'".$s_value['attach'].">".$s_value['string']."</td>";
- } else {
- $s_return .= "\n<td class='listheader' style='border-bottom:1px solid #b0b0b0;'".$s_value['attach'].">".$s_value['string']."</td>";
- }
- $i_count--;
+
+ $s_return.= "\n<td class='listheader' ".$s_value['attach'].">".$s_value['string']."</td>";
+
+ // Increment column counter
+ $this->cols++;
+
}
- // Only create additional column if we're using scrollbars
- if($this->i_entriesPerPage==0) {
- $s_return .= "<td class='listheader' style='border-right:0px;padding:0px;border-bottom:1px solid #b0b0b0;width:16px;'> </td>";
+ // Attach a 13px-wide column (used as scrollbar space in body-table),
+ // but do this only if we are really using scrolltables.
+ if($this->i_entriesPerPage == 0) {
+ $s_return.= "\n<td class='listheader' style='width:13px;border-right:0px;'> </td>";
+ $s_return.= "\n</table></td>";
}
- $s_return .= "\n</tr>";
+
+ $s_return.= "\n</tr>";
return $s_return;
}
$s_value = "";
$s_key = "";
$s_return = "";
-
- $i_alternate=0;
-
+
+ if($this->i_entriesPerPage == 0) {
+ // We need to construct a "body"-table that is width-of-scrollbar thinner than the "head"-table.
+ if(!$this->force_height) {
+ $s_return .= "\n<tr><td colspan='".$this->cols."' class='scrollbody'><div style='width:".$this->s_width."px;height:".($this->s_height-20)."px;' id='d_scrollbody' class='scrollbody'>";
+ $s_return .= "<table summary='' style='height:100%;width:581px;' cellspacing='0' id='t_scrollbody'>";
+ } else {
+ $s_return .= "\n<tr><td colspan='".$this->cols."' class='scrollbody'><div style='width:".$this->s_width."px;height:".($this->s_height-20)."px;' id='d_scrollbody_onlywidth' class='scrollbody'>";
+ $s_return .= "<table summary='' style='height:100%;width:581px;' cellspacing='0' id='t_scrollbody_onlywidth'>";
+ }
+ }
+
+ $i_alternate=0;
if(isset($_GET['start'])){
$_SESSION['start'.$this->pageid]=$_GET['start'];
$start = $_GET['start'];
$start=0;
}
}
-
- if ($this->i_entriesPerPage > 0) {
- while($start > $this->_numentries()){
- $start = $start - $this->i_entriesPerPage;
- }
-
- $stop = $start + $this->i_entriesPerPage;
-
- $appendempty = ($this->_numentries() -$start);
-
- for($i = $start ; $i < $stop;$i++){
-
- if(isset($this->a_entries[$i])){
-
- $s_value = $this->a_entries[$i];
-
-
- if($i_alternate) $i_alternate=0; else $i_alternate=1;
-
- $s_return .= "\n<tr>";
-
- $cnt = 0;
-
- foreach($s_value as $s_key2 => $s_value2 ){
-
- $this->cols = count($s_value) ;
- $cnt++;
-
- if(!isset($s_value2['class'])){
- $class = "list".$i_alternate;
- }else{
- $class = $s_value2['class'];
- }
-
- if(!isset($s_value2['attach'])){
- $style = "";
- }else{
- $style = " ".$s_value2['attach']." " ;
- }
-
- $s_return .= "\n<td ".$style." class='".$class."'>";
- $s_return .= $s_value2['string'];
- $s_return .= "\n</td>";
- }
- if($cnt == 0 ){
- $s_return.="\n<td> </td>";
- }
- $s_return .= "\n</tr>";
- }
- }
+ /* If divlist is empty, append a single white entry */
+ if(count($this->a_entries)==0){
+ $str = $s_return."<tr>";
+ $str.="<td class='list1nohighlight' colspan='".$this->cols."' style='height:100%;border-right:0px;width:100%;'> </td>";
+ $str.="</tr>";
+ if($this->i_entriesPerPage == 0) {
+ $str.="</table></div></td></tr>";
+ }
+ return($str);
+ } else {
+
+ //FIXME: Ahrg. I'd like to read this code without wasting my time.
+ if ($this->i_entriesPerPage > 0) {
+ while($start > $this->_numentries()){
+ $start = $start - $this->i_entriesPerPage;
+ }
+
+ $stop = $start + $this->i_entriesPerPage;
+
+ $appendempty = ($this->_numentries() -$start);
+
+ for($i = $start ; $i < $stop;$i++){
+
+ if(isset($this->a_entries[$i])){
+
+ $s_value = $this->a_entries[$i];
+
+
+ if($i_alternate) $i_alternate=0; else $i_alternate=1;
+
+ $s_return .= "\n<tr>";
+
+ $cnt = 0;
+
+ foreach($s_value as $s_key2 => $s_value2 ){
+
+ $cnt++;
+
+ if(!isset($s_value2['class'])){
+ $class = "list".$i_alternate;
+ }else{
+ $class = $s_value2['class'];
+ }
+
+ if(!isset($s_value2['attach'])){
+ $style = "";
+ }else{
+ $style = " ".$s_value2['attach']." " ;
+ }
+
+ $s_return .= "\n<td ".$style." class='".$class."'>";
+ $s_return .= $s_value2['string'];
+ $s_return .= "\n</td>";
+ }
+ if($cnt == 0 ){
+ $s_return.="\n<td> </td>";
+ }
- if(!(($stop)<$this->_numentries())){
- $nums = $stop - $this->_numentries();// - $stop;
- for($i = 0 ; $i < $nums ; $i ++ ){
- $s_return.="<tr>";
- $cnt=0;
- for($a = 0 ; $a < (count($this->a_header[0])) ; $a ++ ) {
- if($a ==(count($this->a_header[0])-1)){
- $s_return.="\n<td class='list1' style='border:0px;' height='26'> </td>";
- } else {
- $s_return.="\n<td class='list1' height='26'> </td>";
- }
- }
- $s_return.="\n</tr>";
- }
- }
+ $s_return .= "\n</tr>";
+ }
+ }
+
+ if(!(($stop)<$this->_numentries())){
+ $nums = $stop - $this->_numentries();// - $stop;
+ for($i = 0 ; $i < $nums ; $i ++ ){
+ $s_return.="<tr>";
+ $cnt=0;
+ for($a = 0 ; $a < (count($this->a_header[0])) ; $a ++ ) {
+ if($a ==(count($this->a_header[0])-1)){
+ $s_return.="\n<td class='list1' style='border:0px;height:26px;'> </td>";
+ } else {
+ $s_return.="\n<td class='list1' style='height:26px;'> </td>";
+ }
+ }
+ $s_return.="\n</tr>";
+ }
+ }
+
+ if($this->b_displayPageNums){
+ $s_return .= "<tr><td colspan='".$this->cols."' align='center'>".range_selector($this->_numentries(),$start,$this->i_entriesPerPage)."</td></tr>";
+ }
+ } else {
+ // $this->i_entriesPerPage <= 0
+ // We should display all entries on one page
- if($this->b_displayPageNums){
- $s_return .= "<tr><td colspan='".$this->cols."' align='center'>".range_selector($this->_numentries(),$start,$this->i_entriesPerPage)."</td></tr>";
- }
- } else {
- // We should display all entries on one page
- foreach($this->a_entries as $s_key => $s_value){
-
- if($i_alternate){
- $i_alternate=0;
- } else {
- $i_alternate=1;
- }
-
- $s_return .= "\n<tr>";
-
- $cnt = 0;
-
- foreach($s_value as $s_key2 => $s_value2 ){
+ $i = $this->_numEntries();
+ foreach($this->a_entries as $s_key => $s_value){
+ $i--;
- $this->cols = count($s_value) ;
- $cnt++;
+ if($i_alternate!=0){
+ $i_alternate=0;
+ } else {
+ $i_alternate=1;
+ }
+
+ $s_return .= "\n<tr class='rowxp".$i_alternate."'>";
+
+ $cnt = 0;
+
+ foreach($s_value as $s_key2 => $s_value2 ){
- if(!isset($s_value2['class'])){
- $class = "list".$i_alternate;
- } else {
- $class = $s_value2['class'];
- }
+ $this->cols = count($s_value) ;
+ $cnt++;
- if(!isset($s_value2['attach'])){
- $style = "";
- } else {
- $style = " ".$s_value2['attach']." " ;
- }
+ if(!isset($s_value2['class'])){
+ $class = "list".$i_alternate;
+ } else {
+ $class = $s_value2['class'];
+ }
- $s_return .= "\n<td ".$style." class='".$class."'>";
- $s_return .= $s_value2['string'];
- $s_return .= "</td>";
- }
-
- if($cnt == 0 ){
- $s_return.="\n<td> </td>";
- } else {
- //$s_return.="\n<td style='border:0px;padding:0px;' class='list".$i_alternate."'> </td>";
- }
- $s_return .= "\n</tr>";
- }
+ if(!isset($s_value2['attach'])){
+ $style = "";
+ } else {
+ $style = " ".$s_value2['attach']." " ;
+ }
+
+ $s_return .= "\n<td ".$style." class='".$class."'>";
+ $s_return .= $s_value2['string'];
+ $s_return .= "</td>";
+ }
+ $s_return .= "\n</tr>";
+ }
+ }
+
+ // if fewer than 22 Entries (list not full), print row to fill empty space
+ //FIXME: Why 22? Isn't the size dynamic
+# if($this->_numEntries()<=22){
+ $fill= "";
+ for ($i= 1; $i <= $this->cols; $i++){
+ if ($i == $this->cols){
+ $fill.= "<td class='list1nohighlight' style='height:100%;border-right:0px;'> </td>";
+ } else {
+ $fill.= "<td class='list1nohighlight' style='height:100%;'> </td>";
+ }
+ }
+ $s_return.="\n<tr>$fill";
+# }
+ if($this->i_entriesPerPage == 0) {
+ $s_return .= "\n</table></div></td>";
+ }
+ $s_return .= "</tr>";
+ return $s_return;
}
-
- return $s_return;
}
}
+
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
?>