Merge branch 'feature/pagemedia' into 1.9

This commit is contained in:
Andy Miller
2018-10-01 10:25:02 -06:00
15 changed files with 82 additions and 31 deletions

View File

@@ -4,10 +4,13 @@
1. [](#new)
* IMPORTANT: Non `admin.super` users are now subject to XSS validation in Page content. Configurable via Configuration / Security
* Added new event `onAdminPage` which allows plugins to customize `Page` object in `$event['page']`
* Added proper support for hiding form fields in blueprints by using dynamic property like `security@: admin.foobar` to any field
1. [](#improved)
* Use `Url:post()` to get the `$_POST` variable (allows common security checks/filtering for the POST data)
1. [](#bugfix)
* Fixed issue in filepicker where missing images would cause a loop to try to load them
* Make all form fields to extend field.html.twig
* Do not redirect to `/admin` for login if admin page does not exist
# v1.8.9
## 08/23/2018

View File

@@ -434,7 +434,13 @@ class AdminPlugin extends Plugin
throw new \RuntimeException('Page Not Found', 404);
}
} else {
$this->grav->redirect($this->admin_route);
// Not Found and not logged in: Display login page.
$login_file = $this->grav['locator']->findResource('plugins://admin/pages/admin/login.md');
$page = new Page();
$page->init(new \SplFileInfo($login_file));
$page->slug(basename($this->route));
unset($this->grav['page']);
$this->grav['page'] = $page;
}
}

View File

@@ -532,7 +532,6 @@ PLUGIN_ADMIN:
ADD_FOLDER: "Add Folder"
PROXY_URL: "Proxy URL"
PROXY_URL_HELP: "Enter the proxy HOST or IP and PORT"
INVALID_FRONTMATTER_COULD_NOT_SAVE: "Invalid frontmatter, could not save"
NOTHING_TO_SAVE: "Nothing to Save"
FILE_ERROR_ADD: "An error occurred while trying to add the file"
FILE_ERROR_UPLOAD: "An error occurred while trying to upload the file"
@@ -584,7 +583,6 @@ PLUGIN_ADMIN:
CANNOT_ADD_FILES_PAGE_NOT_SAVED: "NOTE: Page must be saved before you can upload files to it."
DROP_FILES_HERE_TO_UPLOAD: "Drop your files here or <strong>click in this area</strong>"
INSERT: "Insert"
METADATA: "Metadata"
UNDO: "Undo"
REDO: "Redo"
HEADERS: "Headers"

View File

@@ -1,3 +1,5 @@
{% if not field.validate.ignore %}
{% set originalValue = originalValue is defined ? originalValue : value %}
{% set toggleableChecked = field.toggleable and (originalValue is not null and originalValue is not empty) %}
{% set isDisabledToggleable = field.toggleable and not toggleableChecked %}
@@ -106,3 +108,5 @@
{% endblock %}
</div>
{% endblock %}
{% endif %}

View File

@@ -1,3 +1,6 @@
{% extends "forms/field.html.twig" %}
{% block field %}
<input
data-grav-field="hidden"
data-grav-disabled="false"
@@ -6,3 +9,4 @@
{% if field.disabled or isDisabledToggleable %}disabled="disabled"{% endif %}
name="{{ (scope ~ field.name)|fieldName }}"
value="{{ blueprints.name }}" />
{% endblock %}

View File

@@ -1,10 +1,14 @@
{% extends "forms/field.html.twig" %}
{% block field %}
{% if field.fields %}
<div class="form-column block pure-u-1-{{ cols }}">
{% for field in field.fields %}
{% if field.type %}
{% set value = field.name ? data.value(field.name) : data.toArray %}
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
{% for child in field.fields %}
{% if child.type and not child.validate.ignore %}
{% set value = child.name ? data.value(child.name) : data.toArray %}
{% include ["forms/fields/#{child.type}/#{child.type}.html.twig", 'forms/fields/text/text.html.twig'] with {field: child} %}
{% endif %}
{% endfor %}
</div>
{% endif %}
{% endblock %}

View File

