/[drupal]/contributions/modules/texy/texy.admin.inc
ViewVC logotype

Contents of /contributions/modules/texy/texy.admin.inc

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


Revision 1.5 - (show annotations) (download) (as text)
Fri Apr 24 12:19:41 2009 UTC (7 months ago) by havran
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +1 -1 lines
File MIME type: text/x-php
From DRUPAL-6--1
1 <?php
2 // $Id: texy.admin.inc,v 1.1.2.6 2009/04/22 09:11:59 havran Exp $
3
4 /**
5 * @file
6 * Admin page callbacks for the Texy module.
7 */
8
9 // PHP4/PHP5 compatibility
10 if ( version_compare('5.0.0', PHP_VERSION, '>') ) {
11 require_once 'texy.php4.inc';
12 }
13 else {
14 require_once 'texy.php5.inc';
15 }
16
17 /**
18 * Form builder; Configure main Texy settings.
19 *
20 * @ingroup forms
21 * @see system_settings_form().
22 */
23 function texy_form_main_settings() {
24 // for Texy! version
25 $texy =& _texy_get_object(TRUE);
26
27
28 $form['basicinfo'] = array(
29 '#type' => 'fieldset',
30 '#weight' => -11,
31 );
32 $form['basicinfo']['info'] = array(
33 '#type' => 'markup',
34 '#value' => t(
35 '<strong>PHP version:</strong> @php_version<br />
36 <strong>Texy! version:</strong> @texy_version',
37 array(
38 '@php_version' => PHP_VERSION,
39 '@texy_version' => _get_texy_version(),
40 )
41 ),
42 );
43
44 $form['basicset'] = array(
45 '#type' => 'fieldset',
46 '#title' => t('Basic settings'),
47 '#collapsible' => TRUE,
48 '#collapsed' => FALSE,
49 '#weight' => -10,
50 );
51 $form['basicset']['texy_heading_base'] = array(
52 '#type' => 'select',
53 '#title' => t('Highest heading level'),
54 '#options' => array(1 => '<h1>', 2 => '<h2>', 3 => '<h3>', 4 => '<h4>', 5 => '<h5>', 6 => '<h6>'),
55 '#description' => t('Highest allowed heading level. Default is &lt;h2&gt;. Setting a higher level is not recommended.'),
56 '#default_value' => variable_get('texy_heading_base', 3),
57 );
58 $form['basicset']['texy_line_wrap'] = array(
59 '#type' => 'textfield',
60 '#size' => '3',
61 '#title' => t('Maximum number of characters per line'),
62 '#description' => t('Enter desired number of characters per line or "0" to disable line wrapping (default).'),
63 '#default_value' => variable_get('texy_line_wrap', 0),
64 );
65 // next two elements are connected in theme function
66 $form['basicset']['texy_allowed_longwords'] = array(
67 '#type' => 'checkbox',
68 '#title' => t('Break words longer than'),
69 '#default_value' => variable_get('texy_allowed_longwords', FALSE),
70 );
71 $form['basicset']['texy_word_limit'] = array(
72 '#type' => 'textfield',
73 '#size' => '3',
74 '#title' => t('Break long words'),
75 '#description' => t('If enabled, Texy! breaks long words with inserting <code>&amp;shy;</code> entity (as invisible character). (Warning! This may interfere with some modules that are use <code>[someword]</code> like filter syntax. (For example <a href="@inline-url">Inline</a> module.) Disabled by default.', array('@inline-url' => url('http://drupal.org/project/inline'))),
76 '#default_value' => variable_get('texy_word_limit', 20),
77 );
78 // end
79 $form['basicset']['texy_obfuscate_email'] = array(
80 '#type' => 'checkbox',
81 '#title' => t('E-mail address obfuscation'),
82 '#description' => t('Obfuscate emails from spambots? Enabled by default.'),
83 '#default_value' => variable_get('texy_obfuscate_email', TRUE),
84 );
85 $form['basicset']['texy_force_nofollow'] = array(
86 '#type' => 'checkbox',
87 '#title' => t('Nofollow attribute'),
88 '#description' => t('Applies the <i>rel="nofollow"</i> attribute to all external links. Disabled by default.'),
89 '#default_value' => variable_get('texy_force_nofollow', FALSE),
90 );
91 $form['basicset']['texy_locale'] = array(
92 '#type' => 'select',
93 '#title' => t('Locale to use'),
94 '#options' => array('en' => 'English', 'cs' => 'Czech/Slovak', 'fr' => 'French', 'de' => 'German', 'pl' => 'Polish'),
95 '#description' => t('Locale settings to use. English by default.'),
96 '#default_value' => variable_get('texy_locale', 'en'),
97 );
98
99 $form['cssset'] = array(
100 '#type' => 'fieldset',
101 '#title' => t('CSS settings'),
102 '#collapsible' => TRUE,
103 '#collapsed' => FALSE,
104 '#weight' => -9,
105 );
106 $form['cssset']['texy_allowed_classes'] = array(
107 '#type' => 'textfield',
108 '#title' => t('Allowed classes'),
109 '#description' => t('Allow following CSS classes and IDs to appear in the text. Default value is empty - allow no classes. Specify <i>&lt;all&gt;</i> to allow all classes (not recommended). Use commas as separators.'),
110 '#default_value' => variable_get('texy_allowed_classes', ''),
111 );
112 $form['cssset']['texy_allowed_styles'] = array(
113 '#type' => 'textfield',
114 '#title' => t('Allowed inline styles'),
115 '#description' => t('Allow following CSS inline styles such as \'font-size\', \'color\', to appear in the text. Default value is empty - allow no styles. Specify <i>&lt;all&gt;</i> to allow all styles (not recommended). Use commas as separators.'),
116 '#default_value' => variable_get('texy_allowed_styles', ''),
117 );
118
119 $form['tagset'] = array(
120 '#type' => 'fieldset',
121 '#title' => t('HTML tags settings'),
122 '#collapsible' => TRUE,
123 '#collapsed' => FALSE,
124 '#weight' => -8,
125 );
126 $form['tagset']['texy_allowed_tags'] = array(
127 '#type' => 'textfield',
128 '#title' => t('Allowed tags'),
129 '#description' => t('Allow following tags to appear in the text. Default value is empty - allow no tags. Specify <i>&lt;all&gt;</i> to allow all tags (not recommended). Use commas as separators.'),
130 '#default_value' => variable_get('texy_allowed_tags', ''),
131 );
132
133
134 $form = system_settings_form($form);
135 unset($form['#theme']); // because system_settings_form() set his own theme
136 return $form;
137 }
138
139 function theme_texy_form_main_settings($form) {
140 // we need this element
141 $my_output = drupal_render($form['basicset']['texy_allowed_longwords']);
142 // get all between beginning <div...> and ending </div>
143 // but if is altered theme_form_element($element, $value) function? who know...
144 preg_match('@<(div+)([^>]*?)>(.*?)(</\1>)@si', $my_output, $match);
145 // and now we have only form element itself (in $match[3])
146 $form['basicset']['texy_word_limit']['#field_prefix'] = $match[3];
147 $form['basicset']['texy_word_limit']['#field_suffix'] = t('characters');
148
149 return drupal_render($form);
150 }
151

  ViewVC Help
Powered by ViewVC 1.1.2