Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DealabsBridge - HotUKDealsBridge - MydealsBridge] Set the Feed URL according to Feed parameters #2320

Merged
merged 1 commit into from
Nov 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 59 additions & 26 deletions bridges/DealabsBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -1887,7 +1887,7 @@ class DealabsBridge extends PepperBridgeAbstract {
'bridge-name' => SELF::NAME,
'context-keyword' => 'Recherche par Mot(s) clé(s)',
'context-group' => 'Deals par groupe',
'uri-group' => '/groupe/',
'uri-group' => 'groupe/',
'request-error' => 'Could not request Dealabs',
'no-results' => 'Il n'y a rien à afficher pour le moment :(',
'relative-date-indicator' => array(
Expand Down Expand Up @@ -1962,12 +1962,7 @@ public function collectData(){
*/
protected function collectDataGroup()
{

$group = $this->getInput('group');
$order = $this->getInput('order');

$url = $this->i8n('bridge-uri')
. $this->i8n('uri-group') . $group . $order;
$url = $this->getGroupURI();
$this->collectDeals($url);
}

Expand All @@ -1976,26 +1971,8 @@ protected function collectDataGroup()
*/
protected function collectDataKeywords()
{
$q = $this->getInput('q');
$hide_expired = $this->getInput('hide_expired');
$hide_local = $this->getInput('hide_local');
$priceFrom = $this->getInput('priceFrom');
$priceTo = $this->getInput('priceFrom');

/* Even if the original website uses POST with the search page, GET works too */
$url = $this->i8n('bridge-uri')
. '/search/advanced?q='
. urlencode($q)
. '&hide_expired=' . $hide_expired
. '&hide_local=' . $hide_local
. '&priceFrom=' . $priceFrom
. '&priceTo=' . $priceTo
/* Some default parameters
* search_fields : Search in Titres & Descriptions & Codes
* sort_by : Sort the search by new deals
* time_frame : Search will not be on a limited timeframe
*/
. '&search_fields[]=1&search_fields[]=2&search_fields[]=3&sort_by=new&time_frame=0';
$url = $this->getSearchURI();
$this->collectDeals($url);
}

Expand Down Expand Up @@ -2371,6 +2348,62 @@ public function getName(){
}
}

/**
* Returns the RSS Feed title according to the parameters
* @return string the RSS feed Title
*/
public function getURI(){
switch($this->queriedContext) {
case $this->i8n('context-keyword'):
return $this->getSearchURI();
break;
case $this->i8n('context-group'):
return $this->getGroupURI();
break;
default: // Return default value
return static::URI;
}
}

/**
* Returns the RSS Feed URI for a keyword Feed
* @return string the RSS feed URI
*/
private function getSearchURI(){
$q = $this->getInput('q');
$hide_expired = $this->getInput('hide_expired');
$hide_local = $this->getInput('hide_local');
$priceFrom = $this->getInput('priceFrom');
$priceTo = $this->getInput('priceFrom');
$url = $this->i8n('bridge-uri')
. 'search/advanced?q='
. urlencode($q)
. '&hide_expired=' . $hide_expired
. '&hide_local=' . $hide_local
. '&priceFrom=' . $priceFrom
. '&priceTo=' . $priceTo
/* Some default parameters
* search_fields : Search in Titres & Descriptions & Codes
* sort_by : Sort the search by new deals
* time_frame : Search will not be on a limited timeframe
*/
. '&search_fields[]=1&search_fields[]=2&search_fields[]=3&sort_by=new&time_frame=0';
return $url;
}

/**
* Returns the RSS Feed URI for a group Feed
* @return string the RSS feed URI
*/
private function getGroupURI(){
$group = $this->getInput('group');
$order = $this->getInput('order');

$url = $this->i8n('bridge-uri')
. $this->i8n('uri-group') . $group . $order;
return $url;
}

/**
* This is some "localisation" function that returns the needed content using
* the "$lang" class variable in the local class
Expand Down
2 changes: 1 addition & 1 deletion bridges/HotUKDealsBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -3255,7 +3255,7 @@ class HotUKDealsBridge extends PepperBridgeAbstract {
'bridge-name' => SELF::NAME,
'context-keyword' => 'Search by keyword(s))',
'context-group' => 'Deals per group',
'uri-group' => '/tag/',
'uri-group' => 'tag/',
'request-error' => 'Could not request HotUKDeals',
'no-results' => 'Ooops, looks like we could',
'relative-date-indicator' => array(
Expand Down
2 changes: 1 addition & 1 deletion bridges/MydealsBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -2004,7 +2004,7 @@ class MydealsBridge extends PepperBridgeAbstract {
'bridge-name' => SELF::NAME,
'context-keyword' => 'Suche nach Stichworten',
'context-group' => 'Deals pro Gruppen',
'uri-group' => '/gruppe/',
'uri-group' => 'gruppe/',
'request-error' => 'Could not request mydeals',
'no-results' => 'Ups, wir konnten keine Deals zu',
'relative-date-indicator' => array(
Expand Down