Project

General

Profile

Revision 76bdcd04

Added by Assos Assos almost 6 years ago

Weekly update of contrib modules

View differences:

drupal7/sites/all/modules/print/print.admin.inc
11 11
 */
12 12

  
13 13
/**
14
 * Menu callback for the Printer-friendly pages module settings form.
14
 * Form constructor for the Printer-friendly pages module settings form.
15 15
 *
16 16
 * @ingroup forms
17 17
 */
......
19 19
  $print_css = variable_get('print_css', PRINT_CSS_DEFAULT);
20 20
  // Check that the stylesheet path is indeed valid and relative to base_path()
21 21
  if (!empty($print_css) && empty($_POST)) {
22
    $css_path = dirname($_SERVER['SCRIPT_FILENAME']) . '/' . strtr($print_css, array('%t' => drupal_get_path('theme', variable_get('theme_default', 'garland'))));
22
    $css_path = DRUPAL_ROOT . '/' . strtr($print_css, array(
23
      '%t' => drupal_get_path('theme', variable_get('theme_default', 'garland')),
24
    ));
23 25
    if (!is_file($css_path) || !is_readable($css_path)) {
24 26
      drupal_set_message(t("File %file is not readable by the web server.", array('%file' => $css_path)), 'warning', FALSE);
25 27
    }
......
37 39
    '#size' => 60,
38 40
    '#maxlength' => 250,
39 41
    '#description' => t('The path to your custom print cascading stylesheet, if any. The path provided must be relative to the base path. When none is specified, the default module CSS file is used.') . '<br />' .
40
                      t('Macros: %t (path to theme: "%theme")', array('%theme' => drupal_get_path('theme', variable_get('theme_default', 'bartik')))) . '<br />' .
41
                      t('Requires the <em>Administer site configuration</em> permission.'),
42
      t('Macros: %t (path to theme: "%theme")', array(
43
        '%theme' => drupal_get_path('theme', variable_get('theme_default', 'bartik')),
44
      )) . '<br />' .
45
      t('Requires the <em>Administer site configuration</em> permission.'),
42 46
    '#disabled' => !user_access('administer site configuration'),
43 47
  );
44 48

  
......
54 58
    '#title' => t('Printer-friendly URLs list'),
55 59
    '#default_value' => variable_get('print_urls', PRINT_URLS_DEFAULT),
56 60
    '#description' => t('If set, a list of the destination URLs for the page links will be displayed at the bottom of the page.') . '<br />' .
57
                      t('Note that you can enable/disable the URL list for each content type individually from the !url.', array('!url' => l(t('Content Types page'), 'admin/structure/types'))),
61
      t('Note that you can enable/disable the URL list for each content type individually from the !url.', array(
62
        '!url' => l(t('Content Types page'), 'admin/structure/types'),
63
      )),
58 64
  );
59 65

  
60 66
  $form['settings']['print_urls_anchors'] = array(
......
71 77
    '#description' => t('When this option is active, user comments are also included in the printer-friendly version. Requires the comment module.'),
72 78
  );
73 79

  
80
  $form['settings']['print_node_router'] = array(
81
    '#type' => 'checkbox',
82
    '#title' => t('Consult menu router for node display handler'),
83
    '#default_value' => variable_get('print_node_router', PRINT_NODE_ROUTER_DEFAULT),
84
    '#description' => t('When this option is active, print module will check the menu router for the handler to consult for page contents at node/%node.'),
85
  );
86

  
74 87
  $form['settings']['print_newwindow'] = array(
75 88
    '#type' => 'radios',
76 89
    '#title' => t('New window method'),
......
89 102
  $form['settings']['logo']['print_logo_options'] = array(
90 103
    '#type' => 'radios',
91 104
    '#title' => t('Logo type'),
92
    '#options' => array(t('None (Disabled)'), t("Current theme's logo"), t('User-specified')),
105
    '#options' => array(
106
      t('None (Disabled)'),
107
      t("Current theme's logo"),
108
      t('User-specified'),
109
    ),
93 110
    '#default_value' => variable_get('print_logo_options', PRINT_LOGO_OPTIONS_DEFAULT),
94 111
    '#description' => t("Select the type of logo to display on the printer-friendly version. In case of a user-specified location, insert the path or URL below."),
95 112
  );
......
120 137
  $form['settings']['footer']['print_footer_options'] = array(
121 138
    '#type' => 'radios',
122 139
    '#title' => t('Footer type'),
123
    '#options' => array(t('None (Disabled)'), t("Site's footer"), t('User-specified')),
140
    '#options' => array(
141
      t('None (Disabled)'),
142
      t("Site's footer"),
143
      t('User-specified'),
144
    ),
124 145
    '#default_value' => variable_get('print_footer_options', PRINT_FOOTER_OPTIONS_DEFAULT),
125 146
    '#description' => t("Select the type of footer to display on the printer-friendly version. In case of a user-specified footer, insert it below."),
126 147
  );
......
168 189
}
169 190

  
170 191
/**
171
 * Validate print_main_settings form.
192
 * Form validation handler for print_main_settings().
172 193
 */
