JUpdaterCollection/findUpdate: Difference between revisions
From Joomla! Documentation
m clean up |
m preparing for archive only |
||
| Line 1: | Line 1: | ||
===Syntax=== | ===Syntax=== | ||
<source lang="php">findUpdate($options)</source> | <source lang="php">findUpdate($options)</source> | ||
| Line 62: | Line 60: | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=findUpdate | category=findUpdate | ||
category=JUpdaterCollection | category=JUpdaterCollection | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
Latest revision as of 02:15, 25 March 2017
Syntax
findUpdate($options)
| Parameter Name | Default Value | Description |
|---|---|---|
| $options |
Defined in
libraries/joomla/updater/adapters/collection.php
Importing
jimport( 'joomla.updater.adapters.collection' );
Source Body
public function findUpdate($options)
{
$url = $options['location'];
$this->_update_site_id = $options['update_site_id'];
if(substr($url, -4) != '.xml') {
if(substr($url, -1) != '/') {
$url .= '/';
}
$url .= 'update.xml';
}
$this->base = new stdClass();
$this->update_sites = Array();
$this->updates = Array();
$dbo =& $this->parent->getDBO();
if (!($fp = @fopen($url, "r"))) {
// TODO: Add a 'mark bad' setting here somehow
JError::raiseWarning('101', JText::_('Update') .'::'. JText::_('Collection') .': '. JText::_('Could not open').' '. $url);
return false;
}
$this->xml_parser = xml_parser_create('');
xml_set_object($this->xml_parser, $this);
xml_set_element_handler($this->xml_parser, '_startElement', '_endElement');
//xml_set_character_data_handler($this->xml_parser, '_characterData');
while ($data = fread($fp, 8192)) {
if (!xml_parse($this->xml_parser, $data, feof($fp))) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($this->xml_parser)),
xml_get_current_line_number($this->xml_parser)));
}
}
// TODO: Decrement the bad counter if non-zero
return Array('update_sites'=>$this->update_sites,'updates'=>$this->updates);
}
Examples
Code Examples