#
-# http://open.38.com #
-##########################################################################
+ http://open.38.com
+ * EN-Revision: Revision of lang_en.inc.php
+ */
+
+@define('PLUGIN_EVENT_NL2BR_NAME', '標記語言: NL2BR');
+@define('PLUGIN_EVENT_NL2BR_DESC', '轉換新行成 BR 標籤');
- @define('PLUGIN_EVENT_NL2BR_NAME', '標記語言: NL2BR');
- @define('PLUGIN_EVENT_NL2BR_DESC', '轉換新行成 BR 標籤');
-?>
\ No newline at end of file
diff --git a/plugins/serendipity_event_nl2br/lang_zh.inc.php b/plugins/serendipity_event_nl2br/lang_zh.inc.php
index d787c46d..0476241e 100644
--- a/plugins/serendipity_event_nl2br/lang_zh.inc.php
+++ b/plugins/serendipity_event_nl2br/lang_zh.inc.php
@@ -1,6 +1,14 @@
-add('description', PLUGIN_EVENT_NL2BR_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Serendipity Team');
- $propbag->add('version', '2.18');
+ $propbag->add('version', '2.19');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
$propbag->add('cachable_events', array('frontend_display' => true));
-
- $propbag->add('event_hooks', array('frontend_display' => true,
+
+ $propbag->add('event_hooks', array('frontend_display' => true,
'backend_configure' => true,
'css' => true
));
@@ -59,16 +59,16 @@ class serendipity_event_nl2br extends serendipity_event
function cleanup() {
global $serendipity;
-
+
/* check possible config mismatch setting in combination with ISOBR */
- if ( serendipity_db_bool($this->get_config('isobr')) === true ) {
- if( serendipity_db_bool($this->get_config('clean_tags')) === true ) {
+ if ( serendipity_db_bool($this->get_config('isobr')) === true ) {
+ if( serendipity_db_bool($this->get_config('clean_tags')) === true ) {
$this->set_config('clean_tags', false);
echo '
';
echo sprintf(PLUGIN_EVENT_NL2BR_CONFIG_ERROR, 'clean_tags', 'ISOBR') . '
';
return false;
}
- if ( serendipity_db_bool($this->get_config('p_tags')) === true ) {
+ if ( serendipity_db_bool($this->get_config('p_tags')) === true ) {
$this->set_config('p_tags', false);
echo '
';
echo sprintf(PLUGIN_EVENT_NL2BR_CONFIG_ERROR, 'p_tags', 'ISOBR') . '
';
@@ -76,7 +76,7 @@ class serendipity_event_nl2br extends serendipity_event
}
}
/* check possible config mismatch setting in combination with P_TAGS */
- if ( serendipity_db_bool($this->get_config('p_tags')) === true && serendipity_db_bool($this->get_config('clean_tags')) === true ) {
+ if ( serendipity_db_bool($this->get_config('p_tags')) === true && serendipity_db_bool($this->get_config('clean_tags')) === true ) {
$this->set_config('clean_tags', false);
echo '
';
echo sprintf(PLUGIN_EVENT_NL2BR_CONFIG_ERROR, 'clean_tags', 'P_TAGS') . '
';
@@ -85,6 +85,23 @@ class serendipity_event_nl2br extends serendipity_event
return true;
}
+ function example() {
+ echo 'PLEASE NOTE the implications of this markup plugin:
+ This plugin transfers linebreaks to HTML-linebreaks, so that they show up in your blog entry.
+ In two cases this can raise problematic issues for you:
+
+ - if you use a WYSIWYG editor to write your entries. In that case, the WYSIWYG editor already inserts proper HTML linebreaks, so the nl2br plugin would actually double those linebreaks.
+ - if you use any other markup plugins in conjunction with this plugin that already translate linebreaks. The TEXTILE and MARKDOWN plugins are examples for plugins like these.
+
+ To prevent problems, you should disable the nl2br plugin on entries globally or per entry within the "Extended properties" section of an entry, if you have the entryproperties plugin installed.
+ Generally advice: The nl2br plugin only makes sense if you
+
+ - A) do not use other markup plugins or
+ - B) you do not use the WYSIWYG editor or
+ - C) you only want to apply linebreak transformations on comments to your blog entries, and do not allow any possible markup of other plugins that you only use for blog entries.
+
'."\n";
+ }
+
function install() {
serendipity_plugin_api::hook_event('backend_cache_entries', $this->title);
}
@@ -187,7 +204,7 @@ class serendipity_event_nl2br extends serendipity_event
if ($clean_tags === null) {
$clean_tags = serendipity_db_bool($this->get_config('clean_tags'));
}
-
+
if (isset($hooks[$event])) {
switch($event) {
case 'frontend_display':
@@ -204,13 +221,12 @@ class serendipity_event_nl2br extends serendipity_event
$serendipity['nl2br']['entry_disabled_markup'] = true;
}
- // don't add additional br or p tags, if the wysiwyg-editor, the textile, or markdown plugin already took care about markup
- if($markup) {
- if ( ($serendipity['wysiwyg'] && serendipity_userLoggedIn()) ||
- ($serendipity['nl2br']['entry_disabled_markup'] === false && (class_exists('serendipity_event_textile') || class_exists('serendipity_event_markdown'))) ) {
- return true;
- }
+ // don't run, if the textile, or markdown plugin already took care about markup
+ if ($markup && $serendipity['nl2br']['entry_disabled_markup'] === false && (class_exists('serendipity_event_textile') || class_exists('serendipity_event_markdown'))) {
+ return true;
}
+ // NOTE: the wysiwyg-editor needs to send its own ['properties']['ep_no_nl2br'] to disable the nl2br() parser!
+
// check for users isolation tags
if ($isolate === null) {
$isolate = $this->get_config('isolate');
@@ -226,14 +242,14 @@ class serendipity_event_nl2br extends serendipity_event
$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] &&
!in_array($this->instance, (array)$serendipity['POST']['properties']['disable_markups']) &&
!$eventData['properties']['ep_no_nl2br'] &&
!isset($serendipity['POST']['properties']['ep_no_nl2br'])) {
-
+
$element = $temp['element'];
if ($p_tags) {
$eventData[$element] = $this->nl2p($eventData[$element]);
@@ -248,12 +264,12 @@ class serendipity_event_nl2br extends serendipity_event
$eventData[$element] = $this->restore($eventData[$element]);
// unset nl tagline, if is
$eventData[$element] = str_replace(array("", "
", "
", ""), "", $eventData[$element]);
- } else {
+ } else {
$eventData[$element] = nl2br($eventData[$element]);
}
}
/* this is an option if not using new isobr default config setting */
- if (!$p_tags && $isobr === false && $clean_tags === true) {
+ if (!$p_tags && $isobr === false && $clean_tags === true) {
// convert line endings to Unix style, if not already done
$eventData[$element] = str_replace(array("\r\n", "\r"), "\n", $eventData[$element]);
// clean special tags from nl2br
@@ -267,18 +283,18 @@ class serendipity_event_nl2br extends serendipity_event
case 'backend_configure':
// check single entry for temporary disabled markups
- if( $isobr ) {
+ if( $isobr ) {
$serendipity['nl2br']['iso2br'] = true; // include to global as also used by staticpages now
- if (!is_object($serendipity['smarty'])) {
+ if (!is_object($serendipity['smarty'])) {
serendipity_smarty_init(); // if not set to avoid member function assign() on a non-object error, start Smarty templating
}
-
+
// hook into default/admin/entries.tpl somehow via the Heart Of Gold = serendipity_printEntryForm() before! it is loaded
$serendipity['smarty']->assign('iso2br', true);
}
-
-
+
+
return true;
break;
@@ -298,7 +314,7 @@ p.break {
]*>)(
)%is";
}
-
+
if(sizeof($br2nl)) $entry = preg_replace($br2nl, '\\1\\2\\3', $entry);
return $entry;
@@ -348,7 +364,7 @@ p.break {
//DOS to Unix and Mac to Unix
$text = str_replace(array("\r\n", "\r"), "\n", $text);
$text = str_split($text);
-
+
$big_p = '';
$small_p = '
';
@@ -360,14 +376,14 @@ p.break {
unset($text[$i-1]);
}
- //main operation: convert \n to big_p and small_p
+ //main operation: convert \n to big_p and small_p
while ($i > 0) {
if ($insert) {
$i = $this->next_nl_block($i, $text);
if ($i == 0) {
//prevent replacing of first character
break;
- }
+ }
if ($whiteline == true) {
$text[$i] = '
' . $big_p;
} else {
@@ -377,7 +393,7 @@ p.break {
$insert = false;
} else {
if ($text[$i-1] === "\n") {
- //newline is follower of a newline
+ //newline is follower of a newline
$whiteline = true;
}
$insert = true;
@@ -453,9 +469,9 @@ p.break {
'-tags from block-elements
* Note: Walking from left to right
@@ -506,7 +522,7 @@ p.break {
}
$len = strpos($text, $end_tag, $offset) - $offset;
return substr($text, $offset, $len);
- }
+ }
/*
* Return corresponding end-tag: