diff --git a/CHANGELOG.md b/CHANGELOG.md
index d0b09cbf6..e85a61bee 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,12 @@
+# 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
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 5b187cdd2..da8896f69 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -12,7 +12,7 @@ patches and features.
## Grav, Plugins, Themes and Skeletons
-Grav is a large open source project—it'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 project — it'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.
diff --git a/system/blueprints/pages/default.yaml b/system/blueprints/pages/default.yaml
index 929a067c3..8472b3b1a 100644
--- a/system/blueprints/pages/default.yaml
+++ b/system/blueprints/pages/default.yaml
@@ -32,7 +32,7 @@ form:
validate:
type: textarea
- uploads:
+ header.media_order:
type: pagemedia
label: PLUGIN_ADMIN.PAGE_MEDIA
diff --git a/system/blueprints/pages/external.yaml b/system/blueprints/pages/external.yaml
index 3148c62e7..3db205f43 100644
--- a/system/blueprints/pages/external.yaml
+++ b/system/blueprints/pages/external.yaml
@@ -25,7 +25,7 @@ form:
content:
unset@: true
- uploads:
+ header.media_order:
unset@: true
header.external_url:
diff --git a/system/blueprints/pages/modular.yaml b/system/blueprints/pages/modular.yaml
index 2331ebf3e..b1e32c1b5 100644
--- a/system/blueprints/pages/modular.yaml
+++ b/system/blueprints/pages/modular.yaml
@@ -42,6 +42,6 @@ form:
type: ignore
content:
type: ignore
- uploads:
+ header.media_orider:
type: ignore
diff --git a/system/defines.php b/system/defines.php
index d8cf6a0a2..b6a4e6200 100644
--- a/system/defines.php
+++ b/system/defines.php
@@ -8,7 +8,7 @@
// Some standard defines
define('GRAV', true);
-define('GRAV_VERSION', '1.3.7');
+define('GRAV_VERSION', '1.3.8');
//define('GRAV_TESTING', true);
define('DS', '/');
diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php
index 3bbf857d0..99566c897 100644
--- a/system/src/Grav/Common/Grav.php
+++ b/system/src/Grav/Common/Grav.php
@@ -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;
diff --git a/system/src/Grav/Common/Page/Medium/AbstractMedia.php b/system/src/Grav/Common/Page/Medium/AbstractMedia.php
index f4e867446..cc428b992 100644
--- a/system/src/Grav/Common/Page/Medium/AbstractMedia.php
+++ b/system/src/Grav/Common/Page/Medium/AbstractMedia.php
@@ -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.
*
diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php
index 6e383c343..5de969b62 100644
--- a/system/src/Grav/Common/Utils.php
+++ b/system/src/Grav/Common/Utils.php
@@ -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
*
diff --git a/system/src/Grav/Console/Gpm/UpdateCommand.php b/system/src/Grav/Console/Gpm/UpdateCommand.php
index 6bc8790b3..1fb07134b 100644
--- a/system/src/Grav/Console/Gpm/UpdateCommand.php
+++ b/system/src/Grav/Console/Gpm/UpdateCommand.php
@@ -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: " . implode(', ',
$ignore) . "");
+
}
}