NTKListView.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. class NTKListView
  3. {
  4. function NTKListView($id, $cols, $action)
  5. {
  6. $this->id = $id;
  7. $this->cols = $cols;
  8. $this->action = $action;
  9. $this->rows = array();
  10. }
  11. function addLine($cols)
  12. {
  13. $this->rows[] =& $cols;
  14. }
  15. function addLines($rows)
  16. {
  17. for($i = 0; $i < count($rows); $i++)
  18. $this->rows[] =& $rows[$i];
  19. }
  20. function getHtml()
  21. {
  22. $html = "";
  23. $actions = "";
  24. $html .= "<table id=\"$this->id\" class=\"listview\" cellspacing=\"0\">\n";
  25. $html .= "<tr>\n";
  26. $actions .= " onmousedown=\"this.className = 'listview_head_down'\"";
  27. $actions .= " onmouseup=\"this.className = 'listview_head'\"";
  28. $actions .= " onmouseover=\"this.className = 'listview_head_over'\"";
  29. $actions .= " onmouseout=\"this.className = 'listview_head'\"";
  30. for($i = 0; $i < count($this->cols); $i++)
  31. {
  32. $html .= "<td class=\"listview_head\" $actions>\n";
  33. $html .= $this->cols[$i];
  34. $html .= "</td>\n";
  35. }
  36. $html .= "</tr>\n";
  37. $color = False;
  38. $color_actions = "";
  39. $plain_actions = "";
  40. $color_actions .= " onmousedown=\"this.className = 'listview_line_down'\"";
  41. $color_actions .= " onmouseup=\"this.className = 'listview_line_over'\"";
  42. $color_actions .= " onmouseover=\"this.className = 'listview_line_over'\"";
  43. $color_actions .= " onmouseout=\"this.className = 'listview_color_line'\"";
  44. $plain_actions .= " onmousedown=\"this.className = 'listview_line_down'\"";
  45. $plain_actions .= " onmouseup=\"this.className = 'listview_line_over'\"";
  46. $plain_actions .= " onmouseover=\"this.className = 'listview_line_over'\"";
  47. $plain_actions .= " onmouseout=\"this.className = 'listview_plain_line'\"";
  48. for($i = 0; $i < count($this->rows); $i++)
  49. {
  50. if($color)
  51. {
  52. $html .= "<tr class=\"listview_color_line\" $color_actions>\n";
  53. $color = False;
  54. }
  55. else
  56. {
  57. $html .= "<tr class=\"listview_plain_line\"$plain_actions>\n";
  58. $color = True;
  59. }
  60. for($j = 0; $j < count($this->cols); $j++)
  61. {
  62. $html .= "<td onclick=\"".str_replace("%0%", $this->rows[$i][0], $this->action)."\">\n";
  63. $html .= $this->rows[$i][$j];
  64. $html .= "</td>\n";
  65. }
  66. $html .= "</tr>\n";
  67. }
  68. $html .= "<tr class=\"listview_spacer\"><td colspan=\"".count($this->cols)."\">&nbsp;</td></tr>\n";
  69. $html .= "</table>\n";
  70. return $html;
  71. }
  72. }
  73. ?>