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

This commit is contained in:
sysadminstory 2021-11-06 19:43:44 +01:00 committed by GitHub
parent 42379071e9
commit 2b634002f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 61 additions and 28 deletions

View file

@ -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(
@ -1962,12 +1962,7 @@ class PepperBridgeAbstract extends BridgeAbstract {
*/
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);
}
@ -1976,26 +1971,8 @@ class PepperBridgeAbstract extends BridgeAbstract {
*/
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);
}
@ -2371,6 +2348,62 @@ class PepperBridgeAbstract extends BridgeAbstract {
}
}
/**
* 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

View file

@ -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(

View file

@ -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(