| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: admin.settings.inc,v 1.3 2009/11/26 15:13:51 dww Exp $ 3 4 /** 5 * @file 6 * Code required for the admin/project/project-release-settings page. 7 */ 8 9 /** 10 * Build the form for the project_release settings administration page. 11 */ 12 function project_release_settings_form() { 13 if ($rel_dir = variable_get('project_release_directory', '')) { 14 $form['project_release_directory'] = array( 15 '#type' => 'textfield', 16 '#title' => t('Release directory'), 17 '#default_value' => $rel_dir, 18 '#size' => 50, 19 '#maxlength' => 255, 20 '#description' => t('This setting has been temporarily deprecated. If your site depends on scanning for releases generated by an external tool, you should wait to upgrade until a future version of the project_release.module is available that restores this functionality. Set the value blank to acknowlege that you do not need this behavior, and this error will disappear.'), 21 ); 22 } 23 $form['project_release_default_version_format'] = array( 24 '#type' => 'textfield', 25 '#title' => t('Default version format string'), 26 '#default_value' => variable_get('project_release_default_version_format', PROJECT_RELEASE_DEFAULT_VERSION_FORMAT), 27 '#size' => 50, 28 '#maxlength' => 255, 29 '#description' => t('Customize the default format of the version strings for releases of projects on this site. Users with "administer projects" permissions can override this setting for each project.') .' '. PROJECT_RELEASE_VERSION_FORMAT_HELP, 30 ); 31 32 $form['project_release_file_extensions'] = array( 33 '#type' => 'textfield', 34 '#title' => t('Permitted file extensions'), 35 '#default_value' => variable_get('project_release_file_extensions', PROJECT_RELEASE_FILE_EXTENSIONS), 36 '#size' => 50, 37 '#maxlength' => 255, 38 '#description' => t('Files uploaded to release nodes will only be allowed if they have an extension that is included in this list.'), 39 ); 40 41 if ($tree = project_release_get_api_taxonomy()) { 42 foreach ($tree as $term) { 43 $terms[$term->tid] = check_plain($term->name); 44 } 45 $vocab = taxonomy_vocabulary_load(_project_release_get_api_vid()); 46 $tids = variable_get('project_release_active_compatibility_tids', array()); 47 $form['project_release_active_compatibility_tids'] = array( 48 '#type' => 'checkboxes', 49 '#title' => t('Active @vocab terms', array('@vocab' => $vocab->name)), 50 '#default_value' => $tids, 51 '#options' => $terms, 52 '#description' => t('Terms from the %vocab vocabulary that should be visibile to end users and project maintainers.', array('%vocab' => $vocab->name)), 53 ); 54 55 // TODO: put these 2 in a fieldset? 56 // @TODO: For D6 port, this setting can be deleted. 57 $terms = array(-1 => t('all')) + $terms; 58 $form['project_release_browse_versions'] = array( 59 '#type' => 'checkbox', 60 '#title' => t('Browse projects by release versions'), 61 '#default_value' => variable_get('project_release_browse_versions', 0), 62 '#description' => t('Checking this box will cause the project browsing page to have a version select.'), 63 ); 64 $form['project_release_overview'] = array( 65 '#type' => 'radios', 66 '#title' => t('Default release overview'), 67 '#default_value' => variable_get('project_release_overview', -1), 68 '#options' => $terms, 69 '#required' => TRUE, 70 '#description' => t('Default release version to list on the overview page.'), 71 ); 72 } 73 $form['project_release_download_base'] = array( 74 '#type' => 'textfield', 75 '#title' => t('Download link base URL'), 76 '#default_value' => variable_get('project_release_download_base', ''), 77 '#size' => 50, 78 '#maxlength' => 255, 79 '#description' => t("By default, all download links to releases will use the standard download path for the site. However, if you wish to host the downloads at a different location, you can specify the base of the URL that should be used for download links. For example, if you stored releases in %files_path and you want to have download links pointing to %ftp_url, you would set this to %ftp_setting. Note that if you define this, the value should end with a slash ('/').", array('%files_path' => 'files/projects/foo.tar.gz', '%ftp_url' => 'ftp://ftp.example.com/files/projects/foo.tar.gz', '%ftp_setting' => 'ftp://ftp.example.com/')), 80 ); 81 return system_settings_form($form); 82 } 83 84 /** 85 * Validation callback for the project_release settings form. 86 */ 87 function project_release_settings_form_validate($form, &$form_state) { 88 if (!empty($form_state['values']['project_release_directory'])) { 89 form_set_error('project_release_directory', t('Release directory setting has been deprecated.')); 90 } 91 // Only validate these form elements if the API compatibility form elements 92 // were even added to the form to avoid PHP notices when there are no terms 93 // in the API compatibility vocabulary. 94 if (isset($form_state['values']['project_release_active_compatibility_tids'])) { 95 $tids = $form_state['values']['project_release_active_compatibility_tids']; 96 $default_tid = $form_state['values']['project_release_overview']; 97 if ($default_tid != -1 && !$tids[$default_tid]) { 98 $vocab = taxonomy_vocabulary_load(_project_release_get_api_vid()); 99 form_set_error('project_release_overview', t('Project release overview must be one of the active %vocab terms.', array('%vocab' => $vocab->name))); 100 } 101 } 102 103 // Make sure the default version format has no bad characters. 104 _project_release_validate_format_string($form_state['values'], 'project_release_default_version_format'); 105 106 // If set, the project_release_download_base must end with a '/' 107 if (!empty($form_state['values']['project_release_download_base'])) { 108 if (substr($form_state['values']['project_release_download_base'], -1) != '/') { 109 form_set_error('project_release_download_base', t('The <em>Download link base URL</em> should end with a slash.')); 110 } 111 } 112 } 113
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |