class.checklist.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. # ***** BEGIN LICENSE BLOCK *****
  3. # This file is part of DotClear.
  4. # Copyright (c) 2004 Olivier Meunier and contributors. All rights
  5. # reserved.
  6. #
  7. # DotClear is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # DotClear is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with DotClear; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. #
  21. # ***** END LICENSE BLOCK *****
  22. class checkList
  23. {
  24. var $check = array();
  25. function checkList()
  26. {
  27. }
  28. function addItem($name,$test,$on,$off)
  29. {
  30. $this->check[$name] = array(
  31. 'test' => (($test === NULL) ? NULL : (boolean) $test),
  32. 'on' => $on,
  33. 'off' => $off
  34. );
  35. }
  36. function checkAll()
  37. {
  38. foreach ($this->check as $v) {
  39. if ($v['test'] === false) {
  40. return false;
  41. }
  42. }
  43. return true;
  44. }
  45. function checkItem($name)
  46. {
  47. if (!empty($this->check[$name])) {
  48. return $this->check[$name]['test'];
  49. } else {
  50. return false;
  51. }
  52. }
  53. function checkWarnings()
  54. {
  55. foreach ($this->check as $v) {
  56. if ($v['test'] === NULL) {
  57. return true;
  58. }
  59. }
  60. return false;
  61. }
  62. function getHTML($img_on='',$img_off='',$img_wrn='')
  63. {
  64. $img_on = '<img src="'.$img_on.'" alt="ok" />';
  65. $img_off = '<img src="'.$img_off.'" alt="error" />';
  66. $img_wrn = '<img src="'.$img_wrn.'" alt="warning" />';
  67. $res = '<table summary="Checklist" class="install">';
  68. foreach ($this->check as $k => $v)
  69. {
  70. $ok = $v['test'];
  71. if ($ok === NULL) {
  72. $img = $img_wrn;
  73. $str = $v['off'];
  74. } elseif ($ok == false) {
  75. $img = $img_off;
  76. $str = $v['off'];
  77. } elseif ($ok) {
  78. $img = $img_on;
  79. $str = $v['on'];
  80. }
  81. $res .=
  82. '<tr>'.
  83. '<td valign="top">'.$img.'</td>'.
  84. '<td valign="top">'.$str.'</td>'.
  85. '</tr>';
  86. }
  87. $res .= '</table>';
  88. return $res;
  89. }
  90. }
  91. ?>