mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-10-30 01:36:27 +01:00
Merge branch 'develop' into feature/integrate-with-admin-pro
This commit is contained in:
50
CHANGELOG.md
50
CHANGELOG.md
@@ -1,3 +1,53 @@
|
||||
# v1.0.0-rc.4
|
||||
## 10/29/2015
|
||||
|
||||
1. [](#improved)
|
||||
* Changed admin menu event hook to `onAdminMenu()`
|
||||
* Minor improvements for admin page location
|
||||
* Additional lang strings for Grav 1.0.0-rc.3
|
||||
|
||||
# v1.0.0-rc.3
|
||||
## 10/27/2015
|
||||
|
||||
1. [](#improved)
|
||||
* Rely on context-language for active language
|
||||
* Improved some Russian translations
|
||||
* Only show login if not already logged in
|
||||
1. [](#bugfix)
|
||||
* Disable asset pipeline in admin only
|
||||
* Fix Editor cursor insertion point when text is selected in some actions
|
||||
|
||||
# v1.0.0-rc.2
|
||||
## 10/23/2015
|
||||
|
||||
1. [](#bugfix)
|
||||
* Reverted lang redirect code. Needs to be reworked to be more reliable
|
||||
|
||||
# v1.0.0-rc.1
|
||||
## 10/23/2015
|
||||
|
||||
1. [](#new)
|
||||
* Redirect to non-language URL except for `pages/`
|
||||
1. [](#improved)
|
||||
* New language strings for new `system.yaml` fields
|
||||
* Improved Russian translations
|
||||
* Improved compatibility with PECL Yaml parser
|
||||
1. [](#bugfix)
|
||||
* Redirect to correct page if you change folder/slug
|
||||
* Fix issue with Asset pipeline not being disabled in admin
|
||||
* Fix for HTML in text input fields
|
||||
* Fixed various icons in headers
|
||||
|
||||
# v0.6.2
|
||||
## 10/15/2015
|
||||
|
||||
1. [](#improved)
|
||||
* Use `title` rather than `menu` in Page listing
|
||||
* Wrapped language strings in double-quotes
|
||||
* New language strings for new fields
|
||||
1. [](#bugfix)
|
||||
* Fixed issue with IE not able to save pages
|
||||
|
||||
# v0.6.1
|
||||
## 10/07/2015
|
||||
|
||||
|
||||
39
admin.php
39
admin.php
@@ -3,6 +3,7 @@ namespace Grav\Plugin;
|
||||
|
||||
use Grav\Common\GPM\GPM;
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Common\Language\Language;
|
||||
use Grav\Common\Page\Page;
|
||||
use Grav\Common\Page\Pages;
|
||||
use Grav\Common\Plugin;
|
||||
@@ -103,6 +104,10 @@ class AdminPlugin extends Plugin
|
||||
if ($this->active) {
|
||||
$this->grav['debugger']->addMessage("Admin Basic");
|
||||
$this->initializeAdmin();
|
||||
|
||||
// Disable Asset pipelining
|
||||
$this->config->set('system.assets.css_pipeline', false);
|
||||
$this->config->set('system.assets.js_pipeline', false);
|
||||
}
|
||||
|
||||
// We need popularity no matter what
|
||||
@@ -127,10 +132,6 @@ class AdminPlugin extends Plugin
|
||||
// Set original route for the home page.
|
||||
$home = '/' . trim($this->config->get('system.home.alias'), '/');
|
||||
|
||||
// Disable Asset pipelining
|
||||
$this->config->set('system.assets.css_pipeline', false);
|
||||
$this->config->set('system.assets.js_pipeline', false);
|
||||
|
||||
// set the default if not set before
|
||||
$this->session->expert = $this->session->expert ?: false;
|
||||
|
||||
@@ -195,17 +196,15 @@ class AdminPlugin extends Plugin
|
||||
$plugins = Grav::instance()['config']->get('plugins', []);
|
||||
|
||||
foreach($plugins as $plugin => $data) {
|
||||
$folder = GRAV_ROOT . "/user/plugins/" . $plugin . "/admin";
|
||||
$path = $this->grav['locator']->findResource(
|
||||
"user://plugins/{$plugin}/admin/pages/{$self->template}.md");
|
||||
|
||||
if (file_exists($folder)) {
|
||||
$file = $folder . "/pages/{$self->template}.md";
|
||||
if (file_exists($file)) {
|
||||
$page->init(new \SplFileInfo($file));
|
||||
if (file_exists($path)) {
|
||||
$page->init(new \SplFileInfo($path));
|
||||
$page->slug(basename($self->template));
|
||||
return $page;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -237,14 +236,17 @@ class AdminPlugin extends Plugin
|
||||
$twig->twig_vars['location'] = $this->template;
|
||||
$twig->twig_vars['base_url_relative_frontend'] = $twig->twig_vars['base_url_relative'] ?: '/';
|
||||
$twig->twig_vars['admin_route'] = trim($this->config->get('plugins.admin.route'), '/');
|
||||
$twig->twig_vars['base_url_relative'] .=
|
||||
($twig->twig_vars['base_url_relative'] != '/' ? '/' : '') . $twig->twig_vars['admin_route'];
|
||||
$twig->twig_vars['base_url_relative'] =
|
||||
$twig->twig_vars['base_url_simple'] . '/' . $twig->twig_vars['admin_route'];
|
||||
$twig->twig_vars['theme_url'] = '/user/plugins/admin/themes/' . $this->theme;
|
||||
$twig->twig_vars['base_url'] = $twig->twig_vars['base_url_relative'];
|
||||
$twig->twig_vars['base_path'] = GRAV_ROOT;
|
||||
$twig->twig_vars['admin'] = $this->admin;
|
||||
|
||||
// Gather Plugin-hooked nav items
|
||||
$this->grav->fireEvent('onAdminMenu');
|
||||
|
||||
// DEPRECATED
|
||||
$this->grav->fireEvent('onAdminTemplateNavPluginHook');
|
||||
|
||||
switch ($this->template) {
|
||||
@@ -293,6 +295,7 @@ class AdminPlugin extends Plugin
|
||||
switch ($action) {
|
||||
case 'getUpdates':
|
||||
$resources_updates = $gpm->getUpdatable();
|
||||
if ($gpm->grav != null) {
|
||||
$grav_updates = [
|
||||
"isUpdatable" => $gpm->grav->isUpdatable(),
|
||||
"assets" => $gpm->grav->getAssets(),
|
||||
@@ -306,6 +309,9 @@ class AdminPlugin extends Plugin
|
||||
"status" => "success",
|
||||
"payload" => ["resources" => $resources_updates, "grav" => $grav_updates, "installed" => $gpm->countInstalled(), 'flushed' => $flush]
|
||||
]);
|
||||
} else {
|
||||
echo json_encode(["status" => "error", "message" => "Cannot connect to the GPM"]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
@@ -346,8 +352,6 @@ class AdminPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Decide admin template and route.
|
||||
$path = trim(substr($this->uri->route(), strlen($this->base)), '/');
|
||||
$this->template = 'dashboard';
|
||||
@@ -358,6 +362,13 @@ class AdminPlugin extends Plugin
|
||||
$this->route = array_shift($array);
|
||||
}
|
||||
|
||||
/** @var Language $language */
|
||||
// $require_language = ['pages', 'translations'];
|
||||
// $language = $this->grav['language'];
|
||||
// if ($language->isLanguageInUrl() && !in_array($this->template, $require_language)) {
|
||||
// $this->grav->redirect($this->uri->route());
|
||||
// }
|
||||
|
||||
// Initialize admin class.
|
||||
require_once __DIR__ . '/classes/admin.php';
|
||||
$this->admin = new Admin($this->grav, $this->base, $this->template, $this->route);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: Admin Panel
|
||||
version: 0.6.1
|
||||
version: 1.0.0-rc.4
|
||||
description: Adds an advanced administration panel to manage your site
|
||||
icon: empire
|
||||
author:
|
||||
|
||||
@@ -1014,8 +1014,10 @@ class AdminController
|
||||
$obj->language($this->grav['session']->admin_lang);
|
||||
}
|
||||
}
|
||||
$admin_route = $this->grav['config']->get('plugins.admin.route');
|
||||
$redirect_url = '/' . ($multilang ? ($obj->language()) : '') . $admin_route . '/' . $this->view . $obj->route();
|
||||
|
||||
$this->setRedirect('/' . ($multilang ? ($obj->language()) : '') . $this->grav['uri']->route());
|
||||
$this->setRedirect($redirect_url);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
4546
languages.yaml
4546
languages.yaml
File diff suppressed because it is too large
Load Diff
@@ -333,18 +333,17 @@
|
||||
});
|
||||
};
|
||||
|
||||
this.replaceSelection = function(replace) {
|
||||
this.replaceSelection = function(replace, action) {
|
||||
|
||||
var text = this.editor.getSelection(),
|
||||
indexOf = -1;
|
||||
|
||||
if (!text.length) {
|
||||
|
||||
var cur = this.editor.getCursor(),
|
||||
indexOf = -1,
|
||||
cur = this.editor.getCursor(),
|
||||
curLine = this.editor.getLine(cur.line),
|
||||
start = cur.ch,
|
||||
end = start;
|
||||
|
||||
if (!text.length) {
|
||||
|
||||
while (end < curLine.length && /[\w$]+/.test(curLine.charAt(end))) ++end;
|
||||
while (start && /[\w$]+/.test(curLine.charAt(start - 1))) --start;
|
||||
|
||||
@@ -361,11 +360,18 @@
|
||||
var html = replace.replace('$1', text);
|
||||
|
||||
this.editor.replaceSelection(html, 'end');
|
||||
if (indexOf !== -1) this.editor.setCursor({ line: cur.line, ch: start + indexOf });
|
||||
if (indexOf !== -1) {
|
||||
this.editor.setCursor({ line: cur.line, ch: start + indexOf });
|
||||
} else {
|
||||
if (action == 'link' || action == 'image') {
|
||||
this.editor.setCursor({ line: cur.line, ch: html.length -1 });
|
||||
}
|
||||
}
|
||||
|
||||
this.editor.focus();
|
||||
};
|
||||
|
||||
this.replaceLine = function(replace) {
|
||||
this.replaceLine = function(replace, action) {
|
||||
var pos = this.editor.getDoc().getCursor(),
|
||||
text = this.editor.getLine(pos.line),
|
||||
html = replace.replace('$1', text);
|
||||
@@ -510,7 +516,7 @@
|
||||
function addAction(name, replace, mode) {
|
||||
editor.element.on('action.'+name, function() {
|
||||
if (editor.getCursorMode() == 'markdown') {
|
||||
editor[mode == 'replaceLine' ? 'replaceLine' : 'replaceSelection'](replace);
|
||||
editor[mode == 'replaceLine' ? 'replaceLine' : 'replaceSelection'](replace, name);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
<input
|
||||
{# required attribute structures #}
|
||||
name="{{ (scope ~ field.name)|fieldName }}"
|
||||
value="{{ value|join(', ') }}"
|
||||
value="{{ value|e('html_attr')|join(', ') }}"
|
||||
{# input attribute structures #}
|
||||
{% block input_attributes %}
|
||||
{% if field.classes is defined %}class="{{ field.classes }}" {% endif %}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<div class="button-bar">
|
||||
<a class="button" href="{{ base_url }}"><i class="fa fa-reply"></i> {{ "PLUGIN_ADMIN.BACK"|tu }}</a>
|
||||
</div>
|
||||
<h1><i class="fa fa-fw fa-th"></i> {{ "PLUGIN_ADMIN.CONFIGURATION"|tu }} - {{ "PLUGIN_ADMIN.PHP_INFO"|tu }}</h1>
|
||||
<h1><i class="fa fa-fw fa-wrench"></i> {{ "PLUGIN_ADMIN.CONFIGURATION"|tu }} - {{ "PLUGIN_ADMIN.PHP_INFO"|tu }}</h1>
|
||||
{% endblock %}
|
||||
|
||||
{% block content_top %}
|
||||
|
||||
@@ -13,8 +13,12 @@
|
||||
{% if notAuthorized %}
|
||||
<a class="button secondary" onclick="window.history.back()"><i class="fa fa-reply"></i> {{ 'PLUGIN_ADMIN.BACK'|tu }}</a>
|
||||
{% else %}
|
||||
{% if not authenticated %}
|
||||
<a class="button secondary" href="{{ base_url_relative }}/forgot"><i class="fa fa-exclamation-circle"></i> {{ 'PLUGIN_ADMIN.LOGIN_BTN_FORGOT'|tu }}</a>
|
||||
<button type="submit" class="button primary" name="task" value="login"><i class="fa fa-sign-in"></i> {{ 'PLUGIN_ADMIN.LOGIN_BTN'|tu }}</button>
|
||||
{% else %}
|
||||
<button type="submit" class="button primary" name="task" value="logout"><i class="fa fa-sign-in"></i> {{ 'PLUGIN_ADMIN.LOGOUT'|tu }}</button>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<a class="button" href="{{ base_url }}"><i class="fa fa-reply"></i> {{ "PLUGIN_ADMIN.BACK"|tu }}</a>
|
||||
<button class="button" type="submit" name="task" value="save" form="blueprints"><i class="fa fa-check"></i> Save</button>
|
||||
</div>
|
||||
<h1><i class="fa fa-fw fa-th"></i> {{ "PLUGIN_ADMIN.CONFIGURATION"|tu }} - {{ "PLUGIN_ADMIN.SITE"|tu }}</h1>
|
||||
<h1><i class="fa fa-fw fa-wrench"></i> {{ "PLUGIN_ADMIN.CONFIGURATION"|tu }} - {{ "PLUGIN_ADMIN.SITE"|tu }}</h1>
|
||||
{% endblock %}
|
||||
|
||||
{% block content_top %}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<a class="button" href="{{ base_url }}"><i class="fa fa-reply"></i> {{ "PLUGIN_ADMIN.BACK"|tu }}</a>
|
||||
<button class="button" type="submit" name="task" value="save" form="blueprints"><i class="fa fa-check"></i> {{ "PLUGIN_ADMIN.SAVE"|tu }}</button>
|
||||
</div>
|
||||
<h1><i class="fa fa-fw fa-th"></i> {{ "PLUGIN_ADMIN.CONFIGURATION"|tu }} - {{ "PLUGIN_ADMIN.SYSTEM"|tu }}</h1>
|
||||
<h1><i class="fa fa-fw fa-wrench"></i> {{ "PLUGIN_ADMIN.CONFIGURATION"|tu }} - {{ "PLUGIN_ADMIN.SYSTEM"|tu }}</h1>
|
||||
{% endblock %}
|
||||
|
||||
{% block content_top %}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
<h1><i class="fa fa-fw fa-plug"></i> {{ "PLUGIN_ADMIN.THEMES"|tu }}</h1>
|
||||
<h1><i class="fa fa-fw fa-tint"></i> {{ "PLUGIN_ADMIN.THEMES"|tu }}</h1>
|
||||
{% else %}
|
||||
{% if (installed) %}
|
||||
<div class="button-bar">
|
||||
|
||||
Reference in New Issue
Block a user