Alba-desarrollo
Threads by month
- ----- 2026 -----
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
October 2007
- 7 participants
- 114 discussions
Buenas gente,
Hoy miércoles a las 23:56H GTM-3, terminamos unas actualizaciones importantes
que teníamos pendiente en el servidor de desarrollo.
Si bien todas las comprobaciones salieron bien, siempre puede quedar algo.
Los servicios afectados son:
- Repositorio SVN
- Trac (Tickets, Wiki, etc)
Si encuentran algún problema, nos envían un mail a soporte(a)pressenter.com.ar.
Gracias!
--
Dock Sud BBS
http://www.docksud.com.ar
telnet://bbs.docksud.com.ar
1
0
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
by commits@pressenter.com.ar 10 Oct '07
by commits@pressenter.com.ar 10 Oct '07
10 Oct '07
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_class.php
prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbs_class_php5.php
prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbsooo_class.php
prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_edit_actions.php
prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_edit_form.php
prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_edit_messages.php
prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_list.php
prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_list_actions.php
prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_list_messages.php
prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_list_td_actions.php
prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_list_td_tabular.php
prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_list_th_tabular.php
prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/busquedaAlumnosSuccess.php
prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/editSuccess.php
prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/listSuccess.php
prosistem/alba/trunk/alba/apps/principal/modules/informes/validate/edit.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/actions.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
Modified: prosistem/alba/trunk/alba/apps/principal/modules/informes/actions/actions.class.php
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/actions/actions.class.php 2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/actions/actions.class.php 2007-10-10 20:53:17 UTC (rev 5218)
@@ -33,12 +33,373 @@
class InformesActions extends sfActions
{
+ public function executeIndex()
+ {
+ return $this->forward('informes', 'list');
+ }
+
+ public function executeList()
+ {
+ $this->processSort();
+
+ $this->processFilters();
+
+ $this->filters = $this->getUser()->getAttributeHolder()->getAll('sf_admin/informes/filters');
+
+ // pager
+ $this->pager = new sfPropelPager('Informe', 10);
+ $c = 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 = $this->getInformeOrCreate();
+
+ if ($this->getRequest()->getMethod() == sfRequest::POST)
+ {
+ $this->updateInformeFromRequest();
+
+ if($this->getRequest()->getFileName('file')) {
+ $mimetype = $this->getRequest()->getFileType('file');
+ $ext = substr($this->getRequest()->getFileName('file'),strrpos($this->getRequest()->getFileName('file'),'.'));
+ $realFileName = $this->getRequest()->getFileName('file');
+ $uniqueFileName = uniqid(rand()) . $ext;
+ $this->getRequest()->moveFile('file', sfConfig::get('sf_upload_dir').'/'.$uniqueFileName);
+ $adjunto = new Adjunto();
+ $adjunto->setFecha(date('Y-m-d'));
+ $adjunto->setNombreArchivo($realFileName);
+ $adjunto->setTipoArchivo($mimetype);
+ $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='.$this->informe->getId());
+ }
+ }
+ else
+ {
+ $this->labels = $this->getLabels();
+ }
+ }
+
+ public function executeDelete()
+ {
+ $this->informe = InformePeer::retrieveByPk($this->getRequestParameter('id'));
+ $this->forward404Unless($this->informe);
+
+ try
+ {
+ unlink(sfConfig::get('sf_upload_dir')."/".$this->informe->getAdjunto()->getRuta());
+ $adjunto_id = $this->informe->getFkAdjuntoId();
+ $this->deleteInforme($this->informe);
+ $adjunto = AdjuntoPeer::retrieveByPk($adjunto_id);
+ $adjunto->delete();
+ }
+ catch (PropelException $e)
+ {
+ $this->getRequest()->setError('delete', 'Could not delete the selected 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 = $this->getInformeOrCreate();
+ $this->updateInformeFromRequest();
+
+ $this->labels = $this->getLabels();
+
+ return sfView::SUCCESS;
+ }
+
+ protected function saveInforme($informe)
+ {
+ $informe->save();
+
+ }
+
+ protected function deleteInforme($informe)
+ {
+ $informe->delete();
+ }
+
+ protected function updateInformeFromRequest()
+ {
+ $informe = $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['listado'] : 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 = 'id')
+ {
+ if (!$this->getRequestParameter($id))
+ {
+ $informe = new Informe();
+ }
+ else
+ {
+ $informe = InformePeer::retrieveByPk($this->getRequestParameter($id));
+
+ $this->forward404Unless($informe);
+ }
+
+ return $informe;
+ }
+
+ protected function processFilters()
+ {
+ if ($this->getRequest()->hasParameter('filter'))
+ {
+ $filters = $this->getRequestParameter('filters');
+
+ $this->getUser()->getAttributeHolder()->removeNamespace('sf_admin/informes/filters');
+ $this->getUser()->getAttributeHolder()->add($filters, 'sf_admin/informes/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 = $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'] !== '')
+ {
+ $c->add(AlumnoPeer::NOMBRE_APELLIDO, $this->filters['nombre_apellido']);
+ }
+ if (isset($this->filters['division_is_empty']))
+ {
+ $criterion = $c->getNewCriterion(AlumnoPeer::DIVISION, '');
+ $criterion->addOr($c->getNewCriterion(AlumnoPeer::DIVISION, null, Criteria::ISNULL));
+ $c->add($criterion);
+ }
+ else if (isset($this->filters['division']) && $this->filters['division'] !== '')
+ {
+ $c->add(AlumnoPeer::DIVISION, $this->filters['division']);
+ }
+ if (isset($this->filters['nro_documento_is_empty']))
+ {
+ $criterion = $c->getNewCriterion(AlumnoPeer::NRO_DOCUMENTO, '');
+ $criterion->addOr($c->getNewCriterion(AlumnoPeer::NRO_DOCUMENTO, null, Criteria::ISNULL));
+ $c->add($criterion);
+ }
+ else if (isset($this->filters['nro_documento']) && $this->filters['nro_documento'] !== '')
+ {
+ $c->add(AlumnoPeer::NRO_DOCUMENTO, strtr($this->filters['nro_documento'], '*', '%'), Criteria::LIKE);
+ }
+ }
+*/
+ protected function addSortCriteria($c)
+ {
+ if ($sort_column = $this->getUser()->getAttribute('sort', null, 'sf_admin/informes/sort'))
+ {
+ $sort_column = InformePeer::translateFieldName($sort_column, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_COLNAME);
+ if ($this->getUser()->getAttribute('type', null, 'sf_admin/informes/sort') == 'asc')
+ {
+ $c->addAscendingOrderByColumn($sort_column);
+ }
+ else
+ {
+ $c->addDescendingOrderByColumn($sort_column);
+ }
+ }
+ }
+
+ protected function getLabels()
+ {
+ return array(
+ 'informe{descripcion}' => 'Descripción:',
+ 'informe{nombre}' => 'Nombre:',
+ 'informe{listado}' => '¿Es un Listado?:',
+ 'informe{fk_tipoinforme_id}' => 'Tipo de Informe:',
+ 'informe{fk_adjunto_id}' => 'Plantilla del informe:',
+ 'informe{variables}' => 'Variables:',
+ 'file' => 'Plantilla del informe :',
+ );
+ }
+
+ public function executeBorrarAdjunto() {
+ $id = $this->getRequestParameter('id');
+ $this->forward404Unless($id);
+ $informe = InformePeer::retrieveByPk($id);
+ $informe->setFkAdjuntoId();
+ $informe->save();
+ $adjunto = AdjuntoPeer::retrieveByPk($informe->getFkAdjuntoId());
+ unlink(sfConfig::get('sf_upload_dir')."/".$adjunto->getRuta());
+ $adjunto->delete();
+ return $this->redirect("informes?action=edit&id=".$id);
+ }
+
+
+ public function executeMostrar() {
+ $informe = InformePeer::retrieveByPk($this->getRequestParameter('id'));
+ $this->forward404Unless($informe);
+
+ $establecimiento_id = $this->getUser()->getAttribute('fk_establecimiento_id');
+
+ $aAlumno = $this->_getTodosLosAlumnos($establecimiento_id);
+
+ $datos = $aAlumno[0];
+ $this->reporteTBSOO($informe->getAdjunto()->getRuta(), $informe->getTipoInforme()->getNombre(), $datos);
+
+ return sfview::NONE;
+ }
+
+
+
+ public function executeBusquedaAlumnos() {
+ $informe = InformePeer::retrieveByPk($this->getRequestParameter('id'));
+ $this->forward404Unless($informe);
+
+ // inicializando variables
+ $optionsDivision = array();
+ $aAlumno = array();
+
+ // tomando los datos del formulario
+ $division_id = $this->getRequestParameter('division_id');
+ $txt = $this->getRequestParameter('txt');
+
+ // llenando el combo de division segun establecimiento
+ $establecimiento_id = $this->getUser()->getAttribute('fk_establecimiento_id');
+ $optionsDivision = $this->_getDivisiones($establecimiento_id);
+
+ if ($this->getRequest()->getMethod() == sfRequest::POST) {
+ $aAlumno = $this->_getAlumnosPorDivision($division_id, $txt); // buscando alumnos
+ }
+
+ // asignando variables para ser usadas en el template
+ $this->optionsDivision = $optionsDivision;
+ $this->division_id = $division_id;
+ $this->txt = $txt;
+ $this->aAlumno = $aAlumno;
+ $this->titulo = $informe->getNombre();
+ $this->is = $informe=
+ }
+
+
+
+
+ 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 = new clsTinyButStrongOOo;
+ $OOo->noErr = 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
*
*/
-
-
private function _getDivisiones($establecimiento_id) {
$optionsDivision = array();
@@ -450,4 +811,4 @@
}
-?>
+?>
\ No newline at end of file
Modified: prosistem/alba/trunk/alba/apps/principal/modules/informes/config/view.yml
===================================================================
--- 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
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbs_class.php 2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbs_class.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 >= 4.0.6
+Date : 2006-05-02
+Web site : www.tinybutstrong.com
+Author : skrol29(a)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 version is '.PHP_VERSION.' while TinyButStrong needs PHP version 4.0.6 or higher.';
+} 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 = false;
+ var $PosEnd = false;
+ var $Enlarged = false;
+ var $FullName = false;
+ var $SubName = '';
+ var $SubOk = false;
+ var $SubLst = array();
+ var $SubNbr = 0;
+ var $PrmLst = array();
+ var $MagnetId = false;
+ var $BlockFound = false;
+ var $FirstMerge = true;
+ var $ConvProtect = true;
+ var $ConvHtml = true;
+ var $ConvBr = true;
+ var $ConvSpe = false;
+}
+
+// *********************************************
+
+class clsTbsDataSource {
+
+var $Type = false;
+var $SubType = 0;
+var $SrcId = false;
+var $Query = '';
+var $RecSet = false;
+var $RecKey = '';
+var $RecNum = 0;
+var $RecNumInit = 0;
+var $RecSaving = false;
+var $RecSaved = false;
+var $RecBuffer = false;
+var $CurrRec = false;
+var $PrevRec = array();
+var $oTBS = false;
+var $BlockName = '';
+var $OnDataOk = false;
+var $OnDataSave = '';
+var $OnDataInfo = false;
+var $OnDataPrm = 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 =& $SrcId;
+ $this->oTBS =& $oTBS;
+
+ if (is_array($SrcId)) {
+ $this->Type = 0;
+ } elseif (is_resource($SrcId)) {
+
+ $Key = get_resource_type($SrcId);
+ switch ($Key) {
+ case 'mysql link' : $this->Type = 1; break;
+ case 'mysql link persistent' : $this->Type = 1; break;
+ case 'mysql result' : $this->Type = 1; $this->SubType = 1; break;
+ case 'pgsql link' : $this->Type = 8; break;
+ case 'pgsql link persistent' : $this->Type = 8; break;
+ case 'pgsql result' : $this->Type = 8; $this->SubType = 1; break;
+ case 'sqlite database' : $this->Type = 9; break;
+ case 'sqlite database (persistent)' : $this->Type = 9; break;
+ case 'sqlite result' : $this->Type = 9; $this->SubType = 1; break;
+ default :
+ $SubKey = 'resource type';
+ $this->Type = 7;
+ $x = strtolower($Key);
+ $x = str_replace('-','_',$x);
+ $Function = '';
+ $i = 0;
+ $iMax = strlen($x);
+ while ($i<$iMax) {
+ if (($x[$i]==='_') or (($x[$i]>='a') and ($x[$i]<='z')) or (($x[$i]>='0') and ($x[$i]<='9'))) {
+ $Function .= $x[$i];
+ $i++;
+ } else {
+ $i = $iMax;
+ }
+ }
+ }
+
+ } elseif (is_string($SrcId)) {
+
+ switch (strtolower($SrcId)) {
+ case 'array' : $this->Type = 0; $this->SubType = 1; break;
+ case 'clear' : $this->Type = 0; $this->SubType = 3; break;
+ case 'mysql' : $this->Type = 1; $this->SubType = 2; break;
+ case 'text' : $this->Type = 4; break;
+ case 'num' : $this->Type = 6; break;
+ default :
+ if ($SrcId[0]==='~') {
+ $ErrMsg = false;
+ $this->FctOpen = $SrcId.'_open';
+ $this->FctFetch = $SrcId.'_fetch';
+ $this->FctClose = $SrcId.'_close';
+ $this->FctPrm = 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 = 11;
+ $this->SrcId =& $oTBS->ObjectRef;
+ }
+ }
+ }
+ if ($ErrMsg!==false) $this->Type = $this->DataAlert($ErrMsg);
+ } else {
+ $Key = $SrcId;
+ $SubKey = 'keyword';
+ $this->Type = 7;
+ $Function = $SrcId;
+ }
+ }
+
+ } elseif (is_object($SrcId)) {
+ if (method_exists($SrcId,'tbsdb_open')) {
+ if (!method_exists($SrcId,'tbsdb_fetch')) {
+ $this->Type = $this->DataAlert('The expected method \'tbsdb_fetch\' is not found for the class '.get_class($SrcId).'.');
+ } elseif (!method_exists($SrcId,'tbsdb_close')) {
+ $this->Type = $this->DataAlert('The expected method \'tbsdb_close\' is not found for the class '.get_class($SrcId).'.');
+ } else {
+ $this->Type = 10;
+ }
+ } else {
+ $Key = get_class($SrcId);
+ $SubKey = 'object type';
+ $this->Type = 7;
+ $Function = $Key;
+ }
+ } elseif ($SrcId===false) {
+ $this->DataAlert('The specified source is set to FALSE. Maybe your connection has failed.');
+ } else {
+ $this->DataAlert('Unsupported variable type : \''.gettype($SrcId).'\'.');
+ }
+
+ if ($this->Type===7) {
+ $this->FctOpen = 'tbsdb_'.$Function.'_open';
+ $Ok = function_exists($this->FctOpen);
+ if (!$Ok) { // Some extended call can have a suffix in the class name, we check without the suffix
+ $i = strpos($Function,'_');
+ if ($i!==false) {
+ $x = substr($Function,0,$i);
+ $z = 'tbsdb_'.$x.'_open';
+ $Ok = function_exists($z);
+ if ($Ok) {
+ $Function = $x;
+ $this->FctOpen = $z;
+ }
+ }
+ }
+ if ($Ok) {
+ $this->FctFetch = 'tbsdb_'.$Function.'_fetch';
+ $this->FctClose = 'tbsdb_'.$Function.'_close';
+ if (function_exists($this->FctFetch)) {
+ if (!function_exists($this->FctClose)) $this->Type = $this->DataAlert('The expected custom function \''.$this->FctClose.'\' is not found.');
+ } else {
+ $this->Type = $this->DataAlert('The expected custom function \''.$this->FctFetch.'\' is not found.');
+ }
+ } else {
+ $this->Type = $this->DataAlert('The data source Id \''.$Key.'\' is an unsupported '.$SubKey.' because custom function \''.$this->FctOpen.'\' is not found.');
+ }
+ }
+
+ return ($this->Type!==false);
+
+}
+
+function DataOpen(&$Query,&$PageSize,&$PageNum,&$RecStop) {
+
+ // Init values
+ unset($this->CurrRec); $this->CurrRec = true;
+ if ($this->RecSaved) {
+ $this->FirstRec = true;
+ unset($this->RecKey); $this->RecKey = '';
+ $this->RecNum = $this->RecNumInit;
+ return true;
+ }
+ unset($this->RecSet); $this->RecSet = false;
+ $this->RecNumInit = 0;
+ $this->RecNum = 0;
+ if ($this->OnDataInfo!==false) {
+ $this->OnDataOk = true;
+ $this->OnDataPrm[0] =& $this->BlockName;
+ $this->OnDataPrm[1] =& $this->CurrRec;
+ $this->OnDataPrm[2] =& $this->RecNum;
+ }
+
+ switch ($this->Type) {
+ case 0: // Array
+ if (($this->SubType===1) and (is_string($Query))) $this->SubType = 2;
+ if ($this->SubType===0) {
+ if (PHP_VERSION==='4.4.1') {$this->RecSet = $this->SrcId;} else {$this->RecSet =& $this->SrcId;} // bad bug in PHP 4.4.1
+ } elseif ($this->SubType===1) {
+ if (is_array($Query)) {
+ if (PHP_VERSION==='4.4.1') {$this->RecSet = $Query;} else {$this->RecSet =& $Query;}
+ } else {
+ $this->DataAlert('Type \''.gettype($Query).'\' not supported for the Query Parameter going with \'array\' Source Type.');
+ }
+ } elseif ($this->SubType===2) {
+ //Found the global variable name and the sub-keys
+ $Pos = strpos($Query,'[');
+ if ($Pos===false) {
+ $VarName = $Query;
+ $Keys = array();
+ } else {
+ $VarName = substr($Query,0,$Pos);
+ $Keys = substr($Query,$Pos+1,strlen($Query)-$Pos-2);
+ $Keys = explode('][',$Keys);
+ }
+ // Check variable and sub-keys
+ if (isset($GLOBALS[$VarName])) {
+ if (PHP_VERSION==='4.4.1') {$Var = $GLOBALS[$VarName];} else {$Var =& $GLOBALS[$VarName];}
+ if (is_array($Var)) {
+ $Ok = true;
+ $KeyMax = count($Keys)-1;
+ $KeyNum = 0;
+ while ($Ok and ($KeyNum<=$KeyMax)) {
+ if (isset($Var[$Keys[$KeyNum]])) {
+ $Var =& $Var[$Keys[$KeyNum]];
+ $KeyNum++;
+ if (!is_array($Var)) $Ok = $this->DataAlert('Invalid query \''.$Query.'\' because item \''.$VarName.'['.implode('][',array_splice($Keys,0,$KeyNum)).']\' is not an array.');
+ } else {
+ $Ok = false; // Item not found => not an error, considered as a query with empty result.
+ $this->RecSet = array();
+ }
+ }
+ if ($Ok) $this->RecSet =& $Var;
+ } else {
+ $this->DataAlert('Invalid query \''.$Query.'\' because global variable \''.$VarName.'\' is not an array.');
+ }
+ } else {
+ $this->DataAlert('Invalid query \''.$Query.'\' because global variable \''.$VarName.'\' is not found.');
+ }
+ } elseif ($this->SubType===3) { // Clear
+ $this->RecSet = array();
+ }
+ // First record
+ if ($this->RecSet!==false) {
+ $this->RecNbr = $this->RecNumInit + count($this->RecSet);
+ $this->FirstRec = true;
+ $this->RecSaved = true;
+ $this->RecSaving = false;
+ }
+ break;
+ case 1: // MySQL
+ switch ($this->SubType) {
+ case 0: $this->RecSet = @mysql_query($Query,$this->SrcId); break;
+ case 1: $this->RecSet = $this->SrcId; break;
+ case 2: $this->RecSet = @mysql_query($Query); break;
+ }
+ if ($this->RecSet===false) $this->DataAlert('MySql error message when opening the query: '.mysql_error());
+ break;
+ case 4: // Text
+ if (is_string($Query)) {
+ $this->RecSet =& $Query;
+ } else {
+ $this->RecSet = ''.$Query;
+ }
+ $PageSize = 0;
+ break;
+ case 6: // Num
+ $this->RecSet = true;
+ $this->NumMin = 1;
+ $this->NumMax = 1;
+ $this->NumStep = 1;
+ if (is_array($Query)) {
+ if (isset($Query['min'])) $this->NumMin = $Query['min'];
+ if (isset($Query['step'])) $this->NumStep = $Query['step'];
+ if (isset($Query['max'])) {
+ $this->NumMax = $Query['max'];
+ } else {
+ $this->RecSet = $this->DataAlert('The \'num\' source is an array that has no value for the \'max\' key.');
+ }
+ if ($this->NumStep==0) $this->RecSet = $this->DataAlert('The \'num\' source is an array that has a step value set to zero.');
+ } else {
+ $this->NumMax = ceil($Query);
+ }
+ if ($this->RecSet) {
+ if ($this->NumStep>0) {
+ $this->NumVal = $this->NumMin;
+ } else {
+ $this->NumVal = $this->NumMax;
+ }
+ }
+ break;
+ case 7: // Custom function
+ $FctOpen = $this->FctOpen;
+ $this->RecSet = $FctOpen($this->SrcId,$Query);
+ break;
+ case 8: // PostgreSQL
+ switch ($this->SubType) {
+ case 0: $this->RecSet = @pg_query($this->SrcId,$Query); break;
+ case 1: $this->RecSet = $this->SrcId; break;
+ }
+ if ($this->RecSet===false) $this->DataAlert('PostgreSQL error message when opening the query: '.pg_last_error($this->SrcId));
+ break;
+ case 9: // SQLite
+ switch ($this->SubType) {
+ case 0: $this->RecSet = @sqlite_query($this->SrcId,$Query); break;
+ case 1: $this->RecSet = $this->SrcId; break;
+ }
+ if ($this->RecSet===false) $this->DataAlert('SQLite error message when opening the query:'.sqlite_error_string(sqlite_last_error($this->SrcId)));
+ break;
+ case 10: // Custom method
+ $this->RecSet = $this->SrcId->tbsdb_open($this->SrcId,$Query);
+ break;
+ case 11: // ObjectRef
+ $this->RecSet = call_user_func_array($this->FctOpen,array(&$this->SrcId,&$Query));
+ break;
+ }
+
+ if ($this->Type===0) {
+ unset($this->RecKey); $this->RecKey = '';
+ } else {
+ if ($this->RecSaving) {
+ unset($this->RecBuffer); $this->RecBuffer = array();
+ }
+ $this->RecKey =& $this->RecNum; // Not array: RecKey = RecNum
+ }
+
+ //Goto the page
+ if (($this->RecSet!==false) and ($PageSize>0)) {
+ if ($PageNum==-1) { // Goto end of the recordset
+ if ($this->RecSaved) { // Data source is array
+ $PageNum = intval(ceil($this->RecNbr/$PageSize));
+ } else {
+ // Read records, saving the last page in $this->RecBuffer
+ $i = 0;
+ unset($this->RecBuffer); $this->RecBuffer = array();
+ $this->RecSaving = true;
+ $this->DataFetch();
+ while ($this->CurrRec!==false) {
+ if ($i===$PageSize) {
+ $this->RecBuffer = array($this->RecKey => $this->CurrRec);
+ $i = 0;
+ $this->RecNumInit += $PageSize;
+ }
+ $i++;
+ $this->DataFetch();
+ }
+ $this->DataClose(); // Close the real recordset source
+ unset($this->RecNum); $this->RecNum = 0+$this->RecNumInit;
+ $this->FirstRec = true;
+ }
+ }
+ if ($PageNum>0) {
+ // We pass all record until the asked page
+ $RecStop = ($PageNum-1) * $PageSize;
+ while ($this->RecNum<$RecStop) {
+ $this->DataFetch();
+ if ($this->CurrRec===false) $RecStop=$this->RecNum;
+ }
+ if ($this->CurrRec!==false) $RecStop = $PageNum * $PageSize;
+ $this->RecNumInit = $this->RecNum; // Useful if RecSaved
+ } else {
+ $RecStop = 1;
+ }
+ }
+
+ return ($this->RecSet!==false);
+
+}
+
+function DataFetch() {
+
+ if ($this->RecSaved) {
+ if ($this->RecNum<$this->RecNbr) {
+ if ($this->FirstRec) {
+ if ($this->SubType===2) { // From string
+ reset($this->RecSet);
+ $this->RecKey = key($this->RecSet);
+ $this->CurrRec =& $this->RecSet[$this->RecKey];
+ } else {
+ $this->CurrRec = reset($this->RecSet);
+ $this->RecKey = key($this->RecSet);
+ }
+ $this->FirstRec = false;
+ } else {
+ if ($this->SubType===2) { // From string
+ next($this->RecSet);
+ $this->RecKey = key($this->RecSet);
+ $this->CurrRec =& $this->RecSet[$this->RecKey];
+ } else {
+ $this->CurrRec = next($this->RecSet);
+ $this->RecKey = key($this->RecSet);
+ }
+ }
+ if (!is_array($this->CurrRec)) $this->CurrRec = array('key'=>$this->RecKey, 'val'=>$this->CurrRec);
+ $this->RecNum++;
+ if ($this->OnDataOk) {
+ $this->OnDataPrm[1] =& $this->CurrRec; // Reference has changed if ($this->SubType===2)
+ call_user_func_array($this->OnDataInfo,$this->OnDataPrm);
+ }
+ } else {
+ unset($this->CurrRec); $this->CurrRec = false;
+ }
+ return;
+ }
+
+ switch ($this->Type) {
+ case 1: // MySQL
+ $this->CurrRec = mysql_fetch_assoc($this->RecSet);
+ break;
+ case 4: // Text
+ if ($this->RecNum===0) {
+ if ($this->RecSet==='') {
+ $this->CurrRec = false;
+ } else {
+ $this->CurrRec =& $this->RecSet;
+ }
+ } else {
+ $this->CurrRec = false;
+ }
+ break;
+ case 6: // Num
+ if (($this->NumVal>=$this->NumMin) and ($this->NumVal<=$this->NumMax)) {
+ $this->CurrRec = array('val'=>$this->NumVal);
+ $this->NumVal += $this->NumStep;
+ } else {
+ $this->CurrRec = false;
+ }
+ break;
+ case 7: // Custom function
+ $FctFetch = $this->FctFetch;
+ $this->CurrRec = $FctFetch($this->RecSet,$this->RecNum+1);
+ break;
+ case 8: // PostgreSQL
+ $this->CurrRec = @pg_fetch_array($this->RecSet,$this->RecNum,PGSQL_ASSOC); // warning comes when no record left.
+ break;
+ case 9: // SQLite
+ $this->CurrRec = sqlite_fetch_array($this->RecSet,SQLITE_ASSOC);
+ break;
+ case 10: // Custom method
+ $this->CurrRec = $this->SrcId->tbsdb_fetch($this->RecSet,$this->RecNum+1);
+ break;
+ case 11: // ObjectRef
+ $this->FctPrm[0] =& $this->RecSet; $this->FctPrm[1] = $this->RecNum+1;
+ $this->CurrRec = call_user_func_array($this->FctFetch,$this->FctPrm);
+ break;
+ }
+
+ // Set the row count
+ if ($this->CurrRec!==false) {
+ $this->RecNum++;
+ if ($this->OnDataOk) call_user_func_array($this->OnDataInfo,$this->OnDataPrm);
+ if ($this->RecSaving) $this->RecBuffer[$this->RecKey] = $this->CurrRec;
+ }
+
+}
+
+function DataClose() {
+ if ($this->RecSaved) return;
+ $this->OnDataOk = false;
+ switch ($this->Type) {
+ case 1: mysql_free_result($this->RecSet); break;
+ case 7: $FctClose=$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)); break;
+ }
+ if ($this->RecSaving) {
+ $this->RecSet =& $this->RecBuffer;
+ $this->RecNbr = $this->RecNumInit + count($this->RecSet);
+ $this->RecSaving = false;
+ $this->RecSaved = true;
+ }
+}
+
+}
+
+// *********************************************
+
+class clsTinyButStrong {
+
+// Public properties
+var $Source = ''; // Current result of the merged template
+var $Render = 3;
+var $HtmlCharSet = '';
+var $TplVars = array();
+var $VarPrefix = '';
+var $ObjectRef = false;
+var $Protect = true;
+// Private properties
+var $_LastFile = ''; // The last loaded template file
+var $_CacheFile = false; // The name of the file to save the content in.
+var $_HtmlCharFct = false;
+var $_Mode = 0;
+// Used to be globals
+var $ChrOpen = '[';
+var $ChrClose = ']';
+var $ChrVal = '[val]';
+var $ChrProtect = '[';
+var $CacheMask = 'cache_tbs_*.php';
+var $TurboBlock = true;
+var $MaxEnd = '...';
+
+function clsTinyButStrong($Chrs='',$VarPrefix='') {
+ if ($Chrs!=='') {
+ $Ok = false;
+ $Len = strlen($Chrs);
+ if ($Len===2) { // For compatibility
+ $this->ChrOpen = $Chrs[0];
+ $this->ChrClose = $Chrs[1];
+ $Ok = true;
+ } else {
+ $Pos = strpos($Chrs,',');
+ if (($Pos!==false) and ($Pos>0) and ($Pos<$Len-1)) {
+ $this->ChrOpen = substr($Chrs,0,$Pos);
+ $this->ChrClose = substr($Chrs,$Pos+1);
+ $Ok = true;
+ }
+ }
+ if ($Ok) {
+ $this->ChrVal = $this->ChrOpen.'val'.$this->ChrClose;
+ $this->ChrProtect = '&#'.ord($this->ChrOpen[0]).';'.substr($this->ChrOpen,1);
+ } else {
+ $this->meth_Misc_Alert('Creating instance','Bad argument for tag delimitors \''.$Chrs.'\'.');
+ }
+ }
+ $this->VarPrefix = $VarPrefix;
+ //Cache for formats
+ if (!isset($GLOBALS['_tbs_FrmMultiLst'])) {
+ $GLOBALS['_tbs_FrmMultiLst'] = array();
+ $GLOBALS['_tbs_FrmSimpleLst'] = array();
+ }
+}
+
+// Public methods
+function LoadTemplate($File,$HtmlCharSet='') {
+ // Load the file
+ $x = '';
+ if (!tbs_Misc_GetFile($x,$File)) return $this->meth_Misc_Alert('LoadTemplate Method','Unable to read the file \''.$File.'\'.');
+ // CharSet analysis
+ if ($HtmlCharSet==='+') {
+ $this->Source .= $x;
+ } else {
+ $this->Source = $x;
+ if ($this->_Mode==0) {
+ $this->_LastFile = $File;
+ $this->_HtmlCharFct = false;
+ $this->TplVars = array();
+ if (is_string($HtmlCharSet)) {
+ if (($HtmlCharSet!=='') and ($HtmlCharSet[0]==='=')) {
+ $ErrMsg = false;
+ $HtmlCharSet = substr($HtmlCharSet,1);
+ if ($this->meth_Misc_UserFctCheck($HtmlCharSet,$ErrMsg)) {
+ $this->_HtmlCharFct = true;
+ } else {
+ $this->meth_Misc_Alert('LoadTemplate Method',$ErrMsg);
+ $HtmlCharSet = '';
+ }
+ }
+ } elseif ($HtmlCharSet===false) {
+ $this->Protect = false;
+ } else {
+ $this->meth_Misc_Alert('LoadTemplate Method','CharSet is not a string.');
+ $HtmlCharSet = '';
+ }
+ $this->HtmlCharSet = $HtmlCharSet;
+ }
+ }
+ // Automatic fields and blocks
+ $this->meth_Merge_Auto($this->Source,'onload',true,true);
+ return true;
+}
+
+function GetBlockSource($BlockName,$List=false) {
+ $RetVal = array();
+ $Nbr = 0;
+ $Pos = 0;
+ $FieldOutside = false;
+ $P1 = false;
+ while ($Loc = $this->meth_Locator_FindBlockNext($this->Source,$BlockName,$Pos,'.',false,$P1,$FieldOutside)) {
+ $P1 = false;
+ $Nbr++;
+ $RetVal[$Nbr] = substr($this->Source,$Loc->PosBeg,$Loc->PosEnd-$Loc->PosBeg+1);
+ if (!$List) return $RetVal[$Nbr];
+ $Pos = $Loc->PosEnd;
+ }
+ if ($List) {
+ return $RetVal;
+ } else {
+ return false;
+ }
+}
+
+function MergeBlock($BlockName,$SrcId,$Query='',$PageSize=0,$PageNum=0,$RecKnown=0) {
+ if ($SrcId==='cond') {
+ $Nbr = 0;
+ $BlockLst = explode(',',$BlockName);
+ foreach ($BlockLst as $Block) {
+ $Nbr += $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=false) {
+ $PosBeg = 0;
+ if ($IsUserFct) {
+ $FctInfo = $Value;
+ $ErrMsg = false;
+ if ($this->meth_Misc_UserFctCheck($FctInfo,$ErrMsg)) {
+ $FctPrm = array('','');
+ while ($Loc = $this->meth_Locator_FindTbs($this->Source,$Name,$PosBeg,'.')) {
+ $FctPrm[0] =& $Loc->SubName; $FctPrm[1] =& $Loc->PrmLst;
+ $x = call_user_func_array($FctInfo,$FctPrm);
+ $PosBeg = $this->meth_Locator_Replace($this->Source,$Loc,$x,false);
+ }
+ } else {
+ $this->meth_Misc_Alert('MergeField Method',$ErrMsg);
+ }
+ } else {
+ while ($Loc = $this->meth_Locator_FindTbs($this->Source,$Name,$PosBeg,'.')) {
+ $PosBeg = $this->meth_Locator_Replace($this->Source,$Loc,$Value,true);
+ }
+ }
+}
+
+function MergeSpecial($Type) {
+ $Type = strtolower($Type);
+ $this->meth_Merge_Special($Type);
+}
+
+function MergeNavigationBar($BlockLst,$Options,$PageCurr,$RecCnt=-1,$PageSize=1) {
+ $BlockLst = explode(',',$BlockLst);
+ foreach ($BlockLst as $BlockName) {
+ $BlockName = trim($BlockName);
+ $this->meth_Merge_NavigationBar($this->Source,$BlockName,$Options,$PageCurr,$RecCnt,$PageSize);
+ }
+}
+
+function Show($Render='') {
+ if ($Render==='') $Render = $this->Render;
+ if ($this->_CacheFile!==true) $this->meth_Merge_Special('onshow,var');
+ if (is_string($this->_CacheFile)) $this->meth_Cache_Save($this->_CacheFile,$this->Source);
+ if (($Render & TBS_OUTPUT)==TBS_OUTPUT) echo $this->Source;
+ if (($this->_Mode==0) and (($Render & TBS_EXIT)==TBS_EXIT)) exit;
+}
+
+function CacheAction($CacheId,$Action=3600,$Dir='') {
+
+ $CacheId = trim($CacheId);
+ $Res = false;
+
+ if ($Action===TBS_CANCEL) { // Cancel cache save if any
+ $this->_CacheFile = false;
+ } elseif ($CacheId === '*') {
+ if ($Action===TBS_DELETE) $Res = tbs_Cache_DeleteAll($Dir,$this->CacheMask);
+ } else {
+ $CacheFile = tbs_Cache_File($Dir,$CacheId,$this->CacheMask);
+ if ($Action===TBS_CACHENOW) {
+ $this->meth_Cache_Save($CacheFile,$this->Source);
+ } elseif ($Action===TBS_CACHEGETAGE) {
+ if (file_exists($CacheFile)) $Res = time()-filemtime($CacheFile);
+ } elseif ($Action===TBS_CACHEGETNAME) {
+ $Res = $CacheFile;
+ } elseif ($Action===TBS_CACHEISONSHOW) {
+ $Res = ($this->_CacheFile!==false);
+ } elseif ($Action===TBS_CACHELOAD) {
+ if (file_exists($CacheFile)) {
+ if (tbs_Misc_GetFile($this->Source,$CacheFile)) {
+ $this->_CacheFile = $CacheFile;
+ $Res = true;
+ }
+ }
+ if ($Res===false) $this->Source = '';
+ } elseif ($Action===TBS_DELETE) {
+ if (file_exists($CacheFile)) $Res = @unlink($CacheFile);
+ } elseif ($Action===TBS_CACHEONSHOW) {
+ $this->_CacheFile = $CacheFile;
+ @touch($CacheFile);
+ } elseif($Action>=0) {
+ $Res = tbs_Cache_IsValide($CacheFile,$Action);
+ if ($Res) { // Load the cache
+ if (tbs_Misc_GetFile($this->Source,$CacheFile)) {
+ $this->_CacheFile = true; // Special value
+ $this->Show();
+ } else {
+ $this->meth_Misc_Alert('CacheAction Method','Unable to read the file \''.$CacheFile.'\'.');
+ $Res==false;
+ }
+ $this->_CacheFile = false;
+ } else {
+ // The result will be saved in the cache when the Show() method is called
+ $this->_CacheFile = $CacheFile;
+ @touch($CacheFile);
+ }
+ }
+ }
+
+ return $Res;
+
+}
+
+// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
+
+function meth_Locator_FindTbs(&$Txt,$Name,$Pos,$ChrSub) {
+// Find a TBS Locator
+
+ $PosEnd = false;
+ $PosMax = strlen($Txt) -1;
+ $Start = $this->ChrOpen.$Name;
+
+ do {
+ // Search for the opening char
+ if ($Pos>$PosMax) return false;
+ $Pos = strpos($Txt,$Start,$Pos);
+
+ // If found => next chars are analyzed
+ if ($Pos===false) {
+ return false;
+ } else {
+ $Loc =& new clsTbsLocator;
+ $ReadPrm = false;
+ $PosX = $Pos + strlen($Start);
+ $x = $Txt[$PosX];
+
+ if ($x===$this->ChrClose) {
+ $PosEnd = $PosX;
+ } elseif ($x===$ChrSub) {
+ $Loc->SubOk = true; // it is no longer the false value
+ $ReadPrm = true;
+ $PosX++;
+ } elseif (strpos(';',$x)!==false) {
+ $ReadPrm = true;
+ $PosX++;
+ } else {
+ $Pos++;
+ }
+
+ if ($ReadPrm) {
+ tbs_Locator_PrmRead($Txt,$PosX,false,'\'',$this->ChrOpen,$this->ChrClose,$Loc,$PosEnd);
+ if ($PosEnd===false) {
+ $this->meth_Misc_Alert('Tag definition','Can\'t found the end of the tag \''.substr($Txt,$Pos,$PosX-$Pos+10).'...\'.');
+ $Pos++;
+ }
+ }
+
+ }
+
+ } while ($PosEnd===false);
+
+ $Loc->PosBeg = $Pos;
+ $Loc->PosEnd = $PosEnd;
+ if ($Loc->SubOk) {
+ $Loc->FullName = $Name.'.'.$Loc->SubName;
+ $Loc->SubLst = explode('.',$Loc->SubName);
+ $Loc->SubNbr = count($Loc->SubLst);
+ } else {
+ $Loc->FullName = $Name;
+ }
+ if ($ReadPrm and isset($Loc->PrmLst['comm'])) {
+ $Loc->PosBeg0 = $Loc->PosBeg;
+ $Loc->PosEnd0 = $Loc->PosEnd;
+ $Loc->Enlarged = tbs_Locator_EnlargeToStr($Txt,$Loc,'<!--' ,'-->');
+ }
+
+ return $Loc;
+
+}
+
+// Search and cache TBS locators founded in $Txt.
+function meth_Locator_SectionCache(&$LocR,$Bid) {
+
+ $LocR->BlockChk[$Bid] = false;
+
+ $LocLst =& $LocR->BlockLoc[$Bid];
+ $Txt =& $LocR->BlockSrc[$Bid];
+ $BlockName =& $LocR->BlockName[$Bid];
+
+ $Pos = 0;
+ $PrevEnd = -1;
+ $Nbr = 0;
+ while ($Loc = $this->meth_Locator_FindTbs($Txt,$BlockName,$Pos,'.')) {
+ if (($Loc->SubName==='#') or ($Loc->SubName==='$')) {
+ $Loc->IsRecInfo = true;
+ $Loc->RecInfo = $Loc->SubName;
+ $Loc->SubName = '';
+ } else {
+ $Loc->IsRecInfo = false;
+ }
+ if ($Loc->PosBeg>$PrevEnd) {
+ // The previous tag is not embeding => increment
+ $Nbr++;
+ } else {
+ // The previous tag is embeding => no increment, then previous is over writed
+ $LocR->BlockChk[$Bid] = true;
+ }
+ $PrevEnd = $Loc->PosEnd;
+ if ($Loc->Enlarged) { // Parameter 'comm'
+ $Pos = $Loc->PosBeg0+1;
+ $Loc->Enlarged = false;
+ } else {
+ $Pos = $Loc->PosBeg+1;
+ }
+ $LocLst[$Nbr] = $Loc;
+ }
+
+ $LocLst[0] = $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 $Value will be replaced.
+
+ // Found the value if there is a subname
+ if ($CheckSub and $Loc->SubOk) {
+ $SubId = 0;
+ while ($SubId<$Loc->SubNbr) {
+ $x = $Loc->SubLst[$SubId]; // &$Loc... brings an error with Event Example, I don't know why.
+ if (is_array($Value)) {
+ if (isset($Value[$x])) {
+ $Value =& $Value[$x];
+ } elseif (array_key_exists($x,$Value)) {// can happens when value is NULL
+ $Value =& $Value[$x];
+ } else {
+ unset($Value); $Value = '';
+ if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert('Array value','Can\'t merge '.$this->ChrOpen.$Loc->FullName.$this->ChrClose.' because sub-item \''.$x.'\' is not an existing key in the array.',true);
+ }
+ $SubId++;
+ } elseif (is_object($Value)) {
+ if (method_exists($Value,$x)) {
+ $x = call_user_func(array(&$Value,$x));
+ } elseif (isset($Value->$x)) {
+ $x = $Value->$x;
+ } else {
+ if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert('Object value','Can\'t merge '.$this->ChrOpen.$Loc->FullName.$this->ChrClose.' because \''.$x.'\' is neither a method nor a property in the class \''.get_class($Value).'\'.',true);
+ unset($x); $x = '';
+ }
+ $Value =& $x;
+ unset($x); $x = '';
+ $SubId++;
+ } else {
+ if (isset($Loc->PrmLst['selected'])) {
+ $SelArray =& $Value;
+ } else {
+ if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert('Object or Array value expected','Can\'t merge '.$this->ChrOpen.$Loc->FullName.$this->ChrClose.' because the item before \''.$x.'\' is neither an object nor an array. Its type is '.gettype($Value).'.',true);
+ }
+ unset($Value); $Value = '';
+ $SubId = $Loc->SubNbr;
+ }
+ }
+ }
+
+ $CurrVal = $Value;
+
+ // File inclusion
+ if (isset($Loc->PrmLst['file'])) {
+ $File = $Loc->PrmLst['file'];
+ $this->meth_Merge_PhpVar($File,false);
+ $File = str_replace($this->ChrVal,$CurrVal,$File);
+ $OnlyBody = !(isset($Loc->PrmLst['htmlconv']) and (strtolower($Loc->PrmLst['htmlconv'])==='no')); // It's a text file, we don't get the BODY part
+ if (tbs_Misc_GetFile($CurrVal,$File)) {
+ if ($OnlyBody) $CurrVal = tbs_Html_GetPart($CurrVal,'BODY',false,true);
+ } else {
+ $CurrVal = '';
+ if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert('Parameter \'file\'','Field '.$this->ChrOpen.$Loc->FullName.$this->ChrClose.' : unable to read the file \''.$File.'\'.',true);
+ }
+ $Loc->ConvHtml = false;
+ $Loc->ConvProtect = false;
+ }
+
+ // OnFormat event
+ if (isset($Loc->PrmLst['onformat'])) {
+ if ($Loc->FirstMerge) {
+ $Loc->OnFrmInfo = $Loc->PrmLst['onformat'];
+ $Loc->OnFrmPrm = array(&$Loc->FullName,'',&$Loc->PrmLst,&$this);
+ $ErrMsg = 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 = 'pi'; // Execute the function pi() just to avoid extra error messages
+ }
+ }
+ $Loc->OnFrmPrm[1] =& $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 = isset($Loc->PrmLst['selected']);
+ if ($Select) {
+ if (is_array($CurrVal)) {
+ $SelArray =& $CurrVal;
+ unset($CurrVal); $CurrVal = ' ';
+ } else {
+ $SelArray = false;
+ }
+ }
+
+ // Convert the value to a string, use format if specified
+ if (isset($Loc->PrmLst['frm'])) {
+ $CurrVal = tbs_Misc_Format($Loc,$CurrVal);
+ $Loc->ConvHtml = false;
+ } else {
+ if (!is_string($CurrVal)) $CurrVal = @strval($CurrVal);
+ }
+
+ // case of an 'if' 'then' 'else' options
+ $OVal =& $CurrVal; // Must be assigner after $SelArray, if any
+ $Script = 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->PrmLst['then'],true);
+ if (isset($Loc->PrmLst['else'])) $this->meth_Merge_PhpVar($Loc->PrmLst['else'],true);
+ }
+ $x = str_replace($this->ChrVal,$CurrVal,$Loc->PrmLst['if']);
+ if (tbs_Misc_CheckCondition($x)) {
+ if (isset($Loc->PrmLst['then'])) {
+ unset($CurrVal); $CurrVal = ''.$Loc->PrmLst['then']; // Now $CurrVal and $OVal are different
+ }
+ } else {
+ $Script = false;
+ if (isset($Loc->PrmLst['else'])) {
+ unset($CurrVal); $CurrVal = ''.$Loc->PrmLst['else']; // Now $CurrVal and $OVal are different
+ } else {
+ $CurrVal = '';
+ }
+ }
+ }
+
+ if ($Script) {// Include external PHP script
+ $File = $Loc->PrmLst['script'];
+ $this->meth_Merge_PhpVar($File,false);
+ $File = str_replace($this->ChrVal,$CurrVal,$File);
+ $Switch = isset($Loc->PrmLst['subtpl']);
+ $GetOb = ($Switch or isset($Loc->PrmLst['getob']));
+ $CurrPrm =& $Loc->PrmLst; // Local var for users
+ $this->meth_Misc_ChangeMode(true,$Loc,$CurrVal,$Switch,$GetOb);
+ if (isset($Loc->PrmLst['once'])) {$x = @include_once($File);} else {$x = @include($File);}
+ if ($x===false) {
+ if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert('Parameter \'script\'','Field '.$this->ChrOpen.$Loc->FullName.$this->ChrClose.' cannot be merged because file \''.$File.'\' is not found or not readable.',true);
+ }
+ $this->meth_Misc_ChangeMode(false,$Loc,$CurrVal,$Switch,$GetOb);
+ }
+
+ if ($Loc->FirstMerge) {
+ $Loc->FirstMerge = false;
+ // Check HtmlConv parameter
+ if (isset($Loc->PrmLst['htmlconv'])) {
+ $x = strtolower($Loc->PrmLst['htmlconv']);
+ $x = '+'.str_replace(' ','',$x).'+';
+ if (strpos($x,'+esc+')!==false) {tbs_Misc_ConvSpe($Loc); $Loc->ConvHtml = false; $Loc->ConvEsc = true; }
+ if (strpos($x,'+wsp+')!==false) {tbs_Misc_ConvSpe($Loc); $Loc->ConvWS = true; }
+ if (strpos($x,'+js+')!==false) {tbs_Misc_ConvSpe($Loc); $Loc->ConvHtml = false; $Loc->ConvJS = true; }
+ if (strpos($x,'+no+')!==false) $Loc->ConvHtml = false;
+ if (strpos($x,'+yes+')!==false) $Loc->ConvHtml = true;
+ if (strpos($x,'+nobr+')!==false) {$Loc->ConvHtml = true; $Loc->ConvBr = false; }
+ if (strpos($x,'+look+')!==false) {tbs_Misc_ConvSpe($Loc); $Loc->ConvLook = true; }
+ } else {
+ if ($this->HtmlCharSet===false) $Loc->ConvHtml = false; // No HTML
+ }
+ // We protect the data that does not come from the source of the template
+ if (isset($Loc->PrmLst['protect'])) {
+ $x = strtolower($Loc->PrmLst['protect']);
+ switch ($x) {
+ case 'no' : $Loc->ConvProtect = false; break;
+ case 'yes': $Loc->ConvProtect = true; break;
+ }
+ } else {
+ if ($this->Protect===false) $Loc->ConvProtect = false;
+ }
+ }
+
+ // MaxLength
+ if (isset($Loc->PrmLst['max'])) {
+ $x = intval($Loc->PrmLst['max']);
+ if (strlen($CurrVal)>$x) {
+ if ($Loc->ConvHtml or ($this->HtmlCharSet===false)) {
+ $CurrVal = 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 = !tbs_Html_IsHtml($OVal);
+ if ($Loc->ConvHtml===false) $OVal = tbs_Html_GetPart($OVal,'BODY',false,true);
+ }
+ if ($Loc->ConvHtml) {
+ $this->meth_Conv_Html($OVal);
+ if ($Loc->ConvBr) $OVal = nl2br($OVal);
+ }
+ if ($Loc->ConvEsc) $OVal = str_replace('\'','\'\'',$OVal);
+ if ($Loc->ConvWS) {
+ $check = ' ';
+ $nbsp = ' ';
+ do {
+ $pos = strpos($OVal,$check);
+ if ($pos!==false) $OVal = substr_replace($OVal,$nbsp,$pos,1);
+ } while ($pos!==false);
+ }
+ if ($Loc->ConvJS) {
+ $OVal = addslashes($OVal); // apply to ('), ("), (\) and (null)
+ $OVal = str_replace("\n",'\n',$OVal);
+ $OVal = str_replace("\r",'\r',$OVal);
+ $OVal = str_replace("\t",'\t',$OVal);
+ }
+ } elseif ($Loc->ConvHtml) {
+ $this->meth_Conv_Html($OVal);
+ if ($Loc->ConvBr) $OVal = nl2br($OVal);
+ }
+ if ($Loc->ConvProtect) $OVal = str_replace($this->ChrOpen,$this->ChrProtect,$OVal);
+ if ($CurrVal!==$OVal) $CurrVal = str_replace($this->ChrVal,$OVal,$CurrVal);
+
+ // Case when it's an empty string
+ if ($CurrVal==='') {
+
+ if ($Loc->MagnetId===false) {
+ if (isset($Loc->PrmLst['.'])) {
+ $Loc->MagnetId = -1;
+ } elseif (isset($Loc->PrmLst['ifempty'])) {
+ $Loc->MagnetId = -2;
+ } elseif (isset($Loc->PrmLst['magnet'])) {
+ $Loc->MagnetId = 1;
+ $Loc->PosBeg0 = $Loc->PosBeg;
+ $Loc->PosEnd0 = $Loc->PosEnd;
+ if (isset($Loc->PrmLst['mtype'])) {
+ switch ($Loc->PrmLst['mtype']) {
+ case 'm+m': $Loc->MagnetId = 2; break;
+ case 'm*': $Loc->MagnetId = 3; break;
+ case '*m': $Loc->MagnetId = 4; break;
+ }
+ }
+ } else {
+ $Loc->MagnetId = 0;
+ }
+ }
+
+ switch ($Loc->MagnetId) {
+ case 0: break;
+ case -1: $CurrVal = ' '; break; // Enables to avoid blanks in HTML tables
+ case -2: $CurrVal = $Loc->PrmLst['ifempty']; break;
+ case 1:
+ $Loc->Enlarged = true;
+ tbs_Locator_EnlargeToTag($Txt,$Loc,$Loc->PrmLst['magnet'],false,false);
+ break;
+ case 2:
+ $Loc->Enlarged = true;
+ $CurrVal = tbs_Locator_EnlargeToTag($Txt,$Loc,$Loc->PrmLst['magnet'],false,true);
+ break;
+ case 3:
+ $Loc->Enlarged = true;
+ $Loc2 = tbs_Html_FindTag($Txt,$Loc->PrmLst['magnet'],true,$Loc->PosBeg,false,1,false);
+ if ($Loc2!==false) {
+ $Loc->PosBeg = $Loc2->PosBeg;
+ if ($Loc->PosEnd<$Loc2->PosEnd) $Loc->PosEnd = $Loc2->PosEnd;
+ }
+ break;
+ case 4:
+ $Loc->Enlarged = true;
+ $Loc2 = tbs_Html_FindTag($Txt,$Loc->PrmLst['magnet'],true,$Loc->PosBeg,true,1,false);
+ if ($Loc2!==false) $Loc->PosEnd = $Loc2->PosEnd;
+ break;
+ }
+ $NewEnd = $Loc->PosBeg; // Useful when mtype='m+m'
+ } else {
+ $NewEnd = $Loc->PosBeg + strlen($CurrVal);
+ }
+
+ $Txt = substr_replace($Txt,$CurrVal,$Loc->PosBeg,$Loc->PosEnd-$Loc->PosBeg+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,$Special,&$P1,&$FieldBefore) {
+// Return the first block locator object just after the PosBeg position
+// If $Special==true => don't set ->BlockSrc and accept TBS Fields (used for automatic blocks)
+
+ $SearchDef = true;
+ $FirstField = false;
+
+ // Search for the first tag with parameter "block"
+ while ($SearchDef and ($Loc = $this->meth_Locator_FindTbs($Txt,$BlockName,$PosBeg,$ChrSub))) {
+ if (isset($Loc->PrmLst['block'])) {
+ $Block = $Loc->PrmLst['block'];
+ if ($P1) {
+ if (isset($Loc->PrmLst['p1'])) return false;
+ } else {
+ if (isset($Loc->PrmLst['p1'])) $P1 = true;
+ }
+ $SearchDef = false;
+ } elseif ($Special) {
+ return $Loc;
+ } elseif ($FirstField===false) {
+ $FirstField = $Loc;
+ }
+ $PosBeg = $Loc->PosEnd;
+ }
+
+ if ($SearchDef) {
+ if ($FirstField!==false) $FieldBefore = true;
+ return false;
+ }
+
+ if ($Block==='begin') { // Block definied using begin/end
+
+ if (($FirstField!==false) and ($FirstField->PosEnd<$Loc->PosBeg)) $FieldBefore = true;
+
+ $Opened = 1;
+ while ($Loc2 = $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==0) {
+ if ($Special) {
+ $Loc->PosBeg2 = $Loc2->PosBeg;
+ $Loc->PosEnd2 = $Loc2->PosEnd;
+ } else {
+ $Loc->BlockSrc = substr($Txt,$Loc->PosEnd+1,$Loc2->PosBeg-$Loc->PosEnd-1);
+ $Loc->PosEnd = $Loc2->PosEnd;
+ $Loc->PosDef = 0;
+ }
+ $Loc->BlockFound = true;
+ return $Loc;
+ }
+ }
+ $PosBeg = $Loc2->PosEnd;
+ }
+
+ return $this->meth_Misc_Alert('Block definition','At least one block '.$this->ChrOpen.$Loc->FullName.$this->ChrClose.' with parameter \'block=end\' is missing.');
+
+ }
+
+ if ($Special) {
+ $Loc->PosBeg2 = false;
+ } else {
+
+ $Loc->PosDef = $Loc->PosBeg;
+ if (!$Loc->SubOk) {
+ $PosBeg1 = $Loc->PosBeg;
+ $PosEnd1 = $Loc->PosEnd;
+ }
+ if (tbs_Locator_EnlargeToTag($Txt,$Loc,$Block,true,false)===false) 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 = $Loc->PosDef - $Loc->PosBeg;
+ if ($Loc->SubOk) {
+ $Loc->BlockSrc = substr($Txt,$Loc->PosBeg,$Loc->PosEnd-$Loc->PosBeg+1);
+ $Loc->PosDef++;
+ } else {
+ $Loc->BlockSrc = substr($Txt,$Loc->PosBeg,$PosBeg1-$Loc->PosBeg).substr($Txt,$PosEnd1+1,$Loc->PosEnd-$PosEnd1);
+ }
+ }
+
+ $Loc->BlockFound = true;
+ if (($FirstField!==false) and ($FirstField->PosEnd<$Loc->PosBeg)) $FieldBefore = 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 =& new clsTbsLocator;
+ $LocR->P1 = false;
+ $LocR->FieldOutside = false;
+ $LocR->BlockNbr = 0;
+ $LocR->BlockSrc = array(); // 1 to BlockNbr
+ $LocR->BlockLoc = array(); // 1 to BlockNbr
+ $LocR->BlockChk = array(); // 1 to BlockNbr
+ $LocR->BlockName = array(); // 1 to BlockNbr
+ $LocR->NoDataBid = false;
+ $LocR->SpecialBid = false;
+ $LocR->HeaderFound = false;
+ $LocR->FooterFound = false;
+ $LocR->WhenFound = false;
+ $LocR->WhenDefaultBid = false;
+ $LocR->SectionNbr = 0;
+ $LocR->SectionBid = array(); // 1 to SectionNbr
+ $LocR->SectionIsSerial = array(); // 1 to SectionNbr
+ $LocR->SectionSerialBid = array(); // 1 to SectionNbr
+ $LocR->SectionSerialOrd = array(); // 1 to SectionNbr
+ $LocR->SerialEmpty = false;
+
+ $Bid =& $LocR->BlockNbr;
+ $Sid =& $LocR->SectionNbr;
+ $Pid = 0;
+
+ do {
+
+ $Loc = $this->meth_Locator_FindBlockNext($Txt,$BlockName,$Pos,'.',false,$LocR->P1,$LocR->FieldOutside);
+
+ if ($Loc===false) {
+
+ if ($Pid>0) { // parentgrp mode => disconnect $Txt from the source
+ $Src = $Txt;
+ $Txt =& $Parent[$Pid]['txt'];
+ if ($LocR->BlockFound) {
+ // Redefine the Header block
+ $LocR->BlockSrc[$Parent[$Pid]['bid']] = substr($Src,0,$LocR->PosBeg);
+ // Add a Footer block
+ tbs_Locator_SectionAddBlk($LocR,$BlockName,substr($Src,$LocR->PosEnd+1));
+ tbs_Locator_SectionAddGrp($LocR,$Bid,'F',$Parent[$Pid]['fld']);
+ }
+ // Now gowing down to previous level
+ $Pos = $Parent[$Pid]['pos'];
+ $LocR->PosBeg = $Parent[$Pid]['beg'];
+ $LocR->PosEnd = $Parent[$Pid]['end'];
+ $LocR->BlockFound = true;
+ unset($Parent[$Pid]);
+ $Pid--;
+ $Loc = true;
+ }
+
+ } else {
+
+ $Pos = $Loc->PosEnd;
+
+ // Define the block limits
+ if ($LocR->BlockFound) {
+ if ( $LocR->PosBeg > $Loc->PosBeg ) $LocR->PosBeg = $Loc->PosBeg;
+ if ( $LocR->PosEnd < $Loc->PosEnd ) $LocR->PosEnd = $Loc->PosEnd;
+ } else {
+ $LocR->BlockFound = true;
+ $LocR->PosBeg = $Loc->PosBeg;
+ $LocR->PosEnd = $Loc->PosEnd;
+ }
+
+ // Merge block parameters
+ if (count($Loc->PrmLst)>0) $LocR->PrmLst = array_merge($LocR->PrmLst,$Loc->PrmLst);
+
+ // Save the block and cache its tags (incrments $LocR->BlockNbr)
+ tbs_Locator_SectionAddBlk($LocR,$BlockName,$Loc->BlockSrc);
+
+ // Add the text in the list of blocks
+ if (isset($Loc->PrmLst['nodata'])) { // Nodata section
+ $LocR->NoDataBid = $Bid;
+ } elseif (isset($Loc->PrmLst['currpage'])) { // Special section (used for navigation bar)
+ $LocR->SpecialBid = $Bid;
+ } elseif (isset($Loc->PrmLst['when'])) {
+ if ($LocR->WhenFound===false) {
+ $LocR->WhenFound = true;
+ $LocR->WhenSeveral = false;
+ $LocR->WhenNbr = 0;
+ $LocR->WhenSectionBid[] = array(); // Bid of the section to display
+ $LocR->WhenCondBid[] = array(); // Bid of the condition to check
+ $LocR->WhenBeforeNS[] = array(); // True if the When section must be displayed before a
+ }
+ $LocR->WhenNbr++;
+ if (isset($Loc->PrmLst['several'])) $LocR->WhenSeveral = true;
+ $LocR->WhenSectionBid[$LocR->WhenNbr] = $Bid;
+ $this->meth_Merge_PhpVar($Loc->PrmLst['when'],false);
+ tbs_Locator_SectionAddBlk($LocR,$BlockName,$Loc->PrmLst['when']);
+ $LocR->WhenCondBid[$LocR->WhenNbr] = $Bid;
+ $LocR->WhenBeforeNS[$LocR->WhenNbr] = ($Sid===0);
+ } elseif (isset($Loc->PrmLst['default'])) {
+ $LocR->WhenDefaultBid = $Bid;
+ $LocR->WhenDefaultBeforeNS = ($Sid===0);
+ } 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'] = $Bid;
+ $Parent[$Pid]['fld'] = $Loc->PrmLst['parentgrp'];
+ $Parent[$Pid]['txt'] =& $Txt;
+ $Parent[$Pid]['pos'] = $Pos;
+ $Parent[$Pid]['beg'] = $LocR->PosBeg;
+ $Parent[$Pid]['end'] = $LocR->PosEnd;
+ $Txt =& $LocR->BlockSrc[$Bid];
+ $Pos = $Loc->PosDef + 1;
+ $LocR->BlockFound = false;
+ $LocR->PosBeg = false;
+ $LocR->PosEnd = false;
+ } elseif (isset($Loc->PrmLst['serial'])) {
+ // Section with Serial Sub-Sections
+ $Src =& $LocR->BlockSrc[$Bid];
+ $Loc0 = false;
+ if ($LocR->SerialEmpty===false) {
+ $NameSr = $BlockName.'_0';
+ $x = false;
+ $LocSr = $this->meth_Locator_FindBlockNext($Src,$NameSr,0,'.',false,$x,$x);
+ if ($LocSr!==false) {
+ $LocR->SerialEmpty = $LocSr->BlockSrc;
+ $Src = substr_replace($Src,'',$LocSr->PosBeg,$LocSr->PosEnd-$LocSr->PosBeg+1);
+ }
+ }
+ $NameSr = $BlockName.'_1';
+ $x = false;
+ $LocSr = $this->meth_Locator_FindBlockNext($Src,$NameSr,0,'.',false,$x,$x);
+ if ($LocSr!==false) {
+ $Sid++;
+ $LocR->SectionBid[$Sid] = $Bid;
+ $LocR->SectionIsSerial[$Sid] = true;
+ $LocR->SectionSerialBid[$Sid] = array();
+ $LocR->SectionSerialOrd[$Sid] = array();
+ $SrBid =& $LocR->SectionSerialBid[$Sid];
+ $SrOrd =& $LocR->SectionSerialOrd[$Sid];
+ $BidParent = $Bid;
+ $SrNum = 1;
+ do {
+ // Save previous sub-section
+ $LocR->BlockLoc[$BidParent][$SrNum] = $LocSr;
+ tbs_Locator_SectionAddBlk($LocR,$NameSr,$LocSr->BlockSrc);
+ $SrBid[$SrNum] = $Bid;
+ $SrOrd[$SrNum] = $SrNum;
+ $i = $SrNum;
+ while (($i>1) and ($LocSr->PosBeg<$LocR->BlockLoc[$BidParent][$SrOrd[$i-1]]->PosBeg)) {
+ $SrOrd[$i] = $SrOrd[$i-1];
+ $SrOrd[$i-1] = $SrNum;
+ $i--;
+ }
+ // Search next section
+ $SrNum++;
+ $NameSr = $BlockName.'_'.$SrNum;
+ $x = false;
+ $LocSr = $this->meth_Locator_FindBlockNext($Src,$NameSr,0,'.',false,$x,$x);
+ } while ($LocSr!==false);
+ $SrBid[0] = $SrNum-1;
+ }
+ } else {
+ // Normal section
+ $Sid++;
+ $LocR->SectionBid[$Sid] = $Bid;
+ $LocR->SectionIsSerial[$Sid] = false;
+ }
+
+ }
+
+ } while ($Loc!==false);
+
+ if ($LocR->WhenFound and ($Sid===0)) {
+ // Add a blank section if When is used without a normal section
+ tbs_Locator_SectionAddBlk($LocR,$BlockName,'');
+ $Sid++;
+ $LocR->SectionBid[$Sid] = $Bid;
+ $LocR->SectionIsSerial[$Sid] = false;
+ }
+
+ // Calculate Cache
+ if ($this->TurboBlock) {
+ for ($i=1;$i<=$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,$PageNum,$RecKnown) {
+
+ // Get source type and info
+ $Src =& new clsTbsDataSource;
+ $Src->BlockName = $BlockName;
+ if (!$Src->DataPrepare($SrcId,$this)) return 0;
+
+ $BlockId = 0;
+ $BlockLst = explode(',',$BlockName);
+ $BlockNbr = count($BlockLst);
+ $WasP1 = false;
+ $NbrRecTot = 0;
+ $QueryZ =& $Query;
+
+ while ($BlockId<$BlockNbr) {
+
+ $RecStop = 0; // Stop the merge after this row
+ $RecSpe = 0; // Row with a special block's definition (used for the navigation bar)
+ $QueryOk = true;
+ $NoFct = true;
+ $Src->BlockName = trim($BlockLst[$BlockId]);
+
+ // Search the block
+ $LocR = $this->meth_Locator_FindBlockLst($Txt,$Src->BlockName,0);
+
+ if ($LocR->BlockFound) {
+ if ($LocR->SpecialBid!==false) $RecSpe = $RecKnown;
+ // OnSection
+ if (isset($LocR->PrmLst['onsection'])) {
+ $LocR->OnSecInfo = $LocR->PrmLst['onsection'];
+ $ErrMsg = false;
+ if ($this->meth_Misc_UserFctCheck($LocR->OnSecInfo,$ErrMsg)) {
+ $LocR->OnSecPrm = array($BlockName,'','','');
+ $NoFct = false;
+ } else {
+ $this->meth_Misc_Alert('Block definition \''.$BlockName.'\'',$ErrMsg);
+ }
+ }
+ // OnData
+ if (isset($LocR->PrmLst['ondata'])) {
+ if ($LocR->PrmLst['ondata']!==$Src->OnDataSave) {
+ $Src->OnDataSave = $LocR->PrmLst['ondata'];
+ $Src->OnDataInfo = $Src->OnDataSave;
+ $ErrMsg = false;
+ if ($this->meth_Misc_UserFctCheck($Src->OnDataInfo,$ErrMsg)) {
+ $Src->OnDataPrm = array($BlockName,'','');
+ } else {
+ $Src->OnDataInfo = false;
+ $this->meth_Misc_Alert('Block definition \''.$BlockName.'\'',$ErrMsg);
+ }
+ }
+ }
+ // Dynamic query
+ if ($LocR->P1) {
+ if (is_string($Query)) {
+ $Src->RecSaved = false;
+ unset($QueryZ); $QueryZ = ''.$Query;
+ $i = 1;
+ do {
+ $x = 'p'.$i;
+ if (isset($LocR->PrmLst[$x])) {
+ $QueryZ = str_replace('%p'.$i.'%',$LocR->PrmLst[$x],$QueryZ);
+ $i++;
+ } else {
+ $i = false;
+ }
+ } while ($i!==false);
+ }
+ $WasP1 = true;
+ } elseif (($Src->RecSaved===false) and ($BlockNbr-$BlockId>1)) {
+ $Src->RecSaving = true;
+ }
+ } else {
+ if ($WasP1) {
+ $QueryOk = false;
+ $WasP1 = false;
+ } else {
+ $RecStop = 1;
+ }
+ }
+
+ // Open the recordset
+ if ($QueryOk) {
+ if ((!$LocR->BlockFound) and (!$LocR->FieldOutside)) {
+ $QueryOk = false;
+ } else {
+ $QueryOk = $Src->DataOpen($QueryZ,$PageSize,$PageNum,$RecStop);
+ }
+ }
+
+ // Merge sections
+ if ($QueryOk) {
+ if ($Src->Type===4) { // Special for Text merge
+ if ($LocR->BlockFound) {
+ $Src->RecNum = 1;
+ $Src->CurrRec = false;
+ if ($NoFct===false) {
+ $LocR->OnSecPrm[1] =& $Src->CurrRec ; $LocR->OnSecPrm[2] =& $Src->RecSet; $LocR->OnSecPrm[3] =& $Src->RecNum;
+ call_user_func_array($LocR->OnSecInfo,$LocR->OnSecPrm);
+ }
+ $Txt = substr_replace($Txt,$Src->RecSet,$LocR->PosBeg,$LocR->PosEnd-$LocR->PosBeg+1);
+ } else {
+ $Src->DataAlert('Can\'t merge the block with a text value because the block definition is not found.');
+ }
+ } else { // Other data source type
+ $Src->DataFetch();
+ if ($LocR->BlockFound!==false) $this->meth_Merge_BlockSections($Txt,$LocR,$Src,$NoFct,$RecSpe,$RecStop);
+ // Mode Page: Calculate the value to return
+ if (($PageSize>0) and ($Src->RecNum>=$RecStop)) {
+ if ($RecKnown<0) { // Pass pages in order to count all records
+ do {
+ $Src->DataFetch();
+ } while ($Src->CurrRec!==false);
+ } else { // We know that there is more records
+ if ($RecKnown>$Src->RecNum) $Src->RecNum = $RecKnown;
+ }
+ }
+ }
+ $Src->DataClose(); // Close the resource
+ }
+
+ if (!$WasP1) {
+ $NbrRecTot += $Src->RecNum;
+ if ($LocR->FieldOutside and $QueryOk) {
+ // Merge last record on the entire template
+ $Pos = 0;
+ $ChkSub = ($Src->CurrRec!==false);
+ while ($Loc = $this->meth_Locator_FindTbs($Txt,$Src->BlockName,$Pos,'.')) {
+ if ($Loc->SubName==='#') {
+ $Pos = $this->meth_Locator_Replace($Txt,$Loc,$Src->RecNum,false);
+ } else {
+ $Pos = $this->meth_Locator_Replace($Txt,$Loc,$Src->CurrRec,$ChkSub);
+ }
+ }
+ }
+ $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 = 0;
+ $SecOk = ($LocR->SectionNbr>0);
+ $SecIncr = true;
+ $BlockRes = ''; // The result of the chained merged blocks
+ $SerialMode = false;
+ $SerialNum = 0;
+ $SerialMax = 0;
+ $SerialTxt = array();
+ $GrpFound = ($LocR->HeaderFound or $LocR->FooterFound);
+
+ // Main loop
+ //$Src->DataFetch();
+ while($Src->CurrRec!==false) {
+
+ // Headers and Footers
+ if ($GrpFound) {
+ $grp_change = false;
+ $grp_src = '';
+ if ($LocR->FooterFound) {
+ $change = false;
+ for ($i=$LocR->FooterNbr;$i>=1;$i--) {
+ $x = $Src->CurrRec[$LocR->FooterField[$i]];
+ if ($Src->RecNum===1) {
+ $LocR->FooterPrevValue[$i] = $x;
+ } else {
+ if ($LocR->FooterIsFooter[$i]) {
+ $change_i =& $change;
+ } else {
+ unset($change_i); $change_i = false;
+ }
+ if (!$change_i) $change_i = !($LocR->FooterPrevValue[$i]===$x);
+ if ($change_i) {
+ $grp_change = true;
+ $grp_src = $this->meth_Merge_SectionNormal($LocR,$LocR->FooterBid[$i],$PrevRec,$PrevNum,$PrevKey,$NoFct).$grp_src;
+ $LocR->FooterPrevValue[$i] = $x;
+ }
+ }
+ }
+ $PrevRec = $Src->CurrRec;
+ $PrevNum = $Src->RecNum;
+ $PrevKey = $Src->RecKey;
+ }
+ if ($LocR->HeaderFound) {
+ $change = ($Src->RecNum===1);
+ for ($i=1;$i<=$LocR->HeaderNbr;$i++) {
+ $x = $Src->CurrRec[$LocR->HeaderField[$i]];
+ if (!$change) $change = !($LocR->HeaderPrevValue[$i]===$x);
+ if ($change) {
+ $grp_src .= $this->meth_Merge_SectionNormal($LocR,$LocR->HeaderBid[$i],$Src->CurrRec,$Src->RecNum,$Src->RecKey,$NoFct);
+ $LocR->HeaderPrevValue[$i] = $x;
+ }
+ }
+ $grp_change = ($grp_change or $change);
+ }
+ if ($grp_change) {
+ if ($SerialMode) {
+ $BlockRes .= $this->meth_Merge_SectionSerial($LocR,$SecId,$SerialNum,$SerialMax,$SerialTxt);
+ $SecIncr = true;
+ }
+ $BlockRes .= $grp_src;
+ }
+ } // end of header and footer
+
+ // Increment Section
+ if ($SecIncr and $SecOk) {
+ $SecId++;
+ if ($SecId>$LocR->SectionNbr) $SecId = 1;
+ $SerialMode = $LocR->SectionIsSerial[$SecId];
+ if ($SerialMode) {
+ $SerialNum = 0;
+ $SerialMax = $LocR->SectionSerialBid[$SecId][0];
+ $SecIncr = false;
+ }
+ }
+
+ // Serial Mode Activation
+ if ($SerialMode) { // Serial Merge
+ $SerialNum++;
+ $Bid = $LocR->SectionSerialBid[$SecId][$SerialNum];
+ $SerialTxt[$SerialNum] = $this->meth_Merge_SectionNormal($LocR,$Bid,$Src->CurrRec,$Src->RecNum,$Src->RecKey,$NoFct);
+ if ($SerialNum>=$SerialMax) {
+ $BlockRes .= $this->meth_Merge_SectionSerial($LocR,$SecId,$SerialNum,$SerialMax,$SerialTxt);
+ $SecIncr = true;
+ }
+ } else { // Classic merge
+ if ($Src->RecNum===$RecSpe) {
+ $Bid = $LocR->SpecialBid;
+ } else {
+ $Bid = $LocR->SectionBid[$SecId];
+ }
+ if ($LocR->WhenFound) { // With conditional blocks
+ $x = $this->meth_Merge_SectionNormal($LocR,$Bid,$Src->CurrRec,$Src->RecNum,$Src->RecKey,$NoFct);
+ $found = false;
+ $continue = true;
+ $i = 1;
+ do {
+ $cond = $this->meth_Merge_SectionNormal($LocR,$LocR->WhenCondBid[$i],$Src->CurrRec,$Src->RecNum,$Src->RecKey,$NoFct);
+ if (tbs_Misc_CheckCondition($cond)) {
+ $x_when = $this->meth_Merge_SectionNormal($LocR,$LocR->WhenSectionBid[$i],$Src->CurrRec,$Src->RecNum,$Src->RecKey,$NoFct);
+ if ($LocR->WhenBeforeNS[$i]) {$x = $x_when.$x;} else {$x = $x.$x_when;}
+ $found = true;
+ if ($LocR->WhenSeveral===false) $continue = false;
+ }
+ $i++;
+ if ($i>$LocR->WhenNbr) $continue = false;
+ } while ($continue);
+ if (($found===false) and ($LocR->WhenDefaultBid!==false)) {
+ $x_when = $this->meth_Merge_SectionNormal($LocR,$LocR->WhenDefaultBid,$Src->CurrRec,$Src->RecNum,$Src->RecKey,$NoFct);
+ if ($LocR->WhenDefaultBeforeNS) {$x = $x_when.$x;} else {$x = $x.$x_when;}
+ }
+ $BlockRes .= $x;
+ } else { // Without conditional blocks
+ $BlockRes .= $this->meth_Merge_SectionNormal($LocR,$Bid,$Src->CurrRec,$Src->RecNum,$Src->RecKey,$NoFct);
+ }
+ }
+
+ // Next row
+ if ($Src->RecNum===$RecStop) {
+ $Src->CurrRec = false;
+ } else {
+ // $CurrRec can be set to False by the OnSection event function.
+ if ($Src->CurrRec!==false) $Src->DataFetch();
+ }
+
+ } //--> while($CurrRec!==false) {
+
+ // Serial: merge the extra the sub-blocks
+ if ($SerialMode and !$SecIncr) {
+ $BlockRes .= $this->meth_Merge_SectionSerial($LocR,$SecId,$SerialNum,$SerialMax,$SerialTxt);
+ }
+
+ // Footer
+ if ($LocR->FooterFound) {
+ if ($Src->RecNum>0) {
+ for ($i=1;$i<=$LocR->FooterNbr;$i++) {
+ if ($LocR->FooterIsFooter[$i]) $BlockRes .= $this->meth_Merge_SectionNormal($LocR,$LocR->FooterBid[$i],$PrevRec,$PrevNum,$PrevKey,$NoFct);
+ }
+ }
+ }
+
+ // NoData
+ if (($Src->RecNum===0) and ($LocR->NoDataBid!==false)) $BlockRes = $LocR->BlockSrc[$LocR->NoDataBid];
+
+ // Merge the result
+ $Txt = substr_replace($Txt,$BlockRes,$LocR->PosBeg,$LocR->PosEnd-$LocR->PosBeg+1);
+
+}
+
+function meth_Merge_PhpVar(&$Txt,$HtmlConv) {
+// Merge the PHP global variables of the main script.
+
+ $Pref =& $this->VarPrefix;
+ $PrefL = strlen($Pref);
+ $PrefOk = ($PrefL>0);
+
+ if ($HtmlConv===false) {
+ $HtmlCharSet = $this->HtmlCharSet;
+ $this->HtmlCharSet = false;
+ }
+
+ // Then we scann all fields in the model
+ $x = '';
+ $Pos = 0;
+ while ($Loc = $this->meth_Locator_FindTbs($Txt,'var',$Pos,'.')) {
+ if ($Loc->SubNbr>0) {
+ if ($Loc->SubLst[0]==='') {
+ $Pos = $this->meth_Merge_System($Txt,$Loc);
+ } elseif ($Loc->SubLst[0][0]==='~') {
+ if (!isset($ObjOk)) $ObjOk = (is_object($this->ObjectRef) or is_array($this->ObjectRef));
+ if ($ObjOk) {
+ $Loc->SubLst[0] = substr($Loc->SubLst[0],1);
+ $Pos = $this->meth_Locator_Replace($Txt,$Loc,$this->ObjectRef,true);
+ } elseif (isset($Loc->PrmLst['noerr'])) {
+ $Pos = $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->ObjectRef).'\'.',true);
+ $Pos = $Loc->PosEnd + 1;
+ }
+ } elseif ($PrefOk and (substr($Loc->SubLst[0],0,$PrefL)!==$Pref)) {
+ if (isset($Loc->PrmLst['noerr'])) {
+ $Pos = $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 is set to \''.$Pref.'\'.',true);
+ $Pos = $Loc->PosEnd + 1;
+ }
+ } elseif (isset($GLOBALS[$Loc->SubLst[0]])) {
+ $Pos = $this->meth_Locator_Replace($Txt,$Loc,$GLOBALS,true);
+ } else {
+ if (isset($Loc->PrmLst['noerr'])) {
+ $Pos = $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+ } else {
+ $Pos = $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===false) $this->HtmlCharSet = $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 = mktime();
+ return $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+ case 'version':
+ $x = '2.05.8';
+ return $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+ case 'script_name':
+ if (isset($_SERVER)) { // PHP<4.1.0 compatibilty
+ $x = tbs_Misc_GetFilePart($_SERVER['PHP_SELF'],1);
+ } else {
+ global $HTTP_SERVER_VARS;
+ $x = 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 = filemtime($this->_LastFile);
+ return $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+ case 'template_path':
+ $x = tbs_Misc_GetFilePart($this->_LastFile,0);
+ return $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+ case 'name':
+ $x = 'TinyButStrong';
+ return $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+ case 'logo':
+ $x = '**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==2) {
+ $x = 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 = $Loc->SubNbr - 2;
+ return $this->meth_Locator_Replace($Txt,$Loc,$this->TplVars,true);
+ } else {
+ $this->meth_Misc_Alert('System Fields','Can\'t merge ['.$Loc->FullName.'] because property TplVars doesn\'t have any item named \''.$Loc->SubLst[2].'\'.');
+ return $Loc->PosBeg+1;
+ }
+ }
+ case '':
+ $this->meth_Misc_Alert('System Fields','Can\'t merge ['.$Loc->FullName.'] because it doesn\'t have any requested keyword.');
+ return $Loc->PosBeg+1;
+ default:
+ $this->meth_Misc_Alert('System Fields','Can\'t merge ['.$Loc->FullName.'] 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==='*') $Type = 'onload,onshow,var';
+
+ $TypeLst = 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,true); break;
+ }
+ }
+
+}
+
+function meth_Merge_SectionNormal(&$LocR,&$BlockId,&$CurrRec,&$RecNum,&$RecKey,&$NoFct) {
+
+ $Txt = $LocR->BlockSrc[$BlockId];
+
+ if ($NoFct) {
+ $LocLst =& $LocR->BlockLoc[$BlockId];
+ $iMax = $LocLst[0];
+ $PosMax = strlen($Txt);
+ $DoUnCached =& $LocR->BlockChk[$BlockId];
+ } else {
+ $Txt0 = $Txt;
+ $LocR->OnSecPrm[1] =& $CurrRec ; $LocR->OnSecPrm[2] =& $Txt; $LocR->OnSecPrm[3] =& $RecNum;
+ call_user_func_array($LocR->OnSecInfo,$LocR->OnSecPrm);
+ if ($Txt0===$Txt) {
+ $LocLst =& $LocR->BlockLoc[$BlockId];
+ $iMax = $LocLst[0];
+ $PosMax = strlen($Txt);
+ $DoUnCached =& $LocR->BlockChk[$BlockId];
+ } else {
+ $iMax = 0;
+ $DoUnCached = true;
+ }
+ }
+
+ if ($RecNum===false) { // Erase all fields
+
+ $x = '';
+
+ // Chached locators
+ for ($i=$iMax;$i>0;$i--) {
+ if ($LocLst[$i]->PosBeg<$PosMax) {
+ $this->meth_Locator_Replace($Txt,$LocLst[$i],$x,false);
+ if ($LocLst[$i]->Enlarged) {
+ $PosMax = $LocLst[$i]->PosBeg;
+ $LocLst[$i]->PosBeg = $LocLst[$i]->PosBeg0;
+ $LocLst[$i]->PosEnd = $LocLst[$i]->PosEnd0;
+ $LocLst[$i]->Enlarged = false;
+ }
+ }
+ }
+
+ // Unchached locators
+ if ($DoUnCached) {
+ $BlockName =& $LocR->BlockName[$BlockId];
+ $Pos = 0;
+ while ($Loc = $this->meth_Locator_FindTbs($Txt,$BlockName,$Pos,'.')) $Pos = $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+ }
+
+ } else {
+
+ // Chached locators
+ for ($i=$iMax;$i>0;$i--) {
+ if ($LocLst[$i]->PosBeg<$PosMax) {
+ if ($LocLst[$i]->IsRecInfo) {
+ if ($LocLst[$i]->RecInfo==='#') {
+ $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 = $LocLst[$i]->PosBeg;
+ $LocLst[$i]->PosBeg = $LocLst[$i]->PosBeg0;
+ $LocLst[$i]->PosEnd = $LocLst[$i]->PosEnd0;
+ $LocLst[$i]->Enlarged = false;
+ }
+ }
+ }
+
+ // Unchached locators
+ if ($DoUnCached) {
+ $BlockName =& $LocR->BlockName[$BlockId];
+ foreach ($CurrRec as $key => $val) {
+ $Pos = 0;
+ $Name = $BlockName.'.'.$key;
+ while ($Loc = $this->meth_Locator_FindTbs($Txt,$Name,$Pos,'.')) {
+ $Pos = $this->meth_Locator_Replace($Txt,$Loc,$val,true);
+ }
+ }
+ $Pos = 0;
+ $Name = $BlockName.'.#';
+ while ($Loc = $this->meth_Locator_FindTbs($Txt,$Name,$Pos,'.')) $Pos = $this->meth_Locator_Replace($Txt,$Loc,$RecNum,true);
+ $Pos = 0;
+ $Name = $BlockName.'.$';
+ while ($Loc = $this->meth_Locator_FindTbs($Txt,$Name,$Pos,'.')) $Pos = $this->meth_Locator_Replace($Txt,$Loc,$RecKey,true);
+ }
+
+ }
+
+ return $Txt;
+
+}
+
+function meth_Merge_SectionSerial(&$LocR,&$SecId,&$SerialNum,&$SerialMax,&$SerialTxt) {
+
+ $Txt = $LocR->BlockSrc[$LocR->SectionBid[$SecId]];
+ $LocLst =& $LocR->BlockLoc[$LocR->SectionBid[$SecId]];
+ $OrdLst =& $LocR->SectionSerialOrd[$SecId];
+
+ // Prepare the Empty Item
+ if ($SerialNum<$SerialMax) {
+ if ($LocR->SerialEmpty===false) {
+ $F = false;
+ $NoFct = true;
+ } else {
+ $EmptySrc =& $LocR->SerialEmpty;
+ }
+ }
+
+ // All Items
+ for ($i=$SerialMax;$i>0;$i--) {
+ $Sr = $OrdLst[$i];
+ if ($Sr>$SerialNum) {
+ if ($LocR->SerialEmpty===false) {
+ $k = $LocR->SectionSerialBid[$SecId][$Sr];
+ $EmptySrc = $this->meth_Merge_SectionNormal($LocR,$k,$F,$F,$F,$NoFct);
+ }
+ $Txt = substr_replace($Txt,$EmptySrc,$LocLst[$Sr]->PosBeg,$LocLst[$Sr]->PosEnd-$LocLst[$Sr]->PosBeg+1);
+ } else {
+ $Txt = substr_replace($Txt,$SerialTxt[$Sr],$LocLst[$Sr]->PosBeg,$LocLst[$Sr]->PosEnd-$LocLst[$Sr]->PosBeg+1);
+ }
+ }
+
+ // Update variables
+ $SerialNum = 0;
+ $SerialTxt = array();
+
+ return $Txt;
+
+}
+
+function meth_Merge_Auto(&$Txt,$Name,$TplVar,$AcceptGrp) {
+// onload - onshow
+
+ $GrpDisplayed = array();
+ $GrpExclusive = array();
+ $P1 = false;
+ $FieldBefore = false;
+ $Pos = 0;
+
+ if ($AcceptGrp) {
+ $ChrSub = '_';
+ } else {
+ $ChrSub = '';
+ }
+
+ while ($LocA=$this->meth_Locator_FindBlockNext($Txt,$Name,$Pos,$ChrSub,true,$P1,$FieldBefore)) {
+
+ if ($LocA->BlockFound) {
+
+ if (!isset($GrpDisplayed[$LocA->SubName])) {
+ $GrpDisplayed[$LocA->SubName] = false;
+ $GrpExclusive[$LocA->SubName] = !($AcceptGrp and ($LocA->SubName===''));
+ }
+ $Displayed =& $GrpDisplayed[$LocA->SubName];
+ $Exclusive =& $GrpExclusive[$LocA->SubName];
+
+ $DelBlock = false;
+ $DelField = false;
+ if ($Displayed and $Exclusive) {
+ $DelBlock = true;
+ } else {
+ if (isset($LocA->PrmLst['when'])) {
+ if (isset($LocA->PrmLst['several'])) $Exclusive=false;
+ $x = $LocA->PrmLst['when'];
+ $this->meth_Merge_PhpVar($x,false);
+ if (tbs_Misc_CheckCondition($x)) {
+ $DelField = true;
+ $Displayed = true;
+ } else {
+ $DelBlock = true;
+ }
+ } elseif(isset($LocA->PrmLst['default'])) {
+ if ($Displayed) {
+ $DelBlock = true;
+ } else {
+ $Displayed = true;
+ $DelField = true;
+ }
+ $Exclusive = true; // No more block displayed for the group after VisElse
+ }
+ }
+
+ // Del parts
+ if ($DelField) {
+ if ($LocA->PosBeg2!==false) $Txt = substr_replace($Txt,'',$LocA->PosBeg2,$LocA->PosEnd2-$LocA->PosBeg2+1);
+ $Txt = substr_replace($Txt,'',$LocA->PosBeg,$LocA->PosEnd-$LocA->PosBeg+1);
+ $Pos = $LocA->PosBeg;
+ } else {
+ if ($LocA->PosBeg2===false) {
+ tbs_Locator_EnlargeToTag($Txt,$LocA,$LocA->PrmLst['block'],true,false);
+ } else {
+ $LocA->PosEnd = $LocA->PosEnd2;
+ }
+ if ($DelBlock) {
+ $Txt = substr_replace($Txt,'',$LocA->PosBeg,$LocA->PosEnd-$LocA->PosBeg+1);
+ } else {
+ // Merge the block as if it was a field
+ $x = '';
+ $this->meth_Locator_Replace($Txt,$LocA,$x,false);
+ }
+ $Pos = $LocA->PosBeg;
+ }
+
+ } else { // Field
+
+ // Check for Template Var
+ if ($TplVar and isset($LocA->PrmLst['tplvars'])) {
+ $Ok = false;
+ foreach ($LocA->PrmLst as $Key => $Val) {
+ if ($Ok) {
+ $this->TplVars[$Key] = $Val;
+ } else {
+ if ($Key==='tplvars') $Ok = true;
+ }
+ }
+ }
+
+ $x = '';
+ $Pos = $this->meth_Locator_Replace($Txt,$LocA,$x,false);
+ $Pos = $LocA->PosBeg;
+
+ }
+
+ }
+
+ return count($GrpDisplayed);
+
+}
+
+function meth_Merge_NavigationBar(&$Txt,$BlockName,$Options,$PageCurr,$RecCnt,$PageSize) {
+
+ // Get block parameters
+ $PosBeg = 0;
+ $PrmLst = array();
+ while ($Loc = $this->meth_Locator_FindTbs($Txt,$BlockName,$PosBeg,'.')) {
+ if (isset($Loc->PrmLst['block'])) $PrmLst = array_merge($PrmLst,$Loc->PrmLst);
+ $PosBeg = $Loc->PosEnd;
+ }
+
+ // Prepare options
+ if (!is_array($Options)) $Options = array('navsize'=>intval($Options));
+ $Options = array_merge($Options,$PrmLst);
+
+ // Default options
+ if (!isset($Options['navsize'])) $Options['navsize'] = 10;
+ if (!isset($Options['navpos'])) $Options['navpos'] = 'step';
+ if (!isset($Options['navdel'])) $Options['navdel'] = '';
+ if (!isset($Options['pagemin'])) $Options['pagemin'] = 1;
+
+ // Check options
+ if ($Options['navsize']<=0) $Options['navsize'] = 10;
+ if ($PageSize<=0) $PageSize = 1;
+ if ($PageCurr<$Options['pagemin']) $PageCurr = $Options['pagemin'];
+
+ $CurrPos = 0;
+ $CurrNav = array('curr'=>$PageCurr,'first'=>$Options['pagemin'],'last'=>-1,'bound'=>false);
+
+ // Calculate displayed PageMin and PageMax
+ if ($Options['navpos']=='centred') {
+ $PageMin = $Options['pagemin']-1+$PageCurr - intval(floor($Options['navsize']/2));
+ } else {
+ // Display by block
+ $PageMin = $Options['pagemin']-1+$PageCurr - ( ($PageCurr-1) % $Options['navsize']);
+ }
+ $PageMin = max($PageMin,$Options['pagemin']);
+ $PageMax = $PageMin + $Options['navsize'] - 1;
+
+ // Calculate previous and next pages
+ $CurrNav['prev'] = $PageCurr - 1;
+ if ($CurrNav['prev']<$Options['pagemin']) {
+ $CurrNav['prev'] = $Options['pagemin'];
+ $CurrNav['bound'] = $Options['pagemin'];
+ }
+ $CurrNav['next'] = $PageCurr + 1;
+ if ($RecCnt>=0) {
+ $PageCnt = $Options['pagemin']-1 + intval(ceil($RecCnt/$PageSize));
+ $PageMax = min($PageMax,$PageCnt);
+ $PageMin = max($Options['pagemin'],$PageMax-$Options['navsize']+1);
+ } else {
+ $PageCnt = $Options['pagemin']-1;
+ }
+ if ($PageCnt>=$Options['pagemin']) {
+ if ($PageCurr>=$PageCnt) {
+ $CurrNav['next'] = $PageCnt;
+ $CurrNav['last'] = $PageCnt;
+ $CurrNav['bound'] = $PageCnt;
+ } else {
+ $CurrNav['last'] = $PageCnt;
+ }
+ }
+
+ // Display or hide the bar
+ if ($Options['navdel']=='') {
+ $Display = true;
+ } else {
+ $Display = (($PageMax-$PageMin)>0);
+ }
+
+ // Merge general information
+ $Pos = 0;
+ while ($Loc = $this->meth_Locator_FindTbs($Txt,$BlockName,$Pos,'.')) {
+ $Pos = $Loc->PosBeg + 1;
+ $x = strtolower($Loc->SubName);
+ if (isset($CurrNav[$x])) {
+ $Val = $CurrNav[$x];
+ if ($CurrNav[$x]==$CurrNav['bound']) {
+ if (isset($Loc->PrmLst['endpoint'])) {
+ $Val = '';
+ }
+ }
+ $this->meth_Locator_Replace($Txt,$Loc,$Val,false);
+ }
+ }
+
+ // Merge pages
+ $Query = '';
+ if ($Display) {
+ $Data = array();
+ $RecSpe = 0;
+ $RecCurr = 0;
+ for ($PageId=$PageMin;$PageId<=$PageMax;$PageId++) {
+ $RecCurr++;
+ if ($PageId==$PageCurr) $RecSpe = $RecCurr;
+ $Data[] = array('page'=>$PageId);
+ }
+ $this->meth_Merge_Block($Txt,$BlockName,$Data,$Query,0,0,$RecSpe);
+ if ($Options['navdel']!='') { // Delete the block definition tags
+ $PosBeg = 0;
+ while ($Loc = $this->meth_Locator_FindTbs($Txt,$Options['navdel'],$PosBeg,'.')) {
+ $PosBeg = $Loc->PosBeg;
+ $Txt = substr_replace($Txt,'',$Loc->PosBeg,$Loc->PosEnd-$Loc->PosBeg+1);
+ }
+ }
+ } else {
+ if ($Options['navdel']!='') {
+ $SrcType = '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==='') {
+ $Txt = htmlspecialchars($Txt); // Faster
+ } elseif ($this->_HtmlCharFct) {
+ $Txt = call_user_func($this->HtmlCharSet,$Txt);
+ } else {
+ $Txt = 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=false) {
+ $x = '<br /><b>TinyButStrong Error</b> ('.$Source.'): '.htmlentities($Message);
+ if ($NoErrMsg) $x = $x.' <em>This message can be cancelled using parameter \'noerr\'.</em>';
+ $x = $x."<br />\n";
+ $x = 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 =& $this->Source;
+ $Loc->SaveRender = $this->Render;
+ $Loc->SaveCache = $this->_CacheFile;
+ $Loc->SaveMode = $this->_Mode;
+ unset($this->Source); $this->Source = '';
+ $this->Render = TBS_OUTPUT;
+ $this->_CacheFile = false;
+ $this->_Mode = 1;
+ $File = $Loc->PrmLst['subtpl'];
+ if (is_string($File) and (strlen($File)>0)) {
+ $this->meth_Merge_PhpVar($File,false);
+ $File = 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('Parameter subtpl','Unable to read the file \''.$File.'\'.');
+ }
+ }
+ }
+ if ($GetOb) ob_start();
+ } else {
+ // Restore contents configuration
+ if ($Switch) {
+ $this->Source =& $Loc->SaveSrc;
+ $this->Render = $Loc->SaveRender;
+ $this->_CacheFile = $Loc->SaveCache;
+ $this->_Mode = $Loc->SaveMode;
+ }
+ if ($GetOb) {
+ $CurrVal = ob_get_contents();
+ ob_end_clean();
+ }
+ $Loc->ConvHtml = false;
+ $Loc->ConvProtect = false;
+ }
+}
+
+function meth_Misc_UserFctCheck(&$FctInfo,&$ErrMsg) {
+ if (substr($FctInfo,0,1)==='~') {
+ $ObjRef =& $this->ObjectRef;
+ $Lst = explode('.',substr($FctInfo,1));
+ $iMax = count($Lst) - 1;
+ for ($i=0;$i<=$iMax;$i++) {
+ $x =& $Lst[$i];
+ if (is_object($ObjRef)) {
+ if (method_exists($ObjRef,$x)) {
+ if ($i===$iMax) {
+ $FctInfo = array(&$ObjRef,$x);
+ } else {
+ $ObjRef = call_user_func(array(&$ObjRef,$x));
+ }
+ } elseif ($i===$iMax) {
+ $ErrMsg = 'Expression \''.$FctInfo.'\' is invalid because \''.$x.'\' is not a method in the class \''.get_class($ObjRef).'\'.';
+ return false;
+ } elseif (isset($ObjRef->$x)) {
+ $ObjRef =& $ObjRef->$x;
+ } else {
+ $ErrMsg = 'Expression \''.$FctInfo.'\' is invalid because sub-item \''.$x.'\' is neither a method nor a property in the class \''.get_class($ObjRef).'\'.';
+ return false;
+ }
+ } elseif (($i<$iMax) and is_array($ObjRef)) {
+ if (isset($ObjRef[$x])) {
+ $ObjRef =& $ObjRef[$x];
+ } else {
+ $ErrMsg = 'Expression \''.$FctInfo.'\' is invalid because sub-item \''.$x.'\' is not a existing key in the array.';
+ return false;
+ }
+ } else {
+ $ErrMsg = 'Expression \''.$FctInfo.'\' is invalid because '.(($i===0)?'property ObjectRef':'sub-item \''.$x.'\'').' is not an object'.(($i<$iMax)?' or an array.':'.');
+ return false;
+ }
+ }
+ } else {
+ if (!function_exists($FctInfo)) {
+ $ErrMsg = 'Custom function \''.$FctInfo.'\' is not found.';
+ return false;
+ }
+ }
+ return true;
+}
+
+function meth_Cache_Save($CacheFile,&$Txt) {
+ $fid = @fopen($CacheFile, 'w');
+ if ($fid===false) {
+ $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===false) {
+ $Loc->ConvSpe = true;
+ $Loc->ConvEsc = false;
+ $Loc->ConvWS = false;
+ $Loc->ConvJS = false;
+ $Loc->ConvLook = false;
+ }
+}
+
+function tbs_Misc_GetStrId($Txt) {
+ $Txt = strtolower($Txt);
+ $Txt = str_replace('-','_',$Txt);
+ $x = '';
+ $i = 0;
+ $iMax = strlen($Txt2);
+ while ($i<$iMax) {
+ if (($Txt[$i]==='_') or (($Txt[$i]>='a') and ($Txt[$i]<='z')) or (($Txt[$i]>='0') and ($Txt[$i]<='9'))) {
+ $x .= $Txt[$i];
+ $i++;
+ } else {
+ $i = $iMax;
+ }
+ }
+ return $x;
+}
+
+function tbs_Misc_CheckCondition($Str) {
+// Check if an expression like "exrp1=expr2" is true or false.
+
+ // Find operator and position
+ $Ope = '=';
+ $Len = 1;
+ $Max = strlen($Str)-1;
+ $Pos = strpos($Str,$Ope);
+ if ($Pos===false) {
+ $Ope = '+';
+ $Pos = strpos($Str,$Ope);
+ if ($Pos===false) return false;
+ if (($Pos>0) and ($Str[$Pos-1]==='-')) {
+ $Ope = '-+'; $Pos--; $Len=2;
+ } elseif (($Pos<$Max) and ($Str[$Pos+1]==='-')) {
+ $Ope = '+-'; $Len=2;
+ } else {
+ return false;
+ }
+ } else {
+ if ($Pos>0) {
+ $x = $Str[$Pos-1];
+ if ($x==='!') {
+ $Ope = '!='; $Pos--; $Len=2;
+ } elseif ($Pos<$Max) {
+ $y = $Str[$Pos+1];
+ if ($y==='=') {
+ $Len=2;
+ } elseif (($x==='+') and ($y==='-')) {
+ $Ope = '+=-'; $Pos--; $Len=3;
+ } elseif (($x==='-') and ($y==='+')) {
+ $Ope = '-=+'; $Pos--; $Len=3;
+ }
+ } else {
+ }
+ }
+ }
+
+ // Read values
+ $Val1 = trim(substr($Str,0,$Pos));
+ $Nude1 = tbs_Misc_DelDelimiter($Val1,'\'');
+ $Val2 = trim(substr($Str,$Pos+$Len));
+ $Nude2 = tbs_Misc_DelDelimiter($Val2,'\'');
+
+ // Compare values
+ if ($Ope==='=') {
+ return (strcasecmp($Val1,$Val2)==0);
+ } elseif ($Ope==='!=') {
+ return (strcasecmp($Val1,$Val2)!=0);
+ } else {
+ if ($Nude1) $Val1 = (float) $Val1;
+ if ($Nude2) $Val2 = (float) $Val2;
+ if ($Ope==='+-') {
+ return ($Val1>$Val2);
+ } elseif ($Ope==='-+') {
+ return ($Val1 < $Val2);
+ } elseif ($Ope==='+=-') {
+ return ($Val1 >= $Val2);
+ } elseif ($Ope==='-=+') {
+ return ($Val1<=$Val2);
+ } else {
+ return false;
+ }
+ }
+
+}
+
+function tbs_Misc_DelDelimiter(&$Txt,$Delim) {
+// Delete the string delimiters
+ $len = strlen($Txt);
+ if (($len>1) and ($Txt[0]===$Delim)) {
+ if ($Txt[$len-1]===$Delim) $Txt = 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 = '';
+ $fd = @fopen($File, 'r'); // 'rb' if binary for some OS
+ if ($fd===false) return false;
+ $fs = @filesize($File); // return False for an URL
+ if ($fs===false) {
+ while (!feof($fd)) $Txt .= fread($fd,4096);
+ } else {
+ if ($fs>0) $Txt = fread($fd,$fs);
+ }
+ fclose($fd);
+ return true;
+}
+
+function tbs_Misc_GetFilePart($File,$Part) {
+ $Pos = strrpos($File,'/');
+ if ($Part===0) { // Path
+ if ($Pos===false) {
+ return '';
+ } else {
+ return substr($File,0,$Pos+1);
+ }
+ } else { // File
+ if ($Pos===false) {
+ 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 numeric variable using a 'VB like' format syntax instead of the PHP syntax.
+
+ global $_tbs_FrmSimpleLst;
+
+ $FrmStr = $Loc->PrmLst['frm'];
+ $CheckNumeric = true;
+ if (is_string($Value)) $Value = trim($Value);
+
+ // Manage Multi format strings
+ if (strpos($FrmStr,'|')!==false) {
+
+ global $_tbs_FrmMultiLst;
+
+ // Save the format if it doesn't exist
+ if (isset($_tbs_FrmMultiLst[$FrmStr])) {
+ $FrmLst =& $_tbs_FrmMultiLst[$FrmStr];
+ } else {
+ $FrmLst = explode('|',$FrmStr); // syntax : PostiveFrm|NegativeFrm|ZeroFrm|NullFrm
+ $FrmNbr = count($FrmLst);
+ if (($FrmNbr<=1) or ($FrmLst[1]==='')) {
+ $FrmLst[1] =& $FrmLst[0]; // negativ
+ $FrmLst['abs'] = false;
+ } else {
+ $FrmLst['abs'] = true;
+ }
+ if (($FrmNbr<=2) or ($FrmLst[2]==='')) $FrmLst[2] =& $FrmLst[0]; // zero
+ if (($FrmNbr<=3) or ($FrmLst[3]==='')) $FrmLst[3] = ''; // null
+ $_tbs_FrmMultiLst[$FrmStr] = $FrmLst;
+ }
+
+ // Select the format
+ if (is_numeric($Value)) {
+ if (is_string($Value)) $Value = 0.0 + $Value;
+ if ($Value>0) {
+ $FrmStr =& $FrmLst[0];
+ } elseif ($Value<0) {
+ $FrmStr =& $FrmLst[1];
+ if ($FrmLst['abs']) $Value = abs($Value);
+ } else { // zero
+ $FrmStr =& $FrmLst[2];
+ $Minus = '';
+ }
+ $CheckNumeric = false;
+ } else {
+ $Value = ''.$Value;
+ if ($Value==='') {
+ return $FrmLst[3]; // Null value
+ } else {
+ $t = strtotime($Value); // We look if it's a date
+ if ($t===-1) { // Date not recognized
+ return $FrmLst[1];
+ } elseif ($t===943916400) { // Date to zero
+ return $FrmLst[2];
+ } else { // It's a date
+ $Value = $t;
+ $FrmStr =& $FrmLst[0];
+ }
+ }
+ }
+
+ }
+
+ if ($FrmStr==='') return ''.$Value;
+
+ // Retrieve the correct simple format
+ if (!isset($_tbs_FrmSimpleLst[$FrmStr])) tbs_Misc_FormatSave($FrmStr);
+
+ $Frm =& $_tbs_FrmSimpleLst[$FrmStr];
+
+ switch ($Frm['type']) {
+ case 'num' :
+ // NUMERIC
+ if ($CheckNumeric) {
+ if (is_numeric($Value)) {
+ if (is_string($Value)) $Value = 0.0 + $Value;
+ } else {
+ return ''.$Value;
+ }
+ }
+ if ($Frm['PerCent']) $Value = $Value * 100;
+ $Value = number_format($Value,$Frm['DecNbr'],$Frm['DecSep'],$Frm['ThsSep']);
+ return substr_replace($FrmStr,$Value,$Frm['Pos'],$Frm['Len']);
+ break;
+ case 'date' :
+ // DATE
+ if (is_string($Value)) {
+ if ($Value==='') return '';
+ $x = strtotime($Value);
+ if ($x===-1) {
+ if (!is_numeric($Value)) $Value = 0;
+ } else {
+ $Value =& $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 = strrpos($FrmStr,'0');
+
+ if ($nPosEnd!==false) {
+
+ // Numeric format
+ $nDecSep = '.';
+ $nDecNbr = 0;
+ $nDecOk = true;
+
+ if (substr($FrmStr,$nPosEnd+1,1)==='.') {
+ $nPosEnd++;
+ $nPosCurr = $nPosEnd;
+ } else {
+ $nPosCurr = $nPosEnd - 1;
+ while (($nPosCurr>=0) and ($FrmStr[$nPosCurr]==='0')) {
+ $nPosCurr--;
+ }
+ if (($nPosCurr>=1) and ($FrmStr[$nPosCurr-1]==='0')) {
+ $nDecSep = $FrmStr[$nPosCurr];
+ $nDecNbr = $nPosEnd - $nPosCurr;
+ } else {
+ $nDecOk = false;
+ }
+ }
+
+ // Thousand separator
+ $nThsSep = '';
+ if (($nDecOk) and ($nPosCurr>=5)) {
+ if ((substr($FrmStr,$nPosCurr-3,3)==='000') and ($FrmStr[$nPosCurr-4]!=='') and ($FrmStr[$nPosCurr-5]==='0')) {
+ $nPosCurr = $nPosCurr-4;
+ $nThsSep = $FrmStr[$nPosCurr];
+ }
+ }
+
+ // Pass next zero
+ if ($nDecOk) $nPosCurr--;
+ while (($nPosCurr>=0) and ($FrmStr[$nPosCurr]==='0')) {
+ $nPosCurr--;
+ }
+
+ // Percent
+ $nPerCent = (strpos($FrmStr,'%')===false) ? false : true;
+
+ $_tbs_FrmSimpleLst[$FrmStr] = array('type'=>'num','Pos'=>($nPosCurr+1),'Len'=>($nPosEnd-$nPosCurr),'ThsSep'=>$nThsSep,'DecSep'=>$nDecSep,'DecNbr'=>$nDecNbr,'PerCent'=>$nPerCent);
+
+ } else { // if ($nPosEnd!==false)
+
+ // Date format
+ $FrmPHP = '';
+ $FrmLOC = '';
+ $Local = false;
+ $StrIn = false;
+ $iMax = strlen($FrmStr);
+ $Cnt = 0;
+
+ for ($i=0;$i<$iMax;$i++) {
+
+ if ($StrIn) {
+ // We are in a string part
+ if ($FrmStr[$i]===$StrChr) {
+ if (substr($FrmStr,$i+1,1)===$StrChr) {
+ $FrmPHP .= '\\'.$FrmStr[$i]; // protected char
+ $FrmLOC .= $FrmStr[$i];
+ $i++;
+ } else {
+ $StrIn = false;
+ }
+ } else {
+ $FrmPHP .= '\\'.$FrmStr[$i]; // protected char
+ $FrmLOC .= $FrmStr[$i];
+ }
+ } else {
+ if (($FrmStr[$i]==='"') or ($FrmStr[$i]==='\'')) {
+ // Check if we have the opening string char
+ $StrIn = true;
+ $StrChr = $FrmStr[$i];
+ } else {
+ $Cnt++;
+ if (strcasecmp(substr($FrmStr,$i,4),'yyyy')===0) { $FrmPHP .= 'Y'; $FrmLOC .= '%Y'; $i += 3; }
+ elseif (strcasecmp(substr($FrmStr,$i,2),'yy' )===0) { $FrmPHP .= 'y'; $FrmLOC .= '%y'; $i += 1; }
+ elseif (strcasecmp(substr($FrmStr,$i,4),'mmmm')===0) { $FrmPHP .= 'F'; $FrmLOC .= '%B'; $i += 3; }
+ elseif (strcasecmp(substr($FrmStr,$i,3),'mmm' )===0) { $FrmPHP .= 'M'; $FrmLOC .= '%b'; $i += 2; }
+ elseif (strcasecmp(substr($FrmStr,$i,2),'mm' )===0) { $FrmPHP .= 'm'; $FrmLOC .= '%m'; $i += 1; }
+ elseif (strcasecmp(substr($FrmStr,$i,1),'m' )===0) { $FrmPHP .= 'n'; $FrmLOC .= '%m'; }
+ elseif (strcasecmp(substr($FrmStr,$i,4),'wwww')===0) { $FrmPHP .= 'l'; $FrmLOC .= '%A'; $i += 3; }
+ elseif (strcasecmp(substr($FrmStr,$i,3),'www' )===0) { $FrmPHP .= 'D'; $FrmLOC .= '%a'; $i += 2; }
+ elseif (strcasecmp(substr($FrmStr,$i,1),'w' )===0) { $FrmPHP .= 'w'; $FrmLOC .= '%u'; }
+ elseif (strcasecmp(substr($FrmStr,$i,4),'dddd')===0) { $FrmPHP .= 'l'; $FrmLOC .= '%A'; $i += 3; }
+ elseif (strcasecmp(substr($FrmStr,$i,3),'ddd' )===0) { $FrmPHP .= 'D'; $FrmLOC .= '%a'; $i += 2; }
+ elseif (strcasecmp(substr($FrmStr,$i,2),'dd' )===0) { $FrmPHP .= 'd'; $FrmLOC .= '%d'; $i += 1; }
+ elseif (strcasecmp(substr($FrmStr,$i,1),'d' )===0) { $FrmPHP .= 'j'; $FrmLOC .= '%d'; }
+ elseif (strcasecmp(substr($FrmStr,$i,2),'hh' )===0) { $FrmPHP .= 'H'; $FrmLOC .= '%H'; $i += 1; }
+ elseif (strcasecmp(substr($FrmStr,$i,2),'nn' )===0) { $FrmPHP .= 'i'; $FrmLOC .= '%M'; $i += 1; }
+ elseif (strcasecmp(substr($FrmStr,$i,2),'ss' )===0) { $FrmPHP .= 's'; $FrmLOC .= '%S'; $i += 1; }
+ elseif (strcasecmp(substr($FrmStr,$i,2),'xx' )===0) { $FrmPHP .= 'S'; $FrmLOC .= '' ; $i += 1; }
+ else {
+ $FrmPHP .= '\\'.$FrmStr[$i]; // protected char
+ $FrmLOC .= $FrmStr[$i]; // protected char
+ $Cnt--;
+ }
+ }
+ } //-> if ($StrIn) {...} else
+
+ } //-> for ($i=0;$i<$iMax;$i++)
+
+ if ($Cnt>0) {
+ $_tbs_FrmSimpleLst[$FrmStr] = array('type'=>'date','str_us'=>$FrmPHP,'str_loc'=>$FrmLOC);
+ } else {
+ $_tbs_FrmSimpleLst[$FrmStr] = array('type'=>'else','string'=>$FrmStr);
+ }
+
+ } // if ($nPosEnd!==false) {...} else
+
+}
+
+function tbs_Locator_SectionAddBlk(&$LocR,$BlockName,$Txt) {
+ $LocR->BlockNbr++;
+ $LocR->BlockName[$LocR->BlockNbr] = $BlockName;
+ $LocR->BlockSrc[$LocR->BlockNbr] = $Txt;
+ $LocR->BlockLoc[$LocR->BlockNbr] = array(0=>0);
+ $LocR->BlockChk[$LocR->BlockNbr] = true;
+ return $LocR->BlockNbr;
+}
+
+function tbs_Locator_SectionAddGrp(&$LocR,$Bid,$Type,$Field) {
+
+ if ($Type==='H') {
+ if ($LocR->HeaderFound===false) {
+ $LocR->HeaderFound = true;
+ $LocR->HeaderNbr = 0;
+ $LocR->HeaderBid = array(); // 1 to HeaderNbr
+ $LocR->HeaderPrevValue = array(); // 1 to HeaderNbr
+ $LocR->HeaderField = array(); // 1 to HeaderNbr
+ }
+ $LocR->HeaderNbr++;
+ $LocR->HeaderBid[$LocR->HeaderNbr] = $Bid;
+ $LocR->HeaderPrevValue[$LocR->HeaderNbr] = false;
+ $LocR->HeaderField[$LocR->HeaderNbr] = $Field;
+ } else {
+ if ($LocR->FooterFound===false) {
+ $LocR->FooterFound = true;
+ $LocR->FooterNbr = 0;
+ $LocR->FooterBid = array(); // 1 to FooterNbr
+ $LocR->FooterPrevValue = array(); // 1 to FooterNbr
+ $LocR->FooterField = array(); // 1 to FooterNbr
+ $LocR->FooterIsFooter = array(); // 1 to FooterNbr
+ }
+ $LocR->FooterNbr++;
+ $LocR->FooterBid[$LocR->FooterNbr] = $Bid;
+ $LocR->FooterPrevValue[$LocR->FooterNbr] = false;
+ if ($Type==='F') {
+ $LocR->FooterField[$LocR->FooterNbr] = $Field;
+ $LocR->FooterIsFooter[$LocR->FooterNbr] = true;
+ } else {
+ $LocR->FooterField[$LocR->FooterNbr] = $Field;
+ $LocR->FooterIsFooter[$LocR->FooterNbr] = false;
+ }
+ }
+
+}
+
+function tbs_Locator_PrmRead(&$Txt,$Pos,$HtmlTag,$DelimChrs,$BegStr,$EndStr,&$Loc,&$PosEnd) {
+
+ // � mettre dans la classe TBS
+ $BegLen = strlen($BegStr);
+ $BegChr = $BegStr[0];
+ $BegIs1 = ($BegLen===1);
+
+ $DelimIdx = false;
+ $DelimCnt = 0;
+ $DelimChr = '';
+ $BegCnt = 0;
+ $SubName = $Loc->SubOk;
+
+ $Status = 0; // 0: name not started, 1: name started, 2: name ended, 3: equal found, 4: value started
+ $PosName = 0;
+ $PosNend = 0;
+ $PosVal = 0;
+
+ // Param�tres de v�rif de la boucle
+ $PosEnd = strpos($Txt,$EndStr,$Pos);
+ if ($PosEnd===false) return;
+ $Continue = ($Pos<$PosEnd);
+
+ while ($Continue) {
+
+ $Chr = $Txt[$Pos];
+
+ if ($DelimIdx) { // Lecture dans une cha�ne
+
+ if ($Chr===$DelimChr) { // Quote rencontr�
+ if ($Chr===$Txt[$Pos+1]) { // Double quote => la cha�ne continue en d�doublant le quote
+ $Pos++;
+ } else { // Simple quote => fin de la cha�ne
+ $DelimIdx = false;
+ }
+ }
+
+ } else { // Lecture hors cha�ne
+
+ if ($BegCnt===0) {
+
+ // Analyse des param�tre
+ $CheckChr = false;
+ if ($Chr===' ') {
+ if ($Status===1) {
+ $Status = 2;
+ $PosNend = $Pos;
+ } elseif ($HtmlTag and ($Status===4)) {
+ tbs_Locator_PrmCompute($Txt,$Loc,$SubName,$Status,$HtmlTag,$DelimChr,$DelimCnt,$PosName,$PosNend,$PosVal,$Pos);
+ $Status = 0;
+ }
+ } elseif (($HtmlTag===false) and ($Chr===';')) {
+ tbs_Locator_PrmCompute($Txt,$Loc,$SubName,$Status,$HtmlTag,$DelimChr,$DelimCnt,$PosName,$PosNend,$PosVal,$Pos);
+ $Status = 0;
+ } elseif ($Status===4) {
+ $CheckChr = true;
+ } elseif ($Status===3) {
+ $Status = 4;
+ $DelimCnt = 0;
+ $PosVal = $Pos;
+ $CheckChr = true;
+ } elseif ($Status===2) {
+ if ($Chr==='=') {
+ $Status = 3;
+ } elseif ($HtmlTag) {
+ tbs_Locator_PrmCompute($Txt,$Loc,$SubName,$Status,$HtmlTag,$DelimChr,$DelimCnt,$PosName,$PosNend,$PosVal,$Pos);
+ $Status = 1;
+ $PosName = $Pos;
+ $CheckChr = true;
+ } else {
+ $Status = 4;
+ $DelimCnt = 0;
+ $PosVal = $Pos;
+ $CheckChr = true;
+ }
+ } elseif ($Status===1) {
+ if ($Chr==='=') {
+ $Status = 3;
+ $PosNend = $Pos;
+ } else {
+ $CheckChr = true;
+ }
+ } else {
+ $Status = 1;
+ $PosName = $Pos;
+ $CheckChr = true;
+ }
+
+ if ($CheckChr) {
+ $DelimIdx = strpos($DelimChrs,$Chr);
+ if ($DelimIdx===false) {
+ if ($Chr===$BegChr) {
+ if ($BegIs1) {
+ $BegCnt++;
+ } elseif(substr($Txt,$Pos,$BegLen)===$BegStr) {
+ $BegCnt++;
+ }
+ }
+ } else {
+ $DelimChr = $DelimChrs[$DelimIdx];
+ $DelimCnt++;
+ $DelimIdx = true;
+ }
+ }
+
+ } else {
+ if ($Chr===$BegChr) {
+ if ($BegIs1) {
+ $BegCnt++;
+ } elseif(substr($Txt,$Pos,$BegLen)===$BegStr) {
+ $BegCnt++;
+ }
+ }
+ }
+
+ }
+
+ // Charact�re suivant
+ $Pos++;
+
+ // On v�rifie si c'est la fin
+ if ($Pos===$PosEnd) {
+ if ($DelimIdx===false) {
+ if ($BegCnt>0) {
+ $BegCnt--;
+ } else {
+ $Continue = false;
+ }
+ }
+ if ($Continue) {
+ $PosEnd = strpos($Txt,$EndStr,$PosEnd+1);
+ if ($PosEnd===false) return;
+ } else {
+ tbs_Locator_PrmCompute($Txt,$Loc,$SubName,$Status,$HtmlTag,$DelimChr,$DelimCnt,$PosName,$PosNend,$PosVal,$Pos);
+ }
+ }
+
+ }
+
+ $PosEnd = $PosEnd + (strlen($EndStr)-1);
+
+}
+
+function tbs_Locator_PrmCompute(&$Txt,&$Loc,&$SubName,$Status,$HtmlTag,$DelimChr,$DelimCnt,$PosName,$PosNend,$PosVal,$Pos) {
+
+ if ($Status===0) {
+ $SubName = false;
+ } else {
+ if ($Status===1) {
+ $x = substr($Txt,$PosName,$Pos-$PosName);
+ } else {
+ $x = substr($Txt,$PosName,$PosNend-$PosName);
+ }
+ if ($HtmlTag) $x = strtolower($x);
+ if ($SubName) {
+ $Loc->SubName = $x;
+ $SubName = false;
+ } elseif ($Status===4) {
+ $v = trim(substr($Txt,$PosVal,$Pos-$PosVal));
+ if ($DelimCnt===1) { // Delete quotes inside the value
+ if ($v[0]===$DelimChr) {
+ $len = strlen($v);
+ if ($v[$len-1]===$DelimChr) {
+ $v = substr($v,1,$len-2);
+ $v = str_replace($DelimChr.$DelimChr,$DelimChr,$v);
+ }
+ }
+ }
+ $Loc->PrmLst[$x] = $v;
+ } else {
+ $Loc->PrmLst[$x] = 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 = $Loc->PosBeg;
+ $Ok = false;
+ do {
+ $Pos = strrpos(substr($Txt,0,$Pos),$StrBeg[0]);
+ if ($Pos!==false) {
+ if (substr($Txt,$Pos,strlen($StrBeg))===$StrBeg) $Ok = true;
+ }
+ } while ( (!$Ok) and ($Pos!==false) );
+
+ if ($Ok) {
+ $PosEnd = strpos($Txt,$StrEnd,$Loc->PosEnd + 1);
+ if ($PosEnd===false) {
+ $Ok = false;
+ } else {
+ $Loc->PosBeg = $Pos;
+ $Loc->PosEnd = $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=true
+
+ if ($Tag==='') { return false; }
+ elseif ($Tag==='row') {$Tag = 'tr'; }
+ elseif ($Tag==='opt') {$Tag = 'option'; }
+
+ $RetVal = true;
+ $Encaps = 1;
+ if ($IsBlock and isset($Loc->PrmLst['encaps'])) $Encaps = abs(intval($Loc->PrmLst['encaps']));
+
+ $TagO = tbs_Html_FindTag($Txt,$Tag,true,$Loc->PosBeg-1,false,$Encaps,false);
+ if ($TagO===false) return false;
+ $TagC = tbs_Html_FindTag($Txt,$Tag,false,$Loc->PosEnd+1,true,$Encaps,false);
+ if ($TagC==false) return false;
+ $PosBeg = $TagO->PosBeg;
+ $PosEnd = $TagC->PosEnd;
+
+ if ($IsBlock) {
+
+ $ExtendFw = false;
+ $ExtendBw = false;
+ if (isset($Loc->PrmLst['extend'])) {
+ $s = ',';
+ $x = str_replace(' ','',''.$Loc->PrmLst['extend']);
+ if (is_numeric($x)) {
+ $x = intval($Loc->PrmLst['extend']);
+ if ($x>0) {
+ $lst =& $ExtendFw;
+ } else {
+ $lst =& $ExtendBw;
+ }
+ $x = str_repeat($Tag.$s,abs($x));
+ } else {
+ $lst =& $ExtendFw;
+ }
+ $lst = explode($s,$x);
+ }
+
+ if ($ExtendFw!==false) { // Forward
+ $TagC = true;
+ foreach ($ExtendFw as $Tag) {
+ if (($Tag!=='') and ($TagC!==false)) {
+ $TagO = tbs_Html_FindTag($Txt,$Tag,true,$PosEnd+1,true,1,false);
+ if ($TagO!==false) {
+ $TagC = tbs_Html_FindTag($Txt,$Tag,false,$TagO->PosEnd+1,true,0,false);
+ if ($TagC!==false) {
+ $PosEnd = $TagC->PosEnd;
+ }
+ }
+ }
+ }
+ }
+
+ if ($ExtendBw!==false) { // Backward
+ $TagO = true;
+ for ($i=count($ExtendBw)-1;$i>=0;$i--) {
+ $Tag = $ExtendBw[$i];
+ if (($Tag!=='') and ($TagO!==false)) {
+ $TagC = tbs_Html_FindTag($Txt,$Tag,false,$PosBeg-1,false,1,false);
+ if ($TagC!==false) {
+ $TagO = tbs_Html_FindTag($Txt,$Tag,true,$TagC->PosBeg-1,false,0,false);
+ if ($TagO!==false) {
+ $PosBeg = $TagO->PosBeg;
+ }
+ }
+ }
+ }
+ }
+
+ } elseif ($ReturnSrc) {
+
+ $RetVal = '';
+ if ($Loc->PosBeg>$TagO->PosEnd) $RetVal .= substr($Txt,$TagO->PosEnd+1,min($Loc->PosBeg,$TagC->PosBeg)-$TagO->PosEnd-1);
+ if ($Loc->PosEnd<$TagC->PosBeg) $RetVal .= substr($Txt,max($Loc->PosEnd,$TagO->PosEnd)+1,$TagC->PosBeg-max($Loc->PosEnd,$TagO->PosEnd)-1);
+
+ }
+
+ $Loc->PosBeg = $PosBeg;
+ $Loc->PosEnd = $PosEnd;
+ return $RetVal;
+
+}
+
+function tbs_Html_Max(&$Txt,&$Nbr) {
+// Limit the number of HTML chars
+
+ $pMax = strlen($Txt)-1;
+ $p=0;
+ $n=0;
+ $in = false;
+ $ok = true;
+
+ while ($ok) {
+ if ($in) {
+ if ($Txt[$p]===';') {
+ $in = false;
+ $n++;
+ }
+ } else {
+ if ($Txt[$p]==='&') {
+ $in = true;
+ } else {
+ $n++;
+ }
+ }
+ if (($n>=$Nbr) or ($p>=$pMax)) {
+ $ok = false;
+ } else {
+ $p++;
+ }
+ }
+
+ if (($n>=$Nbr) and ($p<$pMax)) $Txt = 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 = strpos($Txt,'<');
+ if ( ($pos!==false) and ($pos<strlen($Txt)-1) ) {
+ $pos = strpos($Txt,'>',$pos + 1);
+ if ( ($pos!==false) and ($pos<strlen($Txt)-1) ) {
+ $pos = strpos($Txt,'</',$pos + 1);
+ if ( ($pos!==false)and ($pos<strlen($Txt)-1) ) {
+ $pos = strpos($Txt,'>',$pos + 1);
+ if ($pos!==false) return true;
+ }
+ }
+ }
+
+ // Search for special char
+ $pos = strpos($Txt,'&');
+ if ( ($pos!==false) and ($pos<strlen($Txt)-1) ) {
+ $pos2 = strpos($Txt,';',$pos+1);
+ if ($pos2!==false) {
+ $x = substr($Txt,$pos+1,$pos2-$pos-1); // We extract the found text between the couple of tags
+ if (strlen($x)<=10) {
+ if (strpos($x,' ')===false) return true;
+ }
+ }
+ }
+
+ // Look for a simple tag
+ $Loc1 = tbs_Html_FindTag($Txt,'BR',true,0,true,0,false); // line break
+ if ($Loc1!==false) return true;
+ $Loc1 = tbs_Html_FindTag($Txt,'HR',true,0,true,0,false); // horizontal line
+ if ($Loc1!==false) return true;
+
+ return false;
+
+}
+
+function tbs_Html_GetPart(&$Txt,$Tag,$WithTags=false,$CancelIfEmpty=false) {
+// This function returns a part of the HTML document (HEAD or BODY)
+// The $CancelIfEmpty parameter enables to cancel the extraction when the part is not found.
+
+ $x = false;
+
+ $LocOpen = tbs_Html_FindTag($Txt,$Tag,true,0,true,0,false);
+ if ($LocOpen!==false) {
+ $LocClose = tbs_Html_FindTag($Txt,$Tag,false,$LocOpen->PosEnd+1,true,0,false);
+ if ($LocClose!==false) {
+ if ($WithTags) {
+ $x = substr($Txt,$LocOpen->PosBeg,$LocClose->PosEnd - $LocOpen->PosBeg + 1);
+ } else {
+ $x = substr($Txt,$LocOpen->PosEnd+1,$LocClose->PosBeg - $LocOpen->PosEnd - 1);
+ }
+ }
+ }
+
+ if ($x===false) {
+ if ($CancelIfEmpty) {
+ $x = $Txt;
+ } else {
+ $x = '';
+ }
+ }
+
+ return $x;
+
+}
+
+function tbs_Html_InsertAttribute(&$Txt,&$Attr,$Pos) {
+ // Check for XHTML end characters
+ if ($Txt[$Pos-1]==='/') {
+ $Pos--;
+ if ($Txt[$Pos-1]===' ') $Pos--;
+ }
+ // Insert the parameter
+ $Txt = 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 inserted before the searched tag.
+It also enables to pass a number of encapsulations.
+To ignore encapsulation and opengin/closing just set $Encaps=0.
+*/
+ if ($Forward) {
+ $Pos = $PosBeg - 1;
+ } else {
+ $Pos = $PosBeg + 1;
+ }
+ $TagIsOpening = false;
+ $TagClosing = '/'.$Tag;
+ if ($Opening) {
+ $EncapsEnd = $Encaps;
+ } else {
+ $EncapsEnd = - $Encaps;
+ }
+ $EncapsCnt = 0;
+ $TagOk = false;
+
+ do {
+
+ // Look for the next tag def
+ if ($Forward) {
+ $Pos = strpos($Txt,'<',$Pos+1);
+ } else {
+ if ($Pos<=0) {
+ $Pos = false;
+ } else {
+ $Pos = strrpos(substr($Txt,0,$Pos - 1),'<');
+ }
+ }
+
+ if ($Pos!==false) {
+ // Check the name of the tag
+ if (strcasecmp(substr($Txt,$Pos+1,strlen($Tag)),$Tag)==0) {
+ $PosX = $Pos + 1 + strlen($Tag); // The next char
+ $TagOk = true;
+ $TagIsOpening = true;
+ } elseif (strcasecmp(substr($Txt,$Pos+1,strlen($TagClosing)),$TagClosing)==0) {
+ $PosX = $Pos + 1 + strlen($TagClosing); // The next char
+ $TagOk = true;
+ $TagIsOpening = false;
+ }
+
+ if ($TagOk) {
+ // Check the next char
+ if (($Txt[$PosX]===' ') or ($Txt[$PosX]==='>')) {
+ // Check the encapsulation count
+ if ($EncapsEnd==0) {
+ // No encaplusation check
+ if ($TagIsOpening!==$Opening) $TagOk = false;
+ } else {
+ // Count the number of encapsulation
+ if ($TagIsOpening) {
+ $EncapsCnt++;
+ } else {
+ $EncapsCnt--;
+ }
+ // Check if it's the expected count
+ if ($EncapsCnt!=$EncapsEnd) $TagOk = false;
+ }
+ } else {
+ $TagOk = false;
+ }
+ } //--> if ($TagOk)
+
+ }
+ } while (($Pos!==false) and ($TagOk===false));
+
+ // Search for the end of the tag
+ if ($TagOk) {
+ $Loc =& new clsTbsLocator;
+ if ($WithPrm) {
+ $PosEnd = 0;
+ tbs_Locator_PrmRead($Txt,$PosX,true,'\'"','<','>',$Loc,$PosEnd);
+ } else {
+ $PosEnd = strpos($Txt,'>',$PosX);
+ if ($PosEnd===false) {
+ $TagOk = false;
+ }
+ }
+ }
+
+ // Result
+ if ($TagOk) {
+ $Loc->PosBeg = $Pos;
+ $Loc->PosEnd = $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']===true) {
+ $IsList = true;
+ $MainTag = 'SELECT';
+ $ItemTag = 'OPTION';
+ $ItemPrm = 'selected';
+ } else {
+ $IsList = false;
+ $MainTag = 'FORM';
+ $ItemTag = 'INPUT';
+ $ItemPrm = 'checked';
+ }
+ if (isset($Loc->PrmLst['selbounds'])) $MainTag = $Loc->PrmLst['selbounds'];
+ $ItemPrmZ = ' '.$ItemPrm.'="'.$ItemPrm.'"';
+
+ $TagO = tbs_Html_FindTag($Txt,$MainTag,true,$Loc->PosBeg-1,false,0,false);
+
+ if ($TagO!==false) {
+
+ $TagC = tbs_Html_FindTag($Txt,$MainTag,false,$Loc->PosBeg,true,0,false);
+ if ($TagC!==false) {
+
+ // We get the main block without the main tags
+ $MainSrc = substr($Txt,$TagO->PosEnd+1,$TagC->PosBeg - $TagO->PosEnd -1);
+
+ if ($IsList) {
+ // Information about the item that was used for the TBS field
+ $Item0Beg = $Loc->PosBeg - ($TagO->PosEnd+1);
+ $Item0Src = '';
+ $Item0Ok = false;
+ } else {
+ // We delete the merged value
+ $MainSrc = substr_replace($MainSrc,'',$Loc->PosBeg - ($TagO->PosEnd+1), strlen($SelValue));
+ }
+
+ // Now, we going to scan all of the item tags
+ $Pos = 0;
+ $SelNbr = 0;
+ while ($ItemLoc = tbs_Html_FindTag($MainSrc,$ItemTag,true,$Pos,true,0,true)) {
+
+ // we get the value of the item
+ $ItemValue = false;
+
+ if ($IsList) {
+ // Look for the end of the item
+ $OptCPos = strpos($MainSrc,'<',$ItemLoc->PosEnd+1);
+ if ($OptCPos===false) $OptCPos = strlen($MainSrc);
+ if (($Item0Ok===false) and ($ItemLoc->PosBeg<$Item0Beg) and ($Item0Beg<=$OptCPos)) {
+ // If it's the original item, we save it and delete it.
+ if (($OptCPos+1<strlen($MainSrc)) and ($MainSrc[$OptCPos+1]==='/')) {
+ $OptCPos = strpos($MainSrc,'>',$OptCPos);
+ if ($OptCPos===false) {
+ $OptCPos = strlen($MainSrc);
+ } else {
+ $OptCPos++;
+ }
+ }
+ $Item0Src = substr($MainSrc,$ItemLoc->PosBeg,$OptCPos-$ItemLoc->PosBeg);
+ $MainSrc = substr_replace($MainSrc,'',$ItemLoc->PosBeg,strlen($Item0Src));
+ if (!isset($ItemLoc->PrmLst[$ItemPrm])) tbs_Html_InsertAttribute($Item0Src,$ItemPrmZ,$ItemLoc->PosEnd-$ItemLoc->PosBeg);
+ $OptCPos = min($ItemLoc->PosBeg,strlen($MainSrc)-1);
+ $Select = false;
+ $Item0Ok = true;
+ } else {
+ if (isset($ItemLoc->PrmLst['value'])) {
+ $ItemValue = $ItemLoc->PrmLst['value'];
+ } else { // The value of the option is its caption.
+ $ItemValue = substr($MainSrc,$ItemLoc->PosEnd+1,$OptCPos - $ItemLoc->PosEnd - 1);
+ $ItemValue = str_replace(chr(9),' ',$ItemValue);
+ $ItemValue = str_replace(chr(10),' ',$ItemValue);
+ $ItemValue = str_replace(chr(13),' ',$ItemValue);
+ $ItemValue = trim($ItemValue);
+ }
+ }
+ $Pos = $OptCPos;
+ } else {
+ if ((isset($ItemLoc->PrmLst['name'])) and (isset($ItemLoc->PrmLst['value']))) {
+ if (strcasecmp($Loc->PrmLst['selected'],$ItemLoc->PrmLst['name'])==0) {
+ $ItemValue = $ItemLoc->PrmLst['value'];
+ }
+ }
+ $Pos = $ItemLoc->PosEnd;
+ }
+
+ if ($ItemValue!==false) {
+ // we look if we select the item
+ $Select = false;
+ if ($SelArray===false) {
+ if (strcasecmp($ItemValue,$SelValue)==0) {
+ if ($SelNbr==0) $Select = true;
+ }
+ } else {
+ if (array_search($ItemValue,$SelArray,false)!==false) $Select = true;
+ }
+ // Select the item
+ if ($Select) {
+ if (!isset($ItemLoc->PrmLst[$ItemPrm])) {
+ tbs_Html_InsertAttribute($MainSrc,$ItemPrmZ,$ItemLoc->PosEnd);
+ $Pos = $Pos + strlen($ItemPrmZ);
+ if ($IsList and ($ItemLoc->PosBeg<$Item0Beg)) $Item0Beg = $Item0Beg + strlen($ItemPrmZ);
+ }
+ $SelNbr++;
+ }
+ }
+
+ } //--> while ($ItemLoc = ... ) {
+
+ if ($IsList) {
+ // Add the original item if it's not found
+ if (($SelArray===false) and ($SelNbr==0)) $MainSrc = $MainSrc.$Item0Src;
+ $NewEnd = $TagO->PosEnd;
+ } else {
+ $NewEnd = $Loc->PosBeg;
+ }
+
+ $Txt = substr_replace($Txt,$MainSrc,$TagO->PosEnd+1,$TagC->PosBeg-$TagO->PosEnd-1);
+
+ } //--> if ($TagC!==false) {
+ } //--> if ($TagO!==false) {
+
+
+}
+
+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 .= '/';
+ }
+ }
+ return $Dir.str_replace('*',$CacheId,$Mask);
+}
+
+function tbs_Cache_DeleteAll($Dir,$Mask) {
+
+ if (strlen($Dir)==0) {
+ $Dir = '.';
+ }
+ if ($Dir[strlen($Dir)-1]<>'/') {
+ $Dir .= '/';
+ }
+ $DirObj = dir($Dir);
+ $Nbr = 0;
+ $PosL = strpos($Mask,'*');
+ $PosR = strlen($Mask) - $PosL - 1;
+
+ // Get the list of cache files
+ $FileLst = array();
+ while ($FileName = $DirObj->read()) {
+ $FullPath = $Dir.$FileName;
+ if (strtolower(filetype($FullPath))==='file') {
+ if (strlen($FileName)>=strlen($Mask)) {
+ if ((substr($FileName,0,$PosL)===substr($Mask,0,$PosL)) and (substr($FileName,-$PosR)===substr($Mask,-$PosR))) {
+ $FileLst[] = $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/informes/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
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbs_class_php5.php 2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbs_class_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 >= 5.0
+Date : 2006-11-26
+Web site : www.tinybutstrong.com
+Author : skrol29(a)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 Version 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 = false;
+ public $PosEnd = false;
+ public $Enlarged = false;
+ public $FullName = false;
+ public $SubName = '';
+ public $SubOk = false;
+ public $SubLst = array();
+ public $SubNbr = 0;
+ public $PrmLst = array();
+ public $PrmIfNbr = false;
+ public $MagnetId = false;
+ public $BlockFound = false;
+ public $FirstMerge = true;
+ public $ConvProtect = true;
+ public $ConvHtml = true;
+ public $ConvMode = 1; // Normal
+ public $ConvBr = true;
+}
+
+// *********************************************
+
+class clsTbsDataSource {
+
+public $Type = false;
+public $SubType = 0;
+public $SrcId = false;
+public $Query = '';
+public $RecSet = false;
+public $RecKey = '';
+public $RecNum = 0;
+public $RecNumInit = 0;
+public $RecSaving = false;
+public $RecSaved = false;
+public $RecBuffer = false;
+public $CurrRec = false;
+public $TBS = false;
+public $OnDataOk = false;
+public $OnDataPrm = false;
+public $OnDataPrmDone = array();
+public $OnDataPi = false;
+
+function DataAlert($Msg) {
+ return $this->TBS->meth_Misc_Alert('when merging block '.$this->TBS->_ChrOpen.$this->TBS->_CurrBlock.$this->TBS->_ChrClose,$Msg);
+}
+
+function DataPrepare(&$SrcId,&$TBS) {
+
+ $this->SrcId =& $SrcId;
+ $this->TBS =& $TBS;
+ $FctInfo = false;
+ $FctObj = false;
+
+ if (is_array($SrcId)) {
+ $this->Type = 0;
+ } elseif (is_resource($SrcId)) {
+
+ $Key = get_resource_type($SrcId);
+ switch ($Key) {
+ case 'mysql link' : $this->Type = 6; break;
+ case 'mysql link persistent' : $this->Type = 6; break;
+ case 'mysql result' : $this->Type = 6; $this->SubType = 1; break;
+ case 'pgsql link' : $this->Type = 7; break;
+ case 'pgsql link persistent' : $this->Type = 7; break;
+ case 'pgsql result' : $this->Type = 7; $this->SubType = 1; break;
+ case 'sqlite database' : $this->Type = 8; break;
+ case 'sqlite database (persistent)' : $this->Type = 8; break;
+ case 'sqlite result' : $this->Type = 8; $this->SubType = 1; break;
+ default :
+ $FctInfo = $Key;
+ $FctCat = 'r';
+ }
+
+ } elseif (is_string($SrcId)) {
+
+ switch (strtolower($SrcId)) {
+ case 'array' : $this->Type = 0; $this->SubType = 1; break;
+ case 'clear' : $this->Type = 0; $this->SubType = 3; break;
+ case 'mysql' : $this->Type = 6; $this->SubType = 2; break;
+ case 'text' : $this->Type = 2; break;
+ case 'num' : $this->Type = 1; break;
+ default :
+ $FctInfo = $SrcId;
+ $FctCat = 'k';
+ }
+
+ } elseif (is_object($SrcId)) {
+ $FctInfo = get_class($SrcId);
+ $FctCat = 'o';
+ $FctObj =& $SrcId;
+ $this->SrcId =& $SrcId;
+ } elseif ($SrcId===false) {
+ $this->DataAlert('the specified source is set to FALSE. Maybe your connection has failed.');
+ } else {
+ $this->DataAlert('unsupported variable type : \''.gettype($SrcId).'\'.');
+ }
+
+ if ($FctInfo!==false) {
+ $ErrMsg = false;
+ if ($TBS->meth_Misc_UserFctCheck($FctInfo,$FctCat,$FctObj,$ErrMsg)) {
+ $this->Type = $FctInfo['type'];
+ if ($this->Type!==5) {
+ if ($this->Type===4) { //
+ $this->FctPrm = array(false,0);
+ $this->SrcId =& $FctInfo['open'][0];
+ }
+ $this->FctOpen =& $FctInfo['open'];
+ $this->FctFetch =& $FctInfo['fetch'];
+ $this->FctClose =& $FctInfo['close'];
+ }
+ } else {
+ $this->Type = $this->DataAlert($ErrMsg);
+ }
+ }
+
+ return ($this->Type!==false);
+
+}
+
+function DataOpen(&$Query) {
+
+ // Init values
+ unset($this->CurrRec); $this->CurrRec = true;
+ if ($this->RecSaved) {
+ $this->FirstRec = true;
+ unset($this->RecKey); $this->RecKey = '';
+ $this->RecNum = $this->RecNumInit;
+ if ($this->OnDataOk) $this->OnDataArgs[1] =& $this->CurrRec;
+ return true;
+ }
+ unset($this->RecSet); $this->RecSet = false;
+ $this->RecNumInit = 0;
+ $this->RecNum = 0;
+
+ if (isset($this->TBS->_piOnData)) {
+ $this->OnDataPi = true;
+ $this->OnDataPiRef =& $this->TBS->_piOnData;
+ $this->OnDataOk = true;
+ }
+ if ($this->OnDataOk) {
+ $this->OnDataArgs = array();
+ $this->OnDataArgs[0] =& $this->TBS->_CurrBlock;
+ $this->OnDataArgs[1] =& $this->CurrRec;
+ $this->OnDataArgs[2] =& $this->RecNum;
+ $this->OnDataArgs[3] =& $this->TBS;
+ }
+
+ switch ($this->Type) {
+ case 0: // Array
+ if (($this->SubType===1) and (is_string($Query))) $this->SubType = 2;
+ if ($this->SubType===0) {
+ $this->RecSet =& $this->SrcId;
+ } elseif ($this->SubType===1) {
+ if (is_array($Query)) {
+ $this->RecSet =& $Query;
+ } else {
+ $this->DataAlert('type \''.gettype($Query).'\' not supported for the Query Parameter going with \'array\' Source Type.');
+ }
+ } elseif ($this->SubType===2) {
+ // TBS query string for array and objects, syntax: "var[item1][item2]->item3[item4]..."
+ $x = trim($Query);
+ $z = chr(0);
+ $x = str_replace(']->',$z,$x);
+ $x = str_replace('][',$z,$x);
+ $x = str_replace('->',$z,$x);
+ $x = str_replace('[',$z,$x);
+ if (substr($x,strlen($x)-1,1)===']') $x = substr($x,0,strlen($x)-1);
+ $ItemLst = explode($z,$x);
+ $ItemNbr = count($ItemLst);
+ $Item0 =& $ItemLst[0];
+ // Check first item
+ if ($Item0[0]==='~') {
+ $Item0 = substr($Item0,1);
+ if ($this->TBS->ObjectRef!==false) {
+ $Var =& $this->TBS->ObjectRef;
+ $i = 0;
+ } else {
+ $i = $this->DataAlert('invalid query \''.$Query.'\' because property ObjectRef is not set.');
+ }
+ } else {
+ if (isset($GLOBALS[$Item0])) {
+ $Var =& $GLOBALS[$Item0];
+ $i = 1;
+ } else {
+ $i = $this->DataAlert('invalid query \''.$Query.'\' because global variable \''.$Item0.'\' is not found.');
+ }
+ }
+ // Check sub-items
+ $Empty = false;
+ while (($i!==false) and ($i<$ItemNbr) and ($Empty===false)) {
+ $x = $ItemLst[$i];
+ if (is_array($Var)) {
+ if (isset($Var[$x])) {
+ $Var =& $Var[$x];
+ } else {
+ $Empty = true;
+ }
+ } elseif (is_object($Var)) {
+ $ArgLst = tbs_Misc_CheckArgLst($x);
+ if (method_exists($Var,$x)) {
+ $f = array(&$Var,$x); unset($Var);
+ $Var = call_user_func_array($f,$ArgLst);
+ } elseif (isset($Var->$x)) {
+ $Var =& $Var->$x;
+ } else {
+ $Empty = true;
+ }
+ } else {
+ $i = $this->DataAlert('invalid query \''.$Query.'\' because item \''.$ItemLst[$i].'\' is neither an Array nor an Object. Its type is \''.gettype($Var).'\'.');
+ }
+ if ($i!==false) $i++;
+ }
+ // Assign data
+ if ($i!==false) {
+ if ($Empty) {
+ $this->RecSet = array();
+ } else {
+ $this->RecSet =& $Var;
+ }
+ }
+ } elseif ($this->SubType===3) { // Clear
+ $this->RecSet = array();
+ }
+ // First record
+ if ($this->RecSet!==false) {
+ $this->RecNbr = $this->RecNumInit + count($this->RecSet);
+ $this->FirstRec = true;
+ $this->RecSaved = true;
+ $this->RecSaving = false;
+ }
+ break;
+ case 6: // MySQL
+ switch ($this->SubType) {
+ case 0: $this->RecSet = @mysql_query($Query,$this->SrcId); break;
+ case 1: $this->RecSet = $this->SrcId; break;
+ case 2: $this->RecSet = @mysql_query($Query); break;
+ }
+ if ($this->RecSet===false) $this->DataAlert('MySql error message when opening the query: '.mysql_error());
+ break;
+ case 1: // Num
+ $this->RecSet = true;
+ $this->NumMin = 1;
+ $this->NumMax = 1;
+ $this->NumStep = 1;
+ if (is_array($Query)) {
+ if (isset($Query['min'])) $this->NumMin = $Query['min'];
+ if (isset($Query['step'])) $this->NumStep = $Query['step'];
+ if (isset($Query['max'])) {
+ $this->NumMax = $Query['max'];
+ } else {
+ $this->RecSet = $this->DataAlert('the \'num\' source is an array that has no value for the \'max\' key.');
+ }
+ if ($this->NumStep==0) $this->RecSet = $this->DataAlert('the \'num\' source is an array that has a step value set to zero.');
+ } else {
+ $this->NumMax = ceil($Query);
+ }
+ if ($this->RecSet) {
+ if ($this->NumStep>0) {
+ $this->NumVal = $this->NumMin;
+ } else {
+ $this->NumVal = $this->NumMax;
+ }
+ }
+ break;
+ case 2: // Text
+ if (is_string($Query)) {
+ $this->RecSet =& $Query;
+ } else {
+ $this->RecSet = ''.$Query;
+ }
+ break;
+ case 3: // Custom function
+ $FctOpen = $this->FctOpen;
+ $this->RecSet = $FctOpen($this->SrcId,$Query);
+ if ($this->RecSet===false) $this->DataAlert('function '.$FctOpen.'() has failed to open query {'.$Query.'}');
+ break;
+ case 4: // Custom method from ObjectRef
+ $this->RecSet = call_user_func_array($this->FctOpen,array(&$this->SrcId,&$Query));
+ if ($this->RecSet===false) $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 = $this->SrcId->tbsdb_open($this->SrcId,$Query);
+ if ($this->RecSet===false) $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 = @pg_query($this->SrcId,$Query); break;
+ case 1: $this->RecSet = $this->SrcId; break;
+ }
+ if ($this->RecSet===false) $this->DataAlert('PostgreSQL error message when opening the query: '.pg_last_error($this->SrcId));
+ break;
+ case 8: // SQLite
+ switch ($this->SubType) {
+ case 0: $this->RecSet = @sqlite_query($this->SrcId,$Query); break;
+ case 1: $this->RecSet = $this->SrcId; break;
+ }
+ if ($this->RecSet===false) $this->DataAlert('SQLite error message when opening the query:'.sqlite_error_string(sqlite_last_error($this->SrcId)));
+ break;
+ }
+
+ if ($this->Type===0) {
+ unset($this->RecKey); $this->RecKey = '';
+ } else {
+ if ($this->RecSaving) {
+ unset($this->RecBuffer); $this->RecBuffer = array();
+ }
+ $this->RecKey =& $this->RecNum; // Not array: RecKey = RecNum
+ }
+
+ return ($this->RecSet!==false);
+
+}
+
+function DataFetch() {
+
+ if ($this->RecSaved) {
+ if ($this->RecNum<$this->RecNbr) {
+ if ($this->FirstRec) {
+ if ($this->SubType===2) { // From string
+ reset($this->RecSet);
+ $this->RecKey = key($this->RecSet);
+ $this->CurrRec =& $this->RecSet[$this->RecKey];
+ } else {
+ $this->CurrRec = reset($this->RecSet);
+ $this->RecKey = key($this->RecSet);
+ }
+ $this->FirstRec = false;
+ } else {
+ if ($this->SubType===2) { // From string
+ next($this->RecSet);
+ $this->RecKey = key($this->RecSet);
+ $this->CurrRec =& $this->RecSet[$this->RecKey];
+ } else {
+ $this->CurrRec = next($this->RecSet);
+ $this->RecKey = key($this->RecSet);
+ }
+ }
+ if ((!is_array($this->CurrRec)) and (!is_object($this->CurrRec))) $this->CurrRec = array('key'=>$this->RecKey, 'val'=>$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->OnDataPiRef,$this->OnDataArgs);
+ if ($this->SubType!==2) $this->RecSet[$this->RecKey] = $this->CurrRec; // save modifications because array reading is done without reference :(
+ }
+ } else {
+ unset($this->CurrRec); $this->CurrRec = false;
+ }
+ return;
+ }
+
+ switch ($this->Type) {
+ case 6: // MySQL
+ $this->CurrRec = mysql_fetch_assoc($this->RecSet);
+ break;
+ case 1: // Num
+ if (($this->NumVal>=$this->NumMin) and ($this->NumVal<=$this->NumMax)) {
+ $this->CurrRec = array('val'=>$this->NumVal);
+ $this->NumVal += $this->NumStep;
+ } else {
+ $this->CurrRec = false;
+ }
+ break;
+ case 2: // Text
+ if ($this->RecNum===0) {
+ if ($this->RecSet==='') {
+ $this->CurrRec = false;
+ } else {
+ $this->CurrRec =& $this->RecSet;
+ }
+ } else {
+ $this->CurrRec = false;
+ }
+ break;
+ case 3: // Custom function
+ $FctFetch = $this->FctFetch;
+ $this->CurrRec = $FctFetch($this->RecSet,$this->RecNum+1);
+ break;
+ case 4: // Custom method from ObjectRef
+ $this->FctPrm[0] =& $this->RecSet; $this->FctPrm[1] = $this->RecNum+1;
+ $this->CurrRec = call_user_func_array($this->FctFetch,$this->FctPrm);
+ break;
+ case 5: // Custom method of object
+ $this->CurrRec = $this->SrcId->tbsdb_fetch($this->RecSet,$this->RecNum+1);
+ break;
+ case 7: // PostgreSQL
+ $this->CurrRec = pg_fetch_assoc($this->RecSet);
+ break;
+ case 8: // SQLite
+ $this->CurrRec = sqlite_fetch_array($this->RecSet,SQLITE_ASSOC);
+ break;
+ }
+
+ // Set the row count
+ if ($this->CurrRec!==false) {
+ $this->RecNum++;
+ if ($this->OnDataOk) {
+ $this->OnDataArgs[1] =& $this->CurrRec; // Reference has changed if ($this->SubType===2)
+ if ($this->OnDataPrm) call_user_func_array($this->OnDataPrmRef,$this->OnDataArgs);
+ if ($this->OnDataPi) $this->TBS->meth_PlugIn_RunAll($this->OnDataPiRef,$this->OnDataArgs);
+ }
+ if ($this->RecSaving) $this->RecBuffer[$this->RecKey] = $this->CurrRec;
+ }
+
+}
+
+function DataClose() {
+ $this->OnDataOk = false;
+ $this->OnDataPrm = false;
+ $this->OnDataPi = false;
+ if ($this->RecSaved) return;
+ switch ($this->Type) {
+ case 6: mysql_free_result($this->RecSet); break;
+ case 3: $FctClose=$this->FctClose; $FctClose($this->RecSet); break;
+ case 4: call_user_func_array($this->FctClose,array(&$this->RecSet)); break;
+ case 5: $this->SrcId->tbsdb_close($this->RecSet); break;
+ case 7: pg_free_result($this->RecSet); break;
+ }
+ if ($this->RecSaving) {
+ $this->RecSet =& $this->RecBuffer;
+ $this->RecNbr = $this->RecNumInit + count($this->RecSet);
+ $this->RecSaving = false;
+ $this->RecSaved = true;
+ }
+}
+
+}
+
+// *********************************************
+
+class clsTinyButStrong {
+
+// Public properties
+public $Source = '';
+public $Render = 3;
+public $TplVars = array();
+public $ObjectRef = false;
+public $NoErr = false;
+// Undocumented (can change at any version)
+public $Version = '3.2.0';
+public $HtmlCharSet = '';
+public $TurboBlock = true;
+public $VarPrefix = '';
+public $Protect = true;
+public $ErrCount = 0;
+// Private
+public $_LastFile = '';
+public $_HtmlCharFct = false;
+public $_Mode = 0;
+public $_CurrBlock = '';
+public $_ChrOpen = '[';
+public $_ChrClose = ']';
+public $_ChrVal = '[val]';
+public $_ChrProtect = '[';
+public $_PlugIns = array();
+public $_PlugIns_Ok = false;
+public $_piOnFrm_Ok = false;
+
+function clsTinyButStrong($Chrs='',$VarPrefix='') {
+ if ($Chrs!=='') {
+ $Ok = false;
+ $Len = strlen($Chrs);
+ if ($Len===2) { // For compatibility
+ $this->_ChrOpen = $Chrs[0];
+ $this->_ChrClose = $Chrs[1];
+ $Ok = true;
+ } else {
+ $Pos = strpos($Chrs,',');
+ if (($Pos!==false) and ($Pos>0) and ($Pos<$Len-1)) {
+ $this->_ChrOpen = substr($Chrs,0,$Pos);
+ $this->_ChrClose = substr($Chrs,$Pos+1);
+ $Ok = true;
+ }
+ }
+ if ($Ok) {
+ $this->_ChrVal = $this->_ChrOpen.'val'.$this->_ChrClose;
+ $this->_ChrProtect = '&#'.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 = $VarPrefix;
+ // Liaison avec variables globales
+ global $_TBS_FrmMultiLst, $_TBS_FrmSimpleLst, $_TBS_UserFctLst, $_TBS_AutoInstallPlugIns;
+ if (!isset($_TBS_FrmMultiLst)) $_TBS_FrmMultiLst = array();
+ if (!isset($_TBS_FrmSimpleLst)) $_TBS_FrmSimpleLst = array();
+ if (!isset($_TBS_UserFctLst)) $_TBS_UserFctLst = array();
+ $this->_FrmMultiLst =& $_TBS_FrmMultiLst;
+ $this->_FrmSimpleLst =& $_TBS_FrmSimpleLst;
+ $this->_UserFctLst =& $_TBS_UserFctLst;
+ // Auto-installing plug-ins
+ if (isset($_TBS_AutoInstallPlugIns)) foreach ($_TBS_AutoInstallPlugIns as $pi) $this->PlugIn(TBS_INSTALL,$pi);
+}
+
+// Public methods
+function LoadTemplate($File,$HtmlCharSet='') {
+ $Ok = true;
+ if ($this->_PlugIns_Ok) {
+ if (isset($this->_piBeforeLoadTemplate) or isset($this->_piAfterLoadTemplate)) {
+ // Plug-ins
+ $ArgLst = func_get_args();
+ $ArgLst[0] =& $File;
+ $ArgLst[1] =& $HtmlCharSet;
+ if (isset($this->_piBeforeLoadTemplate)) $Ok = $this->meth_PlugIn_RunAll($this->_piBeforeLoadTemplate,$ArgLst);
+ }
+ }
+ // Load the file
+ if ($Ok!==false) {
+ $x = '';
+ if (!tbs_Misc_GetFile($x,$File,$this->_LastFile)) return $this->meth_Misc_Alert('with LoadTemplate() method','file \''.$File.'\' is not found or not readable.');
+ // CharSet analysis
+ if ($HtmlCharSet==='+') {
+ $this->Source .= $x;
+ } else {
+ $this->Source = $x;
+ if ($this->_Mode==0) {
+ $this->_LastFile = $File;
+ $this->_HtmlCharFct = false;
+ $this->TplVars = array();
+ if (is_string($HtmlCharSet)) {
+ if (($HtmlCharSet!=='') and ($HtmlCharSet[0]==='=')) {
+ $ErrMsg = false;
+ $HtmlCharSet = substr($HtmlCharSet,1);
+ if ($this->meth_Misc_UserFctCheck($HtmlCharSet,'f',$ErrMsg,$ErrMsg)) {
+ $this->_HtmlCharFct = true;
+ } else {
+ $this->meth_Misc_Alert('with LoadTemplate() method',$ErrMsg);
+ $HtmlCharSet = '';
+ }
+ }
+ } elseif ($HtmlCharSet===false) {
+ $this->Protect = false;
+ } else {
+ $this->meth_Misc_Alert('with LoadTemplate() method','the CharSet argument is not a string.');
+ $HtmlCharSet = '';
+ }
+ $this->HtmlCharSet = $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->_piAfterLoadTemplate)) $Ok = $this->meth_PlugIn_RunAll($this->_piAfterLoadTemplate,$ArgLst);
+ return $Ok;
+}
+
+function GetBlockSource($BlockName,$List=false,$KeepDefTags=true) {
+ $RetVal = array();
+ $Nbr = 0;
+ $Pos = 0;
+ $FieldOutside = false;
+ $P1 = false;
+ $Mode = ($KeepDefTags) ? 3 : 2;
+ while ($Loc = $this->meth_Locator_FindBlockNext($this->Source,$BlockName,$Pos,'.',$Mode,$P1,$FieldOutside)) {
+ $P1 = false;
+ $Nbr++;
+ $RetVal[$Nbr] = $Loc->BlockSrc;
+ if (!$List) return $RetVal[$Nbr];
+ $Pos = $Loc->PosEnd;
+ }
+ if ($List) {
+ return $RetVal;
+ } else {
+ return false;
+ }
+}
+
+function MergeBlock($BlockLst,$SrcId,$Query='') {
+ if ($SrcId==='cond') {
+ $Nbr = 0;
+ $BlockLst = explode(',',$BlockLst);
+ foreach ($BlockLst as $Block) {
+ $Block = trim($Block);
+ if ($Block!=='') $Nbr += $this->meth_Merge_AutoOn($this->Source,$Block,false,false);
+ }
+ return $Nbr;
+ } else {
+ return $this->meth_Merge_Block($this->Source,$BlockLst,$SrcId,$Query,false,0);
+ }
+}
+
+function MergeField($NameLst,$Value=null,$IsUserFct=false) {
+
+ $FctCheck = $IsUserFct;
+ if ($PlugIn = isset($this->_piOnMergeField)) $ArgPi = array('','',&$Value,0,&$this->Source,0,0);
+ $SubStart = 0;
+ $Ok = true;
+
+ $NameLst = explode(',',$NameLst);
+ foreach ($NameLst as $Name) {
+ $Name = trim($Name);
+ if ($Name==='') continue;
+ if ($this->meth_Merge_AutoAny($Name)) continue;
+ if ($PlugIn) $ArgPi[0] = $Name;
+ $PosBeg = 0;
+ // Initilize the user function (only once)
+ if ($FctCheck) {
+ $FctInfo = $Value;
+ $ErrMsg = false;
+ if (!$this->meth_Misc_UserFctCheck($FctInfo,'f',$ErrMsg,$ErrMsg)) return $this->meth_Misc_Alert('with MergeField() method',$ErrMsg);
+ $FctArg = array('','');
+ $SubStart = false;
+ $FctCheck = false;
+ }
+ while ($Loc = $this->meth_Locator_FindTbs($this->Source,$Name,$PosBeg,'.')) {
+ // Apply user function
+ if ($IsUserFct) {
+ $FctArg[0] =& $Loc->SubName; $FctArg[1] =& $Loc->PrmLst;
+ $Value = call_user_func_array($FctInfo,$FctArg);
+ }
+ // Plug-ins
+ if ($PlugIn) {
+ $ArgPi[1] = $Loc->SubName; $ArgPi[3] =& $Loc->PrmLst; $ArgPi[5] =& $Loc->PosBeg; $ArgPi[6] =& $Loc->PosEnd;
+ $Ok = $this->meth_PlugIn_RunAll($this->_piOnMergeField,$ArgPi);
+ }
+ // Merge the field
+ if ($Ok) {
+ $PosBeg = $this->meth_Locator_Replace($this->Source,$Loc,$Value,$SubStart);
+ } else {
+ $PosBeg = $Loc->PosEnd;
+ }
+ }
+ }
+}
+
+function Show($Render=false) {
+ $Ok = true;
+ if ($Render===false) $Render = $this->Render;
+ if ($this->_PlugIns_Ok) {
+ if (isset($this->_piBeforeShow) or isset($this->_piAfterShow)) {
+ // Plug-ins
+ $ArgLst = func_get_args();
+ $ArgLst[0] =& $Render;
+ if (isset($this->_piBeforeShow)) $Ok = $this->meth_PlugIn_RunAll($this->_piBeforeShow,$ArgLst);
+ }
+ }
+ if ($Ok!==false) {
+ $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)==TBS_OUTPUT) echo $this->Source;
+ if (($this->_Mode==0) and (($Render & TBS_EXIT)==TBS_EXIT)) exit;
+ return $Ok;
+}
+
+function PlugIn($Prm1,$Prm2=0) {
+
+ if (is_numeric($Prm1)) {
+ switch ($Prm1) {
+ case TBS_INSTALL:
+ $PlugInId = $Prm2;
+ // Try to install the plug-in
+ if (isset($this->_PlugIns[$PlugInId])) {
+ return $this->meth_Misc_Alert('with PlugIn() method','plug-in \''.$PlugInId.'\' is already installed.');
+ } else {
+ $ArgLst = 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 = $this->_PlugIns_Ok;
+ $this->_PlugIns_Ok = false;
+ return true;
+ case -5: // Deactivate OnFormat
+ $this->_piOnFrm_Ok_save = $this->_piOnFrm_Ok;
+ $this->_piOnFrm_Ok = false;
+ return true;
+ case -10: // Restore
+ $this->_PlugIns_Ok = $this->_PlugIns_Ok_save;
+ $this->_piOnFrm_Ok = $this->_piOnFrm_Ok_save;
+ return true;
+ }
+
+ } elseif (is_string($Prm1)) {
+ // Plug-in's command
+ $PlugInId = $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_Alert('with PlugIn() method','plug-in \''.$PlugInId.'\' can\'t run any command because the OnCommand event is not defined or activated.');
+ $ArgLst = func_get_args();
+ array_shift($ArgLst);
+ $Ok = call_user_func_array($this->_piOnCommand[$PlugInId],$ArgLst);
+ if (is_null($Ok)) $Ok = 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 = false;
+ $PosMax = strlen($Txt) -1;
+ $Start = $this->_ChrOpen.$Name;
+
+ do {
+ // Search for the opening char
+ if ($Pos>$PosMax) return false;
+ $Pos = strpos($Txt,$Start,$Pos);
+
+ // If found => next chars are analyzed
+ if ($Pos===false) {
+ return false;
+ } else {
+ $Loc = new clsTbsLocator;
+ $ReadPrm = false;
+ $PosX = $Pos + strlen($Start);
+ $x = $Txt[$PosX];
+
+ if ($x===$this->_ChrClose) {
+ $PosEnd = $PosX;
+ } elseif ($x===$ChrSub) {
+ $Loc->SubOk = true; // it is no longer the false value
+ $ReadPrm = true;
+ $PosX++;
+ } elseif (strpos(';',$x)!==false) {
+ $ReadPrm = true;
+ $PosX++;
+ } else {
+ $Pos++;
+ }
+
+ if ($ReadPrm) {
+ tbs_Locator_PrmRead($Txt,$PosX,false,'\'',$this->_ChrOpen,$this->_ChrClose,$Loc,$PosEnd);
+ if ($PosEnd===false) {
+ $this->meth_Misc_Alert('','can\'t found the end of the tag \''.substr($Txt,$Pos,$PosX-$Pos+10).'...\'.');
+ $Pos++;
+ }
+ }
+
+ }
+
+ } while ($PosEnd===false);
+
+ $Loc->PosBeg = $Pos;
+ $Loc->PosEnd = $PosEnd;
+ if ($Loc->SubOk) {
+ $Loc->FullName = $Name.'.'.$Loc->SubName;
+ $Loc->SubLst = explode('.',$Loc->SubName);
+ $Loc->SubNbr = count($Loc->SubLst);
+ } else {
+ $Loc->FullName = $Name;
+ }
+ if ($ReadPrm and isset($Loc->PrmLst['comm'])) {
+ $Loc->PosBeg0 = $Loc->PosBeg;
+ $Loc->PosEnd0 = $Loc->PosEnd;
+ $comm = $Loc->PrmLst['comm'];
+ if (($comm===true) or ($comm==='')) {
+ $Loc->Enlarged = tbs_Locator_EnlargeToStr($Txt,$Loc,'<!--' ,'-->');
+ } else {
+ $Loc->Enlarged = tbs_Locator_EnlargeToTag($Txt,$Loc,$comm,false);
+ }
+ }
+
+ return $Loc;
+
+}
+
+function &meth_Locator_SectionNewBDef(&$LocR,$BlockName,$Txt,$PrmLst) {
+
+ $Chk = true;
+ $LocLst = array();
+ $LocNbr = 0;
+
+ // Cache TBS locators
+ if ($this->TurboBlock) {
+
+ $Chk = false;
+ $Pos = 0;
+ $PrevEnd = -1;
+ while ($Loc = $this->meth_Locator_FindTbs($Txt,$BlockName,$Pos,'.')) {
+ if (($Loc->SubName==='#') or ($Loc->SubName==='$')) {
+ $Loc->IsRecInfo = true;
+ $Loc->RecInfo = $Loc->SubName;
+ $Loc->SubName = '';
+ } else {
+ $Loc->IsRecInfo = false;
+ }
+ if ($Loc->PosBeg>$PrevEnd) {
+ // The previous tag is not embeding => increment
+ $LocNbr++;
+ } else {
+ // The previous tag is embeding => no increment, then previous is over writed
+ $Chk = true;
+ }
+ $PrevEnd = $Loc->PosEnd;
+ if ($Loc->Enlarged) { // Parameter 'comm'
+ $Pos = $Loc->PosBeg0+1;
+ $Loc->Enlarged = false;
+ } else {
+ $Pos = $Loc->PosBeg+1;
+ }
+ $LocLst[$LocNbr] = $Loc;
+ }
+
+ }
+
+ // Create the object
+ $o = (object) null;
+ $o->Prm = $PrmLst;
+ $o->LocLst = $LocLst;
+ $o->LocNbr = $LocNbr;
+ $o->Name = $BlockName;
+ $o->Src = $Txt;
+ $o->Chk = $Chk;
+ $o->IsSerial = false;
+ $LocR->BDefLst[] =& $o; // Can be usefull for plug-in
+ return $o;
+
+}
+
+function meth_Locator_SectionAddGrp(&$LocR,&$BDef,$Type,$Field) {
+
+ $BDef->PrevValue = false;
+ $BDef->Field = $Field;
+
+ if ($Type==='H') {
+ if ($LocR->HeaderFound===false) {
+ $LocR->HeaderFound = true;
+ $LocR->HeaderNbr = 0;
+ $LocR->HeaderDef = array(); // 1 to HeaderNbr
+ }
+ $i = ++$LocR->HeaderNbr;
+ $LocR->HeaderDef[$i] =& $BDef;
+ } else {
+ if ($LocR->FooterFound===false) {
+ $LocR->FooterFound = true;
+ $LocR->FooterNbr = 0;
+ $LocR->FooterDef = array(); // 1 to FooterNbr
+ }
+ $BDef->IsFooter = ($Type==='F');
+ $i = ++$LocR->FooterNbr;
+ $LocR->FooterDef[$i] =& $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 $Value will be replaced.
+
+ // Found the value if there is a subname
+ if (($SubStart!==false) and $Loc->SubOk) {
+ for ($i=$SubStart;$i<$Loc->SubNbr;$i++) {
+ $x = $Loc->SubLst[$i]; // &$Loc... brings an error with Event Example, I don't know why.
+ if (is_array($Value)) {
+ if (isset($Value[$x])) {
+ $Value =& $Value[$x];
+ } elseif (array_key_exists($x,$Value)) {// can happens when value is NULL
+ $Value =& $Value[$x];
+ } else {
+ if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert($Loc,'item \''.$x.'\' is not an existing key in the array.',true);
+ unset($Value); $Value = ''; break;
+ }
+ } elseif (is_object($Value)) {
+ $ArgLst = tbs_Misc_CheckArgLst($x);
+ if (method_exists($Value,$x)) {
+ $x = call_user_func_array(array(&$Value,$x),$ArgLst);
+ } elseif (property_exists($Value,$x)) {
+ $x =& $Value->$x;
+ } else {
+ if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert($Loc,'item '.$x.'\' is neither a method nor a property in the class \''.get_class($Value).'\'.',true);
+ unset($Value); $Value = ''; break;
+ }
+ $Value =& $x; unset($x); $x = '';
+ } else {
+ if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert($Loc,'item before \''.$x.'\' is neither an object nor an array. Its type is '.gettype($Value).'.',true);
+ unset($Value); $Value = ''; break;
+ }
+ }
+ }
+
+ $CurrVal = $Value; // Unlink
+
+ if (isset($Loc->PrmLst['onformat'])) {
+ if ($Loc->FirstMerge) {
+ $Loc->OnFrmInfo = $Loc->PrmLst['onformat'];
+ $Loc->OnFrmArg = array(&$Loc->FullName,'',&$Loc->PrmLst,&$this);
+ $ErrMsg = false;
+ if (!$this->meth_Misc_UserFctCheck($Loc->OnFrmInfo,'f',$ErrMsg,$ErrMsg)) {
+ unset($Loc->PrmLst['onformat']);
+ if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert($Loc,'(parameter onformat) '.$ErrMsg);
+ $Loc->OnFrmInfo = 'pi'; // Execute the function pi() just to avoid extra error messages
+ }
+ }
+ $Loc->OnFrmArg[1] =& $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 = false;
+ $Loc->ConvHtml = false;
+ } else {
+ call_user_func_array($Loc->OnFrmInfo,$Loc->OnFrmArg);
+ }
+ }
+
+ if ($Loc->FirstMerge) {
+ if (isset($Loc->PrmLst['frm'])) {
+ $Loc->ConvMode = 0; // Frm
+ $Loc->ConvProtect = false;
+ } else {
+ // Analyze parameter 'htmlconv'
+ if (isset($Loc->PrmLst['htmlconv'])) {
+ $x = strtolower($Loc->PrmLst['htmlconv']);
+ $x = '+'.str_replace(' ','',$x).'+';
+ if (strpos($x,'+esc+')!==false) {tbs_Misc_ConvSpe($Loc); $Loc->ConvHtml = false; $Loc->ConvEsc = true; }
+ if (strpos($x,'+wsp+')!==false) {tbs_Misc_ConvSpe($Loc); $Loc->ConvWS = true; }
+ if (strpos($x,'+js+')!==false) {tbs_Misc_ConvSpe($Loc); $Loc->ConvHtml = false; $Loc->ConvJS = true; }
+ if (strpos($x,'+no+')!==false) $Loc->ConvHtml = false;
+ if (strpos($x,'+yes+')!==false) $Loc->ConvHtml = true;
+ if (strpos($x,'+nobr+')!==false) {$Loc->ConvHtml = true; $Loc->ConvBr = false; }
+ } else {
+ if ($this->HtmlCharSet===false) $Loc->ConvHtml = false; // No HTML
+ }
+ // Analyze parameter 'protect'
+ if (isset($Loc->PrmLst['protect'])) {
+ $x = strtolower($Loc->PrmLst['protect']);
+ if ($x==='no') {
+ $Loc->ConvProtect = false;
+ } elseif ($x==='yes') {
+ $Loc->ConvProtect = true;
+ }
+ } elseif ($this->Protect===false) {
+ $Loc->ConvProtect = false;
+ }
+ }
+ if ($Loc->Ope = isset($Loc->PrmLst['ope'])) {
+ $OpeLst = explode(',',$Loc->PrmLst['ope']);
+ $Loc->OpeAct = array();
+ $Loc->OpeArg = array();
+ foreach ($OpeLst as $i=>$ope) {
+ if ($ope==='list') {
+ $Loc->OpeAct[$i] = 1;
+ $Loc->OpePrm[$i] = (isset($Loc->PrmLst['valsep'])) ? $Loc->PrmLst['valsep'] : ',';
+ } else {
+ $x = substr($ope,0,4);
+ if ($x==='max:') {
+ $Loc->OpeAct[$i] = (isset($Loc->PrmLst['maxhtml'])) ? 2 : 3;
+ $Loc->OpePrm[$i] = intval(trim(substr($ope,4)));
+ $Loc->OpeEnd = (isset($Loc->PrmLst['maxend'])) ? $Loc->PrmLst['maxend'] : '...';
+ if ($Loc->OpePrm[$i]<=0) $Loc->Ope = false;
+ } elseif ($x==='mod:') {$Loc->OpeAct[$i] = 4; $Loc->OpePrm[$i] = '0'+trim(substr($ope,4));
+ } elseif ($x==='add:') {$Loc->OpeAct[$i] = 5; $Loc->OpePrm[$i] = '0'+trim(substr($ope,4));
+ } elseif ($x==='mul:') {$Loc->OpeAct[$i] = 6; $Loc->OpePrm[$i] = '0'+trim(substr($ope,4));
+ } elseif ($x==='div:') {$Loc->OpeAct[$i] = 7; $Loc->OpePrm[$i] = '0'+trim(substr($ope,4));
+ } elseif (isset($this->_piOnOperation)) {
+ $Loc->OpeAct[$i] = 0;
+ $Loc->OpePrm[$i] = $ope;
+ $Loc->OpeArg[$i] = array(&$Loc->FullName,&$CurrVal,&$Loc->PrmLst,&$Txt,$Loc->PosBeg,$Loc->PosEnd,&$Loc);
+ $Loc->PrmLst['_ope'] = $Loc->PrmLst['ope'];
+ } elseif (!isset($Loc->PrmLst['noerr'])) {
+ $this->meth_Misc_Alert($Loc,'parameter ope doesn\'t support value \''.$ope.'\'.',true);
+ }
+ }
+ }
+ }
+ $Loc->FirstMerge = false;
+ }
+ $ConvProtect = $Loc->ConvProtect;
+
+ // Plug-in OnFormat
+ if ($this->_piOnFrm_Ok) {
+ if (isset($Loc->OnFrmArgPi)) {
+ $Loc->OnFrmArgPi[1] =& $CurrVal;
+ } else {
+ $Loc->OnFrmArgPi = array(&$Loc->FullName,&$CurrVal,&$Loc->PrmLst,&$this);
+ }
+ $this->meth_PlugIn_RunAll($this->_piOnFormat,$Loc->OnFrmArgPi);
+ }
+
+ // Operation
+ if ($Loc->Ope) {
+ foreach ($Loc->OpeAct as $i=>$ope) {
+ switch ($ope) {
+ case 0:
+ $Loc->PrmLst['ope'] = $Loc->OpePrm[$i]; // for compatibility
+ $OpeArg =& $Loc->OpeArg[$i];
+ $OpeArg[1] =& $CurrVal; $OpeArg[3] =& $Txt;
+ if (!$this->meth_PlugIn_RunAll($this->_piOnOperation,$OpeArg)) return $Loc->PosBeg;
+ break;
+ case 1: if (is_array($CurrVal)) $CurrVal = implode($Loc->OpePrm[$i],$CurrVal); break;
+ case 2: if (strlen(''.$CurrVal)>$Loc->OpePrm[$i]) tbs_Html_Max($CurrVal,$Loc->OpePrm[$i],$Loc->OpeEnd); break;
+ case 3: if (strlen(''.$CurrVal)>$Loc->OpePrm[$i]) $CurrVal = substr(''.$CurrVal,0,$Loc->OpePrm[$i]).$Loc->OpeEnd; break;
+ case 4: $CurrVal = ('0'+$CurrVal) % $Loc->OpePrm[$i]; break;
+ case 5: $CurrVal = ('0'+$CurrVal) + $Loc->OpePrm[$i]; break;
+ case 6: $CurrVal = ('0'+$CurrVal) * $Loc->OpePrm[$i]; break;
+ case 7: $CurrVal = ('0'+$CurrVal) / $Loc->OpePrm[$i]; break;
+ }
+ }
+ }
+
+ // HTML conversion or format
+ if ($Loc->ConvMode===1) { // Html simple
+ if (!is_string($CurrVal)) $CurrVal = @strval($CurrVal);
+ if ($Loc->ConvHtml) {
+ $this->meth_Conv_Html($CurrVal);
+ if ($Loc->ConvBr) $CurrVal = nl2br($CurrVal);
+ }
+ } elseif ($Loc->ConvMode===0) { // Format
+ $CurrVal = $this->meth_Misc_Format($CurrVal,$Loc->PrmLst);
+ } elseif ($Loc->ConvMode===2) { // Html special
+ if (!is_string($CurrVal)) $CurrVal = @strval($CurrVal);
+ if ($Loc->ConvHtml) {
+ $this->meth_Conv_Html($CurrVal);
+ if ($Loc->ConvBr) $CurrVal = nl2br($CurrVal);
+ }
+ if ($Loc->ConvEsc) $CurrVal = str_replace('\'','\'\'',$CurrVal);
+ if ($Loc->ConvWS) {
+ $check = ' ';
+ $nbsp = ' ';
+ do {
+ $pos = strpos($CurrVal,$check);
+ if ($pos!==false) $CurrVal = substr_replace($CurrVal,$nbsp,$pos,1);
+ } while ($pos!==false);
+ }
+ if ($Loc->ConvJS) {
+ $CurrVal = addslashes($CurrVal); // apply to ('), ("), (\) and (null)
+ $CurrVal = str_replace("\n",'\n',$CurrVal);
+ $CurrVal = str_replace("\r",'\r',$CurrVal);
+ $CurrVal = str_replace("\t",'\t',$CurrVal);
+ }
+ }
+
+ // if/then/else process, there may be several if/then
+ if ($Loc->PrmIfNbr) {
+ $z = false;
+ $i = 1;
+ while ($i!==false) {
+ if ($Loc->PrmIfVar[$i]) $Loc->PrmIfVar[$i] = $this->meth_Merge_AutoVar($Loc->PrmIf[$i],true);
+ $x = 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] = $this->meth_Merge_AutoVar($Loc->PrmThen[$i],true);
+ $z = $Loc->PrmThen[$i];
+ }
+ $i = false;
+ } else {
+ $i++;
+ if ($i>$Loc->PrmIfNbr) {
+ if (isset($Loc->PrmLst['else'])) {
+ if ($Loc->PrmElseVar) $Loc->PrmElseVar = $this->meth_Merge_AutoVar($Loc->PrmLst['else'],true);
+ $z =$Loc->PrmLst['else'];
+ }
+ $i = false;
+ }
+ }
+ }
+ if ($z!==false) {
+ if ($ConvProtect) {
+ $CurrVal = str_replace($this->_ChrOpen,$this->_ChrProtect,$CurrVal); // TBS protection
+ $ConvProtect = false;
+ }
+ $CurrVal = str_replace($this->_ChrVal,$CurrVal,$z);
+ }
+ }
+
+ if (isset($Loc->PrmLst['file'])) {
+ $x = $Loc->PrmLst['file'];
+ if ($x===true) $x = $CurrVal;
+ $this->meth_Merge_AutoVar($x,false);
+ $x = trim(str_replace($this->_ChrVal,$CurrVal,$x));
+ $CurrVal = '';
+ if ($x!=='') {
+ if (tbs_Misc_GetFile($CurrVal,$x,$this->_LastFile)) {
+ if (isset($Loc->PrmLst['getbody'])) $CurrVal = tbs_Html_GetPart($CurrVal,$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.',true);
+ }
+ $ConvProtect = false;
+ }
+ }
+
+ if (isset($Loc->PrmLst['script'])) {// Include external PHP script
+ $x = $Loc->PrmLst['script'];
+ if ($x===true) $x = $CurrVal;
+ $this->meth_Merge_AutoVar($x,false);
+ $x = trim(str_replace($this->_ChrVal,$CurrVal,$x));
+ if ($x!=='') {
+ $this->_Subscript = $x;
+ $this->CurrPrm =& $Loc->PrmLst;
+ $sub = isset($Loc->PrmLst['subtpl']);
+ if ($sub) $this->meth_Misc_ChangeMode(true,$Loc,$CurrVal);
+ if ($this->meth_Misc_RunSubscript($CurrVal,$Loc->PrmLst)===false) {
+ 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 = tbs_Html_GetPart($CurrVal,$Loc->PrmLst['getbody'],false,true);
+ unset($this->CurrPrm);
+ $ConvProtect = false;
+ }
+ }
+
+ // Case when it's an empty string
+ if ($CurrVal==='') {
+
+ if ($Loc->MagnetId===false) {
+ if (isset($Loc->PrmLst['.'])) {
+ $Loc->MagnetId = -1;
+ } elseif (isset($Loc->PrmLst['ifempty'])) {
+ $Loc->MagnetId = -2;
+ } elseif (isset($Loc->PrmLst['magnet'])) {
+ $Loc->MagnetId = 1;
+ $Loc->PosBeg0 = $Loc->PosBeg;
+ $Loc->PosEnd0 = $Loc->PosEnd;
+ if (isset($Loc->PrmLst['mtype'])) {
+ switch ($Loc->PrmLst['mtype']) {
+ case 'm+m': $Loc->MagnetId = 2; break;
+ case 'm*': $Loc->MagnetId = 3; break;
+ case '*m': $Loc->MagnetId = 4; break;
+ }
+ }
+ } else {
+ $Loc->MagnetId = 0;
+ }
+ }
+
+ switch ($Loc->MagnetId) {
+ case 0: break;
+ case -1: $CurrVal = ' '; break; // Enables to avoid blanks in HTML tables
+ case -2: $CurrVal = $Loc->PrmLst['ifempty']; break;
+ case 1:
+ $Loc->Enlarged = true;
+ tbs_Locator_EnlargeToTag($Txt,$Loc,$Loc->PrmLst['magnet'],false);
+ break;
+ case 2:
+ $Loc->Enlarged = true;
+ $CurrVal = tbs_Locator_EnlargeToTag($Txt,$Loc,$Loc->PrmLst['magnet'],true);
+ break;
+ case 3:
+ $Loc->Enlarged = true;
+ $Loc2 = tbs_Html_FindTag($Txt,$Loc->PrmLst['magnet'],true,$Loc->PosBeg,false,1,false);
+ if ($Loc2!==false) {
+ $Loc->PosBeg = $Loc2->PosBeg;
+ if ($Loc->PosEnd<$Loc2->PosEnd) $Loc->PosEnd = $Loc2->PosEnd;
+ }
+ break;
+ case 4:
+ $Loc->Enlarged = true;
+ $Loc2 = tbs_Html_FindTag($Txt,$Loc->PrmLst['magnet'],true,$Loc->PosBeg,true,1,false);
+ if ($Loc2!==false) $Loc->PosEnd = $Loc2->PosEnd;
+ break;
+ }
+ $NewEnd = $Loc->PosBeg; // Useful when mtype='m+m'
+ } else {
+
+ if ($ConvProtect) $CurrVal = str_replace($this->_ChrOpen,$this->_ChrProtect,$CurrVal); // TBS protection
+ $NewEnd = $Loc->PosBeg + strlen($CurrVal);
+
+ }
+
+ $Txt = substr_replace($Txt,$CurrVal,$Loc->PosBeg,$Loc->PosEnd-$Loc->PosBeg+1);
+ return $NewEnd; // Return the new end position of the field
+
+}
+
+function meth_Locator_FindBlockNext(&$Txt,$BlockName,$PosBeg,$ChrSub,$Mode,&$P1,&$FieldBefore) {
+// Return the first block locator just after the PosBeg position
+// Mode = 1 : Merge_Auto => doesn't save $Loc->BlockSrc, save the bounds of TBS Def tags instead, return also fields
+// Mode = 2 : FindBlockLst or GetBlockSource => save $Loc->BlockSrc without TBS Def tags
+// Mode = 3 : GetBlockSource => save $Loc->BlockSrc with TBS Def tags
+
+ $SearchDef = true;
+ $FirstField = false;
+
+ // Search for the first tag with parameter "block"
+ while ($SearchDef and ($Loc = $this->meth_Locator_FindTbs($Txt,$BlockName,$PosBeg,$ChrSub))) {
+ if (isset($Loc->PrmLst['block'])) {
+ if ($P1) {
+ if (isset($Loc->PrmLst['p1'])) return false;
+ } else {
+ if (isset($Loc->PrmLst['p1'])) $P1 = true;
+ }
+ $Block = $Loc->PrmLst['block'];
+ $SearchDef = false;
+ } elseif ($Mode===1) {
+ return $Loc;
+ } elseif ($FirstField===false) {
+ $FirstField = $Loc;
+ }
+ $PosBeg = $Loc->PosEnd;
+ }
+
+ if ($SearchDef) {
+ if ($FirstField!==false) $FieldBefore = true;
+ return false;
+ }
+
+ if ($Block==='begin') { // Block definied using begin/end
+
+ if (($FirstField!==false) and ($FirstField->PosEnd<$Loc->PosBeg)) $FieldBefore = true;
+
+ $Opened = 1;
+ while ($Loc2 = $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==0) {
+ if ($Mode===1) {
+ $Loc->PosBeg2 = $Loc2->PosBeg;
+ $Loc->PosEnd2 = $Loc2->PosEnd;
+ } else {
+ if ($Mode===2) {
+ $Loc->BlockSrc = substr($Txt,$Loc->PosEnd+1,$Loc2->PosBeg-$Loc->PosEnd-1);
+ } else {
+ $Loc->BlockSrc = substr($Txt,$Loc->PosBeg,$Loc2->PosEnd-$Loc->PosBeg+1);
+ }
+ $Loc->PosEnd = $Loc2->PosEnd;
+ $Loc->PosDef = 0;
+ }
+ $Loc->BlockFound = true;
+ return $Loc;
+ }
+ }
+ $PosBeg = $Loc2->PosEnd;
+ }
+
+ return $this->meth_Misc_Alert($Loc,'a least one tag with parameter \'block=end\' is missing.',false,'in block\'s definition');
+
+ }
+
+ if ($Mode===1) {
+ $Loc->PosBeg2 = false;
+ } else {
+
+ $Loc->PosDef = $Loc->PosBeg;
+ if (!$Loc->SubOk) {
+ $PosBeg1 = $Loc->PosBeg;
+ $PosEnd1 = $Loc->PosEnd;
+ }
+ if (tbs_Locator_EnlargeToTag($Txt,$Loc,$Block,false)===false) return $this->meth_Misc_Alert($Loc,'at least one tag corresponding to '.$Loc->PrmLst['block'].' is not found. Check opengin tags, closing tags and levels.',false,'in block\'s definition');
+ $Loc->PosDef = $Loc->PosDef - $Loc->PosBeg;
+ if ($Loc->SubOk or ($Mode===3)) {
+ $Loc->BlockSrc = substr($Txt,$Loc->PosBeg,$Loc->PosEnd-$Loc->PosBeg+1);
+ $Loc->PosDef++;
+ } else {
+ $Loc->BlockSrc = substr($Txt,$Loc->PosBeg,$PosBeg1-$Loc->PosBeg).substr($Txt,$PosEnd1+1,$Loc->PosEnd-$PosEnd1);
+ }
+ }
+
+ $Loc->BlockFound = true;
+ if (($FirstField!==false) and ($FirstField->PosEnd<$Loc->PosBeg)) $FieldBefore = 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 = new clsTbsLocator;
+ $LocR->P1 = false;
+ $LocR->FieldOutside = false;
+ $LocR->BDefLst = array();
+
+ $LocR->NoData = false;
+ $LocR->Special = false;
+ $LocR->HeaderFound = false;
+ $LocR->FooterFound = false;
+ $LocR->SerialEmpty = false;
+
+ $LocR->WhenFound = false;
+ $LocR->WhenDefault = false;
+
+ $LocR->SectionNbr = 0; // Normal sections
+ $LocR->SectionLst = array(); // 1 to SectionNbr
+
+ $BDef = false;
+ $ParentLst = array();
+ $Pid = 0;
+
+ do {
+
+ if ($BlockName==='') {
+ $Loc = false;
+ } else {
+ $Loc = $this->meth_Locator_FindBlockNext($Txt,$BlockName,$Pos,'.',2,$LocR->P1,$LocR->FieldOutside);
+ }
+
+ if ($Loc===false) {
+
+ if ($Pid>0) { // parentgrp mode => disconnect $Txt from the source
+ $Parent =& $ParentLst[$Pid];
+ $Src = $Txt;
+ $Txt =& $Parent->Txt;
+ if ($LocR->BlockFound) {
+ // Redefine the Header block
+ $Parent->Src = substr($Src,0,$LocR->PosBeg);
+ // Add a Footer block
+ $BDef =& $this->meth_Locator_SectionNewBDef($LocR,$BlockName,substr($Src,$LocR->PosEnd+1),$Parent->Prm);
+ $this->meth_Locator_SectionAddGrp($LocR,$BDef,'F',$Parent->Fld);
+ }
+ // Now go down to previous level
+ $Pos = $Parent->Pos;
+ $LocR->PosBeg = $Parent->Beg;
+ $LocR->PosEnd = $Parent->End;
+ $LocR->BlockFound = true;
+ unset($Parent);
+ unset($ParentLst[$Pid]);
+ $Pid--;
+ $Loc = true;
+ }
+
+ } else {
+
+ $Pos = $Loc->PosEnd;
+
+ // Define the block limits
+ if ($LocR->BlockFound) {
+ if ( $LocR->PosBeg > $Loc->PosBeg ) $LocR->PosBeg = $Loc->PosBeg;
+ if ( $LocR->PosEnd < $Loc->PosEnd ) $LocR->PosEnd = $Loc->PosEnd;
+ } else {
+ $LocR->BlockFound = true;
+ $LocR->PosBeg = $Loc->PosBeg;
+ $LocR->PosEnd = $Loc->PosEnd;
+ }
+
+ // Merge block parameters
+ if (count($Loc->PrmLst)>0) $LocR->PrmLst = array_merge($LocR->PrmLst,$Loc->PrmLst);
+
+ // Save the block and cache its tags
+ $BDef =& $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 =& $BDef;
+ } elseif (($SpePrm!==false) and isset($Loc->PrmLst[$SpePrm])) { // Special section (used for navigation bar)
+ $LocR->Special =& $BDef;
+ } elseif (isset($Loc->PrmLst['when'])) {
+ if ($LocR->WhenFound===false) {
+ $LocR->WhenFound = true;
+ $LocR->WhenSeveral = false;
+ $LocR->WhenNbr = 0;
+ $LocR->WhenLst = array();
+ }
+ $this->meth_Merge_AutoVar($Loc->PrmLst['when'],false);
+ $BDef->WhenCond =& $this->meth_Locator_SectionNewBDef($LocR,$BlockName,$Loc->PrmLst['when'],array());
+ $BDef->WhenBeforeNS = ($LocR->SectionNbr===0);
+ $i = ++$LocR->WhenNbr;
+ $LocR->WhenLst[$i] =& $BDef;
+ if (isset($Loc->PrmLst['several'])) $LocR->WhenSeveral = true;
+ } elseif (isset($Loc->PrmLst['default'])) {
+ $LocR->WhenDefault =& $BDef;
+ $LocR->WhenDefaultBeforeNS = ($LocR->SectionNbr===0);
+ } elseif (isset($Loc->PrmLst['headergrp'])) {
+ $this->meth_Locator_SectionAddGrp($LocR,$BDef,'H',$Loc->PrmLst['headergrp']);
+ } elseif (isset($Loc->PrmLst['footergrp'])) {
+ $this->meth_Locator_SectionAddGrp($LocR,$BDef,'F',$Loc->PrmLst['footergrp']);
+ } elseif (isset($Loc->PrmLst['splittergrp'])) {
+ $this->meth_Locator_SectionAddGrp($LocR,$BDef,'S',$Loc->PrmLst['splittergrp']);
+ } elseif (isset($Loc->PrmLst['parentgrp'])) {
+ $this->meth_Locator_SectionAddGrp($LocR,$BDef,'H',$Loc->PrmLst['parentgrp']);
+ $BDef->Fld = $Loc->PrmLst['parentgrp'];
+ $BDef->Txt =& $Txt;
+ $BDef->Pos = $Pos;
+ $BDef->Beg = $LocR->PosBeg;
+ $BDef->End = $LocR->PosEnd;
+ $Pid++;
+ $ParentLst[$Pid] =& $BDef;
+ $Txt =& $BDef->Src;
+ $Pos = $Loc->PosDef + 1;
+ $LocR->BlockFound = false;
+ $LocR->PosBeg = false;
+ $LocR->PosEnd = false;
+ } elseif (isset($Loc->PrmLst['serial'])) {
+ // Section with serial subsections
+ $SrSrc =& $BDef->Src;
+ // Search the empty item
+ if ($LocR->SerialEmpty===false) {
+ $SrName = $BlockName.'_0';
+ $x = false;
+ $SrLoc = $this->meth_Locator_FindBlockNext($SrSrc,$SrName,0,'.',2,$x,$x);
+ if ($SrLoc!==false) {
+ $LocR->SerialEmpty = $SrLoc->BlockSrc;
+ $SrSrc = substr_replace($SrSrc,'',$SrLoc->PosBeg,$SrLoc->PosEnd-$SrLoc->PosBeg+1);
+ }
+ }
+ $SrName = $BlockName.'_1';
+ $x = false;
+ $SrLoc = $this->meth_Locator_FindBlockNext($SrSrc,$SrName,0,'.',2,$x,$x);
+ if ($SrLoc!==false) {
+ $SrId = 1;
+ do {
+ // Save previous subsection
+ $SrBDef =& $this->meth_Locator_SectionNewBDef($LocR,$SrName,$SrLoc->BlockSrc,$SrLoc->PrmLst);
+ $SrBDef->SrBeg = $SrLoc->PosBeg;
+ $SrBDef->SrLen = $SrLoc->PosEnd - $SrLoc->PosBeg + 1;
+ $SrBDef->SrTxt = false;
+ $BDef->SrBDefLst[$SrId] =& $SrBDef;
+ // Put in order
+ $BDef->SrBDefOrdered[$SrId] =& $SrBDef;
+ $i = $SrId;
+ while (($i>1) and ($SrBDef->SrBeg<$BDef->SrBDefOrdered[$SrId-1]->SrBeg)) {
+ $BDef->SrBDefOrdered[$i] =& $BDef->SrBDefOrdered[$i-1];
+ $BDef->SrBDefOrdered[$i-1] =& $SrBDef;
+ $i--;
+ }
+ // Search next subsection
+ $SrId++;
+ $SrName = $BlockName.'_'.$SrId;
+ $x = false;
+ $SrLoc = $this->meth_Locator_FindBlockNext($SrSrc,$SrName,0,'.',2,$x,$x);
+ } while ($SrLoc!==false);
+ $BDef->SrBDefNbr = $SrId-1;
+ $BDef->IsSerial = true;
+ $i = ++$LocR->SectionNbr;
+ $LocR->SectionLst[$i] =& $BDef;
+ }
+ } else {
+ // Normal section
+ $i = ++$LocR->SectionNbr;
+ $LocR->SectionLst[$i] =& $BDef;
+ }
+
+ }
+
+ } while ($Loc!==false);
+
+ if ($LocR->WhenFound and ($LocR->SectionNbr===0)) {
+ // Add a blank section if When is used without a normal section
+ $BDef =& $this->meth_Locator_SectionNewBDef($LocR,$BlockName,'',array());
+ $LocR->SectionNbr = 1;
+ $LocR->SectionLst[1] =& $BDef;
+ }
+
+ return $LocR; // methods return by ref by default
+
+}
+
+function meth_Merge_Block(&$Txt,&$BlockLst,&$SrcId,&$Query,$SpePrm,$SpeRecNum) {
+
+ $BlockSave = $this->_CurrBlock;
+ $this->_CurrBlock = $BlockLst;
+
+ // Get source type and info
+ $Src = new clsTbsDataSource;
+ if (!$Src->DataPrepare($SrcId,$this)) {
+ $this->_CurrBlock = $BlockSave;
+ return 0;
+ }
+
+ $BlockLst = explode(',',$BlockLst);
+ $BlockNbr = count($BlockLst);
+ $BlockId = 0;
+ $WasP1 = false;
+ $NbrRecTot = 0;
+ $QueryZ =& $Query;
+ $ReturnData = false;
+
+ while ($BlockId<$BlockNbr) {
+
+ $RecSpe = 0; // Row with a special block's definition (used for the navigation bar)
+ $QueryOk = true;
+ $this->_CurrBlock = trim($BlockLst[$BlockId]);
+ if ($this->_CurrBlock==='*') {
+ $ReturnData = true;
+ if ($Src->RecSaved===false) $Src->RecSaving = true;
+ $this->_CurrBlock = '';
+ }
+
+ // Search the block
+ $LocR = $this->meth_Locator_FindBlockLst($Txt,$this->_CurrBlock,0,$SpePrm);
+
+ if ($WasP1) $this->meth_Merge_FieldOutside($Txt,$Src,$LocR);
+
+ if ($LocR->BlockFound) {
+ if ($LocR->Special!==false) $RecSpe = $SpeRecNum;
+ // OnData
+ if ($Src->OnDataPrm = isset($LocR->PrmLst['ondata'])) {
+ $Src->OnDataPrmRef = $LocR->PrmLst['ondata'];
+ if (isset($Src->OnDataPrmDone[$Src->OnDataPrmRef])) {
+ $Src->OnDataPrm = false;
+ } else {
+ $ErrMsg = false;
+ if ($this->meth_Misc_UserFctCheck($Src->OnDataPrmRef,'f',$ErrMsg,$ErrMsg)) {
+ $Src->OnDataOk = true;
+ } else {
+ $LocR->FullName = $this->_CurrBlock;
+ $Src->OnDataPrm = $this->meth_Misc_Alert($LocR,'(parameter ondata) '.$ErrMsg,false,'block');
+ }
+ }
+ }
+ // Dynamic query
+ if ($LocR->P1) {
+ if (is_string($Query)) {
+ $Src->RecSaved = false;
+ unset($QueryZ); $QueryZ = ''.$Query;
+ $i = 1;
+ do {
+ $x = 'p'.$i;
+ if (isset($LocR->PrmLst[$x])) {
+ $QueryZ = str_replace('%p'.$i.'%',$LocR->PrmLst[$x],$QueryZ);
+ $i++;
+ } else {
+ $i = false;
+ }
+ } while ($i!==false);
+ }
+ $WasP1 = true;
+ } elseif (($Src->RecSaved===false) and ($BlockNbr-$BlockId>1)) {
+ $Src->RecSaving = true;
+ }
+ } elseif ($WasP1) {
+ $QueryOk = false;
+ $WasP1 = false;
+ }
+
+ // Open the recordset
+ if ($QueryOk) {
+ if ((!$LocR->BlockFound) and (!$LocR->FieldOutside)) {
+ // Special case: return data without any block to merge
+ $QueryOk = false;
+ if ($ReturnData and (!$Src->RecSaved)) {
+ if ($Src->DataOpen($QueryZ)) {
+ do {$Src->DataFetch();} while ($Src->CurrRec!==false);
+ $Src->DataClose();
+ }
+ }
+ } else {
+ $QueryOk = $Src->DataOpen($QueryZ);
+ }
+ }
+
+ // Merge sections
+ if ($QueryOk) {
+ if ($Src->Type===2) { // Special for Text merge
+ if ($LocR->BlockFound) {
+ $Src->RecNum = 1;
+ $Src->CurrRec = false;
+ $Txt = substr_replace($Txt,$Src->RecSet,$LocR->PosBeg,$LocR->PosEnd-$LocR->PosBeg+1);
+ } else {
+ $Src->DataAlert('can\'t merge the block with a text value because the block definition is not found.');
+ }
+ } elseif ($LocR->BlockFound===false) {
+ $Src->DataFetch(); // Merge first record only
+ } else {
+ $this->meth_Merge_BlockSections($Txt,$LocR,$Src,$RecSpe);
+ }
+ $Src->DataClose(); // Close the resource
+ }
+
+ if (!$WasP1) {
+ $NbrRecTot += $Src->RecNum;
+ if ($LocR->FieldOutside and $QueryOk) {
+ $LocR->BlockFound = false; // Cancel Loc limit
+ $this->meth_Merge_FieldOutside($Txt,$Src,$LocR);
+ }
+ $BlockId++;
+ }
+
+ }
+
+ // End of the merge
+ unset($LocR);
+ $this->_CurrBlock = $BlockSave;
+ if ($ReturnData) {
+ return $Src->RecSet;
+ } else {
+ unset($Src);
+ return $NbrRecTot;
+ }
+
+}
+
+function meth_Merge_BlockSections(&$Txt,&$LocR,&$Src,&$RecSpe) {
+
+ // Initialise
+ $SecId = 0;
+ $SecOk = ($LocR->SectionNbr>0);
+ $SecSrc = '';
+ $BlockRes = ''; // The result of the chained merged blocks
+ $IsSerial = false;
+ $SrId = 0;
+ $SrNbr = 0;
+ $GrpFound = ($LocR->HeaderFound or $LocR->FooterFound);
+ if ($LocR->FooterFound) $PrevSrc = (object) null;
+ $piOMS = false;
+ // Plug-ins
+ if ($this->_PlugIns_Ok and isset($this->_piBeforeMergeBlock)) {
+ $ArgLst = 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 = array(&$BlockRes,&$SecSrc);
+ $piOMS = true;
+ }
+
+ // Main loop
+ $Src->DataFetch();
+ while($Src->CurrRec!==false) {
+
+ // Headers and Footers
+ if ($GrpFound) {
+ $grp_change = false;
+ $grp_src = '';
+ if ($LocR->FooterFound) {
+ $change = false;
+ for ($i=$LocR->FooterNbr;$i>=1;$i--) {
+ $GrpDef =& $LocR->FooterDef[$i];
+ $x = $Src->CurrRec[$GrpDef->Field];
+ if ($Src->RecNum===1) {
+ $GrpDef->PrevValue = $x;
+ } else {
+ if ($GrpDef->IsFooter) {
+ $change_i =& $change;
+ } else {
+ unset($change_i); $change_i = false;
+ }
+ if (!$change_i) $change_i = !($GrpDef->PrevValue===$x);
+ if ($change_i) {
+ $grp_change = true;
+ $grp_src = $this->meth_Merge_SectionNormal($GrpDef,$PrevSrc).$grp_src;
+ $GrpDef->PrevValue = $x;
+ }
+ }
+ }
+ $PrevSrc->CurrRec = $Src->CurrRec;
+ $PrevSrc->RecNum = $Src->RecNum;
+ $PrevSrc->RecKey = $Src->RecKey;
+ }
+ if ($LocR->HeaderFound) {
+ $change = ($Src->RecNum===1);
+ for ($i=1;$i<=$LocR->HeaderNbr;$i++) {
+ $GrpDef =& $LocR->HeaderDef[$i];
+ $x = $Src->CurrRec[$GrpDef->Field];
+ if (!$change) $change = !($GrpDef->PrevValue===$x);
+ if ($change) {
+ $grp_src .= $this->meth_Merge_SectionNormal($GrpDef,$Src);
+ $GrpDef->PrevValue = $x;
+ }
+ }
+ $grp_change = ($grp_change or $change);
+ }
+ if ($grp_change) {
+ if ($IsSerial) {
+ $BlockRes .= $this->meth_Merge_SectionSerial($SecDef,$SrId,$LocR);
+ $IsSerial = false;
+ }
+ $BlockRes .= $grp_src;
+ }
+ } // end of header and footer
+
+ // Increment Section
+ if (($IsSerial===false) and $SecOk) {
+ $SecId++;
+ if ($SecId>$LocR->SectionNbr) $SecId = 1;
+ $SecDef =& $LocR->SectionLst[$SecId];
+ $IsSerial = $SecDef->IsSerial;
+ if ($IsSerial) {
+ $SrId = 0;
+ $SrNbr = $SecDef->SrBDefNbr;
+ }
+ }
+
+ // Serial Mode Activation
+ if ($IsSerial) { // Serial Merge
+ $SrId++;
+ $SrBDef =& $SecDef->SrBDefLst[$SrId];
+ $SrBDef->SrTxt = $this->meth_Merge_SectionNormal($SrBDef,$Src);
+ if ($SrId>=$SrNbr) {
+ $SecSrc = $this->meth_Merge_SectionSerial($SecDef,$SrId,$LocR);
+ $BlockRes .= $SecSrc;
+ $IsSerial = false;
+ }
+ } else { // Classic merge
+ if ($SecOk) {
+ if ($Src->RecNum===$RecSpe) $SecDef =& $LocR->Special;
+ $SecSrc = $this->meth_Merge_SectionNormal($SecDef,$Src);
+ } else {
+ $SecSrc = '';
+ }
+ if ($LocR->WhenFound) { // With conditional blocks
+ $found = false;
+ $continue = true;
+ $i = 1;
+ do {
+ $WhenBDef =& $LocR->WhenLst[$i];
+ $cond = $this->meth_Merge_SectionNormal($WhenBDef->WhenCond,$Src);
+ if (tbs_Misc_CheckCondition($cond)) {
+ $x_when = $this->meth_Merge_SectionNormal($WhenBDef,$Src);
+ if ($WhenBDef->WhenBeforeNS) {$SecSrc = $x_when.$SecSrc;} else {$SecSrc = $SecSrc.$x_when;}
+ $found = true;
+ if ($LocR->WhenSeveral===false) $continue = false;
+ }
+ $i++;
+ if ($i>$LocR->WhenNbr) $continue = false;
+ } while ($continue);
+ if (($found===false) and ($LocR->WhenDefault!==false)) {
+ $x_when = $this->meth_Merge_SectionNormal($LocR->WhenDefault,$Src);
+ if ($LocR->WhenDefaultBeforeNS) {$SecSrc = $x_when.$SecSrc;} else {$SecSrc = $SecSrc.$x_when;}
+ }
+ }
+ if ($piOMS) $this->meth_PlugIn_RunAll($this->_piOnMergeSection,$ArgLst);
+ $BlockRes .= $SecSrc;
+ }
+
+ // Next row
+ $Src->DataFetch();
+
+ } //--> while($CurrRec!==false) {
+
+ $SecSrc = '';
+
+ // Serial: merge the extra the sub-blocks
+ if ($IsSerial) $SecSrc .= $this->meth_Merge_SectionSerial($SecDef,$SrId,$LocR);
+
+ // Footer
+ if ($LocR->FooterFound) {
+ if ($Src->RecNum>0) {
+ for ($i=1;$i<=$LocR->FooterNbr;$i++) {
+ $GrpDef =& $LocR->FooterDef[$i];
+ if ($GrpDef->IsFooter) $SecSrc .= $this->meth_Merge_SectionNormal($GrpDef,$PrevSrc);
+ }
+ }
+ }
+
+ // NoData
+ if ($Src->RecNum===0) {
+ if ($LocR->NoData!==false) {
+ $SecSrc = $LocR->NoData->Src;
+ } elseif(isset($LocR->PrmLst['bmagnet'])) {
+ tbs_Locator_EnlargeToTag($Txt,$LocR,$LocR->PrmLst['bmagnet'],false);
+ }
+ }
+
+ // Plug-ins
+ if ($piOMS and ($SecSrc!=='')) $this->meth_PlugIn_RunAll($this->_piOnMergeSection,$ArgLst);
+
+ $BlockRes .= $SecSrc;
+
+ // Plug-ins
+ if ($this->_PlugIns_Ok and isset($ArgLst) and isset($this->_piAfterMergeBlock)) {
+ $ArgLst = array(&$BlockRes,&$Src,&$LocR);
+ $this->meth_PlugIn_RunAll($this->_piAfterMergeBlock,$ArgLst);
+ }
+
+ // Merge the result
+ $Txt = substr_replace($Txt,$BlockRes,$LocR->PosBeg,$LocR->PosEnd-$LocR->PosBeg+1);
+
+}
+
+function meth_Merge_AutoVar(&$Txt,$HtmlConv,$Id='var') {
+// Merge [var.*] fields with global variables
+
+ $Pref =& $this->VarPrefix;
+ $PrefL = strlen($Pref);
+ $PrefOk = ($PrefL>0);
+
+ if ($HtmlConv===false) {
+ $HtmlCharSet = $this->HtmlCharSet;
+ $this->HtmlCharSet = false;
+ }
+
+ // Then we scann all fields in the model
+ $x = '';
+ $Pos = 0;
+ while ($Loc = $this->meth_Locator_FindTbs($Txt,$Id,$Pos,'.')) {
+ if ($Loc->SubNbr==0) $Loc->SubLst[0]=''; // In order to force error message
+ if ($Loc->SubLst[0]==='') {
+ $Pos = $this->meth_Merge_AutoSpe($Txt,$Loc);
+ } elseif ($Loc->SubLst[0][0]==='~') {
+ if (!isset($ObjOk)) $ObjOk = (is_object($this->ObjectRef) or is_array($this->ObjectRef));
+ if ($ObjOk) {
+ $Loc->SubLst[0] = substr($Loc->SubLst[0],1);
+ $Pos = $this->meth_Locator_Replace($Txt,$Loc,$this->ObjectRef,0);
+ } elseif ($this->NoErr or isset($Loc->PrmLst['noerr'])) {
+ $Pos = $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 = $Loc->PosEnd + 1;
+ }
+ } elseif ($PrefOk and (substr($Loc->SubLst[0],0,$PrefL)!==$Pref)) {
+ if ($this->NoErr or isset($Loc->PrmLst['noerr'])) {
+ $Pos = $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+ } else {
+ $this->meth_Misc_Alert($Loc,'does not match the allowed prefix.',true);
+ $Pos = $Loc->PosEnd + 1;
+ }
+ } elseif (isset($GLOBALS[$Loc->SubLst[0]])) {
+ $Pos = $this->meth_Locator_Replace($Txt,$Loc,$GLOBALS[$Loc->SubLst[0]],1);
+ } else {
+ if ($this->NoErr or isset($Loc->PrmLst['noerr'])) {
+ $Pos = $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+ } else {
+ $Pos = $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===false) $this->HtmlCharSet = $HtmlCharSet;
+
+ return false; // Useful property PrmIfVar & PrmThenVar
+
+}
+
+function meth_Merge_AutoSpe(&$Txt,&$Loc) {
+// Merge [var..*] (Special Var Fields)
+
+ $ErrMsg = false;
+ $SubStart = false;
+ if (isset($Loc->SubLst[1])) {
+ switch ($Loc->SubLst[1]) {
+ case 'now': $x = mktime(); break;
+ case 'version': $x = $this->Version; break;
+ case 'script_name': $x = basename(((isset($_SERVER)) ? $_SERVER['PHP_SELF'] : $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] )); break;
+ case 'template_name': $x = $this->_LastFile; break;
+ case 'template_date': $x = filemtime($this->_LastFile); break;
+ case 'template_path': $x = dirname($this->_LastFile).'/'; break;
+ case 'name': $x = 'TinyButStrong'; break;
+ case 'logo': $x = '**TinyButStrong**'; break;
+ case 'charset': $x = $this->HtmlCharSet; break;
+ case '': $ErrMsg = 'it doesn\'t have any keyword.'; break;
+ case 'tplvars':
+ if ($Loc->SubNbr==2) {
+ $SubStart = 2;
+ $x = implode(',',array_keys($this->TplVars));
+ } else {
+ if (isset($this->TplVars[$Loc->SubLst[2]])) {
+ $SubStart = 3;
+ $x =& $this->TplVars[$Loc->SubLst[2]];
+ } else {
+ $ErrMsg = 'property TplVars doesn\'t have any item named \''.$Loc->SubLst[2].'\'.';
+ }
+ }
+ break;
+ case 'cst': $x = @constant($Loc->SubLst[2]); break;
+ case 'tbs_info':
+ $x = 'TinyButStrong version '.$this->Version.' for PHP 5';
+ $x .= "\r\nInstalled plug-ins: ".count($this->_PlugIns);
+ foreach (array_keys($this->_PlugIns) as $pi) {
+ $o =& $this->_PlugIns[$pi];
+ $x .= "\r\n- plug-in [".(isset($o->Name) ? $o->Name : $pi ).'] version '.(isset($o->Version) ? $o->Version : '?' );
+ }
+ break;
+ default:
+ $IsSupported = false;
+ if (isset($this->_piOnSpecialVar)) {
+ $x = '';
+ $ArgLst = 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 = '\''.$Loc->SubLst[1].'\' is an unsupported keyword.';
+ }
+ } else {
+ $ErrMsg = 'it doesn\'t have any subname.';
+ }
+ if ($ErrMsg!==false) {
+ $this->meth_Misc_Alert($Loc,$ErrMsg);
+ $x = '';
+ }
+ if ($Loc->PosBeg===false) {
+ 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,true); return true;
+ case 'onshow': $this->meth_Merge_AutoOn($this->Source,'onshow',false,true);return true;
+ default: return false;
+ }
+}
+
+function meth_Merge_FieldOutside(&$Txt,&$Src,&$LocR) {
+ $Pos = 0;
+ $SubStart = ($Src->CurrRec===false) ? false : 0;
+ do {
+ $Loc = $this->meth_Locator_FindTbs($Txt,$this->_CurrBlock,$Pos,'.');
+ if ($LocR->BlockFound and ($Loc!==false)) {
+ $OldEnd = $Loc->PosEnd;
+ if ($Loc->PosEnd>=$LocR->PosBeg) $Loc = false;
+ }
+ if ($Loc!==false) {
+ if ($Loc->SubName==='#') {
+ $Pos = $this->meth_Locator_Replace($Txt,$Loc,$Src->RecNum,false);
+ } else {
+ $Pos = $this->meth_Locator_Replace($Txt,$Loc,$Src->CurrRec,$SubStart);
+ }
+ if ($LocR->BlockFound) {
+ $Delta = $Pos - $OldEnd;
+ $LocR->PosBeg += $Delta;
+ $LocR->PosEnd += $Delta;
+ }
+ }
+ } while ($Loc!==false);
+}
+
+function meth_Merge_SectionNormal(&$BDef,&$Src) {
+
+ $Txt = $BDef->Src;
+ $LocLst =& $BDef->LocLst;
+ $iMax = $BDef->LocNbr;
+ $PosMax = strlen($Txt);
+
+ if ($Src===false) { // Erase all fields
+
+ $x = '';
+
+ // Chached locators
+ for ($i=$iMax;$i>0;$i--) {
+ if ($LocLst[$i]->PosBeg<$PosMax) {
+ $this->meth_Locator_Replace($Txt,$LocLst[$i],$x,false);
+ if ($LocLst[$i]->Enlarged) {
+ $PosMax = $LocLst[$i]->PosBeg;
+ $LocLst[$i]->PosBeg = $LocLst[$i]->PosBeg0;
+ $LocLst[$i]->PosEnd = $LocLst[$i]->PosEnd0;
+ $LocLst[$i]->Enlarged = false;
+ }
+ }
+ }
+
+ // Unchached locators
+ if ($BDef->Chk) {
+ $BlockName =& $BDef->Name;
+ $Pos = 0;
+ while ($Loc = $this->meth_Locator_FindTbs($Txt,$BlockName,$Pos,'.')) $Pos = $this->meth_Locator_Replace($Txt,$Loc,$x,false);
+ }
+
+ } else {
+
+ // Chached locators
+ for ($i=$iMax;$i>0;$i--) {
+ if ($LocLst[$i]->PosBeg<$PosMax) {
+ if ($LocLst[$i]->IsRecInfo) {
+ if ($LocLst[$i]->RecInfo==='#') {
+ $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 = $LocLst[$i]->PosBeg;
+ $LocLst[$i]->PosBeg = $LocLst[$i]->PosBeg0;
+ $LocLst[$i]->PosEnd = $LocLst[$i]->PosEnd0;
+ $LocLst[$i]->Enlarged = false;
+ }
+ }
+ }
+
+ // Unchached locators
+ if ($BDef->Chk) {
+ $BlockName =& $BDef->Name;
+ foreach ($Src->CurrRec as $key => $val) {
+ $Pos = 0;
+ $Name = $BlockName.'.'.$key;
+ while ($Loc = $this->meth_Locator_FindTbs($Txt,$Name,$Pos,'.')) $Pos = $this->meth_Locator_Replace($Txt,$Loc,$val,0);
+ }
+ $Pos = 0;
+ $Name = $BlockName.'.#';
+ while ($Loc = $this->meth_Locator_FindTbs($Txt,$Name,$Pos,'.')) $Pos = $this->meth_Locator_Replace($Txt,$Loc,$Src->RecNum,0);
+ $Pos = 0;
+ $Name = $BlockName.'.$';
+ while ($Loc = $this->meth_Locator_FindTbs($Txt,$Name,$Pos,'.')) $Pos = $this->meth_Locator_Replace($Txt,$Loc,$Src->RecKey,0);
+ }
+
+ }
+
+ return $Txt;
+
+}
+
+function meth_Merge_SectionSerial(&$BDef,&$SrId,&$LocR) {
+
+ $Txt = $BDef->Src;
+ $SrBDefOrdered =& $BDef->SrBDefOrdered;
+ $Empty =& $LocR->SerialEmpty;
+
+ // All Items
+ $F = false;
+ for ($i=$BDef->SrBDefNbr;$i>0;$i--) {
+ $SrBDef =& $SrBDefOrdered[$i];
+ if ($SrBDef->SrTxt===false) { // Subsection not merged with a record
+ if ($Empty===false) {
+ $SrBDef->SrTxt = $this->meth_Merge_SectionNormal($SrBDef,$F);
+ } else {
+ $SrBDef->SrTxt = $Empty;
+ }
+ }
+ $Txt = substr_replace($Txt,$SrBDef->SrTxt,$SrBDef->SrBeg,$SrBDef->SrLen);
+ $SrBDef->SrTxt = false;
+ }
+
+ $SrId = 0;
+ return $Txt;
+
+}
+
+function meth_Merge_AutoOn(&$Txt,$Name,$TplVar,$AcceptGrp) {
+// Merge [onload] or [onshow] fields and blocks
+
+ $GrpDisplayed = array();
+ $GrpExclusive = array();
+ $P1 = false;
+ $FieldBefore = false;
+ $Pos = 0;
+
+ if ($AcceptGrp) {
+ $ChrSub = '_';
+ } else {
+ $ChrSub = '';
+ }
+
+ while ($LocA=$this->meth_Locator_FindBlockNext($Txt,$Name,$Pos,$ChrSub,1,$P1,$FieldBefore)) {
+
+ if ($LocA->BlockFound) {
+
+ if (!isset($GrpDisplayed[$LocA->SubName])) {
+ $GrpDisplayed[$LocA->SubName] = false;
+ $GrpExclusive[$LocA->SubName] = !($AcceptGrp and ($LocA->SubName===''));
+ }
+ $Displayed =& $GrpDisplayed[$LocA->SubName];
+ $Exclusive =& $GrpExclusive[$LocA->SubName];
+
+ $DelBlock = false;
+ $DelField = false;
+ if ($Displayed and $Exclusive) {
+ $DelBlock = true;
+ } else {
+ if (isset($LocA->PrmLst['when'])) {
+ if (isset($LocA->PrmLst['several'])) $Exclusive=false;
+ $x = $LocA->PrmLst['when'];
+ $this->meth_Merge_AutoVar($x,false);
+ if (tbs_Misc_CheckCondition($x)) {
+ $DelField = true;
+ $Displayed = true;
+ } else {
+ $DelBlock = true;
+ }
+ } elseif(isset($LocA->PrmLst['default'])) {
+ if ($Displayed) {
+ $DelBlock = true;
+ } else {
+ $Displayed = true;
+ $DelField = true;
+ }
+ $Exclusive = true; // No more block displayed for the group after VisElse
+ }
+ }
+
+ // Del parts
+ if ($DelField) {
+ if ($LocA->PosBeg2!==false) $Txt = substr_replace($Txt,'',$LocA->PosBeg2,$LocA->PosEnd2-$LocA->PosBeg2+1);
+ $Txt = substr_replace($Txt,'',$LocA->PosBeg,$LocA->PosEnd-$LocA->PosBeg+1);
+ $Pos = $LocA->PosBeg;
+ } else {
+ if ($LocA->PosBeg2===false) {
+ tbs_Locator_EnlargeToTag($Txt,$LocA,$LocA->PrmLst['block'],false);
+ } else {
+ $LocA->PosEnd = $LocA->PosEnd2;
+ }
+ if ($DelBlock) {
+ $Txt = substr_replace($Txt,'',$LocA->PosBeg,$LocA->PosEnd-$LocA->PosBeg+1);
+ } else {
+ // Merge the block as if it was a field
+ $x = '';
+ $this->meth_Locator_Replace($Txt,$LocA,$x,false);
+ }
+ $Pos = $LocA->PosBeg;
+ }
+
+ } else { // Field
+
+ // Check for Template Var
+ if ($TplVar and isset($LocA->PrmLst['tplvars'])) {
+ $Ok = false;
+ foreach ($LocA->PrmLst as $Key => $Val) {
+ if ($Ok) {
+ $this->TplVars[$Key] = $Val;
+ } else {
+ if ($Key==='tplvars') $Ok = true;
+ }
+ }
+ }
+
+ $x = '';
+ $Pos = $this->meth_Locator_Replace($Txt,$LocA,$x,false);
+ $Pos = $LocA->PosBeg;
+
+ }
+
+ }
+
+ return count($GrpDisplayed);
+
+}
+
+// Convert a string to Html with several options
+function meth_Conv_Html(&$Txt) {
+ if ($this->HtmlCharSet==='') {
+ $Txt = htmlspecialchars($Txt); // Faster
+ } elseif ($this->_HtmlCharFct) {
+ $Txt = call_user_func($this->HtmlCharSet,$Txt);
+ } else {
+ $Txt = 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=false,$SrcType=false) {
+ $this->ErrCount++;
+ if ($this->NoErr) return false;
+ if (!is_string($Src)) {
+ if ($SrcType===false) $SrcType='in field';
+ $Src = $SrcType.' '.$this->_ChrOpen.$Src->FullName.'...'.$this->_ChrClose;
+ }
+ $x = '<br /><b>TinyButStrong Error</b> '.$Src.' : '.htmlentities($Msg);
+ if ($NoErrMsg) $x = $x.' <em>This message can be cancelled using parameter \'noerr\'.</em>';
+ $x = $x."<br />\n";
+ $x = 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 =& $this->Source;
+ $Loc->SaveRender = $this->Render;
+ $Loc->SaveMode = $this->_Mode;
+ unset($this->Source); $this->Source = '';
+ $this->Render = TBS_OUTPUT;
+ $this->_Mode++; // Mode>0 means subtemplate mode
+ ob_start(); // Start buffuring output
+ } else {
+ // Restore contents configuration
+ $this->Source =& $Loc->SaveSrc;
+ $this->Render = $Loc->SaveRender;
+ $this->_Mode = $Loc->SaveMode;
+ $CurrVal = ob_get_contents();
+ ob_end_clean();
+ }
+}
+
+function meth_Misc_UserFctCheck(&$FctInfo,$FctCat,&$FctObj,&$ErrMsg) {
+
+ $FctId = $FctCat.':'.$FctInfo;
+ if (isset($this->_UserFctLst[$FctId])) {
+ $FctInfo = $this->_UserFctLst[$FctId];
+ return true;
+ }
+
+ // Check and put in cache
+ $FctStr = $FctInfo;
+ $IsData = ($FctCat!=='f');
+ $Save = true;
+ if ($FctStr[0]==='~') {
+ $ObjRef =& $this->ObjectRef;
+ $Lst = explode('.',substr($FctStr,1));
+ $iMax = count($Lst) - 1;
+ $Suff = 'tbsdb';
+ $iMax0 = $iMax;
+ if ($IsData) {
+ $Suff = $Lst[$iMax];
+ $iMax--;
+ }
+ // Reading sub items
+ for ($i=0;$i<=$iMax;$i++) {
+ $x =& $Lst[$i];
+ if (is_object($ObjRef)) {
+ $ArgLst = tbs_Misc_CheckArgLst($x);
+ if (method_exists($ObjRef,$x)) {
+ if ($i<$iMax) {
+ $f = array(&$ObjRef,$x); unset($ObjRef);
+ $ObjRef = call_user_func_array($f,$ArgLst);
+ }
+ } elseif ($i===$iMax0) {
+ $ErrMsg = 'Expression \''.$FctStr.'\' is invalid because \''.$x.'\' is not a method in the class \''.get_class($ObjRef).'\'.';
+ return false;
+ } elseif (isset($ObjRef->$x)) {
+ $ObjRef =& $ObjRef->$x;
+ } else {
+ $ErrMsg = '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 =& $ObjRef[$x];
+ } else {
+ $ErrMsg = 'Expression \''.$FctStr.'\' is invalid because sub-item \''.$x.'\' is not a existing key in the array.';
+ return false;
+ }
+ } else {
+ $ErrMsg = 'Expression \''.$FctStr.'\' is invalid because '.(($i===0)?'property ObjectRef':'sub-item \''.$x.'\'').' is not an object'.(($i<$iMax)?' or an array.':'.');
+ return false;
+ }
+ }
+ // Referencing last item
+ if ($IsData) {
+ $FctInfo = array('open'=>'','fetch'=>'','close'=>'');
+ foreach ($FctInfo as $act=>$x) {
+ $FctName = $Suff.'_'.$act;
+ if (method_exists($ObjRef,$FctName)) {
+ $FctInfo[$act] = array(&$ObjRef,$FctName);
+ } else {
+ $ErrMsg = 'Expression \''.$FctStr.'\' is invalid because method '.$FctName.' is not found.';
+ return false;
+ }
+ }
+ $FctInfo['type'] = 4;
+ if (isset($this->RecheckObj) and $this->RecheckObj) $Save = false;
+ } else {
+ $FctInfo = array(&$ObjRef,$x);
+ }
+ } elseif ($IsData) {
+
+ $IsObj = ($FctCat==='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 = 'the expected method \'tbsdb_fetch\' is not found for the class '.$Cls.'.';
+ return false;
+ }
+ if (!method_exists($FctObj,'tbsdb_close')) {
+ $ErrMsg = 'the expected method \'tbsdb_close\' is not found for the class '.$Cls.'.';
+ return false;
+ }
+ $FctInfo = array('type'=>5);
+
+ } else {
+
+ if ($FctCat==='r') { // Resource
+ $x = strtolower($FctStr);
+ $x = str_replace('-','_',$x);
+ $Key = '';
+ $i = 0;
+ $iMax = strlen($x);
+ while ($i<$iMax) {
+ if (($x[$i]==='_') or (($x[$i]>='a') and ($x[$i]<='z')) or (($x[$i]>='0') and ($x[$i]<='9'))) {
+ $Key .= $x[$i];
+ $i++;
+ } else {
+ $i = $iMax;
+ }
+ }
+ } else {
+ $Key = $FctStr;
+ }
+
+ $FctInfo = array('open'=>'','fetch'=>'','close'=>'');
+ foreach ($FctInfo as $act=>$x) {
+ $FctName = 'tbsdb_'.$Key.'_'.$act;
+ if (function_exists($FctName)) {
+ $FctInfo[$act] = $FctName;
+ } else {
+ $err = true;
+ if ($act==='open') { // Try simplified key
+ $p = strpos($Key,'_');
+ if ($p!==false) {
+ $Key2 = substr($Key,0,$p);
+ $FctName2 = 'tbsdb_'.$Key2.'_'.$act;
+ if (function_exists($FctName2)) {
+ $err = false;
+ $Key = $Key2;
+ $FctInfo[$act] = $FctName2;
+ }
+ }
+ }
+ if ($err) {
+ $ErrMsg = 'Data source Id \''.$FctStr.'\' is unsupported because function \''.$FctName.'\' is not found.';
+ return false;
+ }
+ }
+ }
+
+ $FctInfo['type'] = 3;
+
+ }
+
+ } else {
+ if (!function_exists($FctStr)) {
+ $x = explode('.',$FctStr);
+ if (count($x)==2) {
+ if (class_exists($x[0])) {
+ $FctInfo = $x;
+ } else {
+ $ErrMsg = 'user function \''.$FctStr.'\' is not correct because \''.$x[0].'\' is not a class name.'; return false;
+ }
+ } else {
+ $ErrMsg = 'user function \''.$FctStr.'\' is not found.'; return false;
+ }
+ }
+ }
+
+ if ($Save) $this->_UserFctLst[$FctId] = $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 = true;
+ foreach ($FctBank as $FctInfo) {
+ $Ok = call_user_func_array($FctInfo,$ArgLst);
+ if (!is_null($Ok)) $OkAll = ($OkAll and $Ok);
+ }
+ return $OkAll;
+}
+
+function meth_PlugIn_Install($PlugInId,$ArgLst,$Auto) {
+
+ $ErrMsg = 'with plug-in \''.$PlugInId.'\'';
+
+ if (class_exists($PlugInId)) {
+ // Create an instance
+ $IsObj = true;
+ $PiRef = new $PlugInId;
+ $PiRef->TBS =& $this;
+ if (!method_exists($PiRef,'OnInstall')) return $this->meth_Misc_Alert($ErrMsg,'OnInstall() method is not found.');
+ $FctRef = array(&$PiRef,'OnInstall');
+ } else {
+ $FctRef = 'tbspi_'.$PlugInId.'_OnInstall';
+ if(function_exists($FctRef)) {
+ $IsObj = false;
+ $PiRef = true;
+ } else {
+ return $this->meth_Misc_Alert($ErrMsg,'no class named \''.$PlugInId.'\' is found, and no function named \''.$FctRef.'\' is found.');
+ }
+ }
+
+ $EventLst = call_user_func_array($FctRef,$ArgLst);
+ if (is_string($EventLst)) $EventLst = explode(',',$EventLst);
+ if (!is_array($EventLst)) return $this->meth_Misc_Alert($ErrMsg,'OnInstall() method does not return an array.');
+
+ // Add activated methods
+ $EventRef = explode(',','OnCommand,BeforeLoadTemplate,AfterLoadTemplate,BeforeShow,AfterShow,OnData,OnFormat,OnOperation,BeforeMergeBlock,OnMergeSection,AfterMergeBlock,OnSpecialVar,OnMergeField');
+ foreach ($EventLst as $Event) {
+ $Event = 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($ErrMsg,'OnInstall() has returned a Plug-in event named \''.$Event.'\' which is not found.');
+ $FctRef = array(&$PiRef,$Event);
+ } else {
+ $FctRef = '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 = '_pi'.$Event;
+ if (!isset($this->$PropName)) $this->$PropName = array();
+ $PropRef =& $this->$PropName;
+ $PropRef[$PlugInId] = $FctRef;
+ // Flags saying if a plugin is installed
+ switch ($Event) {
+ case 'OnCommand': break;
+ case 'OnSpecialVar': break;
+ case 'OnOperation': break;
+ case 'OnFormat': $this->_piOnFrm_Ok = true; break;
+ default: $this->_PlugIns_Ok = true; break;
+ }
+ }
+
+ $this->_PlugIns[$PlugInId] =& $PiRef;
+ return true;
+
+}
+
+function meth_Misc_Format(&$Value,&$PrmLst) {
+// This function return the formated representation of a Date/Time or numeric variable using a 'VB like' format syntax instead of the PHP syntax.
+
+ $FrmStr = $PrmLst['frm'];
+ $CheckNumeric = true;
+ if (is_string($Value)) $Value = trim($Value);
+
+ // Manage Multi format strings
+ if (strpos($FrmStr,'|')!==false) {
+
+ // Save the format if it doesn't exist
+ if (isset($this->_FrmMultiLst[$FrmStr])) {
+ $FrmLst =& $this->_FrmMultiLst[$FrmStr];
+ } else {
+ $FrmLst = explode('|',$FrmStr); // syntax : Postive|Negative|Zero|Null
+ $FrmNbr = count($FrmLst);
+ $FrmLst['abs'] = ($FrmNbr>1);
+ if ($FrmNbr<3) $FrmLst[2] =& $FrmLst[0]; // zero
+ if ($FrmNbr<4) $FrmLst[3] = ''; // null
+ $this->_FrmMultiLst[$FrmStr] = $FrmLst;
+ }
+
+ // Select the format
+ if (is_numeric($Value)) {
+ if (is_string($Value)) $Value = 0.0 + $Value;
+ if ($Value>0) {
+ $FrmStr =& $FrmLst[0];
+ } elseif ($Value<0) {
+ $FrmStr =& $FrmLst[1];
+ if ($FrmLst['abs']) $Value = abs($Value);
+ } else { // zero
+ $FrmStr =& $FrmLst[2];
+ $Minus = '';
+ }
+ $CheckNumeric = false;
+ } else {
+ $Value = ''.$Value;
+ if ($Value==='') {
+ return $FrmLst[3]; // Null value
+ } else {
+ $t = strtotime($Value); // We look if it's a date
+ if (($t===-1) or ($t===false)) { // Date not recognized
+ return $FrmLst[1];
+ } elseif ($t===943916400) { // Date to zero
+ return $FrmLst[2];
+ } else { // It's a date
+ $Value = $t;
+ $FrmStr =& $FrmLst[0];
+ }
+ }
+ }
+
+ }
+
+ if ($FrmStr==='') return '';
+
+ // Retrieve the correct simple format
+ if (!isset($this->_FrmSimpleLst[$FrmStr])) $this->meth_Misc_FormatSave($FrmStr);
+
+ $Frm =& $this->_FrmSimpleLst[$FrmStr];
+
+ switch ($Frm['type']) {
+ case 'num' :
+ // NUMERIC
+ if ($CheckNumeric) {
+ if (is_numeric($Value)) {
+ if (is_string($Value)) $Value = 0.0 + $Value;
+ } else {
+ return ''.$Value;
+ }
+ }
+ if ($Frm['PerCent']) $Value = $Value * 100;
+ $Value = number_format($Value,$Frm['DecNbr'],$Frm['DecSep'],$Frm['ThsSep']);
+ return substr_replace($FrmStr,$Value,$Frm['Pos'],$Frm['Len']);
+ break;
+ case 'date' :
+ // DATE
+ if (is_string($Value)) {
+ if ($Value==='') return '';
+ $x = strtotime($Value);
+ if (($x===-1) or ($x===false)) {
+ if (!is_numeric($Value)) $Value = 0;
+ } else {
+ $Value =& $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 = strrpos($FrmStr,'0');
+
+ if ($nPosEnd!==false) {
+
+ // Numeric format
+ $nDecSep = '.';
+ $nDecNbr = 0;
+ $nDecOk = true;
+
+ if (substr($FrmStr,$nPosEnd+1,1)==='.') {
+ $nPosEnd++;
+ $nPosCurr = $nPosEnd;
+ } else {
+ $nPosCurr = $nPosEnd - 1;
+ while (($nPosCurr>=0) and ($FrmStr[$nPosCurr]==='0')) {
+ $nPosCurr--;
+ }
+ if (($nPosCurr>=1) and ($FrmStr[$nPosCurr-1]==='0')) {
+ $nDecSep = $FrmStr[$nPosCurr];
+ $nDecNbr = $nPosEnd - $nPosCurr;
+ } else {
+ $nDecOk = false;
+ }
+ }
+
+ // Thousand separator
+ $nThsSep = '';
+ if (($nDecOk) and ($nPosCurr>=5)) {
+ if ((substr($FrmStr,$nPosCurr-3,3)==='000') and ($FrmStr[$nPosCurr-4]!=='') and ($FrmStr[$nPosCurr-5]==='0')) {
+ $nPosCurr = $nPosCurr-4;
+ $nThsSep = $FrmStr[$nPosCurr];
+ }
+ }
+
+ // Pass next zero
+ if ($nDecOk) $nPosCurr--;
+ while (($nPosCurr>=0) and ($FrmStr[$nPosCurr]==='0')) {
+ $nPosCurr--;
+ }
+
+ // Percent
+ $nPerCent = (strpos($FrmStr,'%')===false) ? false : true;
+
+ $this->_FrmSimpleLst[$FrmStr] = array('type'=>'num','Pos'=>($nPosCurr+1),'Len'=>($nPosEnd-$nPosCurr),'ThsSep'=>$nThsSep,'DecSep'=>$nDecSep,'DecNbr'=>$nDecNbr,'PerCent'=>$nPerCent);
+
+ } else { // if ($nPosEnd!==false)
+
+ // Date format
+ $FrmPHP = '';
+ $FrmLOC = '';
+ $Local = false;
+ $StrIn = false;
+ $iMax = strlen($FrmStr);
+ $Cnt = 0;
+
+ for ($i=0;$i<$iMax;$i++) {
+
+ if ($StrIn) {
+ // We are in a string part
+ if ($FrmStr[$i]==='"') {
+ if (substr($FrmStr,$i+1,1)==='"') {
+ $FrmPHP .= '\\"'; // protected char
+ $FrmLOC .= $FrmStr[$i];
+ $i++;
+ } else {
+ $StrIn = false;
+ }
+ } else {
+ $FrmPHP .= '\\'.$FrmStr[$i]; // protected char
+ $FrmLOC .= $FrmStr[$i];
+ }
+ } else {
+ if ($FrmStr[$i]==='"') {
+ $StrIn = true;
+ } else {
+ $Cnt++;
+ if (strcasecmp(substr($FrmStr,$i,2),'hh' )===0) { $FrmPHP .= 'H'; $FrmLOC .= '%H'; $i += 1;}
+ elseif (strcasecmp(substr($FrmStr,$i,2),'hm' )===0) { $FrmPHP .= 'h'; $FrmLOC .= '%I'; $i += 1;} // for compatibility
+ elseif (strcasecmp(substr($FrmStr,$i,1),'h' )===0) { $FrmPHP .= 'G'; $FrmLOC .= '%H';}
+ elseif (strcasecmp(substr($FrmStr,$i,2),'rr' )===0) { $FrmPHP .= 'h'; $FrmLOC .= '%I'; $i += 1;}
+ elseif (strcasecmp(substr($FrmStr,$i,1),'r' )===0) { $FrmPHP .= 'g'; $FrmLOC .= '%I';}
+ elseif (strcasecmp(substr($FrmStr,$i,4),'ampm')===0) { $FrmPHP .= substr($FrmStr,$i,1); $FrmLOC .= '%p'; $i += 3;} // $Fmp = 'A' or 'a'
+ elseif (strcasecmp(substr($FrmStr,$i,2),'nn' )===0) { $FrmPHP .= 'i'; $FrmLOC .= '%M'; $i += 1;}
+ elseif (strcasecmp(substr($FrmStr,$i,2),'ss' )===0) { $FrmPHP .= 's'; $FrmLOC .= '%S'; $i += 1;}
+ elseif (strcasecmp(substr($FrmStr,$i,2),'xx' )===0) { $FrmPHP .= 'S'; $FrmLOC .= '' ; $i += 1;}
+ elseif (strcasecmp(substr($FrmStr,$i,4),'yyyy')===0) { $FrmPHP .= 'Y'; $FrmLOC .= '%Y'; $i += 3;}
+ elseif (strcasecmp(substr($FrmStr,$i,2),'yy' )===0) { $FrmPHP .= 'y'; $FrmLOC .= '%y'; $i += 1;}
+ elseif (strcasecmp(substr($FrmStr,$i,4),'mmmm')===0) { $FrmPHP .= 'F'; $FrmLOC .= '%B'; $i += 3;}
+ elseif (strcasecmp(substr($FrmStr,$i,3),'mmm' )===0) { $FrmPHP .= 'M'; $FrmLOC .= '%b'; $i += 2;}
+ elseif (strcasecmp(substr($FrmStr,$i,2),'mm' )===0) { $FrmPHP .= 'm'; $FrmLOC .= '%m'; $i += 1;}
+ elseif (strcasecmp(substr($FrmStr,$i,1),'m' )===0) { $FrmPHP .= 'n'; $FrmLOC .= '%m';}
+ elseif (strcasecmp(substr($FrmStr,$i,4),'wwww')===0) { $FrmPHP .= 'l'; $FrmLOC .= '%A'; $i += 3;}
+ elseif (strcasecmp(substr($FrmStr,$i,3),'www' )===0) { $FrmPHP .= 'D'; $FrmLOC .= '%a'; $i += 2;}
+ elseif (strcasecmp(substr($FrmStr,$i,1),'w' )===0) { $FrmPHP .= 'w'; $FrmLOC .= '%u';}
+ elseif (strcasecmp(substr($FrmStr,$i,4),'dddd')===0) { $FrmPHP .= 'l'; $FrmLOC .= '%A'; $i += 3;}
+ elseif (strcasecmp(substr($FrmStr,$i,3),'ddd' )===0) { $FrmPHP .= 'D'; $FrmLOC .= '%a'; $i += 2;}
+ elseif (strcasecmp(substr($FrmStr,$i,2),'dd' )===0) { $FrmPHP .= 'd'; $FrmLOC .= '%d'; $i += 1;}
+ elseif (strcasecmp(substr($FrmStr,$i,1),'d' )===0) { $FrmPHP .= 'j'; $FrmLOC .= '%d';}
+ else {
+ $FrmPHP .= '\\'.$FrmStr[$i]; // protected char
+ $FrmLOC .= $FrmStr[$i]; // protected char
+ $Cnt--;
+ }
+ }
+ } //-> if ($StrIn) {...} else
+
+ } //-> for ($i=0;$i<$iMax;$i++)
+
+ if ($Cnt>0) {
+ $this->_FrmSimpleLst[$FrmStr] = array('type'=>'date','str_us'=>$FrmPHP,'str_loc'=>$FrmLOC);
+ } else {
+ $this->_FrmSimpleLst[$FrmStr] = array('type'=>'else','string'=>$FrmStr);
+ }
+
+ } // if ($nPosEnd!==false) {...} else
+
+}
+
+} // class clsTinyButStrong
+
+// *********************************************
+
+function tbs_Misc_ConvSpe(&$Loc) {
+ if ($Loc->ConvMode!==2) {
+ $Loc->ConvMode = 2;
+ $Loc->ConvEsc = false;
+ $Loc->ConvWS = false;
+ $Loc->ConvJS = false;
+ }
+}
+
+function tbs_Misc_CheckArgLst(&$Str) {
+ $ArgLst = array();
+ if (substr($Str,-1,1)===')') {
+ $pos = strpos($Str,'(');
+ if ($pos!==false) {
+ $ArgLst = explode(',',substr($Str,$pos+1,strlen($Str)-$pos-2));
+ $Str = substr($Str,0,$pos);
+ }
+ }
+ return $ArgLst;
+}
+
+function tbs_Misc_CheckCondition($Str) {
+// Check if an expression like "exrp1=expr2" is true or false.
+
+ // Find operator and position
+ $Ope = '=';
+ $Len = 1;
+ $Max = strlen($Str)-1;
+ $Pos = strpos($Str,$Ope);
+ if ($Pos===false) {
+ $Ope = '+';
+ $Pos = strpos($Str,$Ope);
+ if ($Pos===false) return false;
+ if (($Pos>0) and ($Str[$Pos-1]==='-')) {
+ $Ope = '-+'; $Pos--; $Len=2;
+ } elseif (($Pos<$Max) and ($Str[$Pos+1]==='-')) {
+ $Ope = '+-'; $Len=2;
+ } else {
+ return false;
+ }
+ } else {
+ if ($Pos>0) {
+ $x = $Str[$Pos-1];
+ if ($x==='!') {
+ $Ope = '!='; $Pos--; $Len=2;
+ } elseif ($x==='~') {
+ $Ope = '~='; $Pos--; $Len=2;
+ } elseif ($Pos<$Max) {
+ $y = $Str[$Pos+1];
+ if ($y==='=') {
+ $Len=2;
+ } elseif (($x==='+') and ($y==='-')) {
+ $Ope = '+=-'; $Pos--; $Len=3;
+ } elseif (($x==='-') and ($y==='+')) {
+ $Ope = '-=+'; $Pos--; $Len=3;
+ }
+ } else {
+ }
+ }
+ }
+
+ // Read values
+ $Val1 = trim(substr($Str,0,$Pos));
+ $Nude1 = tbs_Misc_DelDelimiter($Val1,'\'');
+ $Val2 = trim(substr($Str,$Pos+$Len));
+ $Nude2 = tbs_Misc_DelDelimiter($Val2,'\'');
+
+ // Compare values
+ if ($Ope==='=') {
+ return (strcasecmp($Val1,$Val2)==0);
+ } elseif ($Ope==='!=') {
+ return (strcasecmp($Val1,$Val2)!=0);
+ } elseif ($Ope==='~=') {
+ return (preg_match($Val2,$Val1)>0);
+ } else {
+ if ($Nude1) $Val1='0'+$Val1;
+ if ($Nude2) $Val2='0'+$Val2;
+ if ($Ope==='+-') {
+ return ($Val1>$Val2);
+ } elseif ($Ope==='-+') {
+ return ($Val1 < $Val2);
+ } elseif ($Ope==='+=-') {
+ return ($Val1 >= $Val2);
+ } elseif ($Ope==='-=+') {
+ return ($Val1<=$Val2);
+ } else {
+ return false;
+ }
+ }
+
+}
+
+function tbs_Misc_DelDelimiter(&$Txt,$Delim) {
+// Delete the string delimiters
+ $len = strlen($Txt);
+ if (($len>1) and ($Txt[0]===$Delim)) {
+ if ($Txt[$len-1]===$Delim) $Txt = substr($Txt,1,$len-2);
+ return false;
+ } else {
+ return true;
+ }
+}
+
+function tbs_Misc_GetFile(&$Txt,&$File,$LastFile='') {
+// Load the content of a file into the text variable.
+ $Txt = '';
+ $fd = @fopen($File, 'r'); // 'rb' if binary for some OS
+ if ($fd===false) {
+ if ($LastFile==='') return false;
+ $File2 = dirname($LastFile).'/'.$File;
+ $fd = @fopen($File2, 'r');
+ if ($fd===false) return false;
+ $File = $File2;
+ }
+ if ($fd===false) return false;
+ $fs = @filesize($File); // return False for an URL
+ if ($fs===false) {
+ while (!feof($fd)) $Txt .= fread($fd,4096);
+ } else {
+ if ($fs>0) $Txt = fread($fd,$fs);
+ }
+ fclose($fd);
+ return true;
+}
+
+function tbs_Locator_PrmRead(&$Txt,$Pos,$HtmlTag,$DelimChrs,$BegStr,$EndStr,&$Loc,&$PosEnd) {
+
+ $BegLen = strlen($BegStr);
+ $BegChr = $BegStr[0];
+ $BegIs1 = ($BegLen===1);
+
+ $DelimIdx = false;
+ $DelimCnt = 0;
+ $DelimChr = '';
+ $BegCnt = 0;
+ $SubName = $Loc->SubOk;
+
+ $Status = 0; // 0: name not started, 1: name started, 2: name ended, 3: equal found, 4: value started
+ $PosName = 0;
+ $PosNend = 0;
+ $PosVal = 0;
+
+ // Variables for checking the loop
+ $PosEnd = strpos($Txt,$EndStr,$Pos);
+ if ($PosEnd===false) return;
+ $Continue = ($Pos<$PosEnd);
+
+ while ($Continue) {
+
+ $Chr = $Txt[$Pos];
+
+ if ($DelimIdx) { // Reading in the string
+
+ if ($Chr===$DelimChr) { // Quote found
+ if ($Chr===$Txt[$Pos+1]) { // Double Quote => the string continue with un-double the quote
+ $Pos++;
+ } else { // Simple Suote => end of string
+ $DelimIdx = false;
+ }
+ }
+
+ } else { // Reading outside the string
+
+ if ($BegCnt===0) {
+
+ // Analyzing parameters
+ $CheckChr = false;
+ if (($Chr===' ') or ($Chr==="\r") or ($Chr==="\n")) {
+ if ($Status===1) {
+ $Status = 2;
+ $PosNend = $Pos;
+ } elseif ($HtmlTag and ($Status===4)) {
+ tbs_Locator_PrmCompute($Txt,$Loc,$SubName,$Status,$HtmlTag,$DelimChr,$DelimCnt,$PosName,$PosNend,$PosVal,$Pos);
+ $Status = 0;
+ }
+ } elseif (($HtmlTag===false) and ($Chr===';')) {
+ tbs_Locator_PrmCompute($Txt,$Loc,$SubName,$Status,$HtmlTag,$DelimChr,$DelimCnt,$PosName,$PosNend,$PosVal,$Pos);
+ $Status = 0;
+ } elseif ($Status===4) {
+ $CheckChr = true;
+ } elseif ($Status===3) {
+ $Status = 4;
+ $DelimCnt = 0;
+ $PosVal = $Pos;
+ $CheckChr = true;
+ } elseif ($Status===2) {
+ if ($Chr==='=') {
+ $Status = 3;
+ } elseif ($HtmlTag) {
+ tbs_Locator_PrmCompute($Txt,$Loc,$SubName,$Status,$HtmlTag,$DelimChr,$DelimCnt,$PosName,$PosNend,$PosVal,$Pos);
+ $Status = 1;
+ $PosName = $Pos;
+ $CheckChr = true;
+ } else {
+ $Status = 4;
+ $DelimCnt = 0;
+ $PosVal = $Pos;
+ $CheckChr = true;
+ }
+ } elseif ($Status===1) {
+ if ($Chr==='=') {
+ $Status = 3;
+ $PosNend = $Pos;
+ } else {
+ $CheckChr = true;
+ }
+ } else {
+ $Status = 1;
+ $PosName = $Pos;
+ $CheckChr = true;
+ }
+
+ if ($CheckChr) {
+ $DelimIdx = strpos($DelimChrs,$Chr);
+ if ($DelimIdx===false) {
+ if ($Chr===$BegChr) {
+ if ($BegIs1) {
+ $BegCnt++;
+ } elseif(substr($Txt,$Pos,$BegLen)===$BegStr) {
+ $BegCnt++;
+ }
+ }
+ } else {
+ $DelimChr = $DelimChrs[$DelimIdx];
+ $DelimCnt++;
+ $DelimIdx = true;
+ }
+ }
+
+ } else {
+ if ($Chr===$BegChr) {
+ if ($BegIs1) {
+ $BegCnt++;
+ } elseif(substr($Txt,$Pos,$BegLen)===$BegStr) {
+ $BegCnt++;
+ }
+ }
+ }
+
+ }
+
+ // Next char
+ $Pos++;
+
+ // We check if it's the end
+ if ($Pos===$PosEnd) {
+ if ($DelimIdx===false) {
+ if ($BegCnt>0) {
+ $BegCnt--;
+ } else {
+ $Continue = false;
+ }
+ }
+ if ($Continue) {
+ $PosEnd = strpos($Txt,$EndStr,$PosEnd+1);
+ if ($PosEnd===false) return;
+ } else {
+ if ($HtmlTag and ($Txt[$Pos-1]==='/')) $Pos--; // In case last attribute is stuck to "/>"
+ tbs_Locator_PrmCompute($Txt,$Loc,$SubName,$Status,$HtmlTag,$DelimChr,$DelimCnt,$PosName,$PosNend,$PosVal,$Pos);
+ }
+ }
+
+ }
+
+ $PosEnd = $PosEnd + (strlen($EndStr)-1);
+
+}
+
+function tbs_Locator_PrmCompute(&$Txt,&$Loc,&$SubName,$Status,$HtmlTag,$DelimChr,$DelimCnt,$PosName,$PosNend,$PosVal,$Pos) {
+
+ if ($Status===0) {
+ $SubName = false;
+ } else {
+ if ($Status===1) {
+ $x = substr($Txt,$PosName,$Pos-$PosName);
+ } else {
+ $x = substr($Txt,$PosName,$PosNend-$PosName);
+ }
+ if ($HtmlTag) $x = strtolower($x);
+ if ($SubName) {
+ $Loc->SubName = $x;
+ $SubName = false;
+ } else {
+ if ($Status===4) {
+ $v = trim(substr($Txt,$PosVal,$Pos-$PosVal));
+ if ($DelimCnt===1) { // Delete quotes inside the value
+ if ($v[0]===$DelimChr) {
+ $len = strlen($v);
+ if ($v[$len-1]===$DelimChr) {
+ $v = substr($v,1,$len-2);
+ $v = str_replace($DelimChr.$DelimChr,$DelimChr,$v);
+ }
+ }
+ }
+ } else {
+ $v = true;
+ }
+ if ($x==='if') {
+ tbs_Locator_PrmIfThen($Loc,true,$v);
+ } elseif ($x==='then') {
+ tbs_Locator_PrmIfThen($Loc,false,$v);
+ } else {
+ $Loc->PrmLst[$x] = $v;
+ }
+ }
+ }
+
+}
+
+function tbs_Locator_PrmIfThen(&$Loc,$IsIf,$Val) {
+ $nbr =& $Loc->PrmIfNbr;
+ if ($nbr===false) {
+ $nbr = 0;
+ $Loc->PrmIf = array();
+ $Loc->PrmIfVar = array();
+ $Loc->PrmThen = array();
+ $Loc->PrmThenVar = array();
+ $Loc->PrmElseVar = true;
+ }
+ if ($IsIf) {
+ $nbr++;
+ $Loc->PrmIf[$nbr] = $Val;
+ $Loc->PrmIfVar[$nbr] = true;
+ } else {
+ $nbr2 = $nbr;
+ if ($nbr2===false) $nbr2 = 1; // Only the first 'then' can be placed before its 'if'. This is for compatibility.
+ $Loc->PrmThen[$nbr2] = $Val;
+ $Loc->PrmThenVar[$nbr2] = 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 = $Loc->PosBeg;
+ $Ok = false;
+ do {
+ $Pos = strrpos(substr($Txt,0,$Pos),$StrBeg[0]);
+ if ($Pos!==false) {
+ if (substr($Txt,$Pos,strlen($StrBeg))===$StrBeg) $Ok = true;
+ }
+ } while ( (!$Ok) and ($Pos!==false) );
+
+ if ($Ok) {
+ $PosEnd = strpos($Txt,$StrEnd,$Loc->PosEnd + 1);
+ if ($PosEnd===false) {
+ $Ok = false;
+ } else {
+ $Loc->PosBeg = $Pos;
+ $Loc->PosEnd = $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=true
+
+ // Analyze string
+ $Ref = 0;
+ $LevelStop = 0;
+ $TagLst = explode('+',$TagLst);
+ $TagIsSgl = array();
+ $TagMax = count($TagLst) - 1;
+ for ($i=0;$i<=$TagMax;$i++) {
+ do { // Check parentheses, relative position and single tag
+ $tag =& $TagLst[$i];
+ $tag = trim($tag);
+ $x = strlen($tag) - 1; // pos of last char
+ if (($x>1) and ($tag[0]==='(') and ($tag[$x]===')')) {
+ if ($Ref===0) $Ref = $i;
+ if ($Ref===$i) $LevelStop++;
+ $tag = substr($tag,1,$x-1);
+ } else {
+ if (($x>=0) and ($tag[$x]==='/')) {
+ $TagIsSgl[$i] = true;
+ $tag = substr($tag,0,$x);
+ } else {
+ $TagIsSgl[$i] = false;
+ }
+ $x = false;
+ }
+ } while ($x!==false);
+ }
+
+ // Find tags that embeds the locator
+ if ($LevelStop===0) $LevelStop = 1;
+ $TagO = tbs_Html_FindTag($Txt,$TagLst[$Ref],true,$Loc->PosBeg-1,false,$LevelStop,false);
+ if ($TagO===false) return false;
+ $PosBeg = $TagO->PosBeg;
+ if ($TagIsSgl[$Ref]) {
+ $PosEnd = max($Loc->PosEnd,$TagO->PosEnd);
+ $InnerLim = $PosEnd + 1;
+ } else {
+ $TagC = tbs_Html_FindTag($Txt,$TagLst[$Ref],false,$Loc->PosEnd+1,true,-$LevelStop,false);
+ if ($TagC==false) return false;
+ $PosEnd = $TagC->PosEnd;
+ $InnerLim = $TagC->PosBeg;
+ }
+
+ $RetVal = true;
+ if ($RetInnerSrc) {
+ $RetVal = '';
+ if ($Loc->PosBeg>$TagO->PosEnd) $RetVal .= substr($Txt,$TagO->PosEnd+1,min($Loc->PosBeg,$InnerLim)-$TagO->PosEnd-1);
+ if ($Loc->PosEnd<$InnerLim) $RetVal .= substr($Txt,max($Loc->PosEnd,$TagO->PosEnd)+1,$InnerLim-max($Loc->PosEnd,$TagO->PosEnd)-1);
+ }
+
+ // Forward
+ $TagC = true;
+ for ($i=$Ref+1;$i<=$TagMax;$i++) {
+ $x = $TagLst[$i];
+ if (($x!=='') and ($TagC!==false)) {
+ $level = ($TagIsSgl[$i]) ? 1 : 0;
+ $TagC = tbs_Html_FindTag($Txt,$x,$TagIsSgl[$i],$PosEnd+1,true,$level,false);
+ if ($TagC!==false) $PosEnd = $TagC->PosEnd;
+ }
+ }
+
+ // Backward
+ $TagO = true;
+ for ($i=$Ref-1;$i>=0;$i--) {
+ $x = $TagLst[$i];
+ if (($x!=='') and ($TagO!==false)) {
+ $level = ($TagIsSgl[$i]) ? 1 : 0;
+ $TagO = tbs_Html_FindTag($Txt,$x,true,$PosBeg-1,false,$level,false);
+ if ($TagO!==false) $PosBeg = $TagO->PosBeg;
+ }
+ }
+
+ $Loc->PosBeg = $PosBeg;
+ $Loc->PosEnd = $PosEnd;
+ return $RetVal;
+
+}
+
+function tbs_Html_Max(&$Txt,&$Nbr,$MaxEnd) {
+// Limit the number of HTML chars
+
+ $pMax = strlen($Txt)-1;
+ $p=0;
+ $n=0;
+ $in = false;
+ $ok = true;
+
+ while ($ok) {
+ if ($in) {
+ if ($Txt[$p]===';') {
+ $in = false;
+ $n++;
+ }
+ } else {
+ if ($Txt[$p]==='&') {
+ $in = true;
+ } else {
+ $n++;
+ }
+ }
+ if (($n>=$Nbr) or ($p>=$pMax)) {
+ $ok = false;
+ } else {
+ $p++;
+ }
+ }
+
+ if (($n>=$Nbr) and ($p<$pMax)) $Txt = substr($Txt,0,$p).$MaxEnd;
+
+}
+
+function tbs_Html_GetPart(&$Txt,$Tag,$WithTags=false,$CancelIfEmpty=false) {
+// This function returns a part of the HTML document (HEAD or BODY)
+// The $CancelIfEmpty parameter enables to cancel the extraction when the part is not found.
+
+ if (($Tag===true) or ($Tag==='')) $Tag = 'BODY';
+
+ $x = false;
+
+ $LocOpen = tbs_Html_FindTag($Txt,$Tag,true,0,true,false,false);
+ if ($LocOpen!==false) {
+ $LocClose = tbs_Html_FindTag($Txt,$Tag,false,$LocOpen->PosEnd+1,true,false,false);
+ if ($LocClose!==false) {
+ if ($WithTags) {
+ $x = substr($Txt,$LocOpen->PosBeg,$LocClose->PosEnd - $LocOpen->PosBeg + 1);
+ } else {
+ $x = substr($Txt,$LocOpen->PosEnd+1,$LocClose->PosBeg - $LocOpen->PosEnd - 1);
+ }
+ }
+ }
+
+ if ($x===false) {
+ if ($CancelIfEmpty) {
+ $x = $Txt;
+ } else {
+ $x = '';
+ }
+ }
+
+ return $x;
+
+}
+
+function tbs_Html_FindTag(&$Txt,$Tag,$Opening,$PosBeg,$Forward,$LevelStop,$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 inserted before the searched tag.
+It also enables to pass a number of encapsulations.
+To ignore encapsulation and opengin/closing just set $LevelStop=false.
+*/
+
+ if ($Tag==='_') { // New line
+ $p = tbs_Html_FindNewLine($Txt,$PosBeg,$Forward,($LevelStop!==0));
+ $Loc = new clsTbsLocator;
+ $Loc->PosBeg = ($Forward) ? $PosBeg : $p;
+ $Loc->PosEnd = ($Forward) ? $p : $PosBeg;
+ return $Loc;
+ }
+
+ $Pos = $PosBeg + (($Forward) ? -1 : +1);
+ $TagIsOpening = false;
+ $TagClosing = '/'.$Tag;
+ $LevelNum = 0;
+ $TagOk = false;
+
+ do {
+
+ // Look for the next tag def
+ if ($Forward) {
+ $Pos = strpos($Txt,'<',$Pos+1);
+ } else {
+ if ($Pos<=0) {
+ $Pos = false;
+ } else {
+ $Pos = strrpos(substr($Txt,0,$Pos - 1),'<');
+ }
+ }
+
+ if ($Pos!==false) {
+
+ // Check the name of the tag
+ if (strcasecmp(substr($Txt,$Pos+1,strlen($Tag)),$Tag)==0) {
+ $PosX = $Pos + 1 + strlen($Tag); // The next char
+ $TagOk = true;
+ $TagIsOpening = true;
+ } elseif (strcasecmp(substr($Txt,$Pos+1,strlen($TagClosing)),$TagClosing)==0) {
+ $PosX = $Pos + 1 + strlen($TagClosing); // The next char
+ $TagOk = true;
+ $TagIsOpening = false;
+ }
+
+ if ($TagOk) {
+ // Check the next char
+ $x = $Txt[$PosX];
+ if (($x===' ') or ($x==="\r") or ($x==="\n") or ($x==='>')) {
+ // Check the encapsulation count
+ if ($LevelStop===false) { // No encaplusation check
+ if ($TagIsOpening!==$Opening) $TagOk = false;
+ } else { // Count the number of level
+ if ($TagIsOpening) {
+ $LevelNum++;
+ } else {
+ $LevelNum--;
+ }
+ // Check if it's the expected level
+ if ($LevelNum!=$LevelStop) $TagOk = false;
+ }
+ } else {
+ $TagOk = false;
+ }
+ } //--> if ($TagOk)
+
+ }
+ } while (($Pos!==false) and ($TagOk===false));
+
+ // Search for the end of the tag
+ if ($TagOk) {
+ $Loc = new clsTbsLocator;
+ if ($WithPrm) {
+ $PosEnd = 0;
+ tbs_Locator_PrmRead($Txt,$PosX,true,'\'"','<','>',$Loc,$PosEnd);
+ } else {
+ $PosEnd = strpos($Txt,'>',$PosX);
+ if ($PosEnd===false) {
+ $TagOk = false;
+ }
+ }
+ }
+
+ // Result
+ if ($TagOk) {
+ $Loc->PosBeg = $Pos;
+ $Loc->PosEnd = $PosEnd;
+ return $Loc;
+ } else {
+ return false;
+ }
+
+}
+
+function tbs_Html_FindNewLine(&$Txt,$PosBeg,$Forward,$IsRef) {
+
+ $p = $PosBeg;
+ if ($Forward) {
+ $Inc = 1;
+ $Inf =& $p;
+ $Sup = strlen($Txt)-1;
+ } else {
+ $Inc = -1;
+ $Inf = 0;
+ $Sup =& $p;
+ }
+
+ do {
+ if ($Inf>$Sup) return max($Sup,0);
+ $x = $Txt[$p];
+ if (($x==="\r") or ($x==="\n")) {
+ $x2 = ($x==="\n") ? "\r" : "\n";
+ $p0 = $p;
+ if (($Inf<$Sup) and ($Txt[$p+$Inc]===$x2)) $p += $Inc; // Newline char can have two chars.
+ if ($Forward) return $p; // Forward => return pos including newline char.
+ if ($IsRef or ($p0!=$PosBeg)) return $p0+1; // Backwars => return pos without newline char. Ignore newline if it is the very first char of the search.
+ }
+ $p += $Inc;
+ } while (true);
+
+}
+
+?>
\ No newline at end of file
Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbs_class_php5.php
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbsooo_class.php
===================================================================
--- 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(a)free.fr)
+Version : 0.7.9
+Require : PHP >= 4.0.6 and TBS >= 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 OpenOffice"
+Download : http://www.tinybutstrong.com/download/download.php?file=tbsooo.zip
+********************************************************
+Released under the GNU LGPL license
+http://www.gnu.org/copyleft/lesser.html
+********************************************************
+*/
+
+class clsTinyButStrongOOo extends clsTinyButStrong
+{
+ // private properties
+
+ var $_process_path = 'tmp/';
+ var $_zip_bin = '';
+ var $_unzip_bin = '';
+ var $_charset = '';
+ var $_ooo_basename = '';
+ var $_ooo_file_ext = '';
+ var $_xml_filename = '';
+
+ // public method
+
+ function SetZipBinary($path_binary, $test=false)
+ {
+ // set the 'zip' binary to compress OOo files
+ if ($path_binary != '') {
+ $this->_zip_bin = $this->_PathQuote($path_binary);
+ }
+
+ // test if zip is present
+ if ($test) {
+ if (strlen(shell_exec($this->_zip_bin.' -h')) == 0) {
+ $this->meth_Misc_Alert('SetZipBinary method', 'Problem to execute the command : shell_exec(\''.$this->_zip_bin.' -h\')');
+ return false;
+ }
+ }
+ return true;
+ }
+
+ function SetUnzipBinary($path_binary, $test=false)
+ {
+ // set the 'unzip binary to decompress OOo files
+ if ($path_binary != '') {
+ $this->_unzip_bin = $this->_PathQuote($path_binary);
+ }
+
+ // test if unzip is present
+ if ($test) {
+ if (strlen(shell_exec($this->_unzip_bin.' -h')) == 0) {
+ $this->meth_Misc_Alert('SetUnzipBinary method', 'Problem to execute 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 == '') {
+ $this->meth_Misc_Alert('SetProcessDir method', 'Parameter is empty');
+ return false;
+ }
+ // add a trailing / at the path
+ $this->_process_path = $process_path.(substr($process_path, -1, 1) == '/' ? '' : '/');
+
+ // test if 'dir' exists
+ if (!is_dir($this->_process_path)) {
+ $this->meth_Misc_Alert('SetProcessDir method', 'Directory not found : '.$this->_process_path);
+ return false;
+ }
+
+ // test if 'dir' is writable
+ if (!is_writable($this->_process_path)) {
+ $this->meth_Misc_Alert('SetProcessDir method', 'Directory not writable : '.$this->_process_path);
+ return false;
+ }
+ return true;
+ }
+
+ function SetDataCharset($charset)
+ {
+ $this->_charset = 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 = md5(microtime());
+ // find path, file and extension
+ $a_pathinfo = pathinfo($ooo_template_filename);
+ $this->_ooo_file_ext = $a_pathinfo['extension'];
+ $this->_ooo_basename = $this->_process_path.$unique;
+
+ // create unique temporary basename dir
+ if (!mkdir($this->_ooo_basename, 0700)) {
+ $this->meth_Misc_Alert('NewDocFromTpl method', 'Can\'t create directory : '.$this->_ooo_basename);
+ return false;
+ }
+
+ // copy the ooo template into the temporary basename dir
+ if (!copy($ooo_template_filename, $this->_ooo_basename.'.'.$this->_ooo_file_ext)) {
+ $this->meth_Misc_Alert('NewDocFromTpl method', 'Can\'t copy file to process dir : '.$ooo_template_filename);
+ return false;
+ }
+ return $this->_ooo_basename.'.'.$this->_ooo_file_ext;
+ }
+
+ function LoadXmlFromDoc($xml_file)
+ {
+ $this->_xml_filename = $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 = &$this;
+ $this->LoadTemplate($this->_ooo_basename.'/'.$this->_xml_filename, '=~_CharsetEncode');
+
+ // work around - convert apostrophe in XML file needed for TBS functions
+ $this->Source = str_replace(''', '\'', $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_file_ext.' '.$filename);
+ }
+
+ function ReplaceTagImage()
+ {
+ /*
+ will be released in tbsooo_img extend tbsooo because need xml php5 functions
+
+ $doc = new DOMDocument();
+ $doc->loadXML($this->Source);
+ $draw_frames = $doc->getElementsByTagName('frame');
+
+ for ($i = 0; $i < $draw_frames->length; $i++) {
+ $draw_frame = $draw_frames->item($i);
+ $svg_descs = $draw_frame->getElementsByTagName('desc');
+ if ($svg_descs->length > 0) {
+ $tag = $svg_descs->item(0)->nodeValue;
+ if (ereg("^\[.*\]", $tag)) {
+ $draw_images = $draw_frame->getElementsByTagName('image');
+ if ($draw_images->length > 0) {
+ $draw_image = $draw_images->item(0);
+ $draw_image->removeAttribute('href');
+ $draw_image->setAttribute('xlink:href', $tag);
+ }
+ }
+ }
+ }
+ $this->Source = $doc->SaveXML();
+ */
+ }
+
+ function SaveXmlToDoc()
+ {
+ // get the source result
+ $this->Show(TBS_NOTHING);
+
+ // store the merge result in place of the XML source file
+ $fdw = 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'; break;
+ 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'; break;
+ 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'; break;
+ case 'ott': return 'application/vnd.oasis.opendocument.text-template'; 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-template'; break;
+ case 'odp': return 'application/vnd.oasis.opendocument.presentation'; break;
+ case 'otp': return 'application/vnd.oasis.opendocument.presentation-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'; break;
+ case 'odf': return 'application/vnd.oasis.opendocument.formula'; break;
+ case 'odb': return 'application/vnd.oasis.opendocument.database'; break;
+ case 'odi': return 'application/vnd.oasis.opendocument.image'; break;
+ default: return ''; break;
+ }
+ }
+
+ function FlushDoc()
+ {
+ // flush file
+ $fp = @fopen($this->GetPathnameDoc(), 'rb'); // replace readfile()
+ fpassthru($fp);
+ fclose($fp);
+ }
+
+ function RemoveDoc()
+ {
+ // remove file
+ unlink($this->GetPathnameDoc());
+ }
+
+ function ClearProcessDir($hour = '2', $minut = '0')
+ {
+ clearstatcache();
+ $now = mktime(date("H")-abs((int)$hour), date("i")-abs((int)$minut), date("s"), date("m"), date("d"), date("Y"));
+ if ($dir = @opendir($this->_process_path)) {
+ while (($file = readdir($dir)) !== false) {
+ if ($file != ".." && $file != ".") {
+ if (filemtime($this->_process_path.$file) < $now) {
+ if (!(is_dir($this->_process_path.$file) ? @rmdir($this->_process_path.'/'.$file) : @unlink($this->_process_path.$file))) {
+ $this->meth_Misc_Alert('ClearProcessDir method', 'Can\'t remove directory or file : '.$this->_process_path.$file);
+ }
+ }
+ }
+ }
+ closedir($dir);
+ }
+ }
+
+ // private method
+
+ function _PathQuote($path_quote)
+ {
+ if (strpos($path_quote, ' ') !== false) {
+ $path_quote = (strpos($path_quote, '"') === 0 ? '' : '"').$path_quote;
+ $path_quote = $path_quote.((strrpos($path_quote, '"') == strlen($path_quote)-1) ? '' : '"');
+ }
+ return $path_quote;
+ }
+
+ function _CharsetEncode($string_encode)
+ {
+ $string_encode = str_replace('&' ,'&', $string_encode);
+ $string_encode = str_replace('<' ,'<', $string_encode);
+ $string_encode = str_replace('>' ,'>', $string_encode);
+ //$string_encode = str_replace("\n", '</text:p><text:p>', $string_encode); // '\n' by XML tags
+ $string_encode = str_replace("\n", '<text:line-break/>', $string_encode); // '\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 = utf8_encode($string_encode);
+ break;
+ }
+ // work-around for EURO caracter
+ $string_encode = str_replace(chr(0xC2).chr(0x80) , chr(0xE2).chr(0x82).chr(0xAC), $string_encode); // �
+ 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 directory : '.$this->_ooo_basename);
+ }
+ }
+}
+?>
\ No newline at end of file
Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/informes/lib/tbsooo_class.php
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_edit_actions.php
===================================================================
--- 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="sf_admin_actions">
+ <li><?php echo submit_tag(__('save'), array (
+ 'name' => 'save',
+ 'class' => 'sf_admin_action_save',
+)) ?></li>
+ <li><?php echo button_to(__('list'), 'informes/list?id='.$informe->getId(), array (
+ 'class' => 'sf_admin_action_list',
+)) ?></li>
+ <li><?php echo submit_tag(__('save and add'), array (
+ 'name' => 'save_and_add',
+ 'class' => 'sf_admin_action_save_and_add',
+)) ?></li>
+</ul>
Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_edit_actions.php
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_edit_form.php
===================================================================
--- 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' => 'sf_admin_edit_form',
+ 'name' => 'sf_admin_edit_form',
+ 'multipart' => true,
+)) ?>
+
+<?php echo object_input_hidden_tag($informe, 'getId') ?>
+
+<fieldset id="sf_fieldset_informacion_general" class="">
+
+<div class="form-row">
+ <?php echo label_for('informe[nombre]', __($labels['informe{nombre}']), 'class="required" ') ?>
+ <div class="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' => 'form-error-msg')) ?>
+ <?php endif; ?>
+
+ <?php $value = object_input_tag($informe, 'getNombre', array (
+ 'size' => 64,
+ 'control_name' => 'informe[nombre]',
+)); echo $value ? $value : ' ' ?>
+ </div>
+</div>
+
+<div class="form-row">
+ <?php echo label_for('informe[descripcion]', __($labels['informe{descripcion}']), 'class="required" ') ?>
+ <div class="content<?php if ($sf_request->hasError('informe{descripcion}')): ?> form-error<?php endif; ?>">
+ <?php if ($sf_request->hasError('informe{descripcion}')): ?>
+ <?php echo form_error('informe{descripcion}', array('class' => 'form-error-msg')) ?>
+ <?php endif; ?>
+
+ <?php $value = object_input_tag($informe, 'getdescripcion', array (
+ 'size' => 64,
+ 'control_name' => 'informe[descripcion]',
+)); echo $value ? $value : ' ' ?>
+ </div>
+</div>
+
+
+
+<div class="form-row">
+ <?php echo label_for('adjunto', __('Plantilla de informe:')) ?>
+ <div class="content<?php if ($sf_request->hasError('file')): ?> form-error<?php endif; ?>">
+ <?php if ($sf_request->hasError('file')): ?>
+ <?php echo form_error('file', array('class' => 'form-error-msg')) ?>
+ <?php endif; ?>
+ <?php echo input_file_tag('file') ?>
+ <?php
+ if($informe->getAdjunto()) {
+ ?><a href="<?php echo sfContext::getInstance()->getRequest()->getRelativeUrlRoot()."/".sfConfig::get('sf_upload_dir_name').'/'. $informe->getAdjunto()->getRuta()?>"><?php echo $informe->getAdjunto()->getNombreArchivo()?></a> <?php
+//- echo link_to("Borrar", "informes?action=borrarAdjunto&id=".$informe->getId());
+ echo " ";
+ }
+ ?>
+ </div>
+</div>
+
+
+<div class="form-row">
+ <?php echo label_for('informe[fk_tipoinforme_id]', __($labels['informe{fk_tipoinforme_id}']), 'class="required" ') ?>
+ <div class="content<?php if ($sf_request->hasError('informe{fk_tipoinforme_id}')): ?> form-error<?php endif; ?>">
+ <?php if ($sf_request->hasError('informe{fk_tipoinforme_id}')): ?>
+ <?php echo form_error('informe{fk_tipoinforme_id}', array('class' => 'form-error-msg')) ?>
+ <?php endif; ?>
+
+ <?php $value = object_select_tag($informe, 'getFkTipoinformeId', array (
+ 'related_class' => 'Tipoinforme',
+ 'control_name' => 'informe[fk_tipoinforme_id]',
+)); echo $value ? $value : ' ' ?>
+ </div>
+</div>
+
+
+
+<div class="form-row">
+ <?php echo label_for('informe[listado]', __($labels['informe{listado}']), 'class="required" ') ?>
+ <div class="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' => 'form-error-msg')) ?>
+ <?php endif; ?>
+
+ <?php $value = object_checkbox_tag($informe, 'getListado', array (
+ 'control_name' => 'informe[listado]',
+)); echo $value ? $value : ' ' ?>
+ </div>
+</div>
+
+
+<div class="form-row">
+ <?php echo label_for('informe[variables]', __($labels['informe{variables}']), 'class="required" ') ?>
+ <div class="content<?php if ($sf_request->hasError('informe{variables}')): ?> form-error<?php endif; ?>">
+ <?php if ($sf_request->hasError('informe{variables}')): ?>
+ <?php echo form_error('informe{variables}', array('class' => 'form-error-msg')) ?>
+ <?php endif; ?>
+
+ <?php $value = object_input_tag($informe, 'getVariables', array (
+ 'size' => 64,
+ 'control_name' => 'informe[variables]',
+)); echo $value ? $value : ' ' ?>
+ </div>
+</div>
+
+
+
+</fieldset>
+
+<?php include_partial('edit_actions', array('informe' => $informe)) ?>
+
+</form>
+
+<ul class="sf_admin_actions">
+ <li class="float-left"><?php if ($informe->getId()): ?>
+<?php echo button_to(__('delete'), 'informes/delete?id='.$informe->getId(), array (
+ 'post' => true,
+ 'confirm' => __('Are you sure?'),
+ 'class' => 'sf_admin_action_delete',
+)) ?><?php endif; ?>
+</li>
+ </ul>
Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_edit_form.php
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_edit_messages.php
===================================================================
--- 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="form-errors">
+<h2><?php echo __('There are some errors that prevent the form to validate') ?></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="save-ok">
+<h2><?php echo __($sf_flash->get('notice')) ?></h2>
+</div>
+<?php endif; ?>
Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_edit_messages.php
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_list.php
===================================================================
--- 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="0" class="sf_admin_list">
+<thead>
+<tr>
+<?php include_partial('list_th_tabular') ?>
+ <th id="sf_admin_list_th_sf_actions"><?php echo __('Actions') ?></th>
+</tr>
+</thead>
+<tbody>
+<?php $i = 1; foreach ($pager->getResults() as $informe): $odd = fmod(++$i, 2) ?>
+<tr class="sf_admin_row_<?php echo $odd ?>">
+<?php include_partial('list_td_tabular', array('informe' => $informe)) ?>
+<?php include_partial('list_td_actions', array('informe' => $informe)) ?>
+</tr>
+<?php endforeach; ?>
+</tbody>
+<tfoot>
+<tr><th colspan="8">
+<div class="float-right">
+<?php if ($pager->haveToPaginate()): ?>
+ <?php echo link_to(image_tag(sfConfig::get('sf_admin_web_dir').'/images/first.png', array('align' => 'absmiddle', 'alt' => __('First'), 'title' => __('First'))), 'informe/list?page=1') ?>
+ <?php echo link_to(image_tag(sfConfig::get('sf_admin_web_dir').'/images/previous.png', array('align' => 'absmiddle', 'alt' => __('Previous'), 'title' => __('Previous'))), 'informe/list?page='.$pager->getPreviousPage()) ?>
+
+ <?php foreach ($pager->getLinks() as $page): ?>
+ <?php echo link_to_unless($page == $pager->getPage(), $page, 'informe/list?page='.$page) ?>
+ <?php endforeach; ?>
+
+ <?php echo link_to(image_tag(sfConfig::get('sf_admin_web_dir').'/images/next.png', array('align' => 'absmiddle', 'alt' => __('Next'), 'title' => __('Next'))), 'informe/list?page='.$pager->getNextPage()) ?>
+ <?php echo link_to(image_tag(sfConfig::get('sf_admin_web_dir').'/images/last.png', array('align' => 'absmiddle', 'alt' => __('Last'), 'title' => __('Last'))), 'informe/list?page='.$pager->getLastPage()) ?>
+<?php endif; ?>
+</div>
+<?php echo format_number_choice('[0] no result|[1] 1 result|(1,+Inf] %1% results', array('%1%' => $pager->getNbResults()), $pager->getNbResults()) ?>
+</th></tr>
+</tfoot>
+</table>
Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_list.php
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_list_actions.php
===================================================================
--- 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="sf_admin_actions">
+ <li><?php echo button_to(__('create'), 'informes/create', array (
+ 'class' => 'sf_admin_action_create',
+)) ?></li>
+ </ul>
Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_list_actions.php
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_list_messages.php
===================================================================
--- 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="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/informes/templates/_list_messages.php
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_list_td_actions.php
===================================================================
--- 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="sf_admin_td_actions">
+ <li><?php echo link_to(image_tag('/sf/sf_admin/images/edit_icon.png', array('alt' => __('edit'), 'title' => __('edit'))), 'informes/edit?id='.$informe->getId()) ?></li>
+ <li><?php echo link_to(image_tag('/sf/sf_admin/images/delete_icon.png', array('alt' => __('delete'), 'title' => __('delete'))), 'informes/delete?id='.$informe->getId(), array (
+ 'post' => true,
+ 'confirm' => __('Are you sure?'),
+)) ?></li>
+ <li><?php echo link_to(image_tag('/images/small/report_go.png', array('alt' => __('ir al reporte'), 'title' => __('ir al reporte'))), 'informes/mostrar?id='.$informe->getId()) ?></li>
+</ul>
+</td>
Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_list_td_actions.php
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_list_td_tabular.php
===================================================================
--- 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='.$informe->getId()) ?></td>
+ <td><?php echo $informe->getDescripcion() ?></td>
+ <td>
+<?php if($informe->getAdjunto()) { ?>
+<a href="<?php echo sfContext::getInstance()->getRequest()->getRelativeUrlRoot()."/".sfConfig::get('sf_upload_dir_name').'/'. $informe->getAdjunto()->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') : ' ' ?></td>
+ <td><?php echo $informe->getVariables() ?></td>
+
+
\ No newline at end of file
Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_list_td_tabular.php
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_list_th_tabular.php
===================================================================
--- 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="sf_admin_list_th_nombre">
+ <?php if ($sf_user->getAttribute('sort', null, 'sf_admin/informes/sort') == 'nombre'): ?>
+ <?php echo link_to(__('Nombre'), 'informes/list?sort=nombre&type='.($sf_user->getAttribute('type', 'asc', 'sf_admin/informes/sort') == 'asc' ? 'desc' : 'asc')) ?>
+ (<?php echo __($sf_user->getAttribute('type', 'asc', 'sf_admin/informes/sort')) ?>)
+ <?php else: ?>
+ <?php echo link_to(__('Nombre'), 'informes/list?sort=nombre&type=asc') ?>
+ <?php endif; ?>
+ </th>
+
+ <th id="sf_admin_list_th_descripcion">
+ <?php if ($sf_user->getAttribute('sort', null, 'sf_admin/informes/sort') == 'descripcion'): ?>
+ <?php echo link_to(__('Descripción'), 'informes/list?sort=descripcion&type='.($sf_user->getAttribute('type', 'asc', 'sf_admin/informes/sort') == 'asc' ? 'desc' : 'asc')) ?>
+ (<?php echo __($sf_user->getAttribute('type', 'asc', 'sf_admin/informes/sort')) ?>)
+ <?php else: ?>
+ <?php echo link_to(__('Descripción'), 'informes/list?sort=descripcion&type=asc') ?>
+ <?php endif; ?>
+ </th>
+
+
+ <th id="sf_admin_list_th_fk_adjunto_id">
+ <?php echo __('Plantilla'); ?>
+ </th>
+
+
+ <th id="sf_admin_list_th_tipoinforme">
+ <?php if ($sf_user->getAttribute('sort', null, 'sf_admin/informes/sort') == 'fk_tipoinforme_id'): ?>
+ <?php echo link_to(__('Tipo de Informe'), 'informes/list?sort=tipoinforme&type='.($sf_user->getAttribute('type', 'asc', 'sf_admin/informes/sort') == 'asc' ? 'desc' : 'asc')) ?>
+ (<?php echo __($sf_user->getAttribute('type', 'asc', 'sf_admin/informes/sort')) ?>)
+ <?php else: ?>
+ <?php echo link_to(__('Tipo de Informe'), 'informes/list?sort=tipoinforme&type=asc') ?>
+ <?php endif; ?>
+ </th>
+
+
+ <th id="sf_admin_list_th_listado">
+ <?php if ($sf_user->getAttribute('sort', null, 'sf_admin/informes/sort') == 'listado'): ?>
+ <?php echo link_to(__('¿Está listado?'), 'informes/list?sort=listado&type='.($sf_user->getAttribute('type', 'asc', 'sf_admin/informes/sort') == 'asc' ? 'desc' : 'asc')) ?>
+ (<?php echo __($sf_user->getAttribute('type', 'asc', 'sf_admin/informes/sort')) ?>)
+ <?php else: ?>
+ <?php echo link_to(__('¿Es un listado?'), 'informes/list?sort=listado&type=asc') ?>
+ <?php endif; ?>
+ </th>
+
+
+ <th id="sf_admin_list_th_variable">
+ <?php echo __('Variables')?>
+ </th>
Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/_list_th_tabular.php
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/busquedaAlumnosSuccess.php
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/busquedaAlumnosSuccess.php 2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/busquedaAlumnosSuccess.php 2007-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,60 @@
+<?php use_helper('I18N'); ?>
+<div id="sf_admin_container">
+<h1>Informe: <?php echo $titulo ?></h1>
+<?php echo form_tag('informes/busquedaAlumnos', 'id=sf_admin_edit_form name=sf_admin_edit_form multipart=true') ?>
+
+<fieldset id="sf_fieldset_none" class="">
+ <div class="form-row">
+ <?php echo label_for('Buscar', __('Buscar Alumnos:')) ?>
+ <?php echo input_tag('txt', $txt) ?>
+ </div>
+
+ <div class="form-row">
+ <?php echo label_for('division', __('Division:')) ?>
+ <?php echo select_tag('division_id', options_for_select($optionsDivision, $division_id)) ?>
+ </div>
+</fieldset>
+ <ul class="sf_admin_actions">
+ <li><?php echo submit_tag(__('Buscar'), array (
+ 'name' => 'Mostrar',
+ 'class' => 'sf_admin_action_save',
+)) ?></li>
+</ul>
+</form>
+<?php if (count($aAlumno) > 0) {
+ if ($txt) { ?>
+ Usted buscó -<?php echo $txt?>-
+ <?php } ?>
+<h1>Alumnos</h1>
+<table cellspacing="0" class="sf_admin_list">
+ <thead>
+ <tr>
+ <th id="sf_admin_list_th_alumno"> Alumno</th>
+ <th id="sf_admin_list_th_sf_actions">Ver Informe</th>
+ </tr>
+ </thead>
+
+ <tbody>
+<?php
+ $i = 0;
+ foreach($aAlumno as $alumno){
+?>
+ <tr class="sf_admin_row_0">
+ <td><?php echo $alumno->alumno_apellido." ".$alumno->alumno_nombre; ?> ( <?php echo $alumno->anio_descripcion?> - <?php echo $alumno->division_nombre?> ) </td>
+ <td>
+ <ul class="sf_admin_td_actions">
+ <li><?php echo link_to(image_tag('/images/small/report_go.png', array('alt' => 'editar', 'title' => 'Editar')) , 'informes?action=mostrar&alumno_id='.$alumno->alumno_id); ?></li>
+ </ul>
+ </td>
+ </tr>
+ <?php } ?>
+ </tbody>
+</table>
+
+<?php } else {
+ if ($txt) { ?>
+ Su búsqueda por -<?php echo $txt?>- no ha encontrado alumnos.
+ <?php }
+}
+?>
+</div>
\ No newline at end of file
Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/busquedaAlumnosSuccess.php
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/editSuccess.php
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/editSuccess.php 2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/editSuccess.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="sf_admin_container">
+
+<h1><?php echo __('Editar informe',
+array()) ?></h1>
+
+
+<div id="sf_admin_content">
+<?php include_partial('informes/edit_messages', array('informe' => $informe, 'labels' => $labels)) ?>
+<?php include_partial('informes/edit_form', array('informe' => $informe, 'labels' => $labels)) ?>
+</div>
+
+
+</div>
Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/editSuccess.php
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/listSuccess.php
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/listSuccess.php 2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/listSuccess.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="sf_admin_container">
+
+<h1><?php echo __('Listado de Informes',
+array()) ?></h1>
+
+<div id="sf_admin_header">
+<?php include_partial('informes/list_messages', array('pager' => $pager)) ?>
+</div>
+
+<div id="sf_admin_content">
+<?php if (!$pager->getNbResults()): ?>
+<?php echo __('no result') ?>
+<?php else: ?>
+<?php include_partial('informes/list', array('pager' => $pager)) ?>
+<?php endif; ?>
+<?php include_partial('list_actions') ?>
+</div>
+
+</div>
Property changes on: prosistem/alba/trunk/alba/apps/principal/modules/informes/templates/listSuccess.php
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
Added: prosistem/alba/trunk/alba/apps/principal/modules/informes/validate/edit.yml
===================================================================
--- prosistem/alba/trunk/alba/apps/principal/modules/informes/validate/edit.yml 2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/apps/principal/modules/informes/validate/edit.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úmerico
+ min: 0
+ min_error: El número debe ser positivo
+
+archivoValidar:
+ class: sfFileValidator
+ param:
+ max_size: 512000
+ max_size_error: Máximo tamaño del archivo adjunto 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/informes/validate/edit.yml
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
Modified: prosistem/alba/trunk/alba/config/schema.yml
===================================================================
--- 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:
+ _attributes:
+ idMethod: native
+ id:
+ type: INTEGER
+ required: true
+ autoIncrement: true
+ primaryKey: true
+ nombre:
+ type: VARCHAR
+ size: 128
+ required: true
+ descripcion:
+ type: VARCHAR
+ size: 255
+ fk_adjunto_id:
+ type: integer
+ size: 11
+ required: true
+ foreignTable: adjunto
+ foreignReference: id
+ fk_tipoinforme_id:
+ type: integer
+ size: 11
+ required: true
+ foreignTable: tipoinforme
+ foreignReference: id
+ listado:
+ type: BOOLEAN
+ required: true
+ default: false
+ variables:
+ type: VARCHAR
+ size: 128
+ tipoinforme:
+ _attributes:
+ idMethod: native
+ id:
+ type: INTEGER
+ required: true
+ autoIncrement: true
+ primaryKey: true
+ nombre:
+ type: VARCHAR
+ size: 128
+ required: true
+ descripcion:
+ type: VARCHAR
+ size: 255
+ required: false
\ No newline at end of file
Modified: prosistem/alba/trunk/alba/data/sql/datos_desde_cero.sql
===================================================================
--- 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) VALUES (55, 1, 61);
INSERT INTO rel_usuario_permiso (id, fk_usuario_id, fk_permiso_id) VALUES (56, 1, 62);
+--
+-- Volcar la base de datos para la tabla `tipoinforme`
+--
+
+INSERT INTO `tipoinforme` (`id` ,`nombre` ,`descripcion`) VALUES (1 , 'Alumnos', 'Informes relacionados a los alumnos');
+
SET FOREIGN_KEY_CHECKS = 1;
-
Modified: prosistem/alba/trunk/alba/data/sql/datos_ejemplo.sql
===================================================================
--- 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);
+--
+-- Volcar la base de datos para la tabla `tipoinforme`
+--
+INSERT INTO `tipoinforme` (`id` ,`nombre` ,`descripcion`) VALUES (1 , 'Alumnos', 'Informes relacionados a los alumnos');
+
SET FOREIGN_KEY_CHECKS = 1;
Modified: prosistem/alba/trunk/alba/data/sql/lib.model.schema.sql
===================================================================
--- 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=InnoDB;
+#-----------------------------------------------------------------------------
+#-- 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=InnoDB;
+
+#-----------------------------------------------------------------------------
+#-- 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=InnoDB;
+
# This restores the fkey checks, after having unset them earlier
SET FOREIGN_KEY_CHECKS = 1;
Added: prosistem/alba/trunk/alba/lib/model/Informe.php
===================================================================
--- prosistem/alba/trunk/alba/lib/model/Informe.php 2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/lib/model/Informe.php 2007-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,12 @@
+<?php
+
+/**
+ * Subclass for representing a row from the 'informe' table.
+ *
+ *
+ *
+ * @package lib.model
+ */
+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
===================================================================
--- 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.
+ *
+ *
+ *
+ * @package lib.model
+ */
+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
===================================================================
--- 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.
+ *
+ *
+ *
+ * @package lib.model
+ */
+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
===================================================================
--- 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 'tipoinforme' table.
+ *
+ *
+ *
+ * @package lib.model
+ */
+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
===================================================================
--- 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 {
+
+
+ const CLASS_NAME = 'lib.model.map.InformeMapBuilder';
+
+
+ private $dbMap;
+
+
+ public function isBuilt()
+ {
+ return ($this->dbMap !== null);
+ }
+
+
+ public function getDatabaseMap()
+ {
+ return $this->dbMap;
+ }
+
+
+ public function doBuild()
+ {
+ $this->dbMap = Propel::getDatabaseMap('alba');
+
+ $tMap = $this->dbMap->addTable('informe');
+ $tMap->setPhpName('Informe');
+
+ $tMap->setUseIdGenerator(true);
+
+ $tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
+
+ $tMap->addColumn('NOMBRE', 'Nombre', 'string', CreoleTypes::VARCHAR, true, 128);
+
+ $tMap->addColumn('DESCRIPCION', 'Descripcion', 'string', CreoleTypes::VARCHAR, false, 255);
+
+ $tMap->addForeignKey('FK_ADJUNTO_ID', 'FkAdjuntoId', 'int', CreoleTypes::INTEGER, 'adjunto', 'ID', true, 11);
+
+ $tMap->addForeignKey('FK_TIPOINFORME_ID', 'FkTipoinformeId', 'int', CreoleTypes::INTEGER, 'tipoinforme', 'ID', true, 11);
+
+ $tMap->addColumn('LISTADO', 'Listado', 'boolean', CreoleTypes::BOOLEAN, true, null);
+
+ $tMap->addColumn('VARIABLES', 'Variables', 'string', CreoleTypes::VARCHAR, false, 128);
+
+ }
+}
\ No newline at end of file
Property changes on: prosistem/alba/trunk/alba/lib/model/map/InformeMapBuilder.php
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
Added: prosistem/alba/trunk/alba/lib/model/map/TipoinformeMapBuilder.php
===================================================================
--- prosistem/alba/trunk/alba/lib/model/map/TipoinformeMapBuilder.php 2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/lib/model/map/TipoinformeMapBuilder.php 2007-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,42 @@
+<?php
+
+
+
+class TipoinformeMapBuilder {
+
+
+ const CLASS_NAME = 'lib.model.map.TipoinformeMapBuilder';
+
+
+ private $dbMap;
+
+
+ public function isBuilt()
+ {
+ return ($this->dbMap !== null);
+ }
+
+
+ public function getDatabaseMap()
+ {
+ return $this->dbMap;
+ }
+
+
+ public function doBuild()
+ {
+ $this->dbMap = Propel::getDatabaseMap('alba');
+
+ $tMap = $this->dbMap->addTable('tipoinforme');
+ $tMap->setPhpName('Tipoinforme');
+
+ $tMap->setUseIdGenerator(true);
+
+ $tMap->addPrimaryKey('ID', 'Id', 'int', CreoleTypes::INTEGER, true, null);
+
+ $tMap->addColumn('NOMBRE', 'Nombre', 'string', CreoleTypes::VARCHAR, true, 128);
+
+ $tMap->addColumn('DESCRIPCION', 'Descripcion', 'string', CreoleTypes::VARCHAR, false, 255);
+
+ }
+}
\ No newline at end of file
Property changes on: prosistem/alba/trunk/alba/lib/model/map/TipoinformeMapBuilder.php
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
Modified: prosistem/alba/trunk/alba/lib/model/om/BaseAdjunto.php
===================================================================
--- 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 = null;
+ protected $collInformes;
+
+
+ protected $lastInformeCriteria = null;
+
+
protected $alreadyInSave = false;
@@ -311,6 +317,14 @@
}
}
+ if ($this->collInformes !== null) {
+ foreach($this->collInformes as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
$this->alreadyInSave = false;
}
return $affectedRows;
@@ -360,7 +374,15 @@
}
}
+ if ($this->collInformes !== null) {
+ foreach($this->collInformes as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
$this->alreadyInValidation = false;
}
@@ -530,6 +552,10 @@
$copyObj->addLegajoadjunto($relObj->copy($deepCopy));
}
+ foreach($this->getInformes() as $relObj) {
+ $copyObj->addInforme($relObj->copy($deepCopy));
+ }
+
}
$copyObj->setNew(true);
@@ -660,4 +686,109 @@
return $this->collLegajoadjuntos;
}
+
+ public function initInformes()
+ {
+ if ($this->collInformes === null) {
+ $this->collInformes = array();
+ }
+ }
+
+
+ public function getInformes($criteria = null, $con = null)
+ {
+ include_once 'lib/model/om/BaseInformePeer.php';
+ if ($criteria === null) {
+ $criteria = new Criteria();
+ }
+ elseif ($criteria instanceof Criteria)
+ {
+ $criteria = clone $criteria;
+ }
+
+ if ($this->collInformes === null) {
+ if ($this->isNew()) {
+ $this->collInformes = array();
+ } else {
+
+ $criteria->add(InformePeer::FK_ADJUNTO_ID, $this->getId());
+
+ InformePeer::addSelectColumns($criteria);
+ $this->collInformes = InformePeer::doSelect($criteria, $con);
+ }
+ } else {
+ if (!$this->isNew()) {
+
+
+ $criteria->add(InformePeer::FK_ADJUNTO_ID, $this->getId());
+
+ InformePeer::addSelectColumns($criteria);
+ if (!isset($this->lastInformeCriteria) || !$this->lastInformeCriteria->equals($criteria)) {
+ $this->collInformes = InformePeer::doSelect($criteria, $con);
+ }
+ }
+ }
+ $this->lastInformeCriteria = $criteria;
+ return $this->collInformes;
+ }
+
+
+ public function countInformes($criteria = null, $distinct = false, $con = null)
+ {
+ include_once 'lib/model/om/BaseInformePeer.php';
+ if ($criteria === null) {
+ $criteria = new Criteria();
+ }
+ elseif ($criteria instanceof Criteria)
+ {
+ $criteria = clone $criteria;
+ }
+
+ $criteria->add(InformePeer::FK_ADJUNTO_ID, $this->getId());
+
+ return InformePeer::doCount($criteria, $distinct, $con);
+ }
+
+
+ public function addInforme(Informe $l)
+ {
+ $this->collInformes[] = $l;
+ $l->setAdjunto($this);
+ }
+
+
+
+ public function getInformesJoinTipoinforme($criteria = null, $con = null)
+ {
+ include_once 'lib/model/om/BaseInformePeer.php';
+ if ($criteria === null) {
+ $criteria = new Criteria();
+ }
+ elseif ($criteria instanceof Criteria)
+ {
+ $criteria = clone $criteria;
+ }
+
+ if ($this->collInformes === null) {
+ if ($this->isNew()) {
+ $this->collInformes = array();
+ } else {
+
+ $criteria->add(InformePeer::FK_ADJUNTO_ID, $this->getId());
+
+ $this->collInformes = InformePeer::doSelectJoinTipoinforme($criteria, $con);
+ }
+ } else {
+
+ $criteria->add(InformePeer::FK_ADJUNTO_ID, $this->getId());
+
+ if (!isset($this->lastInformeCriteria) || !$this->lastInformeCriteria->equals($criteria)) {
+ $this->collInformes = InformePeer::doSelectJoinTipoinforme($criteria, $con);
+ }
+ }
+ $this->lastInformeCriteria = $criteria;
+
+ return $this->collInformes;
+ }
+
}
\ No newline at end of file
Added: prosistem/alba/trunk/alba/lib/model/om/BaseInforme.php
===================================================================
--- 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 {
+
+
+
+ protected static $peer;
+
+
+
+ protected $id;
+
+
+
+ protected $nombre;
+
+
+
+ protected $descripcion;
+
+
+
+ protected $fk_adjunto_id;
+
+
+
+ protected $fk_tipoinforme_id;
+
+
+
+ protected $listado = false;
+
+
+
+ protected $variables;
+
+
+ protected $aAdjunto;
+
+
+ protected $aTipoinforme;
+
+
+ protected $alreadyInSave = false;
+
+
+ protected $alreadyInValidation = false;
+
+
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+
+ public function getNombre()
+ {
+
+ return $this->nombre;
+ }
+
+
+ public function getDescripcion()
+ {
+
+ return $this->descripcion;
+ }
+
+
+ public function getFkAdjuntoId()
+ {
+
+ return $this->fk_adjunto_id;
+ }
+
+
+ public function getFkTipoinformeId()
+ {
+
+ return $this->fk_tipoinforme_id;
+ }
+
+
+ public function getListado()
+ {
+
+ return $this->listado;
+ }
+
+
+ public function getVariables()
+ {
+
+ return $this->variables;
+ }
+
+
+ public function setId($v)
+ {
+
+ if ($v !== null && !is_int($v) && is_numeric($v)) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = InformePeer::ID;
+ }
+
+ }
+
+ public function setNombre($v)
+ {
+
+ if ($v !== null && !is_string($v)) {
+ $v = (string) $v;
+ }
+
+ if ($this->nombre !== $v) {
+ $this->nombre = $v;
+ $this->modifiedColumns[] = InformePeer::NOMBRE;
+ }
+
+ }
+
+ public function setDescripcion($v)
+ {
+
+ if ($v !== null && !is_string($v)) {
+ $v = (string) $v;
+ }
+
+ if ($this->descripcion !== $v) {
+ $this->descripcion = $v;
+ $this->modifiedColumns[] = InformePeer::DESCRIPCION;
+ }
+
+ }
+
+ public function setFkAdjuntoId($v)
+ {
+
+ if ($v !== null && !is_int($v) && is_numeric($v)) {
+ $v = (int) $v;
+ }
+
+ if ($this->fk_adjunto_id !== $v) {
+ $this->fk_adjunto_id = $v;
+ $this->modifiedColumns[] = InformePeer::FK_ADJUNTO_ID;
+ }
+
+ if ($this->aAdjunto !== null && $this->aAdjunto->getId() !== $v) {
+ $this->aAdjunto = null;
+ }
+
+ }
+
+ public function setFkTipoinformeId($v)
+ {
+
+ if ($v !== null && !is_int($v) && is_numeric($v)) {
+ $v = (int) $v;
+ }
+
+ if ($this->fk_tipoinforme_id !== $v) {
+ $this->fk_tipoinforme_id = $v;
+ $this->modifiedColumns[] = InformePeer::FK_TIPOINFORME_ID;
+ }
+
+ if ($this->aTipoinforme !== null && $this->aTipoinforme->getId() !== $v) {
+ $this->aTipoinforme = null;
+ }
+
+ }
+
+ public function setListado($v)
+ {
+
+ if ($this->listado !== $v || $v === false) {
+ $this->listado = $v;
+ $this->modifiedColumns[] = InformePeer::LISTADO;
+ }
+
+ }
+
+ public function setVariables($v)
+ {
+
+ if ($v !== null && !is_string($v)) {
+ $v = (string) $v;
+ }
+
+ if ($this->variables !== $v) {
+ $this->variables = $v;
+ $this->modifiedColumns[] = InformePeer::VARIABLES;
+ }
+
+ }
+
+ public function hydrate(ResultSet $rs, $startcol = 1)
+ {
+ try {
+
+ $this->id = $rs->getInt($startcol + 0);
+
+ $this->nombre = $rs->getString($startcol + 1);
+
+ $this->descripcion = $rs->getString($startcol + 2);
+
+ $this->fk_adjunto_id = $rs->getInt($startcol + 3);
+
+ $this->fk_tipoinforme_id = $rs->getInt($startcol + 4);
+
+ $this->listado = $rs->getBoolean($startcol + 5);
+
+ $this->variables = $rs->getString($startcol + 6);
+
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ return $startcol + 7;
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Informe object", $e);
+ }
+ }
+
+
+ public function delete($con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(InformePeer::DATABASE_NAME);
+ }
+
+ try {
+ $con->begin();
+ InformePeer::doDelete($this, $con);
+ $this->setDeleted(true);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollback();
+ throw $e;
+ }
+ }
+
+
+ public function save($con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(InformePeer::DATABASE_NAME);
+ }
+
+ try {
+ $con->begin();
+ $affectedRows = $this->doSave($con);
+ $con->commit();
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollback();
+ throw $e;
+ }
+ }
+
+
+ protected function doSave($con)
+ {
+ $affectedRows = 0; if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+
+
+ if ($this->aAdjunto !== null) {
+ if ($this->aAdjunto->isModified()) {
+ $affectedRows += $this->aAdjunto->save($con);
+ }
+ $this->setAdjunto($this->aAdjunto);
+ }
+
+ if ($this->aTipoinforme !== null) {
+ if ($this->aTipoinforme->isModified()) {
+ $affectedRows += $this->aTipoinforme->save($con);
+ }
+ $this->setTipoinforme($this->aTipoinforme);
+ }
+
+
+ if ($this->isModified()) {
+ if ($this->isNew()) {
+ $pk = InformePeer::doInsert($this, $con);
+ $affectedRows += 1;
+ $this->setId($pk);
+ $this->setNew(false);
+ } else {
+ $affectedRows += InformePeer::doUpdate($this, $con);
+ }
+ $this->resetModified(); }
+
+ $this->alreadyInSave = false;
+ }
+ return $affectedRows;
+ }
+
+ protected $validationFailures = array();
+
+
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+ return true;
+ } else {
+ $this->validationFailures = $res;
+ return false;
+ }
+ }
+
+
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+
+ if ($this->aAdjunto !== null) {
+ if (!$this->aAdjunto->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aAdjunto->getValidationFailures());
+ }
+ }
+
+ if ($this->aTipoinforme !== null) {
+ if (!$this->aTipoinforme->validate($columns)) {
+ $failureMap = array_merge($failureMap, $this->aTipoinforme->getValidationFailures());
+ }
+ }
+
+
+ if (($retval = InformePeer::doValidate($this, $columns)) !== true) {
+ $failureMap = array_merge($failureMap, $retval);
+ }
+
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = InformePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ return $this->getByPosition($pos);
+ }
+
+
+ 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;
+ } }
+
+
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = InformePeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getNombre(),
+ $keys[2] => $this->getDescripcion(),
+ $keys[3] => $this->getFkAdjuntoId(),
+ $keys[4] => $this->getFkTipoinformeId(),
+ $keys[5] => $this->getListado(),
+ $keys[6] => $this->getVariables(),
+ );
+ return $result;
+ }
+
+
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = InformePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ return $this->setByPosition($pos, $value);
+ }
+
+
+ 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;
+ } }
+
+
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = 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]]);
+ }
+
+
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(InformePeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(InformePeer::ID)) $criteria->add(InformePeer::ID, $this->id);
+ if ($this->isColumnModified(InformePeer::NOMBRE)) $criteria->add(InformePeer::NOMBRE, $this->nombre);
+ if ($this->isColumnModified(InformePeer::DESCRIPCION)) $criteria->add(InformePeer::DESCRIPCION, $this->descripcion);
+ if ($this->isColumnModified(InformePeer::FK_ADJUNTO_ID)) $criteria->add(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(InformePeer::LISTADO, $this->listado);
+ if ($this->isColumnModified(InformePeer::VARIABLES)) $criteria->add(InformePeer::VARIABLES, $this->variables);
+
+ return $criteria;
+ }
+
+
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(InformePeer::DATABASE_NAME);
+
+ $criteria->add(InformePeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+
+ public function copyInto($copyObj, $deepCopy = 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);
+ }
+
+
+ public function copy($deepCopy = false)
+ {
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+ return $copyObj;
+ }
+
+
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new InformePeer();
+ }
+ return self::$peer;
+ }
+
+
+ public function setAdjunto($v)
+ {
+
+
+ if ($v === null) {
+ $this->setFkAdjuntoId(NULL);
+ } else {
+ $this->setFkAdjuntoId($v->getId());
+ }
+
+
+ $this->aAdjunto = $v;
+ }
+
+
+
+ public function getAdjunto($con = null)
+ {
+ include_once 'lib/model/om/BaseAdjuntoPeer.php';
+
+ if ($this->aAdjunto === null && ($this->fk_adjunto_id !== null)) {
+
+ $this->aAdjunto = AdjuntoPeer::retrieveByPK($this->fk_adjunto_id, $con);
+
+
+ }
+ return $this->aAdjunto;
+ }
+
+
+ public function setTipoinforme($v)
+ {
+
+
+ if ($v === null) {
+ $this->setFkTipoinformeId(NULL);
+ } else {
+ $this->setFkTipoinformeId($v->getId());
+ }
+
+
+ $this->aTipoinforme = $v;
+ }
+
+
+
+ public function getTipoinforme($con = null)
+ {
+ include_once 'lib/model/om/BaseTipoinformePeer.php';
+
+ if ($this->aTipoinforme === null && ($this->fk_tipoinforme_id !== null)) {
+
+ $this->aTipoinforme = TipoinformePeer::retrieveByPK($this->fk_tipoinforme_id, $con);
+
+
+ }
+ return $this->aTipoinforme;
+ }
+
+}
\ No newline at end of file
Property changes on: prosistem/alba/trunk/alba/lib/model/om/BaseInforme.php
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
Added: prosistem/alba/trunk/alba/lib/model/om/BaseInformePeer.php
===================================================================
--- 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 {
+
+
+ const DATABASE_NAME = 'alba';
+
+
+ const TABLE_NAME = 'informe';
+
+
+ const CLASS_DEFAULT = 'lib.model.Informe';
+
+
+ const NUM_COLUMNS = 7;
+
+
+ const NUM_LAZY_LOAD_COLUMNS = 0;
+
+
+
+ const ID = 'informe.ID';
+
+
+ const NOMBRE = 'informe.NOMBRE';
+
+
+ const DESCRIPCION = 'informe.DESCRIPCION';
+
+
+ const FK_ADJUNTO_ID = 'informe.FK_ADJUNTO_ID';
+
+
+ const FK_TIPOINFORME_ID = 'informe.FK_TIPOINFORME_ID';
+
+
+ const LISTADO = 'informe.LISTADO';
+
+
+ const VARIABLES = 'informe.VARIABLES';
+
+
+ private static $phpNameMap = null;
+
+
+
+ private static $fieldNames = array (
+ BasePeer::TYPE_PHPNAME => array ('Id', 'Nombre', 'Descripcion', 'FkAdjuntoId', 'FkTipoinformeId', 'Listado', 'Variables', ),
+ BasePeer::TYPE_COLNAME => array (InformePeer::ID, InformePeer::NOMBRE, InformePeer::DESCRIPCION, InformePeer::FK_ADJUNTO_ID, InformePeer::FK_TIPOINFORME_ID, InformePeer::LISTADO, InformePeer::VARIABLES, ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'nombre', 'descripcion', 'fk_adjunto_id', 'fk_tipoinforme_id', 'listado', 'variables', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+
+ private static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Nombre' => 1, 'Descripcion' => 2, 'FkAdjuntoId' => 3, 'FkTipoinformeId' => 4, 'Listado' => 5, 'Variables' => 6, ),
+ BasePeer::TYPE_COLNAME => array (InformePeer::ID => 0, InformePeer::NOMBRE => 1, InformePeer::DESCRIPCION => 2, InformePeer::FK_ADJUNTO_ID => 3, InformePeer::FK_TIPOINFORME_ID => 4, InformePeer::LISTADO => 5, InformePeer::VARIABLES => 6, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'nombre' => 1, 'descripcion' => 2, 'fk_adjunto_id' => 3, 'fk_tipoinforme_id' => 4, 'listado' => 5, 'variables' => 6, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, 6, )
+ );
+
+
+ public static function getMapBuilder()
+ {
+ include_once 'lib/model/map/InformeMapBuilder.php';
+ return BasePeer::getMapBuilder('lib.model.map.InformeMapBuilder');
+ }
+
+ public static function getPhpNameMap()
+ {
+ if (self::$phpNameMap === null) {
+ $map = InformePeer::getTableMap();
+ $columns = $map->getColumns();
+ $nameMap = array();
+ foreach ($columns as $column) {
+ $nameMap[$column->getPhpName()] = $column->getColumnName();
+ }
+ self::$phpNameMap = $nameMap;
+ }
+ return self::$phpNameMap;
+ }
+
+ static public function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = self::getFieldNames($toType);
+ $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
+ }
+ return $toNames[$key];
+ }
+
+
+
+ static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, self::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
+ }
+ return self::$fieldNames[$type];
+ }
+
+
+ public static function alias($alias, $column)
+ {
+ return str_replace(InformePeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+
+ 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 = 'COUNT(informe.ID)';
+ const COUNT_DISTINCT = 'COUNT(DISTINCT informe.ID)';
+
+
+ public static function doCount(Criteria $criteria, $distinct = false, $con = null)
+ {
+ $criteria = clone $criteria;
+
+ $criteria->clearSelectColumns()->clearOrderByColumns();
+ if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->addSelectColumn(InformePeer::COUNT_DISTINCT);
+ } else {
+ $criteria->addSelectColumn(InformePeer::COUNT);
+ }
+
+ foreach($criteria->getGroupByColumns() as $column)
+ {
+ $criteria->addSelectColumn($column);
+ }
+
+ $rs = InformePeer::doSelectRS($criteria, $con);
+ if ($rs->next()) {
+ return $rs->getInt(1);
+ } else {
+ return 0;
+ }
+ }
+
+ public static function doSelectOne(Criteria $criteria, $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = InformePeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+ return null;
+ }
+
+ public static function doSelect(Criteria $criteria, $con = null)
+ {
+ return InformePeer::populateObjects(InformePeer::doSelectRS($criteria, $con));
+ }
+
+ public static function doSelectRS(Criteria $criteria, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(self::DATABASE_NAME);
+ }
+
+ if (!$criteria->getSelectColumns()) {
+ $criteria = clone $criteria;
+ InformePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->setDbName(self::DATABASE_NAME);
+
+ return BasePeer::doSelect($criteria, $con);
+ }
+
+ public static function populateObjects(ResultSet $rs)
+ {
+ $results = array();
+
+ $cls = InformePeer::getOMClass();
+ $cls = Propel::import($cls);
+ while($rs->next()) {
+
+ $obj = new $cls();
+ $obj->hydrate($rs);
+ $results[] = $obj;
+
+ }
+ return $results;
+ }
+
+
+ public static function doCountJoinAdjunto(Criteria $criteria, $distinct = false, $con = null)
+ {
+ $criteria = clone $criteria;
+
+ $criteria->clearSelectColumns()->clearOrderByColumns();
+ if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $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 = InformePeer::doSelectRS($criteria, $con);
+ if ($rs->next()) {
+ return $rs->getInt(1);
+ } else {
+ return 0;
+ }
+ }
+
+
+
+ public static function doCountJoinTipoinforme(Criteria $criteria, $distinct = false, $con = null)
+ {
+ $criteria = clone $criteria;
+
+ $criteria->clearSelectColumns()->clearOrderByColumns();
+ if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $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 = InformePeer::doSelectRS($criteria, $con);
+ if ($rs->next()) {
+ return $rs->getInt(1);
+ } else {
+ return 0;
+ }
+ }
+
+
+
+ public static function doSelectJoinAdjunto(Criteria $c, $con = null)
+ {
+ $c = clone $c;
+
+ if ($c->getDbName() == Propel::getDefaultDB()) {
+ $c->setDbName(self::DATABASE_NAME);
+ }
+
+ InformePeer::addSelectColumns($c);
+ $startcol = (InformePeer::NUM_COLUMNS - InformePeer::NUM_LAZY_LOAD_COLUMNS) + 1;
+ AdjuntoPeer::addSelectColumns($c);
+
+ $c->addJoin(InformePeer::FK_ADJUNTO_ID, AdjuntoPeer::ID);
+ $rs = BasePeer::doSelect($c, $con);
+ $results = array();
+
+ while($rs->next()) {
+
+ $omClass = InformePeer::getOMClass();
+
+ $cls = Propel::import($omClass);
+ $obj1 = new $cls();
+ $obj1->hydrate($rs);
+
+ $omClass = AdjuntoPeer::getOMClass();
+
+ $cls = Propel::import($omClass);
+ $obj2 = new $cls();
+ $obj2->hydrate($rs, $startcol);
+
+ $newObject = true;
+ foreach($results as $temp_obj1) {
+ $temp_obj2 = $temp_obj1->getAdjunto(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
+ $newObject = false;
+ $temp_obj2->addInforme($obj1); break;
+ }
+ }
+ if ($newObject) {
+ $obj2->initInformes();
+ $obj2->addInforme($obj1); }
+ $results[] = $obj1;
+ }
+ return $results;
+ }
+
+
+
+ public static function doSelectJoinTipoinforme(Criteria $c, $con = null)
+ {
+ $c = clone $c;
+
+ if ($c->getDbName() == Propel::getDefaultDB()) {
+ $c->setDbName(self::DATABASE_NAME);
+ }
+
+ InformePeer::addSelectColumns($c);
+ $startcol = (InformePeer::NUM_COLUMNS - InformePeer::NUM_LAZY_LOAD_COLUMNS) + 1;
+ TipoinformePeer::addSelectColumns($c);
+
+ $c->addJoin(InformePeer::FK_TIPOINFORME_ID, TipoinformePeer::ID);
+ $rs = BasePeer::doSelect($c, $con);
+ $results = array();
+
+ while($rs->next()) {
+
+ $omClass = InformePeer::getOMClass();
+
+ $cls = Propel::import($omClass);
+ $obj1 = new $cls();
+ $obj1->hydrate($rs);
+
+ $omClass = TipoinformePeer::getOMClass();
+
+ $cls = Propel::import($omClass);
+ $obj2 = new $cls();
+ $obj2->hydrate($rs, $startcol);
+
+ $newObject = true;
+ foreach($results as $temp_obj1) {
+ $temp_obj2 = $temp_obj1->getTipoinforme(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
+ $newObject = false;
+ $temp_obj2->addInforme($obj1); break;
+ }
+ }
+ if ($newObject) {
+ $obj2->initInformes();
+ $obj2->addInforme($obj1); }
+ $results[] = $obj1;
+ }
+ return $results;
+ }
+
+
+
+ public static function doCountJoinAll(Criteria $criteria, $distinct = false, $con = null)
+ {
+ $criteria = clone $criteria;
+
+ $criteria->clearSelectColumns()->clearOrderByColumns();
+ if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $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 = InformePeer::doSelectRS($criteria, $con);
+ if ($rs->next()) {
+ return $rs->getInt(1);
+ } else {
+ return 0;
+ }
+ }
+
+
+
+ public static function doSelectJoinAll(Criteria $c, $con = null)
+ {
+ $c = clone $c;
+
+ if ($c->getDbName() == Propel::getDefaultDB()) {
+ $c->setDbName(self::DATABASE_NAME);
+ }
+
+ InformePeer::addSelectColumns($c);
+ $startcol2 = (InformePeer::NUM_COLUMNS - InformePeer::NUM_LAZY_LOAD_COLUMNS) + 1;
+
+ AdjuntoPeer::addSelectColumns($c);
+ $startcol3 = $startcol2 + AdjuntoPeer::NUM_COLUMNS;
+
+ TipoinformePeer::addSelectColumns($c);
+ $startcol4 = $startcol3 + TipoinformePeer::NUM_COLUMNS;
+
+ $c->addJoin(InformePeer::FK_ADJUNTO_ID, AdjuntoPeer::ID);
+
+ $c->addJoin(InformePeer::FK_TIPOINFORME_ID, TipoinformePeer::ID);
+
+ $rs = BasePeer::doSelect($c, $con);
+ $results = array();
+
+ while($rs->next()) {
+
+ $omClass = InformePeer::getOMClass();
+
+
+ $cls = Propel::import($omClass);
+ $obj1 = new $cls();
+ $obj1->hydrate($rs);
+
+
+
+ $omClass = AdjuntoPeer::getOMClass();
+
+
+ $cls = Propel::import($omClass);
+ $obj2 = new $cls();
+ $obj2->hydrate($rs, $startcol2);
+
+ $newObject = true;
+ for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
+ $temp_obj1 = $results[$j];
+ $temp_obj2 = $temp_obj1->getAdjunto(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
+ $newObject = false;
+ $temp_obj2->addInforme($obj1); break;
+ }
+ }
+
+ if ($newObject) {
+ $obj2->initInformes();
+ $obj2->addInforme($obj1);
+ }
+
+
+
+ $omClass = TipoinformePeer::getOMClass();
+
+
+ $cls = Propel::import($omClass);
+ $obj3 = new $cls();
+ $obj3->hydrate($rs, $startcol3);
+
+ $newObject = true;
+ for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
+ $temp_obj1 = $results[$j];
+ $temp_obj3 = $temp_obj1->getTipoinforme(); if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) {
+ $newObject = false;
+ $temp_obj3->addInforme($obj1); break;
+ }
+ }
+
+ if ($newObject) {
+ $obj3->initInformes();
+ $obj3->addInforme($obj1);
+ }
+
+ $results[] = $obj1;
+ }
+ return $results;
+ }
+
+
+
+ public static function doCountJoinAllExceptAdjunto(Criteria $criteria, $distinct = false, $con = null)
+ {
+ $criteria = clone $criteria;
+
+ $criteria->clearSelectColumns()->clearOrderByColumns();
+ if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $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 = InformePeer::doSelectRS($criteria, $con);
+ if ($rs->next()) {
+ return $rs->getInt(1);
+ } else {
+ return 0;
+ }
+ }
+
+
+
+ public static function doCountJoinAllExceptTipoinforme(Criteria $criteria, $distinct = false, $con = null)
+ {
+ $criteria = clone $criteria;
+
+ $criteria->clearSelectColumns()->clearOrderByColumns();
+ if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $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 = InformePeer::doSelectRS($criteria, $con);
+ if ($rs->next()) {
+ return $rs->getInt(1);
+ } else {
+ return 0;
+ }
+ }
+
+
+
+ public static function doSelectJoinAllExceptAdjunto(Criteria $c, $con = null)
+ {
+ $c = clone $c;
+
+ if ($c->getDbName() == Propel::getDefaultDB()) {
+ $c->setDbName(self::DATABASE_NAME);
+ }
+
+ InformePeer::addSelectColumns($c);
+ $startcol2 = (InformePeer::NUM_COLUMNS - InformePeer::NUM_LAZY_LOAD_COLUMNS) + 1;
+
+ TipoinformePeer::addSelectColumns($c);
+ $startcol3 = $startcol2 + TipoinformePeer::NUM_COLUMNS;
+
+ $c->addJoin(InformePeer::FK_TIPOINFORME_ID, TipoinformePeer::ID);
+
+
+ $rs = BasePeer::doSelect($c, $con);
+ $results = array();
+
+ while($rs->next()) {
+
+ $omClass = InformePeer::getOMClass();
+
+ $cls = Propel::import($omClass);
+ $obj1 = new $cls();
+ $obj1->hydrate($rs);
+
+ $omClass = TipoinformePeer::getOMClass();
+
+
+ $cls = Propel::import($omClass);
+ $obj2 = new $cls();
+ $obj2->hydrate($rs, $startcol2);
+
+ $newObject = true;
+ for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
+ $temp_obj1 = $results[$j];
+ $temp_obj2 = $temp_obj1->getTipoinforme(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
+ $newObject = false;
+ $temp_obj2->addInforme($obj1);
+ break;
+ }
+ }
+
+ if ($newObject) {
+ $obj2->initInformes();
+ $obj2->addInforme($obj1);
+ }
+
+ $results[] = $obj1;
+ }
+ return $results;
+ }
+
+
+
+ public static function doSelectJoinAllExceptTipoinforme(Criteria $c, $con = null)
+ {
+ $c = clone $c;
+
+ if ($c->getDbName() == Propel::getDefaultDB()) {
+ $c->setDbName(self::DATABASE_NAME);
+ }
+
+ InformePeer::addSelectColumns($c);
+ $startcol2 = (InformePeer::NUM_COLUMNS - InformePeer::NUM_LAZY_LOAD_COLUMNS) + 1;
+
+ AdjuntoPeer::addSelectColumns($c);
+ $startcol3 = $startcol2 + AdjuntoPeer::NUM_COLUMNS;
+
+ $c->addJoin(InformePeer::FK_ADJUNTO_ID, AdjuntoPeer::ID);
+
+
+ $rs = BasePeer::doSelect($c, $con);
+ $results = array();
+
+ while($rs->next()) {
+
+ $omClass = InformePeer::getOMClass();
+
+ $cls = Propel::import($omClass);
+ $obj1 = new $cls();
+ $obj1->hydrate($rs);
+
+ $omClass = AdjuntoPeer::getOMClass();
+
+
+ $cls = Propel::import($omClass);
+ $obj2 = new $cls();
+ $obj2->hydrate($rs, $startcol2);
+
+ $newObject = true;
+ for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
+ $temp_obj1 = $results[$j];
+ $temp_obj2 = $temp_obj1->getAdjunto(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
+ $newObject = false;
+ $temp_obj2->addInforme($obj1);
+ break;
+ }
+ }
+
+ if ($newObject) {
+ $obj2->initInformes();
+ $obj2->addInforme($obj1);
+ }
+
+ $results[] = $obj1;
+ }
+ return $results;
+ }
+
+
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
+ }
+
+
+ public static function getOMClass()
+ {
+ return InformePeer::CLASS_DEFAULT;
+ }
+
+
+ public static function doInsert($values, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(self::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; } else {
+ $criteria = $values->buildCriteria(); }
+
+ $criteria->remove(InformePeer::ID);
+
+ $criteria->setDbName(self::DATABASE_NAME);
+
+ try {
+ $con->begin();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch(PropelException $e) {
+ $con->rollback();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+
+ public static function doUpdate($values, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(self::DATABASE_NAME);
+ }
+
+ $selectCriteria = new Criteria(self::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values;
+ $comparison = $criteria->getComparison(InformePeer::ID);
+ $selectCriteria->add(InformePeer::ID, $criteria->remove(InformePeer::ID), $comparison);
+
+ } else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
+
+ $criteria->setDbName(self::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+
+ public static function doDeleteAll($con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(self::DATABASE_NAME);
+ }
+ $affectedRows = 0; try {
+ $con->begin();
+ $affectedRows += BasePeer::doDeleteAll(InformePeer::TABLE_NAME, $con);
+ $con->commit();
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollback();
+ throw $e;
+ }
+ }
+
+
+ public static function doDelete($values, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(InformePeer::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; } elseif ($values instanceof Informe) {
+
+ $criteria = $values->buildPkeyCriteria();
+ } else {
+ $criteria = new Criteria(self::DATABASE_NAME);
+ $criteria->add(InformePeer::ID, (array) $values, Criteria::IN);
+ }
+
+ $criteria->setDbName(self::DATABASE_NAME);
+
+ $affectedRows = 0;
+ try {
+ $con->begin();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ $con->commit();
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollback();
+ throw $e;
+ }
+ }
+
+
+ public static function doValidate(Informe $obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(InformePeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(InformePeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach($cols as $colName) {
+ if ($tableMap->containsColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ $res = BasePeer::doValidate(InformePeer::DATABASE_NAME, InformePeer::TABLE_NAME, $columns);
+ if ($res !== true) {
+ $request = sfContext::getInstance()->getRequest();
+ foreach ($res as $failed) {
+ $col = InformePeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
+ $request->setError($col, $failed->getMessage());
+ }
+ }
+
+ return $res;
+ }
+
+
+ public static function retrieveByPK($pk, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(self::DATABASE_NAME);
+ }
+
+ $criteria = new Criteria(InformePeer::DATABASE_NAME);
+
+ $criteria->add(InformePeer::ID, $pk);
+
+
+ $v = InformePeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+
+ public static function retrieveByPKs($pks, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(self::DATABASE_NAME);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria();
+ $criteria->add(InformePeer::ID, $pks, Criteria::IN);
+ $objs = InformePeer::doSelect($criteria, $con);
+ }
+ return $objs;
+ }
+
+}
+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/BaseInformePeer.php
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
Added: prosistem/alba/trunk/alba/lib/model/om/BaseTipoinforme.php
===================================================================
--- 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 {
+
+
+
+ protected static $peer;
+
+
+
+ protected $id;
+
+
+
+ protected $nombre;
+
+
+
+ protected $descripcion;
+
+
+ protected $collInformes;
+
+
+ protected $lastInformeCriteria = null;
+
+
+ protected $alreadyInSave = false;
+
+
+ protected $alreadyInValidation = false;
+
+
+ public function getId()
+ {
+
+ return $this->id;
+ }
+
+
+ public function getNombre()
+ {
+
+ return $this->nombre;
+ }
+
+
+ public function getDescripcion()
+ {
+
+ return $this->descripcion;
+ }
+
+
+ public function setId($v)
+ {
+
+ if ($v !== null && !is_int($v) && is_numeric($v)) {
+ $v = (int) $v;
+ }
+
+ if ($this->id !== $v) {
+ $this->id = $v;
+ $this->modifiedColumns[] = TipoinformePeer::ID;
+ }
+
+ }
+
+ public function setNombre($v)
+ {
+
+ if ($v !== null && !is_string($v)) {
+ $v = (string) $v;
+ }
+
+ if ($this->nombre !== $v) {
+ $this->nombre = $v;
+ $this->modifiedColumns[] = TipoinformePeer::NOMBRE;
+ }
+
+ }
+
+ public function setDescripcion($v)
+ {
+
+ if ($v !== null && !is_string($v)) {
+ $v = (string) $v;
+ }
+
+ if ($this->descripcion !== $v) {
+ $this->descripcion = $v;
+ $this->modifiedColumns[] = TipoinformePeer::DESCRIPCION;
+ }
+
+ }
+
+ public function hydrate(ResultSet $rs, $startcol = 1)
+ {
+ try {
+
+ $this->id = $rs->getInt($startcol + 0);
+
+ $this->nombre = $rs->getString($startcol + 1);
+
+ $this->descripcion = $rs->getString($startcol + 2);
+
+ $this->resetModified();
+
+ $this->setNew(false);
+
+ return $startcol + 3;
+ } catch (Exception $e) {
+ throw new PropelException("Error populating Tipoinforme object", $e);
+ }
+ }
+
+
+ public function delete($con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("This object has already been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TipoinformePeer::DATABASE_NAME);
+ }
+
+ try {
+ $con->begin();
+ TipoinformePeer::doDelete($this, $con);
+ $this->setDeleted(true);
+ $con->commit();
+ } catch (PropelException $e) {
+ $con->rollback();
+ throw $e;
+ }
+ }
+
+
+ public function save($con = null)
+ {
+ if ($this->isDeleted()) {
+ throw new PropelException("You cannot save an object that has been deleted.");
+ }
+
+ if ($con === null) {
+ $con = Propel::getConnection(TipoinformePeer::DATABASE_NAME);
+ }
+
+ try {
+ $con->begin();
+ $affectedRows = $this->doSave($con);
+ $con->commit();
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollback();
+ throw $e;
+ }
+ }
+
+
+ protected function doSave($con)
+ {
+ $affectedRows = 0; if (!$this->alreadyInSave) {
+ $this->alreadyInSave = true;
+
+
+ if ($this->isModified()) {
+ if ($this->isNew()) {
+ $pk = TipoinformePeer::doInsert($this, $con);
+ $affectedRows += 1;
+ $this->setId($pk);
+ $this->setNew(false);
+ } else {
+ $affectedRows += TipoinformePeer::doUpdate($this, $con);
+ }
+ $this->resetModified(); }
+
+ if ($this->collInformes !== null) {
+ foreach($this->collInformes as $referrerFK) {
+ if (!$referrerFK->isDeleted()) {
+ $affectedRows += $referrerFK->save($con);
+ }
+ }
+ }
+
+ $this->alreadyInSave = false;
+ }
+ return $affectedRows;
+ }
+
+ protected $validationFailures = array();
+
+
+ public function getValidationFailures()
+ {
+ return $this->validationFailures;
+ }
+
+
+ public function validate($columns = null)
+ {
+ $res = $this->doValidate($columns);
+ if ($res === true) {
+ $this->validationFailures = array();
+ return true;
+ } else {
+ $this->validationFailures = $res;
+ return false;
+ }
+ }
+
+
+ protected function doValidate($columns = null)
+ {
+ if (!$this->alreadyInValidation) {
+ $this->alreadyInValidation = true;
+ $retval = null;
+
+ $failureMap = array();
+
+
+ if (($retval = TipoinformePeer::doValidate($this, $columns)) !== true) {
+ $failureMap = array_merge($failureMap, $retval);
+ }
+
+
+ if ($this->collInformes !== null) {
+ foreach($this->collInformes as $referrerFK) {
+ if (!$referrerFK->validate($columns)) {
+ $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
+ }
+ }
+ }
+
+
+ $this->alreadyInValidation = false;
+ }
+
+ return (!empty($failureMap) ? $failureMap : true);
+ }
+
+
+ public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = TipoinformePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ return $this->getByPosition($pos);
+ }
+
+
+ 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;
+ } }
+
+
+ public function toArray($keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = TipoinformePeer::getFieldNames($keyType);
+ $result = array(
+ $keys[0] => $this->getId(),
+ $keys[1] => $this->getNombre(),
+ $keys[2] => $this->getDescripcion(),
+ );
+ return $result;
+ }
+
+
+ public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
+ {
+ $pos = TipoinformePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
+ return $this->setByPosition($pos, $value);
+ }
+
+
+ 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;
+ } }
+
+
+ public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
+ {
+ $keys = 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]]);
+ }
+
+
+ public function buildCriteria()
+ {
+ $criteria = new Criteria(TipoinformePeer::DATABASE_NAME);
+
+ if ($this->isColumnModified(TipoinformePeer::ID)) $criteria->add(TipoinformePeer::ID, $this->id);
+ if ($this->isColumnModified(TipoinformePeer::NOMBRE)) $criteria->add(TipoinformePeer::NOMBRE, $this->nombre);
+ if ($this->isColumnModified(TipoinformePeer::DESCRIPCION)) $criteria->add(TipoinformePeer::DESCRIPCION, $this->descripcion);
+
+ return $criteria;
+ }
+
+
+ public function buildPkeyCriteria()
+ {
+ $criteria = new Criteria(TipoinformePeer::DATABASE_NAME);
+
+ $criteria->add(TipoinformePeer::ID, $this->id);
+
+ return $criteria;
+ }
+
+
+ public function getPrimaryKey()
+ {
+ return $this->getId();
+ }
+
+
+ public function setPrimaryKey($key)
+ {
+ $this->setId($key);
+ }
+
+
+ public function copyInto($copyObj, $deepCopy = false)
+ {
+
+ $copyObj->setNombre($this->nombre);
+
+ $copyObj->setDescripcion($this->descripcion);
+
+
+ if ($deepCopy) {
+ $copyObj->setNew(false);
+
+ foreach($this->getInformes() as $relObj) {
+ $copyObj->addInforme($relObj->copy($deepCopy));
+ }
+
+ }
+
+ $copyObj->setNew(true);
+
+ $copyObj->setId(NULL);
+ }
+
+
+ public function copy($deepCopy = false)
+ {
+ $clazz = get_class($this);
+ $copyObj = new $clazz();
+ $this->copyInto($copyObj, $deepCopy);
+ return $copyObj;
+ }
+
+
+ public function getPeer()
+ {
+ if (self::$peer === null) {
+ self::$peer = new TipoinformePeer();
+ }
+ return self::$peer;
+ }
+
+
+ public function initInformes()
+ {
+ if ($this->collInformes === null) {
+ $this->collInformes = array();
+ }
+ }
+
+
+ public function getInformes($criteria = null, $con = null)
+ {
+ include_once 'lib/model/om/BaseInformePeer.php';
+ if ($criteria === null) {
+ $criteria = new Criteria();
+ }
+ elseif ($criteria instanceof Criteria)
+ {
+ $criteria = clone $criteria;
+ }
+
+ if ($this->collInformes === null) {
+ if ($this->isNew()) {
+ $this->collInformes = array();
+ } else {
+
+ $criteria->add(InformePeer::FK_TIPOINFORME_ID, $this->getId());
+
+ InformePeer::addSelectColumns($criteria);
+ $this->collInformes = InformePeer::doSelect($criteria, $con);
+ }
+ } else {
+ if (!$this->isNew()) {
+
+
+ $criteria->add(InformePeer::FK_TIPOINFORME_ID, $this->getId());
+
+ InformePeer::addSelectColumns($criteria);
+ if (!isset($this->lastInformeCriteria) || !$this->lastInformeCriteria->equals($criteria)) {
+ $this->collInformes = InformePeer::doSelect($criteria, $con);
+ }
+ }
+ }
+ $this->lastInformeCriteria = $criteria;
+ return $this->collInformes;
+ }
+
+
+ public function countInformes($criteria = null, $distinct = false, $con = null)
+ {
+ include_once 'lib/model/om/BaseInformePeer.php';
+ if ($criteria === null) {
+ $criteria = new Criteria();
+ }
+ elseif ($criteria instanceof Criteria)
+ {
+ $criteria = clone $criteria;
+ }
+
+ $criteria->add(InformePeer::FK_TIPOINFORME_ID, $this->getId());
+
+ return InformePeer::doCount($criteria, $distinct, $con);
+ }
+
+
+ public function addInforme(Informe $l)
+ {
+ $this->collInformes[] = $l;
+ $l->setTipoinforme($this);
+ }
+
+
+
+ public function getInformesJoinAdjunto($criteria = null, $con = null)
+ {
+ include_once 'lib/model/om/BaseInformePeer.php';
+ if ($criteria === null) {
+ $criteria = new Criteria();
+ }
+ elseif ($criteria instanceof Criteria)
+ {
+ $criteria = clone $criteria;
+ }
+
+ if ($this->collInformes === null) {
+ if ($this->isNew()) {
+ $this->collInformes = array();
+ } else {
+
+ $criteria->add(InformePeer::FK_TIPOINFORME_ID, $this->getId());
+
+ $this->collInformes = InformePeer::doSelectJoinAdjunto($criteria, $con);
+ }
+ } else {
+
+ $criteria->add(InformePeer::FK_TIPOINFORME_ID, $this->getId());
+
+ if (!isset($this->lastInformeCriteria) || !$this->lastInformeCriteria->equals($criteria)) {
+ $this->collInformes = InformePeer::doSelectJoinAdjunto($criteria, $con);
+ }
+ }
+ $this->lastInformeCriteria = $criteria;
+
+ return $this->collInformes;
+ }
+
+}
\ No newline at end of file
Property changes on: prosistem/alba/trunk/alba/lib/model/om/BaseTipoinforme.php
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
Added: prosistem/alba/trunk/alba/lib/model/om/BaseTipoinformePeer.php
===================================================================
--- prosistem/alba/trunk/alba/lib/model/om/BaseTipoinformePeer.php 2007-10-10 17:24:59 UTC (rev 5217)
+++ prosistem/alba/trunk/alba/lib/model/om/BaseTipoinformePeer.php 2007-10-10 20:53:17 UTC (rev 5218)
@@ -0,0 +1,373 @@
+<?php
+
+
+abstract class BaseTipoinformePeer {
+
+
+ const DATABASE_NAME = 'alba';
+
+
+ const TABLE_NAME = 'tipoinforme';
+
+
+ const CLASS_DEFAULT = 'lib.model.Tipoinforme';
+
+
+ const NUM_COLUMNS = 3;
+
+
+ const NUM_LAZY_LOAD_COLUMNS = 0;
+
+
+
+ const ID = 'tipoinforme.ID';
+
+
+ const NOMBRE = 'tipoinforme.NOMBRE';
+
+
+ const DESCRIPCION = 'tipoinforme.DESCRIPCION';
+
+
+ private static $phpNameMap = null;
+
+
+
+ private static $fieldNames = array (
+ BasePeer::TYPE_PHPNAME => array ('Id', 'Nombre', 'Descripcion', ),
+ BasePeer::TYPE_COLNAME => array (TipoinformePeer::ID, TipoinformePeer::NOMBRE, TipoinformePeer::DESCRIPCION, ),
+ BasePeer::TYPE_FIELDNAME => array ('id', 'nombre', 'descripcion', ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, )
+ );
+
+
+ private static $fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Nombre' => 1, 'Descripcion' => 2, ),
+ BasePeer::TYPE_COLNAME => array (TipoinformePeer::ID => 0, TipoinformePeer::NOMBRE => 1, TipoinformePeer::DESCRIPCION => 2, ),
+ BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'nombre' => 1, 'descripcion' => 2, ),
+ BasePeer::TYPE_NUM => array (0, 1, 2, )
+ );
+
+
+ public static function getMapBuilder()
+ {
+ include_once 'lib/model/map/TipoinformeMapBuilder.php';
+ return BasePeer::getMapBuilder('lib.model.map.TipoinformeMapBuilder');
+ }
+
+ public static function getPhpNameMap()
+ {
+ if (self::$phpNameMap === null) {
+ $map = TipoinformePeer::getTableMap();
+ $columns = $map->getColumns();
+ $nameMap = array();
+ foreach ($columns as $column) {
+ $nameMap[$column->getPhpName()] = $column->getColumnName();
+ }
+ self::$phpNameMap = $nameMap;
+ }
+ return self::$phpNameMap;
+ }
+
+ static public function translateFieldName($name, $fromType, $toType)
+ {
+ $toNames = self::getFieldNames($toType);
+ $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
+ if ($key === null) {
+ throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
+ }
+ return $toNames[$key];
+ }
+
+
+
+ static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists($type, self::$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
+ }
+ return self::$fieldNames[$type];
+ }
+
+
+ public static function alias($alias, $column)
+ {
+ return str_replace(TipoinformePeer::TABLE_NAME.'.', $alias.'.', $column);
+ }
+
+
+ public static function addSelectColumns(Criteria $criteria)
+ {
+
+ $criteria->addSelectColumn(TipoinformePeer::ID);
+
+ $criteria->addSelectColumn(TipoinformePeer::NOMBRE);
+
+ $criteria->addSelectColumn(TipoinformePeer::DESCRIPCION);
+
+ }
+
+ const COUNT = 'COUNT(tipoinforme.ID)';
+ const COUNT_DISTINCT = 'COUNT(DISTINCT tipoinforme.ID)';
+
+
+ public static function doCount(Criteria $criteria, $distinct = false, $con = null)
+ {
+ $criteria = clone $criteria;
+
+ $criteria->clearSelectColumns()->clearOrderByColumns();
+ if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
+ $criteria->addSelectColumn(TipoinformePeer::COUNT_DISTINCT);
+ } else {
+ $criteria->addSelectColumn(TipoinformePeer::COUNT);
+ }
+
+ foreach($criteria->getGroupByColumns() as $column)
+ {
+ $criteria->addSelectColumn($column);
+ }
+
+ $rs = TipoinformePeer::doSelectRS($criteria, $con);
+ if ($rs->next()) {
+ return $rs->getInt(1);
+ } else {
+ return 0;
+ }
+ }
+
+ public static function doSelectOne(Criteria $criteria, $con = null)
+ {
+ $critcopy = clone $criteria;
+ $critcopy->setLimit(1);
+ $objects = TipoinformePeer::doSelect($critcopy, $con);
+ if ($objects) {
+ return $objects[0];
+ }
+ return null;
+ }
+
+ public static function doSelect(Criteria $criteria, $con = null)
+ {
+ return TipoinformePeer::populateObjects(TipoinformePeer::doSelectRS($criteria, $con));
+ }
+
+ public static function doSelectRS(Criteria $criteria, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(self::DATABASE_NAME);
+ }
+
+ if (!$criteria->getSelectColumns()) {
+ $criteria = clone $criteria;
+ TipoinformePeer::addSelectColumns($criteria);
+ }
+
+ $criteria->setDbName(self::DATABASE_NAME);
+
+ return BasePeer::doSelect($criteria, $con);
+ }
+
+ public static function populateObjects(ResultSet $rs)
+ {
+ $results = array();
+
+ $cls = TipoinformePeer::getOMClass();
+ $cls = Propel::import($cls);
+ while($rs->next()) {
+
+ $obj = new $cls();
+ $obj->hydrate($rs);
+ $results[] = $obj;
+
+ }
+ return $results;
+ }
+
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
+ }
+
+
+ public static function getOMClass()
+ {
+ return TipoinformePeer::CLASS_DEFAULT;
+ }
+
+
+ public static function doInsert($values, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(self::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; } else {
+ $criteria = $values->buildCriteria(); }
+
+ $criteria->remove(TipoinformePeer::ID);
+
+ $criteria->setDbName(self::DATABASE_NAME);
+
+ try {
+ $con->begin();
+ $pk = BasePeer::doInsert($criteria, $con);
+ $con->commit();
+ } catch(PropelException $e) {
+ $con->rollback();
+ throw $e;
+ }
+
+ return $pk;
+ }
+
+
+ public static function doUpdate($values, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(self::DATABASE_NAME);
+ }
+
+ $selectCriteria = new Criteria(self::DATABASE_NAME);
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values;
+ $comparison = $criteria->getComparison(TipoinformePeer::ID);
+ $selectCriteria->add(TipoinformePeer::ID, $criteria->remove(TipoinformePeer::ID), $comparison);
+
+ } else { $criteria = $values->buildCriteria(); $selectCriteria = $values->buildPkeyCriteria(); }
+
+ $criteria->setDbName(self::DATABASE_NAME);
+
+ return BasePeer::doUpdate($selectCriteria, $criteria, $con);
+ }
+
+
+ public static function doDeleteAll($con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(self::DATABASE_NAME);
+ }
+ $affectedRows = 0; try {
+ $con->begin();
+ $affectedRows += BasePeer::doDeleteAll(TipoinformePeer::TABLE_NAME, $con);
+ $con->commit();
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollback();
+ throw $e;
+ }
+ }
+
+
+ public static function doDelete($values, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(TipoinformePeer::DATABASE_NAME);
+ }
+
+ if ($values instanceof Criteria) {
+ $criteria = clone $values; } elseif ($values instanceof Tipoinforme) {
+
+ $criteria = $values->buildPkeyCriteria();
+ } else {
+ $criteria = new Criteria(self::DATABASE_NAME);
+ $criteria->add(TipoinformePeer::ID, (array) $values, Criteria::IN);
+ }
+
+ $criteria->setDbName(self::DATABASE_NAME);
+
+ $affectedRows = 0;
+ try {
+ $con->begin();
+
+ $affectedRows += BasePeer::doDelete($criteria, $con);
+ $con->commit();
+ return $affectedRows;
+ } catch (PropelException $e) {
+ $con->rollback();
+ throw $e;
+ }
+ }
+
+
+ public static function doValidate(Tipoinforme $obj, $cols = null)
+ {
+ $columns = array();
+
+ if ($cols) {
+ $dbMap = Propel::getDatabaseMap(TipoinformePeer::DATABASE_NAME);
+ $tableMap = $dbMap->getTable(TipoinformePeer::TABLE_NAME);
+
+ if (! is_array($cols)) {
+ $cols = array($cols);
+ }
+
+ foreach($cols as $colName) {
+ if ($tableMap->containsColumn($colName)) {
+ $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
+ $columns[$colName] = $obj->$get();
+ }
+ }
+ } else {
+
+ }
+
+ $res = BasePeer::doValidate(TipoinformePeer::DATABASE_NAME, TipoinformePeer::TABLE_NAME, $columns);
+ if ($res !== true) {
+ $request = sfContext::getInstance()->getRequest();
+ foreach ($res as $failed) {
+ $col = TipoinformePeer::translateFieldname($failed->getColumn(), BasePeer::TYPE_COLNAME, BasePeer::TYPE_PHPNAME);
+ $request->setError($col, $failed->getMessage());
+ }
+ }
+
+ return $res;
+ }
+
+
+ public static function retrieveByPK($pk, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(self::DATABASE_NAME);
+ }
+
+ $criteria = new Criteria(TipoinformePeer::DATABASE_NAME);
+
+ $criteria->add(TipoinformePeer::ID, $pk);
+
+
+ $v = TipoinformePeer::doSelect($criteria, $con);
+
+ return !empty($v) > 0 ? $v[0] : null;
+ }
+
+
+ public static function retrieveByPKs($pks, $con = null)
+ {
+ if ($con === null) {
+ $con = Propel::getConnection(self::DATABASE_NAME);
+ }
+
+ $objs = null;
+ if (empty($pks)) {
+ $objs = array();
+ } else {
+ $criteria = new Criteria();
+ $criteria->add(TipoinformePeer::ID, $pks, Criteria::IN);
+ $objs = TipoinformePeer::doSelect($criteria, $con);
+ }
+ return $objs;
+ }
+
+}
+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/BaseTipoinformePeer.php
___________________________________________________________________
Name: svn:keywords
+ "Id Author URL Date Rev"
1
0
10 Oct '07
Author: josx
Date: 2007-10-10 14:24:59 -0300 (Wed, 10 Oct 2007)
New Revision: 5217
Added:
prosistem/alba/trunk/alba/doc/patchs/newMimeTypes.patch
Modified:
prosistem/alba/trunk/alba/doc/patchs/LEEME
Log:
Agrego nuevo parche contribuido a symfony #2362 que agregar mimetypes para los archivos de opendocment
Modified: prosistem/alba/trunk/alba/doc/patchs/LEEME
===================================================================
--- prosistem/alba/trunk/alba/doc/patchs/LEEME 2007-10-10 17:02:46 UTC (rev 5216)
+++ prosistem/alba/trunk/alba/doc/patchs/LEEME 2007-10-10 17:24:59 UTC (rev 5217)
@@ -6,4 +6,7 @@
Listado:
check_radio_array.patch
-ver situacion en http://trac.symfony-project.com/trac/ticket/1776
\ No newline at end of file
+ver situacion en http://trac.symfony-project.com/trac/ticket/1776
+
+newMimeTypes.pacth
+ver situacion en http://trac.symfony-project.com/ticket/2362
\ No newline at end of file
Added: prosistem/alba/trunk/alba/doc/patchs/newMimeTypes.patch
===================================================================
--- prosistem/alba/trunk/alba/doc/patchs/newMimeTypes.patch 2007-10-10 17:02:46 UTC (rev 5216)
+++ prosistem/alba/trunk/alba/doc/patchs/newMimeTypes.patch 2007-10-10 17:24:59 UTC (rev 5217)
@@ -0,0 +1,52 @@
+==== Patch <newMimeTypes> level 1
+Source: 7e279c5d-a611-4b96-a2ae-919964e9ce6a:/symfony/local/trunk:2654 [local]
+Target: ee427ae8-e902-0410-961c-c3ed070cd9f9:/trunk:5410 [mirrored]
+ (http://svn.symfony-project.com/trunk)
+Log:
+ r2505@idilia: josx | 2007-08-06 23:10:41 -0300
+ creating local branch for symfony/trunk
+ r2506@idilia: josx | 2007-08-06 23:18:02 -0300
+
+ r2624@idilia: josx | 2007-09-22 15:19:37 -0300
+ nuevo cambio para standar de symfony
+ r2625@idilia: josx | 2007-09-25 10:57:16 -0300
+ Se agregaron un para de tests para los multiples checkboxes y radios
+ r2632@idilia: josx | 2007-09-25 11:03:51 -0300
+ arreglo a los estandars del codigo symfony
+ r2654@idilia: josx | 2007-10-10 14:07:32 -0300
+ Adding open office mime types
+
+=== data/data/mime_types.php
+==================================================================
+--- data/data/mime_types.php (revision 5410)
++++ data/data/mime_types.php (patch newMimeTypes level 1)
+@@ -116,6 +116,20 @@
+ application/vnd.nervana ent
+ application/vnd.nokia.radio-preset rpst
+ application/vnd.nokia.radio-presets rpss
++application/vnd.oasis.opendocument.text odt
++application/vnd.oasis.opendocument.text-template ott
++application/vnd.oasis.opendocument.text-web oth
++application/vnd.oasis.opendocument.text-master odm
++application/vnd.oasis.opendocument.graphics odg
++application/vnd.oasis.opendocument.graphics-template otg
++application/vnd.oasis.opendocument.presentation odp
++application/vnd.oasis.opendocument.presentation-template otp
++application/vnd.oasis.opendocument.spreadsheet ods
++application/vnd.oasis.opendocument.spreadsheet-template ots
++application/vnd.oasis.opendocument.chart odc
++application/vnd.oasis.opendocument.formula odf
++application/vnd.oasis.opendocument.database odb
++application/vnd.oasis.opendocument.image odi
+ application/vnd.palm prc
+ application/vnd.picsel efif
+ application/vnd.pvi.ptid1 pti
+=== data/data/mime_types.dat
+==================================================================
+--- data/data/mime_types.dat (revision 5410)
++++ data/data/mime_types.dat (patch newMimeTypes level 1)
+@@ -1 +1 @@
+-a:390:{s:24:"application/andrew-inset";s:2:"ez";s:23:"application/appledouble";s:6:"base64";s:21:"application/applefile";s:6:"base64";s:24:"application/commonground";s:2:"dp";s:21:"application/cprplayer";s:3:"pqi";s:19:"application/dsptype";s:3:"tsp";s:17:"application/excel";s:3:"xls";s:22:"application/font-tdpfr";s:3:"pfr";s:24:"application/futuresplash";s:3:"spl";s:16:"application/hstu";s:3:"stk";s:23:"application/hyperstudio";s:3:"stk";s:22:"application/javascript";s:2:"js";s:24:"application/mac-binhex40";s:3:"hqx";s:26:"application/mac-compactpro";s:3:"cpt";s:16:"application/mbed";s:3:"mbd";s:18:"application/mirage";s:3:"mfp";s:18:"application/msword";s:3:"doc";s:24:"application/ocsp-request";s:3:"orq";s:25:"application/ocsp-response";s:3:"ors";s:24:"application/octet-stream";s:3:"exe";s:15:"application/oda";s:3:"oda";s:15:"application/ogg";s:3:"ogg";s:15:"application/pdf";s:3:"pdf";s:25:"application/pgp-encrypted";s:4:"7bit";s:20:"application/pgp-keys";s:4:"7bit";s:25:"application/pgp-signature";s:3:"sig";s:18:"application/pkcs10";s:3:"p10";s:22:"application/pkcs7-mime";s:3:"p7m";s:27:"application/pkcs7-signature";s:3:"p7s";s:21:"application/pkix-cert";s:3:"cer";s:20:"application/pkix-crl";s:3:"crl";s:24:"application/pkix-pkipath";s:7:"pkipath";s:19:"application/pkixcmp";s:3:"pki";s:22:"application/postscript";s:2:"ps";s:25:"application/presentations";s:3:"shw";s:19:"application/prs.cww";s:2:"cw";s:22:"application/prs.nprend";s:3:"rnd";s:17:"application/quest";s:3:"qrt";s:15:"application/rtf";s:3:"rtf";s:29:"application/sgml-open-catalog";s:3:"soc";s:17:"application/sieve";s:3:"siv";s:16:"application/smil";s:3:"smi";s:20:"application/toolbook";s:3:"tbk";s:33:"application/vnd.3gpp.pic-bw-large";s:3:"plb";s:33:"application/vnd.3gpp.pic-bw-small";s:3:"psb";s:31:"application/vnd.3gpp.pic-bw-var";s:3:"pvb";s:24:"application/vnd.3gpp.sms";s:3:"sms";s:23:"application/vnd.acucorp";s:3:"atc";s:26:"application/vnd.adobe.xfdf";s:4:"xfdf";s:25:"application/vnd.amiga.amu";s:3:"ami";s:33:"application/vnd.blueice.multipa
ss";s:3:"mpm";s:26:"application/vnd.cinderella";s:3:"cdy";s:27:"application/vnd.cosmocaller";s:3:"cmc";s:37:"application/vnd.criticaltools.wbs+xml";s:3:"wbs";s:20:"application/vnd.curl";s:4:"curl";s:31:"application/vnd.data-vision.rdz";s:3:"rdz";s:28:"application/vnd.dreamfactory";s:4:"dfac";s:28:"application/vnd.fsc.weblauch";s:3:"fsc";s:32:"application/vnd.genomatix.tuxedo";s:3:"txd";s:20:"application/vnd.hbci";s:4:"hbci";s:33:"application/vnd.hhe.lesson-player";s:3:"les";s:23:"application/vnd.hp-hpgl";s:3:"plt";s:36:"application/vnd.ibm.electronic-media";s:3:"emm";s:37:"application/vnd.ibm.rights-management";s:3:"irm";s:36:"application/vnd.ibm.secure-container";s:2:"sc";s:37:"application/vnd.ipunplugged.rcprofile";s:9:"rcprofile";s:39:"application/vnd.irepository.package+xml";s:3:"irp";s:20:"application/vnd.jisp";s:4:"jisp";s:26:"application/vnd.kde.karbon";s:6:"karbon";s:26:"application/vnd.kde.kchart";s:4:"chrt";s:28:"application/vnd.kde.kformula";s:3:"kfo";s:25:"application/vnd.kde.kivio";s:3:"flw";s:27:"application/vnd.kde.kontour";s:3:"kon";s:30:"application/vnd.kde.kpresenter";s:3:"kpr";s:27:"application/vnd.kde.kspread";s:3:"ksp";s:25:"application/vnd.kde.kword";s:3:"kwd";s:25:"application/vnd.kenameapp";s:4:"htke";s:28:"application/vnd.kidspiration";s:3:"kia";s:21:"application/vnd.kinar";s:3:"kne";s:50:"application/vnd.llamagraphics.life-balance.desktop";s:3:"lbd";s:55:"application/vnd.llamagraphics.life-balance.exchange+xml";s:3:"lbe";s:27:"application/vnd.lotus-1-2-3";s:3:"wks";s:19:"application/vnd.mcd";s:3:"mcd";s:20:"application/vnd.mfmp";s:3:"mfm";s:30:"application/vnd.micrografx.flo";s:3:"flo";s:30:"application/vnd.micrografx.igx";s:3:"igx";s:19:"application/vnd.mif";s:3:"mif";s:34:"application/vnd.mophun.application";s:3:"mpn";s:34:"application/vnd.mophun.certificate";s:3:"mpc";s:31:"application/vnd.mozilla.xul+xml";s:3:"xul";s:27:"application/vnd.ms-artgalry";s:3:"cil";s:22:"application/vnd.ms-asf";s:3:"asf";s:24:"application/vnd.ms-excel";s:3:"xls";s:22:"application/vnd.ms-lrm";s:3:"lrm";s:29
:"application/vnd.ms-powerpoint";s:3:"ppt";s:26:"application/vnd.ms-project";s:3:"mpp";s:23:"application/vnd.ms-tnef";s:6:"base64";s:24:"application/vnd.ms-works";s:6:"base64";s:22:"application/vnd.ms-wpl";s:3:"wpl";s:20:"application/vnd.mseq";s:4:"mseq";s:23:"application/vnd.nervana";s:3:"ent";s:34:"application/vnd.nokia.radio-preset";s:4:"rpst";s:35:"application/vnd.nokia.radio-presets";s:4:"rpss";s:20:"application/vnd.palm";s:3:"prc";s:22:"application/vnd.picsel";s:4:"efif";s:25:"application/vnd.pvi.ptid1";s:3:"pti";s:33:"application/vnd.quark.quarkxpress";s:3:"qxd";s:26:"application/vnd.sealed.doc";s:4:"sdoc";s:26:"application/vnd.sealed.eml";s:4:"seml";s:26:"application/vnd.sealed.mht";s:4:"smht";s:26:"application/vnd.sealed.ppt";s:4:"sppt";s:26:"application/vnd.sealed.xls";s:4:"sxls";s:41:"application/vnd.sealedmedia.softseal.html";s:4:"stml";s:40:"application/vnd.sealedmedia.softseal.pdf";s:4:"spdf";s:23:"application/vnd.seemail";s:3:"see";s:20:"application/vnd.smaf";s:3:"mmf";s:28:"application/vnd.sun.xml.calc";s:3:"sxc";s:37:"application/vnd.sun.xml.calc.template";s:3:"stc";s:28:"application/vnd.sun.xml.draw";s:3:"sxd";s:37:"application/vnd.sun.xml.draw.template";s:3:"std";s:31:"application/vnd.sun.xml.impress";s:3:"sxi";s:40:"application/vnd.sun.xml.impress.template";s:3:"sti";s:28:"application/vnd.sun.xml.math";s:3:"sxm";s:30:"application/vnd.sun.xml.writer";s:3:"sxw";s:37:"application/vnd.sun.xml.writer.global";s:3:"sxg";s:39:"application/vnd.sun.xml.writer.template";s:3:"stw";s:28:"application/vnd.sus-calendar";s:3:"sus";s:37:"application/vnd.vidsoft.vidconference";s:3:"vsc";s:21:"application/vnd.visio";s:3:"vsd";s:25:"application/vnd.visionary";s:3:"vis";s:23:"application/vnd.wap.sic";s:3:"sic";s:23:"application/vnd.wap.slc";s:3:"slc";s:25:"application/vnd.wap.wbxml";s:5:"wbxml";s:24:"application/vnd.wap.wmlc";s:4:"wmlc";s:30:"application/vnd.wap.wmlscriptc";s:5:"wmlsc";s:24:"application/vnd.webturbo";s:3:"wtb";s:27:"application/vnd.wordperfect";s:3:"wpd";s:19:"application/vnd.wqd";s:3:"wqd";s:28:"a
pplication/vnd.wv.csp+wbxml";s:2:"wv";s:26:"application/vnd.wv.csp+xml";s:4:"8bit";s:26:"application/vnd.wv.ssp+xml";s:4:"8bit";s:29:"application/vnd.yamaha.hv-dic";s:3:"hvd";s:32:"application/vnd.yamaha.hv-script";s:3:"hvs";s:31:"application/vnd.yamaha.hv-voice";s:3:"hvp";s:33:"application/vnd.yamaha.smaf-audio";s:3:"saf";s:34:"application/vnd.yamaha.smaf-phrase";s:3:"spf";s:31:"application/vocaltec-media-desc";s:3:"vmd";s:31:"application/vocaltec-media-file";s:3:"vmf";s:27:"application/vocaltec-talker";s:3:"vtk";s:27:"application/watcherinfo+xml";s:3:"wif";s:26:"application/wordperfect5.1";s:3:"wp5";s:17:"application/x-123";s:2:"wk";s:29:"application/x-7th_level_event";s:3:"7ls";s:28:"application/x-authorware-bin";s:3:"aab";s:28:"application/x-authorware-map";s:3:"aam";s:28:"application/x-authorware-seg";s:3:"aas";s:19:"application/x-bcpio";s:5:"bcpio";s:21:"application/x-bleeper";s:5:"bleep";s:19:"application/x-bzip2";s:3:"bz2";s:20:"application/x-cdlink";s:3:"vcd";s:18:"application/x-chat";s:4:"chat";s:23:"application/x-chess-pgn";s:3:"pgn";s:22:"application/x-compress";s:1:"z";s:18:"application/x-cpio";s:4:"cpio";s:23:"application/x-cprplayer";s:3:"pqf";s:17:"application/x-csh";s:3:"csh";s:22:"application/x-cu-seeme";s:3:"csm";s:27:"application/x-cult3d-object";s:2:"co";s:28:"application/x-debian-package";s:3:"deb";s:22:"application/x-director";s:3:"dxr";s:17:"application/x-dvi";s:3:"dvi";s:19:"application/x-envoy";s:3:"evy";s:26:"application/x-futuresplash";s:3:"spl";s:18:"application/x-gtar";s:4:"gtar";s:18:"application/x-gzip";s:2:"gz";s:17:"application/x-hdf";s:3:"hdf";s:17:"application/x-hep";s:3:"hep";s:23:"application/x-html+ruby";s:5:"rhtml";s:24:"application/x-httpd-miva";s:2:"mv";s:23:"application/x-httpd-php";s:5:"phtml";s:17:"application/x-ica";s:3:"ica";s:22:"application/x-imagemap";s:8:"imagemap";s:18:"application/x-ipix";s:3:"ipx";s:22:"application/x-ipscript";s:3:"ips";s:26:"application/x-java-archive";s:3:"jar";s:28:"application/x-java-jnlp-file";s:4:"jnlp";s:36:"application/x-java-serialize
d-object";s:3:"ser";s:21:"application/x-java-vm";s:5:"class";s:24:"application/x-javascript";s:2:"js";s:18:"application/x-koan";s:3:"skp";s:19:"application/x-latex";s:5:"latex";s:28:"application/x-mac-compactpro";s:3:"cpt";s:19:"application/x-maker";s:3:"frm";s:21:"application/x-mathcad";s:3:"mcd";s:18:"application/x-midi";s:3:"mid";s:17:"application/x-mif";s:3:"mif";s:22:"application/x-msaccess";s:3:"mda";s:27:"application/x-msdos-program";s:3:"com";s:24:"application/x-msdownload";s:6:"base64";s:21:"application/x-msexcel";s:3:"xls";s:20:"application/x-msword";s:3:"doc";s:20:"application/x-netcdf";s:2:"nc";s:33:"application/x-ns-proxy-autoconfig";s:3:"pac";s:23:"application/x-pagemaker";s:3:"pm5";s:18:"application/x-perl";s:2:"pl";s:26:"application/x-pn-realmedia";s:2:"rp";s:20:"application/x-python";s:2:"py";s:29:"application/x-quicktimeplayer";s:3:"qtl";s:28:"application/x-rar-compressed";s:3:"rar";s:18:"application/x-ruby";s:2:"rb";s:16:"application/x-sh";s:2:"sh";s:18:"application/x-shar";s:4:"shar";s:29:"application/x-shockwave-flash";s:3:"swf";s:20:"application/x-sprite";s:3:"spr";s:18:"application/x-spss";s:3:"sav";s:17:"application/x-spt";s:3:"spt";s:21:"application/x-stuffit";s:3:"sit";s:21:"application/x-sv4cpio";s:7:"sv4cpio";s:20:"application/x-sv4crc";s:6:"sv4crc";s:17:"application/x-tar";s:3:"tar";s:17:"application/x-tcl";s:3:"tcl";s:17:"application/x-tex";s:3:"tex";s:21:"application/x-texinfo";s:7:"texinfo";s:19:"application/x-troff";s:1:"t";s:23:"application/x-troff-man";s:3:"man";s:22:"application/x-troff-me";s:2:"me";s:22:"application/x-troff-ms";s:2:"ms";s:20:"application/x-twinvq";s:3:"vqf";s:27:"application/x-twinvq-plugin";s:3:"vqe";s:19:"application/x-ustar";s:5:"ustar";s:23:"application/x-vmsbackup";s:3:"bck";s:25:"application/x-wais-source";s:3:"src";s:19:"application/x-wingz";s:2:"wz";s:18:"application/x-word";s:6:"base64";s:28:"application/x-wordperfect6.1";s:3:"wp6";s:26:"application/x-x509-ca-cert";s:3:"crt";s:28:"application/x-zip-compressed";s:3:"zip";s:21:"application/xhtml+xml";s:
5:"xhtml";s:15:"application/zip";s:3:"zip";s:10:"audio/3gpp";s:4:"3gpp";s:9:"audio/amr";s:3:"amr";s:12:"audio/amr-wb";s:3:"awb";s:11:"audio/basic";s:2:"au";s:10:"audio/evrc";s:3:"evc";s:9:"audio/l16";s:3:"l16";s:10:"audio/midi";s:3:"mid";s:10:"audio/mpeg";s:4:"mpga";s:13:"audio/prs.sid";s:3:"sid";s:11:"audio/qcelp";s:3:"qcp";s:9:"audio/smv";s:3:"smv";s:18:"audio/vnd.audiokoz";s:3:"koz";s:23:"audio/vnd.digital-winds";s:3:"eol";s:20:"audio/vnd.everad.plj";s:3:"plj";s:22:"audio/vnd.lucent.voice";s:3:"lvp";s:26:"audio/vnd.nokia.mobile-xmf";s:4:"mxmf";s:20:"audio/vnd.nortel.vbk";s:3:"vbk";s:25:"audio/vnd.nuera.ecelp4800";s:9:"ecelp4800";s:25:"audio/vnd.nuera.ecelp7470";s:9:"ecelp7470";s:25:"audio/vnd.nuera.ecelp9600";s:9:"ecelp9600";s:35:"audio/vnd.sealedmedia.softseal.mpeg";s:4:"smp3";s:13:"audio/voxware";s:3:"vox";s:12:"audio/x-aiff";s:3:"aif";s:11:"audio/x-mid";s:3:"mid";s:12:"audio/x-midi";s:3:"mid";s:12:"audio/x-mpeg";s:3:"mp2";s:15:"audio/x-mpegurl";s:3:"mpu";s:20:"audio/x-pn-realaudio";s:2:"rm";s:27:"audio/x-pn-realaudio-plugin";s:3:"rpm";s:17:"audio/x-realaudio";s:2:"ra";s:11:"audio/x-wav";s:3:"wav";s:15:"chemical/x-csml";s:3:"csm";s:29:"chemical/x-embl-dl-nucleotide";s:3:"emb";s:24:"chemical/x-gaussian-cube";s:4:"cube";s:25:"chemical/x-gaussian-input";s:3:"gau";s:19:"chemical/x-jcamp-dx";s:3:"jdx";s:22:"chemical/x-mdl-molfile";s:3:"mol";s:22:"chemical/x-mdl-rxnfile";s:3:"rxn";s:18:"chemical/x-mdl-tgf";s:3:"tgf";s:22:"chemical/x-mopac-input";s:3:"mop";s:14:"chemical/x-pdb";s:3:"pdb";s:17:"chemical/x-rasmol";s:3:"scr";s:14:"chemical/x-xyz";s:3:"xyz";s:11:"drawing/dwf";s:3:"dwf";s:13:"drawing/x-dwf";s:3:"dwf";s:14:"i-world/i-vrml";s:3:"ivr";s:9:"image/bmp";s:3:"bmp";s:15:"image/cewavelet";s:3:"wif";s:13:"image/cis-cod";s:3:"cod";s:9:"image/fif";s:3:"fif";s:9:"image/gif";s:3:"gif";s:9:"image/ief";s:3:"ief";s:9:"image/jp2";s:3:"jp2";s:10:"image/jpeg";s:3:"jpg";s:9:"image/jpm";s:3:"jpm";s:9:"image/jpx";s:3:"jpf";s:10:"image/pict";s:3:"pic";s:11:"image/pjpeg";s:3:"jpg";s:9:"image/png";s:3:"png";s:11:"image/targa";s:
3:"tga";s:10:"image/tiff";s:4:"tiff";s:12:"image/vn-svf";s:3:"svf";s:13:"image/vnd.dgn";s:3:"dgn";s:14:"image/vnd.djvu";s:4:"djvu";s:13:"image/vnd.dwg";s:3:"dwg";s:28:"image/vnd.glocalgraphics.pgb";s:3:"pgb";s:24:"image/vnd.microsoft.icon";s:3:"ico";s:17:"image/vnd.ms-modi";s:3:"mdi";s:20:"image/vnd.sealed.png";s:4:"spng";s:34:"image/vnd.sealedmedia.softseal.gif";s:4:"sgif";s:34:"image/vnd.sealedmedia.softseal.jpg";s:4:"sjpg";s:18:"image/vnd.wap.wbmp";s:4:"wbmp";s:11:"image/x-bmp";s:3:"bmp";s:18:"image/x-cmu-raster";s:3:"ras";s:16:"image/x-freehand";s:3:"fh4";s:11:"image/x-png";s:3:"png";s:23:"image/x-portable-anymap";s:3:"pnm";s:23:"image/x-portable-bitmap";s:3:"pbm";s:24:"image/x-portable-graymap";s:3:"pgm";s:23:"image/x-portable-pixmap";s:3:"ppm";s:11:"image/x-rgb";s:3:"rgb";s:15:"image/x-xbitmap";s:3:"xbm";s:15:"image/x-xpixmap";s:3:"xpm";s:19:"image/x-xwindowdump";s:3:"xwd";s:21:"message/external-body";s:4:"8bit";s:12:"message/news";s:4:"8bit";s:15:"message/partial";s:4:"8bit";s:14:"message/rfc822";s:4:"8bit";s:10:"model/iges";s:3:"igs";s:10:"model/mesh";s:3:"msh";s:35:"model/vnd.parasolid.transmit.binary";s:3:"x_b";s:33:"model/vnd.parasolid.transmit.text";s:3:"x_t";s:10:"model/vrml";s:3:"wrl";s:21:"multipart/alternative";s:4:"8bit";s:21:"multipart/appledouble";s:4:"8bit";s:16:"multipart/digest";s:4:"8bit";s:15:"multipart/mixed";s:4:"8bit";s:18:"multipart/parallel";s:4:"8bit";s:27:"text/comma-separated-values";s:3:"csv";s:8:"text/css";s:3:"css";s:9:"text/html";s:4:"html";s:10:"text/plain";s:3:"txt";s:24:"text/prs.fallenstein.rst";s:3:"rst";s:13:"text/richtext";s:3:"rtx";s:8:"text/rtf";s:3:"rtf";s:9:"text/sgml";s:4:"sgml";s:25:"text/tab-separated-values";s:3:"tsv";s:37:"text/vnd.net2phone.commcenter.command";s:3:"ccc";s:32:"text/vnd.sun.j2me.app-descriptor";s:3:"jad";s:15:"text/vnd.wap.si";s:2:"si";s:15:"text/vnd.wap.sl";s:2:"sl";s:16:"text/vnd.wap.wml";s:3:"wml";s:22:"text/vnd.wap.wmlscript";s:4:"wmls";s:11:"text/x-hdml";s:4:"hdml";s:13:"text/x-setext";s:3:"etx";s:11:"text/x-sgml";s:4:"sgml";s:13:"text/x-spe
ech";s:4:"talk";s:16:"text/x-vcalendar";s:3:"vcs";s:12:"text/x-vcard";s:3:"vcf";s:8:"text/xml";s:3:"xml";s:10:"ulead/vrml";s:3:"uvr";s:10:"video/3gpp";s:3:"3gp";s:8:"video/dl";s:2:"dl";s:8:"video/gl";s:2:"gl";s:9:"video/mj2";s:3:"mj2";s:10:"video/mpeg";s:3:"mpg";s:15:"video/quicktime";s:2:"qt";s:9:"video/vdo";s:3:"vdo";s:10:"video/vivo";s:3:"viv";s:13:"video/vnd.fvt";s:3:"fvt";s:17:"video/vnd.mpegurl";s:3:"mxu";s:38:"video/vnd.nokia.interleaved-multimedia";s:3:"nim";s:21:"video/vnd.objectvideo";s:3:"mp4";s:22:"video/vnd.sealed.mpeg1";s:3:"s11";s:22:"video/vnd.sealed.mpeg4";s:4:"smpg";s:20:"video/vnd.sealed.swf";s:4:"sswf";s:34:"video/vnd.sealedmedia.softseal.mov";s:4:"smov";s:14:"video/vnd.vivo";s:4:"vivo";s:11:"video/x-fli";s:3:"fli";s:14:"video/x-ms-asf";s:3:"asf";s:14:"video/x-ms-wmv";s:3:"wmv";s:15:"video/x-msvideo";s:3:"avi";s:17:"video/x-sgi-movie";s:5:"movie";s:16:"x-chemical/x-pdb";s:3:"pdb";s:16:"x-chemical/x-xyz";s:3:"xyz";s:23:"x-conference/x-cooltalk";s:3:"ice";s:13:"x-drawing/dwf";s:3:"dwf";s:13:"x-world/x-d96";s:1:"d";s:13:"x-world/x-svr";s:3:"svr";s:15:"x-world/x-vream";s:3:"vrw";s:14:"x-world/x-vrml";s:3:"wrl";}
+\ Sin fin-de-línea al final del archivo
++a:404:{s:24:"application/andrew-inset";s:2:"ez";s:23:"application/appledouble";s:6:"base64";s:21:"application/applefile";s:6:"base64";s:24:"application/commonground";s:2:"dp";s:21:"application/cprplayer";s:3:"pqi";s:19:"application/dsptype";s:3:"tsp";s:17:"application/excel";s:3:"xls";s:22:"application/font-tdpfr";s:3:"pfr";s:24:"application/futuresplash";s:3:"spl";s:16:"application/hstu";s:3:"stk";s:23:"application/hyperstudio";s:3:"stk";s:22:"application/javascript";s:2:"js";s:24:"application/mac-binhex40";s:3:"hqx";s:26:"application/mac-compactpro";s:3:"cpt";s:16:"application/mbed";s:3:"mbd";s:18:"application/mirage";s:3:"mfp";s:18:"application/msword";s:3:"doc";s:24:"application/ocsp-request";s:3:"orq";s:25:"application/ocsp-response";s:3:"ors";s:24:"application/octet-stream";s:3:"exe";s:15:"application/oda";s:3:"oda";s:15:"application/ogg";s:3:"ogg";s:15:"application/pdf";s:3:"pdf";s:25:"application/pgp-encrypted";s:4:"7bit";s:20:"application/pgp-keys";s:4:"7bit";s:25:"application/pgp-signature";s:3:"sig";s:18:"application/pkcs10";s:3:"p10";s:22:"application/pkcs7-mime";s:3:"p7m";s:27:"application/pkcs7-signature";s:3:"p7s";s:21:"application/pkix-cert";s:3:"cer";s:20:"application/pkix-crl";s:3:"crl";s:24:"application/pkix-pkipath";s:7:"pkipath";s:19:"application/pkixcmp";s:3:"pki";s:22:"application/postscript";s:2:"ps";s:25:"application/presentations";s:3:"shw";s:19:"application/prs.cww";s:2:"cw";s:22:"application/prs.nprend";s:3:"rnd";s:17:"application/quest";s:3:"qrt";s:15:"application/rtf";s:3:"rtf";s:29:"application/sgml-open-catalog";s:3:"soc";s:17:"application/sieve";s:3:"siv";s:16:"application/smil";s:3:"smi";s:20:"application/toolbook";s:3:"tbk";s:33:"application/vnd.3gpp.pic-bw-large";s:3:"plb";s:33:"application/vnd.3gpp.pic-bw-small";s:3:"psb";s:31:"application/vnd.3gpp.pic-bw-var";s:3:"pvb";s:24:"application/vnd.3gpp.sms";s:3:"sms";s:23:"application/vnd.acucorp";s:3:"atc";s:26:"application/vnd.adobe.xfdf";s:4:"xfdf";s:25:"application/vnd.amiga.amu";s:3:"ami";s:33:"application/vnd.blueice.multipa
ss";s:3:"mpm";s:26:"application/vnd.cinderella";s:3:"cdy";s:27:"application/vnd.cosmocaller";s:3:"cmc";s:37:"application/vnd.criticaltools.wbs+xml";s:3:"wbs";s:20:"application/vnd.curl";s:4:"curl";s:31:"application/vnd.data-vision.rdz";s:3:"rdz";s:28:"application/vnd.dreamfactory";s:4:"dfac";s:28:"application/vnd.fsc.weblauch";s:3:"fsc";s:32:"application/vnd.genomatix.tuxedo";s:3:"txd";s:20:"application/vnd.hbci";s:4:"hbci";s:33:"application/vnd.hhe.lesson-player";s:3:"les";s:23:"application/vnd.hp-hpgl";s:3:"plt";s:36:"application/vnd.ibm.electronic-media";s:3:"emm";s:37:"application/vnd.ibm.rights-management";s:3:"irm";s:36:"application/vnd.ibm.secure-container";s:2:"sc";s:37:"application/vnd.ipunplugged.rcprofile";s:9:"rcprofile";s:39:"application/vnd.irepository.package+xml";s:3:"irp";s:20:"application/vnd.jisp";s:4:"jisp";s:26:"application/vnd.kde.karbon";s:6:"karbon";s:26:"application/vnd.kde.kchart";s:4:"chrt";s:28:"application/vnd.kde.kformula";s:3:"kfo";s:25:"application/vnd.kde.kivio";s:3:"flw";s:27:"application/vnd.kde.kontour";s:3:"kon";s:30:"application/vnd.kde.kpresenter";s:3:"kpr";s:27:"application/vnd.kde.kspread";s:3:"ksp";s:25:"application/vnd.kde.kword";s:3:"kwd";s:25:"application/vnd.kenameapp";s:4:"htke";s:28:"application/vnd.kidspiration";s:3:"kia";s:21:"application/vnd.kinar";s:3:"kne";s:50:"application/vnd.llamagraphics.life-balance.desktop";s:3:"lbd";s:55:"application/vnd.llamagraphics.life-balance.exchange+xml";s:3:"lbe";s:27:"application/vnd.lotus-1-2-3";s:3:"wks";s:19:"application/vnd.mcd";s:3:"mcd";s:20:"application/vnd.mfmp";s:3:"mfm";s:30:"application/vnd.micrografx.flo";s:3:"flo";s:30:"application/vnd.micrografx.igx";s:3:"igx";s:19:"application/vnd.mif";s:3:"mif";s:34:"application/vnd.mophun.application";s:3:"mpn";s:34:"application/vnd.mophun.certificate";s:3:"mpc";s:31:"application/vnd.mozilla.xul+xml";s:3:"xul";s:27:"application/vnd.ms-artgalry";s:3:"cil";s:22:"application/vnd.ms-asf";s:3:"asf";s:24:"application/vnd.ms-excel";s:3:"xls";s:22:"application/vnd.ms-lrm";s:3:"lrm";s:29
:"application/vnd.ms-powerpoint";s:3:"ppt";s:26:"application/vnd.ms-project";s:3:"mpp";s:23:"application/vnd.ms-tnef";s:6:"base64";s:24:"application/vnd.ms-works";s:6:"base64";s:22:"application/vnd.ms-wpl";s:3:"wpl";s:20:"application/vnd.mseq";s:4:"mseq";s:23:"application/vnd.nervana";s:3:"ent";s:34:"application/vnd.nokia.radio-preset";s:4:"rpst";s:35:"application/vnd.nokia.radio-presets";s:4:"rpss";s:39:"application/vnd.oasis.opendocument.text";s:3:"odt";s:48:"application/vnd.oasis.opendocument.text-template";s:3:"ott";s:43:"application/vnd.oasis.opendocument.text-web";s:3:"oth";s:46:"application/vnd.oasis.opendocument.text-master";s:3:"odm";s:43:"application/vnd.oasis.opendocument.graphics";s:3:"odg";s:52:"application/vnd.oasis.opendocument.graphics-template";s:3:"otg";s:47:"application/vnd.oasis.opendocument.presentation";s:3:"odp";s:56:"application/vnd.oasis.opendocument.presentation-template";s:3:"otp";s:46:"application/vnd.oasis.opendocument.spreadsheet";s:3:"ods";s:55:"application/vnd.oasis.opendocument.spreadsheet-template";s:3:"ots";s:40:"application/vnd.oasis.opendocument.chart";s:3:"odc";s:42:"application/vnd.oasis.opendocument.formula";s:3:"odf";s:43:"application/vnd.oasis.opendocument.database";s:3:"odb";s:40:"application/vnd.oasis.opendocument.image";s:3:"odi";s:20:"application/vnd.palm";s:3:"prc";s:22:"application/vnd.picsel";s:4:"efif";s:25:"application/vnd.pvi.ptid1";s:3:"pti";s:33:"application/vnd.quark.quarkxpress";s:3:"qxd";s:26:"application/vnd.sealed.doc";s:4:"sdoc";s:26:"application/vnd.sealed.eml";s:4:"seml";s:26:"application/vnd.sealed.mht";s:4:"smht";s:26:"application/vnd.sealed.ppt";s:4:"sppt";s:26:"application/vnd.sealed.xls";s:4:"sxls";s:41:"application/vnd.sealedmedia.softseal.html";s:4:"stml";s:40:"application/vnd.sealedmedia.softseal.pdf";s:4:"spdf";s:23:"application/vnd.seemail";s:3:"see";s:20:"application/vnd.smaf";s:3:"mmf";s:28:"application/vnd.sun.xml.calc";s:3:"sxc";s:37:"application/vnd.sun.xml.calc.template";s:3:"stc";s:28:"application/vnd.sun.xml.draw";s:3:"sxd";s:37:"appl
ication/vnd.sun.xml.draw.template";s:3:"std";s:31:"application/vnd.sun.xml.impress";s:3:"sxi";s:40:"application/vnd.sun.xml.impress.template";s:3:"sti";s:28:"application/vnd.sun.xml.math";s:3:"sxm";s:30:"application/vnd.sun.xml.writer";s:3:"sxw";s:37:"application/vnd.sun.xml.writer.global";s:3:"sxg";s:39:"application/vnd.sun.xml.writer.template";s:3:"stw";s:28:"application/vnd.sus-calendar";s:3:"sus";s:37:"application/vnd.vidsoft.vidconference";s:3:"vsc";s:21:"application/vnd.visio";s:3:"vsd";s:25:"application/vnd.visionary";s:3:"vis";s:23:"application/vnd.wap.sic";s:3:"sic";s:23:"application/vnd.wap.slc";s:3:"slc";s:25:"application/vnd.wap.wbxml";s:5:"wbxml";s:24:"application/vnd.wap.wmlc";s:4:"wmlc";s:30:"application/vnd.wap.wmlscriptc";s:5:"wmlsc";s:24:"application/vnd.webturbo";s:3:"wtb";s:27:"application/vnd.wordperfect";s:3:"wpd";s:19:"application/vnd.wqd";s:3:"wqd";s:28:"application/vnd.wv.csp+wbxml";s:2:"wv";s:26:"application/vnd.wv.csp+xml";s:4:"8bit";s:26:"application/vnd.wv.ssp+xml";s:4:"8bit";s:29:"application/vnd.yamaha.hv-dic";s:3:"hvd";s:32:"application/vnd.yamaha.hv-script";s:3:"hvs";s:31:"application/vnd.yamaha.hv-voice";s:3:"hvp";s:33:"application/vnd.yamaha.smaf-audio";s:3:"saf";s:34:"application/vnd.yamaha.smaf-phrase";s:3:"spf";s:31:"application/vocaltec-media-desc";s:3:"vmd";s:31:"application/vocaltec-media-file";s:3:"vmf";s:27:"application/vocaltec-talker";s:3:"vtk";s:27:"application/watcherinfo+xml";s:3:"wif";s:26:"application/wordperfect5.1";s:3:"wp5";s:17:"application/x-123";s:2:"wk";s:29:"application/x-7th_level_event";s:3:"7ls";s:28:"application/x-authorware-bin";s:3:"aab";s:28:"application/x-authorware-map";s:3:"aam";s:28:"application/x-authorware-seg";s:3:"aas";s:19:"application/x-bcpio";s:5:"bcpio";s:21:"application/x-bleeper";s:5:"bleep";s:19:"application/x-bzip2";s:3:"bz2";s:20:"application/x-cdlink";s:3:"vcd";s:18:"application/x-chat";s:4:"chat";s:23:"application/x-chess-pgn";s:3:"pgn";s:22:"application/x-compress";s:1:"z";s:18:"application/x-cpio";s:4:"cpio";s:23:"application/x-
cprplayer";s:3:"pqf";s:17:"application/x-csh";s:3:"csh";s:22:"application/x-cu-seeme";s:3:"csm";s:27:"application/x-cult3d-object";s:2:"co";s:28:"application/x-debian-package";s:3:"deb";s:22:"application/x-director";s:3:"dxr";s:17:"application/x-dvi";s:3:"dvi";s:19:"application/x-envoy";s:3:"evy";s:26:"application/x-futuresplash";s:3:"spl";s:18:"application/x-gtar";s:4:"gtar";s:18:"application/x-gzip";s:2:"gz";s:17:"application/x-hdf";s:3:"hdf";s:17:"application/x-hep";s:3:"hep";s:23:"application/x-html+ruby";s:5:"rhtml";s:24:"application/x-httpd-miva";s:2:"mv";s:23:"application/x-httpd-php";s:5:"phtml";s:17:"application/x-ica";s:3:"ica";s:22:"application/x-imagemap";s:8:"imagemap";s:18:"application/x-ipix";s:3:"ipx";s:22:"application/x-ipscript";s:3:"ips";s:26:"application/x-java-archive";s:3:"jar";s:28:"application/x-java-jnlp-file";s:4:"jnlp";s:36:"application/x-java-serialized-object";s:3:"ser";s:21:"application/x-java-vm";s:5:"class";s:24:"application/x-javascript";s:2:"js";s:18:"application/x-koan";s:3:"skp";s:19:"application/x-latex";s:5:"latex";s:28:"application/x-mac-compactpro";s:3:"cpt";s:19:"application/x-maker";s:3:"frm";s:21:"application/x-mathcad";s:3:"mcd";s:18:"application/x-midi";s:3:"mid";s:17:"application/x-mif";s:3:"mif";s:22:"application/x-msaccess";s:3:"mda";s:27:"application/x-msdos-program";s:3:"com";s:24:"application/x-msdownload";s:6:"base64";s:21:"application/x-msexcel";s:3:"xls";s:20:"application/x-msword";s:3:"doc";s:20:"application/x-netcdf";s:2:"nc";s:33:"application/x-ns-proxy-autoconfig";s:3:"pac";s:23:"application/x-pagemaker";s:3:"pm5";s:18:"application/x-perl";s:2:"pl";s:26:"application/x-pn-realmedia";s:2:"rp";s:20:"application/x-python";s:2:"py";s:29:"application/x-quicktimeplayer";s:3:"qtl";s:28:"application/x-rar-compressed";s:3:"rar";s:18:"application/x-ruby";s:2:"rb";s:16:"application/x-sh";s:2:"sh";s:18:"application/x-shar";s:4:"shar";s:29:"application/x-shockwave-flash";s:3:"swf";s:20:"application/x-sprite";s:3:"spr";s:18:"application/x-spss";s:3:"sav";s:17:"applicatio
n/x-spt";s:3:"spt";s:21:"application/x-stuffit";s:3:"sit";s:21:"application/x-sv4cpio";s:7:"sv4cpio";s:20:"application/x-sv4crc";s:6:"sv4crc";s:17:"application/x-tar";s:3:"tar";s:17:"application/x-tcl";s:3:"tcl";s:17:"application/x-tex";s:3:"tex";s:21:"application/x-texinfo";s:7:"texinfo";s:19:"application/x-troff";s:1:"t";s:23:"application/x-troff-man";s:3:"man";s:22:"application/x-troff-me";s:2:"me";s:22:"application/x-troff-ms";s:2:"ms";s:20:"application/x-twinvq";s:3:"vqf";s:27:"application/x-twinvq-plugin";s:3:"vqe";s:19:"application/x-ustar";s:5:"ustar";s:23:"application/x-vmsbackup";s:3:"bck";s:25:"application/x-wais-source";s:3:"src";s:19:"application/x-wingz";s:2:"wz";s:18:"application/x-word";s:6:"base64";s:28:"application/x-wordperfect6.1";s:3:"wp6";s:26:"application/x-x509-ca-cert";s:3:"crt";s:28:"application/x-zip-compressed";s:3:"zip";s:21:"application/xhtml+xml";s:5:"xhtml";s:15:"application/zip";s:3:"zip";s:10:"audio/3gpp";s:4:"3gpp";s:9:"audio/amr";s:3:"amr";s:12:"audio/amr-wb";s:3:"awb";s:11:"audio/basic";s:2:"au";s:10:"audio/evrc";s:3:"evc";s:9:"audio/l16";s:3:"l16";s:10:"audio/midi";s:3:"mid";s:10:"audio/mpeg";s:4:"mpga";s:13:"audio/prs.sid";s:3:"sid";s:11:"audio/qcelp";s:3:"qcp";s:9:"audio/smv";s:3:"smv";s:18:"audio/vnd.audiokoz";s:3:"koz";s:23:"audio/vnd.digital-winds";s:3:"eol";s:20:"audio/vnd.everad.plj";s:3:"plj";s:22:"audio/vnd.lucent.voice";s:3:"lvp";s:26:"audio/vnd.nokia.mobile-xmf";s:4:"mxmf";s:20:"audio/vnd.nortel.vbk";s:3:"vbk";s:25:"audio/vnd.nuera.ecelp4800";s:9:"ecelp4800";s:25:"audio/vnd.nuera.ecelp7470";s:9:"ecelp7470";s:25:"audio/vnd.nuera.ecelp9600";s:9:"ecelp9600";s:35:"audio/vnd.sealedmedia.softseal.mpeg";s:4:"smp3";s:13:"audio/voxware";s:3:"vox";s:12:"audio/x-aiff";s:3:"aif";s:11:"audio/x-mid";s:3:"mid";s:12:"audio/x-midi";s:3:"mid";s:12:"audio/x-mpeg";s:3:"mp2";s:15:"audio/x-mpegurl";s:3:"mpu";s:20:"audio/x-pn-realaudio";s:2:"rm";s:27:"audio/x-pn-realaudio-plugin";s:3:"rpm";s:17:"audio/x-realaudio";s:2:"ra";s:11:"audio/x-wav";s:3:"wav";s:15:"chemical/x-csml";s:3:"csm";s:2
9:"chemical/x-embl-dl-nucleotide";s:3:"emb";s:24:"chemical/x-gaussian-cube";s:4:"cube";s:25:"chemical/x-gaussian-input";s:3:"gau";s:19:"chemical/x-jcamp-dx";s:3:"jdx";s:22:"chemical/x-mdl-molfile";s:3:"mol";s:22:"chemical/x-mdl-rxnfile";s:3:"rxn";s:18:"chemical/x-mdl-tgf";s:3:"tgf";s:22:"chemical/x-mopac-input";s:3:"mop";s:14:"chemical/x-pdb";s:3:"pdb";s:17:"chemical/x-rasmol";s:3:"scr";s:14:"chemical/x-xyz";s:3:"xyz";s:11:"drawing/dwf";s:3:"dwf";s:13:"drawing/x-dwf";s:3:"dwf";s:14:"i-world/i-vrml";s:3:"ivr";s:9:"image/bmp";s:3:"bmp";s:15:"image/cewavelet";s:3:"wif";s:13:"image/cis-cod";s:3:"cod";s:9:"image/fif";s:3:"fif";s:9:"image/gif";s:3:"gif";s:9:"image/ief";s:3:"ief";s:9:"image/jp2";s:3:"jp2";s:10:"image/jpeg";s:3:"jpg";s:9:"image/jpm";s:3:"jpm";s:9:"image/jpx";s:3:"jpf";s:10:"image/pict";s:3:"pic";s:11:"image/pjpeg";s:3:"jpg";s:9:"image/png";s:3:"png";s:11:"image/targa";s:3:"tga";s:10:"image/tiff";s:4:"tiff";s:12:"image/vn-svf";s:3:"svf";s:13:"image/vnd.dgn";s:3:"dgn";s:14:"image/vnd.djvu";s:4:"djvu";s:13:"image/vnd.dwg";s:3:"dwg";s:28:"image/vnd.glocalgraphics.pgb";s:3:"pgb";s:24:"image/vnd.microsoft.icon";s:3:"ico";s:17:"image/vnd.ms-modi";s:3:"mdi";s:20:"image/vnd.sealed.png";s:4:"spng";s:34:"image/vnd.sealedmedia.softseal.gif";s:4:"sgif";s:34:"image/vnd.sealedmedia.softseal.jpg";s:4:"sjpg";s:18:"image/vnd.wap.wbmp";s:4:"wbmp";s:11:"image/x-bmp";s:3:"bmp";s:18:"image/x-cmu-raster";s:3:"ras";s:16:"image/x-freehand";s:3:"fh4";s:11:"image/x-png";s:3:"png";s:23:"image/x-portable-anymap";s:3:"pnm";s:23:"image/x-portable-bitmap";s:3:"pbm";s:24:"image/x-portable-graymap";s:3:"pgm";s:23:"image/x-portable-pixmap";s:3:"ppm";s:11:"image/x-rgb";s:3:"rgb";s:15:"image/x-xbitmap";s:3:"xbm";s:15:"image/x-xpixmap";s:3:"xpm";s:19:"image/x-xwindowdump";s:3:"xwd";s:21:"message/external-body";s:4:"8bit";s:12:"message/news";s:4:"8bit";s:15:"message/partial";s:4:"8bit";s:14:"message/rfc822";s:4:"8bit";s:10:"model/iges";s:3:"igs";s:10:"model/mesh";s:3:"msh";s:35:"model/vnd.parasolid.transmit.binary";s:3:"x_b";s:33:"model/vnd.p
arasolid.transmit.text";s:3:"x_t";s:10:"model/vrml";s:3:"wrl";s:21:"multipart/alternative";s:4:"8bit";s:21:"multipart/appledouble";s:4:"8bit";s:16:"multipart/digest";s:4:"8bit";s:15:"multipart/mixed";s:4:"8bit";s:18:"multipart/parallel";s:4:"8bit";s:27:"text/comma-separated-values";s:3:"csv";s:8:"text/css";s:3:"css";s:9:"text/html";s:4:"html";s:10:"text/plain";s:3:"txt";s:24:"text/prs.fallenstein.rst";s:3:"rst";s:13:"text/richtext";s:3:"rtx";s:8:"text/rtf";s:3:"rtf";s:9:"text/sgml";s:4:"sgml";s:25:"text/tab-separated-values";s:3:"tsv";s:37:"text/vnd.net2phone.commcenter.command";s:3:"ccc";s:32:"text/vnd.sun.j2me.app-descriptor";s:3:"jad";s:15:"text/vnd.wap.si";s:2:"si";s:15:"text/vnd.wap.sl";s:2:"sl";s:16:"text/vnd.wap.wml";s:3:"wml";s:22:"text/vnd.wap.wmlscript";s:4:"wmls";s:11:"text/x-hdml";s:4:"hdml";s:13:"text/x-setext";s:3:"etx";s:11:"text/x-sgml";s:4:"sgml";s:13:"text/x-speech";s:4:"talk";s:16:"text/x-vcalendar";s:3:"vcs";s:12:"text/x-vcard";s:3:"vcf";s:8:"text/xml";s:3:"xml";s:10:"ulead/vrml";s:3:"uvr";s:10:"video/3gpp";s:3:"3gp";s:8:"video/dl";s:2:"dl";s:8:"video/gl";s:2:"gl";s:9:"video/mj2";s:3:"mj2";s:10:"video/mpeg";s:3:"mpg";s:15:"video/quicktime";s:2:"qt";s:9:"video/vdo";s:3:"vdo";s:10:"video/vivo";s:3:"viv";s:13:"video/vnd.fvt";s:3:"fvt";s:17:"video/vnd.mpegurl";s:3:"mxu";s:38:"video/vnd.nokia.interleaved-multimedia";s:3:"nim";s:21:"video/vnd.objectvideo";s:3:"mp4";s:22:"video/vnd.sealed.mpeg1";s:3:"s11";s:22:"video/vnd.sealed.mpeg4";s:4:"smpg";s:20:"video/vnd.sealed.swf";s:4:"sswf";s:34:"video/vnd.sealedmedia.softseal.mov";s:4:"smov";s:14:"video/vnd.vivo";s:4:"vivo";s:11:"video/x-fli";s:3:"fli";s:14:"video/x-ms-asf";s:3:"asf";s:14:"video/x-ms-wmv";s:3:"wmv";s:15:"video/x-msvideo";s:3:"avi";s:17:"video/x-sgi-movie";s:5:"movie";s:16:"x-chemical/x-pdb";s:3:"pdb";s:16:"x-chemical/x-xyz";s:3:"xyz";s:23:"x-conference/x-cooltalk";s:3:"ice";s:13:"x-drawing/dwf";s:3:"dwf";s:13:"x-world/x-d96";s:1:"d";s:13:"x-world/x-svr";s:3:"svr";s:15:"x-world/x-vream";s:3:"vrw";s:14:"x-world/x-vrml";s:3:"wrl";}
+\ Sin fin-de-línea al final del archivo
1
0
Author: hsanchez
Date: 2007-10-10 14:02:46 -0300 (Wed, 10 Oct 2007)
New Revision: 5216
Added:
prosistem/alba/tags/1.0/installer/
Log:
version 1.0|
Copied: prosistem/alba/tags/1.0/installer (from rev 5215, prosistem/alba/trunk/installer)
1
0
Author: hsanchez
Date: 2007-10-10 14:02:24 -0300 (Wed, 10 Oct 2007)
New Revision: 5215
Added:
prosistem/alba/tags/1.0/dist/
Log:
version 1.0
Copied: prosistem/alba/tags/1.0/dist (from rev 5214, prosistem/alba/trunk/dist)
1
0
Author: hsanchez
Date: 2007-10-10 14:02:04 -0300 (Wed, 10 Oct 2007)
New Revision: 5214
Added:
prosistem/alba/tags/1.0/debian/
Log:
version 1.0
Copied: prosistem/alba/tags/1.0/debian (from rev 5213, prosistem/alba/trunk/debian)
1
0
Author: hsanchez
Date: 2007-10-10 14:01:26 -0300 (Wed, 10 Oct 2007)
New Revision: 5213
Added:
prosistem/alba/tags/1.0/alba/
Log:
version 1.0
Copied: prosistem/alba/tags/1.0/alba (from rev 5212, prosistem/alba/trunk/alba)
1
0
Author: hsanchez
Date: 2007-10-10 14:00:53 -0300 (Wed, 10 Oct 2007)
New Revision: 5212
Added:
prosistem/alba/tags/1.0/
Log:
version 1.0
1
0
Author: hsanchez
Date: 2007-10-10 13:53:17 -0300 (Wed, 10 Oct 2007)
New Revision: 5211
Removed:
prosistem/alba/tags/1.0rc/trunk/
Log:
Erorro
1
0
Author: hsanchez
Date: 2007-10-10 13:51:31 -0300 (Wed, 10 Oct 2007)
New Revision: 5210
Added:
prosistem/alba/tags/1.0rc/trunk/
Log:
version 1.0
Copied: prosistem/alba/tags/1.0rc/trunk (from rev 5209, prosistem/alba/trunk)
1
0