Skip to content

Commit

Permalink
moved text to translate files
Browse files Browse the repository at this point in the history
  • Loading branch information
Giel Berkers committed Oct 1, 2012
1 parent 71cc7bb commit bdf4e30
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 73 deletions.
14 changes: 0 additions & 14 deletions assets/cookie_law.js

This file was deleted.

21 changes: 16 additions & 5 deletions data-sources/data.cookie_law.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,20 @@ public function allowEditorToParse()
return false;
}

/**
* Return translation
* @param $str
* @return string
*/
public function __($str)
{
return Lang::Dictionary()->translate($str);
}

public function execute(&$param_pool)
{
$result = new XMLElement($this->dsParamROOTELEMENT);


$html = sprintf('
<script type="text/javascript">
function cookie_action(){
Expand All @@ -65,8 +74,8 @@ function cookie_action(){
{
document.write(unescape("%%3Cdiv id=\'cookies_bar\'%%3E" +
"%s" +
"%%3Ca href=\'#\' id=\'cookies_accept\'%%3Eaccepteren%%3C/a%%3E" +
"%%3Ca href=\'#\' id=\'cookies_decline\'%%3Eweigeren%%3C/a%%3E" +
"%%3Ca href=\'#\' id=\'cookies_accept\'%%3E%s%%3C/a%%3E" +
"%%3Ca href=\'#\' id=\'cookies_decline\'%%3E%s%%3C/a%%3E" +
"%%3Cdiv id=\'cookies_disclaimer_box\'%%3E" +
"%s" +
"%%3C/div%%3E" +
Expand Down Expand Up @@ -102,8 +111,10 @@ function cookie_action(){
</script>',
Symphony::Configuration()->get('javascript', 'cookie_law'),
str_replace('{', '%3Ca href=\'#\' id=\'cookies_disclaimer\'%3E',
str_replace('}', '%3C/a%3E', Symphony::Configuration()->get('text', 'cookie_law'))),
str_replace(array("\r", "\n"), array('', '<br />'), Symphony::Configuration()->get('disclaimer', 'cookie_law'))
str_replace('}', '%3C/a%3E', $this->__('cookie_text'))),
$this->__('cookie_accept'),
$this->__('cookie_decline'),
str_replace(array("\r", "\n"), array('', '<br />'), $this->__('cookie_disclaimer'))
);

$result->appendChild(new XMLElement('html', $html));
Expand Down
41 changes: 2 additions & 39 deletions extension.driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
public function about() {
return array(
'name' => 'Cookie Law',
'version' => '1.0',
'release-date' => '2012-09-05',
'version' => '1.1',
'release-date' => '2012-10-01',
'author' => array(
'name' => '<a href="http://gielberkers.com">Giel Berkers</a>'
),
Expand All @@ -26,48 +26,11 @@ public function getSubscribedDelegates(){

public function appendPresets($context)
{
Administration::instance()->Page->addScriptToHead(URL.'/extensions/cookie_law/assets/cookie_law.js', 2000);

$wrapper = $context['wrapper'];

$fieldset = new XMLElement('fieldset', '', array('class'=>'settings'));
$fieldset->appendChild(new XMLElement('legend', __('Cookie Law')));

$label = Widget::Label(__('Enter the fields below or select a preset:'));
$options = array(
array('0', true, __('Choose a preset'))
);
$presets = glob(EXTENSIONS.'/cookie_law/presets/*.json');
foreach($presets as $preset)
{
$a = explode('-', basename(str_replace('.json', '', $preset)));
$name = ucfirst($a[0]).': '.ucfirst($a[1]);
$options[] = array(URL.'/extensions/cookie_law/presets/'.basename($preset), false, $name);
}

$label->appendChild(Widget::Select('cookie_preset', $options));
$fieldset->appendChild($label);

$label = Widget::Label(__('Text to show (wrap disclaimer link in curly braces)'));
$value = Symphony::Configuration()->get('text', 'cookie_law');
$label->appendChild(Widget::Input('settings[cookie_law][text]', $value));
$fieldset->appendChild($label);

$label = Widget::Label(__('Disclaimer text:'));
$value = Symphony::Configuration()->get('disclaimer', 'cookie_law');
$label->appendChild(Widget::Textarea('settings[cookie_law][disclaimer]', 15, 50, $value));
$fieldset->appendChild($label);

$label = Widget::Label(__('Accept Text'));
$value = Symphony::Configuration()->get('accept', 'cookie_law');
$label->appendChild(Widget::Input('settings[cookie_law][accept]', $value));
$fieldset->appendChild($label);

$label = Widget::Label(__('Decline Text'));
$value = Symphony::Configuration()->get('decline', 'cookie_law');
$label->appendChild(Widget::Input('settings[cookie_law][decline]', $value));
$fieldset->appendChild($label);

$label = Widget::Label(__('Javascript code to inject when the user accepts the cookie law:'));
$value = Symphony::Configuration()->get('javascript', 'cookie_law');
$label->appendChild(Widget::Textarea('settings[cookie_law][javascript]', 15, 50, $value));
Expand Down
1 change: 1 addition & 0 deletions extension.meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
</author>
</authors>
<releases>
<release version="1.1" date="2012-10-01" min="2.1.2" max="2.3" />
<release version="1.0" date="2012-09-05" min="2.1.2" max="2.3" />
</releases>
</extension>
21 changes: 21 additions & 0 deletions lang/lang.en.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
$dictionary = array(

'cookie_text' =>
'To constantly improve the quality of this website we make use of {cookies}.',

'cookie_disclaimer' =>
'We make use of cookies on this website. A cookie is a small file that is sent to your browser and stored on the hard drive of your computer.
Through our website, a cookie is placed by Google, as part of the \'Analytics\' service. We use this service to track and get reports about how visitors use the website. Google may transfer this information to third parties if Google is legally required or if third parties process the information on Google\'s behalf. We have no influence on this.
The information we collect is anonymous as much as possible. Your IP address is not explicitly given. The information is transmitted to and stored by Google on servers in the United States.',

'cookie_accept' =>
'accept',

'cookie_decline' =>
'decline'

);

21 changes: 21 additions & 0 deletions lang/lang.nl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
$dictionary = array(

'cookie_text' =>
'Om de kwaliteit van deze website constant te verbeteren maken wij gebruik van {cookies}.',

'cookie_disclaimer' =>
'Wij maken op deze website gebruik van cookies. Een cookie is een eenvoudig klein bestandje dat met pagina’s van deze website wordt meegestuurd en door uw browser op uw harde schrijf van uw computer wordt opgeslagen.
Via onze website wordt een cookie geplaatst van het Amerikaanse bedrijf Google, als deel van de “Analytics”-dienst. Wij gebruiken deze dienst om bij te houden en rapportages te krijgen over hoe bezoekers de website gebruiken. Google kan deze informatie aan derden verschaffen indien Google hiertoe wettelijk wordt verplicht, of voor zover derden de informatie namens Google verwerken. Wij hebben hier geen invloed op.
De informatie die Google verzamelt wordt zo veel mogelijk geanonimiseerd. Uw IP-adres wordt nadrukkelijk niet meegegeven. De informatie wordt overgebracht naar en door Google opgeslagen op servers in de Verenigde Staten.',

'cookie_accept' =>
'accepteren',

'cookie_decline' =>
'weigeren'

);

7 changes: 0 additions & 7 deletions presets/dutch-only analytics.json

This file was deleted.

7 changes: 0 additions & 7 deletions presets/english-only analytics.json

This file was deleted.

7 changes: 6 additions & 1 deletion readme.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,9 @@ it could also be used for your own custom Javascript. When the value is `0`, thi

A nice little detail to 'push' people into accepting the cookie: when the cookie is declined, the `cookie_accept`-cookie
will expire at the end of the browsing session, meaning that the next time the user comes to your website, they are
confronted with the same question. However... when the user accepts the cookie, it is valid until December 31st, 2999.
confronted with the same question. However... when the user accepts the cookie, it is valid until December 31st, 2999.

## Localisation

The texts for the cookie message are stored in the `lang`-folder. So if you want to change these texts, you can change
the text for the corresponding language.

0 comments on commit bdf4e30

Please sign in to comment.