Added new blocks:

- E-Mail Block
- Telephone number Block
This commit is contained in:
Julian Prieber 2023-03-05 20:02:42 +01:00
parent 35d26c51e2
commit 7aea53e0b8
8 changed files with 102 additions and 36 deletions

View File

@ -116,6 +116,8 @@ class UserController extends Controller
if ($id !== 0) {
$linkData = Link::find($id);
} elseif ($id == 0) {
$linkData = new Link(['typename' => 'link', 'id'=>'0']);
} else {
$linkData = new Link(['typename' => 'link', 'id'=>'0']);
}
@ -138,6 +140,10 @@ class UserController extends Controller
$data['linkTypeID'] = "4";
} elseif ($bid == 93) {
$data['linkTypeID'] = "5";
} elseif ($bid == 6 or $bid == 7) {
$data['linkTypeID'] = "6";
} elseif ($bid == 44) {
$data['linkTypeID'] = "7";
} else {
$data['linkTypeID'] = "1";
}
@ -158,18 +164,6 @@ class UserController extends Controller
//Save add link
public function saveLink(request $request)
{
// if ($request->button == 'heading' or $request->button == 'space')
// $request->validate([
// 'link' => '',
// 'title' => '',
// 'button' => 'required'
// ]);
// else
// $request->validate([
// 'link' => 'required',
// 'title' => '',
// 'button' => 'required'
// ]);
$linkType = LinkType::find($request->linktype_id);
$LinkTitle = ($request->link_text ?? $request->link_title) ?? $request->title;
@ -178,19 +172,6 @@ class UserController extends Controller
$OrigLink = Link::find($request->linkid);
// if (stringStartsWith($LinkURL, 'http://') == 'true' or stringStartsWith($LinkURL, 'https://') == 'true')
// $link1 = $LinkURL;
// elseif (!empty($LinkURL))
// $link1 = 'https://' . $LinkURL;
// if (stringEndsWith($LinkURL, '/') == 'true')
// $link = rtrim($link1, "/ ");
// else
// $link = $link1;
$customParams = [];
foreach ($request->all() as $key => $param) {
//echo $key . " = " . $param . "<br />";
@ -250,6 +231,20 @@ class UserController extends Controller
'button_id' => "93",
'title' => $request->text,
]);
}elseif($linkType->typename == "email"){
$LinkURL = "mailto:".$LinkURL;
$OrigLink->update([
'link' => $LinkURL,
'button_id' => $button?->id,
'title' => $LinkTitle,
]);
}elseif($linkType->typename == "telephone"){
$LinkURL = "tel:".$LinkURL;
$OrigLink->update([
'link' => $LinkURL,
'button_id' => $button?->id,
'title' => $LinkTitle,
]);
}else{
$OrigLink->update([
'link' => $LinkURL,
@ -259,6 +254,7 @@ class UserController extends Controller
}
$message .="updated";
} else {
// ADDING NEW
@ -284,11 +280,16 @@ class UserController extends Controller
}elseif($linkType->typename == "text"){
$links->button_id = "93";
$links->title = $request->text;
}elseif($linkType->typename == "email"){
$links->link = "mailto:".$links->link;
$links->button_id = $button?->id;
}elseif($linkType->typename == "telephone"){
$links->link = "tel:".$links->link;
$links->button_id = $button?->id;
}else{
$links->button_id = $button?->id;
}
// $links->type_params = json_encode($customParams);
// $links->typename = $linkType->typename;
$links->save();
$links->order = ($links->id - 1);
@ -299,8 +300,6 @@ class UserController extends Controller
return Redirect('studio/links')
->with('success', $message);
// echo $customParams['GetSiteIcon'];
}
public function sortLinks(Request $request)
@ -467,7 +466,7 @@ class UserController extends Controller
if (stringEndsWith($request->link, '/') == 'true')
$link = rtrim($link1, "/ ");
else
$link = $link1;
$link = $link1;
$title = $request->title;
$order = $request->order;
$button = $request->button;

View File

