/** * Get a list of available addons * */ function GetAvailAddons() { global $dataDir; $addonPath = $dataDir . '/addons'; if (!file_exists($addonPath)) { message('Warning: The /addons folder "<em>' . $addonPath . '</em>" does not exist on your server.'); return array(); } $installed_path = $dataDir . '/data/_addoncode'; $folders = \gp\tool\Files::ReadDir($addonPath, 1); $versions = array(); $avail = array(); foreach ($folders as $value) { $fullPath = $addonPath . '/' . $value; $info = $this->GetAvailInstall($fullPath); if (!$info) { continue; } $info['upgrade_key'] = \gp\admin\Addon\Tools::UpgradePath($info); $avail[$value] = $info; if (isset($info['Addon_Version']) && isset($info['Addon_Unique_ID'])) { $id = $info['Addon_Unique_ID']; if (!isset($versions[$id])) { $versions[$id] = $info['Addon_Version']; } elseif (version_compare($versions[$id], $info['Addon_Version'], '<')) { $versions[$id] = $info['Addon_Version']; continue; } } if (!$info['upgrade_key']) { $this->avail_count++; } } if (gp_unique_addons) { $avail = self::FilterUnique($avail, $versions); } return $avail; }
/** * Set the install destination * */ protected function SetDestination() { $this->config_key = \gp\admin\Addon\Tools::UpgradePath($this->ini_contents, $this->config_index); $this->upgrade_key = $this->config_key; if ($this->remote_install) { if ($this->config_key) { $this->dest = $this->addon_folder . '/' . $this->config_key; } else { $this->dest = $this->TempFile(); } } else { $this->dest = $this->source; } $this->dest_name = basename($this->dest); if (!$this->config_key) { $this->config_key = $this->dest_name; } }