/includes/patTemplate/patTemplate/Dump.php

https://github.com/Arkadiy-Sedelnikov/joostina-1.4 · PHP · 72 lines · 50 code · 9 blank · 13 comment · 6 complexity · cc83feacf2c0d971b9c415295404a4f9 MD5 · raw file

  1. <?php
  2. /**
  3. * @package Joostina
  4. * @copyright ��������� ����� (C) 2008 Joostina team. ��� ����� ��������.
  5. * @license �������� http://www.gnu.org/licenses/gpl-2.0.htm GNU/GPL, ��� help/license.php
  6. * Joostina! - ��������� ����������� ����������� ���������������� �� �������� �������� GNU/GPL
  7. * ��� ��������� ���������� � ������������ ����������� � ��������� �� ��������� �����, �������� ���� help/copyright.php.
  8. * @version 3.1.0
  9. * @package patTemplate
  10. * @author Stephan Schmidt <schst@php.net>
  11. * @license LGPL
  12. * @link http://www.php-tools.net
  13. */
  14. // ������ ������� �������
  15. defined('_JLINDEX') or die();
  16. class patTemplate_Dump extends patTemplate_Module{
  17. var $_tmpl;
  18. function setTemplateReference(&$tmpl){
  19. $this->_tmpl = &$tmpl;
  20. }
  21. function displayHeader(){
  22. }
  23. function dumpGlobals($globals){
  24. }
  25. function dumpTemplates($templates, $vars){
  26. }
  27. function displayFooter(){
  28. }
  29. function _flattenVars($vars){
  30. $flatten = array();
  31. foreach($vars['scalar'] as $var => $value){
  32. $flatten[$var] = $value;
  33. }
  34. foreach($vars['rows'] as $row){
  35. foreach($row as $var => $value){
  36. if(!isset($flatten[$var]) || !is_array($flatten[$var]))
  37. $flatten[$var] = array();
  38. array_push($flatten[$var], $value);
  39. }
  40. }
  41. foreach($flatten as $var => $value){
  42. if(!is_array($value))
  43. continue;
  44. $flatten[$var] = '[' . count($value) . ' rows] (' . implode(', ', $value) . ')';
  45. }
  46. return $flatten;
  47. }
  48. function _extractVars($template){
  49. $pattern = '/' . $this->_tmpl->getStartTag() . '([^a-z]+)' . $this->_tmpl->getEndTag() . '/U';
  50. $matches = array();
  51. $result = preg_match_all($pattern, $template, $matches);
  52. if($result == false)
  53. return array();
  54. $vars = array();
  55. foreach($matches[1] as $var){
  56. if(strncmp($var, 'TMPL:', 5) === 0)
  57. continue;
  58. array_push($vars, $var);
  59. }
  60. return array_unique($vars);
  61. }
  62. }
  63. ?>