From 0d645886ac5fd5ed2491c9276893d0ef70acb655 Mon Sep 17 00:00:00 2001 From: garvinhicking Date: Tue, 14 Nov 2006 09:23:16 +0000 Subject: [PATCH] Proper placing --- docs/NEWS | 4 + include/functions_images.inc.php | 4 +- index.php | 9 +- .../UTF-8/lang_de.inc.php | 6 +- .../serendipity_event_nl2br/lang_de.inc.php | 6 +- .../serendipity_event_nl2br/lang_en.inc.php | 3 +- .../serendipity_event_nl2br.php | 60 +++- templates/default/admin/media_upload.tpl | 263 ++++++++++++++++++ 8 files changed, 338 insertions(+), 17 deletions(-) create mode 100644 templates/default/admin/media_upload.tpl diff --git a/docs/NEWS b/docs/NEWS index 011d9bc..2d5e15c 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 420962d..98eb861 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 a96437e..1c49165 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 ba776fb..9ae1b61 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 60db21e..8fe2e01 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.3'); + $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,28 +72,75 @@ 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']]) && + !$eventData['properties']['ep_disable_markup_' . $this->instance] && + !isset($serendipity['POST']['properties']['disable_markup_' . $this->instance]) && !$eventData['properties']['ep_no_nl2br'] && - !isset($serendipity['POST']['properties']['no_nl2br'])) { + !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 new file mode 100644 index 0000000..99fcd6d --- /dev/null +++ b/templates/default/admin/media_upload.tpl @@ -0,0 +1,263 @@ +
{$CONST.ADD_MEDIA_BLAHBLAH}
+ + + +
+
+ {if $media.max_file_size} + + {/if} + {$media.token} + + + + {$media.form_hidden} + + + + + + + + + + + + + +
{$CONST.ENTER_MEDIA_URL}
{$CONST.ENTER_MEDIA_URL_METHOD} + +
- {$CONST.WORD_OR} -
+ + +
+ + + + + + + + + + + + + + + + + + + +
{$CONST.ENTER_MEDIA_UPLOAD}

{$CONST.SAVE_FILE_AS}
{$CONST.STORE_IN_DIRECTORY} +
+
+
+ +
+
+ + + + {serendipity_hookPlugin hook="backend_image_addform" hookAll=true} + +
+ + +
+ + - {$CONST.WORD_OR} - + +
+
+
{$CONST.ADD_MEDIA_BLAHBLAH_NOTE}
+
+ -- 2.39.5