Skip to content

Commit

Permalink
Save theme screenshot from repo
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayoola FALOLA committed May 18, 2019
1 parent 98f997e commit d8381a9
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion pagecarton/core/library/Ayoola/Extension/Import/Repository.php
Expand Up @@ -89,13 +89,17 @@ protected function init()
$content = self::fetchLink( $link, array( 'time_out' => 28800, 'connect_time_out' => 28800, 'raw_response_header' => true, 'return_as_array' => true, ) ); $content = self::fetchLink( $link, array( 'time_out' => 28800, 'connect_time_out' => 28800, 'raw_response_header' => true, 'return_as_array' => true, ) );
$filename = tempnam( CACHE_DIR, __CLASS__ ) . ''; $filename = tempnam( CACHE_DIR, __CLASS__ ) . '';


if(preg_match('/Content-Disposition: .*filename=([^ ]+)/', $content['options']['raw_response_header'], $matches)) { if(preg_match('/Content-Disposition: .*filename=([^0-9A-Za-z_-.]+)/', $content['options']['raw_response_header'], $matches)) {
$filename .= $matches[1]; $filename .= $matches[1];
// var_export( $matches );
} }
else else
{ {
$filename .= '.tar.gz'; $filename .= '.tar.gz';
} }



// var_export( $filename ); // var_export( $filename );
// var_export( $content['options'] ); // var_export( $content['options'] );
// exit(); // exit();
Expand All @@ -104,6 +108,20 @@ protected function init()
file_put_contents( $filename, $content['response'] ); file_put_contents( $filename, $content['response'] );
$values = static::getOtherInstallOptions( $filename ); $values = static::getOtherInstallOptions( $filename );


copy( $filename, $filename . '.copy.tar.gz' );

// add screenshot
$repository = 'Ayoola_Phar_Data';

$repository = new $repository( $filename );
// var_export( $filename );
$repository->startBuffering();
$repository['screenshot.jpg'] = file_get_contents( $photoUrl );
$repository->stopBuffering();
// $repository->compress( Ayoola_Phar::GZ );
// var_export( Ayoola_Doc::getFiles( dirname( $filename ) ) );
// exit();

try try
{ {
$class = new static::$_pluginClass( array( 'xno_init' => true, 'fake_values' => $values, 'path' => $filename, ) ); $class = new static::$_pluginClass( array( 'xno_init' => true, 'fake_values' => $values, 'path' => $filename, ) );
Expand Down

0 comments on commit d8381a9

Please sign in to comment.