ClearFavoritesButton.php
931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace Favorites\Entities\Favorite;
use Favorites\Entities\User\UserRepository;
use Favorites\Config\SettingsRepository;
class ClearFavoritesButton
{
/**
* Site ID
*/
private $site_id;
/**
* User Respository
*/
private $user;
/**
* The Button Text
*/
private $text;
/**
* Settings Repository
*/
private $settings_repo;
public function __construct($site_id, $text)
{
$this->user = new UserRepository;
$this->settings_repo = new SettingsRepository;
$this->site_id = $site_id;
$this->text = $text;
}
/**
* Display the button
*/
public function display()
{
if ( !$this->user->getsButton() ) return false;
if ( !$this->text ) $this->text = html_entity_decode($this->settings_repo->clearFavoritesText());
if ( !$this->site_id ) $this->site_id = 1;
$out = '<button class="simplefavorites-clear" data-siteid="' . $this->site_id . '">' . $this->text . '</button>';
return $out;
}
}