本文整理汇总了PHP中JUpdate::loadFromXml方法的典型用法代码示例。如果您正苦于以下问题:PHP JUpdate::loadFromXml方法的具体用法?PHP JUpdate::loadFromXml怎么用?PHP JUpdate::loadFromXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUpdate
的用法示例。
在下文中一共展示了JUpdate::loadFromXml方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getPackageUrl
/**
* Finds the url of the package to download.
*
* @param string $remote_manifest url to the manifest XML file of the remote package
*
* @return string|bool
*
* @since 2.5.7
*/
protected function _getPackageUrl($remote_manifest)
{
$update = new JUpdate();
$update->loadFromXml($remote_manifest);
$package_url = trim($update->get('downloadurl', false)->_data);
return $package_url;
}
示例2: update
/**
* Finds an update for an extension
*
* @param integer $id Id of the extension
*
* @return mixed
*
* @since 11.1
*/
public function update($id)
{
$updaterow = JTable::getInstance('update');
$updaterow->load($id);
$update = new JUpdate();
if ($update->loadFromXml($updaterow->detailsurl)) {
return $update->install();
}
return false;
}
示例3: update
/**
* Update function.
*
* Sets the "result" state with the result of the operation.
*
* @param array $uids Array[int] List of updates to apply
* @param int $minimum_stability The minimum allowed stability for installed updates {@see JUpdater}
*
* @return void
*
* @since 1.6
*/
public function update($uids, $minimum_stability = JUpdater::STABILITY_STABLE)
{
$result = true;
foreach ($uids as $uid) {
$update = new JUpdate();
$instance = JTable::getInstance('update');
$instance->load($uid);
$update->loadFromXml($instance->detailsurl, $minimum_stability);
$update->set('extra_query', $instance->extra_query);
// Install sets state and enqueues messages
$res = $this->install($update);
if ($res) {
$instance->delete($uid);
}
$result = $res & $result;
}
// Set the final state
$this->setState('result', $result);
}
示例4: _getPackageFromUrl
/**
* Install an extension from a URL.
*
* @return Package details or false on failure.
*
* @since 1.5
*/
protected function _getPackageFromUrl()
{
$input = JFactory::getApplication()->input;
// Get the URL of the package to install.
$url = $input->getString('install_url');
// Did you give us a URL?
if (!$url) {
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_ENTER_A_URL'));
return false;
}
// Handle updater XML file case:
if (preg_match('/\\.xml\\s*$/', $url)) {
jimport('joomla.updater.update');
$update = new JUpdate();
$update->loadFromXml($url);
$package_url = trim($update->get('downloadurl', false)->_data);
if ($package_url) {
$url = $package_url;
}
unset($update);
}
// Download the package at the URL given.
$p_file = JInstallerHelper::downloadPackage($url);
// Was the package downloaded?
if (!$p_file) {
JError::raiseWarning('', JText::_('COM_INSTALLER_MSG_INSTALL_INVALID_URL'));
return false;
}
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path');
// Unpack the downloaded package file.
$package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file, true);
return $package;
}
示例5: doInstallUpdate
public function doInstallUpdate($update_row)
{
// Load
$this->out('Loading update #' . $update_row->update_id . '...');
$update = new JUpdate();
$updateRow = JTable::getInstance('update');
$updateRow->load($update_row->update_id);
$update->loadFromXml($updateRow->detailsurl, $this->installer->params->get('minimum_stability', JUpdater::STABILITY_STABLE, 'int'));
$update->set('extra_query', $updateRow->extra_query);
// Download
$tmpPath = $this->config->get('tmp_path');
if (!is_writeable($tmpPath)) {
$tmpPath = JPATH_BASE . '/tmp';
}
$url = $update->downloadurl->_data;
if ($extra_query = $update->get('extra_query')) {
$url .= strpos($url, '?') === false ? '?' : '&';
$url .= $extra_query;
}
$this->out(' - Download ' . $url);
$p_file = JInstallerHelper::downloadPackage($url);
if ($p_file) {
$filePath = $tmpPath . '/' . $p_file;
} else {
$this->out(' - Download Failed, Attempting alternate download method...');
$urlFile = preg_replace('/^.*\\/(.*?)$/', '$1', $url);
$filePath = $tmpPath . '/' . $urlFile;
if ($fileHandle = @fopen($filePath, 'w+')) {
$curl = curl_init($url);
curl_setopt_array($curl, [CURLOPT_URL => $url, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_BINARYTRANSFER => 1, CURLOPT_RETURNTRANSFER => 1, CURLOPT_FILE => $fileHandle, CURLOPT_TIMEOUT => 50, CURLOPT_USERAGENT => 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)']);
$response = curl_exec($curl);
if ($response === false) {
$this->out(' - Download Failed: ' . curl_error($curl));
return false;
}
} else {
$this->out(' - Download Failed, Error writing ' . $filePath);
return false;
}
}
// Catch Error
if (!is_file($filePath)) {
$this->out(' - Download Failed/ File not found');
return false;
}
// Extracting Package
$this->out(' - Extracting Package...');
$package = JInstallerHelper::unpack($filePath);
if (!$package) {
$this->out(' - Extract Failed');
JInstallerHelper::cleanupInstall($filePath);
return false;
}
// Install the package
$this->out(' - Installing ' . $package['dir'] . '...');
$installer = JInstaller::getInstance();
$update->set('type', $package['type']);
if (!$installer->update($package['dir'])) {
$this->out(' - Update Error');
$result = false;
} else {
$this->out(' - Update Success');
$result = true;
}
// Cleanup the install files
$this->out(' - Cleanup');
JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']);
// Complete
return $result;
}
示例6: _getPackageUrl
/**
* Finds the url of the package to download.
*
* @param string $remote_manifest url to the manifest XML file of the remote package
*
* @return string|bool
*
* @since 2.5.7
*/
protected function _getPackageUrl($remote_manifest)
{
$update = new JUpdate();
$update->loadFromXml($remote_manifest);
$downloadUrlElement = $update->get('downloadurl', false);
if ($downloadUrlElement === false) {
return false;
}
return trim($downloadUrlElement->_data);
}