mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-19 06:42:14 +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:
@@ -10,41 +10,43 @@ class WikipediaBridge extends BridgeAbstract {
|
||||
const DESCRIPTION = 'Returns articles for a language of your choice';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'language'=>array(
|
||||
'name'=>'Language',
|
||||
'type'=>'list',
|
||||
'required'=>true,
|
||||
'title'=>'Select your language',
|
||||
'exampleValue'=>'English',
|
||||
'values'=>array(
|
||||
'English'=>'en',
|
||||
'Dutch'=>'nl',
|
||||
'Esperanto'=>'eo',
|
||||
'French'=>'fr',
|
||||
'German'=>'de',
|
||||
'language' => array(
|
||||
'name' => 'Language',
|
||||
'type' => 'list',
|
||||
'required' => true,
|
||||
'title' => 'Select your language',
|
||||
'exampleValue' => 'English',
|
||||
'values' => array(
|
||||
'English' => 'en',
|
||||
'Dutch' => 'nl',
|
||||
'Esperanto' => 'eo',
|
||||
'French' => 'fr',
|
||||
'German' => 'de',
|
||||
)
|
||||
),
|
||||
'subject'=>array(
|
||||
'name'=>'Subject',
|
||||
'type'=>'list',
|
||||
'required'=>true,
|
||||
'title'=>'What subject are you interested in?',
|
||||
'exampleValue'=>'Today\'s featured article',
|
||||
'values'=>array(
|
||||
'Today\'s featured article'=>'tfa',
|
||||
'Did you know…'=>'dyk'
|
||||
'subject' => array(
|
||||
'name' => 'Subject',
|
||||
'type' => 'list',
|
||||
'required' => true,
|
||||
'title' => 'What subject are you interested in?',
|
||||
'exampleValue' => 'Today\'s featured article',
|
||||
'values' => array(
|
||||
'Today\'s featured article' => 'tfa',
|
||||
'Did you know…' => 'dyk'
|
||||
)
|
||||
),
|
||||
'fullarticle'=>array(
|
||||
'name'=>'Load full article',
|
||||
'type'=>'checkbox',
|
||||
'title'=>'Activate to always load the full article'
|
||||
'fullarticle' => array(
|
||||
'name' => 'Load full article',
|
||||
'type' => 'checkbox',
|
||||
'title' => 'Activate to always load the full article'
|
||||
)
|
||||
));
|
||||
|
||||
public function getURI(){
|
||||
return 'https://' . strtolower($this->getInput('language')) . '.wikipedia.org';
|
||||
}
|
||||
return 'https://'
|
||||
. strtolower($this->getInput('language'))
|
||||
. '.wikipedia.org';
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
switch($this->getInput('subject')){
|
||||
@@ -61,17 +63,23 @@ class WikipediaBridge extends BridgeAbstract {
|
||||
|
||||
switch($subject){
|
||||
case WIKIPEDIA_SUBJECT_TFA:
|
||||
$name = 'Today\'s featured article from ' . strtolower($this->getInput('language')) . '.wikipedia.org';
|
||||
$name = 'Today\'s featured article from '
|
||||
. strtolower($this->getInput('language'))
|
||||
. '.wikipedia.org';
|
||||
break;
|
||||
case WIKIPEDIA_SUBJECT_DYK:
|
||||
$name = 'Did you know? - articles from ' . strtolower($this->getInput('language')) . '.wikipedia.org';
|
||||
$name = 'Did you know? - articles from '
|
||||
. strtolower($this->getInput('language'))
|
||||
. '.wikipedia.org';
|
||||
break;
|
||||
default:
|
||||
$name = 'Articles from ' . strtolower($this->getInput('language')) . '.wikipedia.org';
|
||||
$name = 'Articles from '
|
||||
. strtolower($this->getInput('language'))
|
||||
. '.wikipedia.org';
|
||||
break;
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
public function collectData(){
|
||||
|
||||
@@ -98,9 +106,9 @@ class WikipediaBridge extends BridgeAbstract {
|
||||
/*
|
||||
* Now read content depending on the language (make sure to create one function per language!)
|
||||
* We build the function name automatically, just make sure you create a private function ending
|
||||
* with your desired language code, where the language code is upper case! (en -> GetContentsEN).
|
||||
* with your desired language code, where the language code is upper case! (en -> getContentsEN).
|
||||
*/
|
||||
$function = 'GetContents' . strtoupper($this->getInput('language'));
|
||||
$function = 'getContents' . ucfirst(strtolower($this->getInput('language')));
|
||||
|
||||
if(!method_exists($this, $function))
|
||||
returnServerError('A function to get the contents for your language is missing (\'' . $function . '\')!');
|
||||
@@ -116,21 +124,27 @@ class WikipediaBridge extends BridgeAbstract {
|
||||
* @param $element A simplehtmldom element
|
||||
* @return The $element->innertext with all URIs replaced
|
||||
*/
|
||||
private function ReplaceURIInHTMLElement($element){
|
||||
private function replaceUriInHtmlElement($element){
|
||||
return str_replace('href="/', 'href="' . $this->getURI() . '/', $element->innertext);
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds a new item to $items using a generic operation (should work for most (all?) wikis)
|
||||
* $anchorText can be specified if the wiki in question doesn't use '...' (like Dutch, French and Italian)
|
||||
* $anchorFallbackIndex can be used to specify a different fallback link than the first (e.g., -1 for the last)
|
||||
* Adds a new item to $items using a generic operation (should work for most
|
||||
* (all?) wikis) $anchorText can be specified if the wiki in question doesn't
|
||||
* use '...' (like Dutch, French and Italian) $anchorFallbackIndex can be
|
||||
* used to specify a different fallback link than the first
|
||||
* (e.g., -1 for the last)
|
||||
*/
|
||||
private function AddTodaysFeaturedArticleGeneric($element, $fullArticle, $anchorText = '...', $anchorFallbackIndex = 0){
|
||||
private function addTodaysFeaturedArticleGeneric($element
|
||||
, $fullArticle
|
||||
, $anchorText = '...'
|
||||
, $anchorFallbackIndex = 0){
|
||||
// Clean the bottom of the featured article
|
||||
if ($element->find('div', -1))
|
||||
$element->find('div', -1)->outertext = '';
|
||||
|
||||
// The title and URI of the article can be found in an anchor containing the string '...' in most wikis ('full article ...')
|
||||
// The title and URI of the article can be found in an anchor containing
|
||||
// the string '...' in most wikis ('full article ...')
|
||||
$target = $element->find('p/a', $anchorFallbackIndex);
|
||||
foreach($element->find('//a') as $anchor){
|
||||
if(strpos($anchor->innertext, $anchorText) !== false){
|
||||
@@ -144,9 +158,9 @@ class WikipediaBridge extends BridgeAbstract {
|
||||
$item['title'] = $target->title;
|
||||
|
||||
if(!$fullArticle)
|
||||
$item['content'] = strip_tags($this->ReplaceURIInHTMLElement($element), '<a><p><br><img>');
|
||||
$item['content'] = strip_tags($this->replaceUriInHtmlElement($element), '<a><p><br><img>');
|
||||
else
|
||||
$item['content'] = $this->LoadFullArticle($item['uri']);
|
||||
$item['content'] = $this->loadFullArticle($item['uri']);
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
@@ -154,7 +168,7 @@ class WikipediaBridge extends BridgeAbstract {
|
||||
/*
|
||||
* Adds a new item to $items using a generic operation (should work for most (all?) wikis)
|
||||
*/
|
||||
private function AddDidYouKnowGeneric($element, $fullArticle){
|
||||
private function addDidYouKnowGeneric($element, $fullArticle){
|
||||
foreach($element->find('ul', 0)->find('li') as $entry){
|
||||
$item = array();
|
||||
|
||||
@@ -163,9 +177,9 @@ class WikipediaBridge extends BridgeAbstract {
|
||||
$item['title'] = strip_tags($entry->innertext);
|
||||
|
||||
if(!$fullArticle)
|
||||
$item['content'] = $this->ReplaceURIInHTMLElement($entry);
|
||||
$item['content'] = $this->replaceUriInHtmlElement($entry);
|
||||
else
|
||||
$item['content'] = $this->LoadFullArticle($item['uri']);
|
||||
$item['content'] = $this->loadFullArticle($item['uri']);
|
||||
|
||||
$this->items[] = $item;
|
||||
}
|
||||
@@ -174,7 +188,7 @@ class WikipediaBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Loads the full article from a given URI
|
||||
*/
|
||||
private function LoadFullArticle($uri){
|
||||
private function loadFullArticle($uri){
|
||||
$content_html = getSimpleHTMLDOMCached($uri);
|
||||
|
||||
if(!$content_html)
|
||||
@@ -199,15 +213,15 @@ class WikipediaBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Implementation for de.wikipedia.org
|
||||
*/
|
||||
private function GetContentsDE($html, $subject, $fullArticle){
|
||||
private function getContentsDe($html, $subject, $fullArticle){
|
||||
switch($subject){
|
||||
case WIKIPEDIA_SUBJECT_TFA:
|
||||
$element = $html->find('div[id=mf-tfa]', 0);
|
||||
$this->AddTodaysFeaturedArticleGeneric($element, $fullArticle);
|
||||
$this->addTodaysFeaturedArticleGeneric($element, $fullArticle);
|
||||
break;
|
||||
case WIKIPEDIA_SUBJECT_DYK:
|
||||
$element = $html->find('div[id=mf-dyk]', 0);
|
||||
$this->AddDidYouKnowGeneric($element, $fullArticle);
|
||||
$this->addDidYouKnowGeneric($element, $fullArticle);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -217,15 +231,15 @@ class WikipediaBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Implementation for fr.wikipedia.org
|
||||
*/
|
||||
private function GetContentsFR($html, $subject, $fullArticle){
|
||||
private function getContentsFr($html, $subject, $fullArticle){
|
||||
switch($subject){
|
||||
case WIKIPEDIA_SUBJECT_TFA:
|
||||
$element = $html->find('div[id=accueil-lumieresur]', 0);
|
||||
$this->AddTodaysFeaturedArticleGeneric($element, $fullArticle, 'Lire la suite');
|
||||
$this->addTodaysFeaturedArticleGeneric($element, $fullArticle, 'Lire la suite');
|
||||
break;
|
||||
case WIKIPEDIA_SUBJECT_DYK:
|
||||
$element = $html->find('div[id=SaviezVous]', 0);
|
||||
$this->AddDidYouKnowGeneric($element, $fullArticle);
|
||||
$this->addDidYouKnowGeneric($element, $fullArticle);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -235,15 +249,15 @@ class WikipediaBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Implementation for en.wikipedia.org
|
||||
*/
|
||||
private function GetContentsEN($html, $subject, $fullArticle){
|
||||
private function getContentsEn($html, $subject, $fullArticle){
|
||||
switch($subject){
|
||||
case WIKIPEDIA_SUBJECT_TFA:
|
||||
$element = $html->find('div[id=mp-tfa]', 0);
|
||||
$this->AddTodaysFeaturedArticleGeneric($element, $fullArticle);
|
||||
$this->addTodaysFeaturedArticleGeneric($element, $fullArticle);
|
||||
break;
|
||||
case WIKIPEDIA_SUBJECT_DYK:
|
||||
$element = $html->find('div[id=mp-dyk]', 0);
|
||||
$this->AddDidYouKnowGeneric($element, $fullArticle);
|
||||
$this->addDidYouKnowGeneric($element, $fullArticle);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -253,15 +267,15 @@ class WikipediaBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Implementation for eo.wikipedia.org
|
||||
*/
|
||||
private function GetContentsEO($html, $subject, $fullArticle){
|
||||
private function getContentsEo($html, $subject, $fullArticle){
|
||||
switch($subject){
|
||||
case WIKIPEDIA_SUBJECT_TFA:
|
||||
$element = $html->find('div[id=mf-artikolo-de-la-semajno]', 0);
|
||||
$this->AddTodaysFeaturedArticleGeneric($element, $fullArticle);
|
||||
$this->addTodaysFeaturedArticleGeneric($element, $fullArticle);
|
||||
break;
|
||||
case WIKIPEDIA_SUBJECT_DYK:
|
||||
$element = $html->find('div[id=mw-content-text]', 0)->find('table', 4)->find('td', 4);
|
||||
$this->AddDidYouKnowGeneric($element, $fullArticle);
|
||||
$this->addDidYouKnowGeneric($element, $fullArticle);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -271,15 +285,15 @@ class WikipediaBridge extends BridgeAbstract {
|
||||
/**
|
||||
* Implementation for nl.wikipedia.org
|
||||
*/
|
||||
private function GetContentsNL($html, $subject, $fullArticle){
|
||||
private function getContentsNl($html, $subject, $fullArticle){
|
||||
switch($subject){
|
||||
case WIKIPEDIA_SUBJECT_TFA:
|
||||
$element = $html->find('div[id=mf-uitgelicht]', 0);
|
||||
$this->AddTodaysFeaturedArticleGeneric($element, $fullArticle, 'Lees meer');
|
||||
$this->addTodaysFeaturedArticleGeneric($element, $fullArticle, 'Lees meer');
|
||||
break;
|
||||
case WIKIPEDIA_SUBJECT_DYK:
|
||||
$element = $html->find('div[id=mw-content-text]', 0)->find('table', 4)->find('td', 2);
|
||||
$this->AddDidYouKnowGeneric($element, $fullArticle);
|
||||
$this->addDidYouKnowGeneric($element, $fullArticle);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
Reference in New Issue
Block a user