[Alba-desarrollo] SVN Alba r5218 - in prosistem/alba/trunk/alba: apps/principal/modules/informes apps/principal/modules/informes/actions apps/principal/modules/informes/config apps/principal/modules/informes/lib apps/principal/modules/informes/templates apps/principal/modules/informes/validate config data/sql lib/model lib/model/map lib/model/om

commits en pressenter.com.ar commits en pressenter.com.ar
Mie Oct 10 22:53:57 CEST 2007


Author: josx
Date: 2007-10-10 17:53:17 -0300 (Wed, 10 Oct 2007)
New Revision: 5218

Added:
   prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/
   prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbs_clas=
s.php
   prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbs_clas=
s_php5.php
   prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbsooo_c=
lass.php
   prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_e=
dit_actions.php
   prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_e=
dit_form.php
   prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_e=
dit_messages.php
   prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_l=
ist.php
   prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_l=
ist_actions.php
   prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_l=
ist_messages.php
   prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_l=
ist_td_actions.php
   prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_l=
ist_td_tabular.php
   prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_l=
ist_th_tabular.php
   prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/bu=
squedaAlumnosSuccess.php
   prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/ed=
itSuccess.php
   prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/li=
stSuccess.php
   prosistem/alba/trunk/alba/apps/principal/modules/informes/validate/edi=
t.yml
   prosistem/alba/trunk/alba/lib/model/Informe.php
   prosistem/alba/trunk/alba/lib/model/InformePeer.php
   prosistem/alba/trunk/alba/lib/model/Tipoinforme.php
   prosistem/alba/trunk/alba/lib/model/TipoinformePeer.php
   prosistem/alba/trunk/alba/lib/model/map/InformeMapBuilder.php
   prosistem/alba/trunk/alba/lib/model/map/TipoinformeMapBuilder.php
   prosistem/alba/trunk/alba/lib/model/om/BaseInforme.php
   prosistem/alba/trunk/alba/lib/model/om/BaseInformePeer.php
   prosistem/alba/trunk/alba/lib/model/om/BaseTipoinforme.php
   prosistem/alba/trunk/alba/lib/model/om/BaseTipoinformePeer.php
Modified:
   prosistem/alba/trunk/alba/apps/principal/modules/informes/actions/acti=
ons.class.php
   prosistem/alba/trunk/alba/apps/principal/modules/informes/config/view.=
yml
   prosistem/alba/trunk/alba/config/schema.yml
   prosistem/alba/trunk/alba/data/sql/datos_desde_cero.sql
   prosistem/alba/trunk/alba/data/sql/datos_ejemplo.sql
   prosistem/alba/trunk/alba/data/sql/lib.model.schema.sql
   prosistem/alba/trunk/alba/lib/model/om/BaseAdjunto.php
Log:
Nueva version embrionaria de generador de informes dinamicos=20

Modified: prosistem/alba/trunk/alba/apps/principal/modules/informes/actio=
ns/actions.class.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/actions/act=
ions.class.php	2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/actions/act=
ions.class.php	2007-10-10 20:53:17 UTC (rev 5218)
@@ -33,12 +33,373 @@
 class InformesActions extends sfActions
 {
=20
+  public function executeIndex()
+  {
+    return $this->forward('informes', 'list');
+  }
+
+  public function executeList()
+  {
+    $this->processSort();
+
+    $this->processFilters();
+
+    $this->filters =3D $this->getUser()->getAttributeHolder()->getAll('s=
f_admin/informes/filters');
+
+    // pager
+    $this->pager =3D new sfPropelPager('Informe', 10);
+    $c =3D new Criteria();
+    $this->addSortCriteria($c);
+//     $this->addFiltersCriteria($c);
+    $this->pager->setCriteria($c);
+    $this->pager->setPage($this->getRequestParameter('page', 1));
+    $this->pager->init();
+  }
+
+  public function executeCreate()
+  {
+    return $this->forward('informes', 'edit');
+  }
+
+  public function executeSave()
+  {
+    return $this->forward('informes', 'edit');
+  }
+
+  public function executeEdit()
+  {
+    $this->informe =3D $this->getInformeOrCreate();
+
+    if ($this->getRequest()->getMethod() =3D=3D sfRequest::POST)
+    {
+        $this->updateInformeFromRequest();
+
+        if($this->getRequest()->getFileName('file')) {
+            $mimetype  =3D $this->getRequest()->getFileType('file');
+            $ext =3D substr($this->getRequest()->getFileName('file'),str=
rpos($this->getRequest()->getFileName('file'),'.'));
+            $realFileName =3D $this->getRequest()->getFileName('file');
+            $uniqueFileName =3D uniqid(rand()) . $ext;
+            $this->getRequest()->moveFile('file', sfConfig::get('sf_uplo=
ad_dir').'/'.$uniqueFileName);
+            $adjunto =3D new Adjunto();=20
+            $adjunto->setFecha(date('Y-m-d'));
+            $adjunto->setNombreArchivo($realFileName);
+            $adjunto->setTipoArchivo($mimetype);    =20
+            $adjunto->setRuta($uniqueFileName);
+            $adjunto->save();
+            $this->informe->setFkAdjuntoId($adjunto->getId());
+            $this->saveInforme($this->informe);
+        }
+
+
+      $this->setFlash('notice', 'Your modifications have been saved');
+
+      if ($this->getRequestParameter('save_and_add'))
+      {
+        return $this->redirect('informes/create');
+      }
+      else if ($this->getRequestParameter('save_and_list'))
+      {
+        return $this->redirect('informes/list');
+      }
+      else
+      {
+        return $this->redirect('informes/edit?id=3D'.$this->informe->get=
Id());
+      }
+    }
+    else
+    {
+      $this->labels =3D $this->getLabels();
+    }
+  }
+
+  public function executeDelete()
+  {
+    $this->informe =3D InformePeer::retrieveByPk($this->getRequestParame=
ter('id'));
+    $this->forward404Unless($this->informe);
+
+    try
+    {
+      unlink(sfConfig::get('sf_upload_dir')."/".$this->informe->getAdjun=
to()->getRuta());
+      $adjunto_id =3D $this->informe->getFkAdjuntoId();
+      $this->deleteInforme($this->informe);
+      $adjunto =3D AdjuntoPeer::retrieveByPk($adjunto_id);
+      $adjunto->delete();
+    }
+    catch (PropelException $e)
+    {
+      $this->getRequest()->setError('delete', 'Could not delete the sele=
cted informe. Make sure it does not have any associated items.');
+      return $this->forward('informes', 'list');
+    }
+
+    return $this->redirect('informes/list');
+  }
+
+  public function handleErrorEdit()
+  {
+    $this->preExecute();
+    $this->informe =3D $this->getInformeOrCreate();
+    $this->updateInformeFromRequest();
+
+    $this->labels =3D $this->getLabels();
+
+    return sfView::SUCCESS;
+  }
+
+  protected function saveInforme($informe)
+  {
+    $informe->save();
+
+  }
+
+  protected function deleteInforme($informe)
+  {
+    $informe->delete();
+  }
+
+  protected function updateInformeFromRequest()
+  {
+    $informe =3D $this->getRequestParameter('informe');
+
+    if (isset($informe['variables']))
+    {
+      $this->informe->setVariables($informe['variables']);
+    }
+
+    if (isset($informe['descripcion']))
+    {
+      $this->informe->setDescripcion($informe['descripcion']);
+    }
+
+    if (isset($informe['nombre']))
+    {
+      $this->informe->setNombre($informe['nombre']);
+    }
+
+    $this->informe->setListado(isset($informe['listado']) ? $informe['li=
stado'] : 0);
+
+    if (isset($informe['fk_adjunto_id']))
+    {
+    $this->informe->setFkAdjuntoId($informe['fk_adjunto_id'] ? $informe[=
'fk_adjunto_id'] : null);
+    }
+
+    if (isset($informe['fk_tipoinforme_id']))
+    {
+    $this->informe->setFkTipoinformeId($informe['fk_tipoinforme_id'] ? $=
informe['fk_tipoinforme_id'] : null);
+    }
+
+  }
+
+  protected function getInformeOrCreate($id =3D 'id')
+  {
+    if (!$this->getRequestParameter($id))
+    {
+      $informe =3D new Informe();
+    }
+    else
+    {
+      $informe =3D InformePeer::retrieveByPk($this->getRequestParameter(=
$id));
+
+      $this->forward404Unless($informe);
+    }
+
+    return $informe;
+  }
+
+  protected function processFilters()
+  {
+    if ($this->getRequest()->hasParameter('filter'))
+    {
+      $filters =3D $this->getRequestParameter('filters');
+
+      $this->getUser()->getAttributeHolder()->removeNamespace('sf_admin/=
informes/filters');
+      $this->getUser()->getAttributeHolder()->add($filters, 'sf_admin/in=
formes/filters');
+    }
+  }
+
+  protected function processSort()
+  {
+    if ($this->getRequestParameter('sort'))
+    {
+      $this->getUser()->setAttribute('sort', $this->getRequestParameter(=
'sort'), 'sf_admin/informes/sort');
+      $this->getUser()->setAttribute('type', $this->getRequestParameter(=
'type', 'asc'), 'sf_admin/alumno/sort');
+    }
+
+    if (!$this->getUser()->getAttribute('sort', null, 'sf_admin/informes=
/sort'))
+    {
+    }
+  }
+
+/*
+  protected function addFiltersCriteria($c)
+  {
+    if (isset($this->filters['nombre_apellido_is_empty']))
+    {
+      $criterion =3D $c->getNewCriterion(AlumnoPeer::NOMBRE_APELLIDO, ''=
);
+      $criterion->addOr($c->getNewCriterion(AlumnoPeer::NOMBRE_APELLIDO,=
 null, Criteria::ISNULL));
+      $c->add($criterion);
+    }
+    else if (isset($this->filters['nombre_apellido']) && $this->filters[=
'nombre_apellido'] !=3D=3D '')
+    {
+      $c->add(AlumnoPeer::NOMBRE_APELLIDO, $this->filters['nombre_apelli=
do']);
+    }
+    if (isset($this->filters['division_is_empty']))
+    {
+      $criterion =3D $c->getNewCriterion(AlumnoPeer::DIVISION, '');
+      $criterion->addOr($c->getNewCriterion(AlumnoPeer::DIVISION, null, =
Criteria::ISNULL));
+      $c->add($criterion);
+    }
+    else if (isset($this->filters['division']) && $this->filters['divisi=
on'] !=3D=3D '')
+    {
+      $c->add(AlumnoPeer::DIVISION, $this->filters['division']);
+    }
+    if (isset($this->filters['nro_documento_is_empty']))
+    {
+      $criterion =3D $c->getNewCriterion(AlumnoPeer::NRO_DOCUMENTO, '');
+      $criterion->addOr($c->getNewCriterion(AlumnoPeer::NRO_DOCUMENTO, n=
ull, Criteria::ISNULL));
+      $c->add($criterion);
+    }
+    else if (isset($this->filters['nro_documento']) && $this->filters['n=
ro_documento'] !=3D=3D '')
+    {
+      $c->add(AlumnoPeer::NRO_DOCUMENTO, strtr($this->filters['nro_docum=
ento'], '*', '%'), Criteria::LIKE);
+    }
+  }
+*/
+  protected function addSortCriteria($c)
+  {
+    if ($sort_column =3D $this->getUser()->getAttribute('sort', null, 's=
f_admin/informes/sort'))
+    {
+      $sort_column =3D InformePeer::translateFieldName($sort_column, Bas=
ePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME);
+      if ($this->getUser()->getAttribute('type', null, 'sf_admin/informe=
s/sort') =3D=3D 'asc')
+      {
+        $c->addAscendingOrderByColumn($sort_column);
+      }
+      else
+      {
+        $c->addDescendingOrderByColumn($sort_column);
+      }
+    }
+  }
+
+  protected function getLabels()
+  {
+    return array(
+      'informe{descripcion}' =3D> 'Descripción:',
+      'informe{nombre}' =3D> 'Nombre:',
+      'informe{listado}' =3D> '=C2=BFEs un Listado?:',
+      'informe{fk_tipoinforme_id}' =3D> 'Tipo de Informe:',
+      'informe{fk_adjunto_id}' =3D> 'Plantilla del informe:',
+      'informe{variables}' =3D> 'Variables:',
+      'file' =3D> 'Plantilla del informe :',
+    );
+  }
+
+    public function executeBorrarAdjunto() {
+        $id =3D $this->getRequestParameter('id');
+        $this->forward404Unless($id);
+        $informe =3D InformePeer::retrieveByPk($id);
+        $informe->setFkAdjuntoId();
+        $informe->save();
+        $adjunto =3D AdjuntoPeer::retrieveByPk($informe->getFkAdjuntoId(=
));
+        unlink(sfConfig::get('sf_upload_dir')."/".$adjunto->getRuta());
+        $adjunto->delete();
+        return $this->redirect("informes?action=3Dedit&id=3D".$id);
+    }
+
+
+    public function executeMostrar() {
+        $informe =3D InformePeer::retrieveByPk($this->getRequestParamete=
r('id'));
+        $this->forward404Unless($informe);
+
+        $establecimiento_id =3D $this->getUser()->getAttribute('fk_estab=
lecimiento_id');
+
+        $aAlumno =3D $this->_getTodosLosAlumnos($establecimiento_id);
+
+        $datos =3D $aAlumno[0];
+        $this->reporteTBSOO($informe->getAdjunto()->getRuta(), $informe-=
>getTipoInforme()->getNombre(), $datos);
+
+        return sfview::NONE;
+    }
+
+
+
+    public function executeBusquedaAlumnos() {
+        $informe =3D InformePeer::retrieveByPk($this->getRequestParamete=
r('id'));
+        $this->forward404Unless($informe);
+
+        // inicializando variables
+        $optionsDivision =3D array();
+        $aAlumno  =3D array();       =20
+
+        // tomando los datos del formulario
+        $division_id =3D $this->getRequestParameter('division_id');
+        $txt =3D $this->getRequestParameter('txt');
+
+        // llenando el combo de division segun establecimiento
+        $establecimiento_id =3D $this->getUser()->getAttribute('fk_estab=
lecimiento_id');
+        $optionsDivision =3D $this->_getDivisiones($establecimiento_id);
+      =20
+        if ($this->getRequest()->getMethod() =3D=3D sfRequest::POST) {
+            $aAlumno =3D $this->_getAlumnosPorDivision($division_id, $tx=
t);             // buscando alumnos
+        }
+
+        // asignando variables para ser usadas en el template
+        $this->optionsDivision =3D $optionsDivision;
+        $this->division_id =3D $division_id;
+        $this->txt =3D $txt;
+        $this->aAlumno =3D $aAlumno;
+        $this->titulo =3D $informe->getNombre();
+        $this->is =3D $informe=3D
+    }
+
+
+
+
+    private function reporteTBSOO($archivo, $tipoinforme, $datos) {
+        define('BASE',sfConfig::get('sf_app_module_dir') .'/informes/' .=
sfConfig::get('sf_app_module_lib_dir_name').'/');
+        require_once(BASE.'tbs_class_php5.php');
+        require_once(BASE.'tbsooo_class.php');
+        $OOo =3D new clsTinyButStrongOOo;
+        $OOo->noErr =3D true;
+        $OOo->SetZipBinary('zip');
+        $OOo->SetUnzipBinary('unzip');
+        $OOo->SetProcessDir(sfConfig::get('sf_upload_dir'));
+        $OOo->SetDataCharset('UTF8');
+        $OOo->NewDocFromTpl(sfConfig::get('sf_upload_dir').'/'.$archivo)=
;
+        $OOo->LoadXmlFromDoc('content.xml');
+        $OOo->MergeField($tipoinforme, $datos);
+        $OOo->SaveXmlToDoc();
+        header('Content-type: '.$OOo->GetMimetypeDoc());
+        header('Content-Length: '.filesize($OOo->GetPathnameDoc()));
+        $OOo->FlushDoc();
+        $OOo->RemoveDoc();
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 /**
  *  Informe: Alumnos por Division=20
  *
  */
-
-
    =20
     private function _getDivisiones($establecimiento_id)  {
         $optionsDivision =3D array();
@@ -450,4 +811,4 @@
=20
=20
 }
-?>
+?>
\ No newline at end of file

Modified: prosistem/alba/trunk/alba/apps/principal/modules/informes/confi=
g/view.yml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/config/view=
.yml	2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/config/view=
.yml	2007-10-10 20:53:17 UTC (rev 5218)
@@ -1,3 +1,3 @@
 default:
-  layout:   layout_sinmenu
+#  layout:   layout_sinmenu
   stylesheets: [informes, %SF_ADMIN_WEB_DIR%/css/main, main ]

Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbs_=
class.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbs_cla=
ss.php	2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbs_cla=
ss.php	2007-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,3397 @@
+<?php
+/*
+********************************************************
+TinyButStrong - Template Engine for Pro and Beginners
+------------------------
+Version  : 2.05.8 for PHP >=3D 4.0.6
+Date     : 2006-05-02
+Web site : www.tinybutstrong.com
+Author   : skrol29 en freesurf.fr
+********************************************************
+This library is free software.
+You can redistribute and modify it even for commercial usage,
+but you must accept and respect the LPGL License (v2.1 or later).
+*/
+// Check PHP version
+if (PHP_VERSION<'4.0.6') {
+	echo '<br><b>TinyButStrong Error</b> (PHP Version Check) : Your PHP ver=
sion is '.PHP_VERSION.' while TinyButStrong needs PHP version 4.0.6 or hi=
gher.';
+} elseif (PHP_VERSION<'4.1.0') {
+	function array_key_exists (&$key,&$array) {
+		return key_exists($key,$array);
+	}
+}
+
+// Render flags
+define('TBS_NOTHING', 0);
+define('TBS_OUTPUT', 1);
+define('TBS_EXIT', 2);
+
+// Special cache actions
+define('TBS_DELETE', -1);
+define('TBS_CANCEL', -2);
+define('TBS_CACHENOW', -3);
+define('TBS_CACHEONSHOW', -4);
+define('TBS_CACHELOAD', -5);
+define('TBS_CACHEGETAGE', -6);
+define('TBS_CACHEGETNAME', -7);
+define('TBS_CACHEISONSHOW', -8);
+
+// *********************************************
+
+class clsTbsLocator {
+	var $PosBeg =3D false;
+	var $PosEnd =3D false;
+	var $Enlarged =3D false;
+	var $FullName =3D false;
+	var $SubName =3D '';
+	var $SubOk =3D false;
+	var $SubLst =3D array();
+	var $SubNbr =3D 0;
+	var $PrmLst =3D array();
+	var $MagnetId =3D false;
+	var $BlockFound =3D false;
+	var $FirstMerge =3D true;
+	var $ConvProtect =3D true;
+	var $ConvHtml =3D true;
+	var $ConvBr =3D true;
+	var $ConvSpe =3D false;
+}
+
+// *********************************************
+
+class clsTbsDataSource {
+
+var $Type =3D false;
+var $SubType =3D 0;
+var $SrcId =3D false;
+var $Query =3D '';
+var $RecSet =3D false;
+var $RecKey =3D '';
+var $RecNum =3D 0;
+var $RecNumInit =3D 0;
+var $RecSaving =3D false;
+var $RecSaved =3D false;
+var $RecBuffer =3D false;
+var $CurrRec =3D false;
+var $PrevRec =3D array();
+var $oTBS =3D false;
+var $BlockName =3D '';
+var $OnDataOk =3D false;
+var $OnDataSave =3D '';
+var $OnDataInfo =3D false;
+var $OnDataPrm =3D array();
+
+function DataAlert($Msg) {
+	return $this->oTBS->meth_Misc_Alert('MergeBlock '.$this->oTBS->ChrOpen.=
$this->BlockName.$this->oTBS->ChrClose,$Msg);
+}
+
+function DataPrepare(&$SrcId,&$oTBS) {
+
+	$this->SrcId =3D& $SrcId;
+	$this->oTBS =3D& $oTBS;
+
+	if (is_array($SrcId)) {
+		$this->Type =3D 0;
+	} elseif (is_resource($SrcId)) {
+
+		$Key =3D get_resource_type($SrcId);
+		switch ($Key) {
+		case 'mysql link'            : $this->Type =3D 1; break;
+		case 'mysql link persistent' : $this->Type =3D 1; break;
+		case 'mysql result'          : $this->Type =3D 1; $this->SubType =3D 1=
; break;
+		case 'pgsql link'            : $this->Type =3D 8; break;
+		case 'pgsql link persistent' : $this->Type =3D 8; break;
+		case 'pgsql result'          : $this->Type =3D 8; $this->SubType =3D 1=
; break;
+		case 'sqlite database'       : $this->Type =3D 9; break;
+		case 'sqlite database (persistent)'	: $this->Type =3D 9; break;
+		case 'sqlite result'         : $this->Type =3D 9; $this->SubType =3D 1=
; break;
+		default :
+			$SubKey =3D 'resource type';
+			$this->Type =3D 7;
+			$x =3D strtolower($Key);
+			$x =3D str_replace('-','_',$x);
+			$Function =3D '';
+			$i =3D 0;
+			$iMax =3D strlen($x);
+			while ($i<$iMax) {
+				if (($x[$i]=3D=3D=3D'_') or (($x[$i]>=3D'a') and ($x[$i]<=3D'z')) or=
 (($x[$i]>=3D'0') and ($x[$i]<=3D'9'))) {
+					$Function .=3D $x[$i];
+					$i++;
+				} else {
+					$i =3D $iMax;
+				}
+			}
+		}
+
+	} elseif (is_string($SrcId)) {
+
+		switch (strtolower($SrcId)) {
+		case 'array' : $this->Type =3D 0; $this->SubType =3D 1; break;
+		case 'clear' : $this->Type =3D 0; $this->SubType =3D 3; break;
+		case 'mysql' : $this->Type =3D 1; $this->SubType =3D 2; break;
+		case 'text'  : $this->Type =3D 4; break;
+		case 'num'   : $this->Type =3D 6; break;
+		default :
+			if ($SrcId[0]=3D=3D=3D'~') {
+				$ErrMsg =3D false;
+				$this->FctOpen  =3D $SrcId.'_open';
+				$this->FctFetch =3D $SrcId.'_fetch';
+				$this->FctClose =3D $SrcId.'_close';
+				$this->FctPrm =3D array(false,0);
+				if ($oTBS->meth_Misc_UserFctCheck($this->FctOpen,$ErrMsg)) {
+					if ($oTBS->meth_Misc_UserFctCheck($this->FctFetch,$ErrMsg)) {
+						if ($oTBS->meth_Misc_UserFctCheck($this->FctClose,$ErrMsg)) {
+							$this->Type =3D 11;
+							$this->SrcId =3D& $oTBS->ObjectRef;
+						}
+					}
+				}
+				if ($ErrMsg!=3D=3Dfalse) $this->Type =3D $this->DataAlert($ErrMsg);
+			} else {
+				$Key =3D $SrcId;
+				$SubKey =3D 'keyword';
+				$this->Type =3D 7;
+				$Function =3D $SrcId;
+			}
+		}
+
+	} elseif (is_object($SrcId)) {
+		if (method_exists($SrcId,'tbsdb_open')) {
+			if (!method_exists($SrcId,'tbsdb_fetch')) {
+				$this->Type =3D $this->DataAlert('The expected method \'tbsdb_fetch\=
' is not found for the class '.get_class($SrcId).'.');
+			} elseif (!method_exists($SrcId,'tbsdb_close')) {
+				$this->Type =3D $this->DataAlert('The expected method \'tbsdb_close\=
' is not found for the class '.get_class($SrcId).'.');
+			} else {
+				$this->Type =3D 10;
+			}
+		} else {
+			$Key =3D get_class($SrcId);
+			$SubKey =3D 'object type';
+			$this->Type =3D 7;
+			$Function =3D $Key;
+		}
+	} elseif ($SrcId=3D=3D=3Dfalse) {
+		$this->DataAlert('The specified source is set to FALSE. Maybe your con=
nection has failed.');
+	} else {
+		$this->DataAlert('Unsupported variable type : \''.gettype($SrcId).'\'.=
');
+	}
+
+	if ($this->Type=3D=3D=3D7) {
+		$this->FctOpen  =3D 'tbsdb_'.$Function.'_open';
+		$Ok =3D function_exists($this->FctOpen);
+		if (!$Ok) { // Some extended call can have a suffix in the class name,=
 we check without the suffix
+			$i =3D strpos($Function,'_');
+			if ($i!=3D=3Dfalse) {
+				$x =3D substr($Function,0,$i);
+				$z  =3D 'tbsdb_'.$x.'_open';
+				$Ok =3D function_exists($z);
+				if ($Ok) {
+					$Function =3D $x;
+					$this->FctOpen =3D $z;
+				}
+			}
+		}
+		if ($Ok) {
+			$this->FctFetch =3D 'tbsdb_'.$Function.'_fetch';
+			$this->FctClose =3D 'tbsdb_'.$Function.'_close';
+			if (function_exists($this->FctFetch)) {
+				if (!function_exists($this->FctClose)) $this->Type =3D $this->DataAl=
ert('The expected custom function \''.$this->FctClose.'\' is not found.')=
;
+			} else {
+				$this->Type =3D $this->DataAlert('The expected custom function \''.$=
this->FctFetch.'\' is not found.');
+			}
+		} else {
+			$this->Type =3D $this->DataAlert('The data source Id \''.$Key.'\' is =
an unsupported '.$SubKey.' because custom function \''.$this->FctOpen.'\'=
 is not found.');
+		}
+	}
+
+	return ($this->Type!=3D=3Dfalse);
+
+}
+
+function DataOpen(&$Query,&$PageSize,&$PageNum,&$RecStop) {
+
+	// Init values
+	unset($this->CurrRec); $this->CurrRec =3D true;
+	if ($this->RecSaved) {
+		$this->FirstRec =3D true;
+		unset($this->RecKey); $this->RecKey =3D '';
+		$this->RecNum =3D $this->RecNumInit;
+		return true;
+	}
+	unset($this->RecSet); $this->RecSet =3D false;
+	$this->RecNumInit =3D 0;
+	$this->RecNum =3D 0;
+	if ($this->OnDataInfo!=3D=3Dfalse) {
+		$this->OnDataOk =3D true;
+		$this->OnDataPrm[0] =3D& $this->BlockName;
+		$this->OnDataPrm[1] =3D& $this->CurrRec;
+		$this->OnDataPrm[2] =3D& $this->RecNum;
+	}
+
+	switch ($this->Type) {
+	case 0: // Array
+		if (($this->SubType=3D=3D=3D1) and (is_string($Query))) $this->SubType=
 =3D 2;
+		if ($this->SubType=3D=3D=3D0) {
+			if (PHP_VERSION=3D=3D=3D'4.4.1') {$this->RecSet =3D $this->SrcId;} el=
se {$this->RecSet =3D& $this->SrcId;} // bad bug in PHP 4.4.1
+		} elseif ($this->SubType=3D=3D=3D1) {
+			if (is_array($Query)) {
+				if (PHP_VERSION=3D=3D=3D'4.4.1') {$this->RecSet =3D $Query;} else {$=
this->RecSet =3D& $Query;}
+			} else {
+				$this->DataAlert('Type \''.gettype($Query).'\' not supported for the=
 Query Parameter going with \'array\' Source Type.');
+			}
+		} elseif ($this->SubType=3D=3D=3D2) {
+			//Found the global variable name and the sub-keys
+			$Pos =3D strpos($Query,'[');
+			if ($Pos=3D=3D=3Dfalse) {
+				$VarName =3D $Query;
+				$Keys =3D array();
+			} else {
+				$VarName =3D substr($Query,0,$Pos);
+				$Keys =3D substr($Query,$Pos+1,strlen($Query)-$Pos-2);
+				$Keys =3D explode('][',$Keys);
+			}
+			// Check variable and sub-keys
+			if (isset($GLOBALS[$VarName])) {
+				if (PHP_VERSION=3D=3D=3D'4.4.1') {$Var =3D $GLOBALS[$VarName];} else=
 {$Var =3D& $GLOBALS[$VarName];}
+				if (is_array($Var)) {
+					$Ok =3D true;
+					$KeyMax =3D count($Keys)-1;
+					$KeyNum =3D 0;
+					while ($Ok and ($KeyNum<=3D$KeyMax)) {
+						if (isset($Var[$Keys[$KeyNum]])) {
+							$Var =3D& $Var[$Keys[$KeyNum]];
+							$KeyNum++;
+							if (!is_array($Var)) $Ok =3D $this->DataAlert('Invalid query \''.=
$Query.'\' because item \''.$VarName.'['.implode('][',array_splice($Keys,=
0,$KeyNum)).']\' is not an array.');
+						} else {
+							$Ok =3D false; // Item not found =3D> not an error, considered as=
 a query with empty result.
+							$this->RecSet =3D array();
+						}
+					}
+					if ($Ok) $this->RecSet =3D& $Var;
+				} else {
+					$this->DataAlert('Invalid query \''.$Query.'\' because global varia=
ble \''.$VarName.'\' is not an array.');
+				}
+			} else {
+				$this->DataAlert('Invalid query \''.$Query.'\' because global variab=
le \''.$VarName.'\' is not found.');
+			}
+		} elseif ($this->SubType=3D=3D=3D3) { // Clear
+			$this->RecSet =3D array();
+		}
+		// First record
+		if ($this->RecSet!=3D=3Dfalse) {
+			$this->RecNbr =3D $this->RecNumInit + count($this->RecSet);
+			$this->FirstRec =3D true;
+			$this->RecSaved =3D true;
+			$this->RecSaving =3D false;
+		}
+		break;
+	case 1: // MySQL
+		switch ($this->SubType) {
+		case 0: $this->RecSet =3D @mysql_query($Query,$this->SrcId); break;
+		case 1: $this->RecSet =3D $this->SrcId; break;
+		case 2: $this->RecSet =3D @mysql_query($Query); break;
+		}
+		if ($this->RecSet=3D=3D=3Dfalse) $this->DataAlert('MySql error message=
 when opening the query: '.mysql_error());
+		break;
+	case 4: // Text
+		if (is_string($Query)) {
+			$this->RecSet =3D& $Query;
+		} else {
+			$this->RecSet =3D ''.$Query;=09
+		}
+		$PageSize =3D 0;
+		break;
+	case 6: // Num
+		$this->RecSet =3D true;
+		$this->NumMin =3D 1;
+		$this->NumMax =3D 1;
+		$this->NumStep =3D 1;
+		if (is_array($Query)) {
+			if (isset($Query['min'])) $this->NumMin =3D $Query['min'];
+			if (isset($Query['step'])) $this->NumStep =3D $Query['step'];
+			if (isset($Query['max'])) {
+				$this->NumMax =3D $Query['max'];
+			} else {
+				$this->RecSet =3D $this->DataAlert('The \'num\' source is an array t=
hat has no value for the \'max\' key.');
+			}
+			if ($this->NumStep=3D=3D0) $this->RecSet =3D $this->DataAlert('The \'=
num\' source is an array that has a step value set to zero.');
+		} else {
+			$this->NumMax =3D ceil($Query);
+		}
+		if ($this->RecSet) {
+			if ($this->NumStep>0) {
+				$this->NumVal =3D $this->NumMin;
+			} else {
+				$this->NumVal =3D $this->NumMax;
+			}
+		}
+		break;
+	case 7: // Custom function
+		$FctOpen =3D $this->FctOpen;
+		$this->RecSet =3D $FctOpen($this->SrcId,$Query);
+		break;
+	case 8: // PostgreSQL
+		switch ($this->SubType) {
+		case 0: $this->RecSet =3D @pg_query($this->SrcId,$Query); break;
+		case 1: $this->RecSet =3D $this->SrcId; break;
+		}
+		if ($this->RecSet=3D=3D=3Dfalse) $this->DataAlert('PostgreSQL error me=
ssage when opening the query: '.pg_last_error($this->SrcId));
+		break;
+	case 9: // SQLite
+		switch ($this->SubType) {
+		case 0: $this->RecSet =3D @sqlite_query($this->SrcId,$Query); break;
+		case 1: $this->RecSet =3D $this->SrcId; break;
+		}
+		if ($this->RecSet=3D=3D=3Dfalse) $this->DataAlert('SQLite error messag=
e when opening the query:'.sqlite_error_string(sqlite_last_error($this->S=
rcId)));
+		break;
+	case 10: // Custom method
+		$this->RecSet =3D $this->SrcId->tbsdb_open($this->SrcId,$Query);
+		break;
+	case 11: // ObjectRef
+		$this->RecSet =3D call_user_func_array($this->FctOpen,array(&$this->Sr=
cId,&$Query));
+		break;
+	}
+
+	if ($this->Type=3D=3D=3D0) {
+		unset($this->RecKey); $this->RecKey =3D '';
+	} else {
+		if ($this->RecSaving) {
+			unset($this->RecBuffer); $this->RecBuffer =3D array();
+		}
+		$this->RecKey =3D& $this->RecNum; // Not array: RecKey =3D RecNum
+	}
+
+	//Goto the page
+	if (($this->RecSet!=3D=3Dfalse) and ($PageSize>0)) {
+		if ($PageNum=3D=3D-1) { // Goto end of the recordset
+			if ($this->RecSaved) { // Data source is array
+				$PageNum =3D intval(ceil($this->RecNbr/$PageSize));
+			} else {
+				// Read records, saving the last page in $this->RecBuffer
+				$i =3D 0;
+				unset($this->RecBuffer); $this->RecBuffer =3D array();
+				$this->RecSaving =3D true;
+				$this->DataFetch();
+				while ($this->CurrRec!=3D=3Dfalse) {
+					if ($i=3D=3D=3D$PageSize) {
+						$this->RecBuffer =3D array($this->RecKey =3D> $this->CurrRec);
+						$i =3D 0;
+						$this->RecNumInit +=3D $PageSize;
+					}
+					$i++;
+					$this->DataFetch();
+				}
+				$this->DataClose(); // Close the real recordset source
+				unset($this->RecNum); $this->RecNum =3D 0+$this->RecNumInit;
+				$this->FirstRec =3D true;
+			}
+		}
+		if ($PageNum>0) {
+			// We pass all record until the asked page
+			$RecStop =3D ($PageNum-1) * $PageSize;
+			while ($this->RecNum<$RecStop) {
+				$this->DataFetch();
+				if ($this->CurrRec=3D=3D=3Dfalse) $RecStop=3D$this->RecNum;=09
+			}
+			if ($this->CurrRec!=3D=3Dfalse) $RecStop =3D $PageNum * $PageSize;
+			$this->RecNumInit =3D $this->RecNum; // Useful if RecSaved
+		} else {
+			$RecStop =3D 1;
+		}
+	}
+
+	return ($this->RecSet!=3D=3Dfalse);
+
+}
+
+function DataFetch() {
+
+	if ($this->RecSaved) {
+		if ($this->RecNum<$this->RecNbr) {
+			if ($this->FirstRec) {
+				if ($this->SubType=3D=3D=3D2) { // From string
+					reset($this->RecSet);
+					$this->RecKey =3D key($this->RecSet);
+					$this->CurrRec =3D& $this->RecSet[$this->RecKey];
+				} else {
+					$this->CurrRec =3D reset($this->RecSet);
+					$this->RecKey =3D key($this->RecSet);
+				}
+				$this->FirstRec =3D false;
+			} else {
+				if ($this->SubType=3D=3D=3D2) { // From string
+					next($this->RecSet);
+					$this->RecKey =3D key($this->RecSet);
+					$this->CurrRec =3D& $this->RecSet[$this->RecKey];
+				} else {
+					$this->CurrRec =3D next($this->RecSet);
+					$this->RecKey =3D key($this->RecSet);
+				}
+			}
+			if (!is_array($this->CurrRec)) $this->CurrRec =3D array('key'=3D>$thi=
s->RecKey, 'val'=3D>$this->CurrRec);
+			$this->RecNum++;
+			if ($this->OnDataOk) {
+				$this->OnDataPrm[1] =3D& $this->CurrRec; // Reference has changed if=
 ($this->SubType=3D=3D=3D2)
+				call_user_func_array($this->OnDataInfo,$this->OnDataPrm);
+			}
+		} else {
+			unset($this->CurrRec); $this->CurrRec =3D false;
+		}
+		return;
+	}
+
+	switch ($this->Type) {
+	case 1: // MySQL
+		$this->CurrRec =3D mysql_fetch_assoc($this->RecSet);
+		break;
+	case 4: // Text
+		if ($this->RecNum=3D=3D=3D0) {
+			if ($this->RecSet=3D=3D=3D'') {
+				$this->CurrRec =3D false;
+			} else {
+				$this->CurrRec =3D& $this->RecSet;
+			}
+		} else {
+			$this->CurrRec =3D false;
+		}
+		break;
+	case 6: // Num
+		if (($this->NumVal>=3D$this->NumMin) and ($this->NumVal<=3D$this->NumM=
ax)) {
+			$this->CurrRec =3D array('val'=3D>$this->NumVal);
+			$this->NumVal +=3D $this->NumStep;
+		} else {
+			$this->CurrRec =3D false;
+		}
+		break;
+	case 7: // Custom function
+		$FctFetch =3D $this->FctFetch;
+		$this->CurrRec =3D $FctFetch($this->RecSet,$this->RecNum+1);
+		break;
+	case 8: // PostgreSQL
+		$this->CurrRec =3D @pg_fetch_array($this->RecSet,$this->RecNum,PGSQL_A=
SSOC); // warning comes when no record left.
+		break;
+	case 9: // SQLite
+		$this->CurrRec =3D sqlite_fetch_array($this->RecSet,SQLITE_ASSOC);
+		break;
+	case 10: // Custom method
+		$this->CurrRec =3D $this->SrcId->tbsdb_fetch($this->RecSet,$this->RecN=
um+1);
+		break;
+	case 11: // ObjectRef
+		$this->FctPrm[0] =3D& $this->RecSet; $this->FctPrm[1] =3D $this->RecNu=
m+1;
+		$this->CurrRec =3D call_user_func_array($this->FctFetch,$this->FctPrm)=
;
+		break;
+	}
+
+	// Set the row count
+	if ($this->CurrRec!=3D=3Dfalse) {
+		$this->RecNum++;
+		if ($this->OnDataOk) call_user_func_array($this->OnDataInfo,$this->OnD=
ataPrm);
+		if ($this->RecSaving) $this->RecBuffer[$this->RecKey] =3D $this->CurrR=
ec;
+	}
+
+}
+
+function DataClose() {
+	if ($this->RecSaved) return;
+	$this->OnDataOk =3D false;
+	switch ($this->Type) {
+	case 1: mysql_free_result($this->RecSet); break;
+	case 7: $FctClose=3D$this->FctClose; $FctClose($this->RecSet); break;
+	case 8: pg_free_result($this->RecSet); break;
+	case 10: $this->SrcId->tbsdb_close($this->RecSet); break;
+	case 11: call_user_func_array($this->FctClose,array(&$this->RecSet)); b=
reak;
+	}
+	if ($this->RecSaving) {
+		$this->RecSet =3D& $this->RecBuffer;
+		$this->RecNbr =3D $this->RecNumInit + count($this->RecSet);
+		$this->RecSaving =3D false;
+		$this->RecSaved =3D true;
+	}
+}
+
+}
+
+// *********************************************
+
+class clsTinyButStrong {
+
+// Public properties
+var $Source =3D ''; // Current result of the merged template
+var $Render =3D 3;
+var $HtmlCharSet =3D '';
+var $TplVars =3D array();
+var $VarPrefix =3D '';
+var $ObjectRef =3D false;
+var $Protect =3D true;
+// Private properties
+var $_LastFile =3D ''; // The last loaded template file
+var $_CacheFile =3D false; // The name of the file to save the content i=
n.
+var $_HtmlCharFct =3D false;
+var $_Mode =3D 0;
+// Used to be globals
+var $ChrOpen =3D '[';
+var $ChrClose =3D ']';
+var $ChrVal =3D '[val]';
+var $ChrProtect =3D '&#91;';
+var $CacheMask =3D 'cache_tbs_*.php';
+var $TurboBlock =3D true;
+var $MaxEnd =3D '...';
+
+function clsTinyButStrong($Chrs=3D'',$VarPrefix=3D'') {
+	if ($Chrs!=3D=3D'') {
+		$Ok =3D false;
+		$Len =3D strlen($Chrs);
+		if ($Len=3D=3D=3D2) { // For compatibility
+			$this->ChrOpen =3D $Chrs[0];
+			$this->ChrClose =3D $Chrs[1];
+			$Ok =3D true;
+		} else {
+			$Pos =3D strpos($Chrs,',');
+			if (($Pos!=3D=3Dfalse) and ($Pos>0) and ($Pos<$Len-1)) {
+				$this->ChrOpen =3D substr($Chrs,0,$Pos);
+				$this->ChrClose =3D substr($Chrs,$Pos+1);
+				$Ok =3D true;
+			}
+		}
+		if ($Ok) {
+			$this->ChrVal =3D $this->ChrOpen.'val'.$this->ChrClose;
+			$this->ChrProtect =3D '&#'.ord($this->ChrOpen[0]).';'.substr($this->C=
hrOpen,1);
+		} else {
+			$this->meth_Misc_Alert('Creating instance','Bad argument for tag deli=
mitors \''.$Chrs.'\'.');
+		}
+	}
+	$this->VarPrefix =3D $VarPrefix;
+	//Cache for formats
+	if (!isset($GLOBALS['_tbs_FrmMultiLst'])) {
+		$GLOBALS['_tbs_FrmMultiLst'] =3D array();
+		$GLOBALS['_tbs_FrmSimpleLst'] =3D array();
+	}
+}
+
+// Public methods
+function LoadTemplate($File,$HtmlCharSet=3D'') {
+	// Load the file
+	$x =3D '';
+	if (!tbs_Misc_GetFile($x,$File)) return $this->meth_Misc_Alert('LoadTem=
plate Method','Unable to read the file \''.$File.'\'.');
+	// CharSet analysis
+	if ($HtmlCharSet=3D=3D=3D'+') {
+		$this->Source .=3D $x;
+	} else {
+		$this->Source =3D $x;
+		if ($this->_Mode=3D=3D0) {
+			$this->_LastFile =3D $File;
+			$this->_HtmlCharFct =3D false;
+			$this->TplVars =3D array();
+			if (is_string($HtmlCharSet)) {
+				if (($HtmlCharSet!=3D=3D'') and ($HtmlCharSet[0]=3D=3D=3D'=3D')) {
+					$ErrMsg =3D false;
+					$HtmlCharSet =3D substr($HtmlCharSet,1);
+					if ($this->meth_Misc_UserFctCheck($HtmlCharSet,$ErrMsg)) {
+						$this->_HtmlCharFct =3D true;
+					} else {
+						$this->meth_Misc_Alert('LoadTemplate Method',$ErrMsg);
+						$HtmlCharSet =3D '';
+					}
+				}
+			} elseif ($HtmlCharSet=3D=3D=3Dfalse) {
+				$this->Protect =3D false;
+			} else {
+				$this->meth_Misc_Alert('LoadTemplate Method','CharSet is not a strin=
g.');
+				$HtmlCharSet =3D '';
+			}
+			$this->HtmlCharSet =3D $HtmlCharSet;
+		}
+	}
+	// Automatic fields and blocks
+	$this->meth_Merge_Auto($this->Source,'onload',true,true);
+	return true;
+}
+
+function GetBlockSource($BlockName,$List=3Dfalse) {
+	$RetVal =3D array();
+	$Nbr =3D 0;
+	$Pos =3D 0;
+	$FieldOutside =3D false;
+	$P1 =3D false;
+	while ($Loc =3D $this->meth_Locator_FindBlockNext($this->Source,$BlockN=
ame,$Pos,'.',false,$P1,$FieldOutside)) {
+		$P1 =3D false;
+		$Nbr++;
+		$RetVal[$Nbr] =3D substr($this->Source,$Loc->PosBeg,$Loc->PosEnd-$Loc-=
>PosBeg+1);
+		if (!$List) return $RetVal[$Nbr];
+		$Pos =3D $Loc->PosEnd;
+	}
+	if ($List) {
+		return $RetVal;
+	} else {
+		return false;
+	}
+}
+
+function MergeBlock($BlockName,$SrcId,$Query=3D'',$PageSize=3D0,$PageNum=
=3D0,$RecKnown=3D0) {
+	if ($SrcId=3D=3D=3D'cond') {
+		$Nbr =3D 0;
+		$BlockLst =3D explode(',',$BlockName);
+		foreach ($BlockLst as $Block) {
+			$Nbr +=3D $this->meth_Merge_Auto($this->Source,$Block,false,false);
+		}
+		return $Nbr;
+	} else {
+		return $this->meth_Merge_Block($this->Source,$BlockName,$SrcId,$Query,=
$PageSize,$PageNum,$RecKnown);
+	}
+}
+
+function MergeField($Name,$Value,$IsUserFct=3Dfalse) {
+	$PosBeg =3D 0;
+	if ($IsUserFct) {
+		$FctInfo =3D $Value;
+		$ErrMsg =3D false;
+		if ($this->meth_Misc_UserFctCheck($FctInfo,$ErrMsg)) {
+			$FctPrm =3D array('','');
+			while ($Loc =3D $this->meth_Locator_FindTbs($this->Source,$Name,$PosB=
eg,'.')) {
+				$FctPrm[0] =3D& $Loc->SubName; $FctPrm[1] =3D& $Loc->PrmLst;
+				$x =3D call_user_func_array($FctInfo,$FctPrm);
+				$PosBeg =3D $this->meth_Locator_Replace($this->Source,$Loc,$x,false)=
;
+			}
+		} else {
+			$this->meth_Misc_Alert('MergeField Method',$ErrMsg);
+		}
+	} else {
+		while ($Loc =3D $this->meth_Locator_FindTbs($this->Source,$Name,$PosBe=
g,'.')) {
+			$PosBeg =3D $this->meth_Locator_Replace($this->Source,$Loc,$Value,tru=
e);
+		}
+	}
+}
+
+function MergeSpecial($Type) {
+	$Type =3D strtolower($Type);
+	$this->meth_Merge_Special($Type);
+}
+
+function MergeNavigationBar($BlockLst,$Options,$PageCurr,$RecCnt=3D-1,$P=
ageSize=3D1) {
+	$BlockLst =3D explode(',',$BlockLst);
+	foreach ($BlockLst as $BlockName) {
+		$BlockName =3D trim($BlockName);
+		$this->meth_Merge_NavigationBar($this->Source,$BlockName,$Options,$Pag=
eCurr,$RecCnt,$PageSize);
+	}
+}
+
+function Show($Render=3D'') {
+	if ($Render=3D=3D=3D'') $Render =3D $this->Render;
+	if ($this->_CacheFile!=3D=3Dtrue) $this->meth_Merge_Special('onshow,var=
');
+	if (is_string($this->_CacheFile)) $this->meth_Cache_Save($this->_CacheF=
ile,$this->Source);
+	if (($Render & TBS_OUTPUT)=3D=3DTBS_OUTPUT) echo $this->Source;
+	if (($this->_Mode=3D=3D0) and (($Render & TBS_EXIT)=3D=3DTBS_EXIT)) exi=
t;
+}
+
+function CacheAction($CacheId,$Action=3D3600,$Dir=3D'') {
+
+	$CacheId =3D trim($CacheId);
+	$Res =3D false;
+
+	if ($Action=3D=3D=3DTBS_CANCEL) { // Cancel cache save if any
+		$this->_CacheFile =3D false;
+	} elseif ($CacheId =3D=3D=3D '*') {
+		if ($Action=3D=3D=3DTBS_DELETE) $Res =3D tbs_Cache_DeleteAll($Dir,$thi=
s->CacheMask);
+	} else {
+		$CacheFile =3D tbs_Cache_File($Dir,$CacheId,$this->CacheMask);
+		if ($Action=3D=3D=3DTBS_CACHENOW) {
+			$this->meth_Cache_Save($CacheFile,$this->Source);
+		} elseif ($Action=3D=3D=3DTBS_CACHEGETAGE) {
+			if (file_exists($CacheFile)) $Res =3D time()-filemtime($CacheFile);
+		} elseif ($Action=3D=3D=3DTBS_CACHEGETNAME) {
+			$Res =3D $CacheFile;
+		} elseif ($Action=3D=3D=3DTBS_CACHEISONSHOW) {
+			$Res =3D ($this->_CacheFile!=3D=3Dfalse);
+		} elseif ($Action=3D=3D=3DTBS_CACHELOAD) {
+			if (file_exists($CacheFile)) {
+				if (tbs_Misc_GetFile($this->Source,$CacheFile)) {
+					$this->_CacheFile =3D $CacheFile;
+					$Res =3D true;
+				}
+			}
+			if ($Res=3D=3D=3Dfalse)	$this->Source =3D '';
+		} elseif ($Action=3D=3D=3DTBS_DELETE) {
+			if (file_exists($CacheFile)) $Res =3D @unlink($CacheFile);
+		} elseif ($Action=3D=3D=3DTBS_CACHEONSHOW) {
+			$this->_CacheFile =3D $CacheFile;
+			@touch($CacheFile);
+		} elseif($Action>=3D0) {
+			$Res =3D tbs_Cache_IsValide($CacheFile,$Action);
+			if ($Res) { // Load the cache
+				if (tbs_Misc_GetFile($this->Source,$CacheFile)) {
+					$this->_CacheFile =3D true; // Special value
+					$this->Show();
+				} else {
+					$this->meth_Misc_Alert('CacheAction Method','Unable to read the fil=
e \''.$CacheFile.'\'.');
+					$Res=3D=3Dfalse;
+				}
+				$this->_CacheFile =3D false;
+			} else {
+				// The result will be saved in the cache when the Show() method is c=
alled
+				$this->_CacheFile =3D $CacheFile;
+				@touch($CacheFile);
+			}
+		}
+	}
+
+	return $Res;
+
+}
+
+// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
+
+function meth_Locator_FindTbs(&$Txt,$Name,$Pos,$ChrSub) {
+// Find a TBS Locator
+
+	$PosEnd =3D false;
+	$PosMax =3D strlen($Txt) -1;
+	$Start =3D $this->ChrOpen.$Name;
+
+	do {
+		// Search for the opening char
+		if ($Pos>$PosMax) return false;
+		$Pos =3D strpos($Txt,$Start,$Pos);
+
+		// If found =3D> next chars are analyzed
+		if ($Pos=3D=3D=3Dfalse) {
+			return false;
+		} else {
+			$Loc =3D& new clsTbsLocator;
+			$ReadPrm =3D false;
+			$PosX =3D $Pos + strlen($Start);
+			$x =3D $Txt[$PosX];
+
+			if ($x=3D=3D=3D$this->ChrClose) {
+				$PosEnd =3D $PosX;
+			} elseif ($x=3D=3D=3D$ChrSub) {
+				$Loc->SubOk =3D true; // it is no longer the false value
+				$ReadPrm =3D true;
+				$PosX++;
+			} elseif (strpos(';',$x)!=3D=3Dfalse) {
+				$ReadPrm =3D true;
+				$PosX++;
+			} else {
+				$Pos++;
+			}
+
+			if ($ReadPrm) {
+				tbs_Locator_PrmRead($Txt,$PosX,false,'\'',$this->ChrOpen,$this->ChrC=
lose,$Loc,$PosEnd);
+				if ($PosEnd=3D=3D=3Dfalse) {
+					$this->meth_Misc_Alert('Tag definition','Can\'t found the end of th=
e tag \''.substr($Txt,$Pos,$PosX-$Pos+10).'...\'.');
+					$Pos++;
+				}
+			}
+		=09
+		}
+
+	} while ($PosEnd=3D=3D=3Dfalse);
+
+	$Loc->PosBeg =3D $Pos;
+	$Loc->PosEnd =3D $PosEnd;
+	if ($Loc->SubOk) {
+		$Loc->FullName =3D $Name.'.'.$Loc->SubName;
+		$Loc->SubLst =3D explode('.',$Loc->SubName);
+		$Loc->SubNbr =3D count($Loc->SubLst);
+	} else {
+		$Loc->FullName =3D $Name;
+	}
+	if ($ReadPrm and isset($Loc->PrmLst['comm'])) {
+		$Loc->PosBeg0 =3D $Loc->PosBeg;
+		$Loc->PosEnd0 =3D $Loc->PosEnd;
+		$Loc->Enlarged =3D tbs_Locator_EnlargeToStr($Txt,$Loc,'<!--' ,'-->');
+	}
+
+	return $Loc;
+
+}
+
+// Search and cache TBS locators founded in $Txt.
+function meth_Locator_SectionCache(&$LocR,$Bid) {
+
+	$LocR->BlockChk[$Bid] =3D false;
+
+	$LocLst =3D& $LocR->BlockLoc[$Bid];
+	$Txt =3D& $LocR->BlockSrc[$Bid];
+	$BlockName =3D& $LocR->BlockName[$Bid];
+
+	$Pos =3D 0;
+	$PrevEnd =3D -1;
+	$Nbr =3D 0;
+	while ($Loc =3D $this->meth_Locator_FindTbs($Txt,$BlockName,$Pos,'.')) =
{
+		if (($Loc->SubName=3D=3D=3D'#') or ($Loc->SubName=3D=3D=3D'$')) {
+			$Loc->IsRecInfo =3D true;
+			$Loc->RecInfo =3D $Loc->SubName;
+			$Loc->SubName =3D '';
+		} else {
+			$Loc->IsRecInfo =3D false;
+		}
+		if ($Loc->PosBeg>$PrevEnd) {
+			// The previous tag is not embeding =3D> increment
+			$Nbr++;
+		} else {
+			// The previous tag is embeding =3D> no increment, then previous is o=
ver writed
+			$LocR->BlockChk[$Bid] =3D true;
+		}
+		$PrevEnd =3D $Loc->PosEnd;
+		if ($Loc->Enlarged) { // Parameter 'comm'
+			$Pos =3D $Loc->PosBeg0+1;
+			$Loc->Enlarged =3D false;
+		} else {
+			$Pos =3D $Loc->PosBeg+1;
+		}
+		$LocLst[$Nbr] =3D $Loc;
+	}
+
+	$LocLst[0] =3D $Nbr;
+
+}
+
+function meth_Locator_Replace(&$Txt,&$Loc,&$Value,$CheckSub) {
+// This function enables to merge a locator with a text and returns the =
position just after the replaced block
+// This position can be useful because we don't know in advance how $Val=
ue will be replaced.
+
+	// Found the value if there is a subname
+	if ($CheckSub and $Loc->SubOk) {
+		$SubId =3D 0;
+		while ($SubId<$Loc->SubNbr) {
+			$x =3D $Loc->SubLst[$SubId]; // &$Loc... brings an error with Event E=
xample, I don't know why.
+			if (is_array($Value)) {
+				if (isset($Value[$x])) {
+					$Value =3D& $Value[$x];
+				} elseif (array_key_exists($x,$Value)) {// can happens when value is=
 NULL
+					$Value =3D& $Value[$x];
+				} else {
+					unset($Value); $Value =3D '';
+					if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert('Array va=
lue','Can\'t merge '.$this->ChrOpen.$Loc->FullName.$this->ChrClose.' beca=
use sub-item \''.$x.'\' is not an existing key in the array.',true);
+				}
+				$SubId++;
+			} elseif (is_object($Value)) {
+				if (method_exists($Value,$x)) {
+					$x =3D call_user_func(array(&$Value,$x));
+				} elseif (isset($Value->$x)) {
+					$x =3D $Value->$x;
+				} else {
+					if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert('Object v=
alue','Can\'t merge '.$this->ChrOpen.$Loc->FullName.$this->ChrClose.' bec=
ause \''.$x.'\' is neither a method nor a property in the class \''.get_c=
lass($Value).'\'.',true);
+					unset($x); $x =3D '';
+				}
+				$Value =3D& $x;
+				unset($x); $x =3D '';
+				$SubId++;
+			} else {
+				if (isset($Loc->PrmLst['selected'])) {
+					$SelArray =3D& $Value;
+				} else {
+					if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert('Object o=
r Array value expected','Can\'t merge '.$this->ChrOpen.$Loc->FullName.$th=
is->ChrClose.' because the item before \''.$x.'\' is neither an object no=
r an array. Its type is '.gettype($Value).'.',true);
+				}
+				unset($Value); $Value =3D '';
+				$SubId =3D $Loc->SubNbr;
+			}
+		}
+	}
+
+	$CurrVal =3D $Value;
+
+	// File inclusion
+	if (isset($Loc->PrmLst['file'])) {
+		$File =3D $Loc->PrmLst['file'];
+		$this->meth_Merge_PhpVar($File,false);
+		$File =3D str_replace($this->ChrVal,$CurrVal,$File);
+		$OnlyBody =3D !(isset($Loc->PrmLst['htmlconv']) and (strtolower($Loc->=
PrmLst['htmlconv'])=3D=3D=3D'no')); // It's a text file, we don't get the=
 BODY part
+		if (tbs_Misc_GetFile($CurrVal,$File)) {
+			if ($OnlyBody) $CurrVal =3D tbs_Html_GetPart($CurrVal,'BODY',false,tr=
ue);
+		} else {
+			$CurrVal =3D '';
+			if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert('Parameter =
\'file\'','Field '.$this->ChrOpen.$Loc->FullName.$this->ChrClose.' : unab=
le to read the file \''.$File.'\'.',true);
+		}
+		$Loc->ConvHtml =3D false;
+		$Loc->ConvProtect =3D false;
+	}
+
+	// OnFormat event
+	if (isset($Loc->PrmLst['onformat'])) {
+		if ($Loc->FirstMerge) {
+			$Loc->OnFrmInfo =3D $Loc->PrmLst['onformat'];
+			$Loc->OnFrmPrm =3D array(&$Loc->FullName,'',&$Loc->PrmLst,&$this);
+			$ErrMsg =3D false;
+			if (!$this->meth_Misc_UserFctCheck($Loc->OnFrmInfo,$ErrMsg)) {
+				unset($Loc->PrmLst['onformat']);
+				if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert('Parameter=
 \'onformat\'',$ErrMsg);
+				$Loc->OnFrmInfo =3D 'pi'; // Execute the function pi() just to avoid=
 extra error messages=20
+			}
+		}
+		$Loc->OnFrmPrm[1] =3D& $CurrVal;
+		if (isset($Loc->PrmLst['subtpl'])) {
+			$this->meth_Misc_ChangeMode(true,$Loc,$CurrVal,true,true);
+			call_user_func_array($Loc->OnFrmInfo,$Loc->OnFrmPrm);
+			$this->meth_Misc_ChangeMode(false,$Loc,$CurrVal,true,true);
+		} else {
+			call_user_func_array($Loc->OnFrmInfo,$Loc->OnFrmPrm);
+		}
+	}
+
+	// Select a value in a HTML option list
+	$Select =3D isset($Loc->PrmLst['selected']);
+	if ($Select) {
+		if (is_array($CurrVal)) {
+			$SelArray =3D& $CurrVal;
+			unset($CurrVal); $CurrVal =3D ' ';
+		} else {
+			$SelArray =3D false;
+		}
+	}
+
+	// Convert the value to a string, use format if specified
+	if (isset($Loc->PrmLst['frm'])) {
+		$CurrVal =3D tbs_Misc_Format($Loc,$CurrVal);
+		$Loc->ConvHtml =3D false;
+	} else {
+		if (!is_string($CurrVal)) $CurrVal =3D @strval($CurrVal);
+	}
+
+	// case of an 'if' 'then' 'else' options
+	$OVal =3D& $CurrVal; // Must be assigner after $SelArray, if any
+	$Script =3D isset($Loc->PrmLst['script']);
+	if (isset($Loc->PrmLst['if'])) {
+		if ($Loc->FirstMerge) {
+			$this->meth_Merge_PhpVar($Loc->PrmLst['if'],false);
+			if (isset($Loc->PrmLst['then'])) $this->meth_Merge_PhpVar($Loc->PrmLs=
t['then'],true);
+			if (isset($Loc->PrmLst['else'])) $this->meth_Merge_PhpVar($Loc->PrmLs=
t['else'],true);
+		}
+		$x =3D str_replace($this->ChrVal,$CurrVal,$Loc->PrmLst['if']);
+		if (tbs_Misc_CheckCondition($x)) {
+			if (isset($Loc->PrmLst['then'])) {
+				unset($CurrVal); $CurrVal =3D ''.$Loc->PrmLst['then']; // Now $CurrV=
al and $OVal are different
+			}
+		} else {
+			$Script =3D false;
+			if (isset($Loc->PrmLst['else'])) {
+				unset($CurrVal); $CurrVal =3D ''.$Loc->PrmLst['else']; // Now $CurrV=
al and $OVal are different
+			} else {
+				$CurrVal =3D '';
+			}
+		}
+	}
+
+	if ($Script) {// Include external PHP script
+		$File =3D $Loc->PrmLst['script'];
+		$this->meth_Merge_PhpVar($File,false);
+		$File =3D str_replace($this->ChrVal,$CurrVal,$File);
+		$Switch =3D isset($Loc->PrmLst['subtpl']);
+		$GetOb =3D ($Switch or isset($Loc->PrmLst['getob']));
+		$CurrPrm =3D& $Loc->PrmLst; // Local var for users
+		$this->meth_Misc_ChangeMode(true,$Loc,$CurrVal,$Switch,$GetOb);
+		if (isset($Loc->PrmLst['once'])) {$x =3D @include_once($File);} else {=
$x =3D @include($File);}
+		if ($x=3D=3D=3Dfalse) {
+			if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert('Parameter =
\'script\'','Field '.$this->ChrOpen.$Loc->FullName.$this->ChrClose.' cann=
ot be merged because file \''.$File.'\' is not found or not readable.',tr=
ue);
+		}
+		$this->meth_Misc_ChangeMode(false,$Loc,$CurrVal,$Switch,$GetOb);
+	}
+
+	if ($Loc->FirstMerge) {
+		$Loc->FirstMerge =3D false;
+		// Check HtmlConv parameter
+		if (isset($Loc->PrmLst['htmlconv'])) {
+			$x =3D strtolower($Loc->PrmLst['htmlconv']);
+			$x =3D '+'.str_replace(' ','',$x).'+';
+			if (strpos($x,'+esc+')!=3D=3Dfalse)  {tbs_Misc_ConvSpe($Loc); $Loc->C=
onvHtml =3D false; $Loc->ConvEsc =3D true; }
+			if (strpos($x,'+wsp+')!=3D=3Dfalse)  {tbs_Misc_ConvSpe($Loc); $Loc->C=
onvWS =3D true; }
+			if (strpos($x,'+js+')!=3D=3Dfalse)   {tbs_Misc_ConvSpe($Loc); $Loc->C=
onvHtml =3D false; $Loc->ConvJS =3D true; }
+			if (strpos($x,'+no+')!=3D=3Dfalse)   $Loc->ConvHtml =3D false;
+			if (strpos($x,'+yes+')!=3D=3Dfalse)  $Loc->ConvHtml =3D true;
+			if (strpos($x,'+nobr+')!=3D=3Dfalse) {$Loc->ConvHtml =3D true; $Loc->=
ConvBr =3D false; }
+			if (strpos($x,'+look+')!=3D=3Dfalse) {tbs_Misc_ConvSpe($Loc); $Loc->C=
onvLook =3D true; }
+		} else {
+			if ($this->HtmlCharSet=3D=3D=3Dfalse) $Loc->ConvHtml =3D false; // No=
 HTML
+		}
+		// We protect the data that does not come from the source of the templ=
ate
+		if (isset($Loc->PrmLst['protect'])) {
+			$x =3D strtolower($Loc->PrmLst['protect']);
+			switch ($x) {
+			case 'no' : $Loc->ConvProtect =3D false; break;
+			case 'yes': $Loc->ConvProtect =3D true; break;
+			}
+		} else {
+			if ($this->Protect=3D=3D=3Dfalse) $Loc->ConvProtect =3D false;
+		}
+	}
+
+	// MaxLength
+	if (isset($Loc->PrmLst['max'])) {
+		$x =3D intval($Loc->PrmLst['max']);
+		if (strlen($CurrVal)>$x) {
+			if ($Loc->ConvHtml or ($this->HtmlCharSet=3D=3D=3Dfalse)) {
+				$CurrVal =3D substr($CurrVal,0,$x-1).$this->MaxEnd;
+			} else {
+				tbs_Html_Max($CurrVal,$x);
+			}
+		}
+	}
+
+	// HTML conversion, and TBS protection
+	if ($Loc->ConvSpe) { // Using special parameters
+		if ($Loc->ConvLook) {
+			$Loc->ConvHtml =3D !tbs_Html_IsHtml($OVal);
+			if ($Loc->ConvHtml=3D=3D=3Dfalse) $OVal =3D tbs_Html_GetPart($OVal,'B=
ODY',false,true);
+		}
+		if ($Loc->ConvHtml) {
+			$this->meth_Conv_Html($OVal);
+			if ($Loc->ConvBr) $OVal =3D nl2br($OVal);
+		}
+		if ($Loc->ConvEsc) $OVal =3D str_replace('\'','\'\'',$OVal);
+		if ($Loc->ConvWS) {
+			$check =3D '  ';
+			$nbsp =3D '&nbsp;';
+			do {
+				$pos =3D strpos($OVal,$check);
+				if ($pos!=3D=3Dfalse) $OVal =3D substr_replace($OVal,$nbsp,$pos,1);
+			} while ($pos!=3D=3Dfalse);
+		}
+		if ($Loc->ConvJS) {
+			$OVal =3D addslashes($OVal); // apply to ('), ("), (\) and (null)
+			$OVal =3D str_replace("\n",'\n',$OVal);
+			$OVal =3D str_replace("\r",'\r',$OVal);
+			$OVal =3D str_replace("\t",'\t',$OVal);
+		}
+	}	elseif ($Loc->ConvHtml) {
+		$this->meth_Conv_Html($OVal);
+		if ($Loc->ConvBr) $OVal =3D nl2br($OVal);
+	}
+	if ($Loc->ConvProtect) $OVal =3D str_replace($this->ChrOpen,$this->ChrP=
rotect,$OVal);
+	if ($CurrVal!=3D=3D$OVal) $CurrVal =3D str_replace($this->ChrVal,$OVal,=
$CurrVal);
+
+	// Case when it's an empty string
+	if ($CurrVal=3D=3D=3D'') {
+
+		if ($Loc->MagnetId=3D=3D=3Dfalse) {
+			if (isset($Loc->PrmLst['.'])) {
+				$Loc->MagnetId =3D -1;
+			} elseif (isset($Loc->PrmLst['ifempty'])) {
+				$Loc->MagnetId =3D -2;
+			} elseif (isset($Loc->PrmLst['magnet'])) {
+				$Loc->MagnetId =3D 1;
+				$Loc->PosBeg0 =3D $Loc->PosBeg;
+				$Loc->PosEnd0 =3D $Loc->PosEnd;
+				if (isset($Loc->PrmLst['mtype'])) {
+					switch ($Loc->PrmLst['mtype']) {
+					case 'm+m': $Loc->MagnetId =3D 2; break;
+					case 'm*': $Loc->MagnetId =3D 3; break;
+					case '*m': $Loc->MagnetId =3D 4; break;
+					}
+				}
+			} else {
+				$Loc->MagnetId =3D 0;
+			}
+		}
+
+		switch ($Loc->MagnetId) {
+		case 0: break;
+		case -1: $CurrVal =3D '&nbsp;'; break; // Enables to avoid blanks in H=
TML tables
+		case -2: $CurrVal =3D $Loc->PrmLst['ifempty']; break;
+		case 1:
+			$Loc->Enlarged =3D true;
+			tbs_Locator_EnlargeToTag($Txt,$Loc,$Loc->PrmLst['magnet'],false,false=
);
+			break;
+		case 2:
+			$Loc->Enlarged =3D true;
+			$CurrVal =3D tbs_Locator_EnlargeToTag($Txt,$Loc,$Loc->PrmLst['magnet'=
],false,true);
+			break;
+		case 3:
+			$Loc->Enlarged =3D true;
+			$Loc2 =3D tbs_Html_FindTag($Txt,$Loc->PrmLst['magnet'],true,$Loc->Pos=
Beg,false,1,false);
+			if ($Loc2!=3D=3Dfalse) {
+				$Loc->PosBeg =3D $Loc2->PosBeg;
+				if ($Loc->PosEnd<$Loc2->PosEnd) $Loc->PosEnd =3D $Loc2->PosEnd;
+			}
+			break;
+		case 4:
+			$Loc->Enlarged =3D true;
+			$Loc2 =3D tbs_Html_FindTag($Txt,$Loc->PrmLst['magnet'],true,$Loc->Pos=
Beg,true,1,false);
+			if ($Loc2!=3D=3Dfalse) $Loc->PosEnd =3D $Loc2->PosEnd;
+			break;
+		}
+		$NewEnd =3D $Loc->PosBeg; // Useful when mtype=3D'm+m'
+	} else {
+		$NewEnd =3D $Loc->PosBeg + strlen($CurrVal);
+	}
+
+	$Txt =3D substr_replace($Txt,$CurrVal,$Loc->PosBeg,$Loc->PosEnd-$Loc->P=
osBeg+1);
+
+	if ($Select) tbs_Html_MergeItems($Txt,$Loc,$CurrVal,$SelArray,$NewEnd);
+
+	return $NewEnd; // Returns the new end position of the field
+
+}
+
+function meth_Locator_FindBlockNext(&$Txt,$BlockName,$PosBeg,$ChrSub,$Sp=
ecial,&$P1,&$FieldBefore) {
+// Return the first block locator object just after the PosBeg position
+// If $Special=3D=3Dtrue =3D> don't set ->BlockSrc and accept TBS Fields=
 (used for automatic blocks)
+
+	$SearchDef =3D true;
+	$FirstField =3D false;
+
+	// Search for the first tag with parameter "block"
+	while ($SearchDef and ($Loc =3D $this->meth_Locator_FindTbs($Txt,$Block=
Name,$PosBeg,$ChrSub))) {
+		if (isset($Loc->PrmLst['block'])) {
+			$Block =3D $Loc->PrmLst['block'];
+			if ($P1) {
+				if (isset($Loc->PrmLst['p1'])) return false;
+			} else {
+				if (isset($Loc->PrmLst['p1'])) $P1 =3D true;
+			}
+			$SearchDef =3D false;
+		} elseif ($Special) {
+			return $Loc;
+		} elseif ($FirstField=3D=3D=3Dfalse) {
+			$FirstField =3D $Loc;
+		}
+		$PosBeg =3D $Loc->PosEnd;
+	}
+
+	if ($SearchDef) {
+		if ($FirstField!=3D=3Dfalse) $FieldBefore =3D true;
+		return false;
+	}
+
+	if ($Block=3D=3D=3D'begin') { // Block definied using begin/end
+
+		if (($FirstField!=3D=3Dfalse) and ($FirstField->PosEnd<$Loc->PosBeg)) =
$FieldBefore =3D true;
+
+		$Opened =3D 1;
+		while ($Loc2 =3D $this->meth_Locator_FindTbs($Txt,$BlockName,$PosBeg,$=
ChrSub)) {
+			if (isset($Loc2->PrmLst['block'])) {
+				switch ($Loc2->PrmLst['block']) {
+				case 'end':   $Opened--; break;
+				case 'begin': $Opened++; break;
+				}
+				if ($Opened=3D=3D0) {
+					if ($Special) {
+						$Loc->PosBeg2 =3D $Loc2->PosBeg;
+						$Loc->PosEnd2 =3D $Loc2->PosEnd;
+					} else {
+						$Loc->BlockSrc =3D substr($Txt,$Loc->PosEnd+1,$Loc2->PosBeg-$Loc->=
PosEnd-1);
+						$Loc->PosEnd =3D $Loc2->PosEnd;
+						$Loc->PosDef =3D 0;
+					}
+					$Loc->BlockFound =3D true;
+					return $Loc;
+				}
+			}
+			$PosBeg =3D $Loc2->PosEnd;
+		}
+
+		return $this->meth_Misc_Alert('Block definition','At least one block '=
.$this->ChrOpen.$Loc->FullName.$this->ChrClose.' with parameter \'block=3D=
end\' is missing.');
+
+	}
+
+	if ($Special) {
+		$Loc->PosBeg2 =3D false;
+	} else {
+
+		$Loc->PosDef =3D $Loc->PosBeg;
+		if (!$Loc->SubOk) {
+			$PosBeg1 =3D $Loc->PosBeg;
+			$PosEnd1 =3D $Loc->PosEnd;
+		}
+		if (tbs_Locator_EnlargeToTag($Txt,$Loc,$Block,true,false)=3D=3D=3Dfals=
e) return $this->meth_Misc_Alert('Block definition',$this->ChrOpen.$Loc->=
FullName.$this->ChrClose.' can not be defined because tag <'.$Loc->PrmLst=
['block'].'> or </'.$Loc->PrmLst['block'].'> is not found.');
+		$Loc->PosDef =3D $Loc->PosDef - $Loc->PosBeg;
+		if ($Loc->SubOk) {
+			$Loc->BlockSrc =3D substr($Txt,$Loc->PosBeg,$Loc->PosEnd-$Loc->PosBeg=
+1);
+			$Loc->PosDef++;
+		} else {
+			$Loc->BlockSrc =3D substr($Txt,$Loc->PosBeg,$PosBeg1-$Loc->PosBeg).su=
bstr($Txt,$PosEnd1+1,$Loc->PosEnd-$PosEnd1);	=09
+		}
+	}
+
+	$Loc->BlockFound =3D true;
+	if (($FirstField!=3D=3Dfalse) and ($FirstField->PosEnd<$Loc->PosBeg)) $=
FieldBefore =3D true;
+	return $Loc; // methods return by ref by default
+
+}
+
+function meth_Locator_FindBlockLst(&$Txt,$BlockName,$Pos) {
+// Return a locator object covering all block definitions, even if there=
 is no block definition found.
+
+	$LocR =3D& new clsTbsLocator;
+	$LocR->P1 =3D false;
+	$LocR->FieldOutside =3D false;
+	$LocR->BlockNbr =3D 0;
+	$LocR->BlockSrc =3D array(); // 1 to BlockNbr
+	$LocR->BlockLoc =3D array(); // 1 to BlockNbr
+	$LocR->BlockChk =3D array(); // 1 to BlockNbr
+	$LocR->BlockName =3D array(); // 1 to BlockNbr
+	$LocR->NoDataBid =3D false;
+	$LocR->SpecialBid =3D false;
+	$LocR->HeaderFound =3D false;
+	$LocR->FooterFound =3D false;
+	$LocR->WhenFound =3D false;
+	$LocR->WhenDefaultBid =3D false;
+	$LocR->SectionNbr =3D 0;
+	$LocR->SectionBid =3D array();       // 1 to SectionNbr
+	$LocR->SectionIsSerial =3D array();  // 1 to SectionNbr
+	$LocR->SectionSerialBid =3D array(); // 1 to SectionNbr
+	$LocR->SectionSerialOrd =3D array(); // 1 to SectionNbr
+	$LocR->SerialEmpty =3D false;
+
+	$Bid =3D& $LocR->BlockNbr;
+	$Sid =3D& $LocR->SectionNbr;
+	$Pid =3D 0;
+
+	do {
+
+		$Loc =3D $this->meth_Locator_FindBlockNext($Txt,$BlockName,$Pos,'.',fa=
lse,$LocR->P1,$LocR->FieldOutside);
+
+		if ($Loc=3D=3D=3Dfalse) {
+
+			if ($Pid>0) { // parentgrp mode =3D> disconnect $Txt from the source
+				$Src =3D $Txt;
+				$Txt =3D& $Parent[$Pid]['txt'];
+				if ($LocR->BlockFound) {
+					// Redefine the Header block
+					$LocR->BlockSrc[$Parent[$Pid]['bid']] =3D substr($Src,0,$LocR->PosB=
eg);
+					// Add a Footer block
+					tbs_Locator_SectionAddBlk($LocR,$BlockName,substr($Src,$LocR->PosEn=
d+1));
+					tbs_Locator_SectionAddGrp($LocR,$Bid,'F',$Parent[$Pid]['fld']);
+				}
+				// Now gowing down to previous level
+				$Pos =3D $Parent[$Pid]['pos'];
+				$LocR->PosBeg =3D $Parent[$Pid]['beg'];
+				$LocR->PosEnd =3D $Parent[$Pid]['end'];
+				$LocR->BlockFound =3D true;
+				unset($Parent[$Pid]);
+				$Pid--;
+				$Loc =3D true;
+			}
+
+		} else {
+
+			$Pos =3D $Loc->PosEnd;
+	=09
+			// Define the block limits
+			if ($LocR->BlockFound) {
+				if ( $LocR->PosBeg > $Loc->PosBeg ) $LocR->PosBeg =3D $Loc->PosBeg;
+				if ( $LocR->PosEnd < $Loc->PosEnd ) $LocR->PosEnd =3D $Loc->PosEnd;
+			} else {
+				$LocR->BlockFound =3D true;
+				$LocR->PosBeg =3D $Loc->PosBeg;
+				$LocR->PosEnd =3D $Loc->PosEnd;
+			}
+=09
+			// Merge block parameters
+			if (count($Loc->PrmLst)>0) $LocR->PrmLst =3D array_merge($LocR->PrmLs=
t,$Loc->PrmLst);
+=09
+			// Save the block and cache its tags (incrments $LocR->BlockNbr)
+			tbs_Locator_SectionAddBlk($LocR,$BlockName,$Loc->BlockSrc);
+=09
+			// Add the text in the list of blocks
+			if (isset($Loc->PrmLst['nodata'])) { // Nodata section
+				$LocR->NoDataBid =3D $Bid;
+			} elseif (isset($Loc->PrmLst['currpage'])) { // Special section (used=
 for navigation bar)
+				$LocR->SpecialBid =3D $Bid;
+			} elseif (isset($Loc->PrmLst['when'])) {
+				if ($LocR->WhenFound=3D=3D=3Dfalse) {
+					$LocR->WhenFound =3D true;
+					$LocR->WhenSeveral =3D false;
+					$LocR->WhenNbr =3D 0;
+					$LocR->WhenSectionBid[] =3D array(); // Bid of the section to displ=
ay
+					$LocR->WhenCondBid[] =3D array();    // Bid of the condition to che=
ck
+					$LocR->WhenBeforeNS[] =3D array();   // True if the When section mu=
st be displayed before a=20
+				}
+				$LocR->WhenNbr++;
+				if (isset($Loc->PrmLst['several'])) $LocR->WhenSeveral =3D true;
+				$LocR->WhenSectionBid[$LocR->WhenNbr] =3D $Bid;
+				$this->meth_Merge_PhpVar($Loc->PrmLst['when'],false);
+				tbs_Locator_SectionAddBlk($LocR,$BlockName,$Loc->PrmLst['when']);
+				$LocR->WhenCondBid[$LocR->WhenNbr] =3D $Bid;
+				$LocR->WhenBeforeNS[$LocR->WhenNbr] =3D ($Sid=3D=3D=3D0);
+			} elseif (isset($Loc->PrmLst['default'])) {
+				$LocR->WhenDefaultBid =3D $Bid;
+				$LocR->WhenDefaultBeforeNS =3D ($Sid=3D=3D=3D0);
+			} elseif (isset($Loc->PrmLst['headergrp'])) {
+				tbs_Locator_SectionAddGrp($LocR,$Bid,'H',$Loc->PrmLst['headergrp']);
+			} elseif (isset($Loc->PrmLst['footergrp'])) {
+				tbs_Locator_SectionAddGrp($LocR,$Bid,'F',$Loc->PrmLst['footergrp']);
+			} elseif (isset($Loc->PrmLst['splittergrp'])) {
+				tbs_Locator_SectionAddGrp($LocR,$Bid,'S',$Loc->PrmLst['splittergrp']=
);
+			} elseif (isset($Loc->PrmLst['parentgrp'])) {
+				tbs_Locator_SectionAddGrp($LocR,$Bid,'H',$Loc->PrmLst['parentgrp']);
+				$Pid++;
+				$Parent[$Pid]['bid'] =3D $Bid;
+				$Parent[$Pid]['fld'] =3D $Loc->PrmLst['parentgrp'];
+				$Parent[$Pid]['txt'] =3D& $Txt;
+				$Parent[$Pid]['pos'] =3D $Pos;
+				$Parent[$Pid]['beg'] =3D $LocR->PosBeg;
+				$Parent[$Pid]['end'] =3D $LocR->PosEnd;
+				$Txt =3D& $LocR->BlockSrc[$Bid];
+				$Pos =3D $Loc->PosDef + 1;
+				$LocR->BlockFound =3D false;
+				$LocR->PosBeg =3D false;
+				$LocR->PosEnd =3D false;
+			} elseif (isset($Loc->PrmLst['serial'])) {
+				// Section	with Serial Sub-Sections
+				$Src =3D& $LocR->BlockSrc[$Bid];
+				$Loc0 =3D false;
+				if ($LocR->SerialEmpty=3D=3D=3Dfalse) {
+					$NameSr =3D $BlockName.'_0';
+					$x =3D false;
+					$LocSr =3D $this->meth_Locator_FindBlockNext($Src,$NameSr,0,'.',fal=
se,$x,$x);
+					if ($LocSr!=3D=3Dfalse) {
+						$LocR->SerialEmpty =3D $LocSr->BlockSrc;
+						$Src =3D substr_replace($Src,'',$LocSr->PosBeg,$LocSr->PosEnd-$Loc=
Sr->PosBeg+1);
+					}
+				}
+				$NameSr =3D $BlockName.'_1';
+				$x =3D false;
+				$LocSr =3D $this->meth_Locator_FindBlockNext($Src,$NameSr,0,'.',fals=
e,$x,$x);
+				if ($LocSr!=3D=3Dfalse) {
+					$Sid++;
+					$LocR->SectionBid[$Sid] =3D $Bid;
+					$LocR->SectionIsSerial[$Sid] =3D true;
+					$LocR->SectionSerialBid[$Sid] =3D array();
+					$LocR->SectionSerialOrd[$Sid] =3D array();
+					$SrBid =3D& $LocR->SectionSerialBid[$Sid];
+					$SrOrd =3D& $LocR->SectionSerialOrd[$Sid];
+					$BidParent =3D $Bid;
+					$SrNum =3D 1;
+					do {
+						// Save previous sub-section
+						$LocR->BlockLoc[$BidParent][$SrNum] =3D $LocSr;
+						tbs_Locator_SectionAddBlk($LocR,$NameSr,$LocSr->BlockSrc);
+						$SrBid[$SrNum] =3D $Bid;
+						$SrOrd[$SrNum] =3D $SrNum;
+						$i =3D $SrNum;
+						while (($i>1) and ($LocSr->PosBeg<$LocR->BlockLoc[$BidParent][$SrO=
rd[$i-1]]->PosBeg)) {
+							$SrOrd[$i] =3D $SrOrd[$i-1];
+							$SrOrd[$i-1] =3D $SrNum;
+							$i--;
+						}
+						// Search next section
+						$SrNum++;
+						$NameSr =3D $BlockName.'_'.$SrNum;
+						$x =3D false;
+						$LocSr =3D $this->meth_Locator_FindBlockNext($Src,$NameSr,0,'.',fa=
lse,$x,$x);
+					} while ($LocSr!=3D=3Dfalse);
+					$SrBid[0] =3D $SrNum-1;
+				}
+			} else {
+				// Normal section
+				$Sid++;
+				$LocR->SectionBid[$Sid] =3D $Bid;
+				$LocR->SectionIsSerial[$Sid] =3D false;
+			}
+		=09
+		}
+
+	} while ($Loc!=3D=3Dfalse);
+
+	if ($LocR->WhenFound and ($Sid=3D=3D=3D0)) {
+		// Add a blank section if When is used without a normal section
+		tbs_Locator_SectionAddBlk($LocR,$BlockName,'');
+		$Sid++;
+		$LocR->SectionBid[$Sid] =3D $Bid;
+		$LocR->SectionIsSerial[$Sid] =3D false;
+	}
+
+	// Calculate Cache
+	if ($this->TurboBlock) {
+		for ($i=3D1;$i<=3D$LocR->BlockNbr;$i++) {
+			$this->meth_Locator_SectionCache($LocR,$i);
+		}
+	}
+
+	return $LocR; // methods return by ref by default
+
+}
+
+function meth_Merge_Block(&$Txt,&$BlockName,&$SrcId,&$Query,$PageSize,$P=
ageNum,$RecKnown) {
+
+	// Get source type and info
+	$Src =3D& new clsTbsDataSource;
+	$Src->BlockName =3D $BlockName;
+	if (!$Src->DataPrepare($SrcId,$this)) return 0;
+
+	$BlockId =3D 0;
+	$BlockLst =3D explode(',',$BlockName);
+	$BlockNbr =3D count($BlockLst);
+	$WasP1 =3D false;
+	$NbrRecTot =3D 0;
+	$QueryZ =3D& $Query;
+
+	while ($BlockId<$BlockNbr) {
+
+		$RecStop =3D 0; // Stop the merge after this row
+		$RecSpe =3D 0;  // Row with a special block's definition (used for the=
 navigation bar)
+		$QueryOk =3D true;
+		$NoFct =3D true;
+		$Src->BlockName =3D trim($BlockLst[$BlockId]);
+
+		// Search the block
+		$LocR =3D $this->meth_Locator_FindBlockLst($Txt,$Src->BlockName,0);
+
+		if ($LocR->BlockFound) {
+			if ($LocR->SpecialBid!=3D=3Dfalse) $RecSpe =3D $RecKnown;
+			// OnSection
+			if (isset($LocR->PrmLst['onsection'])) {
+				$LocR->OnSecInfo =3D $LocR->PrmLst['onsection'];
+				$ErrMsg =3D false;
+				if ($this->meth_Misc_UserFctCheck($LocR->OnSecInfo,$ErrMsg)) {
+					$LocR->OnSecPrm =3D array($BlockName,'','','');
+					$NoFct =3D false;
+				} else {
+					$this->meth_Misc_Alert('Block definition \''.$BlockName.'\'',$ErrMs=
g);
+				}
+			}
+			// OnData
+			if (isset($LocR->PrmLst['ondata'])) {
+				if ($LocR->PrmLst['ondata']!=3D=3D$Src->OnDataSave) {
+					$Src->OnDataSave =3D $LocR->PrmLst['ondata'];
+					$Src->OnDataInfo =3D $Src->OnDataSave;
+					$ErrMsg =3D false;
+					if ($this->meth_Misc_UserFctCheck($Src->OnDataInfo,$ErrMsg)) {
+						$Src->OnDataPrm =3D array($BlockName,'','');
+					} else {
+						$Src->OnDataInfo =3D false;
+						$this->meth_Misc_Alert('Block definition \''.$BlockName.'\'',$ErrM=
sg);
+					}
+				}
+			}
+			// Dynamic query
+			if ($LocR->P1) {
+				if (is_string($Query)) {
+					$Src->RecSaved =3D false;
+					unset($QueryZ); $QueryZ =3D ''.$Query;
+					$i =3D 1;
+					do {
+						$x =3D 'p'.$i;
+						if (isset($LocR->PrmLst[$x])) {
+							$QueryZ =3D str_replace('%p'.$i.'%',$LocR->PrmLst[$x],$QueryZ);
+							$i++;
+						} else {
+							$i =3D false;
+						}
+					} while ($i!=3D=3Dfalse);
+				}
+				$WasP1 =3D true;
+			} elseif (($Src->RecSaved=3D=3D=3Dfalse) and ($BlockNbr-$BlockId>1)) =
{
+				$Src->RecSaving =3D true;
+			}
+		} else {
+			if ($WasP1) {
+				$QueryOk =3D false;
+				$WasP1 =3D false;
+			} else {
+				$RecStop =3D 1;
+			}
+		}
+
+		// Open the recordset
+		if ($QueryOk) {
+			if ((!$LocR->BlockFound) and (!$LocR->FieldOutside)) {
+				$QueryOk =3D false;
+			}	else {
+				$QueryOk =3D $Src->DataOpen($QueryZ,$PageSize,$PageNum,$RecStop);
+			}
+		}
+
+		// Merge sections
+		if ($QueryOk) {
+			if ($Src->Type=3D=3D=3D4) { // Special for Text merge
+				if ($LocR->BlockFound) {
+					$Src->RecNum =3D 1;
+					$Src->CurrRec =3D false;
+					if ($NoFct=3D=3D=3Dfalse) {
+						$LocR->OnSecPrm[1] =3D& $Src->CurrRec ; $LocR->OnSecPrm[2] =3D& $S=
rc->RecSet; $LocR->OnSecPrm[3] =3D& $Src->RecNum;
+						call_user_func_array($LocR->OnSecInfo,$LocR->OnSecPrm);
+					}
+					$Txt =3D substr_replace($Txt,$Src->RecSet,$LocR->PosBeg,$LocR->PosE=
nd-$LocR->PosBeg+1);
+				} else {
+					$Src->DataAlert('Can\'t merge the block with a text value because t=
he block definition is not found.');
+				}
+			} else { // Other data source type
+				$Src->DataFetch();
+				if ($LocR->BlockFound!=3D=3Dfalse) $this->meth_Merge_BlockSections($=
Txt,$LocR,$Src,$NoFct,$RecSpe,$RecStop);
+				// Mode Page: Calculate the value to return
+				if (($PageSize>0) and ($Src->RecNum>=3D$RecStop)) {
+					if ($RecKnown<0) { // Pass pages in order to count all records
+						do {
+							$Src->DataFetch();
+						} while ($Src->CurrRec!=3D=3Dfalse);
+					} else { // We know that there is more records
+						if ($RecKnown>$Src->RecNum) $Src->RecNum =3D $RecKnown;
+					}
+				}
+			}
+			$Src->DataClose(); // Close the resource
+		}
+
+		if (!$WasP1) {
+			$NbrRecTot +=3D $Src->RecNum;
+			if ($LocR->FieldOutside and $QueryOk) {
+				// Merge last record on the entire template
+				$Pos =3D 0;
+				$ChkSub =3D ($Src->CurrRec!=3D=3Dfalse);
+				while ($Loc =3D $this->meth_Locator_FindTbs($Txt,$Src->BlockName,$Po=
s,'.')) {
+					if ($Loc->SubName=3D=3D=3D'#') {
+						$Pos =3D $this->meth_Locator_Replace($Txt,$Loc,$Src->RecNum,false)=
;
+					} else {
+						$Pos =3D $this->meth_Locator_Replace($Txt,$Loc,$Src->CurrRec,$ChkS=
ub);
+					}
+				}
+			}
+			$BlockId++;
+		}
+
+	} // -> while ($BlockId<$BlockNbr) {...
+
+	// End of the merge
+	unset($Src); unset($LocR); return $NbrRecTot;
+
+}
+
+function meth_Merge_BlockSections(&$Txt,&$LocR,&$Src,&$NoFct,&$RecSpe,&$=
RecStop) {
+
+	// Initialise
+	$SecId =3D 0;
+	$SecOk =3D ($LocR->SectionNbr>0);
+	$SecIncr =3D true;
+	$BlockRes =3D ''; // The result of the chained merged blocks
+	$SerialMode =3D false;
+	$SerialNum =3D 0;
+	$SerialMax =3D 0;
+	$SerialTxt =3D array();
+	$GrpFound =3D ($LocR->HeaderFound or $LocR->FooterFound);
+
+	// Main loop
+	//$Src->DataFetch();
+	while($Src->CurrRec!=3D=3Dfalse) {
+
+		// Headers and Footers
+		if ($GrpFound) {
+			$grp_change =3D false;
+			$grp_src =3D '';
+			if ($LocR->FooterFound) {
+				$change =3D false;
+				for ($i=3D$LocR->FooterNbr;$i>=3D1;$i--) {
+					$x =3D $Src->CurrRec[$LocR->FooterField[$i]];
+					if ($Src->RecNum=3D=3D=3D1) {
+						$LocR->FooterPrevValue[$i] =3D $x;
+					} else {
+						if ($LocR->FooterIsFooter[$i]) {
+							$change_i =3D& $change;
+						} else {
+							unset($change_i); $change_i =3D false;
+						}
+						if (!$change_i) $change_i =3D !($LocR->FooterPrevValue[$i]=3D=3D=3D=
$x);
+						if ($change_i) {
+							$grp_change =3D true;
+							$grp_src =3D $this->meth_Merge_SectionNormal($LocR,$LocR->FooterB=
id[$i],$PrevRec,$PrevNum,$PrevKey,$NoFct).$grp_src;
+							$LocR->FooterPrevValue[$i] =3D $x;
+						}
+					}
+				}
+				$PrevRec =3D $Src->CurrRec;
+				$PrevNum =3D $Src->RecNum;
+				$PrevKey =3D $Src->RecKey;
+			}
+			if ($LocR->HeaderFound) {
+				$change =3D ($Src->RecNum=3D=3D=3D1);
+				for ($i=3D1;$i<=3D$LocR->HeaderNbr;$i++) {
+					$x =3D $Src->CurrRec[$LocR->HeaderField[$i]];
+					if (!$change) $change =3D !($LocR->HeaderPrevValue[$i]=3D=3D=3D$x);
+					if ($change) {
+						$grp_src .=3D $this->meth_Merge_SectionNormal($LocR,$LocR->HeaderB=
id[$i],$Src->CurrRec,$Src->RecNum,$Src->RecKey,$NoFct);
+						$LocR->HeaderPrevValue[$i] =3D $x;
+					}
+				}
+				$grp_change =3D ($grp_change or $change);
+			}
+			if ($grp_change) {
+				if ($SerialMode) {
+					$BlockRes .=3D $this->meth_Merge_SectionSerial($LocR,$SecId,$Serial=
Num,$SerialMax,$SerialTxt);
+					$SecIncr =3D true;
+				}
+				$BlockRes .=3D $grp_src;
+			}
+		} // end of header and footer
+
+		// Increment Section
+		if ($SecIncr and $SecOk) {
+			$SecId++;
+			if ($SecId>$LocR->SectionNbr) $SecId =3D 1;
+			$SerialMode =3D $LocR->SectionIsSerial[$SecId];
+			if ($SerialMode) {
+				$SerialNum =3D 0;
+				$SerialMax =3D $LocR->SectionSerialBid[$SecId][0];
+				$SecIncr =3D false;
+			}
+		}
+
+		// Serial Mode Activation
+		if ($SerialMode) { // Serial Merge
+			$SerialNum++;
+			$Bid =3D $LocR->SectionSerialBid[$SecId][$SerialNum];
+			$SerialTxt[$SerialNum] =3D $this->meth_Merge_SectionNormal($LocR,$Bid=
,$Src->CurrRec,$Src->RecNum,$Src->RecKey,$NoFct);
+			if ($SerialNum>=3D$SerialMax) {
+				$BlockRes .=3D $this->meth_Merge_SectionSerial($LocR,$SecId,$SerialN=
um,$SerialMax,$SerialTxt);
+				$SecIncr =3D true;
+			}
+		} else { // Classic merge
+			if ($Src->RecNum=3D=3D=3D$RecSpe) {
+				$Bid =3D $LocR->SpecialBid;
+			} else {
+				$Bid =3D $LocR->SectionBid[$SecId];
+			}
+			if ($LocR->WhenFound) { // With conditional blocks
+				$x =3D $this->meth_Merge_SectionNormal($LocR,$Bid,$Src->CurrRec,$Src=
->RecNum,$Src->RecKey,$NoFct);
+				$found =3D false;
+				$continue =3D true;
+				$i =3D 1;
+				do {
+					$cond =3D $this->meth_Merge_SectionNormal($LocR,$LocR->WhenCondBid[=
$i],$Src->CurrRec,$Src->RecNum,$Src->RecKey,$NoFct);
+					if (tbs_Misc_CheckCondition($cond)) {
+						$x_when =3D $this->meth_Merge_SectionNormal($LocR,$LocR->WhenSecti=
onBid[$i],$Src->CurrRec,$Src->RecNum,$Src->RecKey,$NoFct);
+						if ($LocR->WhenBeforeNS[$i]) {$x =3D $x_when.$x;} else {$x =3D $x.=
$x_when;}
+						$found =3D true;
+						if ($LocR->WhenSeveral=3D=3D=3Dfalse) $continue =3D false;
+					}
+					$i++;
+					if ($i>$LocR->WhenNbr) $continue =3D false;
+				} while ($continue);
+				if (($found=3D=3D=3Dfalse) and ($LocR->WhenDefaultBid!=3D=3Dfalse)) =
{
+					$x_when =3D $this->meth_Merge_SectionNormal($LocR,$LocR->WhenDefaul=
tBid,$Src->CurrRec,$Src->RecNum,$Src->RecKey,$NoFct);
+					if ($LocR->WhenDefaultBeforeNS) {$x =3D $x_when.$x;} else {$x =3D $=
x.$x_when;}
+				}
+				$BlockRes .=3D $x;
+			} else { // Without conditional blocks
+				$BlockRes .=3D $this->meth_Merge_SectionNormal($LocR,$Bid,$Src->Curr=
Rec,$Src->RecNum,$Src->RecKey,$NoFct);
+			}
+		}
+
+		// Next row
+		if ($Src->RecNum=3D=3D=3D$RecStop) {
+			$Src->CurrRec =3D false;
+		} else {
+			// $CurrRec can be set to False by the OnSection event function.
+			if ($Src->CurrRec!=3D=3Dfalse) $Src->DataFetch();
+		}
+
+	} //--> while($CurrRec!=3D=3Dfalse) {
+
+	// Serial: merge the extra the sub-blocks
+	if ($SerialMode and !$SecIncr) {
+		$BlockRes .=3D $this->meth_Merge_SectionSerial($LocR,$SecId,$SerialNum=
,$SerialMax,$SerialTxt);
+	}
+
+	// Footer
+	if ($LocR->FooterFound) {
+		if ($Src->RecNum>0) {
+			for ($i=3D1;$i<=3D$LocR->FooterNbr;$i++) {
+				if ($LocR->FooterIsFooter[$i]) $BlockRes .=3D $this->meth_Merge_Sect=
ionNormal($LocR,$LocR->FooterBid[$i],$PrevRec,$PrevNum,$PrevKey,$NoFct);
+			}
+		}
+	}
+
+	// NoData
+	if (($Src->RecNum=3D=3D=3D0) and ($LocR->NoDataBid!=3D=3Dfalse)) $Block=
Res =3D $LocR->BlockSrc[$LocR->NoDataBid];
+=09
+	// Merge the result
+	$Txt =3D substr_replace($Txt,$BlockRes,$LocR->PosBeg,$LocR->PosEnd-$Loc=
R->PosBeg+1);
+
+}
+
+function meth_Merge_PhpVar(&$Txt,$HtmlConv) {
+// Merge the PHP global variables of the main script.
+
+	$Pref =3D& $this->VarPrefix;
+	$PrefL =3D strlen($Pref);
+	$PrefOk =3D ($PrefL>0);
+
+	if ($HtmlConv=3D=3D=3Dfalse) {
+		$HtmlCharSet =3D $this->HtmlCharSet;
+		$this->HtmlCharSet =3D false;
+	}
+
+	// Then we scann all fields in the model
+	$x =3D '';
+	$Pos =3D 0;
+	while ($Loc =3D $this->meth_Locator_FindTbs($Txt,'var',$Pos,'.')) {
+		if ($Loc->SubNbr>0) {
+			if ($Loc->SubLst[0]=3D=3D=3D'') {
+				$Pos =3D $this->meth_Merge_System($Txt,$Loc);
+			} elseif ($Loc->SubLst[0][0]=3D=3D=3D'~') {
+				if (!isset($ObjOk)) $ObjOk =3D (is_object($this->ObjectRef) or is_ar=
ray($this->ObjectRef));
+				if ($ObjOk) {
+					$Loc->SubLst[0] =3D substr($Loc->SubLst[0],1);
+					$Pos =3D $this->meth_Locator_Replace($Txt,$Loc,$this->ObjectRef,tru=
e);
+				} elseif (isset($Loc->PrmLst['noerr'])) {
+					$Pos =3D $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+				} else {
+					$this->meth_Misc_Alert('Merge ObjectRef sub item','Can\'t merge '.$=
this->ChrOpen.$Loc->FullName.$this->ChrClose.' because property ObjectRef=
 is neither an object nor an array. Its type is \''.gettype($this->Object=
Ref).'\'.',true);
+					$Pos =3D $Loc->PosEnd + 1;
+				}
+			} elseif ($PrefOk and (substr($Loc->SubLst[0],0,$PrefL)!=3D=3D$Pref))=
 {
+				if (isset($Loc->PrmLst['noerr'])) {
+					$Pos =3D $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+				} else {
+					$this->meth_Misc_Alert('Merge PHP global variables','Can\'t merge '=
.$this->ChrOpen.$Loc->FullName.$this->ChrClose.' because allowed prefix i=
s set to \''.$Pref.'\'.',true);
+					$Pos =3D $Loc->PosEnd + 1;
+				}
+			} elseif (isset($GLOBALS[$Loc->SubLst[0]])) {
+				$Pos =3D $this->meth_Locator_Replace($Txt,$Loc,$GLOBALS,true);
+			} else {
+				if (isset($Loc->PrmLst['noerr'])) {
+					$Pos =3D $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+				} else {
+					$Pos =3D $Loc->PosEnd + 1;
+					$this->meth_Misc_Alert('Merge PHP global variables','Can\'t merge '=
.$this->ChrOpen.$Loc->FullName.$this->ChrClose.' because there is no PHP =
global variable named \''.$Loc->SubLst[0].'\'.',true);
+				}
+			}
+		}
+	}
+
+	if ($HtmlConv=3D=3D=3Dfalse) $this->HtmlCharSet =3D $HtmlCharSet;
+
+}
+
+function meth_Merge_System(&$Txt,&$Loc) {
+// This function enables to merge TBS special fields
+
+	if (isset($Loc->SubLst[1])) {
+		switch ($Loc->SubLst[1]) {
+		case 'now':
+			$x =3D mktime();
+			return $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+		case 'version':
+			$x =3D '2.05.8';
+			return $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+		case 'script_name':
+			if (isset($_SERVER)) { // PHP<4.1.0 compatibilty
+				$x =3D tbs_Misc_GetFilePart($_SERVER['PHP_SELF'],1);
+			} else {
+				global $HTTP_SERVER_VARS;
+				$x =3D tbs_Misc_GetFilePart($HTTP_SERVER_VARS['PHP_SELF'],1);
+			}
+			return $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+		case 'template_name':
+			return $this->meth_Locator_Replace($Txt,$Loc,$this->_LastFile,false);
+		case 'template_date':
+			$x =3D filemtime($this->_LastFile);
+			return $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+		case 'template_path':
+			$x =3D tbs_Misc_GetFilePart($this->_LastFile,0);
+			return $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+		case 'name':
+			$x =3D 'TinyButStrong';
+			return $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+		case 'logo':
+			$x =3D '**TinyButStrong**';
+			return $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+		case 'charset':
+			return $this->meth_Locator_Replace($Txt,$Loc,$this->HtmlCharSet,false=
);
+		case 'tplvars':
+			if ($Loc->SubNbr=3D=3D2) {
+				$x =3D implode(',',array_keys($this->TplVars));
+				return $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+			} else {
+				if (isset($this->TplVars[$Loc->SubLst[2]])) {
+					array_shift($Loc->SubLst);
+					array_shift($Loc->SubLst);
+					$Loc->SubNbr =3D $Loc->SubNbr - 2;
+					return $this->meth_Locator_Replace($Txt,$Loc,$this->TplVars,true);
+				} else {
+					$this->meth_Misc_Alert('System Fields','Can\'t merge ['.$Loc->FullN=
ame.'] because property TplVars doesn\'t have any item named \''.$Loc->Su=
bLst[2].'\'.');
+					return $Loc->PosBeg+1;
+				}
+			}
+		case '':
+			$this->meth_Misc_Alert('System Fields','Can\'t merge ['.$Loc->FullNam=
e.'] because it doesn\'t have any requested keyword.');
+			return $Loc->PosBeg+1;
+		default:
+			$this->meth_Misc_Alert('System Fields','Can\'t merge ['.$Loc->FullNam=
e.'] because \''.$Loc->SubLst[1].'\' is an unknown keyword.');
+			return $Loc->PosBeg+1;
+		}
+	} else {
+		$this->meth_Misc_Alert('System Fields','Can\'t merge ['.$Loc->FullName=
.'] because it doesn\'t have any subname.');
+		return $Loc->PosBeg+1;
+	}
+
+}
+
+function meth_Merge_Special($Type) {
+// Proceed to one of the special merge
+
+	if ($Type=3D=3D=3D'*') $Type =3D 'onload,onshow,var';
+
+	$TypeLst =3D explode(',',$Type);
+	foreach ($TypeLst as $Type) {
+		switch ($Type) {
+		case 'var':	$this->meth_Merge_PhpVar($this->Source,true); break;
+		case 'onload': $this->meth_Merge_Auto($this->Source,'onload',true,true=
); break;
+		case 'onshow': $this->meth_Merge_Auto($this->Source,'onshow',false,tru=
e); break;
+		}
+	}
+
+}
+
+function meth_Merge_SectionNormal(&$LocR,&$BlockId,&$CurrRec,&$RecNum,&$=
RecKey,&$NoFct) {
+
+	$Txt =3D $LocR->BlockSrc[$BlockId];
+
+	if ($NoFct) {
+		$LocLst =3D& $LocR->BlockLoc[$BlockId];
+		$iMax =3D $LocLst[0];
+		$PosMax =3D strlen($Txt);
+		$DoUnCached =3D& $LocR->BlockChk[$BlockId];
+	} else {
+		$Txt0 =3D $Txt;
+		$LocR->OnSecPrm[1] =3D& $CurrRec ; $LocR->OnSecPrm[2] =3D& $Txt; $LocR=
->OnSecPrm[3] =3D& $RecNum;
+		call_user_func_array($LocR->OnSecInfo,$LocR->OnSecPrm);
+		if ($Txt0=3D=3D=3D$Txt) {
+			$LocLst =3D& $LocR->BlockLoc[$BlockId];
+			$iMax =3D $LocLst[0];
+			$PosMax =3D strlen($Txt);
+			$DoUnCached =3D& $LocR->BlockChk[$BlockId];
+		} else {
+			$iMax =3D 0;
+			$DoUnCached =3D true;
+		}
+	}
+
+	if ($RecNum=3D=3D=3Dfalse) { // Erase all fields
+
+		$x =3D '';
+
+		// Chached locators
+		for ($i=3D$iMax;$i>0;$i--) {
+			if ($LocLst[$i]->PosBeg<$PosMax) {
+				$this->meth_Locator_Replace($Txt,$LocLst[$i],$x,false);
+				if ($LocLst[$i]->Enlarged) {
+					$PosMax =3D $LocLst[$i]->PosBeg;
+					$LocLst[$i]->PosBeg =3D $LocLst[$i]->PosBeg0;
+					$LocLst[$i]->PosEnd =3D $LocLst[$i]->PosEnd0;
+					$LocLst[$i]->Enlarged =3D false;
+				}
+			}
+		}
+
+		// Unchached locators
+		if ($DoUnCached) {
+			$BlockName =3D& $LocR->BlockName[$BlockId];
+			$Pos =3D 0;
+			while ($Loc =3D $this->meth_Locator_FindTbs($Txt,$BlockName,$Pos,'.')=
) $Pos =3D $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+		}	=09
+
+	} else {
+
+		// Chached locators
+		for ($i=3D$iMax;$i>0;$i--) {
+			if ($LocLst[$i]->PosBeg<$PosMax) {
+				if ($LocLst[$i]->IsRecInfo) {
+					if ($LocLst[$i]->RecInfo=3D=3D=3D'#') {
+						$this->meth_Locator_Replace($Txt,$LocLst[$i],$RecNum,false);
+					} else {
+						$this->meth_Locator_Replace($Txt,$LocLst[$i],$RecKey,false);
+					}
+				} else {
+					$this->meth_Locator_Replace($Txt,$LocLst[$i],$CurrRec,true);
+				}
+				if ($LocLst[$i]->Enlarged) {
+					$PosMax =3D $LocLst[$i]->PosBeg;
+					$LocLst[$i]->PosBeg =3D $LocLst[$i]->PosBeg0;
+					$LocLst[$i]->PosEnd =3D $LocLst[$i]->PosEnd0;
+					$LocLst[$i]->Enlarged =3D false;
+				}
+			}
+		}
+
+		// Unchached locators
+		if ($DoUnCached) {
+			$BlockName =3D& $LocR->BlockName[$BlockId];
+			foreach ($CurrRec as $key =3D> $val) {
+				$Pos =3D 0;
+				$Name =3D $BlockName.'.'.$key;
+				while ($Loc =3D $this->meth_Locator_FindTbs($Txt,$Name,$Pos,'.')) {
+					$Pos =3D $this->meth_Locator_Replace($Txt,$Loc,$val,true);
+				}
+			}
+			$Pos =3D 0;
+			$Name =3D $BlockName.'.#';
+			while ($Loc =3D $this->meth_Locator_FindTbs($Txt,$Name,$Pos,'.')) $Po=
s =3D $this->meth_Locator_Replace($Txt,$Loc,$RecNum,true);
+			$Pos =3D 0;
+			$Name =3D $BlockName.'.$';
+			while ($Loc =3D $this->meth_Locator_FindTbs($Txt,$Name,$Pos,'.')) $Po=
s =3D $this->meth_Locator_Replace($Txt,$Loc,$RecKey,true);
+		}
+
+	}
+
+	return $Txt;
+
+}
+
+function meth_Merge_SectionSerial(&$LocR,&$SecId,&$SerialNum,&$SerialMax=
,&$SerialTxt) {
+
+	$Txt =3D $LocR->BlockSrc[$LocR->SectionBid[$SecId]];
+	$LocLst =3D& $LocR->BlockLoc[$LocR->SectionBid[$SecId]];
+	$OrdLst =3D& $LocR->SectionSerialOrd[$SecId];
+
+	// Prepare the Empty Item
+	if ($SerialNum<$SerialMax) {
+		if ($LocR->SerialEmpty=3D=3D=3Dfalse) {
+			$F =3D false;
+			$NoFct =3D true;
+		} else {
+			$EmptySrc =3D& $LocR->SerialEmpty;
+		}
+	}
+
+	// All Items
+	for ($i=3D$SerialMax;$i>0;$i--) {
+		$Sr =3D $OrdLst[$i];
+		if ($Sr>$SerialNum) {
+			if ($LocR->SerialEmpty=3D=3D=3Dfalse) {
+				$k =3D $LocR->SectionSerialBid[$SecId][$Sr];
+				$EmptySrc =3D $this->meth_Merge_SectionNormal($LocR,$k,$F,$F,$F,$NoF=
ct);
+			}
+			$Txt =3D substr_replace($Txt,$EmptySrc,$LocLst[$Sr]->PosBeg,$LocLst[$=
Sr]->PosEnd-$LocLst[$Sr]->PosBeg+1);
+		} else {
+			$Txt =3D substr_replace($Txt,$SerialTxt[$Sr],$LocLst[$Sr]->PosBeg,$Lo=
cLst[$Sr]->PosEnd-$LocLst[$Sr]->PosBeg+1);
+		}
+	}
+
+	// Update variables
+	$SerialNum =3D 0;
+	$SerialTxt =3D array();
+
+	return $Txt;
+
+}
+
+function meth_Merge_Auto(&$Txt,$Name,$TplVar,$AcceptGrp) {
+// onload - onshow
+
+	$GrpDisplayed =3D array();
+	$GrpExclusive =3D array();
+	$P1 =3D false;
+	$FieldBefore =3D false;
+	$Pos =3D 0;
+
+	if ($AcceptGrp) {
+		$ChrSub =3D '_';
+	} else {
+		$ChrSub =3D '';
+	}
+
+	while ($LocA=3D$this->meth_Locator_FindBlockNext($Txt,$Name,$Pos,$ChrSu=
b,true,$P1,$FieldBefore)) {
+
+		if ($LocA->BlockFound) {
+
+			if (!isset($GrpDisplayed[$LocA->SubName])) {
+				$GrpDisplayed[$LocA->SubName] =3D false;
+				$GrpExclusive[$LocA->SubName] =3D !($AcceptGrp and ($LocA->SubName=3D=
=3D=3D''));
+			}
+			$Displayed =3D& $GrpDisplayed[$LocA->SubName];
+			$Exclusive =3D& $GrpExclusive[$LocA->SubName];
+
+			$DelBlock =3D false;
+			$DelField =3D false;
+			if ($Displayed and $Exclusive) {
+				$DelBlock =3D true;
+			} else {
+				if (isset($LocA->PrmLst['when'])) {
+					if (isset($LocA->PrmLst['several'])) $Exclusive=3Dfalse;
+					$x =3D $LocA->PrmLst['when'];
+					$this->meth_Merge_PhpVar($x,false);
+					if (tbs_Misc_CheckCondition($x)) {
+						$DelField =3D true;
+						$Displayed =3D true;
+					} else {
+						$DelBlock =3D true;
+					}
+				} elseif(isset($LocA->PrmLst['default'])) {
+					if ($Displayed) {
+						$DelBlock =3D true;
+					} else {
+						$Displayed =3D true;
+						$DelField =3D true;
+					}
+					$Exclusive =3D true; // No more block displayed for the group after=
 VisElse
+				}
+			}
+						=09
+			// Del parts
+			if ($DelField) {
+				if ($LocA->PosBeg2!=3D=3Dfalse) $Txt =3D substr_replace($Txt,'',$Loc=
A->PosBeg2,$LocA->PosEnd2-$LocA->PosBeg2+1);
+				$Txt =3D substr_replace($Txt,'',$LocA->PosBeg,$LocA->PosEnd-$LocA->P=
osBeg+1);
+				$Pos =3D $LocA->PosBeg;
+			} else {
+				if ($LocA->PosBeg2=3D=3D=3Dfalse) {
+					tbs_Locator_EnlargeToTag($Txt,$LocA,$LocA->PrmLst['block'],true,fal=
se);
+				} else {
+					$LocA->PosEnd =3D $LocA->PosEnd2;
+				}
+				if ($DelBlock) {
+					$Txt =3D substr_replace($Txt,'',$LocA->PosBeg,$LocA->PosEnd-$LocA->=
PosBeg+1);
+				} else {
+					// Merge the block as if it was a field
+					$x =3D '';
+					$this->meth_Locator_Replace($Txt,$LocA,$x,false);
+				}
+				$Pos =3D $LocA->PosBeg;
+			}
+
+		} else { // Field
+
+			// Check for Template Var
+			if ($TplVar and	isset($LocA->PrmLst['tplvars'])) {
+				$Ok =3D false;
+				foreach ($LocA->PrmLst as $Key =3D> $Val) {
+					if ($Ok) {
+						$this->TplVars[$Key] =3D $Val;
+					} else {
+						if ($Key=3D=3D=3D'tplvars') $Ok =3D true;
+					}
+				}
+			}
+
+			$x =3D '';
+			$Pos =3D $this->meth_Locator_Replace($Txt,$LocA,$x,false);
+			$Pos =3D $LocA->PosBeg;
+
+		}
+
+	}
+
+	return count($GrpDisplayed);
+
+}
+
+function meth_Merge_NavigationBar(&$Txt,$BlockName,$Options,$PageCurr,$R=
ecCnt,$PageSize) {
+
+	// Get block parameters
+	$PosBeg =3D 0;
+	$PrmLst =3D array();
+	while ($Loc =3D $this->meth_Locator_FindTbs($Txt,$BlockName,$PosBeg,'.'=
)) {
+		if (isset($Loc->PrmLst['block'])) $PrmLst =3D array_merge($PrmLst,$Loc=
->PrmLst);
+		$PosBeg =3D $Loc->PosEnd;
+	}
+
+	// Prepare options
+	if (!is_array($Options)) $Options =3D array('navsize'=3D>intval($Option=
s));
+	$Options =3D array_merge($Options,$PrmLst);
+
+	// Default options
+	if (!isset($Options['navsize'])) $Options['navsize'] =3D 10;
+	if (!isset($Options['navpos'])) $Options['navpos'] =3D 'step';
+	if (!isset($Options['navdel'])) $Options['navdel'] =3D '';
+	if (!isset($Options['pagemin'])) $Options['pagemin'] =3D 1;
+
+	// Check options
+	if ($Options['navsize']<=3D0) $Options['navsize'] =3D 10;
+	if ($PageSize<=3D0) $PageSize =3D 1;
+	if ($PageCurr<$Options['pagemin']) $PageCurr =3D $Options['pagemin'];
+
+	$CurrPos =3D 0;
+	$CurrNav =3D array('curr'=3D>$PageCurr,'first'=3D>$Options['pagemin'],'=
last'=3D>-1,'bound'=3D>false);
+
+	// Calculate displayed PageMin and PageMax
+	if ($Options['navpos']=3D=3D'centred') {
+		$PageMin =3D $Options['pagemin']-1+$PageCurr - intval(floor($Options['=
navsize']/2));
+	} else {
+		// Display by block
+		$PageMin =3D $Options['pagemin']-1+$PageCurr - ( ($PageCurr-1) % $Opti=
ons['navsize']);
+	}
+	$PageMin =3D max($PageMin,$Options['pagemin']);
+	$PageMax =3D $PageMin + $Options['navsize'] - 1;
+
+	// Calculate previous and next pages
+	$CurrNav['prev'] =3D $PageCurr - 1;
+	if ($CurrNav['prev']<$Options['pagemin']) {
+		$CurrNav['prev'] =3D $Options['pagemin'];
+		$CurrNav['bound'] =3D $Options['pagemin'];
+	}
+	$CurrNav['next'] =3D $PageCurr + 1;
+	if ($RecCnt>=3D0) {
+		$PageCnt =3D $Options['pagemin']-1 + intval(ceil($RecCnt/$PageSize));
+		$PageMax =3D min($PageMax,$PageCnt);
+		$PageMin =3D max($Options['pagemin'],$PageMax-$Options['navsize']+1);
+	} else {
+		$PageCnt =3D $Options['pagemin']-1;
+	}
+	if ($PageCnt>=3D$Options['pagemin']) {
+		if ($PageCurr>=3D$PageCnt) {
+			$CurrNav['next'] =3D $PageCnt;
+			$CurrNav['last'] =3D $PageCnt;
+			$CurrNav['bound'] =3D $PageCnt;
+		} else {
+			$CurrNav['last'] =3D $PageCnt;
+		}
+	}=09
+
+	// Display or hide the bar
+	if ($Options['navdel']=3D=3D'') {
+		$Display =3D true;
+	} else {
+		$Display =3D (($PageMax-$PageMin)>0);
+	}
+
+	// Merge general information
+	$Pos =3D 0;
+	while ($Loc =3D $this->meth_Locator_FindTbs($Txt,$BlockName,$Pos,'.')) =
{
+		$Pos =3D $Loc->PosBeg + 1;
+		$x =3D strtolower($Loc->SubName);
+		if (isset($CurrNav[$x])) {
+			$Val =3D $CurrNav[$x];
+			if ($CurrNav[$x]=3D=3D$CurrNav['bound']) {
+				if (isset($Loc->PrmLst['endpoint'])) {
+					$Val =3D '';
+				}
+			}
+			$this->meth_Locator_Replace($Txt,$Loc,$Val,false);
+		}
+	}
+
+	// Merge pages
+	$Query =3D '';
+	if ($Display) {
+		$Data =3D array();
+		$RecSpe =3D 0;
+		$RecCurr =3D 0;
+		for ($PageId=3D$PageMin;$PageId<=3D$PageMax;$PageId++) {
+			$RecCurr++;
+			if ($PageId=3D=3D$PageCurr) $RecSpe =3D $RecCurr;
+			$Data[] =3D array('page'=3D>$PageId);
+		}
+		$this->meth_Merge_Block($Txt,$BlockName,$Data,$Query,0,0,$RecSpe);
+		if ($Options['navdel']!=3D'') { // Delete the block definition tags
+			$PosBeg =3D 0;
+			while ($Loc =3D $this->meth_Locator_FindTbs($Txt,$Options['navdel'],$=
PosBeg,'.')) {
+				$PosBeg =3D $Loc->PosBeg;
+				$Txt =3D substr_replace($Txt,'',$Loc->PosBeg,$Loc->PosEnd-$Loc->PosB=
eg+1);
+			}
+		}
+	} else {
+		if ($Options['navdel']!=3D'') {
+			$SrcType =3D 'text';
+			$this->meth_Merge_Block($Txt,$Options['navdel'],$SrcType,$Query,0,0,0=
);
+		}
+	}
+
+}
+
+// Convert a string to Html with several options
+function meth_Conv_Html(&$Txt) {
+	if ($this->HtmlCharSet=3D=3D=3D'') {
+		$Txt =3D htmlspecialchars($Txt); // Faster
+	} elseif ($this->_HtmlCharFct) {
+		$Txt =3D call_user_func($this->HtmlCharSet,$Txt);
+	} else {
+		$Txt =3D htmlspecialchars($Txt,ENT_COMPAT,$this->HtmlCharSet);
+	}
+}
+
+// Standard alert message provided by TinyButStrong, return False is the=
 message is cancelled.
+function meth_Misc_Alert($Source,$Message,$NoErrMsg=3Dfalse) {
+	$x =3D '<br /><b>TinyButStrong Error</b> ('.$Source.'): '.htmlentities(=
$Message);
+	if ($NoErrMsg) $x =3D $x.' <em>This message can be cancelled using para=
meter \'noerr\'.</em>';
+	$x =3D $x."<br />\n";
+	$x =3D str_replace($this->ChrOpen,$this->ChrProtect,$x);
+	echo $x;
+	return false;
+}
+
+function meth_Misc_ChangeMode($Init,&$Loc,&$CurrVal,$Switch,$GetOb) {
+	if ($Init) {
+		// Save contents configuration
+		if ($Switch) {
+			$Loc->SaveSrc =3D& $this->Source;
+			$Loc->SaveRender =3D $this->Render;
+			$Loc->SaveCache =3D $this->_CacheFile;
+			$Loc->SaveMode =3D $this->_Mode;
+			unset($this->Source); $this->Source =3D '';
+			$this->Render =3D TBS_OUTPUT;
+			$this->_CacheFile =3D false;
+			$this->_Mode =3D 1;
+			$File =3D $Loc->PrmLst['subtpl'];
+			if (is_string($File) and (strlen($File)>0)) {
+				$this->meth_Merge_PhpVar($File,false);
+				$File =3D str_replace($this->ChrVal,$CurrVal,$File);
+				if (tbs_Misc_GetFile($this->Source,$File)) {
+					$this->meth_Merge_Auto($this->Source,'onload',true,true);
+				} else {
+					if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert('Paramete=
r subtpl','Unable to read the file \''.$File.'\'.');
+				}
+			}
+		}
+		if ($GetOb) ob_start();
+	} else {
+		// Restore contents configuration
+		if ($Switch) {
+			$this->Source =3D& $Loc->SaveSrc;
+			$this->Render =3D $Loc->SaveRender;
+			$this->_CacheFile =3D $Loc->SaveCache;
+			$this->_Mode =3D $Loc->SaveMode;
+		}
+		if ($GetOb) {
+			$CurrVal =3D ob_get_contents();
+			ob_end_clean();
+		}
+		$Loc->ConvHtml =3D false;
+		$Loc->ConvProtect =3D false;
+	}
+}
+
+function meth_Misc_UserFctCheck(&$FctInfo,&$ErrMsg) {
+	if (substr($FctInfo,0,1)=3D=3D=3D'~') {
+		$ObjRef =3D& $this->ObjectRef;
+		$Lst =3D explode('.',substr($FctInfo,1));
+		$iMax =3D count($Lst) - 1;
+		for ($i=3D0;$i<=3D$iMax;$i++) {
+			$x =3D& $Lst[$i];
+			if (is_object($ObjRef)) {
+				if (method_exists($ObjRef,$x)) {
+					if ($i=3D=3D=3D$iMax) {
+						$FctInfo =3D array(&$ObjRef,$x);
+					} else {
+						$ObjRef =3D call_user_func(array(&$ObjRef,$x));
+					}
+				} elseif ($i=3D=3D=3D$iMax) {
+					$ErrMsg =3D 'Expression \''.$FctInfo.'\' is invalid because \''.$x.=
'\' is not a method in the class \''.get_class($ObjRef).'\'.';
+					return false;
+				} elseif (isset($ObjRef->$x)) {
+					$ObjRef =3D& $ObjRef->$x;
+				} else {
+					$ErrMsg =3D 'Expression \''.$FctInfo.'\' is invalid because sub-ite=
m \''.$x.'\' is neither a method nor a property in the class \''.get_clas=
s($ObjRef).'\'.';
+					return false;
+				}
+			} elseif (($i<$iMax) and is_array($ObjRef)) {
+				if (isset($ObjRef[$x])) {
+					$ObjRef =3D& $ObjRef[$x];
+				} else {
+					$ErrMsg =3D 'Expression \''.$FctInfo.'\' is invalid because sub-ite=
m \''.$x.'\' is not a existing key in the array.';
+					return false;
+				}
+			} else {
+				$ErrMsg =3D 'Expression \''.$FctInfo.'\' is invalid because '.(($i=3D=
=3D=3D0)?'property ObjectRef':'sub-item \''.$x.'\'').' is not an object'.=
(($i<$iMax)?' or an array.':'.');
+				return false;
+			}
+		}
+	} else {
+		if (!function_exists($FctInfo)) {
+			$ErrMsg =3D 'Custom function \''.$FctInfo.'\' is not found.';
+			return false;
+		}
+	}
+	return true;
+}
+
+function meth_Cache_Save($CacheFile,&$Txt) {
+	$fid =3D @fopen($CacheFile, 'w');
+	if ($fid=3D=3D=3Dfalse) {
+		$this->meth_Misc_Alert('Cache System','The cache file \''.$CacheFile.'=
\' can not be saved.');
+		return false;
+	} else {
+		flock($fid,2); // acquire an exlusive lock
+		fwrite($fid,$Txt);
+		flock($fid,3); // release the lock
+		fclose($fid);
+		return true;
+	}
+}
+
+} // class clsTinyButStrong
+
+// *********************************************
+
+function tbs_Misc_ConvSpe(&$Loc) {
+	if ($Loc->ConvSpe=3D=3D=3Dfalse) {
+		$Loc->ConvSpe =3D true;
+		$Loc->ConvEsc =3D false;
+		$Loc->ConvWS =3D false;
+		$Loc->ConvJS =3D false;
+		$Loc->ConvLook =3D false;
+	}
+}
+
+function tbs_Misc_GetStrId($Txt) {
+	$Txt =3D strtolower($Txt);
+	$Txt =3D str_replace('-','_',$Txt);
+	$x =3D '';
+	$i =3D 0;
+	$iMax =3D strlen($Txt2);
+	while ($i<$iMax) {
+		if (($Txt[$i]=3D=3D=3D'_') or (($Txt[$i]>=3D'a') and ($Txt[$i]<=3D'z')=
) or (($Txt[$i]>=3D'0') and ($Txt[$i]<=3D'9'))) {
+			$x .=3D $Txt[$i];
+			$i++;
+		} else {
+			$i =3D $iMax;
+		}
+	}
+	return $x;
+}
+
+function tbs_Misc_CheckCondition($Str) {
+// Check if an expression like "exrp1=3Dexpr2" is true or false.
+
+	// Find operator and position
+	$Ope =3D '=3D';
+	$Len =3D 1;
+	$Max =3D strlen($Str)-1;
+	$Pos =3D strpos($Str,$Ope);
+	if ($Pos=3D=3D=3Dfalse) {
+		$Ope =3D '+';
+		$Pos =3D strpos($Str,$Ope);
+		if ($Pos=3D=3D=3Dfalse) return false;
+		if (($Pos>0) and ($Str[$Pos-1]=3D=3D=3D'-')) {
+			$Ope =3D '-+'; $Pos--; $Len=3D2;
+		} elseif (($Pos<$Max) and ($Str[$Pos+1]=3D=3D=3D'-')) {
+			$Ope =3D '+-'; $Len=3D2;
+		} else {
+			return false;
+		}
+	} else {
+		if ($Pos>0) {
+			$x =3D $Str[$Pos-1];
+			if ($x=3D=3D=3D'!') {
+				$Ope =3D '!=3D'; $Pos--; $Len=3D2;
+			} elseif ($Pos<$Max) {
+				$y =3D $Str[$Pos+1];
+				if ($y=3D=3D=3D'=3D') {
+					$Len=3D2;
+				} elseif (($x=3D=3D=3D'+') and ($y=3D=3D=3D'-')) {
+					$Ope =3D '+=3D-'; $Pos--; $Len=3D3;
+				} elseif (($x=3D=3D=3D'-') and ($y=3D=3D=3D'+')) {
+					$Ope =3D '-=3D+'; $Pos--; $Len=3D3;
+				}
+			} else {
+			}
+		}
+	}
+
+	// Read values
+	$Val1  =3D trim(substr($Str,0,$Pos));
+	$Nude1 =3D tbs_Misc_DelDelimiter($Val1,'\'');
+	$Val2  =3D trim(substr($Str,$Pos+$Len));
+	$Nude2 =3D tbs_Misc_DelDelimiter($Val2,'\'');
+
+	// Compare values
+	if ($Ope=3D=3D=3D'=3D') {
+		return (strcasecmp($Val1,$Val2)=3D=3D0);
+	} elseif ($Ope=3D=3D=3D'!=3D') {
+		return (strcasecmp($Val1,$Val2)!=3D0);
+	} else {
+		if ($Nude1) $Val1 =3D (float) $Val1;
+		if ($Nude2) $Val2 =3D (float) $Val2;
+		if ($Ope=3D=3D=3D'+-') {
+			return ($Val1>$Val2);
+		} elseif ($Ope=3D=3D=3D'-+') {
+			return ($Val1 < $Val2);
+		} elseif ($Ope=3D=3D=3D'+=3D-') {
+			return ($Val1 >=3D $Val2);
+		} elseif ($Ope=3D=3D=3D'-=3D+') {
+			return ($Val1<=3D$Val2);
+		} else {
+			return false;
+		}
+	}
+
+}
+
+function tbs_Misc_DelDelimiter(&$Txt,$Delim) {
+// Delete the string delimiters
+	$len =3D strlen($Txt);
+	if (($len>1) and ($Txt[0]=3D=3D=3D$Delim)) {
+		if ($Txt[$len-1]=3D=3D=3D$Delim) $Txt =3D substr($Txt,1,$len-2);
+		return false;
+	} else {
+		return true;
+	}
+}
+
+function tbs_Misc_GetFile(&$Txt,$File) {
+// Load the content of a file into the text variable.
+	$Txt =3D '';
+	$fd =3D @fopen($File, 'r'); // 'rb' if binary for some OS
+	if ($fd=3D=3D=3Dfalse) return false;
+	$fs =3D @filesize($File); // return False for an URL
+	if ($fs=3D=3D=3Dfalse) {
+		while (!feof($fd)) $Txt .=3D fread($fd,4096);
+	} else {
+		if ($fs>0) $Txt =3D fread($fd,$fs);
+	}=09
+	fclose($fd);
+	return true;
+}
+
+function tbs_Misc_GetFilePart($File,$Part) {
+	$Pos =3D strrpos($File,'/');
+	if ($Part=3D=3D=3D0) { // Path
+		if ($Pos=3D=3D=3Dfalse) {
+			return '';
+		} else {
+			return substr($File,0,$Pos+1);
+		}
+	} else { // File
+		if ($Pos=3D=3D=3Dfalse) {
+			return $File;
+		} else {
+			return substr($File,$Pos+1);
+		}
+	}
+}
+
+function tbs_Misc_Format(&$Loc,&$Value) {
+// This function return the formated representation of a Date/Time or nu=
meric variable using a 'VB like' format syntax instead of the PHP syntax.
+
+	global $_tbs_FrmSimpleLst;
+
+	$FrmStr =3D $Loc->PrmLst['frm'];
+	$CheckNumeric =3D true;
+	if (is_string($Value)) $Value =3D trim($Value);
+
+	// Manage Multi format strings
+	if (strpos($FrmStr,'|')!=3D=3Dfalse) {
+
+		global $_tbs_FrmMultiLst;
+
+		// Save the format if it doesn't exist
+		if (isset($_tbs_FrmMultiLst[$FrmStr])) {
+			$FrmLst =3D& $_tbs_FrmMultiLst[$FrmStr];
+		} else {
+			$FrmLst =3D explode('|',$FrmStr); // syntax : PostiveFrm|NegativeFrm|=
ZeroFrm|NullFrm
+			$FrmNbr =3D count($FrmLst);
+			if (($FrmNbr<=3D1) or ($FrmLst[1]=3D=3D=3D'')) {
+				$FrmLst[1] =3D& $FrmLst[0]; // negativ
+				$FrmLst['abs'] =3D false;
+			} else {
+				$FrmLst['abs'] =3D true;
+			}
+			if (($FrmNbr<=3D2) or ($FrmLst[2]=3D=3D=3D'')) $FrmLst[2] =3D& $FrmLs=
t[0]; // zero
+			if (($FrmNbr<=3D3) or ($FrmLst[3]=3D=3D=3D'')) $FrmLst[3] =3D ''; // =
null
+			$_tbs_FrmMultiLst[$FrmStr] =3D $FrmLst;
+		}
+
+		// Select the format
+		if (is_numeric($Value)) {
+			if (is_string($Value)) $Value =3D 0.0 + $Value;
+			if ($Value>0) {
+				$FrmStr =3D& $FrmLst[0];
+			} elseif ($Value<0) {
+				$FrmStr =3D& $FrmLst[1];
+				if ($FrmLst['abs']) $Value =3D abs($Value);
+			} else { // zero
+				$FrmStr =3D& $FrmLst[2];
+				$Minus =3D '';
+			}
+			$CheckNumeric =3D false;
+		} else {
+			$Value =3D ''.$Value;
+			if ($Value=3D=3D=3D'') {
+				return $FrmLst[3]; // Null value
+			} else {
+				$t =3D strtotime($Value); // We look if it's a date
+				if ($t=3D=3D=3D-1) { // Date not recognized
+					return $FrmLst[1];
+				} elseif ($t=3D=3D=3D943916400) { // Date to zero
+					return $FrmLst[2];
+				} else { // It's a date
+					$Value =3D $t;
+					$FrmStr =3D& $FrmLst[0];
+				}
+			}
+		}
+
+	}
+
+	if ($FrmStr=3D=3D=3D'') return ''.$Value;
+
+	// Retrieve the correct simple format
+	if (!isset($_tbs_FrmSimpleLst[$FrmStr])) tbs_Misc_FormatSave($FrmStr);
+
+	$Frm =3D& $_tbs_FrmSimpleLst[$FrmStr];
+
+	switch ($Frm['type']) {
+	case 'num' :
+		// NUMERIC
+		if ($CheckNumeric) {
+			if (is_numeric($Value)) {
+				if (is_string($Value)) $Value =3D 0.0 + $Value;
+			} else {
+				return ''.$Value;
+			}
+		}
+		if ($Frm['PerCent']) $Value =3D $Value * 100;
+		$Value =3D number_format($Value,$Frm['DecNbr'],$Frm['DecSep'],$Frm['Th=
sSep']);
+		return substr_replace($FrmStr,$Value,$Frm['Pos'],$Frm['Len']);
+		break;
+	case 'date' :
+		// DATE
+		if (is_string($Value)) {
+			if ($Value=3D=3D=3D'') return '';
+			$x =3D strtotime($Value);
+			if ($x=3D=3D=3D-1) {
+				if (!is_numeric($Value)) $Value =3D 0;
+			} else {
+				$Value =3D& $x;
+			}
+		} else {
+			if (!is_numeric($Value)) return ''.$Value;
+		}
+		if (isset($Loc->PrmLst['locale'])) {
+			return strftime($Frm['str_loc'],$Value);
+		} else {
+			return date($Frm['str_us'],$Value);
+		}
+		break;
+	default:
+		return $Frm['string'];
+		break;
+	}
+
+}
+
+function tbs_Misc_FormatSave(&$FrmStr) {
+
+	global $_tbs_FrmSimpleLst;
+
+	$nPosEnd =3D strrpos($FrmStr,'0');
+
+	if ($nPosEnd!=3D=3Dfalse) {
+
+		// Numeric format
+		$nDecSep =3D '.';
+		$nDecNbr =3D 0;
+		$nDecOk =3D true;
+
+		if (substr($FrmStr,$nPosEnd+1,1)=3D=3D=3D'.') {
+			$nPosEnd++;
+			$nPosCurr =3D $nPosEnd;
+		} else {
+			$nPosCurr =3D $nPosEnd - 1;
+			while (($nPosCurr>=3D0) and ($FrmStr[$nPosCurr]=3D=3D=3D'0')) {
+				$nPosCurr--;
+			}
+			if (($nPosCurr>=3D1) and ($FrmStr[$nPosCurr-1]=3D=3D=3D'0')) {
+				$nDecSep =3D $FrmStr[$nPosCurr];
+				$nDecNbr =3D $nPosEnd - $nPosCurr;
+			} else {
+				$nDecOk =3D false;
+			}
+		}
+
+		// Thousand separator
+		$nThsSep =3D '';
+		if (($nDecOk) and ($nPosCurr>=3D5)) {
+			if ((substr($FrmStr,$nPosCurr-3,3)=3D=3D=3D'000') and ($FrmStr[$nPosC=
urr-4]!=3D=3D'') and ($FrmStr[$nPosCurr-5]=3D=3D=3D'0')) {
+				$nPosCurr =3D $nPosCurr-4;
+				$nThsSep =3D $FrmStr[$nPosCurr];
+			}
+		}
+
+		// Pass next zero
+		if ($nDecOk) $nPosCurr--;
+		while (($nPosCurr>=3D0) and ($FrmStr[$nPosCurr]=3D=3D=3D'0')) {
+			$nPosCurr--;
+		}
+
+		// Percent
+		$nPerCent =3D (strpos($FrmStr,'%')=3D=3D=3Dfalse) ? false : true;
+
+		$_tbs_FrmSimpleLst[$FrmStr] =3D array('type'=3D>'num','Pos'=3D>($nPosC=
urr+1),'Len'=3D>($nPosEnd-$nPosCurr),'ThsSep'=3D>$nThsSep,'DecSep'=3D>$nD=
ecSep,'DecNbr'=3D>$nDecNbr,'PerCent'=3D>$nPerCent);
+
+	} else { // if ($nPosEnd!=3D=3Dfalse)
+
+		// Date format
+		$FrmPHP =3D '';
+		$FrmLOC =3D '';
+		$Local =3D false;
+		$StrIn =3D false;
+		$iMax =3D strlen($FrmStr);
+		$Cnt =3D 0;
+
+		for ($i=3D0;$i<$iMax;$i++) {
+
+			if ($StrIn) {
+				// We are in a string part
+				if ($FrmStr[$i]=3D=3D=3D$StrChr) {
+					if (substr($FrmStr,$i+1,1)=3D=3D=3D$StrChr) {
+						$FrmPHP .=3D '\\'.$FrmStr[$i]; // protected char
+						$FrmLOC .=3D $FrmStr[$i];
+						$i++;
+					} else {
+						$StrIn =3D false;
+					}
+				} else {
+					$FrmPHP .=3D '\\'.$FrmStr[$i]; // protected char
+					$FrmLOC .=3D $FrmStr[$i];
+				}
+			} else {
+				if (($FrmStr[$i]=3D=3D=3D'"') or ($FrmStr[$i]=3D=3D=3D'\'')) {
+					// Check if we have the opening string char
+					$StrIn =3D true;
+					$StrChr =3D $FrmStr[$i];
+				} else {
+					$Cnt++;
+					if     (strcasecmp(substr($FrmStr,$i,4),'yyyy')=3D=3D=3D0) { $FrmPH=
P .=3D 'Y'; $FrmLOC .=3D '%Y'; $i +=3D 3; }
+					elseif (strcasecmp(substr($FrmStr,$i,2),'yy'  )=3D=3D=3D0) { $FrmPH=
P .=3D 'y'; $FrmLOC .=3D '%y'; $i +=3D 1; }
+					elseif (strcasecmp(substr($FrmStr,$i,4),'mmmm')=3D=3D=3D0) { $FrmPH=
P .=3D 'F'; $FrmLOC .=3D '%B'; $i +=3D 3; }
+					elseif (strcasecmp(substr($FrmStr,$i,3),'mmm' )=3D=3D=3D0) { $FrmPH=
P .=3D 'M'; $FrmLOC .=3D '%b'; $i +=3D 2; }
+					elseif (strcasecmp(substr($FrmStr,$i,2),'mm'  )=3D=3D=3D0) { $FrmPH=
P .=3D 'm'; $FrmLOC .=3D '%m'; $i +=3D 1; }
+					elseif (strcasecmp(substr($FrmStr,$i,1),'m'   )=3D=3D=3D0) { $FrmPH=
P .=3D 'n'; $FrmLOC .=3D '%m'; }
+					elseif (strcasecmp(substr($FrmStr,$i,4),'wwww')=3D=3D=3D0) { $FrmPH=
P .=3D 'l'; $FrmLOC .=3D '%A'; $i +=3D 3; }
+					elseif (strcasecmp(substr($FrmStr,$i,3),'www' )=3D=3D=3D0) { $FrmPH=
P .=3D 'D'; $FrmLOC .=3D '%a'; $i +=3D 2; }
+					elseif (strcasecmp(substr($FrmStr,$i,1),'w'   )=3D=3D=3D0) { $FrmPH=
P .=3D 'w'; $FrmLOC .=3D '%u'; }
+					elseif (strcasecmp(substr($FrmStr,$i,4),'dddd')=3D=3D=3D0) { $FrmPH=
P .=3D 'l'; $FrmLOC .=3D '%A'; $i +=3D 3; }
+					elseif (strcasecmp(substr($FrmStr,$i,3),'ddd' )=3D=3D=3D0) { $FrmPH=
P .=3D 'D'; $FrmLOC .=3D '%a'; $i +=3D 2; }
+					elseif (strcasecmp(substr($FrmStr,$i,2),'dd'  )=3D=3D=3D0) { $FrmPH=
P .=3D 'd'; $FrmLOC .=3D '%d'; $i +=3D 1; }
+					elseif (strcasecmp(substr($FrmStr,$i,1),'d'   )=3D=3D=3D0) { $FrmPH=
P .=3D 'j'; $FrmLOC .=3D '%d'; }
+					elseif (strcasecmp(substr($FrmStr,$i,2),'hh'  )=3D=3D=3D0) { $FrmPH=
P .=3D 'H'; $FrmLOC .=3D '%H'; $i +=3D 1; }
+					elseif (strcasecmp(substr($FrmStr,$i,2),'nn'  )=3D=3D=3D0) { $FrmPH=
P .=3D 'i'; $FrmLOC .=3D '%M'; $i +=3D 1; }
+					elseif (strcasecmp(substr($FrmStr,$i,2),'ss'  )=3D=3D=3D0) { $FrmPH=
P .=3D 's'; $FrmLOC .=3D '%S'; $i +=3D 1; }
+					elseif (strcasecmp(substr($FrmStr,$i,2),'xx'  )=3D=3D=3D0) { $FrmPH=
P .=3D 'S'; $FrmLOC .=3D ''  ; $i +=3D 1; }
+					else {
+						$FrmPHP .=3D '\\'.$FrmStr[$i]; // protected char
+						$FrmLOC .=3D $FrmStr[$i]; // protected char
+						$Cnt--;
+					}
+				}
+			} //-> if ($StrIn) {...} else
+
+		} //-> for ($i=3D0;$i<$iMax;$i++)
+
+		if ($Cnt>0) {
+			$_tbs_FrmSimpleLst[$FrmStr] =3D array('type'=3D>'date','str_us'=3D>$F=
rmPHP,'str_loc'=3D>$FrmLOC);
+		} else {
+			$_tbs_FrmSimpleLst[$FrmStr] =3D array('type'=3D>'else','string'=3D>$F=
rmStr);
+		}
+
+	} // if ($nPosEnd!=3D=3Dfalse) {...} else
+
+}
+
+function tbs_Locator_SectionAddBlk(&$LocR,$BlockName,$Txt) {
+	$LocR->BlockNbr++;
+	$LocR->BlockName[$LocR->BlockNbr] =3D $BlockName;
+	$LocR->BlockSrc[$LocR->BlockNbr] =3D $Txt;
+	$LocR->BlockLoc[$LocR->BlockNbr] =3D array(0=3D>0);
+	$LocR->BlockChk[$LocR->BlockNbr] =3D true;
+	return $LocR->BlockNbr;
+}
+
+function tbs_Locator_SectionAddGrp(&$LocR,$Bid,$Type,$Field) {
+
+	if ($Type=3D=3D=3D'H') {
+		if ($LocR->HeaderFound=3D=3D=3Dfalse) {
+			$LocR->HeaderFound =3D true;
+			$LocR->HeaderNbr =3D 0;
+			$LocR->HeaderBid =3D array();       // 1 to HeaderNbr
+			$LocR->HeaderPrevValue =3D array(); // 1 to HeaderNbr
+			$LocR->HeaderField =3D array();     // 1 to HeaderNbr
+		}
+		$LocR->HeaderNbr++;
+		$LocR->HeaderBid[$LocR->HeaderNbr] =3D $Bid;
+		$LocR->HeaderPrevValue[$LocR->HeaderNbr] =3D false;
+		$LocR->HeaderField[$LocR->HeaderNbr] =3D $Field;
+	} else {
+		if ($LocR->FooterFound=3D=3D=3Dfalse) {
+			$LocR->FooterFound =3D true;
+			$LocR->FooterNbr =3D 0;
+			$LocR->FooterBid =3D array();       // 1 to FooterNbr
+			$LocR->FooterPrevValue =3D array(); // 1 to FooterNbr
+			$LocR->FooterField =3D array();     // 1 to FooterNbr
+			$LocR->FooterIsFooter =3D array();  // 1 to FooterNbr
+		}
+		$LocR->FooterNbr++;
+		$LocR->FooterBid[$LocR->FooterNbr] =3D $Bid;
+		$LocR->FooterPrevValue[$LocR->FooterNbr] =3D false;
+		if ($Type=3D=3D=3D'F') {
+			$LocR->FooterField[$LocR->FooterNbr] =3D $Field;
+			$LocR->FooterIsFooter[$LocR->FooterNbr] =3D true;
+		} else {
+			$LocR->FooterField[$LocR->FooterNbr] =3D $Field;
+			$LocR->FooterIsFooter[$LocR->FooterNbr] =3D false;
+		}
+	}
+=09
+}
+
+function tbs_Locator_PrmRead(&$Txt,$Pos,$HtmlTag,$DelimChrs,$BegStr,$End=
Str,&$Loc,&$PosEnd) {
+
+	// =C0 mettre dans la classe TBS
+	$BegLen =3D strlen($BegStr);
+	$BegChr =3D $BegStr[0];
+	$BegIs1 =3D ($BegLen=3D=3D=3D1);
+
+	$DelimIdx =3D false;
+	$DelimCnt =3D 0;
+	$DelimChr =3D '';
+	$BegCnt =3D 0;
+	$SubName =3D $Loc->SubOk;
+=09
+	$Status =3D 0; // 0: name not started, 1: name started, 2: name ended, =
3: equal found, 4: value started
+	$PosName =3D 0;
+	$PosNend =3D 0;
+	$PosVal =3D 0;
+=09
+	// Param=E8tres de v=E9rif de la boucle
+	$PosEnd =3D strpos($Txt,$EndStr,$Pos);
+	if ($PosEnd=3D=3D=3Dfalse) return;
+	$Continue =3D ($Pos<$PosEnd);
+=09
+	while ($Continue) {
+	=09
+		$Chr =3D $Txt[$Pos];
+
+		if ($DelimIdx) { // Lecture dans une cha=EEne
+
+			if ($Chr=3D=3D=3D$DelimChr) { // Quote rencontr=E9
+				if ($Chr=3D=3D=3D$Txt[$Pos+1]) { // Double quote =3D> la cha=EEne co=
ntinue en d=E9doublant le quote
+					$Pos++;
+				} else { // Simple quote =3D> fin de la cha=EEne
+					$DelimIdx =3D false;
+				}
+			}
+
+		} else { // Lecture hors cha=EEne
+		=09
+			if ($BegCnt=3D=3D=3D0) {
+			=09
+				// Analyse des param=E8tre
+				$CheckChr =3D false;
+				if ($Chr=3D=3D=3D' ') {
+					if ($Status=3D=3D=3D1) {
+						$Status =3D 2;
+						$PosNend =3D $Pos;
+					} elseif ($HtmlTag and ($Status=3D=3D=3D4)) {
+						tbs_Locator_PrmCompute($Txt,$Loc,$SubName,$Status,$HtmlTag,$DelimC=
hr,$DelimCnt,$PosName,$PosNend,$PosVal,$Pos);
+						$Status =3D 0;
+					}
+				} elseif (($HtmlTag=3D=3D=3Dfalse) and ($Chr=3D=3D=3D';')) {
+					tbs_Locator_PrmCompute($Txt,$Loc,$SubName,$Status,$HtmlTag,$DelimCh=
r,$DelimCnt,$PosName,$PosNend,$PosVal,$Pos);
+					$Status =3D 0;
+				} elseif ($Status=3D=3D=3D4) {
+					$CheckChr =3D true;
+				} elseif ($Status=3D=3D=3D3) {
+					$Status =3D 4;
+					$DelimCnt =3D 0;
+					$PosVal =3D $Pos;
+					$CheckChr =3D true;
+				} elseif ($Status=3D=3D=3D2) {
+					if ($Chr=3D=3D=3D'=3D') {
+						$Status =3D 3;
+					} elseif ($HtmlTag) {
+						tbs_Locator_PrmCompute($Txt,$Loc,$SubName,$Status,$HtmlTag,$DelimC=
hr,$DelimCnt,$PosName,$PosNend,$PosVal,$Pos);
+						$Status =3D 1;
+						$PosName =3D $Pos;
+						$CheckChr =3D true;
+					} else {
+						$Status =3D 4;
+						$DelimCnt =3D 0;
+						$PosVal =3D $Pos;
+						$CheckChr =3D true;
+					}
+				} elseif ($Status=3D=3D=3D1) {
+					if ($Chr=3D=3D=3D'=3D') {
+						$Status =3D 3;
+						$PosNend =3D $Pos;
+					} else {
+						$CheckChr =3D true;
+					}
+				} else {
+					$Status =3D 1;
+					$PosName =3D $Pos;
+					$CheckChr =3D true;
+				}
+			=09
+				if ($CheckChr) {
+					$DelimIdx =3D strpos($DelimChrs,$Chr);
+					if ($DelimIdx=3D=3D=3Dfalse) {
+						if ($Chr=3D=3D=3D$BegChr) {
+							if ($BegIs1) {
+								$BegCnt++;
+							} elseif(substr($Txt,$Pos,$BegLen)=3D=3D=3D$BegStr) {
+								$BegCnt++;
+							}
+						}
+					} else {
+						$DelimChr =3D $DelimChrs[$DelimIdx];
+						$DelimCnt++;
+						$DelimIdx =3D true;
+					}
+				}
+			=09
+			} else {
+				if ($Chr=3D=3D=3D$BegChr) {
+					if ($BegIs1) {
+						$BegCnt++;
+					} elseif(substr($Txt,$Pos,$BegLen)=3D=3D=3D$BegStr) {
+						$BegCnt++;
+					}
+				}
+			}
+	=09
+		}
+	=09
+		// Charact=E8re suivant
+		$Pos++;
+
+		// On v=E9rifie si c'est la fin
+		if ($Pos=3D=3D=3D$PosEnd) {
+			if ($DelimIdx=3D=3D=3Dfalse) {
+				if ($BegCnt>0) {
+					$BegCnt--;
+				} else {
+					$Continue =3D false;
+				}
+			}
+			if ($Continue) {
+				$PosEnd =3D strpos($Txt,$EndStr,$PosEnd+1);
+				if ($PosEnd=3D=3D=3Dfalse) return;
+			} else {
+				tbs_Locator_PrmCompute($Txt,$Loc,$SubName,$Status,$HtmlTag,$DelimChr=
,$DelimCnt,$PosName,$PosNend,$PosVal,$Pos);
+			}
+		}
+=09
+	}
+=09
+	$PosEnd =3D $PosEnd + (strlen($EndStr)-1);
+
+}
+
+function tbs_Locator_PrmCompute(&$Txt,&$Loc,&$SubName,$Status,$HtmlTag,$=
DelimChr,$DelimCnt,$PosName,$PosNend,$PosVal,$Pos) {
+=09
+	if ($Status=3D=3D=3D0) {
+		$SubName =3D false;
+	} else {
+		if ($Status=3D=3D=3D1) {
+			$x =3D substr($Txt,$PosName,$Pos-$PosName);
+		} else {
+			$x =3D substr($Txt,$PosName,$PosNend-$PosName);
+		}
+		if ($HtmlTag) $x =3D strtolower($x);
+		if ($SubName) {
+			$Loc->SubName =3D $x;
+			$SubName =3D false;
+		} elseif ($Status=3D=3D=3D4) {
+			$v =3D trim(substr($Txt,$PosVal,$Pos-$PosVal));
+			if ($DelimCnt=3D=3D=3D1) { // Delete quotes inside the value
+				if ($v[0]=3D=3D=3D$DelimChr) {
+					$len =3D strlen($v);
+					if ($v[$len-1]=3D=3D=3D$DelimChr) {
+						$v =3D substr($v,1,$len-2);
+						$v =3D str_replace($DelimChr.$DelimChr,$DelimChr,$v);
+					}
+				}
+			}
+			$Loc->PrmLst[$x] =3D $v;
+		} else {
+			$Loc->PrmLst[$x] =3D true;
+		}
+	}
+
+}
+
+function tbs_Locator_EnlargeToStr(&$Txt,&$Loc,$StrBeg,$StrEnd) {
+/*
+This function enables to enlarge the pos limits of the Locator.
+If the search result is not correct, $PosBeg must not change its value, =
and $PosEnd must be False.
+This is because of the calling function.
+*/
+
+	// Search for the begining string
+	$Pos =3D $Loc->PosBeg;
+	$Ok =3D false;
+	do {
+		$Pos =3D strrpos(substr($Txt,0,$Pos),$StrBeg[0]);
+		if ($Pos!=3D=3Dfalse) {
+			if (substr($Txt,$Pos,strlen($StrBeg))=3D=3D=3D$StrBeg) $Ok =3D true;
+		}
+	} while ( (!$Ok) and ($Pos!=3D=3Dfalse) );
+
+	if ($Ok) {
+		$PosEnd =3D strpos($Txt,$StrEnd,$Loc->PosEnd + 1);
+		if ($PosEnd=3D=3D=3Dfalse) {
+			$Ok =3D false;
+		} else {
+			$Loc->PosBeg =3D $Pos;
+			$Loc->PosEnd =3D $PosEnd + strlen($StrEnd) - 1;
+		}
+	}
+
+	return $Ok;
+
+}
+
+function tbs_Locator_EnlargeToTag(&$Txt,&$Loc,$Tag,$IsBlock,$ReturnSrc) =
{
+//Modify $Loc, return false if tags not found, returns the source of the=
 locator if $ReturnSrc=3Dtrue
+
+	if ($Tag=3D=3D=3D'') { return false; }
+	elseif ($Tag=3D=3D=3D'row') {$Tag =3D 'tr'; }
+	elseif ($Tag=3D=3D=3D'opt') {$Tag =3D 'option'; }
+
+	$RetVal =3D true;
+	$Encaps =3D 1;
+	if ($IsBlock and isset($Loc->PrmLst['encaps'])) $Encaps =3D abs(intval(=
$Loc->PrmLst['encaps']));
+
+	$TagO =3D tbs_Html_FindTag($Txt,$Tag,true,$Loc->PosBeg-1,false,$Encaps,=
false);
+	if ($TagO=3D=3D=3Dfalse) return false;
+	$TagC =3D tbs_Html_FindTag($Txt,$Tag,false,$Loc->PosEnd+1,true,$Encaps,=
false);
+	if ($TagC=3D=3Dfalse) return false;
+	$PosBeg =3D $TagO->PosBeg;
+	$PosEnd =3D $TagC->PosEnd;
+
+	if ($IsBlock) {
+	=09
+		$ExtendFw =3D false;
+		$ExtendBw =3D false;
+		if (isset($Loc->PrmLst['extend'])) {
+			$s =3D ',';
+			$x =3D str_replace(' ','',''.$Loc->PrmLst['extend']);
+			if (is_numeric($x)) {
+				$x =3D intval($Loc->PrmLst['extend']);
+				if ($x>0) {
+					$lst =3D& $ExtendFw;
+				} else {
+					$lst =3D& $ExtendBw;
+				}
+				$x =3D str_repeat($Tag.$s,abs($x));
+			} else {
+				$lst =3D& $ExtendFw;
+			}
+			$lst =3D explode($s,$x);
+		}	=09
+	=09
+		if ($ExtendFw!=3D=3Dfalse) { // Forward
+			$TagC =3D true;
+			foreach ($ExtendFw as $Tag) {
+				if (($Tag!=3D=3D'') and ($TagC!=3D=3Dfalse)) {
+					$TagO =3D tbs_Html_FindTag($Txt,$Tag,true,$PosEnd+1,true,1,false);
+					if ($TagO!=3D=3Dfalse) {
+						$TagC =3D tbs_Html_FindTag($Txt,$Tag,false,$TagO->PosEnd+1,true,0,=
false);
+						if ($TagC!=3D=3Dfalse) {
+							$PosEnd =3D $TagC->PosEnd;
+						}
+					}
+				}
+			}
+		}
+	=09
+		if ($ExtendBw!=3D=3Dfalse) { // Backward
+			$TagO =3D true;
+			for ($i=3Dcount($ExtendBw)-1;$i>=3D0;$i--) {
+				$Tag =3D $ExtendBw[$i];
+				if (($Tag!=3D=3D'') and ($TagO!=3D=3Dfalse)) {
+					$TagC =3D tbs_Html_FindTag($Txt,$Tag,false,$PosBeg-1,false,1,false)=
;
+					if ($TagC!=3D=3Dfalse) {
+						$TagO =3D tbs_Html_FindTag($Txt,$Tag,true,$TagC->PosBeg-1,false,0,=
false);
+						if ($TagO!=3D=3Dfalse) {
+							$PosBeg =3D $TagO->PosBeg;
+						}
+					}
+				}
+			}
+		}
+	=09
+	} elseif ($ReturnSrc) {
+	=09
+		$RetVal =3D '';
+		if ($Loc->PosBeg>$TagO->PosEnd) $RetVal .=3D substr($Txt,$TagO->PosEnd=
+1,min($Loc->PosBeg,$TagC->PosBeg)-$TagO->PosEnd-1);
+		if ($Loc->PosEnd<$TagC->PosBeg) $RetVal .=3D substr($Txt,max($Loc->Pos=
End,$TagO->PosEnd)+1,$TagC->PosBeg-max($Loc->PosEnd,$TagO->PosEnd)-1);
+	=09
+	}
+
+	$Loc->PosBeg =3D $PosBeg;
+	$Loc->PosEnd =3D $PosEnd;
+	return $RetVal;
+
+}
+
+function tbs_Html_Max(&$Txt,&$Nbr) {
+// Limit the number of HTML chars
+
+	$pMax =3D strlen($Txt)-1;
+	$p=3D0;
+	$n=3D0;
+	$in =3D false;
+	$ok =3D true;
+
+	while ($ok) {
+		if ($in) {
+			if ($Txt[$p]=3D=3D=3D';') {
+				$in =3D false;
+				$n++;
+			}
+		} else {
+			if ($Txt[$p]=3D=3D=3D'&') {
+				$in =3D true;
+			} else {
+				$n++;
+			}
+		}
+		if (($n>=3D$Nbr) or ($p>=3D$pMax)) {
+			$ok =3D false;
+		} else {
+			$p++;
+		}
+	}
+
+	if (($n>=3D$Nbr) and ($p<$pMax)) $Txt =3D substr($Txt,0,$p).'...';
+
+}
+
+function tbs_Html_IsHtml(&$Txt) {
+// This function returns True if the text seems to have some HTML tags.
+
+	// Search for opening and closing tags
+	$pos =3D strpos($Txt,'<');
+	if ( ($pos!=3D=3Dfalse) and ($pos<strlen($Txt)-1) ) {
+		$pos =3D strpos($Txt,'>',$pos + 1);
+		if ( ($pos!=3D=3Dfalse) and ($pos<strlen($Txt)-1) ) {
+			$pos =3D strpos($Txt,'</',$pos + 1);
+			if ( ($pos!=3D=3Dfalse)and ($pos<strlen($Txt)-1) ) {
+				$pos =3D strpos($Txt,'>',$pos + 1);
+				if ($pos!=3D=3Dfalse) return true;
+			}
+		}
+	}
+
+	// Search for special char
+	$pos =3D strpos($Txt,'&');
+	if ( ($pos!=3D=3Dfalse) and ($pos<strlen($Txt)-1) ) {
+		$pos2 =3D strpos($Txt,';',$pos+1);
+		if ($pos2!=3D=3Dfalse) {
+			$x =3D substr($Txt,$pos+1,$pos2-$pos-1); // We extract the found text=
 between the couple of tags
+			if (strlen($x)<=3D10) {
+				if (strpos($x,' ')=3D=3D=3Dfalse) return true;
+			}
+		}
+	}
+
+	// Look for a simple tag
+	$Loc1 =3D tbs_Html_FindTag($Txt,'BR',true,0,true,0,false); // line brea=
k
+	if ($Loc1!=3D=3Dfalse) return true;
+	$Loc1 =3D tbs_Html_FindTag($Txt,'HR',true,0,true,0,false); // horizonta=
l line
+	if ($Loc1!=3D=3Dfalse) return true;
+
+	return false;
+
+}
+
+function tbs_Html_GetPart(&$Txt,$Tag,$WithTags=3Dfalse,$CancelIfEmpty=3D=
false) {
+// This function returns a part of the HTML document (HEAD or BODY)
+// The $CancelIfEmpty parameter enables to cancel the extraction when th=
e part is not found.
+
+	$x =3D false;
+
+	$LocOpen =3D tbs_Html_FindTag($Txt,$Tag,true,0,true,0,false);
+	if ($LocOpen!=3D=3Dfalse) {
+		$LocClose =3D tbs_Html_FindTag($Txt,$Tag,false,$LocOpen->PosEnd+1,true=
,0,false);
+		if ($LocClose!=3D=3Dfalse) {
+			if ($WithTags) {
+				$x =3D substr($Txt,$LocOpen->PosBeg,$LocClose->PosEnd - $LocOpen->Po=
sBeg + 1);
+			} else {
+				$x =3D substr($Txt,$LocOpen->PosEnd+1,$LocClose->PosBeg - $LocOpen->=
PosEnd - 1);
+			}
+		}
+	}
+
+	if ($x=3D=3D=3Dfalse) {
+		if ($CancelIfEmpty) {
+			$x =3D $Txt;
+		} else {
+			$x =3D '';
+		}
+	}
+
+	return $x;
+
+}
+
+function tbs_Html_InsertAttribute(&$Txt,&$Attr,$Pos) {
+	// Check for XHTML end characters
+	if ($Txt[$Pos-1]=3D=3D=3D'/') {
+		$Pos--;
+		if ($Txt[$Pos-1]=3D=3D=3D' ') $Pos--;
+	}
+	// Insert the parameter
+	$Txt =3D substr_replace($Txt,$Attr,$Pos,0);
+}
+
+function tbs_Html_FindTag(&$Txt,$Tag,$Opening,$PosBeg,$Forward,$Encaps,$=
WithPrm) {
+/* This function is a smarter issue to find an HTML tag.
+It enables to ignore full opening/closing couple of tag that could be in=
serted before the searched tag.
+It also enables to pass a number of encapsulations.
+To ignore encapsulation and opengin/closing just set $Encaps=3D0.
+*/
+	if ($Forward) {
+		$Pos =3D $PosBeg - 1;
+	} else {
+		$Pos =3D $PosBeg + 1;
+	}
+	$TagIsOpening =3D false;
+	$TagClosing =3D '/'.$Tag;
+	if ($Opening) {
+		$EncapsEnd =3D $Encaps;
+	} else {
+		$EncapsEnd =3D - $Encaps;
+	}
+	$EncapsCnt =3D 0;
+	$TagOk =3D false;
+
+	do {
+
+		// Look for the next tag def
+		if ($Forward) {
+			$Pos =3D strpos($Txt,'<',$Pos+1);
+		} else {
+			if ($Pos<=3D0) {
+				$Pos =3D false;
+			} else {
+				$Pos =3D strrpos(substr($Txt,0,$Pos - 1),'<');
+			}
+		}
+
+		if ($Pos!=3D=3Dfalse) {
+			// Check the name of the tag
+			if (strcasecmp(substr($Txt,$Pos+1,strlen($Tag)),$Tag)=3D=3D0) {
+				$PosX =3D $Pos + 1 + strlen($Tag); // The next char
+				$TagOk =3D true;
+				$TagIsOpening =3D true;
+			} elseif (strcasecmp(substr($Txt,$Pos+1,strlen($TagClosing)),$TagClos=
ing)=3D=3D0) {
+				$PosX =3D $Pos + 1 + strlen($TagClosing); // The next char
+				$TagOk =3D true;
+				$TagIsOpening =3D false;
+			}
+
+			if ($TagOk) {
+				// Check the next char
+				if (($Txt[$PosX]=3D=3D=3D' ') or ($Txt[$PosX]=3D=3D=3D'>')) {
+					// Check the encapsulation count
+					if ($EncapsEnd=3D=3D0) {
+						// No encaplusation check
+						if ($TagIsOpening!=3D=3D$Opening) $TagOk =3D false;
+					} else {
+						// Count the number of encapsulation
+						if ($TagIsOpening) {
+							$EncapsCnt++;
+						} else {
+							$EncapsCnt--;
+						}
+						// Check if it's the expected count
+						if ($EncapsCnt!=3D$EncapsEnd) $TagOk =3D false;
+					}
+				} else {
+					$TagOk =3D false;
+				}
+			} //--> if ($TagOk)
+
+		}
+	} while (($Pos!=3D=3Dfalse) and ($TagOk=3D=3D=3Dfalse));
+
+	// Search for the end of the tag
+	if ($TagOk) {
+		$Loc =3D& new clsTbsLocator;
+		if ($WithPrm) {
+			$PosEnd =3D 0;
+			tbs_Locator_PrmRead($Txt,$PosX,true,'\'"','<','>',$Loc,$PosEnd);
+		} else {
+			$PosEnd =3D strpos($Txt,'>',$PosX);
+			if ($PosEnd=3D=3D=3Dfalse) {
+				$TagOk =3D false;
+			}
+		}
+	}
+
+	// Result
+	if ($TagOk) {
+		$Loc->PosBeg =3D $Pos;
+		$Loc->PosEnd =3D $PosEnd;
+		return $Loc;
+	} else {
+		return false;
+	}
+
+}
+
+function tbs_Html_MergeItems(&$Txt,&$Loc,&$SelValue,&$SelArray,&$NewEnd)=
 {
+// Merge items of a list, or radio or check buttons.
+// At this point, the Locator is already merged with $SelValue.
+
+	if ($Loc->PrmLst['selected']=3D=3D=3Dtrue) {
+		$IsList =3D true;
+		$MainTag =3D 'SELECT';
+		$ItemTag =3D 'OPTION';
+		$ItemPrm =3D 'selected';
+	} else {
+		$IsList =3D false;
+		$MainTag =3D 'FORM';
+		$ItemTag =3D 'INPUT';
+		$ItemPrm =3D 'checked';
+	}
+	if (isset($Loc->PrmLst['selbounds'])) $MainTag =3D $Loc->PrmLst['selbou=
nds'];
+	$ItemPrmZ =3D ' '.$ItemPrm.'=3D"'.$ItemPrm.'"';
+
+	$TagO =3D tbs_Html_FindTag($Txt,$MainTag,true,$Loc->PosBeg-1,false,0,fa=
lse);
+
+	if ($TagO!=3D=3Dfalse) {
+
+		$TagC =3D tbs_Html_FindTag($Txt,$MainTag,false,$Loc->PosBeg,true,0,fal=
se);
+		if ($TagC!=3D=3Dfalse) {
+
+			// We get the main block without the main tags
+			$MainSrc =3D substr($Txt,$TagO->PosEnd+1,$TagC->PosBeg - $TagO->PosEn=
d -1);
+
+			if ($IsList) {
+				// Information about the item that was used for the TBS field
+				$Item0Beg =3D $Loc->PosBeg - ($TagO->PosEnd+1);
+				$Item0Src =3D '';
+				$Item0Ok =3D false;
+			} else {
+				// We delete the merged value
+				$MainSrc =3D substr_replace($MainSrc,'',$Loc->PosBeg - ($TagO->PosEn=
d+1), strlen($SelValue));
+			}
+
+			// Now, we going to scan all of the item tags
+			$Pos =3D 0;
+			$SelNbr =3D 0;
+			while ($ItemLoc =3D tbs_Html_FindTag($MainSrc,$ItemTag,true,$Pos,true=
,0,true)) {
+
+				// we get the value of the item
+				$ItemValue =3D false;
+
+				if ($IsList) {
+					// Look for the end of the item
+					$OptCPos =3D strpos($MainSrc,'<',$ItemLoc->PosEnd+1);
+					if ($OptCPos=3D=3D=3Dfalse) $OptCPos =3D strlen($MainSrc);
+					if (($Item0Ok=3D=3D=3Dfalse) and ($ItemLoc->PosBeg<$Item0Beg) and (=
$Item0Beg<=3D$OptCPos)) {
+						// If it's the original item, we save it and delete it.
+						if (($OptCPos+1<strlen($MainSrc)) and ($MainSrc[$OptCPos+1]=3D=3D=3D=
'/')) {
+							$OptCPos =3D strpos($MainSrc,'>',$OptCPos);
+							if ($OptCPos=3D=3D=3Dfalse) {
+								$OptCPos =3D strlen($MainSrc);
+							} else {
+								$OptCPos++;
+							}
+						}
+						$Item0Src =3D substr($MainSrc,$ItemLoc->PosBeg,$OptCPos-$ItemLoc->=
PosBeg);
+						$MainSrc =3D substr_replace($MainSrc,'',$ItemLoc->PosBeg,strlen($I=
tem0Src));
+						if (!isset($ItemLoc->PrmLst[$ItemPrm])) tbs_Html_InsertAttribute($=
Item0Src,$ItemPrmZ,$ItemLoc->PosEnd-$ItemLoc->PosBeg);
+						$OptCPos =3D min($ItemLoc->PosBeg,strlen($MainSrc)-1);
+						$Select =3D false;
+						$Item0Ok =3D true;
+					} else {
+						if (isset($ItemLoc->PrmLst['value'])) {
+							$ItemValue =3D $ItemLoc->PrmLst['value'];
+						} else { // The value of the option is its caption.
+							$ItemValue =3D substr($MainSrc,$ItemLoc->PosEnd+1,$OptCPos - $Ite=
mLoc->PosEnd - 1);
+							$ItemValue =3D str_replace(chr(9),' ',$ItemValue);
+							$ItemValue =3D str_replace(chr(10),' ',$ItemValue);
+							$ItemValue =3D str_replace(chr(13),' ',$ItemValue);
+							$ItemValue =3D trim($ItemValue);
+						}
+					}
+					$Pos =3D $OptCPos;
+				} else {
+					if ((isset($ItemLoc->PrmLst['name'])) and (isset($ItemLoc->PrmLst['=
value']))) {
+						if (strcasecmp($Loc->PrmLst['selected'],$ItemLoc->PrmLst['name'])=3D=
=3D0) {
+							$ItemValue =3D $ItemLoc->PrmLst['value'];
+						}
+					}
+					$Pos =3D $ItemLoc->PosEnd;
+				}
+
+				if ($ItemValue!=3D=3Dfalse) {
+					// we look if we select the item
+					$Select =3D false;
+					if ($SelArray=3D=3D=3Dfalse) {
+						if (strcasecmp($ItemValue,$SelValue)=3D=3D0) {
+							if ($SelNbr=3D=3D0) $Select =3D true;
+						}
+					} else {
+						if (array_search($ItemValue,$SelArray,false)!=3D=3Dfalse) $Select =
=3D true;
+					}
+					// Select the item
+					if ($Select) {
+						if (!isset($ItemLoc->PrmLst[$ItemPrm])) {
+							tbs_Html_InsertAttribute($MainSrc,$ItemPrmZ,$ItemLoc->PosEnd);
+							$Pos =3D $Pos + strlen($ItemPrmZ);
+							if ($IsList and ($ItemLoc->PosBeg<$Item0Beg)) $Item0Beg =3D $Item=
0Beg + strlen($ItemPrmZ);
+						}
+						$SelNbr++;
+					}
+				}
+
+			} //--> while ($ItemLoc =3D ... ) {
+
+			if ($IsList) {
+				// Add the original item if it's not found
+				if (($SelArray=3D=3D=3Dfalse) and ($SelNbr=3D=3D0)) $MainSrc =3D $Ma=
inSrc.$Item0Src;
+				$NewEnd =3D $TagO->PosEnd;
+			} else {
+				$NewEnd =3D $Loc->PosBeg;
+			}
+
+			$Txt =3D substr_replace($Txt,$MainSrc,$TagO->PosEnd+1,$TagC->PosBeg-$=
TagO->PosEnd-1);
+
+		} //--> if ($TagC!=3D=3Dfalse) {
+	} //--> if ($TagO!=3D=3Dfalse) {
+
+
+}
+
+function tbs_Cache_IsValide($CacheFile,$TimeOut) {
+// Return True if there is a existing valid cache for the given file id.
+	if (file_exists($CacheFile)) {
+		if (time()-filemtime($CacheFile)>$TimeOut) {
+			return false;
+		} else {
+			return true;
+		}
+	} else {
+		return false;
+	}
+}
+
+function tbs_Cache_File($Dir,$CacheId,$Mask) {
+// Return the cache file path for a given Id.
+	if (strlen($Dir)>0) {
+		if ($Dir[strlen($Dir)-1]<>'/') {
+			$Dir .=3D '/';
+		}
+	}
+	return $Dir.str_replace('*',$CacheId,$Mask);
+}
+
+function tbs_Cache_DeleteAll($Dir,$Mask) {
+
+	if (strlen($Dir)=3D=3D0) {
+		$Dir =3D '.';
+	}
+	if ($Dir[strlen($Dir)-1]<>'/') {
+		$Dir .=3D '/';
+	}
+	$DirObj =3D dir($Dir);
+	$Nbr =3D 0;
+	$PosL =3D strpos($Mask,'*');
+	$PosR =3D strlen($Mask) - $PosL - 1;
+
+	// Get the list of cache files
+	$FileLst =3D array();
+	while ($FileName =3D $DirObj->read()) {
+		$FullPath =3D $Dir.$FileName;
+		if (strtolower(filetype($FullPath))=3D=3D=3D'file') {
+			if (strlen($FileName)>=3Dstrlen($Mask)) {
+				if ((substr($FileName,0,$PosL)=3D=3D=3Dsubstr($Mask,0,$PosL)) and (s=
ubstr($FileName,-$PosR)=3D=3D=3Dsubstr($Mask,-$PosR))) {
+					$FileLst[] =3D $FullPath;
+				}
+			}
+		}
+	}
+	// Delete all listed files
+	foreach ($FileLst as $FullPath) {
+		if (@unlink($FullPath)) $Nbr++;
+	}
+
+	return $Nbr;
+
+}
+
+?>
\ No newline at end of file


Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/inf=
ormes/lib/tbs_class.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbs_=
class_php5.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbs_cla=
ss_php5.php	2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbs_cla=
ss_php5.php	2007-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,3265 @@
+<?php
+/*
+********************************************************
+TinyButStrong - Template Engine for Pro and Beginners
+------------------------
+Version  : 3.2.0 PHP >=3D 5.0
+Date     : 2006-11-26
+Web site : www.tinybutstrong.com
+Author   : skrol29 en freesurf.fr
+********************************************************
+This library is free software.
+You can redistribute and modify it even for commercial usage,
+but you must accept and respect the LPGL License version 2.1.
+*/
+// Check PHP version
+if (PHP_VERSION<'4.0.6') echo '<br><b>TinyButStrong Error</b> (PHP Versi=
on Check) : Your PHP version is '.PHP_VERSION.' while TinyButStrong needs=
 PHP version 4.0.6 or higher.';
+if (!is_callable('property_exists')) {
+	function property_exists(&$obj,$prop) {return true;}
+}
+
+// Render flags
+define('TBS_NOTHING', 0);
+define('TBS_OUTPUT', 1);
+define('TBS_EXIT', 2);
+
+// Plug-ins actions
+define('TBS_INSTALL', -1);
+define('TBS_ISINSTALLED', -3);
+
+// *********************************************
+
+class clsTbsLocator {
+	public $PosBeg =3D false;
+	public $PosEnd =3D false;
+	public $Enlarged =3D false;
+	public $FullName =3D false;
+	public $SubName =3D '';
+	public $SubOk =3D false;
+	public $SubLst =3D array();
+	public $SubNbr =3D 0;
+	public $PrmLst =3D array();
+	public $PrmIfNbr =3D false;
+	public $MagnetId =3D false;
+	public $BlockFound =3D false;
+	public $FirstMerge =3D true;
+	public $ConvProtect =3D true;
+	public $ConvHtml =3D true;
+	public $ConvMode =3D 1; // Normal
+	public $ConvBr =3D true;
+}
+
+// *********************************************
+
+class clsTbsDataSource {
+
+public $Type =3D false;
+public $SubType =3D 0;
+public $SrcId =3D false;
+public $Query =3D '';
+public $RecSet =3D false;
+public $RecKey =3D '';
+public $RecNum =3D 0;
+public $RecNumInit =3D 0;
+public $RecSaving =3D false;
+public $RecSaved =3D false;
+public $RecBuffer =3D false;
+public $CurrRec =3D false;
+public $TBS =3D false;
+public $OnDataOk =3D false;
+public $OnDataPrm =3D false;
+public $OnDataPrmDone =3D array();
+public $OnDataPi =3D false;
+
+function DataAlert($Msg) {
+	return $this->TBS->meth_Misc_Alert('when merging block '.$this->TBS->_C=
hrOpen.$this->TBS->_CurrBlock.$this->TBS->_ChrClose,$Msg);
+}
+
+function DataPrepare(&$SrcId,&$TBS) {
+
+	$this->SrcId =3D& $SrcId;
+	$this->TBS =3D& $TBS;
+	$FctInfo =3D false;
+	$FctObj =3D false;
+=09
+	if (is_array($SrcId)) {
+		$this->Type =3D 0;
+	} elseif (is_resource($SrcId)) {
+
+		$Key =3D get_resource_type($SrcId);
+		switch ($Key) {
+		case 'mysql link'            : $this->Type =3D 6; break;
+		case 'mysql link persistent' : $this->Type =3D 6; break;
+		case 'mysql result'          : $this->Type =3D 6; $this->SubType =3D 1=
; break;
+		case 'pgsql link'            : $this->Type =3D 7; break;
+		case 'pgsql link persistent' : $this->Type =3D 7; break;
+		case 'pgsql result'          : $this->Type =3D 7; $this->SubType =3D 1=
; break;
+		case 'sqlite database'       : $this->Type =3D 8; break;
+		case 'sqlite database (persistent)'	: $this->Type =3D 8; break;
+		case 'sqlite result'         : $this->Type =3D 8; $this->SubType =3D 1=
; break;
+		default :
+			$FctInfo =3D $Key;
+			$FctCat =3D 'r';
+		}
+
+	} elseif (is_string($SrcId)) {
+
+		switch (strtolower($SrcId)) {
+		case 'array' : $this->Type =3D 0; $this->SubType =3D 1; break;
+		case 'clear' : $this->Type =3D 0; $this->SubType =3D 3; break;
+		case 'mysql' : $this->Type =3D 6; $this->SubType =3D 2; break;
+		case 'text'  : $this->Type =3D 2; break;
+		case 'num'   : $this->Type =3D 1; break;
+		default :
+			$FctInfo =3D $SrcId;
+			$FctCat =3D 'k';
+		}
+
+	} elseif (is_object($SrcId)) {
+		$FctInfo =3D get_class($SrcId);
+		$FctCat =3D 'o';
+		$FctObj =3D& $SrcId;=20
+		$this->SrcId =3D& $SrcId;
+	} elseif ($SrcId=3D=3D=3Dfalse) {
+		$this->DataAlert('the specified source is set to FALSE. Maybe your con=
nection has failed.');
+	} else {
+		$this->DataAlert('unsupported variable type : \''.gettype($SrcId).'\'.=
');
+	}
+
+	if ($FctInfo!=3D=3Dfalse) {
+		$ErrMsg =3D false;
+		if ($TBS->meth_Misc_UserFctCheck($FctInfo,$FctCat,$FctObj,$ErrMsg)) {
+			$this->Type =3D $FctInfo['type'];
+			if ($this->Type!=3D=3D5) {
+				if ($this->Type=3D=3D=3D4) { //=20
+					$this->FctPrm =3D array(false,0);
+					$this->SrcId =3D& $FctInfo['open'][0];
+				}
+				$this->FctOpen  =3D& $FctInfo['open'];
+				$this->FctFetch =3D& $FctInfo['fetch'];
+				$this->FctClose =3D& $FctInfo['close'];
+			}
+		} else {
+			$this->Type =3D $this->DataAlert($ErrMsg);
+		}
+	}
+
+	return ($this->Type!=3D=3Dfalse);
+
+}
+
+function DataOpen(&$Query) {
+
+	// Init values
+	unset($this->CurrRec); $this->CurrRec =3D true;
+	if ($this->RecSaved) {
+		$this->FirstRec =3D true;
+		unset($this->RecKey); $this->RecKey =3D '';
+		$this->RecNum =3D $this->RecNumInit;
+		if ($this->OnDataOk) $this->OnDataArgs[1] =3D& $this->CurrRec;
+		return true;
+	}
+	unset($this->RecSet); $this->RecSet =3D false;
+	$this->RecNumInit =3D 0;
+	$this->RecNum =3D 0;
+
+	if (isset($this->TBS->_piOnData)) {
+		$this->OnDataPi =3D true;
+		$this->OnDataPiRef =3D& $this->TBS->_piOnData;
+		$this->OnDataOk =3D true;
+	}
+	if ($this->OnDataOk) {
+		$this->OnDataArgs =3D array();
+		$this->OnDataArgs[0] =3D& $this->TBS->_CurrBlock;
+		$this->OnDataArgs[1] =3D& $this->CurrRec;
+		$this->OnDataArgs[2] =3D& $this->RecNum;
+		$this->OnDataArgs[3] =3D& $this->TBS;
+	}
+
+	switch ($this->Type) {
+	case 0: // Array
+		if (($this->SubType=3D=3D=3D1) and (is_string($Query))) $this->SubType=
 =3D 2;
+		if ($this->SubType=3D=3D=3D0) {
+			$this->RecSet =3D& $this->SrcId;
+		} elseif ($this->SubType=3D=3D=3D1) {
+			if (is_array($Query)) {
+				$this->RecSet =3D& $Query;
+			} else {
+				$this->DataAlert('type \''.gettype($Query).'\' not supported for the=
 Query Parameter going with \'array\' Source Type.');
+			}
+		} elseif ($this->SubType=3D=3D=3D2) {
+			// TBS query string for array and objects, syntax: "var[item1][item2]=
->item3[item4]..."
+			$x =3D trim($Query);
+			$z =3D chr(0);
+			$x =3D str_replace(']->',$z,$x);
+			$x =3D str_replace('][',$z,$x);
+			$x =3D str_replace('->',$z,$x);
+			$x =3D str_replace('[',$z,$x);
+			if (substr($x,strlen($x)-1,1)=3D=3D=3D']') $x =3D substr($x,0,strlen(=
$x)-1);
+			$ItemLst =3D explode($z,$x);
+			$ItemNbr =3D count($ItemLst);
+			$Item0 =3D& $ItemLst[0];
+			// Check first item
+			if ($Item0[0]=3D=3D=3D'~') {
+				$Item0 =3D substr($Item0,1);
+				if ($this->TBS->ObjectRef!=3D=3Dfalse) {
+					$Var =3D& $this->TBS->ObjectRef;
+					$i =3D 0;
+				} else {
+					$i =3D $this->DataAlert('invalid query \''.$Query.'\' because prope=
rty ObjectRef is not set.');
+				}
+			} else {
+				if (isset($GLOBALS[$Item0])) {
+					$Var =3D& $GLOBALS[$Item0];
+					$i =3D 1;
+				} else {
+					$i =3D $this->DataAlert('invalid query \''.$Query.'\' because globa=
l variable \''.$Item0.'\' is not found.');
+				}
+			}
+			// Check sub-items
+			$Empty =3D false;
+			while (($i!=3D=3Dfalse) and ($i<$ItemNbr) and ($Empty=3D=3D=3Dfalse))=
 {
+				$x =3D $ItemLst[$i];
+				if (is_array($Var)) {
+					if (isset($Var[$x])) {
+						$Var =3D& $Var[$x];
+					} else {
+						$Empty =3D true;
+					}
+				} elseif (is_object($Var)) {
+					$ArgLst =3D tbs_Misc_CheckArgLst($x);
+					if (method_exists($Var,$x)) {
+						$f =3D array(&$Var,$x); unset($Var);
+						$Var =3D call_user_func_array($f,$ArgLst);
+					} elseif (isset($Var->$x)) {
+						$Var =3D& $Var->$x;
+					} else {
+						$Empty =3D true;
+					}
+				} else {
+					$i =3D $this->DataAlert('invalid query \''.$Query.'\' because item =
\''.$ItemLst[$i].'\' is neither an Array nor an Object. Its type is \''.g=
ettype($Var).'\'.');
+				}
+				if ($i!=3D=3Dfalse) $i++;
+			}
+			// Assign data
+			if ($i!=3D=3Dfalse) {
+				if ($Empty) {
+					$this->RecSet =3D array();
+				} else {
+					$this->RecSet =3D& $Var;
+				}
+			}
+		} elseif ($this->SubType=3D=3D=3D3) { // Clear
+			$this->RecSet =3D array();
+		}
+		// First record
+		if ($this->RecSet!=3D=3Dfalse) {
+			$this->RecNbr =3D $this->RecNumInit + count($this->RecSet);
+			$this->FirstRec =3D true;
+			$this->RecSaved =3D true;
+			$this->RecSaving =3D false;
+		}
+		break;
+	case 6: // MySQL
+		switch ($this->SubType) {
+		case 0: $this->RecSet =3D @mysql_query($Query,$this->SrcId); break;
+		case 1: $this->RecSet =3D $this->SrcId; break;
+		case 2: $this->RecSet =3D @mysql_query($Query); break;
+		}
+		if ($this->RecSet=3D=3D=3Dfalse) $this->DataAlert('MySql error message=
 when opening the query: '.mysql_error());
+		break;
+	case 1: // Num
+		$this->RecSet =3D true;
+		$this->NumMin =3D 1;
+		$this->NumMax =3D 1;
+		$this->NumStep =3D 1;
+		if (is_array($Query)) {
+			if (isset($Query['min'])) $this->NumMin =3D $Query['min'];
+			if (isset($Query['step'])) $this->NumStep =3D $Query['step'];
+			if (isset($Query['max'])) {
+				$this->NumMax =3D $Query['max'];
+			} else {
+				$this->RecSet =3D $this->DataAlert('the \'num\' source is an array t=
hat has no value for the \'max\' key.');
+			}
+			if ($this->NumStep=3D=3D0) $this->RecSet =3D $this->DataAlert('the \'=
num\' source is an array that has a step value set to zero.');
+		} else {
+			$this->NumMax =3D ceil($Query);
+		}
+		if ($this->RecSet) {
+			if ($this->NumStep>0) {
+				$this->NumVal =3D $this->NumMin;
+			} else {
+				$this->NumVal =3D $this->NumMax;
+			}
+		}
+		break;
+	case 2: // Text
+		if (is_string($Query)) {
+			$this->RecSet =3D& $Query;
+		} else {
+			$this->RecSet =3D ''.$Query;
+		}
+		break;
+	case 3: // Custom function
+		$FctOpen =3D $this->FctOpen;
+		$this->RecSet =3D $FctOpen($this->SrcId,$Query);
+		if ($this->RecSet=3D=3D=3Dfalse) $this->DataAlert('function '.$FctOpen=
.'() has failed to open query {'.$Query.'}');
+		break;
+	case 4: // Custom method from ObjectRef
+		$this->RecSet =3D call_user_func_array($this->FctOpen,array(&$this->Sr=
cId,&$Query));
+		if ($this->RecSet=3D=3D=3Dfalse) $this->DataAlert('method '.get_class(=
$this->FctOpen[0]).'::'.$this->FctOpen[1].'() has failed to open query {'=
.$Query.'}');
+		break;
+	case 5: // Custom method of object
+		$this->RecSet =3D $this->SrcId->tbsdb_open($this->SrcId,$Query);
+		if ($this->RecSet=3D=3D=3Dfalse) $this->DataAlert('method '.get_class(=
$this->SrcId).'::tbsdb_open() has failed to open query {'.$Query.'}');
+		break;
+	case 7: // PostgreSQL
+		switch ($this->SubType) {
+		case 0: $this->RecSet =3D @pg_query($this->SrcId,$Query); break;
+		case 1: $this->RecSet =3D $this->SrcId; break;
+		}
+		if ($this->RecSet=3D=3D=3Dfalse) $this->DataAlert('PostgreSQL error me=
ssage when opening the query: '.pg_last_error($this->SrcId));
+		break;
+	case 8: // SQLite
+		switch ($this->SubType) {
+		case 0: $this->RecSet =3D @sqlite_query($this->SrcId,$Query); break;
+		case 1: $this->RecSet =3D $this->SrcId; break;
+		}
+		if ($this->RecSet=3D=3D=3Dfalse) $this->DataAlert('SQLite error messag=
e when opening the query:'.sqlite_error_string(sqlite_last_error($this->S=
rcId)));
+		break;
+	}
+
+	if ($this->Type=3D=3D=3D0) {
+		unset($this->RecKey); $this->RecKey =3D '';
+	} else {
+		if ($this->RecSaving) {
+			unset($this->RecBuffer); $this->RecBuffer =3D array();
+		}
+		$this->RecKey =3D& $this->RecNum; // Not array: RecKey =3D RecNum
+	}
+
+	return ($this->RecSet!=3D=3Dfalse);
+
+}
+
+function DataFetch() {
+
+	if ($this->RecSaved) {
+		if ($this->RecNum<$this->RecNbr) {
+			if ($this->FirstRec) {
+				if ($this->SubType=3D=3D=3D2) { // From string
+					reset($this->RecSet);
+					$this->RecKey =3D key($this->RecSet);
+					$this->CurrRec =3D& $this->RecSet[$this->RecKey];
+				} else {
+					$this->CurrRec =3D reset($this->RecSet);
+					$this->RecKey =3D key($this->RecSet);
+				}
+				$this->FirstRec =3D false;
+			} else {
+				if ($this->SubType=3D=3D=3D2) { // From string
+					next($this->RecSet);
+					$this->RecKey =3D key($this->RecSet);
+					$this->CurrRec =3D& $this->RecSet[$this->RecKey];
+				} else {
+					$this->CurrRec =3D next($this->RecSet);
+					$this->RecKey =3D key($this->RecSet);
+				}
+			}
+			if ((!is_array($this->CurrRec)) and (!is_object($this->CurrRec))) $th=
is->CurrRec =3D array('key'=3D>$this->RecKey, 'val'=3D>$this->CurrRec);
+			$this->RecNum++;
+			if ($this->OnDataOk) {
+				if ($this->OnDataPrm) call_user_func_array($this->OnDataPrmRef,$this=
->OnDataArgs);
+				if ($this->OnDataPi) $this->TBS->meth_PlugIn_RunAll($this->OnDataPiR=
ef,$this->OnDataArgs);
+				if ($this->SubType!=3D=3D2) $this->RecSet[$this->RecKey] =3D $this->=
CurrRec; // save modifications because array reading is done without refe=
rence :(
+			}
+		} else {
+			unset($this->CurrRec); $this->CurrRec =3D false;
+		}
+		return;
+	}
+
+	switch ($this->Type) {
+	case 6: // MySQL
+		$this->CurrRec =3D mysql_fetch_assoc($this->RecSet);
+		break;
+	case 1: // Num
+		if (($this->NumVal>=3D$this->NumMin) and ($this->NumVal<=3D$this->NumM=
ax)) {
+			$this->CurrRec =3D array('val'=3D>$this->NumVal);
+			$this->NumVal +=3D $this->NumStep;
+		} else {
+			$this->CurrRec =3D false;
+		}
+		break;
+	case 2: // Text
+		if ($this->RecNum=3D=3D=3D0) {
+			if ($this->RecSet=3D=3D=3D'') {
+				$this->CurrRec =3D false;
+			} else {
+				$this->CurrRec =3D& $this->RecSet;
+			}
+		} else {
+			$this->CurrRec =3D false;
+		}
+		break;
+	case 3: // Custom function
+		$FctFetch =3D $this->FctFetch;
+		$this->CurrRec =3D $FctFetch($this->RecSet,$this->RecNum+1);
+		break;
+	case 4: // Custom method from ObjectRef
+		$this->FctPrm[0] =3D& $this->RecSet; $this->FctPrm[1] =3D $this->RecNu=
m+1;
+		$this->CurrRec =3D call_user_func_array($this->FctFetch,$this->FctPrm)=
;
+		break;
+	case 5: // Custom method of object
+		$this->CurrRec =3D $this->SrcId->tbsdb_fetch($this->RecSet,$this->RecN=
um+1);
+		break;
+	case 7: // PostgreSQL
+		$this->CurrRec =3D pg_fetch_assoc($this->RecSet);
+		break;
+	case 8: // SQLite
+		$this->CurrRec =3D sqlite_fetch_array($this->RecSet,SQLITE_ASSOC);
+		break;
+	}
+
+	// Set the row count
+	if ($this->CurrRec!=3D=3Dfalse) {
+		$this->RecNum++;
+		if ($this->OnDataOk) {
+			$this->OnDataArgs[1] =3D& $this->CurrRec; // Reference has changed if=
 ($this->SubType=3D=3D=3D2)
+			if ($this->OnDataPrm) call_user_func_array($this->OnDataPrmRef,$this-=
>OnDataArgs);
+			if ($this->OnDataPi) $this->TBS->meth_PlugIn_RunAll($this->OnDataPiRe=
f,$this->OnDataArgs);
+		}
+		if ($this->RecSaving) $this->RecBuffer[$this->RecKey] =3D $this->CurrR=
ec;
+	}
+
+}
+
+function DataClose() {
+	$this->OnDataOk =3D false;
+	$this->OnDataPrm =3D false;
+	$this->OnDataPi =3D false;
+	if ($this->RecSaved) return;
+	switch ($this->Type) {
+	case 6: mysql_free_result($this->RecSet); break;
+	case 3: $FctClose=3D$this->FctClose; $FctClose($this->RecSet); break;
+	case 4: call_user_func_array($this->FctClose,array(&$this->RecSet)); br=
eak;
+	case 5: $this->SrcId->tbsdb_close($this->RecSet); break;
+	case 7: pg_free_result($this->RecSet); break;
+	}
+	if ($this->RecSaving) {
+		$this->RecSet =3D& $this->RecBuffer;
+		$this->RecNbr =3D $this->RecNumInit + count($this->RecSet);
+		$this->RecSaving =3D false;
+		$this->RecSaved =3D true;
+	}
+}
+
+}
+
+// *********************************************
+
+class clsTinyButStrong {
+
+// Public properties
+public $Source =3D '';
+public $Render =3D 3;
+public $TplVars =3D array();
+public $ObjectRef =3D false;
+public $NoErr =3D false;
+// Undocumented (can change at any version)
+public $Version =3D '3.2.0';
+public $HtmlCharSet =3D '';
+public $TurboBlock =3D true;
+public $VarPrefix =3D '';
+public $Protect =3D true;
+public $ErrCount =3D 0;
+// Private
+public $_LastFile =3D '';
+public $_HtmlCharFct =3D false;
+public $_Mode =3D 0;
+public $_CurrBlock =3D '';
+public $_ChrOpen =3D '[';
+public $_ChrClose =3D ']';
+public $_ChrVal =3D '[val]';
+public $_ChrProtect =3D '&#91;';
+public $_PlugIns =3D array();
+public $_PlugIns_Ok =3D false;
+public $_piOnFrm_Ok =3D false;
+
+function clsTinyButStrong($Chrs=3D'',$VarPrefix=3D'') {
+	if ($Chrs!=3D=3D'') {
+		$Ok =3D false;
+		$Len =3D strlen($Chrs);
+		if ($Len=3D=3D=3D2) { // For compatibility
+			$this->_ChrOpen =3D $Chrs[0];
+			$this->_ChrClose =3D $Chrs[1];
+			$Ok =3D true;
+		} else {
+			$Pos =3D strpos($Chrs,',');
+			if (($Pos!=3D=3Dfalse) and ($Pos>0) and ($Pos<$Len-1)) {
+				$this->_ChrOpen =3D substr($Chrs,0,$Pos);
+				$this->_ChrClose =3D substr($Chrs,$Pos+1);
+				$Ok =3D true;
+			}
+		}
+		if ($Ok) {
+			$this->_ChrVal =3D $this->_ChrOpen.'val'.$this->_ChrClose;
+			$this->_ChrProtect =3D '&#'.ord($this->_ChrOpen[0]).';'.substr($this-=
>_ChrOpen,1);
+		} else {
+			$this->meth_Misc_Alert('with clsTinyButStrong() function','value \''.=
$Chrs.'\' is a bad tag delimitor definition.');
+		}
+	}
+	$this->VarPrefix =3D $VarPrefix;
+	// Liaison avec variables globales
+	global $_TBS_FrmMultiLst, $_TBS_FrmSimpleLst, $_TBS_UserFctLst, $_TBS_A=
utoInstallPlugIns;
+	if (!isset($_TBS_FrmMultiLst))  $_TBS_FrmMultiLst  =3D array();
+	if (!isset($_TBS_FrmSimpleLst)) $_TBS_FrmSimpleLst =3D array();
+	if (!isset($_TBS_UserFctLst))   $_TBS_UserFctLst   =3D array();
+	$this->_FrmMultiLst =3D& $_TBS_FrmMultiLst;
+	$this->_FrmSimpleLst =3D& $_TBS_FrmSimpleLst;
+	$this->_UserFctLst =3D& $_TBS_UserFctLst;=20
+	// Auto-installing plug-ins
+	if (isset($_TBS_AutoInstallPlugIns)) foreach ($_TBS_AutoInstallPlugIns =
as $pi) $this->PlugIn(TBS_INSTALL,$pi);
+}
+
+// Public methods
+function LoadTemplate($File,$HtmlCharSet=3D'') {
+	$Ok =3D true;
+	if ($this->_PlugIns_Ok) {
+		if (isset($this->_piBeforeLoadTemplate) or isset($this->_piAfterLoadTe=
mplate)) {
+			// Plug-ins
+			$ArgLst =3D func_get_args();
+			$ArgLst[0] =3D& $File;
+			$ArgLst[1] =3D& $HtmlCharSet;
+			if (isset($this->_piBeforeLoadTemplate)) $Ok =3D $this->meth_PlugIn_R=
unAll($this->_piBeforeLoadTemplate,$ArgLst);
+		}
+	}
+	// Load the file
+	if ($Ok!=3D=3Dfalse) {
+		$x =3D '';
+		if (!tbs_Misc_GetFile($x,$File,$this->_LastFile)) return $this->meth_M=
isc_Alert('with LoadTemplate() method','file \''.$File.'\' is not found o=
r not readable.');
+		// CharSet analysis
+		if ($HtmlCharSet=3D=3D=3D'+') {
+			$this->Source .=3D $x;
+		} else {
+			$this->Source =3D $x;
+			if ($this->_Mode=3D=3D0) {
+				$this->_LastFile =3D $File;
+				$this->_HtmlCharFct =3D false;
+				$this->TplVars =3D array();
+				if (is_string($HtmlCharSet)) {
+					if (($HtmlCharSet!=3D=3D'') and ($HtmlCharSet[0]=3D=3D=3D'=3D')) {
+						$ErrMsg =3D false;
+						$HtmlCharSet =3D substr($HtmlCharSet,1);
+						if ($this->meth_Misc_UserFctCheck($HtmlCharSet,'f',$ErrMsg,$ErrMsg=
)) {
+							$this->_HtmlCharFct =3D true;
+						} else {
+							$this->meth_Misc_Alert('with LoadTemplate() method',$ErrMsg);
+							$HtmlCharSet =3D '';
+						}
+					}
+				} elseif ($HtmlCharSet=3D=3D=3Dfalse) {
+					$this->Protect =3D false;
+				} else {
+					$this->meth_Misc_Alert('with LoadTemplate() method','the CharSet ar=
gument is not a string.');
+					$HtmlCharSet =3D '';
+				}
+				$this->HtmlCharSet =3D $HtmlCharSet;
+			}
+		}
+		// Automatic fields and blocks
+		$this->meth_Merge_AutoOn($this->Source,'onload',true,true);
+		$this->meth_Merge_AutoVar($this->Source,true,'onload');
+	}
+	// Plug-ins
+	if ($this->_PlugIns_Ok and isset($ArgLst) and isset($this->_piAfterLoad=
Template)) $Ok =3D $this->meth_PlugIn_RunAll($this->_piAfterLoadTemplate,=
$ArgLst);
+	return $Ok;
+}
+
+function GetBlockSource($BlockName,$List=3Dfalse,$KeepDefTags=3Dtrue) {
+	$RetVal =3D array();
+	$Nbr =3D 0;
+	$Pos =3D 0;
+	$FieldOutside =3D false;
+	$P1 =3D false;
+	$Mode =3D ($KeepDefTags) ? 3 : 2;
+	while ($Loc =3D $this->meth_Locator_FindBlockNext($this->Source,$BlockN=
ame,$Pos,'.',$Mode,$P1,$FieldOutside)) {
+		$P1 =3D false;
+		$Nbr++;
+		$RetVal[$Nbr] =3D $Loc->BlockSrc;
+		if (!$List) return $RetVal[$Nbr];
+		$Pos =3D $Loc->PosEnd;
+	}
+	if ($List) {
+		return $RetVal;
+	} else {
+		return false;
+	}
+}
+
+function MergeBlock($BlockLst,$SrcId,$Query=3D'') {
+	if ($SrcId=3D=3D=3D'cond') {
+		$Nbr =3D 0;
+		$BlockLst =3D explode(',',$BlockLst);
+		foreach ($BlockLst as $Block) {
+			$Block =3D trim($Block);
+			if ($Block!=3D=3D'') $Nbr +=3D $this->meth_Merge_AutoOn($this->Source=
,$Block,false,false);
+		}
+		return $Nbr;
+	} else {
+		return $this->meth_Merge_Block($this->Source,$BlockLst,$SrcId,$Query,f=
alse,0);
+	}
+}
+
+function MergeField($NameLst,$Value=3Dnull,$IsUserFct=3Dfalse) {
+
+	$FctCheck =3D $IsUserFct;
+	if ($PlugIn =3D isset($this->_piOnMergeField)) $ArgPi =3D array('','',&=
$Value,0,&$this->Source,0,0);
+	$SubStart =3D 0;
+	$Ok =3D true;
+
+	$NameLst =3D explode(',',$NameLst);
+	foreach ($NameLst as $Name) {
+		$Name =3D trim($Name);
+		if ($Name=3D=3D=3D'') continue;
+		if ($this->meth_Merge_AutoAny($Name)) continue;
+		if ($PlugIn) $ArgPi[0] =3D $Name;
+		$PosBeg =3D 0;
+		// Initilize the user function (only once)
+		if ($FctCheck) {
+			$FctInfo =3D $Value;
+			$ErrMsg =3D false;
+			if (!$this->meth_Misc_UserFctCheck($FctInfo,'f',$ErrMsg,$ErrMsg)) ret=
urn $this->meth_Misc_Alert('with MergeField() method',$ErrMsg);
+			$FctArg =3D array('','');
+			$SubStart =3D false;
+			$FctCheck =3D false;
+		}
+		while ($Loc =3D $this->meth_Locator_FindTbs($this->Source,$Name,$PosBe=
g,'.')) {
+			// Apply user function
+			if ($IsUserFct) {
+				$FctArg[0] =3D& $Loc->SubName; $FctArg[1] =3D& $Loc->PrmLst;
+				$Value =3D call_user_func_array($FctInfo,$FctArg);
+			}
+			// Plug-ins
+			if ($PlugIn) {
+				$ArgPi[1] =3D $Loc->SubName; $ArgPi[3] =3D& $Loc->PrmLst; $ArgPi[5] =
=3D& $Loc->PosBeg; $ArgPi[6] =3D& $Loc->PosEnd;
+				$Ok =3D $this->meth_PlugIn_RunAll($this->_piOnMergeField,$ArgPi);
+			}
+			// Merge the field
+			if ($Ok) {
+				$PosBeg =3D $this->meth_Locator_Replace($this->Source,$Loc,$Value,$S=
ubStart);
+			} else {
+				$PosBeg =3D $Loc->PosEnd;
+			}
+		}
+	}
+}
+
+function Show($Render=3Dfalse) {
+	$Ok =3D true;
+	if ($Render=3D=3D=3Dfalse) $Render =3D $this->Render;
+	if ($this->_PlugIns_Ok) {
+		if (isset($this->_piBeforeShow) or isset($this->_piAfterShow)) {
+			// Plug-ins
+			$ArgLst =3D func_get_args();
+			$ArgLst[0] =3D& $Render;
+			if (isset($this->_piBeforeShow)) $Ok =3D $this->meth_PlugIn_RunAll($t=
his->_piBeforeShow,$ArgLst);
+		}
+	}
+	if ($Ok!=3D=3Dfalse) {
+		$this->meth_Merge_AutoAny('onshow');
+		$this->meth_Merge_AutoAny('var');
+	}
+	if ($this->_PlugIns_Ok and isset($ArgLst) and isset($this->_piAfterShow=
)) $this->meth_PlugIn_RunAll($this->_piAfterShow,$ArgLst);
+	if (($Render & TBS_OUTPUT)=3D=3DTBS_OUTPUT) echo $this->Source;
+	if (($this->_Mode=3D=3D0) and (($Render & TBS_EXIT)=3D=3DTBS_EXIT)) exi=
t;
+	return $Ok;
+}
+
+function PlugIn($Prm1,$Prm2=3D0) {
+
+	if (is_numeric($Prm1)) {
+		switch ($Prm1) {
+		case TBS_INSTALL:
+			$PlugInId =3D $Prm2;
+	  	// Try to install the plug-in
+			if (isset($this->_PlugIns[$PlugInId])) {
+				return $this->meth_Misc_Alert('with PlugIn() method','plug-in \''.$P=
lugInId.'\' is already installed.');
+			} else {
+				$ArgLst =3D func_get_args();
+				array_shift($ArgLst); array_shift($ArgLst);
+				return $this->meth_PlugIn_Install($PlugInId,$ArgLst,false);
+			}
+		case TBS_ISINSTALLED:
+	  	// Check if the plug-in is installed
+			return isset($this->_PlugIns[$Prm2]);
+		case -4: // Deactivate special plug-ins
+			$this->_PlugIns_Ok_save =3D $this->_PlugIns_Ok;
+			$this->_PlugIns_Ok =3D false;
+			return true;
+		case -5: // Deactivate OnFormat
+			$this->_piOnFrm_Ok_save =3D $this->_piOnFrm_Ok;
+			$this->_piOnFrm_Ok =3D false;
+			return true;
+		case -10:  // Restore
+			$this->_PlugIns_Ok =3D $this->_PlugIns_Ok_save;
+			$this->_piOnFrm_Ok =3D $this->_piOnFrm_Ok_save;
+			return true;
+		}
+
+  } elseif (is_string($Prm1)) {
+  	// Plug-in's command
+  	$PlugInId =3D $Prm1;
+		if (!isset($this->_PlugIns[$PlugInId])) {
+			if (!$this->meth_PlugIn_Install($PlugInId,array(),true)) return false=
;
+		}
+		if (!isset($this->_piOnCommand[$PlugInId])) return $this->meth_Misc_Al=
ert('with PlugIn() method','plug-in \''.$PlugInId.'\' can\'t run any comm=
and because the OnCommand event is not defined or activated.');
+		$ArgLst =3D func_get_args();
+		array_shift($ArgLst);
+		$Ok =3D call_user_func_array($this->_piOnCommand[$PlugInId],$ArgLst);
+		if (is_null($Ok)) $Ok =3D true;
+		return $Ok;
+  }
+	return $this->meth_Misc_Alert('with PlugIn() method','\''.$Prm1.'\' is =
an invalid plug-in key, the type of the value is \''.gettype($Prm1).'\'.'=
);
+
+}
+
+// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
+
+function meth_Locator_FindTbs(&$Txt,$Name,$Pos,$ChrSub) {
+// Find a TBS Locator
+
+	$PosEnd =3D false;
+	$PosMax =3D strlen($Txt) -1;
+	$Start =3D $this->_ChrOpen.$Name;
+
+	do {
+		// Search for the opening char
+		if ($Pos>$PosMax) return false;
+		$Pos =3D strpos($Txt,$Start,$Pos);
+
+		// If found =3D> next chars are analyzed
+		if ($Pos=3D=3D=3Dfalse) {
+			return false;
+		} else {
+			$Loc =3D new clsTbsLocator;
+			$ReadPrm =3D false;
+			$PosX =3D $Pos + strlen($Start);
+			$x =3D $Txt[$PosX];
+
+			if ($x=3D=3D=3D$this->_ChrClose) {
+				$PosEnd =3D $PosX;
+			} elseif ($x=3D=3D=3D$ChrSub) {
+				$Loc->SubOk =3D true; // it is no longer the false value
+				$ReadPrm =3D true;
+				$PosX++;
+			} elseif (strpos(';',$x)!=3D=3Dfalse) {
+				$ReadPrm =3D true;
+				$PosX++;
+			} else {
+				$Pos++;
+			}
+
+			if ($ReadPrm) {
+				tbs_Locator_PrmRead($Txt,$PosX,false,'\'',$this->_ChrOpen,$this->_Ch=
rClose,$Loc,$PosEnd);
+				if ($PosEnd=3D=3D=3Dfalse) {
+					$this->meth_Misc_Alert('','can\'t found the end of the tag \''.subs=
tr($Txt,$Pos,$PosX-$Pos+10).'...\'.');
+					$Pos++;
+				}
+			}
+
+		}
+
+	} while ($PosEnd=3D=3D=3Dfalse);
+
+	$Loc->PosBeg =3D $Pos;
+	$Loc->PosEnd =3D $PosEnd;
+	if ($Loc->SubOk) {
+		$Loc->FullName =3D $Name.'.'.$Loc->SubName;
+		$Loc->SubLst =3D explode('.',$Loc->SubName);
+		$Loc->SubNbr =3D count($Loc->SubLst);
+	} else {
+		$Loc->FullName =3D $Name;
+	}
+	if ($ReadPrm and isset($Loc->PrmLst['comm'])) {
+		$Loc->PosBeg0 =3D $Loc->PosBeg;
+		$Loc->PosEnd0 =3D $Loc->PosEnd;
+		$comm =3D $Loc->PrmLst['comm'];
+		if (($comm=3D=3D=3Dtrue) or ($comm=3D=3D=3D'')) {
+			$Loc->Enlarged =3D tbs_Locator_EnlargeToStr($Txt,$Loc,'<!--' ,'-->');
+		} else {
+			$Loc->Enlarged =3D tbs_Locator_EnlargeToTag($Txt,$Loc,$comm,false);
+		}
+	}
+
+	return $Loc;
+
+}
+
+function &meth_Locator_SectionNewBDef(&$LocR,$BlockName,$Txt,$PrmLst) {
+
+	$Chk =3D true;
+	$LocLst =3D array();
+	$LocNbr =3D 0;
+
+	// Cache TBS locators
+	if ($this->TurboBlock) {
+
+		$Chk =3D false;
+		$Pos =3D 0;
+		$PrevEnd =3D -1;
+		while ($Loc =3D $this->meth_Locator_FindTbs($Txt,$BlockName,$Pos,'.'))=
 {
+			if (($Loc->SubName=3D=3D=3D'#') or ($Loc->SubName=3D=3D=3D'$')) {
+				$Loc->IsRecInfo =3D true;
+				$Loc->RecInfo =3D $Loc->SubName;
+				$Loc->SubName =3D '';
+			} else {
+				$Loc->IsRecInfo =3D false;
+			}
+			if ($Loc->PosBeg>$PrevEnd) {
+				// The previous tag is not embeding =3D> increment
+				$LocNbr++;
+			} else {
+				// The previous tag is embeding =3D> no increment, then previous is =
over writed
+				$Chk =3D true;
+			}
+			$PrevEnd =3D $Loc->PosEnd;
+			if ($Loc->Enlarged) { // Parameter 'comm'
+				$Pos =3D $Loc->PosBeg0+1;
+				$Loc->Enlarged =3D false;
+			} else {
+				$Pos =3D $Loc->PosBeg+1;
+			}
+			$LocLst[$LocNbr] =3D $Loc;
+		}
+=09
+	}
+
+	// Create the object
+	$o =3D (object) null;
+	$o->Prm =3D $PrmLst;
+	$o->LocLst =3D $LocLst;
+	$o->LocNbr =3D $LocNbr;
+	$o->Name =3D $BlockName;
+	$o->Src =3D $Txt;
+	$o->Chk =3D $Chk;
+	$o->IsSerial =3D false;
+	$LocR->BDefLst[] =3D& $o; // Can be usefull for plug-in
+	return $o;
+
+}
+
+function meth_Locator_SectionAddGrp(&$LocR,&$BDef,$Type,$Field) {
+
+	$BDef->PrevValue =3D false;
+	$BDef->Field =3D $Field;
+
+	if ($Type=3D=3D=3D'H') {
+		if ($LocR->HeaderFound=3D=3D=3Dfalse) {
+			$LocR->HeaderFound =3D true;
+			$LocR->HeaderNbr =3D 0;
+			$LocR->HeaderDef =3D array(); // 1 to HeaderNbr
+		}
+		$i =3D ++$LocR->HeaderNbr;
+		$LocR->HeaderDef[$i] =3D& $BDef;
+	} else {
+		if ($LocR->FooterFound=3D=3D=3Dfalse) {
+			$LocR->FooterFound =3D true;
+			$LocR->FooterNbr =3D 0;
+			$LocR->FooterDef =3D array(); // 1 to FooterNbr
+		}
+		$BDef->IsFooter =3D ($Type=3D=3D=3D'F');
+		$i =3D ++$LocR->FooterNbr;
+		$LocR->FooterDef[$i] =3D& $BDef;
+	}
+
+}
+
+function meth_Locator_Replace(&$Txt,&$Loc,&$Value,$SubStart) {
+// This function enables to merge a locator with a text and returns the =
position just after the replaced block
+// This position can be useful because we don't know in advance how $Val=
ue will be replaced.
+
+	// Found the value if there is a subname
+	if (($SubStart!=3D=3Dfalse) and $Loc->SubOk) {
+		for ($i=3D$SubStart;$i<$Loc->SubNbr;$i++) {
+			$x =3D $Loc->SubLst[$i]; // &$Loc... brings an error with Event Examp=
le, I don't know why.
+			if (is_array($Value)) {
+				if (isset($Value[$x])) {
+					$Value =3D& $Value[$x];
+				} elseif (array_key_exists($x,$Value)) {// can happens when value is=
 NULL
+					$Value =3D& $Value[$x];
+				} else {
+					if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert($Loc,'ite=
m \''.$x.'\' is not an existing key in the array.',true);
+					unset($Value); $Value =3D ''; break;
+				}
+			} elseif (is_object($Value)) {
+				$ArgLst =3D tbs_Misc_CheckArgLst($x);
+				if (method_exists($Value,$x)) {
+					$x =3D call_user_func_array(array(&$Value,$x),$ArgLst);
+				} elseif (property_exists($Value,$x)) {
+					$x =3D& $Value->$x;
+				} else {
+					if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert($Loc,'ite=
m '.$x.'\' is neither a method nor a property in the class \''.get_class(=
$Value).'\'.',true);
+					unset($Value); $Value =3D ''; break;
+				}
+				$Value =3D& $x; unset($x); $x =3D '';
+			} else {
+				if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert($Loc,'item=
 before \''.$x.'\' is neither an object nor an array. Its type is '.getty=
pe($Value).'.',true);
+				unset($Value); $Value =3D ''; break;
+			}
+		}
+	}
+
+	$CurrVal =3D $Value; // Unlink
+
+	if (isset($Loc->PrmLst['onformat'])) {
+		if ($Loc->FirstMerge) {
+			$Loc->OnFrmInfo =3D $Loc->PrmLst['onformat'];
+			$Loc->OnFrmArg =3D array(&$Loc->FullName,'',&$Loc->PrmLst,&$this);
+			$ErrMsg =3D false;
+			if (!$this->meth_Misc_UserFctCheck($Loc->OnFrmInfo,'f',$ErrMsg,$ErrMs=
g)) {
+				unset($Loc->PrmLst['onformat']);
+				if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert($Loc,'(par=
ameter onformat) '.$ErrMsg);
+				$Loc->OnFrmInfo =3D 'pi'; // Execute the function pi() just to avoid=
 extra error messages=20
+			}
+		}
+		$Loc->OnFrmArg[1] =3D& $CurrVal;
+		if (isset($Loc->PrmLst['subtpl'])) {
+			$this->meth_Misc_ChangeMode(true,$Loc,$CurrVal);
+			call_user_func_array($Loc->OnFrmInfo,$Loc->OnFrmArg);
+			$this->meth_Misc_ChangeMode(false,$Loc,$CurrVal);
+			$Loc->ConvProtect =3D false;
+			$Loc->ConvHtml =3D false;
+		} else {
+			call_user_func_array($Loc->OnFrmInfo,$Loc->OnFrmArg);
+		}
+	}
+
+	if ($Loc->FirstMerge) {
+		if (isset($Loc->PrmLst['frm'])) {
+			$Loc->ConvMode =3D 0; // Frm
+			$Loc->ConvProtect =3D false;
+		} else {
+			// Analyze parameter 'htmlconv'
+			if (isset($Loc->PrmLst['htmlconv'])) {
+				$x =3D strtolower($Loc->PrmLst['htmlconv']);
+				$x =3D '+'.str_replace(' ','',$x).'+';
+				if (strpos($x,'+esc+')!=3D=3Dfalse)  {tbs_Misc_ConvSpe($Loc); $Loc->=
ConvHtml =3D false; $Loc->ConvEsc =3D true; }
+				if (strpos($x,'+wsp+')!=3D=3Dfalse)  {tbs_Misc_ConvSpe($Loc); $Loc->=
ConvWS =3D true; }
+				if (strpos($x,'+js+')!=3D=3Dfalse)   {tbs_Misc_ConvSpe($Loc); $Loc->=
ConvHtml =3D false; $Loc->ConvJS =3D true; }
+				if (strpos($x,'+no+')!=3D=3Dfalse)   $Loc->ConvHtml =3D false;
+				if (strpos($x,'+yes+')!=3D=3Dfalse)  $Loc->ConvHtml =3D true;
+				if (strpos($x,'+nobr+')!=3D=3Dfalse) {$Loc->ConvHtml =3D true; $Loc-=
>ConvBr =3D false; }
+			} else {
+				if ($this->HtmlCharSet=3D=3D=3Dfalse) $Loc->ConvHtml =3D false; // N=
o HTML
+			}
+			// Analyze parameter 'protect'
+			if (isset($Loc->PrmLst['protect'])) {
+				$x =3D strtolower($Loc->PrmLst['protect']);
+				if ($x=3D=3D=3D'no') {
+					$Loc->ConvProtect =3D false;
+				} elseif ($x=3D=3D=3D'yes') {
+					$Loc->ConvProtect =3D true;
+				}
+			} elseif ($this->Protect=3D=3D=3Dfalse) {
+				$Loc->ConvProtect =3D false;
+			}
+		}
+		if ($Loc->Ope =3D isset($Loc->PrmLst['ope'])) {
+			$OpeLst =3D explode(',',$Loc->PrmLst['ope']);
+			$Loc->OpeAct =3D array();
+			$Loc->OpeArg =3D array();
+			foreach ($OpeLst as $i=3D>$ope) {
+				if ($ope=3D=3D=3D'list') {
+					$Loc->OpeAct[$i] =3D 1;
+					$Loc->OpePrm[$i] =3D (isset($Loc->PrmLst['valsep'])) ? $Loc->PrmLst=
['valsep'] : ',';
+				} else {
+					$x =3D substr($ope,0,4);
+					if ($x=3D=3D=3D'max:') {
+						$Loc->OpeAct[$i] =3D (isset($Loc->PrmLst['maxhtml'])) ? 2 : 3;
+						$Loc->OpePrm[$i] =3D intval(trim(substr($ope,4)));
+						$Loc->OpeEnd =3D (isset($Loc->PrmLst['maxend'])) ? $Loc->PrmLst['m=
axend'] : '...';
+						if ($Loc->OpePrm[$i]<=3D0) $Loc->Ope =3D false;
+					} elseif ($x=3D=3D=3D'mod:') {$Loc->OpeAct[$i] =3D 4; $Loc->OpePrm[=
$i] =3D '0'+trim(substr($ope,4));
+					} elseif ($x=3D=3D=3D'add:') {$Loc->OpeAct[$i] =3D 5; $Loc->OpePrm[=
$i] =3D '0'+trim(substr($ope,4));
+					} elseif ($x=3D=3D=3D'mul:') {$Loc->OpeAct[$i] =3D 6; $Loc->OpePrm[=
$i] =3D '0'+trim(substr($ope,4));
+					} elseif ($x=3D=3D=3D'div:') {$Loc->OpeAct[$i] =3D 7; $Loc->OpePrm[=
$i] =3D '0'+trim(substr($ope,4));
+					} elseif (isset($this->_piOnOperation)) {
+						$Loc->OpeAct[$i] =3D 0;
+						$Loc->OpePrm[$i] =3D $ope;
+						$Loc->OpeArg[$i] =3D array(&$Loc->FullName,&$CurrVal,&$Loc->PrmLst=
,&$Txt,$Loc->PosBeg,$Loc->PosEnd,&$Loc);
+						$Loc->PrmLst['_ope'] =3D $Loc->PrmLst['ope'];
+					} elseif (!isset($Loc->PrmLst['noerr'])) {
+						$this->meth_Misc_Alert($Loc,'parameter ope doesn\'t support value =
\''.$ope.'\'.',true);
+					}
+				}
+			}
+		}
+		$Loc->FirstMerge =3D false;
+	}
+	$ConvProtect =3D $Loc->ConvProtect;
+
+	// Plug-in OnFormat
+	if ($this->_piOnFrm_Ok) {
+		if (isset($Loc->OnFrmArgPi)) {
+			$Loc->OnFrmArgPi[1] =3D& $CurrVal;
+		} else {
+			$Loc->OnFrmArgPi =3D array(&$Loc->FullName,&$CurrVal,&$Loc->PrmLst,&$=
this);
+		}
+		$this->meth_PlugIn_RunAll($this->_piOnFormat,$Loc->OnFrmArgPi);
+	}
+
+	// Operation
+	if ($Loc->Ope) {
+		foreach ($Loc->OpeAct as $i=3D>$ope) {
+			switch ($ope) {
+			case 0:
+				$Loc->PrmLst['ope'] =3D $Loc->OpePrm[$i]; // for compatibility
+				$OpeArg =3D& $Loc->OpeArg[$i];
+				$OpeArg[1] =3D& $CurrVal; $OpeArg[3] =3D& $Txt;
+				if (!$this->meth_PlugIn_RunAll($this->_piOnOperation,$OpeArg)) retur=
n $Loc->PosBeg;
+				break;
+			case 1: if (is_array($CurrVal)) $CurrVal =3D implode($Loc->OpePrm[$i]=
,$CurrVal); break;
+			case 2: if (strlen(''.$CurrVal)>$Loc->OpePrm[$i]) tbs_Html_Max($CurrV=
al,$Loc->OpePrm[$i],$Loc->OpeEnd); break;
+			case 3: if (strlen(''.$CurrVal)>$Loc->OpePrm[$i]) $CurrVal =3D substr=
(''.$CurrVal,0,$Loc->OpePrm[$i]).$Loc->OpeEnd; break;
+			case 4: $CurrVal =3D ('0'+$CurrVal) % $Loc->OpePrm[$i]; break;
+			case 5: $CurrVal =3D ('0'+$CurrVal) + $Loc->OpePrm[$i]; break;
+			case 6: $CurrVal =3D ('0'+$CurrVal) * $Loc->OpePrm[$i]; break;
+			case 7: $CurrVal =3D ('0'+$CurrVal) / $Loc->OpePrm[$i]; break;
+			}
+		}
+	}
+
+	// HTML conversion or format
+	if ($Loc->ConvMode=3D=3D=3D1) { // Html simple
+		if (!is_string($CurrVal)) $CurrVal =3D @strval($CurrVal);
+		if ($Loc->ConvHtml) {
+			$this->meth_Conv_Html($CurrVal);
+			if ($Loc->ConvBr) $CurrVal =3D nl2br($CurrVal);
+		}
+	} elseif ($Loc->ConvMode=3D=3D=3D0) { // Format
+		$CurrVal =3D $this->meth_Misc_Format($CurrVal,$Loc->PrmLst);
+	} elseif ($Loc->ConvMode=3D=3D=3D2) { // Html special
+		if (!is_string($CurrVal)) $CurrVal =3D @strval($CurrVal);
+		if ($Loc->ConvHtml) {
+			$this->meth_Conv_Html($CurrVal);
+			if ($Loc->ConvBr) $CurrVal =3D nl2br($CurrVal);
+		}
+		if ($Loc->ConvEsc) $CurrVal =3D str_replace('\'','\'\'',$CurrVal);
+		if ($Loc->ConvWS) {
+			$check =3D '  ';
+			$nbsp =3D '&nbsp;';
+			do {
+				$pos =3D strpos($CurrVal,$check);
+				if ($pos!=3D=3Dfalse) $CurrVal =3D substr_replace($CurrVal,$nbsp,$po=
s,1);
+			} while ($pos!=3D=3Dfalse);
+		}
+		if ($Loc->ConvJS) {
+			$CurrVal =3D addslashes($CurrVal); // apply to ('), ("), (\) and (nul=
l)
+			$CurrVal =3D str_replace("\n",'\n',$CurrVal);
+			$CurrVal =3D str_replace("\r",'\r',$CurrVal);
+			$CurrVal =3D str_replace("\t",'\t',$CurrVal);
+		}
+	}
+
+	// if/then/else process, there may be several if/then
+	if ($Loc->PrmIfNbr) {
+		$z =3D false;
+		$i =3D 1;
+		while ($i!=3D=3Dfalse) {
+			if ($Loc->PrmIfVar[$i]) $Loc->PrmIfVar[$i] =3D $this->meth_Merge_Auto=
Var($Loc->PrmIf[$i],true);
+			$x =3D str_replace($this->_ChrVal,$CurrVal,$Loc->PrmIf[$i]);
+			if (tbs_Misc_CheckCondition($x)) {
+				if (isset($Loc->PrmThen[$i])) {
+					if ($Loc->PrmThenVar[$i]) $Loc->PrmThenVar[$i] =3D $this->meth_Merg=
e_AutoVar($Loc->PrmThen[$i],true);
+					$z =3D $Loc->PrmThen[$i];
+				}
+				$i =3D false;
+			} else {
+				$i++;
+				if ($i>$Loc->PrmIfNbr) {
+					if (isset($Loc->PrmLst['else'])) {
+						if ($Loc->PrmElseVar) $Loc->PrmElseVar =3D $this->meth_Merge_AutoV=
ar($Loc->PrmLst['else'],true);
+						$z =3D$Loc->PrmLst['else'];
+					}
+					$i =3D false;
+				}
+			}
+		}
+		if ($z!=3D=3Dfalse) {
+			if ($ConvProtect) {
+				$CurrVal =3D str_replace($this->_ChrOpen,$this->_ChrProtect,$CurrVal=
); // TBS protection
+				$ConvProtect =3D false;
+			}
+			$CurrVal =3D str_replace($this->_ChrVal,$CurrVal,$z);
+		}
+	}
+
+	if (isset($Loc->PrmLst['file'])) {
+		$x =3D $Loc->PrmLst['file'];
+		if ($x=3D=3D=3Dtrue) $x =3D $CurrVal;
+		$this->meth_Merge_AutoVar($x,false);
+		$x =3D trim(str_replace($this->_ChrVal,$CurrVal,$x));
+		$CurrVal =3D '';
+		if ($x!=3D=3D'') {
+			if (tbs_Misc_GetFile($CurrVal,$x,$this->_LastFile)) {
+				if (isset($Loc->PrmLst['getbody'])) $CurrVal =3D tbs_Html_GetPart($C=
urrVal,$Loc->PrmLst['getbody'],false,true);
+			} else {
+				if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert($Loc,'the =
file \''.$x.'\' given by parameter file is not found or not readable.',tr=
ue);
+			}
+			$ConvProtect =3D false;
+		}
+	}
+
+	if (isset($Loc->PrmLst['script'])) {// Include external PHP script
+		$x =3D $Loc->PrmLst['script'];
+		if ($x=3D=3D=3Dtrue) $x =3D $CurrVal;
+		$this->meth_Merge_AutoVar($x,false);
+		$x =3D trim(str_replace($this->_ChrVal,$CurrVal,$x));
+		if ($x!=3D=3D'') {
+			$this->_Subscript =3D $x;
+			$this->CurrPrm =3D& $Loc->PrmLst;
+			$sub =3D isset($Loc->PrmLst['subtpl']);
+			if ($sub) $this->meth_Misc_ChangeMode(true,$Loc,$CurrVal);
+			if ($this->meth_Misc_RunSubscript($CurrVal,$Loc->PrmLst)=3D=3D=3Dfals=
e) {
+				if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert($Loc,'the =
file \''.$x.'\' given by parameter script is not found or not readable.',=
true);
+			}
+			if ($sub) $this->meth_Misc_ChangeMode(false,$Loc,$CurrVal);
+			if (isset($Loc->PrmLst['getbody'])) $CurrVal =3D tbs_Html_GetPart($Cu=
rrVal,$Loc->PrmLst['getbody'],false,true);
+			unset($this->CurrPrm);
+			$ConvProtect =3D false;
+		}
+	}
+
+	// Case when it's an empty string
+	if ($CurrVal=3D=3D=3D'') {
+
+		if ($Loc->MagnetId=3D=3D=3Dfalse) {
+			if (isset($Loc->PrmLst['.'])) {
+				$Loc->MagnetId =3D -1;
+			} elseif (isset($Loc->PrmLst['ifempty'])) {
+				$Loc->MagnetId =3D -2;
+			} elseif (isset($Loc->PrmLst['magnet'])) {
+				$Loc->MagnetId =3D 1;
+				$Loc->PosBeg0 =3D $Loc->PosBeg;
+				$Loc->PosEnd0 =3D $Loc->PosEnd;
+				if (isset($Loc->PrmLst['mtype'])) {
+					switch ($Loc->PrmLst['mtype']) {
+					case 'm+m': $Loc->MagnetId =3D 2; break;
+					case 'm*': $Loc->MagnetId =3D 3; break;
+					case '*m': $Loc->MagnetId =3D 4; break;
+					}
+				}
+			} else {
+				$Loc->MagnetId =3D 0;
+			}
+		}
+
+		switch ($Loc->MagnetId) {
+		case 0: break;
+		case -1: $CurrVal =3D '&nbsp;'; break; // Enables to avoid blanks in H=
TML tables
+		case -2: $CurrVal =3D $Loc->PrmLst['ifempty']; break;
+		case 1:
+			$Loc->Enlarged =3D true;
+			tbs_Locator_EnlargeToTag($Txt,$Loc,$Loc->PrmLst['magnet'],false);
+			break;
+		case 2:
+			$Loc->Enlarged =3D true;
+			$CurrVal =3D tbs_Locator_EnlargeToTag($Txt,$Loc,$Loc->PrmLst['magnet'=
],true);
+			break;
+		case 3:
+			$Loc->Enlarged =3D true;
+			$Loc2 =3D tbs_Html_FindTag($Txt,$Loc->PrmLst['magnet'],true,$Loc->Pos=
Beg,false,1,false);
+			if ($Loc2!=3D=3Dfalse) {
+				$Loc->PosBeg =3D $Loc2->PosBeg;
+				if ($Loc->PosEnd<$Loc2->PosEnd) $Loc->PosEnd =3D $Loc2->PosEnd;
+			}
+			break;
+		case 4:
+			$Loc->Enlarged =3D true;
+			$Loc2 =3D tbs_Html_FindTag($Txt,$Loc->PrmLst['magnet'],true,$Loc->Pos=
Beg,true,1,false);
+			if ($Loc2!=3D=3Dfalse) $Loc->PosEnd =3D $Loc2->PosEnd;
+			break;
+		}
+		$NewEnd =3D $Loc->PosBeg; // Useful when mtype=3D'm+m'
+	} else {
+
+		if ($ConvProtect) $CurrVal =3D str_replace($this->_ChrOpen,$this->_Chr=
Protect,$CurrVal); // TBS protection
+		$NewEnd =3D $Loc->PosBeg + strlen($CurrVal);
+
+	}
+
+	$Txt =3D substr_replace($Txt,$CurrVal,$Loc->PosBeg,$Loc->PosEnd-$Loc->P=
osBeg+1);
+	return $NewEnd; // Return the new end position of the field
+
+}
+
+function meth_Locator_FindBlockNext(&$Txt,$BlockName,$PosBeg,$ChrSub,$Mo=
de,&$P1,&$FieldBefore) {
+// Return the first block locator just after the PosBeg position
+// Mode =3D 1 : Merge_Auto =3D> doesn't save $Loc->BlockSrc, save the bo=
unds of TBS Def tags instead, return also fields
+// Mode =3D 2 : FindBlockLst or GetBlockSource =3D> save $Loc->BlockSrc =
without TBS Def tags
+// Mode =3D 3 : GetBlockSource =3D> save $Loc->BlockSrc with TBS Def tag=
s
+
+	$SearchDef =3D true;
+	$FirstField =3D false;
+
+	// Search for the first tag with parameter "block"
+	while ($SearchDef and ($Loc =3D $this->meth_Locator_FindTbs($Txt,$Block=
Name,$PosBeg,$ChrSub))) {
+		if (isset($Loc->PrmLst['block'])) {
+			if ($P1) {
+				if (isset($Loc->PrmLst['p1'])) return false;
+			} else {
+				if (isset($Loc->PrmLst['p1'])) $P1 =3D true;
+			}
+			$Block =3D $Loc->PrmLst['block'];
+			$SearchDef =3D false;
+		} elseif ($Mode=3D=3D=3D1) {
+			return $Loc;
+		} elseif ($FirstField=3D=3D=3Dfalse) {
+			$FirstField =3D $Loc;
+		}
+		$PosBeg =3D $Loc->PosEnd;
+	}
+
+	if ($SearchDef) {
+		if ($FirstField!=3D=3Dfalse) $FieldBefore =3D true;
+		return false;
+	}
+
+	if ($Block=3D=3D=3D'begin') { // Block definied using begin/end
+
+		if (($FirstField!=3D=3Dfalse) and ($FirstField->PosEnd<$Loc->PosBeg)) =
$FieldBefore =3D true;
+
+		$Opened =3D 1;
+		while ($Loc2 =3D $this->meth_Locator_FindTbs($Txt,$BlockName,$PosBeg,$=
ChrSub)) {
+			if (isset($Loc2->PrmLst['block'])) {
+				switch ($Loc2->PrmLst['block']) {
+				case 'end':   $Opened--; break;
+				case 'begin': $Opened++; break;
+				}
+				if ($Opened=3D=3D0) {
+					if ($Mode=3D=3D=3D1) {
+						$Loc->PosBeg2 =3D $Loc2->PosBeg;
+						$Loc->PosEnd2 =3D $Loc2->PosEnd;
+					} else {
+						if ($Mode=3D=3D=3D2) {
+							$Loc->BlockSrc =3D substr($Txt,$Loc->PosEnd+1,$Loc2->PosBeg-$Loc-=
>PosEnd-1);
+						} else {
+							$Loc->BlockSrc =3D substr($Txt,$Loc->PosBeg,$Loc2->PosEnd-$Loc->P=
osBeg+1);
+						}
+						$Loc->PosEnd =3D $Loc2->PosEnd;
+						$Loc->PosDef =3D 0;
+					}
+					$Loc->BlockFound =3D true;
+					return $Loc;
+				}
+			}
+			$PosBeg =3D $Loc2->PosEnd;
+		}
+
+		return $this->meth_Misc_Alert($Loc,'a least one tag with parameter \'b=
lock=3Dend\' is missing.',false,'in block\'s definition');
+
+	}
+
+	if ($Mode=3D=3D=3D1) {
+		$Loc->PosBeg2 =3D false;
+	} else {
+
+		$Loc->PosDef =3D $Loc->PosBeg;
+		if (!$Loc->SubOk) {
+			$PosBeg1 =3D $Loc->PosBeg;
+			$PosEnd1 =3D $Loc->PosEnd;
+		}
+		if (tbs_Locator_EnlargeToTag($Txt,$Loc,$Block,false)=3D=3D=3Dfalse) re=
turn $this->meth_Misc_Alert($Loc,'at least one tag corresponding to '.$Lo=
c->PrmLst['block'].' is not found. Check opengin tags, closing tags and l=
evels.',false,'in block\'s definition');
+		$Loc->PosDef =3D $Loc->PosDef - $Loc->PosBeg;
+		if ($Loc->SubOk or ($Mode=3D=3D=3D3)) {
+			$Loc->BlockSrc =3D substr($Txt,$Loc->PosBeg,$Loc->PosEnd-$Loc->PosBeg=
+1);
+			$Loc->PosDef++;
+		} else {
+			$Loc->BlockSrc =3D substr($Txt,$Loc->PosBeg,$PosBeg1-$Loc->PosBeg).su=
bstr($Txt,$PosEnd1+1,$Loc->PosEnd-$PosEnd1);
+		}
+	}
+
+	$Loc->BlockFound =3D true;
+	if (($FirstField!=3D=3Dfalse) and ($FirstField->PosEnd<$Loc->PosBeg)) $=
FieldBefore =3D true;
+	return $Loc; // methods return by ref by default
+
+}
+
+function meth_Locator_FindBlockLst(&$Txt,$BlockName,$Pos,$SpePrm) {
+// Return a locator object covering all block definitions, even if there=
 is no block definition found.
+
+	$LocR =3D new clsTbsLocator;
+	$LocR->P1 =3D false;
+	$LocR->FieldOutside =3D false;
+	$LocR->BDefLst =3D array();
+=09
+	$LocR->NoData =3D false;
+	$LocR->Special =3D false;
+	$LocR->HeaderFound =3D false;
+	$LocR->FooterFound =3D false;
+	$LocR->SerialEmpty =3D false;
+
+	$LocR->WhenFound =3D false;
+	$LocR->WhenDefault =3D false;
+
+	$LocR->SectionNbr =3D 0;       // Normal sections
+	$LocR->SectionLst =3D array(); // 1 to SectionNbr
+
+	$BDef =3D false;
+	$ParentLst =3D array();
+	$Pid =3D 0;
+
+	do {
+
+		if ($BlockName=3D=3D=3D'') {
+			$Loc =3D false;
+		} else {
+			$Loc =3D $this->meth_Locator_FindBlockNext($Txt,$BlockName,$Pos,'.',2=
,$LocR->P1,$LocR->FieldOutside);
+		}
+
+		if ($Loc=3D=3D=3Dfalse) {
+
+			if ($Pid>0) { // parentgrp mode =3D> disconnect $Txt from the source
+				$Parent =3D& $ParentLst[$Pid];=20
+				$Src =3D $Txt;
+				$Txt =3D& $Parent->Txt;
+				if ($LocR->BlockFound) {
+					// Redefine the Header block
+					$Parent->Src =3D substr($Src,0,$LocR->PosBeg);
+					// Add a Footer block
+					$BDef =3D& $this->meth_Locator_SectionNewBDef($LocR,$BlockName,subs=
tr($Src,$LocR->PosEnd+1),$Parent->Prm);
+					$this->meth_Locator_SectionAddGrp($LocR,$BDef,'F',$Parent->Fld);
+				}
+				// Now go down to previous level
+				$Pos =3D $Parent->Pos;
+				$LocR->PosBeg =3D $Parent->Beg;
+				$LocR->PosEnd =3D $Parent->End;
+				$LocR->BlockFound =3D true;
+				unset($Parent);
+				unset($ParentLst[$Pid]);
+				$Pid--;
+				$Loc =3D true;
+			}
+
+		} else {
+
+			$Pos =3D $Loc->PosEnd;
+
+			// Define the block limits
+			if ($LocR->BlockFound) {
+				if ( $LocR->PosBeg > $Loc->PosBeg ) $LocR->PosBeg =3D $Loc->PosBeg;
+				if ( $LocR->PosEnd < $Loc->PosEnd ) $LocR->PosEnd =3D $Loc->PosEnd;
+			} else {
+				$LocR->BlockFound =3D true;
+				$LocR->PosBeg =3D $Loc->PosBeg;
+				$LocR->PosEnd =3D $Loc->PosEnd;
+			}
+
+			// Merge block parameters
+			if (count($Loc->PrmLst)>0) $LocR->PrmLst =3D array_merge($LocR->PrmLs=
t,$Loc->PrmLst);
+
+			// Save the block and cache its tags
+			$BDef =3D& $this->meth_Locator_SectionNewBDef($LocR,$BlockName,$Loc->=
BlockSrc,$Loc->PrmLst);
+
+			// Add the text in the list of blocks
+			if (isset($Loc->PrmLst['nodata'])) { // Nodata section
+				$LocR->NoData =3D& $BDef;
+			} elseif (($SpePrm!=3D=3Dfalse) and isset($Loc->PrmLst[$SpePrm])) { /=
/ Special section (used for navigation bar)
+				$LocR->Special =3D& $BDef;
+			} elseif (isset($Loc->PrmLst['when'])) {
+				if ($LocR->WhenFound=3D=3D=3Dfalse) {
+					$LocR->WhenFound =3D true;
+					$LocR->WhenSeveral =3D false;
+					$LocR->WhenNbr =3D 0;
+					$LocR->WhenLst =3D array();
+				}
+				$this->meth_Merge_AutoVar($Loc->PrmLst['when'],false);
+				$BDef->WhenCond =3D& $this->meth_Locator_SectionNewBDef($LocR,$Block=
Name,$Loc->PrmLst['when'],array());
+				$BDef->WhenBeforeNS =3D ($LocR->SectionNbr=3D=3D=3D0);
+				$i =3D ++$LocR->WhenNbr;
+				$LocR->WhenLst[$i] =3D& $BDef;
+				if (isset($Loc->PrmLst['several'])) $LocR->WhenSeveral =3D true;
+			} elseif (isset($Loc->PrmLst['default'])) {
+				$LocR->WhenDefault =3D& $BDef;
+				$LocR->WhenDefaultBeforeNS =3D ($LocR->SectionNbr=3D=3D=3D0);
+			} elseif (isset($Loc->PrmLst['headergrp'])) {
+				$this->meth_Locator_SectionAddGrp($LocR,$BDef,'H',$Loc->PrmLst['head=
ergrp']);
+			} elseif (isset($Loc->PrmLst['footergrp'])) {
+				$this->meth_Locator_SectionAddGrp($LocR,$BDef,'F',$Loc->PrmLst['foot=
ergrp']);
+			} elseif (isset($Loc->PrmLst['splittergrp'])) {
+				$this->meth_Locator_SectionAddGrp($LocR,$BDef,'S',$Loc->PrmLst['spli=
ttergrp']);
+			} elseif (isset($Loc->PrmLst['parentgrp'])) {
+				$this->meth_Locator_SectionAddGrp($LocR,$BDef,'H',$Loc->PrmLst['pare=
ntgrp']);
+				$BDef->Fld =3D $Loc->PrmLst['parentgrp'];
+				$BDef->Txt =3D& $Txt;
+				$BDef->Pos =3D $Pos;
+				$BDef->Beg =3D $LocR->PosBeg;
+				$BDef->End =3D $LocR->PosEnd;
+				$Pid++;
+				$ParentLst[$Pid] =3D& $BDef;
+				$Txt =3D& $BDef->Src;
+				$Pos =3D $Loc->PosDef + 1;
+				$LocR->BlockFound =3D false;
+				$LocR->PosBeg =3D false;
+				$LocR->PosEnd =3D false;
+			} elseif (isset($Loc->PrmLst['serial'])) {
+				// Section	with serial subsections
+				$SrSrc =3D& $BDef->Src;
+				// Search the empty item
+				if ($LocR->SerialEmpty=3D=3D=3Dfalse) {
+					$SrName =3D $BlockName.'_0';
+					$x =3D false;
+					$SrLoc =3D $this->meth_Locator_FindBlockNext($SrSrc,$SrName,0,'.',2=
,$x,$x);
+					if ($SrLoc!=3D=3Dfalse) {
+						$LocR->SerialEmpty =3D $SrLoc->BlockSrc;
+						$SrSrc =3D substr_replace($SrSrc,'',$SrLoc->PosBeg,$SrLoc->PosEnd-=
$SrLoc->PosBeg+1);
+					}
+				}
+				$SrName =3D $BlockName.'_1';
+				$x =3D false;
+				$SrLoc =3D $this->meth_Locator_FindBlockNext($SrSrc,$SrName,0,'.',2,=
$x,$x);
+				if ($SrLoc!=3D=3Dfalse) {
+					$SrId =3D 1;
+					do {
+						// Save previous subsection
+						$SrBDef =3D& $this->meth_Locator_SectionNewBDef($LocR,$SrName,$SrL=
oc->BlockSrc,$SrLoc->PrmLst);
+						$SrBDef->SrBeg =3D $SrLoc->PosBeg;
+						$SrBDef->SrLen =3D $SrLoc->PosEnd - $SrLoc->PosBeg + 1;
+						$SrBDef->SrTxt =3D false;
+						$BDef->SrBDefLst[$SrId] =3D& $SrBDef;
+						// Put in order
+						$BDef->SrBDefOrdered[$SrId] =3D& $SrBDef;
+						$i =3D $SrId;
+						while (($i>1) and ($SrBDef->SrBeg<$BDef->SrBDefOrdered[$SrId-1]->S=
rBeg)) {
+							$BDef->SrBDefOrdered[$i] =3D& $BDef->SrBDefOrdered[$i-1];
+							$BDef->SrBDefOrdered[$i-1] =3D& $SrBDef;
+							$i--;
+						}
+						// Search next subsection
+						$SrId++;
+						$SrName =3D $BlockName.'_'.$SrId;
+						$x =3D false;
+						$SrLoc =3D $this->meth_Locator_FindBlockNext($SrSrc,$SrName,0,'.',=
2,$x,$x);
+					} while ($SrLoc!=3D=3Dfalse);
+					$BDef->SrBDefNbr =3D $SrId-1;
+					$BDef->IsSerial =3D true;
+					$i =3D ++$LocR->SectionNbr;
+					$LocR->SectionLst[$i] =3D& $BDef;
+				}
+			} else {
+				// Normal section
+				$i =3D ++$LocR->SectionNbr;
+				$LocR->SectionLst[$i] =3D& $BDef;
+			}
+
+		}
+
+	} while ($Loc!=3D=3Dfalse);
+
+	if ($LocR->WhenFound and ($LocR->SectionNbr=3D=3D=3D0)) {
+		// Add a blank section if When is used without a normal section
+		$BDef =3D& $this->meth_Locator_SectionNewBDef($LocR,$BlockName,'',arra=
y());
+		$LocR->SectionNbr =3D 1;
+		$LocR->SectionLst[1] =3D& $BDef;
+	}
+
+	return $LocR; // methods return by ref by default
+
+}
+
+function meth_Merge_Block(&$Txt,&$BlockLst,&$SrcId,&$Query,$SpePrm,$SpeR=
ecNum) {
+
+	$BlockSave =3D $this->_CurrBlock;
+	$this->_CurrBlock =3D $BlockLst;
+
+	// Get source type and info
+	$Src =3D new clsTbsDataSource;
+	if (!$Src->DataPrepare($SrcId,$this)) {
+		$this->_CurrBlock =3D $BlockSave;
+		return 0;
+	}
+
+	$BlockLst =3D explode(',',$BlockLst);
+	$BlockNbr =3D count($BlockLst);
+	$BlockId =3D 0;
+	$WasP1 =3D false;
+	$NbrRecTot =3D 0;
+	$QueryZ =3D& $Query;
+	$ReturnData =3D false;
+
+	while ($BlockId<$BlockNbr) {
+
+		$RecSpe =3D 0;  // Row with a special block's definition (used for the=
 navigation bar)
+		$QueryOk =3D true;
+		$this->_CurrBlock =3D trim($BlockLst[$BlockId]);
+		if ($this->_CurrBlock=3D=3D=3D'*') {
+			$ReturnData =3D true;
+			if ($Src->RecSaved=3D=3D=3Dfalse) $Src->RecSaving =3D true;
+			$this->_CurrBlock =3D '';
+		}
+
+		// Search the block
+		$LocR =3D $this->meth_Locator_FindBlockLst($Txt,$this->_CurrBlock,0,$S=
pePrm);
+
+		if ($WasP1) $this->meth_Merge_FieldOutside($Txt,$Src,$LocR);
+
+		if ($LocR->BlockFound) {
+			if ($LocR->Special!=3D=3Dfalse) $RecSpe =3D $SpeRecNum;
+			// OnData
+			if ($Src->OnDataPrm =3D isset($LocR->PrmLst['ondata'])) {
+				$Src->OnDataPrmRef =3D $LocR->PrmLst['ondata'];
+				if (isset($Src->OnDataPrmDone[$Src->OnDataPrmRef])) {
+					$Src->OnDataPrm =3D false;
+				} else {
+					$ErrMsg =3D false;
+					if ($this->meth_Misc_UserFctCheck($Src->OnDataPrmRef,'f',$ErrMsg,$E=
rrMsg)) {
+						$Src->OnDataOk =3D true;
+					} else {
+						$LocR->FullName =3D $this->_CurrBlock;
+						$Src->OnDataPrm =3D $this->meth_Misc_Alert($LocR,'(parameter ondat=
a) '.$ErrMsg,false,'block');
+					}
+				}
+			}
+			// Dynamic query
+			if ($LocR->P1) {
+				if (is_string($Query)) {
+					$Src->RecSaved =3D false;
+					unset($QueryZ); $QueryZ =3D ''.$Query;
+					$i =3D 1;
+					do {
+						$x =3D 'p'.$i;
+						if (isset($LocR->PrmLst[$x])) {
+							$QueryZ =3D str_replace('%p'.$i.'%',$LocR->PrmLst[$x],$QueryZ);
+							$i++;
+						} else {
+							$i =3D false;
+						}
+					} while ($i!=3D=3Dfalse);
+				}
+				$WasP1 =3D true;
+			} elseif (($Src->RecSaved=3D=3D=3Dfalse) and ($BlockNbr-$BlockId>1)) =
{
+				$Src->RecSaving =3D true;
+			}
+		} elseif ($WasP1) {
+			$QueryOk =3D false;
+			$WasP1 =3D false;
+		}
+
+		// Open the recordset
+		if ($QueryOk) {
+			if ((!$LocR->BlockFound) and (!$LocR->FieldOutside)) {
+				// Special case: return data without any block to merge=20
+				$QueryOk =3D false;
+				if ($ReturnData and (!$Src->RecSaved)) {
+					if ($Src->DataOpen($QueryZ)) {
+						do {$Src->DataFetch();} while ($Src->CurrRec!=3D=3Dfalse);
+						$Src->DataClose();
+					}
+				}
+			}	else {
+				$QueryOk =3D $Src->DataOpen($QueryZ);
+			}
+		}
+
+		// Merge sections
+		if ($QueryOk) {
+			if ($Src->Type=3D=3D=3D2) { // Special for Text merge
+				if ($LocR->BlockFound) {
+					$Src->RecNum =3D 1;
+					$Src->CurrRec =3D false;
+					$Txt =3D substr_replace($Txt,$Src->RecSet,$LocR->PosBeg,$LocR->PosE=
nd-$LocR->PosBeg+1);
+				} else {
+					$Src->DataAlert('can\'t merge the block with a text value because t=
he block definition is not found.');
+				}
+			} elseif ($LocR->BlockFound=3D=3D=3Dfalse) {
+				$Src->DataFetch(); // Merge first record only
+			} else {
+				$this->meth_Merge_BlockSections($Txt,$LocR,$Src,$RecSpe);
+			}
+			$Src->DataClose(); // Close the resource
+		}
+
+		if (!$WasP1) {
+			$NbrRecTot +=3D $Src->RecNum;
+			if ($LocR->FieldOutside and $QueryOk) {
+				$LocR->BlockFound =3D false; // Cancel Loc limit
+				$this->meth_Merge_FieldOutside($Txt,$Src,$LocR);
+			}
+			$BlockId++;
+		}
+
+	}
+
+	// End of the merge
+	unset($LocR);
+	$this->_CurrBlock =3D $BlockSave;
+	if ($ReturnData) {
+		return $Src->RecSet;
+	} else {
+		unset($Src);
+		return $NbrRecTot;
+	}
+
+}
+
+function meth_Merge_BlockSections(&$Txt,&$LocR,&$Src,&$RecSpe) {
+
+	// Initialise
+	$SecId =3D 0;
+	$SecOk =3D ($LocR->SectionNbr>0);
+	$SecSrc =3D '';
+	$BlockRes =3D ''; // The result of the chained merged blocks
+	$IsSerial =3D false;
+	$SrId =3D 0;
+	$SrNbr =3D 0;
+	$GrpFound =3D ($LocR->HeaderFound or $LocR->FooterFound);
+	if ($LocR->FooterFound) $PrevSrc =3D (object) null;
+	$piOMS =3D false;
+  // Plug-ins
+	if ($this->_PlugIns_Ok and isset($this->_piBeforeMergeBlock)) {
+		$ArgLst =3D array(&$Txt,&$LocR->PosBeg,&$LocR->PosEnd,$LocR->PrmLst,&$=
Src,&$LocR);
+		$this->meth_Plugin_RunAll($this->_piBeforeMergeBlock,$ArgLst);
+	}
+	if ($this->_PlugIns_Ok and isset($this->_piOnMergeSection)) {
+		$ArgLst =3D array(&$BlockRes,&$SecSrc);
+		$piOMS =3D true;
+	}
+
+	// Main loop
+	$Src->DataFetch();
+	while($Src->CurrRec!=3D=3Dfalse) {
+
+		// Headers and Footers
+		if ($GrpFound) {
+			$grp_change =3D false;
+			$grp_src =3D '';
+			if ($LocR->FooterFound) {
+				$change =3D false;
+				for ($i=3D$LocR->FooterNbr;$i>=3D1;$i--) {
+					$GrpDef =3D& $LocR->FooterDef[$i];
+					$x =3D $Src->CurrRec[$GrpDef->Field];
+					if ($Src->RecNum=3D=3D=3D1) {
+						$GrpDef->PrevValue =3D $x;
+					} else {
+						if ($GrpDef->IsFooter) {
+							$change_i =3D& $change;
+						} else {
+							unset($change_i); $change_i =3D false;
+						}
+						if (!$change_i) $change_i =3D !($GrpDef->PrevValue=3D=3D=3D$x);
+						if ($change_i) {
+							$grp_change =3D true;
+							$grp_src =3D $this->meth_Merge_SectionNormal($GrpDef,$PrevSrc).$g=
rp_src;
+							$GrpDef->PrevValue =3D $x;
+						}
+					}
+				}
+				$PrevSrc->CurrRec =3D $Src->CurrRec;
+				$PrevSrc->RecNum  =3D $Src->RecNum;
+				$PrevSrc->RecKey  =3D $Src->RecKey;
+			}
+			if ($LocR->HeaderFound) {
+				$change =3D ($Src->RecNum=3D=3D=3D1);
+				for ($i=3D1;$i<=3D$LocR->HeaderNbr;$i++) {
+					$GrpDef =3D& $LocR->HeaderDef[$i];
+					$x =3D $Src->CurrRec[$GrpDef->Field];
+					if (!$change) $change =3D !($GrpDef->PrevValue=3D=3D=3D$x);
+					if ($change) {
+						$grp_src .=3D $this->meth_Merge_SectionNormal($GrpDef,$Src);
+						$GrpDef->PrevValue =3D $x;
+					}
+				}
+				$grp_change =3D ($grp_change or $change);
+			}
+			if ($grp_change) {
+				if ($IsSerial) {
+					$BlockRes .=3D $this->meth_Merge_SectionSerial($SecDef,$SrId,$LocR)=
;
+					$IsSerial =3D false;
+				}
+				$BlockRes .=3D $grp_src;
+			}
+		} // end of header and footer
+
+		// Increment Section
+		if (($IsSerial=3D=3D=3Dfalse) and $SecOk) {
+			$SecId++;
+			if ($SecId>$LocR->SectionNbr) $SecId =3D 1;
+			$SecDef =3D& $LocR->SectionLst[$SecId];
+			$IsSerial =3D $SecDef->IsSerial;
+			if ($IsSerial) {
+				$SrId =3D 0;
+				$SrNbr =3D $SecDef->SrBDefNbr;
+			}
+		}
+
+		// Serial Mode Activation
+		if ($IsSerial) { // Serial Merge
+			$SrId++;
+			$SrBDef =3D& $SecDef->SrBDefLst[$SrId];
+			$SrBDef->SrTxt =3D $this->meth_Merge_SectionNormal($SrBDef,$Src);
+			if ($SrId>=3D$SrNbr) {
+				$SecSrc =3D $this->meth_Merge_SectionSerial($SecDef,$SrId,$LocR);
+				$BlockRes .=3D $SecSrc;
+				$IsSerial =3D false;
+			}
+		} else { // Classic merge
+			if ($SecOk) {
+				if ($Src->RecNum=3D=3D=3D$RecSpe) $SecDef =3D& $LocR->Special;=20
+				$SecSrc =3D $this->meth_Merge_SectionNormal($SecDef,$Src);
+			} else {
+				$SecSrc =3D '';
+			}
+			if ($LocR->WhenFound) { // With conditional blocks
+				$found =3D false;
+				$continue =3D true;
+				$i =3D 1;
+				do {
+					$WhenBDef =3D& $LocR->WhenLst[$i];=20
+					$cond =3D $this->meth_Merge_SectionNormal($WhenBDef->WhenCond,$Src)=
;
+					if (tbs_Misc_CheckCondition($cond)) {
+						$x_when =3D $this->meth_Merge_SectionNormal($WhenBDef,$Src);
+						if ($WhenBDef->WhenBeforeNS) {$SecSrc =3D $x_when.$SecSrc;} else {=
$SecSrc =3D $SecSrc.$x_when;}
+						$found =3D true;
+						if ($LocR->WhenSeveral=3D=3D=3Dfalse) $continue =3D false;
+					}
+					$i++;
+					if ($i>$LocR->WhenNbr) $continue =3D false;
+				} while ($continue);
+				if (($found=3D=3D=3Dfalse) and ($LocR->WhenDefault!=3D=3Dfalse)) {
+					$x_when =3D $this->meth_Merge_SectionNormal($LocR->WhenDefault,$Src=
);
+					if ($LocR->WhenDefaultBeforeNS) {$SecSrc =3D $x_when.$SecSrc;} else=
 {$SecSrc =3D $SecSrc.$x_when;}
+				}
+			}
+			if ($piOMS) $this->meth_PlugIn_RunAll($this->_piOnMergeSection,$ArgLs=
t);
+			$BlockRes .=3D $SecSrc;
+		}
+
+		// Next row
+		$Src->DataFetch();
+
+	} //--> while($CurrRec!=3D=3Dfalse) {
+
+	$SecSrc =3D '';
+
+	// Serial: merge the extra the sub-blocks
+	if ($IsSerial) $SecSrc .=3D $this->meth_Merge_SectionSerial($SecDef,$Sr=
Id,$LocR);
+
+	// Footer
+	if ($LocR->FooterFound) {
+		if ($Src->RecNum>0) {
+			for ($i=3D1;$i<=3D$LocR->FooterNbr;$i++) {
+				$GrpDef =3D& $LocR->FooterDef[$i];
+				if ($GrpDef->IsFooter) $SecSrc .=3D $this->meth_Merge_SectionNormal(=
$GrpDef,$PrevSrc);
+			}
+		}
+	}
+
+	// NoData
+	if ($Src->RecNum=3D=3D=3D0) {
+		if ($LocR->NoData!=3D=3Dfalse) {
+			$SecSrc =3D $LocR->NoData->Src;
+		} elseif(isset($LocR->PrmLst['bmagnet'])) {
+			tbs_Locator_EnlargeToTag($Txt,$LocR,$LocR->PrmLst['bmagnet'],false);
+		}
+	}
+
+	// Plug-ins
+	if ($piOMS and ($SecSrc!=3D=3D'')) $this->meth_PlugIn_RunAll($this->_pi=
OnMergeSection,$ArgLst);
+
+	$BlockRes .=3D $SecSrc;
+
+	// Plug-ins
+	if ($this->_PlugIns_Ok and isset($ArgLst) and isset($this->_piAfterMerg=
eBlock)) {
+		$ArgLst =3D array(&$BlockRes,&$Src,&$LocR);
+		$this->meth_PlugIn_RunAll($this->_piAfterMergeBlock,$ArgLst);
+	}
+
+	// Merge the result
+	$Txt =3D substr_replace($Txt,$BlockRes,$LocR->PosBeg,$LocR->PosEnd-$Loc=
R->PosBeg+1);
+
+}
+
+function meth_Merge_AutoVar(&$Txt,$HtmlConv,$Id=3D'var') {
+// Merge [var.*] fields with global variables
+
+	$Pref =3D& $this->VarPrefix;
+	$PrefL =3D strlen($Pref);
+	$PrefOk =3D ($PrefL>0);
+
+	if ($HtmlConv=3D=3D=3Dfalse) {
+		$HtmlCharSet =3D $this->HtmlCharSet;
+		$this->HtmlCharSet =3D false;
+	}
+
+	// Then we scann all fields in the model
+	$x =3D '';
+	$Pos =3D 0;
+	while ($Loc =3D $this->meth_Locator_FindTbs($Txt,$Id,$Pos,'.')) {
+		if ($Loc->SubNbr=3D=3D0) $Loc->SubLst[0]=3D''; // In order to force er=
ror message
+		if ($Loc->SubLst[0]=3D=3D=3D'') {
+			$Pos =3D $this->meth_Merge_AutoSpe($Txt,$Loc);
+		} elseif ($Loc->SubLst[0][0]=3D=3D=3D'~') {
+			if (!isset($ObjOk)) $ObjOk =3D (is_object($this->ObjectRef) or is_arr=
ay($this->ObjectRef));
+			if ($ObjOk) {
+				$Loc->SubLst[0] =3D substr($Loc->SubLst[0],1);
+				$Pos =3D $this->meth_Locator_Replace($Txt,$Loc,$this->ObjectRef,0);
+			} elseif ($this->NoErr or isset($Loc->PrmLst['noerr'])) {
+				$Pos =3D $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+			} else {
+				$this->meth_Misc_Alert($Loc,'property ObjectRef is neither an object=
 nor an array. Its type is \''.gettype($this->ObjectRef).'\'.',true);
+				$Pos =3D $Loc->PosEnd + 1;
+			}
+		} elseif ($PrefOk and (substr($Loc->SubLst[0],0,$PrefL)!=3D=3D$Pref)) =
{
+			if ($this->NoErr or isset($Loc->PrmLst['noerr'])) {
+				$Pos =3D $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+			} else {
+				$this->meth_Misc_Alert($Loc,'does not match the allowed prefix.',tru=
e);
+				$Pos =3D $Loc->PosEnd + 1;
+			}
+		} elseif (isset($GLOBALS[$Loc->SubLst[0]])) {
+			$Pos =3D $this->meth_Locator_Replace($Txt,$Loc,$GLOBALS[$Loc->SubLst[=
0]],1);
+		} else {
+			if ($this->NoErr or isset($Loc->PrmLst['noerr'])) {
+				$Pos =3D $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+			} else {
+				$Pos =3D $Loc->PosEnd + 1;
+				$this->meth_Misc_Alert($Loc,'the PHP global variable named \''.$Loc-=
>SubLst[0].'\' does not exist or is not set yet.',true);
+			}
+		}
+	}
+
+	if ($HtmlConv=3D=3D=3Dfalse) $this->HtmlCharSet =3D $HtmlCharSet;
+
+	return false; // Useful property PrmIfVar & PrmThenVar
+
+}
+
+function meth_Merge_AutoSpe(&$Txt,&$Loc) {
+// Merge [var..*] (Special Var Fields)
+
+	$ErrMsg =3D false;
+	$SubStart =3D false;
+	if (isset($Loc->SubLst[1])) {
+		switch ($Loc->SubLst[1]) {
+		case 'now': $x =3D mktime(); break;
+		case 'version': $x =3D $this->Version; break;
+		case 'script_name': $x =3D basename(((isset($_SERVER)) ? $_SERVER['PHP=
_SELF'] : $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] )); break;
+		case 'template_name': $x =3D $this->_LastFile; break;
+		case 'template_date': $x =3D filemtime($this->_LastFile); break;
+		case 'template_path': $x =3D dirname($this->_LastFile).'/'; break;
+		case 'name': $x =3D 'TinyButStrong'; break;
+		case 'logo': $x =3D '**TinyButStrong**'; break;
+		case 'charset': $x =3D $this->HtmlCharSet; break;
+		case '': $ErrMsg =3D 'it doesn\'t have any keyword.'; break;
+		case 'tplvars':
+			if ($Loc->SubNbr=3D=3D2) {
+				$SubStart =3D 2;
+				$x =3D implode(',',array_keys($this->TplVars));
+			} else {
+				if (isset($this->TplVars[$Loc->SubLst[2]])) {
+					$SubStart =3D 3;
+					$x =3D& $this->TplVars[$Loc->SubLst[2]];
+				} else {
+					$ErrMsg =3D 'property TplVars doesn\'t have any item named \''.$Loc=
->SubLst[2].'\'.';
+				}
+			}
+			break;
+		case 'cst': $x =3D @constant($Loc->SubLst[2]); break;
+		case 'tbs_info':
+			$x =3D 'TinyButStrong version '.$this->Version.' for PHP 5';
+			$x .=3D "\r\nInstalled plug-ins: ".count($this->_PlugIns);=20
+			foreach (array_keys($this->_PlugIns) as $pi) {
+				$o =3D& $this->_PlugIns[$pi];
+				$x .=3D "\r\n- plug-in [".(isset($o->Name) ? $o->Name : $pi ).'] ver=
sion '.(isset($o->Version) ? $o->Version : '?' );
+			}
+			break;
+		default:
+			$IsSupported =3D false;
+			if (isset($this->_piOnSpecialVar)) {
+				$x =3D '';
+				$ArgLst =3D array(substr($Loc->SubName,1),&$IsSupported ,&$x, &$Loc-=
>PrmLst,&$Txt,&$Loc->PosBeg,&$Loc->PosEnd,&$Loc);
+				$this->meth_PlugIn_RunAll($this->_piOnSpecialVar,$ArgLst) ;
+			}
+			if (!$IsSupported) $ErrMsg =3D '\''.$Loc->SubLst[1].'\' is an unsuppo=
rted keyword.';
+		}
+	} else {
+		$ErrMsg =3D 'it doesn\'t have any subname.';
+	}
+	if ($ErrMsg!=3D=3Dfalse) {
+		$this->meth_Misc_Alert($Loc,$ErrMsg);
+		$x =3D '';
+	}
+	if ($Loc->PosBeg=3D=3D=3Dfalse) {
+		return $Loc->PosEnd;
+	} else {
+		return $this->meth_Locator_Replace($Txt,$Loc,$x,$SubStart);
+	}
+}
+
+function meth_Merge_AutoAny($Name) {
+// Merge any automatic fields (var, onload, onshow)
+	switch ($Name) {
+	case 'var':	$this->meth_Merge_AutoVar($this->Source,true); return true;
+	case 'onload': $this->meth_Merge_AutoOn($this->Source,'onload',true,tru=
e); return true;
+	case 'onshow': $this->meth_Merge_AutoOn($this->Source,'onshow',false,tr=
ue);return true;
+	default: return false;
+	}
+}
+
+function meth_Merge_FieldOutside(&$Txt,&$Src,&$LocR) {
+	$Pos =3D 0;
+	$SubStart =3D ($Src->CurrRec=3D=3D=3Dfalse) ? false : 0;
+	do {
+		$Loc =3D $this->meth_Locator_FindTbs($Txt,$this->_CurrBlock,$Pos,'.');
+		if ($LocR->BlockFound and ($Loc!=3D=3Dfalse)) {
+			$OldEnd =3D $Loc->PosEnd;
+			if ($Loc->PosEnd>=3D$LocR->PosBeg) $Loc =3D false;
+		}
+		if ($Loc!=3D=3Dfalse) {
+			if ($Loc->SubName=3D=3D=3D'#') {
+				$Pos =3D $this->meth_Locator_Replace($Txt,$Loc,$Src->RecNum,false);
+			} else {
+				$Pos =3D $this->meth_Locator_Replace($Txt,$Loc,$Src->CurrRec,$SubSta=
rt);
+			}
+			if ($LocR->BlockFound) {
+				$Delta =3D $Pos - $OldEnd;
+				$LocR->PosBeg +=3D $Delta; =20
+				$LocR->PosEnd +=3D $Delta; =20
+			}
+		}
+	} while ($Loc!=3D=3Dfalse);
+}
+
+function meth_Merge_SectionNormal(&$BDef,&$Src) {
+
+	$Txt =3D $BDef->Src;
+	$LocLst =3D& $BDef->LocLst;
+	$iMax =3D $BDef->LocNbr;
+	$PosMax =3D strlen($Txt);
+
+	if ($Src=3D=3D=3Dfalse) { // Erase all fields
+
+		$x =3D '';
+
+		// Chached locators
+		for ($i=3D$iMax;$i>0;$i--) {
+			if ($LocLst[$i]->PosBeg<$PosMax) {
+				$this->meth_Locator_Replace($Txt,$LocLst[$i],$x,false);
+				if ($LocLst[$i]->Enlarged) {
+					$PosMax =3D $LocLst[$i]->PosBeg;
+					$LocLst[$i]->PosBeg =3D $LocLst[$i]->PosBeg0;
+					$LocLst[$i]->PosEnd =3D $LocLst[$i]->PosEnd0;
+					$LocLst[$i]->Enlarged =3D false;
+				}
+			}
+		}
+
+		// Unchached locators
+		if ($BDef->Chk) {
+			$BlockName =3D& $BDef->Name;
+			$Pos =3D 0;
+			while ($Loc =3D $this->meth_Locator_FindTbs($Txt,$BlockName,$Pos,'.')=
) $Pos =3D $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+		}
+
+	} else {
+
+		// Chached locators
+		for ($i=3D$iMax;$i>0;$i--) {
+			if ($LocLst[$i]->PosBeg<$PosMax) {
+				if ($LocLst[$i]->IsRecInfo) {
+					if ($LocLst[$i]->RecInfo=3D=3D=3D'#') {
+						$this->meth_Locator_Replace($Txt,$LocLst[$i],$Src->RecNum,false);
+					} else {
+						$this->meth_Locator_Replace($Txt,$LocLst[$i],$Src->RecKey,false);
+					}
+				} else {
+					$this->meth_Locator_Replace($Txt,$LocLst[$i],$Src->CurrRec,0);
+				}
+				if ($LocLst[$i]->Enlarged) {
+					$PosMax =3D $LocLst[$i]->PosBeg;
+					$LocLst[$i]->PosBeg =3D $LocLst[$i]->PosBeg0;
+					$LocLst[$i]->PosEnd =3D $LocLst[$i]->PosEnd0;
+					$LocLst[$i]->Enlarged =3D false;
+				}
+			}
+		}
+
+		// Unchached locators
+		if ($BDef->Chk) {
+			$BlockName =3D& $BDef->Name;
+			foreach ($Src->CurrRec as $key =3D> $val) {
+				$Pos =3D 0;
+				$Name =3D $BlockName.'.'.$key;
+				while ($Loc =3D $this->meth_Locator_FindTbs($Txt,$Name,$Pos,'.')) $P=
os =3D $this->meth_Locator_Replace($Txt,$Loc,$val,0);
+			}
+			$Pos =3D 0;
+			$Name =3D $BlockName.'.#';
+			while ($Loc =3D $this->meth_Locator_FindTbs($Txt,$Name,$Pos,'.')) $Po=
s =3D $this->meth_Locator_Replace($Txt,$Loc,$Src->RecNum,0);
+			$Pos =3D 0;
+			$Name =3D $BlockName.'.$';
+			while ($Loc =3D $this->meth_Locator_FindTbs($Txt,$Name,$Pos,'.')) $Po=
s =3D $this->meth_Locator_Replace($Txt,$Loc,$Src->RecKey,0);
+		}
+
+	}
+
+	return $Txt;
+
+}
+
+function meth_Merge_SectionSerial(&$BDef,&$SrId,&$LocR) {
+
+	$Txt =3D $BDef->Src;
+	$SrBDefOrdered =3D& $BDef->SrBDefOrdered;
+	$Empty =3D& $LocR->SerialEmpty;=20
+
+	// All Items
+	$F =3D false;
+	for ($i=3D$BDef->SrBDefNbr;$i>0;$i--) {
+		$SrBDef =3D& $SrBDefOrdered[$i];
+		if ($SrBDef->SrTxt=3D=3D=3Dfalse) { // Subsection not merged with a re=
cord
+			if ($Empty=3D=3D=3Dfalse) {
+				$SrBDef->SrTxt =3D $this->meth_Merge_SectionNormal($SrBDef,$F);
+			} else {
+				$SrBDef->SrTxt =3D $Empty;
+			}
+		}
+		$Txt =3D substr_replace($Txt,$SrBDef->SrTxt,$SrBDef->SrBeg,$SrBDef->Sr=
Len);
+		$SrBDef->SrTxt =3D false;
+	}
+
+	$SrId =3D 0;
+	return $Txt;
+
+}
+
+function meth_Merge_AutoOn(&$Txt,$Name,$TplVar,$AcceptGrp) {
+// Merge [onload] or [onshow] fields and blocks
+
+	$GrpDisplayed =3D array();
+	$GrpExclusive =3D array();
+	$P1 =3D false;
+	$FieldBefore =3D false;
+	$Pos =3D 0;
+
+	if ($AcceptGrp) {
+		$ChrSub =3D '_';
+	} else {
+		$ChrSub =3D '';
+	}
+
+	while ($LocA=3D$this->meth_Locator_FindBlockNext($Txt,$Name,$Pos,$ChrSu=
b,1,$P1,$FieldBefore)) {
+
+		if ($LocA->BlockFound) {
+
+			if (!isset($GrpDisplayed[$LocA->SubName])) {
+				$GrpDisplayed[$LocA->SubName] =3D false;
+				$GrpExclusive[$LocA->SubName] =3D !($AcceptGrp and ($LocA->SubName=3D=
=3D=3D''));
+			}
+			$Displayed =3D& $GrpDisplayed[$LocA->SubName];
+			$Exclusive =3D& $GrpExclusive[$LocA->SubName];
+
+			$DelBlock =3D false;
+			$DelField =3D false;
+			if ($Displayed and $Exclusive) {
+				$DelBlock =3D true;
+			} else {
+				if (isset($LocA->PrmLst['when'])) {
+					if (isset($LocA->PrmLst['several'])) $Exclusive=3Dfalse;
+					$x =3D $LocA->PrmLst['when'];
+					$this->meth_Merge_AutoVar($x,false);
+					if (tbs_Misc_CheckCondition($x)) {
+						$DelField =3D true;
+						$Displayed =3D true;
+					} else {
+						$DelBlock =3D true;
+					}
+				} elseif(isset($LocA->PrmLst['default'])) {
+					if ($Displayed) {
+						$DelBlock =3D true;
+					} else {
+						$Displayed =3D true;
+						$DelField =3D true;
+					}
+					$Exclusive =3D true; // No more block displayed for the group after=
 VisElse
+				}
+			}
+
+			// Del parts
+			if ($DelField) {
+				if ($LocA->PosBeg2!=3D=3Dfalse) $Txt =3D substr_replace($Txt,'',$Loc=
A->PosBeg2,$LocA->PosEnd2-$LocA->PosBeg2+1);
+				$Txt =3D substr_replace($Txt,'',$LocA->PosBeg,$LocA->PosEnd-$LocA->P=
osBeg+1);
+				$Pos =3D $LocA->PosBeg;
+			} else {
+				if ($LocA->PosBeg2=3D=3D=3Dfalse) {
+					tbs_Locator_EnlargeToTag($Txt,$LocA,$LocA->PrmLst['block'],false);
+				} else {
+					$LocA->PosEnd =3D $LocA->PosEnd2;
+				}
+				if ($DelBlock) {
+					$Txt =3D substr_replace($Txt,'',$LocA->PosBeg,$LocA->PosEnd-$LocA->=
PosBeg+1);
+				} else {
+					// Merge the block as if it was a field
+					$x =3D '';
+					$this->meth_Locator_Replace($Txt,$LocA,$x,false);
+				}
+				$Pos =3D $LocA->PosBeg;
+			}
+
+		} else { // Field
+
+			// Check for Template Var
+			if ($TplVar and	isset($LocA->PrmLst['tplvars'])) {
+				$Ok =3D false;
+				foreach ($LocA->PrmLst as $Key =3D> $Val) {
+					if ($Ok) {
+						$this->TplVars[$Key] =3D $Val;
+					} else {
+						if ($Key=3D=3D=3D'tplvars') $Ok =3D true;
+					}
+				}
+			}
+
+			$x =3D '';
+			$Pos =3D $this->meth_Locator_Replace($Txt,$LocA,$x,false);
+			$Pos =3D $LocA->PosBeg;
+
+		}
+
+	}
+
+	return count($GrpDisplayed);
+
+}
+
+// Convert a string to Html with several options
+function meth_Conv_Html(&$Txt) {
+	if ($this->HtmlCharSet=3D=3D=3D'') {
+		$Txt =3D htmlspecialchars($Txt); // Faster
+	} elseif ($this->_HtmlCharFct) {
+		$Txt =3D call_user_func($this->HtmlCharSet,$Txt);
+	} else {
+		$Txt =3D htmlspecialchars($Txt,ENT_COMPAT,$this->HtmlCharSet);
+	}
+}
+
+// Standard alert message provided by TinyButStrong, return False is the=
 message is cancelled.
+function meth_Misc_Alert($Src,$Msg,$NoErrMsg=3Dfalse,$SrcType=3Dfalse) {
+	$this->ErrCount++;
+	if ($this->NoErr) return false;
+	if (!is_string($Src)) {
+		if ($SrcType=3D=3D=3Dfalse) $SrcType=3D'in field';
+		$Src =3D $SrcType.' '.$this->_ChrOpen.$Src->FullName.'...'.$this->_Chr=
Close;
+	}
+	$x =3D '<br /><b>TinyButStrong Error</b> '.$Src.' : '.htmlentities($Msg=
);
+	if ($NoErrMsg) $x =3D $x.' <em>This message can be cancelled using para=
meter \'noerr\'.</em>';
+	$x =3D $x."<br />\n";
+	$x =3D str_replace($this->_ChrOpen,$this->_ChrProtect,$x);
+	echo $x;
+	return false;
+}
+
+function meth_Misc_ChangeMode($Init,&$Loc,&$CurrVal) {
+	if ($Init) {
+		// Save contents configuration
+		$Loc->SaveSrc =3D& $this->Source;
+		$Loc->SaveRender =3D $this->Render;
+		$Loc->SaveMode =3D $this->_Mode;
+		unset($this->Source); $this->Source =3D '';
+		$this->Render =3D TBS_OUTPUT;
+		$this->_Mode++; // Mode>0 means subtemplate mode
+		ob_start(); // Start buffuring output=20
+	} else {
+		// Restore contents configuration
+		$this->Source =3D& $Loc->SaveSrc;
+		$this->Render =3D $Loc->SaveRender;
+		$this->_Mode =3D $Loc->SaveMode;
+		$CurrVal =3D ob_get_contents();
+		ob_end_clean();
+	}
+}
+
+function meth_Misc_UserFctCheck(&$FctInfo,$FctCat,&$FctObj,&$ErrMsg) {
+
+	$FctId =3D $FctCat.':'.$FctInfo;
+	if (isset($this->_UserFctLst[$FctId])) {
+		$FctInfo =3D $this->_UserFctLst[$FctId];
+		return true;
+	}
+
+	// Check and put in cache
+	$FctStr =3D $FctInfo;
+	$IsData =3D ($FctCat!=3D=3D'f');
+	$Save =3D true;
+	if ($FctStr[0]=3D=3D=3D'~') {
+		$ObjRef =3D& $this->ObjectRef;
+		$Lst =3D explode('.',substr($FctStr,1));
+		$iMax =3D count($Lst) - 1;
+		$Suff =3D 'tbsdb';
+		$iMax0 =3D $iMax;
+		if ($IsData) {
+			$Suff =3D $Lst[$iMax];
+			$iMax--;
+		}
+		// Reading sub items
+		for ($i=3D0;$i<=3D$iMax;$i++) {
+			$x =3D& $Lst[$i];
+			if (is_object($ObjRef)) {
+				$ArgLst =3D tbs_Misc_CheckArgLst($x);
+				if (method_exists($ObjRef,$x)) {
+					if ($i<$iMax) {
+						$f =3D array(&$ObjRef,$x); unset($ObjRef);
+						$ObjRef =3D call_user_func_array($f,$ArgLst);
+					}
+				} elseif ($i=3D=3D=3D$iMax0) {
+					$ErrMsg =3D 'Expression \''.$FctStr.'\' is invalid because \''.$x.'=
\' is not a method in the class \''.get_class($ObjRef).'\'.';
+					return false;
+				} elseif (isset($ObjRef->$x)) {
+					$ObjRef =3D& $ObjRef->$x;
+				} else {
+					$ErrMsg =3D 'Expression \''.$FctStr.'\' is invalid because sub-item=
 \''.$x.'\' is neither a method nor a property in the class \''.get_class=
($ObjRef).'\'.';
+					return false;
+				}
+			} elseif (($i<$iMax0) and is_array($ObjRef)) {
+				if (isset($ObjRef[$x])) {
+					$ObjRef =3D& $ObjRef[$x];
+				} else {
+					$ErrMsg =3D 'Expression \''.$FctStr.'\' is invalid because sub-item=
 \''.$x.'\' is not a existing key in the array.';
+					return false;
+				}
+			} else {
+				$ErrMsg =3D 'Expression \''.$FctStr.'\' is invalid because '.(($i=3D=
=3D=3D0)?'property ObjectRef':'sub-item \''.$x.'\'').' is not an object'.=
(($i<$iMax)?' or an array.':'.');
+				return false;
+			}
+		}
+		// Referencing last item
+		if ($IsData) {
+			$FctInfo =3D array('open'=3D>'','fetch'=3D>'','close'=3D>'');
+			foreach ($FctInfo as $act=3D>$x) {
+				$FctName =3D $Suff.'_'.$act;
+				if (method_exists($ObjRef,$FctName)) {
+					$FctInfo[$act] =3D array(&$ObjRef,$FctName);
+				} else {
+					$ErrMsg =3D 'Expression \''.$FctStr.'\' is invalid because method '=
.$FctName.' is not found.';
+					return false;
+				}
+			}
+			$FctInfo['type'] =3D 4;
+			if (isset($this->RecheckObj) and $this->RecheckObj) $Save =3D false;
+		} else {
+			$FctInfo =3D array(&$ObjRef,$x);
+		}
+	} elseif ($IsData) {
+
+		$IsObj =3D ($FctCat=3D=3D=3D'o');
+
+		if ($IsObj and method_exists($FctObj,'tbsdb_open') and (!method_exists=
($FctObj,'+'))) { // '+' avoid a bug in PHP 5
+
+			if (!method_exists($FctObj,'tbsdb_fetch')) {
+				$ErrMsg =3D 'the expected method \'tbsdb_fetch\' is not found for th=
e class '.$Cls.'.';
+				return false;
+			}
+			if (!method_exists($FctObj,'tbsdb_close')) {
+				$ErrMsg =3D 'the expected method \'tbsdb_close\' is not found for th=
e class '.$Cls.'.';
+				return false;
+			}
+			$FctInfo =3D array('type'=3D>5);
+
+		}	else {=09
+
+			if ($FctCat=3D=3D=3D'r') { // Resource
+				$x =3D strtolower($FctStr);
+				$x =3D str_replace('-','_',$x);
+				$Key =3D '';
+				$i =3D 0;
+				$iMax =3D strlen($x);
+				while ($i<$iMax) {
+					if (($x[$i]=3D=3D=3D'_') or (($x[$i]>=3D'a') and ($x[$i]<=3D'z')) o=
r (($x[$i]>=3D'0') and ($x[$i]<=3D'9'))) {
+						$Key .=3D $x[$i];
+						$i++;
+					} else {
+						$i =3D $iMax;
+					}
+				}
+			} else {
+				$Key =3D $FctStr;
+			}
+
+			$FctInfo =3D array('open'=3D>'','fetch'=3D>'','close'=3D>'');
+			foreach ($FctInfo as $act=3D>$x) {
+				$FctName =3D 'tbsdb_'.$Key.'_'.$act;
+				if (function_exists($FctName)) {
+					$FctInfo[$act] =3D $FctName;
+				} else {
+					$err =3D true;
+					if ($act=3D=3D=3D'open') { // Try simplified key
+						$p =3D strpos($Key,'_');
+						if ($p!=3D=3Dfalse) {
+							$Key2 =3D substr($Key,0,$p);
+							$FctName2  =3D 'tbsdb_'.$Key2.'_'.$act;
+							if (function_exists($FctName2)) {
+								$err =3D false;
+								$Key =3D $Key2;
+								$FctInfo[$act] =3D $FctName2;
+							}
+						}
+					}
+					if ($err) {
+						$ErrMsg =3D 'Data source Id \''.$FctStr.'\' is unsupported because=
 function \''.$FctName.'\' is not found.';
+						return false;
+					}
+				}
+			}
+
+			$FctInfo['type'] =3D 3;
+		=09
+		}
+	=09
+	} else {
+		if (!function_exists($FctStr)) {
+			$x =3D explode('.',$FctStr);
+			if (count($x)=3D=3D2) {
+				if (class_exists($x[0])) {
+					$FctInfo =3D $x;
+				} else {
+					$ErrMsg =3D 'user function \''.$FctStr.'\' is not correct because \=
''.$x[0].'\' is not a class name.'; return false;
+				}
+			} else {
+				$ErrMsg =3D 'user function \''.$FctStr.'\' is not found.'; return fa=
lse;
+			}
+		}
+	}
+=09
+	if ($Save) $this->_UserFctLst[$FctId] =3D $FctInfo;
+	return true;
+
+}
+
+function meth_Misc_RunSubscript(&$CurrVal,$CurrPrm) {
+// Run a subscript without any local variable damage
+	return @include($this->_Subscript);
+}
+
+function meth_PlugIn_RunAll(&$FctBank,&$ArgLst) {
+	$OkAll =3D true;
+	foreach ($FctBank as $FctInfo) {
+		$Ok =3D call_user_func_array($FctInfo,$ArgLst);
+		if (!is_null($Ok)) $OkAll =3D ($OkAll and $Ok);
+	}
+	return $OkAll;
+}
+
+function meth_PlugIn_Install($PlugInId,$ArgLst,$Auto) {
+
+	$ErrMsg =3D 'with plug-in \''.$PlugInId.'\'';
+
+	if (class_exists($PlugInId)) {
+		// Create an instance
+		$IsObj =3D true;
+		$PiRef =3D new $PlugInId;
+		$PiRef->TBS =3D& $this;
+		if (!method_exists($PiRef,'OnInstall')) return $this->meth_Misc_Alert(=
$ErrMsg,'OnInstall() method is not found.');
+		$FctRef =3D array(&$PiRef,'OnInstall');
+	} else {
+		$FctRef =3D 'tbspi_'.$PlugInId.'_OnInstall';
+		if(function_exists($FctRef)) {
+			$IsObj =3D false;
+			$PiRef =3D true;
+		} else {
+			return $this->meth_Misc_Alert($ErrMsg,'no class named \''.$PlugInId.'=
\' is found, and no function named \''.$FctRef.'\' is found.');
+		}
+	}
+
+	$EventLst =3D call_user_func_array($FctRef,$ArgLst);
+	if (is_string($EventLst)) $EventLst =3D explode(',',$EventLst);
+	if (!is_array($EventLst)) return $this->meth_Misc_Alert($ErrMsg,'OnInst=
all() method does not return an array.');
+
+	// Add activated methods
+	$EventRef =3D explode(',','OnCommand,BeforeLoadTemplate,AfterLoadTempla=
te,BeforeShow,AfterShow,OnData,OnFormat,OnOperation,BeforeMergeBlock,OnMe=
rgeSection,AfterMergeBlock,OnSpecialVar,OnMergeField');
+	foreach ($EventLst as $Event) {
+		$Event =3D trim($Event);
+		if (!in_array($Event,$EventRef)) return $this->meth_Misc_Alert($ErrMsg=
,'OnInstall() method return an unknowed plug-in event named \''.$Event.'\=
' (case-sensitive).');
+		if ($IsObj) {
+			if (!method_exists($PiRef,$Event)) return $this->meth_Misc_Alert($Err=
Msg,'OnInstall() has returned a Plug-in event named \''.$Event.'\' which =
is not found.');
+			$FctRef =3D array(&$PiRef,$Event);
+		} else {
+			$FctRef =3D 'tbspi_'.$PlugInId.'_'.$Event;
+			if (!function_exists($FctRef)) return $this->meth_Misc_Alert($ErrMsg,=
'requiered function \''.$FctRef.'\' is not found.');
+		}
+		// Save information into the corresponding property
+		$PropName =3D '_pi'.$Event;
+		if (!isset($this->$PropName)) $this->$PropName =3D array();
+		$PropRef =3D& $this->$PropName;
+		$PropRef[$PlugInId] =3D $FctRef;
+		// Flags saying if a plugin is installed
+		switch ($Event) {
+		case 'OnCommand': break;
+		case 'OnSpecialVar': break;
+		case 'OnOperation': break;
+		case 'OnFormat': $this->_piOnFrm_Ok =3D true; break;
+		default: $this->_PlugIns_Ok =3D true; break;
+		}
+	}
+
+	$this->_PlugIns[$PlugInId] =3D& $PiRef;
+	return true;
+
+}
+
+function meth_Misc_Format(&$Value,&$PrmLst) {
+// This function return the formated representation of a Date/Time or nu=
meric variable using a 'VB like' format syntax instead of the PHP syntax.
+
+	$FrmStr =3D $PrmLst['frm'];
+	$CheckNumeric =3D true;
+	if (is_string($Value)) $Value =3D trim($Value);
+
+	// Manage Multi format strings
+	if (strpos($FrmStr,'|')!=3D=3Dfalse) {
+
+		// Save the format if it doesn't exist
+		if (isset($this->_FrmMultiLst[$FrmStr])) {
+			$FrmLst =3D& $this->_FrmMultiLst[$FrmStr];
+		} else {
+			$FrmLst =3D explode('|',$FrmStr); // syntax : Postive|Negative|Zero|N=
ull
+			$FrmNbr =3D count($FrmLst);
+			$FrmLst['abs'] =3D ($FrmNbr>1);
+			if ($FrmNbr<3) $FrmLst[2] =3D& $FrmLst[0]; // zero
+			if ($FrmNbr<4) $FrmLst[3] =3D ''; // null
+			$this->_FrmMultiLst[$FrmStr] =3D $FrmLst;
+		}
+
+		// Select the format
+		if (is_numeric($Value)) {
+			if (is_string($Value)) $Value =3D 0.0 + $Value;
+			if ($Value>0) {
+				$FrmStr =3D& $FrmLst[0];
+			} elseif ($Value<0) {
+				$FrmStr =3D& $FrmLst[1];
+				if ($FrmLst['abs']) $Value =3D abs($Value);
+			} else { // zero
+				$FrmStr =3D& $FrmLst[2];
+				$Minus =3D '';
+			}
+			$CheckNumeric =3D false;
+		} else {
+			$Value =3D ''.$Value;
+			if ($Value=3D=3D=3D'') {
+				return $FrmLst[3]; // Null value
+			} else {
+				$t =3D strtotime($Value); // We look if it's a date
+				if (($t=3D=3D=3D-1) or ($t=3D=3D=3Dfalse)) { // Date not recognized
+					return $FrmLst[1];
+				} elseif ($t=3D=3D=3D943916400) { // Date to zero
+					return $FrmLst[2];
+				} else { // It's a date
+					$Value =3D $t;
+					$FrmStr =3D& $FrmLst[0];
+				}
+			}
+		}
+
+	}
+
+	if ($FrmStr=3D=3D=3D'') return '';
+
+	// Retrieve the correct simple format
+	if (!isset($this->_FrmSimpleLst[$FrmStr])) $this->meth_Misc_FormatSave(=
$FrmStr);
+
+	$Frm =3D& $this->_FrmSimpleLst[$FrmStr];
+
+	switch ($Frm['type']) {
+	case 'num' :
+		// NUMERIC
+		if ($CheckNumeric) {
+			if (is_numeric($Value)) {
+				if (is_string($Value)) $Value =3D 0.0 + $Value;
+			} else {
+				return ''.$Value;
+			}
+		}
+		if ($Frm['PerCent']) $Value =3D $Value * 100;
+		$Value =3D number_format($Value,$Frm['DecNbr'],$Frm['DecSep'],$Frm['Th=
sSep']);
+		return substr_replace($FrmStr,$Value,$Frm['Pos'],$Frm['Len']);
+		break;
+	case 'date' :
+		// DATE
+		if (is_string($Value)) {
+			if ($Value=3D=3D=3D'') return '';
+			$x =3D strtotime($Value);
+			if (($x=3D=3D=3D-1) or ($x=3D=3D=3Dfalse)) {
+				if (!is_numeric($Value)) $Value =3D 0;
+			} else {
+				$Value =3D& $x;
+			}
+		} else {
+			if (!is_numeric($Value)) return ''.$Value;
+		}
+		if (isset($PrmLst['locale'])) {
+			return strftime($Frm['str_loc'],$Value);
+		} else {
+			return date($Frm['str_us'],$Value);
+		}
+		break;
+	default:
+		return $Frm['string'];
+		break;
+	}
+
+}
+
+function meth_Misc_FormatSave(&$FrmStr) {
+
+	$nPosEnd =3D strrpos($FrmStr,'0');
+
+	if ($nPosEnd!=3D=3Dfalse) {
+
+		// Numeric format
+		$nDecSep =3D '.';
+		$nDecNbr =3D 0;
+		$nDecOk =3D true;
+
+		if (substr($FrmStr,$nPosEnd+1,1)=3D=3D=3D'.') {
+			$nPosEnd++;
+			$nPosCurr =3D $nPosEnd;
+		} else {
+			$nPosCurr =3D $nPosEnd - 1;
+			while (($nPosCurr>=3D0) and ($FrmStr[$nPosCurr]=3D=3D=3D'0')) {
+				$nPosCurr--;
+			}
+			if (($nPosCurr>=3D1) and ($FrmStr[$nPosCurr-1]=3D=3D=3D'0')) {
+				$nDecSep =3D $FrmStr[$nPosCurr];
+				$nDecNbr =3D $nPosEnd - $nPosCurr;
+			} else {
+				$nDecOk =3D false;
+			}
+		}
+
+		// Thousand separator
+		$nThsSep =3D '';
+		if (($nDecOk) and ($nPosCurr>=3D5)) {
+			if ((substr($FrmStr,$nPosCurr-3,3)=3D=3D=3D'000') and ($FrmStr[$nPosC=
urr-4]!=3D=3D'') and ($FrmStr[$nPosCurr-5]=3D=3D=3D'0')) {
+				$nPosCurr =3D $nPosCurr-4;
+				$nThsSep =3D $FrmStr[$nPosCurr];
+			}
+		}
+
+		// Pass next zero
+		if ($nDecOk) $nPosCurr--;
+		while (($nPosCurr>=3D0) and ($FrmStr[$nPosCurr]=3D=3D=3D'0')) {
+			$nPosCurr--;
+		}
+
+		// Percent
+		$nPerCent =3D (strpos($FrmStr,'%')=3D=3D=3Dfalse) ? false : true;
+
+		$this->_FrmSimpleLst[$FrmStr] =3D array('type'=3D>'num','Pos'=3D>($nPo=
sCurr+1),'Len'=3D>($nPosEnd-$nPosCurr),'ThsSep'=3D>$nThsSep,'DecSep'=3D>$=
nDecSep,'DecNbr'=3D>$nDecNbr,'PerCent'=3D>$nPerCent);
+
+	} else { // if ($nPosEnd!=3D=3Dfalse)
+
+		// Date format
+		$FrmPHP =3D '';
+		$FrmLOC =3D '';
+		$Local =3D false;
+		$StrIn =3D false;
+		$iMax =3D strlen($FrmStr);
+		$Cnt =3D 0;
+
+		for ($i=3D0;$i<$iMax;$i++) {
+
+			if ($StrIn) {
+				// We are in a string part
+				if ($FrmStr[$i]=3D=3D=3D'"') {
+					if (substr($FrmStr,$i+1,1)=3D=3D=3D'"') {
+						$FrmPHP .=3D '\\"'; // protected char
+						$FrmLOC .=3D $FrmStr[$i];
+						$i++;
+					} else {
+						$StrIn =3D false;
+					}
+				} else {
+					$FrmPHP .=3D '\\'.$FrmStr[$i]; // protected char
+					$FrmLOC .=3D $FrmStr[$i];
+				}
+			} else {
+				if ($FrmStr[$i]=3D=3D=3D'"') {
+					$StrIn =3D true;
+				} else {
+					$Cnt++;
+					if     (strcasecmp(substr($FrmStr,$i,2),'hh'  )=3D=3D=3D0) { $FrmPH=
P .=3D 'H'; $FrmLOC .=3D '%H'; $i +=3D 1;}
+					elseif (strcasecmp(substr($FrmStr,$i,2),'hm'  )=3D=3D=3D0) { $FrmPH=
P .=3D 'h'; $FrmLOC .=3D '%I'; $i +=3D 1;} // for compatibility
+					elseif (strcasecmp(substr($FrmStr,$i,1),'h'   )=3D=3D=3D0) { $FrmPH=
P .=3D 'G'; $FrmLOC .=3D '%H';}
+					elseif (strcasecmp(substr($FrmStr,$i,2),'rr'  )=3D=3D=3D0) { $FrmPH=
P .=3D 'h'; $FrmLOC .=3D '%I'; $i +=3D 1;}
+					elseif (strcasecmp(substr($FrmStr,$i,1),'r'   )=3D=3D=3D0) { $FrmPH=
P .=3D 'g'; $FrmLOC .=3D '%I';}
+					elseif (strcasecmp(substr($FrmStr,$i,4),'ampm')=3D=3D=3D0) { $FrmPH=
P .=3D substr($FrmStr,$i,1); $FrmLOC .=3D '%p'; $i +=3D 3;} // $Fmp =3D '=
A' or 'a'
+					elseif (strcasecmp(substr($FrmStr,$i,2),'nn'  )=3D=3D=3D0) { $FrmPH=
P .=3D 'i'; $FrmLOC .=3D '%M'; $i +=3D 1;}
+					elseif (strcasecmp(substr($FrmStr,$i,2),'ss'  )=3D=3D=3D0) { $FrmPH=
P .=3D 's'; $FrmLOC .=3D '%S'; $i +=3D 1;}
+					elseif (strcasecmp(substr($FrmStr,$i,2),'xx'  )=3D=3D=3D0) { $FrmPH=
P .=3D 'S'; $FrmLOC .=3D ''  ; $i +=3D 1;}
+					elseif (strcasecmp(substr($FrmStr,$i,4),'yyyy')=3D=3D=3D0) { $FrmPH=
P .=3D 'Y'; $FrmLOC .=3D '%Y'; $i +=3D 3;}
+					elseif (strcasecmp(substr($FrmStr,$i,2),'yy'  )=3D=3D=3D0) { $FrmPH=
P .=3D 'y'; $FrmLOC .=3D '%y'; $i +=3D 1;}
+					elseif (strcasecmp(substr($FrmStr,$i,4),'mmmm')=3D=3D=3D0) { $FrmPH=
P .=3D 'F'; $FrmLOC .=3D '%B'; $i +=3D 3;}
+					elseif (strcasecmp(substr($FrmStr,$i,3),'mmm' )=3D=3D=3D0) { $FrmPH=
P .=3D 'M'; $FrmLOC .=3D '%b'; $i +=3D 2;}
+					elseif (strcasecmp(substr($FrmStr,$i,2),'mm'  )=3D=3D=3D0) { $FrmPH=
P .=3D 'm'; $FrmLOC .=3D '%m'; $i +=3D 1;}
+					elseif (strcasecmp(substr($FrmStr,$i,1),'m'   )=3D=3D=3D0) { $FrmPH=
P .=3D 'n'; $FrmLOC .=3D '%m';}
+					elseif (strcasecmp(substr($FrmStr,$i,4),'wwww')=3D=3D=3D0) { $FrmPH=
P .=3D 'l'; $FrmLOC .=3D '%A'; $i +=3D 3;}
+					elseif (strcasecmp(substr($FrmStr,$i,3),'www' )=3D=3D=3D0) { $FrmPH=
P .=3D 'D'; $FrmLOC .=3D '%a'; $i +=3D 2;}
+					elseif (strcasecmp(substr($FrmStr,$i,1),'w'   )=3D=3D=3D0) { $FrmPH=
P .=3D 'w'; $FrmLOC .=3D '%u';}
+					elseif (strcasecmp(substr($FrmStr,$i,4),'dddd')=3D=3D=3D0) { $FrmPH=
P .=3D 'l'; $FrmLOC .=3D '%A'; $i +=3D 3;}
+					elseif (strcasecmp(substr($FrmStr,$i,3),'ddd' )=3D=3D=3D0) { $FrmPH=
P .=3D 'D'; $FrmLOC .=3D '%a'; $i +=3D 2;}
+					elseif (strcasecmp(substr($FrmStr,$i,2),'dd'  )=3D=3D=3D0) { $FrmPH=
P .=3D 'd'; $FrmLOC .=3D '%d'; $i +=3D 1;}
+					elseif (strcasecmp(substr($FrmStr,$i,1),'d'   )=3D=3D=3D0) { $FrmPH=
P .=3D 'j'; $FrmLOC .=3D '%d';}
+					else {
+						$FrmPHP .=3D '\\'.$FrmStr[$i]; // protected char
+						$FrmLOC .=3D $FrmStr[$i]; // protected char
+						$Cnt--;
+					}
+				}
+			} //-> if ($StrIn) {...} else
+
+		} //-> for ($i=3D0;$i<$iMax;$i++)
+
+		if ($Cnt>0) {
+			$this->_FrmSimpleLst[$FrmStr] =3D array('type'=3D>'date','str_us'=3D>=
$FrmPHP,'str_loc'=3D>$FrmLOC);
+		} else {
+			$this->_FrmSimpleLst[$FrmStr] =3D array('type'=3D>'else','string'=3D>=
$FrmStr);
+		}
+
+	} // if ($nPosEnd!=3D=3Dfalse) {...} else
+
+}
+
+} // class clsTinyButStrong
+
+// *********************************************
+
+function tbs_Misc_ConvSpe(&$Loc) {
+	if ($Loc->ConvMode!=3D=3D2) {
+		$Loc->ConvMode =3D 2;
+		$Loc->ConvEsc =3D false;
+		$Loc->ConvWS =3D false;
+		$Loc->ConvJS =3D false;
+	}
+}
+
+function tbs_Misc_CheckArgLst(&$Str) {
+	$ArgLst =3D array();
+	if (substr($Str,-1,1)=3D=3D=3D')') {
+		$pos =3D strpos($Str,'(');
+		if ($pos!=3D=3Dfalse) {
+			$ArgLst =3D explode(',',substr($Str,$pos+1,strlen($Str)-$pos-2));
+			$Str =3D substr($Str,0,$pos);
+		}
+	}
+	return $ArgLst;
+}
+
+function tbs_Misc_CheckCondition($Str) {
+// Check if an expression like "exrp1=3Dexpr2" is true or false.
+
+	// Find operator and position
+	$Ope =3D '=3D';
+	$Len =3D 1;
+	$Max =3D strlen($Str)-1;
+	$Pos =3D strpos($Str,$Ope);
+	if ($Pos=3D=3D=3Dfalse) {
+		$Ope =3D '+';
+		$Pos =3D strpos($Str,$Ope);
+		if ($Pos=3D=3D=3Dfalse) return false;
+		if (($Pos>0) and ($Str[$Pos-1]=3D=3D=3D'-')) {
+			$Ope =3D '-+'; $Pos--; $Len=3D2;
+		} elseif (($Pos<$Max) and ($Str[$Pos+1]=3D=3D=3D'-')) {
+			$Ope =3D '+-'; $Len=3D2;
+		} else {
+			return false;
+		}
+	} else {
+		if ($Pos>0) {
+			$x =3D $Str[$Pos-1];
+			if ($x=3D=3D=3D'!') {
+				$Ope =3D '!=3D'; $Pos--; $Len=3D2;
+			} elseif ($x=3D=3D=3D'~') {
+				$Ope =3D '~=3D'; $Pos--; $Len=3D2;
+			} elseif ($Pos<$Max) {
+				$y =3D $Str[$Pos+1];
+				if ($y=3D=3D=3D'=3D') {
+					$Len=3D2;
+				} elseif (($x=3D=3D=3D'+') and ($y=3D=3D=3D'-')) {
+					$Ope =3D '+=3D-'; $Pos--; $Len=3D3;
+				} elseif (($x=3D=3D=3D'-') and ($y=3D=3D=3D'+')) {
+					$Ope =3D '-=3D+'; $Pos--; $Len=3D3;
+				}
+			} else {
+			}
+		}
+	}
+
+	// Read values
+	$Val1  =3D trim(substr($Str,0,$Pos));
+	$Nude1 =3D tbs_Misc_DelDelimiter($Val1,'\'');
+	$Val2  =3D trim(substr($Str,$Pos+$Len));
+	$Nude2 =3D tbs_Misc_DelDelimiter($Val2,'\'');
+
+	// Compare values
+	if ($Ope=3D=3D=3D'=3D') {
+		return (strcasecmp($Val1,$Val2)=3D=3D0);
+	} elseif ($Ope=3D=3D=3D'!=3D') {
+		return (strcasecmp($Val1,$Val2)!=3D0);
+	} elseif ($Ope=3D=3D=3D'~=3D') {
+		return (preg_match($Val2,$Val1)>0);
+	} else {
+		if ($Nude1) $Val1=3D'0'+$Val1;
+		if ($Nude2) $Val2=3D'0'+$Val2;
+		if ($Ope=3D=3D=3D'+-') {
+			return ($Val1>$Val2);
+		} elseif ($Ope=3D=3D=3D'-+') {
+			return ($Val1 < $Val2);
+		} elseif ($Ope=3D=3D=3D'+=3D-') {
+			return ($Val1 >=3D $Val2);
+		} elseif ($Ope=3D=3D=3D'-=3D+') {
+			return ($Val1<=3D$Val2);
+		} else {
+			return false;
+		}
+	}
+
+}
+
+function tbs_Misc_DelDelimiter(&$Txt,$Delim) {
+// Delete the string delimiters
+	$len =3D strlen($Txt);
+	if (($len>1) and ($Txt[0]=3D=3D=3D$Delim)) {
+		if ($Txt[$len-1]=3D=3D=3D$Delim) $Txt =3D substr($Txt,1,$len-2);
+		return false;
+	} else {
+		return true;
+	}
+}
+
+function tbs_Misc_GetFile(&$Txt,&$File,$LastFile=3D'') {
+// Load the content of a file into the text variable.
+	$Txt =3D '';
+	$fd =3D @fopen($File, 'r'); // 'rb' if binary for some OS
+	if ($fd=3D=3D=3Dfalse) {
+		if ($LastFile=3D=3D=3D'') return false;
+		$File2 =3D dirname($LastFile).'/'.$File;
+		$fd =3D @fopen($File2, 'r');
+		if ($fd=3D=3D=3Dfalse) return false;
+		$File =3D $File2;
+	}
+	if ($fd=3D=3D=3Dfalse) return false;
+	$fs =3D @filesize($File); // return False for an URL
+	if ($fs=3D=3D=3Dfalse) {
+		while (!feof($fd)) $Txt .=3D fread($fd,4096);
+	} else {
+		if ($fs>0) $Txt =3D fread($fd,$fs);
+	}
+	fclose($fd);
+	return true;
+}
+
+function tbs_Locator_PrmRead(&$Txt,$Pos,$HtmlTag,$DelimChrs,$BegStr,$End=
Str,&$Loc,&$PosEnd) {
+
+	$BegLen =3D strlen($BegStr);
+	$BegChr =3D $BegStr[0];
+	$BegIs1 =3D ($BegLen=3D=3D=3D1);
+
+	$DelimIdx =3D false;
+	$DelimCnt =3D 0;
+	$DelimChr =3D '';
+	$BegCnt =3D 0;
+	$SubName =3D $Loc->SubOk;
+
+	$Status =3D 0; // 0: name not started, 1: name started, 2: name ended, =
3: equal found, 4: value started
+	$PosName =3D 0;
+	$PosNend =3D 0;
+	$PosVal =3D 0;
+
+	// Variables for checking the loop
+	$PosEnd =3D strpos($Txt,$EndStr,$Pos);
+	if ($PosEnd=3D=3D=3Dfalse) return;
+	$Continue =3D ($Pos<$PosEnd);
+
+	while ($Continue) {
+
+		$Chr =3D $Txt[$Pos];
+
+		if ($DelimIdx) { // Reading in the string
+
+			if ($Chr=3D=3D=3D$DelimChr) { // Quote found
+				if ($Chr=3D=3D=3D$Txt[$Pos+1]) { // Double Quote =3D> the string con=
tinue with un-double the quote
+					$Pos++;
+				} else { // Simple Suote =3D> end of string
+					$DelimIdx =3D false;
+				}
+			}
+
+		} else { // Reading outside the string
+
+			if ($BegCnt=3D=3D=3D0) {
+
+				// Analyzing parameters
+				$CheckChr =3D false;
+				if (($Chr=3D=3D=3D' ') or ($Chr=3D=3D=3D"\r") or ($Chr=3D=3D=3D"\n")=
) {
+					if ($Status=3D=3D=3D1) {
+						$Status =3D 2;
+						$PosNend =3D $Pos;
+					} elseif ($HtmlTag and ($Status=3D=3D=3D4)) {
+						tbs_Locator_PrmCompute($Txt,$Loc,$SubName,$Status,$HtmlTag,$DelimC=
hr,$DelimCnt,$PosName,$PosNend,$PosVal,$Pos);
+						$Status =3D 0;
+					}
+				} elseif (($HtmlTag=3D=3D=3Dfalse) and ($Chr=3D=3D=3D';')) {
+					tbs_Locator_PrmCompute($Txt,$Loc,$SubName,$Status,$HtmlTag,$DelimCh=
r,$DelimCnt,$PosName,$PosNend,$PosVal,$Pos);
+					$Status =3D 0;
+				} elseif ($Status=3D=3D=3D4) {
+					$CheckChr =3D true;
+				} elseif ($Status=3D=3D=3D3) {
+					$Status =3D 4;
+					$DelimCnt =3D 0;
+					$PosVal =3D $Pos;
+					$CheckChr =3D true;
+				} elseif ($Status=3D=3D=3D2) {
+					if ($Chr=3D=3D=3D'=3D') {
+						$Status =3D 3;
+					} elseif ($HtmlTag) {
+						tbs_Locator_PrmCompute($Txt,$Loc,$SubName,$Status,$HtmlTag,$DelimC=
hr,$DelimCnt,$PosName,$PosNend,$PosVal,$Pos);
+						$Status =3D 1;
+						$PosName =3D $Pos;
+						$CheckChr =3D true;
+					} else {
+						$Status =3D 4;
+						$DelimCnt =3D 0;
+						$PosVal =3D $Pos;
+						$CheckChr =3D true;
+					}
+				} elseif ($Status=3D=3D=3D1) {
+					if ($Chr=3D=3D=3D'=3D') {
+						$Status =3D 3;
+						$PosNend =3D $Pos;
+					} else {
+						$CheckChr =3D true;
+					}
+				} else {
+					$Status =3D 1;
+					$PosName =3D $Pos;
+					$CheckChr =3D true;
+				}
+
+				if ($CheckChr) {
+					$DelimIdx =3D strpos($DelimChrs,$Chr);
+					if ($DelimIdx=3D=3D=3Dfalse) {
+						if ($Chr=3D=3D=3D$BegChr) {
+							if ($BegIs1) {
+								$BegCnt++;
+							} elseif(substr($Txt,$Pos,$BegLen)=3D=3D=3D$BegStr) {
+								$BegCnt++;
+							}
+						}
+					} else {
+						$DelimChr =3D $DelimChrs[$DelimIdx];
+						$DelimCnt++;
+						$DelimIdx =3D true;
+					}
+				}
+
+			} else {
+				if ($Chr=3D=3D=3D$BegChr) {
+					if ($BegIs1) {
+						$BegCnt++;
+					} elseif(substr($Txt,$Pos,$BegLen)=3D=3D=3D$BegStr) {
+						$BegCnt++;
+					}
+				}
+			}
+
+		}
+
+		// Next char
+		$Pos++;
+
+		// We check if it's the end
+		if ($Pos=3D=3D=3D$PosEnd) {
+			if ($DelimIdx=3D=3D=3Dfalse) {
+				if ($BegCnt>0) {
+					$BegCnt--;
+				} else {
+					$Continue =3D false;
+				}
+			}
+			if ($Continue) {
+				$PosEnd =3D strpos($Txt,$EndStr,$PosEnd+1);
+				if ($PosEnd=3D=3D=3Dfalse) return;
+			} else {
+				if ($HtmlTag and ($Txt[$Pos-1]=3D=3D=3D'/')) $Pos--; // In case last=
 attribute is stuck to "/>"=20
+				tbs_Locator_PrmCompute($Txt,$Loc,$SubName,$Status,$HtmlTag,$DelimChr=
,$DelimCnt,$PosName,$PosNend,$PosVal,$Pos);
+			}
+		}
+
+	}
+
+	$PosEnd =3D $PosEnd + (strlen($EndStr)-1);
+
+}
+
+function tbs_Locator_PrmCompute(&$Txt,&$Loc,&$SubName,$Status,$HtmlTag,$=
DelimChr,$DelimCnt,$PosName,$PosNend,$PosVal,$Pos) {
+
+	if ($Status=3D=3D=3D0) {
+		$SubName =3D false;
+	} else {
+		if ($Status=3D=3D=3D1) {
+			$x =3D substr($Txt,$PosName,$Pos-$PosName);
+		} else {
+			$x =3D substr($Txt,$PosName,$PosNend-$PosName);
+		}
+		if ($HtmlTag) $x =3D strtolower($x);
+		if ($SubName) {
+			$Loc->SubName =3D $x;
+			$SubName =3D false;
+		} else {
+			if ($Status=3D=3D=3D4) {
+				$v =3D trim(substr($Txt,$PosVal,$Pos-$PosVal));
+				if ($DelimCnt=3D=3D=3D1) { // Delete quotes inside the value
+					if ($v[0]=3D=3D=3D$DelimChr) {
+						$len =3D strlen($v);
+						if ($v[$len-1]=3D=3D=3D$DelimChr) {
+							$v =3D substr($v,1,$len-2);
+							$v =3D str_replace($DelimChr.$DelimChr,$DelimChr,$v);
+						}
+					}
+				}
+			} else {
+				$v =3D true;
+			}
+			if ($x=3D=3D=3D'if') {
+				tbs_Locator_PrmIfThen($Loc,true,$v);
+			} elseif ($x=3D=3D=3D'then') {
+				tbs_Locator_PrmIfThen($Loc,false,$v);
+			} else {
+				$Loc->PrmLst[$x] =3D $v;
+			}
+		}
+	}
+
+}
+
+function tbs_Locator_PrmIfThen(&$Loc,$IsIf,$Val) {
+	$nbr =3D& $Loc->PrmIfNbr;
+	if ($nbr=3D=3D=3Dfalse) {
+		$nbr =3D 0;
+		$Loc->PrmIf =3D array();
+		$Loc->PrmIfVar =3D array();
+		$Loc->PrmThen =3D array();
+		$Loc->PrmThenVar =3D array();
+		$Loc->PrmElseVar =3D true;
+	}=20
+	if ($IsIf) {
+		$nbr++;
+		$Loc->PrmIf[$nbr] =3D $Val;
+		$Loc->PrmIfVar[$nbr] =3D true;
+	} else {
+		$nbr2 =3D $nbr;
+		if ($nbr2=3D=3D=3Dfalse) $nbr2 =3D 1; // Only the first 'then' can be =
placed before its 'if'. This is for compatibility.
+		$Loc->PrmThen[$nbr2] =3D $Val;
+		$Loc->PrmThenVar[$nbr2] =3D true;
+	}
+}
+
+function tbs_Locator_EnlargeToStr(&$Txt,&$Loc,$StrBeg,$StrEnd) {
+/*
+This function enables to enlarge the pos limits of the Locator.
+If the search result is not correct, $PosBeg must not change its value, =
and $PosEnd must be False.
+This is because of the calling function.
+*/
+
+	// Search for the begining string
+	$Pos =3D $Loc->PosBeg;
+	$Ok =3D false;
+	do {
+		$Pos =3D strrpos(substr($Txt,0,$Pos),$StrBeg[0]);
+		if ($Pos!=3D=3Dfalse) {
+			if (substr($Txt,$Pos,strlen($StrBeg))=3D=3D=3D$StrBeg) $Ok =3D true;
+		}
+	} while ( (!$Ok) and ($Pos!=3D=3Dfalse) );
+
+	if ($Ok) {
+		$PosEnd =3D strpos($Txt,$StrEnd,$Loc->PosEnd + 1);
+		if ($PosEnd=3D=3D=3Dfalse) {
+			$Ok =3D false;
+		} else {
+			$Loc->PosBeg =3D $Pos;
+			$Loc->PosEnd =3D $PosEnd + strlen($StrEnd) - 1;
+		}
+	}
+
+	return $Ok;
+
+}
+
+function tbs_Locator_EnlargeToTag(&$Txt,&$Loc,$TagLst,$RetInnerSrc) {
+//Modify $Loc, return false if tags not found, returns the inner source =
of tag if $RetInnerSrc=3Dtrue
+
+	// Analyze string
+	$Ref =3D 0;
+	$LevelStop =3D 0;
+	$TagLst =3D explode('+',$TagLst);
+	$TagIsSgl =3D array();
+  $TagMax =3D count($TagLst) - 1;
+  for ($i=3D0;$i<=3D$TagMax;$i++) {
+ 		do { // Check parentheses, relative position and single tag
+ 			$tag =3D& $TagLst[$i];
+	  	$tag =3D trim($tag);
+	 		$x =3D strlen($tag) - 1; // pos of last char
+	 		if (($x>1) and ($tag[0]=3D=3D=3D'(') and ($tag[$x]=3D=3D=3D')')) {
+	 			if ($Ref=3D=3D=3D0) $Ref =3D $i;
+	 			if ($Ref=3D=3D=3D$i) $LevelStop++;
+	 			$tag =3D substr($tag,1,$x-1);
+	 		} else {
+	 			if (($x>=3D0) and ($tag[$x]=3D=3D=3D'/')) {
+	 				$TagIsSgl[$i] =3D true;
+	 				$tag =3D substr($tag,0,$x);
+	 			} else {
+	 				$TagIsSgl[$i] =3D false;
+	 			}
+	 			$x =3D false;
+	 		}
+ 		}	while ($x!=3D=3Dfalse);
+  }
+
+	// Find tags that embeds the locator
+	if ($LevelStop=3D=3D=3D0) $LevelStop =3D 1;
+	$TagO =3D tbs_Html_FindTag($Txt,$TagLst[$Ref],true,$Loc->PosBeg-1,false=
,$LevelStop,false);
+	if ($TagO=3D=3D=3Dfalse) return false;
+	$PosBeg =3D $TagO->PosBeg;
+	if ($TagIsSgl[$Ref]) {
+		$PosEnd =3D max($Loc->PosEnd,$TagO->PosEnd);
+		$InnerLim =3D $PosEnd + 1;
+	} else {
+		$TagC =3D tbs_Html_FindTag($Txt,$TagLst[$Ref],false,$Loc->PosEnd+1,tru=
e,-$LevelStop,false);
+		if ($TagC=3D=3Dfalse) return false;
+		$PosEnd =3D $TagC->PosEnd;
+		$InnerLim =3D $TagC->PosBeg;
+	}
+
+	$RetVal =3D true;
+	if ($RetInnerSrc) {
+		$RetVal =3D '';
+		if ($Loc->PosBeg>$TagO->PosEnd) $RetVal .=3D substr($Txt,$TagO->PosEnd=
+1,min($Loc->PosBeg,$InnerLim)-$TagO->PosEnd-1);
+		if ($Loc->PosEnd<$InnerLim) $RetVal .=3D substr($Txt,max($Loc->PosEnd,=
$TagO->PosEnd)+1,$InnerLim-max($Loc->PosEnd,$TagO->PosEnd)-1);
+	}
+
+	// Forward
+	$TagC =3D true;
+	for ($i=3D$Ref+1;$i<=3D$TagMax;$i++) {
+		$x =3D $TagLst[$i];
+		if (($x!=3D=3D'') and ($TagC!=3D=3Dfalse)) {
+			$level =3D ($TagIsSgl[$i]) ? 1 : 0;
+			$TagC =3D tbs_Html_FindTag($Txt,$x,$TagIsSgl[$i],$PosEnd+1,true,$leve=
l,false);
+			if ($TagC!=3D=3Dfalse) $PosEnd =3D $TagC->PosEnd;
+		}
+	}
+
+	// Backward
+	$TagO =3D true;
+	for ($i=3D$Ref-1;$i>=3D0;$i--) {
+		$x =3D $TagLst[$i];
+		if (($x!=3D=3D'') and ($TagO!=3D=3Dfalse)) {
+			$level =3D ($TagIsSgl[$i]) ? 1 : 0;
+			$TagO =3D tbs_Html_FindTag($Txt,$x,true,$PosBeg-1,false,$level,false)=
;
+			if ($TagO!=3D=3Dfalse) $PosBeg =3D $TagO->PosBeg;
+		}
+	}
+
+	$Loc->PosBeg =3D $PosBeg;
+	$Loc->PosEnd =3D $PosEnd;
+	return $RetVal;
+
+}
+
+function tbs_Html_Max(&$Txt,&$Nbr,$MaxEnd) {
+// Limit the number of HTML chars
+
+	$pMax =3D  strlen($Txt)-1;
+	$p=3D0;
+	$n=3D0;
+	$in =3D false;
+	$ok =3D true;
+
+	while ($ok) {
+		if ($in) {
+			if ($Txt[$p]=3D=3D=3D';') {
+				$in =3D false;
+				$n++;
+			}
+		} else {
+			if ($Txt[$p]=3D=3D=3D'&') {
+				$in =3D true;
+			} else {
+				$n++;
+			}
+		}
+		if (($n>=3D$Nbr) or ($p>=3D$pMax)) {
+			$ok =3D false;
+		} else {
+			$p++;
+		}
+	}
+
+	if (($n>=3D$Nbr) and ($p<$pMax)) $Txt =3D substr($Txt,0,$p).$MaxEnd;
+
+}
+
+function tbs_Html_GetPart(&$Txt,$Tag,$WithTags=3Dfalse,$CancelIfEmpty=3D=
false) {
+// This function returns a part of the HTML document (HEAD or BODY)
+// The $CancelIfEmpty parameter enables to cancel the extraction when th=
e part is not found.
+
+	if (($Tag=3D=3D=3Dtrue) or ($Tag=3D=3D=3D'')) $Tag =3D 'BODY';
+
+	$x =3D false;
+
+	$LocOpen =3D tbs_Html_FindTag($Txt,$Tag,true,0,true,false,false);
+	if ($LocOpen!=3D=3Dfalse) {
+		$LocClose =3D tbs_Html_FindTag($Txt,$Tag,false,$LocOpen->PosEnd+1,true=
,false,false);
+		if ($LocClose!=3D=3Dfalse) {
+			if ($WithTags) {
+				$x =3D substr($Txt,$LocOpen->PosBeg,$LocClose->PosEnd - $LocOpen->Po=
sBeg + 1);
+			} else {
+				$x =3D substr($Txt,$LocOpen->PosEnd+1,$LocClose->PosBeg - $LocOpen->=
PosEnd - 1);
+			}
+		}
+	}
+
+	if ($x=3D=3D=3Dfalse) {
+		if ($CancelIfEmpty) {
+			$x =3D $Txt;
+		} else {
+			$x =3D '';
+		}
+	}
+
+	return $x;
+
+}
+
+function tbs_Html_FindTag(&$Txt,$Tag,$Opening,$PosBeg,$Forward,$LevelSto=
p,$WithPrm) {
+/* This function is a smarter issue to find an HTML tag.
+It enables to ignore full opening/closing couple of tag that could be in=
serted before the searched tag.
+It also enables to pass a number of encapsulations.
+To ignore encapsulation and opengin/closing just set $LevelStop=3Dfalse.
+*/
+
+	if ($Tag=3D=3D=3D'_') { // New line
+		$p =3D tbs_Html_FindNewLine($Txt,$PosBeg,$Forward,($LevelStop!=3D=3D0)=
);
+		$Loc =3D new clsTbsLocator;
+		$Loc->PosBeg =3D ($Forward) ? $PosBeg : $p;
+		$Loc->PosEnd =3D ($Forward) ? $p : $PosBeg;
+		return $Loc;
+	}
+
+	$Pos =3D $PosBeg + (($Forward) ? -1 : +1);
+	$TagIsOpening =3D false;
+	$TagClosing =3D '/'.$Tag;
+	$LevelNum =3D 0;
+	$TagOk =3D false;
+
+	do {
+
+		// Look for the next tag def
+		if ($Forward) {
+			$Pos =3D strpos($Txt,'<',$Pos+1);
+		} else {
+			if ($Pos<=3D0) {
+				$Pos =3D false;
+			} else {
+				$Pos =3D strrpos(substr($Txt,0,$Pos - 1),'<');
+			}
+		}
+
+		if ($Pos!=3D=3Dfalse) {
+
+			// Check the name of the tag
+			if (strcasecmp(substr($Txt,$Pos+1,strlen($Tag)),$Tag)=3D=3D0) {
+				$PosX =3D $Pos + 1 + strlen($Tag); // The next char
+				$TagOk =3D true;
+				$TagIsOpening =3D true;
+			} elseif (strcasecmp(substr($Txt,$Pos+1,strlen($TagClosing)),$TagClos=
ing)=3D=3D0) {
+				$PosX =3D $Pos + 1 + strlen($TagClosing); // The next char
+				$TagOk =3D true;
+				$TagIsOpening =3D false;
+			}
+
+			if ($TagOk) {
+				// Check the next char
+				$x =3D $Txt[$PosX];
+				if (($x=3D=3D=3D' ') or ($x=3D=3D=3D"\r") or ($x=3D=3D=3D"\n") or ($=
x=3D=3D=3D'>')) {
+					// Check the encapsulation count
+					if ($LevelStop=3D=3D=3Dfalse) { // No encaplusation check
+						if ($TagIsOpening!=3D=3D$Opening) $TagOk =3D false;
+					} else { // Count the number of level
+						if ($TagIsOpening) {
+							$LevelNum++;
+						} else {
+							$LevelNum--;
+						}
+						// Check if it's the expected level
+						if ($LevelNum!=3D$LevelStop) $TagOk =3D false;
+					}
+				} else {
+					$TagOk =3D false;
+				}
+			} //--> if ($TagOk)
+
+		}
+	} while (($Pos!=3D=3Dfalse) and ($TagOk=3D=3D=3Dfalse));
+
+	// Search for the end of the tag
+	if ($TagOk) {
+		$Loc =3D new clsTbsLocator;
+		if ($WithPrm) {
+			$PosEnd =3D 0;
+			tbs_Locator_PrmRead($Txt,$PosX,true,'\'"','<','>',$Loc,$PosEnd);
+		} else {
+			$PosEnd =3D strpos($Txt,'>',$PosX);
+			if ($PosEnd=3D=3D=3Dfalse) {
+				$TagOk =3D false;
+			}
+		}
+	}
+
+	// Result
+	if ($TagOk) {
+		$Loc->PosBeg =3D $Pos;
+		$Loc->PosEnd =3D $PosEnd;
+		return $Loc;
+	} else {
+		return false;
+	}
+
+}
+
+function tbs_Html_FindNewLine(&$Txt,$PosBeg,$Forward,$IsRef) {
+
+	$p =3D $PosBeg;
+	if ($Forward) {
+		$Inc =3D 1;
+		$Inf =3D& $p;
+		$Sup =3D strlen($Txt)-1;
+	} else {
+		$Inc =3D -1;
+		$Inf =3D 0;
+		$Sup =3D& $p;
+	}
+
+	do {
+		if ($Inf>$Sup) return max($Sup,0);
+		$x =3D $Txt[$p];
+		if (($x=3D=3D=3D"\r") or ($x=3D=3D=3D"\n")) {
+			$x2 =3D ($x=3D=3D=3D"\n") ? "\r" : "\n";
+			$p0 =3D $p;
+			if (($Inf<$Sup) and ($Txt[$p+$Inc]=3D=3D=3D$x2)) $p +=3D $Inc; // New=
line char can have two chars.
+			if ($Forward) return $p; // Forward =3D> return pos including newline=
 char.
+			if ($IsRef or ($p0!=3D$PosBeg)) return $p0+1; // Backwars =3D> return=
 pos without newline char. Ignore newline if it is the very first char of=
 the search.
+		}
+		$p +=3D $Inc;
+	} while (true);
+
+}
+
+?>
\ No newline at end of file


Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/inf=
ormes/lib/tbs_class_php5.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbso=
oo_class.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbsooo_=
class.php	2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbsooo_=
class.php	2007-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,328 @@
+<?php
+/*
+********************************************************
+TinyButStrongOOo (extend TinyButStrong to process OOo doc)
+Author   : Olivier LOYNET (tbsooo en free.fr)
+Version  : 0.7.9
+Require  : PHP >=3D 4.0.6 and TBS >=3D 2.0.4
+Date     : 2006-06-12
+Web site : www.tinybutstrong.com
+Doc      : http://www.tinybutstrong.com/apps/tbsooo/doc.html
+Forum    : http://www.tinybutstrong.com/forum.php - see "TBS with OpenOf=
fice"
+Download : http://www.tinybutstrong.com/download/download.php?file=3Dtbs=
ooo.zip
+********************************************************
+Released under the GNU LGPL license
+http://www.gnu.org/copyleft/lesser.html
+********************************************************
+*/
+
+class clsTinyButStrongOOo extends clsTinyButStrong
+{
+  // private properties
+
+  var $_process_path =3D 'tmp/';
+  var $_zip_bin =3D '';
+  var $_unzip_bin =3D '';
+  var $_charset =3D '';
+  var $_ooo_basename =3D '';
+  var $_ooo_file_ext =3D '';
+  var $_xml_filename =3D '';
+
+  // public method
+
+  function SetZipBinary($path_binary, $test=3Dfalse)
+  {
+    // set the 'zip' binary to compress OOo files
+    if ($path_binary !=3D '') {
+      $this->_zip_bin =3D $this->_PathQuote($path_binary);
+    }
+
+    // test if zip is present
+    if ($test) {
+      if (strlen(shell_exec($this->_zip_bin.' -h')) =3D=3D 0) {
+        $this->meth_Misc_Alert('SetZipBinary method', 'Problem to execut=
e the command : shell_exec(\''.$this->_zip_bin.' -h\')');
+        return false;
+      }
+    }
+    return true;
+  }
+
+  function SetUnzipBinary($path_binary, $test=3Dfalse)
+  {
+    // set the 'unzip binary to decompress OOo files
+    if ($path_binary !=3D '') {
+      $this->_unzip_bin =3D $this->_PathQuote($path_binary);
+    }
+
+    // test if unzip is present
+    if ($test) {
+      if (strlen(shell_exec($this->_unzip_bin.' -h')) =3D=3D 0) {
+        $this->meth_Misc_Alert('SetUnzipBinary method', 'Problem to exec=
ute the command : shell_exec(\''.$this->_unzip_bin.' -h\')');
+        return false;
+      }
+    }
+    return true;
+  }
+
+  function SetProcessDir($process_path)
+  {
+    clearstatcache();
+
+    // set the directory for processing temporary OOo files
+    if ($process_path =3D=3D '') {
+      $this->meth_Misc_Alert('SetProcessDir method', 'Parameter is empty=
');
+      return false;
+    }
+    // add a trailing / at the path
+    $this->_process_path =3D $process_path.(substr($process_path, -1, 1)=
 =3D=3D '/' ? '' : '/');
+   =20
+    // test if 'dir' exists
+    if (!is_dir($this->_process_path)) {
+      $this->meth_Misc_Alert('SetProcessDir method', 'Directory not foun=
d : '.$this->_process_path);
+      return false;
+    }
+
+    // test if 'dir' is writable
+    if (!is_writable($this->_process_path)) {
+      $this->meth_Misc_Alert('SetProcessDir method', 'Directory not writ=
able : '.$this->_process_path);
+      return false;
+    }
+    return true;
+  }
+
+  function SetDataCharset($charset)
+  {
+    $this->_charset =3D strtoupper($charset);
+  }
+
+  function NewDocFromTpl($ooo_template_filename)
+  {
+    // test if OOo source file exist
+    if (!file_exists($ooo_template_filename)) {
+      $this->meth_Misc_Alert('NewDocFromTpl method', 'File not found : '=
.$ooo_template_filename);
+      return false;
+    }
+
+    // create unique ID
+    $unique =3D md5(microtime());
+    // find path, file and extension
+    $a_pathinfo =3D pathinfo($ooo_template_filename);
+    $this->_ooo_file_ext  =3D $a_pathinfo['extension'];
+    $this->_ooo_basename =3D $this->_process_path.$unique;
+
+    // create unique temporary basename dir
+    if (!mkdir($this->_ooo_basename, 0700)) {
+      $this->meth_Misc_Alert('NewDocFromTpl method', 'Can\'t create dire=
ctory : '.$this->_ooo_basename);
+      return false;
+    }
+
+    // copy the ooo template into the temporary basename dir
+    if (!copy($ooo_template_filename, $this->_ooo_basename.'.'.$this->_o=
oo_file_ext)) {
+      $this->meth_Misc_Alert('NewDocFromTpl method', 'Can\'t copy file t=
o process dir : '.$ooo_template_filename);
+      return false;
+    }
+    return $this->_ooo_basename.'.'.$this->_ooo_file_ext;
+  }
+
+  function LoadXmlFromDoc($xml_file)
+  {
+    $this->_xml_filename =3D $xml_file;
+
+    // unzip the XML files
+    exec($this->_unzip_bin.' '.$this->_ooo_basename.'.'.$this->_ooo_file=
_ext.' -d '.$this->_ooo_basename.' '.$this->_xml_filename);
+
+    // test if XML file exist
+    if (!file_exists($this->_ooo_basename.'/'.$this->_xml_filename)) {
+      $this->meth_Misc_Alert('LoadXmlFromDoc method', 'File not found : =
'.$this->_ooo_basename.'/'.$this->_xml_filename);
+      return false;
+    }
+
+    // load the template
+    $this->ObjectRef =3D &$this;
+    $this->LoadTemplate($this->_ooo_basename.'/'.$this->_xml_filename, '=
=3D~_CharsetEncode');
+
+    // work around - convert apostrophe in XML file needed for TBS funct=
ions
+    $this->Source =3D str_replace('&apos;', '\'', $this->Source);
+
+    // convert tag image need in future release of tbsooo_img
+    $this->ReplaceTagImage();
+
+    // return
+    return true;
+  }
+
+  function AddFileToDoc($filename)
+  {
+    if (!file_exists($filename)) {
+      $this->meth_Misc_Alert('AddFileToDoc method', 'File not found : '.=
$filename);
+      return false;
+    }
+    exec($this->_zip_bin.' -u '.$this->_ooo_basename.'.'.$this->_ooo_fil=
e_ext.' '.$filename);
+  }
+
+  function ReplaceTagImage()
+  {
+    /*
+    will be released in tbsooo_img extend tbsooo because need xml php5 f=
unctions
+
+    $doc =3D new DOMDocument();
+    $doc->loadXML($this->Source);
+    $draw_frames =3D $doc->getElementsByTagName('frame');
+
+    for ($i =3D 0; $i < $draw_frames->length; $i++) {
+      $draw_frame =3D $draw_frames->item($i); =20
+      $svg_descs =3D $draw_frame->getElementsByTagName('desc');=20
+      if ($svg_descs->length > 0) {
+        $tag =3D $svg_descs->item(0)->nodeValue;
+        if (ereg("^\[.*\]", $tag)) {
+          $draw_images =3D $draw_frame->getElementsByTagName('image');=20
+          if ($draw_images->length > 0) {
+            $draw_image =3D $draw_images->item(0);
+            $draw_image->removeAttribute('href');                       =
            =20
+            $draw_image->setAttribute('xlink:href', $tag);             =20
+          }
+        }
+      }
+    }
+    $this->Source =3D $doc->SaveXML();
+    */
+  }
+
+  function SaveXmlToDoc()
+  {
+    // get the source result
+    $this->Show(TBS_NOTHING);
+
+    // store the merge result in place of the XML source file
+    $fdw =3D fopen($this->_ooo_basename.'/'.$this->_xml_filename, "w");
+    fwrite($fdw, $this->Source, strlen($this->Source));
+    fclose ($fdw);
+
+    // test if XML file exist
+    if (!file_exists($this->_ooo_basename.'/'.$this->_xml_filename)) {
+      $this->meth_Misc_Alert('SaveXmlToDoc method', 'File not found : '.=
$this->_ooo_basename.'/'.$this->_xml_filename);
+      return false;
+    }
+
+    // zip and remove the file
+    exec($this->_zip_bin.' -j -m '.$this->_ooo_basename.'.'.$this->_ooo_=
file_ext.' '.$this->_ooo_basename.'/'.$this->_xml_filename);
+
+    return true;
+  }
+
+  function GetPathnameDoc()
+  {
+    // remove tmp dir
+    $this->_RemoveTmpBasenameDir();
+
+    // return path
+    return $this->_ooo_basename.'.'.$this->_ooo_file_ext;
+  }
+
+  function GetMimetypeDoc()
+  {
+    switch($this->_ooo_file_ext) {
+      case 'sxw': return 'application/vnd.sun.xml.writer'; break;
+      case 'stw': return 'application/vnd.sun.xml.writer.template'; brea=
k;
+      case 'sxg': return 'application/vnd.sun.xml.writer.global'; break;
+      case 'sxc': return 'application/vnd.sun.xml.calc'; break;
+      case 'stc': return 'application/vnd.sun.xml.calc.template'; break;
+      case 'sxi': return 'application/vnd.sun.xml.impress'; break;
+      case 'sti': return 'application/vnd.sun.xml.impress.template'; bre=
ak;
+      case 'sxd': return 'application/vnd.sun.xml.draw'; break;
+      case 'std': return 'application/vnd.sun.xml.draw.template'; break;
+      case 'sxm': return 'application/vnd.sun.xml.math'; break;
+      case 'odt': return 'application/vnd.oasis.opendocument.text'; brea=
k;
+      case 'ott': return 'application/vnd.oasis.opendocument.text-templa=
te'; break;
+      case 'oth': return 'application/vnd.oasis.opendocument.text-web'; =
break;
+      case 'odm': return 'application/vnd.oasis.opendocument.text-master=
'; break;
+      case 'odg': return 'application/vnd.oasis.opendocument.graphics'; =
break;
+      case 'otg': return 'application/vnd.oasis.opendocument.graphics-te=
mplate'; break;
+      case 'odp': return 'application/vnd.oasis.opendocument.presentatio=
n'; break;
+      case 'otp': return 'application/vnd.oasis.opendocument.presentatio=
n-template'; break;
+      case 'ods': return 'application/vnd.oasis.opendocument.spreadsheet=
'; break;
+      case 'ots': return 'application/vnd.oasis.opendocument.spreadsheet=
-template'; break;
+      case 'odc': return 'application/vnd.oasis.opendocument.chart'; bre=
ak;
+      case 'odf': return 'application/vnd.oasis.opendocument.formula'; b=
reak;
+      case 'odb': return 'application/vnd.oasis.opendocument.database'; =
break;
+      case 'odi': return 'application/vnd.oasis.opendocument.image'; bre=
ak;
+      default:    return ''; break;
+    }
+  }
+
+  function FlushDoc()
+  {
+    // flush file
+    $fp =3D @fopen($this->GetPathnameDoc(), 'rb'); // replace readfile()
+    fpassthru($fp);
+    fclose($fp);
+  }
+
+  function RemoveDoc()
+  {
+    // remove file
+    unlink($this->GetPathnameDoc());
+  }
+
+  function ClearProcessDir($hour =3D '2', $minut =3D '0')
+  {
+    clearstatcache();
+    $now =3D mktime(date("H")-abs((int)$hour), date("i")-abs((int)$minut=
), date("s"), date("m"), date("d"), date("Y"));
+    if ($dir =3D @opendir($this->_process_path)) {
+      while (($file =3D readdir($dir)) !=3D=3D false)  {
+        if ($file !=3D ".." && $file !=3D ".") {
+          if (filemtime($this->_process_path.$file) < $now) {
+            if (!(is_dir($this->_process_path.$file) ? @rmdir($this->_pr=
ocess_path.'/'.$file) : @unlink($this->_process_path.$file))) {
+              $this->meth_Misc_Alert('ClearProcessDir method', 'Can\'t r=
emove directory or file : '.$this->_process_path.$file);
+            }
+          }
+        }
+      }
+      closedir($dir);
+    }
+  }
+
+  // private method
+
+  function _PathQuote($path_quote)
+  {
+    if (strpos($path_quote, ' ') !=3D=3D false) {
+      $path_quote =3D (strpos($path_quote, '"') =3D=3D=3D 0 ? '' : '"').=
$path_quote;
+      $path_quote =3D $path_quote.((strrpos($path_quote, '"') =3D=3D str=
len($path_quote)-1) ? '' : '"');
+    }
+    return $path_quote;
+  }
+
+  function _CharsetEncode($string_encode)
+  {
+    $string_encode =3D str_replace('&'   ,'&amp;', $string_encode);
+    $string_encode =3D str_replace('<'   ,'&lt;',  $string_encode);
+    $string_encode =3D str_replace('>'   ,'&gt;',  $string_encode);
+    //$string_encode =3D str_replace("\n", '</text:p><text:p>', $string_=
encode); // '\n' by XML tags
+    $string_encode =3D str_replace("\n", '<text:line-break/>', $string_e=
ncode); // '\n' by XML tags
+
+    switch($this->_charset) {
+      // OOo XML charset is utf8
+      case 'UTF8': // no encode
+        break;
+      case 'ISO 8859-1': // encode ISO 8859-1 to UTF8
+      default:
+        $string_encode =3D utf8_encode($string_encode);=20
+        break;
+    }
+    // work-around for EURO caracter
+    $string_encode =3D str_replace(chr(0xC2).chr(0x80) , chr(0xE2).chr(0=
x82).chr(0xAC),  $string_encode); // =80
+    return $string_encode;
+  }
+
+  function _RemoveTmpBasenameDir()
+  {
+    clearstatcache();
+
+    // remove the temporary directory
+    if (is_dir($this->_ooo_basename) && !rmdir ($this->_ooo_basename)) {
+      $this->meth_Misc_Alert('_RemoveTmpDir method', 'Can\'t remove dire=
ctory : '.$this->_ooo_basename);
+    }
+  }
+}
+?>
\ No newline at end of file


Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/inf=
ormes/lib/tbsooo_class.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/template=
s/_edit_actions.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_=
edit_actions.php	2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_=
edit_actions.php	2007-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,13 @@
+<ul class=3D"sf_admin_actions">
+      <li><?php echo submit_tag(__('save'), array (
+  'name' =3D> 'save',
+  'class' =3D> 'sf_admin_action_save',
+)) ?></li>
+    <li><?php echo button_to(__('list'), 'informes/list?id=3D'.$informe-=
>getId(), array (
+  'class' =3D> 'sf_admin_action_list',
+)) ?></li>
+    <li><?php echo submit_tag(__('save and add'), array (
+  'name' =3D> 'save_and_add',
+  'class' =3D> 'sf_admin_action_save_and_add',
+)) ?></li>
+</ul>


Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/inf=
ormes/templates/_edit_actions.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/template=
s/_edit_form.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_=
edit_form.php	2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_=
edit_form.php	2007-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,119 @@
+<?php echo form_tag('informes/save', array(
+  'id'        =3D> 'sf_admin_edit_form',
+  'name'      =3D> 'sf_admin_edit_form',
+  'multipart' =3D> true,
+)) ?>
+
+<?php echo object_input_hidden_tag($informe, 'getId') ?>
+
+<fieldset id=3D"sf_fieldset_informacion_general" class=3D"">
+
+<div class=3D"form-row">
+  <?php echo label_for('informe[nombre]', __($labels['informe{nombre}'])=
, 'class=3D"required" ') ?>
+  <div class=3D"content<?php if ($sf_request->hasError('informe{nombre}'=
)): ?> form-error<?php endif; ?>">
+  <?php if ($sf_request->hasError('informe{nombre}')): ?>
+    <?php echo form_error('informe{nombre}', array('class' =3D> 'form-er=
ror-msg')) ?>
+  <?php endif; ?>
+
+  <?php $value =3D object_input_tag($informe, 'getNombre', array (
+  'size' =3D> 64,
+  'control_name' =3D> 'informe[nombre]',
+)); echo $value ? $value : '&nbsp;' ?>
+    </div>
+</div>
+
+<div class=3D"form-row">
+  <?php echo label_for('informe[descripcion]', __($labels['informe{descr=
ipcion}']), 'class=3D"required" ') ?>
+  <div class=3D"content<?php if ($sf_request->hasError('informe{descripc=
ion}')): ?> form-error<?php endif; ?>">
+  <?php if ($sf_request->hasError('informe{descripcion}')): ?>
+    <?php echo form_error('informe{descripcion}', array('class' =3D> 'fo=
rm-error-msg')) ?>
+  <?php endif; ?>
+
+  <?php $value =3D object_input_tag($informe, 'getdescripcion', array (
+  'size' =3D> 64,
+  'control_name' =3D> 'informe[descripcion]',
+)); echo $value ? $value : '&nbsp;' ?>
+    </div>
+</div>
+
+
+
+<div class=3D"form-row">
+        <?php echo label_for('adjunto', __('Plantilla de informe:')) ?>
+  <div class=3D"content<?php if ($sf_request->hasError('file')): ?> form=
-error<?php endif; ?>">
+  <?php if ($sf_request->hasError('file')): ?>
+    <?php echo form_error('file', array('class' =3D> 'form-error-msg')) =
?>
+  <?php endif; ?>
+        <?php echo input_file_tag('file') ?>
+        <?php =20
+           if($informe->getAdjunto()) {
+           ?><a href=3D"<?php echo sfContext::getInstance()->getRequest(=
)->getRelativeUrlRoot()."/".sfConfig::get('sf_upload_dir_name').'/'. $inf=
orme->getAdjunto()->getRuta()?>"><?php echo $informe->getAdjunto()->getNo=
mbreArchivo()?></a>&nbsp;&nbsp;<?php=20
+//-           echo link_to("Borrar", "informes?action=3DborrarAdjunto&id=
=3D".$informe->getId());
+           echo "&nbsp;&nbsp;&nbsp;&nbsp;";
+            }=20
+        ?>
+    </div>
+</div>
+
+
+<div class=3D"form-row">
+  <?php echo label_for('informe[fk_tipoinforme_id]', __($labels['informe=
{fk_tipoinforme_id}']), 'class=3D"required" ') ?>
+  <div class=3D"content<?php if ($sf_request->hasError('informe{fk_tipoi=
nforme_id}')): ?> form-error<?php endif; ?>">
+  <?php if ($sf_request->hasError('informe{fk_tipoinforme_id}')): ?>
+    <?php echo form_error('informe{fk_tipoinforme_id}', array('class' =3D=
> 'form-error-msg')) ?>
+  <?php endif; ?>
+
+  <?php $value =3D object_select_tag($informe, 'getFkTipoinformeId', arr=
ay (
+  'related_class' =3D> 'Tipoinforme',
+  'control_name' =3D> 'informe[fk_tipoinforme_id]',
+)); echo $value ? $value : '&nbsp;' ?>
+    </div>
+</div>
+
+
+
+<div class=3D"form-row">
+  <?php echo label_for('informe[listado]', __($labels['informe{listado}'=
]), 'class=3D"required" ') ?>
+  <div class=3D"content<?php if ($sf_request->hasError('informe{listado}=
')): ?> form-error<?php endif; ?>">
+  <?php if ($sf_request->hasError('informe{listado}')): ?>
+    <?php echo form_error('informe{listado}', array('class' =3D> 'form-e=
rror-msg')) ?>
+  <?php endif; ?>
+
+  <?php $value =3D object_checkbox_tag($informe, 'getListado', array (
+  'control_name' =3D> 'informe[listado]',
+)); echo $value ? $value : '&nbsp;' ?>
+    </div>
+</div>
+
+
+<div class=3D"form-row">
+  <?php echo label_for('informe[variables]', __($labels['informe{variabl=
es}']), 'class=3D"required" ') ?>
+  <div class=3D"content<?php if ($sf_request->hasError('informe{variable=
s}')): ?> form-error<?php endif; ?>">
+  <?php if ($sf_request->hasError('informe{variables}')): ?>
+    <?php echo form_error('informe{variables}', array('class' =3D> 'form=
-error-msg')) ?>
+  <?php endif; ?>
+
+  <?php $value =3D object_input_tag($informe, 'getVariables', array (
+  'size' =3D> 64,
+  'control_name' =3D> 'informe[variables]',
+)); echo $value ? $value : '&nbsp;' ?>
+    </div>
+</div>
+
+
+
+</fieldset>
+
+<?php include_partial('edit_actions', array('informe' =3D> $informe)) ?>
+
+</form>
+
+<ul class=3D"sf_admin_actions">
+      <li class=3D"float-left"><?php if ($informe->getId()): ?>
+<?php echo button_to(__('delete'), 'informes/delete?id=3D'.$informe->get=
Id(), array (
+  'post' =3D> true,
+  'confirm' =3D> __('Are you sure?'),
+  'class' =3D> 'sf_admin_action_delete',
+)) ?><?php endif; ?>
+</li>
+  </ul>


Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/inf=
ormes/templates/_edit_form.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/template=
s/_edit_messages.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_=
edit_messages.php	2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_=
edit_messages.php	2007-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,15 @@
+<?php if ($sf_request->hasErrors()): ?>
+<div class=3D"form-errors">
+<h2><?php echo __('There are some errors that prevent the form to valida=
te') ?></h2>
+<dl>
+<?php foreach ($sf_request->getErrorNames() as $name): ?>
+  <dt><?php echo __($labels[$name]) ?></dt>
+  <dd><?php echo $sf_request->getError($name) ?></dd>
+<?php endforeach; ?>
+</dl>
+</div>
+<?php elseif ($sf_flash->has('notice')): ?>
+<div class=3D"save-ok">
+<h2><?php echo __($sf_flash->get('notice')) ?></h2>
+</div>
+<?php endif; ?>


Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/inf=
ormes/templates/_edit_messages.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/template=
s/_list.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_=
list.php	2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_=
list.php	2007-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,34 @@
+<table cellspacing=3D"0" class=3D"sf_admin_list">
+<thead>
+<tr>
+<?php include_partial('list_th_tabular') ?>
+  <th id=3D"sf_admin_list_th_sf_actions"><?php echo __('Actions') ?></th=
>
+</tr>
+</thead>
+<tbody>
+<?php $i =3D 1; foreach ($pager->getResults() as $informe): $odd =3D fmo=
d(++$i, 2) ?>
+<tr class=3D"sf_admin_row_<?php echo $odd ?>">
+<?php include_partial('list_td_tabular', array('informe' =3D> $informe))=
 ?>
+<?php include_partial('list_td_actions', array('informe' =3D> $informe))=
 ?>
+</tr>
+<?php endforeach; ?>
+</tbody>
+<tfoot>
+<tr><th colspan=3D"8">
+<div class=3D"float-right">
+<?php if ($pager->haveToPaginate()): ?>
+  <?php echo link_to(image_tag(sfConfig::get('sf_admin_web_dir').'/image=
s/first.png', array('align' =3D> 'absmiddle', 'alt' =3D> __('First'), 'ti=
tle' =3D> __('First'))), 'informe/list?page=3D1') ?>
+  <?php echo link_to(image_tag(sfConfig::get('sf_admin_web_dir').'/image=
s/previous.png', array('align' =3D> 'absmiddle', 'alt' =3D> __('Previous'=
), 'title' =3D> __('Previous'))), 'informe/list?page=3D'.$pager->getPrevi=
ousPage()) ?>
+
+  <?php foreach ($pager->getLinks() as $page): ?>
+    <?php echo link_to_unless($page =3D=3D $pager->getPage(), $page, 'in=
forme/list?page=3D'.$page) ?>
+  <?php endforeach; ?>
+
+  <?php echo link_to(image_tag(sfConfig::get('sf_admin_web_dir').'/image=
s/next.png', array('align' =3D> 'absmiddle', 'alt' =3D> __('Next'), 'titl=
e' =3D> __('Next'))), 'informe/list?page=3D'.$pager->getNextPage()) ?>
+  <?php echo link_to(image_tag(sfConfig::get('sf_admin_web_dir').'/image=
s/last.png', array('align' =3D> 'absmiddle', 'alt' =3D> __('Last'), 'titl=
e' =3D> __('Last'))), 'informe/list?page=3D'.$pager->getLastPage()) ?>
+<?php endif; ?>
+</div>
+<?php echo format_number_choice('[0] no result|[1] 1 result|(1,+Inf] %1%=
 results', array('%1%' =3D> $pager->getNbResults()), $pager->getNbResults=
()) ?>
+</th></tr>
+</tfoot>
+</table>


Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/inf=
ormes/templates/_list.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/template=
s/_list_actions.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_=
list_actions.php	2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_=
list_actions.php	2007-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,5 @@
+<ul class=3D"sf_admin_actions">
+      <li><?php echo button_to(__('create'), 'informes/create', array (
+  'class' =3D> 'sf_admin_action_create',
+)) ?></li>
+  </ul>


Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/inf=
ormes/templates/_list_actions.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/template=
s/_list_messages.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_=
list_messages.php	2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_=
list_messages.php	2007-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,8 @@
+<?php if ($sf_request->getError('delete')): ?>
+<div class=3D"form-errors">
+  <h2>Could not delete the selected Informe</h2>
+  <ul>
+    <li><?php echo $sf_request->getError('delete') ?></li>
+  </ul>
+</div>
+<?php endif; ?>


Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/inf=
ormes/templates/_list_messages.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/template=
s/_list_td_actions.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_=
list_td_actions.php	2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_=
list_td_actions.php	2007-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,10 @@
+<td>
+<ul class=3D"sf_admin_td_actions">
+  <li><?php echo link_to(image_tag('/sf/sf_admin/images/edit_icon.png', =
array('alt' =3D> __('edit'), 'title' =3D> __('edit'))), 'informes/edit?id=
=3D'.$informe->getId()) ?></li>
+  <li><?php echo link_to(image_tag('/sf/sf_admin/images/delete_icon.png'=
, array('alt' =3D> __('delete'), 'title' =3D> __('delete'))), 'informes/d=
elete?id=3D'.$informe->getId(), array (
+  'post' =3D> true,
+  'confirm' =3D> __('Are you sure?'),
+)) ?></li>
+    <li><?php echo link_to(image_tag('/images/small/report_go.png', arra=
y('alt' =3D> __('ir al reporte'), 'title' =3D> __('ir al reporte'))), 'in=
formes/mostrar?id=3D'.$informe->getId()) ?></li>
+</ul>
+</td>


Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/inf=
ormes/templates/_list_td_actions.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/template=
s/_list_td_tabular.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_=
list_td_tabular.php	2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_=
list_td_tabular.php	2007-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,11 @@
+    <td><?php echo link_to($informe->getNombre() ? $informe->getNombre()=
 : __('-'), 'informes/edit?id=3D'.$informe->getId()) ?></td>
+    <td><?php echo $informe->getDescripcion() ?></td>
+    <td>
+<?php if($informe->getAdjunto()) { ?>
+<a href=3D"<?php echo sfContext::getInstance()->getRequest()->getRelativ=
eUrlRoot()."/".sfConfig::get('sf_upload_dir_name').'/'. $informe->getAdju=
nto()->getRuta()?>"><?php echo $informe->getAdjunto()->getNombreArchivo()=
?></a>
+<?php }  ?>
+    <td><?php echo ($informe->getTipoinforme())?$informe->getTipoinforme=
()->getNombre():"" ?></td>
+    <td><?php echo $informe->getListado() ? image_tag(sfConfig::get('sf_=
admin_web_dir').'/images/tick.png') : '&nbsp;' ?></td>
+    <td><?php echo $informe->getVariables() ?></td>
+
+ =20
\ No newline at end of file


Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/inf=
ormes/templates/_list_td_tabular.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/template=
s/_list_th_tabular.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_=
list_th_tabular.php	2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_=
list_th_tabular.php	2007-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,47 @@
+    <th id=3D"sf_admin_list_th_nombre">
+          <?php if ($sf_user->getAttribute('sort', null, 'sf_admin/infor=
mes/sort') =3D=3D 'nombre'): ?>
+      <?php echo link_to(__('Nombre'), 'informes/list?sort=3Dnombre&type=
=3D'.($sf_user->getAttribute('type', 'asc', 'sf_admin/informes/sort') =3D=
=3D 'asc' ? 'desc' : 'asc')) ?>
+      (<?php echo __($sf_user->getAttribute('type', 'asc', 'sf_admin/inf=
ormes/sort')) ?>)
+      <?php else: ?>
+      <?php echo link_to(__('Nombre'), 'informes/list?sort=3Dnombre&type=
=3Dasc') ?>
+      <?php endif; ?>
+    </th>
+
+    <th id=3D"sf_admin_list_th_descripcion">
+          <?php if ($sf_user->getAttribute('sort', null, 'sf_admin/infor=
mes/sort') =3D=3D 'descripcion'): ?>
+      <?php echo link_to(__('Descripci&oacute;n'), 'informes/list?sort=3D=
descripcion&type=3D'.($sf_user->getAttribute('type', 'asc', 'sf_admin/inf=
ormes/sort') =3D=3D 'asc' ? 'desc' : 'asc')) ?>
+      (<?php echo __($sf_user->getAttribute('type', 'asc', 'sf_admin/inf=
ormes/sort')) ?>)
+      <?php else: ?>
+      <?php echo link_to(__('Descripci&oacute;n'), 'informes/list?sort=3D=
descripcion&type=3Dasc') ?>
+      <?php endif; ?>
+    </th>
+
+
+    <th id=3D"sf_admin_list_th_fk_adjunto_id">
+      <?php echo __('Plantilla'); ?>
+    </th>
+
+
+    <th id=3D"sf_admin_list_th_tipoinforme">
+          <?php if ($sf_user->getAttribute('sort', null, 'sf_admin/infor=
mes/sort') =3D=3D 'fk_tipoinforme_id'): ?>
+      <?php echo link_to(__('Tipo de Informe'), 'informes/list?sort=3Dti=
poinforme&type=3D'.($sf_user->getAttribute('type', 'asc', 'sf_admin/infor=
mes/sort') =3D=3D 'asc' ? 'desc' : 'asc')) ?>
+      (<?php echo __($sf_user->getAttribute('type', 'asc', 'sf_admin/inf=
ormes/sort')) ?>)
+      <?php else: ?>
+      <?php echo link_to(__('Tipo de Informe'), 'informes/list?sort=3Dti=
poinforme&type=3Dasc') ?>
+      <?php endif; ?>
+    </th>
+
+
+    <th id=3D"sf_admin_list_th_listado">
+          <?php if ($sf_user->getAttribute('sort', null, 'sf_admin/infor=
mes/sort') =3D=3D 'listado'): ?>
+      <?php echo link_to(__('=C2=BFEst&aacute; listado?'), 'informes/lis=
t?sort=3Dlistado&type=3D'.($sf_user->getAttribute('type', 'asc', 'sf_admi=
n/informes/sort') =3D=3D 'asc' ? 'desc' : 'asc')) ?>
+      (<?php echo __($sf_user->getAttribute('type', 'asc', 'sf_admin/inf=
ormes/sort')) ?>)
+      <?php else: ?>
+      <?php echo link_to(__('=C2=BFEs un listado?'), 'informes/list?sort=
=3Dlistado&type=3Dasc') ?>
+      <?php endif; ?>
+    </th>
+
+
+    <th id=3D"sf_admin_list_th_variable">
+      <?php echo __('Variables')?>
+    </th>


Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/inf=
ormes/templates/_list_th_tabular.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/template=
s/busquedaAlumnosSuccess.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/b=
usquedaAlumnosSuccess.php	2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/b=
usquedaAlumnosSuccess.php	2007-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,60 @@
+<?php use_helper('I18N'); ?>
+<div id=3D"sf_admin_container">
+<h1>Informe: <?php echo $titulo ?></h1>
+<?php echo form_tag('informes/busquedaAlumnos', 'id=3Dsf_admin_edit_form=
 name=3Dsf_admin_edit_form multipart=3Dtrue') ?>
+
+<fieldset id=3D"sf_fieldset_none" class=3D"">
+    <div class=3D"form-row">
+        <?php echo label_for('Buscar', __('Buscar Alumnos:')) ?>
+        <?php echo input_tag('txt', $txt) ?>  =20
+    </div>
+
+    <div class=3D"form-row">
+        <?php echo label_for('division', __('Division:')) ?>
+        <?php echo select_tag('division_id', options_for_select($options=
Division, $division_id)) ?>
+    </div>
+</fieldset>
+ <ul class=3D"sf_admin_actions">
+  <li><?php echo submit_tag(__('Buscar'), array (
+  'name' =3D> 'Mostrar',
+  'class' =3D> 'sf_admin_action_save',
+)) ?></li>
+</ul>
+</form>
+<?php if (count($aAlumno) > 0) {
+    if ($txt) { ?>
+    Usted busc&oacute; -<?php echo $txt?>-
+    <?php } ?>
+<h1>Alumnos</h1>
+<table cellspacing=3D"0" class=3D"sf_admin_list">
+  <thead>
+  <tr>
+    <th id=3D"sf_admin_list_th_alumno"> Alumno</th>
+    <th id=3D"sf_admin_list_th_sf_actions">Ver Informe</th>
+  </tr>
+  </thead>
+
+  <tbody>
+<?php
+    $i =3D 0;
+    foreach($aAlumno as $alumno){
+?>
+  <tr class=3D"sf_admin_row_0">
+    <td><?php echo $alumno->alumno_apellido." ".$alumno->alumno_nombre; =
?> ( <?php echo $alumno->anio_descripcion?> - <?php echo $alumno->divisio=
n_nombre?> ) </td>
+    <td>
+    <ul class=3D"sf_admin_td_actions">
+     <li><?php echo link_to(image_tag('/images/small/report_go.png', arr=
ay('alt' =3D> 'editar', 'title' =3D> 'Editar')) , 'informes?action=3Dmost=
rar&alumno_id=3D'.$alumno->alumno_id); ?></li>
+    </ul>
+    </td>
+  </tr>
+  <?php } ?>
+  </tbody>
+</table>
+
+<?php } else {
+    if ($txt) { ?>
+        Su b&uacute;squeda por -<?php echo $txt?>- no ha encontrado alum=
nos.
+    <?php }=20
+}=20
+?>
+</div>
\ No newline at end of file


Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/inf=
ormes/templates/busquedaAlumnosSuccess.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/template=
s/editSuccess.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/e=
ditSuccess.php	2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/e=
ditSuccess.php	2007-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,17 @@
+<?php use_helper('Object', 'Validation', 'ObjectAdmin', 'I18N', 'Date') =
?>
+
+<?php use_stylesheet('/sf/sf_admin/css/main') ?>
+
+<div id=3D"sf_admin_container">
+
+<h1><?php echo __('Editar informe',=20
+array()) ?></h1>
+
+
+<div id=3D"sf_admin_content">
+<?php include_partial('informes/edit_messages', array('informe' =3D> $in=
forme, 'labels' =3D> $labels)) ?>
+<?php include_partial('informes/edit_form', array('informe' =3D> $inform=
e, 'labels' =3D> $labels)) ?>
+</div>
+
+
+</div>


Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/inf=
ormes/templates/editSuccess.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/template=
s/listSuccess.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/l=
istSuccess.php	2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/l=
istSuccess.php	2007-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,23 @@
+<?php use_helper('I18N', 'Date') ?>
+
+<?php use_stylesheet('/sf/sf_admin/css/main') ?>
+
+<div id=3D"sf_admin_container">
+
+<h1><?php echo __('Listado de Informes',=20
+array()) ?></h1>
+
+<div id=3D"sf_admin_header">
+<?php include_partial('informes/list_messages', array('pager' =3D> $page=
r)) ?>
+</div>
+
+<div id=3D"sf_admin_content">
+<?php if (!$pager->getNbResults()): ?>
+<?php echo __('no result') ?>
+<?php else: ?>
+<?php include_partial('informes/list', array('pager' =3D> $pager)) ?>
+<?php endif; ?>
+<?php include_partial('list_actions') ?>
+</div>
+
+</div>


Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/inf=
ormes/templates/listSuccess.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/validate=
/edit.yml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/validate/ed=
it.yml	2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/validate/ed=
it.yml	2007-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,64 @@
+methods:
+  post:
+    - "informe{nombre}"
+    - "informe{descripcion}"
+    - "informe{variables}"
+    - "informe{fk_tipoinforme_id}"
+    - file
+
+
+fillin:
+    enabled:       on
+
+names:
+    informe{nombre}:
+        required:     Yes
+        required_msg: El campo nombre es obligatorio
+        validators: caracteresMaximos128
+
+    informe{fk_tipoinforme_id}:
+        required:     Yes
+        validators: validarNumero
+
+    informe{descripcion}:
+        required:     No
+        validators: caracteresMaximos255
+
+    informe{variables}:
+        required:     No
+        validators: caracteresMaximos255
+
+    file:
+        required: Yes
+        required_msg: El campo plantilla de informe es obligatorio
+        file: true
+        validators: archivoValidar
+
+
+caracteresMaximos128:
+    class:  sfStringValidator
+    param:
+        max: 128
+        max_error: La maxima cantidad de caracteres permitida es de 128
+
+caracteresMaximos255:
+    class:  sfStringValidator
+    param:
+        max: 255
+        max_error: La maxima cantidad de caracteres permitida es de 255
+
+validarNumero:
+    class: sfNumberValidator
+    param:
+        nan_error: Por favor ingrese un valor n&uacute;merico      =20
+        min: 0
+        min_error: El n&uacute;mero debe ser positivo
+
+archivoValidar:
+    class:  sfFileValidator
+    param:
+        max_size:         512000
+        max_size_error:   M&aacute;ximo tama&ntilde;o del archivo adjunt=
o es 512Kb
+#        mime_types:
+#          - 'image/jpeg'
+#        mime_types_error: Solamente ODT o SWX son permitidos


Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/inf=
ormes/validate/edit.yml
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Modified: prosistem/alba/trunk/alba/config/schema.yml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/config/schema.yml	2007-10-10 17:24:59 UTC (=
rev 5217)
+++ prosistem/alba/trunk/alba/config/schema.yml	2007-10-10 20:53:17 UTC (=
rev 5218)
@@ -1839,4 +1839,54 @@
       required: true
       primaryKey: true
       foreignTable: docente
-      foreignReference: id
\ No newline at end of file
+      foreignReference: id
+  informe:=20
+    _attributes:=20
+      idMethod: native
+    id:=20
+      type: INTEGER
+      required: true
+      autoIncrement: true
+      primaryKey: true
+    nombre:=20
+      type: VARCHAR
+      size: 128
+      required: true
+    descripcion:=20
+      type: VARCHAR
+      size: 255
+    fk_adjunto_id:=20
+      type: integer
+      size: 11
+      required: true
+      foreignTable: adjunto
+      foreignReference: id
+    fk_tipoinforme_id:=20
+      type: integer
+      size: 11
+      required: true
+      foreignTable: tipoinforme
+      foreignReference: id
+    listado:=20
+      type: BOOLEAN
+      required: true
+      default: false
+    variables:=20
+      type: VARCHAR
+      size: 128
+  tipoinforme:=20
+    _attributes:=20
+      idMethod: native
+    id:=20
+      type: INTEGER
+      required: true
+      autoIncrement: true
+      primaryKey: true
+    nombre:=20
+      type: VARCHAR
+      size: 128
+      required: true
+    descripcion:=20
+      type: VARCHAR
+      size: 255
+      required: false
\ No newline at end of file

Modified: prosistem/alba/trunk/alba/data/sql/datos_desde_cero.sql
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/data/sql/datos_desde_cero.sql	2007-10-10 17=
:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/data/sql/datos_desde_cero.sql	2007-10-10 20=
:53:17 UTC (rev 5218)
@@ -309,5 +309,10 @@
 INSERT INTO rel_usuario_permiso (id, fk_usuario_id, fk_permiso_id) VALUE=
S (55, 1, 61);
 INSERT INTO rel_usuario_permiso (id, fk_usuario_id, fk_permiso_id) VALUE=
S (56, 1, 62);
=20
+--=20
+-- Volcar la base de datos para la tabla `tipoinforme`
+--=20
+
+INSERT INTO `tipoinforme` (`id` ,`nombre` ,`descripcion`) VALUES (1 , 'A=
lumnos', 'Informes relacionados a los alumnos');
+
 SET FOREIGN_KEY_CHECKS =3D 1;
-

Modified: prosistem/alba/trunk/alba/data/sql/datos_ejemplo.sql
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/data/sql/datos_ejemplo.sql	2007-10-10 17:24=
:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/data/sql/datos_ejemplo.sql	2007-10-10 20:53=
:17 UTC (rev 5218)
@@ -3448,6 +3448,11 @@
 INSERT INTO `evento` (`id`, `titulo`, `fecha_inicio`, `fecha_fin`, `tipo=
`, `frecuencia`, `frecuencia_intervalo`, `recurrencia_fin`, `recurrencia_=
dias`, `estado`) VALUES (32, 'Cuarto Grado A - Estudios sociales', '2007-=
03-05 14:50:00', '2007-03-05 15:30:00', 1, 5, 1, '2007-12-14 00:00', 6, 1=
);
=20
=20
+--=20
+-- Volcar la base de datos para la tabla `tipoinforme`
+--=20
=20
+INSERT INTO `tipoinforme` (`id` ,`nombre` ,`descripcion`) VALUES (1 , 'A=
lumnos', 'Informes relacionados a los alumnos');
+
 SET FOREIGN_KEY_CHECKS =3D 1;
=20

Modified: prosistem/alba/trunk/alba/data/sql/lib.model.schema.sql
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/data/sql/lib.model.schema.sql	2007-10-10 17=
:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/data/sql/lib.model.schema.sql	2007-10-10 20=
:53:17 UTC (rev 5218)
@@ -1438,5 +1438,47 @@
 		REFERENCES `docente` (`id`)
 )Type=3DInnoDB;
=20
+#-----------------------------------------------------------------------=
------
+#-- informe
+#-----------------------------------------------------------------------=
------
+
+DROP TABLE IF EXISTS `informe`;
+
+
+CREATE TABLE `informe`
+(
+	`id` INTEGER  NOT NULL AUTO_INCREMENT,
+	`nombre` VARCHAR(128)  NOT NULL,
+	`descripcion` VARCHAR(255),
+	`fk_adjunto_id` INTEGER(11)  NOT NULL,
+	`fk_tipoinforme_id` INTEGER(11)  NOT NULL,
+	`listado` INTEGER default 0 NOT NULL,
+	`variables` VARCHAR(128),
+	PRIMARY KEY (`id`),
+	INDEX `informe_FI_1` (`fk_adjunto_id`),
+	CONSTRAINT `informe_FK_1`
+		FOREIGN KEY (`fk_adjunto_id`)
+		REFERENCES `adjunto` (`id`),
+	INDEX `informe_FI_2` (`fk_tipoinforme_id`),
+	CONSTRAINT `informe_FK_2`
+		FOREIGN KEY (`fk_tipoinforme_id`)
+		REFERENCES `tipoinforme` (`id`)
+)Type=3DInnoDB;
+
+#-----------------------------------------------------------------------=
------
+#-- tipoinforme
+#-----------------------------------------------------------------------=
------
+
+DROP TABLE IF EXISTS `tipoinforme`;
+
+
+CREATE TABLE `tipoinforme`
+(
+	`id` INTEGER  NOT NULL AUTO_INCREMENT,
+	`nombre` VARCHAR(128)  NOT NULL,
+	`descripcion` VARCHAR(255),
+	PRIMARY KEY (`id`)
+)Type=3DInnoDB;
+
 # This restores the fkey checks, after having unset them earlier
 SET FOREIGN_KEY_CHECKS =3D 1;

Added: prosistem/alba/trunk/alba/lib/model/Informe.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/lib/model/Informe.php	2007-10-10 17:24:59 U=
TC (rev 5217)
+++ prosistem/alba/trunk/alba/lib/model/Informe.php	2007-10-10 20:53:17 U=
TC (rev 5218)
@@ -0,0 +1,12 @@
+<?php
+
+/**
+ * Subclass for representing a row from the 'informe' table.
+ *
+ *=20
+ *
+ * @package lib.model
+ */=20
+class Informe extends BaseInforme
+{
+}


Property changes on: prosistem/alba/trunk/alba/lib/model/Informe.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/lib/model/InformePeer.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/lib/model/InformePeer.php	2007-10-10 17:24:=
59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/lib/model/InformePeer.php	2007-10-10 20:53:=
17 UTC (rev 5218)
@@ -0,0 +1,12 @@
+<?php
+
+/**
+ * Subclass for performing query and update operations on the 'informe' =
table.
+ *
+ *=20
+ *
+ * @package lib.model
+ */=20
+class InformePeer extends BaseInformePeer
+{
+}


Property changes on: prosistem/alba/trunk/alba/lib/model/InformePeer.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/lib/model/Tipoinforme.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/lib/model/Tipoinforme.php	2007-10-10 17:24:=
59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/lib/model/Tipoinforme.php	2007-10-10 20:53:=
17 UTC (rev 5218)
@@ -0,0 +1,16 @@
+<?php
+
+/**
+ * Subclass for representing a row from the 'tipoinforme' table.
+ *
+ *=20
+ *
+ * @package lib.model
+ */=20
+class Tipoinforme extends BaseTipoinforme
+{
+    public function __toString() {
+        return $this->getNombre();
+    }
+
+}


Property changes on: prosistem/alba/trunk/alba/lib/model/Tipoinforme.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/lib/model/TipoinformePeer.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/lib/model/TipoinformePeer.php	2007-10-10 17=
:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/lib/model/TipoinformePeer.php	2007-10-10 20=
:53:17 UTC (rev 5218)
@@ -0,0 +1,12 @@
+<?php
+
+/**
+ * Subclass for performing query and update operations on the 'tipoinfor=
me' table.
+ *
+ *=20
+ *
+ * @package lib.model
+ */=20
+class TipoinformePeer extends BaseTipoinformePeer
+{
+}


Property changes on: prosistem/alba/trunk/alba/lib/model/TipoinformePeer.=
php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/lib/model/map/InformeMapBuilder.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/lib/model/map/InformeMapBuilder.php	2007-10=
-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/lib/model/map/InformeMapBuilder.php	2007-10=
-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,50 @@
+<?php
+
+
+
+class InformeMapBuilder {
+
+=09
+	const CLASS_NAME =3D 'lib.model.map.InformeMapBuilder';
+
+=09
+	private $dbMap;
+
+=09
+	public function isBuilt()
+	{
+		return ($this->dbMap !=3D=3D null);
+	}
+
+=09
+	public function getDatabaseMap()
+	{
+		return $this->dbMap;
+	}
+
+=09
+	public function doBuild()
+	{
+		$this->dbMap =3D Propel::getDatabaseMap('alba');
+
+		$tMap =3D $this->dbMap->addTable('informe');
+		$tMap->setPhpName('Informe');
+
+		$tMap->setUseIdGenerator(true);
+
+		$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, nu=
ll);
+
+		$tMap->addColumn('NOMBRE', 'Nombre', 'string', CreoleTypes::VARCHAR, t=
rue, 128);
+
+		$tMap->addColumn('DESCRIPCION', 'Descripcion', 'string', CreoleTypes::=
VARCHAR, false, 255);
+
+		$tMap->addForeignKey('FK_ADJUNTO_ID', 'FkAdjuntoId', 'int', CreoleType=
s::INTEGER, 'adjunto', 'ID', true, 11);
+
+		$tMap->addForeignKey('FK_TIPOINFORME_ID', 'FkTipoinformeId', 'int', Cr=
eoleTypes::INTEGER, 'tipoinforme', 'ID', true, 11);
+
+		$tMap->addColumn('LISTADO', 'Listado', 'boolean', CreoleTypes::BOOLEAN=
, true, null);
+
+		$tMap->addColumn('VARIABLES', 'Variables', 'string', CreoleTypes::VARC=
HAR, false, 128);
+
+	}=20
+}=20
\ No newline at end of file


Property changes on: prosistem/alba/trunk/alba/lib/model/map/InformeMapBu=
ilder.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/lib/model/map/TipoinformeMapBuilder.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/lib/model/map/TipoinformeMapBuilder.php	200=
7-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/lib/model/map/TipoinformeMapBuilder.php	200=
7-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,42 @@
+<?php
+
+
+
+class TipoinformeMapBuilder {
+
+=09
+	const CLASS_NAME =3D 'lib.model.map.TipoinformeMapBuilder';
+
+=09
+	private $dbMap;
+
+=09
+	public function isBuilt()
+	{
+		return ($this->dbMap !=3D=3D null);
+	}
+
+=09
+	public function getDatabaseMap()
+	{
+		return $this->dbMap;
+	}
+
+=09
+	public function doBuild()
+	{
+		$this->dbMap =3D Propel::getDatabaseMap('alba');
+
+		$tMap =3D $this->dbMap->addTable('tipoinforme');
+		$tMap->setPhpName('Tipoinforme');
+
+		$tMap->setUseIdGenerator(true);
+
+		$tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, nu=
ll);
+
+		$tMap->addColumn('NOMBRE', 'Nombre', 'string', CreoleTypes::VARCHAR, t=
rue, 128);
+
+		$tMap->addColumn('DESCRIPCION', 'Descripcion', 'string', CreoleTypes::=
VARCHAR, false, 255);
+
+	}=20
+}=20
\ No newline at end of file


Property changes on: prosistem/alba/trunk/alba/lib/model/map/TipoinformeM=
apBuilder.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Modified: prosistem/alba/trunk/alba/lib/model/om/BaseAdjunto.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/lib/model/om/BaseAdjunto.php	2007-10-10 17:=
24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/lib/model/om/BaseAdjunto.php	2007-10-10 20:=
53:17 UTC (rev 5218)
@@ -42,6 +42,12 @@
 	protected $lastLegajoadjuntoCriteria =3D null;
=20
 =09
+	protected $collInformes;
+
+=09
+	protected $lastInformeCriteria =3D null;
+
+=09
 	protected $alreadyInSave =3D false;
=20
 =09
@@ -311,6 +317,14 @@
 				}
 			}
=20
+			if ($this->collInformes !=3D=3D null) {
+				foreach($this->collInformes as $referrerFK) {
+					if (!$referrerFK->isDeleted()) {
+						$affectedRows +=3D $referrerFK->save($con);
+					}
+				}
+			}
+
 			$this->alreadyInSave =3D false;
 		}
 		return $affectedRows;
@@ -360,7 +374,15 @@
 					}
 				}
=20
+				if ($this->collInformes !=3D=3D null) {
+					foreach($this->collInformes as $referrerFK) {
+						if (!$referrerFK->validate($columns)) {
+							$failureMap =3D array_merge($failureMap, $referrerFK->getValidati=
onFailures());
+						}
+					}
+				}
=20
+
 			$this->alreadyInValidation =3D false;
 		}
=20
@@ -530,6 +552,10 @@
 				$copyObj->addLegajoadjunto($relObj->copy($deepCopy));
 			}
=20
+			foreach($this->getInformes() as $relObj) {
+				$copyObj->addInforme($relObj->copy($deepCopy));
+			}
+
 		}=20
=20
 		$copyObj->setNew(true);
@@ -660,4 +686,109 @@
 		return $this->collLegajoadjuntos;
 	}
=20
+=09
+	public function initInformes()
+	{
+		if ($this->collInformes =3D=3D=3D null) {
+			$this->collInformes =3D array();
+		}
+	}
+
+=09
+	public function getInformes($criteria =3D null, $con =3D null)
+	{
+				include_once 'lib/model/om/BaseInformePeer.php';
+		if ($criteria =3D=3D=3D null) {
+			$criteria =3D new Criteria();
+		}
+		elseif ($criteria instanceof Criteria)
+		{
+			$criteria =3D clone $criteria;
+		}
+
+		if ($this->collInformes =3D=3D=3D null) {
+			if ($this->isNew()) {
+			   $this->collInformes =3D array();
+			} else {
+
+				$criteria->add(InformePeer::FK_ADJUNTO_ID, $this->getId());
+
+				InformePeer::addSelectColumns($criteria);
+				$this->collInformes =3D InformePeer::doSelect($criteria, $con);
+			}
+		} else {
+						if (!$this->isNew()) {
+											=09
+
+				$criteria->add(InformePeer::FK_ADJUNTO_ID, $this->getId());
+
+				InformePeer::addSelectColumns($criteria);
+				if (!isset($this->lastInformeCriteria) || !$this->lastInformeCriteri=
a->equals($criteria)) {
+					$this->collInformes =3D InformePeer::doSelect($criteria, $con);
+				}
+			}
+		}
+		$this->lastInformeCriteria =3D $criteria;
+		return $this->collInformes;
+	}
+
+=09
+	public function countInformes($criteria =3D null, $distinct =3D false, =
$con =3D null)
+	{
+				include_once 'lib/model/om/BaseInformePeer.php';
+		if ($criteria =3D=3D=3D null) {
+			$criteria =3D new Criteria();
+		}
+		elseif ($criteria instanceof Criteria)
+		{
+			$criteria =3D clone $criteria;
+		}
+
+		$criteria->add(InformePeer::FK_ADJUNTO_ID, $this->getId());
+
+		return InformePeer::doCount($criteria, $distinct, $con);
+	}
+
+=09
+	public function addInforme(Informe $l)
+	{
+		$this->collInformes[] =3D $l;
+		$l->setAdjunto($this);
+	}
+
+
+=09
+	public function getInformesJoinTipoinforme($criteria =3D null, $con =3D=
 null)
+	{
+				include_once 'lib/model/om/BaseInformePeer.php';
+		if ($criteria =3D=3D=3D null) {
+			$criteria =3D new Criteria();
+		}
+		elseif ($criteria instanceof Criteria)
+		{
+			$criteria =3D clone $criteria;
+		}
+
+		if ($this->collInformes =3D=3D=3D null) {
+			if ($this->isNew()) {
+				$this->collInformes =3D array();
+			} else {
+
+				$criteria->add(InformePeer::FK_ADJUNTO_ID, $this->getId());
+
+				$this->collInformes =3D InformePeer::doSelectJoinTipoinforme($criter=
ia, $con);
+			}
+		} else {
+								=09
+			$criteria->add(InformePeer::FK_ADJUNTO_ID, $this->getId());
+
+			if (!isset($this->lastInformeCriteria) || !$this->lastInformeCriteria=
->equals($criteria)) {
+				$this->collInformes =3D InformePeer::doSelectJoinTipoinforme($criter=
ia, $con);
+			}
+		}
+		$this->lastInformeCriteria =3D $criteria;
+
+		return $this->collInformes;
+	}
+
 }=20
\ No newline at end of file

Added: prosistem/alba/trunk/alba/lib/model/om/BaseInforme.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/lib/model/om/BaseInforme.php	2007-10-10 17:=
24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/lib/model/om/BaseInforme.php	2007-10-10 20:=
53:17 UTC (rev 5218)
@@ -0,0 +1,609 @@
+<?php
+
+
+abstract class BaseInforme extends BaseObject  implements Persistent {
+
+
+=09
+	protected static $peer;
+
+
+=09
+	protected $id;
+
+
+=09
+	protected $nombre;
+
+
+=09
+	protected $descripcion;
+
+
+=09
+	protected $fk_adjunto_id;
+
+
+=09
+	protected $fk_tipoinforme_id;
+
+
+=09
+	protected $listado =3D false;
+
+
+=09
+	protected $variables;
+
+=09
+	protected $aAdjunto;
+
+=09
+	protected $aTipoinforme;
+
+=09
+	protected $alreadyInSave =3D false;
+
+=09
+	protected $alreadyInValidation =3D false;
+
+=09
+	public function getId()
+	{
+
+		return $this->id;
+	}
+
+=09
+	public function getNombre()
+	{
+
+		return $this->nombre;
+	}
+
+=09
+	public function getDescripcion()
+	{
+
+		return $this->descripcion;
+	}
+
+=09
+	public function getFkAdjuntoId()
+	{
+
+		return $this->fk_adjunto_id;
+	}
+
+=09
+	public function getFkTipoinformeId()
+	{
+
+		return $this->fk_tipoinforme_id;
+	}
+
+=09
+	public function getListado()
+	{
+
+		return $this->listado;
+	}
+
+=09
+	public function getVariables()
+	{
+
+		return $this->variables;
+	}
+
+=09
+	public function setId($v)
+	{
+
+						if ($v !=3D=3D null && !is_int($v) && is_numeric($v)) {
+			$v =3D (int) $v;
+		}
+
+		if ($this->id !=3D=3D $v) {
+			$this->id =3D $v;
+			$this->modifiedColumns[] =3D InformePeer::ID;
+		}
+
+	}=20
+=09
+	public function setNombre($v)
+	{
+
+						if ($v !=3D=3D null && !is_string($v)) {
+			$v =3D (string) $v;=20
+		}
+
+		if ($this->nombre !=3D=3D $v) {
+			$this->nombre =3D $v;
+			$this->modifiedColumns[] =3D InformePeer::NOMBRE;
+		}
+
+	}=20
+=09
+	public function setDescripcion($v)
+	{
+
+						if ($v !=3D=3D null && !is_string($v)) {
+			$v =3D (string) $v;=20
+		}
+
+		if ($this->descripcion !=3D=3D $v) {
+			$this->descripcion =3D $v;
+			$this->modifiedColumns[] =3D InformePeer::DESCRIPCION;
+		}
+
+	}=20
+=09
+	public function setFkAdjuntoId($v)
+	{
+
+						if ($v !=3D=3D null && !is_int($v) && is_numeric($v)) {
+			$v =3D (int) $v;
+		}
+
+		if ($this->fk_adjunto_id !=3D=3D $v) {
+			$this->fk_adjunto_id =3D $v;
+			$this->modifiedColumns[] =3D InformePeer::FK_ADJUNTO_ID;
+		}
+
+		if ($this->aAdjunto !=3D=3D null && $this->aAdjunto->getId() !=3D=3D $=
v) {
+			$this->aAdjunto =3D null;
+		}
+
+	}=20
+=09
+	public function setFkTipoinformeId($v)
+	{
+
+						if ($v !=3D=3D null && !is_int($v) && is_numeric($v)) {
+			$v =3D (int) $v;
+		}
+
+		if ($this->fk_tipoinforme_id !=3D=3D $v) {
+			$this->fk_tipoinforme_id =3D $v;
+			$this->modifiedColumns[] =3D InformePeer::FK_TIPOINFORME_ID;
+		}
+
+		if ($this->aTipoinforme !=3D=3D null && $this->aTipoinforme->getId() !=
=3D=3D $v) {
+			$this->aTipoinforme =3D null;
+		}
+
+	}=20
+=09
+	public function setListado($v)
+	{
+
+		if ($this->listado !=3D=3D $v || $v =3D=3D=3D false) {
+			$this->listado =3D $v;
+			$this->modifiedColumns[] =3D InformePeer::LISTADO;
+		}
+
+	}=20
+=09
+	public function setVariables($v)
+	{
+
+						if ($v !=3D=3D null && !is_string($v)) {
+			$v =3D (string) $v;=20
+		}
+
+		if ($this->variables !=3D=3D $v) {
+			$this->variables =3D $v;
+			$this->modifiedColumns[] =3D InformePeer::VARIABLES;
+		}
+
+	}=20
+=09
+	public function hydrate(ResultSet $rs, $startcol =3D 1)
+	{
+		try {
+
+			$this->id =3D $rs->getInt($startcol + 0);
+
+			$this->nombre =3D $rs->getString($startcol + 1);
+
+			$this->descripcion =3D $rs->getString($startcol + 2);
+
+			$this->fk_adjunto_id =3D $rs->getInt($startcol + 3);
+
+			$this->fk_tipoinforme_id =3D $rs->getInt($startcol + 4);
+
+			$this->listado =3D $rs->getBoolean($startcol + 5);
+
+			$this->variables =3D $rs->getString($startcol + 6);
+
+			$this->resetModified();
+
+			$this->setNew(false);
+
+						return $startcol + 7;=20
+		} catch (Exception $e) {
+			throw new PropelException("Error populating Informe object", $e);
+		}
+	}
+
+=09
+	public function delete($con =3D null)
+	{
+		if ($this->isDeleted()) {
+			throw new PropelException("This object has already been deleted.");
+		}
+
+		if ($con =3D=3D=3D null) {
+			$con =3D Propel::getConnection(InformePeer::DATABASE_NAME);
+		}
+
+		try {
+			$con->begin();
+			InformePeer::doDelete($this, $con);
+			$this->setDeleted(true);
+			$con->commit();
+		} catch (PropelException $e) {
+			$con->rollback();
+			throw $e;
+		}
+	}
+
+=09
+	public function save($con =3D null)
+	{
+		if ($this->isDeleted()) {
+			throw new PropelException("You cannot save an object that has been de=
leted.");
+		}
+
+		if ($con =3D=3D=3D null) {
+			$con =3D Propel::getConnection(InformePeer::DATABASE_NAME);
+		}
+
+		try {
+			$con->begin();
+			$affectedRows =3D $this->doSave($con);
+			$con->commit();
+			return $affectedRows;
+		} catch (PropelException $e) {
+			$con->rollback();
+			throw $e;
+		}
+	}
+
+=09
+	protected function doSave($con)
+	{
+		$affectedRows =3D 0; 		if (!$this->alreadyInSave) {
+			$this->alreadyInSave =3D true;
+
+
+											=09
+			if ($this->aAdjunto !=3D=3D null) {
+				if ($this->aAdjunto->isModified()) {
+					$affectedRows +=3D $this->aAdjunto->save($con);
+				}
+				$this->setAdjunto($this->aAdjunto);
+			}
+
+			if ($this->aTipoinforme !=3D=3D null) {
+				if ($this->aTipoinforme->isModified()) {
+					$affectedRows +=3D $this->aTipoinforme->save($con);
+				}
+				$this->setTipoinforme($this->aTipoinforme);
+			}
+
+
+						if ($this->isModified()) {
+				if ($this->isNew()) {
+					$pk =3D InformePeer::doInsert($this, $con);
+					$affectedRows +=3D 1; 										 										=20
+					$this->setId($pk); =20
+					$this->setNew(false);
+				} else {
+					$affectedRows +=3D InformePeer::doUpdate($this, $con);
+				}
+				$this->resetModified(); 			}
+
+			$this->alreadyInSave =3D false;
+		}
+		return $affectedRows;
+	}=20
+=09
+	protected $validationFailures =3D array();
+
+=09
+	public function getValidationFailures()
+	{
+		return $this->validationFailures;
+	}
+
+=09
+	public function validate($columns =3D null)
+	{
+		$res =3D $this->doValidate($columns);
+		if ($res =3D=3D=3D true) {
+			$this->validationFailures =3D array();
+			return true;
+		} else {
+			$this->validationFailures =3D $res;
+			return false;
+		}
+	}
+
+=09
+	protected function doValidate($columns =3D null)
+	{
+		if (!$this->alreadyInValidation) {
+			$this->alreadyInValidation =3D true;
+			$retval =3D null;
+
+			$failureMap =3D array();
+
+
+											=09
+			if ($this->aAdjunto !=3D=3D null) {
+				if (!$this->aAdjunto->validate($columns)) {
+					$failureMap =3D array_merge($failureMap, $this->aAdjunto->getValida=
tionFailures());
+				}
+			}
+
+			if ($this->aTipoinforme !=3D=3D null) {
+				if (!$this->aTipoinforme->validate($columns)) {
+					$failureMap =3D array_merge($failureMap, $this->aTipoinforme->getVa=
lidationFailures());
+				}
+			}
+
+
+			if (($retval =3D InformePeer::doValidate($this, $columns)) !=3D=3D tr=
ue) {
+				$failureMap =3D array_merge($failureMap, $retval);
+			}
+
+
+
+			$this->alreadyInValidation =3D false;
+		}
+
+		return (!empty($failureMap) ? $failureMap : true);
+	}
+
+=09
+	public function getByName($name, $type =3D BasePeer::TYPE_PHPNAME)
+	{
+		$pos =3D InformePeer::translateFieldName($name, $type, BasePeer::TYPE_=
NUM);
+		return $this->getByPosition($pos);
+	}
+
+=09
+	public function getByPosition($pos)
+	{
+		switch($pos) {
+			case 0:
+				return $this->getId();
+				break;
+			case 1:
+				return $this->getNombre();
+				break;
+			case 2:
+				return $this->getDescripcion();
+				break;
+			case 3:
+				return $this->getFkAdjuntoId();
+				break;
+			case 4:
+				return $this->getFkTipoinformeId();
+				break;
+			case 5:
+				return $this->getListado();
+				break;
+			case 6:
+				return $this->getVariables();
+				break;
+			default:
+				return null;
+				break;
+		} 	}
+
+=09
+	public function toArray($keyType =3D BasePeer::TYPE_PHPNAME)
+	{
+		$keys =3D InformePeer::getFieldNames($keyType);
+		$result =3D array(
+			$keys[0] =3D> $this->getId(),
+			$keys[1] =3D> $this->getNombre(),
+			$keys[2] =3D> $this->getDescripcion(),
+			$keys[3] =3D> $this->getFkAdjuntoId(),
+			$keys[4] =3D> $this->getFkTipoinformeId(),
+			$keys[5] =3D> $this->getListado(),
+			$keys[6] =3D> $this->getVariables(),
+		);
+		return $result;
+	}
+
+=09
+	public function setByName($name, $value, $type =3D BasePeer::TYPE_PHPNA=
ME)
+	{
+		$pos =3D InformePeer::translateFieldName($name, $type, BasePeer::TYPE_=
NUM);
+		return $this->setByPosition($pos, $value);
+	}
+
+=09
+	public function setByPosition($pos, $value)
+	{
+		switch($pos) {
+			case 0:
+				$this->setId($value);
+				break;
+			case 1:
+				$this->setNombre($value);
+				break;
+			case 2:
+				$this->setDescripcion($value);
+				break;
+			case 3:
+				$this->setFkAdjuntoId($value);
+				break;
+			case 4:
+				$this->setFkTipoinformeId($value);
+				break;
+			case 5:
+				$this->setListado($value);
+				break;
+			case 6:
+				$this->setVariables($value);
+				break;
+		} 	}
+
+=09
+	public function fromArray($arr, $keyType =3D BasePeer::TYPE_PHPNAME)
+	{
+		$keys =3D InformePeer::getFieldNames($keyType);
+
+		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+		if (array_key_exists($keys[1], $arr)) $this->setNombre($arr[$keys[1]])=
;
+		if (array_key_exists($keys[2], $arr)) $this->setDescripcion($arr[$keys=
[2]]);
+		if (array_key_exists($keys[3], $arr)) $this->setFkAdjuntoId($arr[$keys=
[3]]);
+		if (array_key_exists($keys[4], $arr)) $this->setFkTipoinformeId($arr[$=
keys[4]]);
+		if (array_key_exists($keys[5], $arr)) $this->setListado($arr[$keys[5]]=
);
+		if (array_key_exists($keys[6], $arr)) $this->setVariables($arr[$keys[6=
]]);
+	}
+
+=09
+	public function buildCriteria()
+	{
+		$criteria =3D new Criteria(InformePeer::DATABASE_NAME);
+
+		if ($this->isColumnModified(InformePeer::ID)) $criteria->add(InformePe=
er::ID, $this->id);
+		if ($this->isColumnModified(InformePeer::NOMBRE)) $criteria->add(Infor=
mePeer::NOMBRE, $this->nombre);
+		if ($this->isColumnModified(InformePeer::DESCRIPCION)) $criteria->add(=
InformePeer::DESCRIPCION, $this->descripcion);
+		if ($this->isColumnModified(InformePeer::FK_ADJUNTO_ID)) $criteria->ad=
d(InformePeer::FK_ADJUNTO_ID, $this->fk_adjunto_id);
+		if ($this->isColumnModified(InformePeer::FK_TIPOINFORME_ID)) $criteria=
->add(InformePeer::FK_TIPOINFORME_ID, $this->fk_tipoinforme_id);
+		if ($this->isColumnModified(InformePeer::LISTADO)) $criteria->add(Info=
rmePeer::LISTADO, $this->listado);
+		if ($this->isColumnModified(InformePeer::VARIABLES)) $criteria->add(In=
formePeer::VARIABLES, $this->variables);
+
+		return $criteria;
+	}
+
+=09
+	public function buildPkeyCriteria()
+	{
+		$criteria =3D new Criteria(InformePeer::DATABASE_NAME);
+
+		$criteria->add(InformePeer::ID, $this->id);
+
+		return $criteria;
+	}
+
+=09
+	public function getPrimaryKey()
+	{
+		return $this->getId();
+	}
+
+=09
+	public function setPrimaryKey($key)
+	{
+		$this->setId($key);
+	}
+
+=09
+	public function copyInto($copyObj, $deepCopy =3D false)
+	{
+
+		$copyObj->setNombre($this->nombre);
+
+		$copyObj->setDescripcion($this->descripcion);
+
+		$copyObj->setFkAdjuntoId($this->fk_adjunto_id);
+
+		$copyObj->setFkTipoinformeId($this->fk_tipoinforme_id);
+
+		$copyObj->setListado($this->listado);
+
+		$copyObj->setVariables($this->variables);
+
+
+		$copyObj->setNew(true);
+
+		$copyObj->setId(NULL);=20
+	}
+
+=09
+	public function copy($deepCopy =3D false)
+	{
+				$clazz =3D get_class($this);
+		$copyObj =3D new $clazz();
+		$this->copyInto($copyObj, $deepCopy);
+		return $copyObj;
+	}
+
+=09
+	public function getPeer()
+	{
+		if (self::$peer =3D=3D=3D null) {
+			self::$peer =3D new InformePeer();
+		}
+		return self::$peer;
+	}
+
+=09
+	public function setAdjunto($v)
+	{
+
+
+		if ($v =3D=3D=3D null) {
+			$this->setFkAdjuntoId(NULL);
+		} else {
+			$this->setFkAdjuntoId($v->getId());
+		}
+
+
+		$this->aAdjunto =3D $v;
+	}
+
+
+=09
+	public function getAdjunto($con =3D null)
+	{
+				include_once 'lib/model/om/BaseAdjuntoPeer.php';
+
+		if ($this->aAdjunto =3D=3D=3D null && ($this->fk_adjunto_id !=3D=3D nu=
ll)) {
+
+			$this->aAdjunto =3D AdjuntoPeer::retrieveByPK($this->fk_adjunto_id, $=
con);
+
+		=09
+		}
+		return $this->aAdjunto;
+	}
+
+=09
+	public function setTipoinforme($v)
+	{
+
+
+		if ($v =3D=3D=3D null) {
+			$this->setFkTipoinformeId(NULL);
+		} else {
+			$this->setFkTipoinformeId($v->getId());
+		}
+
+
+		$this->aTipoinforme =3D $v;
+	}
+
+
+=09
+	public function getTipoinforme($con =3D null)
+	{
+				include_once 'lib/model/om/BaseTipoinformePeer.php';
+
+		if ($this->aTipoinforme =3D=3D=3D null && ($this->fk_tipoinforme_id !=3D=
=3D null)) {
+
+			$this->aTipoinforme =3D TipoinformePeer::retrieveByPK($this->fk_tipoi=
nforme_id, $con);
+
+		=09
+		}
+		return $this->aTipoinforme;
+	}
+
+}=20
\ No newline at end of file


Property changes on: prosistem/alba/trunk/alba/lib/model/om/BaseInforme.p=
hp
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/lib/model/om/BaseInformePeer.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/lib/model/om/BaseInformePeer.php	2007-10-10=
 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/lib/model/om/BaseInformePeer.php	2007-10-10=
 20:53:17 UTC (rev 5218)
@@ -0,0 +1,829 @@
+<?php
+
+
+abstract class BaseInformePeer {
+
+=09
+	const DATABASE_NAME =3D 'alba';
+
+=09
+	const TABLE_NAME =3D 'informe';
+
+=09
+	const CLASS_DEFAULT =3D 'lib.model.Informe';
+
+=09
+	const NUM_COLUMNS =3D 7;
+
+=09
+	const NUM_LAZY_LOAD_COLUMNS =3D 0;
+
+
+=09
+	const ID =3D 'informe.ID';
+
+=09
+	const NOMBRE =3D 'informe.NOMBRE';
+
+=09
+	const DESCRIPCION =3D 'informe.DESCRIPCION';
+
+=09
+	const FK_ADJUNTO_ID =3D 'informe.FK_ADJUNTO_ID';
+
+=09
+	const FK_TIPOINFORME_ID =3D 'informe.FK_TIPOINFORME_ID';
+
+=09
+	const LISTADO =3D 'informe.LISTADO';
+
+=09
+	const VARIABLES =3D 'informe.VARIABLES';
+
+=09
+	private static $phpNameMap =3D null;
+
+
+=09
+	private static $fieldNames =3D array (
+		BasePeer::TYPE_PHPNAME =3D> array ('Id', 'Nombre', 'Descripcion', 'FkA=
djuntoId', 'FkTipoinformeId', 'Listado', 'Variables', ),
+		BasePeer::TYPE_COLNAME =3D> array (InformePeer::ID, InformePeer::NOMBR=
E, InformePeer::DESCRIPCION, InformePeer::FK_ADJUNTO_ID, InformePeer::FK_=
TIPOINFORME_ID, InformePeer::LISTADO, InformePeer::VARIABLES, ),
+		BasePeer::TYPE_FIELDNAME =3D> array ('id', 'nombre', 'descripcion', 'f=
k_adjunto_id', 'fk_tipoinforme_id', 'listado', 'variables', ),
+		BasePeer::TYPE_NUM =3D> array (0, 1, 2, 3, 4, 5, 6, )
+	);
+
+=09
+	private static $fieldKeys =3D array (
+		BasePeer::TYPE_PHPNAME =3D> array ('Id' =3D> 0, 'Nombre' =3D> 1, 'Desc=
ripcion' =3D> 2, 'FkAdjuntoId' =3D> 3, 'FkTipoinformeId' =3D> 4, 'Listado=
' =3D> 5, 'Variables' =3D> 6, ),
+		BasePeer::TYPE_COLNAME =3D> array (InformePeer::ID =3D> 0, InformePeer=
::NOMBRE =3D> 1, InformePeer::DESCRIPCION =3D> 2, InformePeer::FK_ADJUNTO=
_ID =3D> 3, InformePeer::FK_TIPOINFORME_ID =3D> 4, InformePeer::LISTADO =3D=
> 5, InformePeer::VARIABLES =3D> 6, ),
+		BasePeer::TYPE_FIELDNAME =3D> array ('id' =3D> 0, 'nombre' =3D> 1, 'de=
scripcion' =3D> 2, 'fk_adjunto_id' =3D> 3, 'fk_tipoinforme_id' =3D> 4, 'l=
istado' =3D> 5, 'variables' =3D> 6, ),
+		BasePeer::TYPE_NUM =3D> array (0, 1, 2, 3, 4, 5, 6, )
+	);
+
+=09
+	public static function getMapBuilder()
+	{
+		include_once 'lib/model/map/InformeMapBuilder.php';
+		return BasePeer::getMapBuilder('lib.model.map.InformeMapBuilder');
+	}
+=09
+	public static function getPhpNameMap()
+	{
+		if (self::$phpNameMap =3D=3D=3D null) {
+			$map =3D InformePeer::getTableMap();
+			$columns =3D $map->getColumns();
+			$nameMap =3D array();
+			foreach ($columns as $column) {
+				$nameMap[$column->getPhpName()] =3D $column->getColumnName();
+			}
+			self::$phpNameMap =3D $nameMap;
+		}
+		return self::$phpNameMap;
+	}
+=09
+	static public function translateFieldName($name, $fromType, $toType)
+	{
+		$toNames =3D self::getFieldNames($toType);
+		$key =3D isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[=
$fromType][$name] : null;
+		if ($key =3D=3D=3D null) {
+			throw new PropelException("'$name' could not be found in the field na=
mes of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromTyp=
e], true));
+		}
+		return $toNames[$key];
+	}
+
+=09
+
+	static public function getFieldNames($type =3D BasePeer::TYPE_PHPNAME)
+	{
+		if (!array_key_exists($type, self::$fieldNames)) {
+			throw new PropelException('Method getFieldNames() expects the paramet=
er $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYP=
E_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
+		}
+		return self::$fieldNames[$type];
+	}
+
+=09
+	public static function alias($alias, $column)
+	{
+		return str_replace(InformePeer::TABLE_NAME.'.', $alias.'.', $column);
+	}
+
+=09
+	public static function addSelectColumns(Criteria $criteria)
+	{
+
+		$criteria->addSelectColumn(InformePeer::ID);
+
+		$criteria->addSelectColumn(InformePeer::NOMBRE);
+
+		$criteria->addSelectColumn(InformePeer::DESCRIPCION);
+
+		$criteria->addSelectColumn(InformePeer::FK_ADJUNTO_ID);
+
+		$criteria->addSelectColumn(InformePeer::FK_TIPOINFORME_ID);
+
+		$criteria->addSelectColumn(InformePeer::LISTADO);
+
+		$criteria->addSelectColumn(InformePeer::VARIABLES);
+
+	}
+
+	const COUNT =3D 'COUNT(informe.ID)';
+	const COUNT_DISTINCT =3D 'COUNT(DISTINCT informe.ID)';
+
+=09
+	public static function doCount(Criteria $criteria, $distinct =3D false,=
 $con =3D null)
+	{
+				$criteria =3D clone $criteria;
+
+				$criteria->clearSelectColumns()->clearOrderByColumns();
+		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModi=
fiers())) {
+			$criteria->addSelectColumn(InformePeer::COUNT_DISTINCT);
+		} else {
+			$criteria->addSelectColumn(InformePeer::COUNT);
+		}
+
+				foreach($criteria->getGroupByColumns() as $column)
+		{
+			$criteria->addSelectColumn($column);
+		}
+
+		$rs =3D InformePeer::doSelectRS($criteria, $con);
+		if ($rs->next()) {
+			return $rs->getInt(1);
+		} else {
+						return 0;
+		}
+	}
+=09
+	public static function doSelectOne(Criteria $criteria, $con =3D null)
+	{
+		$critcopy =3D clone $criteria;
+		$critcopy->setLimit(1);
+		$objects =3D InformePeer::doSelect($critcopy, $con);
+		if ($objects) {
+			return $objects[0];
+		}
+		return null;
+	}
+=09
+	public static function doSelect(Criteria $criteria, $con =3D null)
+	{
+		return InformePeer::populateObjects(InformePeer::doSelectRS($criteria,=
 $con));
+	}
+=09
+	public static function doSelectRS(Criteria $criteria, $con =3D null)
+	{
+		if ($con =3D=3D=3D null) {
+			$con =3D Propel::getConnection(self::DATABASE_NAME);
+		}
+
+		if (!$criteria->getSelectColumns()) {
+			$criteria =3D clone $criteria;
+			InformePeer::addSelectColumns($criteria);
+		}
+
+				$criteria->setDbName(self::DATABASE_NAME);
+
+						return BasePeer::doSelect($criteria, $con);
+	}
+=09
+	public static function populateObjects(ResultSet $rs)
+	{
+		$results =3D array();
+=09
+				$cls =3D InformePeer::getOMClass();
+		$cls =3D Propel::import($cls);
+				while($rs->next()) {
+	=09
+			$obj =3D new $cls();
+			$obj->hydrate($rs);
+			$results[] =3D $obj;
+		=09
+		}
+		return $results;
+	}
+
+=09
+	public static function doCountJoinAdjunto(Criteria $criteria, $distinct=
 =3D false, $con =3D null)
+	{
+				$criteria =3D clone $criteria;
+
+				$criteria->clearSelectColumns()->clearOrderByColumns();
+		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModi=
fiers())) {
+			$criteria->addSelectColumn(InformePeer::COUNT_DISTINCT);
+		} else {
+			$criteria->addSelectColumn(InformePeer::COUNT);
+		}
+
+				foreach($criteria->getGroupByColumns() as $column)
+		{
+			$criteria->addSelectColumn($column);
+		}
+
+		$criteria->addJoin(InformePeer::FK_ADJUNTO_ID, AdjuntoPeer::ID);
+
+		$rs =3D InformePeer::doSelectRS($criteria, $con);
+		if ($rs->next()) {
+			return $rs->getInt(1);
+		} else {
+						return 0;
+		}
+	}
+
+
+=09
+	public static function doCountJoinTipoinforme(Criteria $criteria, $dist=
inct =3D false, $con =3D null)
+	{
+				$criteria =3D clone $criteria;
+
+				$criteria->clearSelectColumns()->clearOrderByColumns();
+		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModi=
fiers())) {
+			$criteria->addSelectColumn(InformePeer::COUNT_DISTINCT);
+		} else {
+			$criteria->addSelectColumn(InformePeer::COUNT);
+		}
+
+				foreach($criteria->getGroupByColumns() as $column)
+		{
+			$criteria->addSelectColumn($column);
+		}
+
+		$criteria->addJoin(InformePeer::FK_TIPOINFORME_ID, TipoinformePeer::ID=
);
+
+		$rs =3D InformePeer::doSelectRS($criteria, $con);
+		if ($rs->next()) {
+			return $rs->getInt(1);
+		} else {
+						return 0;
+		}
+	}
+
+
+=09
+	public static function doSelectJoinAdjunto(Criteria $c, $con =3D null)
+	{
+		$c =3D clone $c;
+
+				if ($c->getDbName() =3D=3D Propel::getDefaultDB()) {
+			$c->setDbName(self::DATABASE_NAME);
+		}
+
+		InformePeer::addSelectColumns($c);
+		$startcol =3D (InformePeer::NUM_COLUMNS - InformePeer::NUM_LAZY_LOAD_C=
OLUMNS) + 1;
+		AdjuntoPeer::addSelectColumns($c);
+
+		$c->addJoin(InformePeer::FK_ADJUNTO_ID, AdjuntoPeer::ID);
+		$rs =3D BasePeer::doSelect($c, $con);
+		$results =3D array();
+
+		while($rs->next()) {
+
+			$omClass =3D InformePeer::getOMClass();
+
+			$cls =3D Propel::import($omClass);
+			$obj1 =3D new $cls();
+			$obj1->hydrate($rs);
+
+			$omClass =3D AdjuntoPeer::getOMClass();
+
+			$cls =3D Propel::import($omClass);
+			$obj2 =3D new $cls();
+			$obj2->hydrate($rs, $startcol);
+
+			$newObject =3D true;
+			foreach($results as $temp_obj1) {
+				$temp_obj2 =3D $temp_obj1->getAdjunto(); 				if ($temp_obj2->getPrim=
aryKey() =3D=3D=3D $obj2->getPrimaryKey()) {
+					$newObject =3D false;
+										$temp_obj2->addInforme($obj1); 					break;
+				}
+			}
+			if ($newObject) {
+				$obj2->initInformes();
+				$obj2->addInforme($obj1); 			}
+			$results[] =3D $obj1;
+		}
+		return $results;
+	}
+
+
+=09
+	public static function doSelectJoinTipoinforme(Criteria $c, $con =3D nu=
ll)
+	{
+		$c =3D clone $c;
+
+				if ($c->getDbName() =3D=3D Propel::getDefaultDB()) {
+			$c->setDbName(self::DATABASE_NAME);
+		}
+
+		InformePeer::addSelectColumns($c);
+		$startcol =3D (InformePeer::NUM_COLUMNS - InformePeer::NUM_LAZY_LOAD_C=
OLUMNS) + 1;
+		TipoinformePeer::addSelectColumns($c);
+
+		$c->addJoin(InformePeer::FK_TIPOINFORME_ID, TipoinformePeer::ID);
+		$rs =3D BasePeer::doSelect($c, $con);
+		$results =3D array();
+
+		while($rs->next()) {
+
+			$omClass =3D InformePeer::getOMClass();
+
+			$cls =3D Propel::import($omClass);
+			$obj1 =3D new $cls();
+			$obj1->hydrate($rs);
+
+			$omClass =3D TipoinformePeer::getOMClass();
+
+			$cls =3D Propel::import($omClass);
+			$obj2 =3D new $cls();
+			$obj2->hydrate($rs, $startcol);
+
+			$newObject =3D true;
+			foreach($results as $temp_obj1) {
+				$temp_obj2 =3D $temp_obj1->getTipoinforme(); 				if ($temp_obj2->get=
PrimaryKey() =3D=3D=3D $obj2->getPrimaryKey()) {
+					$newObject =3D false;
+										$temp_obj2->addInforme($obj1); 					break;
+				}
+			}
+			if ($newObject) {
+				$obj2->initInformes();
+				$obj2->addInforme($obj1); 			}
+			$results[] =3D $obj1;
+		}
+		return $results;
+	}
+
+
+=09
+	public static function doCountJoinAll(Criteria $criteria, $distinct =3D=
 false, $con =3D null)
+	{
+		$criteria =3D clone $criteria;
+
+				$criteria->clearSelectColumns()->clearOrderByColumns();
+		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModi=
fiers())) {
+			$criteria->addSelectColumn(InformePeer::COUNT_DISTINCT);
+		} else {
+			$criteria->addSelectColumn(InformePeer::COUNT);
+		}
+
+				foreach($criteria->getGroupByColumns() as $column)
+		{
+			$criteria->addSelectColumn($column);
+		}
+
+		$criteria->addJoin(InformePeer::FK_ADJUNTO_ID, AdjuntoPeer::ID);
+
+		$criteria->addJoin(InformePeer::FK_TIPOINFORME_ID, TipoinformePeer::ID=
);
+
+		$rs =3D InformePeer::doSelectRS($criteria, $con);
+		if ($rs->next()) {
+			return $rs->getInt(1);
+		} else {
+						return 0;
+		}
+	}
+
+
+=09
+	public static function doSelectJoinAll(Criteria $c, $con =3D null)
+	{
+		$c =3D clone $c;
+
+				if ($c->getDbName() =3D=3D Propel::getDefaultDB()) {
+			$c->setDbName(self::DATABASE_NAME);
+		}
+
+		InformePeer::addSelectColumns($c);
+		$startcol2 =3D (InformePeer::NUM_COLUMNS - InformePeer::NUM_LAZY_LOAD_=
COLUMNS) + 1;
+
+		AdjuntoPeer::addSelectColumns($c);
+		$startcol3 =3D $startcol2 + AdjuntoPeer::NUM_COLUMNS;
+
+		TipoinformePeer::addSelectColumns($c);
+		$startcol4 =3D $startcol3 + TipoinformePeer::NUM_COLUMNS;
+
+		$c->addJoin(InformePeer::FK_ADJUNTO_ID, AdjuntoPeer::ID);
+
+		$c->addJoin(InformePeer::FK_TIPOINFORME_ID, TipoinformePeer::ID);
+
+		$rs =3D BasePeer::doSelect($c, $con);
+		$results =3D array();
+
+		while($rs->next()) {
+
+			$omClass =3D InformePeer::getOMClass();
+
+
+			$cls =3D Propel::import($omClass);
+			$obj1 =3D new $cls();
+			$obj1->hydrate($rs);
+
+
+				=09
+			$omClass =3D AdjuntoPeer::getOMClass();
+
+
+			$cls =3D Propel::import($omClass);
+			$obj2 =3D new $cls();
+			$obj2->hydrate($rs, $startcol2);
+
+			$newObject =3D true;
+			for ($j=3D0, $resCount=3Dcount($results); $j < $resCount; $j++) {
+				$temp_obj1 =3D $results[$j];
+				$temp_obj2 =3D $temp_obj1->getAdjunto(); 				if ($temp_obj2->getPrim=
aryKey() =3D=3D=3D $obj2->getPrimaryKey()) {
+					$newObject =3D false;
+					$temp_obj2->addInforme($obj1); 					break;
+				}
+			}
+
+			if ($newObject) {
+				$obj2->initInformes();
+				$obj2->addInforme($obj1);
+			}
+
+
+				=09
+			$omClass =3D TipoinformePeer::getOMClass();
+
+
+			$cls =3D Propel::import($omClass);
+			$obj3 =3D new $cls();
+			$obj3->hydrate($rs, $startcol3);
+
+			$newObject =3D true;
+			for ($j=3D0, $resCount=3Dcount($results); $j < $resCount; $j++) {
+				$temp_obj1 =3D $results[$j];
+				$temp_obj3 =3D $temp_obj1->getTipoinforme(); 				if ($temp_obj3->get=
PrimaryKey() =3D=3D=3D $obj3->getPrimaryKey()) {
+					$newObject =3D false;
+					$temp_obj3->addInforme($obj1); 					break;
+				}
+			}
+
+			if ($newObject) {
+				$obj3->initInformes();
+				$obj3->addInforme($obj1);
+			}
+
+			$results[] =3D $obj1;
+		}
+		return $results;
+	}
+
+
+=09
+	public static function doCountJoinAllExceptAdjunto(Criteria $criteria, =
$distinct =3D false, $con =3D null)
+	{
+				$criteria =3D clone $criteria;
+
+				$criteria->clearSelectColumns()->clearOrderByColumns();
+		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModi=
fiers())) {
+			$criteria->addSelectColumn(InformePeer::COUNT_DISTINCT);
+		} else {
+			$criteria->addSelectColumn(InformePeer::COUNT);
+		}
+
+				foreach($criteria->getGroupByColumns() as $column)
+		{
+			$criteria->addSelectColumn($column);
+		}
+
+		$criteria->addJoin(InformePeer::FK_TIPOINFORME_ID, TipoinformePeer::ID=
);
+
+		$rs =3D InformePeer::doSelectRS($criteria, $con);
+		if ($rs->next()) {
+			return $rs->getInt(1);
+		} else {
+						return 0;
+		}
+	}
+
+
+=09
+	public static function doCountJoinAllExceptTipoinforme(Criteria $criter=
ia, $distinct =3D false, $con =3D null)
+	{
+				$criteria =3D clone $criteria;
+
+				$criteria->clearSelectColumns()->clearOrderByColumns();
+		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModi=
fiers())) {
+			$criteria->addSelectColumn(InformePeer::COUNT_DISTINCT);
+		} else {
+			$criteria->addSelectColumn(InformePeer::COUNT);
+		}
+
+				foreach($criteria->getGroupByColumns() as $column)
+		{
+			$criteria->addSelectColumn($column);
+		}
+
+		$criteria->addJoin(InformePeer::FK_ADJUNTO_ID, AdjuntoPeer::ID);
+
+		$rs =3D InformePeer::doSelectRS($criteria, $con);
+		if ($rs->next()) {
+			return $rs->getInt(1);
+		} else {
+						return 0;
+		}
+	}
+
+
+=09
+	public static function doSelectJoinAllExceptAdjunto(Criteria $c, $con =3D=
 null)
+	{
+		$c =3D clone $c;
+
+								if ($c->getDbName() =3D=3D Propel::getDefaultDB()) {
+			$c->setDbName(self::DATABASE_NAME);
+		}
+
+		InformePeer::addSelectColumns($c);
+		$startcol2 =3D (InformePeer::NUM_COLUMNS - InformePeer::NUM_LAZY_LOAD_=
COLUMNS) + 1;
+
+		TipoinformePeer::addSelectColumns($c);
+		$startcol3 =3D $startcol2 + TipoinformePeer::NUM_COLUMNS;
+
+		$c->addJoin(InformePeer::FK_TIPOINFORME_ID, TipoinformePeer::ID);
+
+
+		$rs =3D BasePeer::doSelect($c, $con);
+		$results =3D array();
+
+		while($rs->next()) {
+
+			$omClass =3D InformePeer::getOMClass();
+
+			$cls =3D Propel::import($omClass);
+			$obj1 =3D new $cls();
+			$obj1->hydrate($rs);
+
+			$omClass =3D TipoinformePeer::getOMClass();
+
+
+			$cls =3D Propel::import($omClass);
+			$obj2  =3D new $cls();
+			$obj2->hydrate($rs, $startcol2);
+
+			$newObject =3D true;
+			for ($j=3D0, $resCount=3Dcount($results); $j < $resCount; $j++) {
+				$temp_obj1 =3D $results[$j];
+				$temp_obj2 =3D $temp_obj1->getTipoinforme(); 				if ($temp_obj2->get=
PrimaryKey() =3D=3D=3D $obj2->getPrimaryKey()) {
+					$newObject =3D false;
+					$temp_obj2->addInforme($obj1);
+					break;
+				}
+			}
+
+			if ($newObject) {
+				$obj2->initInformes();
+				$obj2->addInforme($obj1);
+			}
+
+			$results[] =3D $obj1;
+		}
+		return $results;
+	}
+
+
+=09
+	public static function doSelectJoinAllExceptTipoinforme(Criteria $c, $c=
on =3D null)
+	{
+		$c =3D clone $c;
+
+								if ($c->getDbName() =3D=3D Propel::getDefaultDB()) {
+			$c->setDbName(self::DATABASE_NAME);
+		}
+
+		InformePeer::addSelectColumns($c);
+		$startcol2 =3D (InformePeer::NUM_COLUMNS - InformePeer::NUM_LAZY_LOAD_=
COLUMNS) + 1;
+
+		AdjuntoPeer::addSelectColumns($c);
+		$startcol3 =3D $startcol2 + AdjuntoPeer::NUM_COLUMNS;
+
+		$c->addJoin(InformePeer::FK_ADJUNTO_ID, AdjuntoPeer::ID);
+
+
+		$rs =3D BasePeer::doSelect($c, $con);
+		$results =3D array();
+
+		while($rs->next()) {
+
+			$omClass =3D InformePeer::getOMClass();
+
+			$cls =3D Propel::import($omClass);
+			$obj1 =3D new $cls();
+			$obj1->hydrate($rs);
+
+			$omClass =3D AdjuntoPeer::getOMClass();
+
+
+			$cls =3D Propel::import($omClass);
+			$obj2  =3D new $cls();
+			$obj2->hydrate($rs, $startcol2);
+
+			$newObject =3D true;
+			for ($j=3D0, $resCount=3Dcount($results); $j < $resCount; $j++) {
+				$temp_obj1 =3D $results[$j];
+				$temp_obj2 =3D $temp_obj1->getAdjunto(); 				if ($temp_obj2->getPrim=
aryKey() =3D=3D=3D $obj2->getPrimaryKey()) {
+					$newObject =3D false;
+					$temp_obj2->addInforme($obj1);
+					break;
+				}
+			}
+
+			if ($newObject) {
+				$obj2->initInformes();
+				$obj2->addInforme($obj1);
+			}
+
+			$results[] =3D $obj1;
+		}
+		return $results;
+	}
+
+=09
+	public static function getTableMap()
+	{
+		return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TAB=
LE_NAME);
+	}
+
+=09
+	public static function getOMClass()
+	{
+		return InformePeer::CLASS_DEFAULT;
+	}
+
+=09
+	public static function doInsert($values, $con =3D null)
+	{
+		if ($con =3D=3D=3D null) {
+			$con =3D Propel::getConnection(self::DATABASE_NAME);
+		}
+
+		if ($values instanceof Criteria) {
+			$criteria =3D clone $values; 		} else {
+			$criteria =3D $values->buildCriteria(); 		}
+
+		$criteria->remove(InformePeer::ID);=20
+
+				$criteria->setDbName(self::DATABASE_NAME);
+
+		try {
+									$con->begin();
+			$pk =3D BasePeer::doInsert($criteria, $con);
+			$con->commit();
+		} catch(PropelException $e) {
+			$con->rollback();
+			throw $e;
+		}
+
+		return $pk;
+	}
+
+=09
+	public static function doUpdate($values, $con =3D null)
+	{
+		if ($con =3D=3D=3D null) {
+			$con =3D Propel::getConnection(self::DATABASE_NAME);
+		}
+
+		$selectCriteria =3D new Criteria(self::DATABASE_NAME);
+
+		if ($values instanceof Criteria) {
+			$criteria =3D clone $values;=20
+			$comparison =3D $criteria->getComparison(InformePeer::ID);
+			$selectCriteria->add(InformePeer::ID, $criteria->remove(InformePeer::=
ID), $comparison);
+
+		} else { 			$criteria =3D $values->buildCriteria(); 			$selectCriteria=
 =3D $values->buildPkeyCriteria(); 		}
+
+				$criteria->setDbName(self::DATABASE_NAME);
+
+		return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+	}
+
+=09
+	public static function doDeleteAll($con =3D null)
+	{
+		if ($con =3D=3D=3D null) {
+			$con =3D Propel::getConnection(self::DATABASE_NAME);
+		}
+		$affectedRows =3D 0; 		try {
+									$con->begin();
+			$affectedRows +=3D BasePeer::doDeleteAll(InformePeer::TABLE_NAME, $co=
n);
+			$con->commit();
+			return $affectedRows;
+		} catch (PropelException $e) {
+			$con->rollback();
+			throw $e;
+		}
+	}
+
+=09
+	 public static function doDelete($values, $con =3D null)
+	 {
+		if ($con =3D=3D=3D null) {
+			$con =3D Propel::getConnection(InformePeer::DATABASE_NAME);
+		}
+
+		if ($values instanceof Criteria) {
+			$criteria =3D clone $values; 		} elseif ($values instanceof Informe) =
{
+
+			$criteria =3D $values->buildPkeyCriteria();
+		} else {
+						$criteria =3D new Criteria(self::DATABASE_NAME);
+			$criteria->add(InformePeer::ID, (array) $values, Criteria::IN);
+		}
+
+				$criteria->setDbName(self::DATABASE_NAME);
+
+		$affectedRows =3D 0;=20
+		try {
+									$con->begin();
+		=09
+			$affectedRows +=3D BasePeer::doDelete($criteria, $con);
+			$con->commit();
+			return $affectedRows;
+		} catch (PropelException $e) {
+			$con->rollback();
+			throw $e;
+		}
+	}
+
+=09
+	public static function doValidate(Informe $obj, $cols =3D null)
+	{
+		$columns =3D array();
+
+		if ($cols) {
+			$dbMap =3D Propel::getDatabaseMap(InformePeer::DATABASE_NAME);
+			$tableMap =3D $dbMap->getTable(InformePeer::TABLE_NAME);
+
+			if (! is_array($cols)) {
+				$cols =3D array($cols);
+			}
+
+			foreach($cols as $colName) {
+				if ($tableMap->containsColumn($colName)) {
+					$get =3D 'get' . $tableMap->getColumn($colName)->getPhpName();
+					$columns[$colName] =3D $obj->$get();
+				}
+			}
+		} else {
+
+		}
+
+		$res =3D  BasePeer::doValidate(InformePeer::DATABASE_NAME, InformePeer=
::TABLE_NAME, $columns);
+    if ($res !=3D=3D true) {
+        $request =3D sfContext::getInstance()->getRequest();
+        foreach ($res as $failed) {
+            $col =3D InformePeer::translateFieldname($failed->getColumn(=
), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
+            $request->setError($col, $failed->getMessage());
+        }
+    }
+
+    return $res;
+	}
+
+=09
+	public static function retrieveByPK($pk, $con =3D null)
+	{
+		if ($con =3D=3D=3D null) {
+			$con =3D Propel::getConnection(self::DATABASE_NAME);
+		}
+
+		$criteria =3D new Criteria(InformePeer::DATABASE_NAME);
+
+		$criteria->add(InformePeer::ID, $pk);
+
+
+		$v =3D InformePeer::doSelect($criteria, $con);
+
+		return !empty($v) > 0 ? $v[0] : null;
+	}
+
+=09
+	public static function retrieveByPKs($pks, $con =3D null)
+	{
+		if ($con =3D=3D=3D null) {
+			$con =3D Propel::getConnection(self::DATABASE_NAME);
+		}
+
+		$objs =3D null;
+		if (empty($pks)) {
+			$objs =3D array();
+		} else {
+			$criteria =3D new Criteria();
+			$criteria->add(InformePeer::ID, $pks, Criteria::IN);
+			$objs =3D InformePeer::doSelect($criteria, $con);
+		}
+		return $objs;
+	}
+
+}=20
+if (Propel::isInit()) {
+			try {
+		BaseInformePeer::getMapBuilder();
+	} catch (Exception $e) {
+		Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::=
LOG_ERR);
+	}
+} else {
+			require_once 'lib/model/map/InformeMapBuilder.php';
+	Propel::registerMapBuilder('lib.model.map.InformeMapBuilder');
+}


Property changes on: prosistem/alba/trunk/alba/lib/model/om/BaseInformePe=
er.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/lib/model/om/BaseTipoinforme.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/lib/model/om/BaseTipoinforme.php	2007-10-10=
 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/lib/model/om/BaseTipoinforme.php	2007-10-10=
 20:53:17 UTC (rev 5218)
@@ -0,0 +1,493 @@
+<?php
+
+
+abstract class BaseTipoinforme extends BaseObject  implements Persistent=
 {
+
+
+=09
+	protected static $peer;
+
+
+=09
+	protected $id;
+
+
+=09
+	protected $nombre;
+
+
+=09
+	protected $descripcion;
+
+=09
+	protected $collInformes;
+
+=09
+	protected $lastInformeCriteria =3D null;
+
+=09
+	protected $alreadyInSave =3D false;
+
+=09
+	protected $alreadyInValidation =3D false;
+
+=09
+	public function getId()
+	{
+
+		return $this->id;
+	}
+
+=09
+	public function getNombre()
+	{
+
+		return $this->nombre;
+	}
+
+=09
+	public function getDescripcion()
+	{
+
+		return $this->descripcion;
+	}
+
+=09
+	public function setId($v)
+	{
+
+						if ($v !=3D=3D null && !is_int($v) && is_numeric($v)) {
+			$v =3D (int) $v;
+		}
+
+		if ($this->id !=3D=3D $v) {
+			$this->id =3D $v;
+			$this->modifiedColumns[] =3D TipoinformePeer::ID;
+		}
+
+	}=20
+=09
+	public function setNombre($v)
+	{
+
+						if ($v !=3D=3D null && !is_string($v)) {
+			$v =3D (string) $v;=20
+		}
+
+		if ($this->nombre !=3D=3D $v) {
+			$this->nombre =3D $v;
+			$this->modifiedColumns[] =3D TipoinformePeer::NOMBRE;
+		}
+
+	}=20
+=09
+	public function setDescripcion($v)
+	{
+
+						if ($v !=3D=3D null && !is_string($v)) {
+			$v =3D (string) $v;=20
+		}
+
+		if ($this->descripcion !=3D=3D $v) {
+			$this->descripcion =3D $v;
+			$this->modifiedColumns[] =3D TipoinformePeer::DESCRIPCION;
+		}
+
+	}=20
+=09
+	public function hydrate(ResultSet $rs, $startcol =3D 1)
+	{
+		try {
+
+			$this->id =3D $rs->getInt($startcol + 0);
+
+			$this->nombre =3D $rs->getString($startcol + 1);
+
+			$this->descripcion =3D $rs->getString($startcol + 2);
+
+			$this->resetModified();
+
+			$this->setNew(false);
+
+						return $startcol + 3;=20
+		} catch (Exception $e) {
+			throw new PropelException("Error populating Tipoinforme object", $e);
+		}
+	}
+
+=09
+	public function delete($con =3D null)
+	{
+		if ($this->isDeleted()) {
+			throw new PropelException("This object has already been deleted.");
+		}
+
+		if ($con =3D=3D=3D null) {
+			$con =3D Propel::getConnection(TipoinformePeer::DATABASE_NAME);
+		}
+
+		try {
+			$con->begin();
+			TipoinformePeer::doDelete($this, $con);
+			$this->setDeleted(true);
+			$con->commit();
+		} catch (PropelException $e) {
+			$con->rollback();
+			throw $e;
+		}
+	}
+
+=09
+	public function save($con =3D null)
+	{
+		if ($this->isDeleted()) {
+			throw new PropelException("You cannot save an object that has been de=
leted.");
+		}
+
+		if ($con =3D=3D=3D null) {
+			$con =3D Propel::getConnection(TipoinformePeer::DATABASE_NAME);
+		}
+
+		try {
+			$con->begin();
+			$affectedRows =3D $this->doSave($con);
+			$con->commit();
+			return $affectedRows;
+		} catch (PropelException $e) {
+			$con->rollback();
+			throw $e;
+		}
+	}
+
+=09
+	protected function doSave($con)
+	{
+		$affectedRows =3D 0; 		if (!$this->alreadyInSave) {
+			$this->alreadyInSave =3D true;
+
+
+						if ($this->isModified()) {
+				if ($this->isNew()) {
+					$pk =3D TipoinformePeer::doInsert($this, $con);
+					$affectedRows +=3D 1; 										 										=20
+					$this->setId($pk); =20
+					$this->setNew(false);
+				} else {
+					$affectedRows +=3D TipoinformePeer::doUpdate($this, $con);
+				}
+				$this->resetModified(); 			}
+
+			if ($this->collInformes !=3D=3D null) {
+				foreach($this->collInformes as $referrerFK) {
+					if (!$referrerFK->isDeleted()) {
+						$affectedRows +=3D $referrerFK->save($con);
+					}
+				}
+			}
+
+			$this->alreadyInSave =3D false;
+		}
+		return $affectedRows;
+	}=20
+=09
+	protected $validationFailures =3D array();
+
+=09
+	public function getValidationFailures()
+	{
+		return $this->validationFailures;
+	}
+
+=09
+	public function validate($columns =3D null)
+	{
+		$res =3D $this->doValidate($columns);
+		if ($res =3D=3D=3D true) {
+			$this->validationFailures =3D array();
+			return true;
+		} else {
+			$this->validationFailures =3D $res;
+			return false;
+		}
+	}
+
+=09
+	protected function doValidate($columns =3D null)
+	{
+		if (!$this->alreadyInValidation) {
+			$this->alreadyInValidation =3D true;
+			$retval =3D null;
+
+			$failureMap =3D array();
+
+
+			if (($retval =3D TipoinformePeer::doValidate($this, $columns)) !=3D=3D=
 true) {
+				$failureMap =3D array_merge($failureMap, $retval);
+			}
+
+
+				if ($this->collInformes !=3D=3D null) {
+					foreach($this->collInformes as $referrerFK) {
+						if (!$referrerFK->validate($columns)) {
+							$failureMap =3D array_merge($failureMap, $referrerFK->getValidati=
onFailures());
+						}
+					}
+				}
+
+
+			$this->alreadyInValidation =3D false;
+		}
+
+		return (!empty($failureMap) ? $failureMap : true);
+	}
+
+=09
+	public function getByName($name, $type =3D BasePeer::TYPE_PHPNAME)
+	{
+		$pos =3D TipoinformePeer::translateFieldName($name, $type, BasePeer::T=
YPE_NUM);
+		return $this->getByPosition($pos);
+	}
+
+=09
+	public function getByPosition($pos)
+	{
+		switch($pos) {
+			case 0:
+				return $this->getId();
+				break;
+			case 1:
+				return $this->getNombre();
+				break;
+			case 2:
+				return $this->getDescripcion();
+				break;
+			default:
+				return null;
+				break;
+		} 	}
+
+=09
+	public function toArray($keyType =3D BasePeer::TYPE_PHPNAME)
+	{
+		$keys =3D TipoinformePeer::getFieldNames($keyType);
+		$result =3D array(
+			$keys[0] =3D> $this->getId(),
+			$keys[1] =3D> $this->getNombre(),
+			$keys[2] =3D> $this->getDescripcion(),
+		);
+		return $result;
+	}
+
+=09
+	public function setByName($name, $value, $type =3D BasePeer::TYPE_PHPNA=
ME)
+	{
+		$pos =3D TipoinformePeer::translateFieldName($name, $type, BasePeer::T=
YPE_NUM);
+		return $this->setByPosition($pos, $value);
+	}
+
+=09
+	public function setByPosition($pos, $value)
+	{
+		switch($pos) {
+			case 0:
+				$this->setId($value);
+				break;
+			case 1:
+				$this->setNombre($value);
+				break;
+			case 2:
+				$this->setDescripcion($value);
+				break;
+		} 	}
+
+=09
+	public function fromArray($arr, $keyType =3D BasePeer::TYPE_PHPNAME)
+	{
+		$keys =3D TipoinformePeer::getFieldNames($keyType);
+
+		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
+		if (array_key_exists($keys[1], $arr)) $this->setNombre($arr[$keys[1]])=
;
+		if (array_key_exists($keys[2], $arr)) $this->setDescripcion($arr[$keys=
[2]]);
+	}
+
+=09
+	public function buildCriteria()
+	{
+		$criteria =3D new Criteria(TipoinformePeer::DATABASE_NAME);
+
+		if ($this->isColumnModified(TipoinformePeer::ID)) $criteria->add(Tipoi=
nformePeer::ID, $this->id);
+		if ($this->isColumnModified(TipoinformePeer::NOMBRE)) $criteria->add(T=
ipoinformePeer::NOMBRE, $this->nombre);
+		if ($this->isColumnModified(TipoinformePeer::DESCRIPCION)) $criteria->=
add(TipoinformePeer::DESCRIPCION, $this->descripcion);
+
+		return $criteria;
+	}
+
+=09
+	public function buildPkeyCriteria()
+	{
+		$criteria =3D new Criteria(TipoinformePeer::DATABASE_NAME);
+
+		$criteria->add(TipoinformePeer::ID, $this->id);
+
+		return $criteria;
+	}
+
+=09
+	public function getPrimaryKey()
+	{
+		return $this->getId();
+	}
+
+=09
+	public function setPrimaryKey($key)
+	{
+		$this->setId($key);
+	}
+
+=09
+	public function copyInto($copyObj, $deepCopy =3D false)
+	{
+
+		$copyObj->setNombre($this->nombre);
+
+		$copyObj->setDescripcion($this->descripcion);
+
+
+		if ($deepCopy) {
+									$copyObj->setNew(false);
+
+			foreach($this->getInformes() as $relObj) {
+				$copyObj->addInforme($relObj->copy($deepCopy));
+			}
+
+		}=20
+
+		$copyObj->setNew(true);
+
+		$copyObj->setId(NULL);=20
+	}
+
+=09
+	public function copy($deepCopy =3D false)
+	{
+				$clazz =3D get_class($this);
+		$copyObj =3D new $clazz();
+		$this->copyInto($copyObj, $deepCopy);
+		return $copyObj;
+	}
+
+=09
+	public function getPeer()
+	{
+		if (self::$peer =3D=3D=3D null) {
+			self::$peer =3D new TipoinformePeer();
+		}
+		return self::$peer;
+	}
+
+=09
+	public function initInformes()
+	{
+		if ($this->collInformes =3D=3D=3D null) {
+			$this->collInformes =3D array();
+		}
+	}
+
+=09
+	public function getInformes($criteria =3D null, $con =3D null)
+	{
+				include_once 'lib/model/om/BaseInformePeer.php';
+		if ($criteria =3D=3D=3D null) {
+			$criteria =3D new Criteria();
+		}
+		elseif ($criteria instanceof Criteria)
+		{
+			$criteria =3D clone $criteria;
+		}
+
+		if ($this->collInformes =3D=3D=3D null) {
+			if ($this->isNew()) {
+			   $this->collInformes =3D array();
+			} else {
+
+				$criteria->add(InformePeer::FK_TIPOINFORME_ID, $this->getId());
+
+				InformePeer::addSelectColumns($criteria);
+				$this->collInformes =3D InformePeer::doSelect($criteria, $con);
+			}
+		} else {
+						if (!$this->isNew()) {
+											=09
+
+				$criteria->add(InformePeer::FK_TIPOINFORME_ID, $this->getId());
+
+				InformePeer::addSelectColumns($criteria);
+				if (!isset($this->lastInformeCriteria) || !$this->lastInformeCriteri=
a->equals($criteria)) {
+					$this->collInformes =3D InformePeer::doSelect($criteria, $con);
+				}
+			}
+		}
+		$this->lastInformeCriteria =3D $criteria;
+		return $this->collInformes;
+	}
+
+=09
+	public function countInformes($criteria =3D null, $distinct =3D false, =
$con =3D null)
+	{
+				include_once 'lib/model/om/BaseInformePeer.php';
+		if ($criteria =3D=3D=3D null) {
+			$criteria =3D new Criteria();
+		}
+		elseif ($criteria instanceof Criteria)
+		{
+			$criteria =3D clone $criteria;
+		}
+
+		$criteria->add(InformePeer::FK_TIPOINFORME_ID, $this->getId());
+
+		return InformePeer::doCount($criteria, $distinct, $con);
+	}
+
+=09
+	public function addInforme(Informe $l)
+	{
+		$this->collInformes[] =3D $l;
+		$l->setTipoinforme($this);
+	}
+
+
+=09
+	public function getInformesJoinAdjunto($criteria =3D null, $con =3D nul=
l)
+	{
+				include_once 'lib/model/om/BaseInformePeer.php';
+		if ($criteria =3D=3D=3D null) {
+			$criteria =3D new Criteria();
+		}
+		elseif ($criteria instanceof Criteria)
+		{
+			$criteria =3D clone $criteria;
+		}
+
+		if ($this->collInformes =3D=3D=3D null) {
+			if ($this->isNew()) {
+				$this->collInformes =3D array();
+			} else {
+
+				$criteria->add(InformePeer::FK_TIPOINFORME_ID, $this->getId());
+
+				$this->collInformes =3D InformePeer::doSelectJoinAdjunto($criteria, =
$con);
+			}
+		} else {
+								=09
+			$criteria->add(InformePeer::FK_TIPOINFORME_ID, $this->getId());
+
+			if (!isset($this->lastInformeCriteria) || !$this->lastInformeCriteria=
->equals($criteria)) {
+				$this->collInformes =3D InformePeer::doSelectJoinAdjunto($criteria, =
$con);
+			}
+		}
+		$this->lastInformeCriteria =3D $criteria;
+
+		return $this->collInformes;
+	}
+
+}=20
\ No newline at end of file


Property changes on: prosistem/alba/trunk/alba/lib/model/om/BaseTipoinfor=
me.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"

Added: prosistem/alba/trunk/alba/lib/model/om/BaseTipoinformePeer.php
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- prosistem/alba/trunk/alba/lib/model/om/BaseTipoinformePeer.php	2007-1=
0-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/lib/model/om/BaseTipoinformePeer.php	2007-1=
0-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,373 @@
+<?php
+
+
+abstract class BaseTipoinformePeer {
+
+=09
+	const DATABASE_NAME =3D 'alba';
+
+=09
+	const TABLE_NAME =3D 'tipoinforme';
+
+=09
+	const CLASS_DEFAULT =3D 'lib.model.Tipoinforme';
+
+=09
+	const NUM_COLUMNS =3D 3;
+
+=09
+	const NUM_LAZY_LOAD_COLUMNS =3D 0;
+
+
+=09
+	const ID =3D 'tipoinforme.ID';
+
+=09
+	const NOMBRE =3D 'tipoinforme.NOMBRE';
+
+=09
+	const DESCRIPCION =3D 'tipoinforme.DESCRIPCION';
+
+=09
+	private static $phpNameMap =3D null;
+
+
+=09
+	private static $fieldNames =3D array (
+		BasePeer::TYPE_PHPNAME =3D> array ('Id', 'Nombre', 'Descripcion', ),
+		BasePeer::TYPE_COLNAME =3D> array (TipoinformePeer::ID, TipoinformePee=
r::NOMBRE, TipoinformePeer::DESCRIPCION, ),
+		BasePeer::TYPE_FIELDNAME =3D> array ('id', 'nombre', 'descripcion', ),
+		BasePeer::TYPE_NUM =3D> array (0, 1, 2, )
+	);
+
+=09
+	private static $fieldKeys =3D array (
+		BasePeer::TYPE_PHPNAME =3D> array ('Id' =3D> 0, 'Nombre' =3D> 1, 'Desc=
ripcion' =3D> 2, ),
+		BasePeer::TYPE_COLNAME =3D> array (TipoinformePeer::ID =3D> 0, Tipoinf=
ormePeer::NOMBRE =3D> 1, TipoinformePeer::DESCRIPCION =3D> 2, ),
+		BasePeer::TYPE_FIELDNAME =3D> array ('id' =3D> 0, 'nombre' =3D> 1, 'de=
scripcion' =3D> 2, ),
+		BasePeer::TYPE_NUM =3D> array (0, 1, 2, )
+	);
+
+=09
+	public static function getMapBuilder()
+	{
+		include_once 'lib/model/map/TipoinformeMapBuilder.php';
+		return BasePeer::getMapBuilder('lib.model.map.TipoinformeMapBuilder');
+	}
+=09
+	public static function getPhpNameMap()
+	{
+		if (self::$phpNameMap =3D=3D=3D null) {
+			$map =3D TipoinformePeer::getTableMap();
+			$columns =3D $map->getColumns();
+			$nameMap =3D array();
+			foreach ($columns as $column) {
+				$nameMap[$column->getPhpName()] =3D $column->getColumnName();
+			}
+			self::$phpNameMap =3D $nameMap;
+		}
+		return self::$phpNameMap;
+	}
+=09
+	static public function translateFieldName($name, $fromType, $toType)
+	{
+		$toNames =3D self::getFieldNames($toType);
+		$key =3D isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[=
$fromType][$name] : null;
+		if ($key =3D=3D=3D null) {
+			throw new PropelException("'$name' could not be found in the field na=
mes of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromTyp=
e], true));
+		}
+		return $toNames[$key];
+	}
+
+=09
+
+	static public function getFieldNames($type =3D BasePeer::TYPE_PHPNAME)
+	{
+		if (!array_key_exists($type, self::$fieldNames)) {
+			throw new PropelException('Method getFieldNames() expects the paramet=
er $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYP=
E_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
+		}
+		return self::$fieldNames[$type];
+	}
+
+=09
+	public static function alias($alias, $column)
+	{
+		return str_replace(TipoinformePeer::TABLE_NAME.'.', $alias.'.', $colum=
n);
+	}
+
+=09
+	public static function addSelectColumns(Criteria $criteria)
+	{
+
+		$criteria->addSelectColumn(TipoinformePeer::ID);
+
+		$criteria->addSelectColumn(TipoinformePeer::NOMBRE);
+
+		$criteria->addSelectColumn(TipoinformePeer::DESCRIPCION);
+
+	}
+
+	const COUNT =3D 'COUNT(tipoinforme.ID)';
+	const COUNT_DISTINCT =3D 'COUNT(DISTINCT tipoinforme.ID)';
+
+=09
+	public static function doCount(Criteria $criteria, $distinct =3D false,=
 $con =3D null)
+	{
+				$criteria =3D clone $criteria;
+
+				$criteria->clearSelectColumns()->clearOrderByColumns();
+		if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModi=
fiers())) {
+			$criteria->addSelectColumn(TipoinformePeer::COUNT_DISTINCT);
+		} else {
+			$criteria->addSelectColumn(TipoinformePeer::COUNT);
+		}
+
+				foreach($criteria->getGroupByColumns() as $column)
+		{
+			$criteria->addSelectColumn($column);
+		}
+
+		$rs =3D TipoinformePeer::doSelectRS($criteria, $con);
+		if ($rs->next()) {
+			return $rs->getInt(1);
+		} else {
+						return 0;
+		}
+	}
+=09
+	public static function doSelectOne(Criteria $criteria, $con =3D null)
+	{
+		$critcopy =3D clone $criteria;
+		$critcopy->setLimit(1);
+		$objects =3D TipoinformePeer::doSelect($critcopy, $con);
+		if ($objects) {
+			return $objects[0];
+		}
+		return null;
+	}
+=09
+	public static function doSelect(Criteria $criteria, $con =3D null)
+	{
+		return TipoinformePeer::populateObjects(TipoinformePeer::doSelectRS($c=
riteria, $con));
+	}
+=09
+	public static function doSelectRS(Criteria $criteria, $con =3D null)
+	{
+		if ($con =3D=3D=3D null) {
+			$con =3D Propel::getConnection(self::DATABASE_NAME);
+		}
+
+		if (!$criteria->getSelectColumns()) {
+			$criteria =3D clone $criteria;
+			TipoinformePeer::addSelectColumns($criteria);
+		}
+
+				$criteria->setDbName(self::DATABASE_NAME);
+
+						return BasePeer::doSelect($criteria, $con);
+	}
+=09
+	public static function populateObjects(ResultSet $rs)
+	{
+		$results =3D array();
+=09
+				$cls =3D TipoinformePeer::getOMClass();
+		$cls =3D Propel::import($cls);
+				while($rs->next()) {
+	=09
+			$obj =3D new $cls();
+			$obj->hydrate($rs);
+			$results[] =3D $obj;
+		=09
+		}
+		return $results;
+	}
+=09
+	public static function getTableMap()
+	{
+		return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TAB=
LE_NAME);
+	}
+
+=09
+	public static function getOMClass()
+	{
+		return TipoinformePeer::CLASS_DEFAULT;
+	}
+
+=09
+	public static function doInsert($values, $con =3D null)
+	{
+		if ($con =3D=3D=3D null) {
+			$con =3D Propel::getConnection(self::DATABASE_NAME);
+		}
+
+		if ($values instanceof Criteria) {
+			$criteria =3D clone $values; 		} else {
+			$criteria =3D $values->buildCriteria(); 		}
+
+		$criteria->remove(TipoinformePeer::ID);=20
+
+				$criteria->setDbName(self::DATABASE_NAME);
+
+		try {
+									$con->begin();
+			$pk =3D BasePeer::doInsert($criteria, $con);
+			$con->commit();
+		} catch(PropelException $e) {
+			$con->rollback();
+			throw $e;
+		}
+
+		return $pk;
+	}
+
+=09
+	public static function doUpdate($values, $con =3D null)
+	{
+		if ($con =3D=3D=3D null) {
+			$con =3D Propel::getConnection(self::DATABASE_NAME);
+		}
+
+		$selectCriteria =3D new Criteria(self::DATABASE_NAME);
+
+		if ($values instanceof Criteria) {
+			$criteria =3D clone $values;=20
+			$comparison =3D $criteria->getComparison(TipoinformePeer::ID);
+			$selectCriteria->add(TipoinformePeer::ID, $criteria->remove(Tipoinfor=
mePeer::ID), $comparison);
+
+		} else { 			$criteria =3D $values->buildCriteria(); 			$selectCriteria=
 =3D $values->buildPkeyCriteria(); 		}
+
+				$criteria->setDbName(self::DATABASE_NAME);
+
+		return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+	}
+
+=09
+	public static function doDeleteAll($con =3D null)
+	{
+		if ($con =3D=3D=3D null) {
+			$con =3D Propel::getConnection(self::DATABASE_NAME);
+		}
+		$affectedRows =3D 0; 		try {
+									$con->begin();
+			$affectedRows +=3D BasePeer::doDeleteAll(TipoinformePeer::TABLE_NAME,=
 $con);
+			$con->commit();
+			return $affectedRows;
+		} catch (PropelException $e) {
+			$con->rollback();
+			throw $e;
+		}
+	}
+
+=09
+	 public static function doDelete($values, $con =3D null)
+	 {
+		if ($con =3D=3D=3D null) {
+			$con =3D Propel::getConnection(TipoinformePeer::DATABASE_NAME);
+		}
+
+		if ($values instanceof Criteria) {
+			$criteria =3D clone $values; 		} elseif ($values instanceof Tipoinfor=
me) {
+
+			$criteria =3D $values->buildPkeyCriteria();
+		} else {
+						$criteria =3D new Criteria(self::DATABASE_NAME);
+			$criteria->add(TipoinformePeer::ID, (array) $values, Criteria::IN);
+		}
+
+				$criteria->setDbName(self::DATABASE_NAME);
+
+		$affectedRows =3D 0;=20
+		try {
+									$con->begin();
+		=09
+			$affectedRows +=3D BasePeer::doDelete($criteria, $con);
+			$con->commit();
+			return $affectedRows;
+		} catch (PropelException $e) {
+			$con->rollback();
+			throw $e;
+		}
+	}
+
+=09
+	public static function doValidate(Tipoinforme $obj, $cols =3D null)
+	{
+		$columns =3D array();
+
+		if ($cols) {
+			$dbMap =3D Propel::getDatabaseMap(TipoinformePeer::DATABASE_NAME);
+			$tableMap =3D $dbMap->getTable(TipoinformePeer::TABLE_NAME);
+
+			if (! is_array($cols)) {
+				$cols =3D array($cols);
+			}
+
+			foreach($cols as $colName) {
+				if ($tableMap->containsColumn($colName)) {
+					$get =3D 'get' . $tableMap->getColumn($colName)->getPhpName();
+					$columns[$colName] =3D $obj->$get();
+				}
+			}
+		} else {
+
+		}
+
+		$res =3D  BasePeer::doValidate(TipoinformePeer::DATABASE_NAME, Tipoinf=
ormePeer::TABLE_NAME, $columns);
+    if ($res !=3D=3D true) {
+        $request =3D sfContext::getInstance()->getRequest();
+        foreach ($res as $failed) {
+            $col =3D TipoinformePeer::translateFieldname($failed->getCol=
umn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
+            $request->setError($col, $failed->getMessage());
+        }
+    }
+
+    return $res;
+	}
+
+=09
+	public static function retrieveByPK($pk, $con =3D null)
+	{
+		if ($con =3D=3D=3D null) {
+			$con =3D Propel::getConnection(self::DATABASE_NAME);
+		}
+
+		$criteria =3D new Criteria(TipoinformePeer::DATABASE_NAME);
+
+		$criteria->add(TipoinformePeer::ID, $pk);
+
+
+		$v =3D TipoinformePeer::doSelect($criteria, $con);
+
+		return !empty($v) > 0 ? $v[0] : null;
+	}
+
+=09
+	public static function retrieveByPKs($pks, $con =3D null)
+	{
+		if ($con =3D=3D=3D null) {
+			$con =3D Propel::getConnection(self::DATABASE_NAME);
+		}
+
+		$objs =3D null;
+		if (empty($pks)) {
+			$objs =3D array();
+		} else {
+			$criteria =3D new Criteria();
+			$criteria->add(TipoinformePeer::ID, $pks, Criteria::IN);
+			$objs =3D TipoinformePeer::doSelect($criteria, $con);
+		}
+		return $objs;
+	}
+
+}=20
+if (Propel::isInit()) {
+			try {
+		BaseTipoinformePeer::getMapBuilder();
+	} catch (Exception $e) {
+		Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::=
LOG_ERR);
+	}
+} else {
+			require_once 'lib/model/map/TipoinformeMapBuilder.php';
+	Propel::registerMapBuilder('lib.model.map.TipoinformeMapBuilder');
+}


Property changes on: prosistem/alba/trunk/alba/lib/model/om/BaseTipoinfor=
mePeer.php
___________________________________________________________________
Name: svn:keywords
   + "Id Author URL Date Rev"




Más información sobre la lista de distribución Alba-desarrollo