mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-04 20:36:03 +01:00
Moved plugins in admin to new GPM
This commit is contained in:
@@ -9,6 +9,7 @@ use Grav\Common\Uri;
|
|||||||
use Grav\Common\Page\Pages;
|
use Grav\Common\Page\Pages;
|
||||||
use Grav\Common\Page\Page;
|
use Grav\Common\Page\Page;
|
||||||
use Grav\Common\Data;
|
use Grav\Common\Data;
|
||||||
|
use Grav\Common\GPM\Local\Packages as LocalPackages;
|
||||||
use RocketTheme\Toolbox\File\File;
|
use RocketTheme\Toolbox\File\File;
|
||||||
use RocketTheme\Toolbox\File\LogFile;
|
use RocketTheme\Toolbox\File\LogFile;
|
||||||
use RocketTheme\Toolbox\File\YamlFile;
|
use RocketTheme\Toolbox\File\YamlFile;
|
||||||
@@ -63,6 +64,11 @@ class Admin
|
|||||||
*/
|
*/
|
||||||
public $user;
|
public $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Packages
|
||||||
|
*/
|
||||||
|
public $localPackages;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
@@ -282,9 +288,15 @@ class Admin
|
|||||||
*/
|
*/
|
||||||
public function themes()
|
public function themes()
|
||||||
{
|
{
|
||||||
|
if (!$this->localPackages) {
|
||||||
|
$this->localPackages = new LocalPackages();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->localPackages['themes']->toArray();
|
||||||
|
|
||||||
/** @var Themes $themes */
|
/** @var Themes $themes */
|
||||||
$themes = $this->grav['themes'];
|
/*$themes = $this->grav['themes'];
|
||||||
return $themes->all();
|
return $themes->all();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -306,9 +318,15 @@ class Admin
|
|||||||
*/
|
*/
|
||||||
public function plugins()
|
public function plugins()
|
||||||
{
|
{
|
||||||
|
if (!$this->localPackages) {
|
||||||
|
$this->localPackages = new LocalPackages();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->localPackages['plugins'];
|
||||||
|
|
||||||
/** @var Plugins $plugins */
|
/** @var Plugins $plugins */
|
||||||
$plugins = $this->grav['plugins'];
|
/*$plugins = $this->grav['plugins'];
|
||||||
return $plugins->all();
|
return $plugins->all();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -335,7 +353,7 @@ class Admin
|
|||||||
* @param integer $count number of pages to pull back
|
* @param integer $count number of pages to pull back
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function latestPages($count=10)
|
public function latestPages($count = 10)
|
||||||
{
|
{
|
||||||
/** @var Pages $pages */
|
/** @var Pages $pages */
|
||||||
$pages = $this->grav['pages'];
|
$pages = $this->grav['pages'];
|
||||||
@@ -348,7 +366,7 @@ class Admin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sort based on modified
|
// sort based on modified
|
||||||
uasort($latest, function($a, $b) {
|
uasort($latest, function ($a, $b) {
|
||||||
if ($a['modified'] == $b['modified']) {
|
if ($a['modified'] == $b['modified']) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -437,5 +455,4 @@ class Admin
|
|||||||
{
|
{
|
||||||
return dirname('/' . Grav::instance()['admin']->route);
|
return dirname('/' . Grav::instance()['admin']->route);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,18 +12,19 @@
|
|||||||
{% include 'partials/messages.html.twig' %}
|
{% include 'partials/messages.html.twig' %}
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
{% for plugin in admin.plugins %}
|
{% for slug, package in admin.plugins %}
|
||||||
{% set blueprints = plugin.blueprints() %}
|
{% set plugin = package.toArray() %}
|
||||||
|
{% set data = package.getData() %}
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ base_url_relative }}/plugins/{{ blueprints.name|url_encode }}">{{ blueprints.get('name') }}</a>
|
<a href="{{ base_url_relative }}/plugins/{{ slug|url_encode }}">{{ plugin.name }}</a>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<form action="{{ base_url_relative }}/plugins/{{ blueprints.name }}" method="post">
|
<form action="{{ base_url_relative }}/plugins/{{ slug }}" method="post">
|
||||||
<input type="hidden" name="enabled" value="{{ plugin.get('enabled') ? 0 : 1 }}" />
|
<input type="hidden" name="enabled" value="{{ plugin.get('enabled') ? 0 : 1 }}" />
|
||||||
<input type="hidden" name="_redirect" value="plugins" />
|
<input type="hidden" name="_redirect" value="plugins" />
|
||||||
<button class="button" name="task" value="enable"{{ blueprints.name == 'admin' ? ' disabled="disabled"' }}>
|
<button class="button" name="task" value="enable"{{ slug == 'admin' ? ' disabled="disabled"' }}>
|
||||||
{{ plugin.get('enabled') ? 'Enabled' : 'Disabled' }}
|
{{ plugin.get('enabled') ? 'Enabled' : 'Disabled' }}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
@@ -32,18 +33,24 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% set plugin = admin.plugins[admin.route] %}
|
{% set package = admin.plugins[admin.route] %}
|
||||||
{% set blueprints = plugin.blueprints() %}
|
{% set plugin = package.toArray() %}
|
||||||
|
|
||||||
|
|
||||||
<h1>
|
<h1>
|
||||||
{{ blueprints.get('name')|e }}
|
{{ plugin.name|e }}
|
||||||
<small>{{ blueprints.get('version') ? 'v' ~ blueprints.get('version')|e }}</small>
|
<small>{{ plugin.version ? 'v' ~ plugin.version|e }}</small>
|
||||||
|
{{ dump(plugin) }}
|
||||||
|
<small>{{ plugin.icon }}</small>
|
||||||
|
<small>{{ plugin.homepage }}</small>
|
||||||
|
<small>{{ plugin.author.name }}</small>
|
||||||
|
<small>{{ plugin.author.email }}</small>
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
{% include 'partials/messages.html.twig' %}
|
{% include 'partials/messages.html.twig' %}
|
||||||
<p>{{ blueprints.get('description') }}</p>
|
<p>{{ plugin.description }}</p>
|
||||||
|
|
||||||
{% include 'partials/blueprints.html.twig' with { data: plugin } %}
|
{% include 'partials/blueprints.html.twig' with { data: plugin.form, blueprints: plugin.form } %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user