10 defined(
'JPATH_PLATFORM') or die;
12 jimport('joomla.updater.updateadapter');
34 protected function _startElement($parser, $name, $attrs = array())
36 array_push($this->stack, $name);
37 $tag = $this->_getStackLocation();
40 if (isset($this->$tag))
42 $this->$tag->_data =
"";
49 $this->currentUpdate->update_site_id = $this->updateSiteId;
50 $this->currentUpdate->detailsurl = $this->_url;
51 $this->currentUpdate->folder =
"";
52 $this->currentUpdate->client_id = 1;
59 if (in_array($name, $this->updatecols))
61 $name = strtolower($name);
62 $this->currentUpdate->$name =
'';
64 if ($name ==
'TARGETPLATFORM')
66 $this->currentUpdate->targetplatform = $attrs;
82 protected function _endElement($parser, $name)
84 array_pop($this->stack);
97 if ($product == $this->currentUpdate->targetplatform[
'NAME']
98 && preg_match(
'/' . $this->currentUpdate->targetplatform[
'VERSION'] .
'/', $ver->RELEASE)
99 && ((!isset($this->currentUpdate->targetplatform->min_dev_level)) || $ver->DEV_LEVEL >= $this->currentUpdate->targetplatform->min_dev_level)
100 && ((!isset($this->currentUpdate->targetplatform->max_dev_level)) || $ver->DEV_LEVEL <= $this->currentUpdate->targetplatform->max_dev_level))
103 unset($this->currentUpdate ->targetplatform);
104 if (isset($this->latest))
106 if (version_compare($this->currentUpdate ->version, $this->latest->version,
'>') == 1)
108 $this->latest = $this->currentUpdate;
113 $this->latest = $this->currentUpdate;
134 protected function _characterData($parser, $data)
136 $tag = $this->_getLastTag();
142 if (in_array($tag, $this->updatecols))
144 $tag = strtolower($tag);
145 $this->currentUpdate->$tag .= $data;
158 public function findUpdate($options)
160 $url = $options[
'location'];
162 $this->updateSiteId = $options[
'update_site_id'];
163 if (substr($url, -4) !=
'.xml')
165 if (substr($url, -1) !=
'/')
169 $url .=
'extension.xml';
172 $db = $this->parent->getDBO();
179 $response = $http->get($url);
186 if (!isset($response) || (!empty($response->code) && 200 != $response->code))
188 $query = $db->getQuery(
true)
189 ->update(
'#__update_sites')
191 ->where(
'update_site_id = ' . $this->updateSiteId);
192 $db->setQuery($query);
197 $app->enqueueMessage(
JText::sprintf(
'JLIB_UPDATER_ERROR_EXTENSION_OPEN_URL', $url),
'warning');
201 $this->xmlParser = xml_parser_create(
'');
202 xml_set_object($this->xmlParser, $this);
203 xml_set_element_handler($this->xmlParser,
'_startElement',
'_endElement');
204 xml_set_character_data_handler($this->xmlParser,
'_characterData');
206 if (!xml_parse($this->xmlParser, $response->body))
210 $app->enqueueMessage(
JText::sprintf(
'JLIB_UPDATER_ERROR_EXTENSION_PARSE_URL', $url),
'warning');
213 xml_parser_free($this->xmlParser);
214 if (isset($this->latest))
216 if (isset($this->latest->client) && strlen($this->latest->client))
218 if (is_numeric($this->latest->client))
224 'Using numeric values for <client> in the updater xml is deprecated. Use \'administrator\' or \'site\' instead.',
232 $this->latest->client_id = JApplicationHelper::getClientInfo($this->latest->client, $byName)->id;
233 unset($this->latest->client);
235 $updates = array($this->latest);
241 return array(
'update_sites' => array(),
'updates' => $updates);