本文整理汇总了PHP中JUpdate::loadFromXML方法的典型用法代码示例。如果您正苦于以下问题:PHP JUpdate::loadFromXML方法的具体用法?PHP JUpdate::loadFromXML怎么用?PHP JUpdate::loadFromXML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JUpdate
的用法示例。
在下文中一共展示了JUpdate::loadFromXML方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update
public function update($uids)
{
$result = true;
foreach ($uids as $uid) {
$update = new JUpdate();
$instance = JTable::getInstance('update');
$instance->load($uid);
$update->loadFromXML($instance->detailsurl);
$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);
}
示例2: getInstallFrom
private function getInstallFrom()
{
if (is_null($this->_installfrom)) {
$app = JFactory::getApplication();
$installfrom = base64_decode($app->input->get('installfrom', '', 'base64'));
$field = new SimpleXMLElement('<field></field>');
$rule = new JFormRuleUrl();
if ($rule->test($field, $installfrom) && preg_match('/\\.xml\\s*$/', $installfrom)) {
jimport('joomla.updater.update');
$update = new JUpdate();
$update->loadFromXML($installfrom);
$package_url = trim($update->get('downloadurl', false)->_data);
if ($package_url) {
$installfrom = $package_url;
}
}
$this->_installfrom = $installfrom;
}
return $this->_installfrom;
}
示例3: 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 3.1
*/
protected function getPackageUrl($remote_manifest)
{
$update = new JUpdate();
$update->loadFromXML($remote_manifest);
$package_url = trim($update->get('downloadurl', false)->_data);
return $package_url;
}
示例4: updateComponent
private function updateComponent()
{
JLoader::import('joomla.updater.update');
$db = JFactory::getDbo();
$update_site = array_shift($this->getUpdateSiteIds());
$query = $db->getQuery(true)->select($db->qn('update_id'))->from($db->qn('#__updates'))->where($db->qn('update_site_id') . ' = ' . $update_site);
$uid = $db->setQuery($query)->loadResult();
$update = new JUpdate();
$instance = JTable::getInstance('update');
$instance->load($uid);
$update->loadFromXML($instance->detailsurl);
if (isset($update->get('downloadurl')->_data)) {
$url = trim($update->downloadurl->_data);
} else {
return "No download URL found inside XML manifest";
}
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path');
if (!$tmp_dest) {
return "Joomla temp directory is empty, please set it before continuing";
} elseif (!JFolder::exists($tmp_dest)) {
return "Joomla temp directory does not exists, please set the correct path before continuing";
}
$p_file = JInstallerHelper::downloadPackage($url);
if (!$p_file) {
return "An error occurred while trying to download the latest version, double check your Download ID";
}
// Unpack the downloaded package file
$package = JInstallerHelper::unpack($tmp_dest . '/' . $p_file);
if (!$package) {
return "An error occurred while unpacking the file, please double check your Joomla temp directory";
}
$installer = new JInstaller();
$installed = $installer->install($package['extractdir']);
// Let's cleanup the downloaded archive and the temp folder
if (JFolder::exists($package['extractdir'])) {
JFolder::delete($package['extractdir']);
}
if (JFile::exists($package['packagefile'])) {
JFile::delete($package['packagefile']);
}
if ($installed) {
return "Component successfully updated";
} else {
return "An error occurred while trying to update the component";
}
}
示例5: update
public function update($id)
{
$updaterow =& JTable::getInstance('update');
$updaterow->load($id);
$update = new JUpdate();
if ($update->loadFromXML($updaterow->detailsurl)) {
return $update->install();
}
return false;
}
示例6: getUpdateInformation
/**
* Returns an array with the Joomla! update information.
*
* @return array
*
* @since 2.5.4
*/
public function getUpdateInformation()
{
// Initialise the return array.
$ret = array('installed' => JVERSION, 'latest' => null, 'object' => null, 'hasUpdate' => false);
// Fetch the update information from the database.
$db = $this->getDbo();
$query = $db->getQuery(true)->select('*')->from($db->quoteName('#__updates'))->where($db->quoteName('extension_id') . ' = ' . $db->quote(700));
$db->setQuery($query);
$updateObject = $db->loadObject();
if (is_null($updateObject)) {
$ret['latest'] = JVERSION;
return $ret;
}
$ret['latest'] = $updateObject->version;
$ret['hasUpdate'] = $updateObject->version != JVERSION;
// Fetch the full update details from the update details URL.
jimport('joomla.updater.update');
$update = new JUpdate();
$update->loadFromXML($updateObject->detailsurl);
$ret['object'] = $update;
return $ret;
}
示例7: findUpdatesJoomla
/**
* Find the available update record object. If we're at the latest version it will return null.
*
* @param bool $force Should I forcibly reload the updates from the server?
*
* @return \stdClass|null
*/
protected function findUpdatesJoomla($force = false)
{
$db = F0FPlatform::getInstance()->getDbo();
// If we are forcing the reload, set the last_check_timestamp to 0
// and remove cached component update info in order to force a reload
if ($force) {
// Find the update site IDs
$updateSiteIds = $this->getUpdateSiteIds();
if (empty($updateSiteIds)) {
return null;
}
// Set the last_check_timestamp to 0
if (version_compare(JVERSION, '2.5.0', 'ge')) {
$query = $db->getQuery(true)->update($db->qn('#__update_sites'))->set($db->qn('last_check_timestamp') . ' = ' . $db->q('0'))->where($db->qn('update_site_id') . ' IN (' . implode(', ', $updateSiteIds) . ')');
$db->setQuery($query);
$db->execute();
}
// Remove cached component update info from #__updates
$query = $db->getQuery(true)->delete($db->qn('#__updates'))->where($db->qn('update_site_id') . ' IN (' . implode(', ', $updateSiteIds) . ')');
$db->setQuery($query);
$db->execute();
}
// Use the update cache timeout specified in com_installer
$timeout = 3600 * F0FUtilsConfigHelper::getComponentConfigurationValue('com_installer', 'cachetimeout', '6');
// Load any updates from the network into the #__updates table
$this->updater->findUpdates($this->extension_id, $timeout);
// Get the update record from the database
$query = $db->getQuery(true)->select('*')->from($db->qn('#__updates'))->where($db->qn('extension_id') . ' = ' . $db->q($this->extension_id));
$db->setQuery($query);
try {
$updateObject = $db->loadObject();
} catch (Exception $e) {
return null;
}
if (!is_object($updateObject)) {
return null;
}
$updateObject->downloadurl = '';
JLoader::import('joomla.updater.update');
if (class_exists('JUpdate')) {
$update = new JUpdate();
$update->loadFromXML($updateObject->detailsurl);
if (isset($update->get('downloadurl')->_data)) {
$url = trim($update->downloadurl->_data);
$extra_query = isset($updateObject->extra_query) ? $updateObject->extra_query : $this->extraQuery;
if ($extra_query) {
if (strpos($url, '?') === false) {
$url .= '?';
} else {
$url .= '&';
}
$url .= $extra_query;
}
$updateObject->downloadurl = $url;
}
}
return $updateObject;
}
示例8: update
/**
* Update function.
*
* Sets the "result" state with the result of the operation.
*
* @param Array[int] List of updates to apply
* @since 1.6
*/
public function update($uids)
{
$result = true;
foreach ($uids as $uid) {
$update = new JUpdate();
$instance = JTable::getInstance('update');
$instance->load($uid);
$update->loadFromXML($instance->detailsurl);
// install sets state and enqueues messages
$res = $this->install($update);
// Disabling the purging of the update list, instead deleting specific row
if ($res) {
$instance->delete($uid);
}
$result = $res & $result;
}
// Set the final state
$this->setState('result', $result);
}
示例9: downloadUpdate
/**
* Downloads an update package given an update record ID ($uid). The package is downloaded
* and its location recorded in the session.
*
* @param integer $uid The update record ID
*
* @return True on success
*/
public function downloadUpdate($uid)
{
// Unset the compressed_package session variable
$session = JFactory::getSession();
$session->set('compressed_package', null, 'akeeba');
// Find the download location from the XML update stream
jimport('joomla.updater.update');
$update = new JUpdate();
$instance = JTable::getInstance('update');
$instance->load($uid);
$update->loadFromXML($instance->detailsurl);
if (isset($update->get('downloadurl')->_data)) {
$url = $update->downloadurl->_data;
} else {
JError::raiseWarning('', JText::_('COM_INSTALLER_INVALID_EXTENSION_UPDATE'));
return false;
}
// Download the package
$p_file = JInstallerHelper::downloadPackage($url);
// Was the package downloaded?
if (!$p_file) {
JError::raiseWarning('', JText::sprintf('COM_INSTALLER_PACKAGE_DOWNLOAD_FAILED', $url));
return false;
}
// Store the uploaded package's location
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path');
$session->set('compressed_package', $tmp_dest . '/' . $p_file, 'akeeba');
return true;
}
示例10: getUpdateInformation
/**
* Returns an array with the Joomla! update information
*
* @return array
*
* @since 2.5.4
*/
public function getUpdateInformation()
{
// Initialise the return array
$ret = array('installed' => JVERSION, 'latest' => null, 'object' => null);
// Fetch the update information from the database
$db = $this->getDbo();
$query = $db->getQuery(true)->select('*')->from($db->nq('#__updates'))->where($db->nq('extension_id') . ' = ' . $db->q(700));
$db->setQuery($query);
$updateObject = $db->loadObject();
if (is_null($updateObject)) {
$ret['latest'] = JVERSION;
return $ret;
} else {
$ret['latest'] = $updateObject->version;
}
// Fetch the full udpate details from the update details URL
jimport('joomla.updater.update');
$update = new JUpdate();
$update->loadFromXML($updateObject->detailsurl);
// Pass the update object
if ($ret['latest'] == JVERSION) {
$ret['object'] = null;
} else {
$ret['object'] = $update;
}
return $ret;
}
示例11: distro_download
/**
* Square One Additions
*/
public function distro_download()
{
$update = new JUpdate();
$detailsurl = base64_decode(JRequest::getString('detailsurl', '', 'post'));
if (substr($detailsurl, 0, 4) == 'http') {
$result->result = false;
if (substr($detailsurl, 0, -3) == 'xml') {
// Url to an update manifest
$update->loadFromXML($detailsurl);
$file = JInstallerHelper::downloadPackage($update->get('downloadurl')->_data);
} else {
$file = JInstallerHelper::downloadPackage($detailsurl);
}
if (!$file) {
$result->message = JText::_('COM_INSTALLER_MSG_INSTALL_INVALID_URL');
} else {
$result->result = true;
$result->task = 'distro_download';
$result->file = $file;
$result->message = JText::_('COM_INSTALLER_PACKAGE_DOWNLOADED');
}
} else {
// We have a file
$config = JFactory::getConfig();
$source = base64_decode(JRequest::getString('source'));
JFile::move($source . '/' . $detailsurl, $config->get('tmp_path') . '/' . $detailsurl);
$result->result = true;
$result->task = 'distro_download';
$result->file = $detailsurl;
$result->message = JText::_('COM_INSTALLER_PACKAGE_FOUND');
}
return $result;
}
示例12: _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;
}
示例13: getUpdateInformation
/**
* Regreso un array con la información de la actualización de Jokte!
*
* @return array
* @since 1.1.9
*/
public function getUpdateInformation()
{
// Inicializo el array a retornar
// Ojo!!! Nueva global: VJOKTE
// La global JVERSION se mantiene por compatibilidad con extensiones Joomla
$ret = array('installed' => VJOKTE, 'latest' => null, 'object' => null);
// Busco la información en la BD
$db = $this->getDbo();
$query = $db->getQuery(true)->select('*')->from($db->nq('#__updates'))->where($db->nq('extension_id') . ' = ' . $db->q(700));
$db->setQuery($query);
$updateObject = $db->loadObject();
if (is_null($updateObject)) {
$ret['latest'] = VJOKTE;
return $ret;
} else {
$ret['latest'] = $updateObject->version;
}
// Busco los detalles completos de la actualización desde la URL
jimport('joomla.updater.update');
$update = new JUpdate();
$update->loadFromXML($updateObject->detailsurl);
//var_dump($update);
// Paso el objeto a actualizar
if ($ret['latest'] == VJOKTE) {
$ret['object'] = null;
} else {
$ret['object'] = $update;
}
return $ret;
}
示例14: getExtension
public function getExtension()
{
// Get extension id
$cache = JFactory::getCache();
$cache->setCaching(1);
$http = new JHttp();
$http->setOption('timeout', 60);
$api_url = new JUri();
$input = new JInput();
$id = $input->get('id', null, 'int');
$release = preg_replace('/[^\\d]/', '', base64_decode($input->get('release', '', 'base64')));
$release = intval($release / 5) * 5;
$api_url->setScheme('http');
$api_url->setHost('extensions.joomla.org/index.php');
$api_url->setvar('option', 'com_jed');
$api_url->setvar('controller', 'filter');
$api_url->setvar('view', 'extension');
$api_url->setvar('format', 'json');
$api_url->setvar('filter[approved]', '1');
$api_url->setvar('filter[published]', '1');
$api_url->setvar('extend', '0');
$api_url->setvar('filter[id]', $id);
$extension_json = $cache->call(array($http, 'get'), $api_url);
// Create item
$items = json_decode($extension_json->body);
$item = $items->data[0];
$this->_catid = $item->core_catid->value;
$item->image = $this->getBaseModel()->getMainImageUrl($item);
$item->downloadurl = $item->download_integration_url->value;
if (preg_match('/\\.xml\\s*$/', $item->downloadurl)) {
$app = JFactory::getApplication();
$product = addslashes(base64_decode($app->input->get('product', '', 'base64')));
$release = preg_replace('/[^\\d\\.]/', '', base64_decode($app->input->get('release', '', 'base64')));
$dev_level = (int) base64_decode($app->input->get('dev_level', '', 'base64'));
$updatefile = JPATH_ROOT . '/libraries/joomla/updater/update.php';
$fh = fopen($updatefile, 'r');
$theData = fread($fh, filesize($updatefile));
fclose($fh);
$theData = str_replace('<?php', '', $theData);
$theData = str_replace('$ver->PRODUCT', "'" . $product . "'", $theData);
$theData = str_replace('$ver->RELEASE', "'" . $release . "'", $theData);
$theData = str_replace('$ver->DEV_LEVEL', "'" . $dev_level . "'", $theData);
eval($theData);
$update = new JUpdate();
$update->loadFromXML($item->downloadurl);
$package_url_node = $update->get('downloadurl', false);
if (isset($package_url_node->_data)) {
$item->downloadurl = $package_url_node->_data;
}
}
$item->download_type = $this->getTypeEnum($item->download_integration_type->value);
return array($item);
}