Projet

Général

Profil

Révision 76bdcd04

Ajouté par Assos Assos il y a plus de 5 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/print/print_mail/print_mail.admin.inc
10 10
 * @ingroup print
11 11
 */
12 12

  
13
// Include MIME library
14
@include_once('Mail/mime.php');
13
// Include MIME library, if available.
14
@include_once 'Mail/mime.php';
15 15

  
16 16
/**
17
 * Menu callback for the send by email module settings form.
17
 * Form constructor for the send by email module settings form.
18 18
 *
19 19
 * @ingroup forms
20 20
 */
21 21
function print_mail_settings() {
22
  $link = print_mail_print_link();
23

  
22 24
  $form['settings'] = array(
23 25
    '#type' => 'fieldset',
24 26
    '#title' => t('Send by email options'),
25 27
  );
26 28

  
27
  $form['settings']['print_mail_link_pos'] = array(
28
    '#type' => 'checkboxes',
29
    '#title' => t('Send by email link'),
30
    '#default_value' => variable_get('print_mail_link_pos', drupal_json_decode(PRINT_MAIL_LINK_POS_DEFAULT)),
31
    '#options' => array('link' => t('Links area'), 'corner' => t('Content corner'), 'block' => t('Block'), 'help' => t('Help area')),
32
    '#description' => t('Choose the location of the link(s) to the send by email page. The Links area is usually below the node content, whereas the Content corner is placed in the upper-right corner of the node content. Unselect all options to disable the link. Even if the link is disabled, you can still send a node by email by going to !path/nid where nid is the numeric id of the node.', array('!path' => PRINTMAIL_PATH)),
33
  );
34

  
35
  $form['settings']['print_mail_link_teaser'] = array(
36
    '#type' => 'checkbox',
37
    '#title' => t('Display send by email link in teaser'),
38
    '#default_value' => variable_get('print_mail_link_teaser', PRINT_MAIL_LINK_TEASER_DEFAULT),
39
    '#description' => t('Enabling this will display the link in teaser mode.'),
40
  );
41

  
42
  $form['settings']['adv_link'] = array(
43
    '#type' => 'fieldset',
44
    '#title' => t('Advanced link options'),
45
    '#collapsible' => TRUE,
46
    '#collapsed' => FALSE,
47
  );
48

  
49
  $form['settings']['adv_link']['print_mail_show_link'] = array(
50
    '#type' => 'radios',
51
    '#title' => t('Link style'),
52
    '#default_value' => variable_get('print_mail_show_link', PRINT_MAIL_SHOW_LINK_DEFAULT),
53
    '#options' => array(1 => t('Text only'), 2 => t('Icon only'), 3 => t('Icon and Text')),
54
    '#description' => t('Select the visual style of the link.'),
55
  );
56

  
57
  $form['settings']['adv_link']['print_mail_link_use_alias'] = array(
58
    '#type' => 'checkbox',
59
    '#title' => t('Use URL alias instead of node ID'),
60
    '#default_value' => variable_get('print_mail_link_use_alias', PRINT_MAIL_LINK_USE_ALIAS_DEFAULT),
61
    '#description' => t('Enabling this will create the link using the URL alias instead of the node ID.'),
62
  );
63

  
64
  $form['settings']['adv_link']['print_mail_link_class'] = array(
65
    '#type' => 'textfield',
66
    '#title' => t('Link class'),
67
    '#default_value' => variable_get('print_mail_link_class', PRINT_MAIL_LINK_CLASS_DEFAULT),
68
    '#size' => 60,
69
    '#maxlength' => 250,
70
    '#description' => t('This can be used by themers to change the link style or by jQuery modules to open in a new window (e.g. greybox or thickbox). Multiple classes can be specified, separated by spaces.'),
71
  );
72

  
73
  $form['settings']['adv_link']['print_mail_node_link_visibility'] = array(
74
    '#type' => 'radios',
75
    '#title' => t('Link visibility'),
76
    '#default_value' => variable_get('print_mail_node_link_visibility', PRINT_MAIL_NODE_LINK_VISIBILITY_DEFAULT),
77
    '#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')),
78
  );
79

  
80
  $form['settings']['adv_link']['print_mail_node_link_pages'] = array(
81
    '#type' => 'textarea',
82
    '#default_value' => variable_get('print_mail_node_link_pages', PRINT_MAIL_NODE_LINK_PAGES_DEFAULT),
83
    '#rows' => 3,
84
    '#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
85
  );
