Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add XMPP Block option #810

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/Models/LinkType.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public static function get()
'heading',
'spacer',
'text',
'xmpp',
];

$sorted = $linkTypes->sortBy(function ($item) use ($custom_order) {
Expand Down
30 changes: 30 additions & 0 deletions assets/linkstack/icons/xmpp.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions blocks/xmpp/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
id: 6
typename: xmpp
icon: "fa fa-xmpp"
custom_html: false
23 changes: 23 additions & 0 deletions blocks/xmpp/form.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php use App\Models\Button; $button = Button::find($button_id); if(isset($button->name)){$buttonName = $button->name;}else{$buttonName = 0;} ?>

<select style="display:none" name="button" class="form-control"><option class="button button-default email" value="default xmpp">{{__('messages.Default XMPP')}}</option></select>

<label for='title' class='form-label'>{{__('messages.Custom Title')}}</label>
<input type='text' name='title' value='{{$title}}' class='form-control' />
<span class='small text-muted'>{{__('messages.Leave blank for default title')}}</span><br>

<label for='link' class='form-label'>{{__('messages.XMPP address')}}</label>
<input type='email' name='link' value='{{str_replace("xmpp:", "", $link)}}' class='form-control' required />
<span class='small text-muted'>{{__('messages.Enter your XMPP')}}</span>

<script>
$(document).ready(function() {
$('form').on('submit', function(e) {
var linkInput = $(this).find('input[name="link"]');
var linkValue = linkInput.val();
if (!linkValue.toLowerCase().startsWith('xmpp:')) {
linkInput.val('xmpp:' + linkValue);
}
});
});
</script>
19 changes: 19 additions & 0 deletions blocks/xmpp/handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/**
* Handles the logic for "xmpp" link type.
*
* @param \Illuminate\Http\Request $request The incoming request.
* @param mixed $linkType The link type information.
* @return array The prepared link data.
*/
function handleLinkType($request, $linkType) {
// Prepare the link data
$linkData = [
'title' => $request->title,
'button_id' => "6",
'link' => $request->link,
];

return $linkData;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
var $TableName = 'link_types';
public function up()
{
DB::table($this->TableName)->updateOrInsert([
'typename' => 'xmpp',
'title' => 'xmpp',
'icon' => 'fa fa-xmpp',
'description' => 'Add a xmpp address that opens a system dialog'
]);
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
};
8 changes: 8 additions & 0 deletions database/seeders/ButtonSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,14 @@ public function run()
"mb" => false,
],

[
"name" => "xmpp",
"alt" => "XMPP",
"exclude" => false,
"group" => "default",
"mb" => false,
],

];

Button::insert($buttons);
Expand Down
4 changes: 4 additions & 0 deletions resources/lang/en/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,9 @@
'block.title.text' => 'Text',
'block.description.text' => 'Add static text to your page that is not clickable.',

'block.title.xmpp' => 'XMPP address',
'block.description.xmpp' => 'Add an XMPP address that opens a system dialog.',


/*
|--------------------------------------------------------------------------
Expand All @@ -911,6 +914,7 @@
'Leave blank for default title' => 'Leave blank for default title',
'E-Mail address' => 'E-Mail address',
'Enter your E-Mail' => 'Enter your E-Mail',
'Enter your XMPP' => 'Enter your XMPP',

'Heading Text:' => 'Heading Text:',

Expand Down
6 changes: 6 additions & 0 deletions resources/views/components/pageitems/xmpp-display.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

<a class="button button-{{ $params->button }} button button-hover icon-hover" rel="noopener noreferrer nofollow" href="{{ route('clickNumber') . '/' . $link->id . '/' . $link->link}}" @if(theme('open_links_in_same_tab') !="true" )target="_blank" @endif>
<img alt="button-icon" class="icon hvr-icon" src="@if(theme('use_custom_icons') == " true"){{ url('themes/' . $GLOBALS['themeName'] . '/extra/custom-icons')}}/{{$params->button}}{{theme('custom_icon_extension')}} @else{{ asset('\/assets/linkstack/icons\/') . $params->button }}.svg @endif">

{{ ucfirst($link->title) }}
</a>
2 changes: 1 addition & 1 deletion resources/views/studio/edit-link.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function submitFormWithParam(paramValue) {
@foreach ($LinkTypes as $lt)
@php
if(block_text_translation_check($lt['title'])) {$title = bt($lt['title']);} else {$title = __('messages.block.title.'.$lt['typename']);}
$description = bt($lt['description']) ?? __('messages.block.description.'.$lt['typename']);
$description = bt($lt['description']) ?? __('messages.block.description.'.$lt['typename']);
@endphp
<a href="#" data-dismiss="modal" data-typeid="{{$lt['typename']}}" data-typename="{{$title}}" class="hvr-grow m-2 w-100 d-block doSelectLinkType">
<div class="rounded mb-3 shadow-lg">
Expand Down
Loading