Main Page   Compound List   File List   Compound Members   File Members  

Pgtable Class Reference

the main class that is used to create the web interface to a postgresql database More...

List of all members.

Public Methods

 Pgtable ($db_conn,$configFile,$user='',$group='',$configSchema='')
 initialize pgtable object

 sort_field ()
 reorder the table, how $indexPriority specify

 set_priority ($priority=0,$schema=false,$table=false,$field=false)
 set the priority of a column and reorder columns

 set_perms_priority ($tbSchema,$tbName)
 set default perms and priority number of a table

 set_defaults ($tbSchema,$tbName)
 set defaults variable when a new table is initialized

 add_table ($tbSchema,$tbName,$pkey=false)
 initialize a new table

 join_child ($schemaParent='public',$parent,$parentcol,$chemaChild='public',$child,$childcol)
 join an existent parent table with its childs, adding links down view/edit pages

 join_parent ($schemaChild='public',$child,$childcol,$schemaParent='public',$parent,$parentcol,$schema='public',$query="",$type="popup",$when=array('search', 'view', 'preSearch', 'new', 'edit'))
 join an existent child table with its parent,

 alter_parent ($schemaChild,$child,$childcol,$arr=array())
 change parent references attributes. Used to alter default values of prelinked tables(for examples type or to specify a query)

 auto_join ($tbSchema,$tbName,$field,$when)
 called when neccesary from internal functions to set form defaults or similar

 auto_join_query ($tbSchema,$tbName,$when)
 called when neccesary from internal functions to set query with joins

 operator ($name,$type='',$defVal=false)
 return appropriate html code for an operator

 delete ($tbSchema,$tbName)
 called when the html button 'Delete' is clicked

 update ($tbSchema,$tbName)
 called when the html button 'Save' is clicked (only save modified data)

 copy ($tbSchema,$tbName)
 called when the html button 'Copy' is clicked

 insert ($tbSchema,$tbName)
 called when the html button 'Insert' is clicked (only insert new data)

 pre_search_new ($tbSchema,$tbName)
 called when the html button 'new search' is clicked

 pre_search_modify ($tbSchema,$tbName)
 called when the html button 'modify search' is clicked

 pre_search ($tbSchema,$tbName,$new=true)
 called when frrom pre_search_modify and pre_search_new functions

 view ($tbSchema,$tbName)
 called when the html button 'View' is clicked

 edit ($tbSchema,$tbName)
 called when the html button 'edit' or 'insert' is clicked

 pre_insert ($tbSchema,$tbName)
 called when the html button 'new insert' is clicked

 view_edit ($tbSchema,$tbName,$when,&$datain)
 called from others functions

 order ($tbSchema,$tbName,$field)
 for order links in search table

 actions ($tbSchema,$tbName,$field,$num,$pkey,$refLink=array(),$type="checkbox")
 add links for each records to modify, delete, view and child subtables if exists

 export ($tbSchema,$tbName)
 called when the html button 'export' is clicked, export current selected records in dbf

 search ($tbSchema,$tbName,$export=false)
 called when the html button 'search' is clicked

 parse_data_in (&$arr,$when='')
 parse submitted data

 parse_data_out ($when,$tbSchema,$tbName)
 parse output data hash, from a bidimensional array of values(corespond to a part of postgres table), create a html table structured in a bidimensinal hash

 form_sub ($tbSchema,$tbName,$field,$num,$when,$def)
 called for each field, to make an appropriate input form

 view_sub ($tbSchema,$tbName,$field,$num,$when,$def)
 called for each field, to view its value in an appropriate parsed mode

 alter_display ($schema,$table,$fields=false,$value=true,$when=array("new","edit","search","view","preSearch","export"))
 set when a column is displayed or not

 alter_type ($tbSchema="public",$tbName,$tbField,$type,$proprieties=false,$change_propriety=true,$where=false)
 change type of a field

 file_url ($file,$lobject=false,$mimeType='')
 file_view ($linkName,$link,$thumbnail,$mimeType)
 switch_actions ($tbSchema='public',$tbName)
 main function

 switch_edit ($tbSchema,$tbName)
 get_table ()
 to be called to know how table is requested

 search_bar ($searchUrl=false,$previousUrl=false,$nextUrl=false,$otherUrl=false,$total=false,$offset=false,$limit=false,$numPages=false,$nameOffset)
 submit ($tbSchema,$tbName,$arr)

