ProjectMGameBridge.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. class ProjectMGameBridge extends BridgeAbstract{
  3. public function loadMetadatas() {
  4. $this->maintainer = "corenting";
  5. $this->name = "Project M Game Bridge";
  6. $this->uri = "http://projectmgame.com/en/";
  7. $this->description = "Returns the newest articles.";
  8. }
  9. public function collectData(array $param){
  10. $html = '';
  11. $html = $this->getSimpleHTMLDOM('http://projectmgame.com/en/') or $this->returnServerError('Error while downloading the Project M homepage');
  12. foreach($html->find('article') as $article) {
  13. $item = array();
  14. $item['uri'] = 'http://projectmgame.com/en/'.$article->find('section div.info_block a',0)->href;
  15. $item['title'] = $article->find('h1 p',0)->innertext;
  16. $p_list = $article->find('section p');
  17. $content = '';
  18. foreach($p_list as $p) $content .= $p->innertext;
  19. $item['content'] = $content;
  20. // get publication date
  21. $str_date = $article->find('section div.info_block a',0)->innertext;
  22. $item['timestamp'] = strtotime($str_date);
  23. $this->items[] = $item;
  24. }
  25. }
  26. public function getCacheDuration(){
  27. return 10800; //3 hours
  28. }
  29. }