@@ -1,9 +1,12 @@
{% extends "forms/field.html.twig" %}
{% block field %}
<div class="form-columns grid pure-g">
{% if field.fields %}
{% set cols = field.fields|length %}
{% for field in field.fields %}
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/column/column.html.twig'] with {'cols':cols} %}
{% for child in field.fields %}
{% include ["forms/fields/#{child.type}/#{child.type}.html.twig", 'forms/fields/column/column.html.twig'] with {field: child, cols: cols} %}
{% endfor %}
{% endif %}
</div>
{% endblock %}

View File

@@ -1,15 +1,17 @@
{% extends "forms/field.html.twig" %}
{% set value = (value is null ? field.default|tu : value) %}
{% if not codemirrorOptions %}
{% set codemirrorOptions = {'mode': 'gfm', 'ignore': ['code', 'preview']}|merge(field.codemirror|default({})) %}
{% endif %}
{% block label %}
{% if field.label %}
{% set hint = field.help ? 'data-hint="' ~ field.help|tu|raw ~ '"': '' %}
<div class="form-label form-field hint--bottom" {{ hint }}>{{ field.label|tu|raw }}</div>
{% endif %}
{% endblock %}
{% block field %}
{% block label %}
{% if field.label %}
{% set hint = field.help ? 'data-hint="' ~ field.help|tu|raw ~ '"': '' %}
<div class="form-label form-field hint--bottom" {{ hint }}>{{ field.label|tu|raw }}</div>
{% endif %}
{% endblock %}
<div class="form-field {{ field.classes|default('') }}">
<div class="form-data grav-editor">
<div class="grav-editor-content is-active">

View File

@@ -1,8 +1,11 @@
{% extends "forms/field.html.twig" %}
{% set value = (value is null ? field.default : value) %}
{% set siblings = context.parent.children %}
{% set canOrder = context.order %}
{% set vertical = field.style == 'vertical' %}
{% block field %}
<div class="form-field grid pure-g{% if vertical %} vertical{% endif %}">
<div class="form-label{% if not vertical %} block size-1-3 pure-u-1-3{% endif %}">
<label>
@@ -29,12 +32,12 @@
{% if siblings|length < 200 %}
{% set sortable_count = 0 %}
<ul id="ordering" class="orderable {{ field.classes }}">
{% for page in siblings if page.order %}
<li class="drag-handle" data-id="{{ page.slug }}" {{ page.slug == data.slug ? 'data-active-id' : ''}}><span class="page-order">{{ page.order }}</span> {{ page.title|e }} <a href="{{ getPageUrl(page) }}"><i class="fa fa-external-link"></i></a></li>
<ul id="ordering" class="orderable {{ field.classes }}">
{% for page in siblings if page.order %}
<li class="drag-handle" data-id="{{ page.slug }}" {{ page.slug == data.slug ? 'data-active-id' : ''}}><span class="page-order">{{ page.order }}</span> {{ page.title|e }} <a href="{{ getPageUrl(page) }}"><i class="fa fa-external-link"></i></a></li>
{% set sortable_count = loop.index %}
{% endfor %}
</ul>
</ul>
{% if sortable_count < siblings|length %}
<label>{{ "PLUGIN_ADMIN.UNSORTABLE_PAGES"|tu }}</label>
<ul class="orderable disabled">
@@ -43,9 +46,10 @@
{% endfor %}
</ul>
{% endif %}
{% else %}
{% else %}
<div class="notice">{{ "PLUGIN_ADMIN.ORDERING_DISABLED_BECAUSE_TOO_MANY_SIBLINGS"|tu }}</div>
{% endif %}
{% endif %}
</div>
</div>
</div>
{% endblock %}

View File

@@ -1,3 +1,5 @@
{% extends "forms/field.html.twig" %}
{% set value = (value is null ? field.default : value) %}
{% set pagemedia = config.get('plugins.admin.pagemedia') %}
{% set pagemedia_settings = {
@@ -16,6 +18,7 @@
resizeQuality: pagemedia.resize_quality ?: 0.8
} %}
{% block field %}
{% if context.folderExists %}
<div class="form-field grid vertical {% if field.classes is defined %}{{ field.classes }}{% endif %}">
<div class="form-label">
@@ -47,3 +50,4 @@
</div>
</div>
{% endif %}
{% endblock %}