Public Attributes

 db
 pkey
 ref
 inh
 perms
 priority
 form
 data
 links
 actions
 user
 group
 configSchema
 operator
 indexPriority
 errors
 messages
 STRINGS


Detailed Description

the main class that is used to create the web interface to a postgresql database

Parameters:
db  Pgdb object, to interface with postgresql db
pkey  name of column to use as a pkey ($pkey[schema][table]=column)
ref  hash of references to other tables
inh  if a table inherits other tables
perms  not used, to manage perms in the future
priority  table priority, not used
form  html form informations
actions  array of action allowed (edit, insert....)
operator  array of operator for each pseudotype
user  not used
group  not used
configSchema  not used
indexPriotity  priority priority of column, if must be reorder from postgres column order ($priority[schema][table][column]=number)
erros  Pgmessage object
messages  Pgmessage object
STRINGS  array of strings, form multilanguage support

Definition at line 45 of file pgtable.php.


Constructor & Destructor Documentation

Pgtable::Pgtable   db_conn,
  configFile,
  user = '',
  group = '',
  configSchema = ''
 

initialize pgtable object

Parameters:
db_conn  valid postgresql connection (the returned value of pg_connect() function)
configFile  ini file in wich there are set some variables as icons urls etc.
users  not used
group  not used
configSchema  not used
Returns:

Definition at line 83 of file pgtable.php.

References configSchema, data, db, errors, form, group, messages, perms, priority, STRINGS, and user.


Member Function Documentation

Pgtable::actions   tbSchema,
  tbName,
  field,
  num,
  pkey,
  refLink = array(),
  type = "checkbox"
 

add links for each records to modify, delete, view and child subtables if exists

Parameters:
tbSchema  schema name of the table
tbName  table name
field  column name
num  line number of current sets of records
pkey  pkey value of current record
refLink  hash to manage refernces to subtables
type=  "checkbox" if use a checkbox or a hidden input type
Returns:
html code

Definition at line 801 of file pgtable.php.

References title.

Pgtable::add_table   tbSchema,
  tbName,
  pkey = false
 

initialize a new table

Parameters:
tbSchema  schema of table
tbName  table name
pkey  the primary key column of the table

Definition at line 254 of file pgtable.php.

References db, inh, pkey, ref, set_defaults(), and set_perms_priority().

Pgtable::alter_display   schema,
  table,
  fields = false,
  value = true,
  when = array("new", "edit", "search", "view", "preSearch", "export")
 

set when a column is displayed or not

Note:
to call before alter_type if alter_type is called!!!
Parameters:
tbSchema  schema name of the table
tbName  table name
field  column name, or arrays of column names, or false if all the columns
value=true  if true view selected columns, if false hide they
when  when apply current changes (new, edit, search...) it could be an array

Definition at line 1383 of file pgtable.php.

References table.

Pgtable::alter_parent   schemaChild,
  child,
  childcol,
  arr = array()
 

change parent references attributes. Used to alter default values of prelinked tables(for examples type or to specify a query)

Parameters:
schemaChild  schema of child table
child  child table
childcol  child table column
arr  hash with this facoltative keys: table, field, query, type=>(popup or select), when=>array('search', 'view', 'preSearch', 'insert', 'edit')
Note:
$query must is a valid sql query that returns two columns, first mast be renamed (with AS sintax) as "OID" , the second as $field. First must correspond to values to insert in $tbName.$field and second as a label of this.
$query must have no semicolon

Definition at line 323 of file pgtable.php.

References ref.

Pgtable::alter_type   tbSchema = "public",
  tbName,
  tbField,
  type,
  proprieties = false,
  change_propriety = true,
  where = false
 

change type of a field

Parameters:
tbSchema=  'public' schema name
tbName  table name
tbField  field name
type  new type to change, eg "file" or "lobject" to store files directly into the database
proprieties  : array for file or lobject types: it could be contain key as: maxsize (in byte) type (it could be an array, and is matched with mime-type) mime_type_col (column of the same table in wich send mime_type of the file) name_col (column of the same table in wich send filename) size_col (column of the same table in wich send file size in byte) thumbnail_col (column of the same table of type oid in wich send thumbnail) thumbnail_size (size in pixel of thumbnail) exif_col (column of the same table in wich send exif info of the image) mime_type (if you would insert a unique type of file, and so mime_type_col and type are not necessary )
change_propriety  if alter display array
where=false  if change only form or attribs array or both

