2016-06-26 01:33:27 +03:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* GithubIssueBridge
|
|
|
|
*
|
|
|
|
* @name GithubIssue Bridge
|
|
|
|
* @description Returns the comments of a github project issue
|
|
|
|
*/
|
|
|
|
class GithubIssueBridge extends BridgeAbstract{
|
|
|
|
public function loadMetadatas() {
|
|
|
|
|
|
|
|
$this->maintainer = 'Pierre Mazière';
|
|
|
|
$this->name = 'Github Issue';
|
|
|
|
$this->uri = '';
|
|
|
|
$this->description = 'Returns the comments of a github project issue';
|
|
|
|
|
2016-08-22 02:25:56 +03:00
|
|
|
$this->parameters[]=array (
|
|
|
|
'u'=>array(
|
|
|
|
'name'=>'User name',
|
|
|
|
'required'=>true
|
|
|
|
),
|
|
|
|
'p'=>array(
|
|
|
|
'name'=>'Project name',
|
|
|
|
'required'=>true
|
|
|
|
),
|
|
|
|
'i'=>array(
|
|
|
|
'name'=>'Issue number',
|
|
|
|
'type'=>'number',
|
|
|
|
'required'=>true
|
|
|
|
)
|
|
|
|
);
|
2016-06-26 01:33:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function collectData(array $param){
|
|
|
|
$uri = 'https://github.com/'.$param['u'].'/'.$param['p'].'/issues/'.$param['i'];
|
2016-07-08 20:06:35 +03:00
|
|
|
$html = $this->getSimpleHTMLDOM($uri)
|
2016-08-17 15:45:08 +03:00
|
|
|
or $this->returnServerError('No results for Github Issue '.$param['i'].' in project '.$param['u'].'/'.$param['p']);
|
2016-06-26 01:33:27 +03:00
|
|
|
|
|
|
|
foreach($html->find('.js-comment-container') as $comment){
|
|
|
|
|
2016-08-22 19:55:59 +03:00
|
|
|
$item = array();
|
|
|
|
$item['author']=$comment->find('img',0)->getAttribute('alt');
|
2016-06-26 01:33:27 +03:00
|
|
|
|
|
|
|
$comment=$comment->firstChild()->nextSibling();
|
|
|
|
|
2016-08-22 19:55:59 +03:00
|
|
|
$item['uri']=$uri.'#'.$comment->getAttribute('id');
|
|
|
|
$item['title']=trim($comment->firstChild()->plaintext);
|
|
|
|
$item['timestamp']=strtotime($comment->find('relative-time',0)->getAttribute('datetime'));
|
|
|
|
$item['content']=$comment->find('.comment-body',0)->innertext;
|
2016-06-26 01:33:27 +03:00
|
|
|
|
|
|
|
$this->items[]=$item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCacheDuration(){
|
|
|
|
return 600; // ten minutes
|
|
|
|
}
|
|
|
|
}
|