@ -97,7 +97,7 @@ class LinkType extends Migration
'typename' => 'heading',
'title' => 'Heading',
'icon' => 'bi bi-card-heading',
'description' => 'Use headings to organize your links and separate them into groups',
'description' => 'Use headings to organize your links and separate them into groups.',
'params' => '[{
"tag": "input",
"id": "heading-text",
@ -113,7 +113,7 @@ class LinkType extends Migration
'typename' => 'spacer',
'title' => 'Spacer',
'icon' => 'bi bi-distribute-vertical',
'description' => 'Add blank space to your list of links. You can choose how big. ',
'description' => 'Add blank space to your list of links. You can choose how tall.',
'params' => '[
{
"tag": "input",
@ -181,6 +181,21 @@ class LinkType extends Migration
]'
]);
DB::table($this->TableName)->updateOrInsert([
'typename' => 'email',
'title' => 'E-Mail address',
'icon' => 'bi bi-envelope-fill',
'description' => 'Add an email that opens a system dialog to compose a new email.'
]);
DB::table($this->TableName)->updateOrInsert([
'typename' => 'telephone',
'title' => 'Telephone number',
'icon' => 'bi bi-telephone-fill',
'description' => 'Add a telephone number that opens a system dialog to initiate a phone call.'
]);
}
}

View File

@ -123,6 +123,20 @@ use Illuminate\Support\Facades\File;
}
]'
]);
DB::table('link_types')->updateOrInsert([
'typename' => 'email',
'title' => 'E-Mail address',
'icon' => 'bi bi-envelope-fill',
'description' => 'Add an email that opens a system dialog to compose a new email.'
]);
DB::table('link_types')->updateOrInsert([
'typename' => 'telephone',
'title' => 'Telephone number',
'icon' => 'bi bi-telephone-fill',
'description' => 'Add a telephone number that opens a system dialog to initiate a phone call.'
]);
} catch (exception $e) {}

View File

@ -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('\/littlelink/icons\/') . $params->button }}.svg @endif">
{{ ucfirst($link->title) }}
</a>

View File

@ -0,0 +1,12 @@
<?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 email">Default Email</option></select>
<label for='title' class='form-label'>Custom Title</label>
<input type='text' name='title' value='{{$link_title}}' class='form-control' />
<span class='small text-muted'>Leave blank for default title</span><br>
<label for='link' class='form-label'>E-Mail address</label>
<input type='email' name='link' value='{{str_replace("mailto:", "", $link_url)}}' class='form-control' required />
<span class='small text-muted'>Enter your E-Mail</span>

View File

@ -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('\/littlelink/icons\/') . $params->button }}.svg @endif">
{{ ucfirst($link->title) }}
</a>

View File

@ -0,0 +1,12 @@
<?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="phone">Phone</option></select>
<label for='title' class='form-label'>Custom Title</label>
<input type='text' name='title' value='{{$link_title}}' class='form-control' />
<span class='small text-muted'>Leave blank for default title</span><br>
<label for='link' class='form-label'>Telephone number</label>
<input type='tel' name='link' value='{{str_replace("tel:", "", $link_url)}}' class='form-control' required />
<span class='small text-muted'>Enter your telephone number</span>

View File