Definition at line 1423 of file pgtable.php.

Pgtable::auto_join   tbSchema,
  tbName,
  field,
  when
 

called when neccesary from internal functions to set form defaults or similar

Parameters:
when  when this function is called (search, insert, edit....)

Definition at line 334 of file pgtable.php.

References db, form, pkey, ref, STRINGS, and table.

Pgtable::auto_join_query   tbSchema,
  tbName,
  when
 

called when neccesary from internal functions to set query with joins

Parameters:
when  when this function is called (search, insert, edit....)

Definition at line 367 of file pgtable.php.

References db, form, pg_escape_string(), pkey, ref, search(), table, and view().

Pgtable::copy   tbSchema,
  tbName
 

called when the html button 'Copy' is clicked

Parameters:
tbSchema  schema name of the table
tbName  table name
Returns:
bidimensional array, that corespond to html table

Definition at line 519 of file pgtable.php.

Referenced by set_defaults().

Pgtable::delete   tbSchema,
  tbName
 

called when the html button 'Delete' is clicked

Parameters:
tbSchema  schema name of the table
tbName  table name

Definition at line 454 of file pgtable.php.

References array_unset().

Pgtable::edit   tbSchema,
  tbName
 

called when the html button 'edit' or 'insert' is clicked

Parameters:
tbSchema  schema name of the table
tbName  table name
Returns:
bidimensional array, that corespond to html table

Definition at line 624 of file pgtable.php.

Referenced by join_parent(), and set_defaults().

Pgtable::export   tbSchema,
  tbName
 

called when the html button 'export' is clicked, export current selected records in dbf

Parameters:
tbSchema  schema name of the table
tbName  table name
Returns:
file link

Definition at line 862 of file pgtable.php.

Pgtable::file_url   file,
  lobject = false,
  mimeType = ''
 

Definition at line 1479 of file pgtable.php.

Pgtable::file_view   linkName,
  link,
  thumbnail,
  mimeType
 

Definition at line 1492 of file pgtable.php.

Pgtable::form_sub   tbSchema,
  tbName,
  field,
  num,
  when,
  def
 

called for each field, to make an appropriate input form

Parameters:
tbSchema  schema name of the table
tbName  table name
field  column name
num  line number of current sets of records
when  when is calles(search, edit, insert...)
def  current value of the field

Definition at line 1209 of file pgtable.php.

Pgtable::get_table  
 

to be called to know how table is requested

Returns:
list(schemaname, tablename, primary key)

Definition at line 1702 of file pgtable.php.

Pgtable::insert   tbSchema,
  tbName
 

called when the html button 'Insert' is clicked (only insert new data)

Parameters:
tbSchema  schema name of the table
tbName  table name

Definition at line 530 of file pgtable.php.

Referenced by set_defaults().

Pgtable::join_child   schemaParent = 'public',
  parent,
  parentcol,
  chemaChild = 'public',
  child,
  childcol
 

join an existent parent table with its childs, adding links down view/edit pages

Note:
if db is created with foeing key or references commandes, this is called automatically
Parameters:
schemaParent  schema of parent table
parent  parent table
parentcol  parent table column
schemaChild  schema of child table
child  child table
childcol  child table column

Definition at line 285 of file pgtable.php.

References ref, and table.

Pgtable::join_parent   schemaChild = 'public',
  child,
  childcol,
  schemaParent = 'public',
  parent,
  parentcol,
  schema = 'public',
  query = "",
  type = "popup",
  when = array('search', 'view', 'preSearch', 'new', 'edit')
 

join an existent child table with its parent,

Note:
if db is created with foeing key or references commandes, this is called automatically and a popup window is opened when necessary. In this case, for small parent references, it is somtimes better use a select list of possible values: see alter_parent() function for this.
Parameters:
schemaChild  schema of child table
child  child table
childcol  child table column
schemaParent  schema of parent table
parent  parent table
parentcol  parent table column
query  valid sql query that select all valid childs
Note:
$query must is a valid sql query that returns two columns, first mast be renamed (with AS sintax) as "OID" , the second as $field. First must correspond to values to insert in $tbName.$field and second as a label of this.
$query must have no semicolon
Parameters:
type=  'popup' or 'select' : the first open a new window, the second make a select menu(DONT USE THIS FOR LONG TABLES!!|)
when=array  ('search', 'view', 'preSearch', 'insert', 'edit') when join

