10 defined(
'JPATH_PLATFORM') or die;
12 jimport('joomla.updater.updateadapter');
37 protected $parent = array(0);
45 protected $pop_parent = 0;
66 protected function _getStackLocation()
68 return implode(
'->', $this->stack);
78 protected function _getParent()
80 return end($this->parent);
94 public function _startElement($parser, $name, $attrs = array())
96 array_push($this->stack, $name);
97 $tag = $this->_getStackLocation();
100 if (isset($this->$tag))
102 $this->$tag->_data =
"";
108 if (isset($attrs[
'REF']))
110 $this->update_sites[] = array(
'type' =>
'collection',
'location' => $attrs[
'REF'],
'update_site_id' => $this->updateSiteId);
115 $this->pop_parent = 1;
120 $update->set(
'update_site_id', $this->updateSiteId);
121 foreach ($this->updatecols as $col)
124 if (!array_key_exists($col, $attrs))
127 if ($col ==
'CLIENT')
129 $attrs[$col] =
'site';
133 $client = JApplicationHelper::getClientInfo($attrs[
'CLIENT'], 1);
134 if (isset($client->id))
136 $attrs[
'CLIENT_ID'] = $client->id;
140 foreach ($attrs as $key => $attr)
142 $values[strtolower($key)] = $attr;
159 if (!isset($values[
'targetplatform']))
161 $values[
'targetplatform'] = $product;
164 if (!isset($values[
'targetplatformversion']))
166 $values[
'targetplatformversion'] = $ver->RELEASE;
170 if ($product == $values[
'targetplatform'] && preg_match(
'/' . $values[
'targetplatformversion'] .
'/', $ver->RELEASE))
172 $update->bind($values);
173 $this->updates[] = $update;
190 protected function _endElement($parser, $name)
192 array_pop($this->stack);
196 if ($this->pop_parent)
198 $this->pop_parent = 0;
199 array_pop($this->parent);
216 public function findUpdate($options)
218 $url = $options[
'location'];
219 $this->updateSiteId = $options[
'update_site_id'];
220 if (substr($url, -4) !=
'.xml')
222 if (substr($url, -1) !=
'/')
226 $url .=
'update.xml';
229 $this->base =
new stdClass;
230 $this->update_sites = array();
231 $this->updates = array();
232 $db = $this->parent->getDBO();
235 $response = $http->get($url);
240 $response = $http->get($url);
247 if (!isset($response) || 200 != $response->code)
249 $query = $db->getQuery(
true)
250 ->update(
'#__update_sites')
252 ->where(
'update_site_id = ' . $this->updateSiteId);
253 $db->setQuery($query);
258 $app->enqueueMessage(
JText::sprintf(
'JLIB_UPDATER_ERROR_COLLECTION_OPEN_URL', $url),
'warning');
262 $this->xmlParser = xml_parser_create(
'');
263 xml_set_object($this->xmlParser, $this);
264 xml_set_element_handler($this->xmlParser,
'_startElement',
'_endElement');
265 if (!xml_parse($this->xmlParser, $response->body))
269 $app->enqueueMessage(
JText::sprintf(
'JLIB_UPDATER_ERROR_COLLECTION_PARSE_URL', $url),
'warning');
273 return array(
'update_sites' => $this->update_sites,
'updates' => $this->updates);