Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once '../system/config.php';
- require_once '../system/functions.php';
- require_once '../system/classes/database.php';
- require_once '../system/classes/page.php';
- require_once '../system/classes/tables.php';
- $tableid = (isset($_GET['tableid'])&&!empty($_GET['tableid'])?$_GET['tableid']:1);
- $tabid = $_GET['tab'];
- $dB = new dataBase;
- $dB->dbConnect();
- $table = new tables($dB);
- /**
- * Table Action[s]
- */
- if ($tabid=='create') {
- $tableid = $table->create_table($_POST['table_name']);
- header("Location: ".buildLink('tables.php', array('tableid'=>$tableid,'tab'=>'properties'), array()));
- exit;
- }elseif($tabid=='changekey') {
- $table->update_primarykey($tableid,$_POST);
- header("Location: ".buildLink('tables.php', array('tableid'=>$tableid,'tab'=>'fields'), array()));
- exit;
- }elseif ($tabid=='fields') {
- if ($_POST) {
- }
- /**
- * Field List - Table & Select
- */
- $fields = $table->get_fields($tableid);
- $arr_fields = array();
- $arr_fieldselect = array();
- if (count($fields)>0) {
- foreach ($fields as $key=>$value) {
- array_push($arr_fields, '
- <tr>
- <td>'.format_nth_num($key+1).'</td>
- <td><a href="">'.$value['field_name'].'</a> '.($value['primary_key']?'<img src="images/key_icon.png" width="20" height="10">':'').'</td>
- <td>'.$value['field_type'].'</td>
- <td>'.$value['numeric_id'].'</td>
- <td><input type="checkbox" name="searchable['.$value['numeric_id'].']" id="searchable'.$value['numeric_id'].'" value="1"'.($value['searchable']?' checked="checked"':'').'></td>
- <td>'.($value['editable']?'<input type="button" name="btn_delete" id="bn_delete" class="stdButton" value="Delete">':'').'</td>
- </tr>
- ');
- 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>');
- }
- }
- $tabid=2; $tab='fields';
- $custom_tags = array(
- 'form_url' => buildLink('tables.php', array(), array()),
- 'fieldlist' => join("\n", $arr_fields),
- 'fieldselect' => join("\n", $arr_fieldselect)
- );
- }elseif ($tabid=='forms') {
- $tabid=3; $tab='forms';
- $custom_tags = array(
- );
- }elseif ($tabid=='reports') {
- $tabid=4; $tab='reports';
- $custom_tags = array(
- );
- }elseif ($tabid=='permissions') {
- $tabid=5; $tab='permissions';
- $custom_tags = array(
- );
- } else { //properties
- if ($_POST) {
- $table->update_properties($tableid,$_POST);
- header("Location: ".buildLink('tables.php', array(), array()));
- exit;
- }
- $properties = $table->get_properties($tableid);
- $tabid=1; $tab='properties';
- $custom_tags = array(
- 'form_url' => buildLink('tables.php', array(), array()),
- 'table_name' => $properties['table_name'],
- 'description' => $properties['description']
- );
- }
- /**
- * Get Table List
- */
- $tables = $table->get_tables();
- $arr_tables = array();
- if (count($tables)>0) {
- foreach ($tables as $key=>$value) {
- 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>');
- }
- }
- $tags = array(
- 'tablelist' => join("\n", $arr_tables),
- 'tabid'.$tabid => ' class="current"',
- 'tab' => '../'.TEMPLATE_DIR.'/tab_'.$tab.'.php',
- 'properties_url' => buildLink('tables.php', array('tab'=>'properties'), array()),
- 'fields_url' => buildLink('tables.php', array('tab'=>'fields'), array()),
- 'forms_url' => buildLink('tables.php', array('tab'=>'forms'), array()),
- 'reports_url' => buildLink('tables.php', array('tab'=>'reports'), array()),
- 'permissions_url' => buildLink('tables.php', array('tab'=>'permissions'), array())
- );
- $tags = array_merge($tags, $custom_tags);
- $page = new Page('tables', 1);
- $page->header('header');
- $page->replace_tags($tags);
- $page->output();
- $page->footer('footer');
- ?>
Add Comment
Please, Sign In to add comment