mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-03 11:55:52 +01:00
- Add locator where need.
- Fix the switch expert/normal issue into pages edit panel. - Set default page mode to normal.
This commit is contained in:
@@ -129,7 +129,7 @@ class AdminPlugin extends Plugin
|
|||||||
$home = '/' . trim($this->config->get('system.home.alias'), '/');
|
$home = '/' . trim($this->config->get('system.home.alias'), '/');
|
||||||
|
|
||||||
// set the default if not set before
|
// set the default if not set before
|
||||||
$this->session->expert = $this->session->expert ?: true;
|
$this->session->expert = $this->session->expert ?: false;
|
||||||
|
|
||||||
// set session variable if it's passed via the url
|
// set session variable if it's passed via the url
|
||||||
if ($this->uri->param('mode') == 'expert') {
|
if ($this->uri->param('mode') == 'expert') {
|
||||||
@@ -143,12 +143,16 @@ class AdminPlugin extends Plugin
|
|||||||
|
|
||||||
$this->grav['admin']->routes = $pages->routes();
|
$this->grav['admin']->routes = $pages->routes();
|
||||||
|
|
||||||
|
// Remove default route from routes.
|
||||||
|
if (isset($this->grav['admin']->routes[$this->grav['config']->get('system.home.alias')])) {
|
||||||
|
unset($this->grav['admin']->routes[$this->grav['config']->get('system.home.alias')]);
|
||||||
|
}
|
||||||
|
|
||||||
$pages->dispatch('/', true)->route($home);
|
$pages->dispatch('/', true)->route($home);
|
||||||
|
|
||||||
// Make local copy of POST.
|
// Make local copy of POST.
|
||||||
$post = !empty($_POST) ? $_POST : array();
|
$post = !empty($_POST) ? $_POST : array();
|
||||||
|
|
||||||
|
|
||||||
// Handle tasks.
|
// Handle tasks.
|
||||||
$this->admin->task = $task = !empty($post['task']) ? $post['task'] : $this->uri->param('task');
|
$this->admin->task = $task = !empty($post['task']) ? $post['task'] : $this->uri->param('task');
|
||||||
if ($task) {
|
if ($task) {
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ class Admin
|
|||||||
public function authenticate($form)
|
public function authenticate($form)
|
||||||
{
|
{
|
||||||
if (!$this->user->authenticated && isset($form['username']) && isset($form['password'])) {
|
if (!$this->user->authenticated && isset($form['username']) && isset($form['password'])) {
|
||||||
$file = CompiledYamlFile::instance(ACCOUNTS_DIR . $form['username'] . YAML_EXT);
|
$file = CompiledYamlFile::instance($this->grav['locator']->findResource('account://' . $form['username'] . YAML_EXT));
|
||||||
if ($file->exists()) {
|
if ($file->exists()) {
|
||||||
$user = new User($file->content());
|
$user = new User($file->content());
|
||||||
$user->authenticated = true;
|
$user->authenticated = true;
|
||||||
@@ -198,7 +198,7 @@ class Admin
|
|||||||
public function blueprints($type)
|
public function blueprints($type)
|
||||||
{
|
{
|
||||||
if ($this->blueprints === null) {
|
if ($this->blueprints === null) {
|
||||||
$this->blueprints = new Data\Blueprints(SYSTEM_DIR . '/blueprints/');
|
$this->blueprints = new Data\Blueprints(ROOT_DIR . 'system/blueprints/');
|
||||||
}
|
}
|
||||||
return $this->blueprints->get($type);
|
return $this->blueprints->get($type);
|
||||||
}
|
}
|
||||||
@@ -231,7 +231,7 @@ class Admin
|
|||||||
$config = $this->grav['config'];
|
$config = $this->grav['config'];
|
||||||
$obj = new Data\Data($config->get('system'), $blueprints);
|
$obj = new Data\Data($config->get('system'), $blueprints);
|
||||||
$obj->merge($post);
|
$obj->merge($post);
|
||||||
$file = CompiledYamlFile::instance(USER_DIR . "config/{$type}.yaml");
|
$file = CompiledYamlFile::instance($this->grav['locator']->findResource("user://config/{$type}.yaml"));
|
||||||
$obj->file($file);
|
$obj->file($file);
|
||||||
$data[$type] = $obj;
|
$data[$type] = $obj;
|
||||||
break;
|
break;
|
||||||
@@ -243,7 +243,7 @@ class Admin
|
|||||||
$config = $this->grav['config'];
|
$config = $this->grav['config'];
|
||||||
$obj = new Data\Data($config->get('site'), $blueprints);
|
$obj = new Data\Data($config->get('site'), $blueprints);
|
||||||
$obj->merge($post);
|
$obj->merge($post);
|
||||||
$file = CompiledYamlFile::instance(USER_DIR . "config/{$type}.yaml");
|
$file = CompiledYamlFile::instance($this->grav['locator']->findResource("user://config/{$type}.yaml"));
|
||||||
$obj->file($file);
|
$obj->file($file);
|
||||||
$data[$type] = $obj;
|
$data[$type] = $obj;
|
||||||
break;
|
break;
|
||||||
@@ -350,7 +350,7 @@ class Admin
|
|||||||
public function logs()
|
public function logs()
|
||||||
{
|
{
|
||||||
if (!isset($this->logs)) {
|
if (!isset($this->logs)) {
|
||||||
$file = LogFile::instance(LOG_DIR . 'exception.log');
|
$file = LogFile::instance($this->grav['locator']->findResource('log://exception.log'));
|
||||||
|
|
||||||
$content = $file->content();
|
$content = $file->content();
|
||||||
|
|
||||||
@@ -405,7 +405,7 @@ class Admin
|
|||||||
*/
|
*/
|
||||||
public function logEntry()
|
public function logEntry()
|
||||||
{
|
{
|
||||||
$file = File::instance(LOG_DIR . $this->route . '.html');
|
$file = File::instance($this->grav['locator']->findResource("log://{$this->route}.html"));
|
||||||
$content = $file->content();
|
$content = $file->content();
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
|
|||||||
@@ -122,7 +122,7 @@
|
|||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if admin.session.expert == '1' %}
|
{% if admin.session.expert == '0' %}
|
||||||
{% include 'partials/blueprints-raw.html.twig' with { blueprints: admin.blueprints('pages/'~modular~'raw'), data: context } %}
|
{% include 'partials/blueprints-raw.html.twig' with { blueprints: admin.blueprints('pages/'~modular~'raw'), data: context } %}
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|||||||
Reference in New Issue
Block a user