86

  
87
  if (module_exists('php')) {
88
    $access = user_access('use PHP for settings');
89

  
90
    if ($form['settings']['adv_link']['print_mail_node_link_visibility']['#default_value'] == 2 && !$access) {
91
      $form['settings']['adv_link']['print_mail_node_link_visibility'] = array('#type' => 'value', '#value' => 2);
92
      $form['settings']['adv_link']['print_mail_node_link_pages'] = array('#type' => 'value', '#value' => $form['settings']['adv_link']['print_mail_node_link_pages']['#default_value']);
93
    }
94
    elseif ($access) {
95
      $form['settings']['adv_link']['print_mail_node_link_visibility']['#options'][] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
96
      $form['settings']['adv_link']['print_mail_node_link_pages']['#description'] .= ' ' . t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '<?php ?>'));
97
    }
98
  }
99

  
100
  $form['settings']['adv_link']['print_mail_sys_link_visibility'] = array(
101
    '#type' => 'radios',
102
    '#title' => t('Show link in system (non-content) pages'),
103
    '#description' => 'Any page that is not a Drupal node. Usually pages generated by Drupal or a module such as Views or Panels.',
104
    '#default_value' => variable_get('print_mail_sys_link_visibility', PRINT_MAIL_SYS_LINK_VISIBILITY_DEFAULT),
105
    '#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')),
106
  );
107

  
108
  $form['settings']['adv_link']['print_mail_sys_link_pages'] = array(
109
    '#type' => 'textarea',
110
    '#default_value' => variable_get('print_mail_sys_link_pages', PRINT_MAIL_SYS_LINK_PAGES_DEFAULT),
111
    '#rows' => 3,
112
    '#description' => t('Setting this option will add a send by email link on pages created by Drupal or the enabled modules.') . '<br />' .
113
                      t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
114
  );
115

  
116
  if (module_exists('php')) {
117
    if ($form['settings']['adv_link']['print_mail_sys_link_visibility']['#default_value'] == 2 && !$access) {
118
      $form['settings']['adv_link']['print_mail_sys_link_visibility'] = array('#type' => 'value', '#value' => 2);
119
      $form['settings']['adv_link']['print_mail_sys_link_pages'] = array('#type' => 'value', '#value' => $form['settings']['adv_link']['print_mail_sys_link_pages']['#default_value']);
120
    }
121
    elseif ($access) {
122
      $form['settings']['adv_link']['print_mail_sys_link_visibility']['#options'][] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
123
      $form['settings']['adv_link']['print_mail_sys_link_pages']['#description'] .= ' ' . t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can break your Drupal site.', array('%php' => '<?php ?>'));
124
    }
125
  }
126

  
127
  $form['settings']['adv_link']['print_mail_book_link'] = array(
128
    '#type' => 'radios',
129
    '#title' => t('Link in book hierarchy nodes'),
130
    '#default_value' => variable_get('print_mail_book_link', PRINT_MAIL_BOOK_LINK_DEFAULT),
131
    '#options' => array(t('No link'), t('Current page and sub-pages'), t('Current page only')),
132
  );
133

  
134 29
  $form['settings']['print_mail_hourly_threshold'] = array(
135 30
    '#type' => 'select',
136 31
    '#title' => t('Hourly threshold'),
137 32
    '#default_value' => variable_get('print_mail_hourly_threshold', PRINT_MAIL_HOURLY_THRESHOLD),
138
    '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50)),
33
    '#options' => drupal_map_assoc(
34
      array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50)
35
    ),
139 36
    '#description' => t('The maximum number of emails a user can send per hour.'),
140 37
  );
141 38

  
......
153 50
    '#description' => t("If selected, the default choice will be to send only the node's teaser instead of the full content."),
154 51
  );
155 52

  
53
  $form['settings']['print_mail_user_recipients'] = array(
54
    '#type' => 'checkbox',
55
    '#title' => t('Enable user list recipients'),
56
    '#default_value' => variable_get('print_mail_user_recipients', PRINT_MAIL_USER_RECIPIENTS_DEFAULT),
57
    '#description' => t("If selected, a user list will be included as possible email recipients."),
58
  );
