Skip to content

Instantly share code, notes, and snippets.

@mbabker mbabker/export.php Secret
Created Feb 4, 2015

Embed
What would you like to do?
Export all specified downloads from JoomlaCode
/**
* JoomlaCode API Connector
*
* @since 1.0
*/
class JoomlaCodeConnector extends JApplicationCli
{
/**
* Array containing Joomla! 1.0 Release IDs
*
* @var array
* @since 1.0
*/
private $jc10ReleaseIds = array(
109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 4508, 4509, 6729, 6730, 6828, 6829
);
/**
* Method to run the application routines.
*
* @return void
*
* @since 1.0
*/
protected function doExecute()
{
try
{
$gforge = new GForge('http://joomlacode.org/gf');
$gforge->login('username', 'password');
$jhttp = JHttpFactory::getHttp();
$baseDLurl = 'http://joomlacode.org';
$releases = $gforge->getReleases($this->jc10ReleaseIds);
foreach ($releases as $release)
{
$this->out('Processing release ID: ' . $release->frs_release_id);
$filesystems = $gforge->getFilesystemsForRelease($release->frs_release_id);
foreach ($filesystems as $filesystem)
{
$this->out('Processing package: ' . $filesystem->file_name_safe);
$file = $jhttp->get($baseDLurl . $filesystem->download_url);
$target = __DIR__ . '/packages/' . $filesystem->file_name_safe;
file_put_contents($target, $file->body);
$this->out('Package successfully downloaded');
}
}
}
catch (Exception $e)
{
$this->out('Exception caught: ' . $e->getMessage(), true);
$this->out('Stack trace: ' . $e->getTraceAsString(), true);
$this->close($e->getCode());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.