Index: includes/plugins.inc =================================================================== RCS file: includes/plugins.inc diff -N includes/plugins.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ includes/plugins.inc 10 Mar 2009 22:24:29 -0000 @@ -0,0 +1,196 @@ +data is the actual contents of the downloaded file. This saves + // it into a local file, whose path is stored in $local. $local is stored + // relative to the drupal installation. + $result = drupal_http_request($path); + if ($result->code != 200 || !file_save_data($result->data, $local)) { + drupal_set_message(t('@remote could not be saved.', array('@remote' => $path)), 'error'); + return FALSE; + } + } + return $local; +} + +/** + * Untars a file. + * + * @param $file + * The file to untar. + * @return + * An array containing the locations of the extracted files, or FALSE on + * failure. + */ +function plugin_manager_untar($file) { + $dir = file_directory_temp() .'/plugin_manager_extraction/'; + $file_safe = escapeshellarg($file); + $dir_safe = escapeshellarg($dir); + $file_list = array(); + + // Try to use tar to extract the files. + if (function_exists('popen')) { + $handle = popen("tar -zvxf $file_safe -C $dir_safe", "r"); + while ($line = fgets($handle)) { + $file_list[] = trim($line); + } + pclose($handle); + } + + // If tar returned something, then it is present, so return it. + if (!empty($file_list)) { + return $file_list; + } + + return FALSE; +} + +/** + * Downloads the list of available themes/modules. + * + * @return + * An form array to be displayed. + */ +function plugin_list_reload() { + // Download a new copy of the project-list. + $file = drupal_http_request(PLUGIN_DEFAULT_URL . '/project-list/all'); + if (isset($file->error)) { + drupal_set_message(t($file->error), 'error'); + return array(); + } + + // Parse it. + $xml = simplexml_load_string($file->data); + if ($xml == FALSE) { + return array(); + } + + // @todo Clear cache here. + + // Look at each project node. + $drupal_version = constant("DRUPAL_CORE_COMPATIBILITY"); + foreach ($xml->project AS $project) { + // If there isn't a release for this version of Drupal then skip it. + if (!isset($project->api_versions)) { + continue; + } + $versions = (array) $project->api_versions; + if (!is_array($versions['api_version'])) { + $versions['api_version'] = array($versions['api_version']); + } + if (!in_array($drupal_version, $versions['api_version'])) { + continue; + } + + // @todo Cache data here. + } + drupal_set_message(t("The repository was updated successfully."), "status"); + variable_set("plugin_manager_last_reload", date('U')); + return array(); +} + +/** + * Get the information about each plugin. + * + * @param $projects + * The project or projects on which information is desired. + * @return + * An array containing info on the supplied projects. + */ +function plugin_get_release_history($projects) { + $version = DRUPAL_CORE_COMPATIBILITY; + $results = array(); + + // If projects isn't an array, turn it into one. + if (!is_array($projects)) { + $projects = array($projects); + } + + // Look up the data for every project requested. + foreach ($projects AS $project) { + $file = drupal_http_request(PLUGIN_DEFAULT_URL . "/$project/$version"); + $xml = simplexml_load_string($file->data); + + // If it failed, then quit. + if ($xml == FALSE) { + drupal_set_message(t('Downloading the release history failed for @project.', array('@project' => $project)), "error"); + return FALSE; + } + + // Get the title, release_link and download_link. + $results[$project]['title'] = (string)$xml->title; + + // Get the information about every release + foreach ($xml->releases->release AS $release) { + $release_version = (string)$release->version; + $results[$project]['release'][] = array( + 'release_link' => (string)$release->release_link, + 'download_link' => (string)$release->download_link, + 'date' => (string)$release->date, + 'version' => $release_version, + ); + $results[$project]['version'][] = $release_version; + } + } + + // Order them and then return the results. + ksort($results); + return $results; +} + +/** + * See if everything that is needed to use the plugin manager is available. + * + * @return + * TRUE if all of the required dependencies are available, FALSE otherwise. + */ +function plugin_manager_runnable() { + // See if we have a way to untar the files. + $handle = popen("tar --version", "r"); + if (!fgets($handle)) { + pclose($handle); + return FALSE; + } + pclose($handle); + + // See if we have any available backends. + $backends = plugin_manager_backends(); + return !empty($backends); +} \ No newline at end of file Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.671 diff -u -p -r1.671 system.module --- modules/system/system.module 9 Mar 2009 11:44:54 -0000 1.671 +++ modules/system/system.module 10 Mar 2009 22:26:09 -0000 @@ -228,6 +228,27 @@ function system_rdf_namespaces() { } /** + * Implementation of hook_backend_plugin(). + */ +function system_backend_plugin() { + $backends = array(); + + // FTP backend is only available if the proper PHP extension is installed or + // allow_url_fopen is on. + if (function_exists('ftp_connect') || ini_get('allow_url_fopen')) { + $backends[] = 'ftp'; + } + + // SSH2 lib backend is only available if the proper PHP extension is + // installed. + if (function_exists('ssh2_connect')) { + $backends[] = 'ssh'; + } + + return $backends; +} + +/** * Implementation of hook_elements(). */ function system_elements() { Index: modules/update/update.fetch.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/update/update.fetch.inc,v retrieving revision 1.15 diff -u -p -r1.15 update.fetch.inc --- modules/update/update.fetch.inc 14 Jan 2009 21:13:42 -0000 1.15 +++ modules/update/update.fetch.inc 10 Mar 2009 21:50:03 -0000 @@ -77,7 +77,7 @@ function _update_refresh() { * @see update_get_projects() */ function _update_build_fetch_url($project, $site_key = '') { - $default_url = variable_get('update_fetch_url', UPDATE_DEFAULT_URL); + $default_url = variable_get('update_fetch_url', PLUGIN_DEFAULT_URL); if (!isset($project['info']['project status url'])) { $project['info']['project status url'] = $default_url; } Index: modules/update/update.module =================================================================== RCS file: /cvs/drupal/drupal/modules/update/update.module,v retrieving revision 1.30 diff -u -p -r1.30 update.module --- modules/update/update.module 22 Jan 2009 03:11:54 -0000 1.30 +++ modules/update/update.module 10 Mar 2009 21:48:52 -0000 @@ -9,11 +9,6 @@ * (admin/reports/status), the module and theme pages, and optionally via email. */ -/** - * URL to check for updates, if a given project doesn't define its own. - */ -define('UPDATE_DEFAULT_URL', 'http://updates.drupal.org/release-history'); - // These are internally used constants for this code, do not modify. /**