Merge remote-tracking branch 'origin/develop' into develop

# Conflicts:
#	composer.lock
This commit is contained in:
Matias Griese
2016-03-10 20:34:20 +02:00
11 changed files with 1574 additions and 37 deletions

1534
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,6 @@
namespace Grav\Common\Backup;
use Grav\Common\Grav;
use Grav\Common\Filesystem\Folder;
use Grav\Common\Inflector;
/**

View File

@@ -2,7 +2,6 @@
namespace Grav\Common\Data;
use Grav\Common\Grav;
use Grav\Common\GravTrait;
use Symfony\Component\Yaml\Exception\ParseException;
use Symfony\Component\Yaml\Parser;

View File

@@ -27,4 +27,4 @@ class ValidationException extends \RuntimeException
{
return $this->messages;
}
}
}

View File

@@ -1,7 +1,6 @@
<?php
namespace Grav\Common\GPM;
use Grav\Common\Grav;
use Grav\Common\Iterator;
abstract class AbstractCollection extends Iterator

View File

@@ -1,7 +1,6 @@
<?php
namespace Grav\Common\GPM\Common;
use Grav\Common\Grav;
use Grav\Common\Iterator;
abstract class AbstractPackageCollection extends Iterator

View File

@@ -2,8 +2,6 @@
namespace Grav\Common\Markdown;
use Grav\Common\Grav;
use Grav\Common\Page\Page;
use Grav\Common\Page\Pages;
use Grav\Common\Uri;
use RocketTheme\Toolbox\Event\Event;

View File

@@ -2,7 +2,6 @@
namespace Grav\Common\Page;
use Grav\Common\Getters;
use Grav\Common\Grav;
use Grav\Common\Page\Medium\Medium;
use Grav\Common\Page\Medium\MediumFactory;

View File

@@ -11,7 +11,6 @@ use Grav\Common\Language\Language;
use Grav\Common\Markdown\Parsedown;
use Grav\Common\Markdown\ParsedownExtra;
use Grav\Common\Taxonomy;
use Grav\Common\Twig;
use Grav\Common\Uri;
use Grav\Common\Utils;
use RocketTheme\Toolbox\Event\Event;

View File

@@ -25,9 +25,9 @@ class TwigExtension extends \Twig_Extension
*/
public function __construct()
{
$this->grav = Grav::instance();
$this->grav = Grav::instance();
$this->debugger = isset($this->grav['debugger']) ? $this->grav['debugger'] : null;
$this->config = $this->grav['config'];
$this->config = $this->grav['config'];
}
/**
@@ -85,6 +85,7 @@ class TwigExtension extends \Twig_Extension
new \Twig_SimpleFilter('ta', [$this, 'translateArray']),
new \Twig_SimpleFilter('truncate', ['\Grav\Common\Utils', 'truncate']),
new \Twig_SimpleFilter('truncate_html', ['\Grav\Common\Utils', 'truncateHTML']),
new \Twig_SimpleFilter('json_decode', [$this, 'jsonDecodeFilter']),
];
}
@@ -111,8 +112,8 @@ class TwigExtension extends \Twig_Extension
new \Twig_simpleFunction('t', [$this, 'translate']),
new \Twig_simpleFunction('ta', [$this, 'translateArray']),
new \Twig_SimpleFunction('url', [$this, 'urlFunc']),
new \Twig_SimpleFunction('json_decode', [$this, 'jsonDecodeFilter']),
new \Twig_SimpleFunction('get_cookie', [$this, 'getCookie']),
];
}
@@ -139,7 +140,7 @@ class TwigExtension extends \Twig_Extension
*/
public function safeEmailFilter($str)
{
$email = '';
$email = '';
$str_len = strlen($str);
for ($i = 0; $i < $str_len; $i++) {
$email .= "&#" . ord($str[$i]) . ";";
@@ -374,11 +375,11 @@ class TwigExtension extends \Twig_Extension
// is it future date or past date
if ($now > $unix_date) {
$difference = $now - $unix_date;
$tense = $this->grav['language']->translate('NICETIME.AGO', null, true);
$tense = $this->grav['language']->translate('NICETIME.AGO', null, true);
} else {
$difference = $unix_date - $now;
$tense = $this->grav['language']->translate('NICETIME.FROM_NOW', null, true);
$tense = $this->grav['language']->translate('NICETIME.FROM_NOW', null, true);
}
for ($j = 0; $difference >= $lengths[$j] && $j < count($lengths) - 1; $j++) {
@@ -411,7 +412,7 @@ class TwigExtension extends \Twig_Extension
*/
public function absoluteUrlFilter($string)
{
$url = $this->grav['uri']->base();
$url = $this->grav['uri']->base();
$string = preg_replace('/((?:href|src) *= *[\'"](?!(http|ftp)))/i', "$1$url", $string);
return $string;
@@ -425,7 +426,7 @@ class TwigExtension extends \Twig_Extension
*/
public function markdownFilter($string)
{
$page = $this->grav['page'];
$page = $this->grav['page'];
$defaults = $this->config->get('system.pages.markdown');
// Initialize the preferred variant of Parsedown
@@ -674,16 +675,16 @@ class TwigExtension extends \Twig_Extension
* Workaround for twig associative array initialization
* Returns a key => val array
*
* @param string $key key of item
* @param string $val value of item
* @param string $current_array optional array to add to
* @param string $key key of item
* @param string $val value of item
* @param string $current_array optional array to add to
*
* @return array
*/
public function arrayKeyValueFunc($key, $val, $current_array = null)
{
if (empty($current_array)) {
return array( $key => $val );
return array($key => $val);
} else {
$current_array[$key] = $val;
return $current_array;
@@ -757,14 +758,40 @@ class TwigExtension extends \Twig_Extension
return $string;
}
/**
* Decodes string from JSON.
*
* @param string $str
* @param bool $assoc
* @param int $depth
* @param int $options
* @return array
*/
public function jsonDecodeFilter($str, $assoc = false, $depth = 512, $options = 0)
{
return json_decode(html_entity_decode($str), $assoc, $depth, $options);
}
/**
* Used to retrieve a cookie value
*
* @param string $key The cookie name to retrieve
*
* @return mixed
*/
public function getCookie($key)
{
return filter_input(INPUT_COOKIE, $key, FILTER_SANITIZE_STRING);
}
/**
* Twig wrapper for PHP's preg_replace method
*
* @param mixed $subject the content to perform the replacement on
* @param mixed $pattern the regex pattern to use for matches
* @param mixed $replace the replacement value either as a string or an array of replacements
* @param int $limit the maximum possible replacements for each pattern in each subject
* @param mixed $subject the content to perform the replacement on
* @param mixed $pattern the regex pattern to use for matches
* @param mixed $replace the replacement value either as a string or an array of replacements
* @param int $limit the maximum possible replacements for each pattern in each subject
*
* @return mixed the resulting content
*/
public function regexReplace($subject, $pattern, $replace, $limit = -1)

View File

@@ -241,6 +241,10 @@ abstract class Utils
ignore_user_abort(false);
// fix corrupted files
if (Grav::instance()['config']->get('system.cache.gzip')) {
// Flush gzhandler buffer if gzip setting was enabled.
ob_end_clean();
}
ob_clean();
if ($force_download) {