-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1153 from proditis/issue-1151
Add support for dynamic menus fixes #1151
- Loading branch information
Showing
9 changed files
with
151 additions
and
9 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
backend/migrations/m240418_224927_update_existing_discord_link_entries.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
use yii\db\Migration; | ||
|
||
/** | ||
* Class m240418_224927_update_existing_discord_link_entries | ||
*/ | ||
class m240418_224927_update_existing_discord_link_entries extends Migration | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function safeUp() | ||
{ | ||
if(Yii::$app->sys->discord_invite_url!==false && Yii::$app->sys->discord_invite_url!=="") | ||
{ | ||
$link=json_encode([ | ||
[ | ||
'name'=>'<i class="fab fa-discord text-discord"></i><p class="text-discord">Join our Discord!</p>', | ||
'link'=>Yii::$app->sys->discord_invite_url | ||
] | ||
]); | ||
$this->update('sysconfig',['val'=>$link,'id'=>'menu_items'],['id'=>'discord_invite_url']); | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function safeDown() | ||
{ | ||
echo "m240418_224927_update_existing_discord_link_entries cannot be reverted.\n"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Menu items allow you to add entries to the frontend menu. | ||
|
||
These support full HTML mode so that you can add icons and | ||
other details that may be needed by some special cases. | ||
|
||
The two fields are: | ||
* **Link name**: The name that will be displayed for the entry. (eg. `<i class="fab fa-discord text-discord"></i><p class="text-discord">Join our Discord!</p>`) | ||
* **URL**: An optional url that we will link to for this entry (eg. `http://example.com/`) | ||
|
||
|
||
**WARNING:** There is no validation performed to the fields. Be careful not to break the frontend HTML. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
use yii\helpers\Html; | ||
|
||
use yii\widgets\ActiveForm; | ||
|
||
/* @var $this yii\web\View */ | ||
/* @var $model app\modules\settings\models\Sysconfig */ | ||
|
||
$this->title='Update '.$model->id; | ||
$this->params['breadcrumbs'][]=ucfirst(Yii::$app->controller->module->id); | ||
$this->params['breadcrumbs'][]=$model->id; | ||
yii\bootstrap5\Modal::begin([ | ||
'title' => '<h2><i class="bi bi-info-circle-fill"></i> '.Html::encode($this->title).' Help</h2>', | ||
'toggleButton' => ['label' => '<i class="bi bi-info-circle-fill"></i> Help','class'=>'btn btn-info'], | ||
]); | ||
echo yii\helpers\Markdown::process($this->render('help/'.$this->context->action->id), 'gfm'); | ||
yii\bootstrap5\Modal::end(); | ||
|
||
?> | ||
<div class="sysconfig-update"> | ||
|
||
<h1><?= Html::encode($this->title) ?></h1> | ||
|
||
<?= Html::beginForm([''], 'POST') ?> | ||
<div class="hint-block"><?=$hint?></div> | ||
<?php | ||
try { | ||
$i=0; | ||
foreach(json_decode($model->val,true) as $i => $item) { | ||
echo '<div class="row">'; | ||
echo '<div class="col">',Html::label('Link name', "item[$i][name]", ['class' => 'label name']); | ||
echo Html::input('text',"item[$i][name]",$item['name'], ['class'=>'form-control','style'=>"font-family:monospace;"]); | ||
echo '<div class="hint-block">Update existing or delete link.</div></div>',"\n"; | ||
|
||
echo '<div class="col">',Html::label('URL', "item[$i][link]", ['class' => 'label link']); | ||
echo Html::input('text',"item[$i][link]",$item['link'], ['class'=>'form-control','style'=>"font-family:monospace;"]); | ||
echo '<div class="hint-block">Update or delete URL.</div></div>',"\n"; | ||
echo '</div><hr/>',"\n"; | ||
} | ||
} | ||
catch(\TypeError $e) {} | ||
?> | ||
<div class="row"> | ||
<div class="col"> | ||
<label class="label name" for="item[<?=intval($i)+1;?>][name]">Link name</label> | ||
<input type="text" name="item[<?=intval($i)+1;?>][name]" class='form-control' style="font-family:monospace;" placeholder="<?=htmlentities('<i class="fab fa-discord text-discord"></i><p class="text-discord">Join our Discord!</p>')?>"> | ||
<div class="hint-block">Enter your desired html code to be displayed as link.</div> | ||
</div> | ||
<div class="col"> | ||
<label class="label link" for="item[<?=intval($i)+1;?>][link]">Link name</label> | ||
<input type="text" name="item[<?=intval($i)+1;?>][link]" class='form-control' style="font-family:monospace;" placeholder="https://example.com/"> | ||
<div class="hint-block">Optionally enter a URL for the menu item to point.</div> | ||
</div> | ||
|
||
</div> | ||
<div class="row"> | ||
<div class="form-group"> | ||
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?> | ||
</div> | ||
</div> | ||
<?= Html::endForm(); ?> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters