Initial commit with Symfony 2.1+Vendors
Signed-off-by: Gergely POLONKAI (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
34
vendor/twig/extensions/lib/Twig/Extensions/Extension/Debug.php
vendored
Normal file
34
vendor/twig/extensions/lib/Twig/Extensions/Extension/Debug.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Twig.
|
||||
*
|
||||
* (c) 2010 Fabien Potencier
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class Twig_Extensions_Extension_Debug extends Twig_Extension
|
||||
{
|
||||
/**
|
||||
* Returns the token parser instance to add to the existing list.
|
||||
*
|
||||
* @return array An array of Twig_TokenParser instances
|
||||
*/
|
||||
public function getTokenParsers()
|
||||
{
|
||||
return array(
|
||||
new Twig_Extensions_TokenParser_Debug(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the extension.
|
||||
*
|
||||
* @return string The extension name
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'debug';
|
||||
}
|
||||
}
|
44
vendor/twig/extensions/lib/Twig/Extensions/Extension/I18n.php
vendored
Normal file
44
vendor/twig/extensions/lib/Twig/Extensions/Extension/I18n.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Twig.
|
||||
*
|
||||
* (c) 2010 Fabien Potencier
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
class Twig_Extensions_Extension_I18n extends Twig_Extension
|
||||
{
|
||||
/**
|
||||
* Returns the token parser instances to add to the existing list.
|
||||
*
|
||||
* @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances
|
||||
*/
|
||||
public function getTokenParsers()
|
||||
{
|
||||
return array(new Twig_Extensions_TokenParser_Trans());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of filters to add to the existing list.
|
||||
*
|
||||
* @return array An array of filters
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
'trans' => new Twig_Filter_Function('gettext'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the extension.
|
||||
*
|
||||
* @return string The extension name
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'i18n';
|
||||
}
|
||||
}
|
70
vendor/twig/extensions/lib/Twig/Extensions/Extension/Intl.php
vendored
Normal file
70
vendor/twig/extensions/lib/Twig/Extensions/Extension/Intl.php
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Twig.
|
||||
*
|
||||
* (c) 2010 Fabien Potencier
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
class Twig_Extensions_Extension_Intl extends Twig_Extension
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
if (!class_exists('IntlDateFormatter')) {
|
||||
throw new RuntimeException('The intl extension is needed to use intl-based filters.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of filters to add to the existing list.
|
||||
*
|
||||
* @return array An array of filters
|
||||
*/
|
||||
public function getFilters()
|
||||
{
|
||||
return array(
|
||||
'localizeddate' => new Twig_Filter_Function('twig_localized_date_filter'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the extension.
|
||||
*
|
||||
* @return string The extension name
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'intl';
|
||||
}
|
||||
}
|
||||
|
||||
function twig_localized_date_filter($date, $dateFormat = 'medium', $timeFormat = 'medium', $locale = null)
|
||||
{
|
||||
$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]
|
||||
);
|
||||
|
||||
if (!$date instanceof DateTime) {
|
||||
if (ctype_digit((string) $date)) {
|
||||
$date = new DateTime('@'.$date);
|
||||
$date->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||
} else {
|
||||
$date = new DateTime($date);
|
||||
}
|
||||
}
|
||||
|
||||
return $formatter->format($date->getTimestamp());
|
||||
}
|
109
vendor/twig/extensions/lib/Twig/Extensions/Extension/Text.php
vendored
Normal file
109
vendor/twig/extensions/lib/Twig/Extensions/Extension/Text.php
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file is part of Twig.
|
||||
*
|
||||
* (c) 2009 Fabien Potencier
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*
|
||||
* @author Henrik Bjornskov <hb@peytz.dk>
|
||||
* @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 = '<br />')
|
||||
{
|
||||
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 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 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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user