[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/etemplate/inc/ -> class.soetemplate.inc.php (sommaire)

(pas de description)

Poids: 1281 lignes (39 kb)
Inclus ou requis: 1 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

soetemplate:: (28 méthodes):
  soetemplate()
  num2chrs()
  empty_cell()
  new_cell()
  add_child()
  set_grid_rows_cols()
  set_rows_cols()
  init()
  read()
  readfile()
  sql_wildcards()
  search()
  db2obj()
  fix_old_template_format()
  compress_array()
  as_array()
  save()
  delete()
  dump4setup()
  getToTranslate()
  getToTranslateApp()
  writeLangFile()
  import_dump()
  test_import()
  echo_tmpl()
  widget_tree_walk()
  tree_walk()
  getToTranslateCell()


Classe: soetemplate  - X-Ref

Storage Objects: Everything to store and retrive and eTemplate.

eTemplates are stored in the db in table 'phpgw_etemplate' and gets distributed
through the file 'etemplates.inc.php' in the setup dir of each app. That file gets
automatically imported in the db, whenever you show a eTemplate of the app. For
performace reasons the timestamp of the file is stored in the db, so 'new'
eTemplates need to have a newer file. The distribution-file is generated with the
function dump, usually by pressing a button in the editor.
writeLangFile writes an lang-file with all Labels, incorporating an existing one.
Beside a name eTemplates use the following keys to find the most suitable template
for an user (in order of precedence):
1) User-/Group-Id (not yet implemented)
2) preferd languages of the user (templates for all langs have $lang='')
3) selected template: verdilak, ... (the default is called '' in the db, not default)
4) a version-number of the form, eg: '0.9.13.001' (filled up with 0 same size)

soetemplate($name='',$template='',$lang='',$group=0,$version='',$rows=1,$cols=1)   X-Ref
constructor of the class

calls init or read depending on a name for the template is given

param: string $name name of the eTemplate or array with the values for all keys
param: string $template template-set, '' loads the prefered template of the user, 'default' loads the default one '' in the db
param: string $lang language, '' loads the pref. lang of the user, 'default' loads the default one '' in the db
param: int $group id of the (primary) group of the user or 0 for none, not used at the moment !!!
param: string $version version of the eTemplate
param: int $rows initial size of the template, default 1, only used if no name given !!!
param: int $cols initial size of the template, default 1, only used if no name given !!!

num2chrs($num)   X-Ref
generates column-names from index: 'A', 'B', ..., 'AA', 'AB', ..., 'ZZ' (not more!)

param: int $num numerical index to generate name from 1 => 'A'
return: string the name

empty_cell($type='label',$name='',$attributes=null)   X-Ref
constructor for a new / empty cell/widget

nothing fancy so far

param: string $type type of the widget
param: string $name name of widget
param: array $attributes=null array with further attributes
return: array the cell

new_cell($row=False,$type='label',$label='',$name='',$attributes=False)   X-Ref
constructs a new cell in a give row or the last row, not existing rows will be created

param: int $row row-number starting with 1 (!)
param: string $type type of the cell
param: string $label label for the cell
param: string $name name of the cell (index in the content-array)
param: array $attributes other attributes for the cell
return: array a reference to the new cell, use $new_cell = &$tpl->new_cell(); (!)

add_child(&$parent,&$cell)   X-Ref
adds $cell to it's parent at the parent-type spezific location for childs

