forked from blallo/rss-bridge
[Kununu] Fix content check condition
Check if null instead of false according to: http://simplehtmldom.sourceforge.net/manual.htm#section_find
This commit is contained in:
parent
83b5bbcc37
commit
5ad3198d71
1 changed files with 10 additions and 10 deletions
|
@ -124,11 +124,11 @@ class KununuBridge extends BridgeAbstract {
|
||||||
*/
|
*/
|
||||||
private function extract_company_name($html){
|
private function extract_company_name($html){
|
||||||
$panel = $html->find('div.panel', 0);
|
$panel = $html->find('div.panel', 0);
|
||||||
if($panel === false)
|
if(is_null($panel))
|
||||||
returnServerError('Cannot find panel for company name!');
|
returnServerError('Cannot find panel for company name!');
|
||||||
|
|
||||||
$company_name = $panel->find('h1', 0);
|
$company_name = $panel->find('h1', 0);
|
||||||
if($company_name === false)
|
if(is_null($company_name))
|
||||||
returnServerError('Cannot find company name!');
|
returnServerError('Cannot find company name!');
|
||||||
|
|
||||||
return $company_name->plaintext;
|
return $company_name->plaintext;
|
||||||
|
@ -140,7 +140,7 @@ class KununuBridge extends BridgeAbstract {
|
||||||
private function extract_article_date($article){
|
private function extract_article_date($article){
|
||||||
// They conviniently provide a time attribute for us :)
|
// They conviniently provide a time attribute for us :)
|
||||||
$date = $article->find('time[itemprop=dtreviewed]', 0);
|
$date = $article->find('time[itemprop=dtreviewed]', 0);
|
||||||
if($date === false)
|
if(is_null($date))
|
||||||
returnServerError('Cannot find article date!');
|
returnServerError('Cannot find article date!');
|
||||||
|
|
||||||
return strtotime($date->datetime);
|
return strtotime($date->datetime);
|
||||||
|
@ -151,7 +151,7 @@ class KununuBridge extends BridgeAbstract {
|
||||||
*/
|
*/
|
||||||
private function extract_article_rating($article){
|
private function extract_article_rating($article){
|
||||||
$rating = $article->find('span.rating', 0);
|
$rating = $article->find('span.rating', 0);
|
||||||
if($rating === false)
|
if(is_null($rating))
|
||||||
returnServerError('Cannot find article rating!');
|
returnServerError('Cannot find article rating!');
|
||||||
|
|
||||||
return $rating->getAttribute('aria-label');
|
return $rating->getAttribute('aria-label');
|
||||||
|
@ -162,7 +162,7 @@ class KununuBridge extends BridgeAbstract {
|
||||||
*/
|
*/
|
||||||
private function extract_article_summary($article){
|
private function extract_article_summary($article){
|
||||||
$summary = $article->find('[itemprop=summary]', 0);
|
$summary = $article->find('[itemprop=summary]', 0);
|
||||||
if($summary === false)
|
if(is_null($summary))
|
||||||
returnServerError('Cannot find article summary!');
|
returnServerError('Cannot find article summary!');
|
||||||
|
|
||||||
return strip_tags($summary->innertext);
|
return strip_tags($summary->innertext);
|
||||||
|
@ -174,11 +174,11 @@ class KununuBridge extends BridgeAbstract {
|
||||||
private function extract_article_uri($article){
|
private function extract_article_uri($article){
|
||||||
// Notice: This first part is the same as in extract_article_summary!
|
// Notice: This first part is the same as in extract_article_summary!
|
||||||
$summary = $article->find('[itemprop=summary]', 0);
|
$summary = $article->find('[itemprop=summary]', 0);
|
||||||
if($summary === false)
|
if(is_null($summary))
|
||||||
returnServerError('Cannot find article summary!');
|
returnServerError('Cannot find article summary!');
|
||||||
|
|
||||||
$anchor = $summary->find('a', 0);
|
$anchor = $summary->find('a', 0);
|
||||||
if($anchor === false)
|
if(is_null($anchor))
|
||||||
returnServerError('Cannot find article URI!');
|
returnServerError('Cannot find article URI!');
|
||||||
|
|
||||||
return self::URI . $anchor->href;
|
return self::URI . $anchor->href;
|
||||||
|
@ -190,7 +190,7 @@ class KununuBridge extends BridgeAbstract {
|
||||||
private function extract_article_author_position($article){
|
private function extract_article_author_position($article){
|
||||||
// We need to parse the aside manually
|
// We need to parse the aside manually
|
||||||
$aside = $article->find('aside', 0);
|
$aside = $article->find('aside', 0);
|
||||||
if($aside === false)
|
if(is_null($aside))
|
||||||
returnServerError('Cannot find article author information!');
|
returnServerError('Cannot find article author information!');
|
||||||
|
|
||||||
// Go through all h2 elements to find index of required span (I know... it's stupid)
|
// Go through all h2 elements to find index of required span (I know... it's stupid)
|
||||||
|
@ -210,7 +210,7 @@ class KununuBridge extends BridgeAbstract {
|
||||||
*/
|
*/
|
||||||
private function extract_article_description($article){
|
private function extract_article_description($article){
|
||||||
$description = $article->find('div[itemprop=description]', 0);
|
$description = $article->find('div[itemprop=description]', 0);
|
||||||
if($description === false)
|
if(is_null($description))
|
||||||
returnServerError('Cannot find article description!');
|
returnServerError('Cannot find article description!');
|
||||||
|
|
||||||
return $this->fix_url($description->innertext);
|
return $this->fix_url($description->innertext);
|
||||||
|
@ -227,7 +227,7 @@ class KununuBridge extends BridgeAbstract {
|
||||||
|
|
||||||
// Find the article
|
// Find the article
|
||||||
$article = $html->find('article', 0);
|
$article = $html->find('article', 0);
|
||||||
if($article === false)
|
if(is_null($article))
|
||||||
returnServerError('Cannot find article!');
|
returnServerError('Cannot find article!');
|
||||||
|
|
||||||
// Luckily they use the same layout for the review overview and full article pages :)
|
// Luckily they use the same layout for the review overview and full article pages :)
|
||||||
|
|
Loading…
Reference in a new issue