Skip to content

Commit c14b142

Browse files
committed
sandbox example added
1 parent 363c98d commit c14b142

15 files changed

Lines changed: 335 additions & 163 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ composer.phar
66
# composer.lock
77
/nbproject/private/
88
/composer.lock
9+
/.build/

.php-cs-fixer.dist.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
declare(strict_types=1);
44

55
/**
6-
* This file is part of the AbraFlexi-Digest package
6+
* This file is part of the EaseHtmlWidgets package
77
*
8-
* https://github.com/VitexSoftware/AbraFlexi-Digest/
8+
* https://github.com/VitexSoftware/php-vitexsoftware-ease-html-widgets
99
*
1010
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
1111
*
@@ -18,9 +18,9 @@
1818
use Ergebnis\PhpCsFixer\Config\RuleSet\Php74;
1919

2020
$header = <<<'HEADER'
21-
This file is part of the AbraFlexi-Digest package
21+
This file is part of the EaseHtmlWidgets package
2222
23-
https://github.com/VitexSoftware/AbraFlexi-Digest/
23+
https://github.com/VitexSoftware/php-vitexsoftware-ease-html-widgets
2424
2525
(c) Vítězslav Dvořák <http://vitexsoftware.com>
2626
@@ -97,6 +97,7 @@
9797
->append([
9898
__DIR__.'/.php-cs-fixer.dist.php',
9999
])
100+
->in('Examples')
100101
->in('src')
101102
->in('tests');
102103

Examples/sandclock.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of the EaseHtmlWidgets package
7+
*
8+
* https://github.com/VitexSoftware/php-vitexsoftware-ease-html-widgets
9+
*
10+
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
11+
*
12+
* For the full copyright and license information, please view the LICENSE
13+
* file that was distributed with this source code.
14+
*/
15+
16+
require_once '../vendor/autoload.php';
17+
18+
$oPage = new \Ease\WebPage();
19+
20+
$oPage->addItem(new \Ease\Html\Widgets\SandClock());
21+
22+
echo $oPage;

Examples/toggle.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
<?php
22

3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of the EaseHtmlWidgets package
7+
*
8+
* https://github.com/VitexSoftware/php-vitexsoftware-ease-html-widgets
9+
*
10+
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
11+
*
12+
* For the full copyright and license information, please view the LICENSE
13+
* file that was distributed with this source code.
14+
*/
15+
316
require_once '../vendor/autoload.php';
417

518
$oPage = new \Ease\WebPage();
619

7-
$oPage->addItem(new \Ease\Html\Widgets\Toggle('tog1','a'));
8-
$oPage->addItem(new \Ease\Html\Widgets\ToggleRounded('tog2','b'));
20+
$oPage->addItem(new \Ease\Html\Widgets\Toggle('tog1', 'a'));
21+
$oPage->addItem(new \Ease\Html\Widgets\ToggleRounded('tog2', 'b'));
922

1023
echo $oPage;
Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,42 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
4-
* EasePHP Bricks - Browsing History.
6+
* This file is part of the EaseHtmlWidgets package
7+
*
8+
* https://github.com/VitexSoftware/php-vitexsoftware-ease-html-widgets
9+
*
10+
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
511
*
6-
* @author Vítězslav Dvořák <vitex@arachne.cz>
7-
* @copyright 2016-2024 Vitex Software
12+
* For the full copyright and license information, please view the LICENSE
13+
* file that was distributed with this source code.
814
*/
915

1016
namespace Ease\Html\Widgets;
1117

