[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: etemplate/inc class.db_tools.inc.php,1.14,1.15
From: |
Ralf Becker <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: etemplate/inc class.db_tools.inc.php,1.14,1.15 |
Date: |
Tue, 22 Apr 2003 19:22:59 -0400 |
Update of /cvsroot/phpgroupware/etemplate/inc
In directory subversions:/tmp/cvs-serv7468
Modified Files:
class.db_tools.inc.php
Log Message:
some fixes:
- content / code after the table_definition in tables_current.inc.php (like in
phpgwapi) is now preserved
- $setup_info[<app>]['tables'][] = <table>; syntaxt in setup.inc.php is now
supported on adding tables, cause the other syntax with one array still works
- hiting [write table] without any change does no longer give u an empty table
- moved all reset($arr); while (list($k,$v) = each($arr)) to foreach
Index: class.db_tools.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/etemplate/inc/class.db_tools.inc.php,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -r1.14 -r1.15
*** class.db_tools.inc.php 18 Mar 2003 13:06:27 -0000 1.14
--- class.db_tools.inc.php 22 Apr 2003 23:22:57 -0000 1.15
***************
*** 39,42 ****
--- 39,44 ----
);
var $types = array(
+ 'varchar' => 'varchar',
+ 'int' => 'int',
'auto' => 'auto',
'blob' => 'blob',
***************
*** 45,54 ****
'decimal' => 'decimal',
'float' => 'float',
- 'int' => 'int',
'longtext' => 'longtext',
'text' => 'text',
'timestamp' => 'timestamp',
// 'abstime' => 'abstime (mysql:timestamp)',
- 'varchar' => 'varchar'
);
var $setup_header = '<?php
--- 47,54 ----
***************
*** 56,59 ****
--- 56,60 ----
* phpGroupWare - Setup *
* http://www.phpgroupware.org *
+ * Created by eTemplates DB-Tools written by address@hidden *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
***************
*** 83,89 ****
if ($lang_on_messages)
{
! reset($this->messages);
! while(list($key,$msg) = each($this->messages))
$this->messages[$key] = lang($msg);
}
}
--- 84,91 ----
if ($lang_on_messages)
{
! foreach($this->messages as $key => $msg)
! {
$this->messages[$key] = lang($msg);
+ }
}
}
***************
*** 130,134 ****
$this->read($this->app,$this->data);
! for (reset($this->data); list($name,$table) =
each($this->data); )
{
$table_names[$name] = $name;
--- 132,136 ----
$this->read($this->app,$this->data);
! foreach($this->data as $name => $table)
{
$table_names[$name] = $name;
***************
*** 297,302 ****
$this->tables_identical($this->data[$posted_table],$edited_table))
{
! $this->app = $new_app;
! $this->data = array();
return False; // continue edit
}
--- 299,307 ----
$this->tables_identical($this->data[$posted_table],$edited_table))
{
! if ($new_app != $this->app) // are we
changeing the app, or hit the user just write
! {
! $this->app = $new_app; // if we change
init the data empty
! $this->data = array();
! }
return False; // continue edit
}
***************
*** 502,507 ****
$def = "array($tabs".($tabs ? "\t" : '');
! reset($arr);
! for ($n = 0; list($key,$val) = each($arr); ++$n)
{
if (!$only_vals)
--- 507,512 ----
$def = "array($tabs".($tabs ? "\t" : '');
! $n = 0;
! foreach($arr as $key => $val)
{
if (!$only_vals)
***************
*** 528,531 ****
--- 533,537 ----
$def .= ",$tabs".($tabs ? "\t" : '');
}
+ ++$n;
}
$def .= "$tabs)";
***************
*** 550,553 ****
--- 556,563 ----
{
$header = fread($f,filesize($file));
+ if ($end = strpos($header,');'))
+ {
+ $footer = substr($header,$end+3);
// this preservs other stuff, which should not be there
+ }
$header =
substr($header,0,strpos($header,'$phpgw_baseline'));
fclose($f);
***************
*** 574,578 ****
$def .= ";\n";
! fwrite($f,$header . $def);
fclose($f);
--- 584,588 ----
$def .= ";\n";
! fwrite($f,$header . $def . $footer);
fclose($f);
***************
*** 629,633 ****
if ($setup_info[$app]['tables']) // if
there is already tables array, update it
{
! $fnew =
eregi_replace("(.*\\$"."setup_info\\['$app'\\]\\['tables'\\][ \\t]*=[
\\t]*array\()[^)]*","\\1$tables",$fnew);
}
else // add the tables array
--- 639,677 ----
if ($setup_info[$app]['tables']) // if
there is already tables array, update it
{
! $fnew =
eregi_replace("(.*\\$"."setup_info\\['$app'\\]\\['tables'\\][ \\t]*=[
\\t]*array\()[^)]*","\\1$tables",$fwas=$fnew);
!
! if ($fwas == $fnew) // nothing
changed => tables are in single lines
! {
! $fwas = explode("\n",$fwas);
! $fnew = $prefix = '';
! $stage = 0; // 0 = before,
1 = in, 2 = after tables section
! foreach($fwas as $line)
! {
! if
(eregi("(.*\\$"."setup_info\\['$app'\\]\\['tables'\\]\\[[ \\t]*\\][ \\t]*=[
\\t]*)'",$line,$parts))
! {
! if ($stage ==
0) // first line of tables-section
! {
! $stage
= 1;
! $prefix
= $parts[1];
! }
! }
! else
// not in table-section
! {
! if ($stage ==
1) // first line after tables-section ==> add it
! {
! $tables
= explode(',',$tables);
! foreach
($tables as $table)
! {
!
$fnew .= $prefix . $table . ";\n";
! }
! $stage
= 2;
! }
! if
(strpos($line,'?>') === False) // dont write the closeing tag
! {
! $fnew
.= $line . "\n";
! }
! }
! }
! }
}
else // add the tables array
***************
*** 719,724 ****
function remove_from_array(&$arr,$value)
{
! reset($arr);
! while (list($key,$val) = each($arr))
{
if ($val == $value)
--- 763,767 ----
function remove_from_array(&$arr,$value)
{
! foreach($arr as $key => $val)
{
if ($val == $value)
***************
*** 734,739 ****
$tables = '';
! reset($old);
! while (list($name,$table_def) = each($old))
{
if (!isset($current[$name])) // table $name
droped
--- 777,781 ----
$tables = '';
! foreach($old as $name => $table_def)
{
if (!isset($current[$name])) // table $name
droped
***************
*** 745,751 ****
$tables .= ($tables ? ',' : '') .
"'$name'";
- reset($table_def['fd']);
$new_table_def = $table_def;
! while(list($col,$col_def) =
each($table_def['fd']))
{
if
(!isset($current[$name]['fd'][$col])) // column $col droped
--- 787,792 ----
$tables .= ($tables ? ',' : '') .
"'$name'";
$new_table_def = $table_def;
! foreach($table_def['fd'] as $col =>
$col_def)
{
if
(!isset($current[$name]['fd'][$col])) // column $col droped
***************
*** 768,784 ****
}
}
! @reset($this->changes[$name]);
! while (list($col,$new_col) =
@each($this->changes[$name]))
{
! if ($new_col != '**deleted**')
{
!
$old[$name]['fd'][$new_col] = $old[$name]['fd'][$col]; // to be able to detect
further changes of the definition
!
unset($old[$name]['fd'][$col]);
}
}
}
}
! reset($current);
! while(list($name,$table_def) = each($current))
{
if (!isset($old[$name])) // table $name
added
--- 809,826 ----
}
}
! if (is_array($this->changes[$name]))
{
! foreach($this->changes[$name]
as $col => $new_col)
{
! if ($new_col !=
'**deleted**')
! {
!
$old[$name]['fd'][$new_col] = $old[$name]['fd'][$col]; // to be able to detect
further changes of the definition
!
unset($old[$name]['fd'][$col]);
! }
}
}
}
}
! foreach($current as $name => $table_def)
{
if (!isset($old[$name])) // table $name
added
***************
*** 793,798 ****
$old_norm =
$this->normalize($old[$name]);
$new_norm =
$this->normalize($table_def);
! reset($table_def['fd']);
! while (list($col,$col_def) =
each($table_def['fd']))
{
if (($add =
!isset($old[$name]['fd'][$col])) || // column $col added
--- 835,839 ----
$old_norm =
$this->normalize($old[$name]);
$new_norm =
$this->normalize($table_def);
! foreach($table_def['fd'] as $col =>
$col_def)
{
if (($add =
!isset($old[$name]['fd'][$col])) || // column $col added
***************
*** 823,828 ****
$all_props =
array('type','precision','nullable','default');
! reset($table['fd']);
! while (list($col,$props) = each($table['fd']))
{
$table['fd'][$col] = array(
--- 864,868 ----
$all_props =
array('type','precision','nullable','default');
! foreach($table['fd'] as $col => $props)
{
$table['fd'][$col] = array(
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: etemplate/inc class.db_tools.inc.php,1.14,1.15,
Ralf Becker <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] CVS: phpgwapi/inc class.common.inc.php,1.200,1.201 class.nextmatchs.inc.php,1.55,1.56 functions.inc.php,1.170,1.171
- Next by Date:
[Phpgroupware-cvs] CVS: phpgroupware archiveTemplate.php,1.1.2.1,1.1.2.2
- Previous by thread:
[Phpgroupware-cvs] CVS: phpgwapi/inc class.common.inc.php,1.200,1.201 class.nextmatchs.inc.php,1.55,1.56 functions.inc.php,1.170,1.171
- Next by thread:
[Phpgroupware-cvs] CVS: phpgroupware archiveTemplate.php,1.1.2.1,1.1.2.2
- Index(es):