/[drupal]/contributions/modules/citizenspeak/citizenspeak.theme.php
ViewVC logotype

Contents of /contributions/modules/citizenspeak/citizenspeak.theme.php

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


Revision 1.18 - (show annotations) (download) (as text)
Sat Mar 18 17:15:49 2006 UTC (3 years, 8 months ago) by georgehotelling
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-5
Changes since 1.17: +8 -8 lines
File MIME type: text/x-php
Whoops, I missed a patch for issue #52280 but it should be good now
1 <?php
2 // $Id: citizenspeak.theme.php,v 1.17 2006/03/18 16:41:31 georgehotelling Exp $
3
4 /**
5 * @file
6 * Theme functions for the CitizenSpeak module
7 */
8
9 /**
10 * Display the form to participate in a campaign
11 *
12 * @param $node
13 * A CitizenSpeak campaign node
14 * @ingroup themeable
15 */
16 function theme_citizenspeak_participate_display($node) {
17 $edit = $_POST['edit'];
18
19 $output = '';
20 $output .= '<div class="citizenspeak_participate">';
21 $output .= theme('citizenspeak_message_preview', $node);
22
23 // Generate form, should probably be handled by forms.module
24 $form = '';
25 foreach (array('name', 'email', 'address', 'city') as $field) {
26 $form .= form_textfield(t(ucfirst($field)), $field, $edit[$field], '', '', null, null, true);
27 }
28
29 $state_array = array('', 'Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'District of Columbia', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming');
30 $form .= form_select(t('State'), 'state', $edit['state'], drupal_map_assoc($state_array), null, 0, false, true);
31
32 $form .= form_textfield(t('ZIP Code'), 'zip', $edit['zip'], 5, 5, null, null, true);
33 $form .= form_textfield(t('Phone'), 'phone', $edit['phone'], '', '', null, null, false);
34 $form .= form_textfield(t('Fax'), 'fax', $edit['fax'], '', '', null, null, false);
35 $form .= form_textarea(t('Personal Statement'), 'personal_statement', $edit['personal_statement'], 60, 20, t('This will be included in the email sent.'));
36
37 // Only make it a form if the node has been saved
38 if ($node->nid) {
39 $form .= form_submit(t('Send'));
40 $output .= form($form, 'post', url('node/'. $node->nid. '/send'));
41 } else {
42 $output .= $form;
43 }
44
45 $output .= '</div>';
46 return $output;
47 } // function theme_citizenspeak_form_display
48
49 /**
50 * Display what the emailed form will look like
51 *
52 * @param $node
53 * A CitizenSpeak campaign node
54 * @return A preview of the message CitizenSpeak will send
55 * @ingroup themeable
56 */
57 function theme_citizenspeak_message_preview($node) {
58 $participant = new StdClass();
59 $participant->name = t('Your Name');
60 $participant->organization = t('Your Organization');
61 $participant->email = 'you@example.com';
62 $participant->address = t('123 Your St.');
63 $participant->city = t('Yousville');
64 $participant->state = t('YO');
65 $participant->zip = t('12345');
66 $participant->phone = t('(123)456-7890');
67 $participant->fax = t('(123)456-7890x123');
68 $participant->personal_statement = t('Your Personal Statement');
69
70 $message = theme("citizenspeak_message", $node, $participant);
71 $headers = theme("citizenspeak_message_headers", $node, $participant);
72
73 $output = '<div id="citizenspeak_message_preview">';
74 $output .= '<tt>';
75 $output .= t("From: ") ."$participant->name &lt;$participant->email&gt;<br />";
76 if (variable_get('citizenspeak_show_to', 1)) {
77 $output .= t("To: ") . htmlentities($node->email_recipients) ."<br />";
78 }
79 $output .= t("Subject: ") . htmlentities($node->title) ."<br /><br />";
80 $output .= nl2br(htmlentities($message));
81 $output .= '</tt>';
82 $output .= '</div>';
83 return theme_box('Message Preview', $output);
84 } // function theme_citizenspeak_block_popular
85
86
87 /**
88 * Display the thank you page after the campaign has been participated in
89 *
90 * @param $node
91 * A CitizenSpeak campaign node
92 * @param $user
93 * The owner of the node
94 * @ingroup themeable
95 */
96 function theme_citizenspeak_thank_you($node, $user) {
97 $user = user_load(array("uid" => $node->uid));
98 drupal_set_title(t('Thank You'));
99
100 $output = '<div id="citizenspeak_thank_you">';
101 $output .= t('<p>Thank you for supporting our campaign. Your email is currently being sent to the individuals identified by %name. You can also be of great help to the campaign simply by passing the word along. All it takes is a brief letter to your e-mail circle.</p>', array("%name" => format_name($user)));
102
103 // Add action list
104 $tell_a_friend_text = t("Dear Friend,
105
106 Please join me in supporting the %title campaign. It's easy, just go to %url and make your voice heard.
107
108 Thank you,
109 ", array('%title' => $node->title, '%url' => url('node/'. $node->nid, null, null, true)));
110 $tell_a_friend_link = "mailto:?subject=". rawurlencode($node->title) ."&body=". rawurlencode($tell_a_friend_text);
111 $actions = array(t('<a href="%uri">Tell a friend</a>', array("%uri" => $tell_a_friend_link)));
112
113 if ($user->request_memberships) {
114 $membership_link = sprintf('https://www.paypal.com/xclick/business=%s&item_name=%s&amount=%.2f&no_note=1&no_shipping=1&tax=0&currency_code=USD', urlencode($user->membership_paypal_id.t(" membership dues")), urlencode($user->username), urlencode($user->membership_paypal_amount));
115 $actions[] = t('Become a member. <a href="%link">Join for $%amount per year.</a>', array("%link" => $membership_link, "%amount" => $user->membership_paypal_amount));
116 }
117
118 if ($user->request_donations) {
119 $donation_link = sprintf('https://www.paypal.com/xclick/business=%s&item_name=%s&no_note=1&no_shipping=1&tax=0&currency_code=USD', urlencode($user->donation_paypal_id), urlencode($user->username.t(' donation')));
120 $actions[] = t('<a href="%link">Make a donation.</a>', array("%link" => $donation_link));
121 }
122
123 if ($user->request_volunteers) {
124 $actions[] = t('<a href="mailto:%email">Become a volunteer</a>', array("%email" => $user->volunteer_email));
125 }
126
127 $output .= theme('item_list', $actions);
128
129 if ($user->include_additional_text) {
130 $output .= "<p>$user->additional_text</p>";
131 }
132
133 if ($user->request_feedback) {
134 $output .= t('<p>If you have any questions, feel free to contact <a href="mailto:%email">%email</a>.</p>', array("%email" => $user->feedback_email));
135 }
136
137 $output .= t('<p>Sincerely,<br /><strong>%name</strong></p>', array("%name" => format_name($user)));
138 $output .= '</div>';
139 return $output;
140 }
141
142 /**
143 * Display the participation statistics page
144 *
145 * @param $params
146 * An associative array with the following keys:
147 * total_emails
148 * total_zips
149 * last_email
150 * zips
151 * @ingroup themeable
152 */
153 function theme_citizenspeak_statistics_page($params) {
154 drupal_set_title(t('Campaign Statistics'));
155
156 $output = '<div id="citizenspeak_statistics">';
157 $output .= t("<strong>Total Emails Sent:</strong> %count<br />", array("%count" => $params['total_emails']));
158 $output .= t('<strong>Unique ZIP Codes:</strong> %count<br />', array("%count" => $params['total_zips']));
159 $output .= t('<strong>Last Email Sent:</strong> %count<br />', array("%count" => $params['last_email']));
160
161 $output .= t("<p>Download reports with all your campaign participants’ contact information, including name, organization, address, email address and personal statement. With campaign reports you can:<ul><li>Expand your list of supporters</li><li>Let supporters know they’re not alone.</li><li>Identify compelling personal statements.</li></ul>Please respect your campaign participants’ privacy by getting consent before making public their contact information and statements.</p>");
162 $output .= t("<p>To download a report, choose a file format and click \"download\"</p>");
163
164 $download_fields .= form_select(t('File format'), 'format', null, array("text" => t("text file"), "excel" => t("excel file"), "dbimport" => t("db import file")));
165 $download_fields .= form_submit(t("download"), 'op');
166 // If clean URLs aren't enabled, include the path
167 if (!variable_get('clean_url', 0)) {
168 $download_fields .= '<input type="hidden" name="q" value="node/'. arg(1) .'/report" />';
169 }
170 $output .= form($download_fields, 'get');
171
172 $output .= t('<h2>ZIP Code Summary</h2>');
173 $output .= theme_table(array(t('ZIP Code'), t('Emails')), $params['zips']);
174
175 $output .= '</div>';
176 return $output;
177 }
178
179 /**
180 * The content of an email to be sent
181 *
182 * @param $node
183 * A CitizenSpeak campaign node
184 * @param $participant
185 * A CitizenSpeak campaign participant
186 * @ingroup themeable
187 */
188 function theme_citizenspeak_message($node, $participant) {
189 // campaign_format is whether to include the personal statement at the top
190 if ($node->campaign_format) {
191 $output .= "$participant->personal_statement
192 ";
193 }
194
195 $output .= "
196 $node->email_message
197
198 $participant->name
199 $participant->organization
200 $participant->address
201 $participant->city, $participant->state $participant->zip";
202 if ($participant->phone) {
203 $output .= "
204 Phone: $participant->phone";
205 }
206 if ($participant->fax) {
207 $output .= "
208 Fax: $participant->fax";
209 }
210
211 if (!$node->campaign_format) {
212 $output .= "
213 p.s.
214 $participant->personal_statement";
215 }
216
217 $sig = t(variable_get('citizenspeak_signature', ""), array("%title" => $node->title, "%url" => url("node/". $node->nid, null, null, true), "%nid" => $node->nid));
218 if (strlen($sig)) {
219 $output .= "
220 --
221 $sig";
222 }
223
224 return $output;
225 }
226
227 /**
228 * Additional headers to add to emails
229 *
230 * @param $node
231 * A CitizenSpeak campaign node
232 * @param $participant
233 * A CitizenSpeak campaign participant
234 * @ingroup themeable
235 */
236
237 function theme_citizenspeak_message_headers($node, $participant) {
238 return "From: {$participant->name} <{$participant->email}>
239 X-Citizenspeak-Id: $node->nid";
240 }
241
242 /**
243 * Debugging Page
244 *
245 * @param $node
246 * A CitizenSpeak campaign node
247 * @param $message
248 * The body of a message, from theme_citizenspeak_message()
249 * @param $headers
250 * Additional headers, from theme_citizenspeak_message_headers()
251 */
252 function theme_citizenspeak_debug_page($node, $message, $headers) {
253 drupal_set_title(t('Debugging Mode'));
254 $output = t('<p>Message not sent because the system is in debugging mode. Use <a href="%settings_url">the CitizenSpeak settings</a> to turn of debugging mode. The email that would have been sent is below.</p>', array("%settings_url" => url("admin/settings/citizenspeak")));
255 $output .= '<pre>';
256 $output .= htmlentities("{$headers}\n");
257 $output .= htmlentities("To: {$node->email_recipients}\n");
258 $output .= htmlentities("Subject: {$node->title}\n");
259 $output .= htmlentities("\n{$message}\n");
260 $output .= '</pre>';
261 $output .= l(t('Continue to Thank You page'), "node/". $node->nid."/thank_you");
262 return $output;
263 }
264 ?>

  ViewVC Help
Powered by ViewVC 1.1.2