Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add LiveZilla Tag
- Loading branch information
Showing
5 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
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,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); | ||
}), | ||
); | ||
} | ||
} |
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,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); | ||
} | ||
}; | ||
}; | ||
})(); |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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