1
0

debug.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4.3.x (and higher), tested with 5.1.4 |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 2002-2006 Kelvin Jones, Claus van Beek, Stefan Deussen |
  7. // +----------------------------------------------------------------------+
  8. // | Authors: Kelvin Jones, Claus van Beek, Stefan Deussen |
  9. // +----------------------------------------------------------------------+
  10. //
  11. // $Id: debug.php 3041 2007-05-22 19:19:55Z b4rt $
  12. /**
  13. * Class uses all of vlibTemplate's functionality but debugs the template files.
  14. * Outputs a debug console to an html page, only use this for html files.
  15. *
  16. * NB: This class is not as well documented as the main vlibTemplate class as all
  17. * functions are private. This will be cleaned up in the future but it's quite
  18. * far down the priority list. It works, and right now, that's what counts.
  19. *
  20. * @author Kelvin Jones, Claus van Beek, Stefan Deussen
  21. * @since 21/01/2002
  22. * @package vLIB
  23. * @access public
  24. */
  25. class vlibTemplateDebug extends vlibTemplate {
  26. /*-----------------------------------------------------------------------------\
  27. | DO NOT TOUCH ANYTHING IN THIS CLASS IT MAY NOT WORK OTHERWISE |
  28. \-----------------------------------------------------------------------------*/
  29. var $VLIBTEMPLATE_DEBUGMOD = './vlibTemplate/vlibTemplate_debugmod.html';
  30. var $VLIBTEMPLATE_DEBUGWRAPPER = './vlibTemplate/vlibTemplate_debugmodwrapper.html';
  31. // 2006-08-12, SD: new option 'DEBUG_WITHOUT_JAVASCRIPT'
  32. var $VLIBTEMPLATE_DEBUGMOD_NO_JAVASCRIPT = './vlibTemplate/vlibTemplate_debugmod_no_javascript.html';
  33. var $VLIBTEMPLATE_DEBUGWRAPPER_NO_JAVASCRIPT = './vlibTemplate/vlibTemplate_debugmodwrapper_no_javascript.html';
  34. /**
  35. * boolean var prints out vlibTemplate debug module
  36. * @see $_tmplfilep
  37. */
  38. var $_debug = 1;
  39. var $_debugIncludedfiles = array();
  40. var $_debugTemplatevars = array();
  41. var $_debugalltags = array();
  42. var $_debugtags = array();
  43. var $_debugwarnings = array();
  44. var $_debugwarningmsgscontrol = array();
  45. var $_debugwarningmsgs = array();
  46. /**
  47. * Builds entire debug module window
  48. * prints it by default.
  49. *
  50. * @access private
  51. */
  52. function doDebug() {
  53. // 2006-08-12, SD: new option 'DEBUG_WITHOUT_JAVASCRIPT'
  54. if($this->OPTIONS['DEBUG_WITHOUT_JAVASCRIPT'])
  55. {
  56. $vLIBtmpl = new vlibTemplate ($this->VLIBTEMPLATE_DEBUGMOD_NO_JAVASCRIPT);
  57. }
  58. else
  59. {
  60. $vLIBtmpl = new vlibTemplate ($this->VLIBTEMPLATE_DEBUGMOD);
  61. }
  62. // set vars needed for JavaScript in popup window
  63. $filename_enc = md5($this->_tmplfilename);
  64. $vLIBtmpl->setvar('vLIB_template_name', $this->_tmplfilename);
  65. $vLIBtmpl->setvar('filename_enc', $filename_enc);
  66. // grab the vars and loops array
  67. ob_start();
  68. print_r($this->_arrvars);
  69. $vLIB_allarrvars = ob_get_contents();
  70. ob_end_clean();
  71. ob_start();
  72. print_r($this->_vars);
  73. $vLIB_allvars = ob_get_contents();
  74. ob_end_clean();
  75. $vLIBtmpl->setvar('vLIB_allarrvars', wordwrap($vLIB_allarrvars, 70, "\n", 1));
  76. $vLIBtmpl->setvar('vLIB_allvars', wordwrap($vLIB_allvars, 70, "\n", 1));
  77. $vLIBtmpl->setvar('vLIB_num_global_vars', (count($this->_vars)) ? count($this->_vars) : '0');
  78. $vLIBtmpl->setvar('vLIB_num_top_level_loops', (count($this->_arrvars)) ? count($this->_arrvars) : '0');
  79. // get all files included using <tmpl_include>
  80. $incdpaths = "";
  81. foreach($this->_debugIncludedfiles as $v) {
  82. $incdpaths .= $v.'<br>';
  83. }
  84. // get the Options and some other stuff
  85. $params = array('vlibTemplate Root' => $this->VLIBTEMPLATE_ROOT);
  86. foreach ($this->OPTIONS as $option => $value) {
  87. (empty($value)) and $value = '<i>null</i>';
  88. (is_array($value)) and $value = join('<br>', $value);
  89. $params[$option] = $value;
  90. }
  91. $paramsarr = array();
  92. foreach($params as $k => $v) {
  93. array_push($paramsarr, array(
  94. 'param_name' => $k,
  95. 'param_value' => $v
  96. ));
  97. }
  98. $vLIBtmpl->setloop('vLIB_list_params', $paramsarr);
  99. // template vars and stuff
  100. $filesarr = array();
  101. if (!is_array($this->_debugTemplatevars['include'])) $this->_debugTemplatevars['include'] = array();
  102. foreach($this->_debugTemplatevars['include'] as $v) {
  103. array_push($filesarr, array(
  104. 'filename' => $v
  105. ));
  106. }
  107. $vLIBtmpl->setloop('vLIB_include_files', $filesarr);
  108. $varsarr = array();
  109. if (!is_array($this->_debugTemplatevars['var'])) $this->_debugTemplatevars['var'] = array();
  110. foreach($this->_debugTemplatevars['var'] as $v) {
  111. array_push($varsarr, array(
  112. 'varname' => $v
  113. ));
  114. }
  115. $vLIBtmpl->setloop('vLIB_vars', $varsarr);
  116. $ifsarr = array();
  117. if (!is_array($this->_debugTemplatevars['if'])) $this->_debugTemplatevars['if'] = array();
  118. foreach($this->_debugTemplatevars['if'] as $v) {
  119. array_push($ifsarr, array(
  120. 'ifname' => $v
  121. ));
  122. }
  123. $vLIBtmpl->setloop('vLIB_ifs', $ifsarr);
  124. $elseifsarr = array();
  125. if (!is_array($this->_debugTemplatevars['elseif'])) $this->_debugTemplatevars['elseif'] = array();
  126. foreach($this->_debugTemplatevars['elseif'] as $v) {
  127. array_push($elseifsarr, array(
  128. 'elseifname' => $v
  129. ));
  130. }
  131. $vLIBtmpl->setloop('vLIB_elseifs', $elseifsarr);
  132. $unlessarr = array();
  133. if (!is_array($this->_debugTemplatevars['unless'])) $this->_debugTemplatevars['unless'] = array();
  134. foreach($this->_debugTemplatevars['unless'] as $v) {
  135. array_push($unlessarr, array(
  136. 'unlessname' => $v
  137. ));
  138. }
  139. $vLIBtmpl->setloop('vLIB_unless', $unlessarr);
  140. $loopsarr = array();
  141. if (!is_array($this->_debugTemplatevars['loop'])) $this->_debugTemplatevars['loop'] = array();
  142. foreach($this->_debugTemplatevars['loop'] as $v) {
  143. array_push($loopsarr, array(
  144. 'loopname' => $v
  145. ));
  146. }
  147. $vLIBtmpl->setloop('vLIB_loops', $loopsarr);
  148. $varsarr = array();
  149. foreach($this->_vars as $k => $v) {
  150. array_push($varsarr, array(
  151. 'varname' => $k
  152. ));
  153. }
  154. $vLIBtmpl->setloop('vLIB_tmplvars', $varsarr);
  155. $loopsarr = array();
  156. $loopst = array_keys($this->_arrvars);
  157. foreach ($loopst as $v) {
  158. array_push($loopsarr, array(
  159. 'loopname' => $v
  160. ));
  161. }
  162. $vLIBtmpl->setloop('vLIB_tmplloops', $loopsarr);
  163. $this->doDebugParse(); // does real debugging
  164. $warningsarr = array();
  165. if (count($this->_debugwarningmsgs) > 0) $vLIBtmpl->setvar('warnings', 1);
  166. foreach($this->_debugwarningmsgs as $v) {
  167. $vals = array_values($v);
  168. list($problem, $detail, $location) = $vals;
  169. array_push($warningsarr, array(
  170. 'problem' => $problem,
  171. 'detail' => $detail,
  172. 'location'=> $location
  173. ));
  174. }
  175. $vLIBtmpl->setloop('vLIB_warnings', $warningsarr);
  176. // finally grab and echo in JS formatted way
  177. $output = $vLIBtmpl->grab();
  178. // 2006-08-12, SD: new option 'DEBUG_WITHOUT_JAVASCRIPT'
  179. if($this->OPTIONS['DEBUG_WITHOUT_JAVASCRIPT'])
  180. {
  181. $wrapper_tmpl = new vlibTemplate($this->VLIBTEMPLATE_DEBUGWRAPPER_NO_JAVASCRIPT);
  182. }
  183. else
  184. {
  185. $wrapper_tmpl = new vlibTemplate($this->VLIBTEMPLATE_DEBUGWRAPPER);
  186. }
  187. $filename = $this->_tmplfilename;
  188. $filename = str_replace('\\', "\\\\", $filename);
  189. $filename = str_replace('\'', "\\'", $filename);
  190. $filename = str_replace("\r", '', $filename);
  191. $filename = str_replace("\n", "\\n", $filename);
  192. $filename = str_replace("\t", "\\t", $filename);
  193. $wrapper_tmpl->setVar('filename', $filename);
  194. $wrapper_tmpl->setvar('filename_enc', $filename_enc);
  195. $wrapper_tmpl->setvar('securecode', md5(time()));
  196. // 2006-08-12, SD: new option 'DEBUG_WITHOUT_JAVASCRIPT'
  197. if($this->OPTIONS['DEBUG_WITHOUT_JAVASCRIPT'])
  198. {
  199. $wrapper_tmpl->setVar('debug_content', $output);
  200. }
  201. else
  202. {
  203. $wrapper_tmpl->setVar('debug_content', $this->enjavanate($output, 120));
  204. }
  205. $wrapper_tmpl->pparse();
  206. }
  207. /**
  208. * rearranges all vars from below regex
  209. *
  210. *
  211. */
  212. function arrangeTags ($arr) {
  213. $temparr = array();
  214. $temparr['tag'] = $arr['tag'];
  215. $temparr['openclose'] = $arr['openclose'];
  216. $temparr['file'] = $arr['file'];
  217. $temparr['line'] = $arr['line'];
  218. $temparr['entire_tag'] = $arr['entire_tag'];
  219. for($i=1; $i < 4; $i++) {
  220. if (empty($arr['paramname'.$i]) && empty($arr['paramval'.$i])) break;
  221. (empty($arr['paramname'.$i])) ? $key = 'name' : $key = strtolower($arr['paramname'.$i]);
  222. $temparr[$key] = trim($arr['paramval'.$i]);
  223. }
  224. array_push($this->_debugalltags, $temparr);
  225. }
  226. /**
  227. * parses the template files
  228. *
  229. * @param array $data data of files line by line
  230. * @param string $filename name of current template file
  231. * @access private
  232. */
  233. function doDebugWarnings ($data, $filename) {
  234. $regex = '/(<|<\/|{|{\/|<!--|<!--\/){1}\s*';
  235. $regex.= '(?:tmpl_)?';
  236. $regex.= '(var|if|elseif|else|endif|unless|endunless|loop|endloop|include|phpinclude|comment|endcomment)\s*';
  237. $regex.= '(?:';
  238. $regex.= '(?:';
  239. $regex.= '(name|format|escape|op|value)';
  240. $regex.= '\s*=\s*';
  241. $regex.= ')?';
  242. $regex.= '(?:[\"\'])?';
  243. $regex.= '((?<=[\"\'])';
  244. $regex.= '[^\"\']*|[a-z0-9_\.]*)';
  245. $regex.= '[\"\']?';
  246. $regex.= ')?\s*';
  247. $regex.= '(?:';
  248. $regex.= '(?:';
  249. $regex.= '(name|format|escape|op|value)';
  250. $regex.= '\s*=\s*';
  251. $regex.= ')';
  252. $regex.= '(?:[\"\'])?';
  253. $regex.= '((?<=[\"\'])';
  254. $regex.= '[^\"\']*|[a-z0-9_\.]*)';
  255. $regex.= '[\"\']?';
  256. $regex.= ')?\s*';
  257. $regex.= '(?:';
  258. $regex.= '(?:';
  259. $regex.= '(name|format|escape|op|value)';
  260. $regex.= '\s*=\s*';
  261. $regex.= ')';
  262. $regex.= '(?:[\"\'])?';
  263. $regex.= '((?<=[\"\'])';
  264. $regex.= '[^\"\']*|[a-z0-9_\.]*)';
  265. $regex.= '[\"\']?';
  266. $regex.= ')?\s*';
  267. $regex.= '(?:>|\/>|}|-->){1}';
  268. $regex.= '/ie';
  269. for ($i = 0; $i < count($data); $i++) {
  270. $file = preg_replace(
  271. $regex,
  272. "\$this->arrangeTags(array(
  273. 'tag' => strtolower('\\2'),
  274. 'paramname1' => strtolower('\\3'),
  275. 'paramval1' => strtolower('\\4'),
  276. 'paramname2' => strtolower('\\5'),
  277. 'paramval2' => strtolower('\\6'),
  278. 'paramname3' => strtolower('\\7'),
  279. 'paramval3' => strtolower('\\8'),
  280. 'openclose' => '\\1',
  281. 'file' => realpath('$filename'),
  282. 'line' => ".($i+1).",
  283. 'entire_tag' => '\\0')
  284. );"
  285. ,
  286. $data[$i]
  287. );
  288. }
  289. }
  290. /**
  291. * takes values from preg_replace in _intparse and determines the replace string
  292. *
  293. * @access private
  294. * @return string replace values
  295. */
  296. function doDebugParse() {
  297. $valid_tags = array('var','loop','if','elseif','else','unless','endloop',
  298. 'endif','endunless', 'include', 'phpinclude', 'comment', 'endcomment');
  299. foreach($this->_debugalltags as $v) {
  300. $lasttag = $this->_debugtags[(count($this->_debugtags)-1)];
  301. $tag = $v['tag'];
  302. $escape = $v['escape'];
  303. $format = $v['format'];
  304. $op = $v['op'];
  305. $value = $v['value'];
  306. $var = trim($v['name']);
  307. $openclose = $v['openclose'];
  308. $file = $v['file'];
  309. $line = $v['line'];
  310. $entire_tag = stripslashes($v['entire_tag']);
  311. // continue if it's a one=line comment
  312. if ($tag == 'comment' && !empty($var)) continue;
  313. // bad tag
  314. if (!in_array($tag, $valid_tags)) {
  315. array_push($this->_debugwarningmsgs, array(
  316. 'problem' => 'Warning: Invalid tag',
  317. 'detail' => "The following tag is not valid:\n".$entire_tag,
  318. 'location' => 'Line: '.$line.', in file: '.$file
  319. ));
  320. continue;
  321. }
  322. // bad escape
  323. if (!empty($escape)){
  324. if (!isset($this->ESCAPE_TAGS[$escape])) {
  325. array_push($this->_debugwarningmsgs, array(
  326. 'problem' => 'Warning: Invalid escape type',
  327. 'detail' => "The escape attribute of the following tag is not valid:\n".$entire_tag,
  328. 'location' => 'Line: '.$line.', in file: '.$file
  329. ));
  330. }
  331. }
  332. // bad format
  333. if (!empty($format)){
  334. if (!isset($this->FORMAT_TAGS[$format])) {
  335. array_push($this->_debugwarningmsgs, array(
  336. 'problem' => 'Warning: Invalid format type',
  337. 'detail' => "The format attribute of the following tag is not valid:\n".$entire_tag,
  338. 'location' => 'Line: '.$line.', in file: '.$file
  339. ));
  340. }
  341. }
  342. // bad operator
  343. if (!empty($op)){
  344. if (!in_array($op, $this->allowed_if_ops)) {
  345. array_push($this->_debugwarningmsgs, array(
  346. 'problem' => 'Warning: Invalid operator type',
  347. 'detail' => "The op attribute of the following tag is not supported:\n".$entire_tag,
  348. 'location' => 'Line: '.$line.', in file: '.$file
  349. ));
  350. }
  351. }
  352. if (preg_match("/^([a-z0-9_]+\.)*([a-z0-9_]+[_a-z0-9]*)$/i", $var, $matches) && !preg_match('/include|comment/', $tag)) $var = $matches[2];
  353. // out of sequences
  354. if ($tag == 'else') {
  355. if (preg_match('/if|elseif|unless/', $lasttag[0])) {
  356. continue;
  357. } else {
  358. array_push($this->_debugwarningmsgs, array(
  359. 'problem' => 'Error: tmpl_else out of sequence',
  360. 'detail' => "The following tag is out of sequence:\n".$entire_tag,
  361. 'location' => 'Line: '.$line.', in file: '.$file
  362. ));
  363. }
  364. }
  365. if ($tag == 'elseif') {
  366. if (preg('/if|elseif/', $lasttag[0])) {
  367. array_pop($this->_debugtags);
  368. } else {
  369. array_push($this->_debugwarningmsgs, array(
  370. 'problem' => 'Error: tmpl_elseif out of sequence',
  371. 'detail' => "The following tag is out of sequence:\n".$entire_tag,
  372. 'location' => 'Line: '.$line.', in file: '.$file
  373. ));
  374. }
  375. }
  376. // bad syntax
  377. if (!preg_match("/^([a-z_]+[_a-z0-9\.]*)$/i", $var) && !preg_match('/include|comment/', $tag) && !empty($var)) {
  378. array_push($this->_debugwarningmsgs, array(
  379. 'problem' => 'Warning: Invalid variable name',
  380. 'detail' => "The variable name in the following tag does not comply with the correct php syntax:\n".$entire_tag,
  381. 'location' => 'Line: '.$line.', in file: '.$file
  382. ));
  383. }
  384. // if it's a closing tag return
  385. if (preg_match("/^<\/|{\/|<!--\/$/s", $openclose) || preg_match("/endloop|endif|endunless|endcomment/", $tag)) {
  386. $closetag = 1;
  387. if ($tag == 'loop' || $tag == 'endloop') $tag = 'loop';
  388. if ($tag == 'if' || $tag == 'endif') $tag = 'if';
  389. if ($tag == 'unless' || $tag == 'endunless') $tag = 'unless';
  390. if ($tag == 'comment' || $tag == 'endcomment') $tag = 'comment';
  391. if ($tag == 'loop') {
  392. if ($lasttag[0] == 'unless') {
  393. array_push($this->_debugwarningmsgs, array(
  394. 'problem' => 'Notice: tmpl_endloop',
  395. 'detail' => "The following end loop tag was found as a closing tag to a tmpl_unless:".$entire_tag
  396. .", whilst this 'may' not cause an error, it is incorrect vlibTemplate syntax (this maybe because of previous errors).",
  397. 'location' => 'Line: '.$line.', in file: '.$file
  398. ));
  399. array_pop($this->_debugtags);
  400. }
  401. elseif ($lasttag[0] == 'if') {
  402. array_push($this->_debugwarningmsgs, array(
  403. 'problem' => 'Error: tmpl_endloop',
  404. 'detail' => "The following end loop tag was found as a closing tag to a tmpl_if:".$entire_tag
  405. .", whilst this 'may' not cause an error, it is incorrect vlibTemplate syntax (this maybe because of previous errors).",
  406. 'location' => 'Line: '.$line.', in file: '.$file
  407. ));
  408. }
  409. elseif($lasttag[0] != 'comment') {
  410. array_pop($this->_debugtags);
  411. }
  412. }
  413. elseif ($tag == 'if') {
  414. if ($lasttag[0] == 'unless') {
  415. array_push($this->_debugwarningmsgs, array(
  416. 'problem' => 'Notice: tmpl_endif',
  417. 'detail' => "The following end if tag was found as a closing tag to a tmpl_unless:".$entire_tag
  418. .", whilst this may not cause an error, it is incorrect vlibTemplate syntax (this maybe because of previous errors).",
  419. 'location' => 'Line: '.$line.', in file: '.$file
  420. ));
  421. array_pop($this->_debugtags);
  422. }
  423. elseif ($lasttag[0] == 'loop') {
  424. array_push($this->_debugwarningmsgs, array(
  425. 'problem' => 'Error: tmpl_endif',
  426. 'detail' => "The following end if tag was found without it's opening tag (this maybe because of previous errors):\n".$entire_tag,
  427. 'location' => 'Line: '.$line.', in file: '.$file
  428. ));
  429. }
  430. elseif($lasttag[0] != 'comment') {
  431. array_pop($this->_debugtags);
  432. }
  433. }
  434. elseif ($tag == 'unless') {
  435. if ($lasttag[0] == 'if') {
  436. array_push($this->_debugwarningmsgs, array(
  437. 'problem' => 'Notice: tmpl_endunless',
  438. 'detail' => "The following end unless tag was found as a closing tag to a tmpl_if:".$entire_tag
  439. .", whilst this may not cause an error, it is incorrect vlibTemplate syntax (this maybe because of previous errors).",
  440. 'location' => 'Line: '.$line.', in file: '.$file
  441. ));
  442. array_pop($this->_debugtags);
  443. }
  444. elseif ($lasttag[0] == 'loop') {
  445. array_push($this->_debugwarningmsgs, array(
  446. 'problem' => 'Error: tmpl_endunless',
  447. 'detail' => "The following end unless tag was found without it's opening tag (this maybe because of previous errors):\n".$entire_tag,
  448. 'location' => 'Line: '.$line.', in file: '.$file
  449. ));
  450. }
  451. elseif($lasttag[0] != 'comment') {
  452. array_pop($this->_debugtags);
  453. }
  454. }
  455. elseif ($tag == 'comment') {
  456. if ($lasttag[0] != 'comment') {
  457. array_push($this->_debugwarningmsgs, array(
  458. 'problem' => 'Error: tmpl_'.$tag,
  459. 'detail' => "The following end comment tag was found without it's opening tag (this maybe because of previous errors):\n".$entire_tag,
  460. 'location' => 'Line: '.$line.', in file: '.$file
  461. ));
  462. }
  463. else {
  464. array_pop($this->_debugtags);
  465. }
  466. }
  467. if (empty($lasttag[0])) {
  468. array_push($this->_debugwarningmsgs, array(
  469. 'problem' => 'Error: tmpl_'.$tag,
  470. 'detail' => "The following end ".$tag." tag was found without it's opening tag (this maybe because of previous errors):\n".$entire_tag,
  471. 'location' => 'Line: '.$line.', in file: '.$file
  472. ));
  473. }
  474. }
  475. if (preg_match('/if|unless|loop|elseif|comment/', $tag) && !$closetag) {
  476. array_push($this->_debugtags, array(
  477. $tag,
  478. $file,
  479. $line,
  480. $entire_tag
  481. ));
  482. }
  483. unset($closetag);
  484. } // foreach
  485. // check for any unclosed tags
  486. foreach($this->_debugtags as $v) {
  487. array_push($this->_debugwarningmsgs, array(
  488. 'problem' => 'Error: tmpl_'.$v[0],
  489. 'detail' => "The following tmpl_".$v[0]." tag was found without it's closing tag (this maybe because of previous errors):\n".$v[3],
  490. 'location' => 'Line: '.$v[2].', in file: '.$v[1]
  491. ));
  492. }
  493. }
  494. /**
  495. * Puts a text string into document.write functions calls in javascript
  496. */
  497. function enjavanate ($str, $limit=60) {
  498. $str = str_replace("\r", '', $str);
  499. $retstr; // string to return
  500. $retstr .= "var vlib_debug_str2add = '';\n\n";
  501. while (strlen($str) > 0)
  502. {
  503. $line = substr ($str, 0, $limit);
  504. $str = substr ($str, $limit);
  505. $line = str_replace('\\', "\\\\", $line);
  506. $line = str_replace('\'', "\\'", $line);
  507. $line = str_replace("\r", '', $line);
  508. $line = str_replace("\n", "\\n", $line);
  509. $line = str_replace("\t", "\\t", $line);
  510. $line = str_replace('<', "<'+'", $line);
  511. $retstr .= "vlib_debug_str2add += '$line';\n";
  512. }
  513. $retstr .= "\nvlib_window_obj.document.write(vlib_debug_str2add);\n";
  514. return $retstr;
  515. }
  516. /**
  517. * Resets the debug module ready for more information
  518. */
  519. function _debugReset () {
  520. $this->_debugIncludedfiles = array();
  521. $this->_debugTemplatevars = array();
  522. $this->_debugtags = array();
  523. $this->_debugwarnings = array();
  524. $this->_debugwarningmsgscontrol = array();
  525. $this->_debugwarningmsgs = array();
  526. }
  527. /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  528. The following functions have no use and are included just so that if the user
  529. is making use of vlibTemplateCache functions, this doesn't crash when changed to
  530. vlibTemplateDebug.
  531. The reason it would crash is that when you call vlibTemplateDebug, it bypasses
  532. the cache class.
  533. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
  534. function clearCache() {}
  535. function recache() {}
  536. function setCacheLifeTime() {}
  537. function setCacheExtension() {}
  538. }
  539. ?>