Révision 76bdcd04
Ajouté par Assos Assos il y a presque 6 ans
drupal7/sites/all/modules/print/print_pdf/print_pdf.admin.inc | ||
---|---|---|
11 | 11 |
*/ |
12 | 12 |
|
13 | 13 |
/** |
14 |
* Menu callback for the PDF version module settings form.
|
|
14 |
* Form constructor for the PDF version module settings form.
|
|
15 | 15 |
* |
16 | 16 |
* @ingroup forms |
17 |
* @see _print_pdf_tools() |
|
18 | 17 |
*/ |
19 | 18 |
function print_pdf_settings() { |
20 |
$pdf_tools = _print_pdf_tools(); |
|
21 |
$current_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT); |
|
22 |
$pdf_tool_default = (in_array($current_pdf_tool, $pdf_tools)) ? $current_pdf_tool : PRINT_PDF_PDF_TOOL_DEFAULT; |
|
19 |
$pdf_tools = array(); |
|
20 |
drupal_alter('print_pdf_available_libs', $pdf_tools); |
|
21 |
|
|
22 |
if (!empty($pdf_tools)) { |
|
23 |
$link = print_pdf_print_link(); |
|
24 |
|
|
25 |
$current_pdf_tool = variable_get('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT); |
|
26 |
$pdf_tool_default = array_key_exists((string) $current_pdf_tool, $pdf_tools) ? $current_pdf_tool : PRINT_PDF_PDF_TOOL_DEFAULT; |
|
23 | 27 |
|
24 |
if ($pdf_tools != -1) { |
|
25 | 28 |
$form['settings'] = array( |
26 | 29 |
'#type' => 'fieldset', |
27 | 30 |
'#title' => t('PDF options'), |
... | ... | |
35 | 38 |
'#description' => t('This option selects the PDF generation tool being used by this module to create the PDF version.'), |
36 | 39 |
); |
37 | 40 |
|
38 |
$form['settings']['print_pdf_link_pos'] = array( |
|
39 |
'#type' => 'checkboxes', |
|
40 |
'#title' => t('PDF version link'), |
|
41 |
'#default_value' => variable_get('print_pdf_link_pos', drupal_json_decode(PRINT_PDF_LINK_POS_DEFAULT)), |
|
42 |
'#options' => array('link' => t('Links area'), 'corner' => t('Content corner'), 'block' => t('Block'), 'help' => t('Help area')), |
|
43 |
'#description' => t('Choose the location of the link(s) to the PDF version. 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 PDF version of a node by going to !path/nid where nid is the numeric id of the node.', array('!path' => PRINTPDF_PATH)), |
|
44 |
); |
|
45 |
|
|
46 |
$form['settings']['print_pdf_link_teaser'] = array( |
|
47 |
'#type' => 'checkbox', |
|
48 |
'#title' => t('Display link to the PDF version in teaser'), |
|
49 |
'#default_value' => variable_get('print_pdf_link_teaser', PRINT_PDF_LINK_TEASER_DEFAULT), |
|
50 |
'#description' => t('Enabling this will display the link in teaser mode.'), |
|
51 |
); |
|
52 |
|
|
53 |
$form['settings']['adv_link'] = array( |
|
54 |
'#type' => 'fieldset', |
|
55 |
'#title' => t('Advanced link options'), |
|
56 |
'#collapsible' => TRUE, |
|
57 |
'#collapsed' => FALSE, |
|
58 |
); |
|
59 |
|
|
60 |
$form['settings']['adv_link']['print_pdf_show_link'] = array( |
|
61 |
'#type' => 'radios', |
|
62 |
'#title' => t('Link style'), |
|
63 |
'#default_value' => variable_get('print_pdf_show_link', PRINT_PDF_SHOW_LINK_DEFAULT), |
|
64 |
'#options' => array(1 => t('Text only'), 2 => t('Icon only'), 3 => t('Icon and Text')), |
|
65 |
'#description' => t('Select the visual style of the link.'), |
|
66 |
); |
|
67 |
|
|
68 |
$form['settings']['adv_link']['print_pdf_link_use_alias'] = array( |
|
69 |
'#type' => 'checkbox', |
|
70 |
'#title' => t('Use URL alias instead of node ID'), |
|
71 |
'#default_value' => variable_get('print_pdf_link_use_alias', PRINT_PDF_LINK_USE_ALIAS_DEFAULT), |
|
72 |
'#description' => t('Enabling this will create the link using the URL alias instead of the node ID.'), |
|
73 |
); |
|
74 |
|
|
75 |
$form['settings']['adv_link']['print_pdf_link_class'] = array( |
|
76 |
'#type' => 'textfield', |
|
77 |
'#title' => t('Link class'), |
|
78 |
'#default_value' => variable_get('print_pdf_link_class', PRINT_PDF_LINK_CLASS_DEFAULT), |
|
79 |
'#size' => 60, |
|
80 |
'#maxlength' => 250, |
|
81 |
'#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.'), |
|
82 |
); |
|
83 |
|
|
84 |
$form['settings']['adv_link']['print_pdf_node_link_visibility'] = array( |
|
85 |
'#type' => 'radios', |
|
86 |
'#title' => t('Link visibility'), |
|
87 |
'#default_value' => variable_get('print_pdf_node_link_visibility', PRINT_PDF_NODE_LINK_VISIBILITY_DEFAULT), |
|
88 |
'#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')), |
|
89 |
); |
|
90 |
|
|
91 |
$form['settings']['adv_link']['print_pdf_node_link_pages'] = array( |
|
92 |
'#type' => 'textarea', |
|
93 |
'#default_value' => variable_get('print_pdf_node_link_pages', PRINT_PDF_NODE_LINK_PAGES_DEFAULT), |
|
94 |
'#rows' => 3, |
|
95 |
'#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>')), |
|
96 |
); |
|
97 |
|
|
98 |
if (module_exists('php')) { |
|
99 |
$access = user_access('use PHP for settings'); |
|
100 |
|
|
101 |
if ($form['settings']['adv_link']['print_pdf_node_link_visibility']['#default_value'] == 2 && !$access) { |
|
102 |
$form['settings']['adv_link']['print_pdf_node_link_visibility'] = array('#type' => 'value', '#value' => 2); |
|
103 |
$form['settings']['adv_link']['print_pdf_node_link_pages'] = array('#type' => 'value', '#value' => $form['settings']['adv_link']['print_pdf_node_link_pages']['#default_value']); |
|
104 |
} |
|
105 |
elseif ($access) { |
|
106 |
$form['settings']['adv_link']['print_pdf_node_link_visibility']['#options'][] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).'); |
|
107 |
$form['settings']['adv_link']['print_pdf_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 ?>')); |
|
108 |
} |
|
109 |
} |
|
110 |
|
|
111 |
$form['settings']['adv_link']['print_pdf_sys_link_visibility'] = array( |
|
112 |
'#type' => 'radios', |
|
113 |
'#title' => t('Show link in system (non-content) pages'), |
|
114 |
'#description' => 'Any page that is not a Drupal node. Usually pages generated by Drupal or a module such as Views or Panels.', |
|
115 |
'#default_value' => variable_get('print_pdf_sys_link_visibility', PRINT_PDF_SYS_LINK_VISIBILITY_DEFAULT), |
|
116 |
'#options' => array(t('Show on every page except the listed pages.'), t('Show on only the listed pages.')), |
|
117 |
); |
|
118 |
|
|
119 |
$form['settings']['adv_link']['print_pdf_sys_link_pages'] = array( |
|
120 |
'#type' => 'textarea', |
|
121 |
'#default_value' => variable_get('print_pdf_sys_link_pages', PRINT_PDF_SYS_LINK_PAGES_DEFAULT), |
|
122 |
'#rows' => 3, |
|
123 |
'#description' => t('Setting this option will add a PDF version page link on pages created by Drupal or the enabled modules.') . '<br />' . |
|
124 |
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>')), |
|
125 |
); |
|
126 |
|
|
127 |
if (module_exists('php')) { |
|
128 |
if ($form['settings']['adv_link']['print_pdf_sys_link_visibility']['#default_value'] == 2 && !$access) { |
|
129 |
$form['settings']['adv_link']['print_pdf_sys_link_visibility'] = array('#type' => 'value', '#value' => 2); |
|
130 |
$form['settings']['adv_link']['print_pdf_sys_link_pages'] = array('#type' => 'value', '#value' => $form['settings']['adv_link']['print_pdf_sys_link_pages']['#default_value']); |
|
131 |
} |
|
132 |
elseif ($access) { |
|
133 |
$form['settings']['adv_link']['print_pdf_sys_link_visibility']['#options'][] = t('Show if the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).'); |
|
134 |
$form['settings']['adv_link']['print_pdf_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 ?>')); |
|
135 |
} |
|
136 |
} |
|
137 |
|
|
138 |
$form['settings']['adv_link']['print_pdf_book_link'] = array( |
|
139 |
'#type' => 'radios', |
|
140 |
'#title' => t('Link in book hierarchy nodes'), |
|
141 |
'#default_value' => variable_get('print_pdf_book_link', PRINT_PDF_BOOK_LINK_DEFAULT), |
|
142 |
'#options' => array(t('No link'), t('Current page and sub-pages'), t('Current page only')), |
|
143 |
); |
|
144 |
|
|
145 | 41 |
$form['settings']['print_pdf_content_disposition'] = array( |
146 | 42 |
'#type' => 'radios', |
147 | 43 |
'#title' => t('Open PDF in'), |
148 |
'#options' => array(t('Same browser window'), t('New browser window'), t('Save dialog')), |
|
44 |
'#options' => array( |
|
45 |
t('Same browser window'), |
|
46 |
t('New browser window'), |
|
47 |
t('Save dialog'), |
|
48 |
), |
|
149 | 49 |
'#default_value' => variable_get('print_pdf_content_disposition', PRINT_PDF_CONTENT_DISPOSITION_DEFAULT), |
150 | 50 |
'#description' => t("Select the desired method for opening the PDF in the user's browser."), |
151 | 51 |
); |
... | ... | |
153 | 53 |
$form['settings']['print_pdf_paper_size'] = array( |
154 | 54 |
'#type' => 'select', |
155 | 55 |
'#title' => t('Paper size'), |
156 |
'#options' => array('4A0' => '4A0', '2A0' => '2A0', 'A0' => 'A0', |
|
157 |
'A1' => 'A1', 'A2' => 'A2', 'A3' => 'A3', 'A4' => 'A4', |
|
158 |
'A5' => 'A5', 'A6' => 'A6', 'A7' => 'A7', 'A8' => 'A8', |
|
159 |
'A9' => 'A9', 'A10' => 'A10', 'B0' => 'B0', 'B1' => 'B1', |
|
160 |
'B2' => 'B2', 'B3' => 'B3', 'B4' => 'B4', 'B5' => 'B5', |
|
161 |
'B6' => 'B6', 'B7' => 'B7', 'B8' => 'B8', 'B9' => 'B9', |
|
162 |
'B10' => 'B10', 'C0' => 'C0', 'C1' => 'C1', 'C2' => 'C2', |
|
163 |
'C3' => 'C3', 'C4' => 'C4', 'C5' => 'C5', 'C6' => 'C6', |
|
164 |
'C7' => 'C7', 'C8' => 'C8', 'C9' => 'C9', 'C10' => 'C10', |
|
165 |
'RA0' => 'RA0', 'RA1' => 'RA1', 'RA2' => 'RA2', |
|
166 |
'RA3' => 'RA3', 'RA4' => 'RA4', 'SRA0' => 'SRA0', |
|
167 |
'SRA1' => 'SRA1', 'SRA2' => 'SRA2', 'SRA3' => 'SRA3', |
|
168 |
'SRA4' => 'SRA4', 'LETTER' => 'Letter', 'LEGAL' => 'Legal', |
|
169 |
'EXECUTIVE' => 'Executive', 'FOLIO' => 'Folio', |
|
170 |
), |
|
56 |
'#options' => _print_pdf_paper_sizes(), |
|
171 | 57 |
'#default_value' => variable_get('print_pdf_paper_size', PRINT_PDF_PAPER_SIZE_DEFAULT), |
172 | 58 |
'#description' => t('Choose the paper size of the generated PDF.'), |
173 | 59 |
); |
... | ... | |
179 | 65 |
'#default_value' => variable_get('print_pdf_page_orientation', PRINT_PDF_PAGE_ORIENTATION_DEFAULT), |
180 | 66 |
'#description' => t('Choose the page orientation of the generated PDF.'), |
181 | 67 |
); |
68 |
|
|
69 |
$form['settings']['print_pdf_cache_enabled'] = array( |
|
70 |
'#type' => 'checkbox', |
|
71 |
'#title' => t('Enable caching of generated PDFs'), |
|
72 |
'#default_value' => variable_get('print_pdf_cache_enabled', PRINT_PDF_CACHE_ENABLED_DEFAULT), |
|
73 |
); |
|
74 |
|
|
75 |
$form['settings']['print_pdf_cache_lifetime'] = array( |
|
76 |
'#type' => 'select', |
|
77 |
'#title' => t('Cache Lifetime'), |
|
78 |
'#options' => array( |
|
79 |
'0' => 'None', |
|
80 |
'10800' => '3 hours', |
|
81 |
'21600' => '6 hours', |
|
82 |
'43200' => '12 hours', |
|
83 |
'64800' => '18 hours', |
|
84 |
'86400' => '24 hours', |
|
85 |
'129600' => '36 hours', |
|
86 |
'172800' => '2 days', |
|
87 |
'259200' => '3 days', |
|
88 |
'345600' => '4 days', |
|
89 |
'432000' => '5 days', |
|
90 |
'518400' => '6 days', |
|
91 |
'604800' => '7 days', |
|
92 |
), |
|
93 |
'#default_value' => variable_get('print_pdf_cache_lifetime', PRINT_PDF_CACHE_LIFETIME_DEFAULT), |
|
94 |
'#description' => t('The lifetime of cached PDFs. A cached PDF is only removed when a node is updated, deleted, or cron is run and the last access is older than this value.'), |
|
95 |
); |
|
96 |
|
|
182 | 97 |
$form['settings']['print_pdf_images_via_file'] = array( |
183 | 98 |
'#type' => 'checkbox', |
184 | 99 |
'#title' => t('Access images via local file access'), |
... | ... | |
191 | 106 |
'#default_value' => variable_get('print_pdf_autoconfig', PRINT_PDF_AUTOCONFIG_DEFAULT), |
192 | 107 |
'#description' => t('If you disable this option, the pdf tool settings must be configured manually. For TCDPF, edit the tcpdf/config/tcpdf_config.php file. For dompdf, edit the dompdf/dompdf_config.inc.php file.'), |
193 | 108 |
); |
194 |
$form['settings']['print_pdf_font_family'] = array( |
|
195 |
'#type' => 'textfield', |
|
196 |
'#title' => t('Font family'), |
|
197 |
'#default_value' => variable_get('print_pdf_font_family', PRINT_PDF_FONT_FAMILY_DEFAULT), |
|
198 |
'#size' => 60, |
|
199 |
'#maxlength' => 250, |
|
200 |
'#description' => t('(TCPDF only) Set the font family to be used. Examples: %examples.', array('%examples' => 'helvetica, times, courier, dejavusans, dejavuserif, freesans, freeserif, freemono')) . '<br />' . |
|
201 |
t("CAUTION: TCPDF embeds the complete font in the generated PDF. If you're not using Unicode, then helvetica or times are safe choices that will keep the PDF small. Unicode fonts can increase the size of the PDF to the 1MB region."), |
|
202 |
); |
|
203 |
$form['settings']['print_pdf_font_size'] = array( |
|
204 |
'#type' => 'textfield', |
|
205 |
'#title' => t('Font size'), |
|
206 |
'#default_value' => variable_get('print_pdf_font_size', PRINT_PDF_FONT_SIZE_DEFAULT), |
|
207 |
'#size' => 2, |
|
208 |
'#maxlength' => 3, |
|
209 |
'#description' => t('(TCPDF only) Set the font size to be used for normal text. This is the base value for the scaling applied to other text styles.'), |
|
210 |
); |
|
211 |
$form['settings']['print_pdf_font_subsetting'] = array( |
|
212 |
'#type' => 'checkbox', |
|
213 |
'#title' => t('Enable font subsetting'), |
|
214 |
'#default_value' => variable_get('print_pdf_font_subsetting', PRINT_PDF_FONT_SUBSETTING_DEFAULT), |
|
215 |
'#description' => t('(TCPDF only) Only embed those font characters that are actually used. This can generates smaller PDF files but may significantly slow down processing.'), |
|
216 |
); |
|
217 |
$form['settings']['print_pdf_dompdf_unicode'] = array( |
|
218 |
'#type' => 'checkbox', |
|
219 |
'#title' => t("Use dompdf's Unicode Mode"), |
|
220 |
'#default_value' => variable_get('print_pdf_dompdf_unicode', PRINT_PDF_DOMPDF_UNICODE_DEFAULT), |
|
221 |
'#description' => t("If enabled, dompdf's Unicode mode is used. If not, the module will attempt to convert some non-ASCII chars to ISO-8859-1."), |
|
222 |
); |
|
223 |
$form['settings']['print_pdf_wkhtmltopdf_options'] = array( |
|
109 |
|
|
110 |
$form['settings']['print_pdf_filename'] = array( |
|
224 | 111 |
'#type' => 'textfield', |
225 |
'#title' => t('wkhtmltopdf options'), |
|
226 |
'#size' => 60, |
|
227 |
'#maxlength' => 500, |
|
228 |
'#default_value' => variable_get('print_pdf_wkhtmltopdf_options', PRINT_PDF_WKHTMLTOPDF_OPTIONS), |
|
229 |
'#description' => t('(wkhtmltopdf only) Set any additional options to be passed to the wkhtmltopdf executable. Tokens may be used in these options (see list below).'), |
|
112 |
'#title' => t('PDF filename'), |
|
113 |
'#default_value' => variable_get('print_pdf_filename', PRINT_PDF_FILENAME_DEFAULT), |
|
114 |
'#description' => t("If left empty the generated filename defaults to the node's path. Tokens may be used to build the filename (see following list). The .pdf extension will be appended automatically."), |
|
230 | 115 |
); |
231 |
|
|
232 |
$form['settings']['print_pdf_filename'] = array( |
|
233 |
'#type' => 'textfield', |
|
234 |
'#title' => t('PDF filename'), |
|
235 |
'#default_value' => variable_get('print_pdf_filename', PRINT_PDF_FILENAME_DEFAULT), |
|
236 |
'#description' => t("If left empty the generated filename defaults to the node's path. Tokens may be used to build the filename (see following list). The .pdf extension will be appended automatically."), |
|
237 |
); |
|
238 | 116 |
if (module_exists('token')) { |
239 | 117 |
$form['settings']['print_pdf_filename_patterns'] = array( |
240 |
'#type' => 'fieldset', |
|
241 |
'#title' => t('Replacement patterns'), |
|
242 |
'#collapsible' => TRUE, |
|
243 |
'#collapsed' => TRUE, |
|
244 |
); |
|
245 |
$form['settings']['print_pdf_filename_patterns']['descriptions'] = array( |
|
246 | 118 |
'#theme' => 'token_tree', |
247 | 119 |
'#token_types' => array('node'), |
120 |
'#dialog' => TRUE, |
|
248 | 121 |
); |
249 | 122 |
} |
250 | 123 |
|
... | ... | |
255 | 128 |
'#description' => t('Enabling this option will display a list of printer-friendly destination URLs at the bottom of the page.'), |
256 | 129 |
); |
257 | 130 |
|
131 |
$form['settings']['link_text'] = array( |
|
132 |
'#type' => 'fieldset', |
|
133 |
'#title' => t('Custom link text'), |
|
134 |
'#collapsible' => TRUE, |
|
135 |
'#collapsed' => TRUE, |
|
136 |
); |
|
137 |
$form['settings']['link_text']['print_pdf_link_text_enabled'] = array( |
|
138 |
'#type' => 'checkbox', |
|
139 |
'#title' => t('Enable custom link text'), |
|
140 |
'#default_value' => variable_get('print_pdf_link_text_enabled', PRINT_TYPE_LINK_TEXT_ENABLED_DEFAULT), |
|
141 |
); |
|
142 |
$form['settings']['link_text']['print_pdf_link_text'] = array( |
|
143 |
'#type' => 'textfield', |
|
144 |
'#default_value' => variable_get('print_pdf_link_text', $link['text']), |
|
145 |
'#description' => t('Text used in the link to the PDF version.'), |
|
146 |
); |
|
147 |
|
|
258 | 148 |
$form['#validate'][] = '_print_pdf_settings_validate'; |
259 | 149 |
} |
260 | 150 |
else { |
151 |
variable_set('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT); |
|
152 |
|
|
261 | 153 |
$form['settings'] = array( |
262 | 154 |
'#type' => 'markup', |
263 | 155 |
'#markup' => '<p>' . t("No PDF generation tool found! Please download a supported PHP PDF generation tool. Check this module's INSTALL.txt for more details.") . '</p>', |
... | ... | |
268 | 160 |
} |
269 | 161 |
|
270 | 162 |
/** |
271 |
* Validate print_pdf_settings form. |
|
163 |
* Form validation handler for print_pdf_settings(). |
|
164 |
* |
|
165 |
* @param array $form |
|
166 |
* Form. |
|
167 |
* @param array $form_state |
|
168 |
* Form state. |
|
169 |
* |
|
170 |
* @see print_pdf_settings() |
|
171 |
* @ingroup forms |
|
272 | 172 |
*/ |
273 | 173 |
function _print_pdf_settings_validate($form, &$form_state) { |
274 | 174 |
if (empty($form_state['values']['print_pdf_pdf_tool'])) { |
275 | 175 |
form_set_error('print_pdf_pdf_tool', t("No PDF tool selected")); |
276 | 176 |
} |
277 |
if ($form_state['values']['print_pdf_font_size'] < 1) { |
|
278 |
form_set_error('print_pdf_font_size', t("Font size must be at least 1.")); |
|
279 |
} |
|
280 |
} |
|
281 |
|
|
282 |
/** |
|
283 |
* Auxiliary function to locate suitable PDF generation tools |
|
284 |
* |
|
285 |
* @return |
|
286 |
* array of filenames with the include-able PHP file of the located tools |
|
287 |
*/ |
|
288 |
function _print_pdf_tools() { |
|
289 |
$pattern = '!^(?:dompdf_config.inc.php|tcpdf.php|wkhtmltopdf.*)$!'; |
|
290 |
$tools = array_keys(file_scan_directory(drupal_get_path('module', 'print'), $pattern)); |
|
291 |
$tools = array_merge($tools, array_keys(file_scan_directory(PRINT_PDF_LIB_PATH, $pattern))); |
|
292 |
if (module_exists('libraries')) { |
|
293 |
$tools = array_merge($tools, array_keys(file_scan_directory(libraries_get_path('dompdf'), '/^dompdf_config.inc.php$/'))); |
|
294 |
$tools = array_merge($tools, array_keys(file_scan_directory(libraries_get_path('tcpdf'), '/^tcpdf.php$/'))); |
|
295 |
$tools = array_merge($tools, array_keys(file_scan_directory(libraries_get_path('wkhtmltopdf'), '/^wkhtmltopdf/'))); |
|
296 |
} |
|
297 |
|
|
298 |
|
|
299 |
$num_tools = count($tools); |
|
300 |
|
|
301 |
if ($num_tools == 0) { |
|
302 |
variable_set('print_pdf_pdf_tool', PRINT_PDF_PDF_TOOL_DEFAULT); |
|
303 |
return -1; |
|
304 |
} |
|
305 |
else { |
|
306 |
return array_combine($tools, $tools); |
|
307 |
} |
|
308 |
} |
|
309 |
|
|
310 |
/** |
|
311 |
* Menu callback for the PDF version module text strings settings form. |
|
312 |
* |
|
313 |
* @ingroup forms |
|
314 |
*/ |
|
315 |
function print_pdf_strings_settings() { |
|
316 |
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'); |
|
317 |
|
|
318 |
$form['print_pdf_text'] = array( |
|
319 |
'#type' => 'fieldset', |
|
320 |
'#title' => t('Text strings'), |
|
321 |
); |
|
322 |
|
|
323 |
$form['print_pdf_text']['print_pdf_link_text'] = array( |
|
324 |
'#type' => 'textfield', |
|
325 |
'#title' => t('Link text'), |
|
326 |
'#default_value' => variable_get('print_pdf_link_text', t('PDF version')), |
|
327 |
'#description' => t('Text used in the link to the PDF version.'), |
|
328 |
); |
|
329 |
$form['print_pdf_text']['reset'] = array( |
|
330 |
'#type' => 'submit', |
|
331 |
'#value' => t('Reset to defaults'), |
|
332 |
'#submit' => array('print_pdf_strings_settings_delete'), |
|
333 |
); |
|
334 |
|
|
335 |
return system_settings_form($form); |
|
336 |
} |
|
337 |
|
|
338 |
/** |
|
339 |
* Reset button callback for text strings settings form |
|
340 |
* |
|
341 |
* @ingroup forms |
|
342 |
*/ |
|
343 |
function print_pdf_strings_settings_delete() { |
|
344 |
variable_del('print_pdf_link_text'); |
|
345 | 177 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules