diff --git a/inc/3rdparty/Twig/Extensions/Autoloader.php b/inc/3rdparty/Twig/Extensions/Autoloader.php deleted file mode 100644 index f23cced..0000000 --- a/inc/3rdparty/Twig/Extensions/Autoloader.php +++ /dev/null @@ -1,45 +0,0 @@ - - */ -class Twig_Extensions_Autoloader -{ - /** - * Registers Twig_Extensions_Autoloader as an SPL autoloader. - */ - static public function register() - { - spl_autoload_register(array(new self, 'autoload')); - } - - /** - * Handles autoloading of classes. - * - * @param string $class A class name. - * - * @return boolean Returns true if the class has been loaded - */ - static public function autoload($class) - { - if (0 !== strpos($class, 'Twig_Extensions')) { - return; - } - - if (file_exists($file = dirname(__FILE__).'/../../'.str_replace('_', '/', $class).'.php')) { - require $file; - } - } -} diff --git a/inc/3rdparty/Twig/Extensions/Extension/Debug.php b/inc/3rdparty/Twig/Extensions/Extension/Debug.php deleted file mode 100644 index 8974ce2..0000000 --- a/inc/3rdparty/Twig/Extensions/Extension/Debug.php +++ /dev/null @@ -1,34 +0,0 @@ - new Twig_Filter_Function('gettext'), - ); - } - - /** - * Returns the name of the extension. - * - * @return string The extension name - */ - public function getName() - { - return 'i18n'; - } -} diff --git a/inc/3rdparty/Twig/Extensions/Extension/Intl.php b/inc/3rdparty/Twig/Extensions/Extension/Intl.php deleted file mode 100644 index 40f7fc2..0000000 --- a/inc/3rdparty/Twig/Extensions/Extension/Intl.php +++ /dev/null @@ -1,66 +0,0 @@ - new Twig_Filter_Function('twig_localized_date_filter', array('needs_environment' => true)), - ); - } - - /** - * Returns the name of the extension. - * - * @return string The extension name - */ - public function getName() - { - return 'intl'; - } -} - -function twig_localized_date_filter(Twig_Environment $env, $date, $dateFormat = 'medium', $timeFormat = 'medium', $locale = null, $timezone = null, $format = null) -{ - $date = twig_date_converter($env, $date, $timezone); - - $formatValues = array( - 'none' => IntlDateFormatter::NONE, - 'short' => IntlDateFormatter::SHORT, - 'medium' => IntlDateFormatter::MEDIUM, - 'long' => IntlDateFormatter::LONG, - 'full' => IntlDateFormatter::FULL, - ); - - $formatter = IntlDateFormatter::create( - $locale !== null ? $locale : Locale::getDefault(), - $formatValues[$dateFormat], - $formatValues[$timeFormat], - $date->getTimezone()->getName(), - IntlDateFormatter::GREGORIAN, - $format - ); - - return $formatter->format($date->getTimestamp()); -} diff --git a/inc/3rdparty/Twig/Extensions/Extension/Text.php b/inc/3rdparty/Twig/Extensions/Extension/Text.php deleted file mode 100644 index 0a3dc35..0000000 --- a/inc/3rdparty/Twig/Extensions/Extension/Text.php +++ /dev/null @@ -1,109 +0,0 @@ - - * @package Twig - * @subpackage Twig-extensions - */ -class Twig_Extensions_Extension_Text extends Twig_Extension -{ - /** - * Returns a list of filters. - * - * @return array - */ - public function getFilters() - { - $filters = array( - 'truncate' => new Twig_Filter_Function('twig_truncate_filter', array('needs_environment' => true)), - 'wordwrap' => new Twig_Filter_Function('twig_wordwrap_filter', array('needs_environment' => true)), - ); - - if (version_compare(Twig_Environment::VERSION, '1.5.0-DEV', '<')) { - $filters['nl2br'] = new Twig_Filter_Function('twig_nl2br_filter', array('pre_escape' => 'html', 'is_safe' => array('html'))); - } - - return $filters; - } - - /** - * Name of this extension - * - * @return string - */ - public function getName() - { - return 'Text'; - } -} - -function twig_nl2br_filter($value, $sep = '
') -{ - return str_replace("\n", $sep."\n", $value); -} - -if (function_exists('mb_get_info')) { - function twig_truncate_filter(Twig_Environment $env, $value, $length = 30, $preserve = false, $separator = '...') - { - if (mb_strlen($value, $env->getCharset()) > $length) { - if ($preserve) { - if (false !== ($breakpoint = mb_strpos($value, ' ', $length, $env->getCharset()))) { - $length = $breakpoint; - } - } - - return rtrim(mb_substr($value, 0, $length, $env->getCharset())) . $separator; - } - - return $value; - } - - function twig_wordwrap_filter(Twig_Environment $env, $value, $length = 80, $separator = "\n", $preserve = false) - { - $sentences = array(); - - $previous = mb_regex_encoding(); - mb_regex_encoding($env->getCharset()); - - $pieces = mb_split($separator, $value); - mb_regex_encoding($previous); - - foreach ($pieces as $piece) { - while(!$preserve && mb_strlen($piece, $env->getCharset()) > $length) { - $sentences[] = mb_substr($piece, 0, $length, $env->getCharset()); - $piece = mb_substr($piece, $length, 2048, $env->getCharset()); - } - - $sentences[] = $piece; - } - - return implode($separator, $sentences); - } -} else { - function twig_truncate_filter(Twig_Environment $env, $value, $length = 30, $preserve = false, $separator = '...') - { - if (strlen($value) > $length) { - if ($preserve) { - if (false !== ($breakpoint = strpos($value, ' ', $length))) { - $length = $breakpoint; - } - } - - return rtrim(substr($value, 0, $length)) . $separator; - } - - return $value; - } - - function twig_wordwrap_filter(Twig_Environment $env, $value, $length = 80, $separator = "\n", $preserve = false) - { - return wordwrap($value, $length, $separator, !$preserve); - } -} \ No newline at end of file diff --git a/inc/3rdparty/Twig/Extensions/Grammar.php b/inc/3rdparty/Twig/Extensions/Grammar.php deleted file mode 100644 index 4d031b1..0000000 --- a/inc/3rdparty/Twig/Extensions/Grammar.php +++ /dev/null @@ -1,30 +0,0 @@ -name = $name; - } - - public function setParser(Twig_ParserInterface $parser) - { - $this->parser = $parser; - } - - public function getName() - { - return $this->name; - } -} diff --git a/inc/3rdparty/Twig/Extensions/Grammar/Arguments.php b/inc/3rdparty/Twig/Extensions/Grammar/Arguments.php deleted file mode 100644 index 158c05a..0000000 --- a/inc/3rdparty/Twig/Extensions/Grammar/Arguments.php +++ /dev/null @@ -1,22 +0,0 @@ -', $this->name); - } - - public function parse(Twig_Token $token) - { - return $this->parser->getExpressionParser()->parseArguments(); - } -} diff --git a/inc/3rdparty/Twig/Extensions/Grammar/Array.php b/inc/3rdparty/Twig/Extensions/Grammar/Array.php deleted file mode 100644 index 34aece0..0000000 --- a/inc/3rdparty/Twig/Extensions/Grammar/Array.php +++ /dev/null @@ -1,22 +0,0 @@ -', $this->name); - } - - public function parse(Twig_Token $token) - { - return $this->parser->getExpressionParser()->parseArrayExpression(); - } -} diff --git a/inc/3rdparty/Twig/Extensions/Grammar/Body.php b/inc/3rdparty/Twig/Extensions/Grammar/Body.php deleted file mode 100644 index 540cfc7..0000000 --- a/inc/3rdparty/Twig/Extensions/Grammar/Body.php +++ /dev/null @@ -1,39 +0,0 @@ -end = null === $end ? 'end'.$name : $end; - } - - public function __toString() - { - return sprintf('<%s:body>', $this->name); - } - - public function parse(Twig_Token $token) - { - $stream = $this->parser->getStream(); - $stream->expect(Twig_Token::BLOCK_END_TYPE); - - return $this->parser->subparse(array($this, 'decideBlockEnd'), true); - } - - public function decideBlockEnd(Twig_Token $token) - { - return $token->test($this->end); - } -} diff --git a/inc/3rdparty/Twig/Extensions/Grammar/Boolean.php b/inc/3rdparty/Twig/Extensions/Grammar/Boolean.php deleted file mode 100644 index c004809..0000000 --- a/inc/3rdparty/Twig/Extensions/Grammar/Boolean.php +++ /dev/null @@ -1,24 +0,0 @@ -', $this->name); - } - - public function parse(Twig_Token $token) - { - $this->parser->getStream()->expect(Twig_Token::NAME_TYPE, array('true', 'false')); - - return new Twig_Node_Expression_Constant('true' === $token->getValue() ? true : false, $token->getLine()); - } -} diff --git a/inc/3rdparty/Twig/Extensions/Grammar/Constant.php b/inc/3rdparty/Twig/Extensions/Grammar/Constant.php deleted file mode 100644 index 9df6045..0000000 --- a/inc/3rdparty/Twig/Extensions/Grammar/Constant.php +++ /dev/null @@ -1,37 +0,0 @@ -name = $name; - $this->type = null === $type ? Twig_Token::NAME_TYPE : $type; - } - - public function __toString() - { - return $this->name; - } - - public function parse(Twig_Token $token) - { - $this->parser->getStream()->expect($this->type, $this->name); - - return $this->name; - } - - public function getType() - { - return $this->type; - } -} diff --git a/inc/3rdparty/Twig/Extensions/Grammar/Expression.php b/inc/3rdparty/Twig/Extensions/Grammar/Expression.php deleted file mode 100644 index 4c33df0..0000000 --- a/inc/3rdparty/Twig/Extensions/Grammar/Expression.php +++ /dev/null @@ -1,22 +0,0 @@ -', $this->name); - } - - public function parse(Twig_Token $token) - { - return $this->parser->getExpressionParser()->parseExpression(); - } -} diff --git a/inc/3rdparty/Twig/Extensions/Grammar/Hash.php b/inc/3rdparty/Twig/Extensions/Grammar/Hash.php deleted file mode 100644 index 98b07d2..0000000 --- a/inc/3rdparty/Twig/Extensions/Grammar/Hash.php +++ /dev/null @@ -1,22 +0,0 @@ -', $this->name); - } - - public function parse(Twig_Token $token) - { - return $this->parser->getExpressionParser()->parseHashExpression(); - } -} diff --git a/inc/3rdparty/Twig/Extensions/Grammar/Number.php b/inc/3rdparty/Twig/Extensions/Grammar/Number.php deleted file mode 100644 index f0857d2..0000000 --- a/inc/3rdparty/Twig/Extensions/Grammar/Number.php +++ /dev/null @@ -1,24 +0,0 @@ -', $this->name); - } - - public function parse(Twig_Token $token) - { - $this->parser->getStream()->expect(Twig_Token::NUMBER_TYPE); - - return new Twig_Node_Expression_Constant($token->getValue(), $token->getLine()); - } -} diff --git a/inc/3rdparty/Twig/Extensions/Grammar/Optional.php b/inc/3rdparty/Twig/Extensions/Grammar/Optional.php deleted file mode 100644 index da42748..0000000 --- a/inc/3rdparty/Twig/Extensions/Grammar/Optional.php +++ /dev/null @@ -1,69 +0,0 @@ -grammar = array(); - foreach (func_get_args() as $grammar) { - $this->addGrammar($grammar); - } - } - - public function __toString() - { - $repr = array(); - foreach ($this->grammar as $grammar) { - $repr[] = (string) $grammar; - } - - return sprintf('[%s]', implode(' ', $repr)); - } - - public function addGrammar(Twig_Extensions_GrammarInterface $grammar) - { - $this->grammar[] = $grammar; - } - - public function parse(Twig_Token $token) - { - // test if we have the optional element before consuming it - if ($this->grammar[0] instanceof Twig_Extensions_Grammar_Constant) { - if (!$this->parser->getStream()->test($this->grammar[0]->getType(), $this->grammar[0]->getName())) { - return array(); - } - } elseif ($this->grammar[0] instanceof Twig_Extensions_Grammar_Name) { - if (!$this->parser->getStream()->test(Twig_Token::NAME_TYPE)) { - return array(); - } - } elseif ($this->parser->getStream()->test(Twig_Token::BLOCK_END_TYPE)) { - // if this is not a Constant or a Name, it must be the last element of the tag - - return array(); - } - - $elements = array(); - foreach ($this->grammar as $grammar) { - $grammar->setParser($this->parser); - - $element = $grammar->parse($token); - if (is_array($element)) { - $elements = array_merge($elements, $element); - } else { - $elements[$grammar->getName()] = $element; - } - } - - return $elements; - } -} diff --git a/inc/3rdparty/Twig/Extensions/Grammar/Switch.php b/inc/3rdparty/Twig/Extensions/Grammar/Switch.php deleted file mode 100644 index 4245f2c..0000000 --- a/inc/3rdparty/Twig/Extensions/Grammar/Switch.php +++ /dev/null @@ -1,24 +0,0 @@ -', $this->name); - } - - public function parse(Twig_Token $token) - { - $this->parser->getStream()->expect(Twig_Token::NAME_TYPE, $this->name); - - return new Twig_Node_Expression_Constant(true, $token->getLine()); - } -} diff --git a/inc/3rdparty/Twig/Extensions/Grammar/Tag.php b/inc/3rdparty/Twig/Extensions/Grammar/Tag.php deleted file mode 100644 index 727f261..0000000 --- a/inc/3rdparty/Twig/Extensions/Grammar/Tag.php +++ /dev/null @@ -1,56 +0,0 @@ -grammar = array(); - foreach (func_get_args() as $grammar) { - $this->addGrammar($grammar); - } - } - - public function __toString() - { - $repr = array(); - foreach ($this->grammar as $grammar) { - $repr[] = (string) $grammar; - } - - return implode(' ', $repr); - } - - public function addGrammar(Twig_Extensions_GrammarInterface $grammar) - { - $this->grammar[] = $grammar; - } - - public function parse(Twig_Token $token) - { - $elements = array(); - foreach ($this->grammar as $grammar) { - $grammar->setParser($this->parser); - - $element = $grammar->parse($token); - if (is_array($element)) { - $elements = array_merge($elements, $element); - } else { - $elements[$grammar->getName()] = $element; - } - } - - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); - - return $elements; - } -} diff --git a/inc/3rdparty/Twig/Extensions/GrammarInterface.php b/inc/3rdparty/Twig/Extensions/GrammarInterface.php deleted file mode 100644 index 22713bf..0000000 --- a/inc/3rdparty/Twig/Extensions/GrammarInterface.php +++ /dev/null @@ -1,18 +0,0 @@ - - * @version SVN: $Id$ - */ -class Twig_Extensions_Node_Debug extends Twig_Node -{ - public function __construct(Twig_Node_Expression $expr = null, $lineno, $tag = null) - { - parent::__construct(array('expr' => $expr), array(), $lineno, $tag); - } - - /** - * Compiles the node to PHP. - * - * @param Twig_Compiler A Twig_Compiler instance - */ - public function compile(Twig_Compiler $compiler) - { - $compiler->addDebugInfo($this); - - $compiler - ->write("if (\$this->env->isDebug()) {\n") - ->indent() - ; - - if (null === $this->getNode('expr')) { - // remove embedded templates (macros) from the context - $compiler - ->write("\$vars = array();\n") - ->write("foreach (\$context as \$key => \$value) {\n") - ->indent() - ->write("if (!\$value instanceof Twig_Template) {\n") - ->indent() - ->write("\$vars[\$key] = \$value;\n") - ->outdent() - ->write("}\n") - ->outdent() - ->write("}\n") - ->write("var_dump(\$vars);\n") - ; - } else { - $compiler - ->write("var_dump(") - ->subcompile($this->getNode('expr')) - ->raw(");\n") - ; - } - - $compiler - ->outdent() - ->write("}\n") - ; - } -} diff --git a/inc/3rdparty/Twig/Extensions/Node/Trans.php b/inc/3rdparty/Twig/Extensions/Node/Trans.php deleted file mode 100644 index d12564a..0000000 --- a/inc/3rdparty/Twig/Extensions/Node/Trans.php +++ /dev/null @@ -1,133 +0,0 @@ - - */ -class Twig_Extensions_Node_Trans extends Twig_Node -{ - public function __construct(Twig_NodeInterface $body, Twig_NodeInterface $plural = null, Twig_Node_Expression $count = null, $lineno, $tag = null) - { - parent::__construct(array('count' => $count, 'body' => $body, 'plural' => $plural), array(), $lineno, $tag); - } - - /** - * Compiles the node to PHP. - * - * @param Twig_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') ? 'gettext' : 'ngettext'; - - if ($vars) { - $compiler - ->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"); - } - } - - protected function compileString(Twig_NodeInterface $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); - } -} diff --git a/inc/3rdparty/Twig/Extensions/SimpleTokenParser.php b/inc/3rdparty/Twig/Extensions/SimpleTokenParser.php deleted file mode 100644 index 4954648..0000000 --- a/inc/3rdparty/Twig/Extensions/SimpleTokenParser.php +++ /dev/null @@ -1,132 +0,0 @@ -getGrammar(); - if (!is_object($grammar)) { - $grammar = self::parseGrammar($grammar); - } - - $grammar->setParser($this->parser); - $values = $grammar->parse($token); - - return $this->getNode($values, $token->getLine()); - } - - /** - * Gets the grammar as an object or as a string. - * - * @return string|Twig_Extensions_Grammar A Twig_Extensions_Grammar instance or a string - */ - abstract protected function getGrammar(); - - /** - * Gets the nodes based on the parsed values. - * - * @param array $values An array of values - * @param integer $line The parser line - */ - abstract protected function getNode(array $values, $line); - - protected function getAttribute($node, $attribute, $arguments = array(), $type = Twig_Node_Expression_GetAttr::TYPE_ANY, $line = -1) - { - return new Twig_Node_Expression_GetAttr( - $node instanceof Twig_NodeInterface ? $node : new Twig_Node_Expression_Name($node, $line), - $attribute instanceof Twig_NodeInterface ? $attribute : new Twig_Node_Expression_Constant($attribute, $line), - $arguments instanceof Twig_NodeInterface ? $arguments : new Twig_Node($arguments), - $type, - $line - ); - } - - protected function call($node, $attribute, $arguments = array(), $line = -1) - { - return $this->getAttribute($node, $attribute, $arguments, Twig_Node_Expression_GetAttr::TYPE_METHOD, $line); - } - - protected function markAsSafe(Twig_NodeInterface $node, $line = -1) - { - return new Twig_Node_Expression_Filter( - $node, - new Twig_Node_Expression_Constant('raw', $line), - new Twig_Node(), - $line - ); - } - - protected function output(Twig_NodeInterface $node, $line = -1) - { - return new Twig_Node_Print($node, $line); - } - - protected function getNodeValues(array $values) - { - $nodes = array(); - foreach ($values as $value) { - if ($value instanceof Twig_NodeInterface) { - $nodes[] = $value; - } - } - - return $nodes; - } - - static public function parseGrammar($str, $main = true) - { - static $cursor; - - if (true === $main) { - $cursor = 0; - $grammar = new Twig_Extensions_Grammar_Tag(); - } else { - $grammar = new Twig_Extensions_Grammar_Optional(); - } - - while ($cursor < strlen($str)) { - if (preg_match('/\s+/A', $str, $match, null, $cursor)) { - $cursor += strlen($match[0]); - } elseif (preg_match('/<(\w+)(?:\:(\w+))?>/A', $str, $match, null, $cursor)) { - $class = sprintf('Twig_Extensions_Grammar_%s', ucfirst(isset($match[2]) ? $match[2] : 'Expression')); - if (!class_exists($class)) { - throw new Twig_Error_Runtime(sprintf('Unable to understand "%s" in grammar (%s class does not exist)', $match[0], $class)); - } - $grammar->addGrammar(new $class($match[1])); - $cursor += strlen($match[0]); - } elseif (preg_match('/\w+/A', $str, $match, null, $cursor)) { - $grammar->addGrammar(new Twig_Extensions_Grammar_Constant($match[0])); - $cursor += strlen($match[0]); - } elseif (preg_match('/,/A', $str, $match, null, $cursor)) { - $grammar->addGrammar(new Twig_Extensions_Grammar_Constant($match[0], Twig_Token::PUNCTUATION_TYPE)); - $cursor += strlen($match[0]); - } elseif (preg_match('/\[/A', $str, $match, null, $cursor)) { - $cursor += strlen($match[0]); - $grammar->addGrammar(self::parseGrammar($str, false)); - } elseif (true !== $main && preg_match('/\]/A', $str, $match, null, $cursor)) { - $cursor += strlen($match[0]); - - return $grammar; - } else { - throw new Twig_Error_Runtime(sprintf('Unable to parse grammar "%s" near "...%s..."', $str, substr($str, $cursor, 10))); - } - } - - return $grammar; - } -} diff --git a/inc/3rdparty/Twig/Extensions/TokenParser/Debug.php b/inc/3rdparty/Twig/Extensions/TokenParser/Debug.php deleted file mode 100644 index 4a7dfcc..0000000 --- a/inc/3rdparty/Twig/Extensions/TokenParser/Debug.php +++ /dev/null @@ -1,42 +0,0 @@ -getLine(); - - $expr = null; - if (!$this->parser->getStream()->test(Twig_Token::BLOCK_END_TYPE)) { - $expr = $this->parser->getExpressionParser()->parseExpression(); - } - $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); - - return new Twig_Extensions_Node_Debug($expr, $lineno, $this->getTag()); - } - - /** - * Gets the tag name associated with this token parser. - * - * @param string The tag name - */ - public function getTag() - { - return 'debug'; - } -} diff --git a/inc/3rdparty/Twig/Extensions/TokenParser/Trans.php b/inc/3rdparty/Twig/Extensions/TokenParser/Trans.php deleted file mode 100644 index 5e2dc46..0000000 --- a/inc/3rdparty/Twig/Extensions/TokenParser/Trans.php +++ /dev/null @@ -1,80 +0,0 @@ -getLine(); - $stream = $this->parser->getStream(); - $count = null; - $plural = 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')); - if ('plural' === $stream->next()->getValue()) { - $count = $this->parser->getExpressionParser()->parseExpression(); - $stream->expect(Twig_Token::BLOCK_END_TYPE); - $plural = $this->parser->subparse(array($this, 'decideForEnd'), true); - } - } - - $stream->expect(Twig_Token::BLOCK_END_TYPE); - - $this->checkTransString($body, $lineno); - - return new Twig_Extensions_Node_Trans($body, $plural, $count, $lineno, $this->getTag()); - } - - public function decideForFork(Twig_Token $token) - { - return $token->test(array('plural', '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 - */ - public function getTag() - { - return 'trans'; - } - - protected function checkTransString(Twig_NodeInterface $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); - } - } -} diff --git a/inc/3rdparty/Twig/Gettext/Extractor.php b/inc/3rdparty/Twig/Gettext/Extractor.php deleted file mode 100644 index e7fa1af..0000000 --- a/inc/3rdparty/Twig/Gettext/Extractor.php +++ /dev/null @@ -1,95 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Twig\Gettext; - -use Symfony\Component\Filesystem\Filesystem; - -/** - * Extracts translations from twig templates. - * - * @author Саша Стаменковић - */ -class Extractor -{ - /** - * @var \Twig_Environment - */ - protected $environment; - - /** - * Template cached file names. - * - * @var string[] - */ - protected $templates; - - /** - * Gettext parameters. - * - * @var string[] - */ - protected $parameters; - - public function __construct(\Twig_Environment $environment) - { - $this->environment = $environment; - $this->reset(); - } - - protected function reset() - { - $this->templates = array(); - $this->parameters = array(); - } - - public function addTemplate($path) - { - $this->environment->loadTemplate($path); - $this->templates[] = $this->environment->getCacheFilename($path); - } - - public function addGettextParameter($parameter) - { - $this->parameters[] = $parameter; - } - - public function setGettextParameters(array $parameters) - { - $this->parameters = $parameters; - } - - public function extract() - { - $command = 'xgettext'; - $command .= ' '.join(' ', $this->parameters); - $command .= ' '.join(' ', $this->templates); - - $error = 0; - $output = system($command, $error); - if (0 !== $error) { - throw new \RuntimeException(sprintf( - 'Gettext command "%s" failed with error code %s and output: %s', - $command, - $error, - $output - )); - } - - $this->reset(); - } - - public function __destruct() - { - $filesystem = new Filesystem(); - $filesystem->remove($this->environment->getCache()); - } -} diff --git a/inc/3rdparty/Twig/Gettext/Loader/Filesystem.php b/inc/3rdparty/Twig/Gettext/Loader/Filesystem.php deleted file mode 100644 index b011b03..0000000 --- a/inc/3rdparty/Twig/Gettext/Loader/Filesystem.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Twig\Gettext\Loader; - -/** - * Loads template from the filesystem. - * - * @author Саша Стаменковић - */ -class Filesystem extends \Twig_Loader_Filesystem -{ - /** - * Hacked find template to allow loading templates by absolute path. - * - * @param string $name template name or absolute path - */ - protected function findTemplate($name) - { - // normalize name - $name = preg_replace('#/{2,}#', '/', strtr($name, '\\', '/')); - - if (isset($this->cache[$name])) { - return $this->cache[$name]; - } - - $this->validateName($name); - - $namespace = '__main__'; - if (isset($name[0]) && '@' == $name[0]) { - if (false === $pos = strpos($name, '/')) { - throw new \InvalidArgumentException(sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name)); - } - - $namespace = substr($name, 1, $pos - 1); - - $name = substr($name, $pos + 1); - } - - if (!isset($this->paths[$namespace])) { - throw new \Twig_Error_Loader(sprintf('There are no registered paths for namespace "%s".', $namespace)); - } - - if (is_file($name)) { - return $this->cache[$name] = $name; - } - - return __DIR__.'/../Test/Fixtures/twig/empty.twig'; - } -} diff --git a/inc/3rdparty/Twig/Gettext/Routing/Generator/UrlGenerator.php b/inc/3rdparty/Twig/Gettext/Routing/Generator/UrlGenerator.php deleted file mode 100644 index 9e3431b..0000000 --- a/inc/3rdparty/Twig/Gettext/Routing/Generator/UrlGenerator.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Twig\Gettext\Routing\Generator; - -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; -use Symfony\Component\Routing\RequestContext; - -/** - * Dummy url generator. - * - * @author Саша Стаменковић - */ -class UrlGenerator implements UrlGeneratorInterface -{ - protected $context; - - public function generate($name, $parameters = array(), $absolute = false) - { - } - - public function getContext() - { - return $this->context; - } - - public function setContext(RequestContext $context) - { - $this->context = $context; - } -} diff --git a/inc/3rdparty/Twig/Gettext/Test/ExtractorTest.php b/inc/3rdparty/Twig/Gettext/Test/ExtractorTest.php deleted file mode 100644 index d467835..0000000 --- a/inc/3rdparty/Twig/Gettext/Test/ExtractorTest.php +++ /dev/null @@ -1,123 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Twig\Gettext\Test; - -use Twig\Gettext\Extractor; -use Twig\Gettext\Loader\Filesystem; -use Symfony\Component\Translation\Loader\PoFileLoader; - -/** - * @author Саша Стаменковић - */ -class ExtractorTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Twig_Environment - */ - protected $twig; - - /** - * @var PoFileLoader - */ - protected $loader; - - protected function setUp() - { - $this->twig = new \Twig_Environment(new Filesystem('/'), array( - 'cache' => '/tmp/cache/'.uniqid(), - 'auto_reload' => true - )); - $this->twig->addExtension(new \Twig_Extensions_Extension_I18n()); - - $this->loader = new PoFileLoader(); - } - - /** - * @dataProvider testExtractDataProvider - */ - public function testExtract(array $templates, array $parameters, array $messages) - { - $extractor = new Extractor($this->twig); - - foreach ($templates as $template) { - $extractor->addTemplate($template); - } - foreach ($parameters as $parameter) { - $extractor->addGettextParameter($parameter); - } - - $extractor->extract(); - - $catalog = $this->loader->load($this->getPotFile(), null); - - foreach ($messages as $message) { - $this->assertTrue( - $catalog->has($message), - sprintf('Message "%s" not found in catalog.', $message) - ); - } - } - - public function testExtractDataProvider() - { - return array( - array( - array( - __DIR__.'/Fixtures/twig/singular.twig', - __DIR__.'/Fixtures/twig/plural.twig', - ), - $this->getGettextParameters(), - array( - 'Hello %name%!', - 'Hello World!', - 'Hey %name%, I have one apple.', - 'Hey %name%, I have %count% apples.', - ), - ), - ); - } - - public function testExtractNoTranslations() - { - $extractor = new Extractor($this->twig); - - $extractor->addTemplate(__DIR__.'/Fixtures/twig/empty.twig'); - $extractor->setGettextParameters($this->getGettextParameters()); - - $extractor->extract(); - - $catalog = $this->loader->load($this->getPotFile(), null); - - $this->assertEmpty($catalog->all('messages')); - } - - private function getPotFile() - { - return __DIR__.'/Fixtures/messages.pot'; - } - - private function getGettextParameters() - { - return array( - '--force-po', - '-o', - $this->getPotFile(), - ); - } - - protected function tearDown() - { - if (file_exists($this->getPotFile())) { - unlink($this->getPotFile()); - } - } -} diff --git a/inc/3rdparty/Twig/Gettext/Test/Fixtures/twig/empty.twig b/inc/3rdparty/Twig/Gettext/Test/Fixtures/twig/empty.twig deleted file mode 100644 index 05f0d26..0000000 --- a/inc/3rdparty/Twig/Gettext/Test/Fixtures/twig/empty.twig +++ /dev/null @@ -1 +0,0 @@ -Nothing to translate here. diff --git a/inc/3rdparty/Twig/Gettext/Test/Fixtures/twig/plural.twig b/inc/3rdparty/Twig/Gettext/Test/Fixtures/twig/plural.twig deleted file mode 100644 index f9754ff..0000000 --- a/inc/3rdparty/Twig/Gettext/Test/Fixtures/twig/plural.twig +++ /dev/null @@ -1,5 +0,0 @@ -{% trans %} - Hey {{ name }}, I have one apple. -{% plural apple_count %} - Hey {{ name }}, I have {{ count }} apples. -{% endtrans %} diff --git a/inc/3rdparty/Twig/Gettext/Test/Fixtures/twig/singular.twig b/inc/3rdparty/Twig/Gettext/Test/Fixtures/twig/singular.twig deleted file mode 100644 index d757cf9..0000000 --- a/inc/3rdparty/Twig/Gettext/Test/Fixtures/twig/singular.twig +++ /dev/null @@ -1,9 +0,0 @@ -{% trans "Hello World!" %} - -{% trans %} - Hello World! -{% endtrans %} - -{% trans %} - Hello {{ name }}! -{% endtrans %} diff --git a/inc/config.php b/inc/config.php index b78147a..495dbb8 100644 --- a/inc/config.php +++ b/inc/config.php @@ -24,15 +24,14 @@ define ('LANG', 'fr_FR.UTF8'); $storage_type = 'sqlite'; # sqlite, file # /!\ Be careful if you change the lines below /!\ - require_once 'poche/pocheTools.class.php'; require_once 'poche/pocheCore.php'; require_once '3rdparty/Readability.php'; require_once '3rdparty/Encoding.php'; require_once '3rdparty/Session.class.php'; -require_once '3rdparty/Twig/Autoloader.php'; require_once 'store/store.class.php'; require_once 'store/' . $storage_type . '.class.php'; +require_once './vendor/autoload.php'; if (DOWNLOAD_PICTURES) { require_once 'poche/pochePicture.php'; @@ -45,7 +44,7 @@ bindtextdomain(LANG, LOCALE); textdomain(LANG); # template engine -Twig_Autoloader::register(); +// Twig_Autoloader::register(); $loader = new Twig_Loader_Filesystem(TPL); $twig = new Twig_Environment($loader, array( 'cache' => CACHE, diff --git a/index.php b/index.php index 81bd017..dc06442 100644 --- a/index.php +++ b/index.php @@ -10,70 +10,74 @@ include dirname(__FILE__).'/inc/config.php'; -$errors = array(); +$notices = array(); # XSRF protection with token -if (!empty($_POST)) { - if (!Session::isToken($_POST['token'])) { - #die(_('Wrong token')); - // TODO CORRIGER ICI !!! - } - unset($_SESSION['tokens']); -} +// if (!empty($_POST)) { +// if (!Session::isToken($_POST['token'])) { +// die(_('Wrong token')); +// // TODO remettre le test +// } +// unset($_SESSION['tokens']); +// } $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']; if (isset($_GET['login'])) { + # hello you if (!empty($_POST['login']) && !empty($_POST['password'])) { if (Session::login($_SESSION['login'], $_SESSION['pass'], $_POST['login'], encode_string($_POST['password'] . $_POST['login']))) { pocheTools::logm('login successful'); - $errors[]['value'] = _('login successful'); + $pocheTools[]['value'] = _('login successful'); if (!empty($_POST['longlastingsession'])) { $_SESSION['longlastingsession'] = 31536000; $_SESSION['expires_on'] = time() + $_SESSION['longlastingsession']; session_set_cookie_params($_SESSION['longlastingsession']); } else { - session_set_cookie_params(0); // when browser closes + session_set_cookie_params(0); } session_regenerate_id(true); pocheTools::redirect($referer); } pocheTools::logm('login failed'); - $errors[]['value'] = _('Login failed !'); + $notices[]['value'] = _('Login failed !'); + pocheTools::redirect(); } else { pocheTools::logm('login failed'); + pocheTools::redirect(); } } elseif (isset($_GET['logout'])) { + # see you soon ! pocheTools::logm('logout'); Session::logout(); pocheTools::redirect(); } elseif (isset($_GET['config'])) { + # Update password if (isset($_POST['password']) && isset($_POST['password_repeat'])) { if ($_POST['password'] == $_POST['password_repeat'] && $_POST['password'] != "") { - pocheTools::logm('password updated'); if (!MODE_DEMO) { + pocheTools::logm('password updated'); $store->updatePassword(encode_string($_POST['password'] . $_SESSION['login'])); - #your password has been updated + Session::logout(); + pocheTools::redirect(); } else { - #in demo mode, you can\'t update password + pocheTools::logm('in demo mode, you can\'t do this'); } } - #else - #your password can\'t be empty and you have to repeat it in the second field } } -# Traitement des paramètres et déclenchement des actions -$view = (isset ($_REQUEST['view'])) ? htmlentities($_REQUEST['view']) : 'home'; -$full_head = (isset ($_REQUEST['full_head'])) ? htmlentities($_REQUEST['full_head']) : 'yes'; -$action = (isset ($_REQUEST['action'])) ? htmlentities($_REQUEST['action']) : ''; -$_SESSION['sort'] = (isset ($_REQUEST['sort'])) ? htmlentities($_REQUEST['sort']) : 'id'; -$id = (isset ($_REQUEST['id'])) ? htmlspecialchars($_REQUEST['id']) : ''; -$url = (isset ($_GET['url'])) ? $_GET['url'] : ''; +# Aaaaaaand action ! +$view = (isset ($_REQUEST['view'])) ? htmlentities($_REQUEST['view']) : 'home'; +$full_head = (isset ($_REQUEST['full_head'])) ? htmlentities($_REQUEST['full_head']) : 'yes'; +$action = (isset ($_REQUEST['action'])) ? htmlentities($_REQUEST['action']) : ''; +$_SESSION['sort'] = (isset ($_REQUEST['sort'])) ? htmlentities($_REQUEST['sort']) : 'id'; +$id = (isset ($_REQUEST['id'])) ? htmlspecialchars($_REQUEST['id']) : ''; +$url = (isset ($_GET['url'])) ? $_GET['url'] : ''; $tpl_vars = array( 'referer' => $referer, @@ -82,7 +86,7 @@ $tpl_vars = array( 'demo' => MODE_DEMO, 'title' => _('poche, a read it later open source system'), 'token' => Session::getToken(), - 'errors' => $errors, + 'notices' => $notices, ); if (Session::isLogged()) { diff --git a/tpl/_head.twig b/tpl/_head.twig index 2d640cb..ad96e9d 100644 --- a/tpl/_head.twig +++ b/tpl/_head.twig @@ -1,10 +1,10 @@ - - - - - - + + + + + + - + - \ No newline at end of file + \ No newline at end of file diff --git a/tpl/_top.twig b/tpl/_top.twig index 8e3ea7e..daee44f 100644 --- a/tpl/_top.twig +++ b/tpl/_top.twig @@ -1,3 +1,3 @@
-

logo pochepoche

+

logo pochepoche

\ No newline at end of file diff --git a/tpl/config.twig b/tpl/config.twig index 10c481d..be2c045 100644 --- a/tpl/config.twig +++ b/tpl/config.twig @@ -12,30 +12,30 @@ {% endblock %} {% block content %}
-

Bookmarklet

-

Thanks to the bookmarklet, you will be able to easily add a link to your poche. If you don't know how use a bookmarklet, have a look here.

-

Drag & drop this link to your bookmarks bar and have fun with poche.

-

poche it !

+

{% trans "Bookmarklet" %}

+

{% trans "Thanks to the bookmarklet, you will be able to easily add a link to your poche." %} {% trans "Have a look to this documentation:" %} http://inthepoche.com/?pages/Documentation.

+

{% trans "Drag & drop this link to your bookmarks bar and have fun with poche." %}

+

{% trans "poche it!" %}

-

Password

+

{% trans "Change your password" %}

- - + +
- - + +
- +
- - + +
-

Export

-

Click here to export your poche datas.

+

{% trans "Export your poche datas" %}

+

{% trans "Click here" %} {% trans "to export your poche datas." %}

{% endblock %} \ No newline at end of file diff --git a/css/knacss.css b/tpl/css/knacss.css similarity index 100% rename from css/knacss.css rename to tpl/css/knacss.css diff --git a/css/style-dark.css b/tpl/css/style-dark.css similarity index 100% rename from css/style-dark.css rename to tpl/css/style-dark.css diff --git a/css/style-light.css b/tpl/css/style-light.css similarity index 100% rename from css/style-light.css rename to tpl/css/style-light.css diff --git a/css/style.css b/tpl/css/style.css similarity index 100% rename from css/style.css rename to tpl/css/style.css diff --git a/tpl/entries.html b/tpl/entries.html deleted file mode 100644 index 83e58c7..0000000 --- a/tpl/entries.html +++ /dev/null @@ -1,21 +0,0 @@ -
- {loop="entries"} -
- -

- {$value.title} -

-
-
    -
  • -
  • -
  • -
  • -
  • -
-
-
{$value.url}
-
-
- {/loop} -
\ No newline at end of file diff --git a/tpl/home.twig b/tpl/home.twig index c79d427..5752b2c 100644 --- a/tpl/home.twig +++ b/tpl/home.twig @@ -11,10 +11,19 @@ {% endblock %} {% block precontent %}
    -
  • {% trans "by date" %}
  • -
  • {% trans "by title" %}
  • +
  • {% trans "by date" %}
  • +
  • {% trans "by title" %}
{% endblock %} +{% block notices %} +
+
    + {% for notice in notices %} +
  • {{ notice.value|e }}
  • + {% endfor %} +
+
+{% endblock %} {% block content %}
{% for entry in entries %} @@ -28,7 +37,7 @@
  • -
  • +
  • @@ -40,9 +49,9 @@ {% endblock %} {% block js %} - - - + + +