本文整理汇总了PHP中Marketplace::downloadRemoteFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Marketplace::downloadRemoteFile方法的具体用法?PHP Marketplace::downloadRemoteFile怎么用?PHP Marketplace::downloadRemoteFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Marketplace
的用法示例。
在下文中一共展示了Marketplace::downloadRemoteFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: download
public function download() {
$file = Marketplace::downloadRemoteFile($this->getRemoteFileURL());
if (empty($file) || $file == Package::E_PACKAGE_DOWNLOAD) {
return array(Package::E_PACKAGE_DOWNLOAD);
} else if ($file == Package::E_PACKAGE_SAVE) {
return array($file);
}
try {
Loader::model('package_archive');
$am = new PackageArchive($this->getHandle());
$am->install($file, true);
} catch (Exception $e) {
return array($e->getMessage());
}
if ($install) {
$tests = Package::testForInstall($this->getHandle());
if (is_array($tests)) {
return $tests;
} else {
$p = Loader::package($this->getHandle());
try {
$p->install();
} catch(Exception $e) {
return array(Package::E_PACKAGE_INSTALL);
}
}
}
}
示例2: download_update
public function download_update()
{
if (MULTI_SITE == 1) {
return false;
}
$vt = Loader::helper('validation/token');
if (!$vt->validate('download_update')) {
$this->error->add($vt->getErrorMessage());
}
if (!is_dir(DIR_APP_UPDATES)) {
$this->error->add(t('The directory %s does not exist.', DIR_APP_UPDATES));
} else {
if (!is_writable(DIR_APP_UPDATES)) {
$this->error->add(t('The directory %s must be writable by the web server.', DIR_APP_UPDATES));
}
}
if (!$this->error->has()) {
$remote = Update::getApplicationUpdateInformation();
if (is_object($remote)) {
// try to download
Loader::library("marketplace");
$r = Marketplace::downloadRemoteFile($remote->url);
if (empty($r) || $r == Package::E_PACKAGE_DOWNLOAD) {
$response = array(Package::E_PACKAGE_DOWNLOAD);
} else {
if ($r == Package::E_PACKAGE_SAVE) {
$response = array($r);
}
}
if (isset($response)) {
$errors = Package::mapError($response);
foreach ($errors as $e) {
$this->error->add($e);
}
}
if (!$this->error->has()) {
// the file exists in the right spot
Loader::library('archive');
$ar = new UpdateArchive();
try {
$ar->install($r);
} catch (Exception $e) {
$this->error->add($e->getMessage());
}
}
} else {
$this->error->add(t('Unable to retrieve software from update server.'));
}
}
$this->view();
}
示例3: download_update
public function download_update()
{
$p = new \Permissions();
if (!$p->canUpgrade()) {
return false;
}
$vt = Loader::helper('validation/token');
if (!$vt->validate('download_update')) {
$this->error->add($vt->getErrorMessage());
}
if (!is_dir(DIR_CORE_UPDATES)) {
$this->error->add(t('The directory %s does not exist.', DIR_CORE_UPDATES));
} else {
if (!is_writable(DIR_CORE_UPDATES)) {
$this->error->add(t('The directory %s must be writable by the web server.', DIR_CORE_UPDATES));
}
}
if (!$this->error->has()) {
$remote = \Concrete\Core\Updater\Update::getApplicationUpdateInformation();
if (is_object($remote)) {
// try to download
$r = \Marketplace::downloadRemoteFile($remote->getDirectDownloadURL());
if (empty($r) || $r == \Package::E_PACKAGE_DOWNLOAD) {
$response = array(\Package::E_PACKAGE_DOWNLOAD);
} else {
if ($r == \Package::E_PACKAGE_SAVE) {
$response = array($r);
}
}
if (isset($response)) {
$errors = \Package::mapError($response);
foreach ($errors as $e) {
$this->error->add($e);
}
}
if (!$this->error->has()) {
// the file exists in the right spot
$ar = new UpdateArchive();
try {
$ar->install($r);
} catch (Exception $e) {
$this->error->add($e->getMessage());
}
}
} else {
$this->error->add(t('Unable to retrieve software from update server.'));
}
}
$this->view();
}