Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/getgrav/grav into 2.0
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
mahagr committed Oct 25, 2017
2 parents ae14381 + d3695b2 commit d00d8cb
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 22 deletions.
17 changes: 13 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@
1. [](#improved)
* Make it possible to include debug bar also into non-HTML responses

# v1.3.8
## xx/xx/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
## mm/dd/2017
## 10/18/2017

1. [](#bugfix)
* Regressionin Uri: `base_url_absolute` always has the port number (#1690)
* Uri: Prefer using REQUEST_SCHEME instead of HTTPS (#1698)
* Fixed routing paths with urlencoded spaces and non-latin letters (#1688)
* 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
Expand Down
16 changes: 8 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion system/blueprints/pages/external.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ form:
content:
unset@: true

uploads:
header.media_order:
unset@: true

header.external_url:
Expand Down
2 changes: 1 addition & 1 deletion system/blueprints/pages/modular.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ form:
type: ignore
content:
type: ignore
uploads:
header.media_orider:
type: ignore

2 changes: 1 addition & 1 deletion system/defines.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

// Some standard defines
define('GRAV', true);
define('GRAV_VERSION', '1.3.6');
define('GRAV_VERSION', '1.3.7');
//define('GRAV_TESTING', true);
define('DS', '/');

Expand Down
5 changes: 4 additions & 1 deletion system/src/Grav/Common/Grav.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function setLocale()
// 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'));
}
Expand Down Expand Up @@ -495,6 +495,9 @@ public function fallbackUrl($path)
}
Utils::download($page->path() . DIRECTORY_SEPARATOR . $uri->basename(), $download);
}

// Nothing found
return false;
}

return $page;
Expand Down
32 changes: 27 additions & 5 deletions system/src/Grav/Common/Page/Medium/AbstractMedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -49,7 +51,8 @@ public function __invoke($filename)
*/
public function all()
{
ksort($this->instances, SORT_NATURAL | SORT_FLAG_CASE);
$this->instances = $this->orderMedia($this->instances);

return $this->instances;
}

Expand All @@ -60,7 +63,7 @@ public function all()
*/
public function images()
{
ksort($this->images, SORT_NATURAL | SORT_FLAG_CASE);
$this->images = $this->orderMedia($this->images);
return $this->images;
}

Expand All @@ -71,7 +74,7 @@ public function images()
*/
public function videos()
{
ksort($this->videos, SORT_NATURAL | SORT_FLAG_CASE);
$this->videos = $this->orderMedia($this->videos);
return $this->videos;
}

Expand All @@ -82,7 +85,7 @@ public function videos()
*/
public function audios()
{
ksort($this->audios, SORT_NATURAL | SORT_FLAG_CASE);
$this->audios = $this->orderMedia($this->audios);
return $this->audios;
}

Expand All @@ -93,7 +96,7 @@ public function audios()
*/
public function files()
{
ksort($this->files, SORT_NATURAL | SORT_FLAG_CASE);
$this->files = $this->orderMedia($this->files);
return $this->files;
}

Expand All @@ -119,6 +122,25 @@ protected function add($name, $file)
}
}

/**
* 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.
*
Expand Down
18 changes: 18 additions & 0 deletions system/src/Grav/Common/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,24 @@ public static function isApache() {
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
*
Expand Down
3 changes: 2 additions & 1 deletion system/src/Grav/Console/Gpm/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ protected function serve()
$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;
}

Expand Down Expand Up @@ -276,6 +276,7 @@ private function userInputPackages($only_packages)
$this->output->writeln('');
$this->output->writeln("Packages not found or not requiring updates: <red>" . implode('</red>, <red>',
$ignore) . "</red>");

}
}

Expand Down

0 comments on commit d00d8cb

Please sign in to comment.