PageRenderTime 64ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 1ms

/xkid_framework/template/tbs_class.php

http://xfw-xkid-framework.googlecode.com/
PHP | 3330 lines | 2823 code | 330 blank | 177 comment | 773 complexity | 29da29aabb465cebfbfa7b7a365a4b10 MD5 | raw file
Possible License(s): LGPL-2.1

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /*
  3. ********************************************************
  4. TinyButStrong - Template Engine for Pro and Beginners
  5. ------------------------
  6. Version : 3.4.0 for PHP 4
  7. Date : 2008-06-06
  8. Web site : http://www.tinybutstrong.com
  9. Author : http://www.tinybutstrong.com/onlyyou.html
  10. ********************************************************
  11. This library is free software.
  12. You can redistribute and modify it even for commercial usage,
  13. but you must accept and respect the LPGL License version 2.1.
  14. */
  15. // Check PHP version
  16. 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.';
  17. if (!is_callable('array_key_exists')) {
  18. function array_key_exists (&$key,&$array) {return key_exists($key,$array);}
  19. }
  20. if (!is_callable('property_exists')) {
  21. function property_exists(&$obj,$prop) {return true;}
  22. }
  23. // Render flags
  24. define('TBS_NOTHING', 0);
  25. define('TBS_OUTPUT', 1);
  26. define('TBS_EXIT', 2);
  27. // Plug-ins actions
  28. define('TBS_INSTALL', -1);
  29. define('TBS_ISINSTALLED', -3);
  30. // *********************************************
  31. class clsTbsLocator {
  32. var $PosBeg = false;
  33. var $PosEnd = false;
  34. var $Enlarged = false;
  35. var $FullName = false;
  36. var $SubName = '';
  37. var $SubOk = false;
  38. var $SubLst = array();
  39. var $SubNbr = 0;
  40. var $PrmLst = array();
  41. var $PrmIfNbr = false;
  42. var $MagnetId = false;
  43. var $BlockFound = false;
  44. var $FirstMerge = true;
  45. var $ConvProtect = true;
  46. var $ConvHtml = true;
  47. var $ConvMode = 1; // Normal
  48. var $ConvBr = true;
  49. }
  50. // *********************************************
  51. class clsTbsDataSource {
  52. var $Type = false;
  53. var $SubType = 0;
  54. var $SrcId = false;
  55. var $Query = '';
  56. var $RecSet = false;
  57. var $RecKey = '';
  58. var $RecNum = 0;
  59. var $RecNumInit = 0;
  60. var $RecSaving = false;
  61. var $RecSaved = false;
  62. var $RecBuffer = false;
  63. var $CurrRec = false;
  64. var $TBS = false;
  65. var $OnDataOk = false;
  66. var $OnDataPrm = false;
  67. var $OnDataPrmDone = array();
  68. var $OnDataPi = false;
  69. function DataAlert($Msg) {
  70. return $this->TBS->meth_Misc_Alert('when merging block '.$this->TBS->_ChrOpen.$this->TBS->_CurrBlock.$this->TBS->_ChrClose,$Msg);
  71. }
  72. function DataPrepare(&$SrcId,&$TBS) {
  73. $this->SrcId =& $SrcId;
  74. $this->TBS =& $TBS;
  75. $FctInfo = false;
  76. $FctObj = false;
  77. if (is_array($SrcId)) {
  78. $this->Type = 0;
  79. } elseif (is_resource($SrcId)) {
  80. $Key = get_resource_type($SrcId);
  81. switch ($Key) {
  82. case 'mysql link' : $this->Type = 6; break;
  83. case 'mysql link persistent' : $this->Type = 6; break;
  84. case 'mysql result' : $this->Type = 6; $this->SubType = 1; break;
  85. case 'pgsql link' : $this->Type = 7; break;
  86. case 'pgsql link persistent' : $this->Type = 7; break;
  87. case 'pgsql result' : $this->Type = 7; $this->SubType = 1; break;
  88. case 'sqlite database' : $this->Type = 8; break;
  89. case 'sqlite database (persistent)' : $this->Type = 8; break;
  90. case 'sqlite result' : $this->Type = 8; $this->SubType = 1; break;
  91. default :
  92. $FctInfo = $Key;
  93. $FctCat = 'r';
  94. }
  95. } elseif (is_string($SrcId)) {
  96. switch (strtolower($SrcId)) {
  97. case 'array' : $this->Type = 0; $this->SubType = 1; break;
  98. case 'clear' : $this->Type = 0; $this->SubType = 3; break;
  99. case 'mysql' : $this->Type = 6; $this->SubType = 2; break;
  100. case 'text' : $this->Type = 2; break;
  101. case 'num' : $this->Type = 1; break;
  102. default :
  103. $FctInfo = $SrcId;
  104. $FctCat = 'k';
  105. }
  106. } elseif (is_object($SrcId)) {
  107. $FctInfo = get_class($SrcId);
  108. $FctCat = 'o';
  109. $FctObj =& $SrcId;
  110. $this->SrcId =& $SrcId;
  111. } elseif ($SrcId===false) {
  112. $this->DataAlert('the specified source is set to FALSE. Maybe your connection has failed.');
  113. } else {
  114. $this->DataAlert('unsupported variable type : \''.gettype($SrcId).'\'.');
  115. }
  116. if ($FctInfo!==false) {
  117. $ErrMsg = false;
  118. if ($TBS->meth_Misc_UserFctCheck($FctInfo,$FctCat,$FctObj,$ErrMsg)) {
  119. $this->Type = $FctInfo['type'];
  120. if ($this->Type!==5) {
  121. if ($this->Type===4) { //
  122. $this->FctPrm = array(false,0);
  123. $this->SrcId =& $FctInfo['open'][0];
  124. }
  125. $this->FctOpen =& $FctInfo['open'];
  126. $this->FctFetch =& $FctInfo['fetch'];
  127. $this->FctClose =& $FctInfo['close'];
  128. }
  129. } else {
  130. $this->Type = $this->DataAlert($ErrMsg);
  131. }
  132. }
  133. return ($this->Type!==false);
  134. }
  135. function DataOpen(&$Query) {
  136. // Init values
  137. unset($this->CurrRec); $this->CurrRec = true;
  138. if ($this->RecSaved) {
  139. $this->FirstRec = true;
  140. unset($this->RecKey); $this->RecKey = '';
  141. $this->RecNum = $this->RecNumInit;
  142. if ($this->OnDataOk) $this->OnDataArgs[1] =& $this->CurrRec;
  143. return true;
  144. }
  145. unset($this->RecSet); $this->RecSet = false;
  146. $this->RecNumInit = 0;
  147. $this->RecNum = 0;
  148. if (isset($this->TBS->_piOnData)) {
  149. $this->OnDataPi = true;
  150. $this->OnDataPiRef =& $this->TBS->_piOnData;
  151. $this->OnDataOk = true;
  152. }
  153. if ($this->OnDataOk) {
  154. $this->OnDataArgs = array();
  155. $this->OnDataArgs[0] =& $this->TBS->_CurrBlock;
  156. $this->OnDataArgs[1] =& $this->CurrRec;
  157. $this->OnDataArgs[2] =& $this->RecNum;
  158. $this->OnDataArgs[3] =& $this->TBS;
  159. }
  160. switch ($this->Type) {
  161. case 0: // Array
  162. if (($this->SubType===1) and (is_string($Query))) $this->SubType = 2;
  163. if ($this->SubType===0) {
  164. if (PHP_VERSION==='4.4.1') {$this->RecSet = $this->SrcId;} else {$this->RecSet =& $this->SrcId;} // bad bug in PHP 4.4.1
  165. } elseif ($this->SubType===1) {
  166. if (is_array($Query)) {
  167. if (PHP_VERSION==='4.4.1') {$this->RecSet = $Query;} else {$this->RecSet =& $Query;}
  168. } else {
  169. $this->DataAlert('type \''.gettype($Query).'\' not supported for the Query Parameter going with \'array\' Source Type.');
  170. }
  171. } elseif ($this->SubType===2) {
  172. // TBS query string for array and objects, syntax: "var[item1][item2]->item3[item4]..."
  173. $x = trim($Query);
  174. $z = chr(0);
  175. $x = str_replace(']->',$z,$x);
  176. $x = str_replace('][',$z,$x);
  177. $x = str_replace('->',$z,$x);
  178. $x = str_replace('[',$z,$x);
  179. if (substr($x,strlen($x)-1,1)===']') $x = substr($x,0,strlen($x)-1);
  180. $ItemLst = explode($z,$x);
  181. $ItemNbr = count($ItemLst);
  182. $Item0 =& $ItemLst[0];
  183. // Check first item
  184. if ($Item0[0]==='~') {
  185. $Item0 = substr($Item0,1);
  186. if ($this->TBS->ObjectRef!==false) {
  187. $Var =& $this->TBS->ObjectRef;
  188. $i = 0;
  189. } else {
  190. $i = $this->DataAlert('invalid query \''.$Query.'\' because property ObjectRef is not set.');
  191. }
  192. } else {
  193. if (isset($GLOBALS[$Item0])) {
  194. if ((PHP_VERSION==='4.4.1') and is_array($GLOBALS[$Item0])) {$Var = $GLOBALS[$Item0];} else {$Var =& $GLOBALS[$Item0];}
  195. $i = 1;
  196. } else {
  197. $i = $this->DataAlert('invalid query \''.$Query.'\' because global variable \''.$Item0.'\' is not found.');
  198. }
  199. }
  200. // Check sub-items
  201. $Empty = false;
  202. while (($i!==false) and ($i<$ItemNbr) and ($Empty===false)) {
  203. $x = $ItemLst[$i];
  204. if (is_array($Var)) {
  205. if (isset($Var[$x])) {
  206. $Var =& $Var[$x];
  207. } else {
  208. $Empty = true;
  209. }
  210. } elseif (is_object($Var)) {
  211. $ArgLst = $this->f_Misc_CheckArgLst($x);
  212. if (method_exists($Var,$x)) {
  213. $f = array(&$Var,$x); unset($Var);
  214. $Var = call_user_func_array($f,$ArgLst);
  215. } elseif (isset($Var->$x)) {
  216. $Var =& $Var->$x;
  217. } else {
  218. $Empty = true;
  219. }
  220. } else {
  221. $i = $this->DataAlert('invalid query \''.$Query.'\' because item \''.$ItemLst[$i].'\' is neither an Array nor an Object. Its type is \''.gettype($Var).'\'.');
  222. }
  223. if ($i!==false) $i++;
  224. }
  225. // Assign data
  226. if ($i!==false) {
  227. if ($Empty) {
  228. $this->RecSet = array();
  229. } else {
  230. $this->RecSet =& $Var;
  231. }
  232. }
  233. } elseif ($this->SubType===3) { // Clear
  234. $this->RecSet = array();
  235. }
  236. // First record
  237. if ($this->RecSet!==false) {
  238. $this->RecNbr = $this->RecNumInit + count($this->RecSet);
  239. $this->FirstRec = true;
  240. $this->RecSaved = true;
  241. $this->RecSaving = false;
  242. }
  243. break;
  244. case 6: // MySQL
  245. switch ($this->SubType) {
  246. case 0: $this->RecSet = @mysql_query($Query,$this->SrcId); break;
  247. case 1: $this->RecSet = $this->SrcId; break;
  248. case 2: $this->RecSet = @mysql_query($Query); break;
  249. }
  250. if ($this->RecSet===false) $this->DataAlert('MySql error message when opening the query: '.mysql_error());
  251. break;
  252. case 1: // Num
  253. $this->RecSet = true;
  254. $this->NumMin = 1;
  255. $this->NumMax = 1;
  256. $this->NumStep = 1;
  257. if (is_array($Query)) {
  258. if (isset($Query['min'])) $this->NumMin = $Query['min'];
  259. if (isset($Query['step'])) $this->NumStep = $Query['step'];
  260. if (isset($Query['max'])) {
  261. $this->NumMax = $Query['max'];
  262. } else {
  263. $this->RecSet = $this->DataAlert('the \'num\' source is an array that has no value for the \'max\' key.');
  264. }
  265. if ($this->NumStep==0) $this->RecSet = $this->DataAlert('the \'num\' source is an array that has a step value set to zero.');
  266. } else {
  267. $this->NumMax = ceil($Query);
  268. }
  269. if ($this->RecSet) {
  270. if ($this->NumStep>0) {
  271. $this->NumVal = $this->NumMin;
  272. } else {
  273. $this->NumVal = $this->NumMax;
  274. }
  275. }
  276. break;
  277. case 2: // Text
  278. if (is_string($Query)) {
  279. $this->RecSet =& $Query;
  280. } else {
  281. $this->RecSet = ''.$Query;
  282. }
  283. break;
  284. case 3: // Custom function
  285. $FctOpen = $this->FctOpen;
  286. $this->RecSet = $FctOpen($this->SrcId,$Query);
  287. if ($this->RecSet===false) $this->DataAlert('function '.$FctOpen.'() has failed to open query {'.$Query.'}');
  288. break;
  289. case 4: // Custom method from ObjectRef
  290. $this->RecSet = call_user_func_array($this->FctOpen,array(&$this->SrcId,&$Query));
  291. if ($this->RecSet===false) $this->DataAlert('method '.get_class($this->FctOpen[0]).'::'.$this->FctOpen[1].'() has failed to open query {'.$Query.'}');
  292. break;
  293. case 5: // Custom method of object
  294. $this->RecSet = $this->SrcId->tbsdb_open($this->SrcId,$Query);
  295. if ($this->RecSet===false) $this->DataAlert('method '.get_class($this->SrcId).'::tbsdb_open() has failed to open query {'.$Query.'}');
  296. break;
  297. case 7: // PostgreSQL
  298. switch ($this->SubType) {
  299. case 0: $this->RecSet = @pg_query($this->SrcId,$Query); break;
  300. case 1: $this->RecSet = $this->SrcId; break;
  301. }
  302. if ($this->RecSet===false) $this->DataAlert('PostgreSQL error message when opening the query: '.pg_last_error($this->SrcId));
  303. break;
  304. case 8: // SQLite
  305. switch ($this->SubType) {
  306. case 0: $this->RecSet = @sqlite_query($this->SrcId,$Query); break;
  307. case 1: $this->RecSet = $this->SrcId; break;
  308. }
  309. if ($this->RecSet===false) $this->DataAlert('SQLite error message when opening the query:'.sqlite_error_string(sqlite_last_error($this->SrcId)));
  310. break;
  311. }
  312. if ($this->Type===0) {
  313. unset($this->RecKey); $this->RecKey = '';
  314. } else {
  315. if ($this->RecSaving) {
  316. unset($this->RecBuffer); $this->RecBuffer = array();
  317. }
  318. $this->RecKey =& $this->RecNum; // Not array: RecKey = RecNum
  319. }
  320. return ($this->RecSet!==false);
  321. }
  322. function DataFetch() {
  323. if ($this->RecSaved) {
  324. if ($this->RecNum<$this->RecNbr) {
  325. if ($this->FirstRec) {
  326. if ($this->SubType===2) { // From string
  327. reset($this->RecSet);
  328. $this->RecKey = key($this->RecSet);
  329. $this->CurrRec =& $this->RecSet[$this->RecKey];
  330. } else {
  331. $this->CurrRec = reset($this->RecSet);
  332. $this->RecKey = key($this->RecSet);
  333. }
  334. $this->FirstRec = false;
  335. } else {
  336. if ($this->SubType===2) { // From string
  337. next($this->RecSet);
  338. $this->RecKey = key($this->RecSet);
  339. $this->CurrRec =& $this->RecSet[$this->RecKey];
  340. } else {
  341. $this->CurrRec = next($this->RecSet);
  342. $this->RecKey = key($this->RecSet);
  343. }
  344. }
  345. if ((!is_array($this->CurrRec)) and (!is_object($this->CurrRec))) $this->CurrRec = array('key'=>$this->RecKey, 'val'=>$this->CurrRec);
  346. $this->RecNum++;
  347. if ($this->OnDataOk) {
  348. if ($this->OnDataPrm) call_user_func_array($this->OnDataPrmRef,$this->OnDataArgs);
  349. if ($this->OnDataPi) $this->TBS->meth_PlugIn_RunAll($this->OnDataPiRef,$this->OnDataArgs);
  350. if ($this->SubType!==2) $this->RecSet[$this->RecKey] = $this->CurrRec; // save modifications because array reading is done without reference :(
  351. }
  352. } else {
  353. unset($this->CurrRec); $this->CurrRec = false;
  354. }
  355. return;
  356. }
  357. switch ($this->Type) {
  358. case 6: // MySQL
  359. $this->CurrRec = mysql_fetch_assoc($this->RecSet);
  360. break;
  361. case 1: // Num
  362. if (($this->NumVal>=$this->NumMin) and ($this->NumVal<=$this->NumMax)) {
  363. $this->CurrRec = array('val'=>$this->NumVal);
  364. $this->NumVal += $this->NumStep;
  365. } else {
  366. $this->CurrRec = false;
  367. }
  368. break;
  369. case 2: // Text
  370. if ($this->RecNum===0) {
  371. if ($this->RecSet==='') {
  372. $this->CurrRec = false;
  373. } else {
  374. $this->CurrRec =& $this->RecSet;
  375. }
  376. } else {
  377. $this->CurrRec = false;
  378. }
  379. break;
  380. case 3: // Custom function
  381. $FctFetch = $this->FctFetch;
  382. $this->CurrRec = $FctFetch($this->RecSet,$this->RecNum+1);
  383. break;
  384. case 4: // Custom method from ObjectRef
  385. $this->FctPrm[0] =& $this->RecSet; $this->FctPrm[1] = $this->RecNum+1;
  386. $this->CurrRec = call_user_func_array($this->FctFetch,$this->FctPrm);
  387. break;
  388. case 5: // Custom method of object
  389. $this->CurrRec = $this->SrcId->tbsdb_fetch($this->RecSet,$this->RecNum+1);
  390. break;
  391. case 7: // PostgreSQL
  392. $this->CurrRec = @pg_fetch_array($this->RecSet,$this->RecNum,PGSQL_ASSOC); // warning comes when no record left.
  393. break;
  394. case 8: // SQLite
  395. $this->CurrRec = sqlite_fetch_array($this->RecSet,SQLITE_ASSOC);
  396. break;
  397. }
  398. // Set the row count
  399. if ($this->CurrRec!==false) {
  400. $this->RecNum++;
  401. if ($this->OnDataOk) {
  402. $this->OnDataArgs[1] =& $this->CurrRec; // Reference has changed if ($this->SubType===2)
  403. if ($this->OnDataPrm) call_user_func_array($this->OnDataPrmRef,$this->OnDataArgs);
  404. if ($this->OnDataPi) $this->TBS->meth_PlugIn_RunAll($this->OnDataPiRef,$this->OnDataArgs);
  405. }
  406. if ($this->RecSaving) $this->RecBuffer[$this->RecKey] = $this->CurrRec;
  407. }
  408. }
  409. function DataClose() {
  410. $this->OnDataOk = false;
  411. $this->OnDataPrm = false;
  412. $this->OnDataPi = false;
  413. if ($this->RecSaved) return;
  414. switch ($this->Type) {
  415. case 6: mysql_free_result($this->RecSet); break;
  416. case 3: $FctClose=$this->FctClose; $FctClose($this->RecSet); break;
  417. case 4: call_user_func_array($this->FctClose,array(&$this->RecSet)); break;
  418. case 5: $this->SrcId->tbsdb_close($this->RecSet); break;
  419. case 7: pg_free_result($this->RecSet); break;
  420. }
  421. if ($this->RecSaving) {
  422. $this->RecSet =& $this->RecBuffer;
  423. $this->RecNbr = $this->RecNumInit + count($this->RecSet);
  424. $this->RecSaving = false;
  425. $this->RecSaved = true;
  426. }
  427. }
  428. }
  429. // *********************************************
  430. class clsTinyButStrong {
  431. // Public properties
  432. var $Source = '';
  433. var $Render = 3;
  434. var $TplVars = array();
  435. var $ObjectRef = false;
  436. var $NoErr = false;
  437. // Undocumented (can change at any version)
  438. var $Version = '3.4.0';
  439. var $HtmlCharSet = '';
  440. var $TurboBlock = true;
  441. var $VarPrefix = '';
  442. var $Protect = true;
  443. var $ErrCount = 0;
  444. // Private
  445. var $_LastFile = '';
  446. var $_HtmlCharFct = false;
  447. var $_Mode = 0;
  448. var $_CurrBlock = '';
  449. var $_ChrOpen = '[';
  450. var $_ChrClose = ']';
  451. var $_ChrVal = '[val]';
  452. var $_ChrProtect = '&#91;';
  453. var $_PlugIns = array();
  454. var $_PlugIns_Ok = false;
  455. var $_piOnFrm_Ok = false;
  456. function clsTinyButStrong($Chrs='',$VarPrefix='') {
  457. if ($Chrs!=='') {
  458. $Ok = false;
  459. $Len = strlen($Chrs);
  460. if ($Len===2) { // For compatibility
  461. $this->_ChrOpen = $Chrs[0];
  462. $this->_ChrClose = $Chrs[1];
  463. $Ok = true;
  464. } else {
  465. $Pos = strpos($Chrs,',');
  466. if (($Pos!==false) and ($Pos>0) and ($Pos<$Len-1)) {
  467. $this->_ChrOpen = substr($Chrs,0,$Pos);
  468. $this->_ChrClose = substr($Chrs,$Pos+1);
  469. $Ok = true;
  470. }
  471. }
  472. if ($Ok) {
  473. $this->_ChrVal = $this->_ChrOpen.'val'.$this->_ChrClose;
  474. $this->_ChrProtect = '&#'.ord($this->_ChrOpen[0]).';'.substr($this->_ChrOpen,1);
  475. } else {
  476. $this->meth_Misc_Alert('with clsTinyButStrong() function','value \''.$Chrs.'\' is a bad tag delimitor definition.');
  477. }
  478. }
  479. $this->VarPrefix = $VarPrefix;
  480. // Links to global variables
  481. global $_TBS_FormatLst, $_TBS_UserFctLst, $_TBS_AutoInstallPlugIns;
  482. if (!isset($_TBS_FormatLst)) $_TBS_FormatLst = array();
  483. if (!isset($_TBS_UserFctLst)) $_TBS_UserFctLst = array();
  484. $this->_FormatLst =& $_TBS_FormatLst;
  485. $this->_UserFctLst =& $_TBS_UserFctLst;
  486. // Auto-installing plug-ins
  487. if (isset($_TBS_AutoInstallPlugIns)) foreach ($_TBS_AutoInstallPlugIns as $pi) $this->PlugIn(TBS_INSTALL,$pi);
  488. }
  489. // Public methods
  490. function LoadTemplate($File,$HtmlCharSet='') {
  491. if ($File==='') {
  492. $this->meth_Misc_Charset($HtmlCharSet);
  493. return true;
  494. }
  495. $Ok = true;
  496. if ($this->_PlugIns_Ok) {
  497. if (isset($this->_piBeforeLoadTemplate) or isset($this->_piAfterLoadTemplate)) {
  498. // Plug-ins
  499. $ArgLst = func_get_args();
  500. $ArgLst[0] =& $File;
  501. $ArgLst[1] =& $HtmlCharSet;
  502. if (isset($this->_piBeforeLoadTemplate)) $Ok = $this->meth_PlugIn_RunAll($this->_piBeforeLoadTemplate,$ArgLst);
  503. }
  504. }
  505. // Load the file
  506. if ($Ok!==false) {
  507. if (!is_null($File)) {
  508. $x = '';
  509. if (!$this->f_Misc_GetFile($x,$File,$this->_LastFile)) return $this->meth_Misc_Alert('with LoadTemplate() method','file \''.$File.'\' is not found or not readable.');
  510. if ($HtmlCharSet==='+') {
  511. $this->Source .= $x;
  512. } else {
  513. $this->Source = $x;
  514. }
  515. }
  516. if ($this->_Mode==0) {
  517. if (!is_null($File)) $this->_LastFile = $File;
  518. $this->TplVars = array();
  519. $this->meth_Misc_Charset($HtmlCharSet);
  520. }
  521. // Automatic fields and blocks
  522. $this->meth_Merge_AutoOn($this->Source,'onload',true,true);
  523. }
  524. // Plug-ins
  525. if ($this->_PlugIns_Ok and isset($ArgLst) and isset($this->_piAfterLoadTemplate)) $Ok = $this->meth_PlugIn_RunAll($this->_piAfterLoadTemplate,$ArgLst);
  526. return $Ok;
  527. }
  528. function GetBlockSource($BlockName,$List=false,$KeepDefTags=true) {
  529. $RetVal = array();
  530. $Nbr = 0;
  531. $Pos = 0;
  532. $FieldOutside = false;
  533. $P1 = false;
  534. $Mode = ($KeepDefTags) ? 3 : 2;
  535. while ($Loc = $this->meth_Locator_FindBlockNext($this->Source,$BlockName,$Pos,'.',$Mode,$P1,$FieldOutside)) {
  536. $P1 = false;
  537. $Nbr++;
  538. $RetVal[$Nbr] = $Loc->BlockSrc;
  539. if (!$List) return $RetVal[$Nbr];
  540. $Pos = $Loc->PosEnd;
  541. }
  542. if ($List) {
  543. return $RetVal;
  544. } else {
  545. return false;
  546. }
  547. }
  548. function MergeBlock($BlockLst,$SrcId,$Query='') {
  549. if ($SrcId==='cond') {
  550. $Nbr = 0;
  551. $BlockLst = explode(',',$BlockLst);
  552. foreach ($BlockLst as $Block) {
  553. $Block = trim($Block);
  554. if ($Block!=='') $Nbr += $this->meth_Merge_AutoOn($this->Source,$Block,true,true);
  555. }
  556. return $Nbr;
  557. } else {
  558. return $this->meth_Merge_Block($this->Source,$BlockLst,$SrcId,$Query,false,0);
  559. }
  560. }
  561. function MergeField($NameLst,$Value=null,$IsUserFct=false) {
  562. $FctCheck = $IsUserFct;
  563. if ($PlugIn = isset($this->_piOnMergeField)) $ArgPi = array('','',&$Value,0,&$this->Source,0,0);
  564. $SubStart = 0;
  565. $Ok = true;
  566. $NameLst = explode(',',$NameLst);
  567. foreach ($NameLst as $Name) {
  568. $Name = trim($Name);
  569. $Cont = false;
  570. switch ($Name) {
  571. case '': $Cont=true;
  572. case 'onload': $this->meth_Merge_AutoOn($this->Source,'onload',true,true);$Cont=true;
  573. case 'onshow': $this->meth_Merge_AutoOn($this->Source,'onshow',true,true);$Cont=true;
  574. case 'var': $this->meth_Merge_AutoVar($this->Source,true);$Cont=true;
  575. }
  576. if ($Cont) continue;
  577. if ($PlugIn) $ArgPi[0] = $Name;
  578. $PosBeg = 0;
  579. // Initilize the user function (only once)
  580. if ($FctCheck) {
  581. $FctInfo = $Value;
  582. $ErrMsg = false;
  583. if (!$this->meth_Misc_UserFctCheck($FctInfo,'f',$ErrMsg,$ErrMsg)) return $this->meth_Misc_Alert('with MergeField() method',$ErrMsg);
  584. $FctArg = array('','');
  585. $SubStart = false;
  586. $FctCheck = false;
  587. }
  588. while ($Loc = $this->meth_Locator_FindTbs($this->Source,$Name,$PosBeg,'.')) {
  589. // Apply user function
  590. if ($IsUserFct) {
  591. $FctArg[0] =& $Loc->SubName; $FctArg[1] =& $Loc->PrmLst;
  592. $Value = call_user_func_array($FctInfo,$FctArg);
  593. }
  594. // Plug-ins
  595. if ($PlugIn) {
  596. $ArgPi[1] = $Loc->SubName; $ArgPi[3] =& $Loc->PrmLst; $ArgPi[5] =& $Loc->PosBeg; $ArgPi[6] =& $Loc->PosEnd;
  597. $Ok = $this->meth_PlugIn_RunAll($this->_piOnMergeField,$ArgPi);
  598. }
  599. // Merge the field
  600. if ($Ok) {
  601. $PosBeg = $this->meth_Locator_Replace($this->Source,$Loc,$Value,$SubStart);
  602. } else {
  603. $PosBeg = $Loc->PosEnd;
  604. }
  605. }
  606. }
  607. }
  608. function Show($Render=false) {
  609. $Ok = true;
  610. if ($Render===false) $Render = $this->Render;
  611. if ($this->_PlugIns_Ok) {
  612. if (isset($this->_piBeforeShow) or isset($this->_piAfterShow)) {
  613. // Plug-ins
  614. $ArgLst = func_get_args();
  615. $ArgLst[0] =& $Render;
  616. if (isset($this->_piBeforeShow)) $Ok = $this->meth_PlugIn_RunAll($this->_piBeforeShow,$ArgLst);
  617. }
  618. }
  619. if ($Ok!==false) {
  620. $this->meth_Merge_AutoOn($this->Source,'onshow',true,true);
  621. $this->meth_Merge_AutoVar($this->Source,true);
  622. }
  623. if ($this->_PlugIns_Ok and isset($ArgLst) and isset($this->_piAfterShow)) $this->meth_PlugIn_RunAll($this->_piAfterShow,$ArgLst);
  624. if (($Render & TBS_OUTPUT)==TBS_OUTPUT) echo $this->Source;
  625. if (($this->_Mode==0) and (($Render & TBS_EXIT)==TBS_EXIT)) exit;
  626. return $Ok;
  627. }
  628. function PlugIn($Prm1,$Prm2=0) {
  629. if (is_numeric($Prm1)) {
  630. switch ($Prm1) {
  631. case TBS_INSTALL:
  632. $PlugInId = $Prm2;
  633. // Try to install the plug-in
  634. if (isset($this->_PlugIns[$PlugInId])) {
  635. return $this->meth_Misc_Alert('with PlugIn() method','plug-in \''.$PlugInId.'\' is already installed.');
  636. } else {
  637. $ArgLst = func_get_args();
  638. array_shift($ArgLst); array_shift($ArgLst);
  639. return $this->meth_PlugIn_Install($PlugInId,$ArgLst,false);
  640. }
  641. case TBS_ISINSTALLED:
  642. // Check if the plug-in is installed
  643. return isset($this->_PlugIns[$Prm2]);
  644. case -4: // Deactivate special plug-ins
  645. $this->_PlugIns_Ok_save = $this->_PlugIns_Ok;
  646. $this->_PlugIns_Ok = false;
  647. return true;
  648. case -5: // Deactivate OnFormat
  649. $this->_piOnFrm_Ok_save = $this->_piOnFrm_Ok;
  650. $this->_piOnFrm_Ok = false;
  651. return true;
  652. case -10: // Restore
  653. $this->_PlugIns_Ok = $this->_PlugIns_Ok_save;
  654. $this->_piOnFrm_Ok = $this->_piOnFrm_Ok_save;
  655. return true;
  656. }
  657. } elseif (is_string($Prm1)) {
  658. // Plug-in's command
  659. $PlugInId = $Prm1;
  660. if (!isset($this->_PlugIns[$PlugInId])) {
  661. if (!$this->meth_PlugIn_Install($PlugInId,array(),true)) return false;
  662. }
  663. 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.');
  664. $ArgLst = func_get_args();
  665. array_shift($ArgLst);
  666. $Ok = call_user_func_array($this->_piOnCommand[$PlugInId],$ArgLst);
  667. if (is_null($Ok)) $Ok = true;
  668. return $Ok;
  669. }
  670. return $this->meth_Misc_Alert('with PlugIn() method','\''.$Prm1.'\' is an invalid plug-in key, the type of the value is \''.gettype($Prm1).'\'.');
  671. }
  672. // *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
  673. function meth_Locator_FindTbs(&$Txt,$Name,$Pos,$ChrSub) {
  674. // Find a TBS Locator
  675. $PosEnd = false;
  676. $PosMax = strlen($Txt) -1;
  677. $Start = $this->_ChrOpen.$Name;
  678. do {
  679. // Search for the opening char
  680. if ($Pos>$PosMax) return false;
  681. $Pos = strpos($Txt,$Start,$Pos);
  682. // If found => next chars are analyzed
  683. if ($Pos===false) {
  684. return false;
  685. } else {
  686. $Loc =& new clsTbsLocator;
  687. $ReadPrm = false;
  688. $PosX = $Pos + strlen($Start);
  689. $x = $Txt[$PosX];
  690. if ($x===$this->_ChrClose) {
  691. $PosEnd = $PosX;
  692. } elseif ($x===$ChrSub) {
  693. $Loc->SubOk = true; // it is no longer the false value
  694. $ReadPrm = true;
  695. $PosX++;
  696. } elseif (strpos(';',$x)!==false) {
  697. $ReadPrm = true;
  698. $PosX++;
  699. } else {
  700. $Pos++;
  701. }
  702. if ($ReadPrm) {
  703. $this->f_Loc_PrmRead($Txt,$PosX,false,'\'',$this->_ChrOpen,$this->_ChrClose,$Loc,$PosEnd);
  704. if ($PosEnd===false) {
  705. $this->meth_Misc_Alert('','can\'t found the end of the tag \''.substr($Txt,$Pos,$PosX-$Pos+10).'...\'.');
  706. $Pos++;
  707. }
  708. }
  709. }
  710. } while ($PosEnd===false);
  711. $Loc->PosBeg = $Pos;
  712. $Loc->PosEnd = $PosEnd;
  713. if ($Loc->SubOk) {
  714. $Loc->FullName = $Name.'.'.$Loc->SubName;
  715. $Loc->SubLst = explode('.',$Loc->SubName);
  716. $Loc->SubNbr = count($Loc->SubLst);
  717. } else {
  718. $Loc->FullName = $Name;
  719. }
  720. if ($ReadPrm and isset($Loc->PrmLst['comm'])) {
  721. $Loc->PosBeg0 = $Loc->PosBeg;
  722. $Loc->PosEnd0 = $Loc->PosEnd;
  723. $comm = $Loc->PrmLst['comm'];
  724. if (($comm===true) or ($comm==='')) {
  725. $Loc->Enlarged = $this->f_Loc_EnlargeToStr($Txt,$Loc,'<!--' ,'-->');
  726. } else {
  727. $Loc->Enlarged = $this->f_Loc_EnlargeToTag($Txt,$Loc,$comm,false);
  728. }
  729. }
  730. return $Loc;
  731. }
  732. function &meth_Locator_SectionNewBDef(&$LocR,$BlockName,$Txt,$PrmLst) {
  733. $Chk = true;
  734. $LocLst = array();
  735. $LocNbr = 0;
  736. // Cache TBS locators
  737. if ($this->TurboBlock) {
  738. $Chk = false;
  739. $Pos = 0;
  740. $PrevEnd = -1;
  741. while ($Loc = $this->meth_Locator_FindTbs($Txt,$BlockName,$Pos,'.')) {
  742. if (($Loc->SubName==='#') or ($Loc->SubName==='$')) {
  743. $Loc->IsRecInfo = true;
  744. $Loc->RecInfo = $Loc->SubName;
  745. $Loc->SubName = '';
  746. } else {
  747. $Loc->IsRecInfo = false;
  748. }
  749. if ($Loc->PosBeg>$PrevEnd) {
  750. // The previous tag is not embeding => increment
  751. $LocNbr++;
  752. } else {
  753. // The previous tag is embeding => no increment, then previous is over writed
  754. $Chk = true;
  755. }
  756. $PrevEnd = $Loc->PosEnd;
  757. if ($Loc->Enlarged) { // Parameter 'comm'
  758. $Pos = $Loc->PosBeg0+1;
  759. $Loc->Enlarged = false;
  760. } else {
  761. $Pos = $Loc->PosBeg+1;
  762. }
  763. $LocLst[$LocNbr] = $Loc;
  764. }
  765. }
  766. // Create the object
  767. $o = (object) null;
  768. $o->Prm = $PrmLst;
  769. $o->LocLst = $LocLst;
  770. $o->LocNbr = $LocNbr;
  771. $o->Name = $BlockName;
  772. $o->Src = $Txt;
  773. $o->Chk = $Chk;
  774. $o->IsSerial = false;
  775. $LocR->BDefLst[] =& $o; // Can be usefull for plug-in
  776. return $o;
  777. }
  778. function meth_Locator_SectionAddGrp(&$LocR,$BlockName,&$BDef,$Type,$Field,$Prm) {
  779. $BDef->PrevValue = false;
  780. $BDef->Type = $Type;
  781. // Save sub items in a structure near to Locator.
  782. $Field0 = $Field;
  783. if (strpos($Field,$this->_ChrOpen)===false) $Field = $this->_ChrOpen.$BlockName.'.'.$Field.$this->_ChrClose;
  784. $BDef->FDef =& $this->meth_Locator_SectionNewBDef($LocR,$BlockName,$Field,array());
  785. if ($BDef->FDef->LocNbr==0) $this->meth_Misc_Alert('Parameter '.$Prm,'The value \''.$Field0.'\' is unvalide for this parameter.');
  786. if ($Type==='H') {
  787. if ($LocR->HeaderFound===false) {
  788. $LocR->HeaderFound = true;
  789. $LocR->HeaderNbr = 0;
  790. $LocR->HeaderDef = array(); // 1 to HeaderNbr
  791. }
  792. $i = ++$LocR->HeaderNbr;
  793. $LocR->HeaderDef[$i] =& $BDef;
  794. } else {
  795. if ($LocR->FooterFound===false) {
  796. $LocR->FooterFound = true;
  797. $LocR->FooterNbr = 0;
  798. $LocR->FooterDef = array(); // 1 to FooterNbr
  799. }
  800. $BDef->AddLastGrp = ($Type==='F');
  801. $i = ++$LocR->FooterNbr;
  802. $LocR->FooterDef[$i] =& $BDef;
  803. }
  804. }
  805. function meth_Locator_Replace(&$Txt,&$Loc,&$Value,$SubStart) {
  806. // This function enables to merge a locator with a text and returns the position just after the replaced block
  807. // This position can be useful because we don't know in advance how $Value will be replaced.
  808. // Found the value if there is a subname
  809. if (($SubStart!==false) and $Loc->SubOk) {
  810. for ($i=$SubStart;$i<$Loc->SubNbr;$i++) {
  811. $x = $Loc->SubLst[$i]; // &$Loc... brings an error with Event Example, I don't know why.
  812. if (is_array($Value)) {
  813. if (isset($Value[$x])) {
  814. $Value =& $Value[$x];
  815. } elseif (array_key_exists($x,$Value)) {// can happens when value is NULL
  816. $Value =& $Value[$x];
  817. } else {
  818. if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert($Loc,'item \''.$x.'\' is not an existing key in the array.',true);
  819. unset($Value); $Value = ''; break;
  820. }
  821. } elseif (is_object($Value)) {
  822. $ArgLst = $this->f_Misc_CheckArgLst($x);
  823. if (method_exists($Value,$x)) {
  824. $x = call_user_func_array(array(&$Value,$x),$ArgLst);
  825. } elseif (property_exists($Value,$x)) {
  826. $x =& $Value->$x;
  827. } else {
  828. 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);
  829. unset($Value); $Value = ''; break;
  830. }
  831. $Value =& $x; unset($x); $x = '';
  832. } else {
  833. 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);
  834. unset($Value); $Value = ''; break;
  835. }
  836. }
  837. }
  838. $CurrVal = $Value; // Unlink
  839. if (isset($Loc->PrmLst['onformat'])) {
  840. if ($Loc->FirstMerge) {
  841. $Loc->OnFrmInfo = $Loc->PrmLst['onformat'];
  842. $Loc->OnFrmArg = array(&$Loc->FullName,'',&$Loc->PrmLst,&$this);
  843. $ErrMsg = false;
  844. if (!$this->meth_Misc_UserFctCheck($Loc->OnFrmInfo,'f',$ErrMsg,$ErrMsg)) {
  845. unset($Loc->PrmLst['onformat']);
  846. if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert($Loc,'(parameter onformat) '.$ErrMsg);
  847. $Loc->OnFrmInfo = 'pi'; // Execute the function pi() just to avoid extra error messages
  848. }
  849. }
  850. $Loc->OnFrmArg[1] =& $CurrVal;
  851. if (isset($Loc->PrmLst['subtpl'])) {
  852. $this->meth_Misc_ChangeMode(true,$Loc,$CurrVal);
  853. call_user_func_array($Loc->OnFrmInfo,$Loc->OnFrmArg);
  854. $this->meth_Misc_ChangeMode(false,$Loc,$CurrVal);
  855. $Loc->ConvProtect = false;
  856. $Loc->ConvHtml = false;
  857. } else {
  858. call_user_func_array($Loc->OnFrmInfo,$Loc->OnFrmArg);
  859. }
  860. }
  861. if ($Loc->FirstMerge) {
  862. if (isset($Loc->PrmLst['frm'])) {
  863. $Loc->ConvMode = 0; // Frm
  864. $Loc->ConvProtect = false;
  865. } else {
  866. // Analyze parameter 'htmlconv'
  867. if (isset($Loc->PrmLst['htmlconv'])) {
  868. $x = strtolower($Loc->PrmLst['htmlconv']);
  869. $x = '+'.str_replace(' ','',$x).'+';
  870. if (strpos($x,'+esc+')!==false) {$this->f_Misc_ConvSpe($Loc); $Loc->ConvHtml = false; $Loc->ConvEsc = true; }
  871. if (strpos($x,'+wsp+')!==false) {$this->f_Misc_ConvSpe($Loc); $Loc->ConvWS = true; }
  872. if (strpos($x,'+js+')!==false) {$this->f_Misc_ConvSpe($Loc); $Loc->ConvHtml = false; $Loc->ConvJS = true; }
  873. if (strpos($x,'+no+')!==false) $Loc->ConvHtml = false;
  874. if (strpos($x,'+yes+')!==false) $Loc->ConvHtml = true;
  875. if (strpos($x,'+nobr+')!==false) {$Loc->ConvHtml = true; $Loc->ConvBr = false; }
  876. } else {
  877. if ($this->HtmlCharSet===false) $Loc->ConvHtml = false; // No HTML
  878. }
  879. // Analyze parameter 'protect'
  880. if (isset($Loc->PrmLst['protect'])) {
  881. $x = strtolower($Loc->PrmLst['protect']);
  882. if ($x==='no') {
  883. $Loc->ConvProtect = false;
  884. } elseif ($x==='yes') {
  885. $Loc->ConvProtect = true;
  886. }
  887. } elseif ($this->Protect===false) {
  888. $Loc->ConvProtect = false;
  889. }
  890. }
  891. if ($Loc->Ope = isset($Loc->PrmLst['ope'])) {
  892. $OpeLst = explode(',',$Loc->PrmLst['ope']);
  893. $Loc->OpeAct = array();
  894. $Loc->OpeArg = array();
  895. foreach ($OpeLst as $i=>$ope) {
  896. if ($ope==='list') {
  897. $Loc->OpeAct[$i] = 1;
  898. $Loc->OpePrm[$i] = (isset($Loc->PrmLst['valsep'])) ? $Loc->PrmLst['valsep'] : ',';
  899. } elseif ($ope==='minv') {
  900. $Loc->OpeAct[$i] = 8;
  901. $Loc->MInv = true;
  902. } else {
  903. $x = substr($ope,0,4);
  904. if ($x==='max:') {
  905. $Loc->OpeAct[$i] = (isset($Loc->PrmLst['maxhtml'])) ? 2 : 3;
  906. $Loc->OpePrm[$i] = intval(trim(substr($ope,4)));
  907. $Loc->OpeEnd = (isset($Loc->PrmLst['maxend'])) ? $Loc->PrmLst['maxend'] : '...';
  908. if ($Loc->OpePrm[$i]<=0) $Loc->Ope = false;
  909. } elseif ($x==='mod:') {$Loc->OpeAct[$i] = 4; $Loc->OpePrm[$i] = '0'+trim(substr($ope,4));
  910. } elseif ($x==='add:') {$Loc->OpeAct[$i] = 5; $Loc->OpePrm[$i] = '0'+trim(substr($ope,4));
  911. } elseif ($x==='mul:') {$Loc->OpeAct[$i] = 6; $Loc->OpePrm[$i] = '0'+trim(substr($ope,4));
  912. } elseif ($x==='div:') {$Loc->OpeAct[$i] = 7; $Loc->OpePrm[$i] = '0'+trim(substr($ope,4));
  913. } elseif ($x==='nif:') {$Loc->OpeAct[$i] = 9; $Loc->OpePrm[$i] = trim(substr($ope,4));
  914. } elseif (isset($this->_piOnOperation)) {
  915. $Loc->OpeAct[$i] = 0;
  916. $Loc->OpePrm[$i] = $ope;
  917. $Loc->OpeArg[$i] = array(&$Loc->FullName,&$CurrVal,&$Loc->PrmLst,&$Txt,$Loc->PosBeg,$Loc->PosEnd,&$Loc);
  918. $Loc->PrmLst['_ope'] = $Loc->PrmLst['ope'];
  919. } elseif (!isset($Loc->PrmLst['noerr'])) {
  920. $this->meth_Misc_Alert($Loc,'parameter ope doesn\'t support value \''.$ope.'\'.',true);
  921. }
  922. }
  923. }
  924. }
  925. $Loc->FirstMerge = false;
  926. }
  927. $ConvProtect = $Loc->ConvProtect;
  928. // Plug-in OnFormat
  929. if ($this->_piOnFrm_Ok) {
  930. if (isset($Loc->OnFrmArgPi)) {
  931. $Loc->OnFrmArgPi[1] =& $CurrVal;
  932. } else {
  933. $Loc->OnFrmArgPi = array(&$Loc->FullName,&$CurrVal,&$Loc->PrmLst,&$this);
  934. }
  935. $this->meth_PlugIn_RunAll($this->_piOnFormat,$Loc->OnFrmArgPi);
  936. }
  937. // Operation
  938. if ($Loc->Ope) {
  939. foreach ($Loc->OpeAct as $i=>$ope) {
  940. switch ($ope) {
  941. case 0:
  942. $Loc->PrmLst['ope'] = $Loc->OpePrm[$i]; // for compatibility
  943. $OpeArg =& $Loc->OpeArg[$i];
  944. $OpeArg[1] =& $CurrVal; $OpeArg[3] =& $Txt;
  945. if (!$this->meth_PlugIn_RunAll($this->_piOnOperation,$OpeArg)) return $Loc->PosBeg;
  946. break;
  947. case 1: if (is_array($CurrVal)) $CurrVal = implode($Loc->OpePrm[$i],$CurrVal); break;
  948. case 2: if (strlen(''.$CurrVal)>$Loc->OpePrm[$i]) $this->f_Xml_Max($CurrVal,$Loc->OpePrm[$i],$Loc->OpeEnd); break;
  949. case 3: if (strlen(''.$CurrVal)>$Loc->OpePrm[$i]) $CurrVal = substr(''.$CurrVal,0,$Loc->OpePrm[$i]).$Loc->OpeEnd; break;
  950. case 4: $CurrVal = ('0'+$CurrVal) % $Loc->OpePrm[$i]; break;
  951. case 5: $CurrVal = ('0'+$CurrVal) + $Loc->OpePrm[$i]; break;
  952. case 6: $CurrVal = ('0'+$CurrVal) * $Loc->OpePrm[$i]; break;
  953. case 7: $CurrVal = ('0'+$CurrVal) / $Loc->OpePrm[$i]; break;
  954. case 8: $Loc->MInvOk = ($CurrVal!==''); $CurrVal = ''; break;
  955. case 9: if ($CurrVal===$Loc->OpePrm[$i]) $CurrVal = ''; break;
  956. }
  957. }
  958. }
  959. // HTML conversion or format
  960. if ($Loc->ConvMode===1) { // Html simple
  961. if (!is_string($CurrVal)) $CurrVal = @strval($CurrVal);
  962. if ($Loc->ConvHtml) $this->meth_Conv_Html($CurrVal,$Loc->ConvBr);
  963. } elseif ($Loc->ConvMode===0) { // Format
  964. $CurrVal = $this->meth_Misc_Format($CurrVal,$Loc->PrmLst);
  965. } elseif ($Loc->ConvMode===2) { // Html special
  966. if (!is_string($CurrVal)) $CurrVal = @strval($CurrVal);
  967. if ($Loc->ConvHtml) $this->meth_Conv_Html($CurrVal,$Loc->ConvBr);
  968. if ($Loc->ConvEsc) $CurrVal = str_replace('\'','\'\'',$CurrVal);
  969. if ($Loc->ConvWS) {
  970. $check = ' ';
  971. $nbsp = '&nbsp;';
  972. do {
  973. $pos = strpos($CurrVal,$check);
  974. if ($pos!==false) $CurrVal = substr_replace($CurrVal,$nbsp,$pos,1);
  975. } while ($pos!==false);
  976. }
  977. if ($Loc->ConvJS) {
  978. $CurrVal = addslashes($CurrVal); // apply to ('), ("), (\) and (null)
  979. $CurrVal = str_replace("\n",'\n',$CurrVal);
  980. $CurrVal = str_replace("\r",'\r',$CurrVal);
  981. $CurrVal = str_replace("\t",'\t',$CurrVal);
  982. }
  983. }
  984. // if/then/else process, there may be several if/then
  985. if ($Loc->PrmIfNbr) {
  986. $z = false;
  987. $i = 1;
  988. while ($i!==false) {
  989. if ($Loc->PrmIfVar[$i]) $Loc->PrmIfVar[$i] = $this->meth_Merge_AutoVar($Loc->PrmIf[$i],true);
  990. $x = str_replace($this->_ChrVal,$CurrVal,$Loc->PrmIf[$i]);
  991. if ($this->f_Misc_CheckCondition($x)) {
  992. if (isset($Loc->PrmThen[$i])) {
  993. if ($Loc->PrmThenVar[$i]) $Loc->PrmThenVar[$i] = $this->meth_Merge_AutoVar($Loc->PrmThen[$i],true);
  994. $z = $Loc->PrmThen[$i];
  995. }
  996. $i = false;
  997. } else {
  998. $i++;
  999. if ($i>$Loc->PrmIfNbr) {
  1000. if (isset($Loc->PrmLst['else'])) {
  1001. if ($Loc->PrmElseVar) $Loc->PrmElseVar = $this->meth_Merge_AutoVar($Loc->PrmLst['else'],true);
  1002. $z =$Loc->PrmLst['else'];
  1003. }
  1004. $i = false;
  1005. }
  1006. }
  1007. }
  1008. if ($z!==false) {
  1009. if ($ConvProtect) {
  1010. $CurrVal = str_replace($this->_ChrOpen,$this->_ChrProtect,$CurrVal); // TBS protection
  1011. $ConvProtect = false;
  1012. }
  1013. $CurrVal = str_replace($this->_ChrVal,$CurrVal,$z);
  1014. }
  1015. }
  1016. if (isset($Loc->PrmLst['file'])) {
  1017. $x = $Loc->PrmLst['file'];
  1018. if ($x===true) $x = $CurrVal;
  1019. $this->meth_Merge_AutoVar($x,false);
  1020. $x = trim(str_replace($this->_ChrVal,$CurrVal,$x));
  1021. $CurrVal = '';
  1022. if ($x!=='') {
  1023. if ($this->f_Misc_GetFile($CurrVal,$x,$this->_LastFile)) {
  1024. if (isset($Loc->PrmLst['getbody'])) $CurrVal = $this->f_Xml_GetPart($CurrVal,$Loc->PrmLst['getbody'],false,true);
  1025. } else {
  1026. if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert($Loc,'the file \''.$x.'\' given by parameter file is not found or not readable.',true);
  1027. }
  1028. $ConvProtect = false;
  1029. }
  1030. }
  1031. if (isset($Loc->PrmLst['script'])) {// Include external PHP script
  1032. $x = $Loc->PrmLst['script'];
  1033. if ($x===true) $x = $CurrVal;
  1034. $this->meth_Merge_AutoVar($x,false);
  1035. $x = trim(str_replace($this->_ChrVal,$CurrVal,$x));
  1036. if ($x!=='') {
  1037. $this->_Subscript = $x;
  1038. $this->CurrPrm =& $Loc->PrmLst;
  1039. $sub = isset($Loc->PrmLst['subtpl']);
  1040. if ($sub) $this->meth_Misc_ChangeMode(true,$Loc,$CurrVal);
  1041. if ($this->meth_Misc_RunSubscript($CurrVal,$Loc->PrmLst)===false) {
  1042. if (!isset($Loc->PrmLst['noerr'])) $this->meth_Misc_Alert($Loc,'the file \''.$x.'\' given by parameter script is not found or not readable.',true);
  1043. }
  1044. if ($sub) $this->meth_Misc_ChangeMode(false,$Loc,$CurrVal);
  1045. if (isset($Loc->PrmLst['getbody'])) $CurrVal = $this->f_Xml_GetPart($CurrVal,$Loc->PrmLst['getbody'],false,true);
  1046. unset($this->CurrPrm);
  1047. $ConvProtect = false;
  1048. }
  1049. }
  1050. // Case when it's an empty string
  1051. if ($CurrVal==='') {
  1052. if ($Loc->MagnetId===false) {
  1053. if (isset($Loc->PrmLst['.'])) {
  1054. $Loc->MagnetId = -1;
  1055. } elseif (isset($Loc->PrmLst['ifempty'])) {
  1056. $Loc->MagnetId = -2;
  1057. } elseif (isset($Loc->PrmLst['magnet'])) {
  1058. $Loc->MagnetId = 1;
  1059. $Loc->PosBeg0 = $Loc->PosBeg;
  1060. $Loc->PosEnd0 = $Loc->PosEnd;
  1061. if (isset($Loc->PrmLst['mtype'])) {
  1062. switch ($Loc->PrmLst['mtype']) {
  1063. case 'm+m': $Loc->MagnetId = 2; break;
  1064. case 'm*': $Loc->MagnetId = 3; break;
  1065. case '*m': $Loc->MagnetId = 4; break;
  1066. }
  1067. }
  1068. } else {
  1069. $Loc->MagnetId = 0;
  1070. }
  1071. if (isset($Loc->MInv)) {
  1072. $Loc->MInv = $Loc->MagnetId;
  1073. $Loc->MagnetId = 5;
  1074. }
  1075. }
  1076. switch ($Loc->MagnetId) {
  1077. case 0: break;
  1078. case -1: $CurrVal = '&nbsp;'; break; // Enables to avoid blanks in HTML tables
  1079. case -2: $CurrVal = $Loc->PrmLst['ifempty']; break;
  1080. case 5: if ($Loc->MInvOk) break;
  1081. case 1:
  1082. $Loc->Enlarged = true;
  1083. $this->f_Loc_EnlargeToTag($Txt,$Loc,$Loc->PrmLst['magnet'],false);
  1084. break;
  1085. case 2:
  1086. $Loc->Enlarged = true;
  1087. $CurrVal = $this->f_Loc_EnlargeToTag($Txt,$Loc,$Loc->PrmLst['magnet'],true);
  1088. break;
  1089. case 3:
  1090. $Loc->Enlarged = true;
  1091. $Loc2 = $this->f_Xml_FindTag($Txt,$Loc->PrmLst['magnet'],true,$Loc->PosBeg,false,1,false);
  1092. if ($Loc2!==false) {
  1093. $Loc->PosBeg = $Loc2->PosBeg;
  1094. if ($Loc->PosEnd<$Loc2->PosEnd) $Loc->PosEnd = $Loc2->PosEnd;
  1095. }
  1096. break;
  1097. case 4:
  1098. $Loc->Enlarged = true;
  1099. $Loc2 = $this->f_Xml_FindTag($Txt,$Loc->PrmLst['magnet'],true,$Loc->PosBeg,true,1,false);
  1100. if ($Loc2!==false) $Loc->PosEnd = $Loc2->PosEnd;
  1101. break;
  1102. }
  1103. $NewEnd = $Loc->PosBeg; // Useful when mtype='m+m'
  1104. } else {
  1105. if ($ConvProtect) $CurrVal = str_replace($this->_ChrOpen,$this->_ChrProtect,$CurrVal); // TBS protection
  1106. $NewEnd = $Loc->PosBeg + strlen($CurrVal);
  1107. }
  1108. $Txt = substr_replace($Txt,$CurrVal,$Loc->PosBeg,$Loc->PosEnd-$Loc->PosBeg+1);
  1109. return $NewEnd; // Return the new end position of the field
  1110. }
  1111. function meth_Locator_FindBlockNext(&$Txt,$BlockName,$PosBeg,$ChrSub,$Mode,&$P1,&$FieldBefore) {
  1112. // Return the first block locator just after the PosBeg position
  1113. // Mode = 1 : Merge_Auto => doesn't save $Loc->BlockSrc, save the bounds of TBS Def tags instead, return also fields
  1114. // Mode = 2 : FindBlockLst or GetBlockSource => save $Loc->BlockSrc without TBS Def tags
  1115. // Mode = 3 : GetBlockSource => save $Loc->BlockSrc with TBS Def tags
  1116. $SearchDef = true;
  1117. $FirstField = false;
  1118. // Search for the first tag with parameter "block"
  1119. while ($SearchDef and ($Loc = $this->meth_Locator_FindTbs($Txt,$BlockName,$PosBeg,$ChrSub))) {
  1120. if (isset($Loc->PrmLst['block'])) {
  1121. if ($P1) {
  1122. if (isset($Loc->PrmLst['p1'])) return false;
  1123. } else {
  1124. if (isset($Loc->PrmLst['p1'])) $P1 = true;
  1125. }
  1126. $Block = $Loc->PrmLst['block'];
  1127. $SearchDef = false;
  1128. } elseif ($Mode===1) {
  1129. return $Loc;
  1130. } elseif ($FirstField===false) {
  1131. $FirstField = $Loc;
  1132. }
  1133. $PosBeg = $Loc->PosEnd;
  1134. }
  1135. if ($SearchDef) {
  1136. if ($FirstField!==false) $FieldBefore = true;
  1137. return false;
  1138. }
  1139. $Loc->PosDefBeg = -1;
  1140. if ($Block==='begin') { // Block definied using begin/end
  1141. if (($FirstField!==false) and ($FirstField->PosEnd<$Loc->PosBeg)) $FieldBefore = true;
  1142. $Opened = 1;
  1143. while ($Loc2 = $this->meth_Locator_FindTbs($Txt,$BlockName,$PosBeg,$ChrSub)) {
  1144. if (isset($Loc2->PrmLst['block'])) {
  1145. switch ($Loc2->PrmLst['block']) {
  1146. case 'end': $Opened--; break;
  1147. case 'begin': $Opened++; break;
  1148. }
  1149. if ($Opened==0) {
  1150. if ($Mode===1) {
  1151. $Loc->PosBeg2 = $Loc2->PosBeg;
  1152. $Loc->PosEnd2 = $Loc2->PosEnd;
  1153. } else {
  1154. if ($Mode===2) {
  1155. $Loc->BlockSrc = substr($Txt,$Loc->PosEnd+1,$Loc2->PosBeg-$Loc->PosEnd-1);
  1156. } else {
  1157. $Loc->BlockSrc = substr($Txt,$Loc->PosBeg,$Loc2->PosEnd-$Loc->PosBeg+1);
  1158. }
  1159. $Loc->PosEnd = $Loc2->PosEnd;
  1160. }
  1161. $Loc->BlockFound = true;
  1162. return $Loc;
  1163. }
  1164. }
  1165. $PosBeg = $Loc2->PosEnd;
  1166. }
  1167. return $this->meth_Misc_Alert($Loc,'a least one tag with parameter \'block=end\' is missing.',false,'in block\'s definition');
  1168. }
  1169. if ($Mode===1) {
  1170. $Loc->PosBeg2 = false;
  1171. } else {
  1172. $beg = $Loc->PosBeg;
  1173. $end = $Loc->PosEnd;
  1174. if ($this->f_Loc_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 opening tags, closing tags and embedding levels.',false,'in block\'s definition');
  1175. if ($Loc->SubOk or ($Mode===3)) {
  1176. $Loc->BlockSrc = substr($Txt,$Loc->PosBeg,$Loc->PosEnd-$Loc->PosBeg+1);
  1177. $Loc->PosDefBeg = $beg - $Loc->PosBeg;
  1178. $Loc->PosDefEnd = $end - $Loc->PosBeg;
  1179. } else {
  1180. $Loc->BlockSrc = substr($Txt,$Loc->PosBeg,$beg-$Loc->PosBeg).substr($Txt,$end+1,$Loc->PosEnd-$end);
  1181. }
  1182. }
  1183. $Loc->BlockFound = true;
  1184. if (($FirstField!==false) and ($FirstField->PosEnd<$Loc->PosBeg)) $FieldBefore = true;
  1185. return $Loc; // methods return by ref by default
  1186. }
  1187. function meth_Locator_FindBlockLst(&$Txt,$BlockName,$Pos,$SpePrm) {
  1188. // Return a locator object covering all block definitions, even if there is no block definition found.
  1189. $LocR =& new clsTbsLocator;
  1190. $LocR->P1 = false;
  1191. $LocR->FieldOutside = false;
  1192. $LocR->BDefLst = array();
  1193. $LocR->NoData = false;
  1194. $LocR->Special = false;
  1195. $LocR->HeaderFound = false;
  1196. $LocR->FooterFound = false;
  1197. $LocR->SerialEmpty = false;
  1198. $LocR->GrpBreak = false; // Only for plug-ins
  1199. $LocR->WhenFound = false;
  1200. $LocR->WhenDefault = false;
  1201. $LocR->SectionNbr = 0; // Normal sections
  1202. $LocR->SectionLst = array(); // 1 to SectionNbr
  1203. $BDef = false;
  1204. $ParentLst = array();
  1205. $Pid = 0;
  1206. do {
  1207. if ($BlockName==='') {
  1208. $Loc = false;
  1209. } else {
  1210. $Loc = $this->meth_Locator_FindBlockNext($Txt,$BlockName,$Pos,'.',2,$LocR->P1,$LocR->FieldOutside);
  1211. }
  1212. if ($Loc===false) {
  1213. if ($Pid>0) { // parentgrp mode => disconnect $Txt from the source
  1214. $Parent =& $ParentLst[$Pid];
  1215. $Src = $Txt;
  1216. $Txt =& $Parent->Txt;
  1217. if ($LocR->BlockFound) {
  1218. // Redefine the Header block
  1219. $Parent->Src = substr($Src,0,$LocR->PosBeg);
  1220. // Add a Footer block
  1221. $BDef =& $this->meth_Locator_SectionNewBDef($LocR,$BlockName,substr($Src,$LocR->PosEnd+1),$Parent->Prm);
  1222. $this->meth_Locator_SectionAddGrp($LocR,$BlockName,$BDef,'F',$Parent->Fld,'parentgrp');
  1223. }
  1224. // Now go down to previous level
  1225. $Pos = $Parent->Pos;
  1226. $LocR->PosBeg = $Parent->Beg;
  1227. $LocR->PosEnd = $Parent->End;
  1228. $LocR->BlockFound = true;
  1229. unset($Parent);
  1230. unset($ParentLst[$Pid]);
  1231. $Pid--;
  1232. $Loc = true;
  1233. }
  1234. } else {
  1235. $Pos = $Loc->PosEnd;
  1236. // Define the block limits
  1237. if ($LocR->BlockFound) {
  1238. if ( $LocR->PosBeg > $Loc->PosBeg ) $LocR->PosBeg = $Loc->PosBeg;
  1239. if ( $LocR->PosEnd < $Loc->PosEnd ) $LocR->PosEnd = $Loc->PosEnd;
  1240. } else {
  1241. $LocR->BlockFound = true;
  1242. $LocR->PosBeg = $Loc->PosBeg;
  1243. $LocR->PosEnd = $Loc->PosEnd;
  1244. }
  1245. // Merge block parameters
  1246. if (count($Loc->PrmLst)>0) $LocR->PrmLst = array_merge($LocR->PrmLst,$Loc->PrmLst);
  1247. // Force dynamic parameter to be cachable
  1248. if ($Loc->PosDefBeg>=0) {
  1249. $dynprm = array('when','headergrp','footergrp','parentgrp');
  1250. foreach($dynprm as $dp) {
  1251. $n = 0;
  1252. if ((isset($Loc->PrmLst[$dp])) and (strpos($Loc->PrmLst[$dp],$this->_ChrOpen.$BlockName)!==false)) {
  1253. $n++;
  1254. if ($n==1) {
  1255. $len = $Loc->PosDefEnd - $Loc->PosDefBeg + 1;
  1256. $x = substr($Loc->BlockSrc,$Loc->PosDefBeg,$len);
  1257. }
  1258. $x = str_replace($Loc->PrmLst[$dp],'',$x);
  1259. }
  1260. if ($n>0) $Loc->BlockSrc = substr_replace($Loc->BlockSrc,$x,$Loc->PosDefBeg,$len);
  1261. }
  1262. }
  1263. // Save the block and cache its tags
  1264. $BDef =& $this->meth_Locator_SectionNewBDef($LocR,$BlockName,$Loc->BlockSrc,$Loc->PrmLst);
  1265. // Add the text in the list of blocks
  1266. if (isset($Loc->PrmLst['nodata'])) { // Nodata section
  1267. $LocR->NoData =& $BDef;
  1268. } elseif (($SpePrm!==false) and isset($Loc->PrmLst[$SpePrm])) { // Special section (used for navigation bar)
  1269. $LocR->Special =& $BDef;
  1270. } elseif (isset($Loc->PrmLst['when'])) {
  1271. if ($LocR->WhenFound===false) {
  1272. $LocR->WhenFound = true;
  1273. $LocR->WhenSeveral = false;
  1274. $LocR->WhenNbr = 0;
  1275. $LocR->WhenLst = array();
  1276. }
  1277. $this->meth_Merge_AutoVar($Loc->PrmLst['when'],false);
  1278. $BDef->WhenCond =& $this->meth_Locator_SectionNewBDef($LocR,$BlockName,$Loc->PrmLst['when'],array());
  1279. $BDef->WhenBeforeNS = ($LocR->SectionNbr===0);
  1280. $i = ++$LocR->WhenNbr;
  1281. $LocR->WhenLst[$i] =& $BDef;
  1282. if (isset($Loc->PrmLst['several'])) $LocR->WhenSeveral = true;
  1283. } elseif (isset($Loc->PrmLst['default'])) {
  1284. $LocR->WhenDefault =& $BDef;
  1285. $LocR->WhenDefaultBeforeNS = ($LocR->SectionNbr===0);
  1286. } elseif (isset($Loc->PrmLst['headergrp'])) {
  1287. $this->meth_Locator_SectionAddGrp($LocR,$BlockName,$BDef,'H',$Loc->PrmLst['headergrp'],'headergrp');
  1288. } elseif (isset($Loc->PrmLst['footergrp'])) {
  1289. $this->meth_Locator_SectionAddGrp($LocR,$BlockName,$BDef,'F',$Loc->PrmLst['footergrp'],'footergrp');
  1290. } elseif (isset($Loc->PrmLst['splittergrp'])) {
  1291. $this->meth_Locator_SectionAddGrp($LocR,$BlockName,$BDef,'S',$Loc->PrmLst['splittergrp'],'splittergrp');
  1292. } elseif (isset($Loc->PrmLst['parentgrp'])) {
  1293. $this->meth_Locator_SectionAddGrp($LocR,$BlockName,$BDef,'H',$Loc->PrmLst['parentgrp'],'parentgrp');
  1294. $BDef->Fld = $Loc->PrmLst['parentgrp'];
  1295. $BDef->Txt =& $Txt;
  1296. $BDef->Pos = $Pos;
  1297. $BDef->Beg = $LocR->PosBeg;
  1298. $BDef->End = $LocR->PosEnd;
  1299. $Pid++;
  1300. $ParentLst[$Pid] =& $BDef;
  1301. $Txt =& $BDef->Src;
  1302. $Pos = $Loc->PosDefBeg + 1;
  1303. $LocR->BlockFound = false;
  1304. $LocR->PosBeg = false;
  1305. $LocR->PosEnd = false;
  1306. } elseif (isset($Loc->PrmLst['serial'])) {
  1307. // Section with serial subsections
  1308. $SrSrc =& $BDef->Src;
  1309. // Search the empty item
  1310. if ($LocR->SerialEmpty===false) {
  1311. $SrName = $BlockName.'_0';
  1312. $x = false;
  1313. $SrLoc = $this->meth_Locator_FindBlockNext($SrSrc,$SrName,0,'.',2,$x,$x);
  1314. if ($SrLoc!==false) {
  1315. $LocR->SerialEmpty = $SrLoc->BlockSrc;
  1316. $SrSrc = substr_replace($SrSrc,'',$SrLoc->PosBeg,$SrLoc->PosEnd-$SrLoc->PosBeg+1);
  1317. }
  1318. }
  1319. $SrName = $BlockName.'_1';
  1320. $x = false;
  1321. $SrLoc = $this->meth_Locator_FindBlockNext($SrSrc,$SrName,0,'.',2,$x,$x);
  1322. if ($SrLoc!==false) {
  1323. $SrId = 1;
  1324. do {
  1325. // Save previous subsection
  1326. $SrBDef =& $this->meth_Locator_SectionNewBDef($LocR,$SrName,$SrLoc->BlockSrc,$SrLoc->PrmLst);
  1327. $SrBDef->SrBeg = $SrLoc->PosBeg;
  1328. $SrBDef->SrLen = $SrLoc->PosEnd - $SrLoc->PosBeg + 1;
  1329. $SrBDef->SrTxt = false;
  1330. $BDef->SrBDefLst[$SrId] =& $SrBDef;
  1331. // Put in order
  1332. $BDef->SrBDefOrdered[$SrId] =& $SrBDef;
  1333. $i = $SrId;
  1334. while (($i>1) and ($SrBDef->SrBeg<$BDef->SrBDefOrdered[$SrId-1]->SrBeg)) {
  1335. $BDef->SrBDefOrdered[$i] =& $BDef->SrBDefOrdered[$i-1];
  1336. $BDef->SrBDefOrdered[$i-1] =& $SrBDef;
  1337. $i--;
  1338. }
  1339. // Search next subsection
  1340. $SrId++;
  1341. $SrName = $BlockName.'_'.$SrId;
  1342. $x = false;
  1343. $SrLoc = $this->meth_Locator_FindBlockNext($SrSrc,$SrName,0,'.',2,$x,$x);
  1344. } while ($SrLoc!==false);
  1345. $BDef->SrBDefNbr = $SrId-1;
  1346. $BDef->IsSerial = true;
  1347. $i = ++$LocR->SectionNbr;
  1348. $LocR->SectionLst[$i] =& $BDef;
  1349. }
  1350. } else {
  1351. // Normal section
  1352. $i = ++$LocR->SectionNbr;
  1353. $LocR->SectionLst[$i] =& $BDef;
  1354. }
  1355. }
  1356. } while ($Loc!==false);
  1357. if ($LocR->WhenFound and ($LocR->SectionNbr===0)) {
  1358. // Add a blank section if When is used without a normal section
  1359. $BDef =& $this->meth_Locator_SectionNewBDef($LocR,$BlockName,'',array());
  1360. $LocR->SectionNbr = 1;
  1361. $LocR->SectionLst[1] =& $BDef;
  1362. }
  1363. return $LocR; // methods return by ref by default
  1364. }
  1365. function meth_Merge_Block(&$Txt,&$BlockLst,&$SrcId,&$Query,$SpePrm,$SpeRecNum) {
  1366. $BlockSave = $this->_CurrBlock;
  1367. $this->_CurrBlock = $BlockLst;
  1368. // Get source type and info
  1369. $Src =& new clsTbsDataSource;
  1370. if (!$Src->DataPrepare($SrcId,$this)) {
  1371. $this->_CurrBlock = $BlockSave;
  1372. return 0;
  1373. }
  1374. $BlockLst = explode(',',$BlockLst);
  1375. $BlockNbr = count($BlockLst);
  1376. $BlockId = 0;
  1377. $WasP1 = false;
  1378. $NbrRecTot = 0;
  1379. $QueryZ =& $Query;
  1380. $ReturnData = false;
  1381. while ($BlockId<$BlockNbr) {
  1382. $RecSpe = 0; // Row with a special block's definition (used for the navigation bar)
  1383. $QueryOk = true;
  1384. $this->_CurrBlock = trim($BlockLst[$BlockId]);
  1385. if ($this->_CurrBlock==='*') {
  1386. $ReturnData = true;
  1387. if ($Src->RecSaved===false) $Src->RecSaving = true;
  1388. $this->_CurrBlock = '';
  1389. }
  1390. // Search the block
  1391. $LocR = $this->meth_Locator_FindBlockLst($Txt,$this->_CurrBlock,0,$SpePrm);
  1392. if ($WasP1) $this->meth_Merge_FieldOutside($Txt,$Src,$LocR);
  1393. if ($LocR->BlockFound) {
  1394. if ($LocR->Special!==false) $RecSpe = $SpeRecNum;
  1395. // OnData
  1396. if ($Src->OnDataPrm = isset($LocR->PrmLst['ondata'])) {
  1397. $Src->OnDataPrmRef = $LocR->PrmLst['ondata'];
  1398. if (isset($Src->OnDataPrmDone[$Src->OnDataPrmRef])) {
  1399. $Src->OnDataPrm = false;
  1400. } else {
  1401. $ErrMsg = false;
  1402. if ($this->meth_Misc_UserFctCheck($Src->OnDataPrmRef,'f',$ErrMsg,$ErrMsg)) {
  1403. $Src->OnDataOk = true;
  1404. } else {
  1405. $LocR->FullName = $this->_CurrBlock;
  1406. $Src->OnDataPrm = $this->meth_Misc_Alert($LocR,'(parameter ondata) '.$ErrMsg,false,'block');
  1407. }
  1408. }
  1409. }
  1410. // Dynamic query
  1411. if ($LocR->

Large files files are truncated, but you can click here to view the full file