param: array &$parent referenc to the parent
param: array &$cell cell to add (need to be unset after the call to add_child, as it's a referenc !)

set_grid_rows_cols(&$grid)   X-Ref
initialises internal vars rows & cols from the data of a grid

param: array &$grid to calc rows and cols

set_rows_cols()   X-Ref
initialises internal vars rows & cols from the data of the first (!) grid


init($name='',$template='',$lang='',$group=0,$version='',$rows=1,$cols=1)   X-Ref
initialises all internal data-structures of the eTemplate and sets the keys

param: string $name name of the eTemplate or array with the values for all keys and possibly data
param: string $template template-set or '' for the default one
param: string $lang language or '' for the default one
param: int $group id of the (primary) group of the user or 0 for none, not used at the moment !!!
param: string $version version of the eTemplate
param: int $rows initial size of the template, default 1
param: int $cols initial size of the template, default 1

read($name,$template='default',$lang='default',$group=0,$version='')   X-Ref
reads an eTemplate from the database

param: string $name name of the eTemplate or array with the values for all keys
param: string $template template-set, '' loads the prefered template of the user, 'default' loads the default one '' in the db
param: string $lang language, '' loads the pref. lang of the user, 'default' loads the default one '' in the db
param: int $group id of the (primary) group of the user or 0 for none, not used at the moment !!!
param: string $version version of the eTemplate
return: boolean True if a fitting template is found, else False

readfile()   X-Ref
Reads an eTemplate from the filesystem, the keys are already set by init in read

return: boolean True if a template was found, else False

sql_wildcards($pattern)   X-Ref
Convert the usual *,? wildcards to the sql ones and quote %,_

param: string $pattern
return: string

search($name,$template='default',$lang='default',$group=0,$version='')   X-Ref
Lists the eTemplates matching the given criteria, sql wildcards % and _ possible

param: string $name name of the eTemplate or array with the values for all keys
param: string $template template-set, '' loads the prefered template of the user, 'default' loads the default one '' in the db
param: string $lang language, '' loads the pref. lang of the user, 'default' loads the default one '' in the db
param: int $group id of the (primary) group of the user or 0 for none, not used at the moment !!!
param: string $version version of the eTemplate
return: array of arrays with the template-params

db2obj()   X-Ref
copies all cols into the obj and unserializes the data-array


fix_old_template_format()   X-Ref
test if we have an old/original template-format and fixes it to the new format


compress_array($arr,$remove_objs=false)   X-Ref
all empty values and objects in the array got unset (to save space in the db )

The never empty type field ensures a cell does not disapear completely.
Calls it self recursivly for arrays / the rows

param: array $arr the array to compress
param: boolean $remove_all_objs if true unset all objs, on false use as_array to save only the data of objs
return: array

as_array($data_too=0,$db_keys=false)   X-Ref
returns obj-data/-vars as array

the returned array ($data_too > 0) can be used with init to recreate the template

param: int $data_too -1 = only keys, 0 = no data array, 1 = data array too, 2 = serialize data array,
param: boolean $db_keys use db-column-names or internal names, default false=internal names
return: array with template-data

save($name='',$template='.',$lang='.',$group='',$version='.')   X-Ref
saves eTemplate-object to db, can be used as saveAs by giving keys as params

param: string $name name of the eTemplate or array with the values for all keys
param: string $template template-set
param: string $lang language or ''
param: int $group id of the (primary) group, not used at the moment !!!
param: string $version version of the eTemplate
return: int number of affected rows, 1 should be ok, 0 somethings wrong

delete()   X-Ref
Pas de description

dump4setup($app)   X-Ref
dumps all eTemplates to <app>/setup/etemplates.inc.php for distribution

param: string $app app- or template-name contain app
return: string translated message with number of dumped templates or error-message (webserver has no write access)

getToTranslate()   X-Ref
extracts all texts: labels and helptexts from the cells of an eTemplate-object

some extensions use a '|' to squezze multiple texts in a label or help field

return: array with messages as key AND value

getToTranslateApp($app)   X-Ref
Read all eTemplates of an app an extracts the texts to an array

param: string $app name of the app
return: array with texts

writeLangFile($app,$lang='en',$additional='')   X-Ref
Write new lang-file using the existing one and all text from the eTemplates

param: string $app app- or template-name
param: string $lang language the messages in the template are, defaults to 'en'
param: array $additional extra texts to translate, if you pass here an array with all messages and
return: string translated message with number of messages written (total and new), or error-message

import_dump($app)   X-Ref
Imports the dump-file /$app/setup/etempplates.inc.php unconditional (!)

param: string $app app name
return: string translated message with number of templates imported

test_import($app)   X-Ref
test if new template-import necessary for app and does the import

Get called on every read of a eTemplate, caches the result in phpgw_info.
The timestamp of the last import for app gets written into the db.

param: string $app app- or template-name
return: string translated message with number of templates imported

echo_tmpl($backtrace=true,$no_other_objs=true)   X-Ref
prints/echos the template's content, eg. for debuging

param: boolean $backtrace = true give a function backtrace
param: boolean $no_other_objs = true dump other objs (db, html, ...) too

widget_tree_walk($func,&$extra)   X-Ref
applys a function to each widget in the children tree of the template

The function should be defined as [&]func([&]$widget,[&]$extra[,$path])
If the function returns anything but null or sets $extra['__RETURN__NOW__'] (func has to reference $extra !!!),
the walk stops imediatly and returns that result

Only some widgets have a sub-tree of children: *box, grid, template, ...
For them we call tree_walk($widget,$func,$extra) instead of func direct

param: string/array $func function to use or array($obj,'method')
param: mixed &$extra extra parameter passed to function
return: mixed return-value of func or null if nothing returned at all

tree_walk(&$widget,$func,&$extra,$path='')   X-Ref
applys a function to each child in the tree of a widget (incl. the widget itself)

The function should be defined as [&]func([&]$widget,[&]$extra[,$path]) [] = optional
If the function returns anything but null or sets $extra['__RETURN__NOW__'] (func has to reference $extra !!!),
the walk stops imediatly and returns that result

Only some widgets have a sub-tree of children: *box, grid, template, ...
For performance reasons the function use recursion only if a widget with children contains
a further widget with children.

param: array $widget the widget(-tree) the function should be applied too
param: string/array $func function to use or array($obj,'method')
param: mixed &$extra extra parameter passed to function
param: string $path path of widget in the widget-tree
return: mixed return-value of func or null if nothing returned at all

getToTranslateCell($cell,&$to_trans)   X-Ref
extracts all translatable labels from a widget

param: array $cell the widget
param: array &$to_trans array with (lowercased) label => translation pairs



Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7