Skip to content

Commit

Permalink
Allow to enable/disable LR searches
Browse files Browse the repository at this point in the history
  • Loading branch information
gsouf committed Oct 26, 2014
1 parent fe1f31f commit 1b835b6
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions lib/GoogleUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class GoogleUrl{

protected $userAgent = "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36";

protected $enableLr = true;

public function __construct() {
$this->init();
Expand Down Expand Up @@ -144,8 +145,13 @@ public function setLang($iso,$setTld=true){
$accept="ACCEPT_".strtoupper($iso);


$this->setParam("hl", constant("self::".$hl))
->setParam('lr', constant("self::".$lr));
$this->setParam("hl", constant("self::".$hl));

if($this->enableLr){
$this->setParam('lr', constant("self::".$lr));
}else{
$this->setParam('lr', null);
}

$this->acceptLangage=constant("self::".$accept);

Expand All @@ -160,6 +166,13 @@ public function setLang($iso,$setTld=true){

return $this;
}

public function enableLr($enabled = true){
$this->enableLr = $enabled;
if(!$this->enableLr){
$this->setParam('lr', null);
}
}


/**
Expand Down Expand Up @@ -188,7 +201,12 @@ public function searchTerm($search){
* @return \GoogleUrl
*/
private function setParam($name,$value){
$this->googleParams[$name]=$value;
if(null === $value){
if($this->googleParams[$name]){
unset($this->googleParams[$name]);
}
}else
$this->googleParams[$name]=$value;

return $this;
}
Expand Down

0 comments on commit 1b835b6

Please sign in to comment.