mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-05-07 03:36:30 +02:00
Merge branch 'develop' into feature/translate-admin
This commit is contained in:
@@ -181,7 +181,6 @@ class Admin
|
||||
|
||||
$this->setMessage($this->translate('PLUGIN_ADMIN.LOGIN_LOGGED_IN'), 'info');
|
||||
|
||||
// $redirect_route =$this->getLoginRedirect() ?: $this->uri->route();
|
||||
$redirect_route = $this->uri->route();
|
||||
$grav->redirect($redirect_route);
|
||||
}
|
||||
@@ -557,9 +556,23 @@ class Admin
|
||||
if (isset($this->session->{$page->route()})) {
|
||||
// Found the type and header from the session.
|
||||
$data = $this->session->{$page->route()};
|
||||
$visible = isset($data['visible']) && $data['visible'] != '' ? (bool)$data['visible'] : $this->guessVisibility($page);
|
||||
|
||||
$header = ['title' => $data['title'], 'visible' => $visible];
|
||||
$header = ['title' => $data['title']];
|
||||
|
||||
if (isset($data['visible'])) {
|
||||
if ($data['visible'] == '' || $data['visible']) {
|
||||
// if auto (ie '')
|
||||
$children = $page->parent()->children();
|
||||
foreach ($children as $child) {
|
||||
if ($child->order()) {
|
||||
// set page order
|
||||
$page->order(1000);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($data['type'] == 'modular') {
|
||||
$header['body_classes'] = 'modular';
|
||||
@@ -582,25 +595,6 @@ class Admin
|
||||
return $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Guess the intended visibility status based on other sibling folders
|
||||
*
|
||||
* @param \Grav\Common\Page\Page $page
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function guessVisibility(Page $page)
|
||||
{
|
||||
$children = $page->parent()->children();
|
||||
foreach ($children as $child) {
|
||||
if ($child->order()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static helper method to return current route.
|
||||
*
|
||||
|
||||
@@ -819,6 +819,9 @@ class AdminController
|
||||
|
||||
$obj = $this->admin->page(true);
|
||||
$original_slug = $obj->slug();
|
||||
$original_order = intval(trim($obj->order(), '.'));
|
||||
|
||||
|
||||
|
||||
// Change parent if needed and initialize move (might be needed also on ordering/folder change).
|
||||
$obj = $obj->move($parent);
|
||||
@@ -829,20 +832,23 @@ class AdminController
|
||||
|
||||
$obj->validate();
|
||||
$obj->filter();
|
||||
$visible_after = $obj->visible();
|
||||
|
||||
// force reordering
|
||||
$reorder = true;
|
||||
|
||||
// rename folder based on visible
|
||||
if ($visible_after && !$obj->order()) {
|
||||
// needs to have order set
|
||||
$obj->order(1000);
|
||||
} elseif (!$visible_after && $obj->order()) {
|
||||
// needs to have order removed
|
||||
$obj->folder($obj->slug());
|
||||
if ($original_order == 1000) {
|
||||
// increment order to force reshuffle
|
||||
$obj->order($original_order + 1);
|
||||
}
|
||||
|
||||
// add or remove numeric prefix based on ordering value
|
||||
if (isset($data['ordering'])) {
|
||||
if ($data['ordering'] && !$obj->order()) {
|
||||
$obj->order(1001);
|
||||
} elseif (!$data['ordering'] && $obj->order()) {
|
||||
$obj->folder($obj->slug());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
// Handle standard data types.
|
||||
$obj = $this->prepareData();
|
||||
@@ -851,7 +857,7 @@ class AdminController
|
||||
}
|
||||
|
||||
if ($obj) {
|
||||
$obj->save($reorder);
|
||||
$obj->save(true);
|
||||
$this->admin->setMessage($this->admin->translate('PLUGIN_ADMIN.SUCCESSFULLY_SAVED'), 'info');
|
||||
}
|
||||
|
||||
@@ -868,8 +874,8 @@ class AdminController
|
||||
|
||||
// Always redirect if a page route was changed, to refresh it
|
||||
if ($obj instanceof Page\Page) {
|
||||
if (method_exists($obj, 'unsetRoute')) {
|
||||
$obj->unsetRoute();
|
||||
if (method_exists($obj, 'unsetRouteSlug')) {
|
||||
$obj->unsetRouteSlug();
|
||||
}
|
||||
$this->setRedirect($this->view . $obj->route());
|
||||
}
|
||||
@@ -1147,11 +1153,12 @@ class AdminController
|
||||
{
|
||||
$input = $this->post;
|
||||
|
||||
$order = max(0, (int) isset($input['order']) ? $input['order'] : $page->value('order'));
|
||||
$ordering = $order ? sprintf('%02d.', $order) : '';
|
||||
$slug = empty($input['folder']) ? $page->value('folder') : (string) $input['folder'];
|
||||
$page->folder($ordering . $slug);
|
||||
|
||||
if (isset($input['order'])) {
|
||||
$order = max(0, (int) isset($input['order']) ? $input['order'] : $page->value('order'));
|
||||
$ordering = $order ? sprintf('%02d.', $order) : '';
|
||||
$slug = empty($input['folder']) ? $page->value('folder') : (string) $input['folder'];
|
||||
$page->folder($ordering . $slug);
|
||||
}
|
||||
|
||||
if (isset($input['type']) && !empty($input['type'])) {
|
||||
$type = (string) strtolower($input['type']);
|
||||
@@ -1176,14 +1183,20 @@ class AdminController
|
||||
|
||||
foreach($header as $key => $value) {
|
||||
if ($key == 'metadata') {
|
||||
foreach($header['metadata'] as $key2 => $value2) {
|
||||
foreach ($header['metadata'] as $key2 => $value2) {
|
||||
if (isset($input['toggleable_header']['metadata'][$key2]) && !$input['toggleable_header']['metadata'][$key2]) {
|
||||
$header['metadata'][$key2] = '';
|
||||
}
|
||||
}
|
||||
} elseif ($key == 'taxonomy') {
|
||||
foreach ($header[$key] as $taxkey => $taxonomy) {
|
||||
if (is_array($taxonomy) && count($taxonomy) == 1 && trim($taxonomy[0]) == '') {
|
||||
unset($header[$key][$taxkey]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isset($input['toggleable_header'][$key]) && !$input['toggleable_header'][$key]) {
|
||||
$header[$key] = '';
|
||||
$header[$key] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -743,6 +743,7 @@ tbody {
|
||||
|
||||
.gpm-details {
|
||||
width: 100%;
|
||||
-webkit-flex: auto;
|
||||
flex: auto; }
|
||||
|
||||
td {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -232,8 +232,21 @@ $(function () {
|
||||
element.find('i').addClass('fa-spin');
|
||||
GPMRefresh({
|
||||
flush: true,
|
||||
callback: function() {
|
||||
callback: function(response) {
|
||||
var payload = response.status == 'success' ? response.payload : false;
|
||||
element.find('i').removeClass('fa-spin');
|
||||
|
||||
if (payload) {
|
||||
if (!payload.grav.isUpdatable && !payload.resources.total) {
|
||||
toastr.success('Everything is up to date!');
|
||||
} else {
|
||||
var grav = payload.grav.isUpdatable ? 'Grav v' + payload.grav.available : '',
|
||||
resources = payload.resources.total ? payload.resources.total + ' updates are available' : '';
|
||||
|
||||
if (!resources) { grav += ' is available for update' }
|
||||
toastr.info(grav + (grav && resources ? ' and ' : '') + resources);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -373,7 +386,7 @@ $(function () {
|
||||
}
|
||||
}
|
||||
|
||||
if (options.callback && typeof options.callback == 'function') options.callback();
|
||||
if (options.callback && typeof options.callback == 'function') options.callback(response);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -6,6 +6,7 @@ tbody {
|
||||
|
||||
.gpm-details {
|
||||
width: 100%;
|
||||
-webkit-flex: auto;
|
||||
flex: auto;
|
||||
}
|
||||
|
||||
@@ -54,7 +55,7 @@ tr {
|
||||
line-height: 1;
|
||||
text-align: right;
|
||||
position: relative;
|
||||
|
||||
|
||||
.gpm-details-expand {
|
||||
position: absolute;
|
||||
top: 12px;
|
||||
|
||||
@@ -22,11 +22,15 @@
|
||||
<span class="note">Page is not visible, ordering disabled</span>
|
||||
{% endif %}
|
||||
|
||||
<ul id="ordering" class="{{ field.classes }}">
|
||||
{% for page in siblings %}
|
||||
<li class="{% if page.order == value %}drag-handle{% else %}ignore{% endif %}" data-id="{{ page.slug }}">{{ page.title() }}</li>
|
||||
{% if siblings|length < 200 %}
|
||||
<ul id="ordering" class="{{ field.classes }}">
|
||||
{% for page in siblings %}
|
||||
<li class="{% if page.order == value %}drag-handle{% else %}ignore{% endif %}" data-id="{{ page.slug }}">{{ page.title() }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</ul>
|
||||
{% else %}
|
||||
<span class="note">Ordering via the admin is unsupported because there are more than 200 siblings</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="{{ base_url_relative_frontend }}{{ theme_url }}/js/sortable.min.js"></script>
|
||||
|
||||
@@ -22,15 +22,19 @@
|
||||
{% set id = "toggle_" ~ field.name ~ key %}
|
||||
|
||||
<input type="radio"
|
||||
value="{{ key }}"
|
||||
id="{{ id }}"
|
||||
name="{{ (scope ~ field.name)|fieldName }}"
|
||||
{% if field.highlight is defined %}
|
||||
class="{{ field.highlight == '' ~ key ? 'highlight' : '' }}"
|
||||
{% endif %}
|
||||
{% if '' ~ key == '' ~ value %}checked="checked" {% endif %}
|
||||
{% if value is defined and (key == 1 or key == '1') %}checked="checked" {% endif %}
|
||||
{% if field.validate.required in ['on', 'true', 1] %}required="required"{% endif %}
|
||||
value="{{ key }}"
|
||||
id="{{ id }}"
|
||||
name="{{ (scope ~ field.name)|fieldName }}"
|
||||
{% if field.highlight is defined %}
|
||||
class="{{ field.highlight == '' ~ key ? 'highlight' : '' }}"
|
||||
{% endif %}
|
||||
{% if field.toggleable %}
|
||||
{% if '' ~ key == '' ~ value %}checked="checked" {% endif %}
|
||||
{% if value is defined and (key == 1 or key == '1') %}checked="checked" {% endif %}
|
||||
{% else %}
|
||||
{% if '' ~ key == '' ~ value %}checked="checked" {% endif %}
|
||||
{% endif %}
|
||||
{% if field.validate.required in ['on', 'true', 1] %}required="required"{% endif %}
|
||||
/>
|
||||
<label for="{{ id }}">{{ text }}</label>
|
||||
{% endfor %}
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
{% set preview_link = '<a class="preview" href="'~ base_url_relative_frontend ~ (context.home ? '' : context.route) ~'"><i class="fa fa-fw fa-angle-double-right"></i></a>' %}
|
||||
|
||||
{% macro loop(page, base_url, depth, warn) %}
|
||||
{% macro loop(page, base_url, depth, warn, separator) %}
|
||||
{% for p in page.children() %}
|
||||
{% set description = (not p.page ? 'Folder • ' : 'Page • ') ~
|
||||
(p.modular ? 'Modular • ' : '') ~
|
||||
@@ -54,17 +54,17 @@
|
||||
<span class="page-home">{{ p.home ? '<i class="fa fa-home"></i>' }}</span>
|
||||
<span class="page-tools">
|
||||
{% if warn %}
|
||||
<a href="#delete" data-remodal-target="delete" data-delete-url="{{ base_url }}/pages/{{ p.route|trim('/') }}/task{{ config.system.param_sep }}delete" class="page-delete" ><i class="fa fa-close"></i></a>
|
||||
<a href="#delete" data-remodal-target="delete" data-delete-url="{{ base_url }}/pages/{{ p.route|trim('/') }}/task{{ separator }}delete" class="page-delete" ><i class="fa fa-close"></i></a>
|
||||
{% else %}
|
||||
<a href="{{ base_url }}/pages/{{ p.route|trim('/') }}/task{{ config.system.param_sep }}delete" class="page-delete" ><i class="fa fa-close"></i></a>
|
||||
<a href="{{ base_url }}/pages/{{ p.route|trim('/') }}/task{{ separator }}delete" class="page-delete" ><i class="fa fa-close"></i></a>
|
||||
{% endif %}
|
||||
</span>
|
||||
<p class="page-route">{{ p.route }}</p>
|
||||
</div>
|
||||
{% if p.children().count > 0 and not p.modular() %}
|
||||
{% if p.children().count > 0 %}
|
||||
|
||||
<ul class="depth-{{ depth + 1 }}" style="display:none;">
|
||||
{{ _self.loop(p, base_url, depth + 1, warn) }}
|
||||
{{ _self.loop(p, base_url, depth + 1, warn, separator) }}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</li>
|
||||
@@ -158,7 +158,7 @@
|
||||
</div>
|
||||
</form>
|
||||
<ul class="pages-list depth-0">
|
||||
{{ _self.loop(pages, base_url_relative, 0, warn) }}
|
||||
{{ _self.loop(pages, base_url_relative, 0, warn, config.system.param_sep) }}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
{% if config.plugins.admin.show_beta_msg %}
|
||||
<div class="notice alert"><i class="fa fa-github"></i> <a href="https://github.com/getgrav/grav-plugin-admin/issues">{{ 'PLUGIN_ADMIN.ADMIN_REPORT_ISSUE'|tu }}</a></div>
|
||||
<div class="notice alert"><i class="fa fa-github"></i> <a href="https://github.com/getgrav/grav-plugin-admin/issues" target="_blank">{{ 'PLUGIN_ADMIN.ADMIN_REPORT_ISSUE'|tu }}</a></div>
|
||||
{% endif %}
|
||||
{% block content_bottom %}{% endblock %}
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{% if user.exists %}
|
||||
<div class="user-details">
|
||||
<img src="http://www.gravatar.com/avatar/{{ user.email|md5 }}?s=128" />
|
||||
<p class="gravatar">Avatar by <a href="http://gravatar.com" target="_blank">gravatar.com</a></p>
|
||||
<h2>{{ user.fullname }}</h2>
|
||||
{% if user.title %}<h5>{{ user.title }}</h5>{% endif %}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user