Add Footer Block options to make_block
This commit is contained in:
parent
19d77064b0
commit
efb2a51216
9 changed files with 185 additions and 12 deletions
|
|
@ -34,3 +34,8 @@ func (blocks *Blocks) Create(ctx context.Context, server *phpx.Server, block Blo
|
|||
err = blocks.Dependencies.PHP.ExecScript(ctx, server, nil, blocksPHP, "create_basic_block", block.Info, block.Content, block.Region, block.BlockID)
|
||||
return err
|
||||
}
|
||||
|
||||
func (blocks *Blocks) GetFooterRegion(ctx context.Context, server *phpx.Server) (region string, err error) {
|
||||
err = blocks.Dependencies.PHP.ExecScript(ctx, server, ®ion, blocksPHP, "get_footer_region")
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,4 +33,33 @@ function create_basic_block(string $info, string $html, string $region, string $
|
|||
'weight' => 0,
|
||||
]);
|
||||
$block->save();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** get_footer_region returns the region that implements the footer */
|
||||
function get_footer_region(): string {
|
||||
$footer_block_map = [
|
||||
"teriyaki" => "footer_bottom",
|
||||
"olivero" => "footer_bottom",
|
||||
"bartik" => "footer_fifth",
|
||||
"ffbartik" => "footer_fifth",
|
||||
"dxpr_theme" => "footer",
|
||||
"bootstrap" => "footer",
|
||||
"bootstrap4" => "footer",
|
||||
"bootstrap5" => "footer",
|
||||
"bootstrap_for_drupal" => "footer_sub_center",
|
||||
"bootstrap_for_drupal_subtheme" => "footer_sub_center",
|
||||
"roma_theme" => "footer_fifth",
|
||||
"gnm2018" => "footer",
|
||||
"oin_graphik" => "footer",
|
||||
"oin_paleo" => "footer",
|
||||
"oin_projekt" => "footer",
|
||||
];
|
||||
|
||||
$theme = \Drupal::service('theme.manager')->getActiveTheme();
|
||||
if (!$theme) {
|
||||
return "";
|
||||
}
|
||||
return $footer_block_map[$theme->getName()] ?? ""; // return the theme
|
||||
}
|
||||
41
internal/wisski/ingredient/php/extras/theme.go
Normal file
41
internal/wisski/ingredient/php/extras/theme.go
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
package extras
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/phpx"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/status"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/php"
|
||||
|
||||
_ "embed"
|
||||
)
|
||||
|
||||
// Prefixes implements reading and writing prefix
|
||||
type Theme struct {
|
||||
ingredient.Base
|
||||
Dependencies struct {
|
||||
PHP *php.PHP
|
||||
}
|
||||
}
|
||||
|
||||
//go:embed theme.php
|
||||
var themePHP string
|
||||
|
||||
// Get returns the currently active theme
|
||||
func (t *Theme) Get(ctx context.Context, server *phpx.Server) (theme string, err error) {
|
||||
err = t.Dependencies.PHP.ExecScript(
|
||||
ctx, server, &theme, themePHP,
|
||||
"get_active_theme",
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
func (t *Theme) Fetch(flags ingredient.FetcherFlags, info *status.WissKI) (err error) {
|
||||
if flags.Quick {
|
||||
return
|
||||
}
|
||||
|
||||
info.Theme, _ = t.Get(flags.Context, flags.Server)
|
||||
return
|
||||
}
|
||||
14
internal/wisski/ingredient/php/extras/theme.php
Normal file
14
internal/wisski/ingredient/php/extras/theme.php
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Gets the actve theme of this WissKI
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_active_theme(): string {
|
||||
$theme = \Drupal::service('theme.manager')->getActiveTheme();
|
||||
if (!$theme) {
|
||||
return "";
|
||||
}
|
||||
return $theme->getName();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue