documentation

This commit is contained in:
Sebastian Mendel
2007-03-26 14:48:30 +00:00
parent 86c5e9c277
commit c58cc56041

View File

@@ -18,54 +18,79 @@ $GLOBALS['PMD']['STYLE'] = 'default';
require_once './libraries/relation.lib.php'; require_once './libraries/relation.lib.php';
$cfgRelation = PMA_getRelationsParam(); $cfgRelation = PMA_getRelationsParam();
$script_display_field = "<script>\n var display_field = new Array();\n"; $GLOBALS['script_display_field'] = "<script>\n var display_field = new Array();\n";
function get_tabs() // PMA_DBI /**
* retrieves table info and stores it in $GLOBALS['PMD']
*
* @uses $GLOBALS['script_display_field']
* @uses $GLOBALS['PMD'] to fill it
* @uses $GLOBALS['db']
* @uses PMA_DBI_get_tables_full()
* @uses PMA_DBI_select_db()
* @uses PMA_getDisplayField()
* @uses urlencode()
* @uses htmlspecialchars()
* @uses strtoupper()
* @uses urlencode()
*/
function get_tabs()
{ {
global $db, $script_display_field;
$GLOBALS['PMD']['TABLE_NAME'] = array();// that foreach no error $GLOBALS['PMD']['TABLE_NAME'] = array();// that foreach no error
$GLOBALS['PMD']['OWNER'] = array(); $GLOBALS['PMD']['OWNER'] = array();
$GLOBALS['PMD']['TABLE_NAME_SMALL'] = array(); $GLOBALS['PMD']['TABLE_NAME_SMALL'] = array();
$tables = PMA_DBI_get_tables_full($db); $tables = PMA_DBI_get_tables_full($GLOBALS['db']);
// seems to be needed later // seems to be needed later
PMA_DBI_select_db($db); PMA_DBI_select_db($GLOBALS['db']);
$i = 0; $i = 0;
foreach ($tables as $one_table) { foreach ($tables as $one_table) {
$GLOBALS['PMD']['TABLE_NAME'][$i] = $db . "." . $one_table['TABLE_NAME']; $GLOBALS['PMD']['TABLE_NAME'][$i] = $GLOBALS['db'] . "." . $one_table['TABLE_NAME'];
$GLOBALS['PMD']['OWNER'][$i] = $db; $GLOBALS['PMD']['OWNER'][$i] = $GLOBALS['db'];
$GLOBALS['PMD']['TABLE_NAME_SMALL'][$i] = $one_table['TABLE_NAME']; $GLOBALS['PMD']['TABLE_NAME_SMALL'][$i] = $one_table['TABLE_NAME'];
$GLOBALS['PMD_URL']['TABLE_NAME'][$i] = urlencode($db . "." . $one_table['TABLE_NAME']); $GLOBALS['PMD_URL']['TABLE_NAME'][$i] = urlencode($GLOBALS['db'] . "." . $one_table['TABLE_NAME']);
$GLOBALS['PMD_URL']['OWNER'][$i] = urlencode($db); $GLOBALS['PMD_URL']['OWNER'][$i] = urlencode($GLOBALS['db']);
$GLOBALS['PMD_URL']['TABLE_NAME_SMALL'][$i] = urlencode($one_table['TABLE_NAME']); $GLOBALS['PMD_URL']['TABLE_NAME_SMALL'][$i] = urlencode($one_table['TABLE_NAME']);
$GLOBALS['PMD_OUT']['TABLE_NAME'][$i] = htmlspecialchars($db . "." . $one_table['TABLE_NAME'], ENT_QUOTES); $GLOBALS['PMD_OUT']['TABLE_NAME'][$i] = htmlspecialchars($GLOBALS['db'] . "." . $one_table['TABLE_NAME'], ENT_QUOTES);
$GLOBALS['PMD_OUT']['OWNER'][$i] = htmlspecialchars($db, ENT_QUOTES); $GLOBALS['PMD_OUT']['OWNER'][$i] = htmlspecialchars($GLOBALS['db'], ENT_QUOTES);
$GLOBALS['PMD_OUT']['TABLE_NAME_SMALL'][$i] = htmlspecialchars($one_table['TABLE_NAME'], ENT_QUOTES); $GLOBALS['PMD_OUT']['TABLE_NAME_SMALL'][$i] = htmlspecialchars($one_table['TABLE_NAME'], ENT_QUOTES);
$GLOBALS['PMD']['TABLE_TYPE'][$i] = strtoupper($one_table['ENGINE']); $GLOBALS['PMD']['TABLE_TYPE'][$i] = strtoupper($one_table['ENGINE']);
$DF = PMA_getDisplayField($db, $one_table['TABLE_NAME']); $DF = PMA_getDisplayField($GLOBALS['db'], $one_table['TABLE_NAME']);
if($DF!='') if ($DF != '') {
$script_display_field .= " display_field['" . $GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i] . "'] = '" . urlencode($DF) . "';\n"; $GLOBALS['script_display_field'] .= " display_field['"
. $GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i] . "'] = '"
. urlencode($DF) . "';\n";
}
$i++; $i++;
} }
$script_display_field .= "</script>\n"; $GLOBALS['script_display_field'] .= "</script>\n";
// return $GLOBALS['PMD']; // many bases // not use ?????? // return $GLOBALS['PMD']; // many bases // not use ??????
} }
function get_tab_info() // PMA_DBI //PMA_backquote /**
* retrieves table column info
*
* @uses $GLOBALS['db']
* @uses PMA_DBI_QUERY_STORE
* @uses PMA_DBI_select_db()
* @uses PMA_DBI_query()
* @uses PMA_DBI_num_rows()
* @uses PMA_backquote()
* @uses count()
* @return array table column nfo
*/
function get_tab_info()
{ {
global $db; PMA_DBI_select_db($GLOBALS['db']);
PMA_DBI_select_db($db);
$tab_column = array(); $tab_column = array();
for ( $i=0; $i < sizeof( $GLOBALS['PMD']["TABLE_NAME"] ); $i++ ) { for ($i = 0; $i < count($GLOBALS['PMD']["TABLE_NAME"]); $i++) {
PMA_DBI_select_db($db);
$fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM '.PMA_backquote($GLOBALS['PMD']["TABLE_NAME_SMALL"][$i]), NULL, PMA_DBI_QUERY_STORE); $fields_rs = PMA_DBI_query('SHOW FULL FIELDS FROM '.PMA_backquote($GLOBALS['PMD']["TABLE_NAME_SMALL"][$i]), NULL, PMA_DBI_QUERY_STORE);
$fields_cnt = PMA_DBI_num_rows($fields_rs); $j = 0;
$j=0;
while ($row = PMA_DBI_fetch_assoc($fields_rs)) { while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
$tab_column[$GLOBALS['PMD']['TABLE_NAME'][$i]]['COLUMN_ID'][$j] = $j; $tab_column[$GLOBALS['PMD']['TABLE_NAME'][$i]]['COLUMN_ID'][$j] = $j;
$tab_column[$GLOBALS['PMD']['TABLE_NAME'][$i]]['COLUMN_NAME'][$j] = $row['Field']; $tab_column[$GLOBALS['PMD']['TABLE_NAME'][$i]]['COLUMN_NAME'][$j] = $row['Field'];
@@ -74,36 +99,51 @@ function get_tab_info() // PMA_DBI //PMA_backquote
$j++; $j++;
} }
} }
return $tab_column; return $tab_column;
} }
//-------------------------------------CONTR-----------------------------------------------
function get_script_contr() { /**
global $db; * returns JavaScript code for intializing vars
PMA_DBI_select_db($db); *
* @uses $GLOBALS['db']
* @uses PMA_DBI_QUERY_STORE
* @uses PMA_DBI_select_db()
* @uses PMA_DBI_query()
* @uses PMA_backquote()
* @uses PMA_DBI_fetch_row()
* @uses PMA_getForeigners()
* @uses urlencode()
* @uses count()
* @uses in_array()
* @return string JavaScript code
*/
function get_script_contr()
{
PMA_DBI_select_db($GLOBALS['db']);
$con["C_NAME"] = array(); $con["C_NAME"] = array();
$i = 0; $i = 0;
$alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db), NULL, PMA_DBI_QUERY_STORE); $alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($GLOBALS['db']), NULL, PMA_DBI_QUERY_STORE);
while ($val = @PMA_DBI_fetch_row($alltab_rs)) { while ($val = @PMA_DBI_fetch_row($alltab_rs)) {
$row = PMA_getForeigners($db,$val[0],'','internal'); $row = PMA_getForeigners($GLOBALS['db'], $val[0], '', 'internal');
//echo "<br> internal ".$db." - ".$val[0]." - "; //echo "<br> internal ".$GLOBALS['db']." - ".$val[0]." - ";
//print_r($row ); //print_r($row );
if ($row !== false) { if ($row !== false) {
foreach ($row as $field => $value) { foreach ($row as $field => $value) {
$con['C_NAME'][$i] = ''; $con['C_NAME'][$i] = '';
$con['DTN'][$i] = urlencode($db . "." . $val[0]); $con['DTN'][$i] = urlencode($GLOBALS['db'] . "." . $val[0]);
$con['DCN'][$i] = urlencode($field); $con['DCN'][$i] = urlencode($field);
$con['STN'][$i] = urlencode($value['foreign_db'] . "." . $value['foreign_table']); $con['STN'][$i] = urlencode($value['foreign_db'] . "." . $value['foreign_table']);
$con['SCN'][$i] = urlencode($value['foreign_field']); $con['SCN'][$i] = urlencode($value['foreign_field']);
$i++; $i++;
} }
} }
$row = PMA_getForeigners($db,$val[0],'','innodb'); $row = PMA_getForeigners($GLOBALS['db'], $val[0], '', 'innodb');
//echo "<br> INNO "; //echo "<br> INNO ";
//print_r($row ); //print_r($row );
if ($row !== false) { if ($row !== false) {
foreach ($row as $field => $value) { foreach ($row as $field => $value) {
$con['C_NAME'][$i] = ''; $con['C_NAME'][$i] = '';
$con['DTN'][$i] = urlencode($db.".".$val[0]); $con['DTN'][$i] = urlencode($GLOBALS['db'].".".$val[0]);
$con['DCN'][$i] = urlencode($field); $con['DCN'][$i] = urlencode($field);
$con['STN'][$i] = urlencode($value['foreign_db'].".".$value['foreign_table']); $con['STN'][$i] = urlencode($value['foreign_db'].".".$value['foreign_table']);
$con['SCN'][$i] = urlencode($value['foreign_field']); $con['SCN'][$i] = urlencode($value['foreign_field']);
@@ -114,29 +154,44 @@ function get_script_contr() {
$ti = 0; $ti = 0;
$script_contr = "<script>\n var contr = new Array();\n"; $script_contr = "<script>\n var contr = new Array();\n";
for ( $i=0; $i < sizeof( $con["C_NAME"] ); $i++ ) { for ($i = 0; $i < count($con["C_NAME"]); $i++) {
$script_contr .= " contr[$ti] = new Array();\n"; $js_var = ' contr[' . $ti . ']';
$script_contr .= " contr[$ti]['".$con['C_NAME'][$i]."'] = new Array();\n"; $script_contr .= $js_var . " = new Array();\n";
if (in_array($con['DTN'][$i],$GLOBALS['PMD_URL']["TABLE_NAME"]) && in_array($con['STN'][$i],$GLOBALS['PMD_URL']["TABLE_NAME"])) { $js_var .= "['" . $con['C_NAME'][$i] . "']";
$script_contr .= " contr[$ti]['".$con['C_NAME'][$i]."']['".$con['DTN'][$i]."'] = new Array();\n";$m_col = array();//} $script_contr .= $js_var . " = new Array();\n";
$script_contr .= " contr[$ti]['".$con['C_NAME'][$i]."']['".$con['DTN'][$i]."']['".$con['DCN'][$i]."'] = new Array();\n";//} if (in_array($con['DTN'][$i], $GLOBALS['PMD_URL']["TABLE_NAME"])
$script_contr .= " contr[$ti]['".$con['C_NAME'][$i]."']['".$con['DTN'][$i]."']['".$con['DCN'][$i]."'][0] = '".$con['STN'][$i]."';\n"; // && in_array($con['STN'][$i], $GLOBALS['PMD_URL']["TABLE_NAME"])) {
$script_contr .= " contr[$ti]['".$con['C_NAME'][$i]."']['".$con['DTN'][$i]."']['".$con['DCN'][$i]."'][1] = '".$con['SCN'][$i]."';\n"; // $js_var .= "['" . $con['DTN'][$i] . "']";
$script_contr .= $js_var . " = new Array();\n";
$m_col = array();//}
$js_var .= "['" . $con['DCN'][$i] . "']";
$script_contr .= $js_var . " = new Array();\n";//}
$script_contr .= $js_var . "[0] = '" . $con['STN'][$i] . "';\n"; //
$script_contr .= $js_var . "[1] = '" . $con['SCN'][$i] . "';\n"; //
} }
$ti++; $ti++;
} }
$script_contr .= "</script>\n"; $script_contr .= "</script>\n";
return $script_contr; return $script_contr;
} }
function get_pk_or_unique_keys() { /**
global $db; * @uses $GLOBALS['db']
require_once('./libraries/tbl_indexes.lib.php'); * @uses $GLOBALS['PMD']
* @uses PMA_DBI_select_db()
* @uses PMA_get_indexes()
* @uses PMA_extract_indexes()
* @uses count()
* @return array unique or primary indizes
*/
function get_pk_or_unique_keys()
{
require_once './libraries/tbl_indexes.lib.php';
PMA_DBI_select_db($db); PMA_DBI_select_db($GLOBALS['db']);
$tables_pk_or_unique_keys = array(); $tables_pk_or_unique_keys = array();
for( $I=0; $I<sizeof($GLOBALS['PMD']['TABLE_NAME_SMALL']); $I++) { for ($I = 0; $I < count($GLOBALS['PMD']['TABLE_NAME_SMALL']); $I++) {
$ret_keys = PMA_get_indexes($GLOBALS['PMD']['TABLE_NAME_SMALL'][$I]); $ret_keys = PMA_get_indexes($GLOBALS['PMD']['TABLE_NAME_SMALL'][$I]);
if (! empty($ret_keys)) { if (! empty($ret_keys)) {
// reset those as the function uses them by reference // reset those as the function uses them by reference
@@ -145,7 +200,8 @@ function get_pk_or_unique_keys() {
// for now, take into account only the first index segment // for now, take into account only the first index segment
foreach ($indexes_data as $key_name => $one_index) { foreach ($indexes_data as $key_name => $one_index) {
$column_name = $one_index[1]['Column_name']; $column_name = $one_index[1]['Column_name'];
if (isset($indexes_info[$key_name]) && $indexes_info[$key_name]['Non_unique'] == 0) { if (isset($indexes_info[$key_name])
&& $indexes_info[$key_name]['Non_unique'] == 0) {
$tables_pk_or_unique_keys[$GLOBALS['PMD']['OWNER'][$I] . '.' .$GLOBALS['PMD']['TABLE_NAME_SMALL'][$I] . '.' . $column_name] = 1; $tables_pk_or_unique_keys[$GLOBALS['PMD']['OWNER'][$I] . '.' .$GLOBALS['PMD']['TABLE_NAME_SMALL'][$I] . '.' . $column_name] = 1;
} }
} }
@@ -154,14 +210,25 @@ function get_pk_or_unique_keys() {
return $tables_pk_or_unique_keys; return $tables_pk_or_unique_keys;
} }
function get_all_keys() { /**
global $db; * returns all indizes
require_once('./libraries/tbl_indexes.lib.php'); *
* @uses $GLOBALS['db']
* @uses $GLOBALS['PMD']
* @uses PMA_DBI_select_db()
* @uses PMA_get_indexes()
* @uses PMA_extract_indexes()
* @uses count()
* @return array indizes
*/
function get_all_keys()
{
require_once './libraries/tbl_indexes.lib.php';
PMA_DBI_select_db($db); PMA_DBI_select_db($GLOBALS['db']);
$tables_all_keys = array(); $tables_all_keys = array();
for( $I=0; $I<sizeof($GLOBALS['PMD']['TABLE_NAME_SMALL']); $I++) { for ($I = 0; $I < count($GLOBALS['PMD']['TABLE_NAME_SMALL']); $I++) {
$ret_keys = PMA_get_indexes($GLOBALS['PMD']['TABLE_NAME_SMALL'][$I]); $ret_keys = PMA_get_indexes($GLOBALS['PMD']['TABLE_NAME_SMALL'][$I]);
if (! empty($ret_keys)) { if (! empty($ret_keys)) {
// reset those as the function uses them by reference // reset those as the function uses them by reference
@@ -177,6 +244,12 @@ function get_all_keys() {
return $tables_all_keys; return $tables_all_keys;
} }
/**
* @uses $GLOBALS['PMD']
* @uses count()
* @uses in_array()
* @return array ???
*/
function get_script_tabs() { function get_script_tabs() {
$script_tabs = "<script>\n var j_tabs = new Array();\n"; $script_tabs = "<script>\n var j_tabs = new Array();\n";
for ( $i=0; $i < sizeof( $GLOBALS['PMD']['TABLE_NAME'] ); $i++ ) { for ( $i=0; $i < sizeof( $GLOBALS['PMD']['TABLE_NAME'] ); $i++ ) {
@@ -201,11 +274,12 @@ function get_tab_pos() {
return isset($tab_pos) ? $tab_pos : NULL; return isset($tab_pos) ? $tab_pos : NULL;
} }
function get_owners() { function get_owners()
{
$m = array(); $m = array();
$j = 0; $j = 0;
for ( $i=0; $i < sizeof( $GLOBALS['PMD']["OWNER"] ); $i++ ) { for ($i = 0; $i < count($GLOBALS['PMD']["OWNER"]); $i++) {
if( ! in_array($GLOBALS['PMD']["OWNER"][$i],$m)) { if (! in_array($GLOBALS['PMD']["OWNER"][$i],$m)) {
$m[$j++] = $GLOBALS['PMD']["OWNER"][$i]; $m[$j++] = $GLOBALS['PMD']["OWNER"][$i];
} }
} }