From 0fd915729bde74884c9722f8d672247dcaec0485 Mon Sep 17 00:00:00 2001
From: Raymond Jelierse
Date: Sat, 25 Feb 2012 20:55:15 +0100
Subject: [PATCH 1/9] First commit.
This still needs some work on the installer, which is not added yet.
---
.htaccess | 12 +
README.md | 28 ++
css/bootstrap.min.css | 632 +++++++++++++++++++++++++++++
css/style.css | 16 +
img/blank.png | Bin 0 -> 4249 bytes
img/glyphicons-halflings-white.png | Bin 0 -> 4352 bytes
img/glyphicons-halflings.png | Bin 0 -> 4352 bytes
index.php | 166 ++++++++
js/bootstrap.min.js | 1 +
js/change.js | 48 +++
settings.json.example | 47 +++
views/base.html.twig | 44 ++
views/change.html.twig | 20 +
views/finish.html.twig | 9 +
views/index.html.twig | 29 ++
views/next.html.twig | 9 +
views/results.html.twig | 77 ++++
views/results.txt.twig | 5 +
18 files changed, 1143 insertions(+)
create mode 100644 .htaccess
create mode 100644 README.md
create mode 100644 css/bootstrap.min.css
create mode 100644 css/style.css
create mode 100644 img/blank.png
create mode 100644 img/glyphicons-halflings-white.png
create mode 100644 img/glyphicons-halflings.png
create mode 100644 index.php
create mode 100644 js/bootstrap.min.js
create mode 100644 js/change.js
create mode 100644 settings.json.example
create mode 100644 views/base.html.twig
create mode 100644 views/change.html.twig
create mode 100644 views/finish.html.twig
create mode 100644 views/index.html.twig
create mode 100644 views/next.html.twig
create mode 100644 views/results.html.twig
create mode 100644 views/results.txt.twig
diff --git a/.htaccess b/.htaccess
new file mode 100644
index 0000000..7fd4e97
--- /dev/null
+++ b/.htaccess
@@ -0,0 +1,12 @@
+
+ RewriteEngine On
+ RewriteBase /
+
+ RewriteRule ^(start|finish|results)/?$ index.php?mode=$1 [L]
+ RewriteRule ^phase/(notable|unnoted|renoted)/?$ index.php?mode=phase&phase=$1 [L]
+ RewriteRule ^results/(download|filtered)/? index.php?mode=results&$1=1 [L]
+
+
+
+ Deny from all
+
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..128c076
--- /dev/null
+++ b/README.md
@@ -0,0 +1,28 @@
+Change blindness test
+===================
+This is a small web application that can be used to test change blindness. It was developed for
+an assignment in the Visual Communication Design course on the Design for Interaction master at
+the Delft University of Technology by Raymond Jelierse.
+
+Requirements
+-----------
+* A webserver with the following packages:
+ * PHP 5.3.x
+ * MySQL 5.x
+ * Twig 1.6
+* Pairs of images to test with.
+ The filenames should have the following format: `-(with|without).png`.
+ You can configure the phases in the `settings.json` file.
+
+Set up
+-----
+1. Place the change blindness test somewhere in your webroot.
+2. Edit the settings file to your needs.
+3. Add the images to the `img` directory.
+4. Go to `/install/` and follow the on screen instructions.
+
+Acknowledgements
+--------------
+The change blindness test makes use of the following projects:
+* [jquery](http://jquery.com/)
+* [bootstrap](http://twitter.github.com/bootstrap/)
diff --git a/css/bootstrap.min.css b/css/bootstrap.min.css
new file mode 100644
index 0000000..30dcae0
--- /dev/null
+++ b/css/bootstrap.min.css
@@ -0,0 +1,632 @@
+article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block;}
+audio,canvas,video{display:inline-block;*display:inline;*zoom:1;}
+audio:not([controls]){display:none;}
+html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;}
+a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px;}
+a:hover,a:active{outline:0;}
+sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline;}
+sup{top:-0.5em;}
+sub{bottom:-0.25em;}
+img{max-width:100%;height:auto;border:0;-ms-interpolation-mode:bicubic;}
+button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle;}
+button,input{*overflow:visible;line-height:normal;}
+button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0;}
+button,input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button;}
+input[type="search"]{-webkit-appearance:textfield;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;}
+input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none;}
+textarea{overflow:auto;vertical-align:top;}
+.clearfix{*zoom:1;}.clearfix:before,.clearfix:after{display:table;content:"";}
+.clearfix:after{clear:both;}
+body{margin:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;line-height:18px;color:#333333;background-color:#ffffff;}
+a{color:#0088cc;text-decoration:none;}
+a:hover{color:#005580;text-decoration:underline;}
+.row{margin-left:-20px;*zoom:1;}.row:before,.row:after{display:table;content:"";}
+.row:after{clear:both;}
+[class*="span"]{float:left;margin-left:20px;}
+.span1{width:60px;}
+.span2{width:140px;}
+.span3{width:220px;}
+.span4{width:300px;}
+.span5{width:380px;}
+.span6{width:460px;}
+.span7{width:540px;}
+.span8{width:620px;}
+.span9{width:700px;}
+.span10{width:780px;}
+.span11{width:860px;}
+.span12,.container{width:940px;}
+.offset1{margin-left:100px;}
+.offset2{margin-left:180px;}
+.offset3{margin-left:260px;}
+.offset4{margin-left:340px;}
+.offset5{margin-left:420px;}
+.offset6{margin-left:500px;}
+.offset7{margin-left:580px;}
+.offset8{margin-left:660px;}
+.offset9{margin-left:740px;}
+.offset10{margin-left:820px;}
+.offset11{margin-left:900px;}
+.row-fluid{width:100%;*zoom:1;}.row-fluid:before,.row-fluid:after{display:table;content:"";}
+.row-fluid:after{clear:both;}
+.row-fluid>[class*="span"]{float:left;margin-left:2.127659574%;}
+.row-fluid>[class*="span"]:first-child{margin-left:0;}
+.row-fluid>.span1{width:6.382978723%;}
+.row-fluid>.span2{width:14.89361702%;}
+.row-fluid>.span3{width:23.404255317%;}
+.row-fluid>.span4{width:31.914893614%;}
+.row-fluid>.span5{width:40.425531911%;}
+.row-fluid>.span6{width:48.93617020799999%;}
+.row-fluid>.span7{width:57.446808505%;}
+.row-fluid>.span8{width:65.95744680199999%;}
+.row-fluid>.span9{width:74.468085099%;}
+.row-fluid>.span10{width:82.97872339599999%;}
+.row-fluid>.span11{width:91.489361693%;}
+.row-fluid>.span12{width:99.99999998999999%;}
+.container{width:940px;margin-left:auto;margin-right:auto;*zoom:1;}.container:before,.container:after{display:table;content:"";}
+.container:after{clear:both;}
+.container-fluid{padding-left:20px;padding-right:20px;*zoom:1;}.container-fluid:before,.container-fluid:after{display:table;content:"";}
+.container-fluid:after{clear:both;}
+p{margin:0 0 9px;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;line-height:18px;}p small{font-size:11px;color:#999999;}
+.lead{margin-bottom:18px;font-size:20px;font-weight:200;line-height:27px;}
+h1,h2,h3,h4,h5,h6{margin:0;font-weight:bold;color:#333333;text-rendering:optimizelegibility;}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{font-weight:normal;color:#999999;}
+h1{font-size:30px;line-height:36px;}h1 small{font-size:18px;}
+h2{font-size:24px;line-height:36px;}h2 small{font-size:18px;}
+h3{line-height:27px;font-size:18px;}h3 small{font-size:14px;}
+h4,h5,h6{line-height:18px;}
+h4{font-size:14px;}h4 small{font-size:12px;}
+h5{font-size:12px;}
+h6{font-size:11px;color:#999999;text-transform:uppercase;}
+.page-header{padding-bottom:17px;margin:18px 0;border-bottom:1px solid #eeeeee;}
+.page-header h1{line-height:1;}
+ul,ol{padding:0;margin:0 0 9px 25px;}
+ul ul,ul ol,ol ol,ol ul{margin-bottom:0;}
+ul{list-style:disc;}
+ol{list-style:decimal;}
+li{line-height:18px;}
+ul.unstyled,ol.unstyled{margin-left:0;list-style:none;}
+dl{margin-bottom:18px;}
+dt,dd{line-height:18px;}
+dt{font-weight:bold;}
+dd{margin-left:9px;}
+hr{margin:18px 0;border:0;border-top:1px solid #eeeeee;border-bottom:1px solid #ffffff;}
+strong{font-weight:bold;}
+em{font-style:italic;}
+.muted{color:#999999;}
+abbr{font-size:90%;text-transform:uppercase;border-bottom:1px dotted #ddd;cursor:help;}
+blockquote{padding:0 0 0 15px;margin:0 0 18px;border-left:5px solid #eeeeee;}blockquote p{margin-bottom:0;font-size:16px;font-weight:300;line-height:22.5px;}
+blockquote small{display:block;line-height:18px;color:#999999;}blockquote small:before{content:'\2014 \00A0';}
+blockquote.pull-right{float:right;padding-left:0;padding-right:15px;border-left:0;border-right:5px solid #eeeeee;}blockquote.pull-right p,blockquote.pull-right small{text-align:right;}
+q:before,q:after,blockquote:before,blockquote:after{content:"";}
+address{display:block;margin-bottom:18px;line-height:18px;font-style:normal;}
+small{font-size:100%;}
+cite{font-style:normal;}
+code,pre{padding:0 3px 2px;font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;color:#333333;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;}
+code{padding:3px 4px;color:#d14;background-color:#f7f7f9;border:1px solid #e1e1e8;}
+pre{display:block;padding:8.5px;margin:0 0 9px;font-size:12px;line-height:18px;background-color:#f5f5f5;border:1px solid #ccc;border:1px solid rgba(0, 0, 0, 0.15);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;white-space:pre;white-space:pre-wrap;word-break:break-all;word-wrap:break-word;}pre.prettyprint{margin-bottom:18px;}
+pre code{padding:0;color:inherit;background-color:transparent;border:0;}
+.pre-scrollable{max-height:340px;overflow-y:scroll;}
+form{margin:0 0 18px;}
+fieldset{padding:0;margin:0;border:0;}
+legend{display:block;width:100%;padding:0;margin-bottom:27px;font-size:19.5px;line-height:36px;color:#333333;border:0;border-bottom:1px solid #eee;}legend small{font-size:13.5px;color:#999999;}
+label,input,button,select,textarea{font-size:13px;font-weight:normal;line-height:18px;}
+input,button,select,textarea{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;}
+label{display:block;margin-bottom:5px;color:#333333;}
+input,textarea,select,.uneditable-input{display:inline-block;width:210px;height:18px;padding:4px;margin-bottom:9px;font-size:13px;line-height:18px;color:#555555;border:1px solid #ccc;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;}
+.uneditable-textarea{width:auto;height:auto;}
+label input,label textarea,label select{display:block;}
+input[type="image"],input[type="checkbox"],input[type="radio"]{width:auto;height:auto;padding:0;margin:3px 0;*margin-top:0;line-height:normal;cursor:pointer;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;border:0 \9;}
+input[type="image"]{border:0;}
+input[type="file"]{width:auto;padding:initial;line-height:initial;border:initial;background-color:#ffffff;background-color:initial;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;}
+input[type="button"],input[type="reset"],input[type="submit"]{width:auto;height:auto;}
+select,input[type="file"]{height:28px;*margin-top:4px;line-height:28px;}
+input[type="file"]{line-height:18px \9;}
+select{width:220px;background-color:#ffffff;}
+select[multiple],select[size]{height:auto;}
+input[type="image"]{-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;}
+textarea{height:auto;}
+input[type="hidden"]{display:none;}
+.radio,.checkbox{padding-left:18px;}
+.radio input[type="radio"],.checkbox input[type="checkbox"]{float:left;margin-left:-18px;}
+.controls>.radio:first-child,.controls>.checkbox:first-child{padding-top:5px;}
+.radio.inline,.checkbox.inline{display:inline-block;padding-top:5px;margin-bottom:0;vertical-align:middle;}
+.radio.inline+.radio.inline,.checkbox.inline+.checkbox.inline{margin-left:10px;}
+input,textarea{-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);-moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075);-webkit-transition:border linear 0.2s,box-shadow linear 0.2s;-moz-transition:border linear 0.2s,box-shadow linear 0.2s;-ms-transition:border linear 0.2s,box-shadow linear 0.2s;-o-transition:border linear 0.2s,box-shadow linear 0.2s;transition:border linear 0.2s,box-shadow linear 0.2s;}
+input:focus,textarea:focus{border-color:rgba(82, 168, 236, 0.8);-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 8px rgba(82, 168, 236, 0.6);-moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 8px rgba(82, 168, 236, 0.6);box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.075),0 0 8px rgba(82, 168, 236, 0.6);outline:0;outline:thin dotted \9;}
+input[type="file"]:focus,input[type="radio"]:focus,input[type="checkbox"]:focus,select:focus{-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px;}
+.input-mini{width:60px;}
+.input-small{width:90px;}
+.input-medium{width:150px;}
+.input-large{width:210px;}
+.input-xlarge{width:270px;}
+.input-xxlarge{width:530px;}
+input[class*="span"],select[class*="span"],textarea[class*="span"],.uneditable-input{float:none;margin-left:0;}
+input.span1,textarea.span1,.uneditable-input.span1{width:50px;}
+input.span2,textarea.span2,.uneditable-input.span2{width:130px;}
+input.span3,textarea.span3,.uneditable-input.span3{width:210px;}
+input.span4,textarea.span4,.uneditable-input.span4{width:290px;}
+input.span5,textarea.span5,.uneditable-input.span5{width:370px;}
+input.span6,textarea.span6,.uneditable-input.span6{width:450px;}
+input.span7,textarea.span7,.uneditable-input.span7{width:530px;}
+input.span8,textarea.span8,.uneditable-input.span8{width:610px;}
+input.span9,textarea.span9,.uneditable-input.span9{width:690px;}
+input.span10,textarea.span10,.uneditable-input.span10{width:770px;}
+input.span11,textarea.span11,.uneditable-input.span11{width:850px;}
+input.span12,textarea.span12,.uneditable-input.span12{width:930px;}
+input[disabled],select[disabled],textarea[disabled],input[readonly],select[readonly],textarea[readonly]{background-color:#f5f5f5;border-color:#ddd;cursor:not-allowed;}
+.control-group.warning>label,.control-group.warning .help-block,.control-group.warning .help-inline{color:#c09853;}
+.control-group.warning input,.control-group.warning select,.control-group.warning textarea{color:#c09853;border-color:#c09853;}.control-group.warning input:focus,.control-group.warning select:focus,.control-group.warning textarea:focus{border-color:#a47e3c;-webkit-box-shadow:0 0 6px #dbc59e;-moz-box-shadow:0 0 6px #dbc59e;box-shadow:0 0 6px #dbc59e;}
+.control-group.warning .input-prepend .add-on,.control-group.warning .input-append .add-on{color:#c09853;background-color:#fcf8e3;border-color:#c09853;}
+.control-group.error>label,.control-group.error .help-block,.control-group.error .help-inline{color:#b94a48;}
+.control-group.error input,.control-group.error select,.control-group.error textarea{color:#b94a48;border-color:#b94a48;}.control-group.error input:focus,.control-group.error select:focus,.control-group.error textarea:focus{border-color:#953b39;-webkit-box-shadow:0 0 6px #d59392;-moz-box-shadow:0 0 6px #d59392;box-shadow:0 0 6px #d59392;}
+.control-group.error .input-prepend .add-on,.control-group.error .input-append .add-on{color:#b94a48;background-color:#f2dede;border-color:#b94a48;}
+.control-group.success>label,.control-group.success .help-block,.control-group.success .help-inline{color:#468847;}
+.control-group.success input,.control-group.success select,.control-group.success textarea{color:#468847;border-color:#468847;}.control-group.success input:focus,.control-group.success select:focus,.control-group.success textarea:focus{border-color:#356635;-webkit-box-shadow:0 0 6px #7aba7b;-moz-box-shadow:0 0 6px #7aba7b;box-shadow:0 0 6px #7aba7b;}
+.control-group.success .input-prepend .add-on,.control-group.success .input-append .add-on{color:#468847;background-color:#dff0d8;border-color:#468847;}
+input:focus:required:invalid,textarea:focus:required:invalid,select:focus:required:invalid{color:#b94a48;border-color:#ee5f5b;}input:focus:required:invalid:focus,textarea:focus:required:invalid:focus,select:focus:required:invalid:focus{border-color:#e9322d;-webkit-box-shadow:0 0 6px #f8b9b7;-moz-box-shadow:0 0 6px #f8b9b7;box-shadow:0 0 6px #f8b9b7;}
+.form-actions{padding:17px 20px 18px;margin-top:18px;margin-bottom:18px;background-color:#f5f5f5;border-top:1px solid #ddd;}
+.uneditable-input{display:block;background-color:#ffffff;border-color:#eee;-webkit-box-shadow:inset 0 1px 2px rgba(0, 0, 0, 0.025);-moz-box-shadow:inset 0 1px 2px rgba(0, 0, 0, 0.025);box-shadow:inset 0 1px 2px rgba(0, 0, 0, 0.025);cursor:not-allowed;}
+:-moz-placeholder{color:#999999;}
+::-webkit-input-placeholder{color:#999999;}
+.help-block{display:block;margin-top:5px;margin-bottom:0;color:#999999;}
+.help-inline{display:inline-block;*display:inline;*zoom:1;margin-bottom:9px;vertical-align:middle;padding-left:5px;}
+.input-prepend,.input-append{margin-bottom:5px;*zoom:1;}.input-prepend:before,.input-append:before,.input-prepend:after,.input-append:after{display:table;content:"";}
+.input-prepend:after,.input-append:after{clear:both;}
+.input-prepend input,.input-append input,.input-prepend .uneditable-input,.input-append .uneditable-input{-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0;}.input-prepend input:focus,.input-append input:focus,.input-prepend .uneditable-input:focus,.input-append .uneditable-input:focus{position:relative;z-index:2;}
+.input-prepend .uneditable-input,.input-append .uneditable-input{border-left-color:#ccc;}
+.input-prepend .add-on,.input-append .add-on{float:left;display:block;width:auto;min-width:16px;height:18px;margin-right:-1px;padding:4px 5px;font-weight:normal;line-height:18px;color:#999999;text-align:center;text-shadow:0 1px 0 #ffffff;background-color:#f5f5f5;border:1px solid #ccc;-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px;}
+.input-prepend .active,.input-append .active{background-color:#a9dba9;border-color:#46a546;}
+.input-prepend .add-on{*margin-top:1px;}
+.input-append input,.input-append .uneditable-input{float:left;-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px;}
+.input-append .uneditable-input{border-left-color:#eee;border-right-color:#ccc;}
+.input-append .add-on{margin-right:0;margin-left:-1px;-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0;}
+.input-append input:first-child{*margin-left:-160px;}.input-append input:first-child+.add-on{*margin-left:-21px;}
+.search-query{padding-left:14px;padding-right:14px;margin-bottom:0;-webkit-border-radius:14px;-moz-border-radius:14px;border-radius:14px;}
+.form-search input,.form-inline input,.form-horizontal input,.form-search textarea,.form-inline textarea,.form-horizontal textarea,.form-search select,.form-inline select,.form-horizontal select,.form-search .help-inline,.form-inline .help-inline,.form-horizontal .help-inline,.form-search .uneditable-input,.form-inline .uneditable-input,.form-horizontal .uneditable-input{display:inline-block;margin-bottom:0;}
+.form-search .hide,.form-inline .hide,.form-horizontal .hide{display:none;}
+.form-search label,.form-inline label,.form-search .input-append,.form-inline .input-append,.form-search .input-prepend,.form-inline .input-prepend{display:inline-block;}
+.form-search .input-append .add-on,.form-inline .input-prepend .add-on,.form-search .input-append .add-on,.form-inline .input-prepend .add-on{vertical-align:middle;}
+.form-search .radio,.form-inline .radio,.form-search .checkbox,.form-inline .checkbox{margin-bottom:0;vertical-align:middle;}
+.control-group{margin-bottom:9px;}
+legend+.control-group{margin-top:18px;-webkit-margin-top-collapse:separate;}
+.form-horizontal .control-group{margin-bottom:18px;*zoom:1;}.form-horizontal .control-group:before,.form-horizontal .control-group:after{display:table;content:"";}
+.form-horizontal .control-group:after{clear:both;}
+.form-horizontal .control-label{float:left;width:140px;padding-top:5px;text-align:right;}
+.form-horizontal .controls{margin-left:160px;}
+.form-horizontal .form-actions{padding-left:160px;}
+table{max-width:100%;border-collapse:collapse;border-spacing:0;}
+.table{width:100%;margin-bottom:18px;}.table th,.table td{padding:8px;line-height:18px;text-align:left;vertical-align:top;border-top:1px solid #ddd;}
+.table th{font-weight:bold;}
+.table thead th{vertical-align:bottom;}
+.table thead:first-child tr th,.table thead:first-child tr td{border-top:0;}
+.table tbody+tbody{border-top:2px solid #ddd;}
+.table-condensed th,.table-condensed td{padding:4px 5px;}
+.table-bordered{border:1px solid #ddd;border-collapse:separate;*border-collapse:collapsed;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;}.table-bordered th+th,.table-bordered td+td,.table-bordered th+td,.table-bordered td+th{border-left:1px solid #ddd;}
+.table-bordered thead:first-child tr:first-child th,.table-bordered tbody:first-child tr:first-child th,.table-bordered tbody:first-child tr:first-child td{border-top:0;}
+.table-bordered thead:first-child tr:first-child th:first-child,.table-bordered tbody:first-child tr:first-child td:first-child{-webkit-border-radius:4px 0 0 0;-moz-border-radius:4px 0 0 0;border-radius:4px 0 0 0;}
+.table-bordered thead:first-child tr:first-child th:last-child,.table-bordered tbody:first-child tr:first-child td:last-child{-webkit-border-radius:0 4px 0 0;-moz-border-radius:0 4px 0 0;border-radius:0 4px 0 0;}
+.table-bordered thead:last-child tr:last-child th:first-child,.table-bordered tbody:last-child tr:last-child td:first-child{-webkit-border-radius:0 0 0 4px;-moz-border-radius:0 0 0 4px;border-radius:0 0 0 4px;}
+.table-bordered thead:last-child tr:last-child th:last-child,.table-bordered tbody:last-child tr:last-child td:last-child{-webkit-border-radius:0 0 4px 0;-moz-border-radius:0 0 4px 0;border-radius:0 0 4px 0;}
+.table-striped tbody tr:nth-child(odd) td,.table-striped tbody tr:nth-child(odd) th{background-color:#f9f9f9;}
+.table tbody tr:hover td,.table tbody tr:hover th{background-color:#f5f5f5;}
+table .span1{float:none;width:44px;margin-left:0;}
+table .span2{float:none;width:124px;margin-left:0;}
+table .span3{float:none;width:204px;margin-left:0;}
+table .span4{float:none;width:284px;margin-left:0;}
+table .span5{float:none;width:364px;margin-left:0;}
+table .span6{float:none;width:444px;margin-left:0;}
+table .span7{float:none;width:524px;margin-left:0;}
+table .span8{float:none;width:604px;margin-left:0;}
+table .span9{float:none;width:684px;margin-left:0;}
+table .span10{float:none;width:764px;margin-left:0;}
+table .span11{float:none;width:844px;margin-left:0;}
+table .span12{float:none;width:924px;margin-left:0;}
+[class^="icon-"],[class*=" icon-"]{display:inline-block;width:14px;height:14px;line-height:14px;vertical-align:text-top;background-image:url("../img/glyphicons-halflings.png");background-position:14px 14px;background-repeat:no-repeat;*margin-right:.3em;}[class^="icon-"]:last-child,[class*=" icon-"]:last-child{*margin-left:0;}
+.icon-white{background-image:url("../img/glyphicons-halflings-white.png");}
+.icon-glass{background-position:0 0;}
+.icon-music{background-position:-24px 0;}
+.icon-search{background-position:-48px 0;}
+.icon-envelope{background-position:-72px 0;}
+.icon-heart{background-position:-96px 0;}
+.icon-star{background-position:-120px 0;}
+.icon-star-empty{background-position:-144px 0;}
+.icon-user{background-position:-168px 0;}
+.icon-film{background-position:-192px 0;}
+.icon-th-large{background-position:-216px 0;}
+.icon-th{background-position:-240px 0;}
+.icon-th-list{background-position:-264px 0;}
+.icon-ok{background-position:-288px 0;}
+.icon-remove{background-position:-312px 0;}
+.icon-zoom-in{background-position:-336px 0;}
+.icon-zoom-out{background-position:-360px 0;}
+.icon-off{background-position:-384px 0;}
+.icon-signal{background-position:-408px 0;}
+.icon-cog{background-position:-432px 0;}
+.icon-trash{background-position:-456px 0;}
+.icon-home{background-position:0 -24px;}
+.icon-file{background-position:-24px -24px;}
+.icon-time{background-position:-48px -24px;}
+.icon-road{background-position:-72px -24px;}
+.icon-download-alt{background-position:-96px -24px;}
+.icon-download{background-position:-120px -24px;}
+.icon-upload{background-position:-144px -24px;}
+.icon-inbox{background-position:-168px -24px;}
+.icon-play-circle{background-position:-192px -24px;}
+.icon-repeat{background-position:-216px -24px;}
+.icon-refresh{background-position:-240px -24px;}
+.icon-list-alt{background-position:-264px -24px;}
+.icon-lock{background-position:-287px -24px;}
+.icon-flag{background-position:-312px -24px;}
+.icon-headphones{background-position:-336px -24px;}
+.icon-volume-off{background-position:-360px -24px;}
+.icon-volume-down{background-position:-384px -24px;}
+.icon-volume-up{background-position:-408px -24px;}
+.icon-qrcode{background-position:-432px -24px;}
+.icon-barcode{background-position:-456px -24px;}
+.icon-tag{background-position:0 -48px;}
+.icon-tags{background-position:-25px -48px;}
+.icon-book{background-position:-48px -48px;}
+.icon-bookmark{background-position:-72px -48px;}
+.icon-print{background-position:-96px -48px;}
+.icon-camera{background-position:-120px -48px;}
+.icon-font{background-position:-144px -48px;}
+.icon-bold{background-position:-167px -48px;}
+.icon-italic{background-position:-192px -48px;}
+.icon-text-height{background-position:-216px -48px;}
+.icon-text-width{background-position:-240px -48px;}
+.icon-align-left{background-position:-264px -48px;}
+.icon-align-center{background-position:-288px -48px;}
+.icon-align-right{background-position:-312px -48px;}
+.icon-align-justify{background-position:-336px -48px;}
+.icon-list{background-position:-360px -48px;}
+.icon-indent-left{background-position:-384px -48px;}
+.icon-indent-right{background-position:-408px -48px;}
+.icon-facetime-video{background-position:-432px -48px;}
+.icon-picture{background-position:-456px -48px;}
+.icon-pencil{background-position:0 -72px;}
+.icon-map-marker{background-position:-24px -72px;}
+.icon-adjust{background-position:-48px -72px;}
+.icon-tint{background-position:-72px -72px;}
+.icon-edit{background-position:-96px -72px;}
+.icon-share{background-position:-120px -72px;}
+.icon-check{background-position:-144px -72px;}
+.icon-move{background-position:-168px -72px;}
+.icon-step-backward{background-position:-192px -72px;}
+.icon-fast-backward{background-position:-216px -72px;}
+.icon-backward{background-position:-240px -72px;}
+.icon-play{background-position:-264px -72px;}
+.icon-pause{background-position:-288px -72px;}
+.icon-stop{background-position:-312px -72px;}
+.icon-forward{background-position:-336px -72px;}
+.icon-fast-forward{background-position:-360px -72px;}
+.icon-step-forward{background-position:-384px -72px;}
+.icon-eject{background-position:-408px -72px;}
+.icon-chevron-left{background-position:-432px -72px;}
+.icon-chevron-right{background-position:-456px -72px;}
+.icon-plus-sign{background-position:0 -96px;}
+.icon-minus-sign{background-position:-24px -96px;}
+.icon-remove-sign{background-position:-48px -96px;}
+.icon-ok-sign{background-position:-72px -96px;}
+.icon-question-sign{background-position:-96px -96px;}
+.icon-info-sign{background-position:-120px -96px;}
+.icon-screenshot{background-position:-144px -96px;}
+.icon-remove-circle{background-position:-168px -96px;}
+.icon-ok-circle{background-position:-192px -96px;}
+.icon-ban-circle{background-position:-216px -96px;}
+.icon-arrow-left{background-position:-240px -96px;}
+.icon-arrow-right{background-position:-264px -96px;}
+.icon-arrow-up{background-position:-289px -96px;}
+.icon-arrow-down{background-position:-312px -96px;}
+.icon-share-alt{background-position:-336px -96px;}
+.icon-resize-full{background-position:-360px -96px;}
+.icon-resize-small{background-position:-384px -96px;}
+.icon-plus{background-position:-408px -96px;}
+.icon-minus{background-position:-433px -96px;}
+.icon-asterisk{background-position:-456px -96px;}
+.icon-exclamation-sign{background-position:0 -120px;}
+.icon-gift{background-position:-24px -120px;}
+.icon-leaf{background-position:-48px -120px;}
+.icon-fire{background-position:-72px -120px;}
+.icon-eye-open{background-position:-96px -120px;}
+.icon-eye-close{background-position:-120px -120px;}
+.icon-warning-sign{background-position:-144px -120px;}
+.icon-plane{background-position:-168px -120px;}
+.icon-calendar{background-position:-192px -120px;}
+.icon-random{background-position:-216px -120px;}
+.icon-comment{background-position:-240px -120px;}
+.icon-magnet{background-position:-264px -120px;}
+.icon-chevron-up{background-position:-288px -120px;}
+.icon-chevron-down{background-position:-313px -119px;}
+.icon-retweet{background-position:-336px -120px;}
+.icon-shopping-cart{background-position:-360px -120px;}
+.icon-folder-close{background-position:-384px -120px;}
+.icon-folder-open{background-position:-408px -120px;}
+.icon-resize-vertical{background-position:-432px -119px;}
+.icon-resize-horizontal{background-position:-456px -118px;}
+.dropdown{position:relative;}
+.dropdown-toggle{*margin-bottom:-3px;}
+.dropdown-toggle:active,.open .dropdown-toggle{outline:0;}
+.caret{display:inline-block;width:0;height:0;text-indent:-99999px;*text-indent:0;vertical-align:top;border-left:4px solid transparent;border-right:4px solid transparent;border-top:4px solid #000000;opacity:0.3;filter:alpha(opacity=30);content:"\2193";}
+.dropdown .caret{margin-top:8px;margin-left:2px;}
+.dropdown:hover .caret,.open.dropdown .caret{opacity:1;filter:alpha(opacity=100);}
+.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;float:left;display:none;min-width:160px;_width:160px;padding:4px 0;margin:0;list-style:none;background-color:#ffffff;border-color:#ccc;border-color:rgba(0, 0, 0, 0.2);border-style:solid;border-width:1px;-webkit-border-radius:0 0 5px 5px;-moz-border-radius:0 0 5px 5px;border-radius:0 0 5px 5px;-webkit-box-shadow:0 5px 10px rgba(0, 0, 0, 0.2);-moz-box-shadow:0 5px 10px rgba(0, 0, 0, 0.2);box-shadow:0 5px 10px rgba(0, 0, 0, 0.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box;*border-right-width:2px;*border-bottom-width:2px;}.dropdown-menu.bottom-up{top:auto;bottom:100%;margin-bottom:2px;}
+.dropdown-menu .divider{height:1px;margin:5px 1px;overflow:hidden;background-color:#e5e5e5;border-bottom:1px solid #ffffff;*width:100%;*margin:-5px 0 5px;}
+.dropdown-menu a{display:block;padding:3px 15px;clear:both;font-weight:normal;line-height:18px;color:#555555;white-space:nowrap;}
+.dropdown-menu li>a:hover,.dropdown-menu .active>a,.dropdown-menu .active>a:hover{color:#ffffff;text-decoration:none;background-color:#0088cc;}
+.dropdown.open{*z-index:1000;}.dropdown.open .dropdown-toggle{color:#ffffff;background:#ccc;background:rgba(0, 0, 0, 0.3);}
+.dropdown.open .dropdown-menu{display:block;}
+.typeahead{margin-top:2px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;}
+.well{min-height:20px;padding:19px;margin-bottom:20px;background-color:#f5f5f5;border:1px solid #eee;border:1px solid rgba(0, 0, 0, 0.05);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05);-moz-box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05);box-shadow:inset 0 1px 1px rgba(0, 0, 0, 0.05);}.well blockquote{border-color:#ddd;border-color:rgba(0, 0, 0, 0.15);}
+.fade{-webkit-transition:opacity 0.15s linear;-moz-transition:opacity 0.15s linear;-ms-transition:opacity 0.15s linear;-o-transition:opacity 0.15s linear;transition:opacity 0.15s linear;opacity:0;}.fade.in{opacity:1;}
+.collapse{-webkit-transition:height 0.35s ease;-moz-transition:height 0.35s ease;-ms-transition:height 0.35s ease;-o-transition:height 0.35s ease;transition:height 0.35s ease;position:relative;overflow:hidden;height:0;}.collapse.in{height:auto;}
+.close{float:right;font-size:20px;font-weight:bold;line-height:18px;color:#000000;text-shadow:0 1px 0 #ffffff;opacity:0.2;filter:alpha(opacity=20);}.close:hover{color:#000000;text-decoration:none;opacity:0.4;filter:alpha(opacity=40);cursor:pointer;}
+.btn{display:inline-block;padding:4px 10px 4px;margin-bottom:0;font-size:13px;line-height:18px;color:#333333;text-align:center;text-shadow:0 1px 1px rgba(255, 255, 255, 0.75);vertical-align:middle;background-color:#f5f5f5;background-image:-moz-linear-gradient(top, #ffffff, #e6e6e6);background-image:-ms-linear-gradient(top, #ffffff, #e6e6e6);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6));background-image:-webkit-linear-gradient(top, #ffffff, #e6e6e6);background-image:-o-linear-gradient(top, #ffffff, #e6e6e6);background-image:linear-gradient(top, #ffffff, #e6e6e6);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#e6e6e6', GradientType=0);border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);border:1px solid #ccc;border-bottom-color:#bbb;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 0 rgba(255, 255, 255, 0.2),0 1px 2px rgba(0, 0, 0, 0.05);-moz-box-shadow:inset 0 1px 0 rgba(255, 255, 255, 0.2),0 1px 2px rgba(0, 0, 0, 0.05);box-shadow:inset 0 1px 0 rgba(255, 255, 255, 0.2),0 1px 2px rgba(0, 0, 0, 0.05);cursor:pointer;filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);*margin-left:.3em;}.btn:hover,.btn:active,.btn.active,.btn.disabled,.btn[disabled]{background-color:#e6e6e6;}
+.btn:active,.btn.active{background-color:#cccccc \9;}
+.btn:first-child{*margin-left:0;}
+.btn:hover{color:#333333;text-decoration:none;background-color:#e6e6e6;background-position:0 -15px;-webkit-transition:background-position 0.1s linear;-moz-transition:background-position 0.1s linear;-ms-transition:background-position 0.1s linear;-o-transition:background-position 0.1s linear;transition:background-position 0.1s linear;}
+.btn:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px;}
+.btn.active,.btn:active{background-image:none;-webkit-box-shadow:inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);-moz-box-shadow:inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);box-shadow:inset 0 2px 4px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);background-color:#e6e6e6;background-color:#d9d9d9 \9;outline:0;}
+.btn.disabled,.btn[disabled]{cursor:default;background-image:none;background-color:#e6e6e6;opacity:0.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none;}
+.btn-large{padding:9px 14px;font-size:15px;line-height:normal;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;}
+.btn-large [class^="icon-"]{margin-top:1px;}
+.btn-small{padding:5px 9px;font-size:11px;line-height:16px;}
+.btn-small [class^="icon-"]{margin-top:-1px;}
+.btn-mini{padding:2px 6px;font-size:11px;line-height:14px;}
+.btn-primary,.btn-primary:hover,.btn-warning,.btn-warning:hover,.btn-danger,.btn-danger:hover,.btn-success,.btn-success:hover,.btn-info,.btn-info:hover,.btn-inverse,.btn-inverse:hover{text-shadow:0 -1px 0 rgba(0, 0, 0, 0.25);color:#ffffff;}
+.btn-primary.active,.btn-warning.active,.btn-danger.active,.btn-success.active,.btn-info.active,.btn-dark.active{color:rgba(255, 255, 255, 0.75);}
+.btn-primary{background-color:#006dcc;background-image:-moz-linear-gradient(top, #0088cc, #0044cc);background-image:-ms-linear-gradient(top, #0088cc, #0044cc);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc));background-image:-webkit-linear-gradient(top, #0088cc, #0044cc);background-image:-o-linear-gradient(top, #0088cc, #0044cc);background-image:linear-gradient(top, #0088cc, #0044cc);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0);border-color:#0044cc #0044cc #002a80;border-color:rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);}.btn-primary:hover,.btn-primary:active,.btn-primary.active,.btn-primary.disabled,.btn-primary[disabled]{background-color:#0044cc;}
+.btn-primary:active,.btn-primary.active{background-color:#003399 \9;}
+.btn-warning{background-color:#faa732;background-image:-moz-linear-gradient(top, #fbb450, #f89406);background-image:-ms-linear-gradient(top, #fbb450, #f89406);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#fbb450), to(#f89406));background-image:-webkit-linear-gradient(top, #fbb450, #f89406);background-image:-o-linear-gradient(top, #fbb450, #f89406);background-image:linear-gradient(top, #fbb450, #f89406);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fbb450', endColorstr='#f89406', GradientType=0);border-color:#f89406 #f89406 #ad6704;border-color:rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);}.btn-warning:hover,.btn-warning:active,.btn-warning.active,.btn-warning.disabled,.btn-warning[disabled]{background-color:#f89406;}
+.btn-warning:active,.btn-warning.active{background-color:#c67605 \9;}
+.btn-danger{background-color:#da4f49;background-image:-moz-linear-gradient(top, #ee5f5b, #bd362f);background-image:-ms-linear-gradient(top, #ee5f5b, #bd362f);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#bd362f));background-image:-webkit-linear-gradient(top, #ee5f5b, #bd362f);background-image:-o-linear-gradient(top, #ee5f5b, #bd362f);background-image:linear-gradient(top, #ee5f5b, #bd362f);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ee5f5b', endColorstr='#bd362f', GradientType=0);border-color:#bd362f #bd362f #802420;border-color:rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);}.btn-danger:hover,.btn-danger:active,.btn-danger.active,.btn-danger.disabled,.btn-danger[disabled]{background-color:#bd362f;}
+.btn-danger:active,.btn-danger.active{background-color:#942a25 \9;}
+.btn-success{background-color:#5bb75b;background-image:-moz-linear-gradient(top, #62c462, #51a351);background-image:-ms-linear-gradient(top, #62c462, #51a351);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#51a351));background-image:-webkit-linear-gradient(top, #62c462, #51a351);background-image:-o-linear-gradient(top, #62c462, #51a351);background-image:linear-gradient(top, #62c462, #51a351);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#62c462', endColorstr='#51a351', GradientType=0);border-color:#51a351 #51a351 #387038;border-color:rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);}.btn-success:hover,.btn-success:active,.btn-success.active,.btn-success.disabled,.btn-success[disabled]{background-color:#51a351;}
+.btn-success:active,.btn-success.active{background-color:#408140 \9;}
+.btn-info{background-color:#49afcd;background-image:-moz-linear-gradient(top, #5bc0de, #2f96b4);background-image:-ms-linear-gradient(top, #5bc0de, #2f96b4);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#2f96b4));background-image:-webkit-linear-gradient(top, #5bc0de, #2f96b4);background-image:-o-linear-gradient(top, #5bc0de, #2f96b4);background-image:linear-gradient(top, #5bc0de, #2f96b4);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#5bc0de', endColorstr='#2f96b4', GradientType=0);border-color:#2f96b4 #2f96b4 #1f6377;border-color:rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);}.btn-info:hover,.btn-info:active,.btn-info.active,.btn-info.disabled,.btn-info[disabled]{background-color:#2f96b4;}
+.btn-info:active,.btn-info.active{background-color:#24748c \9;}
+.btn-inverse{background-color:#393939;background-image:-moz-linear-gradient(top, #454545, #262626);background-image:-ms-linear-gradient(top, #454545, #262626);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#454545), to(#262626));background-image:-webkit-linear-gradient(top, #454545, #262626);background-image:-o-linear-gradient(top, #454545, #262626);background-image:linear-gradient(top, #454545, #262626);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#454545', endColorstr='#262626', GradientType=0);border-color:#262626 #262626 #000000;border-color:rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);}.btn-inverse:hover,.btn-inverse:active,.btn-inverse.active,.btn-inverse.disabled,.btn-inverse[disabled]{background-color:#262626;}
+.btn-inverse:active,.btn-inverse.active{background-color:#0c0c0c \9;}
+button.btn,input[type="submit"].btn{*padding-top:2px;*padding-bottom:2px;}button.btn::-moz-focus-inner,input[type="submit"].btn::-moz-focus-inner{padding:0;border:0;}
+button.btn.large,input[type="submit"].btn.large{*padding-top:7px;*padding-bottom:7px;}
+button.btn.small,input[type="submit"].btn.small{*padding-top:3px;*padding-bottom:3px;}
+.btn-group{position:relative;*zoom:1;*margin-left:.3em;}.btn-group:before,.btn-group:after{display:table;content:"";}
+.btn-group:after{clear:both;}
+.btn-group:first-child{*margin-left:0;}
+.btn-group+.btn-group{margin-left:5px;}
+.btn-toolbar{margin-top:9px;margin-bottom:9px;}.btn-toolbar .btn-group{display:inline-block;*display:inline;*zoom:1;}
+.btn-group .btn{position:relative;float:left;margin-left:-1px;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;}
+.btn-group .btn:first-child{margin-left:0;-webkit-border-top-left-radius:4px;-moz-border-radius-topleft:4px;border-top-left-radius:4px;-webkit-border-bottom-left-radius:4px;-moz-border-radius-bottomleft:4px;border-bottom-left-radius:4px;}
+.btn-group .btn:last-child,.btn-group .dropdown-toggle{-webkit-border-top-right-radius:4px;-moz-border-radius-topright:4px;border-top-right-radius:4px;-webkit-border-bottom-right-radius:4px;-moz-border-radius-bottomright:4px;border-bottom-right-radius:4px;}
+.btn-group .btn.large:first-child{margin-left:0;-webkit-border-top-left-radius:6px;-moz-border-radius-topleft:6px;border-top-left-radius:6px;-webkit-border-bottom-left-radius:6px;-moz-border-radius-bottomleft:6px;border-bottom-left-radius:6px;}
+.btn-group .btn.large:last-child,.btn-group .large.dropdown-toggle{-webkit-border-top-right-radius:6px;-moz-border-radius-topright:6px;border-top-right-radius:6px;-webkit-border-bottom-right-radius:6px;-moz-border-radius-bottomright:6px;border-bottom-right-radius:6px;}
+.btn-group .btn:hover,.btn-group .btn:focus,.btn-group .btn:active,.btn-group .btn.active{z-index:2;}
+.btn-group .dropdown-toggle:active,.btn-group.open .dropdown-toggle{outline:0;}
+.btn-group .dropdown-toggle{padding-left:8px;padding-right:8px;-webkit-box-shadow:inset 1px 0 0 rgba(255, 255, 255, 0.125),inset 0 1px 0 rgba(255, 255, 255, 0.2),0 1px 2px rgba(0, 0, 0, 0.05);-moz-box-shadow:inset 1px 0 0 rgba(255, 255, 255, 0.125),inset 0 1px 0 rgba(255, 255, 255, 0.2),0 1px 2px rgba(0, 0, 0, 0.05);box-shadow:inset 1px 0 0 rgba(255, 255, 255, 0.125),inset 0 1px 0 rgba(255, 255, 255, 0.2),0 1px 2px rgba(0, 0, 0, 0.05);*padding-top:5px;*padding-bottom:5px;}
+.btn-group.open{*z-index:1000;}.btn-group.open .dropdown-menu{display:block;margin-top:1px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;}
+.btn-group.open .dropdown-toggle{background-image:none;-webkit-box-shadow:inset 0 1px 6px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);-moz-box-shadow:inset 0 1px 6px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);box-shadow:inset 0 1px 6px rgba(0, 0, 0, 0.15),0 1px 2px rgba(0, 0, 0, 0.05);}
+.btn .caret{margin-top:7px;margin-left:0;}
+.btn:hover .caret,.open.btn-group .caret{opacity:1;filter:alpha(opacity=100);}
+.btn-primary .caret,.btn-danger .caret,.btn-info .caret,.btn-success .caret,.btn-inverse .caret{border-top-color:#ffffff;opacity:0.75;filter:alpha(opacity=75);}
+.btn-small .caret{margin-top:4px;}
+.alert{padding:8px 35px 8px 14px;margin-bottom:18px;text-shadow:0 1px 0 rgba(255, 255, 255, 0.5);background-color:#fcf8e3;border:1px solid #fbeed5;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;}
+.alert,.alert-heading{color:#c09853;}
+.alert .close{position:relative;top:-2px;right:-21px;line-height:18px;}
+.alert-success{background-color:#dff0d8;border-color:#d6e9c6;}
+.alert-success,.alert-success .alert-heading{color:#468847;}
+.alert-danger,.alert-error{background-color:#f2dede;border-color:#eed3d7;}
+.alert-danger,.alert-error,.alert-danger .alert-heading,.alert-error .alert-heading{color:#b94a48;}
+.alert-info{background-color:#d9edf7;border-color:#bce8f1;}
+.alert-info,.alert-info .alert-heading{color:#3a87ad;}
+.alert-block{padding-top:14px;padding-bottom:14px;}
+.alert-block>p,.alert-block>ul{margin-bottom:0;}
+.alert-block p+p{margin-top:5px;}
+.nav{margin-left:0;margin-bottom:18px;list-style:none;}
+.nav>li>a{display:block;}
+.nav>li>a:hover{text-decoration:none;background-color:#eeeeee;}
+.nav .nav-header{display:block;padding:3px 15px;font-size:11px;font-weight:bold;line-height:18px;color:#999999;text-shadow:0 1px 0 rgba(255, 255, 255, 0.5);text-transform:uppercase;}
+.nav li+.nav-header{margin-top:9px;}
+.nav-list{padding-left:14px;padding-right:14px;margin-bottom:0;}
+.nav-list>li>a,.nav-list .nav-header{margin-left:-15px;margin-right:-15px;text-shadow:0 1px 0 rgba(255, 255, 255, 0.5);}
+.nav-list>li>a{padding:3px 15px;}
+.nav-list .active>a,.nav-list .active>a:hover{color:#ffffff;text-shadow:0 -1px 0 rgba(0, 0, 0, 0.2);background-color:#0088cc;}
+.nav-list [class^="icon-"]{margin-right:2px;}
+.nav-tabs,.nav-pills{*zoom:1;}.nav-tabs:before,.nav-pills:before,.nav-tabs:after,.nav-pills:after{display:table;content:"";}
+.nav-tabs:after,.nav-pills:after{clear:both;}
+.nav-tabs>li,.nav-pills>li{float:left;}
+.nav-tabs>li>a,.nav-pills>li>a{padding-right:12px;padding-left:12px;margin-right:2px;line-height:14px;}
+.nav-tabs{border-bottom:1px solid #ddd;}
+.nav-tabs>li{margin-bottom:-1px;}
+.nav-tabs>li>a{padding-top:9px;padding-bottom:9px;border:1px solid transparent;-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0;}.nav-tabs>li>a:hover{border-color:#eeeeee #eeeeee #dddddd;}
+.nav-tabs>.active>a,.nav-tabs>.active>a:hover{color:#555555;background-color:#ffffff;border:1px solid #ddd;border-bottom-color:transparent;cursor:default;}
+.nav-pills>li>a{padding-top:8px;padding-bottom:8px;margin-top:2px;margin-bottom:2px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;}
+.nav-pills .active>a,.nav-pills .active>a:hover{color:#ffffff;background-color:#0088cc;}
+.nav-stacked>li{float:none;}
+.nav-stacked>li>a{margin-right:0;}
+.nav-tabs.nav-stacked{border-bottom:0;}
+.nav-tabs.nav-stacked>li>a{border:1px solid #ddd;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;}
+.nav-tabs.nav-stacked>li:first-child>a{-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0;}
+.nav-tabs.nav-stacked>li:last-child>a{-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px;}
+.nav-tabs.nav-stacked>li>a:hover{border-color:#ddd;z-index:2;}
+.nav-pills.nav-stacked>li>a{margin-bottom:3px;}
+.nav-pills.nav-stacked>li:last-child>a{margin-bottom:1px;}
+.nav-tabs .dropdown-menu,.nav-pills .dropdown-menu{margin-top:1px;border-width:1px;}
+.nav-pills .dropdown-menu{-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;}
+.nav-tabs .dropdown-toggle .caret,.nav-pills .dropdown-toggle .caret{border-top-color:#0088cc;margin-top:6px;}
+.nav-tabs .dropdown-toggle:hover .caret,.nav-pills .dropdown-toggle:hover .caret{border-top-color:#005580;}
+.nav-tabs .active .dropdown-toggle .caret,.nav-pills .active .dropdown-toggle .caret{border-top-color:#333333;}
+.nav>.dropdown.active>a:hover{color:#000000;cursor:pointer;}
+.nav-tabs .open .dropdown-toggle,.nav-pills .open .dropdown-toggle,.nav>.open.active>a:hover{color:#ffffff;background-color:#999999;border-color:#999999;}
+.nav .open .caret,.nav .open.active .caret,.nav .open a:hover .caret{border-top-color:#ffffff;opacity:1;filter:alpha(opacity=100);}
+.tabs-stacked .open>a:hover{border-color:#999999;}
+.tabbable{*zoom:1;}.tabbable:before,.tabbable:after{display:table;content:"";}
+.tabbable:after{clear:both;}
+.tab-content{overflow:hidden;}
+.tabs-below .nav-tabs,.tabs-right .nav-tabs,.tabs-left .nav-tabs{border-bottom:0;}
+.tab-content>.tab-pane,.pill-content>.pill-pane{display:none;}
+.tab-content>.active,.pill-content>.active{display:block;}
+.tabs-below .nav-tabs{border-top:1px solid #ddd;}
+.tabs-below .nav-tabs>li{margin-top:-1px;margin-bottom:0;}
+.tabs-below .nav-tabs>li>a{-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px;}.tabs-below .nav-tabs>li>a:hover{border-bottom-color:transparent;border-top-color:#ddd;}
+.tabs-below .nav-tabs .active>a,.tabs-below .nav-tabs .active>a:hover{border-color:transparent #ddd #ddd #ddd;}
+.tabs-left .nav-tabs>li,.tabs-right .nav-tabs>li{float:none;}
+.tabs-left .nav-tabs>li>a,.tabs-right .nav-tabs>li>a{min-width:74px;margin-right:0;margin-bottom:3px;}
+.tabs-left .nav-tabs{float:left;margin-right:19px;border-right:1px solid #ddd;}
+.tabs-left .nav-tabs>li>a{margin-right:-1px;-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px;}
+.tabs-left .nav-tabs>li>a:hover{border-color:#eeeeee #dddddd #eeeeee #eeeeee;}
+.tabs-left .nav-tabs .active>a,.tabs-left .nav-tabs .active>a:hover{border-color:#ddd transparent #ddd #ddd;*border-right-color:#ffffff;}
+.tabs-right .nav-tabs{float:right;margin-left:19px;border-left:1px solid #ddd;}
+.tabs-right .nav-tabs>li>a{margin-left:-1px;-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0;}
+.tabs-right .nav-tabs>li>a:hover{border-color:#eeeeee #eeeeee #eeeeee #dddddd;}
+.tabs-right .nav-tabs .active>a,.tabs-right .nav-tabs .active>a:hover{border-color:#ddd #ddd #ddd transparent;*border-left-color:#ffffff;}
+.navbar{overflow:visible;margin-bottom:18px;}
+.navbar-inner{padding-left:20px;padding-right:20px;background-color:#2c2c2c;background-image:-moz-linear-gradient(top, #333333, #222222);background-image:-ms-linear-gradient(top, #333333, #222222);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#333333), to(#222222));background-image:-webkit-linear-gradient(top, #333333, #222222);background-image:-o-linear-gradient(top, #333333, #222222);background-image:linear-gradient(top, #333333, #222222);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#333333', endColorstr='#222222', GradientType=0);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:0 1px 3px rgba(0, 0, 0, 0.25),inset 0 -1px 0 rgba(0, 0, 0, 0.1);-moz-box-shadow:0 1px 3px rgba(0, 0, 0, 0.25),inset 0 -1px 0 rgba(0, 0, 0, 0.1);box-shadow:0 1px 3px rgba(0, 0, 0, 0.25),inset 0 -1px 0 rgba(0, 0, 0, 0.1);}
+.btn-navbar{display:none;float:right;padding:7px 10px;margin-left:5px;margin-right:5px;background-color:#2c2c2c;background-image:-moz-linear-gradient(top, #333333, #222222);background-image:-ms-linear-gradient(top, #333333, #222222);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#333333), to(#222222));background-image:-webkit-linear-gradient(top, #333333, #222222);background-image:-o-linear-gradient(top, #333333, #222222);background-image:linear-gradient(top, #333333, #222222);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#333333', endColorstr='#222222', GradientType=0);border-color:#222222 #222222 #000000;border-color:rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled = false);-webkit-box-shadow:inset 0 1px 0 rgba(255, 255, 255, 0.1),0 1px 0 rgba(255, 255, 255, 0.075);-moz-box-shadow:inset 0 1px 0 rgba(255, 255, 255, 0.1),0 1px 0 rgba(255, 255, 255, 0.075);box-shadow:inset 0 1px 0 rgba(255, 255, 255, 0.1),0 1px 0 rgba(255, 255, 255, 0.075);}.btn-navbar:hover,.btn-navbar:active,.btn-navbar.active,.btn-navbar.disabled,.btn-navbar[disabled]{background-color:#222222;}
+.btn-navbar:active,.btn-navbar.active{background-color:#080808 \9;}
+.btn-navbar .icon-bar{display:block;width:18px;height:2px;background-color:#f5f5f5;-webkit-border-radius:1px;-moz-border-radius:1px;border-radius:1px;-webkit-box-shadow:0 1px 0 rgba(0, 0, 0, 0.25);-moz-box-shadow:0 1px 0 rgba(0, 0, 0, 0.25);box-shadow:0 1px 0 rgba(0, 0, 0, 0.25);}
+.btn-navbar .icon-bar+.icon-bar{margin-top:3px;}
+.nav-collapse.collapse{height:auto;}
+.navbar .brand:hover{text-decoration:none;}
+.navbar .brand{float:left;display:block;padding:8px 20px 12px;margin-left:-20px;font-size:20px;font-weight:200;line-height:1;color:#ffffff;}
+.navbar .navbar-text{margin-bottom:0;line-height:40px;color:#999999;}.navbar .navbar-text a:hover{color:#ffffff;background-color:transparent;}
+.navbar .btn,.navbar .btn-group{margin-top:5px;}
+.navbar .btn-group .btn{margin-top:0;}
+.navbar-form{margin-bottom:0;*zoom:1;}.navbar-form:before,.navbar-form:after{display:table;content:"";}
+.navbar-form:after{clear:both;}
+.navbar-form input,.navbar-form select{display:inline-block;margin-top:5px;margin-bottom:0;}
+.navbar-form .radio,.navbar-form .checkbox{margin-top:5px;}
+.navbar-form input[type="image"],.navbar-form input[type="checkbox"],.navbar-form input[type="radio"]{margin-top:3px;}
+.navbar-form .input-append,.navbar-form .input-prepend{margin-top:6px;white-space:nowrap;}.navbar-form .input-append input,.navbar-form .input-prepend input{margin-top:0;}
+.navbar-search{position:relative;float:left;margin-top:6px;margin-bottom:0;}.navbar-search .search-query{padding:4px 9px;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;font-weight:normal;line-height:1;color:#ffffff;color:rgba(255, 255, 255, 0.75);background:#666;background:rgba(255, 255, 255, 0.3);border:1px solid #111;-webkit-box-shadow:inset 0 1px 2px rgba(0, 0, 0, 0.1),0 1px 0px rgba(255, 255, 255, 0.15);-moz-box-shadow:inset 0 1px 2px rgba(0, 0, 0, 0.1),0 1px 0px rgba(255, 255, 255, 0.15);box-shadow:inset 0 1px 2px rgba(0, 0, 0, 0.1),0 1px 0px rgba(255, 255, 255, 0.15);-webkit-transition:none;-moz-transition:none;-ms-transition:none;-o-transition:none;transition:none;}.navbar-search .search-query :-moz-placeholder{color:#eeeeee;}
+.navbar-search .search-query::-webkit-input-placeholder{color:#eeeeee;}
+.navbar-search .search-query:hover{color:#ffffff;background-color:#999999;background-color:rgba(255, 255, 255, 0.5);}
+.navbar-search .search-query:focus,.navbar-search .search-query.focused{padding:5px 10px;color:#333333;text-shadow:0 1px 0 #ffffff;background-color:#ffffff;border:0;-webkit-box-shadow:0 0 3px rgba(0, 0, 0, 0.15);-moz-box-shadow:0 0 3px rgba(0, 0, 0, 0.15);box-shadow:0 0 3px rgba(0, 0, 0, 0.15);outline:0;}
+.navbar-fixed-top{position:fixed;top:0;right:0;left:0;z-index:1030;}
+.navbar-fixed-top .navbar-inner{padding-left:0;padding-right:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;}
+.navbar .nav{position:relative;left:0;display:block;float:left;margin:0 10px 0 0;}
+.navbar .nav.pull-right{float:right;}
+.navbar .nav>li{display:block;float:left;}
+.navbar .nav>li>a{float:none;padding:10px 10px 11px;line-height:19px;color:#999999;text-decoration:none;text-shadow:0 -1px 0 rgba(0, 0, 0, 0.25);}
+.navbar .nav>li>a:hover{background-color:transparent;color:#ffffff;text-decoration:none;}
+.navbar .nav .active>a,.navbar .nav .active>a:hover{color:#ffffff;text-decoration:none;background-color:#222222;}
+.navbar .divider-vertical{height:40px;width:1px;margin:0 9px;overflow:hidden;background-color:#222222;border-right:1px solid #333333;}
+.navbar .nav.pull-right{margin-left:10px;margin-right:0;}
+.navbar .dropdown-menu{margin-top:1px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;}.navbar .dropdown-menu:before{content:'';display:inline-block;border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid #ccc;border-bottom-color:rgba(0, 0, 0, 0.2);position:absolute;top:-7px;left:9px;}
+.navbar .dropdown-menu:after{content:'';display:inline-block;border-left:6px solid transparent;border-right:6px solid transparent;border-bottom:6px solid #ffffff;position:absolute;top:-6px;left:10px;}
+.navbar .nav .dropdown-toggle .caret,.navbar .nav .open.dropdown .caret{border-top-color:#ffffff;}
+.navbar .nav .active .caret{opacity:1;filter:alpha(opacity=100);}
+.navbar .nav .open>.dropdown-toggle,.navbar .nav .active>.dropdown-toggle,.navbar .nav .open.active>.dropdown-toggle{background-color:transparent;}
+.navbar .nav .active>.dropdown-toggle:hover{color:#ffffff;}
+.navbar .nav.pull-right .dropdown-menu{left:auto;right:0;}.navbar .nav.pull-right .dropdown-menu:before{left:auto;right:12px;}
+.navbar .nav.pull-right .dropdown-menu:after{left:auto;right:13px;}
+.breadcrumb{padding:7px 14px;margin:0 0 18px;background-color:#fbfbfb;background-image:-moz-linear-gradient(top, #ffffff, #f5f5f5);background-image:-ms-linear-gradient(top, #ffffff, #f5f5f5);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#f5f5f5));background-image:-webkit-linear-gradient(top, #ffffff, #f5f5f5);background-image:-o-linear-gradient(top, #ffffff, #f5f5f5);background-image:linear-gradient(top, #ffffff, #f5f5f5);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#f5f5f5', GradientType=0);border:1px solid #ddd;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;-webkit-box-shadow:inset 0 1px 0 #ffffff;-moz-box-shadow:inset 0 1px 0 #ffffff;box-shadow:inset 0 1px 0 #ffffff;}.breadcrumb li{display:inline-block;text-shadow:0 1px 0 #ffffff;}
+.breadcrumb .divider{padding:0 5px;color:#999999;}
+.breadcrumb .active a{color:#333333;}
+.pagination{height:36px;margin:18px 0;}
+.pagination ul{display:inline-block;*display:inline;*zoom:1;margin-left:0;margin-bottom:0;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 2px rgba(0, 0, 0, 0.05);-moz-box-shadow:0 1px 2px rgba(0, 0, 0, 0.05);box-shadow:0 1px 2px rgba(0, 0, 0, 0.05);}
+.pagination li{display:inline;}
+.pagination a{float:left;padding:0 14px;line-height:34px;text-decoration:none;border:1px solid #ddd;border-left-width:0;}
+.pagination a:hover,.pagination .active a{background-color:#f5f5f5;}
+.pagination .active a{color:#999999;cursor:default;}
+.pagination .disabled a,.pagination .disabled a:hover{color:#999999;background-color:transparent;cursor:default;}
+.pagination li:first-child a{border-left-width:1px;-webkit-border-radius:3px 0 0 3px;-moz-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px;}
+.pagination li:last-child a{-webkit-border-radius:0 3px 3px 0;-moz-border-radius:0 3px 3px 0;border-radius:0 3px 3px 0;}
+.pagination-centered{text-align:center;}
+.pagination-right{text-align:right;}
+.pager{margin-left:0;margin-bottom:18px;list-style:none;text-align:center;*zoom:1;}.pager:before,.pager:after{display:table;content:"";}
+.pager:after{clear:both;}
+.pager li{display:inline;}
+.pager a{display:inline-block;padding:5px 14px;background-color:#fff;border:1px solid #ddd;-webkit-border-radius:15px;-moz-border-radius:15px;border-radius:15px;}
+.pager a:hover{text-decoration:none;background-color:#f5f5f5;}
+.pager .next a{float:right;}
+.pager .previous a{float:left;}
+.modal-open .dropdown-menu{z-index:2050;}
+.modal-open .dropdown.open{*z-index:2050;}
+.modal-open .popover{z-index:2060;}
+.modal-open .tooltip{z-index:2070;}
+.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;background-color:#000000;}.modal-backdrop.fade{opacity:0;}
+.modal-backdrop,.modal-backdrop.fade.in{opacity:0.8;filter:alpha(opacity=80);}
+.modal{position:fixed;top:50%;left:50%;z-index:1050;max-height:500px;overflow:auto;width:560px;margin:-250px 0 0 -280px;background-color:#ffffff;border:1px solid #999;border:1px solid rgba(0, 0, 0, 0.3);*border:1px solid #999;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 3px 7px rgba(0, 0, 0, 0.3);-moz-box-shadow:0 3px 7px rgba(0, 0, 0, 0.3);box-shadow:0 3px 7px rgba(0, 0, 0, 0.3);-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box;}.modal.fade{-webkit-transition:opacity .3s linear, top .3s ease-out;-moz-transition:opacity .3s linear, top .3s ease-out;-ms-transition:opacity .3s linear, top .3s ease-out;-o-transition:opacity .3s linear, top .3s ease-out;transition:opacity .3s linear, top .3s ease-out;top:-25%;}
+.modal.fade.in{top:50%;}
+.modal-header{padding:9px 15px;border-bottom:1px solid #eee;}.modal-header .close{margin-top:2px;}
+.modal-body{padding:15px;}
+.modal-body .modal-form{margin-bottom:0;}
+.modal-footer{padding:14px 15px 15px;margin-bottom:0;background-color:#f5f5f5;border-top:1px solid #ddd;-webkit-border-radius:0 0 6px 6px;-moz-border-radius:0 0 6px 6px;border-radius:0 0 6px 6px;-webkit-box-shadow:inset 0 1px 0 #ffffff;-moz-box-shadow:inset 0 1px 0 #ffffff;box-shadow:inset 0 1px 0 #ffffff;*zoom:1;}.modal-footer:before,.modal-footer:after{display:table;content:"";}
+.modal-footer:after{clear:both;}
+.modal-footer .btn{float:right;margin-left:5px;margin-bottom:0;}
+.tooltip{position:absolute;z-index:1020;display:block;visibility:visible;padding:5px;font-size:11px;opacity:0;filter:alpha(opacity=0);}.tooltip.in{opacity:0.8;filter:alpha(opacity=80);}
+.tooltip.top{margin-top:-2px;}
+.tooltip.right{margin-left:2px;}
+.tooltip.bottom{margin-top:2px;}
+.tooltip.left{margin-left:-2px;}
+.tooltip.top .tooltip-arrow{bottom:0;left:50%;margin-left:-5px;border-left:5px solid transparent;border-right:5px solid transparent;border-top:5px solid #000000;}
+.tooltip.left .tooltip-arrow{top:50%;right:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:5px solid #000000;}
+.tooltip.bottom .tooltip-arrow{top:0;left:50%;margin-left:-5px;border-left:5px solid transparent;border-right:5px solid transparent;border-bottom:5px solid #000000;}
+.tooltip.right .tooltip-arrow{top:50%;left:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-right:5px solid #000000;}
+.tooltip-inner{max-width:200px;padding:3px 8px;color:#ffffff;text-align:center;text-decoration:none;background-color:#000000;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;}
+.tooltip-arrow{position:absolute;width:0;height:0;}
+.popover{position:absolute;top:0;left:0;z-index:1010;display:none;padding:5px;}.popover.top{margin-top:-5px;}
+.popover.right{margin-left:5px;}
+.popover.bottom{margin-top:5px;}
+.popover.left{margin-left:-5px;}
+.popover.top .arrow{bottom:0;left:50%;margin-left:-5px;border-left:5px solid transparent;border-right:5px solid transparent;border-top:5px solid #000000;}
+.popover.right .arrow{top:50%;left:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-right:5px solid #000000;}
+.popover.bottom .arrow{top:0;left:50%;margin-left:-5px;border-left:5px solid transparent;border-right:5px solid transparent;border-bottom:5px solid #000000;}
+.popover.left .arrow{top:50%;right:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:5px solid #000000;}
+.popover .arrow{position:absolute;width:0;height:0;}
+.popover-inner{padding:3px;width:280px;overflow:hidden;background:#000000;background:rgba(0, 0, 0, 0.8);-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 3px 7px rgba(0, 0, 0, 0.3);-moz-box-shadow:0 3px 7px rgba(0, 0, 0, 0.3);box-shadow:0 3px 7px rgba(0, 0, 0, 0.3);}
+.popover-title{padding:9px 15px;line-height:1;background-color:#f5f5f5;border-bottom:1px solid #eee;-webkit-border-radius:3px 3px 0 0;-moz-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0;}
+.popover-content{padding:14px;background-color:#ffffff;-webkit-border-radius:0 0 3px 3px;-moz-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box;}.popover-content p,.popover-content ul,.popover-content ol{margin-bottom:0;}
+.thumbnails{margin-left:-20px;list-style:none;*zoom:1;}.thumbnails:before,.thumbnails:after{display:table;content:"";}
+.thumbnails:after{clear:both;}
+.thumbnails>li{float:left;margin:0 0 18px 20px;}
+.thumbnail{display:block;padding:4px;line-height:1;border:1px solid #ddd;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:0 1px 1px rgba(0, 0, 0, 0.075);-moz-box-shadow:0 1px 1px rgba(0, 0, 0, 0.075);box-shadow:0 1px 1px rgba(0, 0, 0, 0.075);}
+a.thumbnail:hover{border-color:#0088cc;-webkit-box-shadow:0 1px 4px rgba(0, 105, 214, 0.25);-moz-box-shadow:0 1px 4px rgba(0, 105, 214, 0.25);box-shadow:0 1px 4px rgba(0, 105, 214, 0.25);}
+.thumbnail>img{display:block;max-width:100%;margin-left:auto;margin-right:auto;}
+.thumbnail .caption{padding:9px;}
+.label{padding:2px 4px 3px;font-size:11.049999999999999px;font-weight:bold;color:#ffffff;text-shadow:0 -1px 0 rgba(0, 0, 0, 0.25);background-color:#999999;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;}
+.label:hover{color:#ffffff;text-decoration:none;}
+.label-important{background-color:#b94a48;}
+.label-important:hover{background-color:#953b39;}
+.label-warning{background-color:#f89406;}
+.label-warning:hover{background-color:#c67605;}
+.label-success{background-color:#468847;}
+.label-success:hover{background-color:#356635;}
+.label-info{background-color:#3a87ad;}
+.label-info:hover{background-color:#2d6987;}
+@-webkit-keyframes progress-bar-stripes{from{background-position:0 0;} to{background-position:40px 0;}}@-moz-keyframes progress-bar-stripes{from{background-position:0 0;} to{background-position:40px 0;}}@keyframes progress-bar-stripes{from{background-position:0 0;} to{background-position:40px 0;}}.progress{overflow:hidden;height:18px;margin-bottom:18px;background-color:#f7f7f7;background-image:-moz-linear-gradient(top, #f5f5f5, #f9f9f9);background-image:-ms-linear-gradient(top, #f5f5f5, #f9f9f9);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#f5f5f5), to(#f9f9f9));background-image:-webkit-linear-gradient(top, #f5f5f5, #f9f9f9);background-image:-o-linear-gradient(top, #f5f5f5, #f9f9f9);background-image:linear-gradient(top, #f5f5f5, #f9f9f9);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f5f5f5', endColorstr='#f9f9f9', GradientType=0);-webkit-box-shadow:inset 0 1px 2px rgba(0, 0, 0, 0.1);-moz-box-shadow:inset 0 1px 2px rgba(0, 0, 0, 0.1);box-shadow:inset 0 1px 2px rgba(0, 0, 0, 0.1);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;}
+.progress .bar{width:0%;height:18px;color:#ffffff;font-size:12px;text-align:center;text-shadow:0 -1px 0 rgba(0, 0, 0, 0.25);background-color:#0e90d2;background-image:-moz-linear-gradient(top, #149bdf, #0480be);background-image:-ms-linear-gradient(top, #149bdf, #0480be);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#149bdf), to(#0480be));background-image:-webkit-linear-gradient(top, #149bdf, #0480be);background-image:-o-linear-gradient(top, #149bdf, #0480be);background-image:linear-gradient(top, #149bdf, #0480be);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#149bdf', endColorstr='#0480be', GradientType=0);-webkit-box-shadow:inset 0 -1px 0 rgba(0, 0, 0, 0.15);-moz-box-shadow:inset 0 -1px 0 rgba(0, 0, 0, 0.15);box-shadow:inset 0 -1px 0 rgba(0, 0, 0, 0.15);-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:width 0.6s ease;-moz-transition:width 0.6s ease;-ms-transition:width 0.6s ease;-o-transition:width 0.6s ease;transition:width 0.6s ease;}
+.progress-striped .bar{background-color:#62c462;background-image:-webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));background-image:-webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-ms-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-o-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);-webkit-background-size:40px 40px;-moz-background-size:40px 40px;-o-background-size:40px 40px;background-size:40px 40px;}
+.progress.active .bar{-webkit-animation:progress-bar-stripes 2s linear infinite;-moz-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite;}
+.progress-danger .bar{background-color:#dd514c;background-image:-moz-linear-gradient(top, #ee5f5b, #c43c35);background-image:-ms-linear-gradient(top, #ee5f5b, #c43c35);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#ee5f5b), to(#c43c35));background-image:-webkit-linear-gradient(top, #ee5f5b, #c43c35);background-image:-o-linear-gradient(top, #ee5f5b, #c43c35);background-image:linear-gradient(top, #ee5f5b, #c43c35);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ee5f5b', endColorstr='#c43c35', GradientType=0);}
+.progress-danger.progress-striped .bar{background-color:#ee5f5b;background-image:-webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));background-image:-webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-ms-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-o-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);}
+.progress-success .bar{background-color:#5eb95e;background-image:-moz-linear-gradient(top, #62c462, #57a957);background-image:-ms-linear-gradient(top, #62c462, #57a957);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#62c462), to(#57a957));background-image:-webkit-linear-gradient(top, #62c462, #57a957);background-image:-o-linear-gradient(top, #62c462, #57a957);background-image:linear-gradient(top, #62c462, #57a957);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#62c462', endColorstr='#57a957', GradientType=0);}
+.progress-success.progress-striped .bar{background-color:#62c462;background-image:-webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));background-image:-webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-ms-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-o-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);}
+.progress-info .bar{background-color:#4bb1cf;background-image:-moz-linear-gradient(top, #5bc0de, #339bb9);background-image:-ms-linear-gradient(top, #5bc0de, #339bb9);background-image:-webkit-gradient(linear, 0 0, 0 100%, from(#5bc0de), to(#339bb9));background-image:-webkit-linear-gradient(top, #5bc0de, #339bb9);background-image:-o-linear-gradient(top, #5bc0de, #339bb9);background-image:linear-gradient(top, #5bc0de, #339bb9);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#5bc0de', endColorstr='#339bb9', GradientType=0);}
+.progress-info.progress-striped .bar{background-color:#5bc0de;background-image:-webkit-gradient(linear, 0 100%, 100% 0, color-stop(0.25, rgba(255, 255, 255, 0.15)), color-stop(0.25, transparent), color-stop(0.5, transparent), color-stop(0.5, rgba(255, 255, 255, 0.15)), color-stop(0.75, rgba(255, 255, 255, 0.15)), color-stop(0.75, transparent), to(transparent));background-image:-webkit-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-moz-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-ms-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:-o-linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);background-image:linear-gradient(-45deg, rgba(255, 255, 255, 0.15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.15) 50%, rgba(255, 255, 255, 0.15) 75%, transparent 75%, transparent);}
+.accordion{margin-bottom:18px;}
+.accordion-group{margin-bottom:2px;border:1px solid #e5e5e5;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;}
+.accordion-heading{border-bottom:0;}
+.accordion-heading .accordion-toggle{display:block;padding:8px 15px;}
+.accordion-inner{padding:9px 15px;border-top:1px solid #e5e5e5;}
+.carousel{position:relative;margin-bottom:18px;line-height:1;}
+.carousel-inner{overflow:hidden;width:100%;position:relative;}
+.carousel .item{display:none;position:relative;-webkit-transition:0.6s ease-in-out left;-moz-transition:0.6s ease-in-out left;-ms-transition:0.6s ease-in-out left;-o-transition:0.6s ease-in-out left;transition:0.6s ease-in-out left;}
+.carousel .item>img{display:block;line-height:1;}
+.carousel .active,.carousel .next,.carousel .prev{display:block;}
+.carousel .active{left:0;}
+.carousel .next,.carousel .prev{position:absolute;top:0;width:100%;}
+.carousel .next{left:100%;}
+.carousel .prev{left:-100%;}
+.carousel .next.left,.carousel .prev.right{left:0;}
+.carousel .active.left{left:-100%;}
+.carousel .active.right{left:100%;}
+.carousel-control{position:absolute;top:40%;left:15px;width:40px;height:40px;margin-top:-20px;font-size:60px;font-weight:100;line-height:30px;color:#ffffff;text-align:center;background:#222222;border:3px solid #ffffff;-webkit-border-radius:23px;-moz-border-radius:23px;border-radius:23px;opacity:0.5;filter:alpha(opacity=50);}.carousel-control.right{left:auto;right:15px;}
+.carousel-control:hover{color:#ffffff;text-decoration:none;opacity:0.9;filter:alpha(opacity=90);}
+.carousel-caption{position:absolute;left:0;right:0;bottom:0;padding:10px 15px 5px;background:#333333;background:rgba(0, 0, 0, 0.75);}
+.carousel-caption h4,.carousel-caption p{color:#ffffff;}
+.hero-unit{padding:60px;margin-bottom:30px;background-color:#f5f5f5;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;}.hero-unit h1{margin-bottom:0;font-size:60px;line-height:1;letter-spacing:-1px;}
+.hero-unit p{font-size:18px;font-weight:200;line-height:27px;}
+.pull-right{float:right;}
+.pull-left{float:left;}
+.hide{display:none;}
+.show{display:block;}
+.invisible{visibility:hidden;}
diff --git a/css/style.css b/css/style.css
new file mode 100644
index 0000000..f65eb16
--- /dev/null
+++ b/css/style.css
@@ -0,0 +1,16 @@
+body {
+ padding-top: 40px;
+}
+
+#rotator {
+ background: #dddddd;
+ width: 960px;
+ height: 627px;
+ overflow: hidden;
+ cursor: pointer;
+}
+
+#rotator img {
+ display: block;
+ margin: 0;
+}
\ No newline at end of file
diff --git a/img/blank.png b/img/blank.png
new file mode 100644
index 0000000000000000000000000000000000000000..1c7bf3bff94c6b5d81c7c865566b688d4040bc2f
GIT binary patch
literal 4249
zcmeHLUuauZ7(Z#US}NH(hIM9&*P9oaP42yE(lpn`HBC|*SxQOkS}RI#lhfWycmM3(
zTa$L^x^@z9&{)zi1fkgi#S9w1aSo)1VIpCfdik@RsstIB?XVEhGH12#fk#|oN|ox&zHjwdB0
zO5a@jn5Lv$lpYSH*|ZkNqSQC5#p$fR79F?E#);
zsq!BU-t^oApGowVeZekDi>9gZ43p32{rPsks!uXpBoZMu0s$W&e8!Ao3I(5Hcx?*_
zY-DvwGbL4_h(%#soi?L1L|RHg)+%Ndqg*B^7*h~5hV!!|B^#Jd-ySN<6|`Yy@MgSK
z4I4u<8fG%sP^a}QG;YF6Txon<$AYQqL#lexuHt~GnyMkH8WkT5QNxmwQ}c#}PN(^l
zVwi%G#i>M;2EJdCa(ri`C*F}{W1(bklH-zGjB5|YBJJ^HPcRY=2Ld)Xp=PILte7@8
zx5@3P$t8mzYv4J7b?F71>(y16vJ&Q{+Oc%jv{&ZlYR3|($z>oIhO~7{n{5@$4iPIu
z3!BQ=V+CeihoQbd^z|EX(GH{%v7y4oPesmwP?M7i{l5I{C!Zali>dQx-tJx%6R)*i
z5U;<|>hoM*KIj__E+@UCMBBScv~UDkI07vk5p5lWdmcll^T(YC&9QC2g`-CveDmDm
zTOZw65sM9O&uaHVt5{sxM}$Tn5rX1bBE;?`f_u~w00{y?)<-$>6mopCmi54s&?x-*
zocG)b=Z(k1r$_d;1e-jr3rn#gB@!{VP!{JK%c9F&76Dfh4-yIyy%uGcZ1;R`$@k?I
z*VsGz`w$vCym;z|OD{dNkofe`wQJ3Vf5XdvBEub3w^E;~?601OzP?BLdU#Rr{L=mK
z#cPX2?~hNPKtFe)77?9o>|S!XJX=;!T6=4SLmOnTw}ML`m!}rEip8CSZ*>o`|MOVu
z0`E34*MblEP-6?xG|NEfay|!+%e3uhz5f9zIQ_#81j@8xHDqzdfHjDNQ)DNyQRog6A
zvDg&cGJj@K&(B`E4=&pG-@(Vv
z;f7z>@LIZp@bwoFYAM3kc&>5pV6P;5!?1S^{%iK{(h
G^M3(PyN!$h
literal 0
HcmV?d00001
diff --git a/img/glyphicons-halflings-white.png b/img/glyphicons-halflings-white.png
new file mode 100644
index 0000000000000000000000000000000000000000..a20760bfde58d1c92cee95116059fba03c68d689
GIT binary patch
literal 4352
zcmd6r_dnEu|G?izMxtxU%uI5!l8nr)ZF&&*%FGe4jtO*5mbhJzhV&et11z&&^B?xH$MZ007{+ZK!Jj01(PQ
zJBFS4pH$0DefCd1HM@h*JNkcsi%oOXzj>qsEle$eQ7ApHL(XYdn5Y$Lk_3-J9p9d)
zFeVfl3J47_g1XaoDXWsnBp9ZzZ74CI9RN-Nw{>+8ArBpZgc9WX2H3Ssv6doZP?t
zS!g}lGvW1<9%?dj_G_x}3WUMN(8(x{a6_pd0yiUsf^67GGS50uSB*ORe5x6}qAf1z
z@Q;2y4G{Lb?f21p)uTpChN&4q%^blZ2IsusUOhk)pe0yxPD6oHKXWSjv8&2pMdnegiQUtoXt1U0MmWAWu2&>3j$eb^qKNV
z_(`JQZP&mXLT@U%-2rPy!7r|*Y1oAdlarltaUyq+yq^|d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+R3j0a8@kqB}PI}{$m!yRab
zvul5lL(>3*TF>n~)*#hsmwUTtKRAA2Fnk0PENdI!9GrZLu@zyKzs+&m-IKFviqv>&
kg1Lm#gqI~e;$iYPkmG5c&N-g{UI@TVLkokN>#mRg2V?7pi2wiq
literal 0
HcmV?d00001
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..8b20fc7
--- /dev/null
+++ b/index.php
@@ -0,0 +1,166 @@
+
+ *
+ * This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
+ * To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to
+ * Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
+ */
+
+require_once 'Twig/Autoloader.php';
+Twig_Autoloader::register();
+
+session_start();
+
+$base_dir = dirname(__FILE__);
+
+$settings = json_decode(file_get_contents('settings.json'));
+
+$db = new mysqli($settings->database->host, $settings->database->username, $settings->database->password, $settings->database->name);
+
+$twig_loader = new Twig_Loader_Filesystem($base_dir.'/views');
+$twig = new Twig_Environment($twig_loader, array('debug' => true));
+
+$variables = array(
+ 'baseURL' => $settings->baseURL
+);
+
+$template = false;
+$mode = !empty($_GET['mode']) ? $_GET['mode'] : 'start';
+$phase = !empty($_GET['phase']) && in_array($_GET['phase'], $settings->phases) ? $_GET['phase'] : false;
+$index = 0;
+
+if (!empty($phase)) {
+ $index = array_search($phase, $settings->phases, true) + 1;
+}
+
+// Store the results upon submittal.
+if (!empty($phase) && isset($_POST['responsetime'])) {
+ $_SESSION['results'][$phase] = array(
+ 'xcoordinate' => $_POST['xcoordinate'],
+ 'ycoordinate' => $_POST['ycoordinate'],
+ 'responsetime' => $_POST['responsetime']
+ );
+
+ // End of the line.
+ if ($index == count($settings->phases)) {
+ header('HTTP/1.0 302 Found');
+ header('Location: http://vcd.sparse.nl/finish');
+ exit;
+ }
+ // Next phase.
+ else {
+ $mode = 'phase_next';
+ }
+}
+
+switch ($mode) {
+ case 'start':
+ $template = 'index.html.twig';
+ break;
+ case 'phase':
+ $template = 'change.html.twig';
+ $variables['imageWithElement'] = 'img/'.$phase.'-with.png';
+ $variables['imageWithoutElement'] = 'img/'.$phase.'-without.png';
+ $variables['step_count'] = $index;
+ break;
+ case 'phase_next':
+ $template = 'next.html.twig';
+ $variables['next_url'] = 'phase/'.$settings->phases[$index];
+ $variables['step_count'] = $index;
+ break;
+ case 'finish':
+ $template = 'finish.html.twig';
+ // Store the result.
+ $query = $db->prepare('insert into vcd_results values (null, unix_timestamp(), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)');
+ $query->bind_param(
+ 'siiiiiiiii',
+ $_SERVER['REMOTE_ADDR'],
+ $_SESSION['results']['notable']['xcoordinate'],
+ $_SESSION['results']['notable']['ycoordinate'],
+ $_SESSION['results']['notable']['responsetime'],
+ $_SESSION['results']['unnoted']['xcoordinate'],
+ $_SESSION['results']['unnoted']['ycoordinate'],
+ $_SESSION['results']['unnoted']['responsetime'],
+ $_SESSION['results']['renoted']['xcoordinate'],
+ $_SESSION['results']['renoted']['ycoordinate'],
+ $_SESSION['results']['renoted']['responsetime']
+ ) or die('Could not prepare query');
+ $query->execute() or die('Could not execute query');
+ $query->close();
+ break;
+ case 'results':
+ $download = isset($_GET['download']);
+
+ if ($settings->debug) {
+ $variables['allow_filtering'] = true;
+ $filtered = isset($_GET['filtered']) || $download;
+ }
+ else {
+ $filtered = true;
+ }
+
+ if ($download) {
+ header('Content-Type: text/tab-separated-values');
+ header('Content-Disposition: attachment; filename=vcd-results.txt');
+ $template = 'results.txt.twig';
+ }
+ else {
+ $template = 'results.html.twig';
+ }
+
+ if ($filtered) {
+ $variables['filtered'] = true;
+ $results = $db->query("select * from vcd_results where result_host != '192.168.0.1' order by result_date asc");
+ }
+ else {
+ $results = $db->query("select * from vcd_results order by result_date asc");
+ }
+
+ if ($results === false) {
+ header('HTTP/1.0 500 Internal Server Error');
+ exit;
+ }
+
+ $variables['records'] = $results->num_rows;
+
+ $variables['data'] = array();
+ $variables['stats'] = array();
+
+ while (($record = $results->fetch_assoc()) !== null) {
+ $data = array();
+ $stats = array();
+
+ // Prepare data
+ foreach ($record as $name => $value) {
+ list($cat, $key) = explode('_', $name);
+ $data[$cat][$key] = $value;
+ }
+ $variables['data'][] = $data;
+
+ // Build statistics
+ foreach ($settings->phases as $phase) {
+ $stats[$phase] = array(
+ 'correct' => (($data[$phase]['xcoordinate'] >= $settings->elementLocations->{$phase}->topleft->x)
+ && ($data[$phase]['xcoordinate'] <= $settings->elementLocations->{$phase}->bottomright->x)
+ && ($data[$phase]['ycoordinate'] >= $settings->elementLocations->{$phase}->topleft->y)
+ && ($data[$phase]['ycoordinate'] <= $settings->elementLocations->{$phase}->bottomright->y)),
+ 'time' => $data[$phase]['responsetime']
+ );
+ }
+ $variables['stats'][] = $stats;
+ }
+
+ $results->free();
+ break;
+}
+
+if (!empty ($template)) {
+ echo $twig->render($template, $variables);
+}
+else {
+ header('HTTP/1.0 404 Not Found');
+}
\ No newline at end of file
diff --git a/js/bootstrap.min.js b/js/bootstrap.min.js
new file mode 100644
index 0000000..97dc88e
--- /dev/null
+++ b/js/bootstrap.min.js
@@ -0,0 +1 @@
+!function(a){a(function(){"use strict",a.support.transition=function(){var b=document.body||document.documentElement,c=b.style,d=c.transition!==undefined||c.WebkitTransition!==undefined||c.MozTransition!==undefined||c.MsTransition!==undefined||c.OTransition!==undefined;return d&&{end:function(){var b="TransitionEnd";return a.browser.webkit?b="webkitTransitionEnd":a.browser.mozilla?b="transitionend":a.browser.opera&&(b="oTransitionEnd"),b}()}}()})}(window.jQuery),!function(a){"use strict";var b='[data-dismiss="alert"]',c=function(c){a(c).on("click",b,this.close)};c.prototype={constructor:c,close:function(b){function f(){e.trigger("closed").remove()}var c=a(this),d=c.attr("data-target"),e;d||(d=c.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,"")),e=a(d),e.trigger("close"),b&&b.preventDefault(),e.length||(e=c.hasClass("alert")?c:c.parent()),e.trigger("close").removeClass("in"),a.support.transition&&e.hasClass("fade")?e.on(a.support.transition.end,f):f()}},a.fn.alert=function(b){return this.each(function(){var d=a(this),e=d.data("alert");e||d.data("alert",e=new c(this)),typeof b=="string"&&e[b].call(d)})},a.fn.alert.Constructor=c,a(function(){a("body").on("click.alert.data-api",b,c.prototype.close)})}(window.jQuery),!function(a){"use strict";var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.button.defaults,c)};b.prototype={constructor:b,setState:function(a){var b="disabled",c=this.$element,d=c.data(),e=c.is("input")?"val":"html";a+="Text",d.resetText||c.data("resetText",c[e]()),c[e](d[a]||this.options[a]),setTimeout(function(){a=="loadingText"?c.addClass(b).attr(b,b):c.removeClass(b).removeAttr(b)},0)},toggle:function(){var a=this.$element.parent('[data-toggle="buttons-radio"]');a&&a.find(".active").removeClass("active"),this.$element.toggleClass("active")}},a.fn.button=function(c){return this.each(function(){var d=a(this),e=d.data("button"),f=typeof c=="object"&&c;e||d.data("button",e=new b(this,f)),c=="toggle"?e.toggle():c&&e.setState(c)})},a.fn.button.defaults={loadingText:"loading..."},a.fn.button.Constructor=b,a(function(){a("body").on("click.button.data-api","[data-toggle^=button]",function(b){var c=a(b.target);c.hasClass("btn")||(c=c.closest(".btn")),c.button("toggle")})})}(window.jQuery),!function(a){"use strict";var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.carousel.defaults,c),this.options.slide&&this.slide(this.options.slide)};b.prototype={cycle:function(){return this.interval=setInterval(a.proxy(this.next,this),this.options.interval),this},to:function(b){var c=this.$element.find(".active"),d=c.parent().children(),e=d.index(c),f=this;if(b>d.length-1||b<0)return;return this.sliding?this.$element.one("slid",function(){f.to(b)}):e==b?this.pause().cycle():this.slide(b>e?"next":"prev",a(d[b]))},pause:function(){return clearInterval(this.interval),this.interval=null,this},next:function(){if(this.sliding)return;return this.slide("next")},prev:function(){if(this.sliding)return;return this.slide("prev")},slide:function(b,c){var d=this.$element.find(".active"),e=c||d[b](),f=this.interval,g=b=="next"?"left":"right",h=b=="next"?"first":"last",i=this;if(!e.length)return;return this.sliding=!0,f&&this.pause(),e=e.length?e:this.$element.find(".item")[h](),!a.support.transition&&this.$element.hasClass("slide")?(this.$element.trigger("slide"),d.removeClass("active"),e.addClass("active"),this.sliding=!1,this.$element.trigger("slid")):(e.addClass(b),e[0].offsetWidth,d.addClass(g),e.addClass(g),this.$element.trigger("slide"),this.$element.one(a.support.transition.end,function(){e.removeClass([b,g].join(" ")).addClass("active"),d.removeClass(["active",g].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger("slid")},0)})),f&&this.cycle(),this}},a.fn.carousel=function(c){return this.each(function(){var d=a(this),e=d.data("carousel"),f=typeof c=="object"&&c;e||d.data("carousel",e=new b(this,f)),typeof c=="number"?e.to(c):typeof c=="string"||(c=f.slide)?e[c]():e.cycle()})},a.fn.carousel.defaults={interval:5e3},a.fn.carousel.Constructor=b,a(function(){a("body").on("click.carousel.data-api","[data-slide]",function(b){var c=a(this),d,e=a(c.attr("data-target")||(d=c.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,"")),f=!e.data("modal")&&a.extend({},e.data(),c.data());e.carousel(f),b.preventDefault()})})}(window.jQuery),!function(a){"use strict";var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.collapse.defaults,c),this.options.parent&&(this.$parent=a(this.options.parent)),this.options.toggle&&this.toggle()};b.prototype={constructor:b,dimension:function(){var a=this.$element.hasClass("width");return a?"width":"height"},show:function(){var b=this.dimension(),c=a.camelCase(["scroll",b].join("-")),d=this.$parent&&this.$parent.find(".in"),e;d&&d.length&&(e=d.data("collapse"),d.collapse("hide"),e||d.data("collapse",null)),this.$element[b](0),this.transition("addClass","show","shown"),this.$element[b](this.$element[0][c])},hide:function(){var a=this.dimension();this.reset(this.$element[a]()),this.transition("removeClass","hide","hidden"),this.$element[a](0)},reset:function(a){var b=this.dimension();this.$element.removeClass("collapse")[b](a||"auto")[0].offsetWidth,this.$element.addClass("collapse")},transition:function(b,c,d){var e=this,f=function(){c=="show"&&e.reset(),e.$element.trigger(d)};this.$element.trigger(c)[b]("in"),a.support.transition&&this.$element.hasClass("collapse")?this.$element.one(a.support.transition.end,f):f()},toggle:function(){this[this.$element.hasClass("in")?"hide":"show"]()}},a.fn.collapse=function(c){return this.each(function(){var d=a(this),e=d.data("collapse"),f=typeof c=="object"&&c;e||d.data("collapse",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.collapse.defaults={toggle:!0},a.fn.collapse.Constructor=b,a(function(){a("body").on("click.collapse.data-api","[data-toggle=collapse]",function(b){var c=a(this),d,e=c.attr("data-target")||b.preventDefault()||(d=c.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""),f=a(e).data("collapse")?"toggle":c.data();a(e).collapse(f)})})}(window.jQuery),!function(a){function d(){a(b).parent().removeClass("open")}"use strict";var b='[data-toggle="dropdown"]',c=function(b){var c=a(b).on("click.dropdown.data-api",this.toggle);a("html").on("click.dropdown.data-api",function(){c.parent().removeClass("open")})};c.prototype={constructor:c,toggle:function(b){var c=a(this),e=c.attr("data-target"),f,g;return e||(e=c.attr("href"),e=e&&e.replace(/.*(?=#[^\s]*$)/,"")),f=a(e),f.length||(f=c.parent()),g=f.hasClass("open"),d(),!g&&f.toggleClass("open"),!1}},a.fn.dropdown=function(b){return this.each(function(){var d=a(this),e=d.data("dropdown");e||d.data("dropdown",e=new c(this)),typeof b=="string"&&e[b].call(d)})},a.fn.dropdown.Constructor=c,a(function(){a("html").on("click.dropdown.data-api",d),a("body").on("click.dropdown.data-api",b,c.prototype.toggle)})}(window.jQuery),!function(a){function c(){var b=this,c=setTimeout(function(){b.$element.off(a.support.transition.end),d.call(b)},500);this.$element.one(a.support.transition.end,function(){clearTimeout(c),d.call(b)})}function d(a){this.$element.hide().trigger("hidden"),e.call(this)}function e(b){var c=this,d=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var e=a.support.transition&&d;this.$backdrop=a('
').appendTo(document.body),this.options.backdrop!="static"&&this.$backdrop.click(a.proxy(this.hide,this)),e&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),e?this.$backdrop.one(a.support.transition.end,b):b()}else!this.isShown&&this.$backdrop?(this.$backdrop.removeClass("in"),a.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one(a.support.transition.end,a.proxy(f,this)):f.call(this)):b&&b()}function f(){this.$backdrop.remove(),this.$backdrop=null}function g(){var b=this;this.isShown&&this.options.keyboard?a(document).on("keyup.dismiss.modal",function(a){a.which==27&&b.hide()}):this.isShown||a(document).off("keyup.dismiss.modal")}"use strict";var b=function(b,c){this.options=c,this.$element=a(b).delegate('[data-dismiss="modal"]',"click.dismiss.modal",a.proxy(this.hide,this))};b.prototype={constructor:b,toggle:function(){return this[this.isShown?"hide":"show"]()},show:function(){var b=this;if(this.isShown)return;a("body").addClass("modal-open"),this.isShown=!0,this.$element.trigger("show"),g.call(this),e.call(this,function(){var c=a.support.transition&&b.$element.hasClass("fade");!b.$element.parent().length&&b.$element.appendTo(document.body),b.$element.show(),c&&b.$element[0].offsetWidth,b.$element.addClass("in"),c?b.$element.one(a.support.transition.end,function(){b.$element.trigger("shown")}):b.$element.trigger("shown")})},hide:function(b){b&&b.preventDefault();if(!this.isShown)return;var e=this;this.isShown=!1,a("body").removeClass("modal-open"),g.call(this),this.$element.trigger("hide").removeClass("in"),a.support.transition&&this.$element.hasClass("fade")?c.call(this):d.call(this)}},a.fn.modal=function(c){return this.each(function(){var d=a(this),e=d.data("modal"),f=a.extend({},a.fn.modal.defaults,d.data(),typeof c=="object"&&c);e||d.data("modal",e=new b(this,f)),typeof c=="string"?e[c]():f.show&&e.show()})},a.fn.modal.defaults={backdrop:!0,keyboard:!0,show:!0},a.fn.modal.Constructor=b,a(function(){a("body").on("click.modal.data-api",'[data-toggle="modal"]',function(b){var c=a(this),d,e=a(c.attr("data-target")||(d=c.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,"")),f=e.data("modal")?"toggle":a.extend({},e.data(),c.data());b.preventDefault(),e.modal(f)})})}(window.jQuery),!function(a){"use strict";var b=function(a,b){this.init("tooltip",a,b)};b.prototype={constructor:b,init:function(b,c,d){var e,f;this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.enabled=!0,this.options.trigger!="manual"&&(e=this.options.trigger=="hover"?"mouseenter":"focus",f=this.options.trigger=="hover"?"mouseleave":"blur",this.$element.on(e,this.options.selector,a.proxy(this.enter,this)),this.$element.on(f,this.options.selector,a.proxy(this.leave,this))),this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},getOptions:function(b){return b=a.extend({},a.fn[this.type].defaults,b,this.$element.data()),b.delay&&typeof b.delay=="number"&&(b.delay={show:b.delay,hide:b.delay}),b},enter:function(b){var c=a(b.currentTarget)[this.type](this._options).data(this.type);!c.options.delay||!c.options.delay.show?c.show():(c.hoverState="in",setTimeout(function(){c.hoverState=="in"&&c.show()},c.options.delay.show))},leave:function(b){var c=a(b.currentTarget)[this.type](this._options).data(this.type);!c.options.delay||!c.options.delay.hide?c.hide():(c.hoverState="out",setTimeout(function(){c.hoverState=="out"&&c.hide()},c.options.delay.hide))},show:function(){var a,b,c,d,e,f,g;if(this.hasContent()&&this.enabled){a=this.tip(),this.setContent(),this.options.animation&&a.addClass("fade"),f=typeof this.options.placement=="function"?this.options.placement.call(this,a[0],this.$element[0]):this.options.placement,b=/in/.test(f),a.remove().css({top:0,left:0,display:"block"}).appendTo(b?this.$element:document.body),c=this.getPosition(b),d=a[0].offsetWidth,e=a[0].offsetHeight;switch(b?f.split(" ")[1]:f){case"bottom":g={top:c.top+c.height,left:c.left+c.width/2-d/2};break;case"top":g={top:c.top-e,left:c.left+c.width/2-d/2};break;case"left":g={top:c.top+c.height/2-e/2,left:c.left-d};break;case"right":g={top:c.top+c.height/2-e/2,left:c.left+c.width}}a.css(g).addClass(f).addClass("in")}},setContent:function(){var a=this.tip();a.find(".tooltip-inner").html(this.getTitle()),a.removeClass("fade in top bottom left right")},hide:function(){function d(){var b=setTimeout(function(){c.off(a.support.transition.end).remove()},500);c.one(a.support.transition.end,function(){clearTimeout(b),c.remove()})}var b=this,c=this.tip();c.removeClass("in"),a.support.transition&&this.$tip.hasClass("fade")?d():c.remove()},fixTitle:function(){var a=this.$element;(a.attr("title")||typeof a.attr("data-original-title")!="string")&&a.attr("data-original-title",a.attr("title")||"").removeAttr("title")},hasContent:function(){return this.getTitle()},getPosition:function(b){return a.extend({},b?{top:0,left:0}:this.$element.offset(),{width:this.$element[0].offsetWidth,height:this.$element[0].offsetHeight})},getTitle:function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||(typeof c.title=="function"?c.title.call(b[0]):c.title),a=a.toString().replace(/(^\s*|\s*$)/,""),a},tip:function(){return this.$tip=this.$tip||a(this.options.template)},validate:function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},toggleEnabled:function(){this.enabled=!this.enabled},toggle:function(){this[this.tip().hasClass("in")?"hide":"show"]()}},a.fn.tooltip=function(c){return this.each(function(){var d=a(this),e=d.data("tooltip"),f=typeof c=="object"&&c;e||d.data("tooltip",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.tooltip.Constructor=b,a.fn.tooltip.defaults={animation:!0,delay:0,selector:!1,placement:"top",trigger:"hover",title:"",template:''}}(window.jQuery),!function(a){"use strict";var b=function(a,b){this.init("popover",a,b)};b.prototype=a.extend({},a.fn.tooltip.Constructor.prototype,{constructor:b,setContent:function(){var b=this.tip(),c=this.getTitle(),d=this.getContent();b.find(".popover-title")[a.type(c)=="object"?"append":"html"](c),b.find(".popover-content > *")[a.type(d)=="object"?"append":"html"](d),b.removeClass("fade top bottom left right in")},hasContent:function(){return this.getTitle()||this.getContent()},getContent:function(){var a,b=this.$element,c=this.options;return a=b.attr("data-content")||(typeof c.content=="function"?c.content.call(b[0]):c.content),a=a.toString().replace(/(^\s*|\s*$)/,""),a},tip:function(){return this.$tip||(this.$tip=a(this.options.template)),this.$tip}}),a.fn.popover=function(c){return this.each(function(){var d=a(this),e=d.data("popover"),f=typeof c=="object"&&c;e||d.data("popover",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.popover.Constructor=b,a.fn.popover.defaults=a.extend({},a.fn.tooltip.defaults,{placement:"right",content:"",template:''})}(window.jQuery),!function(a){function b(b,c){var d=a.proxy(this.process,this),e=a(b).is("body")?a(window):a(b),f;this.options=a.extend({},a.fn.scrollspy.defaults,c),this.$scrollElement=e.on("scroll.scroll.data-api",d),this.selector=(this.options.target||(f=a(b).attr("href"))&&f.replace(/.*(?=#[^\s]+$)/,"")||"")+" .nav li > a",this.$body=a("body").on("click.scroll.data-api",this.selector,d),this.refresh(),this.process()}"use strict",b.prototype={constructor:b,refresh:function(){this.targets=this.$body.find(this.selector).map(function(){var b=a(this).attr("href");return/^#\w/.test(b)&&a(b).length?b:null}),this.offsets=a.map(this.targets,function(b){return a(b).position().top})},process:function(){var a=this.$scrollElement.scrollTop()+this.options.offset,b=this.offsets,c=this.targets,d=this.activeTarget,e;for(e=b.length;e--;)d!=c[e]&&a>=b[e]&&(!b[e+1]||a<=b[e+1])&&this.activate(c[e])},activate:function(a){var b;this.activeTarget=a,this.$body.find(this.selector).parent(".active").removeClass("active"),b=this.$body.find(this.selector+'[href="'+a+'"]').parent("li").addClass("active"),b.parent(".dropdown-menu")&&b.closest("li.dropdown").addClass("active")}},a.fn.scrollspy=function(c){return this.each(function(){var d=a(this),e=d.data("scrollspy"),f=typeof c=="object"&&c;e||d.data("scrollspy",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.scrollspy.Constructor=b,a.fn.scrollspy.defaults={offset:10},a(function(){a('[data-spy="scroll"]').each(function(){var b=a(this);b.scrollspy(b.data())})})}(window.jQuery),!function(a){"use strict";var b=function(b){this.element=a(b)};b.prototype={constructor:b,show:function(){var b=this.element,c=b.closest("ul:not(.dropdown-menu)"),d=b.attr("data-target"),e,f;d||(d=b.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,""));if(b.parent("li").hasClass("active"))return;e=c.find(".active a").last()[0],b.trigger({type:"show",relatedTarget:e}),f=a(d),this.activate(b.parent("li"),c),this.activate(f,f.parent(),function(){b.trigger({type:"shown",relatedTarget:e})})},activate:function(b,c,d){function g(){e.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"),b.addClass("active"),f?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu")&&b.closest("li.dropdown").addClass("active"),d&&d()}var e=c.find("> .active"),f=d&&a.support.transition&&e.hasClass("fade");f?e.one(a.support.transition.end,g):g(),e.removeClass("in")}},a.fn.tab=function(c){return this.each(function(){var d=a(this),e=d.data("tab");e||d.data("tab",e=new b(this)),typeof c=="string"&&e[c]()})},a.fn.tab.Constructor=b,a(function(){a("body").on("click.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(b){b.preventDefault(),a(this).tab("show")})})}(window.jQuery),!function(a){"use strict";var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.typeahead.defaults,c),this.matcher=this.options.matcher||this.matcher,this.sorter=this.options.sorter||this.sorter,this.highlighter=this.options.highlighter||this.highlighter,this.$menu=a(this.options.menu).appendTo("body"),this.source=this.options.source,this.shown=!1,this.listen()};b.prototype={constructor:b,select:function(){var a=this.$menu.find(".active").attr("data-value");return this.$element.val(a),this.hide()},show:function(){var b=a.extend({},this.$element.offset(),{height:this.$element[0].offsetHeight});return this.$menu.css({top:b.top+b.height,left:b.left}),this.$menu.show(),this.shown=!0,this},hide:function(){return this.$menu.hide(),this.shown=!1,this},lookup:function(b){var c=this,d,e;return this.query=this.$element.val(),this.query?(d=a.grep(this.source,function(a){if(c.matcher(a))return a}),d=this.sorter(d),d.length?this.render(d.slice(0,this.options.items)).show():this.shown?this.hide():this):this.shown?this.hide():this},matcher:function(a){return~a.toLowerCase().indexOf(this.query.toLowerCase())},sorter:function(a){var b=[],c=[],d=[],e;while(e=a.shift())e.toLowerCase().indexOf(this.query.toLowerCase())?~e.indexOf(this.query)?c.push(e):d.push(e):b.push(e);return b.concat(c,d)},highlighter:function(a){return a.replace(new RegExp("("+this.query+")","ig"),function(a,b){return""+b+" "})},render:function(b){var c=this;return b=a(b).map(function(b,d){return b=a(c.options.item).attr("data-value",d),b.find("a").html(c.highlighter(d)),b[0]}),b.first().addClass("active"),this.$menu.html(b),this},next:function(b){var c=this.$menu.find(".active").removeClass("active"),d=c.next();d.length||(d=a(this.$menu.find("li")[0])),d.addClass("active")},prev:function(a){var b=this.$menu.find(".active").removeClass("active"),c=b.prev();c.length||(c=this.$menu.find("li").last()),c.addClass("active")},listen:function(){this.$element.on("blur",a.proxy(this.blur,this)).on("keypress",a.proxy(this.keypress,this)).on("keyup",a.proxy(this.keyup,this)),(a.browser.webkit||a.browser.msie)&&this.$element.on("keydown",a.proxy(this.keypress,this)),this.$menu.on("click",a.proxy(this.click,this)).on("mouseenter","li",a.proxy(this.mouseenter,this))},keyup:function(a){a.stopPropagation(),a.preventDefault();switch(a.keyCode){case 40:case 38:break;case 9:case 13:if(!this.shown)return;this.select();break;case 27:this.hide();break;default:this.lookup()}},keypress:function(a){a.stopPropagation();if(!this.shown)return;switch(a.keyCode){case 9:case 13:case 27:a.preventDefault();break;case 38:a.preventDefault(),this.prev();break;case 40:a.preventDefault(),this.next()}},blur:function(a){var b=this;a.stopPropagation(),a.preventDefault(),setTimeout(function(){b.hide()},150)},click:function(a){a.stopPropagation(),a.preventDefault(),this.select()},mouseenter:function(b){this.$menu.find(".active").removeClass("active"),a(b.currentTarget).addClass("active")}},a.fn.typeahead=function(c){return this.each(function(){var d=a(this),e=d.data("typeahead"),f=typeof c=="object"&&c;e||d.data("typeahead",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.typeahead.defaults={source:[],items:8,menu:'',item:' '},a.fn.typeahead.Constructor=b,a(function(){a("body").on("focus.typeahead.data-api",'[data-provide="typeahead"]',function(b){var c=a(this);if(c.data("typeahead"))return;b.preventDefault(),c.typeahead(c.data())})})}(window.jQuery);
\ No newline at end of file
diff --git a/js/change.js b/js/change.js
new file mode 100644
index 0000000..029b84c
--- /dev/null
+++ b/js/change.js
@@ -0,0 +1,48 @@
+// Script settings.
+var slideDuration = 400;
+var blankDuration = 100;
+
+// Script internals.
+var $currentSlide;
+var $slides;
+var d1 = new Date();
+var startTime;
+
+$(document).ready(function(){
+ $slides = $('#rotator').children('img');
+
+ $slides.each(function(index){
+ $(this).hide();
+ });
+
+ $currentSlide = $slides.first();
+ $currentSlide.show();
+
+ setTimeout(slideHide, slideDuration);
+
+ startTime = d1.getTime();
+
+ $('#rotator').mousedown(function(event){
+ document.getElementById('xcoordinate').value = event.pageX - this.offsetLeft;
+ document.getElementById('ycoordinate').value = event.pageY - this.offsetTop;
+ var d2 = new Date(); var endTime = d2.getTime();
+ document.getElementById('responsetime').value = endTime - startTime;
+ document.changeform.submit();
+ });
+
+ $('#placeholder').hide();
+ $('#rotator').show();
+});
+
+function slideHide() {
+ $currentSlide.hide();
+
+ setTimeout(slideShow, blankDuration);
+}
+
+function slideShow() {
+ $currentSlide = $currentSlide.siblings().first();
+ $currentSlide.show();
+
+ setTimeout(slideHide, slideDuration);
+}
\ No newline at end of file
diff --git a/settings.json.example b/settings.json.example
new file mode 100644
index 0000000..580ab27
--- /dev/null
+++ b/settings.json.example
@@ -0,0 +1,47 @@
+{
+ "database": {
+ "host": "localhost",
+ "username": "user",
+ "password": "pass",
+ "name": "db"
+ },
+ "phases": [
+ "notable",
+ "unnoted",
+ "renoted"
+ ],
+ "baseURL": "/",
+ "elementLocations": {
+ "notable": {
+ "topleft": {
+ "x": 724,
+ "y": 340
+ },
+ "bottomright": {
+ "x": 884,
+ "y": 456
+ }
+ },
+ "unnoted": {
+ "topleft": {
+ "x": 48,
+ "y": 180
+ },
+ "bottomright": {
+ "x": 900,
+ "y": 200
+ }
+ },
+ "renoted": {
+ "topleft": {
+ "x": 48,
+ "y": 180
+ },
+ "bottomright": {
+ "x": 900,
+ "y": 204
+ }
+ }
+ },
+ "debug": false
+}
diff --git a/views/base.html.twig b/views/base.html.twig
new file mode 100644
index 0000000..78534ff
--- /dev/null
+++ b/views/base.html.twig
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+ Change blindness test
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {% block content %}
+ No content here.
+ {% endblock %}
+
+
+
+
+
+
+
+
+{% block webapis %}
+{% endblock %}
+
+
+
\ No newline at end of file
diff --git a/views/change.html.twig b/views/change.html.twig
new file mode 100644
index 0000000..c9e29ac
--- /dev/null
+++ b/views/change.html.twig
@@ -0,0 +1,20 @@
+{% extends 'base.html.twig' %}
+
+{% block content %}
+
+
+
Please wait while the images are loaded.
+
+
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/views/finish.html.twig b/views/finish.html.twig
new file mode 100644
index 0000000..8285ab9
--- /dev/null
+++ b/views/finish.html.twig
@@ -0,0 +1,9 @@
+{% extends 'base.html.twig' %}
+
+{% block content %}
+
+ Thank you for your participation.
+ Return to homepage »
+{% endblock %}
\ No newline at end of file
diff --git a/views/index.html.twig b/views/index.html.twig
new file mode 100644
index 0000000..1aa2db0
--- /dev/null
+++ b/views/index.html.twig
@@ -0,0 +1,29 @@
+{% extends 'base.html.twig' %}
+
+{% block content %}
+
+
+
+
+
+ Instructions
+ You will be shown a series of images, each are a pair of alternating images with a slight alteration. Your task is to find the difference as quick as possible. If you have located the difference, click on the area that you think has been changed.
+ When you click on the image, you will be taken to the next pair of images. In total, you will assess three different pairs.
+
+
+ Disclaimer
+ Zappos.com is in no way affaliated with this website, nor does it have any relation to the contents of this website.
+ For purposes of keeing track of your progress through the test, this website stores a cookie with session information. This cookie will expire once you close your browser.
+
+
+{% endblock %}
+
+{% block webapis %}
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/views/next.html.twig b/views/next.html.twig
new file mode 100644
index 0000000..d00cdf9
--- /dev/null
+++ b/views/next.html.twig
@@ -0,0 +1,9 @@
+{% extends 'base.html.twig' %}
+
+{% block content %}
+
+ Your response has been recorded.
+ « Retry Continue to step {{ step_count + 1 }} »
+{% endblock %}
\ No newline at end of file
diff --git a/views/results.html.twig b/views/results.html.twig
new file mode 100644
index 0000000..d813893
--- /dev/null
+++ b/views/results.html.twig
@@ -0,0 +1,77 @@
+{% extends 'base.html.twig' %}
+
+{% block content %}
+
+ {% if records == 1 %}Retrieved 1 result.{% else %}Retrieved {{ records }} results.{% endif %}
+ {% if allow_filtering %}
+
+ {% endif %}
+
+ Statistics
+
+
+
+ #
+ Notable
+ Unnoted
+ Renoted
+
+
+
+ {% for record in stats %}
+
+ {{ loop.index }}.
+ {% if record.notable.correct %} {% else %} {% endif %} {{ record.notable.time / 1000 }} seconds
+ {% if record.unnoted.correct %} {% else %} {% endif %} {{ record.unnoted.time / 1000 }} seconds
+ {% if record.renoted.correct %} {% else %} {% endif %} {{ record.renoted.time / 1000 }} seconds
+
+ {% endfor %}
+
+
+
+ Raw results
+ Download results
+
+
+
+ #
+ Notable
+ Unnoted
+ Renoted
+
+
+
+ x
+ y
+ time
+ x
+ y
+ time
+ x
+ y
+ time
+
+
+
+ {% for record in data %}
+
+ {{ loop.index }}.
+ {{ record.notable.xcoordinate }}
+ {{ record.notable.ycoordinate }}
+ {{ record.notable.responsetime }}
+ {{ record.unnoted.xcoordinate }}
+ {{ record.unnoted.ycoordinate }}
+ {{ record.unnoted.responsetime }}
+ {{ record.renoted.xcoordinate }}
+ {{ record.renoted.ycoordinate }}
+ {{ record.renoted.responsetime }}
+
+ {% endfor %}
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/views/results.txt.twig b/views/results.txt.twig
new file mode 100644
index 0000000..8cbaae2
--- /dev/null
+++ b/views/results.txt.twig
@@ -0,0 +1,5 @@
+notable unnoted renoted
+x y time x y time x y time
+{% for result in data %}
+{{result.notable.xcoordinate}} {{result.notable.ycoordinate}} {{result.notable.responsetime}} {{result.unnoted.xcoordinate}} {{result.unnoted.ycoordinate}} {{result.unnoted.responsetime}} {{result.renoted.xcoordinate}} {{result.renoted.ycoordinate}} {{result.renoted.responsetime}}
+{% endfor %}
From 9149a682b1ca63454e073acadfe4bf36fe588544 Mon Sep 17 00:00:00 2001
From: Raymond Jelierse
Date: Sat, 25 Feb 2012 20:57:13 +0100
Subject: [PATCH 2/9] Fixed style error in README.
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index 128c076..32d7af4 100644
--- a/README.md
+++ b/README.md
@@ -24,5 +24,6 @@ Set up
Acknowledgements
--------------
The change blindness test makes use of the following projects:
+
* [jquery](http://jquery.com/)
* [bootstrap](http://twitter.github.com/bootstrap/)
From eda91ff49266f2ed6dc03411442fd2718c2cac0d Mon Sep 17 00:00:00 2001
From: Raymond Jelierse
Date: Sat, 25 Feb 2012 21:08:20 +0100
Subject: [PATCH 3/9] Updates to README.md
---
README.md | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index 32d7af4..4fbba3d 100644
--- a/README.md
+++ b/README.md
@@ -1,29 +1,30 @@
Change blindness test
-===================
+=====================
This is a small web application that can be used to test change blindness. It was developed for
an assignment in the Visual Communication Design course on the Design for Interaction master at
-the Delft University of Technology by Raymond Jelierse.
+the [Delft University of Technology] by [Raymond Jelierse].
Requirements
------------
+------------
* A webserver with the following packages:
* PHP 5.3.x
* MySQL 5.x
- * Twig 1.6
+ * [Twig] 1.6
* Pairs of images to test with.
The filenames should have the following format: `-(with|without).png`.
You can configure the phases in the `settings.json` file.
Set up
------
+------
1. Place the change blindness test somewhere in your webroot.
2. Edit the settings file to your needs.
3. Add the images to the `img` directory.
4. Go to `/install/` and follow the on screen instructions.
Acknowledgements
---------------
-The change blindness test makes use of the following projects:
+----------------
+This project includes code from [Bootstrap].
-* [jquery](http://jquery.com/)
-* [bootstrap](http://twitter.github.com/bootstrap/)
+[Bootstrap]: http://twitter.github.com/bootstrap/
+[Delft University of Technology]: http://home.tudelft.nl/
+[Raymond Jelierse]: http://www.raymondjelierse.nl/
\ No newline at end of file
From abadd5bc3851883a6628a1644136b27380358226 Mon Sep 17 00:00:00 2001
From: mattbk
Date: Wed, 28 Oct 2015 22:04:20 -0500
Subject: [PATCH 4/9] Start working
Modified some paths to be more generic and not require rewrite. Some
instances of phase names have been changed, others are still in process.
---
.gitignore | 4 +
.htaccess | 4 +-
Twig/Autoloader.php | 54 +
Twig/BaseNodeVisitor.php | 62 +
Twig/Cache/Filesystem.php | 96 +
Twig/Cache/Null.php | 48 +
Twig/CacheInterface.php | 56 +
Twig/Compiler.php | 277 +++
Twig/CompilerInterface.php | 36 +
Twig/Environment.php | 1355 ++++++++++++++
Twig/Error.php | 250 +++
Twig/Error/Loader.php | 31 +
Twig/Error/Runtime.php | 20 +
Twig/Error/Syntax.php | 20 +
Twig/ExistsLoaderInterface.php | 29 +
Twig/ExpressionParser.php | 645 +++++++
Twig/Extension.php | 75 +
Twig/Extension/Core.php | 1574 +++++++++++++++++
Twig/Extension/Debug.php | 71 +
Twig/Extension/Escaper.php | 122 ++
Twig/Extension/Optimizer.php | 35 +
Twig/Extension/Profiler.php | 52 +
Twig/Extension/Sandbox.php | 112 ++
Twig/Extension/Staging.php | 115 ++
Twig/Extension/StringLoader.php | 47 +
Twig/ExtensionInterface.php | 83 +
Twig/FileExtensionEscapingStrategy.php | 58 +
Twig/Filter.php | 84 +
Twig/Filter/Function.php | 40 +
Twig/Filter/Method.php | 42 +
Twig/Filter/Node.php | 42 +
Twig/FilterCallableInterface.php | 24 +
Twig/FilterInterface.php | 43 +
Twig/Function.php | 74 +
Twig/Function/Function.php | 41 +
Twig/Function/Method.php | 43 +
Twig/Function/Node.php | 42 +
Twig/FunctionCallableInterface.php | 24 +
Twig/FunctionInterface.php | 40 +
Twig/Lexer.php | 411 +++++
Twig/LexerInterface.php | 32 +
Twig/Loader/Array.php | 95 +
Twig/Loader/Chain.php | 138 ++
Twig/Loader/Filesystem.php | 260 +++
Twig/Loader/String.php | 63 +
Twig/LoaderInterface.php | 53 +
Twig/Markup.php | 37 +
Twig/Node.php | 231 +++
Twig/Node/AutoEscape.php | 39 +
Twig/Node/Block.php | 44 +
Twig/Node/BlockReference.php | 37 +
Twig/Node/Body.php | 19 +
Twig/Node/CheckSecurity.php | 78 +
Twig/Node/Do.php | 38 +
Twig/Node/Embed.php | 42 +
Twig/Node/Expression.php | 20 +
Twig/Node/Expression/Array.php | 86 +
Twig/Node/Expression/AssignName.php | 28 +
Twig/Node/Expression/Binary.php | 40 +
Twig/Node/Expression/Binary/Add.php | 18 +
Twig/Node/Expression/Binary/And.php | 18 +
Twig/Node/Expression/Binary/BitwiseAnd.php | 18 +
Twig/Node/Expression/Binary/BitwiseOr.php | 18 +
Twig/Node/Expression/Binary/BitwiseXor.php | 18 +
Twig/Node/Expression/Binary/Concat.php | 18 +
Twig/Node/Expression/Binary/Div.php | 18 +
Twig/Node/Expression/Binary/EndsWith.php | 30 +
Twig/Node/Expression/Binary/Equal.php | 17 +
Twig/Node/Expression/Binary/FloorDiv.php | 29 +
Twig/Node/Expression/Binary/Greater.php | 17 +
Twig/Node/Expression/Binary/GreaterEqual.php | 17 +
Twig/Node/Expression/Binary/In.php | 33 +
Twig/Node/Expression/Binary/Less.php | 17 +
Twig/Node/Expression/Binary/LessEqual.php | 17 +
Twig/Node/Expression/Binary/Matches.php | 28 +
Twig/Node/Expression/Binary/Mod.php | 18 +
Twig/Node/Expression/Binary/Mul.php | 18 +
Twig/Node/Expression/Binary/NotEqual.php | 17 +
Twig/Node/Expression/Binary/NotIn.php | 33 +
Twig/Node/Expression/Binary/Or.php | 18 +
Twig/Node/Expression/Binary/Power.php | 33 +
Twig/Node/Expression/Binary/Range.php | 33 +
Twig/Node/Expression/Binary/StartsWith.php | 30 +
Twig/Node/Expression/Binary/Sub.php | 18 +
Twig/Node/Expression/BlockReference.php | 51 +
Twig/Node/Expression/Call.php | 247 +++
Twig/Node/Expression/Conditional.php | 31 +
Twig/Node/Expression/Constant.php | 23 +
Twig/Node/Expression/ExtensionReference.php | 33 +
Twig/Node/Expression/Filter.php | 39 +
Twig/Node/Expression/Filter/Default.php | 43 +
Twig/Node/Expression/Function.php | 38 +
Twig/Node/Expression/GetAttr.php | 63 +
Twig/Node/Expression/MethodCall.php | 41 +
Twig/Node/Expression/Name.php | 98 +
Twig/Node/Expression/Parent.php | 47 +
Twig/Node/Expression/TempName.php | 26 +
Twig/Node/Expression/Test.php | 35 +
Twig/Node/Expression/Test/Constant.php | 46 +
Twig/Node/Expression/Test/Defined.php | 54 +
Twig/Node/Expression/Test/Divisibleby.php | 33 +
Twig/Node/Expression/Test/Even.php | 32 +
Twig/Node/Expression/Test/Null.php | 31 +
Twig/Node/Expression/Test/Odd.php | 32 +
Twig/Node/Expression/Test/Sameas.php | 29 +
Twig/Node/Expression/Unary.php | 27 +
Twig/Node/Expression/Unary/Neg.php | 18 +
Twig/Node/Expression/Unary/Not.php | 18 +
Twig/Node/Expression/Unary/Pos.php | 18 +
Twig/Node/Flush.php | 36 +
Twig/Node/For.php | 111 ++
Twig/Node/ForLoop.php | 55 +
Twig/Node/If.php | 66 +
Twig/Node/Import.php | 54 +
Twig/Node/Include.php | 88 +
Twig/Node/Macro.php | 123 ++
Twig/Node/Module.php | 408 +++++
Twig/Node/Print.php | 39 +
Twig/Node/Sandbox.php | 47 +
Twig/Node/SandboxedPrint.php | 61 +
Twig/Node/Set.php | 101 ++
Twig/Node/SetTemp.php | 35 +
Twig/Node/Spaceless.php | 40 +
Twig/Node/Text.php | 39 +
Twig/NodeInterface.php | 31 +
Twig/NodeOutputInterface.php | 19 +
Twig/NodeTraverser.php | 89 +
Twig/NodeVisitor/Escaper.php | 157 ++
Twig/NodeVisitor/Optimizer.php | 271 +++
Twig/NodeVisitor/SafeAnalysis.php | 154 ++
Twig/NodeVisitor/Sandbox.php | 82 +
Twig/NodeVisitorInterface.php | 47 +
Twig/Parser.php | 399 +++++
Twig/ParserInterface.php | 31 +
Twig/Profiler/Dumper/Blackfire.php | 68 +
Twig/Profiler/Dumper/Html.php | 43 +
Twig/Profiler/Dumper/Text.php | 68 +
Twig/Profiler/Node/EnterProfile.php | 40 +
Twig/Profiler/Node/LeaveProfile.php | 34 +
Twig/Profiler/NodeVisitor/Profiler.php | 72 +
Twig/Profiler/Profile.php | 160 ++
Twig/Sandbox/SecurityError.php | 19 +
.../Sandbox/SecurityNotAllowedFilterError.php | 31 +
.../SecurityNotAllowedFunctionError.php | 31 +
Twig/Sandbox/SecurityNotAllowedTagError.php | 31 +
Twig/Sandbox/SecurityPolicy.php | 119 ++
Twig/Sandbox/SecurityPolicyInterface.php | 24 +
Twig/SimpleFilter.php | 112 ++
Twig/SimpleFunction.php | 102 ++
Twig/SimpleTest.php | 64 +
Twig/Template.php | 614 +++++++
Twig/TemplateInterface.php | 48 +
Twig/Test.php | 37 +
Twig/Test/Function.php | 38 +
Twig/Test/IntegrationTestCase.php | 230 +++
Twig/Test/Method.php | 40 +
Twig/Test/Node.php | 40 +
Twig/Test/NodeTestCase.php | 60 +
Twig/TestCallableInterface.php | 22 +
Twig/TestInterface.php | 27 +
Twig/Token.php | 216 +++
Twig/TokenParser.php | 33 +
Twig/TokenParser/AutoEscape.php | 91 +
Twig/TokenParser/Block.php | 81 +
Twig/TokenParser/Do.php | 42 +
Twig/TokenParser/Embed.php | 66 +
Twig/TokenParser/Extends.php | 52 +
Twig/TokenParser/Filter.php | 61 +
Twig/TokenParser/Flush.php | 42 +
Twig/TokenParser/For.php | 135 ++
Twig/TokenParser/From.php | 74 +
Twig/TokenParser/If.php | 94 +
Twig/TokenParser/Import.php | 49 +
Twig/TokenParser/Include.php | 75 +
Twig/TokenParser/Macro.php | 68 +
Twig/TokenParser/Sandbox.php | 68 +
Twig/TokenParser/Set.php | 83 +
Twig/TokenParser/Spaceless.php | 59 +
Twig/TokenParser/Use.php | 76 +
Twig/TokenParserBroker.php | 141 ++
Twig/TokenParserBrokerInterface.php | 46 +
Twig/TokenParserInterface.php | 43 +
Twig/TokenStream.php | 155 ++
Twig/Util/DeprecationCollector.php | 82 +
Twig/Util/TemplateDirIterator.php | 26 +
img/scene1-with.png | Bin 0 -> 195683 bytes
img/scene1-without.png | Bin 0 -> 158024 bytes
img/scene2-with.png | Bin 0 -> 195683 bytes
img/scene2-without.png | Bin 0 -> 158024 bytes
index.php | 5 +-
js/change.js | 4 +-
views/index.html.twig | 5 +-
192 files changed, 16085 insertions(+), 7 deletions(-)
create mode 100644 .gitignore
mode change 100644 => 100755 .htaccess
create mode 100644 Twig/Autoloader.php
create mode 100644 Twig/BaseNodeVisitor.php
create mode 100644 Twig/Cache/Filesystem.php
create mode 100644 Twig/Cache/Null.php
create mode 100644 Twig/CacheInterface.php
create mode 100644 Twig/Compiler.php
create mode 100644 Twig/CompilerInterface.php
create mode 100644 Twig/Environment.php
create mode 100644 Twig/Error.php
create mode 100644 Twig/Error/Loader.php
create mode 100644 Twig/Error/Runtime.php
create mode 100644 Twig/Error/Syntax.php
create mode 100644 Twig/ExistsLoaderInterface.php
create mode 100644 Twig/ExpressionParser.php
create mode 100644 Twig/Extension.php
create mode 100644 Twig/Extension/Core.php
create mode 100644 Twig/Extension/Debug.php
create mode 100644 Twig/Extension/Escaper.php
create mode 100644 Twig/Extension/Optimizer.php
create mode 100644 Twig/Extension/Profiler.php
create mode 100644 Twig/Extension/Sandbox.php
create mode 100644 Twig/Extension/Staging.php
create mode 100644 Twig/Extension/StringLoader.php
create mode 100644 Twig/ExtensionInterface.php
create mode 100644 Twig/FileExtensionEscapingStrategy.php
create mode 100644 Twig/Filter.php
create mode 100644 Twig/Filter/Function.php
create mode 100644 Twig/Filter/Method.php
create mode 100644 Twig/Filter/Node.php
create mode 100644 Twig/FilterCallableInterface.php
create mode 100644 Twig/FilterInterface.php
create mode 100644 Twig/Function.php
create mode 100644 Twig/Function/Function.php
create mode 100644 Twig/Function/Method.php
create mode 100644 Twig/Function/Node.php
create mode 100644 Twig/FunctionCallableInterface.php
create mode 100644 Twig/FunctionInterface.php
create mode 100644 Twig/Lexer.php
create mode 100644 Twig/LexerInterface.php
create mode 100644 Twig/Loader/Array.php
create mode 100644 Twig/Loader/Chain.php
create mode 100644 Twig/Loader/Filesystem.php
create mode 100644 Twig/Loader/String.php
create mode 100644 Twig/LoaderInterface.php
create mode 100644 Twig/Markup.php
create mode 100644 Twig/Node.php
create mode 100644 Twig/Node/AutoEscape.php
create mode 100644 Twig/Node/Block.php
create mode 100644 Twig/Node/BlockReference.php
create mode 100644 Twig/Node/Body.php
create mode 100644 Twig/Node/CheckSecurity.php
create mode 100644 Twig/Node/Do.php
create mode 100644 Twig/Node/Embed.php
create mode 100644 Twig/Node/Expression.php
create mode 100644 Twig/Node/Expression/Array.php
create mode 100644 Twig/Node/Expression/AssignName.php
create mode 100644 Twig/Node/Expression/Binary.php
create mode 100644 Twig/Node/Expression/Binary/Add.php
create mode 100644 Twig/Node/Expression/Binary/And.php
create mode 100644 Twig/Node/Expression/Binary/BitwiseAnd.php
create mode 100644 Twig/Node/Expression/Binary/BitwiseOr.php
create mode 100644 Twig/Node/Expression/Binary/BitwiseXor.php
create mode 100644 Twig/Node/Expression/Binary/Concat.php
create mode 100644 Twig/Node/Expression/Binary/Div.php
create mode 100644 Twig/Node/Expression/Binary/EndsWith.php
create mode 100644 Twig/Node/Expression/Binary/Equal.php
create mode 100644 Twig/Node/Expression/Binary/FloorDiv.php
create mode 100644 Twig/Node/Expression/Binary/Greater.php
create mode 100644 Twig/Node/Expression/Binary/GreaterEqual.php
create mode 100644 Twig/Node/Expression/Binary/In.php
create mode 100644 Twig/Node/Expression/Binary/Less.php
create mode 100644 Twig/Node/Expression/Binary/LessEqual.php
create mode 100644 Twig/Node/Expression/Binary/Matches.php
create mode 100644 Twig/Node/Expression/Binary/Mod.php
create mode 100644 Twig/Node/Expression/Binary/Mul.php
create mode 100644 Twig/Node/Expression/Binary/NotEqual.php
create mode 100644 Twig/Node/Expression/Binary/NotIn.php
create mode 100644 Twig/Node/Expression/Binary/Or.php
create mode 100644 Twig/Node/Expression/Binary/Power.php
create mode 100644 Twig/Node/Expression/Binary/Range.php
create mode 100644 Twig/Node/Expression/Binary/StartsWith.php
create mode 100644 Twig/Node/Expression/Binary/Sub.php
create mode 100644 Twig/Node/Expression/BlockReference.php
create mode 100644 Twig/Node/Expression/Call.php
create mode 100644 Twig/Node/Expression/Conditional.php
create mode 100644 Twig/Node/Expression/Constant.php
create mode 100644 Twig/Node/Expression/ExtensionReference.php
create mode 100644 Twig/Node/Expression/Filter.php
create mode 100644 Twig/Node/Expression/Filter/Default.php
create mode 100644 Twig/Node/Expression/Function.php
create mode 100644 Twig/Node/Expression/GetAttr.php
create mode 100644 Twig/Node/Expression/MethodCall.php
create mode 100644 Twig/Node/Expression/Name.php
create mode 100644 Twig/Node/Expression/Parent.php
create mode 100644 Twig/Node/Expression/TempName.php
create mode 100644 Twig/Node/Expression/Test.php
create mode 100644 Twig/Node/Expression/Test/Constant.php
create mode 100644 Twig/Node/Expression/Test/Defined.php
create mode 100644 Twig/Node/Expression/Test/Divisibleby.php
create mode 100644 Twig/Node/Expression/Test/Even.php
create mode 100644 Twig/Node/Expression/Test/Null.php
create mode 100644 Twig/Node/Expression/Test/Odd.php
create mode 100644 Twig/Node/Expression/Test/Sameas.php
create mode 100644 Twig/Node/Expression/Unary.php
create mode 100644 Twig/Node/Expression/Unary/Neg.php
create mode 100644 Twig/Node/Expression/Unary/Not.php
create mode 100644 Twig/Node/Expression/Unary/Pos.php
create mode 100644 Twig/Node/Flush.php
create mode 100644 Twig/Node/For.php
create mode 100644 Twig/Node/ForLoop.php
create mode 100644 Twig/Node/If.php
create mode 100644 Twig/Node/Import.php
create mode 100644 Twig/Node/Include.php
create mode 100644 Twig/Node/Macro.php
create mode 100644 Twig/Node/Module.php
create mode 100644 Twig/Node/Print.php
create mode 100644 Twig/Node/Sandbox.php
create mode 100644 Twig/Node/SandboxedPrint.php
create mode 100644 Twig/Node/Set.php
create mode 100644 Twig/Node/SetTemp.php
create mode 100644 Twig/Node/Spaceless.php
create mode 100644 Twig/Node/Text.php
create mode 100644 Twig/NodeInterface.php
create mode 100644 Twig/NodeOutputInterface.php
create mode 100644 Twig/NodeTraverser.php
create mode 100644 Twig/NodeVisitor/Escaper.php
create mode 100644 Twig/NodeVisitor/Optimizer.php
create mode 100644 Twig/NodeVisitor/SafeAnalysis.php
create mode 100644 Twig/NodeVisitor/Sandbox.php
create mode 100644 Twig/NodeVisitorInterface.php
create mode 100644 Twig/Parser.php
create mode 100644 Twig/ParserInterface.php
create mode 100644 Twig/Profiler/Dumper/Blackfire.php
create mode 100644 Twig/Profiler/Dumper/Html.php
create mode 100644 Twig/Profiler/Dumper/Text.php
create mode 100644 Twig/Profiler/Node/EnterProfile.php
create mode 100644 Twig/Profiler/Node/LeaveProfile.php
create mode 100644 Twig/Profiler/NodeVisitor/Profiler.php
create mode 100644 Twig/Profiler/Profile.php
create mode 100644 Twig/Sandbox/SecurityError.php
create mode 100644 Twig/Sandbox/SecurityNotAllowedFilterError.php
create mode 100644 Twig/Sandbox/SecurityNotAllowedFunctionError.php
create mode 100644 Twig/Sandbox/SecurityNotAllowedTagError.php
create mode 100644 Twig/Sandbox/SecurityPolicy.php
create mode 100644 Twig/Sandbox/SecurityPolicyInterface.php
create mode 100644 Twig/SimpleFilter.php
create mode 100644 Twig/SimpleFunction.php
create mode 100644 Twig/SimpleTest.php
create mode 100644 Twig/Template.php
create mode 100644 Twig/TemplateInterface.php
create mode 100644 Twig/Test.php
create mode 100644 Twig/Test/Function.php
create mode 100644 Twig/Test/IntegrationTestCase.php
create mode 100644 Twig/Test/Method.php
create mode 100644 Twig/Test/Node.php
create mode 100644 Twig/Test/NodeTestCase.php
create mode 100644 Twig/TestCallableInterface.php
create mode 100644 Twig/TestInterface.php
create mode 100644 Twig/Token.php
create mode 100644 Twig/TokenParser.php
create mode 100644 Twig/TokenParser/AutoEscape.php
create mode 100644 Twig/TokenParser/Block.php
create mode 100644 Twig/TokenParser/Do.php
create mode 100644 Twig/TokenParser/Embed.php
create mode 100644 Twig/TokenParser/Extends.php
create mode 100644 Twig/TokenParser/Filter.php
create mode 100644 Twig/TokenParser/Flush.php
create mode 100644 Twig/TokenParser/For.php
create mode 100644 Twig/TokenParser/From.php
create mode 100644 Twig/TokenParser/If.php
create mode 100644 Twig/TokenParser/Import.php
create mode 100644 Twig/TokenParser/Include.php
create mode 100644 Twig/TokenParser/Macro.php
create mode 100644 Twig/TokenParser/Sandbox.php
create mode 100644 Twig/TokenParser/Set.php
create mode 100644 Twig/TokenParser/Spaceless.php
create mode 100644 Twig/TokenParser/Use.php
create mode 100644 Twig/TokenParserBroker.php
create mode 100644 Twig/TokenParserBrokerInterface.php
create mode 100644 Twig/TokenParserInterface.php
create mode 100644 Twig/TokenStream.php
create mode 100644 Twig/Util/DeprecationCollector.php
create mode 100644 Twig/Util/TemplateDirIterator.php
create mode 100644 img/scene1-with.png
create mode 100644 img/scene1-without.png
create mode 100644 img/scene2-with.png
create mode 100644 img/scene2-without.png
mode change 100644 => 100755 index.php
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..e43da88
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+
+settings.json
+
+error_log
diff --git a/.htaccess b/.htaccess
old mode 100644
new mode 100755
index 7fd4e97..61c79b6
--- a/.htaccess
+++ b/.htaccess
@@ -1,9 +1,11 @@
+DirectoryIndex index.php index.shtml index.html
+
RewriteEngine On
RewriteBase /
RewriteRule ^(start|finish|results)/?$ index.php?mode=$1 [L]
- RewriteRule ^phase/(notable|unnoted|renoted)/?$ index.php?mode=phase&phase=$1 [L]
+ # RewriteRule ^phase/(notable|unnoted|renoted)/?$ index.php?mode=phase&phase=$1 [L]
RewriteRule ^results/(download|filtered)/? index.php?mode=results&$1=1 [L]
diff --git a/Twig/Autoloader.php b/Twig/Autoloader.php
new file mode 100644
index 0000000..d47583f
--- /dev/null
+++ b/Twig/Autoloader.php
@@ -0,0 +1,54 @@
+
+ *
+ * @deprecated Use Composer instead. Will be removed in Twig 2.0.
+ */
+class Twig_Autoloader
+{
+ /**
+ * Registers Twig_Autoloader as an SPL autoloader.
+ *
+ * @param bool $prepend Whether to prepend the autoloader or not.
+ */
+ public static function register($prepend = false)
+ {
+ @trigger_error('Using Twig_Autoloader is deprecated. Use Composer instead.', E_USER_DEPRECATED);
+
+ if (PHP_VERSION_ID < 50300) {
+ spl_autoload_register(array(__CLASS__, 'autoload'));
+ } else {
+ spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
+ }
+ }
+
+ /**
+ * Handles autoloading of classes.
+ *
+ * @param string $class A class name.
+ */
+ public static function autoload($class)
+ {
+ if (0 !== strpos($class, 'Twig')) {
+ return;
+ }
+
+ if (is_file($file = dirname(__FILE__).'/../'.str_replace(array('_', "\0"), array('/', ''), $class).'.php')) {
+ require $file;
+ }
+ }
+}
diff --git a/Twig/BaseNodeVisitor.php b/Twig/BaseNodeVisitor.php
new file mode 100644
index 0000000..3c6ef66
--- /dev/null
+++ b/Twig/BaseNodeVisitor.php
@@ -0,0 +1,62 @@
+
+ */
+abstract class Twig_BaseNodeVisitor implements Twig_NodeVisitorInterface
+{
+ /**
+ * {@inheritdoc}
+ */
+ final public function enterNode(Twig_NodeInterface $node, Twig_Environment $env)
+ {
+ if (!$node instanceof Twig_Node) {
+ throw new LogicException('Twig_BaseNodeVisitor only supports Twig_Node instances.');
+ }
+
+ return $this->doEnterNode($node, $env);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ final public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env)
+ {
+ if (!$node instanceof Twig_Node) {
+ throw new LogicException('Twig_BaseNodeVisitor only supports Twig_Node instances.');
+ }
+
+ return $this->doLeaveNode($node, $env);
+ }
+
+ /**
+ * Called before child nodes are visited.
+ *
+ * @param Twig_Node $node The node to visit
+ * @param Twig_Environment $env The Twig environment instance
+ *
+ * @return Twig_Node The modified node
+ */
+ abstract protected function doEnterNode(Twig_Node $node, Twig_Environment $env);
+
+ /**
+ * Called after child nodes are visited.
+ *
+ * @param Twig_Node $node The node to visit
+ * @param Twig_Environment $env The Twig environment instance
+ *
+ * @return Twig_Node|false The modified node or false if the node must be removed
+ */
+ abstract protected function doLeaveNode(Twig_Node $node, Twig_Environment $env);
+}
diff --git a/Twig/Cache/Filesystem.php b/Twig/Cache/Filesystem.php
new file mode 100644
index 0000000..2c2182a
--- /dev/null
+++ b/Twig/Cache/Filesystem.php
@@ -0,0 +1,96 @@
+
+ */
+class Twig_Cache_Filesystem implements Twig_CacheInterface
+{
+ const FORCE_BYTECODE_INVALIDATION = 1;
+
+ private $directory;
+ private $options;
+
+ /**
+ * @param $directory string The root cache directory
+ * @param $options int A set of options
+ */
+ public function __construct($directory, $options = 0)
+ {
+ $this->directory = $directory;
+ $this->options = $options;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function generateKey($name, $className)
+ {
+ $hash = hash('sha256', $className);
+
+ return $this->directory.'/'.$hash[0].$hash[1].'/'.$hash.'.php';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function load($key)
+ {
+ @include_once $key;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function write($key, $content)
+ {
+ $dir = dirname($key);
+ if (!is_dir($dir)) {
+ if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) {
+ throw new RuntimeException(sprintf('Unable to create the cache directory (%s).', $dir));
+ }
+ } elseif (!is_writable($dir)) {
+ throw new RuntimeException(sprintf('Unable to write in the cache directory (%s).', $dir));
+ }
+
+ $tmpFile = tempnam($dir, basename($key));
+ if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $key)) {
+ @chmod($key, 0666 & ~umask());
+
+ if (self::FORCE_BYTECODE_INVALIDATION == ($this->options & self::FORCE_BYTECODE_INVALIDATION)) {
+ // Compile cached file into bytecode cache
+ if (function_exists('opcache_invalidate')) {
+ opcache_invalidate($key, true);
+ } elseif (function_exists('apc_compile_file')) {
+ apc_compile_file($key);
+ }
+ }
+
+ return;
+ }
+
+ throw new RuntimeException(sprintf('Failed to write cache file "%s".', $key));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getTimestamp($key)
+ {
+ if (!file_exists($key)) {
+ return 0;
+ }
+
+ return (int) @filemtime($key);
+ }
+}
diff --git a/Twig/Cache/Null.php b/Twig/Cache/Null.php
new file mode 100644
index 0000000..fde8c80
--- /dev/null
+++ b/Twig/Cache/Null.php
@@ -0,0 +1,48 @@
+
+ */
+class Twig_Cache_Null implements Twig_CacheInterface
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function generateKey($name, $className)
+ {
+ return '';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function write($key, $content)
+ {
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function load($key)
+ {
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getTimestamp($key)
+ {
+ return 0;
+ }
+}
diff --git a/Twig/CacheInterface.php b/Twig/CacheInterface.php
new file mode 100644
index 0000000..9b17e0f
--- /dev/null
+++ b/Twig/CacheInterface.php
@@ -0,0 +1,56 @@
+
+ */
+interface Twig_CacheInterface
+{
+ /**
+ * Generates a cache key for the given template class name.
+ *
+ * @param string $name The template name
+ * @param string $className The template class name
+ *
+ * @return string
+ */
+ public function generateKey($name, $className);
+
+ /**
+ * Writes the compiled template to cache.
+ *
+ * @param string $key The cache key
+ * @param string $content The template representation as a PHP class
+ */
+ public function write($key, $content);
+
+ /**
+ * Loads a template from the cache.
+ *
+ * @param string $key The cache key
+ */
+ public function load($key);
+
+ /**
+ * Returns the modification timestamp of a key.
+ *
+ * @param string $key The cache key
+ *
+ * @return int
+ */
+ public function getTimestamp($key);
+}
diff --git a/Twig/Compiler.php b/Twig/Compiler.php
new file mode 100644
index 0000000..abea3aa
--- /dev/null
+++ b/Twig/Compiler.php
@@ -0,0 +1,277 @@
+
+ */
+class Twig_Compiler implements Twig_CompilerInterface
+{
+ protected $lastLine;
+ protected $source;
+ protected $indentation;
+ protected $env;
+ protected $debugInfo = array();
+ protected $sourceOffset;
+ protected $sourceLine;
+ protected $filename;
+
+ /**
+ * Constructor.
+ *
+ * @param Twig_Environment $env The twig environment instance
+ */
+ public function __construct(Twig_Environment $env)
+ {
+ $this->env = $env;
+ }
+
+ public function getFilename()
+ {
+ return $this->filename;
+ }
+
+ /**
+ * Returns the environment instance related to this compiler.
+ *
+ * @return Twig_Environment The environment instance
+ */
+ public function getEnvironment()
+ {
+ return $this->env;
+ }
+
+ /**
+ * Gets the current PHP code after compilation.
+ *
+ * @return string The PHP code
+ */
+ public function getSource()
+ {
+ return $this->source;
+ }
+
+ /**
+ * Compiles a node.
+ *
+ * @param Twig_NodeInterface $node The node to compile
+ * @param int $indentation The current indentation
+ *
+ * @return Twig_Compiler The current compiler instance
+ */
+ public function compile(Twig_NodeInterface $node, $indentation = 0)
+ {
+ $this->lastLine = null;
+ $this->source = '';
+ $this->debugInfo = array();
+ $this->sourceOffset = 0;
+ // source code starts at 1 (as we then increment it when we encounter new lines)
+ $this->sourceLine = 1;
+ $this->indentation = $indentation;
+
+ if ($node instanceof Twig_Node_Module) {
+ $this->filename = $node->getAttribute('filename');
+ }
+
+ $node->compile($this);
+
+ return $this;
+ }
+
+ public function subcompile(Twig_NodeInterface $node, $raw = true)
+ {
+ if (false === $raw) {
+ $this->addIndentation();
+ }
+
+ $node->compile($this);
+
+ return $this;
+ }
+
+ /**
+ * Adds a raw string to the compiled code.
+ *
+ * @param string $string The string
+ *
+ * @return Twig_Compiler The current compiler instance
+ */
+ public function raw($string)
+ {
+ $this->source .= $string;
+
+ return $this;
+ }
+
+ /**
+ * Writes a string to the compiled code by adding indentation.
+ *
+ * @return Twig_Compiler The current compiler instance
+ */
+ public function write()
+ {
+ $strings = func_get_args();
+ foreach ($strings as $string) {
+ $this->addIndentation();
+ $this->source .= $string;
+ }
+
+ return $this;
+ }
+
+ /**
+ * Appends an indentation to the current PHP code after compilation.
+ *
+ * @return Twig_Compiler The current compiler instance
+ */
+ public function addIndentation()
+ {
+ $this->source .= str_repeat(' ', $this->indentation * 4);
+
+ return $this;
+ }
+
+ /**
+ * Adds a quoted string to the compiled code.
+ *
+ * @param string $value The string
+ *
+ * @return Twig_Compiler The current compiler instance
+ */
+ public function string($value)
+ {
+ $this->source .= sprintf('"%s"', addcslashes($value, "\0\t\"\$\\"));
+
+ return $this;
+ }
+
+ /**
+ * Returns a PHP representation of a given value.
+ *
+ * @param mixed $value The value to convert
+ *
+ * @return Twig_Compiler The current compiler instance
+ */
+ public function repr($value)
+ {
+ if (is_int($value) || is_float($value)) {
+ if (false !== $locale = setlocale(LC_NUMERIC, 0)) {
+ setlocale(LC_NUMERIC, 'C');
+ }
+
+ $this->raw($value);
+
+ if (false !== $locale) {
+ setlocale(LC_NUMERIC, $locale);
+ }
+ } elseif (null === $value) {
+ $this->raw('null');
+ } elseif (is_bool($value)) {
+ $this->raw($value ? 'true' : 'false');
+ } elseif (is_array($value)) {
+ $this->raw('array(');
+ $first = true;
+ foreach ($value as $key => $v) {
+ if (!$first) {
+ $this->raw(', ');
+ }
+ $first = false;
+ $this->repr($key);
+ $this->raw(' => ');
+ $this->repr($v);
+ }
+ $this->raw(')');
+ } else {
+ $this->string($value);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Adds debugging information.
+ *
+ * @param Twig_NodeInterface $node The related twig node
+ *
+ * @return Twig_Compiler The current compiler instance
+ */
+ public function addDebugInfo(Twig_NodeInterface $node)
+ {
+ if ($node->getLine() != $this->lastLine) {
+ $this->write(sprintf("// line %d\n", $node->getLine()));
+
+ // when mbstring.func_overload is set to 2
+ // mb_substr_count() replaces substr_count()
+ // but they have different signatures!
+ if (((int) ini_get('mbstring.func_overload')) & 2) {
+ // this is much slower than the "right" version
+ $this->sourceLine += mb_substr_count(mb_substr($this->source, $this->sourceOffset), "\n");
+ } else {
+ $this->sourceLine += substr_count($this->source, "\n", $this->sourceOffset);
+ }
+ $this->sourceOffset = strlen($this->source);
+ $this->debugInfo[$this->sourceLine] = $node->getLine();
+
+ $this->lastLine = $node->getLine();
+ }
+
+ return $this;
+ }
+
+ public function getDebugInfo()
+ {
+ ksort($this->debugInfo);
+
+ return $this->debugInfo;
+ }
+
+ /**
+ * Indents the generated code.
+ *
+ * @param int $step The number of indentation to add
+ *
+ * @return Twig_Compiler The current compiler instance
+ */
+ public function indent($step = 1)
+ {
+ $this->indentation += $step;
+
+ return $this;
+ }
+
+ /**
+ * Outdents the generated code.
+ *
+ * @param int $step The number of indentation to remove
+ *
+ * @return Twig_Compiler The current compiler instance
+ *
+ * @throws LogicException When trying to outdent too much so the indentation would become negative
+ */
+ public function outdent($step = 1)
+ {
+ // can't outdent by more steps than the current indentation level
+ if ($this->indentation < $step) {
+ throw new LogicException('Unable to call outdent() as the indentation would become negative');
+ }
+
+ $this->indentation -= $step;
+
+ return $this;
+ }
+
+ public function getVarName()
+ {
+ return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
+ }
+}
diff --git a/Twig/CompilerInterface.php b/Twig/CompilerInterface.php
new file mode 100644
index 0000000..272c767
--- /dev/null
+++ b/Twig/CompilerInterface.php
@@ -0,0 +1,36 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 3.0)
+ */
+interface Twig_CompilerInterface
+{
+ /**
+ * Compiles a node.
+ *
+ * @param Twig_NodeInterface $node The node to compile
+ *
+ * @return Twig_CompilerInterface The current compiler instance
+ */
+ public function compile(Twig_NodeInterface $node);
+
+ /**
+ * Gets the current PHP code after compilation.
+ *
+ * @return string The PHP code
+ */
+ public function getSource();
+}
diff --git a/Twig/Environment.php b/Twig/Environment.php
new file mode 100644
index 0000000..04a656a
--- /dev/null
+++ b/Twig/Environment.php
@@ -0,0 +1,1355 @@
+
+ */
+class Twig_Environment
+{
+ const VERSION = '1.22.3';
+
+ protected $charset;
+ protected $loader;
+ protected $debug;
+ protected $autoReload;
+ protected $cache;
+ protected $lexer;
+ protected $parser;
+ protected $compiler;
+ protected $baseTemplateClass;
+ protected $extensions;
+ protected $parsers;
+ protected $visitors;
+ protected $filters;
+ protected $tests;
+ protected $functions;
+ protected $globals;
+ protected $runtimeInitialized = false;
+ protected $extensionInitialized = false;
+ protected $loadedTemplates;
+ protected $strictVariables;
+ protected $unaryOperators;
+ protected $binaryOperators;
+ protected $templateClassPrefix = '__TwigTemplate_';
+ protected $functionCallbacks = array();
+ protected $filterCallbacks = array();
+ protected $staging;
+
+ private $originalCache;
+ private $bcWriteCacheFile = false;
+ private $bcGetCacheFilename = false;
+ private $lastModifiedExtension = 0;
+
+ /**
+ * Constructor.
+ *
+ * Available options:
+ *
+ * * debug: When set to true, it automatically set "auto_reload" to true as
+ * well (default to false).
+ *
+ * * charset: The charset used by the templates (default to UTF-8).
+ *
+ * * base_template_class: The base template class to use for generated
+ * templates (default to Twig_Template).
+ *
+ * * cache: An absolute path where to store the compiled templates,
+ * a Twig_Cache_Interface implementation,
+ * or false to disable compilation cache (default).
+ *
+ * * auto_reload: Whether to reload the template if the original source changed.
+ * If you don't provide the auto_reload option, it will be
+ * determined automatically based on the debug value.
+ *
+ * * strict_variables: Whether to ignore invalid variables in templates
+ * (default to false).
+ *
+ * * autoescape: Whether to enable auto-escaping (default to html):
+ * * false: disable auto-escaping
+ * * true: equivalent to html
+ * * html, js: set the autoescaping to one of the supported strategies
+ * * filename: set the autoescaping strategy based on the template filename extension
+ * * PHP callback: a PHP callback that returns an escaping strategy based on the template "filename"
+ *
+ * * optimizations: A flag that indicates which optimizations to apply
+ * (default to -1 which means that all optimizations are enabled;
+ * set it to 0 to disable).
+ *
+ * @param Twig_LoaderInterface $loader A Twig_LoaderInterface instance
+ * @param array $options An array of options
+ */
+ public function __construct(Twig_LoaderInterface $loader = null, $options = array())
+ {
+ if (null !== $loader) {
+ $this->setLoader($loader);
+ } else {
+ @trigger_error('Not passing a Twig_LoaderInterface as the first constructor argument of Twig_Environment is deprecated.', E_USER_DEPRECATED);
+ }
+
+ $options = array_merge(array(
+ 'debug' => false,
+ 'charset' => 'UTF-8',
+ 'base_template_class' => 'Twig_Template',
+ 'strict_variables' => false,
+ 'autoescape' => 'html',
+ 'cache' => false,
+ 'auto_reload' => null,
+ 'optimizations' => -1,
+ ), $options);
+
+ $this->debug = (bool) $options['debug'];
+ $this->charset = strtoupper($options['charset']);
+ $this->baseTemplateClass = $options['base_template_class'];
+ $this->autoReload = null === $options['auto_reload'] ? $this->debug : (bool) $options['auto_reload'];
+ $this->strictVariables = (bool) $options['strict_variables'];
+ $this->setCache($options['cache']);
+
+ $this->addExtension(new Twig_Extension_Core());
+ $this->addExtension(new Twig_Extension_Escaper($options['autoescape']));
+ $this->addExtension(new Twig_Extension_Optimizer($options['optimizations']));
+ $this->staging = new Twig_Extension_Staging();
+
+ // For BC
+ if (is_string($this->originalCache)) {
+ $r = new ReflectionMethod($this, 'writeCacheFile');
+ if ($r->getDeclaringClass()->getName() !== __CLASS__) {
+ @trigger_error('The Twig_Environment::writeCacheFile method is deprecated and will be removed in Twig 2.0.', E_USER_DEPRECATED);
+
+ $this->bcWriteCacheFile = true;
+ }
+
+ $r = new ReflectionMethod($this, 'getCacheFilename');
+ if ($r->getDeclaringClass()->getName() !== __CLASS__) {
+ @trigger_error('The Twig_Environment::getCacheFilename method is deprecated and will be removed in Twig 2.0.', E_USER_DEPRECATED);
+
+ $this->bcGetCacheFilename = true;
+ }
+ }
+ }
+
+ /**
+ * Gets the base template class for compiled templates.
+ *
+ * @return string The base template class name
+ */
+ public function getBaseTemplateClass()
+ {
+ return $this->baseTemplateClass;
+ }
+
+ /**
+ * Sets the base template class for compiled templates.
+ *
+ * @param string $class The base template class name
+ */
+ public function setBaseTemplateClass($class)
+ {
+ $this->baseTemplateClass = $class;
+ }
+
+ /**
+ * Enables debugging mode.
+ */
+ public function enableDebug()
+ {
+ $this->debug = true;
+ }
+
+ /**
+ * Disables debugging mode.
+ */
+ public function disableDebug()
+ {
+ $this->debug = false;
+ }
+
+ /**
+ * Checks if debug mode is enabled.
+ *
+ * @return bool true if debug mode is enabled, false otherwise
+ */
+ public function isDebug()
+ {
+ return $this->debug;
+ }
+
+ /**
+ * Enables the auto_reload option.
+ */
+ public function enableAutoReload()
+ {
+ $this->autoReload = true;
+ }
+
+ /**
+ * Disables the auto_reload option.
+ */
+ public function disableAutoReload()
+ {
+ $this->autoReload = false;
+ }
+
+ /**
+ * Checks if the auto_reload option is enabled.
+ *
+ * @return bool true if auto_reload is enabled, false otherwise
+ */
+ public function isAutoReload()
+ {
+ return $this->autoReload;
+ }
+
+ /**
+ * Enables the strict_variables option.
+ */
+ public function enableStrictVariables()
+ {
+ $this->strictVariables = true;
+ }
+
+ /**
+ * Disables the strict_variables option.
+ */
+ public function disableStrictVariables()
+ {
+ $this->strictVariables = false;
+ }
+
+ /**
+ * Checks if the strict_variables option is enabled.
+ *
+ * @return bool true if strict_variables is enabled, false otherwise
+ */
+ public function isStrictVariables()
+ {
+ return $this->strictVariables;
+ }
+
+ /**
+ * Gets the current cache implementation.
+ *
+ * @param bool $original Whether to return the original cache option or the real cache instance
+ *
+ * @return Twig_CacheInterface|string|false A Twig_CacheInterface implementation,
+ * an absolute path to the compiled templates,
+ * or false to disable cache
+ */
+ public function getCache($original = true)
+ {
+ return $original ? $this->originalCache : $this->cache;
+ }
+
+ /**
+ * Sets the current cache implementation.
+ *
+ * @param Twig_CacheInterface|string|false $cache A Twig_CacheInterface implementation,
+ * an absolute path to the compiled templates,
+ * or false to disable cache
+ */
+ public function setCache($cache)
+ {
+ if (is_string($cache)) {
+ $this->originalCache = $cache;
+ $this->cache = new Twig_Cache_Filesystem($cache);
+ } elseif (false === $cache) {
+ $this->originalCache = $cache;
+ $this->cache = new Twig_Cache_Null();
+ } elseif (null === $cache) {
+ @trigger_error('Using "null" as the cache strategy is deprecated and will be removed in Twig 2.0.', E_USER_DEPRECATED);
+ $this->originalCache = false;
+ $this->cache = new Twig_Cache_Null();
+ } elseif ($cache instanceof Twig_CacheInterface) {
+ $this->originalCache = $this->cache = $cache;
+ } else {
+ throw new LogicException(sprintf('Cache can only be a string, false, or a Twig_CacheInterface implementation.'));
+ }
+ }
+
+ /**
+ * Gets the cache filename for a given template.
+ *
+ * @param string $name The template name
+ *
+ * @return string|false The cache file name or false when caching is disabled
+ *
+ * @deprecated since 1.22 (to be removed in 2.0)
+ */
+ public function getCacheFilename($name)
+ {
+ @trigger_error(sprintf('The %s method is deprecated and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
+
+ $key = $this->cache->generateKey($name, $this->getTemplateClass($name));
+
+ return !$key ? false : $key;
+ }
+
+ /**
+ * Gets the template class associated with the given string.
+ *
+ * The generated template class is based on the following parameters:
+ *
+ * * The cache key for the given template;
+ * * The currently enabled extensions;
+ * * Whether the Twig C extension is available or not.
+ *
+ * @param string $name The name for which to calculate the template class name
+ * @param int|null $index The index if it is an embedded template
+ *
+ * @return string The template class name
+ */
+ public function getTemplateClass($name, $index = null)
+ {
+ $key = $this->getLoader()->getCacheKey($name);
+ $key .= json_encode(array_keys($this->extensions));
+ $key .= function_exists('twig_template_get_attributes');
+
+ return $this->templateClassPrefix.hash('sha256', $key).(null === $index ? '' : '_'.$index);
+ }
+
+ /**
+ * Gets the template class prefix.
+ *
+ * @return string The template class prefix
+ *
+ * @deprecated since 1.22 (to be removed in 2.0)
+ */
+ public function getTemplateClassPrefix()
+ {
+ @trigger_error(sprintf('The %s method is deprecated and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
+
+ return $this->templateClassPrefix;
+ }
+
+ /**
+ * Renders a template.
+ *
+ * @param string $name The template name
+ * @param array $context An array of parameters to pass to the template
+ *
+ * @return string The rendered template
+ *
+ * @throws Twig_Error_Loader When the template cannot be found
+ * @throws Twig_Error_Syntax When an error occurred during compilation
+ * @throws Twig_Error_Runtime When an error occurred during rendering
+ */
+ public function render($name, array $context = array())
+ {
+ return $this->loadTemplate($name)->render($context);
+ }
+
+ /**
+ * Displays a template.
+ *
+ * @param string $name The template name
+ * @param array $context An array of parameters to pass to the template
+ *
+ * @throws Twig_Error_Loader When the template cannot be found
+ * @throws Twig_Error_Syntax When an error occurred during compilation
+ * @throws Twig_Error_Runtime When an error occurred during rendering
+ */
+ public function display($name, array $context = array())
+ {
+ $this->loadTemplate($name)->display($context);
+ }
+
+ /**
+ * Loads a template by name.
+ *
+ * @param string $name The template name
+ * @param int $index The index if it is an embedded template
+ *
+ * @return Twig_TemplateInterface A template instance representing the given template name
+ *
+ * @throws Twig_Error_Loader When the template cannot be found
+ * @throws Twig_Error_Syntax When an error occurred during compilation
+ */
+ public function loadTemplate($name, $index = null)
+ {
+ $cls = $this->getTemplateClass($name, $index);
+
+ if (isset($this->loadedTemplates[$cls])) {
+ return $this->loadedTemplates[$cls];
+ }
+
+ if (!class_exists($cls, false)) {
+ if ($this->bcGetCacheFilename) {
+ $key = $this->getCacheFilename($name);
+ } else {
+ $key = $this->cache->generateKey($name, $cls);
+ }
+
+ if (!$this->isAutoReload() || $this->isTemplateFresh($name, $this->cache->getTimestamp($key))) {
+ $this->cache->load($key);
+ }
+
+ if (!class_exists($cls, false)) {
+ $content = $this->compileSource($this->getLoader()->getSource($name), $name);
+ if ($this->bcWriteCacheFile) {
+ $this->writeCacheFile($key, $content);
+ } else {
+ $this->cache->write($key, $content);
+ }
+
+ eval('?>'.$content);
+ }
+ }
+
+ if (!$this->runtimeInitialized) {
+ $this->initRuntime();
+ }
+
+ return $this->loadedTemplates[$cls] = new $cls($this);
+ }
+
+ /**
+ * Creates a template from source.
+ *
+ * This method should not be used as a generic way to load templates.
+ *
+ * @param string $template The template name
+ *
+ * @return Twig_Template A template instance representing the given template name
+ *
+ * @throws Twig_Error_Loader When the template cannot be found
+ * @throws Twig_Error_Syntax When an error occurred during compilation
+ */
+ public function createTemplate($template)
+ {
+ $name = sprintf('__string_template__%s', hash('sha256', uniqid(mt_rand(), true), false));
+
+ $loader = new Twig_Loader_Chain(array(
+ new Twig_Loader_Array(array($name => $template)),
+ $current = $this->getLoader(),
+ ));
+
+ $this->setLoader($loader);
+ try {
+ $template = $this->loadTemplate($name);
+ } catch (Exception $e) {
+ $this->setLoader($current);
+
+ throw $e;
+ }
+ $this->setLoader($current);
+
+ return $template;
+ }
+
+ /**
+ * Returns true if the template is still fresh.
+ *
+ * Besides checking the loader for freshness information,
+ * this method also checks if the enabled extensions have
+ * not changed.
+ *
+ * @param string $name The template name
+ * @param int $time The last modification time of the cached template
+ *
+ * @return bool true if the template is fresh, false otherwise
+ */
+ public function isTemplateFresh($name, $time)
+ {
+ return $this->lastModifiedExtension <= $time && $this->getLoader()->isFresh($name, $time);
+ }
+
+ /**
+ * Tries to load a template consecutively from an array.
+ *
+ * Similar to loadTemplate() but it also accepts Twig_TemplateInterface instances and an array
+ * of templates where each is tried to be loaded.
+ *
+ * @param string|Twig_Template|array $names A template or an array of templates to try consecutively
+ *
+ * @return Twig_Template
+ *
+ * @throws Twig_Error_Loader When none of the templates can be found
+ * @throws Twig_Error_Syntax When an error occurred during compilation
+ */
+ public function resolveTemplate($names)
+ {
+ if (!is_array($names)) {
+ $names = array($names);
+ }
+
+ foreach ($names as $name) {
+ if ($name instanceof Twig_Template) {
+ return $name;
+ }
+
+ try {
+ return $this->loadTemplate($name);
+ } catch (Twig_Error_Loader $e) {
+ }
+ }
+
+ if (1 === count($names)) {
+ throw $e;
+ }
+
+ throw new Twig_Error_Loader(sprintf('Unable to find one of the following templates: "%s".', implode('", "', $names)));
+ }
+
+ /**
+ * Clears the internal template cache.
+ *
+ * @deprecated since 1.18.3 (to be removed in 2.0)
+ */
+ public function clearTemplateCache()
+ {
+ @trigger_error(sprintf('The %s method is deprecated and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
+
+ $this->loadedTemplates = array();
+ }
+
+ /**
+ * Clears the template cache files on the filesystem.
+ *
+ * @deprecated since 1.22 (to be removed in 2.0)
+ */
+ public function clearCacheFiles()
+ {
+ @trigger_error(sprintf('The %s method is deprecated and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
+
+ if (is_string($this->originalCache)) {
+ foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->originalCache), RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
+ if ($file->isFile()) {
+ @unlink($file->getPathname());
+ }
+ }
+ }
+ }
+
+ /**
+ * Gets the Lexer instance.
+ *
+ * @return Twig_LexerInterface A Twig_LexerInterface instance
+ */
+ public function getLexer()
+ {
+ if (null === $this->lexer) {
+ $this->lexer = new Twig_Lexer($this);
+ }
+
+ return $this->lexer;
+ }
+
+ /**
+ * Sets the Lexer instance.
+ *
+ * @param Twig_LexerInterface $lexer A Twig_LexerInterface instance
+ */
+ public function setLexer(Twig_LexerInterface $lexer)
+ {
+ $this->lexer = $lexer;
+ }
+
+ /**
+ * Tokenizes a source code.
+ *
+ * @param string $source The template source code
+ * @param string $name The template name
+ *
+ * @return Twig_TokenStream A Twig_TokenStream instance
+ *
+ * @throws Twig_Error_Syntax When the code is syntactically wrong
+ */
+ public function tokenize($source, $name = null)
+ {
+ return $this->getLexer()->tokenize($source, $name);
+ }
+
+ /**
+ * Gets the Parser instance.
+ *
+ * @return Twig_ParserInterface A Twig_ParserInterface instance
+ */
+ public function getParser()
+ {
+ if (null === $this->parser) {
+ $this->parser = new Twig_Parser($this);
+ }
+
+ return $this->parser;
+ }
+
+ /**
+ * Sets the Parser instance.
+ *
+ * @param Twig_ParserInterface $parser A Twig_ParserInterface instance
+ */
+ public function setParser(Twig_ParserInterface $parser)
+ {
+ $this->parser = $parser;
+ }
+
+ /**
+ * Converts a token stream to a node tree.
+ *
+ * @param Twig_TokenStream $stream A token stream instance
+ *
+ * @return Twig_Node_Module A node tree
+ *
+ * @throws Twig_Error_Syntax When the token stream is syntactically or semantically wrong
+ */
+ public function parse(Twig_TokenStream $stream)
+ {
+ return $this->getParser()->parse($stream);
+ }
+
+ /**
+ * Gets the Compiler instance.
+ *
+ * @return Twig_CompilerInterface A Twig_CompilerInterface instance
+ */
+ public function getCompiler()
+ {
+ if (null === $this->compiler) {
+ $this->compiler = new Twig_Compiler($this);
+ }
+
+ return $this->compiler;
+ }
+
+ /**
+ * Sets the Compiler instance.
+ *
+ * @param Twig_CompilerInterface $compiler A Twig_CompilerInterface instance
+ */
+ public function setCompiler(Twig_CompilerInterface $compiler)
+ {
+ $this->compiler = $compiler;
+ }
+
+ /**
+ * Compiles a node and returns the PHP code.
+ *
+ * @param Twig_NodeInterface $node A Twig_NodeInterface instance
+ *
+ * @return string The compiled PHP source code
+ */
+ public function compile(Twig_NodeInterface $node)
+ {
+ return $this->getCompiler()->compile($node)->getSource();
+ }
+
+ /**
+ * Compiles a template source code.
+ *
+ * @param string $source The template source code
+ * @param string $name The template name
+ *
+ * @return string The compiled PHP source code
+ *
+ * @throws Twig_Error_Syntax When there was an error during tokenizing, parsing or compiling
+ */
+ public function compileSource($source, $name = null)
+ {
+ try {
+ $compiled = $this->compile($this->parse($this->tokenize($source, $name)), $source);
+
+ if (isset($source[0])) {
+ $compiled .= '/* '.str_replace(array('*/', "\r\n", "\r", "\n"), array('*//* ', "\n", "\n", "*/\n/* "), $source)."*/\n";
+ }
+
+ return $compiled;
+ } catch (Twig_Error $e) {
+ $e->setTemplateFile($name);
+ throw $e;
+ } catch (Exception $e) {
+ throw new Twig_Error_Syntax(sprintf('An exception has been thrown during the compilation of a template ("%s").', $e->getMessage()), -1, $name, $e);
+ }
+ }
+
+ /**
+ * Sets the Loader instance.
+ *
+ * @param Twig_LoaderInterface $loader A Twig_LoaderInterface instance
+ */
+ public function setLoader(Twig_LoaderInterface $loader)
+ {
+ $this->loader = $loader;
+ }
+
+ /**
+ * Gets the Loader instance.
+ *
+ * @return Twig_LoaderInterface A Twig_LoaderInterface instance
+ */
+ public function getLoader()
+ {
+ if (null === $this->loader) {
+ throw new LogicException('You must set a loader first.');
+ }
+
+ return $this->loader;
+ }
+
+ /**
+ * Sets the default template charset.
+ *
+ * @param string $charset The default charset
+ */
+ public function setCharset($charset)
+ {
+ $this->charset = strtoupper($charset);
+ }
+
+ /**
+ * Gets the default template charset.
+ *
+ * @return string The default charset
+ */
+ public function getCharset()
+ {
+ return $this->charset;
+ }
+
+ /**
+ * Initializes the runtime environment.
+ */
+ public function initRuntime()
+ {
+ $this->runtimeInitialized = true;
+
+ foreach ($this->getExtensions() as $extension) {
+ $extension->initRuntime($this);
+ }
+ }
+
+ /**
+ * Returns true if the given extension is registered.
+ *
+ * @param string $name The extension name
+ *
+ * @return bool Whether the extension is registered or not
+ */
+ public function hasExtension($name)
+ {
+ return isset($this->extensions[$name]);
+ }
+
+ /**
+ * Gets an extension by name.
+ *
+ * @param string $name The extension name
+ *
+ * @return Twig_ExtensionInterface A Twig_ExtensionInterface instance
+ */
+ public function getExtension($name)
+ {
+ if (!isset($this->extensions[$name])) {
+ throw new Twig_Error_Runtime(sprintf('The "%s" extension is not enabled.', $name));
+ }
+
+ return $this->extensions[$name];
+ }
+
+ /**
+ * Registers an extension.
+ *
+ * @param Twig_ExtensionInterface $extension A Twig_ExtensionInterface instance
+ */
+ public function addExtension(Twig_ExtensionInterface $extension)
+ {
+ if ($this->extensionInitialized) {
+ throw new LogicException(sprintf('Unable to register extension "%s" as extensions have already been initialized.', $extension->getName()));
+ }
+
+ $r = new ReflectionObject($extension);
+ if (($extensionTime = filemtime($r->getFileName())) > $this->lastModifiedExtension) {
+ $this->lastModifiedExtension = $extensionTime;
+ }
+
+ $this->extensions[$extension->getName()] = $extension;
+ }
+
+ /**
+ * Removes an extension by name.
+ *
+ * This method is deprecated and you should not use it.
+ *
+ * @param string $name The extension name
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+ public function removeExtension($name)
+ {
+ @trigger_error(sprintf('The %s method is deprecated and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED);
+
+ if ($this->extensionInitialized) {
+ throw new LogicException(sprintf('Unable to remove extension "%s" as extensions have already been initialized.', $name));
+ }
+
+ unset($this->extensions[$name]);
+ }
+
+ /**
+ * Registers an array of extensions.
+ *
+ * @param array $extensions An array of extensions
+ */
+ public function setExtensions(array $extensions)
+ {
+ foreach ($extensions as $extension) {
+ $this->addExtension($extension);
+ }
+ }
+
+ /**
+ * Returns all registered extensions.
+ *
+ * @return array An array of extensions
+ */
+ public function getExtensions()
+ {
+ return $this->extensions;
+ }
+
+ /**
+ * Registers a Token Parser.
+ *
+ * @param Twig_TokenParserInterface $parser A Twig_TokenParserInterface instance
+ */
+ public function addTokenParser(Twig_TokenParserInterface $parser)
+ {
+ if ($this->extensionInitialized) {
+ throw new LogicException('Unable to add a token parser as extensions have already been initialized.');
+ }
+
+ $this->staging->addTokenParser($parser);
+ }
+
+ /**
+ * Gets the registered Token Parsers.
+ *
+ * @return Twig_TokenParserBrokerInterface A broker containing token parsers
+ */
+ public function getTokenParsers()
+ {
+ if (!$this->extensionInitialized) {
+ $this->initExtensions();
+ }
+
+ return $this->parsers;
+ }
+
+ /**
+ * Gets registered tags.
+ *
+ * Be warned that this method cannot return tags defined by Twig_TokenParserBrokerInterface classes.
+ *
+ * @return Twig_TokenParserInterface[] An array of Twig_TokenParserInterface instances
+ */
+ public function getTags()
+ {
+ $tags = array();
+ foreach ($this->getTokenParsers()->getParsers() as $parser) {
+ if ($parser instanceof Twig_TokenParserInterface) {
+ $tags[$parser->getTag()] = $parser;
+ }
+ }
+
+ return $tags;
+ }
+
+ /**
+ * Registers a Node Visitor.
+ *
+ * @param Twig_NodeVisitorInterface $visitor A Twig_NodeVisitorInterface instance
+ */
+ public function addNodeVisitor(Twig_NodeVisitorInterface $visitor)
+ {
+ if ($this->extensionInitialized) {
+ throw new LogicException('Unable to add a node visitor as extensions have already been initialized.');
+ }
+
+ $this->staging->addNodeVisitor($visitor);
+ }
+
+ /**
+ * Gets the registered Node Visitors.
+ *
+ * @return Twig_NodeVisitorInterface[] An array of Twig_NodeVisitorInterface instances
+ */
+ public function getNodeVisitors()
+ {
+ if (!$this->extensionInitialized) {
+ $this->initExtensions();
+ }
+
+ return $this->visitors;
+ }
+
+ /**
+ * Registers a Filter.
+ *
+ * @param string|Twig_SimpleFilter $name The filter name or a Twig_SimpleFilter instance
+ * @param Twig_FilterInterface|Twig_SimpleFilter $filter A Twig_FilterInterface instance or a Twig_SimpleFilter instance
+ */
+ public function addFilter($name, $filter = null)
+ {
+ if (!$name instanceof Twig_SimpleFilter && !($filter instanceof Twig_SimpleFilter || $filter instanceof Twig_FilterInterface)) {
+ throw new LogicException('A filter must be an instance of Twig_FilterInterface or Twig_SimpleFilter');
+ }
+
+ if ($name instanceof Twig_SimpleFilter) {
+ $filter = $name;
+ $name = $filter->getName();
+ } else {
+ @trigger_error(sprintf('Passing a name as a first argument to the %s method is deprecated. Pass an instance of "Twig_SimpleFilter" instead when defining filter "%s".', __METHOD__, $name), E_USER_DEPRECATED);
+ }
+
+ if ($this->extensionInitialized) {
+ throw new LogicException(sprintf('Unable to add filter "%s" as extensions have already been initialized.', $name));
+ }
+
+ $this->staging->addFilter($name, $filter);
+ }
+
+ /**
+ * Get a filter by name.
+ *
+ * Subclasses may override this method and load filters differently;
+ * so no list of filters is available.
+ *
+ * @param string $name The filter name
+ *
+ * @return Twig_Filter|false A Twig_Filter instance or false if the filter does not exist
+ */
+ public function getFilter($name)
+ {
+ if (!$this->extensionInitialized) {
+ $this->initExtensions();
+ }
+
+ if (isset($this->filters[$name])) {
+ return $this->filters[$name];
+ }
+
+ foreach ($this->filters as $pattern => $filter) {
+ $pattern = str_replace('\\*', '(.*?)', preg_quote($pattern, '#'), $count);
+
+ if ($count) {
+ if (preg_match('#^'.$pattern.'$#', $name, $matches)) {
+ array_shift($matches);
+ $filter->setArguments($matches);
+
+ return $filter;
+ }
+ }
+ }
+
+ foreach ($this->filterCallbacks as $callback) {
+ if (false !== $filter = call_user_func($callback, $name)) {
+ return $filter;
+ }
+ }
+
+ return false;
+ }
+
+ public function registerUndefinedFilterCallback($callable)
+ {
+ $this->filterCallbacks[] = $callable;
+ }
+
+ /**
+ * Gets the registered Filters.
+ *
+ * Be warned that this method cannot return filters defined with registerUndefinedFunctionCallback.
+ *
+ * @return Twig_FilterInterface[] An array of Twig_FilterInterface instances
+ *
+ * @see registerUndefinedFilterCallback
+ */
+ public function getFilters()
+ {
+ if (!$this->extensionInitialized) {
+ $this->initExtensions();
+ }
+
+ return $this->filters;
+ }
+
+ /**
+ * Registers a Test.
+ *
+ * @param string|Twig_SimpleTest $name The test name or a Twig_SimpleTest instance
+ * @param Twig_TestInterface|Twig_SimpleTest $test A Twig_TestInterface instance or a Twig_SimpleTest instance
+ */
+ public function addTest($name, $test = null)
+ {
+ if (!$name instanceof Twig_SimpleTest && !($test instanceof Twig_SimpleTest || $test instanceof Twig_TestInterface)) {
+ throw new LogicException('A test must be an instance of Twig_TestInterface or Twig_SimpleTest');
+ }
+
+ if ($name instanceof Twig_SimpleTest) {
+ $test = $name;
+ $name = $test->getName();
+ } else {
+ @trigger_error(sprintf('Passing a name as a first argument to the %s method is deprecated. Pass an instance of "Twig_SimpleTest" instead when defining test "%s".', __METHOD__, $name), E_USER_DEPRECATED);
+ }
+
+ if ($this->extensionInitialized) {
+ throw new LogicException(sprintf('Unable to add test "%s" as extensions have already been initialized.', $name));
+ }
+
+ $this->staging->addTest($name, $test);
+ }
+
+ /**
+ * Gets the registered Tests.
+ *
+ * @return Twig_TestInterface[] An array of Twig_TestInterface instances
+ */
+ public function getTests()
+ {
+ if (!$this->extensionInitialized) {
+ $this->initExtensions();
+ }
+
+ return $this->tests;
+ }
+
+ /**
+ * Gets a test by name.
+ *
+ * @param string $name The test name
+ *
+ * @return Twig_Test|false A Twig_Test instance or false if the test does not exist
+ */
+ public function getTest($name)
+ {
+ if (!$this->extensionInitialized) {
+ $this->initExtensions();
+ }
+
+ if (isset($this->tests[$name])) {
+ return $this->tests[$name];
+ }
+
+ return false;
+ }
+
+ /**
+ * Registers a Function.
+ *
+ * @param string|Twig_SimpleFunction $name The function name or a Twig_SimpleFunction instance
+ * @param Twig_FunctionInterface|Twig_SimpleFunction $function A Twig_FunctionInterface instance or a Twig_SimpleFunction instance
+ */
+ public function addFunction($name, $function = null)
+ {
+ if (!$name instanceof Twig_SimpleFunction && !($function instanceof Twig_SimpleFunction || $function instanceof Twig_FunctionInterface)) {
+ throw new LogicException('A function must be an instance of Twig_FunctionInterface or Twig_SimpleFunction');
+ }
+
+ if ($name instanceof Twig_SimpleFunction) {
+ $function = $name;
+ $name = $function->getName();
+ } else {
+ @trigger_error(sprintf('Passing a name as a first argument to the %s method is deprecated. Pass an instance of "Twig_SimpleFunction" instead when defining function "%s".', __METHOD__, $name), E_USER_DEPRECATED);
+ }
+
+ if ($this->extensionInitialized) {
+ throw new LogicException(sprintf('Unable to add function "%s" as extensions have already been initialized.', $name));
+ }
+
+ $this->staging->addFunction($name, $function);
+ }
+
+ /**
+ * Get a function by name.
+ *
+ * Subclasses may override this method and load functions differently;
+ * so no list of functions is available.
+ *
+ * @param string $name function name
+ *
+ * @return Twig_Function|false A Twig_Function instance or false if the function does not exist
+ */
+ public function getFunction($name)
+ {
+ if (!$this->extensionInitialized) {
+ $this->initExtensions();
+ }
+
+ if (isset($this->functions[$name])) {
+ return $this->functions[$name];
+ }
+
+ foreach ($this->functions as $pattern => $function) {
+ $pattern = str_replace('\\*', '(.*?)', preg_quote($pattern, '#'), $count);
+
+ if ($count) {
+ if (preg_match('#^'.$pattern.'$#', $name, $matches)) {
+ array_shift($matches);
+ $function->setArguments($matches);
+
+ return $function;
+ }
+ }
+ }
+
+ foreach ($this->functionCallbacks as $callback) {
+ if (false !== $function = call_user_func($callback, $name)) {
+ return $function;
+ }
+ }
+
+ return false;
+ }
+
+ public function registerUndefinedFunctionCallback($callable)
+ {
+ $this->functionCallbacks[] = $callable;
+ }
+
+ /**
+ * Gets registered functions.
+ *
+ * Be warned that this method cannot return functions defined with registerUndefinedFunctionCallback.
+ *
+ * @return Twig_FunctionInterface[] An array of Twig_FunctionInterface instances
+ *
+ * @see registerUndefinedFunctionCallback
+ */
+ public function getFunctions()
+ {
+ if (!$this->extensionInitialized) {
+ $this->initExtensions();
+ }
+
+ return $this->functions;
+ }
+
+ /**
+ * Registers a Global.
+ *
+ * New globals can be added before compiling or rendering a template;
+ * but after, you can only update existing globals.
+ *
+ * @param string $name The global name
+ * @param mixed $value The global value
+ */
+ public function addGlobal($name, $value)
+ {
+ if ($this->extensionInitialized || $this->runtimeInitialized) {
+ if (null === $this->globals) {
+ $this->globals = $this->initGlobals();
+ }
+
+ if (!array_key_exists($name, $this->globals)) {
+ // The deprecation notice must be turned into the following exception in Twig 2.0
+ @trigger_error(sprintf('Registering global variable "%s" at runtime or when the extensions have already been initialized is deprecated.', $name), E_USER_DEPRECATED);
+ //throw new LogicException(sprintf('Unable to add global "%s" as the runtime or the extensions have already been initialized.', $name));
+ }
+ }
+
+ if ($this->extensionInitialized || $this->runtimeInitialized) {
+ // update the value
+ $this->globals[$name] = $value;
+ } else {
+ $this->staging->addGlobal($name, $value);
+ }
+ }
+
+ /**
+ * Gets the registered Globals.
+ *
+ * @return array An array of globals
+ */
+ public function getGlobals()
+ {
+ if (!$this->runtimeInitialized && !$this->extensionInitialized) {
+ return $this->initGlobals();
+ }
+
+ if (null === $this->globals) {
+ $this->globals = $this->initGlobals();
+ }
+
+ return $this->globals;
+ }
+
+ /**
+ * Merges a context with the defined globals.
+ *
+ * @param array $context An array representing the context
+ *
+ * @return array The context merged with the globals
+ */
+ public function mergeGlobals(array $context)
+ {
+ // we don't use array_merge as the context being generally
+ // bigger than globals, this code is faster.
+ foreach ($this->getGlobals() as $key => $value) {
+ if (!array_key_exists($key, $context)) {
+ $context[$key] = $value;
+ }
+ }
+
+ return $context;
+ }
+
+ /**
+ * Gets the registered unary Operators.
+ *
+ * @return array An array of unary operators
+ */
+ public function getUnaryOperators()
+ {
+ if (!$this->extensionInitialized) {
+ $this->initExtensions();
+ }
+
+ return $this->unaryOperators;
+ }
+
+ /**
+ * Gets the registered binary Operators.
+ *
+ * @return array An array of binary operators
+ */
+ public function getBinaryOperators()
+ {
+ if (!$this->extensionInitialized) {
+ $this->initExtensions();
+ }
+
+ return $this->binaryOperators;
+ }
+
+ public function computeAlternatives($name, $items)
+ {
+ $alternatives = array();
+ foreach ($items as $item) {
+ $lev = levenshtein($name, $item);
+ if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) {
+ $alternatives[$item] = $lev;
+ }
+ }
+ asort($alternatives);
+
+ return array_keys($alternatives);
+ }
+
+ protected function initGlobals()
+ {
+ $globals = array();
+ foreach ($this->extensions as $extension) {
+ $extGlob = $extension->getGlobals();
+ if (!is_array($extGlob)) {
+ throw new UnexpectedValueException(sprintf('"%s::getGlobals()" must return an array of globals.', get_class($extension)));
+ }
+
+ $globals[] = $extGlob;
+ }
+
+ $globals[] = $this->staging->getGlobals();
+
+ return call_user_func_array('array_merge', $globals);
+ }
+
+ protected function initExtensions()
+ {
+ if ($this->extensionInitialized) {
+ return;
+ }
+
+ $this->extensionInitialized = true;
+ $this->parsers = new Twig_TokenParserBroker(array(), array(), false);
+ $this->filters = array();
+ $this->functions = array();
+ $this->tests = array();
+ $this->visitors = array();
+ $this->unaryOperators = array();
+ $this->binaryOperators = array();
+
+ foreach ($this->extensions as $extension) {
+ $this->initExtension($extension);
+ }
+ $this->initExtension($this->staging);
+ }
+
+ protected function initExtension(Twig_ExtensionInterface $extension)
+ {
+ // filters
+ foreach ($extension->getFilters() as $name => $filter) {
+ if ($filter instanceof Twig_SimpleFilter) {
+ $name = $filter->getName();
+ } else {
+ @trigger_error(sprintf('Using an instance of "%s" for filter "%s" is deprecated. Use Twig_SimpleFilter instead.', get_class($filter), $name), E_USER_DEPRECATED);
+ }
+
+ $this->filters[$name] = $filter;
+ }
+
+ // functions
+ foreach ($extension->getFunctions() as $name => $function) {
+ if ($function instanceof Twig_SimpleFunction) {
+ $name = $function->getName();
+ } else {
+ @trigger_error(sprintf('Using an instance of "%s" for function "%s" is deprecated. Use Twig_SimpleFunction instead.', get_class($function), $name), E_USER_DEPRECATED);
+ }
+
+ $this->functions[$name] = $function;
+ }
+
+ // tests
+ foreach ($extension->getTests() as $name => $test) {
+ if ($test instanceof Twig_SimpleTest) {
+ $name = $test->getName();
+ } else {
+ @trigger_error(sprintf('Using an instance of "%s" for test "%s" is deprecated. Use Twig_SimpleTest instead.', get_class($test), $name), E_USER_DEPRECATED);
+ }
+
+ $this->tests[$name] = $test;
+ }
+
+ // token parsers
+ foreach ($extension->getTokenParsers() as $parser) {
+ if ($parser instanceof Twig_TokenParserInterface) {
+ $this->parsers->addTokenParser($parser);
+ } elseif ($parser instanceof Twig_TokenParserBrokerInterface) {
+ @trigger_error('Registering a Twig_TokenParserBrokerInterface instance is deprecated.', E_USER_DEPRECATED);
+
+ $this->parsers->addTokenParserBroker($parser);
+ } else {
+ throw new LogicException('getTokenParsers() must return an array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances');
+ }
+ }
+
+ // node visitors
+ foreach ($extension->getNodeVisitors() as $visitor) {
+ $this->visitors[] = $visitor;
+ }
+
+ // operators
+ if ($operators = $extension->getOperators()) {
+ if (2 !== count($operators)) {
+ throw new InvalidArgumentException(sprintf('"%s::getOperators()" does not return a valid operators array.', get_class($extension)));
+ }
+
+ $this->unaryOperators = array_merge($this->unaryOperators, $operators[0]);
+ $this->binaryOperators = array_merge($this->binaryOperators, $operators[1]);
+ }
+ }
+
+ /**
+ * @deprecated since 1.22 (to be removed in 2.0)
+ */
+ protected function writeCacheFile($file, $content)
+ {
+ $this->cache->write($file, $content);
+ }
+}
diff --git a/Twig/Error.php b/Twig/Error.php
new file mode 100644
index 0000000..90650c5
--- /dev/null
+++ b/Twig/Error.php
@@ -0,0 +1,250 @@
+
+ */
+class Twig_Error extends Exception
+{
+ protected $lineno;
+ protected $filename;
+ protected $rawMessage;
+ protected $previous;
+
+ /**
+ * Constructor.
+ *
+ * Set both the line number and the filename to false to
+ * disable automatic guessing of the original template name
+ * and line number.
+ *
+ * Set the line number to -1 to enable its automatic guessing.
+ * Set the filename to null to enable its automatic guessing.
+ *
+ * By default, automatic guessing is enabled.
+ *
+ * @param string $message The error message
+ * @param int $lineno The template line where the error occurred
+ * @param string $filename The template file name where the error occurred
+ * @param Exception $previous The previous exception
+ */
+ public function __construct($message, $lineno = -1, $filename = null, Exception $previous = null)
+ {
+ if (PHP_VERSION_ID < 50300) {
+ $this->previous = $previous;
+ parent::__construct('');
+ } else {
+ parent::__construct('', 0, $previous);
+ }
+
+ $this->lineno = $lineno;
+ $this->filename = $filename;
+
+ if (-1 === $this->lineno || null === $this->filename) {
+ $this->guessTemplateInfo();
+ }
+
+ $this->rawMessage = $message;
+
+ $this->updateRepr();
+ }
+
+ /**
+ * Gets the raw message.
+ *
+ * @return string The raw message
+ */
+ public function getRawMessage()
+ {
+ return $this->rawMessage;
+ }
+
+ /**
+ * Gets the filename where the error occurred.
+ *
+ * @return string The filename
+ */
+ public function getTemplateFile()
+ {
+ return $this->filename;
+ }
+
+ /**
+ * Sets the filename where the error occurred.
+ *
+ * @param string $filename The filename
+ */
+ public function setTemplateFile($filename)
+ {
+ $this->filename = $filename;
+
+ $this->updateRepr();
+ }
+
+ /**
+ * Gets the template line where the error occurred.
+ *
+ * @return int The template line
+ */
+ public function getTemplateLine()
+ {
+ return $this->lineno;
+ }
+
+ /**
+ * Sets the template line where the error occurred.
+ *
+ * @param int $lineno The template line
+ */
+ public function setTemplateLine($lineno)
+ {
+ $this->lineno = $lineno;
+
+ $this->updateRepr();
+ }
+
+ public function guess()
+ {
+ $this->guessTemplateInfo();
+ $this->updateRepr();
+ }
+
+ /**
+ * For PHP < 5.3.0, provides access to the getPrevious() method.
+ *
+ * @param string $method The method name
+ * @param array $arguments The parameters to be passed to the method
+ *
+ * @return Exception The previous exception or null
+ *
+ * @throws BadMethodCallException
+ */
+ public function __call($method, $arguments)
+ {
+ if ('getprevious' == strtolower($method)) {
+ return $this->previous;
+ }
+
+ throw new BadMethodCallException(sprintf('Method "Twig_Error::%s()" does not exist.', $method));
+ }
+
+ protected function updateRepr()
+ {
+ $this->message = $this->rawMessage;
+
+ $dot = false;
+ if ('.' === substr($this->message, -1)) {
+ $this->message = substr($this->message, 0, -1);
+ $dot = true;
+ }
+
+ if ($this->filename) {
+ if (is_string($this->filename) || (is_object($this->filename) && method_exists($this->filename, '__toString'))) {
+ $filename = sprintf('"%s"', $this->filename);
+ } else {
+ $filename = json_encode($this->filename);
+ }
+ $this->message .= sprintf(' in %s', $filename);
+ }
+
+ if ($this->lineno && $this->lineno >= 0) {
+ $this->message .= sprintf(' at line %d', $this->lineno);
+ }
+
+ if ($dot) {
+ $this->message .= '.';
+ }
+ }
+
+ protected function guessTemplateInfo()
+ {
+ $template = null;
+ $templateClass = null;
+
+ if (PHP_VERSION_ID >= 50306) {
+ $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT);
+ } else {
+ $backtrace = debug_backtrace();
+ }
+
+ foreach ($backtrace as $trace) {
+ if (isset($trace['object']) && $trace['object'] instanceof Twig_Template && 'Twig_Template' !== get_class($trace['object'])) {
+ $currentClass = get_class($trace['object']);
+ $isEmbedContainer = 0 === strpos($templateClass, $currentClass);
+ if (null === $this->filename || ($this->filename == $trace['object']->getTemplateName() && !$isEmbedContainer)) {
+ $template = $trace['object'];
+ $templateClass = get_class($trace['object']);
+ }
+ }
+ }
+
+ // update template filename
+ if (null !== $template && null === $this->filename) {
+ $this->filename = $template->getTemplateName();
+ }
+
+ if (null === $template || $this->lineno > -1) {
+ return;
+ }
+
+ $r = new ReflectionObject($template);
+ $file = $r->getFileName();
+
+ // hhvm has a bug where eval'ed files comes out as the current directory
+ if (is_dir($file)) {
+ $file = '';
+ }
+
+ $exceptions = array($e = $this);
+ while (($e instanceof self || method_exists($e, 'getPrevious')) && $e = $e->getPrevious()) {
+ $exceptions[] = $e;
+ }
+
+ while ($e = array_pop($exceptions)) {
+ $traces = $e->getTrace();
+ array_unshift($traces, array('file' => $e->getFile(), 'line' => $e->getLine()));
+
+ while ($trace = array_shift($traces)) {
+ if (!isset($trace['file']) || !isset($trace['line']) || $file != $trace['file']) {
+ continue;
+ }
+
+ foreach ($template->getDebugInfo() as $codeLine => $templateLine) {
+ if ($codeLine <= $trace['line']) {
+ // update template line
+ $this->lineno = $templateLine;
+
+ return;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/Twig/Error/Loader.php b/Twig/Error/Loader.php
new file mode 100644
index 0000000..68efb57
--- /dev/null
+++ b/Twig/Error/Loader.php
@@ -0,0 +1,31 @@
+
+ */
+class Twig_Error_Loader extends Twig_Error
+{
+ public function __construct($message, $lineno = -1, $filename = null, Exception $previous = null)
+ {
+ parent::__construct($message, false, false, $previous);
+ }
+}
diff --git a/Twig/Error/Runtime.php b/Twig/Error/Runtime.php
new file mode 100644
index 0000000..8b6cedd
--- /dev/null
+++ b/Twig/Error/Runtime.php
@@ -0,0 +1,20 @@
+
+ */
+class Twig_Error_Runtime extends Twig_Error
+{
+}
diff --git a/Twig/Error/Syntax.php b/Twig/Error/Syntax.php
new file mode 100644
index 0000000..0f5c579
--- /dev/null
+++ b/Twig/Error/Syntax.php
@@ -0,0 +1,20 @@
+
+ */
+class Twig_Error_Syntax extends Twig_Error
+{
+}
diff --git a/Twig/ExistsLoaderInterface.php b/Twig/ExistsLoaderInterface.php
new file mode 100644
index 0000000..b168c3c
--- /dev/null
+++ b/Twig/ExistsLoaderInterface.php
@@ -0,0 +1,29 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 3.0)
+ */
+interface Twig_ExistsLoaderInterface
+{
+ /**
+ * Check if we have the source code of a template, given its name.
+ *
+ * @param string $name The name of the template to check if we can load
+ *
+ * @return bool If the template source code is handled by this loader or not
+ */
+ public function exists($name);
+}
diff --git a/Twig/ExpressionParser.php b/Twig/ExpressionParser.php
new file mode 100644
index 0000000..322976c
--- /dev/null
+++ b/Twig/ExpressionParser.php
@@ -0,0 +1,645 @@
+
+ */
+class Twig_ExpressionParser
+{
+ const OPERATOR_LEFT = 1;
+ const OPERATOR_RIGHT = 2;
+
+ protected $parser;
+ protected $unaryOperators;
+ protected $binaryOperators;
+
+ public function __construct(Twig_Parser $parser, array $unaryOperators, array $binaryOperators)
+ {
+ $this->parser = $parser;
+ $this->unaryOperators = $unaryOperators;
+ $this->binaryOperators = $binaryOperators;
+ }
+
+ public function parseExpression($precedence = 0)
+ {
+ $expr = $this->getPrimary();
+ $token = $this->parser->getCurrentToken();
+ while ($this->isBinary($token) && $this->binaryOperators[$token->getValue()]['precedence'] >= $precedence) {
+ $op = $this->binaryOperators[$token->getValue()];
+ $this->parser->getStream()->next();
+
+ if (isset($op['callable'])) {
+ $expr = call_user_func($op['callable'], $this->parser, $expr);
+ } else {
+ $expr1 = $this->parseExpression(self::OPERATOR_LEFT === $op['associativity'] ? $op['precedence'] + 1 : $op['precedence']);
+ $class = $op['class'];
+ $expr = new $class($expr, $expr1, $token->getLine());
+ }
+
+ $token = $this->parser->getCurrentToken();
+ }
+
+ if (0 === $precedence) {
+ return $this->parseConditionalExpression($expr);
+ }
+
+ return $expr;
+ }
+
+ protected function getPrimary()
+ {
+ $token = $this->parser->getCurrentToken();
+
+ if ($this->isUnary($token)) {
+ $operator = $this->unaryOperators[$token->getValue()];
+ $this->parser->getStream()->next();
+ $expr = $this->parseExpression($operator['precedence']);
+ $class = $operator['class'];
+
+ return $this->parsePostfixExpression(new $class($expr, $token->getLine()));
+ } elseif ($token->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
+ $this->parser->getStream()->next();
+ $expr = $this->parseExpression();
+ $this->parser->getStream()->expect(Twig_Token::PUNCTUATION_TYPE, ')', 'An opened parenthesis is not properly closed');
+
+ return $this->parsePostfixExpression($expr);
+ }
+
+ return $this->parsePrimaryExpression();
+ }
+
+ protected function parseConditionalExpression($expr)
+ {
+ while ($this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, '?')) {
+ if (!$this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, ':')) {
+ $expr2 = $this->parseExpression();
+ if ($this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, ':')) {
+ $expr3 = $this->parseExpression();
+ } else {
+ $expr3 = new Twig_Node_Expression_Constant('', $this->parser->getCurrentToken()->getLine());
+ }
+ } else {
+ $expr2 = $expr;
+ $expr3 = $this->parseExpression();
+ }
+
+ $expr = new Twig_Node_Expression_Conditional($expr, $expr2, $expr3, $this->parser->getCurrentToken()->getLine());
+ }
+
+ return $expr;
+ }
+
+ protected function isUnary(Twig_Token $token)
+ {
+ return $token->test(Twig_Token::OPERATOR_TYPE) && isset($this->unaryOperators[$token->getValue()]);
+ }
+
+ protected function isBinary(Twig_Token $token)
+ {
+ return $token->test(Twig_Token::OPERATOR_TYPE) && isset($this->binaryOperators[$token->getValue()]);
+ }
+
+ public function parsePrimaryExpression()
+ {
+ $token = $this->parser->getCurrentToken();
+ switch ($token->getType()) {
+ case Twig_Token::NAME_TYPE:
+ $this->parser->getStream()->next();
+ switch ($token->getValue()) {
+ case 'true':
+ case 'TRUE':
+ $node = new Twig_Node_Expression_Constant(true, $token->getLine());
+ break;
+
+ case 'false':
+ case 'FALSE':
+ $node = new Twig_Node_Expression_Constant(false, $token->getLine());
+ break;
+
+ case 'none':
+ case 'NONE':
+ case 'null':
+ case 'NULL':
+ $node = new Twig_Node_Expression_Constant(null, $token->getLine());
+ break;
+
+ default:
+ if ('(' === $this->parser->getCurrentToken()->getValue()) {
+ $node = $this->getFunctionNode($token->getValue(), $token->getLine());
+ } else {
+ $node = new Twig_Node_Expression_Name($token->getValue(), $token->getLine());
+ }
+ }
+ break;
+
+ case Twig_Token::NUMBER_TYPE:
+ $this->parser->getStream()->next();
+ $node = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine());
+ break;
+
+ case Twig_Token::STRING_TYPE:
+ case Twig_Token::INTERPOLATION_START_TYPE:
+ $node = $this->parseStringExpression();
+ break;
+
+ case Twig_Token::OPERATOR_TYPE:
+ if (preg_match(Twig_Lexer::REGEX_NAME, $token->getValue(), $matches) && $matches[0] == $token->getValue()) {
+ // in this context, string operators are variable names
+ $this->parser->getStream()->next();
+ $node = new Twig_Node_Expression_Name($token->getValue(), $token->getLine());
+ break;
+ } elseif (isset($this->unaryOperators[$token->getValue()])) {
+ $class = $this->unaryOperators[$token->getValue()]['class'];
+
+ $ref = new ReflectionClass($class);
+ $negClass = 'Twig_Node_Expression_Unary_Neg';
+ $posClass = 'Twig_Node_Expression_Unary_Pos';
+ if (!(in_array($ref->getName(), array($negClass, $posClass)) || $ref->isSubclassOf($negClass) || $ref->isSubclassOf($posClass))) {
+ throw new Twig_Error_Syntax(sprintf('Unexpected unary operator "%s"', $token->getValue()), $token->getLine(), $this->parser->getFilename());
+ }
+
+ $this->parser->getStream()->next();
+ $expr = $this->parsePrimaryExpression();
+
+ $node = new $class($expr, $token->getLine());
+ break;
+ }
+
+ default:
+ if ($token->test(Twig_Token::PUNCTUATION_TYPE, '[')) {
+ $node = $this->parseArrayExpression();
+ } elseif ($token->test(Twig_Token::PUNCTUATION_TYPE, '{')) {
+ $node = $this->parseHashExpression();
+ } else {
+ throw new Twig_Error_Syntax(sprintf('Unexpected token "%s" of value "%s"', Twig_Token::typeToEnglish($token->getType()), $token->getValue()), $token->getLine(), $this->parser->getFilename());
+ }
+ }
+
+ return $this->parsePostfixExpression($node);
+ }
+
+ public function parseStringExpression()
+ {
+ $stream = $this->parser->getStream();
+
+ $nodes = array();
+ // a string cannot be followed by another string in a single expression
+ $nextCanBeString = true;
+ while (true) {
+ if ($nextCanBeString && $token = $stream->nextIf(Twig_Token::STRING_TYPE)) {
+ $nodes[] = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine());
+ $nextCanBeString = false;
+ } elseif ($stream->nextIf(Twig_Token::INTERPOLATION_START_TYPE)) {
+ $nodes[] = $this->parseExpression();
+ $stream->expect(Twig_Token::INTERPOLATION_END_TYPE);
+ $nextCanBeString = true;
+ } else {
+ break;
+ }
+ }
+
+ $expr = array_shift($nodes);
+ foreach ($nodes as $node) {
+ $expr = new Twig_Node_Expression_Binary_Concat($expr, $node, $node->getLine());
+ }
+
+ return $expr;
+ }
+
+ public function parseArrayExpression()
+ {
+ $stream = $this->parser->getStream();
+ $stream->expect(Twig_Token::PUNCTUATION_TYPE, '[', 'An array element was expected');
+
+ $node = new Twig_Node_Expression_Array(array(), $stream->getCurrent()->getLine());
+ $first = true;
+ while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, ']')) {
+ if (!$first) {
+ $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'An array element must be followed by a comma');
+
+ // trailing ,?
+ if ($stream->test(Twig_Token::PUNCTUATION_TYPE, ']')) {
+ break;
+ }
+ }
+ $first = false;
+
+ $node->addElement($this->parseExpression());
+ }
+ $stream->expect(Twig_Token::PUNCTUATION_TYPE, ']', 'An opened array is not properly closed');
+
+ return $node;
+ }
+
+ public function parseHashExpression()
+ {
+ $stream = $this->parser->getStream();
+ $stream->expect(Twig_Token::PUNCTUATION_TYPE, '{', 'A hash element was expected');
+
+ $node = new Twig_Node_Expression_Array(array(), $stream->getCurrent()->getLine());
+ $first = true;
+ while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, '}')) {
+ if (!$first) {
+ $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'A hash value must be followed by a comma');
+
+ // trailing ,?
+ if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '}')) {
+ break;
+ }
+ }
+ $first = false;
+
+ // a hash key can be:
+ //
+ // * a number -- 12
+ // * a string -- 'a'
+ // * a name, which is equivalent to a string -- a
+ // * an expression, which must be enclosed in parentheses -- (1 + 2)
+ if (($token = $stream->nextIf(Twig_Token::STRING_TYPE)) || ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) || $token = $stream->nextIf(Twig_Token::NUMBER_TYPE)) {
+ $key = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine());
+ } elseif ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
+ $key = $this->parseExpression();
+ } else {
+ $current = $stream->getCurrent();
+
+ throw new Twig_Error_Syntax(sprintf('A hash key must be a quoted string, a number, a name, or an expression enclosed in parentheses (unexpected token "%s" of value "%s"', Twig_Token::typeToEnglish($current->getType()), $current->getValue()), $current->getLine(), $this->parser->getFilename());
+ }
+
+ $stream->expect(Twig_Token::PUNCTUATION_TYPE, ':', 'A hash key must be followed by a colon (:)');
+ $value = $this->parseExpression();
+
+ $node->addElement($value, $key);
+ }
+ $stream->expect(Twig_Token::PUNCTUATION_TYPE, '}', 'An opened hash is not properly closed');
+
+ return $node;
+ }
+
+ public function parsePostfixExpression($node)
+ {
+ while (true) {
+ $token = $this->parser->getCurrentToken();
+ if ($token->getType() == Twig_Token::PUNCTUATION_TYPE) {
+ if ('.' == $token->getValue() || '[' == $token->getValue()) {
+ $node = $this->parseSubscriptExpression($node);
+ } elseif ('|' == $token->getValue()) {
+ $node = $this->parseFilterExpression($node);
+ } else {
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+
+ return $node;
+ }
+
+ public function getFunctionNode($name, $line)
+ {
+ switch ($name) {
+ case 'parent':
+ $this->parseArguments();
+ if (!count($this->parser->getBlockStack())) {
+ throw new Twig_Error_Syntax('Calling "parent" outside a block is forbidden', $line, $this->parser->getFilename());
+ }
+
+ if (!$this->parser->getParent() && !$this->parser->hasTraits()) {
+ throw new Twig_Error_Syntax('Calling "parent" on a template that does not extend nor "use" another template is forbidden', $line, $this->parser->getFilename());
+ }
+
+ return new Twig_Node_Expression_Parent($this->parser->peekBlockStack(), $line);
+ case 'block':
+ return new Twig_Node_Expression_BlockReference($this->parseArguments()->getNode(0), false, $line);
+ case 'attribute':
+ $args = $this->parseArguments();
+ if (count($args) < 2) {
+ throw new Twig_Error_Syntax('The "attribute" function takes at least two arguments (the variable and the attributes)', $line, $this->parser->getFilename());
+ }
+
+ return new Twig_Node_Expression_GetAttr($args->getNode(0), $args->getNode(1), count($args) > 2 ? $args->getNode(2) : null, Twig_Template::ANY_CALL, $line);
+ default:
+ if (null !== $alias = $this->parser->getImportedSymbol('function', $name)) {
+ $arguments = new Twig_Node_Expression_Array(array(), $line);
+ foreach ($this->parseArguments() as $n) {
+ $arguments->addElement($n);
+ }
+
+ $node = new Twig_Node_Expression_MethodCall($alias['node'], $alias['name'], $arguments, $line);
+ $node->setAttribute('safe', true);
+
+ return $node;
+ }
+
+ $args = $this->parseArguments(true);
+ $class = $this->getFunctionNodeClass($name, $line);
+
+ return new $class($name, $args, $line);
+ }
+ }
+
+ public function parseSubscriptExpression($node)
+ {
+ $stream = $this->parser->getStream();
+ $token = $stream->next();
+ $lineno = $token->getLine();
+ $arguments = new Twig_Node_Expression_Array(array(), $lineno);
+ $type = Twig_Template::ANY_CALL;
+ if ($token->getValue() == '.') {
+ $token = $stream->next();
+ if (
+ $token->getType() == Twig_Token::NAME_TYPE
+ ||
+ $token->getType() == Twig_Token::NUMBER_TYPE
+ ||
+ ($token->getType() == Twig_Token::OPERATOR_TYPE && preg_match(Twig_Lexer::REGEX_NAME, $token->getValue()))
+ ) {
+ $arg = new Twig_Node_Expression_Constant($token->getValue(), $lineno);
+
+ if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
+ $type = Twig_TemplateInterface::METHOD_CALL;
+ foreach ($this->parseArguments() as $n) {
+ $arguments->addElement($n);
+ }
+ }
+ } else {
+ throw new Twig_Error_Syntax('Expected name or number', $lineno, $this->parser->getFilename());
+ }
+
+ if ($node instanceof Twig_Node_Expression_Name && null !== $this->parser->getImportedSymbol('template', $node->getAttribute('name'))) {
+ if (!$arg instanceof Twig_Node_Expression_Constant) {
+ throw new Twig_Error_Syntax(sprintf('Dynamic macro names are not supported (called on "%s")', $node->getAttribute('name')), $token->getLine(), $this->parser->getFilename());
+ }
+
+ $name = $arg->getAttribute('value');
+
+ if ($this->parser->isReservedMacroName($name)) {
+ throw new Twig_Error_Syntax(sprintf('"%s" cannot be called as macro as it is a reserved keyword', $name), $token->getLine(), $this->parser->getFilename());
+ }
+
+ $node = new Twig_Node_Expression_MethodCall($node, 'get'.$name, $arguments, $lineno);
+ $node->setAttribute('safe', true);
+
+ return $node;
+ }
+ } else {
+ $type = Twig_Template::ARRAY_CALL;
+
+ // slice?
+ $slice = false;
+ if ($stream->test(Twig_Token::PUNCTUATION_TYPE, ':')) {
+ $slice = true;
+ $arg = new Twig_Node_Expression_Constant(0, $token->getLine());
+ } else {
+ $arg = $this->parseExpression();
+ }
+
+ if ($stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ':')) {
+ $slice = true;
+ }
+
+ if ($slice) {
+ if ($stream->test(Twig_Token::PUNCTUATION_TYPE, ']')) {
+ $length = new Twig_Node_Expression_Constant(null, $token->getLine());
+ } else {
+ $length = $this->parseExpression();
+ }
+
+ $class = $this->getFilterNodeClass('slice', $token->getLine());
+ $arguments = new Twig_Node(array($arg, $length));
+ $filter = new $class($node, new Twig_Node_Expression_Constant('slice', $token->getLine()), $arguments, $token->getLine());
+
+ $stream->expect(Twig_Token::PUNCTUATION_TYPE, ']');
+
+ return $filter;
+ }
+
+ $stream->expect(Twig_Token::PUNCTUATION_TYPE, ']');
+ }
+
+ return new Twig_Node_Expression_GetAttr($node, $arg, $arguments, $type, $lineno);
+ }
+
+ public function parseFilterExpression($node)
+ {
+ $this->parser->getStream()->next();
+
+ return $this->parseFilterExpressionRaw($node);
+ }
+
+ public function parseFilterExpressionRaw($node, $tag = null)
+ {
+ while (true) {
+ $token = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE);
+
+ $name = new Twig_Node_Expression_Constant($token->getValue(), $token->getLine());
+ if (!$this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
+ $arguments = new Twig_Node();
+ } else {
+ $arguments = $this->parseArguments(true);
+ }
+
+ $class = $this->getFilterNodeClass($name->getAttribute('value'), $token->getLine());
+
+ $node = new $class($node, $name, $arguments, $token->getLine(), $tag);
+
+ if (!$this->parser->getStream()->test(Twig_Token::PUNCTUATION_TYPE, '|')) {
+ break;
+ }
+
+ $this->parser->getStream()->next();
+ }
+
+ return $node;
+ }
+
+ /**
+ * Parses arguments.
+ *
+ * @param bool $namedArguments Whether to allow named arguments or not
+ * @param bool $definition Whether we are parsing arguments for a function definition
+ *
+ * @return Twig_Node
+ *
+ * @throws Twig_Error_Syntax
+ */
+ public function parseArguments($namedArguments = false, $definition = false)
+ {
+ $args = array();
+ $stream = $this->parser->getStream();
+
+ $stream->expect(Twig_Token::PUNCTUATION_TYPE, '(', 'A list of arguments must begin with an opening parenthesis');
+ while (!$stream->test(Twig_Token::PUNCTUATION_TYPE, ')')) {
+ if (!empty($args)) {
+ $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',', 'Arguments must be separated by a comma');
+ }
+
+ if ($definition) {
+ $token = $stream->expect(Twig_Token::NAME_TYPE, null, 'An argument must be a name');
+ $value = new Twig_Node_Expression_Name($token->getValue(), $this->parser->getCurrentToken()->getLine());
+ } else {
+ $value = $this->parseExpression();
+ }
+
+ $name = null;
+ if ($namedArguments && $token = $stream->nextIf(Twig_Token::OPERATOR_TYPE, '=')) {
+ if (!$value instanceof Twig_Node_Expression_Name) {
+ throw new Twig_Error_Syntax(sprintf('A parameter name must be a string, "%s" given', get_class($value)), $token->getLine(), $this->parser->getFilename());
+ }
+ $name = $value->getAttribute('name');
+
+ if ($definition) {
+ $value = $this->parsePrimaryExpression();
+
+ if (!$this->checkConstantExpression($value)) {
+ throw new Twig_Error_Syntax(sprintf('A default value for an argument must be a constant (a boolean, a string, a number, or an array).'), $token->getLine(), $this->parser->getFilename());
+ }
+ } else {
+ $value = $this->parseExpression();
+ }
+ }
+
+ if ($definition) {
+ if (null === $name) {
+ $name = $value->getAttribute('name');
+ $value = new Twig_Node_Expression_Constant(null, $this->parser->getCurrentToken()->getLine());
+ }
+ $args[$name] = $value;
+ } else {
+ if (null === $name) {
+ $args[] = $value;
+ } else {
+ $args[$name] = $value;
+ }
+ }
+ }
+ $stream->expect(Twig_Token::PUNCTUATION_TYPE, ')', 'A list of arguments must be closed by a parenthesis');
+
+ return new Twig_Node($args);
+ }
+
+ public function parseAssignmentExpression()
+ {
+ $targets = array();
+ while (true) {
+ $token = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE, null, 'Only variables can be assigned to');
+ if (in_array($token->getValue(), array('true', 'false', 'none'))) {
+ throw new Twig_Error_Syntax(sprintf('You cannot assign a value to "%s"', $token->getValue()), $token->getLine(), $this->parser->getFilename());
+ }
+ $targets[] = new Twig_Node_Expression_AssignName($token->getValue(), $token->getLine());
+
+ if (!$this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) {
+ break;
+ }
+ }
+
+ return new Twig_Node($targets);
+ }
+
+ public function parseMultitargetExpression()
+ {
+ $targets = array();
+ while (true) {
+ $targets[] = $this->parseExpression();
+ if (!$this->parser->getStream()->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) {
+ break;
+ }
+ }
+
+ return new Twig_Node($targets);
+ }
+
+ protected function getFunctionNodeClass($name, $line)
+ {
+ $env = $this->parser->getEnvironment();
+
+ if (false === $function = $env->getFunction($name)) {
+ $message = sprintf('The function "%s" does not exist', $name);
+ if ($alternatives = $env->computeAlternatives($name, array_keys($env->getFunctions()))) {
+ $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
+ }
+
+ throw new Twig_Error_Syntax($message, $line, $this->parser->getFilename());
+ }
+
+ if ($function instanceof Twig_SimpleFunction && $function->isDeprecated()) {
+ $message = sprintf('Twig Function "%s" is deprecated', $function->getName());
+ if ($function->getAlternative()) {
+ $message .= sprintf('. Use "%s" instead', $function->getAlternative());
+ }
+ $message .= sprintf(' in %s at line %d.', $this->parser->getFilename(), $line);
+
+ @trigger_error($message, E_USER_DEPRECATED);
+ }
+
+ if ($function instanceof Twig_SimpleFunction) {
+ return $function->getNodeClass();
+ }
+
+ return $function instanceof Twig_Function_Node ? $function->getClass() : 'Twig_Node_Expression_Function';
+ }
+
+ protected function getFilterNodeClass($name, $line)
+ {
+ $env = $this->parser->getEnvironment();
+
+ if (false === $filter = $env->getFilter($name)) {
+ $message = sprintf('The filter "%s" does not exist', $name);
+ if ($alternatives = $env->computeAlternatives($name, array_keys($env->getFilters()))) {
+ $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
+ }
+
+ throw new Twig_Error_Syntax($message, $line, $this->parser->getFilename());
+ }
+
+ if ($filter instanceof Twig_SimpleFilter && $filter->isDeprecated()) {
+ $message = sprintf('Twig Filter "%s" is deprecated', $filter->getName());
+ if ($filter->getAlternative()) {
+ $message .= sprintf('. Use "%s" instead', $filter->getAlternative());
+ }
+ $message .= sprintf(' in %s at line %d.', $this->parser->getFilename(), $line);
+
+ @trigger_error($message, E_USER_DEPRECATED);
+ }
+
+ if ($filter instanceof Twig_SimpleFilter) {
+ return $filter->getNodeClass();
+ }
+
+ return $filter instanceof Twig_Filter_Node ? $filter->getClass() : 'Twig_Node_Expression_Filter';
+ }
+
+ // checks that the node only contains "constant" elements
+ protected function checkConstantExpression(Twig_NodeInterface $node)
+ {
+ if (!($node instanceof Twig_Node_Expression_Constant || $node instanceof Twig_Node_Expression_Array
+ || $node instanceof Twig_Node_Expression_Unary_Neg || $node instanceof Twig_Node_Expression_Unary_Pos
+ )) {
+ return false;
+ }
+
+ foreach ($node as $n) {
+ if (!$this->checkConstantExpression($n)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+}
diff --git a/Twig/Extension.php b/Twig/Extension.php
new file mode 100644
index 0000000..7a3c859
--- /dev/null
+++ b/Twig/Extension.php
@@ -0,0 +1,75 @@
+escapers[$strategy] = $callable;
+ }
+
+ /**
+ * Gets all defined escapers.
+ *
+ * @return array An array of escapers
+ */
+ public function getEscapers()
+ {
+ return $this->escapers;
+ }
+
+ /**
+ * Sets the default format to be used by the date filter.
+ *
+ * @param string $format The default date format string
+ * @param string $dateIntervalFormat The default date interval format string
+ */
+ public function setDateFormat($format = null, $dateIntervalFormat = null)
+ {
+ if (null !== $format) {
+ $this->dateFormats[0] = $format;
+ }
+
+ if (null !== $dateIntervalFormat) {
+ $this->dateFormats[1] = $dateIntervalFormat;
+ }
+ }
+
+ /**
+ * Gets the default format to be used by the date filter.
+ *
+ * @return array The default date format string and the default date interval format string
+ */
+ public function getDateFormat()
+ {
+ return $this->dateFormats;
+ }
+
+ /**
+ * Sets the default timezone to be used by the date filter.
+ *
+ * @param DateTimeZone|string $timezone The default timezone string or a DateTimeZone object
+ */
+ public function setTimezone($timezone)
+ {
+ $this->timezone = $timezone instanceof DateTimeZone ? $timezone : new DateTimeZone($timezone);
+ }
+
+ /**
+ * Gets the default timezone to be used by the date filter.
+ *
+ * @return DateTimeZone The default timezone currently in use
+ */
+ public function getTimezone()
+ {
+ if (null === $this->timezone) {
+ $this->timezone = new DateTimeZone(date_default_timezone_get());
+ }
+
+ return $this->timezone;
+ }
+
+ /**
+ * Sets the default format to be used by the number_format filter.
+ *
+ * @param int $decimal The number of decimal places to use.
+ * @param string $decimalPoint The character(s) to use for the decimal point.
+ * @param string $thousandSep The character(s) to use for the thousands separator.
+ */
+ public function setNumberFormat($decimal, $decimalPoint, $thousandSep)
+ {
+ $this->numberFormat = array($decimal, $decimalPoint, $thousandSep);
+ }
+
+ /**
+ * Get the default format used by the number_format filter.
+ *
+ * @return array The arguments for number_format()
+ */
+ public function getNumberFormat()
+ {
+ return $this->numberFormat;
+ }
+
+ /**
+ * Returns the token parser instance to add to the existing list.
+ *
+ * @return Twig_TokenParser[] An array of Twig_TokenParser instances
+ */
+ public function getTokenParsers()
+ {
+ return array(
+ new Twig_TokenParser_For(),
+ new Twig_TokenParser_If(),
+ new Twig_TokenParser_Extends(),
+ new Twig_TokenParser_Include(),
+ new Twig_TokenParser_Block(),
+ new Twig_TokenParser_Use(),
+ new Twig_TokenParser_Filter(),
+ new Twig_TokenParser_Macro(),
+ new Twig_TokenParser_Import(),
+ new Twig_TokenParser_From(),
+ new Twig_TokenParser_Set(),
+ new Twig_TokenParser_Spaceless(),
+ new Twig_TokenParser_Flush(),
+ new Twig_TokenParser_Do(),
+ new Twig_TokenParser_Embed(),
+ );
+ }
+
+ /**
+ * Returns a list of filters to add to the existing list.
+ *
+ * @return array An array of filters
+ */
+ public function getFilters()
+ {
+ $filters = array(
+ // formatting filters
+ new Twig_SimpleFilter('date', 'twig_date_format_filter', array('needs_environment' => true)),
+ new Twig_SimpleFilter('date_modify', 'twig_date_modify_filter', array('needs_environment' => true)),
+ new Twig_SimpleFilter('format', 'sprintf'),
+ new Twig_SimpleFilter('replace', 'twig_replace_filter'),
+ new Twig_SimpleFilter('number_format', 'twig_number_format_filter', array('needs_environment' => true)),
+ new Twig_SimpleFilter('abs', 'abs'),
+ new Twig_SimpleFilter('round', 'twig_round'),
+
+ // encoding
+ new Twig_SimpleFilter('url_encode', 'twig_urlencode_filter'),
+ new Twig_SimpleFilter('json_encode', 'twig_jsonencode_filter'),
+ new Twig_SimpleFilter('convert_encoding', 'twig_convert_encoding'),
+
+ // string filters
+ new Twig_SimpleFilter('title', 'twig_title_string_filter', array('needs_environment' => true)),
+ new Twig_SimpleFilter('capitalize', 'twig_capitalize_string_filter', array('needs_environment' => true)),
+ new Twig_SimpleFilter('upper', 'strtoupper'),
+ new Twig_SimpleFilter('lower', 'strtolower'),
+ new Twig_SimpleFilter('striptags', 'strip_tags'),
+ new Twig_SimpleFilter('trim', 'trim'),
+ new Twig_SimpleFilter('nl2br', 'nl2br', array('pre_escape' => 'html', 'is_safe' => array('html'))),
+
+ // array helpers
+ new Twig_SimpleFilter('join', 'twig_join_filter'),
+ new Twig_SimpleFilter('split', 'twig_split_filter', array('needs_environment' => true)),
+ new Twig_SimpleFilter('sort', 'twig_sort_filter'),
+ new Twig_SimpleFilter('merge', 'twig_array_merge'),
+ new Twig_SimpleFilter('batch', 'twig_array_batch'),
+
+ // string/array filters
+ new Twig_SimpleFilter('reverse', 'twig_reverse_filter', array('needs_environment' => true)),
+ new Twig_SimpleFilter('length', 'twig_length_filter', array('needs_environment' => true)),
+ new Twig_SimpleFilter('slice', 'twig_slice', array('needs_environment' => true)),
+ new Twig_SimpleFilter('first', 'twig_first', array('needs_environment' => true)),
+ new Twig_SimpleFilter('last', 'twig_last', array('needs_environment' => true)),
+
+ // iteration and runtime
+ new Twig_SimpleFilter('default', '_twig_default_filter', array('node_class' => 'Twig_Node_Expression_Filter_Default')),
+ new Twig_SimpleFilter('keys', 'twig_get_array_keys_filter'),
+
+ // escaping
+ new Twig_SimpleFilter('escape', 'twig_escape_filter', array('needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe')),
+ new Twig_SimpleFilter('e', 'twig_escape_filter', array('needs_environment' => true, 'is_safe_callback' => 'twig_escape_filter_is_safe')),
+ );
+
+ if (function_exists('mb_get_info')) {
+ $filters[] = new Twig_SimpleFilter('upper', 'twig_upper_filter', array('needs_environment' => true));
+ $filters[] = new Twig_SimpleFilter('lower', 'twig_lower_filter', array('needs_environment' => true));
+ }
+
+ return $filters;
+ }
+
+ /**
+ * Returns a list of global functions to add to the existing list.
+ *
+ * @return array An array of global functions
+ */
+ public function getFunctions()
+ {
+ return array(
+ new Twig_SimpleFunction('max', 'max'),
+ new Twig_SimpleFunction('min', 'min'),
+ new Twig_SimpleFunction('range', 'range'),
+ new Twig_SimpleFunction('constant', 'twig_constant'),
+ new Twig_SimpleFunction('cycle', 'twig_cycle'),
+ new Twig_SimpleFunction('random', 'twig_random', array('needs_environment' => true)),
+ new Twig_SimpleFunction('date', 'twig_date_converter', array('needs_environment' => true)),
+ new Twig_SimpleFunction('include', 'twig_include', array('needs_environment' => true, 'needs_context' => true, 'is_safe' => array('all'))),
+ new Twig_SimpleFunction('source', 'twig_source', array('needs_environment' => true, 'is_safe' => array('all'))),
+ );
+ }
+
+ /**
+ * Returns a list of tests to add to the existing list.
+ *
+ * @return array An array of tests
+ */
+ public function getTests()
+ {
+ return array(
+ new Twig_SimpleTest('even', null, array('node_class' => 'Twig_Node_Expression_Test_Even')),
+ new Twig_SimpleTest('odd', null, array('node_class' => 'Twig_Node_Expression_Test_Odd')),
+ new Twig_SimpleTest('defined', null, array('node_class' => 'Twig_Node_Expression_Test_Defined')),
+ new Twig_SimpleTest('sameas', null, array('node_class' => 'Twig_Node_Expression_Test_Sameas', 'deprecated' => true, 'alternative' => 'same as')),
+ new Twig_SimpleTest('same as', null, array('node_class' => 'Twig_Node_Expression_Test_Sameas')),
+ new Twig_SimpleTest('none', null, array('node_class' => 'Twig_Node_Expression_Test_Null')),
+ new Twig_SimpleTest('null', null, array('node_class' => 'Twig_Node_Expression_Test_Null')),
+ new Twig_SimpleTest('divisibleby', null, array('node_class' => 'Twig_Node_Expression_Test_Divisibleby', 'deprecated' => true, 'alternative' => 'divisible by')),
+ new Twig_SimpleTest('divisible by', null, array('node_class' => 'Twig_Node_Expression_Test_Divisibleby')),
+ new Twig_SimpleTest('constant', null, array('node_class' => 'Twig_Node_Expression_Test_Constant')),
+ new Twig_SimpleTest('empty', 'twig_test_empty'),
+ new Twig_SimpleTest('iterable', 'twig_test_iterable'),
+ );
+ }
+
+ /**
+ * Returns a list of operators to add to the existing list.
+ *
+ * @return array An array of operators
+ */
+ public function getOperators()
+ {
+ return array(
+ array(
+ 'not' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'),
+ '-' => array('precedence' => 500, 'class' => 'Twig_Node_Expression_Unary_Neg'),
+ '+' => array('precedence' => 500, 'class' => 'Twig_Node_Expression_Unary_Pos'),
+ ),
+ array(
+ 'or' => array('precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ 'and' => array('precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ 'b-or' => array('precedence' => 16, 'class' => 'Twig_Node_Expression_Binary_BitwiseOr', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ 'b-xor' => array('precedence' => 17, 'class' => 'Twig_Node_Expression_Binary_BitwiseXor', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ 'b-and' => array('precedence' => 18, 'class' => 'Twig_Node_Expression_Binary_BitwiseAnd', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ '==' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Equal', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ '!=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ '<' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Less', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ '>' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Greater', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ '>=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_GreaterEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ '<=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_LessEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ 'not in' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotIn', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ 'in' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_In', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ 'matches' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Matches', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ 'starts with' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_StartsWith', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ 'ends with' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_EndsWith', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ '..' => array('precedence' => 25, 'class' => 'Twig_Node_Expression_Binary_Range', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ '+' => array('precedence' => 30, 'class' => 'Twig_Node_Expression_Binary_Add', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ '-' => array('precedence' => 30, 'class' => 'Twig_Node_Expression_Binary_Sub', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ '~' => array('precedence' => 40, 'class' => 'Twig_Node_Expression_Binary_Concat', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ '*' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mul', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ '/' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Div', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ '//' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_FloorDiv', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ '%' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mod', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ 'is' => array('precedence' => 100, 'callable' => array($this, 'parseTestExpression'), 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ 'is not' => array('precedence' => 100, 'callable' => array($this, 'parseNotTestExpression'), 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT),
+ '**' => array('precedence' => 200, 'class' => 'Twig_Node_Expression_Binary_Power', 'associativity' => Twig_ExpressionParser::OPERATOR_RIGHT),
+ ),
+ );
+ }
+
+ public function parseNotTestExpression(Twig_Parser $parser, Twig_NodeInterface $node)
+ {
+ return new Twig_Node_Expression_Unary_Not($this->parseTestExpression($parser, $node), $parser->getCurrentToken()->getLine());
+ }
+
+ public function parseTestExpression(Twig_Parser $parser, Twig_NodeInterface $node)
+ {
+ $stream = $parser->getStream();
+ list($name, $test) = $this->getTest($parser, $node->getLine());
+
+ if ($test instanceof Twig_SimpleTest && $test->isDeprecated()) {
+ $message = sprintf('Twig Test "%s" is deprecated', $name);
+ if ($test->getAlternative()) {
+ $message .= sprintf('. Use "%s" instead', $test->getAlternative());
+ }
+ $message .= sprintf(' in %s at line %d.', $stream->getFilename(), $stream->getCurrent()->getLine());
+
+ @trigger_error($message, E_USER_DEPRECATED);
+ }
+
+ $class = $this->getTestNodeClass($parser, $test);
+ $arguments = null;
+ if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) {
+ $arguments = $parser->getExpressionParser()->parseArguments(true);
+ }
+
+ return new $class($node, $name, $arguments, $parser->getCurrentToken()->getLine());
+ }
+
+ protected function getTest(Twig_Parser $parser, $line)
+ {
+ $stream = $parser->getStream();
+ $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
+ $env = $parser->getEnvironment();
+
+ if ($test = $env->getTest($name)) {
+ return array($name, $test);
+ }
+
+ if ($stream->test(Twig_Token::NAME_TYPE)) {
+ // try 2-words tests
+ $name = $name.' '.$parser->getCurrentToken()->getValue();
+
+ if ($test = $env->getTest($name)) {
+ $parser->getStream()->next();
+
+ return array($name, $test);
+ }
+ }
+
+ $message = sprintf('The test "%s" does not exist', $name);
+ if ($alternatives = $env->computeAlternatives($name, array_keys($env->getTests()))) {
+ $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
+ }
+
+ throw new Twig_Error_Syntax($message, $line, $parser->getFilename());
+ }
+
+ protected function getTestNodeClass(Twig_Parser $parser, $test)
+ {
+ if ($test instanceof Twig_SimpleTest) {
+ return $test->getNodeClass();
+ }
+
+ return $test instanceof Twig_Test_Node ? $test->getClass() : 'Twig_Node_Expression_Test';
+ }
+
+ /**
+ * Returns the name of the extension.
+ *
+ * @return string The extension name
+ */
+ public function getName()
+ {
+ return 'core';
+ }
+}
+
+/**
+ * Cycles over a value.
+ *
+ * @param ArrayAccess|array $values An array or an ArrayAccess instance
+ * @param int $position The cycle position
+ *
+ * @return string The next value in the cycle
+ */
+function twig_cycle($values, $position)
+{
+ if (!is_array($values) && !$values instanceof ArrayAccess) {
+ return $values;
+ }
+
+ return $values[$position % count($values)];
+}
+
+/**
+ * Returns a random value depending on the supplied parameter type:
+ * - a random item from a Traversable or array
+ * - a random character from a string
+ * - a random integer between 0 and the integer parameter.
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ * @param Traversable|array|int|string $values The values to pick a random item from
+ *
+ * @throws Twig_Error_Runtime When $values is an empty array (does not apply to an empty string which is returned as is).
+ *
+ * @return mixed A random value from the given sequence
+ */
+function twig_random(Twig_Environment $env, $values = null)
+{
+ if (null === $values) {
+ return mt_rand();
+ }
+
+ if (is_int($values) || is_float($values)) {
+ return $values < 0 ? mt_rand($values, 0) : mt_rand(0, $values);
+ }
+
+ if ($values instanceof Traversable) {
+ $values = iterator_to_array($values);
+ } elseif (is_string($values)) {
+ if ('' === $values) {
+ return '';
+ }
+ if (null !== $charset = $env->getCharset()) {
+ if ('UTF-8' != $charset) {
+ $values = twig_convert_encoding($values, 'UTF-8', $charset);
+ }
+
+ // unicode version of str_split()
+ // split at all positions, but not after the start and not before the end
+ $values = preg_split('/(? $value) {
+ $values[$i] = twig_convert_encoding($value, $charset, 'UTF-8');
+ }
+ }
+ } else {
+ return $values[mt_rand(0, strlen($values) - 1)];
+ }
+ }
+
+ if (!is_array($values)) {
+ return $values;
+ }
+
+ if (0 === count($values)) {
+ throw new Twig_Error_Runtime('The random function cannot pick from an empty array.');
+ }
+
+ return $values[array_rand($values, 1)];
+}
+
+/**
+ * Converts a date to the given format.
+ *
+ *
+ * {{ post.published_at|date("m/d/Y") }}
+ *
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ * @param DateTime|DateTimeInterface|DateInterval|string $date A date
+ * @param string|null $format The target format, null to use the default
+ * @param DateTimeZone|string|null|false $timezone The target timezone, null to use the default, false to leave unchanged
+ *
+ * @return string The formatted date
+ */
+function twig_date_format_filter(Twig_Environment $env, $date, $format = null, $timezone = null)
+{
+ if (null === $format) {
+ $formats = $env->getExtension('core')->getDateFormat();
+ $format = $date instanceof DateInterval ? $formats[1] : $formats[0];
+ }
+
+ if ($date instanceof DateInterval) {
+ return $date->format($format);
+ }
+
+ return twig_date_converter($env, $date, $timezone)->format($format);
+}
+
+/**
+ * Returns a new date object modified.
+ *
+ *
+ * {{ post.published_at|date_modify("-1day")|date("m/d/Y") }}
+ *
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ * @param DateTime|string $date A date
+ * @param string $modifier A modifier string
+ *
+ * @return DateTime A new date object
+ */
+function twig_date_modify_filter(Twig_Environment $env, $date, $modifier)
+{
+ $date = twig_date_converter($env, $date, false);
+ $resultDate = $date->modify($modifier);
+
+ // This is a hack to ensure PHP 5.2 support and support for DateTimeImmutable
+ // DateTime::modify does not return the modified DateTime object < 5.3.0
+ // and DateTimeImmutable does not modify $date.
+ return null === $resultDate ? $date : $resultDate;
+}
+
+/**
+ * Converts an input to a DateTime instance.
+ *
+ *
+ * {% if date(user.created_at) < date('+2days') %}
+ * {# do something #}
+ * {% endif %}
+ *
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ * @param DateTime|DateTimeInterface|string|null $date A date
+ * @param DateTimeZone|string|null|false $timezone The target timezone, null to use the default, false to leave unchanged
+ *
+ * @return DateTime A DateTime instance
+ */
+function twig_date_converter(Twig_Environment $env, $date = null, $timezone = null)
+{
+ // determine the timezone
+ if (false !== $timezone) {
+ if (null === $timezone) {
+ $timezone = $env->getExtension('core')->getTimezone();
+ } elseif (!$timezone instanceof DateTimeZone) {
+ $timezone = new DateTimeZone($timezone);
+ }
+ }
+
+ // immutable dates
+ if ($date instanceof DateTimeImmutable) {
+ return false !== $timezone ? $date->setTimezone($timezone) : $date;
+ }
+
+ if ($date instanceof DateTime || $date instanceof DateTimeInterface) {
+ $date = clone $date;
+ if (false !== $timezone) {
+ $date->setTimezone($timezone);
+ }
+
+ return $date;
+ }
+
+ if (null === $date || 'now' === $date) {
+ return new DateTime($date, false !== $timezone ? $timezone : $env->getExtension('core')->getTimezone());
+ }
+
+ $asString = (string) $date;
+ if (ctype_digit($asString) || (!empty($asString) && '-' === $asString[0] && ctype_digit(substr($asString, 1)))) {
+ $date = new DateTime('@'.$date);
+ } else {
+ $date = new DateTime($date, $env->getExtension('core')->getTimezone());
+ }
+
+ if (false !== $timezone) {
+ $date->setTimezone($timezone);
+ }
+
+ return $date;
+}
+
+/**
+ * Replaces strings within a string.
+ *
+ * @param string $str String to replace in
+ * @param array|Traversable $from Replace values
+ * @param string|null $to Replace to, deprecated (@see http://php.net/manual/en/function.strtr.php)
+ *
+ * @return string
+ */
+function twig_replace_filter($str, $from, $to = null)
+{
+ if ($from instanceof Traversable) {
+ $from = iterator_to_array($from);
+ } elseif (is_string($from) && is_string($to)) {
+ @trigger_error('Using "replace" with character by character replacement is deprecated and will be removed in Twig 2.0', E_USER_DEPRECATED);
+
+ return strtr($str, $from, $to);
+ } elseif (!is_array($from)) {
+ throw new Twig_Error_Runtime(sprintf('The "replace" filter expects an array or "Traversable" as replace values, got "%s".',is_object($from) ? get_class($from) : gettype($from)));
+ }
+
+ return strtr($str, $from);
+}
+
+/**
+ * Rounds a number.
+ *
+ * @param int|float $value The value to round
+ * @param int|float $precision The rounding precision
+ * @param string $method The method to use for rounding
+ *
+ * @return int|float The rounded number
+ */
+function twig_round($value, $precision = 0, $method = 'common')
+{
+ if ('common' == $method) {
+ return round($value, $precision);
+ }
+
+ if ('ceil' != $method && 'floor' != $method) {
+ throw new Twig_Error_Runtime('The round filter only supports the "common", "ceil", and "floor" methods.');
+ }
+
+ return $method($value * pow(10, $precision)) / pow(10, $precision);
+}
+
+/**
+ * Number format filter.
+ *
+ * All of the formatting options can be left null, in that case the defaults will
+ * be used. Supplying any of the parameters will override the defaults set in the
+ * environment object.
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ * @param mixed $number A float/int/string of the number to format
+ * @param int $decimal The number of decimal points to display.
+ * @param string $decimalPoint The character(s) to use for the decimal point.
+ * @param string $thousandSep The character(s) to use for the thousands separator.
+ *
+ * @return string The formatted number
+ */
+function twig_number_format_filter(Twig_Environment $env, $number, $decimal = null, $decimalPoint = null, $thousandSep = null)
+{
+ $defaults = $env->getExtension('core')->getNumberFormat();
+ if (null === $decimal) {
+ $decimal = $defaults[0];
+ }
+
+ if (null === $decimalPoint) {
+ $decimalPoint = $defaults[1];
+ }
+
+ if (null === $thousandSep) {
+ $thousandSep = $defaults[2];
+ }
+
+ return number_format((float) $number, $decimal, $decimalPoint, $thousandSep);
+}
+
+/**
+ * URL encodes (RFC 3986) a string as a path segment or an array as a query string.
+ *
+ * @param string|array $url A URL or an array of query parameters
+ *
+ * @return string The URL encoded value
+ */
+function twig_urlencode_filter($url)
+{
+ if (is_array($url)) {
+ if (defined('PHP_QUERY_RFC3986')) {
+ return http_build_query($url, '', '&', PHP_QUERY_RFC3986);
+ }
+
+ return http_build_query($url, '', '&');
+ }
+
+ return rawurlencode($url);
+}
+
+if (PHP_VERSION_ID < 50300) {
+ /**
+ * JSON encodes a variable.
+ *
+ * @param mixed $value The value to encode.
+ * @param int $options Not used on PHP 5.2.x
+ *
+ * @return mixed The JSON encoded value
+ */
+ function twig_jsonencode_filter($value, $options = 0)
+ {
+ if ($value instanceof Twig_Markup) {
+ $value = (string) $value;
+ } elseif (is_array($value)) {
+ array_walk_recursive($value, '_twig_markup2string');
+ }
+
+ return json_encode($value);
+ }
+} else {
+ /**
+ * JSON encodes a variable.
+ *
+ * @param mixed $value The value to encode.
+ * @param int $options Bitmask consisting of JSON_HEX_QUOT, JSON_HEX_TAG, JSON_HEX_AMP, JSON_HEX_APOS, JSON_NUMERIC_CHECK, JSON_PRETTY_PRINT, JSON_UNESCAPED_SLASHES, JSON_FORCE_OBJECT
+ *
+ * @return mixed The JSON encoded value
+ */
+ function twig_jsonencode_filter($value, $options = 0)
+ {
+ if ($value instanceof Twig_Markup) {
+ $value = (string) $value;
+ } elseif (is_array($value)) {
+ array_walk_recursive($value, '_twig_markup2string');
+ }
+
+ return json_encode($value, $options);
+ }
+}
+
+function _twig_markup2string(&$value)
+{
+ if ($value instanceof Twig_Markup) {
+ $value = (string) $value;
+ }
+}
+
+/**
+ * Merges an array with another one.
+ *
+ *
+ * {% set items = { 'apple': 'fruit', 'orange': 'fruit' } %}
+ *
+ * {% set items = items|merge({ 'peugeot': 'car' }) %}
+ *
+ * {# items now contains { 'apple': 'fruit', 'orange': 'fruit', 'peugeot': 'car' } #}
+ *
+ *
+ * @param array|Traversable $arr1 An array
+ * @param array|Traversable $arr2 An array
+ *
+ * @return array The merged array
+ */
+function twig_array_merge($arr1, $arr2)
+{
+ if ($arr1 instanceof Traversable) {
+ $arr1 = iterator_to_array($arr1);
+ } elseif (!is_array($arr1)) {
+ throw new Twig_Error_Runtime(sprintf('The merge filter only works with arrays or "Traversable", got "%s" as first argument.', gettype($arr1)));
+ }
+
+ if ($arr2 instanceof Traversable) {
+ $arr2 = iterator_to_array($arr2);
+ } elseif (!is_array($arr2)) {
+ throw new Twig_Error_Runtime(sprintf('The merge filter only works with arrays or "Traversable", got "%s" as second argument.', gettype($arr2)));
+ }
+
+ return array_merge($arr1, $arr2);
+}
+
+/**
+ * Slices a variable.
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ * @param mixed $item A variable
+ * @param int $start Start of the slice
+ * @param int $length Size of the slice
+ * @param bool $preserveKeys Whether to preserve key or not (when the input is an array)
+ *
+ * @return mixed The sliced variable
+ */
+function twig_slice(Twig_Environment $env, $item, $start, $length = null, $preserveKeys = false)
+{
+ if ($item instanceof Traversable) {
+ if ($item instanceof IteratorAggregate) {
+ $item = $item->getIterator();
+ }
+
+ if ($start >= 0 && $length >= 0 && $item instanceof Iterator) {
+ try {
+ return iterator_to_array(new LimitIterator($item, $start, $length === null ? -1 : $length), $preserveKeys);
+ } catch (OutOfBoundsException $exception) {
+ return array();
+ }
+ }
+
+ $item = iterator_to_array($item, $preserveKeys);
+ }
+
+ if (is_array($item)) {
+ return array_slice($item, $start, $length, $preserveKeys);
+ }
+
+ $item = (string) $item;
+
+ if (function_exists('mb_get_info') && null !== $charset = $env->getCharset()) {
+ return (string) mb_substr($item, $start, null === $length ? mb_strlen($item, $charset) - $start : $length, $charset);
+ }
+
+ return (string) (null === $length ? substr($item, $start) : substr($item, $start, $length));
+}
+
+/**
+ * Returns the first element of the item.
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ * @param mixed $item A variable
+ *
+ * @return mixed The first element of the item
+ */
+function twig_first(Twig_Environment $env, $item)
+{
+ $elements = twig_slice($env, $item, 0, 1, false);
+
+ return is_string($elements) ? $elements : current($elements);
+}
+
+/**
+ * Returns the last element of the item.
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ * @param mixed $item A variable
+ *
+ * @return mixed The last element of the item
+ */
+function twig_last(Twig_Environment $env, $item)
+{
+ $elements = twig_slice($env, $item, -1, 1, false);
+
+ return is_string($elements) ? $elements : current($elements);
+}
+
+/**
+ * Joins the values to a string.
+ *
+ * The separator between elements is an empty string per default, you can define it with the optional parameter.
+ *
+ *
+ * {{ [1, 2, 3]|join('|') }}
+ * {# returns 1|2|3 #}
+ *
+ * {{ [1, 2, 3]|join }}
+ * {# returns 123 #}
+ *
+ *
+ * @param array $value An array
+ * @param string $glue The separator
+ *
+ * @return string The concatenated string
+ */
+function twig_join_filter($value, $glue = '')
+{
+ if ($value instanceof Traversable) {
+ $value = iterator_to_array($value, false);
+ }
+
+ return implode($glue, (array) $value);
+}
+
+/**
+ * Splits the string into an array.
+ *
+ *
+ * {{ "one,two,three"|split(',') }}
+ * {# returns [one, two, three] #}
+ *
+ * {{ "one,two,three,four,five"|split(',', 3) }}
+ * {# returns [one, two, "three,four,five"] #}
+ *
+ * {{ "123"|split('') }}
+ * {# returns [1, 2, 3] #}
+ *
+ * {{ "aabbcc"|split('', 2) }}
+ * {# returns [aa, bb, cc] #}
+ *
+ *
+ * @param string $value A string
+ * @param string $delimiter The delimiter
+ * @param int $limit The limit
+ *
+ * @return array The split string as an array
+ */
+function twig_split_filter(Twig_Environment $env, $value, $delimiter, $limit = null)
+{
+ if (!empty($delimiter)) {
+ return null === $limit ? explode($delimiter, $value) : explode($delimiter, $value, $limit);
+ }
+
+ if (!function_exists('mb_get_info') || null === $charset = $env->getCharset()) {
+ return str_split($value, null === $limit ? 1 : $limit);
+ }
+
+ if ($limit <= 1) {
+ return preg_split('/(?
+ * {% for key in array|keys %}
+ * {# ... #}
+ * {% endfor %}
+ *
+ *
+ * @param array $array An array
+ *
+ * @return array The keys
+ */
+function twig_get_array_keys_filter($array)
+{
+ if ($array instanceof Traversable) {
+ return array_keys(iterator_to_array($array));
+ }
+
+ if (!is_array($array)) {
+ return array();
+ }
+
+ return array_keys($array);
+}
+
+/**
+ * Reverses a variable.
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ * @param array|Traversable|string $item An array, a Traversable instance, or a string
+ * @param bool $preserveKeys Whether to preserve key or not
+ *
+ * @return mixed The reversed input
+ */
+function twig_reverse_filter(Twig_Environment $env, $item, $preserveKeys = false)
+{
+ if ($item instanceof Traversable) {
+ return array_reverse(iterator_to_array($item), $preserveKeys);
+ }
+
+ if (is_array($item)) {
+ return array_reverse($item, $preserveKeys);
+ }
+
+ if (null !== $charset = $env->getCharset()) {
+ $string = (string) $item;
+
+ if ('UTF-8' != $charset) {
+ $item = twig_convert_encoding($string, 'UTF-8', $charset);
+ }
+
+ preg_match_all('/./us', $item, $matches);
+
+ $string = implode('', array_reverse($matches[0]));
+
+ if ('UTF-8' != $charset) {
+ $string = twig_convert_encoding($string, $charset, 'UTF-8');
+ }
+
+ return $string;
+ }
+
+ return strrev((string) $item);
+}
+
+/**
+ * Sorts an array.
+ *
+ * @param array|Traversable $array
+ *
+ * @return array
+ */
+function twig_sort_filter($array)
+{
+ if ($array instanceof Traversable) {
+ $array = iterator_to_array($array);
+ } elseif (!is_array($array)) {
+ throw new Twig_Error_Runtime(sprintf('The sort filter only works with arrays or "Traversable", got "%s".', gettype($array)));
+ }
+
+ asort($array);
+
+ return $array;
+}
+
+/**
+ * @internal
+ */
+function twig_in_filter($value, $compare)
+{
+ if (is_array($compare)) {
+ return in_array($value, $compare, is_object($value) || is_resource($value));
+ } elseif (is_string($compare) && (is_string($value) || is_int($value) || is_float($value))) {
+ return '' === $value || false !== strpos($compare, (string) $value);
+ } elseif ($compare instanceof Traversable) {
+ return in_array($value, iterator_to_array($compare, false), is_object($value) || is_resource($value));
+ }
+
+ return false;
+}
+
+/**
+ * Escapes a string.
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ * @param string $string The value to be escaped
+ * @param string $strategy The escaping strategy
+ * @param string $charset The charset
+ * @param bool $autoescape Whether the function is called by the auto-escaping feature (true) or by the developer (false)
+ *
+ * @return string
+ */
+function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html', $charset = null, $autoescape = false)
+{
+ if ($autoescape && $string instanceof Twig_Markup) {
+ return $string;
+ }
+
+ if (!is_string($string)) {
+ if (is_object($string) && method_exists($string, '__toString')) {
+ $string = (string) $string;
+ } elseif (in_array($strategy, array('html', 'js', 'css', 'html_attr', 'url'))) {
+ return $string;
+ }
+ }
+
+ if (null === $charset) {
+ $charset = $env->getCharset();
+ }
+
+ switch ($strategy) {
+ case 'html':
+ // see http://php.net/htmlspecialchars
+
+ // Using a static variable to avoid initializing the array
+ // each time the function is called. Moving the declaration on the
+ // top of the function slow downs other escaping strategies.
+ static $htmlspecialcharsCharsets;
+
+ if (null === $htmlspecialcharsCharsets) {
+ if (defined('HHVM_VERSION')) {
+ $htmlspecialcharsCharsets = array('utf-8' => true, 'UTF-8' => true);
+ } else {
+ $htmlspecialcharsCharsets = array(
+ 'ISO-8859-1' => true, 'ISO8859-1' => true,
+ 'ISO-8859-15' => true, 'ISO8859-15' => true,
+ 'utf-8' => true, 'UTF-8' => true,
+ 'CP866' => true, 'IBM866' => true, '866' => true,
+ 'CP1251' => true, 'WINDOWS-1251' => true, 'WIN-1251' => true,
+ '1251' => true,
+ 'CP1252' => true, 'WINDOWS-1252' => true, '1252' => true,
+ 'KOI8-R' => true, 'KOI8-RU' => true, 'KOI8R' => true,
+ 'BIG5' => true, '950' => true,
+ 'GB2312' => true, '936' => true,
+ 'BIG5-HKSCS' => true,
+ 'SHIFT_JIS' => true, 'SJIS' => true, '932' => true,
+ 'EUC-JP' => true, 'EUCJP' => true,
+ 'ISO8859-5' => true, 'ISO-8859-5' => true, 'MACROMAN' => true,
+ );
+ }
+ }
+
+ if (isset($htmlspecialcharsCharsets[$charset])) {
+ return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
+ }
+
+ if (isset($htmlspecialcharsCharsets[strtoupper($charset)])) {
+ // cache the lowercase variant for future iterations
+ $htmlspecialcharsCharsets[$charset] = true;
+
+ return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
+ }
+
+ $string = twig_convert_encoding($string, 'UTF-8', $charset);
+ $string = htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
+
+ return twig_convert_encoding($string, $charset, 'UTF-8');
+
+ case 'js':
+ // escape all non-alphanumeric characters
+ // into their \xHH or \uHHHH representations
+ if ('UTF-8' != $charset) {
+ $string = twig_convert_encoding($string, 'UTF-8', $charset);
+ }
+
+ if (0 == strlen($string) ? false : (1 == preg_match('/^./su', $string) ? false : true)) {
+ throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.');
+ }
+
+ $string = preg_replace_callback('#[^a-zA-Z0-9,\._]#Su', '_twig_escape_js_callback', $string);
+
+ if ('UTF-8' != $charset) {
+ $string = twig_convert_encoding($string, $charset, 'UTF-8');
+ }
+
+ return $string;
+
+ case 'css':
+ if ('UTF-8' != $charset) {
+ $string = twig_convert_encoding($string, 'UTF-8', $charset);
+ }
+
+ if (0 == strlen($string) ? false : (1 == preg_match('/^./su', $string) ? false : true)) {
+ throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.');
+ }
+
+ $string = preg_replace_callback('#[^a-zA-Z0-9]#Su', '_twig_escape_css_callback', $string);
+
+ if ('UTF-8' != $charset) {
+ $string = twig_convert_encoding($string, $charset, 'UTF-8');
+ }
+
+ return $string;
+
+ case 'html_attr':
+ if ('UTF-8' != $charset) {
+ $string = twig_convert_encoding($string, 'UTF-8', $charset);
+ }
+
+ if (0 == strlen($string) ? false : (1 == preg_match('/^./su', $string) ? false : true)) {
+ throw new Twig_Error_Runtime('The string to escape is not a valid UTF-8 string.');
+ }
+
+ $string = preg_replace_callback('#[^a-zA-Z0-9,\.\-_]#Su', '_twig_escape_html_attr_callback', $string);
+
+ if ('UTF-8' != $charset) {
+ $string = twig_convert_encoding($string, $charset, 'UTF-8');
+ }
+
+ return $string;
+
+ case 'url':
+ if (PHP_VERSION_ID < 50300) {
+ return str_replace('%7E', '~', rawurlencode($string));
+ }
+
+ return rawurlencode($string);
+
+ default:
+ static $escapers;
+
+ if (null === $escapers) {
+ $escapers = $env->getExtension('core')->getEscapers();
+ }
+
+ if (isset($escapers[$strategy])) {
+ return call_user_func($escapers[$strategy], $env, $string, $charset);
+ }
+
+ $validStrategies = implode(', ', array_merge(array('html', 'js', 'url', 'css', 'html_attr'), array_keys($escapers)));
+
+ throw new Twig_Error_Runtime(sprintf('Invalid escaping strategy "%s" (valid ones: %s).', $strategy, $validStrategies));
+ }
+}
+
+/**
+ * @internal
+ */
+function twig_escape_filter_is_safe(Twig_Node $filterArgs)
+{
+ foreach ($filterArgs as $arg) {
+ if ($arg instanceof Twig_Node_Expression_Constant) {
+ return array($arg->getAttribute('value'));
+ }
+
+ return array();
+ }
+
+ return array('html');
+}
+
+if (function_exists('mb_convert_encoding')) {
+ function twig_convert_encoding($string, $to, $from)
+ {
+ return mb_convert_encoding($string, $to, $from);
+ }
+} elseif (function_exists('iconv')) {
+ function twig_convert_encoding($string, $to, $from)
+ {
+ return iconv($from, $to, $string);
+ }
+} else {
+ function twig_convert_encoding($string, $to, $from)
+ {
+ throw new Twig_Error_Runtime('No suitable convert encoding function (use UTF-8 as your encoding or install the iconv or mbstring extension).');
+ }
+}
+
+function _twig_escape_js_callback($matches)
+{
+ $char = $matches[0];
+
+ // \xHH
+ if (!isset($char[1])) {
+ return '\\x'.strtoupper(substr('00'.bin2hex($char), -2));
+ }
+
+ // \uHHHH
+ $char = twig_convert_encoding($char, 'UTF-16BE', 'UTF-8');
+
+ return '\\u'.strtoupper(substr('0000'.bin2hex($char), -4));
+}
+
+function _twig_escape_css_callback($matches)
+{
+ $char = $matches[0];
+
+ // \xHH
+ if (!isset($char[1])) {
+ $hex = ltrim(strtoupper(bin2hex($char)), '0');
+ if (0 === strlen($hex)) {
+ $hex = '0';
+ }
+
+ return '\\'.$hex.' ';
+ }
+
+ // \uHHHH
+ $char = twig_convert_encoding($char, 'UTF-16BE', 'UTF-8');
+
+ return '\\'.ltrim(strtoupper(bin2hex($char)), '0').' ';
+}
+
+/**
+ * This function is adapted from code coming from Zend Framework.
+ *
+ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+function _twig_escape_html_attr_callback($matches)
+{
+ /*
+ * While HTML supports far more named entities, the lowest common denominator
+ * has become HTML5's XML Serialisation which is restricted to the those named
+ * entities that XML supports. Using HTML entities would result in this error:
+ * XML Parsing Error: undefined entity
+ */
+ static $entityMap = array(
+ 34 => 'quot', /* quotation mark */
+ 38 => 'amp', /* ampersand */
+ 60 => 'lt', /* less-than sign */
+ 62 => 'gt', /* greater-than sign */
+ );
+
+ $chr = $matches[0];
+ $ord = ord($chr);
+
+ /*
+ * The following replaces characters undefined in HTML with the
+ * hex entity for the Unicode replacement character.
+ */
+ if (($ord <= 0x1f && $chr != "\t" && $chr != "\n" && $chr != "\r") || ($ord >= 0x7f && $ord <= 0x9f)) {
+ return '�';
+ }
+
+ /*
+ * Check if the current character to escape has a name entity we should
+ * replace it with while grabbing the hex value of the character.
+ */
+ if (strlen($chr) == 1) {
+ $hex = strtoupper(substr('00'.bin2hex($chr), -2));
+ } else {
+ $chr = twig_convert_encoding($chr, 'UTF-16BE', 'UTF-8');
+ $hex = strtoupper(substr('0000'.bin2hex($chr), -4));
+ }
+
+ $int = hexdec($hex);
+ if (array_key_exists($int, $entityMap)) {
+ return sprintf('&%s;', $entityMap[$int]);
+ }
+
+ /*
+ * Per OWASP recommendations, we'll use hex entities for any other
+ * characters where a named entity does not exist.
+ */
+ return sprintf('%s;', $hex);
+}
+
+// add multibyte extensions if possible
+if (function_exists('mb_get_info')) {
+ /**
+ * Returns the length of a variable.
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ * @param mixed $thing A variable
+ *
+ * @return int The length of the value
+ */
+ function twig_length_filter(Twig_Environment $env, $thing)
+ {
+ return is_scalar($thing) ? mb_strlen($thing, $env->getCharset()) : count($thing);
+ }
+
+ /**
+ * Converts a string to uppercase.
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ * @param string $string A string
+ *
+ * @return string The uppercased string
+ */
+ function twig_upper_filter(Twig_Environment $env, $string)
+ {
+ if (null !== ($charset = $env->getCharset())) {
+ return mb_strtoupper($string, $charset);
+ }
+
+ return strtoupper($string);
+ }
+
+ /**
+ * Converts a string to lowercase.
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ * @param string $string A string
+ *
+ * @return string The lowercased string
+ */
+ function twig_lower_filter(Twig_Environment $env, $string)
+ {
+ if (null !== ($charset = $env->getCharset())) {
+ return mb_strtolower($string, $charset);
+ }
+
+ return strtolower($string);
+ }
+
+ /**
+ * Returns a titlecased string.
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ * @param string $string A string
+ *
+ * @return string The titlecased string
+ */
+ function twig_title_string_filter(Twig_Environment $env, $string)
+ {
+ if (null !== ($charset = $env->getCharset())) {
+ return mb_convert_case($string, MB_CASE_TITLE, $charset);
+ }
+
+ return ucwords(strtolower($string));
+ }
+
+ /**
+ * Returns a capitalized string.
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ * @param string $string A string
+ *
+ * @return string The capitalized string
+ */
+ function twig_capitalize_string_filter(Twig_Environment $env, $string)
+ {
+ if (null !== $charset = $env->getCharset()) {
+ return mb_strtoupper(mb_substr($string, 0, 1, $charset), $charset).mb_strtolower(mb_substr($string, 1, mb_strlen($string, $charset), $charset), $charset);
+ }
+
+ return ucfirst(strtolower($string));
+ }
+}
+// and byte fallback
+else {
+ /**
+ * Returns the length of a variable.
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ * @param mixed $thing A variable
+ *
+ * @return int The length of the value
+ */
+ function twig_length_filter(Twig_Environment $env, $thing)
+ {
+ return is_scalar($thing) ? strlen($thing) : count($thing);
+ }
+
+ /**
+ * Returns a titlecased string.
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ * @param string $string A string
+ *
+ * @return string The titlecased string
+ */
+ function twig_title_string_filter(Twig_Environment $env, $string)
+ {
+ return ucwords(strtolower($string));
+ }
+
+ /**
+ * Returns a capitalized string.
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ * @param string $string A string
+ *
+ * @return string The capitalized string
+ */
+ function twig_capitalize_string_filter(Twig_Environment $env, $string)
+ {
+ return ucfirst(strtolower($string));
+ }
+}
+
+/**
+ * @internal
+ */
+function twig_ensure_traversable($seq)
+{
+ if ($seq instanceof Traversable || is_array($seq)) {
+ return $seq;
+ }
+
+ return array();
+}
+
+/**
+ * Checks if a variable is empty.
+ *
+ *
+ * {# evaluates to true if the foo variable is null, false, or the empty string #}
+ * {% if foo is empty %}
+ * {# ... #}
+ * {% endif %}
+ *
+ *
+ * @param mixed $value A variable
+ *
+ * @return bool true if the value is empty, false otherwise
+ */
+function twig_test_empty($value)
+{
+ if ($value instanceof Countable) {
+ return 0 == count($value);
+ }
+
+ return '' === $value || false === $value || null === $value || array() === $value;
+}
+
+/**
+ * Checks if a variable is traversable.
+ *
+ *
+ * {# evaluates to true if the foo variable is an array or a traversable object #}
+ * {% if foo is traversable %}
+ * {# ... #}
+ * {% endif %}
+ *
+ *
+ * @param mixed $value A variable
+ *
+ * @return bool true if the value is traversable
+ */
+function twig_test_iterable($value)
+{
+ return $value instanceof Traversable || is_array($value);
+}
+
+/**
+ * Renders a template.
+ *
+ * @param Twig_Environment $env
+ * @param array $context
+ * @param string|array $template The template to render or an array of templates to try consecutively
+ * @param array $variables The variables to pass to the template
+ * @param bool $withContext
+ * @param bool $ignoreMissing Whether to ignore missing templates or not
+ * @param bool $sandboxed Whether to sandbox the template or not
+ *
+ * @return string The rendered template
+ */
+function twig_include(Twig_Environment $env, $context, $template, $variables = array(), $withContext = true, $ignoreMissing = false, $sandboxed = false)
+{
+ $alreadySandboxed = false;
+ $sandbox = null;
+ if ($withContext) {
+ $variables = array_merge($context, $variables);
+ }
+
+ if ($isSandboxed = $sandboxed && $env->hasExtension('sandbox')) {
+ $sandbox = $env->getExtension('sandbox');
+ if (!$alreadySandboxed = $sandbox->isSandboxed()) {
+ $sandbox->enableSandbox();
+ }
+ }
+
+ $result = null;
+ try {
+ $result = $env->resolveTemplate($template)->render($variables);
+ } catch (Twig_Error_Loader $e) {
+ if (!$ignoreMissing) {
+ if ($isSandboxed && !$alreadySandboxed) {
+ $sandbox->disableSandbox();
+ }
+
+ throw $e;
+ }
+ }
+
+ if ($isSandboxed && !$alreadySandboxed) {
+ $sandbox->disableSandbox();
+ }
+
+ return $result;
+}
+
+/**
+ * Returns a template content without rendering it.
+ *
+ * @param string $name The template name
+ * @param bool $ignoreMissing Whether to ignore missing templates or not
+ *
+ * @return string The template source
+ */
+function twig_source(Twig_Environment $env, $name, $ignoreMissing = false)
+{
+ try {
+ return $env->getLoader()->getSource($name);
+ } catch (Twig_Error_Loader $e) {
+ if (!$ignoreMissing) {
+ throw $e;
+ }
+ }
+}
+
+/**
+ * Provides the ability to get constants from instances as well as class/global constants.
+ *
+ * @param string $constant The name of the constant
+ * @param null|object $object The object to get the constant from
+ *
+ * @return string
+ */
+function twig_constant($constant, $object = null)
+{
+ if (null !== $object) {
+ $constant = get_class($object).'::'.$constant;
+ }
+
+ return constant($constant);
+}
+
+/**
+ * Batches item.
+ *
+ * @param array $items An array of items
+ * @param int $size The size of the batch
+ * @param mixed $fill A value used to fill missing items
+ *
+ * @return array
+ */
+function twig_array_batch($items, $size, $fill = null)
+{
+ if ($items instanceof Traversable) {
+ $items = iterator_to_array($items, false);
+ }
+
+ $size = ceil($size);
+
+ $result = array_chunk($items, $size, true);
+
+ if (null !== $fill && !empty($result)) {
+ $last = count($result) - 1;
+ if ($fillCount = $size - count($result[$last])) {
+ $result[$last] = array_merge(
+ $result[$last],
+ array_fill(0, $fillCount, $fill)
+ );
+ }
+ }
+
+ return $result;
+}
diff --git a/Twig/Extension/Debug.php b/Twig/Extension/Debug.php
new file mode 100644
index 0000000..86d07c2
--- /dev/null
+++ b/Twig/Extension/Debug.php
@@ -0,0 +1,71 @@
+ $isDumpOutputHtmlSafe ? array('html') : array(), 'needs_context' => true, 'needs_environment' => true)),
+ );
+ }
+
+ /**
+ * Returns the name of the extension.
+ *
+ * @return string The extension name
+ */
+ public function getName()
+ {
+ return 'debug';
+ }
+}
+
+function twig_var_dump(Twig_Environment $env, $context)
+{
+ if (!$env->isDebug()) {
+ return;
+ }
+
+ ob_start();
+
+ $count = func_num_args();
+ if (2 === $count) {
+ $vars = array();
+ foreach ($context as $key => $value) {
+ if (!$value instanceof Twig_Template) {
+ $vars[$key] = $value;
+ }
+ }
+
+ var_dump($vars);
+ } else {
+ for ($i = 2; $i < $count; ++$i) {
+ var_dump(func_get_arg($i));
+ }
+ }
+
+ return ob_get_clean();
+}
diff --git a/Twig/Extension/Escaper.php b/Twig/Extension/Escaper.php
new file mode 100644
index 0000000..053a895
--- /dev/null
+++ b/Twig/Extension/Escaper.php
@@ -0,0 +1,122 @@
+setDefaultStrategy($defaultStrategy);
+ }
+
+ /**
+ * Returns the token parser instances to add to the existing list.
+ *
+ * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances
+ */
+ public function getTokenParsers()
+ {
+ return array(new Twig_TokenParser_AutoEscape());
+ }
+
+ /**
+ * Returns the node visitor instances to add to the existing list.
+ *
+ * @return Twig_NodeVisitorInterface[] An array of Twig_NodeVisitorInterface instances
+ */
+ public function getNodeVisitors()
+ {
+ return array(new Twig_NodeVisitor_Escaper());
+ }
+
+ /**
+ * Returns a list of filters to add to the existing list.
+ *
+ * @return array An array of filters
+ */
+ public function getFilters()
+ {
+ return array(
+ new Twig_SimpleFilter('raw', 'twig_raw_filter', array('is_safe' => array('all'))),
+ );
+ }
+
+ /**
+ * Sets the default strategy to use when not defined by the user.
+ *
+ * The strategy can be a valid PHP callback that takes the template
+ * "filename" as an argument and returns the strategy to use.
+ *
+ * @param string|false|callable $defaultStrategy An escaping strategy
+ */
+ public function setDefaultStrategy($defaultStrategy)
+ {
+ // for BC
+ if (true === $defaultStrategy) {
+ @trigger_error('Using "true" as the default strategy is deprecated. Use "html" instead.', E_USER_DEPRECATED);
+
+ $defaultStrategy = 'html';
+ }
+
+ if ('filename' === $defaultStrategy) {
+ $defaultStrategy = array('Twig_FileExtensionEscapingStrategy', 'guess');
+ }
+
+ $this->defaultStrategy = $defaultStrategy;
+ }
+
+ /**
+ * Gets the default strategy to use when not defined by the user.
+ *
+ * @param string $filename The template "filename"
+ *
+ * @return string|false The default strategy to use for the template
+ */
+ public function getDefaultStrategy($filename)
+ {
+ // disable string callables to avoid calling a function named html or js,
+ // or any other upcoming escaping strategy
+ if (!is_string($this->defaultStrategy) && false !== $this->defaultStrategy) {
+ return call_user_func($this->defaultStrategy, $filename);
+ }
+
+ return $this->defaultStrategy;
+ }
+
+ /**
+ * Returns the name of the extension.
+ *
+ * @return string The extension name
+ */
+ public function getName()
+ {
+ return 'escaper';
+ }
+}
+
+/**
+ * Marks a variable as being safe.
+ *
+ * @param string $string A PHP variable
+ *
+ * @return string
+ */
+function twig_raw_filter($string)
+{
+ return $string;
+}
diff --git a/Twig/Extension/Optimizer.php b/Twig/Extension/Optimizer.php
new file mode 100644
index 0000000..013fcb6
--- /dev/null
+++ b/Twig/Extension/Optimizer.php
@@ -0,0 +1,35 @@
+optimizers = $optimizers;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getNodeVisitors()
+ {
+ return array(new Twig_NodeVisitor_Optimizer($this->optimizers));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getName()
+ {
+ return 'optimizer';
+ }
+}
diff --git a/Twig/Extension/Profiler.php b/Twig/Extension/Profiler.php
new file mode 100644
index 0000000..e21fdb6
--- /dev/null
+++ b/Twig/Extension/Profiler.php
@@ -0,0 +1,52 @@
+actives[] = $profile;
+ }
+
+ public function enter(Twig_Profiler_Profile $profile)
+ {
+ $this->actives[0]->addProfile($profile);
+ array_unshift($this->actives, $profile);
+ }
+
+ public function leave(Twig_Profiler_Profile $profile)
+ {
+ $profile->leave();
+ array_shift($this->actives);
+
+ if (1 === count($this->actives)) {
+ $this->actives[0]->leave();
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getNodeVisitors()
+ {
+ return array(new Twig_Profiler_NodeVisitor_Profiler($this->getName()));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getName()
+ {
+ return 'profiler';
+ }
+}
diff --git a/Twig/Extension/Sandbox.php b/Twig/Extension/Sandbox.php
new file mode 100644
index 0000000..3593e9e
--- /dev/null
+++ b/Twig/Extension/Sandbox.php
@@ -0,0 +1,112 @@
+policy = $policy;
+ $this->sandboxedGlobally = $sandboxed;
+ }
+
+ /**
+ * Returns the token parser instances to add to the existing list.
+ *
+ * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances
+ */
+ public function getTokenParsers()
+ {
+ return array(new Twig_TokenParser_Sandbox());
+ }
+
+ /**
+ * Returns the node visitor instances to add to the existing list.
+ *
+ * @return Twig_NodeVisitorInterface[] An array of Twig_NodeVisitorInterface instances
+ */
+ public function getNodeVisitors()
+ {
+ return array(new Twig_NodeVisitor_Sandbox());
+ }
+
+ public function enableSandbox()
+ {
+ $this->sandboxed = true;
+ }
+
+ public function disableSandbox()
+ {
+ $this->sandboxed = false;
+ }
+
+ public function isSandboxed()
+ {
+ return $this->sandboxedGlobally || $this->sandboxed;
+ }
+
+ public function isSandboxedGlobally()
+ {
+ return $this->sandboxedGlobally;
+ }
+
+ public function setSecurityPolicy(Twig_Sandbox_SecurityPolicyInterface $policy)
+ {
+ $this->policy = $policy;
+ }
+
+ public function getSecurityPolicy()
+ {
+ return $this->policy;
+ }
+
+ public function checkSecurity($tags, $filters, $functions)
+ {
+ if ($this->isSandboxed()) {
+ $this->policy->checkSecurity($tags, $filters, $functions);
+ }
+ }
+
+ public function checkMethodAllowed($obj, $method)
+ {
+ if ($this->isSandboxed()) {
+ $this->policy->checkMethodAllowed($obj, $method);
+ }
+ }
+
+ public function checkPropertyAllowed($obj, $method)
+ {
+ if ($this->isSandboxed()) {
+ $this->policy->checkPropertyAllowed($obj, $method);
+ }
+ }
+
+ public function ensureToStringAllowed($obj)
+ {
+ if ($this->isSandboxed() && is_object($obj)) {
+ $this->policy->checkMethodAllowed($obj, '__toString');
+ }
+
+ return $obj;
+ }
+
+ /**
+ * Returns the name of the extension.
+ *
+ * @return string The extension name
+ */
+ public function getName()
+ {
+ return 'sandbox';
+ }
+}
diff --git a/Twig/Extension/Staging.php b/Twig/Extension/Staging.php
new file mode 100644
index 0000000..583e6a9
--- /dev/null
+++ b/Twig/Extension/Staging.php
@@ -0,0 +1,115 @@
+
+ *
+ * @internal
+ */
+class Twig_Extension_Staging extends Twig_Extension
+{
+ protected $functions = array();
+ protected $filters = array();
+ protected $visitors = array();
+ protected $tokenParsers = array();
+ protected $globals = array();
+ protected $tests = array();
+
+ public function addFunction($name, $function)
+ {
+ $this->functions[$name] = $function;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getFunctions()
+ {
+ return $this->functions;
+ }
+
+ public function addFilter($name, $filter)
+ {
+ $this->filters[$name] = $filter;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getFilters()
+ {
+ return $this->filters;
+ }
+
+ public function addNodeVisitor(Twig_NodeVisitorInterface $visitor)
+ {
+ $this->visitors[] = $visitor;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getNodeVisitors()
+ {
+ return $this->visitors;
+ }
+
+ public function addTokenParser(Twig_TokenParserInterface $parser)
+ {
+ $this->tokenParsers[] = $parser;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getTokenParsers()
+ {
+ return $this->tokenParsers;
+ }
+
+ public function addGlobal($name, $value)
+ {
+ $this->globals[$name] = $value;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getGlobals()
+ {
+ return $this->globals;
+ }
+
+ public function addTest($name, $test)
+ {
+ $this->tests[$name] = $test;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getTests()
+ {
+ return $this->tests;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getName()
+ {
+ return 'staging';
+ }
+}
diff --git a/Twig/Extension/StringLoader.php b/Twig/Extension/StringLoader.php
new file mode 100644
index 0000000..d96673c
--- /dev/null
+++ b/Twig/Extension/StringLoader.php
@@ -0,0 +1,47 @@
+ true)),
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getName()
+ {
+ return 'string_loader';
+ }
+}
+
+/**
+ * Loads a template from a string.
+ *
+ *
+ * {{ include(template_from_string("Hello {{ name }}")) }}
+ *
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ * @param string $template A template as a string or object implementing __toString()
+ *
+ * @return Twig_Template A Twig_Template instance
+ */
+function twig_template_from_string(Twig_Environment $env, $template)
+{
+ return $env->createTemplate((string) $template);
+}
diff --git a/Twig/ExtensionInterface.php b/Twig/ExtensionInterface.php
new file mode 100644
index 0000000..92abf7d
--- /dev/null
+++ b/Twig/ExtensionInterface.php
@@ -0,0 +1,83 @@
+
+ */
+interface Twig_ExtensionInterface
+{
+ /**
+ * Initializes the runtime environment.
+ *
+ * This is where you can load some file that contains filter functions for instance.
+ *
+ * @param Twig_Environment $environment The current Twig_Environment instance
+ */
+ public function initRuntime(Twig_Environment $environment);
+
+ /**
+ * Returns the token parser instances to add to the existing list.
+ *
+ * @return Twig_TokenParserInterface[]
+ */
+ public function getTokenParsers();
+
+ /**
+ * Returns the node visitor instances to add to the existing list.
+ *
+ * @return Twig_NodeVisitorInterface[] An array of Twig_NodeVisitorInterface instances
+ */
+ public function getNodeVisitors();
+
+ /**
+ * Returns a list of filters to add to the existing list.
+ *
+ * @return Twig_SimpleFilter[]
+ */
+ public function getFilters();
+
+ /**
+ * Returns a list of tests to add to the existing list.
+ *
+ * @return Twig_SimpleTest[]
+ */
+ public function getTests();
+
+ /**
+ * Returns a list of functions to add to the existing list.
+ *
+ * @return Twig_SimpleFunction[]
+ */
+ public function getFunctions();
+
+ /**
+ * Returns a list of operators to add to the existing list.
+ *
+ * @return array An array of operators
+ */
+ public function getOperators();
+
+ /**
+ * Returns a list of global variables to add to the existing list.
+ *
+ * @return array An array of global variables
+ */
+ public function getGlobals();
+
+ /**
+ * Returns the name of the extension.
+ *
+ * @return string The extension name
+ */
+ public function getName();
+}
diff --git a/Twig/FileExtensionEscapingStrategy.php b/Twig/FileExtensionEscapingStrategy.php
new file mode 100644
index 0000000..9bda0b4
--- /dev/null
+++ b/Twig/FileExtensionEscapingStrategy.php
@@ -0,0 +1,58 @@
+
+ */
+class Twig_FileExtensionEscapingStrategy
+{
+ /**
+ * Guesses the best autoescaping strategy based on the file name.
+ *
+ * @param string $filename The template file name
+ *
+ * @return string|false The escaping strategy name to use or false to disable
+ */
+ public static function guess($filename)
+ {
+ if (in_array(substr($filename, -1), array('/', '\\'))) {
+ return 'html'; // return html for directories
+ }
+
+ if ('.twig' === substr($filename, -5)) {
+ $filename = substr($filename, 0, -5);
+ }
+
+ $extension = pathinfo($filename, PATHINFO_EXTENSION);
+
+ switch ($extension) {
+ case 'js':
+ return 'js';
+
+ case 'css':
+ return 'css';
+
+ case 'txt':
+ return false;
+
+ default:
+ return 'html';
+ }
+ }
+}
diff --git a/Twig/Filter.php b/Twig/Filter.php
new file mode 100644
index 0000000..101d2e7
--- /dev/null
+++ b/Twig/Filter.php
@@ -0,0 +1,84 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+abstract class Twig_Filter implements Twig_FilterInterface, Twig_FilterCallableInterface
+{
+ protected $options;
+ protected $arguments = array();
+
+ public function __construct(array $options = array())
+ {
+ $this->options = array_merge(array(
+ 'needs_environment' => false,
+ 'needs_context' => false,
+ 'pre_escape' => null,
+ 'preserves_safety' => null,
+ 'callable' => null,
+ ), $options);
+ }
+
+ public function setArguments($arguments)
+ {
+ $this->arguments = $arguments;
+ }
+
+ public function getArguments()
+ {
+ return $this->arguments;
+ }
+
+ public function needsEnvironment()
+ {
+ return $this->options['needs_environment'];
+ }
+
+ public function needsContext()
+ {
+ return $this->options['needs_context'];
+ }
+
+ public function getSafe(Twig_Node $filterArgs)
+ {
+ if (isset($this->options['is_safe'])) {
+ return $this->options['is_safe'];
+ }
+
+ if (isset($this->options['is_safe_callback'])) {
+ return call_user_func($this->options['is_safe_callback'], $filterArgs);
+ }
+ }
+
+ public function getPreservesSafety()
+ {
+ return $this->options['preserves_safety'];
+ }
+
+ public function getPreEscape()
+ {
+ return $this->options['pre_escape'];
+ }
+
+ public function getCallable()
+ {
+ return $this->options['callable'];
+ }
+}
diff --git a/Twig/Filter/Function.php b/Twig/Filter/Function.php
new file mode 100644
index 0000000..d679cab
--- /dev/null
+++ b/Twig/Filter/Function.php
@@ -0,0 +1,40 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+class Twig_Filter_Function extends Twig_Filter
+{
+ protected $function;
+
+ public function __construct($function, array $options = array())
+ {
+ $options['callable'] = $function;
+
+ parent::__construct($options);
+
+ $this->function = $function;
+ }
+
+ public function compile()
+ {
+ return $this->function;
+ }
+}
diff --git a/Twig/Filter/Method.php b/Twig/Filter/Method.php
new file mode 100644
index 0000000..655aab4
--- /dev/null
+++ b/Twig/Filter/Method.php
@@ -0,0 +1,42 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+class Twig_Filter_Method extends Twig_Filter
+{
+ protected $extension;
+ protected $method;
+
+ public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array())
+ {
+ $options['callable'] = array($extension, $method);
+
+ parent::__construct($options);
+
+ $this->extension = $extension;
+ $this->method = $method;
+ }
+
+ public function compile()
+ {
+ return sprintf('$this->env->getExtension(\'%s\')->%s', $this->extension->getName(), $this->method);
+ }
+}
diff --git a/Twig/Filter/Node.php b/Twig/Filter/Node.php
new file mode 100644
index 0000000..a922f50
--- /dev/null
+++ b/Twig/Filter/Node.php
@@ -0,0 +1,42 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+class Twig_Filter_Node extends Twig_Filter
+{
+ protected $class;
+
+ public function __construct($class, array $options = array())
+ {
+ parent::__construct($options);
+
+ $this->class = $class;
+ }
+
+ public function getClass()
+ {
+ return $this->class;
+ }
+
+ public function compile()
+ {
+ }
+}
diff --git a/Twig/FilterCallableInterface.php b/Twig/FilterCallableInterface.php
new file mode 100644
index 0000000..5679861
--- /dev/null
+++ b/Twig/FilterCallableInterface.php
@@ -0,0 +1,24 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+interface Twig_FilterCallableInterface
+{
+ public function getCallable();
+}
diff --git a/Twig/FilterInterface.php b/Twig/FilterInterface.php
new file mode 100644
index 0000000..6b0be0e
--- /dev/null
+++ b/Twig/FilterInterface.php
@@ -0,0 +1,43 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+interface Twig_FilterInterface
+{
+ /**
+ * Compiles a filter.
+ *
+ * @return string The PHP code for the filter
+ */
+ public function compile();
+
+ public function needsEnvironment();
+
+ public function needsContext();
+
+ public function getSafe(Twig_Node $filterArgs);
+
+ public function getPreservesSafety();
+
+ public function getPreEscape();
+
+ public function setArguments($arguments);
+
+ public function getArguments();
+}
diff --git a/Twig/Function.php b/Twig/Function.php
new file mode 100644
index 0000000..9fc76a8
--- /dev/null
+++ b/Twig/Function.php
@@ -0,0 +1,74 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+abstract class Twig_Function implements Twig_FunctionInterface, Twig_FunctionCallableInterface
+{
+ protected $options;
+ protected $arguments = array();
+
+ public function __construct(array $options = array())
+ {
+ $this->options = array_merge(array(
+ 'needs_environment' => false,
+ 'needs_context' => false,
+ 'callable' => null,
+ ), $options);
+ }
+
+ public function setArguments($arguments)
+ {
+ $this->arguments = $arguments;
+ }
+
+ public function getArguments()
+ {
+ return $this->arguments;
+ }
+
+ public function needsEnvironment()
+ {
+ return $this->options['needs_environment'];
+ }
+
+ public function needsContext()
+ {
+ return $this->options['needs_context'];
+ }
+
+ public function getSafe(Twig_Node $functionArgs)
+ {
+ if (isset($this->options['is_safe'])) {
+ return $this->options['is_safe'];
+ }
+
+ if (isset($this->options['is_safe_callback'])) {
+ return call_user_func($this->options['is_safe_callback'], $functionArgs);
+ }
+
+ return array();
+ }
+
+ public function getCallable()
+ {
+ return $this->options['callable'];
+ }
+}
diff --git a/Twig/Function/Function.php b/Twig/Function/Function.php
new file mode 100644
index 0000000..ae83e15
--- /dev/null
+++ b/Twig/Function/Function.php
@@ -0,0 +1,41 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+class Twig_Function_Function extends Twig_Function
+{
+ protected $function;
+
+ public function __construct($function, array $options = array())
+ {
+ $options['callable'] = $function;
+
+ parent::__construct($options);
+
+ $this->function = $function;
+ }
+
+ public function compile()
+ {
+ return $this->function;
+ }
+}
diff --git a/Twig/Function/Method.php b/Twig/Function/Method.php
new file mode 100644
index 0000000..ba9945e
--- /dev/null
+++ b/Twig/Function/Method.php
@@ -0,0 +1,43 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+class Twig_Function_Method extends Twig_Function
+{
+ protected $extension;
+ protected $method;
+
+ public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array())
+ {
+ $options['callable'] = array($extension, $method);
+
+ parent::__construct($options);
+
+ $this->extension = $extension;
+ $this->method = $method;
+ }
+
+ public function compile()
+ {
+ return sprintf('$this->env->getExtension(\'%s\')->%s', $this->extension->getName(), $this->method);
+ }
+}
diff --git a/Twig/Function/Node.php b/Twig/Function/Node.php
new file mode 100644
index 0000000..118b0ba
--- /dev/null
+++ b/Twig/Function/Node.php
@@ -0,0 +1,42 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+class Twig_Function_Node extends Twig_Function
+{
+ protected $class;
+
+ public function __construct($class, array $options = array())
+ {
+ parent::__construct($options);
+
+ $this->class = $class;
+ }
+
+ public function getClass()
+ {
+ return $this->class;
+ }
+
+ public function compile()
+ {
+ }
+}
diff --git a/Twig/FunctionCallableInterface.php b/Twig/FunctionCallableInterface.php
new file mode 100644
index 0000000..87d795e
--- /dev/null
+++ b/Twig/FunctionCallableInterface.php
@@ -0,0 +1,24 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+interface Twig_FunctionCallableInterface
+{
+ public function getCallable();
+}
diff --git a/Twig/FunctionInterface.php b/Twig/FunctionInterface.php
new file mode 100644
index 0000000..f449234
--- /dev/null
+++ b/Twig/FunctionInterface.php
@@ -0,0 +1,40 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+interface Twig_FunctionInterface
+{
+ /**
+ * Compiles a function.
+ *
+ * @return string The PHP code for the function
+ */
+ public function compile();
+
+ public function needsEnvironment();
+
+ public function needsContext();
+
+ public function getSafe(Twig_Node $filterArgs);
+
+ public function setArguments($arguments);
+
+ public function getArguments();
+}
diff --git a/Twig/Lexer.php b/Twig/Lexer.php
new file mode 100644
index 0000000..75f763f
--- /dev/null
+++ b/Twig/Lexer.php
@@ -0,0 +1,411 @@
+
+ */
+class Twig_Lexer implements Twig_LexerInterface
+{
+ protected $tokens;
+ protected $code;
+ protected $cursor;
+ protected $lineno;
+ protected $end;
+ protected $state;
+ protected $states;
+ protected $brackets;
+ protected $env;
+ protected $filename;
+ protected $options;
+ protected $regexes;
+ protected $position;
+ protected $positions;
+ protected $currentVarBlockLine;
+
+ const STATE_DATA = 0;
+ const STATE_BLOCK = 1;
+ const STATE_VAR = 2;
+ const STATE_STRING = 3;
+ const STATE_INTERPOLATION = 4;
+
+ const REGEX_NAME = '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A';
+ const REGEX_NUMBER = '/[0-9]+(?:\.[0-9]+)?/A';
+ const REGEX_STRING = '/"([^#"\\\\]*(?:\\\\.[^#"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As';
+ const REGEX_DQ_STRING_DELIM = '/"/A';
+ const REGEX_DQ_STRING_PART = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As';
+ const PUNCTUATION = '()[]{}?:.,|';
+
+ public function __construct(Twig_Environment $env, array $options = array())
+ {
+ $this->env = $env;
+
+ $this->options = array_merge(array(
+ 'tag_comment' => array('{#', '#}'),
+ 'tag_block' => array('{%', '%}'),
+ 'tag_variable' => array('{{', '}}'),
+ 'whitespace_trim' => '-',
+ 'interpolation' => array('#{', '}'),
+ ), $options);
+
+ $this->regexes = array(
+ 'lex_var' => '/\s*'.preg_quote($this->options['whitespace_trim'].$this->options['tag_variable'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_variable'][1], '/').'/A',
+ 'lex_block' => '/\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')\n?/A',
+ 'lex_raw_data' => '/('.preg_quote($this->options['tag_block'][0].$this->options['whitespace_trim'], '/').'|'.preg_quote($this->options['tag_block'][0], '/').')\s*(?:end%s)\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/s',
+ 'operator' => $this->getOperatorRegex(),
+ 'lex_comment' => '/(?:'.preg_quote($this->options['whitespace_trim'], '/').preg_quote($this->options['tag_comment'][1], '/').'\s*|'.preg_quote($this->options['tag_comment'][1], '/').')\n?/s',
+ 'lex_block_raw' => '/\s*(raw|verbatim)\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/As',
+ 'lex_block_line' => '/\s*line\s+(\d+)\s*'.preg_quote($this->options['tag_block'][1], '/').'/As',
+ 'lex_tokens_start' => '/('.preg_quote($this->options['tag_variable'][0], '/').'|'.preg_quote($this->options['tag_block'][0], '/').'|'.preg_quote($this->options['tag_comment'][0], '/').')('.preg_quote($this->options['whitespace_trim'], '/').')?/s',
+ 'interpolation_start' => '/'.preg_quote($this->options['interpolation'][0], '/').'\s*/A',
+ 'interpolation_end' => '/\s*'.preg_quote($this->options['interpolation'][1], '/').'/A',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function tokenize($code, $filename = null)
+ {
+ if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
+ $mbEncoding = mb_internal_encoding();
+ mb_internal_encoding('ASCII');
+ } else {
+ $mbEncoding = null;
+ }
+
+ $this->code = str_replace(array("\r\n", "\r"), "\n", $code);
+ $this->filename = $filename;
+ $this->cursor = 0;
+ $this->lineno = 1;
+ $this->end = strlen($this->code);
+ $this->tokens = array();
+ $this->state = self::STATE_DATA;
+ $this->states = array();
+ $this->brackets = array();
+ $this->position = -1;
+
+ // find all token starts in one go
+ preg_match_all($this->regexes['lex_tokens_start'], $this->code, $matches, PREG_OFFSET_CAPTURE);
+ $this->positions = $matches;
+
+ while ($this->cursor < $this->end) {
+ // dispatch to the lexing functions depending
+ // on the current state
+ switch ($this->state) {
+ case self::STATE_DATA:
+ $this->lexData();
+ break;
+
+ case self::STATE_BLOCK:
+ $this->lexBlock();
+ break;
+
+ case self::STATE_VAR:
+ $this->lexVar();
+ break;
+
+ case self::STATE_STRING:
+ $this->lexString();
+ break;
+
+ case self::STATE_INTERPOLATION:
+ $this->lexInterpolation();
+ break;
+ }
+ }
+
+ $this->pushToken(Twig_Token::EOF_TYPE);
+
+ if (!empty($this->brackets)) {
+ list($expect, $lineno) = array_pop($this->brackets);
+ throw new Twig_Error_Syntax(sprintf('Unclosed "%s"', $expect), $lineno, $this->filename);
+ }
+
+ if ($mbEncoding) {
+ mb_internal_encoding($mbEncoding);
+ }
+
+ return new Twig_TokenStream($this->tokens, $this->filename);
+ }
+
+ protected function lexData()
+ {
+ // if no matches are left we return the rest of the template as simple text token
+ if ($this->position == count($this->positions[0]) - 1) {
+ $this->pushToken(Twig_Token::TEXT_TYPE, substr($this->code, $this->cursor));
+ $this->cursor = $this->end;
+
+ return;
+ }
+
+ // Find the first token after the current cursor
+ $position = $this->positions[0][++$this->position];
+ while ($position[1] < $this->cursor) {
+ if ($this->position == count($this->positions[0]) - 1) {
+ return;
+ }
+ $position = $this->positions[0][++$this->position];
+ }
+
+ // push the template text first
+ $text = $textContent = substr($this->code, $this->cursor, $position[1] - $this->cursor);
+ if (isset($this->positions[2][$this->position][0])) {
+ $text = rtrim($text);
+ }
+ $this->pushToken(Twig_Token::TEXT_TYPE, $text);
+ $this->moveCursor($textContent.$position[0]);
+
+ switch ($this->positions[1][$this->position][0]) {
+ case $this->options['tag_comment'][0]:
+ $this->lexComment();
+ break;
+
+ case $this->options['tag_block'][0]:
+ // raw data?
+ if (preg_match($this->regexes['lex_block_raw'], $this->code, $match, null, $this->cursor)) {
+ $this->moveCursor($match[0]);
+ $this->lexRawData($match[1]);
+ // {% line \d+ %}
+ } elseif (preg_match($this->regexes['lex_block_line'], $this->code, $match, null, $this->cursor)) {
+ $this->moveCursor($match[0]);
+ $this->lineno = (int) $match[1];
+ } else {
+ $this->pushToken(Twig_Token::BLOCK_START_TYPE);
+ $this->pushState(self::STATE_BLOCK);
+ $this->currentVarBlockLine = $this->lineno;
+ }
+ break;
+
+ case $this->options['tag_variable'][0]:
+ $this->pushToken(Twig_Token::VAR_START_TYPE);
+ $this->pushState(self::STATE_VAR);
+ $this->currentVarBlockLine = $this->lineno;
+ break;
+ }
+ }
+
+ protected function lexBlock()
+ {
+ if (empty($this->brackets) && preg_match($this->regexes['lex_block'], $this->code, $match, null, $this->cursor)) {
+ $this->pushToken(Twig_Token::BLOCK_END_TYPE);
+ $this->moveCursor($match[0]);
+ $this->popState();
+ } else {
+ $this->lexExpression();
+ }
+ }
+
+ protected function lexVar()
+ {
+ if (empty($this->brackets) && preg_match($this->regexes['lex_var'], $this->code, $match, null, $this->cursor)) {
+ $this->pushToken(Twig_Token::VAR_END_TYPE);
+ $this->moveCursor($match[0]);
+ $this->popState();
+ } else {
+ $this->lexExpression();
+ }
+ }
+
+ protected function lexExpression()
+ {
+ // whitespace
+ if (preg_match('/\s+/A', $this->code, $match, null, $this->cursor)) {
+ $this->moveCursor($match[0]);
+
+ if ($this->cursor >= $this->end) {
+ throw new Twig_Error_Syntax(sprintf('Unclosed "%s"', $this->state === self::STATE_BLOCK ? 'block' : 'variable'), $this->currentVarBlockLine, $this->filename);
+ }
+ }
+
+ // operators
+ if (preg_match($this->regexes['operator'], $this->code, $match, null, $this->cursor)) {
+ $this->pushToken(Twig_Token::OPERATOR_TYPE, preg_replace('/\s+/', ' ', $match[0]));
+ $this->moveCursor($match[0]);
+ }
+ // names
+ elseif (preg_match(self::REGEX_NAME, $this->code, $match, null, $this->cursor)) {
+ $this->pushToken(Twig_Token::NAME_TYPE, $match[0]);
+ $this->moveCursor($match[0]);
+ }
+ // numbers
+ elseif (preg_match(self::REGEX_NUMBER, $this->code, $match, null, $this->cursor)) {
+ $number = (float) $match[0]; // floats
+ if (ctype_digit($match[0]) && $number <= PHP_INT_MAX) {
+ $number = (int) $match[0]; // integers lower than the maximum
+ }
+ $this->pushToken(Twig_Token::NUMBER_TYPE, $number);
+ $this->moveCursor($match[0]);
+ }
+ // punctuation
+ elseif (false !== strpos(self::PUNCTUATION, $this->code[$this->cursor])) {
+ // opening bracket
+ if (false !== strpos('([{', $this->code[$this->cursor])) {
+ $this->brackets[] = array($this->code[$this->cursor], $this->lineno);
+ }
+ // closing bracket
+ elseif (false !== strpos(')]}', $this->code[$this->cursor])) {
+ if (empty($this->brackets)) {
+ throw new Twig_Error_Syntax(sprintf('Unexpected "%s"', $this->code[$this->cursor]), $this->lineno, $this->filename);
+ }
+
+ list($expect, $lineno) = array_pop($this->brackets);
+ if ($this->code[$this->cursor] != strtr($expect, '([{', ')]}')) {
+ throw new Twig_Error_Syntax(sprintf('Unclosed "%s"', $expect), $lineno, $this->filename);
+ }
+ }
+
+ $this->pushToken(Twig_Token::PUNCTUATION_TYPE, $this->code[$this->cursor]);
+ ++$this->cursor;
+ }
+ // strings
+ elseif (preg_match(self::REGEX_STRING, $this->code, $match, null, $this->cursor)) {
+ $this->pushToken(Twig_Token::STRING_TYPE, stripcslashes(substr($match[0], 1, -1)));
+ $this->moveCursor($match[0]);
+ }
+ // opening double quoted string
+ elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) {
+ $this->brackets[] = array('"', $this->lineno);
+ $this->pushState(self::STATE_STRING);
+ $this->moveCursor($match[0]);
+ }
+ // unlexable
+ else {
+ throw new Twig_Error_Syntax(sprintf('Unexpected character "%s"', $this->code[$this->cursor]), $this->lineno, $this->filename);
+ }
+ }
+
+ protected function lexRawData($tag)
+ {
+ if ('raw' === $tag) {
+ @trigger_error(sprintf('Twig Tag "raw" is deprecated. Use "verbatim" instead in %s at line %d.', $this->filename, $this->lineno), E_USER_DEPRECATED);
+ }
+
+ if (!preg_match(str_replace('%s', $tag, $this->regexes['lex_raw_data']), $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
+ throw new Twig_Error_Syntax(sprintf('Unexpected end of file: Unclosed "%s" block', $tag), $this->lineno, $this->filename);
+ }
+
+ $text = substr($this->code, $this->cursor, $match[0][1] - $this->cursor);
+ $this->moveCursor($text.$match[0][0]);
+
+ if (false !== strpos($match[1][0], $this->options['whitespace_trim'])) {
+ $text = rtrim($text);
+ }
+
+ $this->pushToken(Twig_Token::TEXT_TYPE, $text);
+ }
+
+ protected function lexComment()
+ {
+ if (!preg_match($this->regexes['lex_comment'], $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) {
+ throw new Twig_Error_Syntax('Unclosed comment', $this->lineno, $this->filename);
+ }
+
+ $this->moveCursor(substr($this->code, $this->cursor, $match[0][1] - $this->cursor).$match[0][0]);
+ }
+
+ protected function lexString()
+ {
+ if (preg_match($this->regexes['interpolation_start'], $this->code, $match, null, $this->cursor)) {
+ $this->brackets[] = array($this->options['interpolation'][0], $this->lineno);
+ $this->pushToken(Twig_Token::INTERPOLATION_START_TYPE);
+ $this->moveCursor($match[0]);
+ $this->pushState(self::STATE_INTERPOLATION);
+ } elseif (preg_match(self::REGEX_DQ_STRING_PART, $this->code, $match, null, $this->cursor) && strlen($match[0]) > 0) {
+ $this->pushToken(Twig_Token::STRING_TYPE, stripcslashes($match[0]));
+ $this->moveCursor($match[0]);
+ } elseif (preg_match(self::REGEX_DQ_STRING_DELIM, $this->code, $match, null, $this->cursor)) {
+ list($expect, $lineno) = array_pop($this->brackets);
+ if ($this->code[$this->cursor] != '"') {
+ throw new Twig_Error_Syntax(sprintf('Unclosed "%s"', $expect), $lineno, $this->filename);
+ }
+
+ $this->popState();
+ ++$this->cursor;
+ }
+ }
+
+ protected function lexInterpolation()
+ {
+ $bracket = end($this->brackets);
+ if ($this->options['interpolation'][0] === $bracket[0] && preg_match($this->regexes['interpolation_end'], $this->code, $match, null, $this->cursor)) {
+ array_pop($this->brackets);
+ $this->pushToken(Twig_Token::INTERPOLATION_END_TYPE);
+ $this->moveCursor($match[0]);
+ $this->popState();
+ } else {
+ $this->lexExpression();
+ }
+ }
+
+ protected function pushToken($type, $value = '')
+ {
+ // do not push empty text tokens
+ if (Twig_Token::TEXT_TYPE === $type && '' === $value) {
+ return;
+ }
+
+ $this->tokens[] = new Twig_Token($type, $value, $this->lineno);
+ }
+
+ protected function moveCursor($text)
+ {
+ $this->cursor += strlen($text);
+ $this->lineno += substr_count($text, "\n");
+ }
+
+ protected function getOperatorRegex()
+ {
+ $operators = array_merge(
+ array('='),
+ array_keys($this->env->getUnaryOperators()),
+ array_keys($this->env->getBinaryOperators())
+ );
+
+ $operators = array_combine($operators, array_map('strlen', $operators));
+ arsort($operators);
+
+ $regex = array();
+ foreach ($operators as $operator => $length) {
+ // an operator that ends with a character must be followed by
+ // a whitespace or a parenthesis
+ if (ctype_alpha($operator[$length - 1])) {
+ $r = preg_quote($operator, '/').'(?=[\s()])';
+ } else {
+ $r = preg_quote($operator, '/');
+ }
+
+ // an operator with a space can be any amount of whitespaces
+ $r = preg_replace('/\s+/', '\s+', $r);
+
+ $regex[] = $r;
+ }
+
+ return '/'.implode('|', $regex).'/A';
+ }
+
+ protected function pushState($state)
+ {
+ $this->states[] = $this->state;
+ $this->state = $state;
+ }
+
+ protected function popState()
+ {
+ if (0 === count($this->states)) {
+ throw new Exception('Cannot pop state without a previous state');
+ }
+
+ $this->state = array_pop($this->states);
+ }
+}
diff --git a/Twig/LexerInterface.php b/Twig/LexerInterface.php
new file mode 100644
index 0000000..24a9478
--- /dev/null
+++ b/Twig/LexerInterface.php
@@ -0,0 +1,32 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 3.0)
+ */
+interface Twig_LexerInterface
+{
+ /**
+ * Tokenizes a source code.
+ *
+ * @param string $code The source code
+ * @param string $filename A unique identifier for the source code
+ *
+ * @return Twig_TokenStream A token stream instance
+ *
+ * @throws Twig_Error_Syntax When the code is syntactically wrong
+ */
+ public function tokenize($code, $filename = null);
+}
diff --git a/Twig/Loader/Array.php b/Twig/Loader/Array.php
new file mode 100644
index 0000000..90221d5
--- /dev/null
+++ b/Twig/Loader/Array.php
@@ -0,0 +1,95 @@
+
+ */
+class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterface
+{
+ protected $templates = array();
+
+ /**
+ * Constructor.
+ *
+ * @param array $templates An array of templates (keys are the names, and values are the source code)
+ */
+ public function __construct(array $templates)
+ {
+ $this->templates = $templates;
+ }
+
+ /**
+ * Adds or overrides a template.
+ *
+ * @param string $name The template name
+ * @param string $template The template source
+ */
+ public function setTemplate($name, $template)
+ {
+ $this->templates[(string) $name] = $template;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getSource($name)
+ {
+ $name = (string) $name;
+ if (!isset($this->templates[$name])) {
+ throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
+ }
+
+ return $this->templates[$name];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function exists($name)
+ {
+ return isset($this->templates[(string) $name]);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getCacheKey($name)
+ {
+ $name = (string) $name;
+ if (!isset($this->templates[$name])) {
+ throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
+ }
+
+ return $this->templates[$name];
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isFresh($name, $time)
+ {
+ $name = (string) $name;
+ if (!isset($this->templates[$name])) {
+ throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name));
+ }
+
+ return true;
+ }
+}
diff --git a/Twig/Loader/Chain.php b/Twig/Loader/Chain.php
new file mode 100644
index 0000000..81d57ad
--- /dev/null
+++ b/Twig/Loader/Chain.php
@@ -0,0 +1,138 @@
+
+ */
+class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterface
+{
+ private $hasSourceCache = array();
+ protected $loaders = array();
+
+ /**
+ * Constructor.
+ *
+ * @param Twig_LoaderInterface[] $loaders An array of loader instances
+ */
+ public function __construct(array $loaders = array())
+ {
+ foreach ($loaders as $loader) {
+ $this->addLoader($loader);
+ }
+ }
+
+ /**
+ * Adds a loader instance.
+ *
+ * @param Twig_LoaderInterface $loader A Loader instance
+ */
+ public function addLoader(Twig_LoaderInterface $loader)
+ {
+ $this->loaders[] = $loader;
+ $this->hasSourceCache = array();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getSource($name)
+ {
+ $exceptions = array();
+ foreach ($this->loaders as $loader) {
+ if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) {
+ continue;
+ }
+
+ try {
+ return $loader->getSource($name);
+ } catch (Twig_Error_Loader $e) {
+ $exceptions[] = $e->getMessage();
+ }
+ }
+
+ throw new Twig_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : ''));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function exists($name)
+ {
+ $name = (string) $name;
+
+ if (isset($this->hasSourceCache[$name])) {
+ return $this->hasSourceCache[$name];
+ }
+
+ foreach ($this->loaders as $loader) {
+ if ($loader instanceof Twig_ExistsLoaderInterface) {
+ if ($loader->exists($name)) {
+ return $this->hasSourceCache[$name] = true;
+ }
+
+ continue;
+ }
+
+ try {
+ $loader->getSource($name);
+
+ return $this->hasSourceCache[$name] = true;
+ } catch (Twig_Error_Loader $e) {
+ }
+ }
+
+ return $this->hasSourceCache[$name] = false;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getCacheKey($name)
+ {
+ $exceptions = array();
+ foreach ($this->loaders as $loader) {
+ if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) {
+ continue;
+ }
+
+ try {
+ return $loader->getCacheKey($name);
+ } catch (Twig_Error_Loader $e) {
+ $exceptions[] = get_class($loader).': '.$e->getMessage();
+ }
+ }
+
+ throw new Twig_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : ''));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isFresh($name, $time)
+ {
+ $exceptions = array();
+ foreach ($this->loaders as $loader) {
+ if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) {
+ continue;
+ }
+
+ try {
+ return $loader->isFresh($name, $time);
+ } catch (Twig_Error_Loader $e) {
+ $exceptions[] = get_class($loader).': '.$e->getMessage();
+ }
+ }
+
+ throw new Twig_Error_Loader(sprintf('Template "%s" is not defined%s.', $name, $exceptions ? ' ('.implode(', ', $exceptions).')' : ''));
+ }
+}
diff --git a/Twig/Loader/Filesystem.php b/Twig/Loader/Filesystem.php
new file mode 100644
index 0000000..1bc75a1
--- /dev/null
+++ b/Twig/Loader/Filesystem.php
@@ -0,0 +1,260 @@
+
+ */
+class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderInterface
+{
+ /** Identifier of the main namespace. */
+ const MAIN_NAMESPACE = '__main__';
+
+ protected $paths = array();
+ protected $cache = array();
+ protected $errorCache = array();
+
+ /**
+ * Constructor.
+ *
+ * @param string|array $paths A path or an array of paths where to look for templates
+ */
+ public function __construct($paths = array())
+ {
+ if ($paths) {
+ $this->setPaths($paths);
+ }
+ }
+
+ /**
+ * Returns the paths to the templates.
+ *
+ * @param string $namespace A path namespace
+ *
+ * @return array The array of paths where to look for templates
+ */
+ public function getPaths($namespace = self::MAIN_NAMESPACE)
+ {
+ return isset($this->paths[$namespace]) ? $this->paths[$namespace] : array();
+ }
+
+ /**
+ * Returns the path namespaces.
+ *
+ * The main namespace is always defined.
+ *
+ * @return array The array of defined namespaces
+ */
+ public function getNamespaces()
+ {
+ return array_keys($this->paths);
+ }
+
+ /**
+ * Sets the paths where templates are stored.
+ *
+ * @param string|array $paths A path or an array of paths where to look for templates
+ * @param string $namespace A path namespace
+ */
+ public function setPaths($paths, $namespace = self::MAIN_NAMESPACE)
+ {
+ if (!is_array($paths)) {
+ $paths = array($paths);
+ }
+
+ $this->paths[$namespace] = array();
+ foreach ($paths as $path) {
+ $this->addPath($path, $namespace);
+ }
+ }
+
+ /**
+ * Adds a path where templates are stored.
+ *
+ * @param string $path A path where to look for templates
+ * @param string $namespace A path name
+ *
+ * @throws Twig_Error_Loader
+ */
+ public function addPath($path, $namespace = self::MAIN_NAMESPACE)
+ {
+ // invalidate the cache
+ $this->cache = $this->errorCache = array();
+
+ if (!is_dir($path)) {
+ throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist.', $path));
+ }
+
+ $this->paths[$namespace][] = rtrim($path, '/\\');
+ }
+
+ /**
+ * Prepends a path where templates are stored.
+ *
+ * @param string $path A path where to look for templates
+ * @param string $namespace A path name
+ *
+ * @throws Twig_Error_Loader
+ */
+ public function prependPath($path, $namespace = self::MAIN_NAMESPACE)
+ {
+ // invalidate the cache
+ $this->cache = $this->errorCache = array();
+
+ if (!is_dir($path)) {
+ throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist.', $path));
+ }
+
+ $path = rtrim($path, '/\\');
+
+ if (!isset($this->paths[$namespace])) {
+ $this->paths[$namespace][] = $path;
+ } else {
+ array_unshift($this->paths[$namespace], $path);
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getSource($name)
+ {
+ return file_get_contents($this->findTemplate($name));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getCacheKey($name)
+ {
+ return $this->findTemplate($name);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function exists($name)
+ {
+ $name = $this->normalizeName($name);
+
+ if (isset($this->cache[$name])) {
+ return true;
+ }
+
+ try {
+ return false !== $this->findTemplate($name, false);
+ } catch (Twig_Error_Loader $exception) {
+ return false;
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isFresh($name, $time)
+ {
+ return filemtime($this->findTemplate($name)) <= $time;
+ }
+
+ protected function findTemplate($name)
+ {
+ $throw = func_num_args() > 1 ? func_get_arg(1) : true;
+ $name = $this->normalizeName($name);
+
+ if (isset($this->cache[$name])) {
+ return $this->cache[$name];
+ }
+
+ if (isset($this->errorCache[$name])) {
+ if (!$throw) {
+ return false;
+ }
+
+ throw new Twig_Error_Loader($this->errorCache[$name]);
+ }
+
+ $this->validateName($name);
+
+ list($namespace, $shortname) = $this->parseName($name);
+
+ if (!isset($this->paths[$namespace])) {
+ $this->errorCache[$name] = sprintf('There are no registered paths for namespace "%s".', $namespace);
+
+ if (!$throw) {
+ return false;
+ }
+
+ throw new Twig_Error_Loader($this->errorCache[$name]);
+ }
+
+ foreach ($this->paths[$namespace] as $path) {
+ if (is_file($path.'/'.$shortname)) {
+ if (false !== $realpath = realpath($path.'/'.$shortname)) {
+ return $this->cache[$name] = $realpath;
+ }
+
+ return $this->cache[$name] = $path.'/'.$shortname;
+ }
+ }
+
+ $this->errorCache[$name] = sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $this->paths[$namespace]));
+
+ if (!$throw) {
+ return false;
+ }
+
+ throw new Twig_Error_Loader($this->errorCache[$name]);
+ }
+
+ protected function parseName($name, $default = self::MAIN_NAMESPACE)
+ {
+ if (isset($name[0]) && '@' == $name[0]) {
+ if (false === $pos = strpos($name, '/')) {
+ throw new Twig_Error_Loader(sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name));
+ }
+
+ $namespace = substr($name, 1, $pos - 1);
+ $shortname = substr($name, $pos + 1);
+
+ return array($namespace, $shortname);
+ }
+
+ return array($default, $name);
+ }
+
+ protected function normalizeName($name)
+ {
+ return preg_replace('#/{2,}#', '/', str_replace('\\', '/', (string) $name));
+ }
+
+ protected function validateName($name)
+ {
+ if (false !== strpos($name, "\0")) {
+ throw new Twig_Error_Loader('A template name cannot contain NUL bytes.');
+ }
+
+ $name = ltrim($name, '/');
+ $parts = explode('/', $name);
+ $level = 0;
+ foreach ($parts as $part) {
+ if ('..' === $part) {
+ --$level;
+ } elseif ('.' !== $part) {
+ ++$level;
+ }
+
+ if ($level < 0) {
+ throw new Twig_Error_Loader(sprintf('Looks like you try to load a template outside configured directories (%s).', $name));
+ }
+ }
+ }
+}
diff --git a/Twig/Loader/String.php b/Twig/Loader/String.php
new file mode 100644
index 0000000..00f507a
--- /dev/null
+++ b/Twig/Loader/String.php
@@ -0,0 +1,63 @@
+
+ */
+class Twig_Loader_String implements Twig_LoaderInterface, Twig_ExistsLoaderInterface
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function getSource($name)
+ {
+ return $name;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function exists($name)
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getCacheKey($name)
+ {
+ return $name;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isFresh($name, $time)
+ {
+ return true;
+ }
+}
diff --git a/Twig/LoaderInterface.php b/Twig/LoaderInterface.php
new file mode 100644
index 0000000..544ea4e
--- /dev/null
+++ b/Twig/LoaderInterface.php
@@ -0,0 +1,53 @@
+
+ */
+interface Twig_LoaderInterface
+{
+ /**
+ * Gets the source code of a template, given its name.
+ *
+ * @param string $name The name of the template to load
+ *
+ * @return string The template source code
+ *
+ * @throws Twig_Error_Loader When $name is not found
+ */
+ public function getSource($name);
+
+ /**
+ * Gets the cache key to use for the cache for a given template name.
+ *
+ * @param string $name The name of the template to load
+ *
+ * @return string The cache key
+ *
+ * @throws Twig_Error_Loader When $name is not found
+ */
+ public function getCacheKey($name);
+
+ /**
+ * Returns true if the template is still fresh.
+ *
+ * @param string $name The template name
+ * @param int $time Timestamp of the last modification time of the
+ * cached template
+ *
+ * @return bool true if the template is fresh, false otherwise
+ *
+ * @throws Twig_Error_Loader When $name is not found
+ */
+ public function isFresh($name, $time);
+}
diff --git a/Twig/Markup.php b/Twig/Markup.php
new file mode 100644
index 0000000..69871fc
--- /dev/null
+++ b/Twig/Markup.php
@@ -0,0 +1,37 @@
+
+ */
+class Twig_Markup implements Countable
+{
+ protected $content;
+ protected $charset;
+
+ public function __construct($content, $charset)
+ {
+ $this->content = (string) $content;
+ $this->charset = $charset;
+ }
+
+ public function __toString()
+ {
+ return $this->content;
+ }
+
+ public function count()
+ {
+ return function_exists('mb_get_info') ? mb_strlen($this->content, $this->charset) : strlen($this->content);
+ }
+}
diff --git a/Twig/Node.php b/Twig/Node.php
new file mode 100644
index 0000000..40d67fe
--- /dev/null
+++ b/Twig/Node.php
@@ -0,0 +1,231 @@
+
+ */
+class Twig_Node implements Twig_NodeInterface
+{
+ protected $nodes;
+ protected $attributes;
+ protected $lineno;
+ protected $tag;
+
+ /**
+ * Constructor.
+ *
+ * The nodes are automatically made available as properties ($this->node).
+ * The attributes are automatically made available as array items ($this['name']).
+ *
+ * @param array $nodes An array of named nodes
+ * @param array $attributes An array of attributes (should not be nodes)
+ * @param int $lineno The line number
+ * @param string $tag The tag name associated with the Node
+ */
+ public function __construct(array $nodes = array(), array $attributes = array(), $lineno = 0, $tag = null)
+ {
+ $this->nodes = $nodes;
+ $this->attributes = $attributes;
+ $this->lineno = $lineno;
+ $this->tag = $tag;
+ }
+
+ public function __toString()
+ {
+ $attributes = array();
+ foreach ($this->attributes as $name => $value) {
+ $attributes[] = sprintf('%s: %s', $name, str_replace("\n", '', var_export($value, true)));
+ }
+
+ $repr = array(get_class($this).'('.implode(', ', $attributes));
+
+ if (count($this->nodes)) {
+ foreach ($this->nodes as $name => $node) {
+ $len = strlen($name) + 4;
+ $noderepr = array();
+ foreach (explode("\n", (string) $node) as $line) {
+ $noderepr[] = str_repeat(' ', $len).$line;
+ }
+
+ $repr[] = sprintf(' %s: %s', $name, ltrim(implode("\n", $noderepr)));
+ }
+
+ $repr[] = ')';
+ } else {
+ $repr[0] .= ')';
+ }
+
+ return implode("\n", $repr);
+ }
+
+ /**
+ * @deprecated since 1.16.1 (to be removed in 2.0)
+ */
+ public function toXml($asDom = false)
+ {
+ @trigger_error(sprintf('%s is deprecated.', __METHOD__), E_USER_DEPRECATED);
+
+ $dom = new DOMDocument('1.0', 'UTF-8');
+ $dom->formatOutput = true;
+ $dom->appendChild($xml = $dom->createElement('twig'));
+
+ $xml->appendChild($node = $dom->createElement('node'));
+ $node->setAttribute('class', get_class($this));
+
+ foreach ($this->attributes as $name => $value) {
+ $node->appendChild($attribute = $dom->createElement('attribute'));
+ $attribute->setAttribute('name', $name);
+ $attribute->appendChild($dom->createTextNode($value));
+ }
+
+ foreach ($this->nodes as $name => $n) {
+ if (null === $n) {
+ continue;
+ }
+
+ $child = $n->toXml(true)->getElementsByTagName('node')->item(0);
+ $child = $dom->importNode($child, true);
+ $child->setAttribute('name', $name);
+
+ $node->appendChild($child);
+ }
+
+ return $asDom ? $dom : $dom->saveXml();
+ }
+
+ public function compile(Twig_Compiler $compiler)
+ {
+ foreach ($this->nodes as $node) {
+ $node->compile($compiler);
+ }
+ }
+
+ public function getLine()
+ {
+ return $this->lineno;
+ }
+
+ public function getNodeTag()
+ {
+ return $this->tag;
+ }
+
+ /**
+ * Returns true if the attribute is defined.
+ *
+ * @param string $name The attribute name
+ *
+ * @return bool true if the attribute is defined, false otherwise
+ */
+ public function hasAttribute($name)
+ {
+ return array_key_exists($name, $this->attributes);
+ }
+
+ /**
+ * Gets an attribute value by name.
+ *
+ * @param string $name
+ *
+ * @return mixed
+ */
+ public function getAttribute($name)
+ {
+ if (!array_key_exists($name, $this->attributes)) {
+ throw new LogicException(sprintf('Attribute "%s" does not exist for Node "%s".', $name, get_class($this)));
+ }
+
+ return $this->attributes[$name];
+ }
+
+ /**
+ * Sets an attribute by name to a value.
+ *
+ * @param string $name
+ * @param mixed $value
+ */
+ public function setAttribute($name, $value)
+ {
+ $this->attributes[$name] = $value;
+ }
+
+ /**
+ * Removes an attribute by name.
+ *
+ * @param string $name
+ */
+ public function removeAttribute($name)
+ {
+ unset($this->attributes[$name]);
+ }
+
+ /**
+ * Returns true if the node with the given name exists.
+ *
+ * @param string $name
+ *
+ * @return bool
+ */
+ public function hasNode($name)
+ {
+ return array_key_exists($name, $this->nodes);
+ }
+
+ /**
+ * Gets a node by name.
+ *
+ * @param string $name
+ *
+ * @return Twig_Node
+ */
+ public function getNode($name)
+ {
+ if (!array_key_exists($name, $this->nodes)) {
+ throw new LogicException(sprintf('Node "%s" does not exist for Node "%s".', $name, get_class($this)));
+ }
+
+ return $this->nodes[$name];
+ }
+
+ /**
+ * Sets a node.
+ *
+ * @param string $name
+ * @param Twig_Node $node
+ */
+ public function setNode($name, $node = null)
+ {
+ $this->nodes[$name] = $node;
+ }
+
+ /**
+ * Removes a node by name.
+ *
+ * @param string $name
+ */
+ public function removeNode($name)
+ {
+ unset($this->nodes[$name]);
+ }
+
+ public function count()
+ {
+ return count($this->nodes);
+ }
+
+ public function getIterator()
+ {
+ return new ArrayIterator($this->nodes);
+ }
+}
diff --git a/Twig/Node/AutoEscape.php b/Twig/Node/AutoEscape.php
new file mode 100644
index 0000000..fcabf90
--- /dev/null
+++ b/Twig/Node/AutoEscape.php
@@ -0,0 +1,39 @@
+
+ */
+class Twig_Node_AutoEscape extends Twig_Node
+{
+ public function __construct($value, Twig_NodeInterface $body, $lineno, $tag = 'autoescape')
+ {
+ parent::__construct(array('body' => $body), array('value' => $value), $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler->subcompile($this->getNode('body'));
+ }
+}
diff --git a/Twig/Node/Block.php b/Twig/Node/Block.php
new file mode 100644
index 0000000..989e4a0
--- /dev/null
+++ b/Twig/Node/Block.php
@@ -0,0 +1,44 @@
+
+ */
+class Twig_Node_Block extends Twig_Node
+{
+ public function __construct($name, Twig_NodeInterface $body, $lineno, $tag = null)
+ {
+ parent::__construct(array('body' => $body), array('name' => $name), $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->addDebugInfo($this)
+ ->write(sprintf("public function block_%s(\$context, array \$blocks = array())\n", $this->getAttribute('name')), "{\n")
+ ->indent()
+ ;
+
+ $compiler
+ ->subcompile($this->getNode('body'))
+ ->outdent()
+ ->write("}\n\n")
+ ;
+ }
+}
diff --git a/Twig/Node/BlockReference.php b/Twig/Node/BlockReference.php
new file mode 100644
index 0000000..a05ea04
--- /dev/null
+++ b/Twig/Node/BlockReference.php
@@ -0,0 +1,37 @@
+
+ */
+class Twig_Node_BlockReference extends Twig_Node implements Twig_NodeOutputInterface
+{
+ public function __construct($name, $lineno, $tag = null)
+ {
+ parent::__construct(array(), array('name' => $name), $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->addDebugInfo($this)
+ ->write(sprintf("\$this->displayBlock('%s', \$context, \$blocks);\n", $this->getAttribute('name')))
+ ;
+ }
+}
diff --git a/Twig/Node/Body.php b/Twig/Node/Body.php
new file mode 100644
index 0000000..3ffb134
--- /dev/null
+++ b/Twig/Node/Body.php
@@ -0,0 +1,19 @@
+
+ */
+class Twig_Node_Body extends Twig_Node
+{
+}
diff --git a/Twig/Node/CheckSecurity.php b/Twig/Node/CheckSecurity.php
new file mode 100644
index 0000000..b4a436a
--- /dev/null
+++ b/Twig/Node/CheckSecurity.php
@@ -0,0 +1,78 @@
+
+ */
+class Twig_Node_CheckSecurity extends Twig_Node
+{
+ protected $usedFilters;
+ protected $usedTags;
+ protected $usedFunctions;
+
+ public function __construct(array $usedFilters, array $usedTags, array $usedFunctions)
+ {
+ $this->usedFilters = $usedFilters;
+ $this->usedTags = $usedTags;
+ $this->usedFunctions = $usedFunctions;
+
+ parent::__construct();
+ }
+
+ public function compile(Twig_Compiler $compiler)
+ {
+ $tags = $filters = $functions = array();
+ foreach (array('tags', 'filters', 'functions') as $type) {
+ foreach ($this->{'used'.ucfirst($type)} as $name => $node) {
+ if ($node instanceof Twig_Node) {
+ ${$type}[$name] = $node->getLine();
+ } else {
+ ${$type}[$node] = null;
+ }
+ }
+ }
+
+ $compiler
+ ->write('$tags = ')->repr(array_filter($tags))->raw(";\n")
+ ->write('$filters = ')->repr(array_filter($filters))->raw(";\n")
+ ->write('$functions = ')->repr(array_filter($functions))->raw(";\n\n")
+ ->write("try {\n")
+ ->indent()
+ ->write("\$this->env->getExtension('sandbox')->checkSecurity(\n")
+ ->indent()
+ ->write(!$tags ? "array(),\n" : "array('".implode("', '", array_keys($tags))."'),\n")
+ ->write(!$filters ? "array(),\n" : "array('".implode("', '", array_keys($filters))."'),\n")
+ ->write(!$functions ? "array()\n" : "array('".implode("', '", array_keys($functions))."')\n")
+ ->outdent()
+ ->write(");\n")
+ ->outdent()
+ ->write("} catch (Twig_Sandbox_SecurityError \$e) {\n")
+ ->indent()
+ ->write("\$e->setTemplateFile(\$this->getTemplateName());\n\n")
+ ->write("if (\$e instanceof Twig_Sandbox_SecurityNotAllowedTagError && isset(\$tags[\$e->getTagName()])) {\n")
+ ->indent()
+ ->write("\$e->setTemplateLine(\$tags[\$e->getTagName()]);\n")
+ ->outdent()
+ ->write("} elseif (\$e instanceof Twig_Sandbox_SecurityNotAllowedFilterError && isset(\$filters[\$e->getFilterName()])) {\n")
+ ->indent()
+ ->write("\$e->setTemplateLine(\$filters[\$e->getFilterName()]);\n")
+ ->outdent()
+ ->write("} elseif (\$e instanceof Twig_Sandbox_SecurityNotAllowedFunctionError && isset(\$functions[\$e->getFunctionName()])) {\n")
+ ->indent()
+ ->write("\$e->setTemplateLine(\$functions[\$e->getFunctionName()]);\n")
+ ->outdent()
+ ->write("}\n\n")
+ ->write("throw \$e;\n")
+ ->outdent()
+ ->write("}\n\n")
+ ;
+ }
+}
diff --git a/Twig/Node/Do.php b/Twig/Node/Do.php
new file mode 100644
index 0000000..9981bc1
--- /dev/null
+++ b/Twig/Node/Do.php
@@ -0,0 +1,38 @@
+
+ */
+class Twig_Node_Do extends Twig_Node
+{
+ public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null)
+ {
+ parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->addDebugInfo($this)
+ ->write('')
+ ->subcompile($this->getNode('expr'))
+ ->raw(";\n")
+ ;
+ }
+}
diff --git a/Twig/Node/Embed.php b/Twig/Node/Embed.php
new file mode 100644
index 0000000..a213040
--- /dev/null
+++ b/Twig/Node/Embed.php
@@ -0,0 +1,42 @@
+
+ */
+class Twig_Node_Embed extends Twig_Node_Include
+{
+ // we don't inject the module to avoid node visitors to traverse it twice (as it will be already visited in the main module)
+ public function __construct($filename, $index, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null)
+ {
+ parent::__construct(new Twig_Node_Expression_Constant('not_used', $lineno), $variables, $only, $ignoreMissing, $lineno, $tag);
+
+ $this->setAttribute('filename', $filename);
+ $this->setAttribute('index', $index);
+ }
+
+ protected function addGetTemplate(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->write('$this->loadTemplate(')
+ ->string($this->getAttribute('filename'))
+ ->raw(', ')
+ ->repr($compiler->getFilename())
+ ->raw(', ')
+ ->repr($this->getLine())
+ ->raw(', ')
+ ->string($this->getAttribute('index'))
+ ->raw(')')
+ ;
+ }
+}
diff --git a/Twig/Node/Expression.php b/Twig/Node/Expression.php
new file mode 100644
index 0000000..a7382e7
--- /dev/null
+++ b/Twig/Node/Expression.php
@@ -0,0 +1,20 @@
+
+ */
+abstract class Twig_Node_Expression extends Twig_Node
+{
+}
diff --git a/Twig/Node/Expression/Array.php b/Twig/Node/Expression/Array.php
new file mode 100644
index 0000000..6cf7ca1
--- /dev/null
+++ b/Twig/Node/Expression/Array.php
@@ -0,0 +1,86 @@
+index = -1;
+ foreach ($this->getKeyValuePairs() as $pair) {
+ if ($pair['key'] instanceof Twig_Node_Expression_Constant && ctype_digit((string) $pair['key']->getAttribute('value')) && $pair['key']->getAttribute('value') > $this->index) {
+ $this->index = $pair['key']->getAttribute('value');
+ }
+ }
+ }
+
+ public function getKeyValuePairs()
+ {
+ $pairs = array();
+
+ foreach (array_chunk($this->nodes, 2) as $pair) {
+ $pairs[] = array(
+ 'key' => $pair[0],
+ 'value' => $pair[1],
+ );
+ }
+
+ return $pairs;
+ }
+
+ public function hasElement(Twig_Node_Expression $key)
+ {
+ foreach ($this->getKeyValuePairs() as $pair) {
+ // we compare the string representation of the keys
+ // to avoid comparing the line numbers which are not relevant here.
+ if ((string) $key == (string) $pair['key']) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public function addElement(Twig_Node_Expression $value, Twig_Node_Expression $key = null)
+ {
+ if (null === $key) {
+ $key = new Twig_Node_Expression_Constant(++$this->index, $value->getLine());
+ }
+
+ array_push($this->nodes, $key, $value);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler->raw('array(');
+ $first = true;
+ foreach ($this->getKeyValuePairs() as $pair) {
+ if (!$first) {
+ $compiler->raw(', ');
+ }
+ $first = false;
+
+ $compiler
+ ->subcompile($pair['key'])
+ ->raw(' => ')
+ ->subcompile($pair['value'])
+ ;
+ }
+ $compiler->raw(')');
+ }
+}
diff --git a/Twig/Node/Expression/AssignName.php b/Twig/Node/Expression/AssignName.php
new file mode 100644
index 0000000..4d5dbdb
--- /dev/null
+++ b/Twig/Node/Expression/AssignName.php
@@ -0,0 +1,28 @@
+raw('$context[')
+ ->string($this->getAttribute('name'))
+ ->raw(']')
+ ;
+ }
+}
diff --git a/Twig/Node/Expression/Binary.php b/Twig/Node/Expression/Binary.php
new file mode 100644
index 0000000..5c383d1
--- /dev/null
+++ b/Twig/Node/Expression/Binary.php
@@ -0,0 +1,40 @@
+ $left, 'right' => $right), array(), $lineno);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->raw('(')
+ ->subcompile($this->getNode('left'))
+ ->raw(' ')
+ ;
+ $this->operator($compiler);
+ $compiler
+ ->raw(' ')
+ ->subcompile($this->getNode('right'))
+ ->raw(')')
+ ;
+ }
+
+ abstract public function operator(Twig_Compiler $compiler);
+}
diff --git a/Twig/Node/Expression/Binary/Add.php b/Twig/Node/Expression/Binary/Add.php
new file mode 100644
index 0000000..0ef8e11
--- /dev/null
+++ b/Twig/Node/Expression/Binary/Add.php
@@ -0,0 +1,18 @@
+raw('+');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/And.php b/Twig/Node/Expression/Binary/And.php
new file mode 100644
index 0000000..d5752eb
--- /dev/null
+++ b/Twig/Node/Expression/Binary/And.php
@@ -0,0 +1,18 @@
+raw('&&');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/BitwiseAnd.php b/Twig/Node/Expression/Binary/BitwiseAnd.php
new file mode 100644
index 0000000..9a46d84
--- /dev/null
+++ b/Twig/Node/Expression/Binary/BitwiseAnd.php
@@ -0,0 +1,18 @@
+raw('&');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/BitwiseOr.php b/Twig/Node/Expression/Binary/BitwiseOr.php
new file mode 100644
index 0000000..058a20b
--- /dev/null
+++ b/Twig/Node/Expression/Binary/BitwiseOr.php
@@ -0,0 +1,18 @@
+raw('|');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/BitwiseXor.php b/Twig/Node/Expression/Binary/BitwiseXor.php
new file mode 100644
index 0000000..f4da73d
--- /dev/null
+++ b/Twig/Node/Expression/Binary/BitwiseXor.php
@@ -0,0 +1,18 @@
+raw('^');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/Concat.php b/Twig/Node/Expression/Binary/Concat.php
new file mode 100644
index 0000000..f9a6462
--- /dev/null
+++ b/Twig/Node/Expression/Binary/Concat.php
@@ -0,0 +1,18 @@
+raw('.');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/Div.php b/Twig/Node/Expression/Binary/Div.php
new file mode 100644
index 0000000..e0797a6
--- /dev/null
+++ b/Twig/Node/Expression/Binary/Div.php
@@ -0,0 +1,18 @@
+raw('/');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/EndsWith.php b/Twig/Node/Expression/Binary/EndsWith.php
new file mode 100644
index 0000000..93b3b96
--- /dev/null
+++ b/Twig/Node/Expression/Binary/EndsWith.php
@@ -0,0 +1,30 @@
+getVarName();
+ $right = $compiler->getVarName();
+ $compiler
+ ->raw(sprintf('(is_string($%s = ', $left))
+ ->subcompile($this->getNode('left'))
+ ->raw(sprintf(') && is_string($%s = ', $right))
+ ->subcompile($this->getNode('right'))
+ ->raw(sprintf(') && (\'\' === $%2$s || $%2$s === substr($%1$s, -strlen($%2$s))))', $left, $right))
+ ;
+ }
+
+ public function operator(Twig_Compiler $compiler)
+ {
+ return $compiler->raw('');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/Equal.php b/Twig/Node/Expression/Binary/Equal.php
new file mode 100644
index 0000000..7b1236d
--- /dev/null
+++ b/Twig/Node/Expression/Binary/Equal.php
@@ -0,0 +1,17 @@
+raw('==');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/FloorDiv.php b/Twig/Node/Expression/Binary/FloorDiv.php
new file mode 100644
index 0000000..d3518b5
--- /dev/null
+++ b/Twig/Node/Expression/Binary/FloorDiv.php
@@ -0,0 +1,29 @@
+raw('intval(floor(');
+ parent::compile($compiler);
+ $compiler->raw('))');
+ }
+
+ public function operator(Twig_Compiler $compiler)
+ {
+ return $compiler->raw('/');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/Greater.php b/Twig/Node/Expression/Binary/Greater.php
new file mode 100644
index 0000000..a110bd9
--- /dev/null
+++ b/Twig/Node/Expression/Binary/Greater.php
@@ -0,0 +1,17 @@
+raw('>');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/GreaterEqual.php b/Twig/Node/Expression/Binary/GreaterEqual.php
new file mode 100644
index 0000000..3754fed
--- /dev/null
+++ b/Twig/Node/Expression/Binary/GreaterEqual.php
@@ -0,0 +1,17 @@
+raw('>=');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/In.php b/Twig/Node/Expression/Binary/In.php
new file mode 100644
index 0000000..1d485b6
--- /dev/null
+++ b/Twig/Node/Expression/Binary/In.php
@@ -0,0 +1,33 @@
+raw('twig_in_filter(')
+ ->subcompile($this->getNode('left'))
+ ->raw(', ')
+ ->subcompile($this->getNode('right'))
+ ->raw(')')
+ ;
+ }
+
+ public function operator(Twig_Compiler $compiler)
+ {
+ return $compiler->raw('in');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/Less.php b/Twig/Node/Expression/Binary/Less.php
new file mode 100644
index 0000000..45fd300
--- /dev/null
+++ b/Twig/Node/Expression/Binary/Less.php
@@ -0,0 +1,17 @@
+raw('<');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/LessEqual.php b/Twig/Node/Expression/Binary/LessEqual.php
new file mode 100644
index 0000000..e38e257
--- /dev/null
+++ b/Twig/Node/Expression/Binary/LessEqual.php
@@ -0,0 +1,17 @@
+raw('<=');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/Matches.php b/Twig/Node/Expression/Binary/Matches.php
new file mode 100644
index 0000000..93bb292
--- /dev/null
+++ b/Twig/Node/Expression/Binary/Matches.php
@@ -0,0 +1,28 @@
+raw('preg_match(')
+ ->subcompile($this->getNode('right'))
+ ->raw(', ')
+ ->subcompile($this->getNode('left'))
+ ->raw(')')
+ ;
+ }
+
+ public function operator(Twig_Compiler $compiler)
+ {
+ return $compiler->raw('');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/Mod.php b/Twig/Node/Expression/Binary/Mod.php
new file mode 100644
index 0000000..9924114
--- /dev/null
+++ b/Twig/Node/Expression/Binary/Mod.php
@@ -0,0 +1,18 @@
+raw('%');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/Mul.php b/Twig/Node/Expression/Binary/Mul.php
new file mode 100644
index 0000000..c91529c
--- /dev/null
+++ b/Twig/Node/Expression/Binary/Mul.php
@@ -0,0 +1,18 @@
+raw('*');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/NotEqual.php b/Twig/Node/Expression/Binary/NotEqual.php
new file mode 100644
index 0000000..26867ba
--- /dev/null
+++ b/Twig/Node/Expression/Binary/NotEqual.php
@@ -0,0 +1,17 @@
+raw('!=');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/NotIn.php b/Twig/Node/Expression/Binary/NotIn.php
new file mode 100644
index 0000000..8f215f1
--- /dev/null
+++ b/Twig/Node/Expression/Binary/NotIn.php
@@ -0,0 +1,33 @@
+raw('!twig_in_filter(')
+ ->subcompile($this->getNode('left'))
+ ->raw(', ')
+ ->subcompile($this->getNode('right'))
+ ->raw(')')
+ ;
+ }
+
+ public function operator(Twig_Compiler $compiler)
+ {
+ return $compiler->raw('not in');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/Or.php b/Twig/Node/Expression/Binary/Or.php
new file mode 100644
index 0000000..adba49c
--- /dev/null
+++ b/Twig/Node/Expression/Binary/Or.php
@@ -0,0 +1,18 @@
+raw('||');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/Power.php b/Twig/Node/Expression/Binary/Power.php
new file mode 100644
index 0000000..6cd3a21
--- /dev/null
+++ b/Twig/Node/Expression/Binary/Power.php
@@ -0,0 +1,33 @@
+raw('pow(')
+ ->subcompile($this->getNode('left'))
+ ->raw(', ')
+ ->subcompile($this->getNode('right'))
+ ->raw(')')
+ ;
+ }
+
+ public function operator(Twig_Compiler $compiler)
+ {
+ return $compiler->raw('**');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/Range.php b/Twig/Node/Expression/Binary/Range.php
new file mode 100644
index 0000000..fc102fe
--- /dev/null
+++ b/Twig/Node/Expression/Binary/Range.php
@@ -0,0 +1,33 @@
+raw('range(')
+ ->subcompile($this->getNode('left'))
+ ->raw(', ')
+ ->subcompile($this->getNode('right'))
+ ->raw(')')
+ ;
+ }
+
+ public function operator(Twig_Compiler $compiler)
+ {
+ return $compiler->raw('..');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/StartsWith.php b/Twig/Node/Expression/Binary/StartsWith.php
new file mode 100644
index 0000000..d2e30d6
--- /dev/null
+++ b/Twig/Node/Expression/Binary/StartsWith.php
@@ -0,0 +1,30 @@
+getVarName();
+ $right = $compiler->getVarName();
+ $compiler
+ ->raw(sprintf('(is_string($%s = ', $left))
+ ->subcompile($this->getNode('left'))
+ ->raw(sprintf(') && is_string($%s = ', $right))
+ ->subcompile($this->getNode('right'))
+ ->raw(sprintf(') && (\'\' === $%2$s || 0 === strpos($%1$s, $%2$s)))', $left, $right))
+ ;
+ }
+
+ public function operator(Twig_Compiler $compiler)
+ {
+ return $compiler->raw('');
+ }
+}
diff --git a/Twig/Node/Expression/Binary/Sub.php b/Twig/Node/Expression/Binary/Sub.php
new file mode 100644
index 0000000..d446399
--- /dev/null
+++ b/Twig/Node/Expression/Binary/Sub.php
@@ -0,0 +1,18 @@
+raw('-');
+ }
+}
diff --git a/Twig/Node/Expression/BlockReference.php b/Twig/Node/Expression/BlockReference.php
new file mode 100644
index 0000000..c25aadd
--- /dev/null
+++ b/Twig/Node/Expression/BlockReference.php
@@ -0,0 +1,51 @@
+
+ */
+class Twig_Node_Expression_BlockReference extends Twig_Node_Expression
+{
+ public function __construct(Twig_NodeInterface $name, $asString = false, $lineno, $tag = null)
+ {
+ parent::__construct(array('name' => $name), array('as_string' => $asString, 'output' => false), $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ if ($this->getAttribute('as_string')) {
+ $compiler->raw('(string) ');
+ }
+
+ if ($this->getAttribute('output')) {
+ $compiler
+ ->addDebugInfo($this)
+ ->write('$this->displayBlock(')
+ ->subcompile($this->getNode('name'))
+ ->raw(", \$context, \$blocks);\n")
+ ;
+ } else {
+ $compiler
+ ->raw('$this->renderBlock(')
+ ->subcompile($this->getNode('name'))
+ ->raw(', $context, $blocks)')
+ ;
+ }
+ }
+}
diff --git a/Twig/Node/Expression/Call.php b/Twig/Node/Expression/Call.php
new file mode 100644
index 0000000..51e2cac
--- /dev/null
+++ b/Twig/Node/Expression/Call.php
@@ -0,0 +1,247 @@
+hasAttribute('callable') && $callable = $this->getAttribute('callable')) {
+ if (is_string($callable)) {
+ $compiler->raw($callable);
+ } elseif (is_array($callable) && $callable[0] instanceof Twig_ExtensionInterface) {
+ $compiler->raw(sprintf('$this->env->getExtension(\'%s\')->%s', $callable[0]->getName(), $callable[1]));
+ } else {
+ $type = ucfirst($this->getAttribute('type'));
+ $compiler->raw(sprintf('call_user_func_array($this->env->get%s(\'%s\')->getCallable(), array', $type, $this->getAttribute('name')));
+ $closingParenthesis = true;
+ }
+ } else {
+ $compiler->raw($this->getAttribute('thing')->compile());
+ }
+
+ $this->compileArguments($compiler);
+
+ if ($closingParenthesis) {
+ $compiler->raw(')');
+ }
+ }
+
+ protected function compileArguments(Twig_Compiler $compiler)
+ {
+ $compiler->raw('(');
+
+ $first = true;
+
+ if ($this->hasAttribute('needs_environment') && $this->getAttribute('needs_environment')) {
+ $compiler->raw('$this->env');
+ $first = false;
+ }
+
+ if ($this->hasAttribute('needs_context') && $this->getAttribute('needs_context')) {
+ if (!$first) {
+ $compiler->raw(', ');
+ }
+ $compiler->raw('$context');
+ $first = false;
+ }
+
+ if ($this->hasAttribute('arguments')) {
+ foreach ($this->getAttribute('arguments') as $argument) {
+ if (!$first) {
+ $compiler->raw(', ');
+ }
+ $compiler->string($argument);
+ $first = false;
+ }
+ }
+
+ if ($this->hasNode('node')) {
+ if (!$first) {
+ $compiler->raw(', ');
+ }
+ $compiler->subcompile($this->getNode('node'));
+ $first = false;
+ }
+
+ if ($this->hasNode('arguments') && null !== $this->getNode('arguments')) {
+ $callable = $this->hasAttribute('callable') ? $this->getAttribute('callable') : null;
+
+ $arguments = $this->getArguments($callable, $this->getNode('arguments'));
+
+ foreach ($arguments as $node) {
+ if (!$first) {
+ $compiler->raw(', ');
+ }
+ $compiler->subcompile($node);
+ $first = false;
+ }
+ }
+
+ $compiler->raw(')');
+ }
+
+ protected function getArguments($callable, $arguments)
+ {
+ $callType = $this->getAttribute('type');
+ $callName = $this->getAttribute('name');
+
+ $parameters = array();
+ $named = false;
+ foreach ($arguments as $name => $node) {
+ if (!is_int($name)) {
+ $named = true;
+ $name = $this->normalizeName($name);
+ } elseif ($named) {
+ throw new Twig_Error_Syntax(sprintf('Positional arguments cannot be used after named arguments for %s "%s".', $callType, $callName));
+ }
+
+ $parameters[$name] = $node;
+ }
+
+ $isVariadic = $this->hasAttribute('is_variadic') && $this->getAttribute('is_variadic');
+ if (!$named && !$isVariadic) {
+ return $parameters;
+ }
+
+ if (!$callable) {
+ if ($named) {
+ $message = sprintf('Named arguments are not supported for %s "%s".', $callType, $callName);
+ } else {
+ $message = sprintf('Arbitrary positional arguments are not supported for %s "%s".', $callType, $callName);
+ }
+
+ throw new LogicException($message);
+ }
+
+ // manage named arguments
+ if (is_array($callable)) {
+ $r = new ReflectionMethod($callable[0], $callable[1]);
+ } elseif (is_object($callable) && !$callable instanceof Closure) {
+ $r = new ReflectionObject($callable);
+ $r = $r->getMethod('__invoke');
+ } elseif (is_string($callable) && false !== strpos($callable, '::')) {
+ $r = new ReflectionMethod($callable);
+ } else {
+ $r = new ReflectionFunction($callable);
+ }
+
+ $definition = $r->getParameters();
+ if ($this->hasNode('node')) {
+ array_shift($definition);
+ }
+ if ($this->hasAttribute('needs_environment') && $this->getAttribute('needs_environment')) {
+ array_shift($definition);
+ }
+ if ($this->hasAttribute('needs_context') && $this->getAttribute('needs_context')) {
+ array_shift($definition);
+ }
+ if ($this->hasAttribute('arguments') && null !== $this->getAttribute('arguments')) {
+ foreach ($this->getAttribute('arguments') as $argument) {
+ array_shift($definition);
+ }
+ }
+ if ($isVariadic) {
+ $argument = end($definition);
+ if ($argument && $argument->isArray() && $argument->isDefaultValueAvailable() && array() === $argument->getDefaultValue()) {
+ array_pop($definition);
+ } else {
+ $callableName = $r->name;
+ if ($r->getDeclaringClass()) {
+ $callableName = $r->getDeclaringClass()->name.'::'.$callableName;
+ }
+
+ throw new LogicException(sprintf('The last parameter of "%s" for %s "%s" must be an array with default value, eg. "array $arg = array()".', $callableName, $callType, $callName));
+ }
+ }
+
+ $arguments = array();
+ $names = array();
+ $missingArguments = array();
+ $optionalArguments = array();
+ $pos = 0;
+ foreach ($definition as $param) {
+ $names[] = $name = $this->normalizeName($param->name);
+
+ if (array_key_exists($name, $parameters)) {
+ if (array_key_exists($pos, $parameters)) {
+ throw new Twig_Error_Syntax(sprintf('Argument "%s" is defined twice for %s "%s".', $name, $callType, $callName));
+ }
+
+ if (!empty($missingArguments)) {
+ throw new Twig_Error_Syntax(sprintf(
+ 'Argument "%s" could not be assigned for %s "%s(%s)" because it is mapped to an internal PHP function which cannot determine default value for optional argument%s "%s".',
+ $name, $callType, $callName, implode(', ', $names), count($missingArguments) > 1 ? 's' : '', implode('", "', $missingArguments))
+ );
+ }
+
+ $arguments = array_merge($arguments, $optionalArguments);
+ $arguments[] = $parameters[$name];
+ unset($parameters[$name]);
+ $optionalArguments = array();
+ } elseif (array_key_exists($pos, $parameters)) {
+ $arguments = array_merge($arguments, $optionalArguments);
+ $arguments[] = $parameters[$pos];
+ unset($parameters[$pos]);
+ $optionalArguments = array();
+ ++$pos;
+ } elseif ($param->isDefaultValueAvailable()) {
+ $optionalArguments[] = new Twig_Node_Expression_Constant($param->getDefaultValue(), -1);
+ } elseif ($param->isOptional()) {
+ if (empty($parameters)) {
+ break;
+ } else {
+ $missingArguments[] = $name;
+ }
+ } else {
+ throw new Twig_Error_Syntax(sprintf('Value for argument "%s" is required for %s "%s".', $name, $callType, $callName));
+ }
+ }
+
+ if ($isVariadic) {
+ $arbitraryArguments = new Twig_Node_Expression_Array(array(), -1);
+ foreach ($parameters as $key => $value) {
+ if (is_int($key)) {
+ $arbitraryArguments->addElement($value);
+ } else {
+ $arbitraryArguments->addElement($value, new Twig_Node_Expression_Constant($key, -1));
+ }
+ unset($parameters[$key]);
+ }
+
+ if ($arbitraryArguments->count()) {
+ $arguments = array_merge($arguments, $optionalArguments);
+ $arguments[] = $arbitraryArguments;
+ }
+ }
+
+ if (!empty($parameters)) {
+ $unknownParameter = null;
+ foreach ($parameters as $parameter) {
+ if ($parameter instanceof Twig_Node) {
+ $unknownParameter = $parameter;
+ break;
+ }
+ }
+
+ throw new Twig_Error_Syntax(sprintf(
+ 'Unknown argument%s "%s" for %s "%s(%s)".',
+ count($parameters) > 1 ? 's' : '', implode('", "', array_keys($parameters)), $callType, $callName, implode(', ', $names)
+ ), $unknownParameter ? $unknownParameter->getLine() : -1);
+ }
+
+ return $arguments;
+ }
+
+ protected function normalizeName($name)
+ {
+ return strtolower(preg_replace(array('/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'), array('\\1_\\2', '\\1_\\2'), $name));
+ }
+}
diff --git a/Twig/Node/Expression/Conditional.php b/Twig/Node/Expression/Conditional.php
new file mode 100644
index 0000000..edcb1e2
--- /dev/null
+++ b/Twig/Node/Expression/Conditional.php
@@ -0,0 +1,31 @@
+ $expr1, 'expr2' => $expr2, 'expr3' => $expr3), array(), $lineno);
+ }
+
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->raw('((')
+ ->subcompile($this->getNode('expr1'))
+ ->raw(') ? (')
+ ->subcompile($this->getNode('expr2'))
+ ->raw(') : (')
+ ->subcompile($this->getNode('expr3'))
+ ->raw('))')
+ ;
+ }
+}
diff --git a/Twig/Node/Expression/Constant.php b/Twig/Node/Expression/Constant.php
new file mode 100644
index 0000000..a91dc69
--- /dev/null
+++ b/Twig/Node/Expression/Constant.php
@@ -0,0 +1,23 @@
+ $value), $lineno);
+ }
+
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler->repr($this->getAttribute('value'));
+ }
+}
diff --git a/Twig/Node/Expression/ExtensionReference.php b/Twig/Node/Expression/ExtensionReference.php
new file mode 100644
index 0000000..db06abb
--- /dev/null
+++ b/Twig/Node/Expression/ExtensionReference.php
@@ -0,0 +1,33 @@
+
+ */
+class Twig_Node_Expression_ExtensionReference extends Twig_Node_Expression
+{
+ public function __construct($name, $lineno, $tag = null)
+ {
+ parent::__construct(array(), array('name' => $name), $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler->raw(sprintf("\$this->env->getExtension('%s')", $this->getAttribute('name')));
+ }
+}
diff --git a/Twig/Node/Expression/Filter.php b/Twig/Node/Expression/Filter.php
new file mode 100644
index 0000000..a906232
--- /dev/null
+++ b/Twig/Node/Expression/Filter.php
@@ -0,0 +1,39 @@
+ $node, 'filter' => $filterName, 'arguments' => $arguments), array(), $lineno, $tag);
+ }
+
+ public function compile(Twig_Compiler $compiler)
+ {
+ $name = $this->getNode('filter')->getAttribute('value');
+ $filter = $compiler->getEnvironment()->getFilter($name);
+
+ $this->setAttribute('name', $name);
+ $this->setAttribute('type', 'filter');
+ $this->setAttribute('thing', $filter);
+ $this->setAttribute('needs_environment', $filter->needsEnvironment());
+ $this->setAttribute('needs_context', $filter->needsContext());
+ $this->setAttribute('arguments', $filter->getArguments());
+ if ($filter instanceof Twig_FilterCallableInterface || $filter instanceof Twig_SimpleFilter) {
+ $this->setAttribute('callable', $filter->getCallable());
+ }
+ if ($filter instanceof Twig_SimpleFilter) {
+ $this->setAttribute('is_variadic', $filter->isVariadic());
+ }
+
+ $this->compileCallable($compiler);
+ }
+}
diff --git a/Twig/Node/Expression/Filter/Default.php b/Twig/Node/Expression/Filter/Default.php
new file mode 100644
index 0000000..1827c88
--- /dev/null
+++ b/Twig/Node/Expression/Filter/Default.php
@@ -0,0 +1,43 @@
+
+ * {{ var.foo|default('foo item on var is not defined') }}
+ *
+ *
+ * @author Fabien Potencier
+ */
+class Twig_Node_Expression_Filter_Default extends Twig_Node_Expression_Filter
+{
+ public function __construct(Twig_NodeInterface $node, Twig_Node_Expression_Constant $filterName, Twig_NodeInterface $arguments, $lineno, $tag = null)
+ {
+ $default = new Twig_Node_Expression_Filter($node, new Twig_Node_Expression_Constant('default', $node->getLine()), $arguments, $node->getLine());
+
+ if ('default' === $filterName->getAttribute('value') && ($node instanceof Twig_Node_Expression_Name || $node instanceof Twig_Node_Expression_GetAttr)) {
+ $test = new Twig_Node_Expression_Test_Defined(clone $node, 'defined', new Twig_Node(), $node->getLine());
+ $false = count($arguments) ? $arguments->getNode(0) : new Twig_Node_Expression_Constant('', $node->getLine());
+
+ $node = new Twig_Node_Expression_Conditional($test, $default, $false, $node->getLine());
+ } else {
+ $node = $default;
+ }
+
+ parent::__construct($node, $filterName, $arguments, $lineno, $tag);
+ }
+
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler->subcompile($this->getNode('node'));
+ }
+}
diff --git a/Twig/Node/Expression/Function.php b/Twig/Node/Expression/Function.php
new file mode 100644
index 0000000..7326ede
--- /dev/null
+++ b/Twig/Node/Expression/Function.php
@@ -0,0 +1,38 @@
+ $arguments), array('name' => $name), $lineno);
+ }
+
+ public function compile(Twig_Compiler $compiler)
+ {
+ $name = $this->getAttribute('name');
+ $function = $compiler->getEnvironment()->getFunction($name);
+
+ $this->setAttribute('name', $name);
+ $this->setAttribute('type', 'function');
+ $this->setAttribute('thing', $function);
+ $this->setAttribute('needs_environment', $function->needsEnvironment());
+ $this->setAttribute('needs_context', $function->needsContext());
+ $this->setAttribute('arguments', $function->getArguments());
+ if ($function instanceof Twig_FunctionCallableInterface || $function instanceof Twig_SimpleFunction) {
+ $this->setAttribute('callable', $function->getCallable());
+ }
+ if ($function instanceof Twig_SimpleFunction) {
+ $this->setAttribute('is_variadic', $function->isVariadic());
+ }
+
+ $this->compileCallable($compiler);
+ }
+}
diff --git a/Twig/Node/Expression/GetAttr.php b/Twig/Node/Expression/GetAttr.php
new file mode 100644
index 0000000..6ce6111
--- /dev/null
+++ b/Twig/Node/Expression/GetAttr.php
@@ -0,0 +1,63 @@
+ $node, 'attribute' => $attribute, 'arguments' => $arguments), array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'disable_c_ext' => false), $lineno);
+ }
+
+ public function compile(Twig_Compiler $compiler)
+ {
+ if (function_exists('twig_template_get_attributes') && !$this->getAttribute('disable_c_ext')) {
+ $compiler->raw('twig_template_get_attributes($this, ');
+ } else {
+ $compiler->raw('$this->getAttribute(');
+ }
+
+ if ($this->getAttribute('ignore_strict_check')) {
+ $this->getNode('node')->setAttribute('ignore_strict_check', true);
+ }
+
+ $compiler->subcompile($this->getNode('node'));
+
+ $compiler->raw(', ')->subcompile($this->getNode('attribute'));
+
+ // only generate optional arguments when needed (to make generated code more readable)
+ $needFourth = $this->getAttribute('ignore_strict_check');
+ $needThird = $needFourth || $this->getAttribute('is_defined_test');
+ $needSecond = $needThird || Twig_Template::ANY_CALL !== $this->getAttribute('type');
+ $needFirst = $needSecond || null !== $this->getNode('arguments');
+
+ if ($needFirst) {
+ if (null !== $this->getNode('arguments')) {
+ $compiler->raw(', ')->subcompile($this->getNode('arguments'));
+ } else {
+ $compiler->raw(', array()');
+ }
+ }
+
+ if ($needSecond) {
+ $compiler->raw(', ')->repr($this->getAttribute('type'));
+ }
+
+ if ($needThird) {
+ $compiler->raw(', ')->repr($this->getAttribute('is_defined_test'));
+ }
+
+ if ($needFourth) {
+ $compiler->raw(', ')->repr($this->getAttribute('ignore_strict_check'));
+ }
+
+ $compiler->raw(')');
+ }
+}
diff --git a/Twig/Node/Expression/MethodCall.php b/Twig/Node/Expression/MethodCall.php
new file mode 100644
index 0000000..620b02b
--- /dev/null
+++ b/Twig/Node/Expression/MethodCall.php
@@ -0,0 +1,41 @@
+ $node, 'arguments' => $arguments), array('method' => $method, 'safe' => false), $lineno);
+
+ if ($node instanceof Twig_Node_Expression_Name) {
+ $node->setAttribute('always_defined', true);
+ }
+ }
+
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->subcompile($this->getNode('node'))
+ ->raw('->')
+ ->raw($this->getAttribute('method'))
+ ->raw('(')
+ ;
+ $first = true;
+ foreach ($this->getNode('arguments')->getKeyValuePairs() as $pair) {
+ if (!$first) {
+ $compiler->raw(', ');
+ }
+ $first = false;
+
+ $compiler->subcompile($pair['value']);
+ }
+ $compiler->raw(')');
+ }
+}
diff --git a/Twig/Node/Expression/Name.php b/Twig/Node/Expression/Name.php
new file mode 100644
index 0000000..c062a21
--- /dev/null
+++ b/Twig/Node/Expression/Name.php
@@ -0,0 +1,98 @@
+ '$this',
+ '_context' => '$context',
+ '_charset' => '$this->env->getCharset()',
+ );
+
+ public function __construct($name, $lineno)
+ {
+ parent::__construct(array(), array('name' => $name, 'is_defined_test' => false, 'ignore_strict_check' => false, 'always_defined' => false), $lineno);
+ }
+
+ public function compile(Twig_Compiler $compiler)
+ {
+ $name = $this->getAttribute('name');
+
+ $compiler->addDebugInfo($this);
+
+ if ($this->getAttribute('is_defined_test')) {
+ if ($this->isSpecial()) {
+ if ('_self' === $name) {
+ @trigger_error(sprintf('Global variable "_self" is deprecated in %s at line %d', '?', $this->getLine()), E_USER_DEPRECATED);
+ }
+
+ $compiler->repr(true);
+ } else {
+ $compiler->raw('array_key_exists(')->repr($name)->raw(', $context)');
+ }
+ } elseif ($this->isSpecial()) {
+ if ('_self' === $name) {
+ @trigger_error(sprintf('Global variable "_self" is deprecated in %s at line %d', '?', $this->getLine()), E_USER_DEPRECATED);
+ }
+
+ $compiler->raw($this->specialVars[$name]);
+ } elseif ($this->getAttribute('always_defined')) {
+ $compiler
+ ->raw('$context[')
+ ->string($name)
+ ->raw(']')
+ ;
+ } else {
+ // remove the non-PHP 5.4 version when PHP 5.3 support is dropped
+ // as the non-optimized version is just a workaround for slow ternary operator
+ // when the context has a lot of variables
+ if (PHP_VERSION_ID >= 50400) {
+ // PHP 5.4 ternary operator performance was optimized
+ $compiler
+ ->raw('(isset($context[')
+ ->string($name)
+ ->raw(']) ? $context[')
+ ->string($name)
+ ->raw('] : ')
+ ;
+
+ if ($this->getAttribute('ignore_strict_check') || !$compiler->getEnvironment()->isStrictVariables()) {
+ $compiler->raw('null)');
+ } else {
+ $compiler->raw('$this->getContext($context, ')->string($name)->raw('))');
+ }
+ } else {
+ $compiler
+ ->raw('$this->getContext($context, ')
+ ->string($name)
+ ;
+
+ if ($this->getAttribute('ignore_strict_check')) {
+ $compiler->raw(', true');
+ }
+
+ $compiler
+ ->raw(')')
+ ;
+ }
+ }
+ }
+
+ public function isSpecial()
+ {
+ return isset($this->specialVars[$this->getAttribute('name')]);
+ }
+
+ public function isSimple()
+ {
+ return !$this->isSpecial() && !$this->getAttribute('is_defined_test');
+ }
+}
diff --git a/Twig/Node/Expression/Parent.php b/Twig/Node/Expression/Parent.php
new file mode 100644
index 0000000..bd5024b
--- /dev/null
+++ b/Twig/Node/Expression/Parent.php
@@ -0,0 +1,47 @@
+
+ */
+class Twig_Node_Expression_Parent extends Twig_Node_Expression
+{
+ public function __construct($name, $lineno, $tag = null)
+ {
+ parent::__construct(array(), array('output' => false, 'name' => $name), $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ if ($this->getAttribute('output')) {
+ $compiler
+ ->addDebugInfo($this)
+ ->write('$this->displayParentBlock(')
+ ->string($this->getAttribute('name'))
+ ->raw(", \$context, \$blocks);\n")
+ ;
+ } else {
+ $compiler
+ ->raw('$this->renderParentBlock(')
+ ->string($this->getAttribute('name'))
+ ->raw(', $context, $blocks)')
+ ;
+ }
+ }
+}
diff --git a/Twig/Node/Expression/TempName.php b/Twig/Node/Expression/TempName.php
new file mode 100644
index 0000000..e6b058e
--- /dev/null
+++ b/Twig/Node/Expression/TempName.php
@@ -0,0 +1,26 @@
+ $name), $lineno);
+ }
+
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->raw('$_')
+ ->raw($this->getAttribute('name'))
+ ->raw('_')
+ ;
+ }
+}
diff --git a/Twig/Node/Expression/Test.php b/Twig/Node/Expression/Test.php
new file mode 100644
index 0000000..c0358c8
--- /dev/null
+++ b/Twig/Node/Expression/Test.php
@@ -0,0 +1,35 @@
+ $node, 'arguments' => $arguments), array('name' => $name), $lineno);
+ }
+
+ public function compile(Twig_Compiler $compiler)
+ {
+ $name = $this->getAttribute('name');
+ $test = $compiler->getEnvironment()->getTest($name);
+
+ $this->setAttribute('name', $name);
+ $this->setAttribute('type', 'test');
+ $this->setAttribute('thing', $test);
+ if ($test instanceof Twig_TestCallableInterface || $test instanceof Twig_SimpleTest) {
+ $this->setAttribute('callable', $test->getCallable());
+ }
+ if ($test instanceof Twig_SimpleTest) {
+ $this->setAttribute('is_variadic', $test->isVariadic());
+ }
+
+ $this->compileCallable($compiler);
+ }
+}
diff --git a/Twig/Node/Expression/Test/Constant.php b/Twig/Node/Expression/Test/Constant.php
new file mode 100644
index 0000000..de55f5f
--- /dev/null
+++ b/Twig/Node/Expression/Test/Constant.php
@@ -0,0 +1,46 @@
+
+ * {% if post.status is constant('Post::PUBLISHED') %}
+ * the status attribute is exactly the same as Post::PUBLISHED
+ * {% endif %}
+ *
+ *
+ * @author Fabien Potencier
+ */
+class Twig_Node_Expression_Test_Constant extends Twig_Node_Expression_Test
+{
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->raw('(')
+ ->subcompile($this->getNode('node'))
+ ->raw(' === constant(')
+ ;
+
+ if ($this->getNode('arguments')->hasNode(1)) {
+ $compiler
+ ->raw('get_class(')
+ ->subcompile($this->getNode('arguments')->getNode(1))
+ ->raw(')."::".')
+ ;
+ }
+
+ $compiler
+ ->subcompile($this->getNode('arguments')->getNode(0))
+ ->raw('))')
+ ;
+ }
+}
diff --git a/Twig/Node/Expression/Test/Defined.php b/Twig/Node/Expression/Test/Defined.php
new file mode 100644
index 0000000..247b2e2
--- /dev/null
+++ b/Twig/Node/Expression/Test/Defined.php
@@ -0,0 +1,54 @@
+
+ * {# defined works with variable names and variable attributes #}
+ * {% if foo is defined %}
+ * {# ... #}
+ * {% endif %}
+ *
+ *
+ * @author Fabien Potencier
+ */
+class Twig_Node_Expression_Test_Defined extends Twig_Node_Expression_Test
+{
+ public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno)
+ {
+ parent::__construct($node, $name, $arguments, $lineno);
+
+ if ($node instanceof Twig_Node_Expression_Name) {
+ $node->setAttribute('is_defined_test', true);
+ } elseif ($node instanceof Twig_Node_Expression_GetAttr) {
+ $node->setAttribute('is_defined_test', true);
+
+ $this->changeIgnoreStrictCheck($node);
+ } else {
+ throw new Twig_Error_Syntax('The "defined" test only works with simple variables', $this->getLine());
+ }
+ }
+
+ protected function changeIgnoreStrictCheck(Twig_Node_Expression_GetAttr $node)
+ {
+ $node->setAttribute('ignore_strict_check', true);
+
+ if ($node->getNode('node') instanceof Twig_Node_Expression_GetAttr) {
+ $this->changeIgnoreStrictCheck($node->getNode('node'));
+ }
+ }
+
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler->subcompile($this->getNode('node'));
+ }
+}
diff --git a/Twig/Node/Expression/Test/Divisibleby.php b/Twig/Node/Expression/Test/Divisibleby.php
new file mode 100644
index 0000000..d5bed23
--- /dev/null
+++ b/Twig/Node/Expression/Test/Divisibleby.php
@@ -0,0 +1,33 @@
+
+ * {% if loop.index is divisible by(3) %}
+ *
+ *
+ * @author Fabien Potencier
+ */
+class Twig_Node_Expression_Test_Divisibleby extends Twig_Node_Expression_Test
+{
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->raw('(0 == ')
+ ->subcompile($this->getNode('node'))
+ ->raw(' % ')
+ ->subcompile($this->getNode('arguments')->getNode(0))
+ ->raw(')')
+ ;
+ }
+}
diff --git a/Twig/Node/Expression/Test/Even.php b/Twig/Node/Expression/Test/Even.php
new file mode 100644
index 0000000..d7853e8
--- /dev/null
+++ b/Twig/Node/Expression/Test/Even.php
@@ -0,0 +1,32 @@
+
+ * {{ var is even }}
+ *
+ *
+ * @author Fabien Potencier
+ */
+class Twig_Node_Expression_Test_Even extends Twig_Node_Expression_Test
+{
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->raw('(')
+ ->subcompile($this->getNode('node'))
+ ->raw(' % 2 == 0')
+ ->raw(')')
+ ;
+ }
+}
diff --git a/Twig/Node/Expression/Test/Null.php b/Twig/Node/Expression/Test/Null.php
new file mode 100644
index 0000000..1c83825
--- /dev/null
+++ b/Twig/Node/Expression/Test/Null.php
@@ -0,0 +1,31 @@
+
+ * {{ var is none }}
+ *
+ *
+ * @author Fabien Potencier
+ */
+class Twig_Node_Expression_Test_Null extends Twig_Node_Expression_Test
+{
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->raw('(null === ')
+ ->subcompile($this->getNode('node'))
+ ->raw(')')
+ ;
+ }
+}
diff --git a/Twig/Node/Expression/Test/Odd.php b/Twig/Node/Expression/Test/Odd.php
new file mode 100644
index 0000000..421c19e
--- /dev/null
+++ b/Twig/Node/Expression/Test/Odd.php
@@ -0,0 +1,32 @@
+
+ * {{ var is odd }}
+ *
+ *
+ * @author Fabien Potencier
+ */
+class Twig_Node_Expression_Test_Odd extends Twig_Node_Expression_Test
+{
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->raw('(')
+ ->subcompile($this->getNode('node'))
+ ->raw(' % 2 == 1')
+ ->raw(')')
+ ;
+ }
+}
diff --git a/Twig/Node/Expression/Test/Sameas.php b/Twig/Node/Expression/Test/Sameas.php
new file mode 100644
index 0000000..b48905e
--- /dev/null
+++ b/Twig/Node/Expression/Test/Sameas.php
@@ -0,0 +1,29 @@
+
+ */
+class Twig_Node_Expression_Test_Sameas extends Twig_Node_Expression_Test
+{
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->raw('(')
+ ->subcompile($this->getNode('node'))
+ ->raw(' === ')
+ ->subcompile($this->getNode('arguments')->getNode(0))
+ ->raw(')')
+ ;
+ }
+}
diff --git a/Twig/Node/Expression/Unary.php b/Twig/Node/Expression/Unary.php
new file mode 100644
index 0000000..1cf54c3
--- /dev/null
+++ b/Twig/Node/Expression/Unary.php
@@ -0,0 +1,27 @@
+ $node), array(), $lineno);
+ }
+
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler->raw(' ');
+ $this->operator($compiler);
+ $compiler->subcompile($this->getNode('node'));
+ }
+
+ abstract public function operator(Twig_Compiler $compiler);
+}
diff --git a/Twig/Node/Expression/Unary/Neg.php b/Twig/Node/Expression/Unary/Neg.php
new file mode 100644
index 0000000..2a3937e
--- /dev/null
+++ b/Twig/Node/Expression/Unary/Neg.php
@@ -0,0 +1,18 @@
+raw('-');
+ }
+}
diff --git a/Twig/Node/Expression/Unary/Not.php b/Twig/Node/Expression/Unary/Not.php
new file mode 100644
index 0000000..f94073c
--- /dev/null
+++ b/Twig/Node/Expression/Unary/Not.php
@@ -0,0 +1,18 @@
+raw('!');
+ }
+}
diff --git a/Twig/Node/Expression/Unary/Pos.php b/Twig/Node/Expression/Unary/Pos.php
new file mode 100644
index 0000000..04edb52
--- /dev/null
+++ b/Twig/Node/Expression/Unary/Pos.php
@@ -0,0 +1,18 @@
+raw('+');
+ }
+}
diff --git a/Twig/Node/Flush.php b/Twig/Node/Flush.php
new file mode 100644
index 0000000..20d6aab
--- /dev/null
+++ b/Twig/Node/Flush.php
@@ -0,0 +1,36 @@
+
+ */
+class Twig_Node_Flush extends Twig_Node
+{
+ public function __construct($lineno, $tag)
+ {
+ parent::__construct(array(), array(), $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->addDebugInfo($this)
+ ->write("flush();\n")
+ ;
+ }
+}
diff --git a/Twig/Node/For.php b/Twig/Node/For.php
new file mode 100644
index 0000000..a8d199a
--- /dev/null
+++ b/Twig/Node/For.php
@@ -0,0 +1,111 @@
+
+ */
+class Twig_Node_For extends Twig_Node
+{
+ protected $loop;
+
+ public function __construct(Twig_Node_Expression_AssignName $keyTarget, Twig_Node_Expression_AssignName $valueTarget, Twig_Node_Expression $seq, Twig_Node_Expression $ifexpr = null, Twig_NodeInterface $body, Twig_NodeInterface $else = null, $lineno, $tag = null)
+ {
+ $body = new Twig_Node(array($body, $this->loop = new Twig_Node_ForLoop($lineno, $tag)));
+
+ if (null !== $ifexpr) {
+ $body = new Twig_Node_If(new Twig_Node(array($ifexpr, $body)), null, $lineno, $tag);
+ }
+
+ parent::__construct(array('key_target' => $keyTarget, 'value_target' => $valueTarget, 'seq' => $seq, 'body' => $body, 'else' => $else), array('with_loop' => true, 'ifexpr' => null !== $ifexpr), $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->addDebugInfo($this)
+ ->write("\$context['_parent'] = \$context;\n")
+ ->write("\$context['_seq'] = twig_ensure_traversable(")
+ ->subcompile($this->getNode('seq'))
+ ->raw(");\n")
+ ;
+
+ if (null !== $this->getNode('else')) {
+ $compiler->write("\$context['_iterated'] = false;\n");
+ }
+
+ if ($this->getAttribute('with_loop')) {
+ $compiler
+ ->write("\$context['loop'] = array(\n")
+ ->write(" 'parent' => \$context['_parent'],\n")
+ ->write(" 'index0' => 0,\n")
+ ->write(" 'index' => 1,\n")
+ ->write(" 'first' => true,\n")
+ ->write(");\n")
+ ;
+
+ if (!$this->getAttribute('ifexpr')) {
+ $compiler
+ ->write("if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof Countable)) {\n")
+ ->indent()
+ ->write("\$length = count(\$context['_seq']);\n")
+ ->write("\$context['loop']['revindex0'] = \$length - 1;\n")
+ ->write("\$context['loop']['revindex'] = \$length;\n")
+ ->write("\$context['loop']['length'] = \$length;\n")
+ ->write("\$context['loop']['last'] = 1 === \$length;\n")
+ ->outdent()
+ ->write("}\n")
+ ;
+ }
+ }
+
+ $this->loop->setAttribute('else', null !== $this->getNode('else'));
+ $this->loop->setAttribute('with_loop', $this->getAttribute('with_loop'));
+ $this->loop->setAttribute('ifexpr', $this->getAttribute('ifexpr'));
+
+ $compiler
+ ->write("foreach (\$context['_seq'] as ")
+ ->subcompile($this->getNode('key_target'))
+ ->raw(' => ')
+ ->subcompile($this->getNode('value_target'))
+ ->raw(") {\n")
+ ->indent()
+ ->subcompile($this->getNode('body'))
+ ->outdent()
+ ->write("}\n")
+ ;
+
+ if (null !== $this->getNode('else')) {
+ $compiler
+ ->write("if (!\$context['_iterated']) {\n")
+ ->indent()
+ ->subcompile($this->getNode('else'))
+ ->outdent()
+ ->write("}\n")
+ ;
+ }
+
+ $compiler->write("\$_parent = \$context['_parent'];\n");
+
+ // remove some "private" loop variables (needed for nested loops)
+ $compiler->write('unset($context[\'_seq\'], $context[\'_iterated\'], $context[\''.$this->getNode('key_target')->getAttribute('name').'\'], $context[\''.$this->getNode('value_target')->getAttribute('name').'\'], $context[\'_parent\'], $context[\'loop\']);'."\n");
+
+ // keep the values set in the inner context for variables defined in the outer context
+ $compiler->write("\$context = array_intersect_key(\$context, \$_parent) + \$_parent;\n");
+ }
+}
diff --git a/Twig/Node/ForLoop.php b/Twig/Node/ForLoop.php
new file mode 100644
index 0000000..d330283
--- /dev/null
+++ b/Twig/Node/ForLoop.php
@@ -0,0 +1,55 @@
+
+ */
+class Twig_Node_ForLoop extends Twig_Node
+{
+ public function __construct($lineno, $tag = null)
+ {
+ parent::__construct(array(), array('with_loop' => false, 'ifexpr' => false, 'else' => false), $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ if ($this->getAttribute('else')) {
+ $compiler->write("\$context['_iterated'] = true;\n");
+ }
+
+ if ($this->getAttribute('with_loop')) {
+ $compiler
+ ->write("++\$context['loop']['index0'];\n")
+ ->write("++\$context['loop']['index'];\n")
+ ->write("\$context['loop']['first'] = false;\n")
+ ;
+
+ if (!$this->getAttribute('ifexpr')) {
+ $compiler
+ ->write("if (isset(\$context['loop']['length'])) {\n")
+ ->indent()
+ ->write("--\$context['loop']['revindex0'];\n")
+ ->write("--\$context['loop']['revindex'];\n")
+ ->write("\$context['loop']['last'] = 0 === \$context['loop']['revindex0'];\n")
+ ->outdent()
+ ->write("}\n")
+ ;
+ }
+ }
+ }
+}
diff --git a/Twig/Node/If.php b/Twig/Node/If.php
new file mode 100644
index 0000000..1b6104d
--- /dev/null
+++ b/Twig/Node/If.php
@@ -0,0 +1,66 @@
+
+ */
+class Twig_Node_If extends Twig_Node
+{
+ public function __construct(Twig_NodeInterface $tests, Twig_NodeInterface $else = null, $lineno, $tag = null)
+ {
+ parent::__construct(array('tests' => $tests, 'else' => $else), array(), $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler->addDebugInfo($this);
+ for ($i = 0, $count = count($this->getNode('tests')); $i < $count; $i += 2) {
+ if ($i > 0) {
+ $compiler
+ ->outdent()
+ ->write('} elseif (')
+ ;
+ } else {
+ $compiler
+ ->write('if (')
+ ;
+ }
+
+ $compiler
+ ->subcompile($this->getNode('tests')->getNode($i))
+ ->raw(") {\n")
+ ->indent()
+ ->subcompile($this->getNode('tests')->getNode($i + 1))
+ ;
+ }
+
+ if ($this->hasNode('else') && null !== $this->getNode('else')) {
+ $compiler
+ ->outdent()
+ ->write("} else {\n")
+ ->indent()
+ ->subcompile($this->getNode('else'))
+ ;
+ }
+
+ $compiler
+ ->outdent()
+ ->write("}\n");
+ }
+}
diff --git a/Twig/Node/Import.php b/Twig/Node/Import.php
new file mode 100644
index 0000000..515ff2a
--- /dev/null
+++ b/Twig/Node/Import.php
@@ -0,0 +1,54 @@
+
+ */
+class Twig_Node_Import extends Twig_Node
+{
+ public function __construct(Twig_Node_Expression $expr, Twig_Node_Expression $var, $lineno, $tag = null)
+ {
+ parent::__construct(array('expr' => $expr, 'var' => $var), array(), $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->addDebugInfo($this)
+ ->write('')
+ ->subcompile($this->getNode('var'))
+ ->raw(' = ')
+ ;
+
+ if ($this->getNode('expr') instanceof Twig_Node_Expression_Name && '_self' === $this->getNode('expr')->getAttribute('name')) {
+ $compiler->raw('$this');
+ } else {
+ $compiler
+ ->raw('$this->loadTemplate(')
+ ->subcompile($this->getNode('expr'))
+ ->raw(', ')
+ ->repr($compiler->getFilename())
+ ->raw(', ')
+ ->repr($this->getLine())
+ ->raw(')')
+ ;
+ }
+
+ $compiler->raw(";\n");
+ }
+}
diff --git a/Twig/Node/Include.php b/Twig/Node/Include.php
new file mode 100644
index 0000000..fecaa82
--- /dev/null
+++ b/Twig/Node/Include.php
@@ -0,0 +1,88 @@
+
+ */
+class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface
+{
+ public function __construct(Twig_Node_Expression $expr, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null)
+ {
+ parent::__construct(array('expr' => $expr, 'variables' => $variables), array('only' => (bool) $only, 'ignore_missing' => (bool) $ignoreMissing), $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler->addDebugInfo($this);
+
+ if ($this->getAttribute('ignore_missing')) {
+ $compiler
+ ->write("try {\n")
+ ->indent()
+ ;
+ }
+
+ $this->addGetTemplate($compiler);
+
+ $compiler->raw('->display(');
+
+ $this->addTemplateArguments($compiler);
+
+ $compiler->raw(");\n");
+
+ if ($this->getAttribute('ignore_missing')) {
+ $compiler
+ ->outdent()
+ ->write("} catch (Twig_Error_Loader \$e) {\n")
+ ->indent()
+ ->write("// ignore missing template\n")
+ ->outdent()
+ ->write("}\n\n")
+ ;
+ }
+ }
+
+ protected function addGetTemplate(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->write('$this->loadTemplate(')
+ ->subcompile($this->getNode('expr'))
+ ->raw(', ')
+ ->repr($compiler->getFilename())
+ ->raw(', ')
+ ->repr($this->getLine())
+ ->raw(')')
+ ;
+ }
+
+ protected function addTemplateArguments(Twig_Compiler $compiler)
+ {
+ if (null === $this->getNode('variables')) {
+ $compiler->raw(false === $this->getAttribute('only') ? '$context' : 'array()');
+ } elseif (false === $this->getAttribute('only')) {
+ $compiler
+ ->raw('array_merge($context, ')
+ ->subcompile($this->getNode('variables'))
+ ->raw(')')
+ ;
+ } else {
+ $compiler->subcompile($this->getNode('variables'));
+ }
+ }
+}
diff --git a/Twig/Node/Macro.php b/Twig/Node/Macro.php
new file mode 100644
index 0000000..03cf4dd
--- /dev/null
+++ b/Twig/Node/Macro.php
@@ -0,0 +1,123 @@
+
+ */
+class Twig_Node_Macro extends Twig_Node
+{
+ const VARARGS_NAME = 'varargs';
+
+ public function __construct($name, Twig_NodeInterface $body, Twig_NodeInterface $arguments, $lineno, $tag = null)
+ {
+ foreach ($arguments as $argumentName => $argument) {
+ if (self::VARARGS_NAME === $argumentName) {
+ throw new Twig_Error_Syntax(sprintf('The argument "%s" in macro "%s" cannot be defined because the variable "%s" is reserved for arbitrary arguments', self::VARARGS_NAME, $name, self::VARARGS_NAME), $argument->getLine());
+ }
+ }
+
+ parent::__construct(array('body' => $body, 'arguments' => $arguments), array('name' => $name), $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->addDebugInfo($this)
+ ->write(sprintf('public function get%s(', $this->getAttribute('name')))
+ ;
+
+ $count = count($this->getNode('arguments'));
+ $pos = 0;
+ foreach ($this->getNode('arguments') as $name => $default) {
+ $compiler
+ ->raw('$__'.$name.'__ = ')
+ ->subcompile($default)
+ ;
+
+ if (++$pos < $count) {
+ $compiler->raw(', ');
+ }
+ }
+
+ if (PHP_VERSION_ID >= 50600) {
+ if ($count) {
+ $compiler->raw(', ');
+ }
+
+ $compiler->raw('...$__varargs__');
+ }
+
+ $compiler
+ ->raw(")\n")
+ ->write("{\n")
+ ->indent()
+ ;
+
+ $compiler
+ ->write("\$context = \$this->env->mergeGlobals(array(\n")
+ ->indent()
+ ;
+
+ foreach ($this->getNode('arguments') as $name => $default) {
+ $compiler
+ ->addIndentation()
+ ->string($name)
+ ->raw(' => $__'.$name.'__')
+ ->raw(",\n")
+ ;
+ }
+
+ $compiler
+ ->addIndentation()
+ ->string(self::VARARGS_NAME)
+ ->raw(' => ')
+ ;
+
+ if (PHP_VERSION_ID >= 50600) {
+ $compiler->raw("\$__varargs__,\n");
+ } else {
+ $compiler
+ ->raw('func_num_args() > ')
+ ->repr($count)
+ ->raw(' ? array_slice(func_get_args(), ')
+ ->repr($count)
+ ->raw(") : array(),\n")
+ ;
+ }
+
+ $compiler
+ ->outdent()
+ ->write("));\n\n")
+ ->write("\$blocks = array();\n\n")
+ ->write("ob_start();\n")
+ ->write("try {\n")
+ ->indent()
+ ->subcompile($this->getNode('body'))
+ ->outdent()
+ ->write("} catch (Exception \$e) {\n")
+ ->indent()
+ ->write("ob_end_clean();\n\n")
+ ->write("throw \$e;\n")
+ ->outdent()
+ ->write("}\n\n")
+ ->write("return ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset());\n")
+ ->outdent()
+ ->write("}\n\n")
+ ;
+ }
+}
diff --git a/Twig/Node/Module.php b/Twig/Node/Module.php
new file mode 100644
index 0000000..1bc4fea
--- /dev/null
+++ b/Twig/Node/Module.php
@@ -0,0 +1,408 @@
+
+ */
+class Twig_Node_Module extends Twig_Node
+{
+ public function __construct(Twig_NodeInterface $body, Twig_Node_Expression $parent = null, Twig_NodeInterface $blocks, Twig_NodeInterface $macros, Twig_NodeInterface $traits, $embeddedTemplates, $filename)
+ {
+ // embedded templates are set as attributes so that they are only visited once by the visitors
+ parent::__construct(array(
+ 'parent' => $parent,
+ 'body' => $body,
+ 'blocks' => $blocks,
+ 'macros' => $macros,
+ 'traits' => $traits,
+ 'display_start' => new Twig_Node(),
+ 'display_end' => new Twig_Node(),
+ 'constructor_start' => new Twig_Node(),
+ 'constructor_end' => new Twig_Node(),
+ 'class_end' => new Twig_Node(),
+ ), array(
+ 'filename' => $filename,
+ 'index' => null,
+ 'embedded_templates' => $embeddedTemplates,
+ ), 1);
+ }
+
+ public function setIndex($index)
+ {
+ $this->setAttribute('index', $index);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $this->compileTemplate($compiler);
+
+ foreach ($this->getAttribute('embedded_templates') as $template) {
+ $compiler->subcompile($template);
+ }
+ }
+
+ protected function compileTemplate(Twig_Compiler $compiler)
+ {
+ if (!$this->getAttribute('index')) {
+ $compiler->write('compileClassHeader($compiler);
+
+ if (
+ count($this->getNode('blocks'))
+ || count($this->getNode('traits'))
+ || null === $this->getNode('parent')
+ || $this->getNode('parent') instanceof Twig_Node_Expression_Constant
+ || count($this->getNode('constructor_start'))
+ || count($this->getNode('constructor_end'))
+ ) {
+ $this->compileConstructor($compiler);
+ }
+
+ $this->compileGetParent($compiler);
+
+ $this->compileDisplay($compiler);
+
+ $compiler->subcompile($this->getNode('blocks'));
+
+ $this->compileMacros($compiler);
+
+ $this->compileGetTemplateName($compiler);
+
+ $this->compileIsTraitable($compiler);
+
+ $this->compileDebugInfo($compiler);
+
+ $this->compileClassFooter($compiler);
+ }
+
+ protected function compileGetParent(Twig_Compiler $compiler)
+ {
+ if (null === $parent = $this->getNode('parent')) {
+ return;
+ }
+
+ $compiler
+ ->write("protected function doGetParent(array \$context)\n", "{\n")
+ ->indent()
+ ->addDebugInfo($parent)
+ ->write('return ')
+ ;
+
+ if ($parent instanceof Twig_Node_Expression_Constant) {
+ $compiler->subcompile($parent);
+ } else {
+ $compiler
+ ->raw('$this->loadTemplate(')
+ ->subcompile($parent)
+ ->raw(', ')
+ ->repr($compiler->getFilename())
+ ->raw(', ')
+ ->repr($this->getNode('parent')->getLine())
+ ->raw(')')
+ ;
+ }
+
+ $compiler
+ ->raw(";\n")
+ ->outdent()
+ ->write("}\n\n")
+ ;
+ }
+
+ protected function compileClassHeader(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->write("\n\n")
+ // if the filename contains */, add a blank to avoid a PHP parse error
+ ->write('/* '.str_replace('*/', '* /', $this->getAttribute('filename'))." */\n")
+ ->write('class '.$compiler->getEnvironment()->getTemplateClass($this->getAttribute('filename'), $this->getAttribute('index')))
+ ->raw(sprintf(" extends %s\n", $compiler->getEnvironment()->getBaseTemplateClass()))
+ ->write("{\n")
+ ->indent()
+ ;
+ }
+
+ protected function compileConstructor(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->write("public function __construct(Twig_Environment \$env)\n", "{\n")
+ ->indent()
+ ->subcompile($this->getNode('constructor_start'))
+ ->write("parent::__construct(\$env);\n\n")
+ ;
+
+ // parent
+ if (null === $parent = $this->getNode('parent')) {
+ $compiler->write("\$this->parent = false;\n\n");
+ } elseif ($parent instanceof Twig_Node_Expression_Constant) {
+ $compiler
+ ->addDebugInfo($parent)
+ ->write('$this->parent = $this->loadTemplate(')
+ ->subcompile($parent)
+ ->raw(', ')
+ ->repr($compiler->getFilename())
+ ->raw(', ')
+ ->repr($this->getNode('parent')->getLine())
+ ->raw(");\n")
+ ;
+ }
+
+ $countTraits = count($this->getNode('traits'));
+ if ($countTraits) {
+ // traits
+ foreach ($this->getNode('traits') as $i => $trait) {
+ $this->compileLoadTemplate($compiler, $trait->getNode('template'), sprintf('$_trait_%s', $i));
+
+ $compiler
+ ->addDebugInfo($trait->getNode('template'))
+ ->write(sprintf("if (!\$_trait_%s->isTraitable()) {\n", $i))
+ ->indent()
+ ->write("throw new Twig_Error_Runtime('Template \"'.")
+ ->subcompile($trait->getNode('template'))
+ ->raw(".'\" cannot be used as a trait.');\n")
+ ->outdent()
+ ->write("}\n")
+ ->write(sprintf("\$_trait_%s_blocks = \$_trait_%s->getBlocks();\n\n", $i, $i))
+ ;
+
+ foreach ($trait->getNode('targets') as $key => $value) {
+ $compiler
+ ->write(sprintf('if (!isset($_trait_%s_blocks[', $i))
+ ->string($key)
+ ->raw("])) {\n")
+ ->indent()
+ ->write("throw new Twig_Error_Runtime(sprintf('Block ")
+ ->string($key)
+ ->raw(' is not defined in trait ')
+ ->subcompile($trait->getNode('template'))
+ ->raw(".'));\n")
+ ->outdent()
+ ->write("}\n\n")
+
+ ->write(sprintf('$_trait_%s_blocks[', $i))
+ ->subcompile($value)
+ ->raw(sprintf('] = $_trait_%s_blocks[', $i))
+ ->string($key)
+ ->raw(sprintf(']; unset($_trait_%s_blocks[', $i))
+ ->string($key)
+ ->raw("]);\n\n")
+ ;
+ }
+ }
+
+ if ($countTraits > 1) {
+ $compiler
+ ->write("\$this->traits = array_merge(\n")
+ ->indent()
+ ;
+
+ for ($i = 0; $i < $countTraits; ++$i) {
+ $compiler
+ ->write(sprintf('$_trait_%s_blocks'.($i == $countTraits - 1 ? '' : ',')."\n", $i))
+ ;
+ }
+
+ $compiler
+ ->outdent()
+ ->write(");\n\n")
+ ;
+ } else {
+ $compiler
+ ->write("\$this->traits = \$_trait_0_blocks;\n\n")
+ ;
+ }
+
+ $compiler
+ ->write("\$this->blocks = array_merge(\n")
+ ->indent()
+ ->write("\$this->traits,\n")
+ ->write("array(\n")
+ ;
+ } else {
+ $compiler
+ ->write("\$this->blocks = array(\n")
+ ;
+ }
+
+ // blocks
+ $compiler
+ ->indent()
+ ;
+
+ foreach ($this->getNode('blocks') as $name => $node) {
+ $compiler
+ ->write(sprintf("'%s' => array(\$this, 'block_%s'),\n", $name, $name))
+ ;
+ }
+
+ if ($countTraits) {
+ $compiler
+ ->outdent()
+ ->write(")\n")
+ ;
+ }
+
+ $compiler
+ ->outdent()
+ ->write(");\n")
+ ->outdent()
+ ->subcompile($this->getNode('constructor_end'))
+ ->write("}\n\n")
+ ;
+ }
+
+ protected function compileDisplay(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->write("protected function doDisplay(array \$context, array \$blocks = array())\n", "{\n")
+ ->indent()
+ ->subcompile($this->getNode('display_start'))
+ ->subcompile($this->getNode('body'))
+ ;
+
+ if (null !== $parent = $this->getNode('parent')) {
+ $compiler->addDebugInfo($parent);
+ if ($parent instanceof Twig_Node_Expression_Constant) {
+ $compiler->write('$this->parent');
+ } else {
+ $compiler->write('$this->getParent($context)');
+ }
+ $compiler->raw("->display(\$context, array_merge(\$this->blocks, \$blocks));\n");
+ }
+
+ $compiler
+ ->subcompile($this->getNode('display_end'))
+ ->outdent()
+ ->write("}\n\n")
+ ;
+ }
+
+ protected function compileClassFooter(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->subcompile($this->getNode('class_end'))
+ ->outdent()
+ ->write("}\n")
+ ;
+ }
+
+ protected function compileMacros(Twig_Compiler $compiler)
+ {
+ $compiler->subcompile($this->getNode('macros'));
+ }
+
+ protected function compileGetTemplateName(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->write("public function getTemplateName()\n", "{\n")
+ ->indent()
+ ->write('return ')
+ ->repr($this->getAttribute('filename'))
+ ->raw(";\n")
+ ->outdent()
+ ->write("}\n\n")
+ ;
+ }
+
+ protected function compileIsTraitable(Twig_Compiler $compiler)
+ {
+ // A template can be used as a trait if:
+ // * it has no parent
+ // * it has no macros
+ // * it has no body
+ //
+ // Put another way, a template can be used as a trait if it
+ // only contains blocks and use statements.
+ $traitable = null === $this->getNode('parent') && 0 === count($this->getNode('macros'));
+ if ($traitable) {
+ if ($this->getNode('body') instanceof Twig_Node_Body) {
+ $nodes = $this->getNode('body')->getNode(0);
+ } else {
+ $nodes = $this->getNode('body');
+ }
+
+ if (!count($nodes)) {
+ $nodes = new Twig_Node(array($nodes));
+ }
+
+ foreach ($nodes as $node) {
+ if (!count($node)) {
+ continue;
+ }
+
+ if ($node instanceof Twig_Node_Text && ctype_space($node->getAttribute('data'))) {
+ continue;
+ }
+
+ if ($node instanceof Twig_Node_BlockReference) {
+ continue;
+ }
+
+ $traitable = false;
+ break;
+ }
+ }
+
+ if ($traitable) {
+ return;
+ }
+
+ $compiler
+ ->write("public function isTraitable()\n", "{\n")
+ ->indent()
+ ->write(sprintf("return %s;\n", $traitable ? 'true' : 'false'))
+ ->outdent()
+ ->write("}\n\n")
+ ;
+ }
+
+ protected function compileDebugInfo(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->write("public function getDebugInfo()\n", "{\n")
+ ->indent()
+ ->write(sprintf("return %s;\n", str_replace("\n", '', var_export(array_reverse($compiler->getDebugInfo(), true), true))))
+ ->outdent()
+ ->write("}\n")
+ ;
+ }
+
+ protected function compileLoadTemplate(Twig_Compiler $compiler, $node, $var)
+ {
+ if ($node instanceof Twig_Node_Expression_Constant) {
+ $compiler
+ ->write(sprintf('%s = $this->loadTemplate(', $var))
+ ->subcompile($node)
+ ->raw(', ')
+ ->repr($compiler->getFilename())
+ ->raw(', ')
+ ->repr($node->getLine())
+ ->raw(");\n")
+ ;
+ } else {
+ throw new LogicException('Trait templates can only be constant nodes');
+ }
+ }
+}
diff --git a/Twig/Node/Print.php b/Twig/Node/Print.php
new file mode 100644
index 0000000..4263536
--- /dev/null
+++ b/Twig/Node/Print.php
@@ -0,0 +1,39 @@
+
+ */
+class Twig_Node_Print extends Twig_Node implements Twig_NodeOutputInterface
+{
+ public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null)
+ {
+ parent::__construct(array('expr' => $expr), array(), $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->addDebugInfo($this)
+ ->write('echo ')
+ ->subcompile($this->getNode('expr'))
+ ->raw(";\n")
+ ;
+ }
+}
diff --git a/Twig/Node/Sandbox.php b/Twig/Node/Sandbox.php
new file mode 100644
index 0000000..8ca772b
--- /dev/null
+++ b/Twig/Node/Sandbox.php
@@ -0,0 +1,47 @@
+
+ */
+class Twig_Node_Sandbox extends Twig_Node
+{
+ public function __construct(Twig_NodeInterface $body, $lineno, $tag = null)
+ {
+ parent::__construct(array('body' => $body), array(), $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->addDebugInfo($this)
+ ->write("\$sandbox = \$this->env->getExtension('sandbox');\n")
+ ->write("if (!\$alreadySandboxed = \$sandbox->isSandboxed()) {\n")
+ ->indent()
+ ->write("\$sandbox->enableSandbox();\n")
+ ->outdent()
+ ->write("}\n")
+ ->subcompile($this->getNode('body'))
+ ->write("if (!\$alreadySandboxed) {\n")
+ ->indent()
+ ->write("\$sandbox->disableSandbox();\n")
+ ->outdent()
+ ->write("}\n")
+ ;
+ }
+}
diff --git a/Twig/Node/SandboxedPrint.php b/Twig/Node/SandboxedPrint.php
new file mode 100644
index 0000000..823e7ac
--- /dev/null
+++ b/Twig/Node/SandboxedPrint.php
@@ -0,0 +1,61 @@
+
+ */
+class Twig_Node_SandboxedPrint extends Twig_Node_Print
+{
+ public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null)
+ {
+ parent::__construct($expr, $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->addDebugInfo($this)
+ ->write('echo $this->env->getExtension(\'sandbox\')->ensureToStringAllowed(')
+ ->subcompile($this->getNode('expr'))
+ ->raw(");\n")
+ ;
+ }
+
+ /**
+ * Removes node filters.
+ *
+ * This is mostly needed when another visitor adds filters (like the escaper one).
+ *
+ * @param Twig_Node $node A Node
+ *
+ * @return Twig_Node
+ */
+ protected function removeNodeFilter($node)
+ {
+ if ($node instanceof Twig_Node_Expression_Filter) {
+ return $this->removeNodeFilter($node->getNode('node'));
+ }
+
+ return $node;
+ }
+}
diff --git a/Twig/Node/Set.php b/Twig/Node/Set.php
new file mode 100644
index 0000000..407d147
--- /dev/null
+++ b/Twig/Node/Set.php
@@ -0,0 +1,101 @@
+
+ */
+class Twig_Node_Set extends Twig_Node
+{
+ public function __construct($capture, Twig_NodeInterface $names, Twig_NodeInterface $values, $lineno, $tag = null)
+ {
+ parent::__construct(array('names' => $names, 'values' => $values), array('capture' => $capture, 'safe' => false), $lineno, $tag);
+
+ /*
+ * Optimizes the node when capture is used for a large block of text.
+ *
+ * {% set foo %}foo{% endset %} is compiled to $context['foo'] = new Twig_Markup("foo");
+ */
+ if ($this->getAttribute('capture')) {
+ $this->setAttribute('safe', true);
+
+ $values = $this->getNode('values');
+ if ($values instanceof Twig_Node_Text) {
+ $this->setNode('values', new Twig_Node_Expression_Constant($values->getAttribute('data'), $values->getLine()));
+ $this->setAttribute('capture', false);
+ }
+ }
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler->addDebugInfo($this);
+
+ if (count($this->getNode('names')) > 1) {
+ $compiler->write('list(');
+ foreach ($this->getNode('names') as $idx => $node) {
+ if ($idx) {
+ $compiler->raw(', ');
+ }
+
+ $compiler->subcompile($node);
+ }
+ $compiler->raw(')');
+ } else {
+ if ($this->getAttribute('capture')) {
+ $compiler
+ ->write("ob_start();\n")
+ ->subcompile($this->getNode('values'))
+ ;
+ }
+
+ $compiler->subcompile($this->getNode('names'), false);
+
+ if ($this->getAttribute('capture')) {
+ $compiler->raw(" = ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset())");
+ }
+ }
+
+ if (!$this->getAttribute('capture')) {
+ $compiler->raw(' = ');
+
+ if (count($this->getNode('names')) > 1) {
+ $compiler->write('array(');
+ foreach ($this->getNode('values') as $idx => $value) {
+ if ($idx) {
+ $compiler->raw(', ');
+ }
+
+ $compiler->subcompile($value);
+ }
+ $compiler->raw(')');
+ } else {
+ if ($this->getAttribute('safe')) {
+ $compiler
+ ->raw("('' === \$tmp = ")
+ ->subcompile($this->getNode('values'))
+ ->raw(") ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset())")
+ ;
+ } else {
+ $compiler->subcompile($this->getNode('values'));
+ }
+ }
+ }
+
+ $compiler->raw(";\n");
+ }
+}
diff --git a/Twig/Node/SetTemp.php b/Twig/Node/SetTemp.php
new file mode 100644
index 0000000..3bdd1cb
--- /dev/null
+++ b/Twig/Node/SetTemp.php
@@ -0,0 +1,35 @@
+ $name), $lineno);
+ }
+
+ public function compile(Twig_Compiler $compiler)
+ {
+ $name = $this->getAttribute('name');
+ $compiler
+ ->addDebugInfo($this)
+ ->write('if (isset($context[')
+ ->string($name)
+ ->raw('])) { $_')
+ ->raw($name)
+ ->raw('_ = $context[')
+ ->repr($name)
+ ->raw(']; } else { $_')
+ ->raw($name)
+ ->raw("_ = null; }\n")
+ ;
+ }
+}
diff --git a/Twig/Node/Spaceless.php b/Twig/Node/Spaceless.php
new file mode 100644
index 0000000..1478c59
--- /dev/null
+++ b/Twig/Node/Spaceless.php
@@ -0,0 +1,40 @@
+
+ */
+class Twig_Node_Spaceless extends Twig_Node
+{
+ public function __construct(Twig_NodeInterface $body, $lineno, $tag = 'spaceless')
+ {
+ parent::__construct(array('body' => $body), array(), $lineno, $tag);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->addDebugInfo($this)
+ ->write("ob_start();\n")
+ ->subcompile($this->getNode('body'))
+ ->write("echo trim(preg_replace('/>\s+', '><', ob_get_clean()));\n")
+ ;
+ }
+}
diff --git a/Twig/Node/Text.php b/Twig/Node/Text.php
new file mode 100644
index 0000000..6863604
--- /dev/null
+++ b/Twig/Node/Text.php
@@ -0,0 +1,39 @@
+
+ */
+class Twig_Node_Text extends Twig_Node implements Twig_NodeOutputInterface
+{
+ public function __construct($data, $lineno)
+ {
+ parent::__construct(array(), array('data' => $data), $lineno);
+ }
+
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->addDebugInfo($this)
+ ->write('echo ')
+ ->string($this->getAttribute('data'))
+ ->raw(";\n")
+ ;
+ }
+}
diff --git a/Twig/NodeInterface.php b/Twig/NodeInterface.php
new file mode 100644
index 0000000..8077349
--- /dev/null
+++ b/Twig/NodeInterface.php
@@ -0,0 +1,31 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 3.0)
+ */
+interface Twig_NodeInterface extends Countable, IteratorAggregate
+{
+ /**
+ * Compiles the node to PHP.
+ *
+ * @param Twig_Compiler $compiler A Twig_Compiler instance
+ */
+ public function compile(Twig_Compiler $compiler);
+
+ public function getLine();
+
+ public function getNodeTag();
+}
diff --git a/Twig/NodeOutputInterface.php b/Twig/NodeOutputInterface.php
new file mode 100644
index 0000000..22172c0
--- /dev/null
+++ b/Twig/NodeOutputInterface.php
@@ -0,0 +1,19 @@
+
+ */
+interface Twig_NodeOutputInterface
+{
+}
diff --git a/Twig/NodeTraverser.php b/Twig/NodeTraverser.php
new file mode 100644
index 0000000..00f7b54
--- /dev/null
+++ b/Twig/NodeTraverser.php
@@ -0,0 +1,89 @@
+
+ */
+class Twig_NodeTraverser
+{
+ protected $env;
+ protected $visitors = array();
+
+ /**
+ * Constructor.
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ * @param Twig_NodeVisitorInterface[] $visitors An array of Twig_NodeVisitorInterface instances
+ */
+ public function __construct(Twig_Environment $env, array $visitors = array())
+ {
+ $this->env = $env;
+ foreach ($visitors as $visitor) {
+ $this->addVisitor($visitor);
+ }
+ }
+
+ /**
+ * Adds a visitor.
+ *
+ * @param Twig_NodeVisitorInterface $visitor A Twig_NodeVisitorInterface instance
+ */
+ public function addVisitor(Twig_NodeVisitorInterface $visitor)
+ {
+ if (!isset($this->visitors[$visitor->getPriority()])) {
+ $this->visitors[$visitor->getPriority()] = array();
+ }
+
+ $this->visitors[$visitor->getPriority()][] = $visitor;
+ }
+
+ /**
+ * Traverses a node and calls the registered visitors.
+ *
+ * @param Twig_NodeInterface $node A Twig_NodeInterface instance
+ *
+ * @return Twig_NodeInterface
+ */
+ public function traverse(Twig_NodeInterface $node)
+ {
+ ksort($this->visitors);
+ foreach ($this->visitors as $visitors) {
+ foreach ($visitors as $visitor) {
+ $node = $this->traverseForVisitor($visitor, $node);
+ }
+ }
+
+ return $node;
+ }
+
+ protected function traverseForVisitor(Twig_NodeVisitorInterface $visitor, Twig_NodeInterface $node = null)
+ {
+ if (null === $node) {
+ return;
+ }
+
+ $node = $visitor->enterNode($node, $this->env);
+
+ foreach ($node as $k => $n) {
+ if (false !== $n = $this->traverseForVisitor($visitor, $n)) {
+ $node->setNode($k, $n);
+ } else {
+ $node->removeNode($k);
+ }
+ }
+
+ return $visitor->leaveNode($node, $this->env);
+ }
+}
diff --git a/Twig/NodeVisitor/Escaper.php b/Twig/NodeVisitor/Escaper.php
new file mode 100644
index 0000000..5c94977
--- /dev/null
+++ b/Twig/NodeVisitor/Escaper.php
@@ -0,0 +1,157 @@
+
+ */
+class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor
+{
+ protected $statusStack = array();
+ protected $blocks = array();
+ protected $safeAnalysis;
+ protected $traverser;
+ protected $defaultStrategy = false;
+ protected $safeVars = array();
+
+ public function __construct()
+ {
+ $this->safeAnalysis = new Twig_NodeVisitor_SafeAnalysis();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doEnterNode(Twig_Node $node, Twig_Environment $env)
+ {
+ if ($node instanceof Twig_Node_Module) {
+ if ($env->hasExtension('escaper') && $defaultStrategy = $env->getExtension('escaper')->getDefaultStrategy($node->getAttribute('filename'))) {
+ $this->defaultStrategy = $defaultStrategy;
+ }
+ $this->safeVars = array();
+ } elseif ($node instanceof Twig_Node_AutoEscape) {
+ $this->statusStack[] = $node->getAttribute('value');
+ } elseif ($node instanceof Twig_Node_Block) {
+ $this->statusStack[] = isset($this->blocks[$node->getAttribute('name')]) ? $this->blocks[$node->getAttribute('name')] : $this->needEscaping($env);
+ } elseif ($node instanceof Twig_Node_Import) {
+ $this->safeVars[] = $node->getNode('var')->getAttribute('name');
+ }
+
+ return $node;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
+ {
+ if ($node instanceof Twig_Node_Module) {
+ $this->defaultStrategy = false;
+ $this->safeVars = array();
+ } elseif ($node instanceof Twig_Node_Expression_Filter) {
+ return $this->preEscapeFilterNode($node, $env);
+ } elseif ($node instanceof Twig_Node_Print) {
+ return $this->escapePrintNode($node, $env, $this->needEscaping($env));
+ }
+
+ if ($node instanceof Twig_Node_AutoEscape || $node instanceof Twig_Node_Block) {
+ array_pop($this->statusStack);
+ } elseif ($node instanceof Twig_Node_BlockReference) {
+ $this->blocks[$node->getAttribute('name')] = $this->needEscaping($env);
+ }
+
+ return $node;
+ }
+
+ protected function escapePrintNode(Twig_Node_Print $node, Twig_Environment $env, $type)
+ {
+ if (false === $type) {
+ return $node;
+ }
+
+ $expression = $node->getNode('expr');
+
+ if ($this->isSafeFor($type, $expression, $env)) {
+ return $node;
+ }
+
+ $class = get_class($node);
+
+ return new $class(
+ $this->getEscaperFilter($type, $expression),
+ $node->getLine()
+ );
+ }
+
+ protected function preEscapeFilterNode(Twig_Node_Expression_Filter $filter, Twig_Environment $env)
+ {
+ $name = $filter->getNode('filter')->getAttribute('value');
+
+ $type = $env->getFilter($name)->getPreEscape();
+ if (null === $type) {
+ return $filter;
+ }
+
+ $node = $filter->getNode('node');
+ if ($this->isSafeFor($type, $node, $env)) {
+ return $filter;
+ }
+
+ $filter->setNode('node', $this->getEscaperFilter($type, $node));
+
+ return $filter;
+ }
+
+ protected function isSafeFor($type, Twig_NodeInterface $expression, $env)
+ {
+ $safe = $this->safeAnalysis->getSafe($expression);
+
+ if (null === $safe) {
+ if (null === $this->traverser) {
+ $this->traverser = new Twig_NodeTraverser($env, array($this->safeAnalysis));
+ }
+
+ $this->safeAnalysis->setSafeVars($this->safeVars);
+
+ $this->traverser->traverse($expression);
+ $safe = $this->safeAnalysis->getSafe($expression);
+ }
+
+ return in_array($type, $safe) || in_array('all', $safe);
+ }
+
+ protected function needEscaping(Twig_Environment $env)
+ {
+ if (count($this->statusStack)) {
+ return $this->statusStack[count($this->statusStack) - 1];
+ }
+
+ return $this->defaultStrategy ? $this->defaultStrategy : false;
+ }
+
+ protected function getEscaperFilter($type, Twig_NodeInterface $node)
+ {
+ $line = $node->getLine();
+ $name = new Twig_Node_Expression_Constant('escape', $line);
+ $args = new Twig_Node(array(new Twig_Node_Expression_Constant((string) $type, $line), new Twig_Node_Expression_Constant(null, $line), new Twig_Node_Expression_Constant(true, $line)));
+
+ return new Twig_Node_Expression_Filter($node, $name, $args, $line);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getPriority()
+ {
+ return 0;
+ }
+}
diff --git a/Twig/NodeVisitor/Optimizer.php b/Twig/NodeVisitor/Optimizer.php
new file mode 100644
index 0000000..872b7fe
--- /dev/null
+++ b/Twig/NodeVisitor/Optimizer.php
@@ -0,0 +1,271 @@
+
+ */
+class Twig_NodeVisitor_Optimizer extends Twig_BaseNodeVisitor
+{
+ const OPTIMIZE_ALL = -1;
+ const OPTIMIZE_NONE = 0;
+ const OPTIMIZE_FOR = 2;
+ const OPTIMIZE_RAW_FILTER = 4;
+ const OPTIMIZE_VAR_ACCESS = 8;
+
+ protected $loops = array();
+ protected $loopsTargets = array();
+ protected $optimizers;
+ protected $prependedNodes = array();
+ protected $inABody = false;
+
+ /**
+ * Constructor.
+ *
+ * @param int $optimizers The optimizer mode
+ */
+ public function __construct($optimizers = -1)
+ {
+ if (!is_int($optimizers) || $optimizers > (self::OPTIMIZE_FOR | self::OPTIMIZE_RAW_FILTER | self::OPTIMIZE_VAR_ACCESS)) {
+ throw new InvalidArgumentException(sprintf('Optimizer mode "%s" is not valid.', $optimizers));
+ }
+
+ $this->optimizers = $optimizers;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doEnterNode(Twig_Node $node, Twig_Environment $env)
+ {
+ if (self::OPTIMIZE_FOR === (self::OPTIMIZE_FOR & $this->optimizers)) {
+ $this->enterOptimizeFor($node, $env);
+ }
+
+ if (PHP_VERSION_ID < 50400 && self::OPTIMIZE_VAR_ACCESS === (self::OPTIMIZE_VAR_ACCESS & $this->optimizers) && !$env->isStrictVariables() && !$env->hasExtension('sandbox')) {
+ if ($this->inABody) {
+ if (!$node instanceof Twig_Node_Expression) {
+ if (get_class($node) !== 'Twig_Node') {
+ array_unshift($this->prependedNodes, array());
+ }
+ } else {
+ $node = $this->optimizeVariables($node, $env);
+ }
+ } elseif ($node instanceof Twig_Node_Body) {
+ $this->inABody = true;
+ }
+ }
+
+ return $node;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
+ {
+ $expression = $node instanceof Twig_Node_Expression;
+
+ if (self::OPTIMIZE_FOR === (self::OPTIMIZE_FOR & $this->optimizers)) {
+ $this->leaveOptimizeFor($node, $env);
+ }
+
+ if (self::OPTIMIZE_RAW_FILTER === (self::OPTIMIZE_RAW_FILTER & $this->optimizers)) {
+ $node = $this->optimizeRawFilter($node, $env);
+ }
+
+ $node = $this->optimizePrintNode($node, $env);
+
+ if (self::OPTIMIZE_VAR_ACCESS === (self::OPTIMIZE_VAR_ACCESS & $this->optimizers) && !$env->isStrictVariables() && !$env->hasExtension('sandbox')) {
+ if ($node instanceof Twig_Node_Body) {
+ $this->inABody = false;
+ } elseif ($this->inABody) {
+ if (!$expression && get_class($node) !== 'Twig_Node' && $prependedNodes = array_shift($this->prependedNodes)) {
+ $nodes = array();
+ foreach (array_unique($prependedNodes) as $name) {
+ $nodes[] = new Twig_Node_SetTemp($name, $node->getLine());
+ }
+
+ $nodes[] = $node;
+ $node = new Twig_Node($nodes);
+ }
+ }
+ }
+
+ return $node;
+ }
+
+ protected function optimizeVariables(Twig_NodeInterface $node, Twig_Environment $env)
+ {
+ if ('Twig_Node_Expression_Name' === get_class($node) && $node->isSimple()) {
+ $this->prependedNodes[0][] = $node->getAttribute('name');
+
+ return new Twig_Node_Expression_TempName($node->getAttribute('name'), $node->getLine());
+ }
+
+ return $node;
+ }
+
+ /**
+ * Optimizes print nodes.
+ *
+ * It replaces:
+ *
+ * * "echo $this->render(Parent)Block()" with "$this->display(Parent)Block()"
+ *
+ * @param Twig_NodeInterface $node A Node
+ * @param Twig_Environment $env The current Twig environment
+ *
+ * @return Twig_NodeInterface
+ */
+ protected function optimizePrintNode(Twig_NodeInterface $node, Twig_Environment $env)
+ {
+ if (!$node instanceof Twig_Node_Print) {
+ return $node;
+ }
+
+ if (
+ $node->getNode('expr') instanceof Twig_Node_Expression_BlockReference ||
+ $node->getNode('expr') instanceof Twig_Node_Expression_Parent
+ ) {
+ $node->getNode('expr')->setAttribute('output', true);
+
+ return $node->getNode('expr');
+ }
+
+ return $node;
+ }
+
+ /**
+ * Removes "raw" filters.
+ *
+ * @param Twig_NodeInterface $node A Node
+ * @param Twig_Environment $env The current Twig environment
+ *
+ * @return Twig_NodeInterface
+ */
+ protected function optimizeRawFilter(Twig_NodeInterface $node, Twig_Environment $env)
+ {
+ if ($node instanceof Twig_Node_Expression_Filter && 'raw' == $node->getNode('filter')->getAttribute('value')) {
+ return $node->getNode('node');
+ }
+
+ return $node;
+ }
+
+ /**
+ * Optimizes "for" tag by removing the "loop" variable creation whenever possible.
+ *
+ * @param Twig_NodeInterface $node A Node
+ * @param Twig_Environment $env The current Twig environment
+ */
+ protected function enterOptimizeFor(Twig_NodeInterface $node, Twig_Environment $env)
+ {
+ if ($node instanceof Twig_Node_For) {
+ // disable the loop variable by default
+ $node->setAttribute('with_loop', false);
+ array_unshift($this->loops, $node);
+ array_unshift($this->loopsTargets, $node->getNode('value_target')->getAttribute('name'));
+ array_unshift($this->loopsTargets, $node->getNode('key_target')->getAttribute('name'));
+ } elseif (!$this->loops) {
+ // we are outside a loop
+ return;
+ }
+
+ // when do we need to add the loop variable back?
+
+ // the loop variable is referenced for the current loop
+ elseif ($node instanceof Twig_Node_Expression_Name && 'loop' === $node->getAttribute('name')) {
+ $node->setAttribute('always_defined', true);
+ $this->addLoopToCurrent();
+ }
+
+ // optimize access to loop targets
+ elseif ($node instanceof Twig_Node_Expression_Name && in_array($node->getAttribute('name'), $this->loopsTargets)) {
+ $node->setAttribute('always_defined', true);
+ }
+
+ // block reference
+ elseif ($node instanceof Twig_Node_BlockReference || $node instanceof Twig_Node_Expression_BlockReference) {
+ $this->addLoopToCurrent();
+ }
+
+ // include without the only attribute
+ elseif ($node instanceof Twig_Node_Include && !$node->getAttribute('only')) {
+ $this->addLoopToAll();
+ }
+
+ // include function without the with_context=false parameter
+ elseif ($node instanceof Twig_Node_Expression_Function
+ && 'include' === $node->getAttribute('name')
+ && (!$node->getNode('arguments')->hasNode('with_context')
+ || false !== $node->getNode('arguments')->getNode('with_context')->getAttribute('value')
+ )
+ ) {
+ $this->addLoopToAll();
+ }
+
+ // the loop variable is referenced via an attribute
+ elseif ($node instanceof Twig_Node_Expression_GetAttr
+ && (!$node->getNode('attribute') instanceof Twig_Node_Expression_Constant
+ || 'parent' === $node->getNode('attribute')->getAttribute('value')
+ )
+ && (true === $this->loops[0]->getAttribute('with_loop')
+ || ($node->getNode('node') instanceof Twig_Node_Expression_Name
+ && 'loop' === $node->getNode('node')->getAttribute('name')
+ )
+ )
+ ) {
+ $this->addLoopToAll();
+ }
+ }
+
+ /**
+ * Optimizes "for" tag by removing the "loop" variable creation whenever possible.
+ *
+ * @param Twig_NodeInterface $node A Node
+ * @param Twig_Environment $env The current Twig environment
+ */
+ protected function leaveOptimizeFor(Twig_NodeInterface $node, Twig_Environment $env)
+ {
+ if ($node instanceof Twig_Node_For) {
+ array_shift($this->loops);
+ array_shift($this->loopsTargets);
+ array_shift($this->loopsTargets);
+ }
+ }
+
+ protected function addLoopToCurrent()
+ {
+ $this->loops[0]->setAttribute('with_loop', true);
+ }
+
+ protected function addLoopToAll()
+ {
+ foreach ($this->loops as $loop) {
+ $loop->setAttribute('with_loop', true);
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getPriority()
+ {
+ return 255;
+ }
+}
diff --git a/Twig/NodeVisitor/SafeAnalysis.php b/Twig/NodeVisitor/SafeAnalysis.php
new file mode 100644
index 0000000..439f5bf
--- /dev/null
+++ b/Twig/NodeVisitor/SafeAnalysis.php
@@ -0,0 +1,154 @@
+safeVars = $safeVars;
+ }
+
+ public function getSafe(Twig_NodeInterface $node)
+ {
+ $hash = spl_object_hash($node);
+ if (!isset($this->data[$hash])) {
+ return;
+ }
+
+ foreach ($this->data[$hash] as $bucket) {
+ if ($bucket['key'] !== $node) {
+ continue;
+ }
+
+ if (in_array('html_attr', $bucket['value'])) {
+ $bucket['value'][] = 'html';
+ }
+
+ return $bucket['value'];
+ }
+ }
+
+ protected function setSafe(Twig_NodeInterface $node, array $safe)
+ {
+ $hash = spl_object_hash($node);
+ if (isset($this->data[$hash])) {
+ foreach ($this->data[$hash] as &$bucket) {
+ if ($bucket['key'] === $node) {
+ $bucket['value'] = $safe;
+
+ return;
+ }
+ }
+ }
+ $this->data[$hash][] = array(
+ 'key' => $node,
+ 'value' => $safe,
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doEnterNode(Twig_Node $node, Twig_Environment $env)
+ {
+ return $node;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
+ {
+ if ($node instanceof Twig_Node_Expression_Constant) {
+ // constants are marked safe for all
+ $this->setSafe($node, array('all'));
+ } elseif ($node instanceof Twig_Node_Expression_BlockReference) {
+ // blocks are safe by definition
+ $this->setSafe($node, array('all'));
+ } elseif ($node instanceof Twig_Node_Expression_Parent) {
+ // parent block is safe by definition
+ $this->setSafe($node, array('all'));
+ } elseif ($node instanceof Twig_Node_Expression_Conditional) {
+ // intersect safeness of both operands
+ $safe = $this->intersectSafe($this->getSafe($node->getNode('expr2')), $this->getSafe($node->getNode('expr3')));
+ $this->setSafe($node, $safe);
+ } elseif ($node instanceof Twig_Node_Expression_Filter) {
+ // filter expression is safe when the filter is safe
+ $name = $node->getNode('filter')->getAttribute('value');
+ $args = $node->getNode('arguments');
+ if (false !== $filter = $env->getFilter($name)) {
+ $safe = $filter->getSafe($args);
+ if (null === $safe) {
+ $safe = $this->intersectSafe($this->getSafe($node->getNode('node')), $filter->getPreservesSafety());
+ }
+ $this->setSafe($node, $safe);
+ } else {
+ $this->setSafe($node, array());
+ }
+ } elseif ($node instanceof Twig_Node_Expression_Function) {
+ // function expression is safe when the function is safe
+ $name = $node->getAttribute('name');
+ $args = $node->getNode('arguments');
+ $function = $env->getFunction($name);
+ if (false !== $function) {
+ $this->setSafe($node, $function->getSafe($args));
+ } else {
+ $this->setSafe($node, array());
+ }
+ } elseif ($node instanceof Twig_Node_Expression_MethodCall) {
+ if ($node->getAttribute('safe')) {
+ $this->setSafe($node, array('all'));
+ } else {
+ $this->setSafe($node, array());
+ }
+ } elseif ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name) {
+ $name = $node->getNode('node')->getAttribute('name');
+ // attributes on template instances are safe
+ if ('_self' == $name || in_array($name, $this->safeVars)) {
+ $this->setSafe($node, array('all'));
+ } else {
+ $this->setSafe($node, array());
+ }
+ } else {
+ $this->setSafe($node, array());
+ }
+
+ return $node;
+ }
+
+ protected function intersectSafe(array $a = null, array $b = null)
+ {
+ if (null === $a || null === $b) {
+ return array();
+ }
+
+ if (in_array('all', $a)) {
+ return $b;
+ }
+
+ if (in_array('all', $b)) {
+ return $a;
+ }
+
+ return array_intersect($a, $b);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getPriority()
+ {
+ return 0;
+ }
+}
diff --git a/Twig/NodeVisitor/Sandbox.php b/Twig/NodeVisitor/Sandbox.php
new file mode 100644
index 0000000..7f1b913
--- /dev/null
+++ b/Twig/NodeVisitor/Sandbox.php
@@ -0,0 +1,82 @@
+
+ */
+class Twig_NodeVisitor_Sandbox extends Twig_BaseNodeVisitor
+{
+ protected $inAModule = false;
+ protected $tags;
+ protected $filters;
+ protected $functions;
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doEnterNode(Twig_Node $node, Twig_Environment $env)
+ {
+ if ($node instanceof Twig_Node_Module) {
+ $this->inAModule = true;
+ $this->tags = array();
+ $this->filters = array();
+ $this->functions = array();
+
+ return $node;
+ } elseif ($this->inAModule) {
+ // look for tags
+ if ($node->getNodeTag() && !isset($this->tags[$node->getNodeTag()])) {
+ $this->tags[$node->getNodeTag()] = $node;
+ }
+
+ // look for filters
+ if ($node instanceof Twig_Node_Expression_Filter && !isset($this->filters[$node->getNode('filter')->getAttribute('value')])) {
+ $this->filters[$node->getNode('filter')->getAttribute('value')] = $node;
+ }
+
+ // look for functions
+ if ($node instanceof Twig_Node_Expression_Function && !isset($this->functions[$node->getAttribute('name')])) {
+ $this->functions[$node->getAttribute('name')] = $node;
+ }
+
+ // wrap print to check __toString() calls
+ if ($node instanceof Twig_Node_Print) {
+ return new Twig_Node_SandboxedPrint($node->getNode('expr'), $node->getLine(), $node->getNodeTag());
+ }
+ }
+
+ return $node;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
+ {
+ if ($node instanceof Twig_Node_Module) {
+ $this->inAModule = false;
+
+ $node->setNode('display_start', new Twig_Node(array(new Twig_Node_CheckSecurity($this->filters, $this->tags, $this->functions), $node->getNode('display_start'))));
+ }
+
+ return $node;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getPriority()
+ {
+ return 0;
+ }
+}
diff --git a/Twig/NodeVisitorInterface.php b/Twig/NodeVisitorInterface.php
new file mode 100644
index 0000000..f276163
--- /dev/null
+++ b/Twig/NodeVisitorInterface.php
@@ -0,0 +1,47 @@
+
+ */
+interface Twig_NodeVisitorInterface
+{
+ /**
+ * Called before child nodes are visited.
+ *
+ * @param Twig_NodeInterface $node The node to visit
+ * @param Twig_Environment $env The Twig environment instance
+ *
+ * @return Twig_NodeInterface The modified node
+ */
+ public function enterNode(Twig_NodeInterface $node, Twig_Environment $env);
+
+ /**
+ * Called after child nodes are visited.
+ *
+ * @param Twig_NodeInterface $node The node to visit
+ * @param Twig_Environment $env The Twig environment instance
+ *
+ * @return Twig_NodeInterface|false The modified node or false if the node must be removed
+ */
+ public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env);
+
+ /**
+ * Returns the priority for this visitor.
+ *
+ * Priority should be between -10 and 10 (0 is the default).
+ *
+ * @return int The priority level
+ */
+ public function getPriority();
+}
diff --git a/Twig/Parser.php b/Twig/Parser.php
new file mode 100644
index 0000000..6f24ee6
--- /dev/null
+++ b/Twig/Parser.php
@@ -0,0 +1,399 @@
+
+ */
+class Twig_Parser implements Twig_ParserInterface
+{
+ protected $stack = array();
+ protected $stream;
+ protected $parent;
+ protected $handlers;
+ protected $visitors;
+ protected $expressionParser;
+ protected $blocks;
+ protected $blockStack;
+ protected $macros;
+ protected $env;
+ protected $reservedMacroNames;
+ protected $importedSymbols;
+ protected $traits;
+ protected $embeddedTemplates = array();
+
+ /**
+ * Constructor.
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ */
+ public function __construct(Twig_Environment $env)
+ {
+ $this->env = $env;
+ }
+
+ public function getEnvironment()
+ {
+ return $this->env;
+ }
+
+ public function getVarName()
+ {
+ return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
+ }
+
+ public function getFilename()
+ {
+ return $this->stream->getFilename();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function parse(Twig_TokenStream $stream, $test = null, $dropNeedle = false)
+ {
+ // push all variables into the stack to keep the current state of the parser
+ $vars = get_object_vars($this);
+ unset($vars['stack'], $vars['env'], $vars['handlers'], $vars['visitors'], $vars['expressionParser'], $vars['reservedMacroNames']);
+ $this->stack[] = $vars;
+
+ // tag handlers
+ if (null === $this->handlers) {
+ $this->handlers = $this->env->getTokenParsers();
+ $this->handlers->setParser($this);
+ }
+
+ // node visitors
+ if (null === $this->visitors) {
+ $this->visitors = $this->env->getNodeVisitors();
+ }
+
+ if (null === $this->expressionParser) {
+ $this->expressionParser = new Twig_ExpressionParser($this, $this->env->getUnaryOperators(), $this->env->getBinaryOperators());
+ }
+
+ $this->stream = $stream;
+ $this->parent = null;
+ $this->blocks = array();
+ $this->macros = array();
+ $this->traits = array();
+ $this->blockStack = array();
+ $this->importedSymbols = array(array());
+ $this->embeddedTemplates = array();
+
+ try {
+ $body = $this->subparse($test, $dropNeedle);
+
+ if (null !== $this->parent) {
+ if (null === $body = $this->filterBodyNodes($body)) {
+ $body = new Twig_Node();
+ }
+ }
+ } catch (Twig_Error_Syntax $e) {
+ if (!$e->getTemplateFile()) {
+ $e->setTemplateFile($this->getFilename());
+ }
+
+ if (!$e->getTemplateLine()) {
+ $e->setTemplateLine($this->stream->getCurrent()->getLine());
+ }
+
+ throw $e;
+ }
+
+ $node = new Twig_Node_Module(new Twig_Node_Body(array($body)), $this->parent, new Twig_Node($this->blocks), new Twig_Node($this->macros), new Twig_Node($this->traits), $this->embeddedTemplates, $this->getFilename());
+
+ $traverser = new Twig_NodeTraverser($this->env, $this->visitors);
+
+ $node = $traverser->traverse($node);
+
+ // restore previous stack so previous parse() call can resume working
+ foreach (array_pop($this->stack) as $key => $val) {
+ $this->$key = $val;
+ }
+
+ return $node;
+ }
+
+ public function subparse($test, $dropNeedle = false)
+ {
+ $lineno = $this->getCurrentToken()->getLine();
+ $rv = array();
+ while (!$this->stream->isEOF()) {
+ switch ($this->getCurrentToken()->getType()) {
+ case Twig_Token::TEXT_TYPE:
+ $token = $this->stream->next();
+ $rv[] = new Twig_Node_Text($token->getValue(), $token->getLine());
+ break;
+
+ case Twig_Token::VAR_START_TYPE:
+ $token = $this->stream->next();
+ $expr = $this->expressionParser->parseExpression();
+ $this->stream->expect(Twig_Token::VAR_END_TYPE);
+ $rv[] = new Twig_Node_Print($expr, $token->getLine());
+ break;
+
+ case Twig_Token::BLOCK_START_TYPE:
+ $this->stream->next();
+ $token = $this->getCurrentToken();
+
+ if ($token->getType() !== Twig_Token::NAME_TYPE) {
+ throw new Twig_Error_Syntax('A block must start with a tag name', $token->getLine(), $this->getFilename());
+ }
+
+ if (null !== $test && call_user_func($test, $token)) {
+ if ($dropNeedle) {
+ $this->stream->next();
+ }
+
+ if (1 === count($rv)) {
+ return $rv[0];
+ }
+
+ return new Twig_Node($rv, array(), $lineno);
+ }
+
+ $subparser = $this->handlers->getTokenParser($token->getValue());
+ if (null === $subparser) {
+ if (null !== $test) {
+ $error = sprintf('Unexpected tag name "%s"', $token->getValue());
+ if (is_array($test) && isset($test[0]) && $test[0] instanceof Twig_TokenParserInterface) {
+ $error .= sprintf(' (expecting closing tag for the "%s" tag defined near line %s)', $test[0]->getTag(), $lineno);
+ }
+
+ throw new Twig_Error_Syntax($error, $token->getLine(), $this->getFilename());
+ }
+
+ $message = sprintf('Unknown tag name "%s"', $token->getValue());
+ if ($alternatives = $this->env->computeAlternatives($token->getValue(), array_keys($this->env->getTags()))) {
+ $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives));
+ }
+
+ throw new Twig_Error_Syntax($message, $token->getLine(), $this->getFilename());
+ }
+
+ $this->stream->next();
+
+ $node = $subparser->parse($token);
+ if (null !== $node) {
+ $rv[] = $node;
+ }
+ break;
+
+ default:
+ throw new Twig_Error_Syntax('Lexer or parser ended up in unsupported state.', 0, $this->getFilename());
+ }
+ }
+
+ if (1 === count($rv)) {
+ return $rv[0];
+ }
+
+ return new Twig_Node($rv, array(), $lineno);
+ }
+
+ public function addHandler($name, $class)
+ {
+ $this->handlers[$name] = $class;
+ }
+
+ public function addNodeVisitor(Twig_NodeVisitorInterface $visitor)
+ {
+ $this->visitors[] = $visitor;
+ }
+
+ public function getBlockStack()
+ {
+ return $this->blockStack;
+ }
+
+ public function peekBlockStack()
+ {
+ return $this->blockStack[count($this->blockStack) - 1];
+ }
+
+ public function popBlockStack()
+ {
+ array_pop($this->blockStack);
+ }
+
+ public function pushBlockStack($name)
+ {
+ $this->blockStack[] = $name;
+ }
+
+ public function hasBlock($name)
+ {
+ return isset($this->blocks[$name]);
+ }
+
+ public function getBlock($name)
+ {
+ return $this->blocks[$name];
+ }
+
+ public function setBlock($name, Twig_Node_Block $value)
+ {
+ $this->blocks[$name] = new Twig_Node_Body(array($value), array(), $value->getLine());
+ }
+
+ public function hasMacro($name)
+ {
+ return isset($this->macros[$name]);
+ }
+
+ public function setMacro($name, Twig_Node_Macro $node)
+ {
+ if ($this->isReservedMacroName($name)) {
+ throw new Twig_Error_Syntax(sprintf('"%s" cannot be used as a macro name as it is a reserved keyword', $name), $node->getLine(), $this->getFilename());
+ }
+
+ $this->macros[$name] = $node;
+ }
+
+ public function isReservedMacroName($name)
+ {
+ if (null === $this->reservedMacroNames) {
+ $this->reservedMacroNames = array();
+ $r = new ReflectionClass($this->env->getBaseTemplateClass());
+ foreach ($r->getMethods() as $method) {
+ $methodName = strtolower($method->getName());
+
+ if ('get' === substr($methodName, 0, 3) && isset($methodName[3])) {
+ $this->reservedMacroNames[] = substr($methodName, 3);
+ }
+ }
+ }
+
+ return in_array(strtolower($name), $this->reservedMacroNames);
+ }
+
+ public function addTrait($trait)
+ {
+ $this->traits[] = $trait;
+ }
+
+ public function hasTraits()
+ {
+ return count($this->traits) > 0;
+ }
+
+ public function embedTemplate(Twig_Node_Module $template)
+ {
+ $template->setIndex(mt_rand());
+
+ $this->embeddedTemplates[] = $template;
+ }
+
+ public function addImportedSymbol($type, $alias, $name = null, Twig_Node_Expression $node = null)
+ {
+ $this->importedSymbols[0][$type][$alias] = array('name' => $name, 'node' => $node);
+ }
+
+ public function getImportedSymbol($type, $alias)
+ {
+ foreach ($this->importedSymbols as $functions) {
+ if (isset($functions[$type][$alias])) {
+ return $functions[$type][$alias];
+ }
+ }
+ }
+
+ public function isMainScope()
+ {
+ return 1 === count($this->importedSymbols);
+ }
+
+ public function pushLocalScope()
+ {
+ array_unshift($this->importedSymbols, array());
+ }
+
+ public function popLocalScope()
+ {
+ array_shift($this->importedSymbols);
+ }
+
+ /**
+ * Gets the expression parser.
+ *
+ * @return Twig_ExpressionParser The expression parser
+ */
+ public function getExpressionParser()
+ {
+ return $this->expressionParser;
+ }
+
+ public function getParent()
+ {
+ return $this->parent;
+ }
+
+ public function setParent($parent)
+ {
+ $this->parent = $parent;
+ }
+
+ /**
+ * Gets the token stream.
+ *
+ * @return Twig_TokenStream The token stream
+ */
+ public function getStream()
+ {
+ return $this->stream;
+ }
+
+ /**
+ * Gets the current token.
+ *
+ * @return Twig_Token The current token
+ */
+ public function getCurrentToken()
+ {
+ return $this->stream->getCurrent();
+ }
+
+ protected function filterBodyNodes(Twig_NodeInterface $node)
+ {
+ // check that the body does not contain non-empty output nodes
+ if (
+ ($node instanceof Twig_Node_Text && !ctype_space($node->getAttribute('data')))
+ ||
+ (!$node instanceof Twig_Node_Text && !$node instanceof Twig_Node_BlockReference && $node instanceof Twig_NodeOutputInterface)
+ ) {
+ if (false !== strpos((string) $node, chr(0xEF).chr(0xBB).chr(0xBF))) {
+ throw new Twig_Error_Syntax('A template that extends another one cannot have a body but a byte order mark (BOM) has been detected; it must be removed.', $node->getLine(), $this->getFilename());
+ }
+
+ throw new Twig_Error_Syntax('A template that extends another one cannot have a body.', $node->getLine(), $this->getFilename());
+ }
+
+ // bypass "set" nodes as they "capture" the output
+ if ($node instanceof Twig_Node_Set) {
+ return $node;
+ }
+
+ if ($node instanceof Twig_NodeOutputInterface) {
+ return;
+ }
+
+ foreach ($node as $k => $n) {
+ if (null !== $n && null === $this->filterBodyNodes($n)) {
+ $node->removeNode($k);
+ }
+ }
+
+ return $node;
+ }
+}
diff --git a/Twig/ParserInterface.php b/Twig/ParserInterface.php
new file mode 100644
index 0000000..8e7cc0a
--- /dev/null
+++ b/Twig/ParserInterface.php
@@ -0,0 +1,31 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 3.0)
+ */
+interface Twig_ParserInterface
+{
+ /**
+ * Converts a token stream to a node tree.
+ *
+ * @param Twig_TokenStream $stream A token stream instance
+ *
+ * @return Twig_Node_Module A node tree
+ *
+ * @throws Twig_Error_Syntax When the token stream is syntactically or semantically wrong
+ */
+ public function parse(Twig_TokenStream $stream);
+}
diff --git a/Twig/Profiler/Dumper/Blackfire.php b/Twig/Profiler/Dumper/Blackfire.php
new file mode 100644
index 0000000..b82747a
--- /dev/null
+++ b/Twig/Profiler/Dumper/Blackfire.php
@@ -0,0 +1,68 @@
+
+ */
+class Twig_Profiler_Dumper_Blackfire
+{
+ public function dump(Twig_Profiler_Profile $profile)
+ {
+ $data = array();
+ $this->dumpProfile('main()', $profile, $data);
+ $this->dumpChildren('main()', $profile, $data);
+
+ $start = microtime(true);
+ $str = << $values) {
+ $str .= "{$name}//{$values['ct']} {$values['wt']} {$values['mu']} {$values['pmu']}\n";
+ }
+
+ return $str;
+ }
+
+ private function dumpChildren($parent, Twig_Profiler_Profile $profile, &$data)
+ {
+ foreach ($profile as $p) {
+ if ($p->isTemplate()) {
+ $name = $p->getTemplate();
+ } else {
+ $name = sprintf('%s::%s(%s)', $p->getTemplate(), $p->getType(), $p->getName());
+ }
+ $this->dumpProfile(sprintf('%s==>%s', $parent, $name), $p, $data);
+ $this->dumpChildren($name, $p, $data);
+ }
+ }
+
+ private function dumpProfile($edge, Twig_Profiler_Profile $profile, &$data)
+ {
+ if (isset($data[$edge])) {
+ $data[$edge]['ct'] += 1;
+ $data[$edge]['wt'] += floor($profile->getDuration() * 1000000);
+ $data[$edge]['mu'] += $profile->getMemoryUsage();
+ $data[$edge]['pmu'] += $profile->getPeakMemoryUsage();
+ } else {
+ $data[$edge] = array(
+ 'ct' => 1,
+ 'wt' => floor($profile->getDuration() * 1000000),
+ 'mu' => $profile->getMemoryUsage(),
+ 'pmu' => $profile->getPeakMemoryUsage(),
+ );
+ }
+ }
+}
diff --git a/Twig/Profiler/Dumper/Html.php b/Twig/Profiler/Dumper/Html.php
new file mode 100644
index 0000000..f066da7
--- /dev/null
+++ b/Twig/Profiler/Dumper/Html.php
@@ -0,0 +1,43 @@
+
+ */
+class Twig_Profiler_Dumper_Html extends Twig_Profiler_Dumper_Text
+{
+ private static $colors = array(
+ 'block' => '#dfd',
+ 'macro' => '#ddf',
+ 'template' => '#ffd',
+ 'big' => '#d44',
+ );
+
+ public function dump(Twig_Profiler_Profile $profile)
+ {
+ return ''.parent::dump($profile).' ';
+ }
+
+ protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix)
+ {
+ return sprintf('%sâ”” %s ', $prefix, self::$colors['template'], $profile->getTemplate());
+ }
+
+ protected function formatNonTemplate(Twig_Profiler_Profile $profile, $prefix)
+ {
+ return sprintf('%sâ”” %s::%s(%s )', $prefix, $profile->getTemplate(), $profile->getType(), isset(self::$colors[$profile->getType()]) ? self::$colors[$profile->getType()] : 'auto', $profile->getName());
+ }
+
+ protected function formatTime(Twig_Profiler_Profile $profile, $percent)
+ {
+ return sprintf('%.2fms/%.0f%% ', $percent > 20 ? self::$colors['big'] : 'auto', $profile->getDuration() * 1000, $percent);
+ }
+}
diff --git a/Twig/Profiler/Dumper/Text.php b/Twig/Profiler/Dumper/Text.php
new file mode 100644
index 0000000..998e210
--- /dev/null
+++ b/Twig/Profiler/Dumper/Text.php
@@ -0,0 +1,68 @@
+
+ */
+class Twig_Profiler_Dumper_Text
+{
+ private $root;
+
+ public function dump(Twig_Profiler_Profile $profile)
+ {
+ return $this->dumpProfile($profile);
+ }
+
+ protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix)
+ {
+ return sprintf('%sâ”” %s', $prefix, $profile->getTemplate());
+ }
+
+ protected function formatNonTemplate(Twig_Profiler_Profile $profile, $prefix)
+ {
+ return sprintf('%sâ”” %s::%s(%s)', $prefix, $profile->getTemplate(), $profile->getType(), $profile->getName());
+ }
+
+ protected function formatTime(Twig_Profiler_Profile $profile, $percent)
+ {
+ return sprintf('%.2fms/%.0f%%', $profile->getDuration() * 1000, $percent);
+ }
+
+ private function dumpProfile(Twig_Profiler_Profile $profile, $prefix = '', $sibling = false)
+ {
+ if ($profile->isRoot()) {
+ $this->root = $profile->getDuration();
+ $start = $profile->getName();
+ } else {
+ if ($profile->isTemplate()) {
+ $start = $this->formatTemplate($profile, $prefix);
+ } else {
+ $start = $this->formatNonTemplate($profile, $prefix);
+ }
+ $prefix .= $sibling ? '│ ' : ' ';
+ }
+
+ $percent = $this->root ? $profile->getDuration() / $this->root * 100 : 0;
+
+ if ($profile->getDuration() * 1000 < 1) {
+ $str = $start."\n";
+ } else {
+ $str = sprintf("%s %s\n", $start, $this->formatTime($profile, $percent));
+ }
+
+ $nCount = count($profile->getProfiles());
+ foreach ($profile as $i => $p) {
+ $str .= $this->dumpProfile($p, $prefix, $i + 1 !== $nCount);
+ }
+
+ return $str;
+ }
+}
diff --git a/Twig/Profiler/Node/EnterProfile.php b/Twig/Profiler/Node/EnterProfile.php
new file mode 100644
index 0000000..2f97214
--- /dev/null
+++ b/Twig/Profiler/Node/EnterProfile.php
@@ -0,0 +1,40 @@
+
+ */
+class Twig_Profiler_Node_EnterProfile extends Twig_Node
+{
+ public function __construct($extensionName, $type, $name, $varName)
+ {
+ parent::__construct(array(), array('extension_name' => $extensionName, 'name' => $name, 'type' => $type, 'var_name' => $varName));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->write(sprintf('$%s = $this->env->getExtension(', $this->getAttribute('var_name')))
+ ->repr($this->getAttribute('extension_name'))
+ ->raw(");\n")
+ ->write(sprintf('$%s->enter($%s = new Twig_Profiler_Profile($this->getTemplateName(), ', $this->getAttribute('var_name'), $this->getAttribute('var_name').'_prof'))
+ ->repr($this->getAttribute('type'))
+ ->raw(', ')
+ ->repr($this->getAttribute('name'))
+ ->raw("));\n\n")
+ ;
+ }
+}
diff --git a/Twig/Profiler/Node/LeaveProfile.php b/Twig/Profiler/Node/LeaveProfile.php
new file mode 100644
index 0000000..88074c2
--- /dev/null
+++ b/Twig/Profiler/Node/LeaveProfile.php
@@ -0,0 +1,34 @@
+
+ */
+class Twig_Profiler_Node_LeaveProfile extends Twig_Node
+{
+ public function __construct($varName)
+ {
+ parent::__construct(array(), array('var_name' => $varName));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function compile(Twig_Compiler $compiler)
+ {
+ $compiler
+ ->write("\n")
+ ->write(sprintf("\$%s->leave(\$%s);\n\n", $this->getAttribute('var_name'), $this->getAttribute('var_name').'_prof'))
+ ;
+ }
+}
diff --git a/Twig/Profiler/NodeVisitor/Profiler.php b/Twig/Profiler/NodeVisitor/Profiler.php
new file mode 100644
index 0000000..4b0baa8
--- /dev/null
+++ b/Twig/Profiler/NodeVisitor/Profiler.php
@@ -0,0 +1,72 @@
+
+ */
+class Twig_Profiler_NodeVisitor_Profiler extends Twig_BaseNodeVisitor
+{
+ private $extensionName;
+
+ public function __construct($extensionName)
+ {
+ $this->extensionName = $extensionName;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doEnterNode(Twig_Node $node, Twig_Environment $env)
+ {
+ return $node;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function doLeaveNode(Twig_Node $node, Twig_Environment $env)
+ {
+ if ($node instanceof Twig_Node_Module) {
+ $varName = $this->getVarName();
+ $node->setNode('display_start', new Twig_Node(array(new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::TEMPLATE, $node->getAttribute('filename'), $varName), $node->getNode('display_start'))));
+ $node->setNode('display_end', new Twig_Node(array(new Twig_Profiler_Node_LeaveProfile($varName), $node->getNode('display_end'))));
+ } elseif ($node instanceof Twig_Node_Block) {
+ $varName = $this->getVarName();
+ $node->setNode('body', new Twig_Node_Body(array(
+ new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::BLOCK, $node->getAttribute('name'), $varName),
+ $node->getNode('body'),
+ new Twig_Profiler_Node_LeaveProfile($varName),
+ )));
+ } elseif ($node instanceof Twig_Node_Macro) {
+ $varName = $this->getVarName();
+ $node->setNode('body', new Twig_Node_Body(array(
+ new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::MACRO, $node->getAttribute('name'), $varName),
+ $node->getNode('body'),
+ new Twig_Profiler_Node_LeaveProfile($varName),
+ )));
+ }
+
+ return $node;
+ }
+
+ private function getVarName()
+ {
+ return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getPriority()
+ {
+ return 0;
+ }
+}
diff --git a/Twig/Profiler/Profile.php b/Twig/Profiler/Profile.php
new file mode 100644
index 0000000..104bc05
--- /dev/null
+++ b/Twig/Profiler/Profile.php
@@ -0,0 +1,160 @@
+
+ */
+class Twig_Profiler_Profile implements IteratorAggregate, Serializable
+{
+ const ROOT = 'ROOT';
+ const BLOCK = 'block';
+ const TEMPLATE = 'template';
+ const MACRO = 'macro';
+
+ private $template;
+ private $name;
+ private $type;
+ private $starts = array();
+ private $ends = array();
+ private $profiles = array();
+
+ public function __construct($template = 'main', $type = self::ROOT, $name = 'main')
+ {
+ $this->template = $template;
+ $this->type = $type;
+ $this->name = 0 === strpos($name, '__internal_') ? 'INTERNAL' : $name;
+ $this->enter();
+ }
+
+ public function getTemplate()
+ {
+ return $this->template;
+ }
+
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ public function isRoot()
+ {
+ return self::ROOT === $this->type;
+ }
+
+ public function isTemplate()
+ {
+ return self::TEMPLATE === $this->type;
+ }
+
+ public function isBlock()
+ {
+ return self::BLOCK === $this->type;
+ }
+
+ public function isMacro()
+ {
+ return self::MACRO === $this->type;
+ }
+
+ public function getProfiles()
+ {
+ return $this->profiles;
+ }
+
+ public function addProfile(Twig_Profiler_Profile $profile)
+ {
+ $this->profiles[] = $profile;
+ }
+
+ /**
+ * Returns the duration in microseconds.
+ *
+ * @return int
+ */
+ public function getDuration()
+ {
+ if ($this->isRoot() && $this->profiles) {
+ // for the root node with children, duration is the sum of all child durations
+ $duration = 0;
+ foreach ($this->profiles as $profile) {
+ $duration += $profile->getDuration();
+ }
+
+ return $duration;
+ }
+
+ return isset($this->ends['wt']) && isset($this->starts['wt']) ? $this->ends['wt'] - $this->starts['wt'] : 0;
+ }
+
+ /**
+ * Returns the memory usage in bytes.
+ *
+ * @return int
+ */
+ public function getMemoryUsage()
+ {
+ return isset($this->ends['mu']) && isset($this->starts['mu']) ? $this->ends['mu'] - $this->starts['mu'] : 0;
+ }
+
+ /**
+ * Returns the peak memory usage in bytes.
+ *
+ * @return int
+ */
+ public function getPeakMemoryUsage()
+ {
+ return isset($this->ends['pmu']) && isset($this->starts['pmu']) ? $this->ends['pmu'] - $this->starts['pmu'] : 0;
+ }
+
+ /**
+ * Starts the profiling.
+ */
+ public function enter()
+ {
+ $this->starts = array(
+ 'wt' => microtime(true),
+ 'mu' => memory_get_usage(),
+ 'pmu' => memory_get_peak_usage(),
+ );
+ }
+
+ /**
+ * Stops the profiling.
+ */
+ public function leave()
+ {
+ $this->ends = array(
+ 'wt' => microtime(true),
+ 'mu' => memory_get_usage(),
+ 'pmu' => memory_get_peak_usage(),
+ );
+ }
+
+ public function getIterator()
+ {
+ return new ArrayIterator($this->profiles);
+ }
+
+ public function serialize()
+ {
+ return serialize(array($this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles));
+ }
+
+ public function unserialize($data)
+ {
+ list($this->template, $this->name, $this->type, $this->starts, $this->ends, $this->profiles) = unserialize($data);
+ }
+}
diff --git a/Twig/Sandbox/SecurityError.php b/Twig/Sandbox/SecurityError.php
new file mode 100644
index 0000000..015bfae
--- /dev/null
+++ b/Twig/Sandbox/SecurityError.php
@@ -0,0 +1,19 @@
+
+ */
+class Twig_Sandbox_SecurityError extends Twig_Error
+{
+}
diff --git a/Twig/Sandbox/SecurityNotAllowedFilterError.php b/Twig/Sandbox/SecurityNotAllowedFilterError.php
new file mode 100644
index 0000000..99faba9
--- /dev/null
+++ b/Twig/Sandbox/SecurityNotAllowedFilterError.php
@@ -0,0 +1,31 @@
+
+ */
+class Twig_Sandbox_SecurityNotAllowedFilterError extends Twig_Sandbox_SecurityError
+{
+ private $filterName;
+
+ public function __construct($message, $functionName, $lineno = -1, $filename = null, Exception $previous = null)
+ {
+ parent::__construct($message, $lineno, $filename, $previous);
+ $this->filterName = $functionName;
+ }
+
+ public function getFilterName()
+ {
+ return $this->filterName;
+ }
+}
diff --git a/Twig/Sandbox/SecurityNotAllowedFunctionError.php b/Twig/Sandbox/SecurityNotAllowedFunctionError.php
new file mode 100644
index 0000000..05cf488
--- /dev/null
+++ b/Twig/Sandbox/SecurityNotAllowedFunctionError.php
@@ -0,0 +1,31 @@
+
+ */
+class Twig_Sandbox_SecurityNotAllowedFunctionError extends Twig_Sandbox_SecurityError
+{
+ private $functionName;
+
+ public function __construct($message, $functionName, $lineno = -1, $filename = null, Exception $previous = null)
+ {
+ parent::__construct($message, $lineno, $filename, $previous);
+ $this->functionName = $functionName;
+ }
+
+ public function getFunctionName()
+ {
+ return $this->functionName;
+ }
+}
diff --git a/Twig/Sandbox/SecurityNotAllowedTagError.php b/Twig/Sandbox/SecurityNotAllowedTagError.php
new file mode 100644
index 0000000..b3bb5e8
--- /dev/null
+++ b/Twig/Sandbox/SecurityNotAllowedTagError.php
@@ -0,0 +1,31 @@
+
+ */
+class Twig_Sandbox_SecurityNotAllowedTagError extends Twig_Sandbox_SecurityError
+{
+ private $tagName;
+
+ public function __construct($message, $tagName, $lineno = -1, $filename = null, Exception $previous = null)
+ {
+ parent::__construct($message, $lineno, $filename, $previous);
+ $this->tagName = $tagName;
+ }
+
+ public function getTagName()
+ {
+ return $this->tagName;
+ }
+}
diff --git a/Twig/Sandbox/SecurityPolicy.php b/Twig/Sandbox/SecurityPolicy.php
new file mode 100644
index 0000000..c4dd03d
--- /dev/null
+++ b/Twig/Sandbox/SecurityPolicy.php
@@ -0,0 +1,119 @@
+
+ */
+class Twig_Sandbox_SecurityPolicy implements Twig_Sandbox_SecurityPolicyInterface
+{
+ protected $allowedTags;
+ protected $allowedFilters;
+ protected $allowedMethods;
+ protected $allowedProperties;
+ protected $allowedFunctions;
+
+ public function __construct(array $allowedTags = array(), array $allowedFilters = array(), array $allowedMethods = array(), array $allowedProperties = array(), array $allowedFunctions = array())
+ {
+ $this->allowedTags = $allowedTags;
+ $this->allowedFilters = $allowedFilters;
+ $this->setAllowedMethods($allowedMethods);
+ $this->allowedProperties = $allowedProperties;
+ $this->allowedFunctions = $allowedFunctions;
+ }
+
+ public function setAllowedTags(array $tags)
+ {
+ $this->allowedTags = $tags;
+ }
+
+ public function setAllowedFilters(array $filters)
+ {
+ $this->allowedFilters = $filters;
+ }
+
+ public function setAllowedMethods(array $methods)
+ {
+ $this->allowedMethods = array();
+ foreach ($methods as $class => $m) {
+ $this->allowedMethods[$class] = array_map('strtolower', is_array($m) ? $m : array($m));
+ }
+ }
+
+ public function setAllowedProperties(array $properties)
+ {
+ $this->allowedProperties = $properties;
+ }
+
+ public function setAllowedFunctions(array $functions)
+ {
+ $this->allowedFunctions = $functions;
+ }
+
+ public function checkSecurity($tags, $filters, $functions)
+ {
+ foreach ($tags as $tag) {
+ if (!in_array($tag, $this->allowedTags)) {
+ throw new Twig_Sandbox_SecurityNotAllowedTagError(sprintf('Tag "%s" is not allowed.', $tag), $tag);
+ }
+ }
+
+ foreach ($filters as $filter) {
+ if (!in_array($filter, $this->allowedFilters)) {
+ throw new Twig_Sandbox_SecurityNotAllowedFilterError(sprintf('Filter "%s" is not allowed.', $filter), $filter);
+ }
+ }
+
+ foreach ($functions as $function) {
+ if (!in_array($function, $this->allowedFunctions)) {
+ throw new Twig_Sandbox_SecurityNotAllowedFunctionError(sprintf('Function "%s" is not allowed.', $function), $function);
+ }
+ }
+ }
+
+ public function checkMethodAllowed($obj, $method)
+ {
+ if ($obj instanceof Twig_TemplateInterface || $obj instanceof Twig_Markup) {
+ return true;
+ }
+
+ $allowed = false;
+ $method = strtolower($method);
+ foreach ($this->allowedMethods as $class => $methods) {
+ if ($obj instanceof $class) {
+ $allowed = in_array($method, $methods);
+
+ break;
+ }
+ }
+
+ if (!$allowed) {
+ throw new Twig_Sandbox_SecurityError(sprintf('Calling "%s" method on a "%s" object is not allowed.', $method, get_class($obj)));
+ }
+ }
+
+ public function checkPropertyAllowed($obj, $property)
+ {
+ $allowed = false;
+ foreach ($this->allowedProperties as $class => $properties) {
+ if ($obj instanceof $class) {
+ $allowed = in_array($property, is_array($properties) ? $properties : array($properties));
+
+ break;
+ }
+ }
+
+ if (!$allowed) {
+ throw new Twig_Sandbox_SecurityError(sprintf('Calling "%s" property on a "%s" object is not allowed.', $property, get_class($obj)));
+ }
+ }
+}
diff --git a/Twig/Sandbox/SecurityPolicyInterface.php b/Twig/Sandbox/SecurityPolicyInterface.php
new file mode 100644
index 0000000..6ab48e3
--- /dev/null
+++ b/Twig/Sandbox/SecurityPolicyInterface.php
@@ -0,0 +1,24 @@
+
+ */
+interface Twig_Sandbox_SecurityPolicyInterface
+{
+ public function checkSecurity($tags, $filters, $functions);
+
+ public function checkMethodAllowed($obj, $method);
+
+ public function checkPropertyAllowed($obj, $method);
+}
diff --git a/Twig/SimpleFilter.php b/Twig/SimpleFilter.php
new file mode 100644
index 0000000..cefc4f5
--- /dev/null
+++ b/Twig/SimpleFilter.php
@@ -0,0 +1,112 @@
+
+ */
+class Twig_SimpleFilter
+{
+ protected $name;
+ protected $callable;
+ protected $options;
+ protected $arguments = array();
+
+ public function __construct($name, $callable, array $options = array())
+ {
+ $this->name = $name;
+ $this->callable = $callable;
+ $this->options = array_merge(array(
+ 'needs_environment' => false,
+ 'needs_context' => false,
+ 'is_variadic' => false,
+ 'is_safe' => null,
+ 'is_safe_callback' => null,
+ 'pre_escape' => null,
+ 'preserves_safety' => null,
+ 'node_class' => 'Twig_Node_Expression_Filter',
+ 'deprecated' => false,
+ 'alternative' => null,
+ ), $options);
+ }
+
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ public function getCallable()
+ {
+ return $this->callable;
+ }
+
+ public function getNodeClass()
+ {
+ return $this->options['node_class'];
+ }
+
+ public function setArguments($arguments)
+ {
+ $this->arguments = $arguments;
+ }
+
+ public function getArguments()
+ {
+ return $this->arguments;
+ }
+
+ public function needsEnvironment()
+ {
+ return $this->options['needs_environment'];
+ }
+
+ public function needsContext()
+ {
+ return $this->options['needs_context'];
+ }
+
+ public function getSafe(Twig_Node $filterArgs)
+ {
+ if (null !== $this->options['is_safe']) {
+ return $this->options['is_safe'];
+ }
+
+ if (null !== $this->options['is_safe_callback']) {
+ return call_user_func($this->options['is_safe_callback'], $filterArgs);
+ }
+ }
+
+ public function getPreservesSafety()
+ {
+ return $this->options['preserves_safety'];
+ }
+
+ public function getPreEscape()
+ {
+ return $this->options['pre_escape'];
+ }
+
+ public function isVariadic()
+ {
+ return $this->options['is_variadic'];
+ }
+
+ public function isDeprecated()
+ {
+ return $this->options['deprecated'];
+ }
+
+ public function getAlternative()
+ {
+ return $this->options['alternative'];
+ }
+}
diff --git a/Twig/SimpleFunction.php b/Twig/SimpleFunction.php
new file mode 100644
index 0000000..7973540
--- /dev/null
+++ b/Twig/SimpleFunction.php
@@ -0,0 +1,102 @@
+
+ */
+class Twig_SimpleFunction
+{
+ protected $name;
+ protected $callable;
+ protected $options;
+ protected $arguments = array();
+
+ public function __construct($name, $callable, array $options = array())
+ {
+ $this->name = $name;
+ $this->callable = $callable;
+ $this->options = array_merge(array(
+ 'needs_environment' => false,
+ 'needs_context' => false,
+ 'is_variadic' => false,
+ 'is_safe' => null,
+ 'is_safe_callback' => null,
+ 'node_class' => 'Twig_Node_Expression_Function',
+ 'deprecated' => false,
+ 'alternative' => null,
+ ), $options);
+ }
+
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ public function getCallable()
+ {
+ return $this->callable;
+ }
+
+ public function getNodeClass()
+ {
+ return $this->options['node_class'];
+ }
+
+ public function setArguments($arguments)
+ {
+ $this->arguments = $arguments;
+ }
+
+ public function getArguments()
+ {
+ return $this->arguments;
+ }
+
+ public function needsEnvironment()
+ {
+ return $this->options['needs_environment'];
+ }
+
+ public function needsContext()
+ {
+ return $this->options['needs_context'];
+ }
+
+ public function getSafe(Twig_Node $functionArgs)
+ {
+ if (null !== $this->options['is_safe']) {
+ return $this->options['is_safe'];
+ }
+
+ if (null !== $this->options['is_safe_callback']) {
+ return call_user_func($this->options['is_safe_callback'], $functionArgs);
+ }
+
+ return array();
+ }
+
+ public function isVariadic()
+ {
+ return $this->options['is_variadic'];
+ }
+
+ public function isDeprecated()
+ {
+ return $this->options['deprecated'];
+ }
+
+ public function getAlternative()
+ {
+ return $this->options['alternative'];
+ }
+}
diff --git a/Twig/SimpleTest.php b/Twig/SimpleTest.php
new file mode 100644
index 0000000..8ba2192
--- /dev/null
+++ b/Twig/SimpleTest.php
@@ -0,0 +1,64 @@
+
+ */
+class Twig_SimpleTest
+{
+ protected $name;
+ protected $callable;
+ protected $options;
+
+ public function __construct($name, $callable, array $options = array())
+ {
+ $this->name = $name;
+ $this->callable = $callable;
+ $this->options = array_merge(array(
+ 'is_variadic' => false,
+ 'node_class' => 'Twig_Node_Expression_Test',
+ 'deprecated' => false,
+ 'alternative' => null,
+ ), $options);
+ }
+
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ public function getCallable()
+ {
+ return $this->callable;
+ }
+
+ public function getNodeClass()
+ {
+ return $this->options['node_class'];
+ }
+
+ public function isVariadic()
+ {
+ return $this->options['is_variadic'];
+ }
+
+ public function isDeprecated()
+ {
+ return $this->options['deprecated'];
+ }
+
+ public function getAlternative()
+ {
+ return $this->options['alternative'];
+ }
+}
diff --git a/Twig/Template.php b/Twig/Template.php
new file mode 100644
index 0000000..a816022
--- /dev/null
+++ b/Twig/Template.php
@@ -0,0 +1,614 @@
+
+ */
+abstract class Twig_Template implements Twig_TemplateInterface
+{
+ protected static $cache = array();
+
+ protected $parent;
+ protected $parents = array();
+ protected $env;
+ protected $blocks = array();
+ protected $traits = array();
+
+ /**
+ * Constructor.
+ *
+ * @param Twig_Environment $env A Twig_Environment instance
+ */
+ public function __construct(Twig_Environment $env)
+ {
+ $this->env = $env;
+ }
+
+ /**
+ * Returns the template name.
+ *
+ * @return string The template name
+ */
+ abstract public function getTemplateName();
+
+ /**
+ * @deprecated since 1.20 (to be removed in 2.0)
+ */
+ public function getEnvironment()
+ {
+ @trigger_error('The '.__METHOD__.' method is deprecated since version 1.20 and will be removed in 2.0.', E_USER_DEPRECATED);
+
+ return $this->env;
+ }
+
+ /**
+ * Returns the parent template.
+ *
+ * This method is for internal use only and should never be called
+ * directly.
+ *
+ * @param array $context
+ *
+ * @return Twig_TemplateInterface|false The parent template or false if there is no parent
+ *
+ * @internal
+ */
+ public function getParent(array $context)
+ {
+ if (null !== $this->parent) {
+ return $this->parent;
+ }
+
+ try {
+ $parent = $this->doGetParent($context);
+
+ if (false === $parent) {
+ return false;
+ }
+
+ if ($parent instanceof self) {
+ return $this->parents[$parent->getTemplateName()] = $parent;
+ }
+
+ if (!isset($this->parents[$parent])) {
+ $this->parents[$parent] = $this->loadTemplate($parent);
+ }
+ } catch (Twig_Error_Loader $e) {
+ $e->setTemplateFile(null);
+ $e->guess();
+
+ throw $e;
+ }
+
+ return $this->parents[$parent];
+ }
+
+ protected function doGetParent(array $context)
+ {
+ return false;
+ }
+
+ public function isTraitable()
+ {
+ return true;
+ }
+
+ /**
+ * Displays a parent block.
+ *
+ * This method is for internal use only and should never be called
+ * directly.
+ *
+ * @param string $name The block name to display from the parent
+ * @param array $context The context
+ * @param array $blocks The current set of blocks
+ *
+ * @internal
+ */
+ public function displayParentBlock($name, array $context, array $blocks = array())
+ {
+ $name = (string) $name;
+
+ if (isset($this->traits[$name])) {
+ $this->traits[$name][0]->displayBlock($name, $context, $blocks, false);
+ } elseif (false !== $parent = $this->getParent($context)) {
+ $parent->displayBlock($name, $context, $blocks, false);
+ } else {
+ throw new Twig_Error_Runtime(sprintf('The template has no parent and no traits defining the "%s" block', $name), -1, $this->getTemplateName());
+ }
+ }
+
+ /**
+ * Displays a block.
+ *
+ * This method is for internal use only and should never be called
+ * directly.
+ *
+ * @param string $name The block name to display
+ * @param array $context The context
+ * @param array $blocks The current set of blocks
+ * @param bool $useBlocks Whether to use the current set of blocks
+ *
+ * @internal
+ */
+ public function displayBlock($name, array $context, array $blocks = array(), $useBlocks = true)
+ {
+ $name = (string) $name;
+
+ if ($useBlocks && isset($blocks[$name])) {
+ $template = $blocks[$name][0];
+ $block = $blocks[$name][1];
+ } elseif (isset($this->blocks[$name])) {
+ $template = $this->blocks[$name][0];
+ $block = $this->blocks[$name][1];
+ } else {
+ $template = null;
+ $block = null;
+ }
+
+ if (null !== $template) {
+ // avoid RCEs when sandbox is enabled
+ if (!$template instanceof self) {
+ throw new LogicException('A block must be a method on a Twig_Template instance.');
+ }
+
+ try {
+ $template->$block($context, $blocks);
+ } catch (Twig_Error $e) {
+ if (!$e->getTemplateFile()) {
+ $e->setTemplateFile($template->getTemplateName());
+ }
+
+ // this is mostly useful for Twig_Error_Loader exceptions
+ // see Twig_Error_Loader
+ if (false === $e->getTemplateLine()) {
+ $e->setTemplateLine(-1);
+ $e->guess();
+ }
+
+ throw $e;
+ } catch (Exception $e) {
+ throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $template->getTemplateName(), $e);
+ }
+ } elseif (false !== $parent = $this->getParent($context)) {
+ $parent->displayBlock($name, $context, array_merge($this->blocks, $blocks), false);
+ }
+ }
+
+ /**
+ * Renders a parent block.
+ *
+ * This method is for internal use only and should never be called
+ * directly.
+ *
+ * @param string $name The block name to render from the parent
+ * @param array $context The context
+ * @param array $blocks The current set of blocks
+ *
+ * @return string The rendered block
+ *
+ * @internal
+ */
+ public function renderParentBlock($name, array $context, array $blocks = array())
+ {
+ ob_start();
+ $this->displayParentBlock($name, $context, $blocks);
+
+ return ob_get_clean();
+ }
+
+ /**
+ * Renders a block.
+ *
+ * This method is for internal use only and should never be called
+ * directly.
+ *
+ * @param string $name The block name to render
+ * @param array $context The context
+ * @param array $blocks The current set of blocks
+ * @param bool $useBlocks Whether to use the current set of blocks
+ *
+ * @return string The rendered block
+ *
+ * @internal
+ */
+ public function renderBlock($name, array $context, array $blocks = array(), $useBlocks = true)
+ {
+ ob_start();
+ $this->displayBlock($name, $context, $blocks, $useBlocks);
+
+ return ob_get_clean();
+ }
+
+ /**
+ * Returns whether a block exists or not.
+ *
+ * This method is for internal use only and should never be called
+ * directly.
+ *
+ * This method does only return blocks defined in the current template
+ * or defined in "used" traits.
+ *
+ * It does not return blocks from parent templates as the parent
+ * template name can be dynamic, which is only known based on the
+ * current context.
+ *
+ * @param string $name The block name
+ *
+ * @return bool true if the block exists, false otherwise
+ *
+ * @internal
+ */
+ public function hasBlock($name)
+ {
+ return isset($this->blocks[(string) $name]);
+ }
+
+ /**
+ * Returns all block names.
+ *
+ * This method is for internal use only and should never be called
+ * directly.
+ *
+ * @return array An array of block names
+ *
+ * @see hasBlock
+ *
+ * @internal
+ */
+ public function getBlockNames()
+ {
+ return array_keys($this->blocks);
+ }
+
+ protected function loadTemplate($template, $templateName = null, $line = null, $index = null)
+ {
+ try {
+ if (is_array($template)) {
+ return $this->env->resolveTemplate($template);
+ }
+
+ if ($template instanceof self) {
+ return $template;
+ }
+
+ return $this->env->loadTemplate($template, $index);
+ } catch (Twig_Error $e) {
+ if (!$e->getTemplateFile()) {
+ $e->setTemplateFile($templateName ? $templateName : $this->getTemplateName());
+ }
+
+ if ($e->getTemplateLine()) {
+ throw $e;
+ }
+
+ if (!$line) {
+ $e->guess();
+ } else {
+ $e->setTemplateLine($line);
+ }
+
+ throw $e;
+ }
+ }
+
+ /**
+ * Returns all blocks.
+ *
+ * This method is for internal use only and should never be called
+ * directly.
+ *
+ * @return array An array of blocks
+ *
+ * @see hasBlock
+ *
+ * @internal
+ */
+ public function getBlocks()
+ {
+ return $this->blocks;
+ }
+
+ /**
+ * Returns the template source code.
+ *
+ * @return string|null The template source code or null if it is not available
+ */
+ public function getSource()
+ {
+ $reflector = new ReflectionClass($this);
+ $file = $reflector->getFileName();
+
+ if (!file_exists($file)) {
+ return;
+ }
+
+ $source = file($file, FILE_IGNORE_NEW_LINES);
+ array_splice($source, 0, $reflector->getEndLine());
+
+ $i = 0;
+ while (isset($source[$i]) && '/* */' === substr_replace($source[$i], '', 3, -2)) {
+ $source[$i] = str_replace('*//* ', '*/', substr($source[$i], 3, -2));
+ ++$i;
+ }
+ array_splice($source, $i);
+
+ return implode("\n", $source);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function display(array $context, array $blocks = array())
+ {
+ $this->displayWithErrorHandling($this->env->mergeGlobals($context), array_merge($this->blocks, $blocks));
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function render(array $context)
+ {
+ $level = ob_get_level();
+ ob_start();
+ try {
+ $this->display($context);
+ } catch (Exception $e) {
+ while (ob_get_level() > $level) {
+ ob_end_clean();
+ }
+
+ throw $e;
+ }
+
+ return ob_get_clean();
+ }
+
+ protected function displayWithErrorHandling(array $context, array $blocks = array())
+ {
+ try {
+ $this->doDisplay($context, $blocks);
+ } catch (Twig_Error $e) {
+ if (!$e->getTemplateFile()) {
+ $e->setTemplateFile($this->getTemplateName());
+ }
+
+ // this is mostly useful for Twig_Error_Loader exceptions
+ // see Twig_Error_Loader
+ if (false === $e->getTemplateLine()) {
+ $e->setTemplateLine(-1);
+ $e->guess();
+ }
+
+ throw $e;
+ } catch (Exception $e) {
+ throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $this->getTemplateName(), $e);
+ }
+ }
+
+ /**
+ * Auto-generated method to display the template with the given context.
+ *
+ * @param array $context An array of parameters to pass to the template
+ * @param array $blocks An array of blocks to pass to the template
+ */
+ abstract protected function doDisplay(array $context, array $blocks = array());
+
+ /**
+ * Returns a variable from the context.
+ *
+ * This method is for internal use only and should never be called
+ * directly.
+ *
+ * This method should not be overridden in a sub-class as this is an
+ * implementation detail that has been introduced to optimize variable
+ * access for versions of PHP before 5.4. This is not a way to override
+ * the way to get a variable value.
+ *
+ * @param array $context The context
+ * @param string $item The variable to return from the context
+ * @param bool $ignoreStrictCheck Whether to ignore the strict variable check or not
+ *
+ * @return mixed The content of the context variable
+ *
+ * @throws Twig_Error_Runtime if the variable does not exist and Twig is running in strict mode
+ *
+ * @internal
+ */
+ final protected function getContext($context, $item, $ignoreStrictCheck = false)
+ {
+ if (!array_key_exists($item, $context)) {
+ if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
+ return;
+ }
+
+ throw new Twig_Error_Runtime(sprintf('Variable "%s" does not exist', $item), -1, $this->getTemplateName());
+ }
+
+ return $context[$item];
+ }
+
+ /**
+ * Returns the attribute value for a given array/object.
+ *
+ * @param mixed $object The object or array from where to get the item
+ * @param mixed $item The item to get from the array or object
+ * @param array $arguments An array of arguments to pass if the item is an object method
+ * @param string $type The type of attribute (@see Twig_Template constants)
+ * @param bool $isDefinedTest Whether this is only a defined check
+ * @param bool $ignoreStrictCheck Whether to ignore the strict attribute check or not
+ *
+ * @return mixed The attribute value, or a Boolean when $isDefinedTest is true, or null when the attribute is not set and $ignoreStrictCheck is true
+ *
+ * @throws Twig_Error_Runtime if the attribute does not exist and Twig is running in strict mode and $isDefinedTest is false
+ */
+ protected function getAttribute($object, $item, array $arguments = array(), $type = self::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false)
+ {
+ // array
+ if (self::METHOD_CALL !== $type) {
+ $arrayItem = is_bool($item) || is_float($item) ? (int) $item : $item;
+
+ if ((is_array($object) && array_key_exists($arrayItem, $object))
+ || ($object instanceof ArrayAccess && isset($object[$arrayItem]))
+ ) {
+ if ($isDefinedTest) {
+ return true;
+ }
+
+ return $object[$arrayItem];
+ }
+
+ if (self::ARRAY_CALL === $type || !is_object($object)) {
+ if ($isDefinedTest) {
+ return false;
+ }
+
+ if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
+ return;
+ }
+
+ if ($object instanceof ArrayAccess) {
+ $message = sprintf('Key "%s" in object with ArrayAccess of class "%s" does not exist', $arrayItem, get_class($object));
+ } elseif (is_object($object)) {
+ $message = sprintf('Impossible to access a key "%s" on an object of class "%s" that does not implement ArrayAccess interface', $item, get_class($object));
+ } elseif (is_array($object)) {
+ if (empty($object)) {
+ $message = sprintf('Key "%s" does not exist as the array is empty', $arrayItem);
+ } else {
+ $message = sprintf('Key "%s" for array with keys "%s" does not exist', $arrayItem, implode(', ', array_keys($object)));
+ }
+ } elseif (self::ARRAY_CALL === $type) {
+ if (null === $object) {
+ $message = sprintf('Impossible to access a key ("%s") on a null variable', $item);
+ } else {
+ $message = sprintf('Impossible to access a key ("%s") on a %s variable ("%s")', $item, gettype($object), $object);
+ }
+ } elseif (null === $object) {
+ $message = sprintf('Impossible to access an attribute ("%s") on a null variable', $item);
+ } else {
+ $message = sprintf('Impossible to access an attribute ("%s") on a %s variable ("%s")', $item, gettype($object), $object);
+ }
+
+ throw new Twig_Error_Runtime($message, -1, $this->getTemplateName());
+ }
+ }
+
+ if (!is_object($object)) {
+ if ($isDefinedTest) {
+ return false;
+ }
+
+ if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
+ return;
+ }
+
+ if (null === $object) {
+ $message = sprintf('Impossible to invoke a method ("%s") on a null variable', $item);
+ } else {
+ $message = sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s")', $item, gettype($object), $object);
+ }
+
+ throw new Twig_Error_Runtime($message, -1, $this->getTemplateName());
+ }
+
+ // object property
+ if (self::METHOD_CALL !== $type && !$object instanceof self) { // Twig_Template does not have public properties, and we don't want to allow access to internal ones
+ if (isset($object->$item) || array_key_exists((string) $item, $object)) {
+ if ($isDefinedTest) {
+ return true;
+ }
+
+ if ($this->env->hasExtension('sandbox')) {
+ $this->env->getExtension('sandbox')->checkPropertyAllowed($object, $item);
+ }
+
+ return $object->$item;
+ }
+ }
+
+ $class = get_class($object);
+
+ // object method
+ if (!isset(self::$cache[$class]['methods'])) {
+ // get_class_methods returns all methods accessible in the scope, but we only want public ones to be accessible in templates
+ if ($object instanceof self) {
+ $ref = new ReflectionClass($class);
+ $methods = array();
+
+ foreach ($ref->getMethods(ReflectionMethod::IS_PUBLIC) as $refMethod) {
+ $methodName = strtolower($refMethod->name);
+
+ // Accessing the environment from templates is forbidden to prevent untrusted changes to the environment
+ if ('getenvironment' !== $methodName) {
+ $methods[$methodName] = true;
+ }
+ }
+
+ self::$cache[$class]['methods'] = $methods;
+ } else {
+ self::$cache[$class]['methods'] = array_change_key_case(array_flip(get_class_methods($object)));
+ }
+ }
+
+ $call = false;
+ $lcItem = strtolower($item);
+ if (isset(self::$cache[$class]['methods'][$lcItem])) {
+ $method = (string) $item;
+ } elseif (isset(self::$cache[$class]['methods']['get'.$lcItem])) {
+ $method = 'get'.$item;
+ } elseif (isset(self::$cache[$class]['methods']['is'.$lcItem])) {
+ $method = 'is'.$item;
+ } elseif (isset(self::$cache[$class]['methods']['__call'])) {
+ $method = (string) $item;
+ $call = true;
+ } else {
+ if ($isDefinedTest) {
+ return false;
+ }
+
+ if ($ignoreStrictCheck || !$this->env->isStrictVariables()) {
+ return;
+ }
+
+ throw new Twig_Error_Runtime(sprintf('Method "%s" for object "%s" does not exist', $item, get_class($object)), -1, $this->getTemplateName());
+ }
+
+ if ($isDefinedTest) {
+ return true;
+ }
+
+ if ($this->env->hasExtension('sandbox')) {
+ $this->env->getExtension('sandbox')->checkMethodAllowed($object, $method);
+ }
+
+ // Some objects throw exceptions when they have __call, and the method we try
+ // to call is not supported. If ignoreStrictCheck is true, we should return null.
+ try {
+ $ret = call_user_func_array(array($object, $method), $arguments);
+ } catch (BadMethodCallException $e) {
+ if ($call && ($ignoreStrictCheck || !$this->env->isStrictVariables())) {
+ return;
+ }
+ throw $e;
+ }
+
+ // useful when calling a template method from a template
+ // this is not supported but unfortunately heavily used in the Symfony profiler
+ if ($object instanceof Twig_TemplateInterface) {
+ return $ret === '' ? '' : new Twig_Markup($ret, $this->env->getCharset());
+ }
+
+ return $ret;
+ }
+}
diff --git a/Twig/TemplateInterface.php b/Twig/TemplateInterface.php
new file mode 100644
index 0000000..3274640
--- /dev/null
+++ b/Twig/TemplateInterface.php
@@ -0,0 +1,48 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 3.0)
+ */
+interface Twig_TemplateInterface
+{
+ const ANY_CALL = 'any';
+ const ARRAY_CALL = 'array';
+ const METHOD_CALL = 'method';
+
+ /**
+ * Renders the template with the given context and returns it as string.
+ *
+ * @param array $context An array of parameters to pass to the template
+ *
+ * @return string The rendered template
+ */
+ public function render(array $context);
+
+ /**
+ * Displays the template with the given context.
+ *
+ * @param array $context An array of parameters to pass to the template
+ * @param array $blocks An array of blocks to pass to the template
+ */
+ public function display(array $context, array $blocks = array());
+
+ /**
+ * Returns the bound environment for this template.
+ *
+ * @return Twig_Environment The current environment
+ */
+ public function getEnvironment();
+}
diff --git a/Twig/Test.php b/Twig/Test.php
new file mode 100644
index 0000000..3c2d859
--- /dev/null
+++ b/Twig/Test.php
@@ -0,0 +1,37 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+abstract class Twig_Test implements Twig_TestInterface, Twig_TestCallableInterface
+{
+ protected $options;
+ protected $arguments = array();
+
+ public function __construct(array $options = array())
+ {
+ $this->options = array_merge(array(
+ 'callable' => null,
+ ), $options);
+ }
+
+ public function getCallable()
+ {
+ return $this->options['callable'];
+ }
+}
diff --git a/Twig/Test/Function.php b/Twig/Test/Function.php
new file mode 100644
index 0000000..5e76c71
--- /dev/null
+++ b/Twig/Test/Function.php
@@ -0,0 +1,38 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+class Twig_Test_Function extends Twig_Test
+{
+ protected $function;
+
+ public function __construct($function, array $options = array())
+ {
+ $options['callable'] = $function;
+
+ parent::__construct($options);
+
+ $this->function = $function;
+ }
+
+ public function compile()
+ {
+ return $this->function;
+ }
+}
diff --git a/Twig/Test/IntegrationTestCase.php b/Twig/Test/IntegrationTestCase.php
new file mode 100644
index 0000000..1ec575e
--- /dev/null
+++ b/Twig/Test/IntegrationTestCase.php
@@ -0,0 +1,230 @@
+
+ * @author Karma Dordrak
+ */
+abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase
+{
+ /**
+ * @return string
+ */
+ abstract protected function getFixturesDir();
+
+ /**
+ * @return Twig_ExtensionInterface[]
+ */
+ protected function getExtensions()
+ {
+ return array();
+ }
+
+ /**
+ * @return Twig_SimpleFilter[]
+ */
+ protected function getTwigFilters()
+ {
+ return array();
+ }
+
+ /**
+ * @return Twig_SimpleFunction[]
+ */
+ protected function getTwigFunctions()
+ {
+ return array();
+ }
+
+ /**
+ * @return Twig_SimpleTest[]
+ */
+ protected function getTwigTests()
+ {
+ return array();
+ }
+
+ /**
+ * @dataProvider getTests
+ */
+ public function testIntegration($file, $message, $condition, $templates, $exception, $outputs)
+ {
+ $this->doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs);
+ }
+
+ /**
+ * @dataProvider getLegacyTests
+ * @group legacy
+ */
+ public function testLegacyIntegration($file, $message, $condition, $templates, $exception, $outputs)
+ {
+ $this->doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs);
+ }
+
+ public function getTests($name, $legacyTests = false)
+ {
+ $fixturesDir = realpath($this->getFixturesDir());
+ $tests = array();
+
+ foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($fixturesDir), RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
+ if (!preg_match('/\.test$/', $file)) {
+ continue;
+ }
+
+ if ($legacyTests xor false !== strpos($file->getRealpath(), '.legacy.test')) {
+ continue;
+ }
+
+ $test = file_get_contents($file->getRealpath());
+
+ if (preg_match('/--TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)\s*(?:--DATA--\s*(.*))?\s*--EXCEPTION--\s*(.*)/sx', $test, $match)) {
+ $message = $match[1];
+ $condition = $match[2];
+ $templates = $this->parseTemplates($match[3]);
+ $exception = $match[5];
+ $outputs = array(array(null, $match[4], null, ''));
+ } elseif (preg_match('/--TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)--DATA--.*?--EXPECT--.*/s', $test, $match)) {
+ $message = $match[1];
+ $condition = $match[2];
+ $templates = $this->parseTemplates($match[3]);
+ $exception = false;
+ preg_match_all('/--DATA--(.*?)(?:--CONFIG--(.*?))?--EXPECT--(.*?)(?=\-\-DATA\-\-|$)/s', $test, $outputs, PREG_SET_ORDER);
+ } else {
+ throw new InvalidArgumentException(sprintf('Test "%s" is not valid.', str_replace($fixturesDir.'/', '', $file)));
+ }
+
+ $tests[] = array(str_replace($fixturesDir.'/', '', $file), $message, $condition, $templates, $exception, $outputs);
+ }
+
+ if ($legacyTests && empty($tests)) {
+ // add a dummy test to avoid a PHPUnit message
+ return array(array('not', '-', '', array(), '', array()));
+ }
+
+ return $tests;
+ }
+
+ public function getLegacyTests()
+ {
+ return $this->getTests('testLegacyIntegration', true);
+ }
+
+ protected function doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs)
+ {
+ if ($condition) {
+ eval('$ret = '.$condition.';');
+ if (!$ret) {
+ $this->markTestSkipped($condition);
+ }
+ }
+
+ $loader = new Twig_Loader_Array($templates);
+
+ foreach ($outputs as $i => $match) {
+ $config = array_merge(array(
+ 'cache' => false,
+ 'strict_variables' => true,
+ ), $match[2] ? eval($match[2].';') : array());
+ $twig = new Twig_Environment($loader, $config);
+ $twig->addGlobal('global', 'global');
+ foreach ($this->getExtensions() as $extension) {
+ $twig->addExtension($extension);
+ }
+
+ foreach ($this->getTwigFilters() as $filter) {
+ $twig->addFilter($filter);
+ }
+
+ foreach ($this->getTwigTests() as $test) {
+ $twig->addTest($test);
+ }
+
+ foreach ($this->getTwigFunctions() as $function) {
+ $twig->addFunction($function);
+ }
+
+ // avoid using the same PHP class name for different cases
+ // only for PHP 5.2+
+ if (PHP_VERSION_ID >= 50300) {
+ $p = new ReflectionProperty($twig, 'templateClassPrefix');
+ $p->setAccessible(true);
+ $p->setValue($twig, '__TwigTemplate_'.hash('sha256', uniqid(mt_rand(), true), false).'_');
+ }
+
+ try {
+ $template = $twig->loadTemplate('index.twig');
+ } catch (Exception $e) {
+ if (false !== $exception) {
+ $this->assertSame(trim($exception), trim(sprintf('%s: %s', get_class($e), $e->getMessage())));
+
+ return;
+ }
+
+ if ($e instanceof Twig_Error_Syntax) {
+ $e->setTemplateFile($file);
+
+ throw $e;
+ }
+
+ throw new Twig_Error(sprintf('%s: %s', get_class($e), $e->getMessage()), -1, $file, $e);
+ }
+
+ try {
+ $output = trim($template->render(eval($match[1].';')), "\n ");
+ } catch (Exception $e) {
+ if (false !== $exception) {
+ $this->assertSame(trim($exception), trim(sprintf('%s: %s', get_class($e), $e->getMessage())));
+
+ return;
+ }
+
+ if ($e instanceof Twig_Error_Syntax) {
+ $e->setTemplateFile($file);
+ } else {
+ $e = new Twig_Error(sprintf('%s: %s', get_class($e), $e->getMessage()), -1, $file, $e);
+ }
+
+ $output = trim(sprintf('%s: %s', get_class($e), $e->getMessage()));
+ }
+
+ if (false !== $exception) {
+ list($class) = explode(':', $exception);
+ $this->assertThat(null, new PHPUnit_Framework_Constraint_Exception($class));
+ }
+
+ $expected = trim($match[3], "\n ");
+
+ if ($expected !== $output) {
+ printf("Compiled templates that failed on case %d:\n", $i + 1);
+
+ foreach (array_keys($templates) as $name) {
+ echo "Template: $name\n";
+ $source = $loader->getSource($name);
+ echo $twig->compile($twig->parse($twig->tokenize($source, $name)));
+ }
+ }
+ $this->assertEquals($expected, $output, $message.' (in '.$file.')');
+ }
+ }
+
+ protected static function parseTemplates($test)
+ {
+ $templates = array();
+ preg_match_all('/--TEMPLATE(?:\((.*?)\))?--(.*?)(?=\-\-TEMPLATE|$)/s', $test, $matches, PREG_SET_ORDER);
+ foreach ($matches as $match) {
+ $templates[($match[1] ? $match[1] : 'index.twig')] = $match[2];
+ }
+
+ return $templates;
+ }
+}
diff --git a/Twig/Test/Method.php b/Twig/Test/Method.php
new file mode 100644
index 0000000..2779986
--- /dev/null
+++ b/Twig/Test/Method.php
@@ -0,0 +1,40 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+class Twig_Test_Method extends Twig_Test
+{
+ protected $extension;
+ protected $method;
+
+ public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array())
+ {
+ $options['callable'] = array($extension, $method);
+
+ parent::__construct($options);
+
+ $this->extension = $extension;
+ $this->method = $method;
+ }
+
+ public function compile()
+ {
+ return sprintf('$this->env->getExtension(\'%s\')->%s', $this->extension->getName(), $this->method);
+ }
+}
diff --git a/Twig/Test/Node.php b/Twig/Test/Node.php
new file mode 100644
index 0000000..baef49c
--- /dev/null
+++ b/Twig/Test/Node.php
@@ -0,0 +1,40 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+class Twig_Test_Node extends Twig_Test
+{
+ protected $class;
+
+ public function __construct($class, array $options = array())
+ {
+ parent::__construct($options);
+
+ $this->class = $class;
+ }
+
+ public function getClass()
+ {
+ return $this->class;
+ }
+
+ public function compile()
+ {
+ }
+}
diff --git a/Twig/Test/NodeTestCase.php b/Twig/Test/NodeTestCase.php
new file mode 100644
index 0000000..6fe1b5f
--- /dev/null
+++ b/Twig/Test/NodeTestCase.php
@@ -0,0 +1,60 @@
+assertNodeCompilation($source, $node, $environment);
+ }
+
+ public function assertNodeCompilation($source, Twig_Node $node, Twig_Environment $environment = null)
+ {
+ $compiler = $this->getCompiler($environment);
+ $compiler->compile($node);
+
+ $this->assertStringMatchesFormat($source, trim($compiler->getSource()));
+ }
+
+ protected function getCompiler(Twig_Environment $environment = null)
+ {
+ return new Twig_Compiler(null === $environment ? $this->getEnvironment() : $environment);
+ }
+
+ protected function getEnvironment()
+ {
+ return new Twig_Environment(new Twig_Loader_Array(array()));
+ }
+
+ protected function getVariableGetter($name, $line = false)
+ {
+ $line = $line > 0 ? "// line {$line}\n" : '';
+
+ if (PHP_VERSION_ID >= 50400) {
+ return sprintf('%s(isset($context["%s"]) ? $context["%s"] : null)', $line, $name, $name);
+ }
+
+ return sprintf('%s$this->getContext($context, "%s")', $line, $name);
+ }
+
+ protected function getAttributeGetter()
+ {
+ if (function_exists('twig_template_get_attributes')) {
+ return 'twig_template_get_attributes($this, ';
+ }
+
+ return '$this->getAttribute(';
+ }
+}
diff --git a/Twig/TestCallableInterface.php b/Twig/TestCallableInterface.php
new file mode 100644
index 0000000..98d3457
--- /dev/null
+++ b/Twig/TestCallableInterface.php
@@ -0,0 +1,22 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+interface Twig_TestCallableInterface
+{
+ public function getCallable();
+}
diff --git a/Twig/TestInterface.php b/Twig/TestInterface.php
new file mode 100644
index 0000000..2fa821c
--- /dev/null
+++ b/Twig/TestInterface.php
@@ -0,0 +1,27 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+interface Twig_TestInterface
+{
+ /**
+ * Compiles a test.
+ *
+ * @return string The PHP code for the test
+ */
+ public function compile();
+}
diff --git a/Twig/Token.php b/Twig/Token.php
new file mode 100644
index 0000000..a0a029b
--- /dev/null
+++ b/Twig/Token.php
@@ -0,0 +1,216 @@
+
+ */
+class Twig_Token
+{
+ protected $value;
+ protected $type;
+ protected $lineno;
+
+ const EOF_TYPE = -1;
+ const TEXT_TYPE = 0;
+ const BLOCK_START_TYPE = 1;
+ const VAR_START_TYPE = 2;
+ const BLOCK_END_TYPE = 3;
+ const VAR_END_TYPE = 4;
+ const NAME_TYPE = 5;
+ const NUMBER_TYPE = 6;
+ const STRING_TYPE = 7;
+ const OPERATOR_TYPE = 8;
+ const PUNCTUATION_TYPE = 9;
+ const INTERPOLATION_START_TYPE = 10;
+ const INTERPOLATION_END_TYPE = 11;
+
+ /**
+ * Constructor.
+ *
+ * @param int $type The type of the token
+ * @param string $value The token value
+ * @param int $lineno The line position in the source
+ */
+ public function __construct($type, $value, $lineno)
+ {
+ $this->type = $type;
+ $this->value = $value;
+ $this->lineno = $lineno;
+ }
+
+ /**
+ * Returns a string representation of the token.
+ *
+ * @return string A string representation of the token
+ */
+ public function __toString()
+ {
+ return sprintf('%s(%s)', self::typeToString($this->type, true), $this->value);
+ }
+
+ /**
+ * Tests the current token for a type and/or a value.
+ *
+ * Parameters may be:
+ * * just type
+ * * type and value (or array of possible values)
+ * * just value (or array of possible values) (NAME_TYPE is used as type)
+ *
+ * @param array|int $type The type to test
+ * @param array|string|null $values The token value
+ *
+ * @return bool
+ */
+ public function test($type, $values = null)
+ {
+ if (null === $values && !is_int($type)) {
+ $values = $type;
+ $type = self::NAME_TYPE;
+ }
+
+ return ($this->type === $type) && (
+ null === $values ||
+ (is_array($values) && in_array($this->value, $values)) ||
+ $this->value == $values
+ );
+ }
+
+ /**
+ * Gets the line.
+ *
+ * @return int The source line
+ */
+ public function getLine()
+ {
+ return $this->lineno;
+ }
+
+ /**
+ * Gets the token type.
+ *
+ * @return int The token type
+ */
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ /**
+ * Gets the token value.
+ *
+ * @return string The token value
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * Returns the constant representation (internal) of a given type.
+ *
+ * @param int $type The type as an integer
+ * @param bool $short Whether to return a short representation or not
+ *
+ * @return string The string representation
+ */
+ public static function typeToString($type, $short = false)
+ {
+ switch ($type) {
+ case self::EOF_TYPE:
+ $name = 'EOF_TYPE';
+ break;
+ case self::TEXT_TYPE:
+ $name = 'TEXT_TYPE';
+ break;
+ case self::BLOCK_START_TYPE:
+ $name = 'BLOCK_START_TYPE';
+ break;
+ case self::VAR_START_TYPE:
+ $name = 'VAR_START_TYPE';
+ break;
+ case self::BLOCK_END_TYPE:
+ $name = 'BLOCK_END_TYPE';
+ break;
+ case self::VAR_END_TYPE:
+ $name = 'VAR_END_TYPE';
+ break;
+ case self::NAME_TYPE:
+ $name = 'NAME_TYPE';
+ break;
+ case self::NUMBER_TYPE:
+ $name = 'NUMBER_TYPE';
+ break;
+ case self::STRING_TYPE:
+ $name = 'STRING_TYPE';
+ break;
+ case self::OPERATOR_TYPE:
+ $name = 'OPERATOR_TYPE';
+ break;
+ case self::PUNCTUATION_TYPE:
+ $name = 'PUNCTUATION_TYPE';
+ break;
+ case self::INTERPOLATION_START_TYPE:
+ $name = 'INTERPOLATION_START_TYPE';
+ break;
+ case self::INTERPOLATION_END_TYPE:
+ $name = 'INTERPOLATION_END_TYPE';
+ break;
+ default:
+ throw new LogicException(sprintf('Token of type "%s" does not exist.', $type));
+ }
+
+ return $short ? $name : 'Twig_Token::'.$name;
+ }
+
+ /**
+ * Returns the english representation of a given type.
+ *
+ * @param int $type The type as an integer
+ *
+ * @return string The string representation
+ */
+ public static function typeToEnglish($type)
+ {
+ switch ($type) {
+ case self::EOF_TYPE:
+ return 'end of template';
+ case self::TEXT_TYPE:
+ return 'text';
+ case self::BLOCK_START_TYPE:
+ return 'begin of statement block';
+ case self::VAR_START_TYPE:
+ return 'begin of print statement';
+ case self::BLOCK_END_TYPE:
+ return 'end of statement block';
+ case self::VAR_END_TYPE:
+ return 'end of print statement';
+ case self::NAME_TYPE:
+ return 'name';
+ case self::NUMBER_TYPE:
+ return 'number';
+ case self::STRING_TYPE:
+ return 'string';
+ case self::OPERATOR_TYPE:
+ return 'operator';
+ case self::PUNCTUATION_TYPE:
+ return 'punctuation';
+ case self::INTERPOLATION_START_TYPE:
+ return 'begin of string interpolation';
+ case self::INTERPOLATION_END_TYPE:
+ return 'end of string interpolation';
+ default:
+ throw new LogicException(sprintf('Token of type "%s" does not exist.', $type));
+ }
+ }
+}
diff --git a/Twig/TokenParser.php b/Twig/TokenParser.php
new file mode 100644
index 0000000..fa9b6d8
--- /dev/null
+++ b/Twig/TokenParser.php
@@ -0,0 +1,33 @@
+
+ */
+abstract class Twig_TokenParser implements Twig_TokenParserInterface
+{
+ /**
+ * @var Twig_Parser
+ */
+ protected $parser;
+
+ /**
+ * Sets the parser associated with this token parser.
+ *
+ * @param Twig_Parser $parser A Twig_Parser instance
+ */
+ public function setParser(Twig_Parser $parser)
+ {
+ $this->parser = $parser;
+ }
+}
diff --git a/Twig/TokenParser/AutoEscape.php b/Twig/TokenParser/AutoEscape.php
new file mode 100644
index 0000000..a8a3d7a
--- /dev/null
+++ b/Twig/TokenParser/AutoEscape.php
@@ -0,0 +1,91 @@
+
+ * {% autoescape true %}
+ * Everything will be automatically escaped in this block
+ * {% endautoescape %}
+ *
+ * {% autoescape false %}
+ * Everything will be outputed as is in this block
+ * {% endautoescape %}
+ *
+ * {% autoescape true js %}
+ * Everything will be automatically escaped in this block
+ * using the js escaping strategy
+ * {% endautoescape %}
+ *
+ */
+class Twig_TokenParser_AutoEscape extends Twig_TokenParser
+{
+ /**
+ * Parses a token and returns a node.
+ *
+ * @param Twig_Token $token A Twig_Token instance
+ *
+ * @return Twig_NodeInterface A Twig_NodeInterface instance
+ */
+ public function parse(Twig_Token $token)
+ {
+ $lineno = $token->getLine();
+ $stream = $this->parser->getStream();
+
+ if ($stream->test(Twig_Token::BLOCK_END_TYPE)) {
+ $value = 'html';
+ } else {
+ $expr = $this->parser->getExpressionParser()->parseExpression();
+ if (!$expr instanceof Twig_Node_Expression_Constant) {
+ throw new Twig_Error_Syntax('An escaping strategy must be a string or a Boolean.', $stream->getCurrent()->getLine(), $stream->getFilename());
+ }
+ $value = $expr->getAttribute('value');
+
+ $compat = true === $value || false === $value;
+
+ if (true === $value) {
+ $value = 'html';
+ }
+
+ if ($compat && $stream->test(Twig_Token::NAME_TYPE)) {
+ @trigger_error('Using the autoescape tag with "true" or "false" before the strategy name is deprecated.', E_USER_DEPRECATED);
+
+ if (false === $value) {
+ throw new Twig_Error_Syntax('Unexpected escaping strategy as you set autoescaping to false.', $stream->getCurrent()->getLine(), $stream->getFilename());
+ }
+
+ $value = $stream->next()->getValue();
+ }
+ }
+
+ $stream->expect(Twig_Token::BLOCK_END_TYPE);
+ $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+ $stream->expect(Twig_Token::BLOCK_END_TYPE);
+
+ return new Twig_Node_AutoEscape($value, $body, $lineno, $this->getTag());
+ }
+
+ public function decideBlockEnd(Twig_Token $token)
+ {
+ return $token->test('endautoescape');
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'autoescape';
+ }
+}
diff --git a/Twig/TokenParser/Block.php b/Twig/TokenParser/Block.php
new file mode 100644
index 0000000..0a46200
--- /dev/null
+++ b/Twig/TokenParser/Block.php
@@ -0,0 +1,81 @@
+
+ * {% block head %}
+ *
+ * {% block title %}{% endblock %} - My Webpage
+ * {% endblock %}
+ *
+ */
+class Twig_TokenParser_Block extends Twig_TokenParser
+{
+ /**
+ * Parses a token and returns a node.
+ *
+ * @param Twig_Token $token A Twig_Token instance
+ *
+ * @return Twig_NodeInterface A Twig_NodeInterface instance
+ */
+ public function parse(Twig_Token $token)
+ {
+ $lineno = $token->getLine();
+ $stream = $this->parser->getStream();
+ $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
+ if ($this->parser->hasBlock($name)) {
+ throw new Twig_Error_Syntax(sprintf("The block '$name' has already been defined line %d", $this->parser->getBlock($name)->getLine()), $stream->getCurrent()->getLine(), $stream->getFilename());
+ }
+ $this->parser->setBlock($name, $block = new Twig_Node_Block($name, new Twig_Node(array()), $lineno));
+ $this->parser->pushLocalScope();
+ $this->parser->pushBlockStack($name);
+
+ if ($stream->nextIf(Twig_Token::BLOCK_END_TYPE)) {
+ $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+ if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) {
+ $value = $token->getValue();
+
+ if ($value != $name) {
+ throw new Twig_Error_Syntax(sprintf('Expected endblock for block "%s" (but "%s" given)', $name, $value), $stream->getCurrent()->getLine(), $stream->getFilename());
+ }
+ }
+ } else {
+ $body = new Twig_Node(array(
+ new Twig_Node_Print($this->parser->getExpressionParser()->parseExpression(), $lineno),
+ ));
+ }
+ $stream->expect(Twig_Token::BLOCK_END_TYPE);
+
+ $block->setNode('body', $body);
+ $this->parser->popBlockStack();
+ $this->parser->popLocalScope();
+
+ return new Twig_Node_BlockReference($name, $lineno, $this->getTag());
+ }
+
+ public function decideBlockEnd(Twig_Token $token)
+ {
+ return $token->test('endblock');
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'block';
+ }
+}
diff --git a/Twig/TokenParser/Do.php b/Twig/TokenParser/Do.php
new file mode 100644
index 0000000..f50939d
--- /dev/null
+++ b/Twig/TokenParser/Do.php
@@ -0,0 +1,42 @@
+parser->getExpressionParser()->parseExpression();
+
+ $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+
+ return new Twig_Node_Do($expr, $token->getLine(), $this->getTag());
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'do';
+ }
+}
diff --git a/Twig/TokenParser/Embed.php b/Twig/TokenParser/Embed.php
new file mode 100644
index 0000000..69cb5f3
--- /dev/null
+++ b/Twig/TokenParser/Embed.php
@@ -0,0 +1,66 @@
+parser->getStream();
+
+ $parent = $this->parser->getExpressionParser()->parseExpression();
+
+ list($variables, $only, $ignoreMissing) = $this->parseArguments();
+
+ // inject a fake parent to make the parent() function work
+ $stream->injectTokens(array(
+ new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', $token->getLine()),
+ new Twig_Token(Twig_Token::NAME_TYPE, 'extends', $token->getLine()),
+ new Twig_Token(Twig_Token::STRING_TYPE, '__parent__', $token->getLine()),
+ new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', $token->getLine()),
+ ));
+
+ $module = $this->parser->parse($stream, array($this, 'decideBlockEnd'), true);
+
+ // override the parent with the correct one
+ $module->setNode('parent', $parent);
+
+ $this->parser->embedTemplate($module);
+
+ $stream->expect(Twig_Token::BLOCK_END_TYPE);
+
+ return new Twig_Node_Embed($module->getAttribute('filename'), $module->getAttribute('index'), $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag());
+ }
+
+ public function decideBlockEnd(Twig_Token $token)
+ {
+ return $token->test('endembed');
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'embed';
+ }
+}
diff --git a/Twig/TokenParser/Extends.php b/Twig/TokenParser/Extends.php
new file mode 100644
index 0000000..f5ecee2
--- /dev/null
+++ b/Twig/TokenParser/Extends.php
@@ -0,0 +1,52 @@
+
+ * {% extends "base.html" %}
+ *
+ */
+class Twig_TokenParser_Extends extends Twig_TokenParser
+{
+ /**
+ * Parses a token and returns a node.
+ *
+ * @param Twig_Token $token A Twig_Token instance
+ *
+ * @return Twig_NodeInterface A Twig_NodeInterface instance
+ */
+ public function parse(Twig_Token $token)
+ {
+ if (!$this->parser->isMainScope()) {
+ throw new Twig_Error_Syntax('Cannot extend from a block', $token->getLine(), $this->parser->getFilename());
+ }
+
+ if (null !== $this->parser->getParent()) {
+ throw new Twig_Error_Syntax('Multiple extends tags are forbidden', $token->getLine(), $this->parser->getFilename());
+ }
+ $this->parser->setParent($this->parser->getExpressionParser()->parseExpression());
+
+ $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'extends';
+ }
+}
diff --git a/Twig/TokenParser/Filter.php b/Twig/TokenParser/Filter.php
new file mode 100644
index 0000000..2b97475
--- /dev/null
+++ b/Twig/TokenParser/Filter.php
@@ -0,0 +1,61 @@
+
+ * {% filter upper %}
+ * This text becomes uppercase
+ * {% endfilter %}
+ *
+ */
+class Twig_TokenParser_Filter extends Twig_TokenParser
+{
+ /**
+ * Parses a token and returns a node.
+ *
+ * @param Twig_Token $token A Twig_Token instance
+ *
+ * @return Twig_NodeInterface A Twig_NodeInterface instance
+ */
+ public function parse(Twig_Token $token)
+ {
+ $name = $this->parser->getVarName();
+ $ref = new Twig_Node_Expression_BlockReference(new Twig_Node_Expression_Constant($name, $token->getLine()), true, $token->getLine(), $this->getTag());
+
+ $filter = $this->parser->getExpressionParser()->parseFilterExpressionRaw($ref, $this->getTag());
+ $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+
+ $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+ $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+
+ $block = new Twig_Node_Block($name, $body, $token->getLine());
+ $this->parser->setBlock($name, $block);
+
+ return new Twig_Node_Print($filter, $token->getLine(), $this->getTag());
+ }
+
+ public function decideBlockEnd(Twig_Token $token)
+ {
+ return $token->test('endfilter');
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'filter';
+ }
+}
diff --git a/Twig/TokenParser/Flush.php b/Twig/TokenParser/Flush.php
new file mode 100644
index 0000000..4e15e78
--- /dev/null
+++ b/Twig/TokenParser/Flush.php
@@ -0,0 +1,42 @@
+parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+
+ return new Twig_Node_Flush($token->getLine(), $this->getTag());
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'flush';
+ }
+}
diff --git a/Twig/TokenParser/For.php b/Twig/TokenParser/For.php
new file mode 100644
index 0000000..5c07d63
--- /dev/null
+++ b/Twig/TokenParser/For.php
@@ -0,0 +1,135 @@
+
+ *
+ * {% for user in users %}
+ * {{ user.username|e }}
+ * {% endfor %}
+ *
+ *
+ */
+class Twig_TokenParser_For extends Twig_TokenParser
+{
+ /**
+ * Parses a token and returns a node.
+ *
+ * @param Twig_Token $token A Twig_Token instance
+ *
+ * @return Twig_NodeInterface A Twig_NodeInterface instance
+ */
+ public function parse(Twig_Token $token)
+ {
+ $lineno = $token->getLine();
+ $stream = $this->parser->getStream();
+ $targets = $this->parser->getExpressionParser()->parseAssignmentExpression();
+ $stream->expect(Twig_Token::OPERATOR_TYPE, 'in');
+ $seq = $this->parser->getExpressionParser()->parseExpression();
+
+ $ifexpr = null;
+ if ($stream->nextIf(Twig_Token::NAME_TYPE, 'if')) {
+ $ifexpr = $this->parser->getExpressionParser()->parseExpression();
+ }
+
+ $stream->expect(Twig_Token::BLOCK_END_TYPE);
+ $body = $this->parser->subparse(array($this, 'decideForFork'));
+ if ($stream->next()->getValue() == 'else') {
+ $stream->expect(Twig_Token::BLOCK_END_TYPE);
+ $else = $this->parser->subparse(array($this, 'decideForEnd'), true);
+ } else {
+ $else = null;
+ }
+ $stream->expect(Twig_Token::BLOCK_END_TYPE);
+
+ if (count($targets) > 1) {
+ $keyTarget = $targets->getNode(0);
+ $keyTarget = new Twig_Node_Expression_AssignName($keyTarget->getAttribute('name'), $keyTarget->getLine());
+ $valueTarget = $targets->getNode(1);
+ $valueTarget = new Twig_Node_Expression_AssignName($valueTarget->getAttribute('name'), $valueTarget->getLine());
+ } else {
+ $keyTarget = new Twig_Node_Expression_AssignName('_key', $lineno);
+ $valueTarget = $targets->getNode(0);
+ $valueTarget = new Twig_Node_Expression_AssignName($valueTarget->getAttribute('name'), $valueTarget->getLine());
+ }
+
+ if ($ifexpr) {
+ $this->checkLoopUsageCondition($stream, $ifexpr);
+ $this->checkLoopUsageBody($stream, $body);
+ }
+
+ return new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, $lineno, $this->getTag());
+ }
+
+ public function decideForFork(Twig_Token $token)
+ {
+ return $token->test(array('else', 'endfor'));
+ }
+
+ public function decideForEnd(Twig_Token $token)
+ {
+ return $token->test('endfor');
+ }
+
+ // the loop variable cannot be used in the condition
+ protected function checkLoopUsageCondition(Twig_TokenStream $stream, Twig_NodeInterface $node)
+ {
+ if ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) {
+ throw new Twig_Error_Syntax('The "loop" variable cannot be used in a looping condition', $node->getLine(), $stream->getFilename());
+ }
+
+ foreach ($node as $n) {
+ if (!$n) {
+ continue;
+ }
+
+ $this->checkLoopUsageCondition($stream, $n);
+ }
+ }
+
+ // check usage of non-defined loop-items
+ // it does not catch all problems (for instance when a for is included into another or when the variable is used in an include)
+ protected function checkLoopUsageBody(Twig_TokenStream $stream, Twig_NodeInterface $node)
+ {
+ if ($node instanceof Twig_Node_Expression_GetAttr && $node->getNode('node') instanceof Twig_Node_Expression_Name && 'loop' == $node->getNode('node')->getAttribute('name')) {
+ $attribute = $node->getNode('attribute');
+ if ($attribute instanceof Twig_Node_Expression_Constant && in_array($attribute->getAttribute('value'), array('length', 'revindex0', 'revindex', 'last'))) {
+ throw new Twig_Error_Syntax(sprintf('The "loop.%s" variable is not defined when looping with a condition', $attribute->getAttribute('value')), $node->getLine(), $stream->getFilename());
+ }
+ }
+
+ // should check for parent.loop.XXX usage
+ if ($node instanceof Twig_Node_For) {
+ return;
+ }
+
+ foreach ($node as $n) {
+ if (!$n) {
+ continue;
+ }
+
+ $this->checkLoopUsageBody($stream, $n);
+ }
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'for';
+ }
+}
diff --git a/Twig/TokenParser/From.php b/Twig/TokenParser/From.php
new file mode 100644
index 0000000..5540efa
--- /dev/null
+++ b/Twig/TokenParser/From.php
@@ -0,0 +1,74 @@
+
+ * {% from 'forms.html' import forms %}
+ *
+ */
+class Twig_TokenParser_From extends Twig_TokenParser
+{
+ /**
+ * Parses a token and returns a node.
+ *
+ * @param Twig_Token $token A Twig_Token instance
+ *
+ * @return Twig_NodeInterface A Twig_NodeInterface instance
+ */
+ public function parse(Twig_Token $token)
+ {
+ $macro = $this->parser->getExpressionParser()->parseExpression();
+ $stream = $this->parser->getStream();
+ $stream->expect('import');
+
+ $targets = array();
+ do {
+ $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
+
+ $alias = $name;
+ if ($stream->nextIf('as')) {
+ $alias = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
+ }
+
+ $targets[$name] = $alias;
+
+ if (!$stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) {
+ break;
+ }
+ } while (true);
+
+ $stream->expect(Twig_Token::BLOCK_END_TYPE);
+
+ $node = new Twig_Node_Import($macro, new Twig_Node_Expression_AssignName($this->parser->getVarName(), $token->getLine()), $token->getLine(), $this->getTag());
+
+ foreach ($targets as $name => $alias) {
+ if ($this->parser->isReservedMacroName($name)) {
+ throw new Twig_Error_Syntax(sprintf('"%s" cannot be an imported macro as it is a reserved keyword', $name), $token->getLine(), $stream->getFilename());
+ }
+
+ $this->parser->addImportedSymbol('function', $alias, 'get'.$name, $node->getNode('var'));
+ }
+
+ return $node;
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'from';
+ }
+}
diff --git a/Twig/TokenParser/If.php b/Twig/TokenParser/If.php
new file mode 100644
index 0000000..3d7d1f5
--- /dev/null
+++ b/Twig/TokenParser/If.php
@@ -0,0 +1,94 @@
+
+ * {% if users %}
+ *
+ * {% for user in users %}
+ * {{ user.username|e }}
+ * {% endfor %}
+ *
+ * {% endif %}
+ *
+ */
+class Twig_TokenParser_If extends Twig_TokenParser
+{
+ /**
+ * Parses a token and returns a node.
+ *
+ * @param Twig_Token $token A Twig_Token instance
+ *
+ * @return Twig_NodeInterface A Twig_NodeInterface instance
+ */
+ public function parse(Twig_Token $token)
+ {
+ $lineno = $token->getLine();
+ $expr = $this->parser->getExpressionParser()->parseExpression();
+ $stream = $this->parser->getStream();
+ $stream->expect(Twig_Token::BLOCK_END_TYPE);
+ $body = $this->parser->subparse(array($this, 'decideIfFork'));
+ $tests = array($expr, $body);
+ $else = null;
+
+ $end = false;
+ while (!$end) {
+ switch ($stream->next()->getValue()) {
+ case 'else':
+ $stream->expect(Twig_Token::BLOCK_END_TYPE);
+ $else = $this->parser->subparse(array($this, 'decideIfEnd'));
+ break;
+
+ case 'elseif':
+ $expr = $this->parser->getExpressionParser()->parseExpression();
+ $stream->expect(Twig_Token::BLOCK_END_TYPE);
+ $body = $this->parser->subparse(array($this, 'decideIfFork'));
+ $tests[] = $expr;
+ $tests[] = $body;
+ break;
+
+ case 'endif':
+ $end = true;
+ break;
+
+ default:
+ throw new Twig_Error_Syntax(sprintf('Unexpected end of template. Twig was looking for the following tags "else", "elseif", or "endif" to close the "if" block started at line %d)', $lineno), $stream->getCurrent()->getLine(), $stream->getFilename());
+ }
+ }
+
+ $stream->expect(Twig_Token::BLOCK_END_TYPE);
+
+ return new Twig_Node_If(new Twig_Node($tests), $else, $lineno, $this->getTag());
+ }
+
+ public function decideIfFork(Twig_Token $token)
+ {
+ return $token->test(array('elseif', 'else', 'endif'));
+ }
+
+ public function decideIfEnd(Twig_Token $token)
+ {
+ return $token->test(array('endif'));
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'if';
+ }
+}
diff --git a/Twig/TokenParser/Import.php b/Twig/TokenParser/Import.php
new file mode 100644
index 0000000..e7050c7
--- /dev/null
+++ b/Twig/TokenParser/Import.php
@@ -0,0 +1,49 @@
+
+ * {% import 'forms.html' as forms %}
+ *
+ */
+class Twig_TokenParser_Import extends Twig_TokenParser
+{
+ /**
+ * Parses a token and returns a node.
+ *
+ * @param Twig_Token $token A Twig_Token instance
+ *
+ * @return Twig_NodeInterface A Twig_NodeInterface instance
+ */
+ public function parse(Twig_Token $token)
+ {
+ $macro = $this->parser->getExpressionParser()->parseExpression();
+ $this->parser->getStream()->expect('as');
+ $var = new Twig_Node_Expression_AssignName($this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue(), $token->getLine());
+ $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+
+ $this->parser->addImportedSymbol('template', $var->getAttribute('name'));
+
+ return new Twig_Node_Import($macro, $var, $token->getLine(), $this->getTag());
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'import';
+ }
+}
diff --git a/Twig/TokenParser/Include.php b/Twig/TokenParser/Include.php
new file mode 100644
index 0000000..9c3099a
--- /dev/null
+++ b/Twig/TokenParser/Include.php
@@ -0,0 +1,75 @@
+
+ * {% include 'header.html' %}
+ * Body
+ * {% include 'footer.html' %}
+ *
+ */
+class Twig_TokenParser_Include extends Twig_TokenParser
+{
+ /**
+ * Parses a token and returns a node.
+ *
+ * @param Twig_Token $token A Twig_Token instance
+ *
+ * @return Twig_NodeInterface A Twig_NodeInterface instance
+ */
+ public function parse(Twig_Token $token)
+ {
+ $expr = $this->parser->getExpressionParser()->parseExpression();
+
+ list($variables, $only, $ignoreMissing) = $this->parseArguments();
+
+ return new Twig_Node_Include($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag());
+ }
+
+ protected function parseArguments()
+ {
+ $stream = $this->parser->getStream();
+
+ $ignoreMissing = false;
+ if ($stream->nextIf(Twig_Token::NAME_TYPE, 'ignore')) {
+ $stream->expect(Twig_Token::NAME_TYPE, 'missing');
+
+ $ignoreMissing = true;
+ }
+
+ $variables = null;
+ if ($stream->nextIf(Twig_Token::NAME_TYPE, 'with')) {
+ $variables = $this->parser->getExpressionParser()->parseExpression();
+ }
+
+ $only = false;
+ if ($stream->nextIf(Twig_Token::NAME_TYPE, 'only')) {
+ $only = true;
+ }
+
+ $stream->expect(Twig_Token::BLOCK_END_TYPE);
+
+ return array($variables, $only, $ignoreMissing);
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'include';
+ }
+}
diff --git a/Twig/TokenParser/Macro.php b/Twig/TokenParser/Macro.php
new file mode 100644
index 0000000..ad910b5
--- /dev/null
+++ b/Twig/TokenParser/Macro.php
@@ -0,0 +1,68 @@
+
+ * {% macro input(name, value, type, size) %}
+ *
+ * {% endmacro %}
+ *
+ */
+class Twig_TokenParser_Macro extends Twig_TokenParser
+{
+ /**
+ * Parses a token and returns a node.
+ *
+ * @param Twig_Token $token A Twig_Token instance
+ *
+ * @return Twig_NodeInterface A Twig_NodeInterface instance
+ */
+ public function parse(Twig_Token $token)
+ {
+ $lineno = $token->getLine();
+ $stream = $this->parser->getStream();
+ $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
+
+ $arguments = $this->parser->getExpressionParser()->parseArguments(true, true);
+
+ $stream->expect(Twig_Token::BLOCK_END_TYPE);
+ $this->parser->pushLocalScope();
+ $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+ if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) {
+ $value = $token->getValue();
+
+ if ($value != $name) {
+ throw new Twig_Error_Syntax(sprintf('Expected endmacro for macro "%s" (but "%s" given)', $name, $value), $stream->getCurrent()->getLine(), $stream->getFilename());
+ }
+ }
+ $this->parser->popLocalScope();
+ $stream->expect(Twig_Token::BLOCK_END_TYPE);
+
+ $this->parser->setMacro($name, new Twig_Node_Macro($name, new Twig_Node_Body(array($body)), $arguments, $lineno, $this->getTag()));
+ }
+
+ public function decideBlockEnd(Twig_Token $token)
+ {
+ return $token->test('endmacro');
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'macro';
+ }
+}
diff --git a/Twig/TokenParser/Sandbox.php b/Twig/TokenParser/Sandbox.php
new file mode 100644
index 0000000..9457325
--- /dev/null
+++ b/Twig/TokenParser/Sandbox.php
@@ -0,0 +1,68 @@
+
+ * {% sandbox %}
+ * {% include 'user.html' %}
+ * {% endsandbox %}
+ *
+ *
+ * @see http://www.twig-project.org/doc/api.html#sandbox-extension for details
+ */
+class Twig_TokenParser_Sandbox extends Twig_TokenParser
+{
+ /**
+ * Parses a token and returns a node.
+ *
+ * @param Twig_Token $token A Twig_Token instance
+ *
+ * @return Twig_NodeInterface A Twig_NodeInterface instance
+ */
+ public function parse(Twig_Token $token)
+ {
+ $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+ $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+ $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+
+ // in a sandbox tag, only include tags are allowed
+ if (!$body instanceof Twig_Node_Include) {
+ foreach ($body as $node) {
+ if ($node instanceof Twig_Node_Text && ctype_space($node->getAttribute('data'))) {
+ continue;
+ }
+
+ if (!$node instanceof Twig_Node_Include) {
+ throw new Twig_Error_Syntax('Only "include" tags are allowed within a "sandbox" section', $node->getLine(), $this->parser->getFilename());
+ }
+ }
+ }
+
+ return new Twig_Node_Sandbox($body, $token->getLine(), $this->getTag());
+ }
+
+ public function decideBlockEnd(Twig_Token $token)
+ {
+ return $token->test('endsandbox');
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'sandbox';
+ }
+}
diff --git a/Twig/TokenParser/Set.php b/Twig/TokenParser/Set.php
new file mode 100644
index 0000000..0b41909
--- /dev/null
+++ b/Twig/TokenParser/Set.php
@@ -0,0 +1,83 @@
+
+ * {% set foo = 'foo' %}
+ *
+ * {% set foo = [1, 2] %}
+ *
+ * {% set foo = {'foo': 'bar'} %}
+ *
+ * {% set foo = 'foo' ~ 'bar' %}
+ *
+ * {% set foo, bar = 'foo', 'bar' %}
+ *
+ * {% set foo %}Some content{% endset %}
+ *
+ */
+class Twig_TokenParser_Set extends Twig_TokenParser
+{
+ /**
+ * Parses a token and returns a node.
+ *
+ * @param Twig_Token $token A Twig_Token instance
+ *
+ * @return Twig_NodeInterface A Twig_NodeInterface instance
+ */
+ public function parse(Twig_Token $token)
+ {
+ $lineno = $token->getLine();
+ $stream = $this->parser->getStream();
+ $names = $this->parser->getExpressionParser()->parseAssignmentExpression();
+
+ $capture = false;
+ if ($stream->nextIf(Twig_Token::OPERATOR_TYPE, '=')) {
+ $values = $this->parser->getExpressionParser()->parseMultitargetExpression();
+
+ $stream->expect(Twig_Token::BLOCK_END_TYPE);
+
+ if (count($names) !== count($values)) {
+ throw new Twig_Error_Syntax('When using set, you must have the same number of variables and assignments.', $stream->getCurrent()->getLine(), $stream->getFilename());
+ }
+ } else {
+ $capture = true;
+
+ if (count($names) > 1) {
+ throw new Twig_Error_Syntax('When using set with a block, you cannot have a multi-target.', $stream->getCurrent()->getLine(), $stream->getFilename());
+ }
+
+ $stream->expect(Twig_Token::BLOCK_END_TYPE);
+
+ $values = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
+ $stream->expect(Twig_Token::BLOCK_END_TYPE);
+ }
+
+ return new Twig_Node_Set($capture, $names, $values, $lineno, $this->getTag());
+ }
+
+ public function decideBlockEnd(Twig_Token $token)
+ {
+ return $token->test('endset');
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'set';
+ }
+}
diff --git a/Twig/TokenParser/Spaceless.php b/Twig/TokenParser/Spaceless.php
new file mode 100644
index 0000000..1e3fa8f
--- /dev/null
+++ b/Twig/TokenParser/Spaceless.php
@@ -0,0 +1,59 @@
+
+ * {% spaceless %}
+ *
+ * foo
+ *
+ * {% endspaceless %}
+ *
+ * {# output will be foo
#}
+ *
+ */
+class Twig_TokenParser_Spaceless extends Twig_TokenParser
+{
+ /**
+ * Parses a token and returns a node.
+ *
+ * @param Twig_Token $token A Twig_Token instance
+ *
+ * @return Twig_NodeInterface A Twig_NodeInterface instance
+ */
+ public function parse(Twig_Token $token)
+ {
+ $lineno = $token->getLine();
+
+ $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+ $body = $this->parser->subparse(array($this, 'decideSpacelessEnd'), true);
+ $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
+
+ return new Twig_Node_Spaceless($body, $lineno, $this->getTag());
+ }
+
+ public function decideSpacelessEnd(Twig_Token $token)
+ {
+ return $token->test('endspaceless');
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'spaceless';
+ }
+}
diff --git a/Twig/TokenParser/Use.php b/Twig/TokenParser/Use.php
new file mode 100644
index 0000000..3ea68b1
--- /dev/null
+++ b/Twig/TokenParser/Use.php
@@ -0,0 +1,76 @@
+
+ * {% extends "base.html" %}
+ *
+ * {% use "blocks.html" %}
+ *
+ * {% block title %}{% endblock %}
+ * {% block content %}{% endblock %}
+ *
+ *
+ * @see http://www.twig-project.org/doc/templates.html#horizontal-reuse for details.
+ */
+class Twig_TokenParser_Use extends Twig_TokenParser
+{
+ /**
+ * Parses a token and returns a node.
+ *
+ * @param Twig_Token $token A Twig_Token instance
+ *
+ * @return Twig_NodeInterface A Twig_NodeInterface instance
+ */
+ public function parse(Twig_Token $token)
+ {
+ $template = $this->parser->getExpressionParser()->parseExpression();
+ $stream = $this->parser->getStream();
+
+ if (!$template instanceof Twig_Node_Expression_Constant) {
+ throw new Twig_Error_Syntax('The template references in a "use" statement must be a string.', $stream->getCurrent()->getLine(), $stream->getFilename());
+ }
+
+ $targets = array();
+ if ($stream->nextIf('with')) {
+ do {
+ $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
+
+ $alias = $name;
+ if ($stream->nextIf('as')) {
+ $alias = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
+ }
+
+ $targets[$name] = new Twig_Node_Expression_Constant($alias, -1);
+
+ if (!$stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) {
+ break;
+ }
+ } while (true);
+ }
+
+ $stream->expect(Twig_Token::BLOCK_END_TYPE);
+
+ $this->parser->addTrait(new Twig_Node(array('template' => $template, 'targets' => new Twig_Node($targets))));
+ }
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag()
+ {
+ return 'use';
+ }
+}
diff --git a/Twig/TokenParserBroker.php b/Twig/TokenParserBroker.php
new file mode 100644
index 0000000..6ca73fb
--- /dev/null
+++ b/Twig/TokenParserBroker.php
@@ -0,0 +1,141 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
+{
+ protected $parser;
+ protected $parsers = array();
+ protected $brokers = array();
+
+ /**
+ * Constructor.
+ *
+ * @param array|Traversable $parsers A Traversable of Twig_TokenParserInterface instances
+ * @param array|Traversable $brokers A Traversable of Twig_TokenParserBrokerInterface instances
+ */
+ public function __construct($parsers = array(), $brokers = array(), $triggerDeprecationError = true)
+ {
+ if ($triggerDeprecationError) {
+ @trigger_error('The '.__CLASS__.' class is deprecated since version 1.12 and will be removed in 2.0.', E_USER_DEPRECATED);
+ }
+
+ foreach ($parsers as $parser) {
+ if (!$parser instanceof Twig_TokenParserInterface) {
+ throw new LogicException('$parsers must a an array of Twig_TokenParserInterface');
+ }
+ $this->parsers[$parser->getTag()] = $parser;
+ }
+ foreach ($brokers as $broker) {
+ if (!$broker instanceof Twig_TokenParserBrokerInterface) {
+ throw new LogicException('$brokers must a an array of Twig_TokenParserBrokerInterface');
+ }
+ $this->brokers[] = $broker;
+ }
+ }
+
+ /**
+ * Adds a TokenParser.
+ *
+ * @param Twig_TokenParserInterface $parser A Twig_TokenParserInterface instance
+ */
+ public function addTokenParser(Twig_TokenParserInterface $parser)
+ {
+ $this->parsers[$parser->getTag()] = $parser;
+ }
+
+ /**
+ * Removes a TokenParser.
+ *
+ * @param Twig_TokenParserInterface $parser A Twig_TokenParserInterface instance
+ */
+ public function removeTokenParser(Twig_TokenParserInterface $parser)
+ {
+ $name = $parser->getTag();
+ if (isset($this->parsers[$name]) && $parser === $this->parsers[$name]) {
+ unset($this->parsers[$name]);
+ }
+ }
+
+ /**
+ * Adds a TokenParserBroker.
+ *
+ * @param Twig_TokenParserBroker $broker A Twig_TokenParserBroker instance
+ */
+ public function addTokenParserBroker(Twig_TokenParserBroker $broker)
+ {
+ $this->brokers[] = $broker;
+ }
+
+ /**
+ * Removes a TokenParserBroker.
+ *
+ * @param Twig_TokenParserBroker $broker A Twig_TokenParserBroker instance
+ */
+ public function removeTokenParserBroker(Twig_TokenParserBroker $broker)
+ {
+ if (false !== $pos = array_search($broker, $this->brokers)) {
+ unset($this->brokers[$pos]);
+ }
+ }
+
+ /**
+ * Gets a suitable TokenParser for a tag.
+ *
+ * First looks in parsers, then in brokers.
+ *
+ * @param string $tag A tag name
+ *
+ * @return null|Twig_TokenParserInterface A Twig_TokenParserInterface or null if no suitable TokenParser was found
+ */
+ public function getTokenParser($tag)
+ {
+ if (isset($this->parsers[$tag])) {
+ return $this->parsers[$tag];
+ }
+ $broker = end($this->brokers);
+ while (false !== $broker) {
+ $parser = $broker->getTokenParser($tag);
+ if (null !== $parser) {
+ return $parser;
+ }
+ $broker = prev($this->brokers);
+ }
+ }
+
+ public function getParsers()
+ {
+ return $this->parsers;
+ }
+
+ public function getParser()
+ {
+ return $this->parser;
+ }
+
+ public function setParser(Twig_ParserInterface $parser)
+ {
+ $this->parser = $parser;
+ foreach ($this->parsers as $tokenParser) {
+ $tokenParser->setParser($parser);
+ }
+ foreach ($this->brokers as $broker) {
+ $broker->setParser($parser);
+ }
+ }
+}
diff --git a/Twig/TokenParserBrokerInterface.php b/Twig/TokenParserBrokerInterface.php
new file mode 100644
index 0000000..3ec2a88
--- /dev/null
+++ b/Twig/TokenParserBrokerInterface.php
@@ -0,0 +1,46 @@
+
+ *
+ * @deprecated since 1.12 (to be removed in 2.0)
+ */
+interface Twig_TokenParserBrokerInterface
+{
+ /**
+ * Gets a TokenParser suitable for a tag.
+ *
+ * @param string $tag A tag name
+ *
+ * @return null|Twig_TokenParserInterface A Twig_TokenParserInterface or null if no suitable TokenParser was found
+ */
+ public function getTokenParser($tag);
+
+ /**
+ * Calls Twig_TokenParserInterface::setParser on all parsers the implementation knows of.
+ *
+ * @param Twig_ParserInterface $parser A Twig_ParserInterface interface
+ */
+ public function setParser(Twig_ParserInterface $parser);
+
+ /**
+ * Gets the Twig_ParserInterface.
+ *
+ * @return null|Twig_ParserInterface A Twig_ParserInterface instance or null
+ */
+ public function getParser();
+}
diff --git a/Twig/TokenParserInterface.php b/Twig/TokenParserInterface.php
new file mode 100644
index 0000000..12ec396
--- /dev/null
+++ b/Twig/TokenParserInterface.php
@@ -0,0 +1,43 @@
+
+ */
+interface Twig_TokenParserInterface
+{
+ /**
+ * Sets the parser associated with this token parser.
+ *
+ * @param Twig_Parser $parser A Twig_Parser instance
+ */
+ public function setParser(Twig_Parser $parser);
+
+ /**
+ * Parses a token and returns a node.
+ *
+ * @param Twig_Token $token A Twig_Token instance
+ *
+ * @return Twig_NodeInterface A Twig_NodeInterface instance
+ *
+ * @throws Twig_Error_Syntax
+ */
+ public function parse(Twig_Token $token);
+
+ /**
+ * Gets the tag name associated with this token parser.
+ *
+ * @return string The tag name
+ */
+ public function getTag();
+}
diff --git a/Twig/TokenStream.php b/Twig/TokenStream.php
new file mode 100644
index 0000000..8d2e220
--- /dev/null
+++ b/Twig/TokenStream.php
@@ -0,0 +1,155 @@
+
+ */
+class Twig_TokenStream
+{
+ protected $tokens;
+ protected $current = 0;
+ protected $filename;
+
+ /**
+ * Constructor.
+ *
+ * @param array $tokens An array of tokens
+ * @param string $filename The name of the filename which tokens are associated with
+ */
+ public function __construct(array $tokens, $filename = null)
+ {
+ $this->tokens = $tokens;
+ $this->filename = $filename;
+ }
+
+ /**
+ * Returns a string representation of the token stream.
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return implode("\n", $this->tokens);
+ }
+
+ public function injectTokens(array $tokens)
+ {
+ $this->tokens = array_merge(array_slice($this->tokens, 0, $this->current), $tokens, array_slice($this->tokens, $this->current));
+ }
+
+ /**
+ * Sets the pointer to the next token and returns the old one.
+ *
+ * @return Twig_Token
+ */
+ public function next()
+ {
+ if (!isset($this->tokens[++$this->current])) {
+ throw new Twig_Error_Syntax('Unexpected end of template', $this->tokens[$this->current - 1]->getLine(), $this->filename);
+ }
+
+ return $this->tokens[$this->current - 1];
+ }
+
+ /**
+ * Tests a token, sets the pointer to the next one and returns it or throws a syntax error.
+ *
+ * @return Twig_Token|null The next token if the condition is true, null otherwise
+ */
+ public function nextIf($primary, $secondary = null)
+ {
+ if ($this->tokens[$this->current]->test($primary, $secondary)) {
+ return $this->next();
+ }
+ }
+
+ /**
+ * Tests a token and returns it or throws a syntax error.
+ *
+ * @return Twig_Token
+ */
+ public function expect($type, $value = null, $message = null)
+ {
+ $token = $this->tokens[$this->current];
+ if (!$token->test($type, $value)) {
+ $line = $token->getLine();
+ throw new Twig_Error_Syntax(sprintf('%sUnexpected token "%s" of value "%s" ("%s" expected%s)',
+ $message ? $message.'. ' : '',
+ Twig_Token::typeToEnglish($token->getType()), $token->getValue(),
+ Twig_Token::typeToEnglish($type), $value ? sprintf(' with value "%s"', $value) : ''),
+ $line,
+ $this->filename
+ );
+ }
+ $this->next();
+
+ return $token;
+ }
+
+ /**
+ * Looks at the next token.
+ *
+ * @param int $number
+ *
+ * @return Twig_Token
+ */
+ public function look($number = 1)
+ {
+ if (!isset($this->tokens[$this->current + $number])) {
+ throw new Twig_Error_Syntax('Unexpected end of template', $this->tokens[$this->current + $number - 1]->getLine(), $this->filename);
+ }
+
+ return $this->tokens[$this->current + $number];
+ }
+
+ /**
+ * Tests the current token.
+ *
+ * @return bool
+ */
+ public function test($primary, $secondary = null)
+ {
+ return $this->tokens[$this->current]->test($primary, $secondary);
+ }
+
+ /**
+ * Checks if end of stream was reached.
+ *
+ * @return bool
+ */
+ public function isEOF()
+ {
+ return $this->tokens[$this->current]->getType() === Twig_Token::EOF_TYPE;
+ }
+
+ /**
+ * Gets the current token.
+ *
+ * @return Twig_Token
+ */
+ public function getCurrent()
+ {
+ return $this->tokens[$this->current];
+ }
+
+ /**
+ * Gets the filename associated with this stream.
+ *
+ * @return string
+ */
+ public function getFilename()
+ {
+ return $this->filename;
+ }
+}
diff --git a/Twig/Util/DeprecationCollector.php b/Twig/Util/DeprecationCollector.php
new file mode 100644
index 0000000..e406f0a
--- /dev/null
+++ b/Twig/Util/DeprecationCollector.php
@@ -0,0 +1,82 @@
+
+ */
+class Twig_Util_DeprecationCollector
+{
+ private $twig;
+ private $deprecations;
+
+ public function __construct(Twig_Environment $twig)
+ {
+ $this->twig = $twig;
+ }
+
+ /**
+ * Returns deprecations for templates contained in a directory.
+ *
+ * @param string $dir A directory where templates are stored
+ * @param string $ext Limit the loaded templates by extension
+ *
+ * @return array() An array of deprecations
+ */
+ public function collectDir($dir, $ext = '.twig')
+ {
+ $iterator = new RegexIterator(
+ new RecursiveIteratorIterator(
+ new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY
+ ), '{'.preg_quote($ext).'$}'
+ );
+
+ return $this->collect(new Twig_Util_TemplateDirIterator($iterator));
+ }
+
+ /**
+ * Returns deprecations for passed templates.
+ *
+ * @param Iterator $iterator An iterator of templates (where keys are template names and values the contents of the template)
+ *
+ * @return array() An array of deprecations
+ */
+ public function collect(Iterator $iterator)
+ {
+ $this->deprecations = array();
+
+ set_error_handler(array($this, 'errorHandler'));
+
+ foreach ($iterator as $name => $contents) {
+ try {
+ $this->twig->parse($this->twig->tokenize($contents, $name));
+ } catch (Twig_Error_Syntax $e) {
+ // ignore templates containing syntax errors
+ }
+ }
+
+ restore_error_handler();
+
+ $deprecations = $this->deprecations;
+ $this->deprecations = array();
+
+ return $deprecations;
+ }
+
+ /**
+ * @internal
+ */
+ public function errorHandler($type, $msg)
+ {
+ if (E_USER_DEPRECATED === $type) {
+ $this->deprecations[] = $msg;
+ }
+ }
+}
diff --git a/Twig/Util/TemplateDirIterator.php b/Twig/Util/TemplateDirIterator.php
new file mode 100644
index 0000000..3fb8932
--- /dev/null
+++ b/Twig/Util/TemplateDirIterator.php
@@ -0,0 +1,26 @@
+
+ */
+class Twig_Util_TemplateDirIterator extends IteratorIterator
+{
+ public function current()
+ {
+ return file_get_contents(parent::current());
+ }
+
+ public function key()
+ {
+ return (string) parent::key();
+ }
+}
diff --git a/img/scene1-with.png b/img/scene1-with.png
new file mode 100644
index 0000000000000000000000000000000000000000..659271879aa596e623b09c8274be026994abc1fd
GIT binary patch
literal 195683
zcmd3NWmFu|wq_J}3l0s9yE}wN8wsw#-Jx+OK;!NX!QBGECAhl<5ANJ$!^%_I4~@)iJZ3u1
ze0do5_V8Xpz3p<_?-+4FYF<4aKJ4Z@X&DHBG{L5mpo{c-5h(*=%Ty*ux&ILs6E5mwwHk@+nHh}Se
z%x(PI;z%>9-IOPp%`@R5wB(N#tAX#Ud%Ohy9tP=G17w5Q`_a|uf82kH@rmctr%#03
zp6Vk=sWpK&UGLFBK0ZFcK{rLkSbO|`r@i-^W}B9dKxj7l8VJt1_rPcUI0%*u`u6SH
zR5S~-e^H)DGBjEOqZ17PWdTC%8Dvf1z;GOR|GvzUKFp1&U^o$Sa_A657uSDo8TCJT
z@WYVmIygCrnL&l&rW^-~D53xHD4+g0JMXh%Y;`7aB)Lisq(v!fBC9F>km`=gzvRXB
z7)gZb+$`y3IIMteW22}2*ABk^CN(c7d}I~Pqd=@)Te3(^nXNDV!ZCh|+R6z`
zu1rMIx{3gJo^oz&6&kw8&$}K^Rebq7W9pHsSi0Gkag`RdhC3-d&~s^MSueO4TAzfuXYT203Iv)nAM-?g-10A~83}
z2EQISf%84>&>DDia)=~`{RR>?ri8(5
zu)h~n_B@SxD-pP5W!hN9pZ^%)xu9q4wp^&2^CDVIlBT^cdrz9yZEo6{Cwxa8yB$16
zyT@YG`L0=|Vlh8a#q0UW`-|dHG*2m6UHnJ7Eo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