@@ -105,8 +105,7 @@ discard block |
||
105 | 105 | natcasesort($themes); |
106 | 106 | $themes = array_values($themes); |
107 | 107 | return !empty($themes) ? $themes : array('default'); |
108 | - } |
|
109 | - else { |
|
108 | + } else { |
|
110 | 109 | return array('default'); |
111 | 110 | } |
112 | 111 | } |
@@ -165,16 +164,13 @@ discard block |
||
165 | 164 | if (version_compare($editor['installed version'], '3.0.1.4391', '<')) { |
166 | 165 | if ($config['css_setting'] == 'theme') { |
167 | 166 | $settings['contentsCss'] = reset(wysiwyg_get_css()); |
168 | - } |
|
169 | - elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) { |
|
167 | + } elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) { |
|
170 | 168 | $settings['contentsCss'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme())); |
171 | 169 | } |
172 | - } |
|
173 | - else { |
|
170 | + } else { |
|
174 | 171 | if ($config['css_setting'] == 'theme') { |
175 | 172 | $settings['contentsCss'] = wysiwyg_get_css(); |
176 | - } |
|
177 | - elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) { |
|
173 | + } elseif ($config['css_setting'] == 'self' && isset($config['css_path'])) { |
|
178 | 174 | $settings['contentsCss'] = explode(',', strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme()))); |
179 | 175 | } |
180 | 176 | } |
@@ -176,8 +176,7 @@ discard block |
||
176 | 176 | } |
177 | 177 | } |
178 | 178 | } |
179 | - } |
|
180 | - else if ($button == 'fontname') { |
|
179 | + } else if ($button == 'fontname') { |
|
181 | 180 | $extra = array('menu' => array( |
182 | 181 | array('text' => 'Arial', 'checked' => TRUE), |
183 | 182 | array('text' => 'Arial Black'), |
@@ -201,8 +200,7 @@ discard block |
||
201 | 200 | if (isset($config['css_setting'])) { |
202 | 201 | if ($config['css_setting'] == 'theme') { |
203 | 202 | $settings['extracss'] = wysiwyg_get_css(); |
204 | - } |
|
205 | - else if ($config['css_setting'] == 'self' && isset($config['css_path'])) { |
|
203 | + } else if ($config['css_setting'] == 'self' && isset($config['css_path'])) { |
|
206 | 204 | $settings['extracss'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme())); |
207 | 205 | $settings['extracss'] = explode(',', $settings['extracss']); |
208 | 206 | } |
@@ -249,11 +247,9 @@ discard block |
||
249 | 247 | if (in_array($button, array('heading', 'fontname'))) { |
250 | 248 | $type = 'select'; |
251 | 249 | $label = $extra['menu'][0]['text']; |
252 | - } |
|
253 | - elseif (in_array($button, array('fontsize'))) { |
|
250 | + } elseif (in_array($button, array('fontsize'))) { |
|
254 | 251 | $type = 'spin'; |
255 | - } |
|
256 | - elseif (in_array($button, array('forecolor', 'backcolor'))) { |
|
252 | + } elseif (in_array($button, array('forecolor', 'backcolor'))) { |
|
257 | 253 | $type = 'color'; |
258 | 254 | } |
259 | 255 |
@@ -101,8 +101,7 @@ |
||
101 | 101 | if (isset($config['css_setting'])) { |
102 | 102 | if ($config['css_setting'] == 'theme') { |
103 | 103 | $settings['CSSFile'] = reset(wysiwyg_get_css()); |
104 | - } |
|
105 | - else if ($config['css_setting'] == 'self' && isset($config['css_path'])) { |
|
104 | + } else if ($config['css_setting'] == 'self' && isset($config['css_path'])) { |
|
106 | 105 | $settings['CSSFile'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme())); |
107 | 106 | } |
108 | 107 | } |
@@ -108,8 +108,7 @@ |
||
108 | 108 | if (file_exists($css)) { |
109 | 109 | $settings['externalCSS'] = base_path() . $css; |
110 | 110 | } |
111 | - } |
|
112 | - else if ($config['css_setting'] == 'self' && isset($config['css_path'])) { |
|
111 | + } else if ($config['css_setting'] == 'self' && isset($config['css_path'])) { |
|
113 | 112 | $settings['externalCSS'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme())); |
114 | 113 | } |
115 | 114 | } |
@@ -188,8 +188,7 @@ discard block |
||
188 | 188 | if (isset($config['css_setting'])) { |
189 | 189 | if ($config['css_setting'] == 'theme') { |
190 | 190 | $settings['content_css'] = implode(',', wysiwyg_get_css()); |
191 | - } |
|
192 | - else if ($config['css_setting'] == 'self' && isset($config['css_path'])) { |
|
191 | + } else if ($config['css_setting'] == 'self' && isset($config['css_path'])) { |
|
193 | 192 | $settings['content_css'] = strtr($config['css_path'], array('%b' => base_path(), '%t' => path_to_theme())); |
194 | 193 | } |
195 | 194 | } |
@@ -367,8 +366,7 @@ discard block |
||
367 | 366 | return '-' . $name; |
368 | 367 | } |
369 | 368 | return $name; |
370 | - } |
|
371 | - else if ($op == 'remove') { |
|
369 | + } else if ($op == 'remove') { |
|
372 | 370 | if (strpos($name, '-') === 0) { |
373 | 371 | return substr($name, 1); |
374 | 372 | } |
@@ -201,8 +201,7 @@ discard block |
||
201 | 201 | if (empty($element['format']['guidelines']['#value'])) { |
202 | 202 | $element['format']['guidelines']['#value'] = ' '; |
203 | 203 | } |
204 | - } |
|
205 | - else { |
|
204 | + } else { |
|
206 | 205 | $element[$format]['#attributes']['class'] = (isset($element[$format]['#attributes']['class']) ? $element[$format]['#attributes']['class'] . ' ' : ''); |
207 | 206 | $element[$format]['#attributes']['class'] .= 'wysiwyg wysiwyg-format-' . $format . ' wysiwyg-editor-' . $editor . ' wysiwyg-field-' . $field['#id'] . ' wysiwyg-status-' . $status . ' wysiwyg-toggle-' . $toggle . $extra_class; |
208 | 207 | } |
@@ -273,8 +272,7 @@ discard block |
||
273 | 272 | if (isset($profile->settings['library']) && isset($editor['libraries'][$profile->settings['library']])) { |
274 | 273 | $library = $profile->settings['library']; |
275 | 274 | $files = $editor['libraries'][$library]['files']; |
276 | - } |
|
277 | - else { |
|
275 | + } else { |
|
278 | 276 | // Fallback to the first defined library by default (external libraries can change). |
279 | 277 | $library = key($editor['libraries']); |
280 | 278 | $files = array_shift($editor['libraries']); |
@@ -284,8 +282,7 @@ discard block |
||
284 | 282 | if (is_array($options)) { |
285 | 283 | $options += array('type' => 'module', 'scope' => 'header', 'defer' => FALSE, 'cache' => TRUE, 'preprocess' => TRUE); |
286 | 284 | drupal_add_js($editor['library path'] . '/' . $file, $options['type'], $options['scope'], $options['defer'], $options['cache'], $options['preprocess']); |
287 | - } |
|
288 | - else { |
|
285 | + } else { |
|
289 | 286 | drupal_add_js($editor['library path'] . '/' . $options); |
290 | 287 | } |
291 | 288 | } |
@@ -322,8 +319,7 @@ discard block |
||
322 | 319 | )), 'setting'); |
323 | 320 | |
324 | 321 | $loaded[$name] = TRUE; |
325 | - } |
|
326 | - else { |
|
322 | + } else { |
|
327 | 323 | $loaded[$name] = FALSE; |
328 | 324 | } |
329 | 325 | } |
@@ -468,8 +464,7 @@ discard block |
||
468 | 464 | if (isset($meta['settings'])) { |
469 | 465 | drupal_add_js(array('wysiwyg' => array('plugins' => array('drupal' => array($plugin => $meta['settings'])))), 'setting'); |
470 | 466 | } |
471 | - } |
|
472 | - else { |
|
467 | + } else { |
|
473 | 468 | $profile_plugins_drupal[$plugin] = $processed_plugins[$proxy][$plugin]; |
474 | 469 | } |
475 | 470 | } |
@@ -711,8 +706,7 @@ discard block |
||
711 | 706 | ); |
712 | 707 | return $form; |
713 | 708 | } |
714 | - } |
|
715 | - elseif ($op == 'insert' || $op == 'update') { |
|
709 | + } elseif ($op == 'insert' || $op == 'update') { |
|
716 | 710 | if (isset($edit['wysiwyg_status'])) { |
717 | 711 | db_query("DELETE FROM {wysiwyg_user} WHERE uid = %d", $account->uid); |
718 | 712 | foreach ($edit['wysiwyg_status'] as $format => $status) { |
@@ -745,8 +739,7 @@ discard block |
||
745 | 739 | |
746 | 740 | if (!empty($profile->settings['user_choose']) && isset($account->wysiwyg_status[$profile->format])) { |
747 | 741 | $status = $account->wysiwyg_status[$profile->format]; |
748 | - } |
|
749 | - else { |
|
742 | + } else { |
|
750 | 743 | $status = isset($profile->settings['default']) ? $profile->settings['default'] : TRUE; |
751 | 744 | } |
752 | 745 |
@@ -19,8 +19,7 @@ |
||
19 | 19 | $links['mark-read']['href'] = "community/forum/{$tid}/read"; |
20 | 20 | |
21 | 21 | return l(t('Mark all topics read') . '<span class="image-replace"></span>', "forum/markasread/$tid", array('html' => TRUE)); |
22 | - } |
|
23 | - else { |
|
22 | + } else { |
|
24 | 23 | $links['mark-read']['title'] = t('Mark all forums read'); |
25 | 24 | $links['mark-read']['href'] = "community/forum/0/read"; |
26 | 25 |
@@ -2,16 +2,16 @@ discard block |
||
2 | 2 | // $Id: bbcode.module,v 1.50 2008/02/07 14:05:30 naudefj Exp $ |
3 | 3 | |
4 | 4 | function bbcode_help($section) { |
5 | - if ($section == 'admin/modules#description') |
|
6 | - return t('Allow the use of BBCode in your posts.'); |
|
7 | -} |
|
5 | + if ($section == 'admin/modules#description') { |
|
6 | + return t('Allow the use of BBCode in your posts.'); |
|
7 | + } |
|
8 | + } |
|
8 | 9 | |
9 | 10 | function bbcode_filter_tips($delta, $format, $long = false) { |
10 | 11 | if ($long) { |
11 | 12 | include_once(drupal_get_path('module', 'bbcode') .'/bbcode-help.inc'); |
12 | 13 | return _bbcode_filter_tip(); |
13 | - } |
|
14 | - else { |
|
14 | + } else { |
|
15 | 15 | # D5: $output = t('You can use !BBCode tags in the text.', array('!BBCode' => l(t('BBCode'), "filter/tips/$format", NULL, NULL, 'filter-bbcode-' . $delta))); |
16 | 16 | $output = t('You can use !BBCode (opens in new window) tags in the text.', |
17 | 17 | array( |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | $elapsed += $timing_stop[0] - $timing_start[0]; |
51 | 51 | $ret .= '<hr />'. l('BBCode', "filter/tips/$format") .' parsed on '.date('r').'<br />Execution time: '.$elapsed.' seconds.<hr />'; |
52 | 52 | return $ret; |
53 | + } else { |
|
54 | + return _bbcode_filter_process($text, $format); |
|
53 | 55 | } |
54 | - else |
|
55 | - return _bbcode_filter_process($text, $format); |
|
56 | 56 | |
57 | 57 | case 'settings': |
58 | 58 | $form = array(); |
@@ -16,23 +16,25 @@ discard block |
||
16 | 16 | if (preg_match_all('#\[code(?::\w+)?\](.*?)\[/code(?::\w+)?\]#si', $body, $code_tags, PREG_SET_ORDER)) { |
17 | 17 | foreach ($code_tags as $code_tag) { |
18 | 18 | $code_tag[1] = str_replace(array('<', '>'), array('<', '>'), $code_tag[1]); |
19 | - if (strpos($code_tag[1], "\n") === FALSE) |
|
20 | - $body = str_replace($code_tag[0], '<code class="bb-code">'. $code_tag[1] .'</code>', $body); |
|
21 | - elseif ($mode) { |
|
19 | + if (strpos($code_tag[1], "\n") === FALSE) { |
|
20 | + $body = str_replace($code_tag[0], '<code class="bb-code">'. $code_tag[1] .'</code>', $body); |
|
21 | + } elseif ($mode) { |
|
22 | 22 | // Strip preformatted code blocks from text during line break processing, replaced below |
23 | 23 | $body = str_replace($code_tag[0], "***pRe_sTrInG$i***", $body); |
24 | 24 | $pre[$i++] = '<pre class="bb-code-block">'. $code_tag[1] .'</pre>'; |
25 | + } else { |
|
26 | + $body = str_replace($code_tag[0], '<pre class="bb-code-block">'. $code_tag[1] .'</pre>', $body); |
|
25 | 27 | } |
26 | - else |
|
27 | - $body = str_replace($code_tag[0], '<pre class="bb-code-block">'. $code_tag[1] .'</pre>', $body); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | 31 | // Apply line and paragraph breaks (skipping preformatted code) |
32 | 32 | if ($mode) { |
33 | 33 | |
34 | - if ($mode == 1) // Line breaks only (starting with PHP 4.0.5, nl2br() is XHTML compliant) |
|
34 | + if ($mode == 1) { |
|
35 | + // Line breaks only (starting with PHP 4.0.5, nl2br() is XHTML compliant) |
|
35 | 36 | $body = nl2br($body); |
37 | + } |
|
36 | 38 | |
37 | 39 | if ($mode == 2) { // Line and paragraph breaks (may not always be XHTML compliant) |
38 | 40 | $body = preg_replace("/(\r\n|\n|\r)/", "\n", $body); |
@@ -40,19 +42,22 @@ discard block |
||
40 | 42 | $parts = explode("\n\n", $body); |
41 | 43 | for ($i=0; $i<sizeof($parts); $i++) { |
42 | 44 | // No linebreaks if paragraph starts with an HTML tag |
43 | - if ( !preg_match('/^<.*>/', $parts[$i]) ) |
|
44 | - $parts[$i] = nl2br($parts[$i]); |
|
45 | + if ( !preg_match('/^<.*>/', $parts[$i]) ) { |
|
46 | + $parts[$i] = nl2br($parts[$i]); |
|
47 | + } |
|
45 | 48 | |
46 | 49 | // Some tags should not be in paragraph blocks |
47 | - if ( !preg_match('/^(?:<|\[)(?:table|list|ol|ul|pre|select|form|blockquote|hr)/i', $parts[$i]) ) |
|
48 | - $parts[$i] = '<p>'. $parts[$i] .'</p>'; |
|
50 | + if ( !preg_match('/^(?:<|\[)(?:table|list|ol|ul|pre|select|form|blockquote|hr)/i', $parts[$i]) ) { |
|
51 | + $parts[$i] = '<p>'. $parts[$i] .'</p>'; |
|
52 | + } |
|
49 | 53 | } |
50 | 54 | $body = implode("\n\n", $parts); |
51 | 55 | } |
52 | 56 | |
53 | 57 | // Reinsert preformatted code blocks |
54 | - foreach ($pre as $i => $code_tag) |
|
55 | - $body = str_replace("***pRe_sTrInG$i***", $code_tag, $body); |
|
58 | + foreach ($pre as $i => $code_tag) { |
|
59 | + $body = str_replace("***pRe_sTrInG$i***", $code_tag, $body); |
|
60 | + } |
|
56 | 61 | } |
57 | 62 | |
58 | 63 | // Replace any improper quote tags with proper quote tags |
@@ -235,8 +240,7 @@ discard block |
||
235 | 240 | // Replacing email addresses with encoded html |
236 | 241 | $body = preg_replace_callback('#\[email(?::\w+)?\]([\w\.\-\+~@]+)\[/email(?::\w+)?\]#si', '_bbcode_encode_mailto', $body); |
237 | 242 | $body = preg_replace_callback('#\[email=(.*?)(?::\w+)?\](.*?)\[/email(?::\w+)?\]#si', '_bbcode_encode_mailto', $body); |
238 | - } |
|
239 | - else { |
|
243 | + } else { |
|
240 | 244 | $body = preg_replace( |
241 | 245 | array('#\[email(?::\w+)?\](.*?)\[/email(?::\w+)?\]#si','#\[email=(.*?)(?::\w+)?\]([\w\s]+)\[/email(?::\w+)?\]#si'), |
242 | 246 | array('<a href="mailto:\\1" class="bb-email">\\1</a>', '<a href="mailto:\\1" class="bb-email">\\2</a>'), |
@@ -264,10 +268,11 @@ discard block |
||
264 | 268 | |
265 | 269 | // matches an email@domain type address at the start of a line, or after a space. |
266 | 270 | // Note: Only the followed chars are valid; alphanums, "-", "_" and or ".". |
267 | - if (variable_get("bbcode_encode_mailto_$format", 1)) |
|
268 | - $ret = preg_replace_callback("#([\t\r\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", '_bbcode_encode_mailto', $ret); |
|
269 | - else |
|
270 | - $ret = preg_replace('#([\t\r\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i', '\\1<a href="mailto:\\2@\\3">\\2@\\3</a>', $ret); |
|
271 | + if (variable_get("bbcode_encode_mailto_$format", 1)) { |
|
272 | + $ret = preg_replace_callback("#([\t\r\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", '_bbcode_encode_mailto', $ret); |
|
273 | + } else { |
|
274 | + $ret = preg_replace('#([\t\r\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i', '\\1<a href="mailto:\\2@\\3">\\2@\\3</a>', $ret); |
|
275 | + } |
|
271 | 276 | |
272 | 277 | // Remove our padding |
273 | 278 | $ret = str_replace("\x07", '', $ret); |
@@ -294,7 +299,9 @@ discard block |
||
294 | 299 | |
295 | 300 | if (preg_match_all('#\[h([1-6]).*?\](.*?)\[/h([1-6]).*?\]#si', $body, $head_tags, PREG_SET_ORDER)) { |
296 | 301 | foreach ($head_tags as $head_tag) { |
297 | - if ($level == 0) $level = $head_tag[1]; |
|
302 | + if ($level == 0) { |
|
303 | + $level = $head_tag[1]; |
|
304 | + } |
|
298 | 305 | $anchor = preg_replace('/([\s]+)/', '_', $head_tag[2]); |
299 | 306 | $anchor = preg_replace('/([\W]+)/', '', $anchor); |
300 | 307 | |
@@ -324,18 +331,21 @@ discard block |
||
324 | 331 | } |
325 | 332 | |
326 | 333 | function _bbcode_encode_mailto($matches) { |
327 | - if (isset($matches[3])) |
|
328 | - $link = 'document.write(\'<a href="mailto:' . $matches[2].'@'.$matches[3] . '">' . $matches[2].'@'.$matches[3] . '</a>\');'; |
|
329 | - else |
|
330 | - $link = 'document.write(\'<a href="mailto:' . $matches[1] . '" class="bb-email">' . (isset($matches[2]) ? $matches[2] : $matches[1]) . '</a>\');'; |
|
334 | + if (isset($matches[3])) { |
|
335 | + $link = 'document.write(\'<a href="mailto:' . $matches[2].'@'.$matches[3] . '">' . $matches[2].'@'.$matches[3] . '</a>\');'; |
|
336 | + } else { |
|
337 | + $link = 'document.write(\'<a href="mailto:' . $matches[1] . '" class="bb-email">' . (isset($matches[2]) ? $matches[2] : $matches[1]) . '</a>\');'; |
|
338 | + } |
|
331 | 339 | |
332 | 340 | $js_encode = ''; |
333 | - for ($x = 0; $x < strlen($link); $x++) |
|
334 | - $js_encode .= '%' . bin2hex($link{$x}); |
|
341 | + for ($x = 0; $x < strlen($link); $x++) { |
|
342 | + $js_encode .= '%' . bin2hex($link{$x}); |
|
343 | + } |
|
335 | 344 | |
336 | 345 | $link = '<script type="text/javascript">eval(unescape(\''.$js_encode.'\'))</script>'; |
337 | - if (isset($matches[3])) |
|
338 | - $link = $matches[1] . $link; |
|
346 | + if (isset($matches[3])) { |
|
347 | + $link = $matches[1] . $link; |
|
348 | + } |
|
339 | 349 | |
340 | 350 | return $link; |
341 | 351 | } |
@@ -349,13 +359,14 @@ discard block |
||
349 | 359 | } |
350 | 360 | |
351 | 361 | function _bbcode_round_size_val($size) { |
352 | - if ($size < 6) |
|
353 | - return 6; |
|
354 | - elseif ($size > 48) |
|
355 | - return 48; |
|
356 | - else |
|
357 | - return $size; |
|
358 | -} |
|
362 | + if ($size < 6) { |
|
363 | + return 6; |
|
364 | + } elseif ($size > 48) { |
|
365 | + return 48; |
|
366 | + } else { |
|
367 | + return $size; |
|
368 | + } |
|
369 | + } |
|
359 | 370 | |
360 | 371 | function _bbcode_replace_nest_tag($arr = NULL) { |
361 | 372 | $text = preg_replace('#(\[[/]*)'. $arr['tag'] .'(.*?\])#si', "$1\x07$2", $arr['text']); |