public function __construct($option, $version, $date)
{
// Initialise from parameters
$this->option = $option;
$this->version = $version;
$this->date = $date;
// Retrieve the date and version from the #__extensions table
$db = \JFactory::getDbo();
$query = $db->getQuery(true)->select('*')->from($db->qn('#__extensions'))->where($db->qn('element') . ' = ' . $db->q($this->option))->where($db->qn('type') . ' = ' . $db->q('component'));
$extension = $db->setQuery($query)->loadObject();
// Check the version and date against those from #__extensions. I hate heavily nested IFs as much as the next
// guy, but what can you do...
if (!is_null($extension)) {
$manifestCache = $extension->manifest_cache;
if (!empty($manifestCache)) {
$manifestCache = json_decode($manifestCache, true);
if (is_array($manifestCache) && isset($manifestCache['creationDate']) && isset($manifestCache['version'])) {
// Make sure the fileslist.php version and date match the component's version
if ($this->version != $manifestCache['version']) {
$this->wrongComponentVersion = true;
}
if ($this->date != $manifestCache['creationDate']) {
$this->wrongComponentVersion = true;
}
}
}
}
// Try to load the fileslist.php file from the component's back-end root
$filePath = JPATH_ADMINISTRATOR . '/components/' . $this->option . '/fileslist.php';
if (!file_exists($filePath)) {
return;
}
$couldInclude = @(include $filePath);
// If we couldn't include the file with the array OR if it didn't define the array we have to quit.
if (!$couldInclude || !isset($phpFileChecker)) {
return;
}
// Make sure the fileslist.php version and date match the component's version
if ($this->version != $phpFileChecker['version']) {
$this->wrongFilesVersion = true;
}
if ($this->date != $phpFileChecker['date']) {
$this->wrongFilesVersion = true;
}
// Initialise the files and directories lists
$this->fileList = $phpFileChecker['files'];
$this->dirList = $phpFileChecker['directories'];
}