@ -311,12 +311,14 @@ function get_operating_system() {
<?php function strp($urlStrp){return str_replace(array('http://', 'https://'), '', $urlStrp);} ?>
<?php $initial=1; // <-- Effectively sets the initial loading time of the buttons. This value should be left at 1. ?>
@foreach($links as $link)
@php $linkName = str_replace('default ','',strtolower($link->title)) @endphp
@php $linkName = str_replace('default ','',strtolower($link->title)) @endphp
@if($link->name === "icon")
@elseif($link->button_id === 0)
<div style="--delay: {{ $initial++ }}s" class="button-entrance"><a class="button button-title 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 >{{ $link->title }}</a></div>
@elseif($link->name === "phone")
<div style="--delay: {{ $initial++ }}s" class="button-entrance"><a class="button button-default button button-hover icon-hover" rel="noopener noreferrer nofollow" href="{{ $link->link }}"><img alt="button-icon" class="icon hvr-icon" src="@if(theme('use_custom_icons') == "true"){{ url('themes/' . $GLOBALS['themeName'] . '/extra/custom-icons')}}/phone{{theme('custom_icon_extension')}} @else{{ asset('\/littlelink/icons\/')}}phone.svg @endif"></i>{{ $link->title }}</a></div>
<div style="--delay: {{ $initial++ }}s" class="button-entrance"><a class="button button-default button button-hover icon-hover" rel="noopener noreferrer nofollow" href="{{ route('clickNumber') . '/' . $link->id . "?" . $link->link }}"><img alt="button-icon" class="icon hvr-icon" src="@if(theme('use_custom_icons') == "true"){{ url('themes/' . $GLOBALS['themeName'] . '/extra/custom-icons')}}/phone{{theme('custom_icon_extension')}} @else{{ asset('\/littlelink/icons\/')}}phone.svg @endif"></i>{{ $link->title }}</a></div>
@elseif($link->name === "default email" or $link->name === "default email_alt")
<div style="--delay: {{ $initial++ }}s" class="button-entrance"><a class="button button-default button button-hover icon-hover" rel="noopener noreferrer nofollow" href="{{ route('clickNumber') . '/' . $link->id . "?" . $link->link }}"><img alt="button-icon" class="icon hvr-icon" src="@if(theme('use_custom_icons') == "true"){{ url('themes/' . $GLOBALS['themeName'] . '/extra/custom-icons')}}/email{{theme('custom_icon_extension')}} @else{{ asset('\/littlelink/icons\/')}}email.svg @endif"></i>{{ $link->title }}</a></div>
@elseif($link->name === "custom" and $link->custom_css === "" or $link->custom_css === "NULL" or (theme('allow_custom_buttons') == "false" and $link->name === "custom"))
<div style="--delay: {{ $initial++ }}s" class="button-entrance"><a class="button button-{{ $link->name }} 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 ><i style="color: {{$link->custom_icon}}" class="icon hvr-icon fa {{$link->custom_icon}}"></i>{{ $link->title }}</a></div>
@elseif($link->name === "custom" and $link->custom_css != "")
@ -343,8 +345,8 @@ function get_operating_system() {
@elseif($link->name === "text")
<div class="fadein"><span style="">@if(env('ALLOW_USER_HTML') === true){!! $link->title !!}@else{{ $link->title }}@endif</span></div>
@else
<?php include base_path('config/button-names.php'); $newLinkName = $linkName; $isNewName = "false"; foreach($buttonNames as $key => $value) { if($newLinkName == $key) { $newLinkName = $value; $isNewName = "true"; }} if($link->name == "default email"){$link->name = "email"; $linkName = "default";} if($link->name == "default email_alt"){$link->name = "email_alt"; $linkName = "default";} ?>
<div style="--delay: {{ $initial++ }}s" class="button-entrance"><a class="button button-{{ $linkName }} 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')}}/{{$link->name}}{{theme('custom_icon_extension')}} @else{{ asset('\/littlelink/icons\/') . $link->name }}.svg @endif">@if($isNewName == "true"){{ $newLinkName }}@else{{ $newLinkName }}@endif</a></div>
<?php include base_path('config/button-names.php'); $newLinkName = $linkName; $isNewName = "false"; foreach($buttonNames as $key => $value) { if($newLinkName == $key) { $newLinkName = $value; $isNewName = "true"; }} ?>
<div style="--delay: {{ $initial++ }}s" class="button-entrance"><a class="button button-{{ $linkName }} 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')}}/{{$link->name}}{{theme('custom_icon_extension')}} @else{{ asset('\/littlelink/icons\/') . $link->name }}.svg @endif">@if($isNewName == "true"){{ ucfirst($newLinkName) }}@else{{ ucfirst($newLinkName) }}@endif</a></div>
@endif
@endforeach