Dictionnary.class.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * Manage application and plugins lists with key/value pair.
  4. *
  5. * @author valentin carruesco
  6. *
  7. * @category Core
  8. *
  9. * @license copyright
  10. */
  11. class Dictionnary extends Entity
  12. {
  13. public $id,$slug,$label,$parent,$state;
  14. protected $fields =
  15. array(
  16. 'id' => 'key',
  17. 'slug' => 'string',
  18. 'label' => 'longstring',
  19. 'parent' => 'int',
  20. 'state' => 'int',
  21. );
  22. public function __construct()
  23. {
  24. parent::__construct();
  25. }
  26. public static function childs($slug, $sort = 'label ASC')
  27. {
  28. $obj = new self();
  29. $childs = array();
  30. $parent = $obj->load(array('slug' => $slug));
  31. if (!$parent) {
  32. return $childs;
  33. }
  34. foreach ($obj->loadAll(array('parent' => $parent->id), $sort) as $child) {
  35. $childs[$child->id] = $child;
  36. }
  37. return $childs;
  38. }
  39. public static function table($slug)
  40. {
  41. $obj = new self();
  42. $parent = $obj->load(array('slug' => $slug));
  43. echo '<div class="table_list_'.$slug.'" data-list="'.$parent->id.'">
  44. <label for="config_application_table"></label>
  45. <table id="" class="table table-striped table-bordered table-hover">
  46. <thead>
  47. <tr>
  48. <th colspan="2">'.$parent->label.'</th>
  49. </tr>
  50. <tr>
  51. <th>Ajouter : <input style="margin:0;width:80%;height:inherit;box-sizing:border-box;padding:5px;" type="text"></th>
  52. <th style="width:50px;text-align:center;"><div class="btn btn-mini btn-success"><i class="fa fa-plus"></i></div></th>
  53. </tr>
  54. </thead>
  55. <tbody>
  56. <tr style="display:none" data-id="{{id}}">
  57. <td>{{label}}</td>
  58. <td>
  59. <div class="btn btn-mini btnEdit"><i class="fa fa-pencil"></i></div>
  60. <div class="btn btn-mini btn-danger"><i class="fa fa-times"></i></div>
  61. </td>
  62. </tr>
  63. </tbody></table>
  64. </div>';
  65. }
  66. }