├── .gitignore ├── LICENSE ├── README.md ├── ansible-callbacks ├── .gitignore ├── ansible-logger.conf.dist └── logger.py ├── ansible-logger-web ├── .gitignore ├── config │ └── config.inc.php.dist ├── includes │ ├── Slim │ │ ├── Environment.php │ │ ├── Exception │ │ │ ├── Pass.php │ │ │ └── Stop.php │ │ ├── Helper │ │ │ └── Set.php │ │ ├── Http │ │ │ ├── Cookies.php │ │ │ ├── Headers.php │ │ │ ├── Request.php │ │ │ ├── Response.php │ │ │ └── Util.php │ │ ├── Log.php │ │ ├── LogWriter.php │ │ ├── Middleware.php │ │ ├── Middleware │ │ │ ├── ContentTypes.php │ │ │ ├── Flash.php │ │ │ ├── MethodOverride.php │ │ │ ├── PrettyExceptions.php │ │ │ └── SessionCookie.php │ │ ├── Route.php │ │ ├── Router.php │ │ ├── Slim.php │ │ ├── View.php │ │ └── Views │ │ │ ├── Twig.php │ │ │ └── TwigExtension.php │ ├── Twig │ │ ├── Autoloader.php │ │ ├── Compiler.php │ │ ├── CompilerInterface.php │ │ ├── Environment.php │ │ ├── Error.php │ │ ├── Error │ │ │ ├── Loader.php │ │ │ ├── Runtime.php │ │ │ └── Syntax.php │ │ ├── ExistsLoaderInterface.php │ │ ├── ExpressionParser.php │ │ ├── Extension.php │ │ ├── Extension │ │ │ ├── Core.php │ │ │ ├── Debug.php │ │ │ ├── Escaper.php │ │ │ ├── Optimizer.php │ │ │ ├── Profiler.php │ │ │ ├── Sandbox.php │ │ │ ├── Staging.php │ │ │ └── StringLoader.php │ │ ├── ExtensionInterface.php │ │ ├── FileExtensionEscapingStrategy.php │ │ ├── Filter.php │ │ ├── Filter │ │ │ ├── Function.php │ │ │ ├── Method.php │ │ │ └── Node.php │ │ ├── FilterCallableInterface.php │ │ ├── FilterInterface.php │ │ ├── Function.php │ │ ├── Function │ │ │ ├── Function.php │ │ │ ├── Method.php │ │ │ └── Node.php │ │ ├── FunctionCallableInterface.php │ │ ├── FunctionInterface.php │ │ ├── Lexer.php │ │ ├── LexerInterface.php │ │ ├── Loader │ │ │ ├── Array.php │ │ │ ├── Chain.php │ │ │ ├── Filesystem.php │ │ │ └── String.php │ │ ├── LoaderInterface.php │ │ ├── Markup.php │ │ ├── Node.php │ │ ├── Node │ │ │ ├── AutoEscape.php │ │ │ ├── Block.php │ │ │ ├── BlockReference.php │ │ │ ├── Body.php │ │ │ ├── CheckSecurity.php │ │ │ ├── Do.php │ │ │ ├── Embed.php │ │ │ ├── Expression.php │ │ │ ├── Expression │ │ │ │ ├── Array.php │ │ │ │ ├── AssignName.php │ │ │ │ ├── Binary.php │ │ │ │ ├── Binary │ │ │ │ │ ├── Add.php │ │ │ │ │ ├── And.php │ │ │ │ │ ├── BitwiseAnd.php │ │ │ │ │ ├── BitwiseOr.php │ │ │ │ │ ├── BitwiseXor.php │ │ │ │ │ ├── Concat.php │ │ │ │ │ ├── Div.php │ │ │ │ │ ├── EndsWith.php │ │ │ │ │ ├── Equal.php │ │ │ │ │ ├── FloorDiv.php │ │ │ │ │ ├── Greater.php │ │ │ │ │ ├── GreaterEqual.php │ │ │ │ │ ├── In.php │ │ │ │ │ ├── Less.php │ │ │ │ │ ├── LessEqual.php │ │ │ │ │ ├── Matches.php │ │ │ │ │ ├── Mod.php │ │ │ │ │ ├── Mul.php │ │ │ │ │ ├── NotEqual.php │ │ │ │ │ ├── NotIn.php │ │ │ │ │ ├── Or.php │ │ │ │ │ ├── Power.php │ │ │ │ │ ├── Range.php │ │ │ │ │ ├── StartsWith.php │ │ │ │ │ └── Sub.php │ │ │ │ ├── BlockReference.php │ │ │ │ ├── Call.php │ │ │ │ ├── Conditional.php │ │ │ │ ├── Constant.php │ │ │ │ ├── ExtensionReference.php │ │ │ │ ├── Filter.php │ │ │ │ ├── Filter │ │ │ │ │ └── Default.php │ │ │ │ ├── Function.php │ │ │ │ ├── GetAttr.php │ │ │ │ ├── MethodCall.php │ │ │ │ ├── Name.php │ │ │ │ ├── Parent.php │ │ │ │ ├── TempName.php │ │ │ │ ├── Test.php │ │ │ │ ├── Test │ │ │ │ │ ├── Constant.php │ │ │ │ │ ├── Defined.php │ │ │ │ │ ├── Divisibleby.php │ │ │ │ │ ├── Even.php │ │ │ │ │ ├── Null.php │ │ │ │ │ ├── Odd.php │ │ │ │ │ └── Sameas.php │ │ │ │ ├── Unary.php │ │ │ │ └── Unary │ │ │ │ │ ├── Neg.php │ │ │ │ │ ├── Not.php │ │ │ │ │ └── Pos.php │ │ │ ├── Flush.php │ │ │ ├── For.php │ │ │ ├── ForLoop.php │ │ │ ├── If.php │ │ │ ├── Import.php │ │ │ ├── Include.php │ │ │ ├── Macro.php │ │ │ ├── Module.php │ │ │ ├── Print.php │ │ │ ├── Sandbox.php │ │ │ ├── SandboxedPrint.php │ │ │ ├── Set.php │ │ │ ├── SetTemp.php │ │ │ ├── Spaceless.php │ │ │ └── Text.php │ │ ├── NodeInterface.php │ │ ├── NodeOutputInterface.php │ │ ├── NodeTraverser.php │ │ ├── NodeVisitor │ │ │ ├── Escaper.php │ │ │ ├── Optimizer.php │ │ │ ├── SafeAnalysis.php │ │ │ └── Sandbox.php │ │ ├── NodeVisitorInterface.php │ │ ├── Parser.php │ │ ├── ParserInterface.php │ │ ├── Profiler │ │ │ ├── Dumper │ │ │ │ ├── Blackfire.php │ │ │ │ ├── Html.php │ │ │ │ └── Text.php │ │ │ ├── Node │ │ │ │ ├── EnterProfile.php │ │ │ │ └── LeaveProfile.php │ │ │ ├── NodeVisitor │ │ │ │ └── Profiler.php │ │ │ └── Profile.php │ │ ├── Sandbox │ │ │ ├── SecurityError.php │ │ │ ├── SecurityNotAllowedFilterError.php │ │ │ ├── SecurityNotAllowedFunctionError.php │ │ │ ├── SecurityNotAllowedTagError.php │ │ │ ├── SecurityPolicy.php │ │ │ └── SecurityPolicyInterface.php │ │ ├── SimpleFilter.php │ │ ├── SimpleFunction.php │ │ ├── SimpleTest.php │ │ ├── Template.php │ │ ├── TemplateInterface.php │ │ ├── Test.php │ │ ├── Test │ │ │ ├── Function.php │ │ │ ├── IntegrationTestCase.php │ │ │ ├── Method.php │ │ │ ├── Node.php │ │ │ └── NodeTestCase.php │ │ ├── TestCallableInterface.php │ │ ├── TestInterface.php │ │ ├── Token.php │ │ ├── TokenParser.php │ │ ├── TokenParser │ │ │ ├── AutoEscape.php │ │ │ ├── Block.php │ │ │ ├── Do.php │ │ │ ├── Embed.php │ │ │ ├── Extends.php │ │ │ ├── Filter.php │ │ │ ├── Flush.php │ │ │ ├── For.php │ │ │ ├── From.php │ │ │ ├── If.php │ │ │ ├── Import.php │ │ │ ├── Include.php │ │ │ ├── Macro.php │ │ │ ├── Sandbox.php │ │ │ ├── Set.php │ │ │ ├── Spaceless.php │ │ │ └── Use.php │ │ ├── TokenParserBroker.php │ │ ├── TokenParserBrokerInterface.php │ │ ├── TokenParserInterface.php │ │ └── TokenStream.php │ └── ansible-logger.php ├── public │ ├── .htaccess │ ├── index.php │ └── static │ │ ├── css │ │ ├── ansible-logger.css │ │ ├── bootstrap-theme.css │ │ ├── bootstrap-theme.css.map │ │ ├── bootstrap-theme.min.css │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ └── dashboard.css │ │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ │ └── js │ │ ├── bootstrap.js │ │ ├── bootstrap.min.js │ │ ├── bootstrap3-typeahead.js │ │ ├── ie10-viewport-bug-workaround.js │ │ └── npm.js └── tpl │ ├── index.html │ ├── page_dashboard.html │ ├── page_factbrowser.html │ ├── page_hostfactview.html │ ├── page_hostplayhistory.html │ ├── page_hosts.html │ └── page_playbookdetails.html ├── helpers └── dbprep │ ├── README.md │ ├── dbprep.py │ ├── facts │ ├── debian_wheezy │ ├── ubuntu_trusty_1 │ └── ubuntu_trusty_2 │ ├── hostnames │ ├── hostpatterns │ ├── playbooks │ └── tasks └── sql └── schema.sql /.gitignore: -------------------------------------------------------------------------------- 1 | venv/ 2 | .idea -------------------------------------------------------------------------------- /ansible-callbacks/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.conf 3 | -------------------------------------------------------------------------------- /ansible-callbacks/ansible-logger.conf.dist: -------------------------------------------------------------------------------- 1 | [database] 2 | host = localhost 3 | user = someuser 4 | password = somepassword 5 | db = somedatabase 6 | 7 | [log-settings] 8 | logging = false 9 | loglevel = debug 10 | logpath = /tmp/ 11 | 12 | -------------------------------------------------------------------------------- /ansible-logger-web/.gitignore: -------------------------------------------------------------------------------- 1 | config/*.php 2 | -------------------------------------------------------------------------------- /ansible-logger-web/config/config.inc.php.dist: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Slim/Exception/Pass.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright 2011 Josh Lockhart 7 | * @link http://www.slimframework.com 8 | * @license http://www.slimframework.com/license 9 | * @version 2.6.1 10 | * @package Slim 11 | * 12 | * MIT LICENSE 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining 15 | * a copy of this software and associated documentation files (the 16 | * "Software"), to deal in the Software without restriction, including 17 | * without limitation the rights to use, copy, modify, merge, publish, 18 | * distribute, sublicense, and/or sell copies of the Software, and to 19 | * permit persons to whom the Software is furnished to do so, subject to 20 | * the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be 23 | * included in all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | */ 33 | namespace Slim\Exception; 34 | 35 | /** 36 | * Pass Exception 37 | * 38 | * This Exception will cause the Router::dispatch method 39 | * to skip the current matching route and continue to the next 40 | * matching route. If no subsequent routes are found, a 41 | * HTTP 404 Not Found response will be sent to the client. 42 | * 43 | * @package Slim 44 | * @author Josh Lockhart 45 | * @since 1.0.0 46 | */ 47 | class Pass extends \Exception 48 | { 49 | } 50 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Slim/Exception/Stop.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright 2011 Josh Lockhart 7 | * @link http://www.slimframework.com 8 | * @license http://www.slimframework.com/license 9 | * @version 2.6.1 10 | * @package Slim 11 | * 12 | * MIT LICENSE 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining 15 | * a copy of this software and associated documentation files (the 16 | * "Software"), to deal in the Software without restriction, including 17 | * without limitation the rights to use, copy, modify, merge, publish, 18 | * distribute, sublicense, and/or sell copies of the Software, and to 19 | * permit persons to whom the Software is furnished to do so, subject to 20 | * the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be 23 | * included in all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | */ 33 | namespace Slim\Exception; 34 | 35 | /** 36 | * Stop Exception 37 | * 38 | * This Exception is thrown when the Slim application needs to abort 39 | * processing and return control flow to the outer PHP script. 40 | * 41 | * @package Slim 42 | * @author Josh Lockhart 43 | * @since 1.0.0 44 | */ 45 | class Stop extends \Exception 46 | { 47 | } 48 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Slim/LogWriter.php: -------------------------------------------------------------------------------- 1 | 6 | * @copyright 2011 Josh Lockhart 7 | * @link http://www.slimframework.com 8 | * @license http://www.slimframework.com/license 9 | * @version 2.6.1 10 | * @package Slim 11 | * 12 | * MIT LICENSE 13 | * 14 | * Permission is hereby granted, free of charge, to any person obtaining 15 | * a copy of this software and associated documentation files (the 16 | * "Software"), to deal in the Software without restriction, including 17 | * without limitation the rights to use, copy, modify, merge, publish, 18 | * distribute, sublicense, and/or sell copies of the Software, and to 19 | * permit persons to whom the Software is furnished to do so, subject to 20 | * the following conditions: 21 | * 22 | * The above copyright notice and this permission notice shall be 23 | * included in all copies or substantial portions of the Software. 24 | * 25 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 29 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 30 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 31 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 32 | */ 33 | namespace Slim; 34 | 35 | /** 36 | * Log Writer 37 | * 38 | * This class is used by Slim_Log to write log messages to a valid, writable 39 | * resource handle (e.g. a file or STDERR). 40 | * 41 | * @package Slim 42 | * @author Josh Lockhart 43 | * @since 1.6.0 44 | */ 45 | class LogWriter 46 | { 47 | /** 48 | * @var resource 49 | */ 50 | protected $resource; 51 | 52 | /** 53 | * Constructor 54 | * @param resource $resource 55 | * @throws \InvalidArgumentException If invalid resource 56 | */ 57 | public function __construct($resource) 58 | { 59 | if (!is_resource($resource)) { 60 | throw new \InvalidArgumentException('Cannot create LogWriter. Invalid resource handle.'); 61 | } 62 | $this->resource = $resource; 63 | } 64 | 65 | /** 66 | * Write message 67 | * @param mixed $message 68 | * @param int $level 69 | * @return int|bool 70 | */ 71 | public function write($message, $level = null) 72 | { 73 | return fwrite($this->resource, (string) $message . PHP_EOL); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Autoloader.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Autoloader 18 | { 19 | /** 20 | * Registers Twig_Autoloader as an SPL autoloader. 21 | * 22 | * @param bool $prepend Whether to prepend the autoloader or not. 23 | */ 24 | public static function register($prepend = false) 25 | { 26 | if (PHP_VERSION_ID < 50300) { 27 | spl_autoload_register(array(__CLASS__, 'autoload')); 28 | } else { 29 | spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend); 30 | } 31 | } 32 | 33 | /** 34 | * Handles autoloading of classes. 35 | * 36 | * @param string $class A class name. 37 | */ 38 | public static function autoload($class) 39 | { 40 | if (0 !== strpos($class, 'Twig')) { 41 | return; 42 | } 43 | 44 | if (is_file($file = dirname(__FILE__).'/../'.str_replace(array('_', "\0"), array('/', ''), $class).'.php')) { 45 | require $file; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/CompilerInterface.php: -------------------------------------------------------------------------------- 1 | 16 | * 17 | * @deprecated since 1.12 (to be removed in 3.0) 18 | */ 19 | interface Twig_CompilerInterface 20 | { 21 | /** 22 | * Compiles a node. 23 | * 24 | * @param Twig_NodeInterface $node The node to compile 25 | * 26 | * @return Twig_CompilerInterface The current compiler instance 27 | */ 28 | public function compile(Twig_NodeInterface $node); 29 | 30 | /** 31 | * Gets the current PHP code after compilation. 32 | * 33 | * @return string The PHP code 34 | */ 35 | public function getSource(); 36 | } 37 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Error/Loader.php: -------------------------------------------------------------------------------- 1 | 24 | */ 25 | class Twig_Error_Loader extends Twig_Error 26 | { 27 | public function __construct($message, $lineno = -1, $filename = null, Exception $previous = null) 28 | { 29 | parent::__construct($message, false, false, $previous); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Error/Runtime.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Error_Runtime extends Twig_Error 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Error/Syntax.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Error_Syntax extends Twig_Error 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/ExistsLoaderInterface.php: -------------------------------------------------------------------------------- 1 | 16 | * 17 | * @deprecated since 1.12 (to be removed in 3.0) 18 | */ 19 | interface Twig_ExistsLoaderInterface 20 | { 21 | /** 22 | * Check if we have the source code of a template, given its name. 23 | * 24 | * @param string $name The name of the template to check if we can load 25 | * 26 | * @return bool If the template source code is handled by this loader or not 27 | */ 28 | public function exists($name); 29 | } 30 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Extension.php: -------------------------------------------------------------------------------- 1 | $isDumpOutputHtmlSafe ? array('html') : array(), 'needs_context' => true, 'needs_environment' => true)), 32 | ); 33 | } 34 | 35 | /** 36 | * Returns the name of the extension. 37 | * 38 | * @return string The extension name 39 | */ 40 | public function getName() 41 | { 42 | return 'debug'; 43 | } 44 | } 45 | 46 | function twig_var_dump(Twig_Environment $env, $context) 47 | { 48 | if (!$env->isDebug()) { 49 | return; 50 | } 51 | 52 | ob_start(); 53 | 54 | $count = func_num_args(); 55 | if (2 === $count) { 56 | $vars = array(); 57 | foreach ($context as $key => $value) { 58 | if (!$value instanceof Twig_Template) { 59 | $vars[$key] = $value; 60 | } 61 | } 62 | 63 | var_dump($vars); 64 | } else { 65 | for ($i = 2; $i < $count; $i++) { 66 | var_dump(func_get_arg($i)); 67 | } 68 | } 69 | 70 | return ob_get_clean(); 71 | } 72 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Extension/Optimizer.php: -------------------------------------------------------------------------------- 1 | optimizers = $optimizers; 18 | } 19 | 20 | /** 21 | * {@inheritdoc} 22 | */ 23 | public function getNodeVisitors() 24 | { 25 | return array(new Twig_NodeVisitor_Optimizer($this->optimizers)); 26 | } 27 | 28 | /** 29 | * {@inheritdoc} 30 | */ 31 | public function getName() 32 | { 33 | return 'optimizer'; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Extension/Profiler.php: -------------------------------------------------------------------------------- 1 | actives = array($profile); 19 | } 20 | 21 | public function enter(Twig_Profiler_Profile $profile) 22 | { 23 | $this->actives[0]->addProfile($profile); 24 | array_unshift($this->actives, $profile); 25 | } 26 | 27 | public function leave(Twig_Profiler_Profile $profile) 28 | { 29 | $profile->leave(); 30 | array_shift($this->actives); 31 | 32 | if (1 === count($this->actives)) { 33 | $this->actives[0]->leave(); 34 | } 35 | } 36 | 37 | /** 38 | * {@inheritdoc} 39 | */ 40 | public function getNodeVisitors() 41 | { 42 | return array(new Twig_Profiler_NodeVisitor_Profiler($this->getName())); 43 | } 44 | 45 | /** 46 | * {@inheritdoc} 47 | */ 48 | public function getName() 49 | { 50 | return 'profiler'; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Extension/Staging.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_Extension_Staging extends Twig_Extension 20 | { 21 | protected $functions = array(); 22 | protected $filters = array(); 23 | protected $visitors = array(); 24 | protected $tokenParsers = array(); 25 | protected $globals = array(); 26 | protected $tests = array(); 27 | 28 | public function addFunction($name, $function) 29 | { 30 | $this->functions[$name] = $function; 31 | } 32 | 33 | /** 34 | * {@inheritdoc} 35 | */ 36 | public function getFunctions() 37 | { 38 | return $this->functions; 39 | } 40 | 41 | public function addFilter($name, $filter) 42 | { 43 | $this->filters[$name] = $filter; 44 | } 45 | 46 | /** 47 | * {@inheritdoc} 48 | */ 49 | public function getFilters() 50 | { 51 | return $this->filters; 52 | } 53 | 54 | public function addNodeVisitor(Twig_NodeVisitorInterface $visitor) 55 | { 56 | $this->visitors[] = $visitor; 57 | } 58 | 59 | /** 60 | * {@inheritdoc} 61 | */ 62 | public function getNodeVisitors() 63 | { 64 | return $this->visitors; 65 | } 66 | 67 | public function addTokenParser(Twig_TokenParserInterface $parser) 68 | { 69 | $this->tokenParsers[] = $parser; 70 | } 71 | 72 | /** 73 | * {@inheritdoc} 74 | */ 75 | public function getTokenParsers() 76 | { 77 | return $this->tokenParsers; 78 | } 79 | 80 | public function addGlobal($name, $value) 81 | { 82 | $this->globals[$name] = $value; 83 | } 84 | 85 | /** 86 | * {@inheritdoc} 87 | */ 88 | public function getGlobals() 89 | { 90 | return $this->globals; 91 | } 92 | 93 | public function addTest($name, $test) 94 | { 95 | $this->tests[$name] = $test; 96 | } 97 | 98 | /** 99 | * {@inheritdoc} 100 | */ 101 | public function getTests() 102 | { 103 | return $this->tests; 104 | } 105 | 106 | /** 107 | * {@inheritdoc} 108 | */ 109 | public function getName() 110 | { 111 | return 'staging'; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Extension/StringLoader.php: -------------------------------------------------------------------------------- 1 | true)), 20 | ); 21 | } 22 | 23 | /** 24 | * {@inheritdoc} 25 | */ 26 | public function getName() 27 | { 28 | return 'string_loader'; 29 | } 30 | } 31 | 32 | /** 33 | * Loads a template from a string. 34 | * 35 | *
36 |  * {{ include(template_from_string("Hello {{ name }}")) }}
37 |  * 
38 | * 39 | * @param Twig_Environment $env A Twig_Environment instance 40 | * @param string $template A template as a string 41 | * 42 | * @return Twig_Template A Twig_Template instance 43 | */ 44 | function twig_template_from_string(Twig_Environment $env, $template) 45 | { 46 | return $env->createTemplate($template); 47 | } 48 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/ExtensionInterface.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | interface Twig_ExtensionInterface 18 | { 19 | /** 20 | * Initializes the runtime environment. 21 | * 22 | * This is where you can load some file that contains filter functions for instance. 23 | * 24 | * @param Twig_Environment $environment The current Twig_Environment instance 25 | */ 26 | public function initRuntime(Twig_Environment $environment); 27 | 28 | /** 29 | * Returns the token parser instances to add to the existing list. 30 | * 31 | * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances 32 | */ 33 | public function getTokenParsers(); 34 | 35 | /** 36 | * Returns the node visitor instances to add to the existing list. 37 | * 38 | * @return Twig_NodeVisitorInterface[] An array of Twig_NodeVisitorInterface instances 39 | */ 40 | public function getNodeVisitors(); 41 | 42 | /** 43 | * Returns a list of filters to add to the existing list. 44 | * 45 | * @return array An array of filters 46 | */ 47 | public function getFilters(); 48 | 49 | /** 50 | * Returns a list of tests to add to the existing list. 51 | * 52 | * @return array An array of tests 53 | */ 54 | public function getTests(); 55 | 56 | /** 57 | * Returns a list of functions to add to the existing list. 58 | * 59 | * @return array An array of functions 60 | */ 61 | public function getFunctions(); 62 | 63 | /** 64 | * Returns a list of operators to add to the existing list. 65 | * 66 | * @return array An array of operators 67 | */ 68 | public function getOperators(); 69 | 70 | /** 71 | * Returns a list of global variables to add to the existing list. 72 | * 73 | * @return array An array of global variables 74 | */ 75 | public function getGlobals(); 76 | 77 | /** 78 | * Returns the name of the extension. 79 | * 80 | * @return string The extension name 81 | */ 82 | public function getName(); 83 | } 84 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/FileExtensionEscapingStrategy.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | class Twig_FileExtensionEscapingStrategy 24 | { 25 | /** 26 | * Guesses the best autoescaping strategy based on the file name. 27 | * 28 | * @param string $filename The template file name 29 | * 30 | * @return string The escaping strategy name to use 31 | */ 32 | public static function guess($filename) 33 | { 34 | if (!preg_match('{\.(js|css|txt)(?:\.[^/\\\\]+)?$}', $filename, $match)) { 35 | return 'html'; 36 | } 37 | 38 | switch ($match[1]) { 39 | case 'js': 40 | return 'js'; 41 | 42 | case 'css': 43 | return 'css'; 44 | 45 | case 'txt': 46 | return false; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Filter.php: -------------------------------------------------------------------------------- 1 | 18 | * @deprecated since 1.12 (to be removed in 2.0) 19 | */ 20 | abstract class Twig_Filter implements Twig_FilterInterface, Twig_FilterCallableInterface 21 | { 22 | protected $options; 23 | protected $arguments = array(); 24 | 25 | public function __construct(array $options = array()) 26 | { 27 | $this->options = array_merge(array( 28 | 'needs_environment' => false, 29 | 'needs_context' => false, 30 | 'pre_escape' => null, 31 | 'preserves_safety' => null, 32 | 'callable' => null, 33 | ), $options); 34 | } 35 | 36 | public function setArguments($arguments) 37 | { 38 | $this->arguments = $arguments; 39 | } 40 | 41 | public function getArguments() 42 | { 43 | return $this->arguments; 44 | } 45 | 46 | public function needsEnvironment() 47 | { 48 | return $this->options['needs_environment']; 49 | } 50 | 51 | public function needsContext() 52 | { 53 | return $this->options['needs_context']; 54 | } 55 | 56 | public function getSafe(Twig_Node $filterArgs) 57 | { 58 | if (isset($this->options['is_safe'])) { 59 | return $this->options['is_safe']; 60 | } 61 | 62 | if (isset($this->options['is_safe_callback'])) { 63 | return call_user_func($this->options['is_safe_callback'], $filterArgs); 64 | } 65 | } 66 | 67 | public function getPreservesSafety() 68 | { 69 | return $this->options['preserves_safety']; 70 | } 71 | 72 | public function getPreEscape() 73 | { 74 | return $this->options['pre_escape']; 75 | } 76 | 77 | public function getCallable() 78 | { 79 | return $this->options['callable']; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Filter/Function.php: -------------------------------------------------------------------------------- 1 | 18 | * @deprecated since 1.12 (to be removed in 2.0) 19 | */ 20 | class Twig_Filter_Function extends Twig_Filter 21 | { 22 | protected $function; 23 | 24 | public function __construct($function, array $options = array()) 25 | { 26 | $options['callable'] = $function; 27 | 28 | parent::__construct($options); 29 | 30 | $this->function = $function; 31 | } 32 | 33 | public function compile() 34 | { 35 | return $this->function; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Filter/Method.php: -------------------------------------------------------------------------------- 1 | 18 | * @deprecated since 1.12 (to be removed in 2.0) 19 | */ 20 | class Twig_Filter_Method extends Twig_Filter 21 | { 22 | protected $extension; 23 | protected $method; 24 | 25 | public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array()) 26 | { 27 | $options['callable'] = array($extension, $method); 28 | 29 | parent::__construct($options); 30 | 31 | $this->extension = $extension; 32 | $this->method = $method; 33 | } 34 | 35 | public function compile() 36 | { 37 | return sprintf('$this->env->getExtension(\'%s\')->%s', $this->extension->getName(), $this->method); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Filter/Node.php: -------------------------------------------------------------------------------- 1 | 18 | * @deprecated since 1.12 (to be removed in 2.0) 19 | */ 20 | class Twig_Filter_Node extends Twig_Filter 21 | { 22 | protected $class; 23 | 24 | public function __construct($class, array $options = array()) 25 | { 26 | parent::__construct($options); 27 | 28 | $this->class = $class; 29 | } 30 | 31 | public function getClass() 32 | { 33 | return $this->class; 34 | } 35 | 36 | public function compile() 37 | { 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/FilterCallableInterface.php: -------------------------------------------------------------------------------- 1 | 18 | * @deprecated since 1.12 (to be removed in 2.0) 19 | */ 20 | interface Twig_FilterCallableInterface 21 | { 22 | public function getCallable(); 23 | } 24 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/FilterInterface.php: -------------------------------------------------------------------------------- 1 | 18 | * @deprecated since 1.12 (to be removed in 2.0) 19 | */ 20 | interface Twig_FilterInterface 21 | { 22 | /** 23 | * Compiles a filter. 24 | * 25 | * @return string The PHP code for the filter 26 | */ 27 | public function compile(); 28 | 29 | public function needsEnvironment(); 30 | 31 | public function needsContext(); 32 | 33 | public function getSafe(Twig_Node $filterArgs); 34 | 35 | public function getPreservesSafety(); 36 | 37 | public function getPreEscape(); 38 | 39 | public function setArguments($arguments); 40 | 41 | public function getArguments(); 42 | } 43 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Function.php: -------------------------------------------------------------------------------- 1 | 18 | * @deprecated since 1.12 (to be removed in 2.0) 19 | */ 20 | abstract class Twig_Function implements Twig_FunctionInterface, Twig_FunctionCallableInterface 21 | { 22 | protected $options; 23 | protected $arguments = array(); 24 | 25 | public function __construct(array $options = array()) 26 | { 27 | $this->options = array_merge(array( 28 | 'needs_environment' => false, 29 | 'needs_context' => false, 30 | 'callable' => null, 31 | ), $options); 32 | } 33 | 34 | public function setArguments($arguments) 35 | { 36 | $this->arguments = $arguments; 37 | } 38 | 39 | public function getArguments() 40 | { 41 | return $this->arguments; 42 | } 43 | 44 | public function needsEnvironment() 45 | { 46 | return $this->options['needs_environment']; 47 | } 48 | 49 | public function needsContext() 50 | { 51 | return $this->options['needs_context']; 52 | } 53 | 54 | public function getSafe(Twig_Node $functionArgs) 55 | { 56 | if (isset($this->options['is_safe'])) { 57 | return $this->options['is_safe']; 58 | } 59 | 60 | if (isset($this->options['is_safe_callback'])) { 61 | return call_user_func($this->options['is_safe_callback'], $functionArgs); 62 | } 63 | 64 | return array(); 65 | } 66 | 67 | public function getCallable() 68 | { 69 | return $this->options['callable']; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Function/Function.php: -------------------------------------------------------------------------------- 1 | 19 | * @deprecated since 1.12 (to be removed in 2.0) 20 | */ 21 | class Twig_Function_Function extends Twig_Function 22 | { 23 | protected $function; 24 | 25 | public function __construct($function, array $options = array()) 26 | { 27 | $options['callable'] = $function; 28 | 29 | parent::__construct($options); 30 | 31 | $this->function = $function; 32 | } 33 | 34 | public function compile() 35 | { 36 | return $this->function; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Function/Method.php: -------------------------------------------------------------------------------- 1 | 19 | * @deprecated since 1.12 (to be removed in 2.0) 20 | */ 21 | class Twig_Function_Method extends Twig_Function 22 | { 23 | protected $extension; 24 | protected $method; 25 | 26 | public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array()) 27 | { 28 | $options['callable'] = array($extension, $method); 29 | 30 | parent::__construct($options); 31 | 32 | $this->extension = $extension; 33 | $this->method = $method; 34 | } 35 | 36 | public function compile() 37 | { 38 | return sprintf('$this->env->getExtension(\'%s\')->%s', $this->extension->getName(), $this->method); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Function/Node.php: -------------------------------------------------------------------------------- 1 | 18 | * @deprecated since 1.12 (to be removed in 2.0) 19 | */ 20 | class Twig_Function_Node extends Twig_Function 21 | { 22 | protected $class; 23 | 24 | public function __construct($class, array $options = array()) 25 | { 26 | parent::__construct($options); 27 | 28 | $this->class = $class; 29 | } 30 | 31 | public function getClass() 32 | { 33 | return $this->class; 34 | } 35 | 36 | public function compile() 37 | { 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/FunctionCallableInterface.php: -------------------------------------------------------------------------------- 1 | 18 | * @deprecated since 1.12 (to be removed in 2.0) 19 | */ 20 | interface Twig_FunctionCallableInterface 21 | { 22 | public function getCallable(); 23 | } 24 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/FunctionInterface.php: -------------------------------------------------------------------------------- 1 | 19 | * @deprecated since 1.12 (to be removed in 2.0) 20 | */ 21 | interface Twig_FunctionInterface 22 | { 23 | /** 24 | * Compiles a function. 25 | * 26 | * @return string The PHP code for the function 27 | */ 28 | public function compile(); 29 | 30 | public function needsEnvironment(); 31 | 32 | public function needsContext(); 33 | 34 | public function getSafe(Twig_Node $filterArgs); 35 | 36 | public function setArguments($arguments); 37 | 38 | public function getArguments(); 39 | } 40 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/LexerInterface.php: -------------------------------------------------------------------------------- 1 | 16 | * 17 | * @deprecated since 1.12 (to be removed in 3.0) 18 | */ 19 | interface Twig_LexerInterface 20 | { 21 | /** 22 | * Tokenizes a source code. 23 | * 24 | * @param string $code The source code 25 | * @param string $filename A unique identifier for the source code 26 | * 27 | * @return Twig_TokenStream A token stream instance 28 | * 29 | * @throws Twig_Error_Syntax When the code is syntactically wrong 30 | */ 31 | public function tokenize($code, $filename = null); 32 | } 33 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Loader/Array.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterface 25 | { 26 | protected $templates = array(); 27 | 28 | /** 29 | * Constructor. 30 | * 31 | * @param array $templates An array of templates (keys are the names, and values are the source code) 32 | * 33 | * @see Twig_Loader 34 | */ 35 | public function __construct(array $templates) 36 | { 37 | $this->templates = $templates; 38 | } 39 | 40 | /** 41 | * Adds or overrides a template. 42 | * 43 | * @param string $name The template name 44 | * @param string $template The template source 45 | */ 46 | public function setTemplate($name, $template) 47 | { 48 | $this->templates[(string) $name] = $template; 49 | } 50 | 51 | /** 52 | * {@inheritdoc} 53 | */ 54 | public function getSource($name) 55 | { 56 | $name = (string) $name; 57 | if (!isset($this->templates[$name])) { 58 | throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); 59 | } 60 | 61 | return $this->templates[$name]; 62 | } 63 | 64 | /** 65 | * {@inheritdoc} 66 | */ 67 | public function exists($name) 68 | { 69 | return isset($this->templates[(string) $name]); 70 | } 71 | 72 | /** 73 | * {@inheritdoc} 74 | */ 75 | public function getCacheKey($name) 76 | { 77 | $name = (string) $name; 78 | if (!isset($this->templates[$name])) { 79 | throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); 80 | } 81 | 82 | return $this->templates[$name]; 83 | } 84 | 85 | /** 86 | * {@inheritdoc} 87 | */ 88 | public function isFresh($name, $time) 89 | { 90 | $name = (string) $name; 91 | if (!isset($this->templates[$name])) { 92 | throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); 93 | } 94 | 95 | return true; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Loader/String.php: -------------------------------------------------------------------------------- 1 | 25 | */ 26 | class Twig_Loader_String implements Twig_LoaderInterface, Twig_ExistsLoaderInterface 27 | { 28 | /** 29 | * {@inheritdoc} 30 | */ 31 | public function getSource($name) 32 | { 33 | return $name; 34 | } 35 | 36 | /** 37 | * {@inheritdoc} 38 | */ 39 | public function exists($name) 40 | { 41 | return true; 42 | } 43 | 44 | /** 45 | * {@inheritdoc} 46 | */ 47 | public function getCacheKey($name) 48 | { 49 | return $name; 50 | } 51 | 52 | /** 53 | * {@inheritdoc} 54 | */ 55 | public function isFresh($name, $time) 56 | { 57 | return true; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/LoaderInterface.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | interface Twig_LoaderInterface 18 | { 19 | /** 20 | * Gets the source code of a template, given its name. 21 | * 22 | * @param string $name The name of the template to load 23 | * 24 | * @return string The template source code 25 | * 26 | * @throws Twig_Error_Loader When $name is not found 27 | */ 28 | public function getSource($name); 29 | 30 | /** 31 | * Gets the cache key to use for the cache for a given template name. 32 | * 33 | * @param string $name The name of the template to load 34 | * 35 | * @return string The cache key 36 | * 37 | * @throws Twig_Error_Loader When $name is not found 38 | */ 39 | public function getCacheKey($name); 40 | 41 | /** 42 | * Returns true if the template is still fresh. 43 | * 44 | * @param string $name The template name 45 | * @param int $time Timestamp of the last modification time of the 46 | * cached template 47 | * 48 | * @return bool true if the template is fresh, false otherwise 49 | * 50 | * @throws Twig_Error_Loader When $name is not found 51 | */ 52 | public function isFresh($name, $time); 53 | } 54 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Markup.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Markup implements Countable 18 | { 19 | protected $content; 20 | protected $charset; 21 | 22 | public function __construct($content, $charset) 23 | { 24 | $this->content = (string) $content; 25 | $this->charset = $charset; 26 | } 27 | 28 | public function __toString() 29 | { 30 | return $this->content; 31 | } 32 | 33 | public function count() 34 | { 35 | return function_exists('mb_get_info') ? mb_strlen($this->content, $this->charset) : strlen($this->content); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/AutoEscape.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | class Twig_Node_AutoEscape extends Twig_Node 24 | { 25 | public function __construct($value, Twig_NodeInterface $body, $lineno, $tag = 'autoescape') 26 | { 27 | parent::__construct(array('body' => $body), array('value' => $value), $lineno, $tag); 28 | } 29 | 30 | /** 31 | * Compiles the node to PHP. 32 | * 33 | * @param Twig_Compiler $compiler A Twig_Compiler instance 34 | */ 35 | public function compile(Twig_Compiler $compiler) 36 | { 37 | $compiler->subcompile($this->getNode('body')); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Block.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Block extends Twig_Node 19 | { 20 | public function __construct($name, Twig_NodeInterface $body, $lineno, $tag = null) 21 | { 22 | parent::__construct(array('body' => $body), array('name' => $name), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler $compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | $compiler 33 | ->addDebugInfo($this) 34 | ->write(sprintf("public function block_%s(\$context, array \$blocks = array())\n", $this->getAttribute('name')), "{\n") 35 | ->indent() 36 | ; 37 | 38 | $compiler 39 | ->subcompile($this->getNode('body')) 40 | ->outdent() 41 | ->write("}\n\n") 42 | ; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/BlockReference.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_BlockReference extends Twig_Node implements Twig_NodeOutputInterface 19 | { 20 | public function __construct($name, $lineno, $tag = null) 21 | { 22 | parent::__construct(array(), array('name' => $name), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler $compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | $compiler 33 | ->addDebugInfo($this) 34 | ->write(sprintf("\$this->displayBlock('%s', \$context, \$blocks);\n", $this->getAttribute('name'))) 35 | ; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Body.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Node_Body extends Twig_Node 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Do.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Node_Do extends Twig_Node 18 | { 19 | public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null) 20 | { 21 | parent::__construct(array('expr' => $expr), array(), $lineno, $tag); 22 | } 23 | 24 | /** 25 | * Compiles the node to PHP. 26 | * 27 | * @param Twig_Compiler $compiler A Twig_Compiler instance 28 | */ 29 | public function compile(Twig_Compiler $compiler) 30 | { 31 | $compiler 32 | ->addDebugInfo($this) 33 | ->write('') 34 | ->subcompile($this->getNode('expr')) 35 | ->raw(";\n") 36 | ; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Embed.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Node_Embed extends Twig_Node_Include 18 | { 19 | // we don't inject the module to avoid node visitors to traverse it twice (as it will be already visited in the main module) 20 | public function __construct($filename, $index, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null) 21 | { 22 | parent::__construct(new Twig_Node_Expression_Constant('not_used', $lineno), $variables, $only, $ignoreMissing, $lineno, $tag); 23 | 24 | $this->setAttribute('filename', $filename); 25 | $this->setAttribute('index', $index); 26 | } 27 | 28 | protected function addGetTemplate(Twig_Compiler $compiler) 29 | { 30 | $compiler 31 | ->write("\$this->loadTemplate(") 32 | ->string($this->getAttribute('filename')) 33 | ->raw(', ') 34 | ->repr($compiler->getFilename()) 35 | ->raw(', ') 36 | ->repr($this->getLine()) 37 | ->raw(', ') 38 | ->string($this->getAttribute('index')) 39 | ->raw(")") 40 | ; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | abstract class Twig_Node_Expression extends Twig_Node 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Array.php: -------------------------------------------------------------------------------- 1 | index = -1; 20 | foreach ($this->getKeyValuePairs() as $pair) { 21 | if ($pair['key'] instanceof Twig_Node_Expression_Constant && ctype_digit((string) $pair['key']->getAttribute('value')) && $pair['key']->getAttribute('value') > $this->index) { 22 | $this->index = $pair['key']->getAttribute('value'); 23 | } 24 | } 25 | } 26 | 27 | public function getKeyValuePairs() 28 | { 29 | $pairs = array(); 30 | 31 | foreach (array_chunk($this->nodes, 2) as $pair) { 32 | $pairs[] = array( 33 | 'key' => $pair[0], 34 | 'value' => $pair[1], 35 | ); 36 | } 37 | 38 | return $pairs; 39 | } 40 | 41 | public function hasElement(Twig_Node_Expression $key) 42 | { 43 | foreach ($this->getKeyValuePairs() as $pair) { 44 | // we compare the string representation of the keys 45 | // to avoid comparing the line numbers which are not relevant here. 46 | if ((string) $key == (string) $pair['key']) { 47 | return true; 48 | } 49 | } 50 | 51 | return false; 52 | } 53 | 54 | public function addElement(Twig_Node_Expression $value, Twig_Node_Expression $key = null) 55 | { 56 | if (null === $key) { 57 | $key = new Twig_Node_Expression_Constant(++$this->index, $value->getLine()); 58 | } 59 | 60 | array_push($this->nodes, $key, $value); 61 | } 62 | 63 | /** 64 | * Compiles the node to PHP. 65 | * 66 | * @param Twig_Compiler $compiler A Twig_Compiler instance 67 | */ 68 | public function compile(Twig_Compiler $compiler) 69 | { 70 | $compiler->raw('array('); 71 | $first = true; 72 | foreach ($this->getKeyValuePairs() as $pair) { 73 | if (!$first) { 74 | $compiler->raw(', '); 75 | } 76 | $first = false; 77 | 78 | $compiler 79 | ->subcompile($pair['key']) 80 | ->raw(' => ') 81 | ->subcompile($pair['value']) 82 | ; 83 | } 84 | $compiler->raw(')'); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/AssignName.php: -------------------------------------------------------------------------------- 1 | raw('$context[') 24 | ->string($this->getAttribute('name')) 25 | ->raw(']') 26 | ; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary.php: -------------------------------------------------------------------------------- 1 | $left, 'right' => $right), array(), $lineno); 17 | } 18 | 19 | /** 20 | * Compiles the node to PHP. 21 | * 22 | * @param Twig_Compiler $compiler A Twig_Compiler instance 23 | */ 24 | public function compile(Twig_Compiler $compiler) 25 | { 26 | $compiler 27 | ->raw('(') 28 | ->subcompile($this->getNode('left')) 29 | ->raw(' ') 30 | ; 31 | $this->operator($compiler); 32 | $compiler 33 | ->raw(' ') 34 | ->subcompile($this->getNode('right')) 35 | ->raw(')') 36 | ; 37 | } 38 | 39 | abstract public function operator(Twig_Compiler $compiler); 40 | } 41 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/Add.php: -------------------------------------------------------------------------------- 1 | raw('+'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/And.php: -------------------------------------------------------------------------------- 1 | raw('&&'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/BitwiseAnd.php: -------------------------------------------------------------------------------- 1 | raw('&'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/BitwiseOr.php: -------------------------------------------------------------------------------- 1 | raw('|'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/BitwiseXor.php: -------------------------------------------------------------------------------- 1 | raw('^'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/Concat.php: -------------------------------------------------------------------------------- 1 | raw('.'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/Div.php: -------------------------------------------------------------------------------- 1 | raw('/'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/EndsWith.php: -------------------------------------------------------------------------------- 1 | getVarName(); 16 | $right = $compiler->getVarName(); 17 | $compiler 18 | ->raw(sprintf('(is_string($%s = ', $left)) 19 | ->subcompile($this->getNode('left')) 20 | ->raw(sprintf(') && is_string($%s = ', $right)) 21 | ->subcompile($this->getNode('right')) 22 | ->raw(sprintf(') && (\'\' === $%2$s || $%2$s === substr($%1$s, -strlen($%2$s))))', $left, $right)) 23 | ; 24 | } 25 | 26 | public function operator(Twig_Compiler $compiler) 27 | { 28 | return $compiler->raw(''); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/Equal.php: -------------------------------------------------------------------------------- 1 | raw('=='); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/FloorDiv.php: -------------------------------------------------------------------------------- 1 | raw('intval(floor('); 21 | parent::compile($compiler); 22 | $compiler->raw('))'); 23 | } 24 | 25 | public function operator(Twig_Compiler $compiler) 26 | { 27 | return $compiler->raw('/'); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/Greater.php: -------------------------------------------------------------------------------- 1 | raw('>'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/GreaterEqual.php: -------------------------------------------------------------------------------- 1 | raw('>='); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/In.php: -------------------------------------------------------------------------------- 1 | raw('twig_in_filter(') 22 | ->subcompile($this->getNode('left')) 23 | ->raw(', ') 24 | ->subcompile($this->getNode('right')) 25 | ->raw(')') 26 | ; 27 | } 28 | 29 | public function operator(Twig_Compiler $compiler) 30 | { 31 | return $compiler->raw('in'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/Less.php: -------------------------------------------------------------------------------- 1 | raw('<'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/LessEqual.php: -------------------------------------------------------------------------------- 1 | raw('<='); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/Matches.php: -------------------------------------------------------------------------------- 1 | raw('preg_match(') 17 | ->subcompile($this->getNode('right')) 18 | ->raw(', ') 19 | ->subcompile($this->getNode('left')) 20 | ->raw(')') 21 | ; 22 | } 23 | 24 | public function operator(Twig_Compiler $compiler) 25 | { 26 | return $compiler->raw(''); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/Mod.php: -------------------------------------------------------------------------------- 1 | raw('%'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/Mul.php: -------------------------------------------------------------------------------- 1 | raw('*'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/NotEqual.php: -------------------------------------------------------------------------------- 1 | raw('!='); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/NotIn.php: -------------------------------------------------------------------------------- 1 | raw('!twig_in_filter(') 22 | ->subcompile($this->getNode('left')) 23 | ->raw(', ') 24 | ->subcompile($this->getNode('right')) 25 | ->raw(')') 26 | ; 27 | } 28 | 29 | public function operator(Twig_Compiler $compiler) 30 | { 31 | return $compiler->raw('not in'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/Or.php: -------------------------------------------------------------------------------- 1 | raw('||'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/Power.php: -------------------------------------------------------------------------------- 1 | raw('pow(') 22 | ->subcompile($this->getNode('left')) 23 | ->raw(', ') 24 | ->subcompile($this->getNode('right')) 25 | ->raw(')') 26 | ; 27 | } 28 | 29 | public function operator(Twig_Compiler $compiler) 30 | { 31 | return $compiler->raw('**'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/Range.php: -------------------------------------------------------------------------------- 1 | raw('range(') 22 | ->subcompile($this->getNode('left')) 23 | ->raw(', ') 24 | ->subcompile($this->getNode('right')) 25 | ->raw(')') 26 | ; 27 | } 28 | 29 | public function operator(Twig_Compiler $compiler) 30 | { 31 | return $compiler->raw('..'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/StartsWith.php: -------------------------------------------------------------------------------- 1 | getVarName(); 16 | $right = $compiler->getVarName(); 17 | $compiler 18 | ->raw(sprintf('(is_string($%s = ', $left)) 19 | ->subcompile($this->getNode('left')) 20 | ->raw(sprintf(') && is_string($%s = ', $right)) 21 | ->subcompile($this->getNode('right')) 22 | ->raw(sprintf(') && (\'\' === $%2$s || 0 === strpos($%1$s, $%2$s)))', $left, $right)) 23 | ; 24 | } 25 | 26 | public function operator(Twig_Compiler $compiler) 27 | { 28 | return $compiler->raw(''); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Binary/Sub.php: -------------------------------------------------------------------------------- 1 | raw('-'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/BlockReference.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Expression_BlockReference extends Twig_Node_Expression 19 | { 20 | public function __construct(Twig_NodeInterface $name, $asString = false, $lineno, $tag = null) 21 | { 22 | parent::__construct(array('name' => $name), array('as_string' => $asString, 'output' => false), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler $compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | if ($this->getAttribute('as_string')) { 33 | $compiler->raw('(string) '); 34 | } 35 | 36 | if ($this->getAttribute('output')) { 37 | $compiler 38 | ->addDebugInfo($this) 39 | ->write("\$this->displayBlock(") 40 | ->subcompile($this->getNode('name')) 41 | ->raw(", \$context, \$blocks);\n") 42 | ; 43 | } else { 44 | $compiler 45 | ->raw("\$this->renderBlock(") 46 | ->subcompile($this->getNode('name')) 47 | ->raw(", \$context, \$blocks)") 48 | ; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Conditional.php: -------------------------------------------------------------------------------- 1 | $expr1, 'expr2' => $expr2, 'expr3' => $expr3), array(), $lineno); 17 | } 18 | 19 | public function compile(Twig_Compiler $compiler) 20 | { 21 | $compiler 22 | ->raw('((') 23 | ->subcompile($this->getNode('expr1')) 24 | ->raw(') ? (') 25 | ->subcompile($this->getNode('expr2')) 26 | ->raw(') : (') 27 | ->subcompile($this->getNode('expr3')) 28 | ->raw('))') 29 | ; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Constant.php: -------------------------------------------------------------------------------- 1 | $value), $lineno); 17 | } 18 | 19 | public function compile(Twig_Compiler $compiler) 20 | { 21 | $compiler->repr($this->getAttribute('value')); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/ExtensionReference.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Node_Expression_ExtensionReference extends Twig_Node_Expression 18 | { 19 | public function __construct($name, $lineno, $tag = null) 20 | { 21 | parent::__construct(array(), array('name' => $name), $lineno, $tag); 22 | } 23 | 24 | /** 25 | * Compiles the node to PHP. 26 | * 27 | * @param Twig_Compiler $compiler A Twig_Compiler instance 28 | */ 29 | public function compile(Twig_Compiler $compiler) 30 | { 31 | $compiler->raw(sprintf("\$this->env->getExtension('%s')", $this->getAttribute('name'))); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Filter.php: -------------------------------------------------------------------------------- 1 | $node, 'filter' => $filterName, 'arguments' => $arguments), array(), $lineno, $tag); 17 | } 18 | 19 | public function compile(Twig_Compiler $compiler) 20 | { 21 | $name = $this->getNode('filter')->getAttribute('value'); 22 | $filter = $compiler->getEnvironment()->getFilter($name); 23 | 24 | $this->setAttribute('name', $name); 25 | $this->setAttribute('type', 'filter'); 26 | $this->setAttribute('thing', $filter); 27 | $this->setAttribute('needs_environment', $filter->needsEnvironment()); 28 | $this->setAttribute('needs_context', $filter->needsContext()); 29 | $this->setAttribute('arguments', $filter->getArguments()); 30 | if ($filter instanceof Twig_FilterCallableInterface || $filter instanceof Twig_SimpleFilter) { 31 | $this->setAttribute('callable', $filter->getCallable()); 32 | } 33 | 34 | $this->compileCallable($compiler); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Filter/Default.php: -------------------------------------------------------------------------------- 1 | 16 | * {{ var.foo|default('foo item on var is not defined') }} 17 | * 18 | * 19 | * @author Fabien Potencier 20 | */ 21 | class Twig_Node_Expression_Filter_Default extends Twig_Node_Expression_Filter 22 | { 23 | public function __construct(Twig_NodeInterface $node, Twig_Node_Expression_Constant $filterName, Twig_NodeInterface $arguments, $lineno, $tag = null) 24 | { 25 | $default = new Twig_Node_Expression_Filter($node, new Twig_Node_Expression_Constant('default', $node->getLine()), $arguments, $node->getLine()); 26 | 27 | if ('default' === $filterName->getAttribute('value') && ($node instanceof Twig_Node_Expression_Name || $node instanceof Twig_Node_Expression_GetAttr)) { 28 | $test = new Twig_Node_Expression_Test_Defined(clone $node, 'defined', new Twig_Node(), $node->getLine()); 29 | $false = count($arguments) ? $arguments->getNode(0) : new Twig_Node_Expression_Constant('', $node->getLine()); 30 | 31 | $node = new Twig_Node_Expression_Conditional($test, $default, $false, $node->getLine()); 32 | } else { 33 | $node = $default; 34 | } 35 | 36 | parent::__construct($node, $filterName, $arguments, $lineno, $tag); 37 | } 38 | 39 | public function compile(Twig_Compiler $compiler) 40 | { 41 | $compiler->subcompile($this->getNode('node')); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Function.php: -------------------------------------------------------------------------------- 1 | $arguments), array('name' => $name), $lineno); 16 | } 17 | 18 | public function compile(Twig_Compiler $compiler) 19 | { 20 | $name = $this->getAttribute('name'); 21 | $function = $compiler->getEnvironment()->getFunction($name); 22 | 23 | $this->setAttribute('name', $name); 24 | $this->setAttribute('type', 'function'); 25 | $this->setAttribute('thing', $function); 26 | $this->setAttribute('needs_environment', $function->needsEnvironment()); 27 | $this->setAttribute('needs_context', $function->needsContext()); 28 | $this->setAttribute('arguments', $function->getArguments()); 29 | if ($function instanceof Twig_FunctionCallableInterface || $function instanceof Twig_SimpleFunction) { 30 | $this->setAttribute('callable', $function->getCallable()); 31 | } 32 | 33 | $this->compileCallable($compiler); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/GetAttr.php: -------------------------------------------------------------------------------- 1 | $node, 'attribute' => $attribute, 'arguments' => $arguments), array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false, 'disable_c_ext' => false), $lineno); 17 | } 18 | 19 | public function compile(Twig_Compiler $compiler) 20 | { 21 | if (function_exists('twig_template_get_attributes') && !$this->getAttribute('disable_c_ext')) { 22 | $compiler->raw('twig_template_get_attributes($this, '); 23 | } else { 24 | $compiler->raw('$this->getAttribute('); 25 | } 26 | 27 | if ($this->getAttribute('ignore_strict_check')) { 28 | $this->getNode('node')->setAttribute('ignore_strict_check', true); 29 | } 30 | 31 | $compiler->subcompile($this->getNode('node')); 32 | 33 | $compiler->raw(', ')->subcompile($this->getNode('attribute')); 34 | 35 | // only generate optional arguments when needed (to make generated code more readable) 36 | $needFourth = $this->getAttribute('ignore_strict_check'); 37 | $needThird = $needFourth || $this->getAttribute('is_defined_test'); 38 | $needSecond = $needThird || Twig_Template::ANY_CALL !== $this->getAttribute('type'); 39 | $needFirst = $needSecond || null !== $this->getNode('arguments'); 40 | 41 | if ($needFirst) { 42 | if (null !== $this->getNode('arguments')) { 43 | $compiler->raw(', ')->subcompile($this->getNode('arguments')); 44 | } else { 45 | $compiler->raw(', array()'); 46 | } 47 | } 48 | 49 | if ($needSecond) { 50 | $compiler->raw(', ')->repr($this->getAttribute('type')); 51 | } 52 | 53 | if ($needThird) { 54 | $compiler->raw(', ')->repr($this->getAttribute('is_defined_test')); 55 | } 56 | 57 | if ($needFourth) { 58 | $compiler->raw(', ')->repr($this->getAttribute('ignore_strict_check')); 59 | } 60 | 61 | $compiler->raw(')'); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/MethodCall.php: -------------------------------------------------------------------------------- 1 | $node, 'arguments' => $arguments), array('method' => $method, 'safe' => false), $lineno); 16 | 17 | if ($node instanceof Twig_Node_Expression_Name) { 18 | $node->setAttribute('always_defined', true); 19 | } 20 | } 21 | 22 | public function compile(Twig_Compiler $compiler) 23 | { 24 | $compiler 25 | ->subcompile($this->getNode('node')) 26 | ->raw('->') 27 | ->raw($this->getAttribute('method')) 28 | ->raw('(') 29 | ; 30 | $first = true; 31 | foreach ($this->getNode('arguments')->getKeyValuePairs() as $pair) { 32 | if (!$first) { 33 | $compiler->raw(', '); 34 | } 35 | $first = false; 36 | 37 | $compiler->subcompile($pair['value']); 38 | } 39 | $compiler->raw(')'); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Parent.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Expression_Parent extends Twig_Node_Expression 19 | { 20 | public function __construct($name, $lineno, $tag = null) 21 | { 22 | parent::__construct(array(), array('output' => false, 'name' => $name), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler $compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | if ($this->getAttribute('output')) { 33 | $compiler 34 | ->addDebugInfo($this) 35 | ->write("\$this->displayParentBlock(") 36 | ->string($this->getAttribute('name')) 37 | ->raw(", \$context, \$blocks);\n") 38 | ; 39 | } else { 40 | $compiler 41 | ->raw("\$this->renderParentBlock(") 42 | ->string($this->getAttribute('name')) 43 | ->raw(", \$context, \$blocks)") 44 | ; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/TempName.php: -------------------------------------------------------------------------------- 1 | $name), $lineno); 16 | } 17 | 18 | public function compile(Twig_Compiler $compiler) 19 | { 20 | $compiler 21 | ->raw('$_') 22 | ->raw($this->getAttribute('name')) 23 | ->raw('_') 24 | ; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Test.php: -------------------------------------------------------------------------------- 1 | $node, 'arguments' => $arguments), array('name' => $name), $lineno); 16 | } 17 | 18 | public function compile(Twig_Compiler $compiler) 19 | { 20 | $name = $this->getAttribute('name'); 21 | $test = $compiler->getEnvironment()->getTest($name); 22 | 23 | $this->setAttribute('name', $name); 24 | $this->setAttribute('type', 'test'); 25 | $this->setAttribute('thing', $test); 26 | if ($test instanceof Twig_TestCallableInterface || $test instanceof Twig_SimpleTest) { 27 | $this->setAttribute('callable', $test->getCallable()); 28 | } 29 | 30 | $this->compileCallable($compiler); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Test/Constant.php: -------------------------------------------------------------------------------- 1 | 16 | * {% if post.status is constant('Post::PUBLISHED') %} 17 | * the status attribute is exactly the same as Post::PUBLISHED 18 | * {% endif %} 19 | * 20 | * 21 | * @author Fabien Potencier 22 | */ 23 | class Twig_Node_Expression_Test_Constant extends Twig_Node_Expression_Test 24 | { 25 | public function compile(Twig_Compiler $compiler) 26 | { 27 | $compiler 28 | ->raw('(') 29 | ->subcompile($this->getNode('node')) 30 | ->raw(' === constant(') 31 | ; 32 | 33 | if ($this->getNode('arguments')->hasNode(1)) { 34 | $compiler 35 | ->raw('get_class(') 36 | ->subcompile($this->getNode('arguments')->getNode(1)) 37 | ->raw(')."::".') 38 | ; 39 | } 40 | 41 | $compiler 42 | ->subcompile($this->getNode('arguments')->getNode(0)) 43 | ->raw('))') 44 | ; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Test/Defined.php: -------------------------------------------------------------------------------- 1 | 16 | * {# defined works with variable names and variable attributes #} 17 | * {% if foo is defined %} 18 | * {# ... #} 19 | * {% endif %} 20 | * 21 | * 22 | * @author Fabien Potencier 23 | */ 24 | class Twig_Node_Expression_Test_Defined extends Twig_Node_Expression_Test 25 | { 26 | public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno) 27 | { 28 | parent::__construct($node, $name, $arguments, $lineno); 29 | 30 | if ($node instanceof Twig_Node_Expression_Name) { 31 | $node->setAttribute('is_defined_test', true); 32 | } elseif ($node instanceof Twig_Node_Expression_GetAttr) { 33 | $node->setAttribute('is_defined_test', true); 34 | 35 | $this->changeIgnoreStrictCheck($node); 36 | } else { 37 | throw new Twig_Error_Syntax('The "defined" test only works with simple variables', $this->getLine()); 38 | } 39 | } 40 | 41 | protected function changeIgnoreStrictCheck(Twig_Node_Expression_GetAttr $node) 42 | { 43 | $node->setAttribute('ignore_strict_check', true); 44 | 45 | if ($node->getNode('node') instanceof Twig_Node_Expression_GetAttr) { 46 | $this->changeIgnoreStrictCheck($node->getNode('node')); 47 | } 48 | } 49 | 50 | public function compile(Twig_Compiler $compiler) 51 | { 52 | $compiler->subcompile($this->getNode('node')); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Test/Divisibleby.php: -------------------------------------------------------------------------------- 1 | 16 | * {% if loop.index is divisible by(3) %} 17 | * 18 | * 19 | * @author Fabien Potencier 20 | */ 21 | class Twig_Node_Expression_Test_Divisibleby extends Twig_Node_Expression_Test 22 | { 23 | public function compile(Twig_Compiler $compiler) 24 | { 25 | $compiler 26 | ->raw('(0 == ') 27 | ->subcompile($this->getNode('node')) 28 | ->raw(' % ') 29 | ->subcompile($this->getNode('arguments')->getNode(0)) 30 | ->raw(')') 31 | ; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Test/Even.php: -------------------------------------------------------------------------------- 1 | 16 | * {{ var is even }} 17 | * 18 | * 19 | * @author Fabien Potencier 20 | */ 21 | class Twig_Node_Expression_Test_Even extends Twig_Node_Expression_Test 22 | { 23 | public function compile(Twig_Compiler $compiler) 24 | { 25 | $compiler 26 | ->raw('(') 27 | ->subcompile($this->getNode('node')) 28 | ->raw(' % 2 == 0') 29 | ->raw(')') 30 | ; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Test/Null.php: -------------------------------------------------------------------------------- 1 | 16 | * {{ var is none }} 17 | * 18 | * 19 | * @author Fabien Potencier 20 | */ 21 | class Twig_Node_Expression_Test_Null extends Twig_Node_Expression_Test 22 | { 23 | public function compile(Twig_Compiler $compiler) 24 | { 25 | $compiler 26 | ->raw('(null === ') 27 | ->subcompile($this->getNode('node')) 28 | ->raw(')') 29 | ; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Test/Odd.php: -------------------------------------------------------------------------------- 1 | 16 | * {{ var is odd }} 17 | * 18 | * 19 | * @author Fabien Potencier 20 | */ 21 | class Twig_Node_Expression_Test_Odd extends Twig_Node_Expression_Test 22 | { 23 | public function compile(Twig_Compiler $compiler) 24 | { 25 | $compiler 26 | ->raw('(') 27 | ->subcompile($this->getNode('node')) 28 | ->raw(' % 2 == 1') 29 | ->raw(')') 30 | ; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Test/Sameas.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Node_Expression_Test_Sameas extends Twig_Node_Expression_Test 18 | { 19 | public function compile(Twig_Compiler $compiler) 20 | { 21 | $compiler 22 | ->raw('(') 23 | ->subcompile($this->getNode('node')) 24 | ->raw(' === ') 25 | ->subcompile($this->getNode('arguments')->getNode(0)) 26 | ->raw(')') 27 | ; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Unary.php: -------------------------------------------------------------------------------- 1 | $node), array(), $lineno); 17 | } 18 | 19 | public function compile(Twig_Compiler $compiler) 20 | { 21 | $compiler->raw(' '); 22 | $this->operator($compiler); 23 | $compiler->subcompile($this->getNode('node')); 24 | } 25 | 26 | abstract public function operator(Twig_Compiler $compiler); 27 | } 28 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Unary/Neg.php: -------------------------------------------------------------------------------- 1 | raw('-'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Unary/Not.php: -------------------------------------------------------------------------------- 1 | raw('!'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Expression/Unary/Pos.php: -------------------------------------------------------------------------------- 1 | raw('+'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Flush.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Node_Flush extends Twig_Node 18 | { 19 | public function __construct($lineno, $tag) 20 | { 21 | parent::__construct(array(), array(), $lineno, $tag); 22 | } 23 | 24 | /** 25 | * Compiles the node to PHP. 26 | * 27 | * @param Twig_Compiler $compiler A Twig_Compiler instance 28 | */ 29 | public function compile(Twig_Compiler $compiler) 30 | { 31 | $compiler 32 | ->addDebugInfo($this) 33 | ->write("flush();\n") 34 | ; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/ForLoop.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Node_ForLoop extends Twig_Node 18 | { 19 | public function __construct($lineno, $tag = null) 20 | { 21 | parent::__construct(array(), array('with_loop' => false, 'ifexpr' => false, 'else' => false), $lineno, $tag); 22 | } 23 | 24 | /** 25 | * Compiles the node to PHP. 26 | * 27 | * @param Twig_Compiler $compiler A Twig_Compiler instance 28 | */ 29 | public function compile(Twig_Compiler $compiler) 30 | { 31 | if ($this->getAttribute('else')) { 32 | $compiler->write("\$context['_iterated'] = true;\n"); 33 | } 34 | 35 | if ($this->getAttribute('with_loop')) { 36 | $compiler 37 | ->write("++\$context['loop']['index0'];\n") 38 | ->write("++\$context['loop']['index'];\n") 39 | ->write("\$context['loop']['first'] = false;\n") 40 | ; 41 | 42 | if (!$this->getAttribute('ifexpr')) { 43 | $compiler 44 | ->write("if (isset(\$context['loop']['length'])) {\n") 45 | ->indent() 46 | ->write("--\$context['loop']['revindex0'];\n") 47 | ->write("--\$context['loop']['revindex'];\n") 48 | ->write("\$context['loop']['last'] = 0 === \$context['loop']['revindex0'];\n") 49 | ->outdent() 50 | ->write("}\n") 51 | ; 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/If.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_If extends Twig_Node 19 | { 20 | public function __construct(Twig_NodeInterface $tests, Twig_NodeInterface $else = null, $lineno, $tag = null) 21 | { 22 | parent::__construct(array('tests' => $tests, 'else' => $else), array(), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler $compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | $compiler->addDebugInfo($this); 33 | for ($i = 0, $count = count($this->getNode('tests')); $i < $count; $i += 2) { 34 | if ($i > 0) { 35 | $compiler 36 | ->outdent() 37 | ->write("} elseif (") 38 | ; 39 | } else { 40 | $compiler 41 | ->write('if (') 42 | ; 43 | } 44 | 45 | $compiler 46 | ->subcompile($this->getNode('tests')->getNode($i)) 47 | ->raw(") {\n") 48 | ->indent() 49 | ->subcompile($this->getNode('tests')->getNode($i + 1)) 50 | ; 51 | } 52 | 53 | if ($this->hasNode('else') && null !== $this->getNode('else')) { 54 | $compiler 55 | ->outdent() 56 | ->write("} else {\n") 57 | ->indent() 58 | ->subcompile($this->getNode('else')) 59 | ; 60 | } 61 | 62 | $compiler 63 | ->outdent() 64 | ->write("}\n"); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Import.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Node_Import extends Twig_Node 18 | { 19 | public function __construct(Twig_Node_Expression $expr, Twig_Node_Expression $var, $lineno, $tag = null) 20 | { 21 | parent::__construct(array('expr' => $expr, 'var' => $var), array(), $lineno, $tag); 22 | } 23 | 24 | /** 25 | * Compiles the node to PHP. 26 | * 27 | * @param Twig_Compiler $compiler A Twig_Compiler instance 28 | */ 29 | public function compile(Twig_Compiler $compiler) 30 | { 31 | $compiler 32 | ->addDebugInfo($this) 33 | ->write('') 34 | ->subcompile($this->getNode('var')) 35 | ->raw(' = ') 36 | ; 37 | 38 | if ($this->getNode('expr') instanceof Twig_Node_Expression_Name && '_self' === $this->getNode('expr')->getAttribute('name')) { 39 | $compiler->raw("\$this"); 40 | } else { 41 | $compiler 42 | ->raw('$this->loadTemplate(') 43 | ->subcompile($this->getNode('expr')) 44 | ->raw(', ') 45 | ->repr($compiler->getFilename()) 46 | ->raw(', ') 47 | ->repr($this->getLine()) 48 | ->raw(")") 49 | ; 50 | } 51 | 52 | $compiler->raw(";\n"); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Include.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface 19 | { 20 | public function __construct(Twig_Node_Expression $expr, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null) 21 | { 22 | parent::__construct(array('expr' => $expr, 'variables' => $variables), array('only' => (bool) $only, 'ignore_missing' => (bool) $ignoreMissing), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler $compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | $compiler->addDebugInfo($this); 33 | 34 | if ($this->getAttribute('ignore_missing')) { 35 | $compiler 36 | ->write("try {\n") 37 | ->indent() 38 | ; 39 | } 40 | 41 | $this->addGetTemplate($compiler); 42 | 43 | $compiler->raw('->display('); 44 | 45 | $this->addTemplateArguments($compiler); 46 | 47 | $compiler->raw(");\n"); 48 | 49 | if ($this->getAttribute('ignore_missing')) { 50 | $compiler 51 | ->outdent() 52 | ->write("} catch (Twig_Error_Loader \$e) {\n") 53 | ->indent() 54 | ->write("// ignore missing template\n") 55 | ->outdent() 56 | ->write("}\n\n") 57 | ; 58 | } 59 | } 60 | 61 | protected function addGetTemplate(Twig_Compiler $compiler) 62 | { 63 | $compiler 64 | ->write("\$this->loadTemplate(") 65 | ->subcompile($this->getNode('expr')) 66 | ->raw(', ') 67 | ->repr($compiler->getFilename()) 68 | ->raw(', ') 69 | ->repr($this->getLine()) 70 | ->raw(")") 71 | ; 72 | } 73 | 74 | protected function addTemplateArguments(Twig_Compiler $compiler) 75 | { 76 | if (null === $this->getNode('variables')) { 77 | $compiler->raw(false === $this->getAttribute('only') ? '$context' : 'array()'); 78 | } elseif (false === $this->getAttribute('only')) { 79 | $compiler 80 | ->raw('array_merge($context, ') 81 | ->subcompile($this->getNode('variables')) 82 | ->raw(')') 83 | ; 84 | } else { 85 | $compiler->subcompile($this->getNode('variables')); 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Print.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Print extends Twig_Node implements Twig_NodeOutputInterface 19 | { 20 | public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null) 21 | { 22 | parent::__construct(array('expr' => $expr), array(), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler $compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | $compiler 33 | ->addDebugInfo($this) 34 | ->write('echo ') 35 | ->subcompile($this->getNode('expr')) 36 | ->raw(";\n") 37 | ; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Sandbox.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Node_Sandbox extends Twig_Node 18 | { 19 | public function __construct(Twig_NodeInterface $body, $lineno, $tag = null) 20 | { 21 | parent::__construct(array('body' => $body), array(), $lineno, $tag); 22 | } 23 | 24 | /** 25 | * Compiles the node to PHP. 26 | * 27 | * @param Twig_Compiler $compiler A Twig_Compiler instance 28 | */ 29 | public function compile(Twig_Compiler $compiler) 30 | { 31 | $compiler 32 | ->addDebugInfo($this) 33 | ->write("\$sandbox = \$this->env->getExtension('sandbox');\n") 34 | ->write("if (!\$alreadySandboxed = \$sandbox->isSandboxed()) {\n") 35 | ->indent() 36 | ->write("\$sandbox->enableSandbox();\n") 37 | ->outdent() 38 | ->write("}\n") 39 | ->subcompile($this->getNode('body')) 40 | ->write("if (!\$alreadySandboxed) {\n") 41 | ->indent() 42 | ->write("\$sandbox->disableSandbox();\n") 43 | ->outdent() 44 | ->write("}\n") 45 | ; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/SandboxedPrint.php: -------------------------------------------------------------------------------- 1 | 21 | */ 22 | class Twig_Node_SandboxedPrint extends Twig_Node_Print 23 | { 24 | public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null) 25 | { 26 | parent::__construct($expr, $lineno, $tag); 27 | } 28 | 29 | /** 30 | * Compiles the node to PHP. 31 | * 32 | * @param Twig_Compiler $compiler A Twig_Compiler instance 33 | */ 34 | public function compile(Twig_Compiler $compiler) 35 | { 36 | $compiler 37 | ->addDebugInfo($this) 38 | ->write('echo $this->env->getExtension(\'sandbox\')->ensureToStringAllowed(') 39 | ->subcompile($this->getNode('expr')) 40 | ->raw(");\n") 41 | ; 42 | } 43 | 44 | /** 45 | * Removes node filters. 46 | * 47 | * This is mostly needed when another visitor adds filters (like the escaper one). 48 | * 49 | * @param Twig_Node $node A Node 50 | * 51 | * @return Twig_Node 52 | */ 53 | protected function removeNodeFilter($node) 54 | { 55 | if ($node instanceof Twig_Node_Expression_Filter) { 56 | return $this->removeNodeFilter($node->getNode('node')); 57 | } 58 | 59 | return $node; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/SetTemp.php: -------------------------------------------------------------------------------- 1 | $name), $lineno); 17 | } 18 | 19 | public function compile(Twig_Compiler $compiler) 20 | { 21 | $name = $this->getAttribute('name'); 22 | $compiler 23 | ->addDebugInfo($this) 24 | ->write('if (isset($context[') 25 | ->string($name) 26 | ->raw('])) { $_') 27 | ->raw($name) 28 | ->raw('_ = $context[') 29 | ->repr($name) 30 | ->raw(']; } else { $_') 31 | ->raw($name) 32 | ->raw("_ = null; }\n") 33 | ; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Spaceless.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_Node_Spaceless extends Twig_Node 20 | { 21 | public function __construct(Twig_NodeInterface $body, $lineno, $tag = 'spaceless') 22 | { 23 | parent::__construct(array('body' => $body), array(), $lineno, $tag); 24 | } 25 | 26 | /** 27 | * Compiles the node to PHP. 28 | * 29 | * @param Twig_Compiler $compiler A Twig_Compiler instance 30 | */ 31 | public function compile(Twig_Compiler $compiler) 32 | { 33 | $compiler 34 | ->addDebugInfo($this) 35 | ->write("ob_start();\n") 36 | ->subcompile($this->getNode('body')) 37 | ->write("echo trim(preg_replace('/>\s+<', ob_get_clean()));\n") 38 | ; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Node/Text.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Text extends Twig_Node implements Twig_NodeOutputInterface 19 | { 20 | public function __construct($data, $lineno) 21 | { 22 | parent::__construct(array(), array('data' => $data), $lineno); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler $compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | $compiler 33 | ->addDebugInfo($this) 34 | ->write('echo ') 35 | ->string($this->getAttribute('data')) 36 | ->raw(";\n") 37 | ; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/NodeInterface.php: -------------------------------------------------------------------------------- 1 | 16 | * 17 | * @deprecated since 1.12 (to be removed in 3.0) 18 | */ 19 | interface Twig_NodeInterface extends Countable, IteratorAggregate 20 | { 21 | /** 22 | * Compiles the node to PHP. 23 | * 24 | * @param Twig_Compiler $compiler A Twig_Compiler instance 25 | */ 26 | public function compile(Twig_Compiler $compiler); 27 | 28 | public function getLine(); 29 | 30 | public function getNodeTag(); 31 | } 32 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/NodeOutputInterface.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | interface Twig_NodeOutputInterface 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/NodeTraverser.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_NodeTraverser 20 | { 21 | protected $env; 22 | protected $visitors; 23 | 24 | /** 25 | * Constructor. 26 | * 27 | * @param Twig_Environment $env A Twig_Environment instance 28 | * @param Twig_NodeVisitorInterface[] $visitors An array of Twig_NodeVisitorInterface instances 29 | */ 30 | public function __construct(Twig_Environment $env, array $visitors = array()) 31 | { 32 | $this->env = $env; 33 | $this->visitors = array(); 34 | foreach ($visitors as $visitor) { 35 | $this->addVisitor($visitor); 36 | } 37 | } 38 | 39 | /** 40 | * Adds a visitor. 41 | * 42 | * @param Twig_NodeVisitorInterface $visitor A Twig_NodeVisitorInterface instance 43 | */ 44 | public function addVisitor(Twig_NodeVisitorInterface $visitor) 45 | { 46 | if (!isset($this->visitors[$visitor->getPriority()])) { 47 | $this->visitors[$visitor->getPriority()] = array(); 48 | } 49 | 50 | $this->visitors[$visitor->getPriority()][] = $visitor; 51 | } 52 | 53 | /** 54 | * Traverses a node and calls the registered visitors. 55 | * 56 | * @param Twig_NodeInterface $node A Twig_NodeInterface instance 57 | * 58 | * @return Twig_NodeInterface 59 | */ 60 | public function traverse(Twig_NodeInterface $node) 61 | { 62 | ksort($this->visitors); 63 | foreach ($this->visitors as $visitors) { 64 | foreach ($visitors as $visitor) { 65 | $node = $this->traverseForVisitor($visitor, $node); 66 | } 67 | } 68 | 69 | return $node; 70 | } 71 | 72 | protected function traverseForVisitor(Twig_NodeVisitorInterface $visitor, Twig_NodeInterface $node = null) 73 | { 74 | if (null === $node) { 75 | return; 76 | } 77 | 78 | $node = $visitor->enterNode($node, $this->env); 79 | 80 | foreach ($node as $k => $n) { 81 | if (false !== $n = $this->traverseForVisitor($visitor, $n)) { 82 | $node->setNode($k, $n); 83 | } else { 84 | $node->removeNode($k); 85 | } 86 | } 87 | 88 | return $visitor->leaveNode($node, $this->env); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/NodeVisitorInterface.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | interface Twig_NodeVisitorInterface 18 | { 19 | /** 20 | * Called before child nodes are visited. 21 | * 22 | * @param Twig_NodeInterface $node The node to visit 23 | * @param Twig_Environment $env The Twig environment instance 24 | * 25 | * @return Twig_NodeInterface The modified node 26 | */ 27 | public function enterNode(Twig_NodeInterface $node, Twig_Environment $env); 28 | 29 | /** 30 | * Called after child nodes are visited. 31 | * 32 | * @param Twig_NodeInterface $node The node to visit 33 | * @param Twig_Environment $env The Twig environment instance 34 | * 35 | * @return Twig_NodeInterface|false The modified node or false if the node must be removed 36 | */ 37 | public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env); 38 | 39 | /** 40 | * Returns the priority for this visitor. 41 | * 42 | * Priority should be between -10 and 10 (0 is the default). 43 | * 44 | * @return int The priority level 45 | */ 46 | public function getPriority(); 47 | } 48 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/ParserInterface.php: -------------------------------------------------------------------------------- 1 | 16 | * 17 | * @deprecated since 1.12 (to be removed in 3.0) 18 | */ 19 | interface Twig_ParserInterface 20 | { 21 | /** 22 | * Converts a token stream to a node tree. 23 | * 24 | * @param Twig_TokenStream $stream A token stream instance 25 | * 26 | * @return Twig_Node_Module A node tree 27 | * 28 | * @throws Twig_Error_Syntax When the token stream is syntactically or semantically wrong 29 | */ 30 | public function parse(Twig_TokenStream $stream); 31 | } 32 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Profiler/Dumper/Blackfire.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | class Twig_Profiler_Dumper_Blackfire 16 | { 17 | public function dump(Twig_Profiler_Profile $profile) 18 | { 19 | $data = array(); 20 | $this->dumpProfile('main()', $profile, $data); 21 | $this->dumpChildren('main()', $profile, $data); 22 | 23 | $start = microtime(true); 24 | $str = << $values) { 33 | $str .= "{$name}//{$values['ct']} {$values['wt']} {$values['mu']} {$values['pmu']}\n"; 34 | } 35 | 36 | return $str; 37 | } 38 | 39 | private function dumpChildren($parent, Twig_Profiler_Profile $profile, &$data) 40 | { 41 | foreach ($profile as $p) { 42 | if ($p->isTemplate()) { 43 | $name = $p->getTemplate(); 44 | } else { 45 | $name = sprintf('%s::%s(%s)', $p->getTemplate(), $p->getType(), $p->getName()); 46 | } 47 | $this->dumpProfile(sprintf('%s==>%s', $parent, $name), $p, $data); 48 | $this->dumpChildren($name, $p, $data); 49 | } 50 | } 51 | 52 | private function dumpProfile($edge, Twig_Profiler_Profile $profile, &$data) 53 | { 54 | if (isset($data[$edge])) { 55 | $data[$edge]['ct'] += 1; 56 | $data[$edge]['wt'] += floor($profile->getDuration() * 1000000); 57 | $data[$edge]['mu'] += $profile->getMemoryUsage(); 58 | $data[$edge]['pmu'] += $profile->getPeakMemoryUsage(); 59 | } else { 60 | $data[$edge] = array( 61 | 'ct' => 1, 62 | 'wt' => floor($profile->getDuration() * 1000000), 63 | 'mu' => $profile->getMemoryUsage(), 64 | 'pmu' => $profile->getPeakMemoryUsage(), 65 | ); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Profiler/Dumper/Html.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | class Twig_Profiler_Dumper_Html extends Twig_Profiler_Dumper_Text 16 | { 17 | static private $colors = array( 18 | 'block' => '#dfd', 19 | 'macro' => '#ddf', 20 | 'template' => '#ffd', 21 | 'big' => '#d44', 22 | ); 23 | 24 | public function dump(Twig_Profiler_Profile $profile) 25 | { 26 | return '
'.parent::dump($profile).'
'; 27 | } 28 | 29 | protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix) 30 | { 31 | return sprintf('%s└ %s', $prefix, self::$colors['template'], $profile->getTemplate()); 32 | } 33 | 34 | protected function formatNonTemplate(Twig_Profiler_Profile $profile, $prefix) 35 | { 36 | return sprintf('%s└ %s::%s(%s)', $prefix, $profile->getTemplate(), $profile->getType(), isset(self::$colors[$profile->getType()]) ? self::$colors[$profile->getType()] : 'auto', $profile->getName()); 37 | } 38 | 39 | protected function formatTime(Twig_Profiler_Profile $profile, $percent) 40 | { 41 | return sprintf('%.2fms/%.0f%%', $percent > 20 ? self::$colors['big'] : 'auto', $profile->getDuration() * 1000, $percent); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Profiler/Dumper/Text.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | class Twig_Profiler_Dumper_Text 16 | { 17 | private $root; 18 | 19 | public function dump(Twig_Profiler_Profile $profile) 20 | { 21 | return $this->dumpProfile($profile); 22 | } 23 | 24 | protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix) 25 | { 26 | return sprintf('%s└ %s', $prefix, $profile->getTemplate()); 27 | } 28 | 29 | protected function formatNonTemplate(Twig_Profiler_Profile $profile, $prefix) 30 | { 31 | return sprintf('%s└ %s::%s(%s)', $prefix, $profile->getTemplate(), $profile->getType(), $profile->getName()); 32 | } 33 | 34 | protected function formatTime(Twig_Profiler_Profile $profile, $percent) 35 | { 36 | return sprintf('%.2fms/%.0f%%', $profile->getDuration() * 1000, $percent); 37 | } 38 | 39 | private function dumpProfile(Twig_Profiler_Profile $profile, $prefix = '', $sibling = false) 40 | { 41 | if ($profile->isRoot()) { 42 | $this->root = $profile->getDuration(); 43 | $start = $profile->getName(); 44 | } else { 45 | if ($profile->isTemplate()) { 46 | $start = $this->formatTemplate($profile, $prefix); 47 | } else { 48 | $start = $this->formatNonTemplate($profile, $prefix); 49 | } 50 | $prefix .= $sibling ? '│ ' : ' '; 51 | } 52 | 53 | $percent = $this->root ? $profile->getDuration() / $this->root * 100 : 0; 54 | 55 | if ($profile->getDuration() * 1000 < 1) { 56 | $str = $start."\n"; 57 | } else { 58 | $str = sprintf("%s %s\n", $start, $this->formatTime($profile, $percent)); 59 | } 60 | 61 | $nCount = count($profile->getProfiles()); 62 | foreach ($profile as $i => $p) { 63 | $str .= $this->dumpProfile($p, $prefix, $i + 1 !== $nCount); 64 | } 65 | 66 | return $str; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Profiler/Node/EnterProfile.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Profiler_Node_EnterProfile extends Twig_Node 18 | { 19 | public function __construct($extensionName, $type, $name, $varName) 20 | { 21 | parent::__construct(array(), array('extension_name' => $extensionName, 'name' => $name, 'type' => $type, 'var_name' => $varName)); 22 | } 23 | 24 | /** 25 | * {@inheritdoc} 26 | */ 27 | public function compile(Twig_Compiler $compiler) 28 | { 29 | $compiler 30 | ->write(sprintf("\$%s = \$this->env->getExtension(", $this->getAttribute('var_name'))) 31 | ->repr($this->getAttribute('extension_name')) 32 | ->raw(");\n") 33 | ->write(sprintf("\$%s->enter(\$%s = new Twig_Profiler_Profile(\$this->getTemplateName(), ", $this->getAttribute('var_name'), $this->getAttribute('var_name').'_prof')) 34 | ->repr($this->getAttribute('type')) 35 | ->raw(", ") 36 | ->repr($this->getAttribute('name')) 37 | ->raw("));\n\n") 38 | ; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Profiler/Node/LeaveProfile.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Profiler_Node_LeaveProfile extends Twig_Node 18 | { 19 | public function __construct($varName) 20 | { 21 | parent::__construct(array(), array('var_name' => $varName)); 22 | } 23 | 24 | /** 25 | * {@inheritdoc} 26 | */ 27 | public function compile(Twig_Compiler $compiler) 28 | { 29 | $compiler 30 | ->write("\n") 31 | ->write(sprintf("\$%s->leave(\$%s);\n\n", $this->getAttribute('var_name'), $this->getAttribute('var_name').'_prof')) 32 | ; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Profiler/NodeVisitor/Profiler.php: -------------------------------------------------------------------------------- 1 | 14 | */ 15 | class Twig_Profiler_NodeVisitor_Profiler implements Twig_NodeVisitorInterface 16 | { 17 | private $extensionName; 18 | 19 | public function __construct($extensionName) 20 | { 21 | $this->extensionName = $extensionName; 22 | } 23 | 24 | /** 25 | * {@inheritdoc} 26 | */ 27 | public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) 28 | { 29 | return $node; 30 | } 31 | 32 | /** 33 | * {@inheritdoc} 34 | */ 35 | public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env) 36 | { 37 | if ($node instanceof Twig_Node_Module) { 38 | $varName = $this->getVarName(); 39 | $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')))); 40 | $node->setNode('display_end', new Twig_Node(array(new Twig_Profiler_Node_LeaveProfile($varName), $node->getNode('display_end')))); 41 | } elseif ($node instanceof Twig_Node_Block) { 42 | $varName = $this->getVarName(); 43 | $node->setNode('body', new Twig_Node_Body(array( 44 | new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::BLOCK, $node->getAttribute('name'), $varName), 45 | $node->getNode('body'), 46 | new Twig_Profiler_Node_LeaveProfile($varName), 47 | ))); 48 | } elseif ($node instanceof Twig_Node_Macro) { 49 | $varName = $this->getVarName(); 50 | $node->setNode('body', new Twig_Node_Body(array( 51 | new Twig_Profiler_Node_EnterProfile($this->extensionName, Twig_Profiler_Profile::MACRO, $node->getAttribute('name'), $varName), 52 | $node->getNode('body'), 53 | new Twig_Profiler_Node_LeaveProfile($varName), 54 | ))); 55 | } 56 | 57 | return $node; 58 | } 59 | 60 | private function getVarName() 61 | { 62 | return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false)); 63 | } 64 | 65 | /** 66 | * {@inheritdoc} 67 | */ 68 | public function getPriority() 69 | { 70 | return 0; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Sandbox/SecurityError.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Sandbox_SecurityError extends Twig_Error 18 | { 19 | } 20 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Sandbox/SecurityNotAllowedFilterError.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Sandbox_SecurityNotAllowedFilterError extends Twig_Sandbox_SecurityError 18 | { 19 | private $filterName; 20 | 21 | public function __construct($message, $functionName, $lineno = -1, $filename = null, Exception $previous = null) 22 | { 23 | parent::__construct($message, $lineno, $filename, $previous); 24 | $this->filterName = $functionName; 25 | } 26 | 27 | public function getFilterName() 28 | { 29 | return $this->filterName; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Sandbox/SecurityNotAllowedFunctionError.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Sandbox_SecurityNotAllowedFunctionError extends Twig_Sandbox_SecurityError 18 | { 19 | private $functionName; 20 | 21 | public function __construct($message, $functionName, $lineno = -1, $filename = null, Exception $previous = null) 22 | { 23 | parent::__construct($message, $lineno, $filename, $previous); 24 | $this->functionName = $functionName; 25 | } 26 | 27 | public function getFunctionName() 28 | { 29 | return $this->functionName; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Sandbox/SecurityNotAllowedTagError.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_Sandbox_SecurityNotAllowedTagError extends Twig_Sandbox_SecurityError 18 | { 19 | private $tagName; 20 | 21 | public function __construct($message, $tagName, $lineno = -1, $filename = null, Exception $previous = null) 22 | { 23 | parent::__construct($message, $lineno, $filename, $previous); 24 | $this->tagName = $tagName; 25 | } 26 | 27 | public function getTagName() 28 | { 29 | return $this->tagName; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Sandbox/SecurityPolicyInterface.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | interface Twig_Sandbox_SecurityPolicyInterface 18 | { 19 | public function checkSecurity($tags, $filters, $functions); 20 | 21 | public function checkMethodAllowed($obj, $method); 22 | 23 | public function checkPropertyAllowed($obj, $method); 24 | } 25 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/SimpleFilter.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_SimpleFilter 18 | { 19 | protected $name; 20 | protected $callable; 21 | protected $options; 22 | protected $arguments = array(); 23 | 24 | public function __construct($name, $callable, array $options = array()) 25 | { 26 | $this->name = $name; 27 | $this->callable = $callable; 28 | $this->options = array_merge(array( 29 | 'needs_environment' => false, 30 | 'needs_context' => false, 31 | 'is_safe' => null, 32 | 'is_safe_callback' => null, 33 | 'pre_escape' => null, 34 | 'preserves_safety' => null, 35 | 'node_class' => 'Twig_Node_Expression_Filter', 36 | ), $options); 37 | } 38 | 39 | public function getName() 40 | { 41 | return $this->name; 42 | } 43 | 44 | public function getCallable() 45 | { 46 | return $this->callable; 47 | } 48 | 49 | public function getNodeClass() 50 | { 51 | return $this->options['node_class']; 52 | } 53 | 54 | public function setArguments($arguments) 55 | { 56 | $this->arguments = $arguments; 57 | } 58 | 59 | public function getArguments() 60 | { 61 | return $this->arguments; 62 | } 63 | 64 | public function needsEnvironment() 65 | { 66 | return $this->options['needs_environment']; 67 | } 68 | 69 | public function needsContext() 70 | { 71 | return $this->options['needs_context']; 72 | } 73 | 74 | public function getSafe(Twig_Node $filterArgs) 75 | { 76 | if (null !== $this->options['is_safe']) { 77 | return $this->options['is_safe']; 78 | } 79 | 80 | if (null !== $this->options['is_safe_callback']) { 81 | return call_user_func($this->options['is_safe_callback'], $filterArgs); 82 | } 83 | } 84 | 85 | public function getPreservesSafety() 86 | { 87 | return $this->options['preserves_safety']; 88 | } 89 | 90 | public function getPreEscape() 91 | { 92 | return $this->options['pre_escape']; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/SimpleFunction.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_SimpleFunction 18 | { 19 | protected $name; 20 | protected $callable; 21 | protected $options; 22 | protected $arguments = array(); 23 | 24 | public function __construct($name, $callable, array $options = array()) 25 | { 26 | $this->name = $name; 27 | $this->callable = $callable; 28 | $this->options = array_merge(array( 29 | 'needs_environment' => false, 30 | 'needs_context' => false, 31 | 'is_safe' => null, 32 | 'is_safe_callback' => null, 33 | 'node_class' => 'Twig_Node_Expression_Function', 34 | ), $options); 35 | } 36 | 37 | public function getName() 38 | { 39 | return $this->name; 40 | } 41 | 42 | public function getCallable() 43 | { 44 | return $this->callable; 45 | } 46 | 47 | public function getNodeClass() 48 | { 49 | return $this->options['node_class']; 50 | } 51 | 52 | public function setArguments($arguments) 53 | { 54 | $this->arguments = $arguments; 55 | } 56 | 57 | public function getArguments() 58 | { 59 | return $this->arguments; 60 | } 61 | 62 | public function needsEnvironment() 63 | { 64 | return $this->options['needs_environment']; 65 | } 66 | 67 | public function needsContext() 68 | { 69 | return $this->options['needs_context']; 70 | } 71 | 72 | public function getSafe(Twig_Node $functionArgs) 73 | { 74 | if (null !== $this->options['is_safe']) { 75 | return $this->options['is_safe']; 76 | } 77 | 78 | if (null !== $this->options['is_safe_callback']) { 79 | return call_user_func($this->options['is_safe_callback'], $functionArgs); 80 | } 81 | 82 | return array(); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/SimpleTest.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | class Twig_SimpleTest 18 | { 19 | protected $name; 20 | protected $callable; 21 | protected $options; 22 | 23 | public function __construct($name, $callable, array $options = array()) 24 | { 25 | $this->name = $name; 26 | $this->callable = $callable; 27 | $this->options = array_merge(array( 28 | 'node_class' => 'Twig_Node_Expression_Test', 29 | ), $options); 30 | } 31 | 32 | public function getName() 33 | { 34 | return $this->name; 35 | } 36 | 37 | public function getCallable() 38 | { 39 | return $this->callable; 40 | } 41 | 42 | public function getNodeClass() 43 | { 44 | return $this->options['node_class']; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/TemplateInterface.php: -------------------------------------------------------------------------------- 1 | 16 | * 17 | * @deprecated since 1.12 (to be removed in 3.0) 18 | */ 19 | interface Twig_TemplateInterface 20 | { 21 | const ANY_CALL = 'any'; 22 | const ARRAY_CALL = 'array'; 23 | const METHOD_CALL = 'method'; 24 | 25 | /** 26 | * Renders the template with the given context and returns it as string. 27 | * 28 | * @param array $context An array of parameters to pass to the template 29 | * 30 | * @return string The rendered template 31 | */ 32 | public function render(array $context); 33 | 34 | /** 35 | * Displays the template with the given context. 36 | * 37 | * @param array $context An array of parameters to pass to the template 38 | * @param array $blocks An array of blocks to pass to the template 39 | */ 40 | public function display(array $context, array $blocks = array()); 41 | 42 | /** 43 | * Returns the bound environment for this template. 44 | * 45 | * @return Twig_Environment The current environment 46 | */ 47 | public function getEnvironment(); 48 | } 49 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Test.php: -------------------------------------------------------------------------------- 1 | 16 | * @deprecated since 1.12 (to be removed in 2.0) 17 | */ 18 | abstract class Twig_Test implements Twig_TestInterface, Twig_TestCallableInterface 19 | { 20 | protected $options; 21 | protected $arguments = array(); 22 | 23 | public function __construct(array $options = array()) 24 | { 25 | $this->options = array_merge(array( 26 | 'callable' => null, 27 | ), $options); 28 | } 29 | 30 | public function getCallable() 31 | { 32 | return $this->options['callable']; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Test/Function.php: -------------------------------------------------------------------------------- 1 | 16 | * @deprecated since 1.12 (to be removed in 2.0) 17 | */ 18 | class Twig_Test_Function extends Twig_Test 19 | { 20 | protected $function; 21 | 22 | public function __construct($function, array $options = array()) 23 | { 24 | $options['callable'] = $function; 25 | 26 | parent::__construct($options); 27 | 28 | $this->function = $function; 29 | } 30 | 31 | public function compile() 32 | { 33 | return $this->function; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Test/Method.php: -------------------------------------------------------------------------------- 1 | 16 | * @deprecated since 1.12 (to be removed in 2.0) 17 | */ 18 | class Twig_Test_Method extends Twig_Test 19 | { 20 | protected $extension; 21 | protected $method; 22 | 23 | public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array()) 24 | { 25 | $options['callable'] = array($extension, $method); 26 | 27 | parent::__construct($options); 28 | 29 | $this->extension = $extension; 30 | $this->method = $method; 31 | } 32 | 33 | public function compile() 34 | { 35 | return sprintf('$this->env->getExtension(\'%s\')->%s', $this->extension->getName(), $this->method); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Test/Node.php: -------------------------------------------------------------------------------- 1 | 16 | * @deprecated since 1.12 (to be removed in 2.0) 17 | */ 18 | class Twig_Test_Node extends Twig_Test 19 | { 20 | protected $class; 21 | 22 | public function __construct($class, array $options = array()) 23 | { 24 | parent::__construct($options); 25 | 26 | $this->class = $class; 27 | } 28 | 29 | public function getClass() 30 | { 31 | return $this->class; 32 | } 33 | 34 | public function compile() 35 | { 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/Test/NodeTestCase.php: -------------------------------------------------------------------------------- 1 | assertNodeCompilation($source, $node, $environment); 21 | } 22 | 23 | public function assertNodeCompilation($source, Twig_Node $node, Twig_Environment $environment = null) 24 | { 25 | $compiler = $this->getCompiler($environment); 26 | $compiler->compile($node); 27 | 28 | $this->assertEquals($source, trim($compiler->getSource())); 29 | } 30 | 31 | protected function getCompiler(Twig_Environment $environment = null) 32 | { 33 | return new Twig_Compiler(null === $environment ? $this->getEnvironment() : $environment); 34 | } 35 | 36 | protected function getEnvironment() 37 | { 38 | return new Twig_Environment(); 39 | } 40 | 41 | protected function getVariableGetter($name, $line = false) 42 | { 43 | $line = $line > 0 ? "// line {$line}\n" : ''; 44 | 45 | if (PHP_VERSION_ID >= 50400) { 46 | return sprintf('%s(isset($context["%s"]) ? $context["%s"] : null)', $line, $name, $name); 47 | } 48 | 49 | return sprintf('%s$this->getContext($context, "%s")', $line, $name); 50 | } 51 | 52 | protected function getAttributeGetter() 53 | { 54 | if (function_exists('twig_template_get_attributes')) { 55 | return 'twig_template_get_attributes($this, '; 56 | } 57 | 58 | return '$this->getAttribute('; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/TestCallableInterface.php: -------------------------------------------------------------------------------- 1 | 16 | * @deprecated since 1.12 (to be removed in 2.0) 17 | */ 18 | interface Twig_TestCallableInterface 19 | { 20 | public function getCallable(); 21 | } 22 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/TestInterface.php: -------------------------------------------------------------------------------- 1 | 16 | * @deprecated since 1.12 (to be removed in 2.0) 17 | */ 18 | interface Twig_TestInterface 19 | { 20 | /** 21 | * Compiles a test. 22 | * 23 | * @return string The PHP code for the test 24 | */ 25 | public function compile(); 26 | } 27 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/TokenParser.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | abstract class Twig_TokenParser implements Twig_TokenParserInterface 18 | { 19 | /** 20 | * @var Twig_Parser 21 | */ 22 | protected $parser; 23 | 24 | /** 25 | * Sets the parser associated with this token parser 26 | * 27 | * @param Twig_Parser $parser A Twig_Parser instance 28 | */ 29 | public function setParser(Twig_Parser $parser) 30 | { 31 | $this->parser = $parser; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/TokenParser/Block.php: -------------------------------------------------------------------------------- 1 | 17 | * {% block head %} 18 | * 19 | * {% block title %}{% endblock %} - My Webpage 20 | * {% endblock %} 21 | * 22 | */ 23 | class Twig_TokenParser_Block extends Twig_TokenParser 24 | { 25 | /** 26 | * Parses a token and returns a node. 27 | * 28 | * @param Twig_Token $token A Twig_Token instance 29 | * 30 | * @return Twig_NodeInterface A Twig_NodeInterface instance 31 | */ 32 | public function parse(Twig_Token $token) 33 | { 34 | $lineno = $token->getLine(); 35 | $stream = $this->parser->getStream(); 36 | $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); 37 | if ($this->parser->hasBlock($name)) { 38 | 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()); 39 | } 40 | $this->parser->setBlock($name, $block = new Twig_Node_Block($name, new Twig_Node(array()), $lineno)); 41 | $this->parser->pushLocalScope(); 42 | $this->parser->pushBlockStack($name); 43 | 44 | if ($stream->nextIf(Twig_Token::BLOCK_END_TYPE)) { 45 | $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); 46 | if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) { 47 | $value = $token->getValue(); 48 | 49 | if ($value != $name) { 50 | throw new Twig_Error_Syntax(sprintf('Expected endblock for block "%s" (but "%s" given)', $name, $value), $stream->getCurrent()->getLine(), $stream->getFilename()); 51 | } 52 | } 53 | } else { 54 | $body = new Twig_Node(array( 55 | new Twig_Node_Print($this->parser->getExpressionParser()->parseExpression(), $lineno), 56 | )); 57 | } 58 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 59 | 60 | $block->setNode('body', $body); 61 | $this->parser->popBlockStack(); 62 | $this->parser->popLocalScope(); 63 | 64 | return new Twig_Node_BlockReference($name, $lineno, $this->getTag()); 65 | } 66 | 67 | public function decideBlockEnd(Twig_Token $token) 68 | { 69 | return $token->test('endblock'); 70 | } 71 | 72 | /** 73 | * Gets the tag name associated with this token parser. 74 | * 75 | * @return string The tag name 76 | */ 77 | public function getTag() 78 | { 79 | return 'block'; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/TokenParser/Do.php: -------------------------------------------------------------------------------- 1 | parser->getExpressionParser()->parseExpression(); 27 | 28 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 29 | 30 | return new Twig_Node_Do($expr, $token->getLine(), $this->getTag()); 31 | } 32 | 33 | /** 34 | * Gets the tag name associated with this token parser. 35 | * 36 | * @return string The tag name 37 | */ 38 | public function getTag() 39 | { 40 | return 'do'; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/TokenParser/Embed.php: -------------------------------------------------------------------------------- 1 | parser->getStream(); 27 | 28 | $parent = $this->parser->getExpressionParser()->parseExpression(); 29 | 30 | list($variables, $only, $ignoreMissing) = $this->parseArguments(); 31 | 32 | // inject a fake parent to make the parent() function work 33 | $stream->injectTokens(array( 34 | new Twig_Token(Twig_Token::BLOCK_START_TYPE, '', $token->getLine()), 35 | new Twig_Token(Twig_Token::NAME_TYPE, 'extends', $token->getLine()), 36 | new Twig_Token(Twig_Token::STRING_TYPE, '__parent__', $token->getLine()), 37 | new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', $token->getLine()), 38 | )); 39 | 40 | $module = $this->parser->parse($stream, array($this, 'decideBlockEnd'), true); 41 | 42 | // override the parent with the correct one 43 | $module->setNode('parent', $parent); 44 | 45 | $this->parser->embedTemplate($module); 46 | 47 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 48 | 49 | return new Twig_Node_Embed($module->getAttribute('filename'), $module->getAttribute('index'), $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); 50 | } 51 | 52 | public function decideBlockEnd(Twig_Token $token) 53 | { 54 | return $token->test('endembed'); 55 | } 56 | 57 | /** 58 | * Gets the tag name associated with this token parser. 59 | * 60 | * @return string The tag name 61 | */ 62 | public function getTag() 63 | { 64 | return 'embed'; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/TokenParser/Extends.php: -------------------------------------------------------------------------------- 1 | 17 | * {% extends "base.html" %} 18 | * 19 | */ 20 | class Twig_TokenParser_Extends extends Twig_TokenParser 21 | { 22 | /** 23 | * Parses a token and returns a node. 24 | * 25 | * @param Twig_Token $token A Twig_Token instance 26 | * 27 | * @return Twig_NodeInterface A Twig_NodeInterface instance 28 | */ 29 | public function parse(Twig_Token $token) 30 | { 31 | if (!$this->parser->isMainScope()) { 32 | throw new Twig_Error_Syntax('Cannot extend from a block', $token->getLine(), $this->parser->getFilename()); 33 | } 34 | 35 | if (null !== $this->parser->getParent()) { 36 | throw new Twig_Error_Syntax('Multiple extends tags are forbidden', $token->getLine(), $this->parser->getFilename()); 37 | } 38 | $this->parser->setParent($this->parser->getExpressionParser()->parseExpression()); 39 | 40 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 41 | } 42 | 43 | /** 44 | * Gets the tag name associated with this token parser. 45 | * 46 | * @return string The tag name 47 | */ 48 | public function getTag() 49 | { 50 | return 'extends'; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/TokenParser/Filter.php: -------------------------------------------------------------------------------- 1 | 16 | * {% filter upper %} 17 | * This text becomes uppercase 18 | * {% endfilter %} 19 | * 20 | */ 21 | class Twig_TokenParser_Filter extends Twig_TokenParser 22 | { 23 | /** 24 | * Parses a token and returns a node. 25 | * 26 | * @param Twig_Token $token A Twig_Token instance 27 | * 28 | * @return Twig_NodeInterface A Twig_NodeInterface instance 29 | */ 30 | public function parse(Twig_Token $token) 31 | { 32 | $name = $this->parser->getVarName(); 33 | $ref = new Twig_Node_Expression_BlockReference(new Twig_Node_Expression_Constant($name, $token->getLine()), true, $token->getLine(), $this->getTag()); 34 | 35 | $filter = $this->parser->getExpressionParser()->parseFilterExpressionRaw($ref, $this->getTag()); 36 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 37 | 38 | $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); 39 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 40 | 41 | $block = new Twig_Node_Block($name, $body, $token->getLine()); 42 | $this->parser->setBlock($name, $block); 43 | 44 | return new Twig_Node_Print($filter, $token->getLine(), $this->getTag()); 45 | } 46 | 47 | public function decideBlockEnd(Twig_Token $token) 48 | { 49 | return $token->test('endfilter'); 50 | } 51 | 52 | /** 53 | * Gets the tag name associated with this token parser. 54 | * 55 | * @return string The tag name 56 | */ 57 | public function getTag() 58 | { 59 | return 'filter'; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/TokenParser/Flush.php: -------------------------------------------------------------------------------- 1 | parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 29 | 30 | return new Twig_Node_Flush($token->getLine(), $this->getTag()); 31 | } 32 | 33 | /** 34 | * Gets the tag name associated with this token parser. 35 | * 36 | * @return string The tag name 37 | */ 38 | public function getTag() 39 | { 40 | return 'flush'; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/TokenParser/From.php: -------------------------------------------------------------------------------- 1 | 16 | * {% from 'forms.html' import forms %} 17 | * 18 | */ 19 | class Twig_TokenParser_From extends Twig_TokenParser 20 | { 21 | /** 22 | * Parses a token and returns a node. 23 | * 24 | * @param Twig_Token $token A Twig_Token instance 25 | * 26 | * @return Twig_NodeInterface A Twig_NodeInterface instance 27 | */ 28 | public function parse(Twig_Token $token) 29 | { 30 | $macro = $this->parser->getExpressionParser()->parseExpression(); 31 | $stream = $this->parser->getStream(); 32 | $stream->expect('import'); 33 | 34 | $targets = array(); 35 | do { 36 | $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); 37 | 38 | $alias = $name; 39 | if ($stream->nextIf('as')) { 40 | $alias = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); 41 | } 42 | 43 | $targets[$name] = $alias; 44 | 45 | if (!$stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) { 46 | break; 47 | } 48 | } while (true); 49 | 50 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 51 | 52 | $node = new Twig_Node_Import($macro, new Twig_Node_Expression_AssignName($this->parser->getVarName(), $token->getLine()), $token->getLine(), $this->getTag()); 53 | 54 | foreach ($targets as $name => $alias) { 55 | $this->parser->addImportedSymbol('function', $alias, 'get'.$name, $node->getNode('var')); 56 | } 57 | 58 | return $node; 59 | } 60 | 61 | /** 62 | * Gets the tag name associated with this token parser. 63 | * 64 | * @return string The tag name 65 | */ 66 | public function getTag() 67 | { 68 | return 'from'; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/TokenParser/Import.php: -------------------------------------------------------------------------------- 1 | 16 | * {% import 'forms.html' as forms %} 17 | * 18 | */ 19 | class Twig_TokenParser_Import extends Twig_TokenParser 20 | { 21 | /** 22 | * Parses a token and returns a node. 23 | * 24 | * @param Twig_Token $token A Twig_Token instance 25 | * 26 | * @return Twig_NodeInterface A Twig_NodeInterface instance 27 | */ 28 | public function parse(Twig_Token $token) 29 | { 30 | $macro = $this->parser->getExpressionParser()->parseExpression(); 31 | $this->parser->getStream()->expect('as'); 32 | $var = new Twig_Node_Expression_AssignName($this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue(), $token->getLine()); 33 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 34 | 35 | $this->parser->addImportedSymbol('template', $var->getAttribute('name')); 36 | 37 | return new Twig_Node_Import($macro, $var, $token->getLine(), $this->getTag()); 38 | } 39 | 40 | /** 41 | * Gets the tag name associated with this token parser. 42 | * 43 | * @return string The tag name 44 | */ 45 | public function getTag() 46 | { 47 | return 'import'; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/TokenParser/Include.php: -------------------------------------------------------------------------------- 1 | 17 | * {% include 'header.html' %} 18 | * Body 19 | * {% include 'footer.html' %} 20 | * 21 | */ 22 | class Twig_TokenParser_Include extends Twig_TokenParser 23 | { 24 | /** 25 | * Parses a token and returns a node. 26 | * 27 | * @param Twig_Token $token A Twig_Token instance 28 | * 29 | * @return Twig_NodeInterface A Twig_NodeInterface instance 30 | */ 31 | public function parse(Twig_Token $token) 32 | { 33 | $expr = $this->parser->getExpressionParser()->parseExpression(); 34 | 35 | list($variables, $only, $ignoreMissing) = $this->parseArguments(); 36 | 37 | return new Twig_Node_Include($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); 38 | } 39 | 40 | protected function parseArguments() 41 | { 42 | $stream = $this->parser->getStream(); 43 | 44 | $ignoreMissing = false; 45 | if ($stream->nextIf(Twig_Token::NAME_TYPE, 'ignore')) { 46 | $stream->expect(Twig_Token::NAME_TYPE, 'missing'); 47 | 48 | $ignoreMissing = true; 49 | } 50 | 51 | $variables = null; 52 | if ($stream->nextIf(Twig_Token::NAME_TYPE, 'with')) { 53 | $variables = $this->parser->getExpressionParser()->parseExpression(); 54 | } 55 | 56 | $only = false; 57 | if ($stream->nextIf(Twig_Token::NAME_TYPE, 'only')) { 58 | $only = true; 59 | } 60 | 61 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 62 | 63 | return array($variables, $only, $ignoreMissing); 64 | } 65 | 66 | /** 67 | * Gets the tag name associated with this token parser. 68 | * 69 | * @return string The tag name 70 | */ 71 | public function getTag() 72 | { 73 | return 'include'; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/TokenParser/Macro.php: -------------------------------------------------------------------------------- 1 | 16 | * {% macro input(name, value, type, size) %} 17 | * 18 | * {% endmacro %} 19 | * 20 | */ 21 | class Twig_TokenParser_Macro extends Twig_TokenParser 22 | { 23 | /** 24 | * Parses a token and returns a node. 25 | * 26 | * @param Twig_Token $token A Twig_Token instance 27 | * 28 | * @return Twig_NodeInterface A Twig_NodeInterface instance 29 | */ 30 | public function parse(Twig_Token $token) 31 | { 32 | $lineno = $token->getLine(); 33 | $stream = $this->parser->getStream(); 34 | $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); 35 | 36 | $arguments = $this->parser->getExpressionParser()->parseArguments(true, true); 37 | 38 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 39 | $this->parser->pushLocalScope(); 40 | $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); 41 | if ($token = $stream->nextIf(Twig_Token::NAME_TYPE)) { 42 | $value = $token->getValue(); 43 | 44 | if ($value != $name) { 45 | throw new Twig_Error_Syntax(sprintf('Expected endmacro for macro "%s" (but "%s" given)', $name, $value), $stream->getCurrent()->getLine(), $stream->getFilename()); 46 | } 47 | } 48 | $this->parser->popLocalScope(); 49 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 50 | 51 | $this->parser->setMacro($name, new Twig_Node_Macro($name, new Twig_Node_Body(array($body)), $arguments, $lineno, $this->getTag())); 52 | } 53 | 54 | public function decideBlockEnd(Twig_Token $token) 55 | { 56 | return $token->test('endmacro'); 57 | } 58 | 59 | /** 60 | * Gets the tag name associated with this token parser. 61 | * 62 | * @return string The tag name 63 | */ 64 | public function getTag() 65 | { 66 | return 'macro'; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/TokenParser/Sandbox.php: -------------------------------------------------------------------------------- 1 | 16 | * {% sandbox %} 17 | * {% include 'user.html' %} 18 | * {% endsandbox %} 19 | * 20 | * 21 | * @see http://www.twig-project.org/doc/api.html#sandbox-extension for details 22 | */ 23 | class Twig_TokenParser_Sandbox extends Twig_TokenParser 24 | { 25 | /** 26 | * Parses a token and returns a node. 27 | * 28 | * @param Twig_Token $token A Twig_Token instance 29 | * 30 | * @return Twig_NodeInterface A Twig_NodeInterface instance 31 | */ 32 | public function parse(Twig_Token $token) 33 | { 34 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 35 | $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); 36 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 37 | 38 | // in a sandbox tag, only include tags are allowed 39 | if (!$body instanceof Twig_Node_Include) { 40 | foreach ($body as $node) { 41 | if ($node instanceof Twig_Node_Text && ctype_space($node->getAttribute('data'))) { 42 | continue; 43 | } 44 | 45 | if (!$node instanceof Twig_Node_Include) { 46 | throw new Twig_Error_Syntax('Only "include" tags are allowed within a "sandbox" section', $node->getLine(), $this->parser->getFilename()); 47 | } 48 | } 49 | } 50 | 51 | return new Twig_Node_Sandbox($body, $token->getLine(), $this->getTag()); 52 | } 53 | 54 | public function decideBlockEnd(Twig_Token $token) 55 | { 56 | return $token->test('endsandbox'); 57 | } 58 | 59 | /** 60 | * Gets the tag name associated with this token parser. 61 | * 62 | * @return string The tag name 63 | */ 64 | public function getTag() 65 | { 66 | return 'sandbox'; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/TokenParser/Set.php: -------------------------------------------------------------------------------- 1 | 16 | * {% set foo = 'foo' %} 17 | * 18 | * {% set foo = [1, 2] %} 19 | * 20 | * {% set foo = {'foo': 'bar'} %} 21 | * 22 | * {% set foo = 'foo' ~ 'bar' %} 23 | * 24 | * {% set foo, bar = 'foo', 'bar' %} 25 | * 26 | * {% set foo %}Some content{% endset %} 27 | * 28 | */ 29 | class Twig_TokenParser_Set extends Twig_TokenParser 30 | { 31 | /** 32 | * Parses a token and returns a node. 33 | * 34 | * @param Twig_Token $token A Twig_Token instance 35 | * 36 | * @return Twig_NodeInterface A Twig_NodeInterface instance 37 | */ 38 | public function parse(Twig_Token $token) 39 | { 40 | $lineno = $token->getLine(); 41 | $stream = $this->parser->getStream(); 42 | $names = $this->parser->getExpressionParser()->parseAssignmentExpression(); 43 | 44 | $capture = false; 45 | if ($stream->nextIf(Twig_Token::OPERATOR_TYPE, '=')) { 46 | $values = $this->parser->getExpressionParser()->parseMultitargetExpression(); 47 | 48 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 49 | 50 | if (count($names) !== count($values)) { 51 | throw new Twig_Error_Syntax('When using set, you must have the same number of variables and assignments.', $stream->getCurrent()->getLine(), $stream->getFilename()); 52 | } 53 | } else { 54 | $capture = true; 55 | 56 | if (count($names) > 1) { 57 | throw new Twig_Error_Syntax('When using set with a block, you cannot have a multi-target.', $stream->getCurrent()->getLine(), $stream->getFilename()); 58 | } 59 | 60 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 61 | 62 | $values = $this->parser->subparse(array($this, 'decideBlockEnd'), true); 63 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 64 | } 65 | 66 | return new Twig_Node_Set($capture, $names, $values, $lineno, $this->getTag()); 67 | } 68 | 69 | public function decideBlockEnd(Twig_Token $token) 70 | { 71 | return $token->test('endset'); 72 | } 73 | 74 | /** 75 | * Gets the tag name associated with this token parser. 76 | * 77 | * @return string The tag name 78 | */ 79 | public function getTag() 80 | { 81 | return 'set'; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/TokenParser/Spaceless.php: -------------------------------------------------------------------------------- 1 | 16 | * {% spaceless %} 17 | *
18 | * foo 19 | *
20 | * {% endspaceless %} 21 | * 22 | * {# output will be
foo
#} 23 | * 24 | */ 25 | class Twig_TokenParser_Spaceless extends Twig_TokenParser 26 | { 27 | /** 28 | * Parses a token and returns a node. 29 | * 30 | * @param Twig_Token $token A Twig_Token instance 31 | * 32 | * @return Twig_NodeInterface A Twig_NodeInterface instance 33 | */ 34 | public function parse(Twig_Token $token) 35 | { 36 | $lineno = $token->getLine(); 37 | 38 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 39 | $body = $this->parser->subparse(array($this, 'decideSpacelessEnd'), true); 40 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 41 | 42 | return new Twig_Node_Spaceless($body, $lineno, $this->getTag()); 43 | } 44 | 45 | public function decideSpacelessEnd(Twig_Token $token) 46 | { 47 | return $token->test('endspaceless'); 48 | } 49 | 50 | /** 51 | * Gets the tag name associated with this token parser. 52 | * 53 | * @return string The tag name 54 | */ 55 | public function getTag() 56 | { 57 | return 'spaceless'; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/TokenParser/Use.php: -------------------------------------------------------------------------------- 1 | 16 | * {% extends "base.html" %} 17 | * 18 | * {% use "blocks.html" %} 19 | * 20 | * {% block title %}{% endblock %} 21 | * {% block content %}{% endblock %} 22 | * 23 | * 24 | * @see http://www.twig-project.org/doc/templates.html#horizontal-reuse for details. 25 | */ 26 | class Twig_TokenParser_Use extends Twig_TokenParser 27 | { 28 | /** 29 | * Parses a token and returns a node. 30 | * 31 | * @param Twig_Token $token A Twig_Token instance 32 | * 33 | * @return Twig_NodeInterface A Twig_NodeInterface instance 34 | */ 35 | public function parse(Twig_Token $token) 36 | { 37 | $template = $this->parser->getExpressionParser()->parseExpression(); 38 | $stream = $this->parser->getStream(); 39 | 40 | if (!$template instanceof Twig_Node_Expression_Constant) { 41 | throw new Twig_Error_Syntax('The template references in a "use" statement must be a string.', $stream->getCurrent()->getLine(), $stream->getFilename()); 42 | } 43 | 44 | $targets = array(); 45 | if ($stream->nextIf('with')) { 46 | do { 47 | $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); 48 | 49 | $alias = $name; 50 | if ($stream->nextIf('as')) { 51 | $alias = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); 52 | } 53 | 54 | $targets[$name] = new Twig_Node_Expression_Constant($alias, -1); 55 | 56 | if (!$stream->nextIf(Twig_Token::PUNCTUATION_TYPE, ',')) { 57 | break; 58 | } 59 | } while (true); 60 | } 61 | 62 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 63 | 64 | $this->parser->addTrait(new Twig_Node(array('template' => $template, 'targets' => new Twig_Node($targets)))); 65 | } 66 | 67 | /** 68 | * Gets the tag name associated with this token parser. 69 | * 70 | * @return string The tag name 71 | */ 72 | public function getTag() 73 | { 74 | return 'use'; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/TokenParserBrokerInterface.php: -------------------------------------------------------------------------------- 1 | 19 | * @deprecated since 1.12 (to be removed in 2.0) 20 | */ 21 | interface Twig_TokenParserBrokerInterface 22 | { 23 | /** 24 | * Gets a TokenParser suitable for a tag. 25 | * 26 | * @param string $tag A tag name 27 | * 28 | * @return null|Twig_TokenParserInterface A Twig_TokenParserInterface or null if no suitable TokenParser was found 29 | */ 30 | public function getTokenParser($tag); 31 | 32 | /** 33 | * Calls Twig_TokenParserInterface::setParser on all parsers the implementation knows of. 34 | * 35 | * @param Twig_ParserInterface $parser A Twig_ParserInterface interface 36 | */ 37 | public function setParser(Twig_ParserInterface $parser); 38 | 39 | /** 40 | * Gets the Twig_ParserInterface. 41 | * 42 | * @return null|Twig_ParserInterface A Twig_ParserInterface instance or null 43 | */ 44 | public function getParser(); 45 | } 46 | -------------------------------------------------------------------------------- /ansible-logger-web/includes/Twig/TokenParserInterface.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | interface Twig_TokenParserInterface 18 | { 19 | /** 20 | * Sets the parser associated with this token parser 21 | * 22 | * @param Twig_Parser $parser A Twig_Parser instance 23 | */ 24 | public function setParser(Twig_Parser $parser); 25 | 26 | /** 27 | * Parses a token and returns a node. 28 | * 29 | * @param Twig_Token $token A Twig_Token instance 30 | * 31 | * @return Twig_NodeInterface A Twig_NodeInterface instance 32 | * 33 | * @throws Twig_Error_Syntax 34 | */ 35 | public function parse(Twig_Token $token); 36 | 37 | /** 38 | * Gets the tag name associated with this token parser. 39 | * 40 | * @return string The tag name 41 | */ 42 | public function getTag(); 43 | } 44 | -------------------------------------------------------------------------------- /ansible-logger-web/public/.htaccess: -------------------------------------------------------------------------------- 1 | RewriteEngine On 2 | 3 | # Some hosts may require you to use the `RewriteBase` directive. 4 | # If you need to use the `RewriteBase` directive, it should be the 5 | # absolute physical path to the directory that contains this htaccess file. 6 | # 7 | # RewriteBase / 8 | 9 | RewriteCond %{REQUEST_FILENAME} !-d 10 | RewriteCond %{REQUEST_FILENAME} !-f 11 | RewriteRule ^ index.php [QSA,L] 12 | -------------------------------------------------------------------------------- /ansible-logger-web/public/static/css/ansible-logger.css: -------------------------------------------------------------------------------- 1 | .failed { 2 | color: red; 3 | } 4 | 5 | .unreachable { 6 | color: red; 7 | } 8 | 9 | .skipped { 10 | color: blue; 11 | } 12 | 13 | .changed { 14 | color: orange; 15 | } 16 | 17 | .ok { 18 | color: green; 19 | } 20 | -------------------------------------------------------------------------------- /ansible-logger-web/public/static/css/dashboard.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Base structure 3 | */ 4 | 5 | /* Move down content because we have a fixed navbar that is 50px tall */ 6 | body { 7 | padding-top: 50px; 8 | } 9 | 10 | 11 | /* 12 | * Global add-ons 13 | */ 14 | 15 | .sub-header { 16 | padding-bottom: 10px; 17 | border-bottom: 1px solid #eee; 18 | } 19 | 20 | /* 21 | * Top navigation 22 | * Hide default border to remove 1px line. 23 | */ 24 | .navbar-fixed-top { 25 | border: 0; 26 | } 27 | 28 | /* 29 | * Sidebar 30 | */ 31 | 32 | /* Hide for mobile, show later */ 33 | .sidebar { 34 | display: none; 35 | } 36 | @media (min-width: 768px) { 37 | .sidebar { 38 | position: fixed; 39 | top: 51px; 40 | bottom: 0; 41 | left: 0; 42 | z-index: 1000; 43 | display: block; 44 | padding: 20px; 45 | overflow-x: hidden; 46 | overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */ 47 | background-color: #f5f5f5; 48 | border-right: 1px solid #eee; 49 | } 50 | } 51 | 52 | /* Sidebar navigation */ 53 | .nav-sidebar { 54 | margin-right: -21px; /* 20px padding + 1px border */ 55 | margin-bottom: 20px; 56 | margin-left: -20px; 57 | } 58 | .nav-sidebar > li > a { 59 | padding-right: 20px; 60 | padding-left: 20px; 61 | } 62 | .nav-sidebar > .active > a, 63 | .nav-sidebar > .active > a:hover, 64 | .nav-sidebar > .active > a:focus { 65 | color: #fff; 66 | background-color: #428bca; 67 | } 68 | 69 | 70 | /* 71 | * Main content 72 | */ 73 | 74 | .main { 75 | padding: 20px; 76 | } 77 | @media (min-width: 768px) { 78 | .main { 79 | padding-right: 40px; 80 | padding-left: 40px; 81 | } 82 | } 83 | .main .page-header { 84 | margin-top: 0; 85 | } 86 | 87 | 88 | /* 89 | * Placeholder dashboard ideas 90 | */ 91 | 92 | .placeholders { 93 | margin-bottom: 30px; 94 | text-align: center; 95 | } 96 | .placeholders h4 { 97 | margin-bottom: 0; 98 | } 99 | .placeholder { 100 | margin-bottom: 20px; 101 | } 102 | .placeholder img { 103 | display: inline-block; 104 | border-radius: 50%; 105 | } 106 | -------------------------------------------------------------------------------- /ansible-logger-web/public/static/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sipgate/ansible-logger/b0b53dbaa878d804c8709f32b5e38d9fe55eb61c/ansible-logger-web/public/static/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /ansible-logger-web/public/static/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sipgate/ansible-logger/b0b53dbaa878d804c8709f32b5e38d9fe55eb61c/ansible-logger-web/public/static/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /ansible-logger-web/public/static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sipgate/ansible-logger/b0b53dbaa878d804c8709f32b5e38d9fe55eb61c/ansible-logger-web/public/static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /ansible-logger-web/public/static/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sipgate/ansible-logger/b0b53dbaa878d804c8709f32b5e38d9fe55eb61c/ansible-logger-web/public/static/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /ansible-logger-web/public/static/js/ie10-viewport-bug-workaround.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * IE10 viewport hack for Surface/desktop Windows 8 bug 3 | * Copyright 2014-2015 Twitter, Inc. 4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 5 | */ 6 | 7 | // See the Getting Started docs for more information: 8 | // http://getbootstrap.com/getting-started/#support-ie10-width 9 | 10 | (function () { 11 | 'use strict'; 12 | 13 | if (navigator.userAgent.match(/IEMobile\/10\.0/)) { 14 | var msViewportStyle = document.createElement('style') 15 | msViewportStyle.appendChild( 16 | document.createTextNode( 17 | '@-ms-viewport{width:auto!important}' 18 | ) 19 | ) 20 | document.querySelector('head').appendChild(msViewportStyle) 21 | } 22 | 23 | })(); 24 | -------------------------------------------------------------------------------- /ansible-logger-web/public/static/js/npm.js: -------------------------------------------------------------------------------- 1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. 2 | require('../../js/transition.js') 3 | require('../../js/alert.js') 4 | require('../../js/button.js') 5 | require('../../js/carousel.js') 6 | require('../../js/collapse.js') 7 | require('../../js/dropdown.js') 8 | require('../../js/modal.js') 9 | require('../../js/tooltip.js') 10 | require('../../js/popover.js') 11 | require('../../js/scrollspy.js') 12 | require('../../js/tab.js') 13 | require('../../js/affix.js') -------------------------------------------------------------------------------- /ansible-logger-web/tpl/page_dashboard.html: -------------------------------------------------------------------------------- 1 | {% extends "index.html" %} 2 | {% block content%} 3 |

Dashboard

4 | 28 |

Recent Ansible Jobs

29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | {% for item in ansiblePlays %} 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | {% endif %} 51 | 52 | {% endfor %} 53 | 54 |
Start TimeDurationGroup/HostnameHostsTasksChangedResult
{{ item.playStart }}{% if item.isRunning %}Running{% else %}{{ item.playTimePretty }}{% endif %}{{ item.playPattern }}{{ item.hostCount }}{{ item.taskCount }}{% if item.hasChanged %}Yes{% else %}No{% endif %}{% if item.hasFailed %}Failed{% else %}OK
55 | 60 | 61 | {% endblock %} 62 | -------------------------------------------------------------------------------- /ansible-logger-web/tpl/page_hostfactview.html: -------------------------------------------------------------------------------- 1 | {% extends "index.html" %} 2 | {% block content%} 3 |

Host Facts for {{ currentHost }}

4 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | {% for item in hostFacts %} 37 | 38 | 39 | 40 | 41 | {% endfor %} 42 | 43 |
FactValue
{{ item.factName }}{{ item.factData }}
44 | 49 | {% endblock %} 50 | -------------------------------------------------------------------------------- /ansible-logger-web/tpl/page_hostplayhistory.html: -------------------------------------------------------------------------------- 1 | {% extends "index.html" %} 2 | {% block content%} 3 |

Host Details for {{ currentHost }}

4 | 28 |

Recent Ansible Jobs

29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | {% for item in ansiblePlays %} 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | {% endif %} 51 | 52 | {% endfor %} 53 | 54 |
Start TimeDurationGroup/HostnameHostsTasksChangedResult
{{ item.playStart }}{% if item.isRunning %}Running{% else %}{{ item.playTimePretty }}{% endif %}{{ item.playPattern }}{{ item.hostCount }}{{ item.taskCount }}{% if item.hasChanged %}Yes{% else %}No{% endif %}{% if item.hasFailed %}Failed{% else %}OK
55 | 60 | {% endblock %} 61 | -------------------------------------------------------------------------------- /ansible-logger-web/tpl/page_hosts.html: -------------------------------------------------------------------------------- 1 | {% extends "index.html" %} 2 | {% block content%} 3 |

Hosts

4 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | {% for item in hosts %} 39 | 40 | 41 | 42 | 43 | 44 | 45 | {% endfor %} 46 | 47 |
FQDNLast SeenRecent PlaybooksFacts
{{ item.hostName }}{{ item.lastSeen }}ViewView
48 | 53 | 54 | {% endblock %} 55 | -------------------------------------------------------------------------------- /ansible-logger-web/tpl/page_playbookdetails.html: -------------------------------------------------------------------------------- 1 | {% extends "index.html" %} 2 | {% block content%} 3 |

Playbook Details

4 |
5 | {% for key,item in playbookDetails.tasks %} 6 |
7 | 14 |
15 |
16 | {% for runKey,runItem in item.runs %} 17 | {% if runItem.changed %} 18 |

19 | Host: {{ runItem.hostName }}{% if runItem.delegated %} (delegated to: {{ runItem.delegatedHost }}){% endif %} 20 | {% if runItem.extraInfo %} 21 | View Module output 22 | {% endif %} 23 |

24 | {% if runItem.extraInfo %} 25 |
26 |
{{ runItem.extraInfo }}
27 |
28 | {% endif %} 29 | {% elseif runItem.failed %} 30 |

Host: {{ runItem.hostName }}
{{ runItem.failMsg }}

31 | {% elseif runItem.unreachable %} 32 |

Host: {{ runItem.hostName }}
{{ runItem.failMsg }}

33 | {% elseif runItem.skipped %} 34 |

Host: {{ runItem.hostName}}

35 | {% else %} 36 |

37 | Host: {{ runItem.hostName }}{% if runItem.delegated %} (delegated to: {{ runItem.delegatedHost }}){% endif %} 38 | {% if runItem.extraInfo %} 39 | View Module output 40 | {% endif %} 41 |

42 | {% if runItem.extraInfo %} 43 |
44 |
{{ runItem.extraInfo }}
45 |
46 | {% endif %} 47 | {% endif %} 48 | {% endfor %} 49 |
50 |
51 |
52 | {% endfor %} 53 |
54 | {% endblock %} 55 | -------------------------------------------------------------------------------- /helpers/dbprep/README.md: -------------------------------------------------------------------------------- 1 | # dbprep 2 | 3 | You can use this script to prepare your database with random data. It will only work on your database if no hosts are found in the ```hosts``` table! 4 | You need to have the database credentials in your config file (currently ```../../ansible-callbacks/ansible-logger.conf```). 5 | 6 | # Usage 7 | ``` 8 | ./dbprep.py 9 | ``` 10 | 11 | # Data Source 12 | The script uses several textfiles to generate random data (Hosts, Facts, Playbook Runs etc.). If you want to add new tasks: please seperate Task-Name and command with a semicolon. The same applies for facts and their values. 13 | -------------------------------------------------------------------------------- /helpers/dbprep/hostnames: -------------------------------------------------------------------------------- 1 | Homer 2 | March 3 | Bart 4 | Lisa 5 | Maggie 6 | Burns 7 | Smithers 8 | Lenny 9 | Carl 10 | Charlie 11 | Ned 12 | Maude 13 | Rod 14 | Todd 15 | Ralph 16 | Milhouse 17 | Nelson 18 | Melissa 19 | Sherri 20 | Terri 21 | Uter 22 | Skinner 23 | Chalmers 24 | Krabappel 25 | Hoover 26 | Willie 27 | Otto 28 | Krusty 29 | Tingeltangel 30 | Itchy 31 | Scratchy 32 | Brockman 33 | McClure 34 | Duffman 35 | Wiggum 36 | Eddie 37 | Lou 38 | Apu 39 | Moe 40 | Barney 41 | Quimby 42 | Lovejoy 43 | FatTony 44 | DiscoStu 45 | Cletus 46 | -------------------------------------------------------------------------------- /helpers/dbprep/hostpatterns: -------------------------------------------------------------------------------- 1 | webservers 2 | production 3 | database 4 | devmachines 5 | misc 6 | random 7 | storage 8 | router 9 | -------------------------------------------------------------------------------- /helpers/dbprep/playbooks: -------------------------------------------------------------------------------- 1 | master-deployment 2 | test-run 3 | jay-is-fixing-stuff 4 | nope 5 | fix-all-the-things 6 | -------------------------------------------------------------------------------- /helpers/dbprep/tasks: -------------------------------------------------------------------------------- 1 | Edit stuff here;command 2 | Start Service;service 3 | Deploy Config;template 4 | Deploy Tarball;copy 5 | Get Config File;fetch 6 | Install MySQL;apt 7 | Update Packet Cache;apt 8 | Configure HaProxy;haproxy 9 | Notify Big Boss;mail 10 | Create DB User;mysql_user 11 | --------------------------------------------------------------------------------