Compare commits

...

26 Commits
1.3.5 ... 1.3.8

Author SHA1 Message Date
Andy Miller
acea401a3d Merge branch 'release/1.3.8' 2017-10-26 18:37:27 -06:00
Andy Miller
0ec7158102 Prepare for release 2017-10-26 18:37:17 -06:00
Andy Miller
d3695b2faa Fixed missing image file not throwing 404 p#1713 2017-10-23 16:19:08 -06:00
Andy Miller
0668a47758 Fixed GPM update issue with filtered slugs #1711 2017-10-23 16:13:22 -06:00
Andy Miller
ca645ef476 updated changelog 2017-10-19 22:13:36 -04:00
Andy Miller
3ff5f79561 Added manual order capability to Page media 2017-10-19 22:10:12 -04:00
Djamil Legato
b5c8b70163 More media order changes 2017-10-19 18:01:37 -04:00
Djamil Legato
173a70c017 Updated default yaml with media order 2017-10-19 17:39:10 -04:00
Benoît Rouleau
eb52f670b9 fix nonsense logic (#1709) 2017-10-19 16:53:31 -04:00
Sam
dd166ce25c Update CONTRIBUTING.md copywriting (#1706) 2017-10-19 09:19:03 -04:00
Andy Miller
ea6423226a Merge branch 'release/1.3.7' 2017-10-18 16:35:41 -04:00
Andy Miller
85bf4406ed Merge tag '1.3.7' into develop
Release v1.3.7
2017-10-18 16:35:41 -04:00
Andy Miller
0cb8e0664e Prepare for release 2017-10-18 16:35:27 -04:00
Matias Griese
2842b8fa39 Fixed routing paths with urlencoded spaces and non-latin letters (#1688) 2017-10-17 14:40:30 +03:00
Matias Griese
317615854a Uri: Prefer using REQUEST_SCHEME instead of HTTPS (#1698) 2017-10-17 13:34:25 +03:00
Matias Griese
a9c82710a6 Regression: base_url_absolute always has the port number (#1690) 2017-10-16 12:36:06 +03:00
Matias Griese
3856a2a719 Add unit test for #1688 2017-10-16 11:13:25 +03:00
Viktor
880128c339 Update Grav Console Cli InstallCommand.php (#1692)
why do I have to clone the entire history of the plugin?
2017-10-13 08:34:39 -06:00
Andy Miller
444b48f788 Merge branch 'release/1.3.6' 2017-10-12 12:26:29 -06:00
Andy Miller
cc69591799 Merge tag '1.3.6' into develop
Release v1.3.6
2017-10-12 12:26:29 -06:00
Andy Miller
0d6f774386 Prepare for release 2017-10-12 12:26:12 -06:00
Andy Miller
474ca513ae Fix for nginx and _url issue
[admin#1244](https://github.com/getgrav/grav-plugin-admin/issues/1244)
2017-10-12 12:23:49 -06:00
Matias Griese
f37c08f341 Regression: Ajax error in ngnix (#1244) 2017-10-12 21:18:34 +03:00
Matias Griese
92afba0e28 Add test case for #1244 2017-10-12 18:36:10 +03:00
Andy Miller
974fc552c5 Added another complex test 2017-10-11 19:24:16 -06:00
Andy Miller
9e1170bd50 Merge tag '1.3.5' into develop
Release v1.3.5
2017-10-11 14:49:28 -06:00
16 changed files with 283 additions and 100 deletions

View File

@@ -1,3 +1,27 @@
# v1.3.8
## 10/26/2017
1. [](#new)
* Added Page `media_order` capability to manually order page media via a page header
1. [](#bugfix)
* Fixed GPM update issue with filtered slugs [#1711](https://github.com/getgrav/grav/issues/1711)
* Fixed issue with missing image file not throwing 404 properly [#1713](https://github.com/getgrav/grav/issues/1713)
# v1.3.7
## 10/18/2017
1. [](#bugfix)
* Regression Uri: `base_url_absolute` always has the port number [#1690](https://github.com/getgrav/grav-plugin-admin/issues/1690)
* Uri: Prefer using REQUEST_SCHEME instead of HTTPS [#1698](https://github.com/getgrav/grav-plugin-admin/issues/1698)
* Fixed routing paths with urlencoded spaces and non-latin letters [#1688](https://github.com/getgrav/grav-plugin-admin/issues/1688)
# v1.3.6
## 10/12/2017
1. [](#bugfix)
* Regression: Ajax error in Nginx [admin#1244](https://github.com/getgrav/grav-plugin-admin/issues/1244)
* Remove the `_url=$uri` portion of the the Nginx `try_files` command [admin#1244](https://github.com/getgrav/grav-plugin-admin/issues/1244)
# v1.3.5
## 10/11/2017

View File

@@ -12,7 +12,7 @@ patches and features.
## Grav, Plugins, Themes and Skeletons
Grav is a large open source projectit's made up of over 100 repositories. When you initially consider contributing to Grav, you might be unsure about which of those 200 repositories implements the functionality you want to change or report a bug for.
Grav is a large open source projectit's made up of over 100 repositories. When you initially consider contributing to Grav, you might be unsure about which of those 200 repositories implements the functionality you want to change or report a bug for.
[https://github.com/getgrav/grav](https://github.com/getgrav/grav) is the main Grav repository. The core of Grav is provided by this repo.
@@ -60,20 +60,20 @@ Guidelines for bug reports:
A good bug report shouldn't leave others needing to chase you up for more
information. Please try to be as detailed as possible in your report.
What is your environment? Is it localhost, OSX, Linux, on a remote server? Same happening locally and or the server, or just locally or just on Linux?
- What is your environment? Is it localhost, OSX, Linux, on a remote server? Same happening locally and or the server, or just locally or just on Linux?
What steps will reproduce the issue? What browser(s) and OS experience the problem?
- What steps will reproduce the issue? What browser(s) and OS experience the problem?
What would you expect to be the outcome?
- What would you expect to be the outcome?
Did the problem start happening recently (e.g. after updating to a new version of Grav) or was this always a problem?
- Did the problem start happening recently (e.g. after updating to a new version of Grav) or was this always a problem?
If the problem started happening recently, can you reproduce the problem in an older version of Grav? What's the most recent version in which the problem doesn't happen? You can download older versions of Grav from the releases page on Github.
- If the problem started happening recently, can you reproduce the problem in an older version of Grav? What's the most recent version in which the problem doesn't happen? You can download older versions of Grav from the releases page on Github.
Can you reliably reproduce the issue? If not, provide details about how often the problem happens and under which conditions it normally happens.
- Can you reliably reproduce the issue? If not, provide details about how often the problem happens and under which conditions it normally happens.
All these details will help people to fix any potential bugs.
All these details will help contributors to fix any potential bugs.
Important: [include Code Samples in triple backticks](https://help.github.com/articles/github-flavored-markdown/#fenced-code-blocks) so that Github will provide a proper indentation. [Add the language name after the backticks](https://help.github.com/articles/github-flavored-markdown/#syntax-highlighting) to add syntax highlighting to the code snippets.

View File

@@ -32,7 +32,7 @@ form:
validate:
type: textarea
uploads:
header.media_order:
type: pagemedia
label: PLUGIN_ADMIN.PAGE_MEDIA

View File

@@ -25,7 +25,7 @@ form:
content:
unset@: true
uploads:
header.media_order:
unset@: true
header.external_url:

View File

@@ -42,6 +42,6 @@ form:
type: ignore
content:
type: ignore
uploads:
header.media_orider:
type: ignore

View File

@@ -8,7 +8,7 @@
// Some standard defines
define('GRAV', true);
define('GRAV_VERSION', '1.3.5');
define('GRAV_VERSION', '1.3.8');
//define('GRAV_TESTING', true);
define('DS', '/');

View File

@@ -148,7 +148,7 @@ class Grav extends Container
// Initialize Locale if set and configured.
if ($this['language']->enabled() && $this['config']->get('system.languages.override_locale')) {
$language = $this['language']->getLanguage();
setlocale(LC_ALL, count($language < 3) ? ($language . '_' . strtoupper($language)) : $language);
setlocale(LC_ALL, strlen($language) < 3 ? ($language . '_' . strtoupper($language)) : $language);
} elseif ($this['config']->get('system.default_locale')) {
setlocale(LC_ALL, $this['config']->get('system.default_locale'));
}
@@ -499,6 +499,9 @@ class Grav extends Container
}
Utils::download($page->path() . DIRECTORY_SEPARATOR . $uri->basename(), $download);
}
// Nothing found
return false;
}
return $page;

View File

@@ -9,6 +9,8 @@
namespace Grav\Common\Page\Medium;
use Grav\Common\Getters;
use Grav\Common\Grav;
use Grav\Common\Utils;
abstract class AbstractMedia extends Getters
{
@@ -49,7 +51,8 @@ abstract class AbstractMedia extends Getters
*/
public function all()
{
ksort($this->instances, SORT_NATURAL | SORT_FLAG_CASE);
$this->instances = $this->orderMedia($this->instances);
return $this->instances;
}
@@ -60,7 +63,7 @@ abstract class AbstractMedia extends Getters
*/
public function images()
{
ksort($this->images, SORT_NATURAL | SORT_FLAG_CASE);
$this->images = $this->orderMedia($this->images);
return $this->images;
}
@@ -71,7 +74,7 @@ abstract class AbstractMedia extends Getters
*/
public function videos()
{
ksort($this->videos, SORT_NATURAL | SORT_FLAG_CASE);
$this->videos = $this->orderMedia($this->videos);
return $this->videos;
}
@@ -82,7 +85,7 @@ abstract class AbstractMedia extends Getters
*/
public function audios()
{
ksort($this->audios, SORT_NATURAL | SORT_FLAG_CASE);
$this->audios = $this->orderMedia($this->audios);
return $this->audios;
}
@@ -93,7 +96,7 @@ abstract class AbstractMedia extends Getters
*/
public function files()
{
ksort($this->files, SORT_NATURAL | SORT_FLAG_CASE);
$this->files = $this->orderMedia($this->files);
return $this->files;
}
@@ -119,6 +122,25 @@ abstract class AbstractMedia extends Getters
}
}
/**
* Order the media based on the page's media_order
*
* @param $media
* @return array
*/
protected function orderMedia($media)
{
$page = Grav::instance()['pages']->get($this->path);
if ($page && isset($page->header()->media_order)) {
$media_order = array_map('trim', explode(',', $page->header()->media_order));
$media = Utils::sortArrayByArray($media, $media_order);
} else {
ksort($media, SORT_NATURAL | SORT_FLAG_CASE);
}
return $media;
}
/**
* Get filename, extension and meta part.
*

View File

@@ -135,7 +135,7 @@ class Page
$this->metadata();
$this->url();
$this->visible();
$this->modularTwig($this->slug[0] == '_');
$this->modularTwig($this->slug[0] === '_');
$this->setPublishState();
$this->published();
$this->urlExtension();
@@ -517,17 +517,18 @@ class Page
// Return entire page content on wrong/ unknown format
if (!in_array($format, ['short', 'long'])) {
return $content;
} elseif (($format === 'short') && isset($summary_size)) {
}
if (($format === 'short') && isset($summary_size)) {
// Use mb_strimwidth to slice the string
if (mb_strwidth($content, 'utf8') > $summary_size) {
return mb_substr($content, 0, $summary_size);
} else {
return $content;
}
return $content;
}
// Get summary size from site config's file
if (is_null($size)) {
if ($size === null) {
$size = $config['size'];
}
@@ -535,7 +536,8 @@ class Page
if ($size === 0) {
return $content;
// Return calculated summary based on defaults
} elseif (!is_numeric($size) || ($size < 0)) {
}
if (!is_numeric($size) || ($size < 0)) {
$size = 300;
}
@@ -726,10 +728,9 @@ class Page
if ($name) {
if (isset($this->content_meta[$name])) {
return $this->content_meta[$name];
} else {
return null;
}
return null;
}
return $this->content_meta;
@@ -825,27 +826,27 @@ class Page
*/
public function value($name, $default = null)
{
if ($name == 'content') {
if ($name === 'content') {
return $this->raw_content;
}
if ($name == 'route') {
if ($name === 'route') {
return $this->parent()->rawRoute();
}
if ($name == 'order') {
if ($name === 'order') {
$order = $this->order();
return $order ? (int)$this->order() : '';
}
if ($name == 'ordering') {
if ($name === 'ordering') {
return (bool)$this->order();
}
if ($name == 'folder') {
if ($name === 'folder') {
return preg_replace(PAGE_ORDER_PREFIX_REGEX, '', $this->folder);
}
if ($name == 'slug') {
if ($name === 'slug') {
return $this->slug();
}
if ($name == 'name') {
if ($name === 'name') {
$language = $this->language() ? '.' . $this->language() : '';
$name_val = str_replace($language . '.md', '', $this->name());
if ($this->modular()) {
@@ -854,30 +855,30 @@ class Page
return $name_val;
}
if ($name == 'media') {
if ($name === 'media') {
return $this->media()->all();
}
if ($name == 'media.file') {
if ($name === 'media.file') {
return $this->media()->files();
}
if ($name == 'media.video') {
if ($name === 'media.video') {
return $this->media()->videos();
}
if ($name == 'media.image') {
if ($name === 'media.image') {
return $this->media()->images();
}
if ($name == 'media.audio') {
if ($name === 'media.audio') {
return $this->media()->audios();
}
$path = explode('.', $name);
$scope = array_shift($path);
if ($name == 'frontmatter') {
if ($name === 'frontmatter') {
return $this->frontmatter;
}
if ($scope == 'header') {
if ($scope === 'header') {
$current = $this->header();
foreach ($path as $field) {
if (is_object($current) && isset($current->{$field})) {
@@ -969,7 +970,7 @@ class Page
$this->_action = 'move';
if ($this->route() == $parent->route()) {
if ($this->route() === $parent->route()) {
throw new Exception('Failed: Cannot set page parent to self');
}
if (Utils::startsWith($parent->rawRoute(), $this->rawRoute())) {
@@ -1029,12 +1030,12 @@ class Page
$edit_mode = isset($grav['admin']) ? $grav['config']->get('plugins.admin.edit_mode') : null;
// override if you only want 'normal' mode
if (empty($fields) && ($edit_mode == 'auto' || $edit_mode == 'normal')) {
if (empty($fields) && ($edit_mode === 'auto' || $edit_mode === 'normal')) {
$blueprint = $pages->blueprints('default');
}
// override if you only want 'expert' mode
if (!empty($fields) && $edit_mode == 'expert') {
if (!empty($fields) && $edit_mode === 'expert') {
$blueprint = $pages->blueprints('');
}
@@ -1459,9 +1460,9 @@ class Page
{
if (isset($this->debugger) && $this->debugger === false) {
return false;
} else {
return true;
}
return true;
}
/**
@@ -1502,7 +1503,7 @@ class Page
// Backward compatibility for nested arrays in metas
if (is_array($value)) {
foreach ($value as $property => $prop_value) {
$prop_key = $key . ":" . $property;
$prop_key = $key . ':' . $property;
$this->metadata[$prop_key] = [
'name' => $prop_key,
'property' => $prop_key,
@@ -1517,7 +1518,7 @@ class Page
'http_equiv' => $key,
'content' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')
];
} elseif ($key == 'charset') {
} elseif ($key === 'charset') {
$this->metadata[$key] = ['charset' => htmlspecialchars($value, ENT_QUOTES, 'UTF-8')];
} else {
// if it's a social metadata with separator, render as property
@@ -1552,7 +1553,7 @@ class Page
*/
public function slug($var = null)
{
if ($var !== null && $var !== "") {
if ($var !== null && $var !== '') {
$this->slug = $var;
}
@@ -1679,7 +1680,7 @@ class Page
$url = rtrim($url, '/');
}
return $url;
return Uri::filterPath($url);
}
/**
@@ -1702,7 +1703,7 @@ class Page
// calculate route based on parent slugs
$parent = $this->parent();
if (isset($parent)) {
if ($this->hide_home_route && $parent->route() == $this->home_route) {
if ($this->hide_home_route && $parent->route() === $this->home_route) {
$baseRoute = '';
} else {
$baseRoute = (string)$parent->route();
@@ -1770,9 +1771,9 @@ class Page
if (!empty($this->routes) && isset($this->routes['aliases'])) {
return $this->routes['aliases'];
} else {
return [];
}
return [];
}
/**
@@ -2298,7 +2299,7 @@ class Page
$routes = Grav::instance()['pages']->routes();
if (isset($routes[$uri_path])) {
if ($routes[$uri_path] == $this->path()) {
if ($routes[$uri_path] === $this->path()) {
return true;
}
@@ -2325,7 +2326,7 @@ class Page
$child_page = $pages->dispatch($uri->route())->parent();
if ($child_page) {
while (!$child_page->root()) {
if ($this->path() == $child_page->path()) {
if ($this->path() === $child_page->path()) {
return true;
}
$child_page = $child_page->parent();
@@ -2344,7 +2345,7 @@ class Page
public function home()
{
$home = Grav::instance()['config']->get('system.home.alias');
$is_home = ($this->route() == $home || $this->rawRoute() == $home);
$is_home = ($this->route() === $home || $this->rawRoute() === $home);
return $is_home;
}
@@ -2358,9 +2359,9 @@ class Page
{
if (!$this->parent && !$this->name && !$this->visible) {
return true;
} else {
return false;
}
return false;
}
/**
@@ -2587,7 +2588,7 @@ class Page
}
/**
* @param string $value
* @param string|array $value
*
* @return mixed
* @internal
@@ -2605,7 +2606,7 @@ class Page
$params = (array)current($value);
} else {
$result = [];
foreach ($value as $key => $val) {
foreach ((array)$value as $key => $val) {
if (is_int($key)) {
$result = $result + $this->evaluate($val)->toArray();
} else {
@@ -2711,7 +2712,7 @@ class Page
case 'root@':
case '@root':
if (!empty($parts) && $parts[0] == 'descendants') {
if (!empty($parts) && $parts[0] === 'descendants') {
$results = $pages->all($pages->root())->nonModular()->published();
} else {
$results = $pages->root()->children()->nonModular()->published();
@@ -2824,11 +2825,11 @@ class Page
// Reorder all moved pages.
foreach ($siblings as $slug => $page) {
$order = intval(trim($page->order(), '.'));
$order = (int)trim($page->order(), '.');
$counter++;
if ($order) {
if ($page->path() == $this->path() && $this->folderExists()) {
if ($page->path() === $this->path() && $this->folderExists()) {
// Handle current page; we do want to change ordering number, but nothing else.
$this->order($counter);
$this->save(false);
@@ -2859,14 +2860,14 @@ class Page
}
if (is_dir($this->_original->path())) {
if ($this->_action == 'move') {
if ($this->_action === 'move') {
Folder::move($this->_original->path(), $this->path());
} elseif ($this->_action == 'copy') {
} elseif ($this->_action === 'copy') {
Folder::copy($this->_original->path(), $this->path());
}
}
if ($this->name() != $this->_original->name()) {
if ($this->name() !== $this->_original->name()) {
$path = $this->path();
if (is_file($path . '/' . $this->_original->name())) {
rename($path . '/' . $this->_original->name(), $path . '/' . $this->name());
@@ -2889,7 +2890,7 @@ class Page
}
}
// publish if required, if not clear cache right before page is published
if ($this->publishDate() && $this->publishDate() && $this->publishDate() > time()) {
if ($this->publishDate() && $this->publishDate() > time()) {
$this->published(false);
Grav::instance()['cache']->setLifeTime($this->publishDate());
}

View File

@@ -16,12 +16,13 @@ use Grav\Common\Filesystem\Folder;
use Grav\Common\Grav;
use Grav\Common\Language\Language;
use Grav\Common\Taxonomy;
use Grav\Common\Uri;
use Grav\Common\Utils;
use Grav\Plugin\Admin;
use RocketTheme\Toolbox\Event\Event;
use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator;
use Whoops\Exception\ErrorException;
use Collator as Collator;
use Collator;
class Pages
{
@@ -152,7 +153,7 @@ class Pages
}
$path_append = rtrim($this->grav['pages']->base(), '/');
if ($language->getDefault() != $lang || $config->get('system.languages.include_default_lang') === true) {
if ($language->getDefault() !== $lang || $config->get('system.languages.include_default_lang') === true) {
$path_append .= $lang ? '/' . $lang : '';
}
@@ -192,7 +193,7 @@ class Pages
return $this->homeUrl($lang, $absolute);
}
return $this->baseUrl($lang, $absolute) . $route;
return $this->baseUrl($lang, $absolute) . Uri::filterPath($route);
}
/**
@@ -297,7 +298,7 @@ class Pages
$sort = $this->sort[$path][$order_by];
if ($order_dir != 'asc') {
if ($order_dir !== 'asc') {
$sort = array_reverse($sort);
}
@@ -327,7 +328,7 @@ class Pages
$sort = $this->sort[$lookup][$orderBy];
if ($orderDir != 'asc') {
if ($orderDir !== 'asc') {
$sort = array_reverse($sort);
}
@@ -345,10 +346,6 @@ class Pages
*/
public function get($path)
{
if (!is_null($path) && !is_string($path)) {
throw new \Exception();
}
return isset($this->instances[(string)$path]) ? $this->instances[(string)$path] : null;
}
@@ -376,13 +373,13 @@ class Pages
*/
public function ancestor($route, $path = null)
{
if (!is_null($path)) {
if ($path !== null) {
$page = $this->dispatch($route, true);
if ($page->path() == $path) {
if ($page && $page->path() === $path) {
return $page;
} elseif (!$page->parent()->root()) {
}
if ($page && !$page->parent()->root()) {
return $this->ancestor($page->parent()->route(), $path);
}
}
@@ -400,15 +397,14 @@ class Pages
*/
public function inherited($route, $field = null)
{
if (!is_null($field)) {
if ($field !== null) {
$page = $this->dispatch($route, true);
$ancestorField = $page->parent()->value('header.' . $field);
if ($ancestorField !== null) {
if ($page && $page->parent()->value('header.' . $field) !== null) {
return $page->parent();
} elseif (!$page->parent()->root()) {
}
if ($page && !$page->parent()->root()) {
return $this->inherited($page->parent()->route(), $field);
}
}
@@ -441,6 +437,8 @@ class Pages
*/
public function dispatch($route, $all = false, $redirect = true)
{
$route = urldecode($route);
// Fetch page if there's a defined route to it.
$page = isset($this->routes[$route]) ? $this->get($this->routes[$route]) : null;
// Try without trailing slash
@@ -499,7 +497,7 @@ class Pages
$pattern = '#^' . str_replace('/', '\/', ltrim($pattern, '^')) . '#';
try {
$found = preg_replace($pattern, $replace, $source_url);
if ($found != $source_url) {
if ($found !== $source_url) {
$page = $this->dispatch($found, $all);
}
} catch (ErrorException $e) {
@@ -535,7 +533,7 @@ class Pages
*/
public function blueprints($type)
{
if (!isset($this->blueprints)) {
if ($this->blueprints === null) {
$this->blueprints = new Blueprints(self::getTypes());
}
@@ -970,7 +968,7 @@ class Pages
* @throws \RuntimeException
* @internal
*/
protected function recurse($directory, Page &$parent = null)
protected function recurse($directory, Page $parent = null)
{
$directory = rtrim($directory, DS);
$page = new Page;
@@ -1023,7 +1021,7 @@ class Pages
if ($found->isDir()) {
continue;
}
$regex = '/^[^\.]*' . preg_quote($extension) . '$/';
$regex = '/^[^\.]*' . preg_quote($extension, '/') . '$/';
if (preg_match($regex, $found->getFilename())) {
$page_found = $found;
$page_extension = $extension;
@@ -1053,10 +1051,8 @@ class Pages
$name = $file->getFilename();
// Ignore all hidden files if set.
if ($this->ignore_hidden) {
if ($name && $name[0] == '.') {
continue;
}
if ($this->ignore_hidden && $name && $name[0] === '.') {
continue;
}
if ($file->isFile()) {
@@ -1096,7 +1092,7 @@ class Pages
}
// Override the modified time if modular
if ($page->template() == 'modular') {
if ($page->template() === 'modular') {
foreach ($page->collection() as $child) {
$modified = $child->modified();
@@ -1174,6 +1170,7 @@ class Pages
* @param array $pages
* @param string $order_by
* @param array $manual
* @param int $sort_flags
*
* @throws \RuntimeException
* @internal
@@ -1249,7 +1246,7 @@ class Pages
}
// handle special case when order_by is random
if ($order_by == 'random') {
if ($order_by === 'random') {
$list = $this->arrayShuffle($list);
} else {
// else just sort the list according to specified key

View File

@@ -58,8 +58,12 @@ class Uri
protected function createFromEnvironment(array $env)
{
// Build scheme.
$https = isset($env['HTTPS']) ? $env['HTTPS'] : '';
$this->scheme = (empty($https) || strtolower($https) === 'off') ? 'http' : 'https';
if (isset($env['REQUEST_SCHEME'])) {
$this->scheme = $env['REQUEST_SCHEME'];
} else {
$https = isset($env['HTTPS']) ? $env['HTTPS'] : '';
$this->scheme = (empty($https) || strtolower($https) === 'off') ? 'http' : 'https';
}
// Build user and password.
$this->user = isset($env['PHP_AUTH_USER']) ? $env['PHP_AUTH_USER'] : null;
@@ -79,6 +83,9 @@ class Uri
// Build port.
$this->port = isset($env['SERVER_PORT']) ? (int)$env['SERVER_PORT'] : null;
if ($this->hasStandardPort()) {
$this->port = null;
}
// Build path.
$request_uri = isset($env['REQUEST_URI']) ? $env['REQUEST_URI'] : '';
@@ -90,6 +97,13 @@ class Uri
$this->query = parse_url('http://example.com' . $request_uri, PHP_URL_QUERY);
}
// Support ngnix routes.
if (strpos($this->query, '_url=') === 0) {
parse_str($this->query, $query);
unset($query['_url']);
$this->query = http_build_query($query);
}
// Build fragment.
$this->fragment = null;
@@ -100,6 +114,16 @@ class Uri
$this->reset();
}
/**
* Does this Uri use a standard port?
*
* @return bool
*/
protected function hasStandardPort()
{
return ($this->scheme === 'http' && $this->port === 80) || ($this->scheme === 'https' && $this->port === 443);
}
/**
* @param string $url
*/

View File

@@ -852,6 +852,24 @@ abstract class Utils
return strpos($_SERVER["SERVER_SOFTWARE"], 'Apache') !== false;
}
/**
* Sort a multidimensional array by another array of ordered keys
*
* @param array $array
* @param array $orderArray
* @return array
*/
public static function sortArrayByArray(array $array, array $orderArray) {
$ordered = array();
foreach ($orderArray as $key) {
if (array_key_exists($key, $array)) {
$ordered[$key] = $array[$key];
unset($array[$key]);
}
}
return $ordered + $array;
}
/**
* Get's path based on a token
*

View File

@@ -117,7 +117,7 @@ class InstallCommand extends ConsoleCommand
$this->destination = rtrim($this->destination, DS);
$path = $this->destination . DS . $data['path'];
if (!file_exists($path)) {
exec('cd "' . $this->destination . '" && git clone -b ' . $data['branch'] . ' ' . $data['url'] . ' ' . $data['path'], $output, $return);
exec('cd "' . $this->destination . '" && git clone -b ' . $data['branch'] . ' --depth 1 ' . $data['url'] . ' ' . $data['path'], $output, $return);
if (!$return) {
$this->output->writeln('<green>SUCCESS</green> cloned <magenta>' . $data['url'] . '</magenta> -> <cyan>' . $path . '</cyan>');

View File

@@ -182,7 +182,7 @@ class UpdateCommand extends ConsoleCommand
$index = 0;
foreach ($this->data as $packages) {
foreach ($packages as $slug => $package) {
if (count($limit_to) && !array_key_exists($slug, $limit_to)) {
if (count($only_packages) && !array_key_exists($slug, $limit_to)) {
continue;
}
@@ -276,6 +276,7 @@ class UpdateCommand extends ConsoleCommand
$this->output->writeln('');
$this->output->writeln("Packages not found or not requiring updates: <red>" . implode('</red>, <red>',
$ignore) . "</red>");
}
}

View File

@@ -371,6 +371,52 @@ class UriTest extends \Codeception\TestCase\Test
'extension' => null,
'addNonce' => 'http://localhost:8080/a/b/c/d/e/f/a/b/c/d/e/f/a/b/c/d/e/f/nonce:{{nonce}}',
],
'http://localhost/this is the path/my page' => [
'scheme' => 'http://',
'user' => null,
'password' => null,
'host' => 'localhost',
'port' => 80,
'path' => '/this%20is%20the%20path/my%20page',
'query' => '',
'fragment' => null,
'route' => '/this%20is%20the%20path/my%20page',
'paths' => ['this%20is%20the%20path', 'my%20page'],
'params' => null,
'url' => '/this%20is%20the%20path/my%20page',
'environment' => 'localhost',
'basename' => 'my%20page',
'base' => 'http://localhost',
'currentPage' => 1,
'rootUrl' => 'http://localhost',
'extension' => null,
'addNonce' => 'http://localhost/this%20is%20the%20path/my%20page/nonce:{{nonce}}',
'__toString' => 'http://localhost/this%20is%20the%20path/my%20page'
],
'http://localhost/pölöpölö/päläpälä' => [
'scheme' => 'http://',
'user' => null,
'password' => null,
'host' => 'localhost',
'port' => 80,
'path' => '/p%C3%B6l%C3%B6p%C3%B6l%C3%B6/p%C3%A4l%C3%A4p%C3%A4l%C3%A4',
'query' => '',
'fragment' => null,
'route' => '/p%C3%B6l%C3%B6p%C3%B6l%C3%B6/p%C3%A4l%C3%A4p%C3%A4l%C3%A4',
'paths' => ['p%C3%B6l%C3%B6p%C3%B6l%C3%B6', 'p%C3%A4l%C3%A4p%C3%A4l%C3%A4'],
'params' => null,
'url' => '/p%C3%B6l%C3%B6p%C3%B6l%C3%B6/p%C3%A4l%C3%A4p%C3%A4l%C3%A4',
'environment' => 'localhost',
'basename' => 'p%C3%A4l%C3%A4p%C3%A4l%C3%A4',
'base' => 'http://localhost',
'currentPage' => 1,
'rootUrl' => 'http://localhost',
'extension' => null,
'addNonce' => 'http://localhost/p%C3%B6l%C3%B6p%C3%B6l%C3%B6/p%C3%A4l%C3%A4p%C3%A4l%C3%A4/nonce:{{nonce}}',
'__toString' => 'http://localhost/p%C3%B6l%C3%B6p%C3%B6l%C3%B6/p%C3%A4l%C3%A4p%C3%A4l%C3%A4'
],
// Query params tests.
'http://localhost:8080/grav/it/ueper?test=x&test2=y' => [
'scheme' => 'http://',
@@ -550,7 +596,53 @@ class UriTest extends \Codeception\TestCase\Test
'rootUrl' => 'http://localhost',
'extension' => 'json',
'addNonce' => 'http://localhost/a-page.json/nonce:{{nonce}}',
'__toString' => 'http://localhost/a-page', // FIXME <-
'__toString' => 'http://localhost/a-page', // FIX ME <-
],
'http://localhost/admin/ajax.json/task:getnewsfeed' => [
'scheme' => 'http://',
'user' => null,
'password' => null,
'host' => 'localhost',
'port' => 80,
'path' => '/admin/ajax',
'query' => '',
'fragment' => null,
'route' => '/admin/ajax',
'paths' => ['admin', 'ajax'],
'params' => '/task:getnewsfeed',
'url' => '/admin/ajax',
'environment' => 'localhost',
'basename' => 'ajax.json',
'base' => 'http://localhost',
'currentPage' => 1,
'rootUrl' => 'http://localhost',
'extension' => 'json',
'addNonce' => 'http://localhost/admin/ajax.json/task:getnewsfeed/nonce:{{nonce}}',
'__toString' => 'http://localhost/admin/ajax/task:getnewsfeed',
],
'http://localhost/grav/admin/media.json/route:L1VzZXJzL3JodWsvd29ya3NwYWNlL2dyYXYtZGVtby1zYW1wbGVyL3VzZXIvYXNzZXRzL3FRMXB4Vk1ERTNJZzh5Ni5qcGc=/task:removeFileFromBlueprint/proute:/blueprint:Y29uZmlnL2RldGFpbHM=/type:config/field:deep.nested.custom_file/path:dXNlci9hc3NldHMvcVExcHhWTURFM0lnOHk2LmpwZw==' => [
'scheme' => 'http://',
'user' => null,
'password' => null,
'host' => 'localhost',
'port' => 80,
'path' => '/grav/admin/media',
'query' => '',
'fragment' => null,
'route' => '/grav/admin/media',
'paths' => ['grav','admin','media'],
'params' => '/route:L1VzZXJzL3JodWsvd29ya3NwYWNlL2dyYXYtZGVtby1zYW1wbGVyL3VzZXIvYXNzZXRzL3FRMXB4Vk1ERTNJZzh5Ni5qcGc=/task:removeFileFromBlueprint/proute:/blueprint:Y29uZmlnL2RldGFpbHM=/type:config/field:deep.nested.custom_file/path:dXNlci9hc3NldHMvcVExcHhWTURFM0lnOHk2LmpwZw==',
'url' => '/grav/admin/media',
'environment' => 'localhost',
'basename' => 'media.json',
'base' => 'http://localhost',
'currentPage' => 1,
'rootUrl' => 'http://localhost',
'extension' => 'json',
'addNonce' => 'http://localhost/grav/admin/media.json/route:L1VzZXJzL3JodWsvd29ya3NwYWNlL2dyYXYtZGVtby1zYW1wbGVyL3VzZXIvYXNzZXRzL3FRMXB4Vk1ERTNJZzh5Ni5qcGc=/task:removeFileFromBlueprint/proute:/blueprint:Y29uZmlnL2RldGFpbHM=/type:config/field:deep.nested.custom_file/path:dXNlci9hc3NldHMvcVExcHhWTURFM0lnOHk2LmpwZw==/nonce:{{nonce}}',
'__toString' => 'http://localhost/grav/admin/media/route:L1VzZXJzL3JodWsvd29ya3NwYWNlL2dyYXYtZGVtby1zYW1wbGVyL3VzZXIvYXNzZXRzL3FRMXB4Vk1ERTNJZzh5Ni5qcGc=/task:removeFileFromBlueprint/proute:/blueprint:Y29uZmlnL2RldGFpbHM=/type:config/field:deep.nested.custom_file/path:dXNlci9hc3NldHMvcVExcHhWTURFM0lnOHk2LmpwZw==', // FIXME <-
],
'http://localhost/a-page.foo' => [
'scheme' => 'http://',
@@ -573,6 +665,7 @@ class UriTest extends \Codeception\TestCase\Test
'rootUrl' => 'http://localhost',
'extension' => 'foo',
'addNonce' => 'http://localhost/a-page.foo/nonce:{{nonce}}',
'__toString' => 'http://localhost/a-page.foo'
],
// Fragment tests.
'http://localhost:8080/a/b/c#my-fragment' => [

View File

@@ -12,7 +12,7 @@ server {
# `location /subfolder {`
# and the rewrite to use `/subfolder/index.php`
location / {
try_files $uri $uri/ /index.php?_url=$uri&$query_string;
try_files $uri $uri/ /index.php?$query_string;
}
## End - Index