diff -u project_verify_package/project_verify_package.info project_verify_package/project_verify_package.info --- project_verify_package/project_verify_package.info 2009-12-03 18:49:56 +0000 +++ project_verify_package/project_verify_package.info 17 Jan 2010 23:02:32 -0000 @@ -1,8 +1,8 @@ -; $Id: $ +; $Id$ name = Project verify package description = drupal.org specific verification helpers for the project packaging system. package = Project dependencies[] = project dependencies[] = project_release dependencies[] = project_package -core = 6.x \ No newline at end of file +core = 6.x diff -u project_verify_package/project_verify_package.install project_verify_package/project_verify_package.install --- project_verify_package/project_verify_package.install 2010-01-07 15:33:21 +0000 +++ project_verify_package/project_verify_package.install 17 Jan 2010 23:02:25 -0000 @@ -1,5 +1,5 @@ http://drupal.org/node/642116 -- to learn more about correcting these errors.\n\n!output\n\nOnce these errors are fixed, commit them to the branch, then resubmit the release."); +define('PROJECT_VERIFY_PACKAGE_BRANCH_ERROR_MESSAGE', "The %makefile file for project %project_title failed verification for CVS branch %cvs_tag.\n\n!doc_link -- to learn more about correcting these errors.\n\n!output\n\nOnce these errors are fixed, commit them to the branch, then resubmit the release."); // The error message to display when verification fails for a tag. Uses the // same tokens as PROJECT_VERIFY_PACKAGE_MAKE_FILE_URI, plus the following: // !doc_link: Link defined in DOCUMENTATION_LINK. // !output: Escaped output from the drush call. -define('PROJECT_VERIFY_PACKAGE_TAG_ERROR_MESSAGE', "The %makefile file for project %project_title failed verification for CVS tag %cvs_tag.\n\nhttp://drupal.org/node/642116 -- to learn more about correcting these errors.\n\n!output\n\nOnce these errors are fixed, re-tag your project and submit the release node again."); +define('PROJECT_VERIFY_PACKAGE_TAG_ERROR_MESSAGE', "The %makefile file for project %project_title failed verification for CVS tag %cvs_tag.\n\n!doc_link -- to learn more about correcting these errors.\n\n!output\n\nOnce these errors are fixed, commit the changes to your %makefile, move the release tag for your project, and submit the release node again."); // ------------------ // END CONFIGURATION. @@ -76,7 +73,6 @@ } } - /** * Implement hook_form_alter(). */ @@ -84,14 +80,13 @@ switch ($form_id) { case 'project_release_node_form': // Can't conditionally add the validation to the final release form, - // as the form is cached and we don't get back to the alter hook. So, + // as the form is cached and we don't get back to the alter hook. So, // just always add the validator and check for the final form there. $form['#validate'][] = 'project_verify_package_verify_release_node'; break; } } - /** * Implement hook_menu(). */ @@ -99,7 +94,7 @@ $items = array(); // 'Verify .make files' link on profile project pages. - $items['node/%node/verify-make-file'] = array( + $items['node/%project_node/verify-make-file'] = array( 'title' => 'Verify ' . PROJECT_VERIFY_PACKAGE_MAKE_FILE . ' files', 'page callback' => 'drupal_get_form', 'page arguments' => array('project_verify_package_convert_verify_make_file_form', 1, 'verify'), @@ -109,7 +104,7 @@ ); // 'Convert .make files' link on profile project pages. - $items['node/%node/convert-make-file'] = array( + $items['node/%project_node/convert-make-file'] = array( 'title' => 'Convert .make files to ' . PROJECT_VERIFY_PACKAGE_MAKE_FILE . ' format', 'page callback' => 'drupal_get_form', 'page arguments' => array('project_verify_package_convert_verify_make_file_form', 1, 'convert'), @@ -118,18 +113,15 @@ 'type' => MENU_CALLBACK, ); - return $items; } /** - * Validation handler for verifying that profile releases with a drupal.org - * packaging .make file have the file corrently formatted. + * Verify if a drupalorg.make file in a release has the right format. */ function project_verify_package_verify_release_node($form, &$form_state) { - $version = $form_state['values']['project_release']['version']; // It's the final release form, not the CVS tag picker. - if (!empty($version)) { + if (!empty($form_state['values']['project_release']['version'])) { // Check that it's a project category we want to verify. $project = node_load(array('nid' => $form['#node']->project_release['pid'])); if (!empty($project->taxonomy[PROJECT_VERIFY_PACKAGE_PROJECT_TYPE_TID])) { @@ -214,7 +206,8 @@ '#value' => $button_text, ); - // Get rid the storage values, so they don't corrupt a future form submission. + // Get rid of the storage values, so they don't corrupt a future form + // submission. unset($form_state['storage']['makefile'], $form_state['storage']['output']); return $form; @@ -298,16 +291,23 @@ } /** - * Helper to get file contents via cURL. + * Helper to get file contents from a URL using a variety of methods. + * + * If PHP is configured to allow URLs in fopen(), we use file_get_contents(). + * Otherwise, if PHP has libcurl loaded, we use that. Finally, we fall back to + * attempting to execute wget from a pipe. + * + * @param $url + * URL for the file you want to fetch. + * @return + * String containing the contents of the requested file, or FALSE on error. */ function project_verify_package_get_remote_file($url) { + $file_contents = FALSE; // Use fopen if allowed. if (ini_get('allow_url_fopen')) { - $output = file_get_contents($url); - if ($output) { - $file_contents = $output; - } + $file_contents = file_get_contents($url); } // Fallback to cURL if it exists. elseif (function_exists('curl_init')) { @@ -315,10 +315,7 @@ curl_setopt($ch, CURLOPT_TIMEOUT, 50); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); - $output = curl_exec($ch); - if ($output) { - $file_contents = $output; - } + $file_contents = curl_exec($ch); curl_close($ch); } // Last try, wget. @@ -329,21 +326,19 @@ } } - if (isset($file_contents)) { - return $file_contents; - } - return FALSE; + return $file_contents; } /** - * Formats the output returned from an exec() call. + * Format the output returned from an exec() call. * * @param $output - * An array of output data, as returned from exec()> + * An array of output data, as returned from exec(). * @return * An array of strings, each string is a formatted version of the $output - * array. The first element is the raw output, the second element is escaped, - * and safe to output to a browser. + * array. The first element is the raw output, the second element is + * escaped, and safe to output to a browser. In both cases, the lines are + * passed through trim() and any blank lines are removed. */ function project_verify_package_format_exec_output($output) { $escaped_output_array = array();