1218
/**
13-
* Show history of visited pages in app
19+
* Show history of visited pages in app.
1420
*
1521
* @param mixed $content
1622
* @param array $properties
1723
*/
1824
class BrowsingHistory extends \Ease\Html\DivTag
1925
{
2026
/**
21-
* Show history of visited pages in app
27+
* Show history of visited pages in app.
2228
*
2329
* @param mixed $content
2430
* @param array $properties
2531
*/
2632
public function __construct($content = null, $properties = null)
2733
{
2834
$webPage = \Ease\Shared::webPage();
29-
if (is_null($properties)) {
35+
36+
if (null === $properties) {
3037
$properties = [];
3138
}
39+
3240
$properties['id'] = 'history';
3341

3442
if (!isset($_SESSION['history'])) {
@@ -40,46 +48,47 @@ public function __construct($content = null, $properties = null)
4048
$currentUrl = \Ease\Page::phpSelf(false);
4149
$currentTitle = $webPage->pageTitle;
4250

43-
4451
foreach ($_SESSION['history'] as $hid => $page) {
45-
if ($page['url'] == $currentUrl) {
52+
if ($page['url'] === $currentUrl) {
4653
unset($_SESSION['history'][$hid]);
4754
}
4855
}
56+
4957
array_unshift(
5058
$_SESSION['history'],
51-
['url' => $currentUrl, 'title' => $currentTitle]
59+
['url' => $currentUrl, 'title' => $currentTitle],
5260
);
61+
5362
foreach ($_SESSION['history'] as $bookmark) {
5463
$this->addItem(new \Ease\Html\SpanTag(
5564
new \Ease\Html\ATag(
5665
$bookmark['url'],
57-
[self::bookmarkIcon(), ' ' . $bookmark['title']]
66+
[self::bookmarkIcon(), ' '.$bookmark['title']],
5867
),
59-
['class' => 'hitem']
68+
['class' => 'hitem'],
6069
));
6170
}
6271
}
6372

6473
/**
65-
*
6674
* @return string
6775
*/
6876
public static function bookmarkIcon()
6977
{
7078
return '&#128278;';
7179
}
7280

73-
7481
/**
75-
* Add Css
82+
* Add Css.
7683
*/
77-
function finalize()
84+
public function finalize(): void
7885
{
79-
$this->addCss('
86+
$this->addCss(<<<'EOD'
87+
8088
.hitem { background-color: #B5FFC4; margin: 5px; border-radius: 15px 50px 30px 5px; padding-left: 3px; padding-right: 10px; }
8189
#history { margin: 5px; }
82-
');
90+
91+
EOD);
8392
parent::finalize();
8493
}
8594
}

src/Ease/Html/Widgets/LangLinks.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
<?php
22

3-
/*
4-
* To change this license header, choose License Headers in Project Properties.
5-
* To change this template file, choose Tools | Templates
6-
* and open the template in the editor.
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of the EaseHtmlWidgets package
7+
*
8+
* https://github.com/VitexSoftware/php-vitexsoftware-ease-html-widgets
9+
*
10+
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
11+
*
12+
* For the full copyright and license information, please view the LICENSE
13+
* file that was distributed with this source code.
714
*/
815

916
namespace Ease\Html\Widgets;
1017

1118
/**
12-
* Description of LangSelect
19+
* Description of LangSelect.
1320
*
1421
* @author vitex
1522
*/
@@ -19,15 +26,17 @@ public function __construct($properties = [])
1926
{
2027
parent::__construct(null, $properties);
2128
$locale = \Ease\Locale::singleton();
29+
2230
foreach ($locale->availble() as $code => $name) {
2331
$name = substr($name, 0, strpos($name, ' ('));
24-
if (\Ease\Locale::$localeUsed == $code) {
32+
33+
if (\Ease\Locale::$localeUsed === $code) {
2534
$this->addItemSmart(new \Ease\Html\StrongTag(new \Ease\Html\ATag(
26-
'?locale=' . $code,
27-
$name
35+
'?locale='.$code,
36+
$name,
2837
)));
2938
} else {
30-
$this->addItemSmart(new \Ease\Html\ATag('?locale=' . $code, $name));
39+
$this->addItemSmart(new \Ease\Html\ATag('?locale='.$code, $name));
3140
}
3241
}
3342
}

src/Ease/Html/Widgets/LangSelect.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
<?php
22

3-
/*
4-
* To change this license header, choose License Headers in Project Properties.
5-
* To change this template file, choose Tools | Templates
6-
* and open the template in the editor.
3+
declare(strict_types=1);
4+
5+
/**
6+
* This file is part of the EaseHtmlWidgets package
7+
*
8+
* https://github.com/VitexSoftware/php-vitexsoftware-ease-html-widgets
9+
*
10+
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
11+
*
12+
* For the full copyright and license information, please view the LICENSE
13+
* file that was distributed with this source code.
714
*/
815

916
namespace Ease\Html\Widgets;
1017

1118
/**
12-
* Description of LangSelect
19+
* Description of LangSelect.
1320
*
1421
* @author vitex
1522
*/
@@ -19,15 +26,17 @@ public function __construct($name = 'lang', $properties = [])
1926
{
2027
parent::__construct($name, $properties);
2128
$locale = \Ease\Locale::singleton();
29+
2230
foreach ($locale->availble() as $code => $name) {
2331
$name = substr($name, 0, strpos($name, ' ('));
24-
if (\Ease\Locale::$localeUsed == $code) {
32+
33+
if (\Ease\Locale::$localeUsed === $code) {
2534
$this->addItemSmart(new \Ease\Html\StrongTag(new \Ease\Html\ATag(
26-
'?locale=' . $code,
27-
$name
35+
'?locale='.$code,
36+
$name,
2837
)));
2938
} else {
30-
$this->addItemSmart(new \Ease\Html\ATag('?locale=' . $code, $name));
39+
$this->addItemSmart(new \Ease\Html\ATag('?locale='.$code, $name));
3140
}
3241
}
3342
}

src/Ease/Html/Widgets/LiveAge.php

Lines changed: 44 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,85 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
/**
4-
* EasePHPbricks - Live Age
6+
* This file is part of the EaseHtmlWidgets package
7+
*
8+
* https://github.com/VitexSoftware/php-vitexsoftware-ease-html-widgets
9+
*
10+
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
511
*
6-
* @author Vítězslav Dvořák <vitex@arachne.cz>
7-
* @copyright 2018 Vitex Software
12+
* For the full copyright and license information, please view the LICENSE
13+
* file that was distributed with this source code.
814
*/
915

1016
namespace Ease\Html\Widgets;
1117

1218
/**
13-
* LiveAge
19+
* LiveAge.
1420
*
1521
* @author Vítězslav Dvořák <info@vitexsoftware.cz>
1622
*/
1723
class LiveAge extends \Ease\Html\TimeTag
1824
{
1925
/**
20-
* Show live time to timestamp
26+
* Show live time to timestamp.
2127
*
22-
* @param long $timestamp UnixTime
23-
* @param array $properties TimeTag properties
28+
* @param long $timestamp UnixTime
29+
* @param array $properties TimeTag properties
2430
*/
2531
public function __construct($timestamp, $properties = [])
2632
{
27-
$age = time() - $timestamp;
33+
$age = time() - $timestamp;
2834
$days = floor($age / 86400);
2935
$dater = new \DateTime();
3036
$dater->setTimestamp($timestamp);
3137
$properties['datetime'] = $dater->format('Y-m-d\TH:i:s');
3238
parent::__construct(
33-
$days . ' ' . _('days') . ', ' . gmdate("G:i:s", $age),
34-
$properties
39+
$days.' '._('days').', '.gmdate('G:i:s', $age),
40+
$properties,
3541
);
3642
$this->setTagID();
3743

38-
$this->addJavaScript('
39-
var timestamp' . $this->getTagID() . ' = ' . $age . ';
44+
$this->addJavaScript(<<<'EOD'
45+
46+
var timestamp
47+
EOD.$this->getTagID().' = '.$age.<<<'EOD'
48+
;
4049
4150
function component(x, v) {
4251
return Math.floor(x / v);
4352
}
4453
45-
var $div' . $this->getTagID() . ' = $(\'#' . $this->getTagID() . '\');
54+
var $div
55+
EOD.$this->getTagID().' = $(\'#'.$this->getTagID().<<<'EOD'
56+
');
4657
4758
setInterval(function() {
4859
49-
timestamp' . $this->getTagID() . '++;
60+
timestamp
61+
EOD.$this->getTagID().<<<'EOD'
62+
++;
5063
51-
var days' . $this->getTagID() . ' = component(timestamp' . $this->getTagID() . ', 24 * 60 * 60),
52-
hours' . $this->getTagID() . ' = component(timestamp' . $this->getTagID() . ', 60 * 60) % 24,
53-
minutes' . $this->getTagID() . ' = component(timestamp' . $this->getTagID() . ', 60) % 60,
54-
seconds' . $this->getTagID() . ' = component(timestamp' . $this->getTagID() . ', 1) % 60;
64+
var days
65+
EOD.$this->getTagID().' = component(timestamp'.$this->getTagID().<<<'EOD'
66+
, 24 * 60 * 60),
67+
hours
68+
EOD.$this->getTagID().' = component(timestamp'.$this->getTagID().<<<'EOD'
69+
, 60 * 60) % 24,
70+
minutes
71+
EOD.$this->getTagID().' = component(timestamp'.$this->getTagID().<<<'EOD'
72+
, 60) % 60,
73+
seconds
74+
EOD.$this->getTagID().' = component(timestamp'.$this->getTagID().<<<'EOD'
75+
, 1) % 60;
5576
56-
$div' . $this->getTagID() . '.html(days' . $this->getTagID() . ' + " ' . _('days') . ', " + hours' . $this->getTagID() . ' + ":" + minutes' . $this->getTagID() . ' + ":" + seconds' . $this->getTagID() . ');
77+
$div
78+
EOD.$this->getTagID().'.html(days'.$this->getTagID().' + " '._('days').', " + hours'.$this->getTagID().' + ":" + minutes'.$this->getTagID().' + ":" + seconds'.$this->getTagID().<<<'EOD'
79+
);
5780
5881
}, 1000);
59-
');
82+
83+
EOD);
6084
}
6185
}

0 commit comments

Comments
 (0)