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

Contact Widget #16

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.DS_Store
/.idea
/composer.lock
/.vscode
/.DS_Store
/.ddev
/logs
/var
Expand Down
5 changes: 5 additions & 0 deletions Build/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ module.exports = function (grunt) {
scssFilePaths: [],
cssFilePaths: []
},
'contactWidget': {
stylesheets: ['contactWidget'],
scssFilePaths: [],
cssFilePaths: []
},
},
scssFilePaths: [],
};
Expand Down
77 changes: 77 additions & 0 deletions Classes/Widgets/ContactWidget.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?php

declare(strict_types=1);

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

namespace FriendsOfTYPO3\Widgets\Widgets;

use TYPO3\CMS\Dashboard\Widgets\AdditionalCssInterface;
use TYPO3\CMS\Dashboard\Widgets\WidgetConfigurationInterface;
use TYPO3\CMS\Dashboard\Widgets\WidgetInterface;
use TYPO3\CMS\Fluid\View\StandaloneView;

class ContactWidget implements WidgetInterface, AdditionalCssInterface
{
/**
* @var WidgetConfigurationInterface
*/
private $configuration;

/**
* @var StandaloneView
*/
private $view;

/**
* @var array
*/
private $options;

/**
* @var null
*/
private $buttonProvider;

public function __construct(
WidgetConfigurationInterface $configuration,
StandaloneView $view,
$buttonProvider = null,
array $options = []
) {
$this->configuration = $configuration;
$this->view = $view;
$this->buttonProvider = $buttonProvider;
$this->options = $options;
}

public function getCssFiles(): array
{
return [
'EXT:widgets/Resources/Public/Css/contactWidget.css',
];
}

public function renderWidgetContent(): string
{

$this->view->setTemplate('Widget/ContactWidget');
$this->view->assignMultiple([
'options' => $this->options,
'button' => $this->buttonProvider,
'configuration' => $this->configuration,
]);
return $this->view->render();
}
}
33 changes: 33 additions & 0 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,36 @@ services:
iconIdentifier: 'content-widget-list'
height: 'medium'
width: 'medium'

dashboard.buttons.contact:
class: 'TYPO3\CMS\Dashboard\Widgets\Provider\ButtonProvider'
arguments:
$title: ''
$link: ''
$target: '_blank'

widgets.dashboard.widget.contact:
KoenWouters marked this conversation as resolved.
Show resolved Hide resolved
class: 'FriendsOfTYPO3\Widgets\Widgets\ContactWidget'
arguments:
$view: '@dashboard.views.widget'
$buttonProvider: '@dashboard.buttons.contact'
$options:
template: 'Widget/ContactWidget'
introText: ''
company: 'Your TYPO3 agency'
address: ''
postalCode: ''
place: ''
tel: ''
mail: ''
website: ''
logoPath: ''
tags:
- name: dashboard.widget
identifier: 'widgets-contact'
groupNames: 'general'
title: 'LLL:EXT:widgets/Resources/Private/Language/locallang.xlf:widgets.dashboard.widget.contact.title'
description: 'LLL:EXT:widgets/Resources/Private/Language/locallang.xlf:widgets.dashboard.widget.contact.description'
iconIdentifier: 'content-widget-list'
height: 'medium'
width: 'small'
13 changes: 13 additions & 0 deletions Resources/Private/Language/locallang.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
<trans-unit id="lastChange" xml:space="preserve">
<source>Last change</source>
</trans-unit>
<trans-unit id="telephone" xml:space="preserve">
<source>Tel:</source>
</trans-unit>
<trans-unit id="mail" xml:space="preserve">
<source>Mail:</source>
</trans-unit>

<trans-unit id="widgets.dashboard.widget.onlineUsers.title" xml:space="preserve">
<source>Current online users</source>
</trans-unit>
Expand All @@ -60,6 +67,12 @@
<trans-unit id="widget_group.seo" xml:space="preserve">
<source>SEO</source>
</trans-unit>
<trans-unit id="widgets.dashboard.widget.contact.title" xml:space="preserve">
<source>Contact information</source>
</trans-unit>
<trans-unit id="widgets.dashboard.widget.contact.description" xml:space="preserve">
<source>Will show contact information of supplier</source>
KoenWouters marked this conversation as resolved.
Show resolved Hide resolved
</trans-unit>
</body>
</file>
</xliff>
8 changes: 8 additions & 0 deletions Resources/Private/Sass/contactWidget.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@import "Base";

.widget {
.widget-contact-logo {
max-width: 290px;
margin-top: 20px;
}
}
53 changes: 53 additions & 0 deletions Resources/Private/Templates/Widget/ContactWidget.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" xmlns:be="http://typo3.org/ns/TYPO3/CMS/Backend/ViewHelpers" data-namespace-typo3-fluid="true">
<f:layout name="Widget/Widget"/>

<f:section name="main">
<f:if condition="{options.introText}">
<p>
{f:translate(key: options.introText, default: options.introText) -> f:format.raw()}
</p>
</f:if>
<p>
<f:if condition="{options.company}">
<strong>{options.company}</strong> <br/>
</f:if>
<f:if condition="{options.address}">
{options.address} <br/>
</f:if>
<f:if condition="{options.postalCode} || {options.place}">
{options.postalCode} {options.place} <br/>
</f:if>
</p>
KoenWouters marked this conversation as resolved.
Show resolved Hide resolved
<f:if condition="{options.tel} || {options.mail}">
<p>
<f:if condition="{options.tel}">
<f:translate key="telephone" extensionName="widgets"/>
{options.tel} <br/>
</f:if>
<f:if condition="{options.mail}">
<f:translate key="mail" extensionName="widgets"/>
<f:link.email email="{options.mail}" class="contact-widget-link">
<strong>{options.mail}</strong></f:link.email>
<br/>
</f:if>
</p>
</f:if>
<f:if condition="{options.website}">
<p>
<a href="{options.website}" target="_blank" class="contact-widget-link"><strong>{options.website}</strong></a>
</p>
</f:if>
<f:if condition="{options.logoPath}">
<img src="{f:uri.image(src: options.logoPath, maxWidth: '290')}"
class="widget-contact-logo"
alt="{f:translate(key: options.company, default: options.company)}"/>
</f:if>
</f:section>

<f:section name="footer">
<f:if condition="{button.title}">
<a href="{button.link}" target="{button.target}" class="widget-cta">{f:translate(id: button.title, default: button.title)}</a>
</f:if>
</f:section>

</html>
1 change: 1 addition & 0 deletions Resources/Public/Css/contactWidget.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.widget .widget-contact-logo{max-width:290px;margin-top:20px}