root / htmltest / sites / all / modules / addthis / classes / AddThisWidgetJs.php @ 4543c6c7
1 | 4543c6c7 | Assos Assos | <?php
|
---|---|---|---|
2 | /**
|
||
3 | * @file
|
||
4 | * Class to manage a WidgetJs url.
|
||
5 | */
|
||
6 | |||
7 | class AddThisWidgetJs { |
||
8 | |||
9 | protected $url; |
||
10 | protected $attributes = array(); |
||
11 | |||
12 | /**
|
||
13 | * Sepecify the url through the construct.
|
||
14 | */
|
||
15 | public function __construct($url) { |
||
16 | $this->url = $url; |
||
17 | } |
||
18 | |||
19 | /**
|
||
20 | * Add a attribute to the querystring.
|
||
21 | */
|
||
22 | public function addAttribute($name, $value) { |
||
23 | $this->attributes[$name] = $value; |
||
24 | } |
||
25 | |||
26 | /**
|
||
27 | * Remove a attribute from the querystring.
|
||
28 | */
|
||
29 | public function removeAttribute($name) { |
||
30 | if (isset($attributes[$name])) { |
||
31 | unset($attributes[$name]); |
||
32 | } |
||
33 | } |
||
34 | |||
35 | /**
|
||
36 | * Get the full url for the widgetjs.
|
||
37 | */
|
||
38 | public function getFullUrl() { |
||
39 | $querystring_elements = array(); |
||
40 | foreach ($this->attributes as $key => $value) { |
||
41 | $querystring_elements[] = $key . '=' . $value; |
||
42 | } |
||
43 | |||
44 | $querystring = implode('&', $querystring_elements); |
||
45 | |||
46 | return $this->url . '#' . $querystring; |
||
47 | } |
||
48 | |||
49 | } |