Skip to content

Commit 646abef

Browse files
committed
BrowsingHistory class added
1 parent b33c59c commit 646abef

File tree

6 files changed

+124
-3
lines changed

6 files changed

+124
-3
lines changed

BrowsingHistory.png

12.1 KB
Loading

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,15 @@ With eye icon to show plaintext
111111
```php
112112
new PasswordInput($this->passwordField);
113113
```
114-
![Password Input](https://raw.githubusercontent.com/VitexSoftware/Ease-PHP-Bricks/master/PaswordInput.png "Password input")
114+
![Password Input](https://raw.githubusercontent.com/VitexSoftware/Ease-PHP-Bricks/master/PasswordInput.png "Password input")
115+
116+
Browsing History
117+
----------------
118+
119+
```
120+
new BrowsingHistory();
121+
```
122+
![Browsing History](https://raw.githubusercontent.com/VitexSoftware/Ease-PHP-Bricks/master/BrowsingHistory.png "Browsing History")
115123

116124

117125
Installation

debian/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ease-bricks",
33
"description": "Addons for PHP Framework (debianized)",
4-
"version": "0.3",
4+
"version": "0.4",
55
"authors": [
66
{
77
"name": "Vítězslav Dvořák",

src/Ease/ui/BrowsingHistory.php

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
/**
3+
* EasePHP Bricks - Browsing History.
4+
*
5+
* @author Vítězslav Dvořák <[email protected]>
6+
* @copyright 2016-2018 Vitex Software
7+
*/
8+
9+
namespace Ease\ui;
10+
11+
/**
12+
* Show history of visited pages in app
13+
*
14+
* @param mixed $content
15+
* @param array $properties
16+
*/
17+
class BrowsingHistory extends \Ease\Html\DivTag
18+
{
19+
20+
/**
21+
* Show history of visited pages in app
22+
*
23+
* @param mixed $content
24+
* @param array $properties
25+
*/
26+
public function __construct($content = null, $properties = null)
27+
{
28+
$webPage = \Ease\Shared::webPage();
29+
if (is_null($properties)) {
30+
$properties = [];
31+
}
32+
$properties['id'] = 'history';
33+
34+
if (!isset($_SESSION['history'])) {
35+
$_SESSION['history'] = [];
36+
}
37+
38+
parent::__construct(null, $properties);
39+
40+
$currentUrl = \Ease\Page::phpSelf(false);
41+
$currentTitle = $webPage->pageTitle;
42+
43+
44+
foreach ($_SESSION['history'] as $hid => $page) {
45+
if ($page['url'] == $currentUrl) {
46+
unset($_SESSION['history'][$hid]);
47+
}
48+
}
49+
array_unshift($_SESSION['history'],
50+
['url' => $currentUrl, 'title' => $currentTitle]);
51+
foreach ($_SESSION['history'] as $bookmark) {
52+
$this->addItem(new \Ease\Html\SpanTag(new \Ease\Html\ATag($bookmark['url'],
53+
[new \Ease\TWB\GlyphIcon('bookmark'), ' '.$bookmark['title']]),
54+
['class' => 'hitem']));
55+
}
56+
}
57+
58+
/**
59+
* Add Css
60+
*/
61+
function finalize()
62+
{
63+
$this->addCss('
64+
.hitem { background-color: #B5FFC4; margin: 5px; border-radius: 15px 50px 30px 5px; padding-left: 3px; padding-right: 10px; }
65+
#history { margin: 5px; }
66+
');
67+
parent::finalize();
68+
}
69+
}

src/Ease/ui/PasswordInput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class PasswordInput extends \Ease\Html\DivTag
2222
* @param string $value Plaintext password
2323
* @param array $properties Poroperties for password input
2424
*/
25-
public function __construct($name, $value = null,$properties = [])
25+
public function __construct($name, $value = null, $properties = [])
2626
{
2727
$inpass = new \Ease\Html\InputPasswordTag($name, $value);
2828
$inpass->setTagID();
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace Ease\ui;
4+
5+
/**
6+
* Generated by PHPUnit_SkeletonGenerator on 2018-09-18 at 11:23:39.
7+
*/
8+
class HistoryTest extends \PHPUnit_Framework_TestCase
9+
{
10+
/**
11+
* @var History
12+
*/
13+
protected $object;
14+
15+
/**
16+
* Sets up the fixture, for example, opens a network connection.
17+
* This method is called before a test is executed.
18+
*/
19+
protected function setUp()
20+
{
21+
$this->object = new BrowsingHistory();
22+
}
23+
24+
/**
25+
* Tears down the fixture, for example, closes a network connection.
26+
* This method is called after a test is executed.
27+
*/
28+
protected function tearDown()
29+
{
30+
31+
}
32+
33+
/**
34+
* @covers Ease\ui\History::finalize
35+
* @todo Implement testFinalize().
36+
*/
37+
public function testFinalize()
38+
{
39+
// Remove the following lines when you implement this test.
40+
$this->markTestIncomplete(
41+
'This test has not been implemented yet.'
42+
);
43+
}
44+
}

0 commit comments

Comments
 (0)