| 1 |
<?php |
| 2 |
namespace WPIDE\App\Controllers; |
| 3 |
|
| 4 |
use WPIDE\App\Classes\Parsedown; |
| 5 |
use WPIDE\App\Kernel\Response; |
| 6 |
use const WPIDE\Constants\DIR; |
| 7 |
|
| 8 |
class ChangelogController { |
| 9 |
|
| 10 |
public function get(Response $response) { |
| 11 |
|
| 12 |
$parsedown = new Parsedown; |
| 13 |
|
| 14 |
$changelog = ''; |
| 15 |
|
| 16 |
$data = file_get_contents( DIR.'readme.txt' ); |
| 17 |
|
| 18 |
if ( ! empty( $data ) ) { |
| 19 |
$data = explode( '== Changelog ==', $data ); |
| 20 |
if ( ! empty( $data[1] ) ) { |
| 21 |
|
| 22 |
$changelog = $data[1]; |
| 23 |
$changelog = preg_replace( |
| 24 |
array( |
| 25 |
'/\[\/\/\]\: \# fs_.+?_only_begin/', |
| 26 |
'/\[\/\/\]\: \# fs_.+?_only_end/', |
| 27 |
), |
| 28 |
'', |
| 29 |
$changelog |
| 30 |
); |
| 31 |
|
| 32 |
$changelog = $parsedown->text( $changelog ); |
| 33 |
|
| 34 |
$changelog = preg_replace( |
| 35 |
array( |
| 36 |
'/\<strong\>(.+?)\<\/strong>\:(.+?)\n/i', |
| 37 |
'/\<p\>/', |
| 38 |
'/\<\/p\>/', |
| 39 |
'/\<a/', |
| 40 |
), |
| 41 |
array( |
| 42 |
'<span class="update-type $1">$1</span><span class="update-txt">$2</span>', |
| 43 |
'', |
| 44 |
'', |
| 45 |
'<a target="_blank"', |
| 46 |
), |
| 47 |
$changelog |
| 48 |
); |
| 49 |
|
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
return $response->html($changelog); |
| 54 |
|
| 55 |
} |
| 56 |
} |