Definition at line 307 of file pgtable.php.

References edit(), ref, search(), table, and view().

Pgtable::operator   name,
  type = '',
  defVal = false
 

return appropriate html code for an operator

Parameters:
name  html input name value
type  type of current field(int, text...)
defVal=  '' default value

Definition at line 423 of file pgtable.php.

References html_select().

Pgtable::order   tbSchema,
  tbName,
  field
 

for order links in search table

Parameters:
tbSchema  schema name of the table
tbName  table name
field  column name
Returns:
html code

Definition at line 771 of file pgtable.php.

References arr_to_url(), and title.

Pgtable::parse_data_in &$    arr,
  when = ''
 

parse submitted data

Note:
because of recursion of query, the fallowing functions must works also if is called more than once on the same data : so dont coud for example add a constant string to a parameter because in some cases it adds more times the same string....
Parameters:
arr  hash to parse
when  when is calles(search, edit, insert...)

Definition at line 1072 of file pgtable.php.

References table.

Pgtable::parse_data_out   when,
  tbSchema,
  tbName
 

parse output data hash, from a bidimensional array of values(corespond to a part of postgres table), create a html table structured in a bidimensinal hash

Parameters:
when  when is calles(search, edit, insert...)
tbSchema  schema of table
tbName  table name

Definition at line 1142 of file pgtable.php.

Pgtable::pre_insert   tbSchema,
  tbName
 

called when the html button 'new insert' is clicked

Parameters:
tbSchema  schema name of the table
tbName  table name
Returns:
bidimensional array, that corespond to html table

Definition at line 637 of file pgtable.php.

Pgtable::pre_search   tbSchema,
  tbName,
  new = true
 

called when frrom pre_search_modify and pre_search_new functions

Parameters:
tbSchema  schema name of the table
tbName  table name
new  if is a new query
Returns:
bidimensional array, that corespopnd to html table

Definition at line 585 of file pgtable.php.

Pgtable::pre_search_modify   tbSchema,
  tbName
 

called when the html button 'modify search' is clicked

Parameters:
tbSchema  schema name of the table
tbName  table name
Returns:
bidimensional array, that corespond to html table

Definition at line 572 of file pgtable.php.

Pgtable::pre_search_new   tbSchema,
  tbName
 

called when the html button 'new search' is clicked

Parameters:
tbSchema  schema name of the table
tbName  table name
Returns:
bidimensional array, that corespond to html table

Definition at line 560 of file pgtable.php.

Pgtable::search   tbSchema,
  tbName,
  export = false
 

called when the html button 'search' is clicked

Parameters:
tbSchema  schema name of the table
tbName  table name
export=false 
Returns:
bidimensional array corespond to html table if $export=false, sql query if $export=true

Definition at line 884 of file pgtable.php.

References array_unset(), getmicrotime(), transpose(), and where_sql().

Referenced by auto_join_query(), join_parent(), and set_defaults().

Pgtable::search_bar   searchUrl = false,
  previousUrl = false,
  nextUrl = false,
  otherUrl = false,
  total = false,
  offset = false,
  limit = false,
  numPages = false,
  nameOffset
 

Definition at line 1717 of file pgtable.php.

Pgtable::set_defaults   tbSchema,
  tbName
 

set defaults variable when a new table is initialized

Parameters:
tbSchema  schema of table
tbName  table name

Definition at line 214 of file pgtable.php.

References actions, copy(), db, edit(), form, insert(), perms, search(), and view().

Referenced by add_table().

Pgtable::set_perms_priority   tbSchema,
  tbName
 

set default perms and priority number of a table

Parameters:
schema  schema of table
table  table name

Definition at line 168 of file pgtable.php.

References db, indexPriority, and sort_field().

Referenced by add_table().

Pgtable::set_priority   priority = 0,
  schema = false,
  table = false,
  field = false
 

set the priority of a column and reorder columns

Parameters:
priority  integer vvalue
schema  schema of table
table  table name
field  column name

Definition at line 152 of file pgtable.php.

References indexPriority, priority, and table.

Referenced by sort_field().

Pgtable::sort_field  
 