59

  
156 60
  $form['settings']['print_mail_teaser_choice'] = array(
157 61
    '#type' => 'checkbox',
158 62
    '#title' => t('Enable teaser/full mode choice'),
......
188 92
    '#description' => t('Enabling this option will display a list of printer-friendly destination URLs at the bottom of the page.'),
189 93
  );
190 94

  
191
  return system_settings_form($form);
192
}
193

  
194
/**
195
 * Menu callback for the send by email module text strings settings form.
196
 *
197
 * @ingroup forms
198
 */
199
function print_mail_strings_settings() {
200
  drupal_set_message(t("Saving these strings will disable their translation via Drupal's language system. Use the reset button to return them to the original state."), 'warning', FALSE);
201

  
202
  $form['print_mail_text'] = array(
95
  $form['settings']['link_text'] = array(
203 96
    '#type' => 'fieldset',
204
    '#title' => t('Text strings'),
205
  );
206

  
207
  $form['print_mail_text']['print_mail_link_text'] = array(
208
    '#type' => 'textfield',
209
    '#title' => t('Link text'),
210
    '#default_value' => variable_get('print_mail_link_text', t('Send by email')),
211
    '#description' => t('Text used in the link to the send by-email form.'),
212
  );
213

  
214
  $form['print_mail_text']['print_mail_text_title'] = array(
215
    '#type' => 'textfield',
216
    '#title' => t('Form page title'),
217
    '#default_value' => variable_get('print_mail_text_title', t('Send page by email')),
218
    '#description' => t("Text used as the page title of the mail submission form. Requires a menu rebuild to apply."),
219
  );
220
  $form['print_mail_text']['print_mail_text_subject'] = array(
221
    '#type' => 'textfield',
222
    '#title' => t('Message subject'),
223
    '#default_value' => variable_get('print_mail_text_subject', t('!user has sent you a message from !site')),
224
    '#description' => t("email subject line. The sender's name will appear in place of !user in the subject. The web site name will be inserted in place of !site. The page title replaces !title."),
225
  );
226
  $form['print_mail_text']['print_mail_text_message'] = array(
227
    '#type' => 'textarea',
228
    '#title' => t('Message preamble'),
229
    '#default_value' => variable_get('print_mail_text_message', t('Message from sender')),
230
    '#description' => t('email message preamble. The sender will be able to add their own message after this.'),
97
    '#title' => t('Custom link text'),
98
    '#collapsible' => TRUE,
99
    '#collapsed' => TRUE,
231 100
  );
232
  $form['print_mail_text']['print_mail_text_content'] = array(
233
    '#type' => 'textarea',
234
    '#title' => t('Message content'),
235
    '#default_value' => variable_get('print_mail_text_content', ''),
236
    '#description' => t('Set the default contents of the message.'),
101
  $form['settings']['link_text']['print_mail_link_text_enabled'] = array(
102
    '#type' => 'checkbox',
103
    '#title' => t('Enable custom link text'),
104
    '#default_value' => variable_get('print_mail_link_text_enabled', PRINT_TYPE_LINK_TEXT_ENABLED_DEFAULT),
237 105
  );
238
  $form['print_mail_text']['print_mail_text_confirmation'] = array(
106
  $form['settings']['link_text']['print_mail_link_text'] = array(
239 107
    '#type' => 'textfield',
240
    '#title' => t('Thank you message'),
241
    '#default_value' => variable_get('print_mail_text_confirmation', t('Thank you for spreading the word about !site.')),
242
    '#description' => t('This message will be displayed after the user successfully submits the form.'),
243
  );
244
  $form['print_mail_text']['reset'] = array(
245
    '#type' => 'submit',
246
    '#value' => t('Reset to defaults'),
247
    '#submit' => array('print_mail_strings_settings_delete'),
108
    '#default_value' => variable_get('print_mail_link_text', $link['text']),
109
    '#description' => t('Text used in the link to the send by email form.'),
248 110
  );
249 111

  
250 112
  return system_settings_form($form);
251 113
}
252

  
253
/**
254
 * Reset button callback for text strings settings form
255
 *
256
 * @ingroup forms
257
 */
258
function print_mail_strings_settings_delete() {
259
  variable_del('print_mail_link_text');
260
  variable_del('print_mail_text_title');
261
  variable_del('print_mail_text_subject');
262
  variable_del('print_mail_text_message');
263
  variable_del('print_mail_text_content');
264
  variable_del('print_mail_text_confirmation');
265
}

Formats disponibles : Unified diff