173 194
function _print_main_settings_validate($form, &$form_state) {
174 195
  global $base_root;
......
179 200
    // files table as a temporary file. We'll make a copy and let the garbage
180 201
    // collector delete the original upload.
181 202
    if ($filename = file_unmanaged_copy($file->uri)) {
203
      /** @var DrupalStreamWrapperInterface $wrapper */
182 204
      $wrapper = file_stream_wrapper_get_instance_by_uri($filename);
183 205

  
184 206
      $form_state['values']['print_logo_options'] = 2;
......
188 210
}
189 211

  
190 212
/**
191
 * Menu callback for the Printer-friendly pages HTML settings form.
213
 * Form constructor for the Printer-friendly pages HTML settings form.
192 214
 *
193 215
 * @ingroup forms
194 216
 */
195 217
function print_html_settings() {
218
  $link = print_print_link();
219

  
196 220
  $form['settings'] = array(
197 221
    '#type' => 'fieldset',
198 222
    '#title' => t('Web page options'),
199 223
  );
200 224

  
201
  $form['settings']['print_html_link_pos'] = array(
202
    '#type' => 'checkboxes',
203
    '#title' => t('Printer-friendly page link'),
204
    '#default_value' => variable_get('print_html_link_pos', drupal_json_decode(PRINT_HTML_LINK_POS_DEFAULT)),
205
    '#options' => array('link' => t('Links area'), 'corner' => t('Content corner'), 'block' => t('Block'), 'help' => t('Help area')),
206
    '#description' => t('Choose the location of the link(s) to the printer-friendly 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 view the print version of a node by going to !path/nid where nid is the numeric id of the node.', array('!path' => PRINT_PATH)),
207
  );
208

  
209
  $form['settings']['print_html_link_teaser'] = array(
210
    '#type' => 'checkbox',
211
    '#title' => t('Display printer-friendly link in teaser'),
212
    '#default_value' => variable_get('print_html_link_teaser', PRINT_HTML_LINK_TEASER_DEFAULT),
213
    '#description' => t('Enabling this will display the link in teaser mode.'),
214
  );
215

  
216
  $form['settings']['adv_link'] = array(
217
    '#type' => 'fieldset',
218
    '#title' => t('Advanced link options'),
219
    '#collapsible' => TRUE,
220
    '#collapsed' => FALSE,
221
  );
222

  
223
  $form['settings']['adv_link']['print_html_show_link'] = array(
224
    '#type' => 'radios',
225
    '#title' => t('Link style'),
226
    '#default_value' => variable_get('print_html_show_link', PRINT_HTML_SHOW_LINK_DEFAULT),
227
    '#options' => array(1 => t('Text only'), 2 => t('Icon only'), 3 => t('Icon and Text')),
228
    '#description' => t('Select the visual style of the link.'),
229
  );
230

  
231
  $form['settings']['adv_link']['print_html_link_use_alias'] = array(
232
    '#type' => 'checkbox',
233
    '#title' => t('Use URL alias instead of node ID'),
234
    '#default_value' => variable_get('print_html_link_use_alias', PRINT_HTML_LINK_USE_ALIAS_DEFAULT),
235
    '#description' => t('Enabling this will create the link using the URL alias instead of the node ID.'),
236
  );
237

  
238
  $form['settings']['adv_link']['print_html_link_class'] = array(
239
    '#type' => 'textfield',
240
    '#title' => t('Link class'),
241
    '#default_value' => variable_get('print_html_link_class', PRINT_HTML_LINK_CLASS_DEFAULT),
242
    '#size' => 60,
243
    '#maxlength' => 250,
244
    '#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.'),
245
  );
246

  
247
  $form['settings']['adv_link']['print_html_node_link_visibility'] = array(
248
    '#type' => 'radios',
249
    '#title' => t('Link visibility'),
250
    '#default_value' => variable_get('print_html_node_link_visibility', PRINT_HTML_NODE_LINK_VISIBILITY_DEFAULT),
251
    '#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')),
