From 2b634002f2608eeda01413cd0acb511f142118ec Mon Sep 17 00:00:00 2001 From: sysadminstory Date: Sat, 6 Nov 2021 19:43:44 +0100 Subject: [PATCH] [DealabsBridge - HotUKDealsBridge - MydealsBridge] Set the Feed URL according to the parameters (#2320) --- bridges/DealabsBridge.php | 85 +++++++++++++++++++++++++----------- bridges/HotUKDealsBridge.php | 2 +- bridges/MydealsBridge.php | 2 +- 3 files changed, 61 insertions(+), 28 deletions(-) diff --git a/bridges/DealabsBridge.php b/bridges/DealabsBridge.php index 1d1b16af..f0a03732 100644 --- a/bridges/DealabsBridge.php +++ b/bridges/DealabsBridge.php @@ -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 diff --git a/bridges/HotUKDealsBridge.php b/bridges/HotUKDealsBridge.php index b1077bd7..60a1ba25 100644 --- a/bridges/HotUKDealsBridge.php +++ b/bridges/HotUKDealsBridge.php @@ -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( diff --git a/bridges/MydealsBridge.php b/bridges/MydealsBridge.php index 6fe8dd1a..1bcc444f 100644 --- a/bridges/MydealsBridge.php +++ b/bridges/MydealsBridge.php @@ -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(