diff --git a/docs/NEWS b/docs/NEWS index 011d9bcb..2d5e15cb 100644 --- a/docs/NEWS +++ b/docs/NEWS @@ -3,6 +3,10 @@ Version 1.1 () ------------------------------------------------------------------------ + * Enhanced nl2br plugin so that it will NOT put breaks into pre- + defined tags like
,  etc. Not enabled by default.
+      Thanks to Brendon K from the forums!
+
     * Portuguese translation update by Angel
 
     * Added functionality to reply to comments in the admin interface
diff --git a/include/functions_images.inc.php b/include/functions_images.inc.php
index 420962de..98eb861f 100644
--- a/include/functions_images.inc.php
+++ b/include/functions_images.inc.php
@@ -610,7 +610,7 @@ function serendipity_makeThumbnail($file, $directory = '', $size = false, $thumb
 
 
     $infile  = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $directory . $file;
-#    echo 'From: ' . $infile . '
'; + echo 'From: ' . $infile . '
'; if ($is_temporary) { $temppath = dirname($thumbname); if (!is_dir($temppath)) { @@ -621,7 +621,7 @@ function serendipity_makeThumbnail($file, $directory = '', $size = false, $thumb $outfile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $directory . $f . '.' . $thumbname . '.' . $suf; } $serendipity['last_outfile'] = $outfile; -# echo 'To: ' . $outfile . '
'; + echo 'To: ' . $outfile . '
'; $fdim = @serendipity_getimagesize($infile, '', $suf); if (isset($fdim['noimage'])) { diff --git a/index.php b/index.php index a96437e6..1c491651 100644 --- a/index.php +++ b/index.php @@ -18,14 +18,15 @@ if ($global_debug) { // rules to handle archives. header('HTTP/1.0 200'); -if ($serendipity['expose_s9y']) { - header('X-Blog: Serendipity'); // Used for installer detection -} - // Session are needed to also remember an autologin user on the frontend ob_start(); include('serendipity_config.inc.php'); header('Content-Type: text/html; charset='. LANG_CHARSET); + +if ($serendipity['expose_s9y']) { + header('X-Blog: Serendipity'); // Used for installer detection +} + if ($serendipity['CacheControl']) { if (!empty($HTTP_SERVER_VARS['SERVER_SOFTWARE']) && strstr($HTTP_SERVER_VARS['SERVER_SOFTWARE'], 'Apache/2')) { header('Cache-Control: no-cache, pre-check=0, post-check=0'); diff --git a/plugins/serendipity_event_nl2br/UTF-8/lang_de.inc.php b/plugins/serendipity_event_nl2br/UTF-8/lang_de.inc.php index ba776fbe..9ae1b613 100644 --- a/plugins/serendipity_event_nl2br/UTF-8/lang_de.inc.php +++ b/plugins/serendipity_event_nl2br/UTF-8/lang_de.inc.php @@ -1,4 +1,6 @@ diff --git a/plugins/serendipity_event_nl2br/serendipity_event_nl2br.php b/plugins/serendipity_event_nl2br/serendipity_event_nl2br.php index c686219c..8fe2e011 100644 --- a/plugins/serendipity_event_nl2br/serendipity_event_nl2br.php +++ b/plugins/serendipity_event_nl2br/serendipity_event_nl2br.php @@ -20,7 +20,7 @@ class serendipity_event_nl2br extends serendipity_event $propbag->add('description', PLUGIN_EVENT_NL2BR_DESC); $propbag->add('stackable', false); $propbag->add('author', 'Serendipity Team'); - $propbag->add('version', '1.4'); + $propbag->add('version', '1.5'); $propbag->add('requirements', array( 'serendipity' => '0.8', 'smarty' => '2.6.7', @@ -50,6 +50,7 @@ class serendipity_event_nl2br extends serendipity_event ); $conf_array = array(); + $conf_array[] = 'isolate'; foreach($this->markup_elements as $element) { $conf_array[] = $element['name']; } @@ -71,21 +72,59 @@ class serendipity_event_nl2br extends serendipity_event function introspect_config_item($name, &$propbag) { - $propbag->add('type', 'boolean'); - $propbag->add('name', constant($name)); - $propbag->add('description', sprintf(APPLY_MARKUP_TO, constant($name))); - $propbag->add('default', 'true'); + switch($name) { + case 'isolate': + $propbag->add('type', 'string'); + $propbag->add('name', PLUGIN_EVENT_NL2BR_ISOLATE_TAGS); + $propbag->add('description', PLUGIN_EVENT_NL2BR_ISOLATE_TAGS_DESC); + $propbag->add('default', ''); + break; + + default: + $propbag->add('type', 'boolean'); + $propbag->add('name', constant($name)); + $propbag->add('description', sprintf(APPLY_MARKUP_TO, constant($name))); + $propbag->add('default', 'true'); + } return true; } + function isolate($src, $regexp = NULL) { + if($regexp) return preg_replace_callback($regexp, array($this, 'isolate'), $src); + global $_buf; + $_buf[] = $src[0]; + return "\\001" . (count($_buf) - 1); + } + + function restore($text) { + global $_buf; + return preg_replace('~\\001(\\d+)~e', '$_buf[$1]', $text); + } + function event_hook($event, &$bag, &$eventData) { global $serendipity; + static $isolate = null; + global $_buf; $hooks = &$bag->get('event_hooks'); if (isset($hooks[$event])) { switch($event) { case 'frontend_display': + if ($isolate === null) { + $isolate = $this->get_config('isolate'); + $tags = (array)explode(',', $isolate); + $isolate = array(); + foreach($tags AS $tag) { + $tag = trim($tag); + if (!empty($tag)) { + $isolate[] = $tag; + } + } + if (count($isolate) < 1) { + $isolate = false; + } + } foreach ($this->markup_elements as $temp) { if (serendipity_db_bool($this->get_config($temp['name'], true)) && isset($eventData[$temp['element']]) && @@ -95,7 +134,13 @@ class serendipity_event_nl2br extends serendipity_event !isset($serendipity['POST']['properties']['ep_no_nl2br'])) { $element = $temp['element']; + if ($isolate) { + $eventData[$element] = $this->isolate($eventData[$element], '~[<\\[](' . implode('|', $isolate) . ').*?[>\\]].*?[<\\[]/\\1[>\\]]~si'); + } $eventData[$element] = nl2br($eventData[$element]); + if ($isolate) { + $eventData[$element] = $this->restore($eventData[$element]); + } } } return true; diff --git a/templates/default/admin/media_upload.tpl b/templates/default/admin/media_upload.tpl index 6ef3c719..99fcd6d1 100644 --- a/templates/default/admin/media_upload.tpl +++ b/templates/default/admin/media_upload.tpl @@ -170,7 +170,7 @@ function fillInput(source, target) {ldelim} {rdelim} -
+
{if $media.max_file_size}