芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/public_html/avenida/views/Twig.zip
PK qY˚ TransExtension.phpnu [ getLine(); $stream = $this->parser->getStream(); $count = null; $plural = null; $notes = null; if (!$stream->test(\Twig_Token::BLOCK_END_TYPE)) { $body = $this->parser->getExpressionParser()->parseExpression(); } else { $stream->expect(\Twig_Token::BLOCK_END_TYPE); $body = $this->parser->subparse(array($this, 'decideForFork')); $next = $stream->next()->getValue(); if ('plural' === $next) { $count = $this->parser->getExpressionParser()->parseExpression(); $stream->expect(\Twig_Token::BLOCK_END_TYPE); $plural = $this->parser->subparse(array($this, 'decideForFork')); if ('notes' === $stream->next()->getValue()) { $stream->expect(\Twig_Token::BLOCK_END_TYPE); $notes = $this->parser->subparse(array($this, 'decideForEnd'), true); } } elseif ('notes' === $next) { $stream->expect(\Twig_Token::BLOCK_END_TYPE); $notes = $this->parser->subparse(array($this, 'decideForEnd'), true); } } $stream->expect(\Twig_Token::BLOCK_END_TYPE); $this->checkTransString($body, $lineno); return new TransNode($body, $plural, $count, $notes, $lineno, $this->getTag()); } public function decideForFork(\Twig_Token $token) { return $token->test(array('plural', 'notes', 'endtrans')); } public function decideForEnd(\Twig_Token $token) { return $token->test('endtrans'); } /** * Gets the tag name associated with this token parser. * * @param string The tag name * * @return string */ public function getTag() { return 'trans'; } protected function checkTransString(\Twig_Node $body, $lineno) { foreach ($body as $i => $node) { if ( $node instanceof \Twig_Node_Text || ($node instanceof \Twig_Node_Print && $node->getNode('expr') instanceof \Twig_Node_Expression_Name) ) { continue; } throw new \Twig_Error_Syntax(sprintf('The text to be translated with "trans" can only contain references to simple variables'), $lineno); } } }PK qYwv TransNode.phpnu [ $count, 'body' => $body, 'plural' => $plural, 'notes' => $notes), array(), $lineno, $tag); } /** * Compiles the node to PHP. * * @param \Twig_Compiler $compiler A Twig_Compiler instance */ public function compile(\Twig_Compiler $compiler) { $compiler->addDebugInfo($this); list($msg, $vars) = $this->compileString($this->getNode('body')); if (null !== $this->getNode('plural')) { list($msg1, $vars1) = $this->compileString($this->getNode('plural')); $vars = array_merge($vars, $vars1); } $function = null === $this->getNode('plural') ? '__' : 'n__'; if (null !== $notes = $this->getNode('notes')) { $message = trim($notes->getAttribute('data')); // line breaks are not allowed cause we want a single line comment $message = str_replace(array("\n", "\r"), ' ', $message); $compiler->write("// notes: {$message}\n"); } if ($vars) { // Add a hint for xgettext so that poedit goes not treat the variable substitution as PHP format // https://github.com/xibosignage/xibo/issues/1284 $compiler ->write('/* xgettext:no-php-format */') ->write('echo strtr(' . $function . '(') ->subcompile($msg); if (null !== $this->getNode('plural')) { $compiler ->raw(', ') ->subcompile($msg1) ->raw(', abs(') ->subcompile($this->getNode('count')) ->raw(')'); } $compiler->raw('), array('); foreach ($vars as $var) { if ('count' === $var->getAttribute('name')) { $compiler ->string('%count%') ->raw(' => abs(') ->subcompile($this->getNode('count')) ->raw('), '); } else { $compiler ->string('%' . $var->getAttribute('name') . '%') ->raw(' => ') ->subcompile($var) ->raw(', '); } } $compiler->raw("));\n"); } else { $compiler ->write('echo ' . $function . '(') ->subcompile($msg); if (null !== $this->getNode('plural')) { $compiler ->raw(', ') ->subcompile($msg1) ->raw(', abs(') ->subcompile($this->getNode('count')) ->raw(')'); } $compiler->raw(");\n"); } } /** * @param \Twig_Node $body A Twig_Node instance * * @return array */ protected function compileString(\Twig_Node $body) { if ($body instanceof \Twig_Node_Expression_Name || $body instanceof \Twig_Node_Expression_Constant || $body instanceof \Twig_Node_Expression_TempName) { return array($body, array()); } $vars = array(); if (count($body)) { $msg = ''; foreach ($body as $node) { if (get_class($node) === 'Twig_Node' && $node->getNode(0) instanceof \Twig_Node_SetTemp) { $node = $node->getNode(1); } if ($node instanceof \Twig_Node_Print) { $n = $node->getNode('expr'); while ($n instanceof \Twig_Node_Expression_Filter) { $n = $n->getNode('node'); } $msg .= sprintf('%%%s%%', $n->getAttribute('name')); $vars[] = new \Twig_Node_Expression_Name($n->getAttribute('name'), $n->getLine()); } else { $msg .= $node->getAttribute('data'); } } } else { $msg = $body->getAttribute('data'); } return array(new \Twig_Node(array(new \Twig_Node_Expression_Constant(trim($msg), $body->getLine()))), $vars); } } PK qY[ce( ( DateFormatTwigExtension.phpnu [ new \Twig_Filter_Method($this, 'dateFormat') ); } /** * Formats a date * * @param string $date in seconds * * @return string formated as HH:mm:ss */ public function dateFormat( $date ) { return gmdate('H:i:s', $date); } /** * Returns the name of the extension. * * @return string The extension name */ public function getName() { return 'datehms'; } } PK qY! W UrlDecodeTwigExtension.phpnu [ new \Twig_Filter_Method($this, 'urlDecode') ); } /** * URL Decode a string * * @param string $url * * @return string The decoded URL */ public function urlDecode( $url ) { return urldecode( $url ); } /** * Returns the name of the extension. * * @return string The extension name */ public function getName() { return 'url_decode'; } }PK qY7j