Skip to content

Commit

Permalink
Add HTML entity support for the components properties (#1075)
Browse files Browse the repository at this point in the history
* [src/Components]: Add HTML entity support for components properties.

* [src/Components]: Fix code style.
  • Loading branch information
dfsmania committed Mar 14, 2022
1 parent ca44b87 commit ad59de6
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 20 deletions.
17 changes: 17 additions & 0 deletions src/Helpers/UtilsHelper.php
@@ -0,0 +1,17 @@
<?php

namespace JeroenNoten\LaravelAdminLte\Helpers;

class UtilsHelper
{
/**
* Apply an HTML entity decoder to the specified string.
*
* @param string $value
* @return string
*/
public static function applyHtmlEntityDecoder($value)
{
return isset($value) ? html_entity_decode($value) : $value;
}
}
3 changes: 2 additions & 1 deletion src/View/Components/Form/Button.php
Expand Up @@ -3,6 +3,7 @@
namespace JeroenNoten\LaravelAdminLte\View\Components\Form;

use Illuminate\View\Component;
use JeroenNoten\LaravelAdminLte\Helpers\UtilsHelper;

class Button extends Component
{
Expand Down Expand Up @@ -44,7 +45,7 @@ class Button extends Component
public function __construct(
$label = null, $type = 'button', $theme = 'default', $icon = null
) {
$this->label = $label;
$this->label = UtilsHelper::applyHtmlEntityDecoder($label);
$this->type = $type;
$this->theme = $theme;
$this->icon = $icon;
Expand Down
3 changes: 2 additions & 1 deletion src/View/Components/Form/InputGroupComponent.php
Expand Up @@ -3,6 +3,7 @@
namespace JeroenNoten\LaravelAdminLte\View\Components\Form;

use Illuminate\View\Component;
use JeroenNoten\LaravelAdminLte\Helpers\UtilsHelper;

class InputGroupComponent extends Component
{
Expand Down Expand Up @@ -97,7 +98,7 @@ public function __construct(
) {
$this->id = $id ?? $name;
$this->name = $name;
$this->label = $label;
$this->label = UtilsHelper::applyHtmlEntityDecoder($label);
$this->size = $igroupSize;
$this->fgroupClass = $fgroupClass;
$this->labelClass = $labelClass;
Expand Down
5 changes: 3 additions & 2 deletions src/View/Components/Form/Options.php
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Support\Arr;
use Illuminate\View\Component;
use JeroenNoten\LaravelAdminLte\Helpers\UtilsHelper;

class Options extends Component
{
Expand Down Expand Up @@ -65,8 +66,8 @@ public function __construct(
$this->selected = Arr::wrap($selected);
$this->disabled = Arr::wrap($disabled);
$this->strict = isset($strict);
$this->emptyOption = $emptyOption;
$this->placeholder = $placeholder;
$this->emptyOption = UtilsHelper::applyHtmlEntityDecoder($emptyOption);
$this->placeholder = UtilsHelper::applyHtmlEntityDecoder($placeholder);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/View/Components/Tool/Modal.php
Expand Up @@ -3,6 +3,7 @@
namespace JeroenNoten\LaravelAdminLte\View\Components\Tool;

use Illuminate\View\Component;
use JeroenNoten\LaravelAdminLte\Helpers\UtilsHelper;

class Modal extends Component
{
Expand Down Expand Up @@ -90,7 +91,7 @@ public function __construct(
$disableAnimations = null
) {
$this->id = $id;
$this->title = $title;
$this->title = UtilsHelper::applyHtmlEntityDecoder($title);
$this->icon = $icon;
$this->size = $size;
$this->theme = $theme;
Expand Down
3 changes: 2 additions & 1 deletion src/View/Components/Widget/Alert.php
Expand Up @@ -3,6 +3,7 @@
namespace JeroenNoten\LaravelAdminLte\View\Components\Widget;

use Illuminate\View\Component;
use JeroenNoten\LaravelAdminLte\Helpers\UtilsHelper;

class Alert extends Component
{
Expand Down Expand Up @@ -61,7 +62,7 @@ public function __construct(
) {
$this->theme = $theme;
$this->icon = $icon;
$this->title = $title;
$this->title = UtilsHelper::applyHtmlEntityDecoder($title);
$this->dismissable = $dismissable;

// When a theme is provided, use the default theme icon if no other
Expand Down
3 changes: 2 additions & 1 deletion src/View/Components/Widget/Callout.php
Expand Up @@ -3,6 +3,7 @@
namespace JeroenNoten\LaravelAdminLte\View\Components\Widget;

use Illuminate\View\Component;
use JeroenNoten\LaravelAdminLte\Helpers\UtilsHelper;

class Callout extends Component
{
Expand Down Expand Up @@ -45,7 +46,7 @@ public function __construct(
) {
$this->theme = $theme;
$this->icon = $icon;
$this->title = $title;
$this->title = UtilsHelper::applyHtmlEntityDecoder($title);
$this->titleClass = $titleClass;
}

Expand Down
3 changes: 2 additions & 1 deletion src/View/Components/Widget/Card.php
Expand Up @@ -3,6 +3,7 @@
namespace JeroenNoten\LaravelAdminLte\View\Components\Widget;

use Illuminate\View\Component;
use JeroenNoten\LaravelAdminLte\Helpers\UtilsHelper;

class Card extends Component
{
Expand Down Expand Up @@ -103,7 +104,7 @@ public function __construct(
$disabled = null, $collapsible = null, $removable = null,
$maximizable = null
) {
$this->title = $title;
$this->title = UtilsHelper::applyHtmlEntityDecoder($title);
$this->icon = $icon;
$this->theme = $theme;
$this->themeMode = $themeMode;
Expand Down
7 changes: 4 additions & 3 deletions src/View/Components/Widget/InfoBox.php
Expand Up @@ -3,6 +3,7 @@
namespace JeroenNoten\LaravelAdminLte\View\Components\Widget;

use Illuminate\View\Component;
use JeroenNoten\LaravelAdminLte\Helpers\UtilsHelper;

class InfoBox extends Component
{
Expand Down Expand Up @@ -76,10 +77,10 @@ public function __construct(
$theme = null, $iconTheme = null, $progress = null,
$progressTheme = 'white'
) {
$this->title = $title;
$this->text = $text;
$this->title = UtilsHelper::applyHtmlEntityDecoder($title);
$this->text = UtilsHelper::applyHtmlEntityDecoder($text);
$this->icon = $icon;
$this->description = $description;
$this->description = UtilsHelper::applyHtmlEntityDecoder($description);
$this->theme = $theme;
$this->iconTheme = $iconTheme;
$this->progress = $progress;
Expand Down
5 changes: 3 additions & 2 deletions src/View/Components/Widget/ProfileColItem.php
Expand Up @@ -3,6 +3,7 @@
namespace JeroenNoten\LaravelAdminLte\View\Components\Widget;

use Illuminate\View\Component;
use JeroenNoten\LaravelAdminLte\Helpers\UtilsHelper;

class ProfileColItem extends Component
{
Expand Down Expand Up @@ -61,8 +62,8 @@ public function __construct(
$title = null, $text = null, $icon = null, $size = 4,
$badge = null, $url = null
) {
$this->title = $title;
$this->text = $text;
$this->title = UtilsHelper::applyHtmlEntityDecoder($title);
$this->text = UtilsHelper::applyHtmlEntityDecoder($text);
$this->icon = $icon;
$this->size = $size;
$this->badge = $badge;
Expand Down
5 changes: 3 additions & 2 deletions src/View/Components/Widget/ProfileRowItem.php
Expand Up @@ -3,6 +3,7 @@
namespace JeroenNoten\LaravelAdminLte\View\Components\Widget;

use Illuminate\View\Component;
use JeroenNoten\LaravelAdminLte\Helpers\UtilsHelper;

class ProfileRowItem extends Component
{
Expand Down Expand Up @@ -61,8 +62,8 @@ public function __construct(
$title = null, $text = null, $icon = null, $size = 12,
$badge = null, $url = null
) {
$this->title = $title;
$this->text = $text;
$this->title = UtilsHelper::applyHtmlEntityDecoder($title);
$this->text = UtilsHelper::applyHtmlEntityDecoder($text);
$this->icon = $icon;
$this->size = $size;
$this->badge = $badge;
Expand Down
5 changes: 3 additions & 2 deletions src/View/Components/Widget/ProfileWidget.php
Expand Up @@ -3,6 +3,7 @@
namespace JeroenNoten\LaravelAdminLte\View\Components\Widget;

use Illuminate\View\Component;
use JeroenNoten\LaravelAdminLte\Helpers\UtilsHelper;

class ProfileWidget extends Component
{
Expand Down Expand Up @@ -74,8 +75,8 @@ public function __construct(
$name = null, $desc = null, $img = null, $theme = null, $cover = null,
$headerClass = null, $footerClass = null, $layoutType = 'modern'
) {
$this->name = $name;
$this->desc = $desc;
$this->name = UtilsHelper::applyHtmlEntityDecoder($name);
$this->desc = UtilsHelper::applyHtmlEntityDecoder($desc);
$this->img = $img;
$this->theme = $theme;
$this->cover = $cover;
Expand Down
7 changes: 4 additions & 3 deletions src/View/Components/Widget/SmallBox.php
Expand Up @@ -3,6 +3,7 @@
namespace JeroenNoten\LaravelAdminLte\View\Components\Widget;

use Illuminate\View\Component;
use JeroenNoten\LaravelAdminLte\Helpers\UtilsHelper;

class SmallBox extends Component
{
Expand Down Expand Up @@ -67,12 +68,12 @@ public function __construct(
$title = null, $text = null, $icon = null, $theme = null,
$url = null, $urlText = null, $loading = null
) {
$this->title = $title;
$this->text = $text;
$this->title = UtilsHelper::applyHtmlEntityDecoder($title);
$this->text = UtilsHelper::applyHtmlEntityDecoder($text);
$this->icon = $icon;
$this->theme = $theme;
$this->url = $url;
$this->urlText = $urlText;
$this->urlText = UtilsHelper::applyHtmlEntityDecoder($urlText);
$this->loading = $loading;
}

Expand Down

0 comments on commit ad59de6

Please sign in to comment.