252
  );
253

  
254
  $form['settings']['adv_link']['print_html_node_link_pages'] = array(
255
    '#type' => 'textarea',
256
    '#default_value' => variable_get('print_html_node_link_pages', PRINT_HTML_NODE_LINK_PAGES_DEFAULT),
257
    '#rows' => 3,
258
    '#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>')),
259
  );
260

  
261
  if (module_exists('php')) {
262
    $access = user_access('use PHP for settings');
263

  
264
    if ($form['settings']['adv_link']['print_html_node_link_visibility']['#default_value'] == 2 && !$access) {
265
      $form['settings']['adv_link']['print_html_node_link_visibility'] = array('#type' => 'value', '#value' => 2);
266
      $form['settings']['adv_link']['print_html_node_link_pages'] = array('#type' => 'value', '#value' => $form['settings']['adv_link']['print_html_node_link_pages']['#default_value']);
267
    }
268
    elseif ($access) {
269
      $form['settings']['adv_link']['print_html_node_link_visibility']['#options'][] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
270
      $form['settings']['adv_link']['print_html_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 ?>'));
271
    }
272
  }
273

  
274
  $form['settings']['adv_link']['print_html_sys_link_visibility'] = array(
275
    '#type' => 'radios',
276
    '#title' => t('Show link in system (non-content) pages'),
277
    '#description' => 'Any page that is not a Drupal node. Usually pages generated by Drupal or a module such as Views or Panels.',
278
    '#default_value' => variable_get('print_html_sys_link_visibility', PRINT_HTML_SYS_LINK_VISIBILITY_DEFAULT),
279
    '#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')),
280
  );
281

  
282
  $form['settings']['adv_link']['print_html_sys_link_pages'] = array(
283
    '#type' => 'textarea',
284
    '#default_value' => variable_get('print_html_sys_link_pages', PRINT_HTML_SYS_LINK_PAGES_DEFAULT),
285
    '#rows' => 3,
286
    '#description' => t('Setting this option will add a printer-friendly version page link on pages created by Drupal or the enabled modules.') . '<br />' .
287
                      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>')),
288
  );
289

  
290
  if (module_exists('php')) {
291
    if ($form['settings']['adv_link']['print_html_sys_link_visibility']['#default_value'] == 2 && !$access) {
292
      $form['settings']['adv_link']['print_html_sys_link_visibility'] = array('#type' => 'value', '#value' => 2);
293
      $form['settings']['adv_link']['print_html_sys_link_pages'] = array('#type' => 'value', '#value' => $form['settings']['adv_link']['print_html_sys_link_pages']['#default_value']);
294
    }
295
    elseif ($access) {
296
      $form['settings']['adv_link']['print_html_sys_link_visibility']['#options'][] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
297
      $form['settings']['adv_link']['print_html_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 ?>'));
298
    }
299
  }
300

  
301
  $form['settings']['adv_link']['print_html_book_link'] = array(
302
    '#type' => 'radios',
303
    '#title' => t('Link in book hierarchy nodes'),
304
    '#default_value' => variable_get('print_html_book_link', PRINT_HTML_BOOK_LINK_DEFAULT),
305
    '#options' => array(t('Book module link not modified'), t('Current page and sub-pages'), t('Current page only')),
306
  );
307

  
308 225
  $form['settings']['print_html_new_window'] = array(
309 226
    '#type' => 'checkbox',
310 227
    '#title' => t('Open the printer-friendly version in a new window'),
......
326 243
    '#description' => t("When the above options are enabled, this option will close the window after its contents are printed."),
327 244
  );
