function CheckMySQLTables($link)
{
    if (count($_POST) && isset($_POST['mysql_select_tables'])) {
        $_SESSION['plugin_mysql_tables'] = $_POST;
    }
    if (isset($_SESSION['plugin_mysql_tables']) && count($_SESSION['plugin_mysql_tables'])) {
        return true;
    }
    $tbs = GetMySQLTables($link);
    echo "\r\n  <style type=\"text/css\">\r\n  .SelectVisible { display: inline; }\r\n  .SelectHidded { display: none; }\r\n  </style>\r\n  <script type=\"text/javascript\">\r\n  var CurrentTable;\r\n  var CurrentColumn;\r\n  function ShowColumns(from) {\r\n    for (var i=0; i<from.options.length; i++) {\r\n\t\t  var o = from.options[i];\r\n      if (select = document.getElementById('tr_'+o.value)) {\r\n  \t\t  if (o.selected) {\r\n          select.className = 'SelectVisible';\r\n          CurrentTable = o.value;\r\n        }\r\n\t\t    else \r\n\t\t      select.className = 'SelectHidded'; \r\n\t\t  }\r\n    }\r\n  }\r\n  function SelectColumn(id) {\r\n    CurrentColumn = document.getElementById('col_'+id);\r\n  }\r\n  function SetColValue(from) {\r\n    for (var i=0; i<from.options.length; i++) {\r\n\t\t  var o = from.options[i];\r\n\t\t  if (o.selected && CurrentColumn)\r\n        CurrentColumn.value = `'+o.value+'`';\r\n    }\r\n  }\r\n  </script>\r\n  <script type=\"text/javascript\" src=\"select.js\"></script>";
    echo '
  <form method="POST">
  <input type="hidden" name="mysql_select_tables" value="doIt">
  <table class="Insert" cellspacing="0" cellpadding="3" width="80%" style="text-align:left">
  <thead><tr><td colspan="2" class="TitleHeader">Columns Assignment</td></tr></thead>
  <tr>
   <td width="75%" align="left" nowrap="nowrap" valign="top">
   ';
    include_once 'include/SQLiteTableProperties.class.php';
    $prop = new SQLiteTableProperties($GLOBALS['workDb']);
    $prop->getTableProperties($GLOBALS['table']);
    foreach ($prop->infoTable as $key => $col_infos) {
        echo '<label for="' . $col_infos['name'] . '"><input onClick="SelectColumn(this.id);" name="column" id="' . $col_infos['name'] . '" ' . (!$key ? 'checked="checked" ' : '') . 'type="radio">';
        echo '<b>' . htmlentities($col_infos['name']) . '</b> ' . $col_infos['type'] . ' ' . ($col_infos['pk'] ? ' [PK] ' : ' ') . ' ' . ($col_infos['dflt_value'] ? 'default : ' . htmlentities($col_infos['dflt_value']) : '') . '</label><br/>' . "\n";
        echo '<input size="35" name="col_' . $col_infos['name'] . '" id="col_' . $col_infos['name'] . '" type="text" value="" class="text"><br/><br/>';
        if ($key == 0) {
            echo '<script type="text/javascript">SelectColumn("' . $col_infos['name'] . '");</script>';
        }
    }
    echo '
   </td>
   <td align="right" valign="top">
     <table><tr><td nowrap="nowrap" valign="top">Select MySQL Table to <br/>fill destination columns</td>
     <td>
     <select valign="bottom" onChange="ShowColumns(this);" name="mysql_tables[]" multiple="multiple" size="7">
     ';
    foreach ($tbs['tables'] as $tb => $rows) {
        echo "<option value=\"{$tb}\">{$tb} ({$rows})</option>";
    }
    echo '
     </select>
     </td></tr></table><table>';
    if (isset($tbs['columns'])) {
        foreach ($tbs['columns'] as $table => $columns) {
            echo '
  <tr id="tr_' . clean_name($table) . '" class="SelectHidded">
   <td align="right">Base ' . htmlentities($_SESSION['plugin_mysql_base']) . ', table <b>' . htmlentities($table) . '</b><br/>
     <select style="width:300px" onChange="SetColValue(this);return false;" size="10" name="mysql_cols_' . clean_name($table) . '[]" multiple="multiple">';
            foreach ($columns as $col => $infos) {
                echo "<option value=\"{$col}\">{$col} ({$infos})</option>";
            }
            echo '
     </select>
   </td>
  </tr>';
        }
    }
    echo '
  </td></tr></table></td>
  <tr>
   <td colspan="2" align="center"><input type="submit" class="button"></td>
  </tr>
  </table>
  </form>
  ';
    return false;
}
 function getTableProperties($table)
 {
     include_once INCLUDE_LIB . 'SQLiteTableProperties.class.php';
     $O_TableProperties = new SQLiteTableProperties($this->connId, $table);
     $this->tableProperties = $O_TableProperties->getTableProperties();
     return $this->tableProperties;
 }
    /**
     * Display Available Operation
     *
     * @access public	
     */
    function operationView()
    {
        $ModifPropOk = !$GLOBALS['workDb']->isReadOnly() && displayCondition('properties');
        $localTableProp = new SQLiteTableProperties($this->connId);
        $fieldInfo = $localTableProp->getTableProperties($GLOBALS["table"]);
        // build select field
        $fieldList = '<select name="field">';
        foreach ($fieldInfo as $info) {
            $fieldList .= '<option value="' . $info["cid"] . '">' . $info["name"] . '</option>';
        }
        $fieldList .= '</select>';
        echo '<center>
				<table cellspacing="0" width="80%">
					<tr>
						<td>';
        echo '				<form name="Rename" action="main.php" method="POST" target="main">
							<table class="Browse" cellspacing="0" width="100%">
								<thead>
									<tr class="Browse">
										<td colspan=2 align="left" class="tapPropTitle">&nbsp;' . $GLOBALS["traduct"]->get(215) . '</td>
									</tr>
								</thead>' . "\n";
        echo '					<tr>
										<td>&nbsp;<input type="text" name="newName" size=15>&nbsp;</td><td align="right"><input type="submit" value="' . $GLOBALS["traduct"]->get(69) . '" class="button"></td>
									</tr>
							</table>
							<input type="hidden" name="dbsel" value="' . $GLOBALS["dbsel"] . '">
							<input type="hidden" name="table" value="' . $GLOBALS["table"] . '">
							<input type="hidden" name="action" value="' . $GLOBALS["action"] . '">
							<input type="hidden" name="operation_action" value="renameTable">
							</form>';
        echo '			</td>
					</tr>';
        echo '		<tr>
						<td>';
        echo '				<form name="Move" action="main.php" method="POST" target="main">
							<table class="Browse" cellspacing="0" width="100%">
								<thead>
									<tr class="Browse">
										<td colspan=2 align="left" class="tapPropTitle">&nbsp;' . $GLOBALS["traduct"]->get(216) . '</td>
									</tr>
								</thead>' . "\n";
        echo '					<tr>
										<td>&nbsp;' . $this->getDbList() . '.<input type="text" name="moveName" size=15>&nbsp;</td>
										<td align="right"><input type="submit" value="' . $GLOBALS["traduct"]->get(69) . '" class="button"></td>
								</tr>
							</table>
							<input type="hidden" name="dbsel" value="' . $GLOBALS["dbsel"] . '">
							<input type="hidden" name="table" value="' . $GLOBALS["table"] . '">
							<input type="hidden" name="action" value="' . $GLOBALS["action"] . '">
							<input type="hidden" name="operation_action" value="moveTable">
							</form>';
        echo '			</td>
					</tr>';
        echo '		<tr>
						<td>';
        echo '				<form name="Copy" action="main.php" method="POST" target="main">
							<table class="Browse" cellspacing="0" width="100%">
								<thead>
									<tr class="Browse">
										<td colspan=3 align="left" class="tapPropTitle">&nbsp;' . $GLOBALS["traduct"]->get(217) . '</td>
									</tr>
								</thead>' . "\n";
        echo '					<tr>
										<td>&nbsp;' . $this->getDbList($GLOBALS["dbsel"]) . '.<input type="text" name="copyName" size=15>&nbsp;</td>
										<td style="white-space: nowrap">
											<input name="whatToDo" value="structure" style="vertical-align: middle;" type="radio">
											<label>' . $GLOBALS["traduct"]->get(124) . '</label>&nbsp;&nbsp;<br>
											<input name="whatToDo" value="data" checked="checked" style="vertical-align: middle;" type="radio">
											<label>' . $GLOBALS["traduct"]->get(125) . '</label>&nbsp;&nbsp;<br>
											<input name="whatToDo" value="dataonly" style="vertical-align: middle;" type="radio">
											<label>' . $GLOBALS["traduct"]->get(126) . '</label>&nbsp;&nbsp;<br>
											<input name="dropTable" value="true" style="vertical-align: middle;" type="checkbox">
											<label>' . $GLOBALS["traduct"]->get(218) . '</label>&nbsp;&nbsp;<br>
										</td>

										<td align="right"><input type="submit" value="' . $GLOBALS["traduct"]->get(69) . '" class="button"></td>
								</tr>
							</table>
							<input type="hidden" name="dbsel" value="' . $GLOBALS["dbsel"] . '">
							<input type="hidden" name="table" value="' . $GLOBALS["table"] . '">
							<input type="hidden" name="action" value="' . $GLOBALS["action"] . '">
							<input type="hidden" name="operation_action" value="copyTable">
							</form>';
        echo '			</td>
					</tr>
				</table>
				</center>';
    }
<?php

/**
* Web based SQLite management
* Show and manage 'TABLE' properties
* @package SQLiteManager
* @author Frédéric HENNINOT
* @version $Id: tableproperties.php,v 1.21 2006/04/14 15:16:52 freddy78 Exp $ $Revision: 1.21 $
*/
include_once INCLUDE_LIB . 'SQLiteTableProperties.class.php';
$tableProp = new SQLiteTableProperties($workDb);
if (!empty($table)) {
    $tableProp->getTableProperties();
    switch ($action) {
        case '':
        default:
            $tableProp->tablePropView();
            break;
        case 'modify':
        case 'addChamp':
            $tableProp->tableEditForm();
            break;
        case 'save':
        case 'delete':
        case 'addprimary':
        case 'noprimary':
            $tableProp->saveProp();
            break;
        case 'unique':
        case 'index':
            $tableProp->saveKey();