reorder the table, how $indexPriority specify

Definition at line 139 of file pgtable.php.

References set_priority().

Referenced by set_perms_priority().

Pgtable::submit   tbSchema,
  tbName,
  arr
 

Definition at line 1728 of file pgtable.php.

Pgtable::switch_actions   tbSchema = 'public',
  tbName
 

main function

Parameters:
tbSchema=  'public' schema name
tbName  table name
Returns:
a hash with keys: text: text to display at the bottom of the table search_bar: search bar submit: submit buttons table: html table

Definition at line 1519 of file pgtable.php.

References arr_to_hidden(), html_table(), and search_bar().

Pgtable::switch_edit   tbSchema,
  tbName
 

Definition at line 1676 of file pgtable.php.

Pgtable::update   tbSchema,
  tbName
 

called when the html button 'Save' is clicked (only save modified data)

Parameters:
tbSchema  schema name of the table
tbName  table name

Definition at line 487 of file pgtable.php.

Pgtable::view   tbSchema,
  tbName
 

called when the html button 'View' is clicked

Parameters:
tbSchema  schema name of the table
tbName  table name
Returns:
bidimensional array, that corespond to html table

Definition at line 612 of file pgtable.php.

Referenced by auto_join_query(), join_parent(), and set_defaults().

Pgtable::view_edit   tbSchema,
  tbName,
  when,
&$    datain
 

called from others functions

Parameters:
tbSchema  schema name of the table
tbName  table name
when  when is called (new, edit, search,...)
datain  input data ($_POST or $_GET)
Returns:
bidimensional array, that corespopnd to html table

Definition at line 669 of file pgtable.php.

References arr_to_hidden(), and table.

Pgtable::view_sub   tbSchema,
  tbName,
  field,
  num,
  when,
  def
 

called for each field, to view its value in an appropriate parsed mode

Parameters:
tbSchema  schema name of the table
tbName  table name
field  column name
num  line number of current sets of records
when  when is calles(search, edit, insert...)
def  current value of the field

Definition at line 1311 of file pgtable.php.


Member Data Documentation

Pgtable::actions
 

Definition at line 58 of file pgtable.php.

Referenced by set_defaults().

Pgtable::configSchema
 

Definition at line 62 of file pgtable.php.

Referenced by Pgtable().

Pgtable::data
 

Definition at line 55 of file pgtable.php.

Referenced by Pgtable().

Pgtable::db
 

Definition at line 46 of file pgtable.php.

Referenced by add_table(), auto_join(), auto_join_query(), Pgtable(), set_defaults(), and set_perms_priority().

Pgtable::errors
 

Definition at line 68 of file pgtable.php.

Referenced by Pgtable().

Pgtable::form
 

Definition at line 54 of file pgtable.php.

Referenced by auto_join(), auto_join_query(), Pgtable(), and set_defaults().

Pgtable::group
 

Definition at line 61 of file pgtable.php.

Referenced by Pgtable().

Pgtable::indexPriority
 

Definition at line 66 of file pgtable.php.

Referenced by set_perms_priority(), and set_priority().

Pgtable::inh
 

Definition at line 50 of file pgtable.php.

Referenced by add_table().

Pgtable::links
 

Definition at line 56 of file pgtable.php.

Pgtable::messages
 

Definition at line 69 of file pgtable.php.

Referenced by Pgtable().

Pgtable::operator
 

Definition at line 64 of file pgtable.php.

Pgtable::perms
 

Definition at line 51 of file pgtable.php.

Referenced by Pgtable(), and set_defaults().

Pgtable::pkey
 

Definition at line 48 of file pgtable.php.

Referenced by add_table(), auto_join(), and auto_join_query().

Pgtable::priority
 

Definition at line 52 of file pgtable.php.

Referenced by Pgtable(), and set_priority().

Pgtable::ref
 

Definition at line 49 of file pgtable.php.

Referenced by add_table(), alter_parent(), auto_join(), auto_join_query(), join_child(), and join_parent().

Pgtable::STRINGS
 

Definition at line 70 of file pgtable.php.

Referenced by auto_join(), and Pgtable().

Pgtable::user
 

Definition at line 60 of file pgtable.php.

Referenced by Pgtable().


The documentation for this class was generated from the following file:
Generated on Mon Nov 29 01:21:59 2004 for phpPgWeb by doxygen1.2.18