Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Upgrade to 1.9.

  • Loading branch information...
commit fa455ed25d600955e9f4168f02d7cfcf8597fd28 1 parent e003280
Vanilla Hsu authored

Showing 3 changed files with 48 additions and 31 deletions. Show diff stats Hide diff stats

  1. +4 0 ChangeLog
  2. +43 30 cTemplate.cpp
  3. +1 1  config.m4
4 ChangeLog
... ... @@ -1,3 +1,7 @@
  1 +Version 1.9 (2009/06/13)
  2 +- Make compatible with google cTemplate 0.95.
  3 +- Add more template modifiers define.
  4 +
1 5 Version 1.8 (2009/05/11)
2 6 - Make compatible with google cTemplate 0.94.
3 7
73 cTemplate.cpp
@@ -13,8 +13,8 @@
13 13 /* $Header: /home/ncvs/php_extension/cTemplate/cTemplate.cpp,v 1.12 2007/07/17 09:45:59 vanilla Exp $ */
14 14
15 15 #include <string>
16   -#include "google/template.h"
17   -#include "google/template_dictionary.h"
  16 +#include "ctemplate/template.h"
  17 +#include "ctemplate/template_dictionary.h"
18 18
19 19 extern "C" {
20 20 #ifdef HAVE_CONFIG_H
@@ -32,7 +32,7 @@ extern "C" {
32 32 }
33 33
34 34 using namespace std;
35   -using namespace google;
  35 +using namespace ctemplate;
36 36
37 37 class cTemplateDict
38 38 {
@@ -67,19 +67,24 @@ typedef struct
67 67
68 68 typedef struct
69 69 {
70   - const template_modifiers::TemplateModifier *m;
  70 + const ctemplate::TemplateModifier *m;
71 71 } minfo;
72 72
73   -static minfo m[] = {
74   - { &template_modifiers::html_escape },
75   - { &template_modifiers::xml_escape },
76   - { &template_modifiers::javascript_escape },
77   - { &template_modifiers::json_escape },
78   - { &template_modifiers::url_query_escape },
79   - { &template_modifiers::pre_escape },
80   - { &template_modifiers::snippet_escape },
81   - { &template_modifiers::validate_url_and_html_escape },
82   - { &template_modifiers::validate_url_and_javascript_escape },
  73 +static minfo minfo_[] = {
  74 + { &ctemplate::html_escape },
  75 + { &ctemplate::pre_escape },
  76 + { &ctemplate::snippet_escape },
  77 + { &ctemplate::cleanse_attribute },
  78 + { &ctemplate::cleanse_css },
  79 + { &ctemplate::validate_url_and_html_escape },
  80 + { &ctemplate::validate_url_and_javascript_escape },
  81 + { &ctemplate::validate_url_and_css_escape },
  82 + { &ctemplate::xml_escape },
  83 + { &ctemplate::javascript_escape },
  84 + { &ctemplate::javascript_number },
  85 + { &ctemplate::url_query_escape },
  86 + { &ctemplate::json_escape },
  87 + { &ctemplate::prefix_line },
83 88 { NULL }
84 89 };
85 90
@@ -174,14 +179,20 @@ PHP_MINIT_FUNCTION(cTemplate)
174 179 REGISTER_LONG_CONSTANT ("TC_XML", TC_XML, CONST_CS | CONST_PERSISTENT);
175 180 REGISTER_LONG_CONSTANT ("TC_MANUAL", TC_MANUAL, CONST_CS | CONST_PERSISTENT);
176 181 REGISTER_LONG_CONSTANT ("HTML_ESCAPE", 0, CONST_CS | CONST_PERSISTENT);
177   - REGISTER_LONG_CONSTANT ("XML_ESCAPE", 1, CONST_CS | CONST_PERSISTENT);
178   - REGISTER_LONG_CONSTANT ("JAVASCRIPT_ESCAPE", 2, CONST_CS | CONST_PERSISTENT);
179   - REGISTER_LONG_CONSTANT ("JSON_ESCAPE", 3, CONST_CS | CONST_PERSISTENT);
180   - REGISTER_LONG_CONSTANT ("URL_ESCAPE", 4, CONST_CS | CONST_PERSISTENT);
181   - REGISTER_LONG_CONSTANT ("PRE_ESCAPE", 5, CONST_CS | CONST_PERSISTENT);
182   - REGISTER_LONG_CONSTANT ("SNIPPET_ESCAPE", 6, CONST_CS | CONST_PERSISTENT);
183   - REGISTER_LONG_CONSTANT ("VALIDATE_URL_AND_HTML_ESCAPE", 7, CONST_CS | CONST_PERSISTENT);
184   - REGISTER_LONG_CONSTANT ("VALIDATE_URL_AND_JAVASCRIPT_ESCAPE", 8, CONST_CS | CONST_PERSISTENT);
  182 + REGISTER_LONG_CONSTANT ("PRE_ESCAPE", 1, CONST_CS | CONST_PERSISTENT);
  183 + REGISTER_LONG_CONSTANT ("SNIPPET_ESCAPE", 2, CONST_CS | CONST_PERSISTENT);
  184 + REGISTER_LONG_CONSTANT ("CLEANSE_ATTRIBUTE", 3, CONST_CS | CONST_PERSISTENT);
  185 + REGISTER_LONG_CONSTANT ("CLEANSE_CSS", 4, CONST_CS | CONST_PERSISTENT);
  186 + REGISTER_LONG_CONSTANT ("VALIDATE_URL_AND_HTML_ESCAPE", 5, CONST_CS | CONST_PERSISTENT);
  187 + REGISTER_LONG_CONSTANT ("VALIDATE_URL_AND_JAVASCRIPT_ESCAPE", 6, CONST_CS | CONST_PERSISTENT);
  188 + REGISTER_LONG_CONSTANT ("VALIDATE_URL_AND_CSS_ESCAPE", 7, CONST_CS | CONST_PERSISTENT);
  189 + REGISTER_LONG_CONSTANT ("XML_ESCAPE", 8, CONST_CS | CONST_PERSISTENT);
  190 + REGISTER_LONG_CONSTANT ("JAVASCRIPT_ESCAPE", 9, CONST_CS | CONST_PERSISTENT);
  191 + REGISTER_LONG_CONSTANT ("JAVASCRIPT_NUMBER", 10, CONST_CS | CONST_PERSISTENT);
  192 + REGISTER_LONG_CONSTANT ("URL_QUERY_ESCAPE", 11, CONST_CS | CONST_PERSISTENT);
  193 + REGISTER_LONG_CONSTANT ("JSON_ESCAPE", 12, CONST_CS | CONST_PERSISTENT);
  194 + REGISTER_LONG_CONSTANT ("PREFIX_LINE", 13, CONST_CS | CONST_PERSISTENT);
  195 +
185 196
186 197 cTemplateTpl_init (TSRMLS_C);
187 198 cTemplateDict_init (TSRMLS_C);
@@ -283,10 +294,12 @@ PHP_METHOD (cTemplateTpl, __construct)
283 294 tpl = (php_cTemplateTpl*) zend_object_store_get_object(object TSRMLS_CC);
284 295 Template::SetTemplateRootDirectory ("./");
285 296
286   - if (ZEND_NUM_ARGS() == 3)
287   - tpl->obj = Template::StringToTemplate (Z_STRVAL_P (arg2), Z_STRLEN_P( arg2 ), (Strip) Z_LVAL_P (arg3), TC_MANUAL);
288   - else
289   - tpl->obj = Template::StringToTemplate (Z_STRVAL_P (arg2), Z_STRLEN_P( arg2 ), (Strip) Z_LVAL_P (arg3), (TemplateContext) Z_LVAL_P (arg4));
  297 + if (ZEND_NUM_ARGS() == 4) {
  298 + php_error( E_STRICT, "deprecated construct function style, use autoescape pragma instead" );
  299 + RETURN_FALSE;
  300 + }
  301 +
  302 + tpl->obj = Template::StringToTemplate (Z_STRVAL_P (arg2), Z_STRLEN_P( arg2 ), (Strip) Z_LVAL_P (arg3));
290 303
291 304 if (tpl->obj == NULL)
292 305 {
@@ -677,16 +690,16 @@ PHP_METHOD(cTemplateDict, SetEscaped)
677 690 if (sec != NULL)
678 691 {
679 692 if (dict->obj->is_root)
680   - dict->obj->d.SetEscapedValueAndShowSection (key, val, *(m[e].m), sec);
  693 + dict->obj->d.SetEscapedValueAndShowSection (key, val, *(minfo_[e].m), sec);
681 694 else
682   - dict->obj->p->SetEscapedValueAndShowSection (key, val, *(m[e].m), sec);
  695 + dict->obj->p->SetEscapedValueAndShowSection (key, val, *(minfo_[e].m), sec);
683 696 }
684 697 else
685 698 {
686 699 if (dict->obj->is_root)
687   - dict->obj->d.SetEscapedValue (key, val, *(m[e].m));
  700 + dict->obj->d.SetEscapedValue (key, val, *(minfo_[e].m));
688 701 else
689   - dict->obj->p->SetEscapedValue (key, val, *(m[e].m));
  702 + dict->obj->p->SetEscapedValue (key, val, *(minfo_[e].m));
690 703 }
691 704 RETURN_TRUE;
692 705 }
2  config.m4
@@ -7,7 +7,7 @@ Make sure that the comment is aligned:
7 7
8 8 if test "$PHP_CTEMPLATE" != "no"; then
9 9 SEARCH_PATH="/usr/local /usr"
10   - SEARCH_FOR="/include/google/template.h"
  10 + SEARCH_FOR="/include/ctemplate/template.h"
11 11 if test -r $PHP_CTEMPLATE/$SEARCH_FOR; then
12 12 CTEMPLATE_DIR=$PHP_CTEMPLATE
13 13 else

0 comments on commit fa455ed

Please sign in to comment.
Something went wrong with that request. Please try again.