Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add LiveZilla Tag
  • Loading branch information
scysys committed Oct 2, 2018
1 parent 8b2576d commit 9288123
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 0 deletions.
93 changes: 93 additions & 0 deletions Template/Tag/LivezillaDynamicTag.php
@@ -0,0 +1,93 @@
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\TagManager\Template\Tag;

use Piwik\Settings\FieldConfig;
use Piwik\Plugins\TagManager\Template\Tag\BaseTag;
use Piwik\Validators\CharacterLength;
use Piwik\Validators\NotEmpty;
use Piwik\Validators\NumberRange;

class LivezillaDynamicTag extends BaseTag
{
public function getName()
{
// By default, the name will be automatically fetched from the TagManager_CustomHtmlTagName translation key.
// you can either adjust/create/remove this translation key, or return a different value here directly.
return parent::getName();
}

public function getDescription()
{
// By default, the description will be automatically fetched from the TagManager_CustomHtmlTagDescription
// translation key. you can either adjust/create/remove this translation key, or return a different value
// here directly.
return parent::getDescription();
}

public function getHelp()
{
// By default, the help will be automatically fetched from the TagManager_CustomHtmlTagHelp translation key.
// you can either adjust/create/remove this translation key, or return a different value here directly.
return parent::getHelp();
}

public function getIcon()
{
// You may optionally specify a path to an image icon URL, for example:
//
// return 'plugins/TagManager/images/MyIcon.png';
//
// to not return default icon call:
// return parent::getIcon();
//
// The image should have ideally a resolution of about 64x64 pixels.
return 'plugins/TagManager/images/icons/livezilla_icon.png';
}

public function getCategory()
{
return self::CATEGORY_SOCIAL;
}

public function getParameters() {
return array(
$this->makeSetting('LivezillaDynamicID', '', FieldConfig::TYPE_STRING, function (FieldConfig $field) {
$field->title = 'Livezilla ID';
$field->description = 'Insert the Livezilla ID from your Dynamic Code section.';
$field->validators[] = new NotEmpty();
$field->validators[] = new CharacterLength(32);
}),
$this->makeSetting('LivezillaDynamicDomain', '', FieldConfig::TYPE_STRING, function (FieldConfig $field) {
$field->title = 'Livezilla Domain';
$field->description = 'Enter your Domain without http:// or https://';
$field->validators[] = new NotEmpty();
$field->validators[] = new CharacterLength(4, 60);
}),
$this->makeSetting('LivezillaDynamicDefer', 'true', FieldConfig::TYPE_STRING, function (FieldConfig $field) {
$field->title = 'Livezilla Script "defer"?';
$field->description = 'In most cases it should be the Standard. (true)
Available options are: true or false'; // Howto linebreak?
$field->validators[] = new NotEmpty();
$field->validators[] = new CharacterLength(4, 5);
}),
$this->makeSetting('LivezillaDynamicCookieLawName', '', FieldConfig::TYPE_STRING, function (FieldConfig $field) {
$field->title = 'EU-Cookie Law Name';
$field->description = 'Insert your Cookie Name. --> Please only fill it out, when you know what you doing here. If you insert wrong details here, this Tag will not work as expected. If you insert your correct Cookie settings, your website visitors will see this Tag only, when he has accepted Cookies on your Website.';
$field->validators[] = new NotEmpty();
$field->validators[] = new CharacterLength(2, 60);
}),
$this->makeSetting('LivezillaDynamicCookieLawValue', '', FieldConfig::TYPE_STRING, function (FieldConfig $field) {
$field->title = 'EU-Cookie Law Value';
$field->description = 'Insert the Cookie Value of your Cookie Name above. --> Please only fill it out, when you know what you doing here. If you insert wrong details here, this Tag will not work as expected. If you insert your correct Cookie settings, your website visitors will see this Tag only, when he has accepted Cookies on your Website.';
$field->validators[] = new NotEmpty();
$field->validators[] = new CharacterLength(2, 60);
}),
);
}
}
27 changes: 27 additions & 0 deletions Template/Tag/LivezillaDynamicTag.web.js
@@ -0,0 +1,27 @@
(function () {
return function (parameters, TagManager) {
this.fire = function () {
var LivezillaDynamicID = parameters.get('LivezillaDynamicID');
var LivezillaDynamicDomain = parameters.get('LivezillaDynamicDomain');
var LivezillaDynamicDefer = parameters.get('LivezillaDynamicDefer');
var LivezillaDynamicCookieLawName = parameters.get('LivezillaDynamicCookieLawName');
var LivezillaDynamicCookieLawValue = parameters.get('LivezillaDynamicCookieLawValue');
if (LivezillaDynamicCookieLawName) {
if (document.cookie.indexOf('' + LivezillaDynamicCookieLawName + '=' + LivezillaDynamicCookieLawValue + '') > -1 ) {
var s1 = document.createElement("script"), s0 = document.getElementsByTagName("script")[0];
s1.type = 'text/javascript';
s1.defer = LivezillaDynamicDefer;
s1.id = LivezillaDynamicID;
s1.src = 'https://' + LivezillaDynamicDomain + '/script.php?id=' + LivezillaDynamicID + '';
s0.parentNode.insertBefore(s1, s0);
} } else {
var s1 = document.createElement("script"), s0 = document.getElementsByTagName("script")[0];
s1.type = 'text/javascript';
s1.defer = LivezillaDynamicDefer;
s1.id = LivezillaDynamicID;
s1.src = 'https://' + LivezillaDynamicDomain + '/script.php?id=' + LivezillaDynamicID + '';
s0.parentNode.insertBefore(s1, s0);
}
};
};
})();
Binary file added images/icons/livezilla_icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions lang/de.json
Expand Up @@ -278,6 +278,9 @@
"LastUpdated": "Zuletzt aktualisiert",
"LastVersions": "Letzte Versionen",
"LearnMore": "Mehr dazu",
"LivezillaDynamicTagName": "Livezilla Chat / Monitoring",
"LivezillaDynamicTagDescription": "Livezilla lässt Sie Besucher auf Ihrer Webseite beobachten und mit Ihnen chatten.",
"LivezillaDynamicTagHelp": "Dieser Tag erlaubt Ihnen, Ihrer Website Livezilla Chats und / oder Monitoring hinzuzufügen.",
"LocalDateVariableDescription": "Das aktuelle lokale Benutzerdatum, zum Beispiel \"Mon Mar 19 2018\".",
"LocalDateVariableName": "Lokales Datum",
"LocalHourVariableDescription": "Die aktuelle Stunde der lokalen Zeit, zum Beispiel \"8\" oder \"11\".",
Expand Down
3 changes: 3 additions & 0 deletions lang/en.json
Expand Up @@ -296,6 +296,9 @@
"LastUpdated": "Last updated",
"LastVersions": "Last versions",
"LearnMore": "Learn more",
"LivezillaDynamicTagName": "Livezilla Chat / Monitoring",
"LivezillaDynamicTagDescription": "Livezilla lets you monitor and chat with visitors on your website.",
"LivezillaDynamicTagHelp": "This tag allows you to add the Dynamic Code integration from Livezilla to Chat with you Customers or just Monitor your website.",
"LocalDateVariableDescription": "The current user's local date, for example \"Mon Mar 19 2018\".",
"LocalDateVariableName": "Local Date",
"LocalHourVariableDescription": "The current hour of the local time, for example \"8\" or \"11\".",
Expand Down

0 comments on commit 9288123

Please sign in to comment.