1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-07 01:06:48 +02:00

[ticket/17283] Remove remaining parts using iconify

PHPBB3-17283
This commit is contained in:
Marc Alexander
2024-01-04 20:35:56 +01:00
parent 9af61c1f1e
commit db56017d57
19 changed files with 11 additions and 531 deletions

View File

@@ -13,8 +13,6 @@
namespace phpbb\template;
use phpbb\assets\iconify_bundler;
class assets_bag
{
/** @var asset[] */
@@ -23,17 +21,6 @@ class assets_bag
/** @var asset[] */
protected $scripts = [];
/** @var string[] */
protected $iconify_icons = [];
/**
* Constructor for assets bag
*
* @param iconify_bundler $iconify_bundler
*/
public function __construct(protected iconify_bundler $iconify_bundler)
{}
/**
* Add a css asset to the bag
*
@@ -54,30 +41,6 @@ class assets_bag
$this->scripts[] = $asset;
}
public function add_iconify_icon(string $icon): void
{
$this->iconify_icons[] = $icon;
}
/**
* Inject iconify icons into template
*
* @param string $output Output before injection
* @param string $variable_name Variable name for injection
* @param bool $use_cdn Flag whether to use CDN or local data
*
* @return string Output after injection
*/
public function inject_iconify_icons(string $output, string $variable_name, bool $use_cdn): string
{
if (str_contains($output, $variable_name))
{
$output = str_replace($variable_name, $use_cdn ? '' : $this->get_iconify_content(), $output);
}
return $output;
}
/**
* Returns all css assets
*
@@ -129,22 +92,4 @@ class assets_bag
return $output;
}
/**
* Gets the HTML code to include all iconify icons
*
* @return string HTML code for iconify bundle
*/
public function get_iconify_content(): string
{
$output = '';
if (count($this->iconify_icons))
{
$output .= '<script>';
$this->iconify_bundler->add_icons($this->iconify_icons);
$output .= $this->iconify_bundler->run();
$output .= '</script>';
}
return $output;
}
}

View File

@@ -211,7 +211,6 @@ class environment extends \Twig\Environment
{
$context['definition']->set('SCRIPTS', '__SCRIPTS_' . $placeholder_salt . '__');
$context['definition']->set('STYLESHEETS', '__STYLESHEETS_' . $placeholder_salt . '__');
$context['definition']->set('ICONIFY_ICONS', '__ICONIFY_ICONS_' . $placeholder_salt . '__');
}
/**
@@ -259,7 +258,6 @@ class environment extends \Twig\Environment
{
$output = str_replace('__STYLESHEETS_' . $placeholder_salt . '__', $this->assets_bag->get_stylesheets_content(), $output);
$output = str_replace('__SCRIPTS_' . $placeholder_salt . '__', $this->assets_bag->get_scripts_content(), $output);
$output = $this->assets_bag->inject_iconify_icons($output, '__ICONIFY_ICONS_' . $placeholder_salt . '__', $this->phpbb_config['allow_cdn']);
return $output;
}

View File

@@ -57,7 +57,7 @@ class icon extends AbstractExtension
* Generate icon HTML for use in the template, depending on the mode.
*
* @param environment $environment Twig environment object
* @param string $type Icon type (font|iconify|png|svg)
* @param string $type Icon type (font|png|svg)
* @param array|string $icon Icon name (eg. "bold")
* @param string $title Icon title
* @param bool $hidden Hide the icon title from view
@@ -86,13 +86,6 @@ class icon extends AbstractExtension
// Nothing to do here..
break;
case 'iconify':
$source = explode(':', $icon);
$source = $source[0];
$environment->get_assets_bag()->add_iconify_icon($icon);
break;
case 'png':
$filesystem = $environment->get_filesystem();
$root_path = $environment->get_web_root_path();
@@ -137,7 +130,6 @@ class icon extends AbstractExtension
default:
return '';
break;
}
// If no PNG or SVG icon was found, display a default 404 SVG icon.