Skip to content

Instantly share code, notes, and snippets.

@mbabker
Created February 4, 2015 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbabker/24ab73694fdd3b95fdc8 to your computer and use it in GitHub Desktop.
Save mbabker/24ab73694fdd3b95fdc8 to your computer and use it in GitHub Desktop.
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