Dictionnary.class.php 1.7 KB

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