public function __construct($config = array())
{
$container = Container::getInstance('com_FOOBAR');
parent::__construct($container);
// Get an instance of the updater class
$this->updater = JUpdater::getInstance();
// Get the component name
if (isset($config['update_component'])) {
$this->component = $config['update_component'];
} else {
$this->component = $this->input->getCmd('option', '');
}
// Get the component version
if (isset($config['update_version'])) {
$this->version = $config['update_version'];
}
// Get the update site
if (isset($config['update_site'])) {
$this->updateSite = $config['update_site'];
}
// Get the extra query
if (isset($config['update_extraquery'])) {
$this->extraQuery = $config['update_extraquery'];
}
// Get the extra query
if (isset($config['update_sitename'])) {
$this->updateSiteName = $config['update_sitename'];
}
// Get the extension type
list($extensionPrefix, $extensionName) = explode('_', $this->component);
switch ($extensionPrefix) {
default:
case 'com':
$type = 'component';
$name = $this->component;
break;
case 'pkg':
$type = 'package';
$name = $this->component;
break;
}
// Find the extension ID
$db = $this->container->db;
$query = $db->getQuery(true)->select('*')->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q($type))->where($db->qn('element') . ' = ' . $db->q($name));
$db->setQuery($query);
$extension = $db->loadObject();
if (is_object($extension)) {
$this->extension_id = $extension->extension_id;
$data = json_decode($extension->manifest_cache, true);
if (isset($data['version'])) {
$this->version = $data['version'];
}
}
}