Finds an update.
{
$url = $options['location'];
$this->_url = &$url;
$this->updateSiteId = $options['update_site_id'];
if (substr($url, -4) != '.xml')
{
if (substr($url, -1) != '/')
{
$url .= '/';
}
$url .= 'extension.xml';
}
$db = $this->parent->getDBO();
try
{
$response = $http->get($url);
}
catch (Exception $e)
{
$response = null;
}
if (!isset($response) || (!empty($response->code) && 200 != $response->code))
{
$query =
$db->getQuery(
true)
->update('#__update_sites')
->set('enabled = 0')
->where('update_site_id = ' . $this->updateSiteId);
$app->enqueueMessage(
JText::sprintf(
'JLIB_UPDATER_ERROR_EXTENSION_OPEN_URL', $url),
'warning');
return false;
}
$this->xmlParser = xml_parser_create('');
xml_set_object($this->xmlParser, $this);
xml_set_element_handler($this->xmlParser, '_startElement', '_endElement');
xml_set_character_data_handler($this->xmlParser, '_characterData');
if (!xml_parse($this->xmlParser, $response->body))
{
$app->enqueueMessage(
JText::sprintf(
'JLIB_UPDATER_ERROR_EXTENSION_PARSE_URL', $url),
'warning');
return false;
}
xml_parser_free($this->xmlParser);
if (isset($this->latest))
{
if (isset($this->latest->client) && strlen($this->latest->client))
{
if (is_numeric($this->latest->client))
{
$byName = false;
'Using numeric values for <client> in the updater xml is deprecated. Use \'administrator\' or \'site\' instead.',
);
}
else
{
$byName = true;
}
$this->latest->client_id = JApplicationHelper::getClientInfo($this->latest->client, $byName)->id;
unset($this->latest->client);
}
$updates = array($this->latest);
}
else
{
$updates = array();
}
return array('update_sites' => array(), 'updates' => $updates);
}