/[drupal]/contributions/modules/versioncontrol_svn/versioncontrol_svn.forms.inc
ViewVC logotype

Contents of /contributions/modules/versioncontrol_svn/versioncontrol_svn.forms.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.13 - (show annotations) (download) (as text)
Sat Jun 20 10:17:52 2009 UTC (5 months, 1 week ago) by jpetso
Branch: MAIN
CVS Tags: HEAD
Changes since 1.12: +2 -2 lines
File MIME type: text/x-php
#491544 by chrono325: Enable log updating via xsvn.

Signed-off-by: Dan Hackney <chrono325@gmail.com>
1 <?php
2 // $Id: versioncontrol_svn.forms.inc,v 1.12 2009-04-27 13:21:25 sdboyer Exp $
3 /**
4 * @file
5 * Subversion backend for Version Control API - Provides Subversion commit
6 * information and account management as a pluggable backend.
7 *
8 * Copyright 2007 by Jakob Petsovits ("jpetso", http://drupal.org/user/56020)
9 * Copyright 2007 by Adam Light ("aclight", http://drupal.org/user/86358)
10 */
11
12
13 /**
14 * Implementation of hook_form_alter(): Add elements to various
15 * administrative forms that the Version Control API provides.
16 */
17 function versioncontrol_svn_form_alter(&$form, $form_state, $form_id) {
18 if ($form['#id'] == 'versioncontrol-repository-form' && $form['#vcs'] == 'svn') {
19 versioncontrol_svn_repository_admin_form_alter($form, $form_state, $form_id);
20 }
21 }
22
23
24 /**
25 * Add SVN specific elements to the add/edit repository form.
26 */
27 function versioncontrol_svn_repository_admin_form_alter(&$form, &$form_state, $form_id) {
28 $repository = empty($form['#repository']) ? NULL : $form['#repository'];
29 $svn_specific = isset($repository) ? $repository['svn_specific'] : array(
30 'updated' => 0,
31 'last_revision' => 0,
32 'auth_username' => '',
33 'auth_password' => '',
34 'update_method' => VERSIONCONTROL_SVN_UPDATE_CRON,
35 'path_trunk' => '/%project/trunk',
36 'path_branches' => '/%project/branches/%branch',
37 'path_tags' => '/%project/tags/%branch/%tag',
38 );
39
40 $form['#versioncontrol_svn'] = TRUE;
41 $form['#updated'] = $svn_specific['updated'];
42 $form['#last_revision'] = $svn_specific['last_revision'];
43
44 $form['repository_information']['root']['#description'] = t(
45 'The URL of this repository. Example: file:///svnroot/repo'
46 );
47
48 $form['repository_information']['svn_authentication'] = array(
49 '#type' => 'fieldset',
50 '#title' => t('Authentication'),
51 '#description' => t('If authentication is required in order to be retrieve commit logs and other information from the repository, you need to supply a username and password that will be passed to the \'svn\' executable as \'--username\' and \'--password\' options.'),
52 '#collapsible' => TRUE,
53 '#collapsed' => TRUE,
54 '#weight' => 10,
55 );
56 $form['repository_information']['svn_authentication']['auth_username'] = array(
57 '#type' => 'textfield',
58 '#title' => t('Username'),
59 '#description' => t('Leave empty in order to fetch logs (and other information) anonymously.'),
60 '#default_value' => $svn_specific['auth_username'],
61 '#weight' => 1,
62 '#size' => 40,
63 '#maxlength' => 128,
64 );
65 $form['repository_information']['svn_authentication']['auth_password'] = array(
66 '#type' => 'password',
67 '#title' => t('Password'),
68 '#description' => t('If empty, the password will not be changed.'),
69 '#default_value' => $svn_specific['auth_password'],
70 '#weight' => 2,
71 '#size' => 40,
72 '#maxlength' => 128,
73 );
74
75 $form['repository_information']['update_method'] = array(
76 '#type' => 'radios',
77 '#title' => t('Update method'),
78 '#description' => t('Automatic log retrieval requires cron.'),
79 '#default_value' => $svn_specific['update_method'],
80 '#weight' => 12,
81 '#options' => array(
82 VERSIONCONTROL_SVN_UPDATE_CRON => t('Automatic log retrieval.'),
83 VERSIONCONTROL_SVN_UPDATE_XSVN => t('Use external script to insert data.'),
84 ),
85 );
86
87 $form['svn_repository_layout'] = array(
88 '#type' => 'fieldset',
89 '#title' => t('Repository layout'),
90 '#description' => t('In order to recognize branches and tags, the Subversion backend needs to know where the trunk, branches and tags directories are located in this repository.'),
91 '#collapsible' => TRUE,
92 '#collapsed' => TRUE,
93 '#weight' => 2,
94 );
95 $form['svn_repository_layout']['path_trunk'] = array(
96 '#type' => 'textfield',
97 '#title' => t('Trunk directory'),
98 '#description' => t('Specify the path of the trunk directory here. Use %project as a placeholder for a directory name (probably the project name) that also occurs in the branches and tags paths.'),
99 '#default_value' => $svn_specific['path_trunk'],
100 '#weight' => 0,
101 '#size' => 40,
102 '#maxlength' => 255,
103 );
104 $form['svn_repository_layout']['path_branches'] = array(
105 '#type' => 'textfield',
106 '#title' => t('Branches directory'),
107 '#description' => t('Specify the path of the branches directory here. Use %branch as a placeholder for the branch name and %project for the directory name that was specified in the trunk directory.'),
108 '#default_value' => $svn_specific['path_branches'],
109 '#weight' => 1,
110 '#size' => 40,
111 '#maxlength' => 255,
112 );
113 $form['svn_repository_layout']['path_tags'] = array(
114 '#type' => 'textfield',
115 '#title' => t('Tags directory'),
116 '#description' => t('Specify the path of the tags directory here. Use %tags as a placeholder for the tag name, %branch for the branch name and %project for the directory name that was specified in the trunk directory.'),
117 '#default_value' => $svn_specific['path_tags'],
118 '#weight' => 2,
119 '#size' => 40,
120 '#maxlength' => 255,
121 );
122 }
123
124 /**
125 * Implementation of hook_versioncontrol_repository_submit():
126 * Extract repository data from the repository editing/adding form's
127 * submitted values, and add it to the @p $repository array. Later, that array
128 * will be passed to hook_versioncontrol_repository() as part of the repository
129 * insert/update procedure.
130 */
131 function versioncontrol_svn_versioncontrol_repository_submit(&$repository, $form, $form_state) {
132 if (!isset($form['#versioncontrol_svn'])) {
133 return;
134 }
135
136 $repository['svn_specific'] = array(
137 'updated' => $form['#updated'],
138 'last_revision' => $form['#last_revision'],
139 'update_method' => $form_state['values']['update_method'],
140 'path_trunk' => $form_state['values']['path_trunk'],
141 'path_branches' => $form_state['values']['path_branches'],
142 'path_tags' => $form_state['values']['path_tags'],
143 'auth_username' => $form_state['values']['auth_username'],
144 );
145 if (empty($form_state['values']['auth_username'])) {
146 $repository['svn_specific']['auth_password'] = '';
147 }
148 else if (!empty($form_state['values']['auth_password'])) {
149 $repository['svn_specific']['auth_password'] = str_rot13($form_state['values']['auth_password']);
150 }
151 }
152
153 /**
154 * Implementation of hook_versioncontrol_alter_repository_list():
155 * Add SVN specific columns into the list of Subversion repositories.
156 * By changing the @p $header and @p $rows_by_repo_id arguments,
157 * the repository list can be customized accordingly.
158 *
159 * @param $vcs
160 * The unique string identifier for the version control system that
161 * the passed repository list covers.
162 * @param $repositories
163 * An array of repositories of the given version control system.
164 * Array keys are the repository ids, and array values are the
165 * repository arrays like returned from versioncontrol_get_repository().
166 * @param $header
167 * A list of columns that will be passed to theme('table').
168 * @param $rows_by_repo_id
169 * An array of existing table rows, with repository ids as array keys.
170 * Each row already includes the generic column values, and for each row
171 * there is a repository with the same repository id given in the
172 * @p $repositories parameter.
173 */
174 function versioncontrol_svn_versioncontrol_alter_repository_list($vcs, $repositories, &$header, &$rows_by_repo_id) {
175 if ($vcs != 'svn') {
176 return;
177 }
178 $header[] = t('Update method');
179 $header[] = t('Last updated');
180
181 foreach ($rows_by_repo_id as $repo_id => &$row) {
182 if ($repositories[$repo_id]['svn_specific']['update_method'] == VERSIONCONTROL_SVN_UPDATE_XSVN) {
183 $row['update_method'] = t('external script');
184 $row['updated'] = t('n/a');
185 }
186 else if ($repositories[$repo_id]['svn_specific']['update_method'] == VERSIONCONTROL_SVN_UPDATE_CRON) {
187 $row['update_method'] = t('logs (!fetch)', array(
188 '!fetch' => l(t('fetch now'), 'admin/project/versioncontrol-repositories/update/svn/'. $repo_id)
189 ));
190 $row['updated'] = $repositories[$repo_id]['svn_specific']['updated']
191 ? t('!date (r!revision)', array(
192 '!date' => format_date($repositories[$repo_id]['svn_specific']['updated'], 'small'),
193 '!revision' => $repositories[$repo_id]['svn_specific']['last_revision'],
194 ))
195 : t('never');
196 }
197 }
198 }

  ViewVC Help
Powered by ViewVC 1.1.2