/[drupal]/contributions/modules/drutex/drutex_tools.inc
ViewVC logotype

Contents of /contributions/modules/drutex/drutex_tools.inc

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


Revision 1.3 - (show annotations) (download) (as text)
Wed Jan 16 00:31:44 2008 UTC (22 months, 1 week ago) by darthsteven
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-5--2, DRUPAL-6--1
Changes since 1.2: +2 -2 lines
File MIME type: text/x-php
Re: #149047 asks latex for its version, not just blindly running it. Fixes for Windows!
1 <?php
2 // $Id: drutex_tools.inc,v 1.2 2007/04/25 14:46:28 darthsteven Exp $
3
4 /**
5 * @file
6 * Tools for more debugging and error logging.
7 */
8
9 /**
10 * Implementation of subhook_info().
11 */
12 function drutex_tools_info($format = -1) {
13 return (object) array(
14 'title' => t('Toolbox'),
15 'description' => t('Tools for more debugging and error logging.'),
16 'toggle' => false,
17 'weight' => 20
18 );
19 }
20
21 /**
22 * Implementation of subhook_defaults().
23 */
24 function drutex_tools_defaults() {
25 $D['drutex_tools_active'] = true;
26 $D['drutex_debug'] = false;
27
28 return $D;
29 }
30
31 /**
32 * Implementation of subhook_filter_settings().
33 */
34 function drutex_tools_filter_settings($format = -1) {
35 $choices = array('drupal' => 'Drupal style',
36 'latex' => 'LaTeX style');
37
38 $form["drutex_debug_$format"] = array(
39 '#type' => 'checkbox',
40 '#title' => t('Debugging mode'),
41 '#default_value' => drutex_var_get("drutex_debug_$format"),
42 '#description' => t('If enabled, the temporary files will no longer be deleted automatically. Also enables super-verbose logging.')
43 );
44
45 $div_error = '<div class="filter-settings-error">';
46 $div_correct = '<div class="filter-settings-correct">';
47
48 /*
49 Temporary directory check
50 */
51 $temporary_dir = drutex_var_get("drutex_dir_temporary_$format");
52 $is_writable = is_writable($temporary_dir);
53
54 if ($is_writable == false) {
55 $form["drutex_check_tmpdir"] = array(
56 '#type' => 'markup',
57 '#value' => $div_error . t('The temporary directory (') . $temporary_dir .') isn\'t writable.'.'</div>'
58 );
59 }
60 else {
61 $form["drutex_check_tmpdir"] = array(
62 '#type' => 'markup',
63 '#value' => $div_correct . t('The temporary directory is writable.') .'</div>'
64 );
65 }
66
67 /*
68 Image directory check
69 */
70 $image_dir = drutex_var_get("drutex_dir_images_$format");
71 $is_writable = is_writable($image_dir);
72
73 if ($is_writable == false) {
74 $form["drutex_check_imgdir"] = array(
75 '#type' => 'markup',
76 '#value' => $div_error . t('The image directory (') . $image_dir .') isn\'t writable.'.'</div>'
77 );
78 }
79 else {
80 $form["drutex_check_imgdir"] = array(
81 '#type' => 'markup',
82 '#value' => $div_correct . t('The image directory is writable.') .'</div>'
83 );
84 }
85
86 /*
87 LaTeX check
88 */
89 exec('latex -version', $latex_output, $latex_return_value); //We grab the version which should work on all platforms
90
91 if ($latex_return_value == 127) {
92 $form["drutex_check_latex"] = array(
93 '#type' => 'markup',
94 '#value' => $div_error . t('Executing "latex" failed. Either LaTeX isn\'t installed or the "latex" executable is not in one of the search paths. <br /> You cannot render high-quality images without LaTeX. <br /> Mimetex maybe an alternative for you. Consult the documentation on how to use Mimetex.') .'</div>'
95 );
96 }
97 else {
98 $form["drutex_check_latex"] = array(
99 '#type' => 'markup',
100 '#value' => $div_correct . t('Executing "latex" was successful: ') ."<tt>{$latex_output[0]}</tt>".'</div>'
101 );
102 }
103
104 /*
105 dvipng check
106 */
107 exec('dvipng', $dvipng_output, $dvipng_return_value);
108
109 if ($dvipng_return_value == 127) {
110 $form["drutex_check_dvipng"] = array(
111 '#type' => 'markup',
112 '#value' => $div_error . t('Executing "dvipng" failed. Either dvipng isn\'t installed or the "dvipng" executable is not in one of the search paths. <br /> You cannot use dvipng for rendering images (check the conversion method above).') .'</div>'
113 );
114 }
115 else {
116 $form["drutex_check_dvipng"] = array(
117 '#type' => 'markup',
118 '#value' => $div_correct . t('Executing "dvipng" was successful: ') ."<tt>{$dvipng_output[0]}</tt>".'</div>'
119 );
120 }
121
122 /*
123 Imagemagick check
124 */
125 exec('convert', $imagemagick_output, $imagemagick_return_value);
126
127 if ($imagemagick_return_value == 127) {
128 $form["drutex_check_imagemagick"] = array(
129 '#type' => 'markup',
130 '#value' => $div_error . t('Executing "convert" (ImageMagick) failed. Either ImageMagick isn\'t installed or the "convert" executable is not in one of the search paths. <br /> You cannot use ImageMagick for rendering images (check the conversion method above).') .'</div>'
131 );
132 }
133 else {
134 $form["drutex_check_imagemagick"] = array(
135 '#type' => 'markup',
136 '#value' => $div_correct . t('Executing "convert" (ImageMagick) was successful: ') ."<tt>{$imagemagick_output[0]}</tt>".'</div>'
137 );
138 }
139
140 return $form;
141 }

  ViewVC Help
Powered by ViewVC 1.1.2