Update of /cvsroot/php-blog/serendipity/plugins/serendipity_event_contentrewrite
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20254/plugins/serendipity_event_contentrewrite
Modified Files:
Tag: branch_0_6
serendipity_event_contentrewrite.php
Log Message:
MFH:
* Upgrader kills the current session for possible changes inside session
data on upgrade
* Fixed wrong comparison operator - bug reported by tom, where nl2br plugin
has "reversed" logic.
This is because (true != 'false') evaluates to true. Plugin config did not
evaluate radio values correctly.
* Fixed textile plugin not enabled by default after adding it as a plugin
* Comments plugin now correctly wordwraps
* Couple of linebreak fixes (*sigh*)
PLEASE TEST THE PLUGIN-STUFF! Needs to be verified working for rc2...
Index: serendipity_event_contentrewrite.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/plugins/serendipity_event_contentrewrite/serendipity_event_contentrewrite.php,v
retrieving revision 1.5.4.1
retrieving revision 1.5.4.2
diff -u -d -r1.5.4.1 -r1.5.4.2
--- serendipity_event_contentrewrite.php 7 Apr 2004 12:38:19 -0000 1.5.4.1
+++ serendipity_event_contentrewrite.php 13 Apr 2004 10:01:12 -0000 1.5.4.2
@@ -21,7 +21,7 @@
@define('PLUGIN_EVENT_CONTENTREWRITE_REWRITECHAR', 'Rewrite Zeichen');
@define('PLUGIN_EVENT_CONTENTREWRITE_REWRITECHARDESC', 'Falls es ein besonderes Zeichen geben soll, was die Wort-Ersetzung ausführt, geben Sie es hier an. Falls z.B. nur \'serendipity*\' damit ersetzt werden soll, was Sie als Akronym für \'serendipity\' definiert haben, und das \'*\' soll entfernt werden, dann geben Sie dieses Zeichen an.');
break;
-
+
case 'en':
case 'es':
default:
@@ -53,14 +53,14 @@
function cleanup() {
// Cleanup. Remove all empty configs on SAVECONF-Submit.
serendipity_plugin_api::remove_plugin_value($this->instance, array('title', 'description'));
-
+
return true;
}
-
+
function introspect(&$propbag)
{
global $serendipity;
-
+
$propbag->add('name', PLUGIN_EVENT_CONTENTREWRITE_NAME);
$propbag->add('description', PLUGIN_EVENT_CONTENTREWRITE_DESCRIPTION);
$propbag->add('event_hooks', array(
@@ -95,14 +95,14 @@
$this->rewrite_to[] = $row['value'];
$found = true;
}
-
+
if ($found) {
$next_counter = $reg_counter[2] + 1;
$counter = ($next_counter > $counter ? $next_counter : $counter);
}
}
}
-
+
$counter = ($counter > 0 ? $counter + 1 : $counter);
if (count($this->title_values) == count($this->descr_values)) {
@@ -114,7 +114,7 @@
$values[] = 'title' . '_' . $counter;
$values[] = 'description' . '_' . $counter;
-
+
$this->markup_elements = array(
array(
'name' => ENTRY_BODY,
@@ -154,19 +154,19 @@
}
preg_match('|^(.+)_([0-9]+)$|msU', $name, $switch);
-
+
if (!isset($switch[2])) {
$switch[1] = $name;
$switch[2] = 'empty';
}
-
+
switch($switch[1]) {
case 'title':
-
+
if ($switch[2] != 'empty') {
$propbag->add('type', 'string');
-
+
if ($this->counter == $switch[2]) {
$propbag->add('name', PLUGIN_EVENT_CONTENTREWRITE_NEWTITLE);
$propbag->add('description', PLUGIN_EVENT_CONTENTREWRITE_NEWTDESCRIPTION);
@@ -231,10 +231,10 @@
</table>
<?php
}
-
+
function event_hook($event, &$bag, &$eventData) {
global $serendipity;
-
+
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch($event) {
@@ -251,26 +251,26 @@
'{' . PLUGIN_EVENT_CONTENTREWRITE_FROM . '}',
'{' . PLUGIN_EVENT_CONTENTREWRITE_TO . '}'
),
-
+
array(
str_replace(
$char,
'',
$v_from
),
-
+
$v_to
),
-
+
$string
);
-
+
// Build a regular expression (ungreedy, multiline) with our quoted value. $val here is the word needing the replacement
$regex = '°([^\d\w])(' . preg_quote($v_from) . ')([^\d\w])°msU';
-
+
// \1 and \3 are the prepend/append strings (usually whitespaces) and $new containing the new value
foreach ($this->markup_elements as $temp) {
- if ($this->get_config($temp['name']) != 'false' && isset($eventData[$temp['element']])) {
+ if (serendipity_db_bool($this->get_config($temp['name'], true)) && isset($eventData[$temp['element']])) {
$element = $temp['element'];
$eventData[$element] = preg_replace($regex, '\1' . $new . '\3', $eventData[$element]);
}
|