Skip to content

Commit e063879

Browse files
authored
Merge pull request #12 from GreenMeteor/develop
Develop
2 parents 79a6782 + 6c72f07 commit e063879

4 files changed

Lines changed: 41 additions & 9 deletions

File tree

components/HtmlParser.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace humhub\modules\codebox\components;
4+
5+
use yii\base\Component;
6+
7+
class HtmlParser extends Component
8+
{
9+
private $html;
10+
11+
public function __construct($html, $config = [])
12+
{
13+
$this->html = $html;
14+
parent::__construct($config);
15+
}
16+
17+
public function render()
18+
{
19+
// Render the HTML content as-is
20+
return $this->html;
21+
}
22+
}

docs/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
# Changelogs
2+
3+
### Release v1.2.2 (*7/10/2024*)
4+
- Enh: New HTML Parser class
5+
- Enh: Display render of HTML widgets in settings
6+
27
### Release v1.2.1 (*5/13/2024*)
38
- Fix: Unknown Property: humhub\modules\codebox\Module::isEnabled
49

module.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "codebox",
3-
"version": "1.2.1",
3+
"version": "1.2.2",
44
"name": "Codebox",
55
"description": "Allows you to add and use HTML snippets on your Dashboard sidebar.",
66
"humhub": {

views/admin/_view.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?php
22

3-
use yii\helpers\Html;
43
use yii\helpers\Url;
4+
use yii\helpers\Html;
5+
use humhub\modules\codebox\components\HtmlParser;
56

67
/* @var $this yii\web\View */
7-
/* @var $model app\models\ConfigureForm */
8+
/* @var $model \humhub\modules\codebox\models\ConfigureForm */
89

910
// Generate unique IDs for panel menu and panel content
1011
$panelMenuId = 'panel-menu-' . $model->id;
@@ -16,39 +17,43 @@
1617
1718
$('#panel-heading-$model->id').hover(
1819
function() {
19-
clearTimeout(timer); // Clear the collapse timer
20+
clearTimeout(timer);
2021
$('#panel-content-$model->id').collapse('show');
2122
},
2223
function() {
2324
timer = setTimeout(function() {
2425
$('#panel-content-$model->id').collapse('hide');
25-
}, 500); // Adjust the delay time as needed (in milliseconds)
26+
}, 500);
2627
}
2728
);
2829
2930
// Keep the panel content open when hovering over it
3031
$('#panel-content-$model->id').hover(
3132
function() {
32-
clearTimeout(timer); // Clear the collapse timer
33+
clearTimeout(timer);
3334
},
3435
function() {
3536
timer = setTimeout(function() {
3637
$('#panel-content-$model->id').collapse('hide');
37-
}, 500); // Adjust the delay time as needed (in milliseconds)
38+
}, 500);
3839
}
3940
);
4041
});
4142
JS;
4243
$this->registerJs($js);
4344

45+
// Instantiate HtmlParser and render the HTML code
46+
$htmlParser = new HtmlParser($model->htmlCode);
47+
$renderedHtml = $htmlParser->render();
48+
4449
?>
4550
<div class="col-md-6">
4651
<div class="panel panel-default">
4752
<div class="panel-heading" id="panel-heading-<?= $model->id ?>">
4853
<?= Html::encode($model->title) ?>
4954
</div>
5055
<div class="panel-body collapse" id="<?= $panelContentId ?>">
51-
<?= Html::encode($model->htmlCode) ?>
56+
<?= $renderedHtml ?>
5257
<br>
5358
<div class="form-group">
5459
<?= Html::a(Yii::t('CodeboxModule.base', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary btn-sm', 'data-toggle' => 'modal', 'data-target' => '#globalModal']); ?>
@@ -60,4 +65,4 @@ function() {
6065
</div>
6166
</div>
6267
</div>
63-
</div>
68+
</div>

0 commit comments

Comments
 (0)