328 245

  
329
  $form['settings']['print_display_sys_urllist'] = array(
246
  $form['settings']['print_html_display_sys_urllist'] = array(
330 247
    '#type' => 'checkbox',
331 248
    '#title' => t('Printer-friendly URLs list in system pages'),
332
    '#default_value' => variable_get('print_display_sys_urllist', PRINT_TYPE_SYS_URLLIST_DEFAULT),
249
    '#default_value' => variable_get('print_html_display_sys_urllist', PRINT_TYPE_SYS_URLLIST_DEFAULT),
333 250
    '#description' => t('Enabling this option will display a list of printer-friendly destination URLs at the bottom of the page.'),
334 251
  );
335 252

  
336 253
  $form['settings']['print_robots_settings'] = array(
337
      '#type' => 'fieldset',
338
      '#title' => t('Robots META tags'),
339
      '#collapsible' => TRUE,
340
      '#collapsed' => TRUE,
254
    '#type' => 'fieldset',
255
    '#title' => t('Robots META tags'),
256
    '#collapsible' => TRUE,
257
    '#collapsed' => FALSE,
341 258
  );
342 259

  
343 260
  $form['settings']['print_robots_settings']['print_robots_noindex'] = array(
......
361 278
    '#description' => t('Non-standard tag to instruct search engines to not show a "Cached" link for your printer-friendly pages. Recognized by Googlebot.'),
362 279
  );
363 280

  
364
  return system_settings_form($form);
365
}
366

  
367
/**
368
 * Menu callback for the common print module text strings settings form
369
 *
370
 * @ingroup forms
371
 */
372
function print_main_strings_settings() {
373
  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');
374

  
375
  $form['print_main_text'] = array(
281
  $form['settings']['link_text'] = array(
376 282
    '#type' => 'fieldset',
377
    '#title' => t('Text strings'),
378
  );
379

  
380
  $form['print_main_text']['print_text_published'] = array(
381
    '#type' => 'textfield',
382
    '#default_value' => variable_get('print_text_published', t('Published on %site_name')),
383
  );
384
  $form['print_main_text']['print_text_source_url'] = array(
385
    '#type' => 'textfield',
386
    '#default_value' => variable_get('print_text_source_url', t('Source URL')),
387
  );
388
  $form['print_main_text']['print_text_retrieved'] = array(
389
    '#type' => 'textfield',
390
    '#default_value' => variable_get('print_text_retrieved', t('retrieved on %date')),
391
  );
392
  $form['print_main_text']['print_text_links'] = array(
393
    '#type' => 'textfield',
394
    '#default_value' => variable_get('print_text_links', t('Links')),
395
  );
396
  $form['print_main_text']['reset'] = array(
397
    '#type' => 'submit',
398
    '#value' => t('Reset to defaults'),
399
    '#submit' => array('print_main_strings_settings_delete'),
283
    '#title' => t('Custom link text'),
284
    '#collapsible' => TRUE,
285
    '#collapsed' => TRUE,
400 286
  );
401

  
402
  return system_settings_form($form);
403
}
404

  
405
/**
406
 * Reset button callback for text strings settings form
407
 *
408
 * @ingroup forms
409
 */
410
function print_main_strings_settings_delete() {
411
  variable_del('print_text_published');
412
  variable_del('print_text_source_url');
413
  variable_del('print_text_retrieved');
414
  variable_del('print_text_links');
415
}
416

  
417
/**
418
 * Menu callback for the printer-friendly version text strings settings form
419
 *
420
 * @ingroup forms
421
 */
422
function print_html_strings_settings() {
423
  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');
424

  
425
  $form['print_html_text'] = array(
426
    '#type' => 'fieldset',
427
    '#title' => t('Text strings'),
287
  $form['settings']['link_text']['print_html_link_text_enabled'] = array(
288
    '#type' => 'checkbox',
289
    '#title' => t('Enable custom link text'),
290
    '#default_value' => variable_get('print_html_link_text_enabled', PRINT_TYPE_LINK_TEXT_ENABLED_DEFAULT),
428 291
  );
429

  
430
  $form['print_html_text']['print_html_link_text'] = array(
292
  $form['settings']['link_text']['print_html_link_text'] = array(
431 293
    '#type' => 'textfield',
432
    '#title' => t('Link text'),
433
    '#default_value' => variable_get('print_html_link_text', t('Printer-friendly version')),
294
    '#default_value' => variable_get('print_html_link_text', $link['text']),
434 295
    '#description' => t('Text used in the link to the printer-friendly version.'),
435 296
  );
436
  $form['print_html_text']['reset'] = array(
437
    '#type' => 'submit',
438
    '#value' => t('Reset to defaults'),
439
    '#submit' => array('print_html_strings_settings_delete'),
440
  );
441 297

  
442 298
  return system_settings_form($form);
443 299
}
444

  
445
/**
446
 * Reset button callback for text strings settings form
447
 *
448
 * @ingroup forms
449
 */
450
function print_html_strings_settings_delete() {
451
  variable_del('print_html_link_text');
452
}

Also available in: Unified diff