mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-23 08:33:24 +02:00
bridges: Fix coding styles
This commit is a squash of all commits that fix coding styles for the new coding style policy. [ABCTabsBridge] Fix coding style [AcrimedBridge] Fix coding style [AllocineFRBridge] Fix coding style [AnimeUltimeBridge] Fix coding style [Arte7Bridge] Fix coding style [AskfmBridge] Fix coding style [BandcampBridge] Fix coding style [BastaBridge] Fix coding style [BlaguesDeMerdeBridge] Fix coding style [BooruprojectBridge] Fix coding style [CADBridge] Fix coding style [CNETBridge] Fix coding style [CastorusBridge] Fix coding style [CollegeDeFranceBridge] Fix coding style [CommonDreamsBridge] Fix coding style [CopieDoubleBridge] Fix coding style [CourrierInternationalBridge] Fix coding style [CpasbienBridge] Fix coding style [CryptomeBridge] Fix coding style [DailymotionBridge] Fix coding style [DanbooruBridge] Fix coding style [DansTonChatBridge] Fix coding style [DauphineLibereBridge] Fix coding style [DeveloppezDotComBridge] Fix coding style [DemoBridge] Fix coding style [DilbertBridge] Fix coding style [DuckDuckGoBridge] Fix coding style [DollbooruBridge] Fix coding style [EliteDangerousGalnetBridge] Fix coding style [ElsevierBridge] Fix coding style [EstCeQuonMetEnProdBridge] Fix coding style [EZTVBridge] Fix coding style [FacebookBridge] Fix coding style [FeedExpanderExampleBridge] Fix coding style [FB2Bridge] Fix coding style [FierPandaBridge] Fix coding style [FlickrBridge] Fix coding style [FootitoBridge] Fix coding style [FourchanBridge] Fix coding style [FuturaSciencesBridge] Fix coding style [GBAtempBridge] Fix coding style [GelbooruBridge] Fix coding style [GiphyBridge] Fix coding style [GithubIssueBridge] Fix coding style [GizmodoBridge] Fix coding style [GoComicsBridge] Fix coding style [GooglePlusPostBridge] Fix coding style [GoogleSearchBridge] Fix coding style [HDWallpapersBridge] Fix coding style [HentaiHavenBridge] Fix coding style [IdenticaBridge] Fix coding style [InstagramBridge] Fix coding style [IsoHuntBridge] Fix coding style [JapanExpoBridge] Fix coding style [KonachanBridge] Fix coding style [KoreusBridge] Fix coding style [KununuBridge] Fix coding style [LeBonCoinBridge] Fix coding style [LegifranceJOBBridge] Fix coding style [LeMondeInformatiqueBridge] Fix coding style [LesJoiesDuCodeBridge] Fix coding style [LichessBridge] Fix coding style [LinkedInCompanyBridge] Fix coding style [LolibooruBridge] Fix coding style [LWNprevBridge] Fix coding style [MangareaderBridge] Fix coding style [MilbooruBridge] Fix coding style [MixCloudBridge] Fix coding style [MoebooruBridge] Fix coding style [MondeDiploBridge] Fix coding style [MsnMondeBridge] Fix coding style [MspabooruBridge] Fix coding style [NasaApodBridge] Fix coding style [NeuviemeArtBridge] Fix coding style [NextgovBridge] Fix coding style [NextInpactBridge] Fix coding style [NiceMatinBridge] Fix coding style [NovelUpdatesBridge] Fix coding style [OpenClassroomsBridge] Fix coding style [ParuVenduImmoBridge] Fix coding style [PickyWallpapersBridge] Fix coding style [PinterestBridge] Fix coding style [PlanetLibreBridge] Fix coding style [ReadComicsBridge] Fix coding style [Releases3DSBridge] Fix coding style [ReporterreBridge] Fix coding style [RTBFBridge] Fix coding style [Rue89Bridge] Fix coding style [Rule34Bridge] Fix coding style [Rule34pahealBridge] Fix coding style [SafebooruBridge] Fix coding style [SakugabooruBridge] Fix coding style [ScmbBridge] Fix coding style [ScoopItBridge] Fix coding style [SensCritiqueBridge] Fix coding style [SexactuBridge] Fix coding style [ShanaprojectBridge] Fix coding style [Shimmie2Bridge] Fix coding style [SoundcloudBridge] Fix coding style [StripeAPIChangeLogBridge] Fix coding style [SuperbWallpapersBridge] Fix coding style [T411Bridge] Fix coding style [TagBoardBridge] Fix coding style [TbibBridge] Fix coding style [TheCodingLoveBridge] Fix coding style [TheHackerNewsBridge] Fix coding style [ThePirateBayBridge] Fix coding style [TheTVDBBridge] Fix coding style [Torrent9Bridge] Fix coding style [TwitterBridge] Fix coding style [UnsplashBridge] Fix coding style [ViadeoCompanyBridge] Fix coding style [VineBridge] Fix coding style [VkBridge] Fix coding style [WallpaperStopBridge] Fix coding style [WebfailBridge] Fix coding style [WeLiveSecurityBridge] Fix coding style [WhydBridge] Fix coding style [WikipediaBridge] Fix coding style [WordPressBridge] Fix coding style [WorldOfTanksBridge] Fix coding style [XbooruBridge] Fix coding style [YandereBridge] Fix coding style [YoutubeBridge] Fix coding style [ZDNetBridge] Fix coding style
This commit is contained in:
@@ -1,40 +1,39 @@
|
||||
<?php
|
||||
class KununuBridge extends BridgeAbstract {
|
||||
const MAINTAINER = "logmanoriginal";
|
||||
const NAME = "Kununu Bridge";
|
||||
const URI = "https://www.kununu.com/";
|
||||
const MAINTAINER = 'logmanoriginal';
|
||||
const NAME = 'Kununu Bridge';
|
||||
const URI = 'https://www.kununu.com/';
|
||||
const CACHE_TIMEOUT = 86400; // 24h
|
||||
const DESCRIPTION = "Returns the latest reviews for a company and site of your choice.";
|
||||
const DESCRIPTION = 'Returns the latest reviews for a company and site of your choice.';
|
||||
|
||||
const PARAMETERS = array(
|
||||
'global' => array(
|
||||
'site'=>array(
|
||||
'name'=>'Site',
|
||||
'type'=>'list',
|
||||
'required'=>true,
|
||||
'title'=>'Select your site',
|
||||
'values'=>array(
|
||||
'Austria'=>'at',
|
||||
'Germany'=>'de',
|
||||
'Switzerland'=>'ch',
|
||||
'United States'=>'us'
|
||||
'site' => array(
|
||||
'name' => 'Site',
|
||||
'type' => 'list',
|
||||
'required' => true,
|
||||
'title' => 'Select your site',
|
||||
'values' => array(
|
||||
'Austria' => 'at',
|
||||
'Germany' => 'de',
|
||||
'Switzerland' => 'ch',
|
||||
'United States' => 'us'
|
||||
)
|
||||
),
|
||||
'full'=>array(
|
||||
'name'=>'Load full article',
|
||||
'type'=>'checkbox',
|
||||
'required'=>false,
|
||||
'exampleValue'=>'checked',
|
||||
'title'=>'Activate to load full article'
|
||||
),
|
||||
'full' => array(
|
||||
'name' => 'Load full article',
|
||||
'type' => 'checkbox',
|
||||
'required' => false,
|
||||
'exampleValue' => 'checked',
|
||||
'title' => 'Activate to load full article'
|
||||
)
|
||||
),
|
||||
|
||||
array(
|
||||
'company'=>array(
|
||||
'name'=>'Company',
|
||||
'required'=>true,
|
||||
'exampleValue'=>'kununu-us',
|
||||
'title'=>'Insert company name (i.e. Kununu US) or URI path (i.e. kununu-us)'
|
||||
'company' => array(
|
||||
'name' => 'Company',
|
||||
'required' => true,
|
||||
'exampleValue' => 'kununu-us',
|
||||
'title' => 'Insert company name (i.e. Kununu US) or URI path (i.e. kununu-us)'
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -44,7 +43,7 @@ class KununuBridge extends BridgeAbstract {
|
||||
public function getURI(){
|
||||
if(!is_null($this->getInput('company')) && !is_null($this->getInput('site'))){
|
||||
|
||||
$company = $this->fix_company_name($this->getInput('company'));
|
||||
$company = $this->fixCompanyName($this->getInput('company'));
|
||||
$site = $this->getInput('site');
|
||||
$section = '';
|
||||
|
||||
@@ -67,8 +66,8 @@ class KununuBridge extends BridgeAbstract {
|
||||
|
||||
function getName(){
|
||||
if(!is_null($this->getInput('company'))){
|
||||
$company = $this->fix_company_name($this->getInput('company'));
|
||||
return ($this->companyName?:$company).' - '.self::NAME;
|
||||
$company = $this->fixCompanyName($this->getInput('company'));
|
||||
return ($this->companyName ?: $company) . ' - ' . self::NAME;
|
||||
}
|
||||
|
||||
return paren::getName();
|
||||
@@ -82,7 +81,7 @@ class KununuBridge extends BridgeAbstract {
|
||||
if(!$html)
|
||||
returnServerError('Unable to receive data from ' . $this->getURI() . '!');
|
||||
// Update name for this request
|
||||
$this->companyName = $this->extract_company_name($html);
|
||||
$this->companyName = $this->extractCompanyName($html);
|
||||
|
||||
// Find the section with all the panels (reviews)
|
||||
$section = $html->find('section.kununu-scroll-element', 0);
|
||||
@@ -98,15 +97,18 @@ class KununuBridge extends BridgeAbstract {
|
||||
foreach($articles as $article){
|
||||
$item = array();
|
||||
|
||||
$item['author'] = $this->extract_article_author_position($article);
|
||||
$item['timestamp'] = $this->extract_article_date($article);
|
||||
$item['title'] = $this->extract_article_rating($article) . ' : ' . $this->extract_article_summary($article);
|
||||
$item['uri'] = $this->extract_article_uri($article);
|
||||
$item['author'] = $this->extractArticleAuthorPosition($article);
|
||||
$item['timestamp'] = $this->extractArticleDate($article);
|
||||
$item['title'] = $this->extractArticleRating($article)
|
||||
. ' : '
|
||||
. $this->extractArticleSummary($article);
|
||||
|
||||
$item['uri'] = $this->extractArticleUri($article);
|
||||
|
||||
if($full)
|
||||
$item['content'] = $this->extract_full_description($item['uri']);
|
||||
$item['content'] = $this->extractFullDescription($item['uri']);
|
||||
else
|
||||
$item['content'] = $this->extract_article_description($article);
|
||||
$item['content'] = $this->extractArticleDescription($article);
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
@@ -115,24 +117,24 @@ class KununuBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Fixes relative URLs in the given text
|
||||
*/
|
||||
private function fix_url($text){
|
||||
private function fixUrl($text){
|
||||
return preg_replace('/href=(\'|\")\//i', 'href="'.self::URI, $text);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns a fixed version of the provided company name
|
||||
*/
|
||||
private function fix_company_name($company){
|
||||
private function fixCompanyName($company){
|
||||
$company = trim($company);
|
||||
$company = str_replace(' ', '-', $company);
|
||||
$company = strtolower($company);
|
||||
return $this->encode_umlauts($company);
|
||||
return $this->encodeUmlauts($company);
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes unmlauts in the given text
|
||||
*/
|
||||
private function encode_umlauts($text){
|
||||
private function encodeUmlauts($text){
|
||||
$umlauts = Array("/ä/","/ö/","/ü/","/Ä/","/Ö/","/Ü/","/ß/");
|
||||
$replace = Array("ae","oe","ue","Ae","Oe","Ue","ss");
|
||||
|
||||
@@ -142,7 +144,7 @@ class KununuBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Returns the company name from the review html
|
||||
*/
|
||||
private function extract_company_name($html){
|
||||
private function extractCompanyName($html){
|
||||
$company_name = $html->find('h1[itemprop=name]', 0);
|
||||
if(is_null($company_name))
|
||||
returnServerError('Cannot find company name!');
|
||||
@@ -153,7 +155,7 @@ class KununuBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Returns the date from a given article
|
||||
*/
|
||||
private function extract_article_date($article){
|
||||
private function extractArticleDate($article){
|
||||
// They conviniently provide a time attribute for us :)
|
||||
$date = $article->find('meta[itemprop=dateCreated]', 0);
|
||||
if(is_null($date))
|
||||
@@ -165,7 +167,7 @@ class KununuBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Returns the rating from a given article
|
||||
*/
|
||||
private function extract_article_rating($article){
|
||||
private function extractArticleRating($article){
|
||||
$rating = $article->find('span.rating', 0);
|
||||
if(is_null($rating))
|
||||
returnServerError('Cannot find article rating!');
|
||||
@@ -176,7 +178,7 @@ class KununuBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Returns the summary from a given article
|
||||
*/
|
||||
private function extract_article_summary($article){
|
||||
private function extractArticleSummary($article){
|
||||
$summary = $article->find('[itemprop=name]', 0);
|
||||
if(is_null($summary))
|
||||
returnServerError('Cannot find article summary!');
|
||||
@@ -187,7 +189,7 @@ class KununuBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Returns the URI from a given article
|
||||
*/
|
||||
private function extract_article_uri($article){
|
||||
private function extractArticleUri($article){
|
||||
$anchor = $article->find('ku-company-review-more', 0);
|
||||
if(is_null($anchor))
|
||||
returnServerError('Cannot find article URI!');
|
||||
@@ -198,7 +200,7 @@ class KununuBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Returns the position of the author from a given article
|
||||
*/
|
||||
private function extract_article_author_position($article){
|
||||
private function extractArticleAuthorPosition($article){
|
||||
// We need to parse the user-content manually
|
||||
$user_content = $article->find('div.user-content', 0);
|
||||
if(is_null($user_content))
|
||||
@@ -219,18 +221,18 @@ class KununuBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Returns the description from a given article
|
||||
*/
|
||||
private function extract_article_description($article){
|
||||
private function extractArticleDescription($article){
|
||||
$description = $article->find('[itemprop=reviewBody]', 0);
|
||||
if(is_null($description))
|
||||
returnServerError('Cannot find article description!');
|
||||
|
||||
return $this->fix_url($description->innertext);
|
||||
return $this->fixUrl($description->innertext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the full description from a given uri
|
||||
*/
|
||||
private function extract_full_description($uri){
|
||||
private function extractFullDescription($uri){
|
||||
// Load full article
|
||||
$html = getSimpleHTMLDOMCached($uri);
|
||||
if($html === false)
|
||||
@@ -242,6 +244,6 @@ class KununuBridge extends BridgeAbstract {
|
||||
returnServerError('Cannot find article!');
|
||||
|
||||
// Luckily they use the same layout for the review overview and full article pages :)
|
||||
return $this->extract_article_description($article);
|
||||
return $this->extractArticleDescription($article);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user