Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [JustIT]Dziwne znaki po dodaniu do tekstu "
Forum PHP.pl > Forum > Gotowe rozwiązania > Systemy szablonów
eunix
Witam,

Koncze właśnie cms na skrypcie szablonów JustIT, jest ony wygodny w użyciu ale mam problem...
Gdy w tekscie dam np.
  1. <a href="#">test</a>
to zamieni mi to podczas wyświetlania na
  1. test</a>"><a href="#">test</a>


zapewne dzieje się tak przez funkcje odpowiedzialną za wyświetlanie w klasie szablonu (bo w bazie teskt wygląda poprawnie).

Funkcja odpowiadająca za wyświetlanie...
  1. function display_body()
  2. {
  3. if ( !$this->status ) return false;
  4. $indexes = $loops = $used_loops = array();
  5. if ( count($this->used_indexes) )
  6. {
  7. foreach($this->used_indexes as $key => $value)
  8. {
  9. $name = explode('.', $key);
  10. $name = $name[(count($name)-1)];
  11. if ( $value > 1 )
  12. {
  13. if ( @!in_array($name, $indexes) )
  14. {
  15. $indexes[] = $name;
  16. }
  17. if ( $value > $loops[$name] )
  18. {
  19. $loops[$name] = $value;
  20. }
  21. }
  22. if ( @!in_array($name, $used_loops) )
  23. {
  24. $value = intval($value);
  25. fputs($this->variables_file_handler, '$tplvar_loop_max_' . $this->unique_hash . '_' . $name . " = '$value';n");
  26. $used_loops[] = $name;
  27. }
  28. }
  29. }
  30. fputs($this->variables_file_handler, '?>');
  31. @fclose($this->variables_file_handler);
  32.  
  33. if ( count($this->used_variables) )
  34. {
  35. $var_file_contents = trim(file_get_contents($this->variables_file));
  36. $var_file_contents_with_globals = str_replace('<?php', '<?php global ' . implode(', ', $this->used_variables) . ';', $var_file_contents);
  37.  
  38. $this->variables_file_handler = @fopen($this->variables_file, 'w+') or $this->error_msg(54, 'Couldn't handle variables file.');
  39. @fputs($this->variables_file_handler, $var_file_contents_with_globals);
  40. @fclose($this->variables_file_handler);
  41. }
  42.  
  43. $this->template_filesize = @filesize($this->template_file);
  44. $this->template_file_contents = trim(@fread($this->template_file_handler, $this->template_filesize));
  45. @fclose($this->template_file_handler);
  46.  
  47. if ( $this->enabled_php_scripts === false )
  48. {
  49. $this->template_file_contents = preg_replace('#<?(.*?)?>#is', '&lt;?1?&gt;', $this->template_file_contents);
  50. $this->template_file_contents = preg_replace('#&lt;?xml(.*?)?&gt;#is', '<?xml1?>', $this->template_file_contents);
  51. }
  52.  
  53. $variables = $required_variables = array();
  54. if ( !$this->template_file_contents )
  55. {
  56. message_die(53, 'Template file is empty.');
  57. }
  58.  
  59. preg_match_all('#{(([0-9a-z_]|.)+)}#i', $this->template_file_contents, $variables);
  60. preg_match_all('#<!-- BEGIN (([0-9a-z_])+) -->#i', $this->template_file_contents, $offsets);
  61.  
  62. foreach ( $variables[1] as $index => $variable )
  63. {
  64. $this->template_file_contents = str_replace($variables[0][$index], '<?php print ' . $this->convert_tplvars($variable) . '; ?>', $this->template_file_contents);
  65. $required_variables[] = $this->convert_tplvars($variable,1);
  66. }
  67.  
  68. foreach ( $offsets[1] as $index => $offset )
  69. {
  70. preg_match_all('#<!-- BEGIN ' . trim($offset) . ' -->(.*?)<!-- END ' . trim($offset) . ' -->#s', $this->template_file_contents, $fields);
  71. foreach ( $fields[1] as $index => $content )
  72. {
  73. $loop_var = '$tplvar_loop_' . $this->unique_hash . '_' . $offset;
  74. $loop_max_var = '$tplvar_loop_max_' . $this->unique_hash . '_' . $offset;
  75. $replacement_a = '<?php for ( ' . $loop_var . ' = 0; ' . $loop_var . ' < ' . $loop_max_var . '; ' . $loop_var . '++ )';
  76. $replacement_a .= "n{ ?>n";
  77. $replacement_b = "n<?php } ?>n";
  78. $this->template_file_contents = str_replace($fields[0][$index], $replacement_a . $content . $replacement_b, $this->template_file_contents);
  79. }
  80. }
  81.  
  82. $global_vars = array();
  83. if ( count($required_variables) )
  84. {
  85. foreach( $required_variables as $var )
  86. {
  87. if ( @!in_array($var, $this->used_variables) && @!in_array($var, $global_vars) )
  88. {
  89. $global_vars[] = $var;
  90. }
  91. }
  92. }
  93. if ( count($global_vars) )
  94. {
  95. $this->template_file_contents = "<?php global " . implode(',', $global_vars) . "; ?>nn" . $this->template_file_contents;
  96. }
  97. @fputs($this->cache_file_handler, $this->template_file_contents);
  98. @fclose($this->cache_file_handler);
  99.  
  100. unset($this->used_indexes, $this->template_file_contents, $this->used_variables);
  101.  
  102. if ( !include($this->variables_file) )
  103. {
  104. $this->error_msg(51, 'Couldn't assign cache file.');
  105. }
  106. unlink($this->variables_file);
  107. if ( !include($this->cache_file) )
  108. {
  109. $this->error_msg(52, 'Couldn't assign template cache file.');
  110. }
  111. $this->status = 0;
  112. }
koobs
witam,

u mnie, zarowno na php w wersji 4.4.1 jak i 5.1.5 skrypt zachowuje sie prawidlowo. problem natomiast wyglada jakby byly zle zdefiniowane indeksy. wkrotce na swiatlo zostanie wypuszczona wersja opatrzona numerkiem 2 gdyz obecna wersja zawierala dosc sporo malych ale uciazliwych bledow.

zatem, czy moglbym prosic o fragment kodu odpowiedzialnego za nadanie wartosci dla zmiennej sprawiajacej klopot oraz fragment tplki ja wyswietlajacy?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.