dtable.class.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. /**
  3. * Dtable class.
  4. *
  5. * @copyright Copyright 2009-2022 QingDao Nature Easy Soft Network Technology Co,LTD (www.cnezsoft.com)
  6. * @author guanxiying <guanxiying@easycorp.ltd>
  7. * @package
  8. * @license LGPL
  9. * @version $Id$
  10. * @Link https://www.zentao.net
  11. */
  12. class dtable
  13. {
  14. /**
  15. * Options of dtable.
  16. */
  17. public $options;
  18. /**
  19. * cols of dtable options.
  20. */
  21. public $cols;
  22. /**
  23. * data of dtable options.
  24. */
  25. public $data;
  26. /**
  27. * Init cols.
  28. *
  29. * @param array $cols
  30. * @access public
  31. * @return object $this
  32. */
  33. public function colInit($cols)
  34. {
  35. $this->cols = $cols;
  36. return $this;
  37. }
  38. /**
  39. * colSet
  40. *
  41. * @param string $colName
  42. * @param object $col
  43. * @access public
  44. * @return object $this
  45. */
  46. public function colSet($colName, $col)
  47. {
  48. $this->cols->$colName = $col;
  49. return $this;
  50. }
  51. /**
  52. * Delete one col.
  53. *
  54. * @param string $colName
  55. * @access public
  56. * @return object
  57. */
  58. public function colDelete($colName)
  59. {
  60. unset($this->cols->$colName);
  61. return $this;
  62. }
  63. /**
  64. * set col attr.
  65. *
  66. * @param string $colName
  67. * @param string $property
  68. * @param mixed $value
  69. * @access public
  70. * @return object
  71. */
  72. public function colAttr($colName, $property, $value)
  73. {
  74. if(!isset($this->cols->$colName)) $this->cols->$colName = new stdClass;
  75. $this->cols->{$colName}->{$property} = $value;
  76. return $this;
  77. }
  78. /**
  79. * dataInit
  80. *
  81. * @param array $data
  82. * @access public
  83. * @return object
  84. */
  85. public function dataInit($data)
  86. {
  87. $this->data = $data;
  88. return $this;
  89. }
  90. /**
  91. * dataAappend
  92. *
  93. * @param object $row
  94. * @access public
  95. * @return object
  96. */
  97. public function dataAappend($row)
  98. {
  99. $this->data[] = $row;
  100. return $this;
  101. }
  102. /**
  103. * dataSet
  104. *
  105. * @param string $index
  106. * @param object $data
  107. * @access public
  108. * @return object
  109. */
  110. public function dataSet($index, $data)
  111. {
  112. $this->data[$index] = $data;
  113. return $this;
  114. }
  115. /**
  116. * dataBatchSet
  117. *
  118. * @param mixed $scope [1,2,3,4] | all
  119. * @param object $data
  120. * @access public
  121. * @return object
  122. */
  123. public function dataBatchSet($scope, $data)
  124. {
  125. if($scope == 'all') $scope = array_keys($this->data);
  126. foreach($scope as $index) $this->data[$index] = $data;
  127. return $this;
  128. }
  129. /**
  130. * Get dtable options.
  131. *
  132. * @access public
  133. * @return object
  134. */
  135. public function getOptions($extra)
  136. {
  137. $this->options = new stdClass;
  138. $this->options->cols = $this->cols;
  139. $this->options->data = $this->data;
  140. return $this->options;
  141. }
  142. /**
  143. * Show dtable codes.
  144. *
  145. * @access public
  146. * @return string
  147. */
  148. public function show()
  149. {
  150. }
  151. }