public function page_sandbox($p)
{
$p->title = 'Install Developer Tools';
//$p->addCrumb('Install Developer Tools');
$v = $p->add('View', null, null, array('view/developer-tools'));
$v->add('Button')->set('Install Now')->addClass('atk-swatch-green')->onClick(function () {
$install_dir = getcwd();
if (file_exists($install_dir) . '/VERSION') {
$install_dir = dirname($install_dir);
}
$path_d = $install_dir . '/agiletoolkit-sandbox-d.phar';
$path = $install_dir . '/agiletoolkit-sandbox.phar';
$url = 'http://www4.agiletoolkit.org/dist/agiletoolkit-sandbox.phar';
if (file_put_contents($path_d, file_get_contents($url)) === false) {
return 'update error';
} else {
if (rename($path_d, $path) === false) {
// get version of a phar
return 'update error';
} else {
$version = file_get_contents('phar://' . $path . '/VERSION');
return 'updated to ' . $version;
}
}
});
}