WYSIJA_help_readme

The MailPoet Newsletters WYSIJA help readme class.

Defined (1)

The class is defined in the following location(s).

/helpers/readme.php  
  1. class WYSIJA_help_readme extends WYSIJA_object{ 
  2. var $changelog=array(); 
  3.  
  4. function __construct() { 
  5. parent::__construct(); 
  6.  
  7. function scan($file=false) { 
  8. if(!$file) $file = WYSIJA_DIR.'readme.txt'; 
  9. $handle = fopen($file, 'r'); 
  10. $content = fread ($handle, filesize ($file)); 
  11. fclose($handle); 
  12.  
  13. // get the changelog content from the readme 
  14. $exploded = explode('== Changelog ==', $content); 
  15. $exploded_versions = explode("\n=", $this->markdown_to_html_links($exploded[1]) ); 
  16. foreach($exploded_versions as $key=> $version) { 
  17. if(!trim($version)) unset($exploded_versions[$key]); 
  18.  
  19. foreach($exploded_versions as $key => $version) { 
  20. $version_number = ''; 
  21. foreach(explode("\n", $version) as $key => $commented_line) { 
  22. if($key==0) { 
  23. //extract version number 
  24. $expldoed_version_number = explode(' - ', $commented_line); 
  25. $version_number = trim($expldoed_version_number[0]); 
  26. }else{ 
  27. //strip the stars 
  28. if(!isset($this->changelog[$version_number])) $this->changelog[$version_number] = array(); 
  29. if(trim($commented_line)) $this->changelog[$version_number][] = str_replace('* ', '', $commented_line); 
  30.  
  31.  
  32. /** 
  33. * preg_replace that will parse a txt and look for links starting with http, https, ftp, file 
  34. * @param string $content 
  35. * @return string 
  36. */ 
  37. function markdown_to_html_links($content) { 
  38. $pattern = "/\[(.*?)\]\((.*?)\)/i"; 
  39. $replace = "<a href=\"$2\" target=\"_blank\" >$1</a>"; 
  40. return preg_replace($pattern, $replace, $content);