Guest User

Untitled

a guest
Jul 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. <?php
  2. require_once '../system/config.php';
  3. require_once '../system/functions.php';
  4. require_once '../system/classes/database.php';
  5. require_once '../system/classes/page.php';
  6.  
  7. require_once '../system/classes/tables.php';
  8.  
  9. $tableid = (isset($_GET['tableid'])&&!empty($_GET['tableid'])?$_GET['tableid']:1);
  10. $tabid = $_GET['tab'];
  11.  
  12. $dB = new dataBase;
  13. $dB->dbConnect();
  14.  
  15. $table = new tables($dB);
  16.  
  17. /**
  18. * Table Action[s]
  19. */
  20. if ($tabid=='create') {
  21.  
  22. $tableid = $table->create_table($_POST['table_name']);
  23.  
  24. header("Location: ".buildLink('tables.php', array('tableid'=>$tableid,'tab'=>'properties'), array()));
  25. exit;
  26.  
  27. }elseif($tabid=='changekey') {
  28.  
  29. $table->update_primarykey($tableid,$_POST);
  30.  
  31. header("Location: ".buildLink('tables.php', array('tableid'=>$tableid,'tab'=>'fields'), array()));
  32. exit;
  33.  
  34. }elseif ($tabid=='fields') {
  35.  
  36. if ($_POST) {
  37.  
  38. }
  39.  
  40. /**
  41. * Field List - Table & Select
  42. */
  43. $fields = $table->get_fields($tableid);
  44. $arr_fields = array();
  45. $arr_fieldselect = array();
  46. if (count($fields)>0) {
  47. foreach ($fields as $key=>$value) {
  48. array_push($arr_fields, '
  49. <tr>
  50. <td>'.format_nth_num($key+1).'</td>
  51. <td><a href="">'.$value['field_name'].'</a> '.($value['primary_key']?'<img src="images/key_icon.png" width="20" height="10">':'').'</td>
  52. <td>'.$value['field_type'].'</td>
  53. <td>'.$value['numeric_id'].'</td>
  54. <td><input type="checkbox" name="searchable['.$value['numeric_id'].']" id="searchable'.$value['numeric_id'].'" value="1"'.($value['searchable']?' checked="checked"':'').'></td>
  55. <td>'.($value['editable']?'<input type="button" name="btn_delete" id="bn_delete" class="stdButton" value="Delete">':'').'</td>
  56. </tr>
  57. ');
  58.  
  59. if($value['editable'] || $value['field_type']=='Record ID#') array_push($arr_fieldselect, '<option value="'.$value['numeric_id'].'"'.($value['primary_key']?' selected="selected"':'').'>'.$value['field_name'].'</option>');
  60. }
  61. }
  62.  
  63. $tabid=2; $tab='fields';
  64. $custom_tags = array(
  65. 'form_url' => buildLink('tables.php', array(), array()),
  66. 'fieldlist' => join("\n", $arr_fields),
  67. 'fieldselect' => join("\n", $arr_fieldselect)
  68. );
  69.  
  70. }elseif ($tabid=='forms') {
  71.  
  72. $tabid=3; $tab='forms';
  73. $custom_tags = array(
  74.  
  75. );
  76.  
  77. }elseif ($tabid=='reports') {
  78.  
  79. $tabid=4; $tab='reports';
  80. $custom_tags = array(
  81.  
  82. );
  83.  
  84. }elseif ($tabid=='permissions') {
  85.  
  86. $tabid=5; $tab='permissions';
  87. $custom_tags = array(
  88.  
  89. );
  90.  
  91. } else { //properties
  92.  
  93. if ($_POST) {
  94. $table->update_properties($tableid,$_POST);
  95. header("Location: ".buildLink('tables.php', array(), array()));
  96. exit;
  97. }
  98.  
  99. $properties = $table->get_properties($tableid);
  100.  
  101. $tabid=1; $tab='properties';
  102. $custom_tags = array(
  103. 'form_url' => buildLink('tables.php', array(), array()),
  104. 'table_name' => $properties['table_name'],
  105. 'description' => $properties['description']
  106. );
  107.  
  108. }
  109.  
  110. /**
  111. * Get Table List
  112. */
  113. $tables = $table->get_tables();
  114. $arr_tables = array();
  115. if (count($tables)>0) {
  116. foreach ($tables as $key=>$value) {
  117. array_push($arr_tables, '<li'.($tableid==$value['numeric_id']?' class="selected_table"':'').'><a href="'.buildLink('tables.php', array('tableid'=>$value['numeric_id']), array()).'">'.$value['table_name'].'</a></li>');
  118. }
  119. }
  120.  
  121. $tags = array(
  122. 'tablelist' => join("\n", $arr_tables),
  123. 'tabid'.$tabid => ' class="current"',
  124. 'tab' => '../'.TEMPLATE_DIR.'/tab_'.$tab.'.php',
  125. 'properties_url' => buildLink('tables.php', array('tab'=>'properties'), array()),
  126. 'fields_url' => buildLink('tables.php', array('tab'=>'fields'), array()),
  127. 'forms_url' => buildLink('tables.php', array('tab'=>'forms'), array()),
  128. 'reports_url' => buildLink('tables.php', array('tab'=>'reports'), array()),
  129. 'permissions_url' => buildLink('tables.php', array('tab'=>'permissions'), array())
  130. );
  131.  
  132. $tags = array_merge($tags, $custom_tags);
  133.  
  134. $page = new Page('tables', 1);
  135. $page->header('header');
  136.  
  137. $page->replace_tags($tags);
  138.  
  139. $page->output();
  140. $page->footer('footer');
  141. ?>
Add Comment
Please, Sign In to add comment