[KununuBridge] Improve feed contents

- Add support for ratings
- Add support for benefits
- Fix broken timestamp
This commit is contained in:
logmanoriginal 2019-06-21 00:00:44 +02:00
parent 7ff97c0c7b
commit 7926ffad73

View file

@ -24,6 +24,16 @@ class KununuBridge extends BridgeAbstract {
'type' => 'checkbox', 'type' => 'checkbox',
'exampleValue' => 'checked', 'exampleValue' => 'checked',
'title' => 'Activate to load full article' 'title' => 'Activate to load full article'
),
'include_ratings' => array(
'name' => 'Include ratings',
'type' => 'checkbox',
'title' => 'Activate to include ratings in the feed'
),
'include_benefits' => array(
'name' => 'Include benefits',
'type' => 'checkbox',
'title' => 'Activate to include benefits in the feed'
) )
), ),
array( array(
@ -116,7 +126,7 @@ class KununuBridge extends BridgeAbstract {
$item = array(); $item = array();
$item['author'] = $this->extractArticleAuthorPosition($article); $item['author'] = $this->extractArticleAuthorPosition($article);
$item['timestamp'] = strtotime($date); $item['timestamp'] = strtotime($date->content);
$item['title'] = $rating->getAttribute('aria-label') $item['title'] = $rating->getAttribute('aria-label')
. ' : ' . ' : '
. strip_tags($summary->innertext); . strip_tags($summary->innertext);
@ -175,7 +185,32 @@ class KununuBridge extends BridgeAbstract {
$description = $article->find('[itemprop=reviewBody]', 0) $description = $article->find('[itemprop=reviewBody]', 0)
or returnServerError('Cannot find article description!'); or returnServerError('Cannot find article description!');
return $description->innertext; $retVal = $description->innertext;
if($this->getInput('include_ratings')
&& ($ratings = $article->find('.review-ratings .rating-group'))) {
$retVal .= (empty($retVal) ? '' : '<hr>') . '<table>';
foreach($ratings as $rating) {
$retVal .= <<<EOD
<tr>
<td>{$rating->find('.rating-title', 0)->plaintext}
<td>{$rating->find('.rating-badge', 0)->plaintext}
</tr>
EOD;
}
$retVal .= '</table>';
}
if($this->getInput('include_benefits')
&& ($benefits = $article->find('benefit'))) {
$retVal .= (empty($retVal) ? '' : '<hr>') . '<ul>';
foreach($benefits as $benefit) {
$retVal .= "<li>{$benefit->plaintext}</li>";
}
$retVal .= '</ul>';
}
return $retVal;
} }
/** /**