View File

@@ -1,3 +1,6 @@
{% extends "forms/field.html.twig" %}
{% block field %}
{% if field.security is empty or authorize(array(field.security)) %}
{% if field.title or field.underline %}
@@ -20,3 +23,4 @@
{% endif %}
{% endif %}
{% endblock %}

View File

@@ -1,7 +1,10 @@
{% extends "forms/field.html.twig" %}
{% block field %}
{% if field.fields %}
<div class="form-tab">
{% for childName, child in field.fields %}
{% if field.type %}
{% if child.type and not child.validate.ignore %}
{%- if childName starts with '.' -%}
{% set child = child|merge({ name: field.name ~ childName }) %}
{% endif %}
@@ -12,3 +15,4 @@
{% endfor %}
</div>
{% endif %}
{% endblock %}

View File

@@ -1,3 +1,6 @@
{% extends "forms/field.html.twig" %}
{% block field %}
<div class="form-tabs {{ field.class }} {{ field.classes }}">
{% if field.fields %}
@@ -18,7 +21,7 @@
<div class="tabs-nav">
{% for tab in field.fields %}
{% if tab.type == 'tab' and (tab.security is empty or authorize(array(tab.security))) %}
{% if tab.type == 'tab' and not tab.validate.ignore and (tab.security is empty or authorize(array(tab.security))) %}
<a class="tab__link {{ (storedTab == scope ~ tab.name) or active == loop.index ? 'active' : '' }}" data-tabid="tab-{{ tabsKey ~ loop.index }}" data-tabkey="tab-{{ tabsKey }}" data-scope="{{ scope ~ tab.name }}">
<span>
{% if grav.twig.twig.filters['tu'] is defined %}{{ tab.title|tu }}{% else %}{{ tab.title|t }}{% endif %}
@@ -28,12 +31,12 @@
{% endfor %}
</div>
<div class="tabs-content">
{% for field in field.fields %}
{% if field.type == 'tab' %}
{% if field.security is empty or authorize(array(field.security)) %}
{% set value = field.name ? data.value(field.name) : data.toArray %}
<div id="tab-{{ tabsKey ~ loop.index }}" class="tab__content {{ (storedTab == scope ~ field.name) or active == loop.index ? 'active' : '' }}">
{% include ["forms/fields/#{field.type}/#{field.type}.html.twig", 'forms/fields/text/text.html.twig'] %}
{% for child in field.fields %}
{% if child.type == 'tab' and not tab.validate.ignore %}
{% if child.security is empty or authorize(array(child.security)) %}
{% set value = child.name ? data.value(child.name) : data.toArray %}
<div id="tab-{{ tabsKey ~ loop.index }}" class="tab__content {{ (storedTab == scope ~ child.name) or active == loop.index ? 'active' : '' }}">
{% include ["forms/fields/#{child.type}/#{child.type}.html.twig", 'forms/fields/text/text.html.twig'] with {field: child} %}
</div>
{% endif %}
{% endif %}
@@ -41,4 +44,4 @@
</div>
{% endif %}
</div>
{% endblock %}

View File

@@ -1,3 +1,6 @@
{% extends "forms/field.html.twig" %}
{% block field %}
{% set taxonomies = (taxonomies is null ? (field.taxonomies ? field.taxonomies : admin.data('config/site').taxonomies) : taxonomies) %}
{% set parentname = field.name %}
{% set options = field.options %}
@@ -24,3 +27,4 @@
{% include ['forms/fields/select/select.html.twig'] %}
{% endfor %}
{% endblock %}

View File

@@ -1,3 +1,6 @@
{% extends "forms/field.html.twig" %}
{% block field %}
<div class="form-field grid user-details">
<div class="form-label block size-1-3">
{% include 'partials/userinfo-avatar.html.twig' %}
@@ -13,3 +16,4 @@
{% include 'partials/userinfo-avatar-credit.html.twig' %}
</div>
</div>
{% endblock %}