mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-01 10:56:08 +01:00
[WORK IN PROGRESS] First draft of a Tools menu with direct install (#990)
* First draft of a Tools menu with direct install * Basic styling * Translate GPM messages * Basic frontend validation * Fix form action path * Added lang strings for offical_gpm_only toggle
This commit is contained in:
committed by
Andy Miller
parent
c473a8db84
commit
c7256134ba
@@ -184,6 +184,18 @@ class Admin
|
||||
return $configurations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the tools found
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function tools()
|
||||
{
|
||||
$tools = [];
|
||||
$event = Grav::instance()->fireEvent('onAdminTools', new Event(['tools' => &$tools]));
|
||||
return $tools;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the languages available in the site
|
||||
*
|
||||
@@ -365,8 +377,10 @@ class Admin
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function translate($args, $languages = null)
|
||||
public static function translate($args, $languages = null)
|
||||
{
|
||||
$grav = Grav::instance();
|
||||
|
||||
if (is_array($args)) {
|
||||
$lookup = array_shift($args);
|
||||
} else {
|
||||
@@ -375,7 +389,7 @@ class Admin
|
||||
}
|
||||
|
||||
if (!$languages) {
|
||||
$languages = [$this->grav['user']->authenticated ? $this->grav['user']->language : 'en'];
|
||||
$languages = [$grav['user']->authenticated ? $grav['user']->language : 'en'];
|
||||
} else {
|
||||
$languages = (array)$languages;
|
||||
}
|
||||
@@ -383,25 +397,25 @@ class Admin
|
||||
|
||||
if ($lookup) {
|
||||
if (empty($languages) || reset($languages) == null) {
|
||||
if ($this->grav['config']->get('system.languages.translations_fallback', true)) {
|
||||
$languages = $this->grav['language']->getFallbackLanguages();
|
||||
if ($grav['config']->get('system.languages.translations_fallback', true)) {
|
||||
$languages = $grav['language']->getFallbackLanguages();
|
||||
} else {
|
||||
$languages = (array)$this->grav['language']->getDefault();
|
||||
$languages = (array)$grav['language']->getDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ((array)$languages as $lang) {
|
||||
$translation = $this->grav['language']->getTranslation($lang, $lookup);
|
||||
$translation = $grav['language']->getTranslation($lang, $lookup);
|
||||
|
||||
if (!$translation) {
|
||||
$language = $this->grav['language']->getDefault() ?: 'en';
|
||||
$translation = $this->grav['language']->getTranslation($language, $lookup);
|
||||
$language = $grav['language']->getDefault() ?: 'en';
|
||||
$translation = $grav['language']->getTranslation($language, $lookup);
|
||||
}
|
||||
|
||||
if (!$translation) {
|
||||
$language = 'en';
|
||||
$translation = $this->grav['language']->getTranslation($language, $lookup);
|
||||
$translation = $grav['language']->getTranslation($language, $lookup);
|
||||
}
|
||||
|
||||
if ($translation) {
|
||||
|
||||
Reference in New Issue
Block a user