You are here

class AddThisWidgetJsUrl in AddThis 7.4

@file Class to manage a WidgetJs url.

Hierarchy

Expanded class hierarchy of AddThisWidgetJsUrl

File

classes/Util/AddThisWidgetJsUrl.php, line 7
Class to manage a WidgetJs url.

View source
class AddThisWidgetJsUrl {
  protected $url;
  protected $attributes = array();

  /**
   * Sepecify the url through the construct.
   */
  public function __construct($url) {
    $this->url = $url;
  }

  /**
   * Add a attribute to the querystring.
   */
  public function addAttribute($name, $value) {
    $this->attributes[$name] = $value;
  }

  /**
   * Remove a attribute from the querystring.
   */
  public function removeAttribute($name) {
    if (isset($attributes[$name])) {
      unset($attributes[$name]);
    }
  }

  /**
   * Get the full url for the widgetjs.
   */
  public function getFullUrl() {
    $querystring_elements = array();
    foreach ($this->attributes as $key => $value) {
      if (!empty($value)) {
        $querystring_elements[] = $key . '=' . $value;
      }
    }
    $querystring = implode('&', $querystring_elements);
    return $this->url . '#' . $querystring;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AddThisWidgetJsUrl::$attributes protected property
AddThisWidgetJsUrl::$url protected property
AddThisWidgetJsUrl::addAttribute public function Add a attribute to the querystring.
AddThisWidgetJsUrl::getFullUrl public function Get the full url for the widgetjs.
AddThisWidgetJsUrl::removeAttribute public function Remove a attribute from the querystring.
AddThisWidgetJsUrl::__construct public function Sepecify the url through the construct.