delocalize
authorgarvinhicking <garvinhicking>
Fri, 23 Jun 2006 13:01:26 +0000 (13:01 +0000)
committergarvinhicking <garvinhicking>
Fri, 23 Jun 2006 13:01:26 +0000 (13:01 +0000)
plugins/serendipity_event_contentrewrite/lang_en.inc.php
plugins/serendipity_event_contentrewrite/serendipity_event_contentrewrite.php

index 2b6978fbf6724fc98e0c6ee2b3eef7131a7d25a6..312745be61177cfc93c8da5aee860f42f69ef44c 100644 (file)
@@ -24,5 +24,5 @@
 @define('PLUGIN_EVENT_CONTENTREWRITE_REWRITESTRINGDESC', 'The string used to rewrite. Place {from} and {to} anywhere you like to get a rewrite.' . "\n" . 'Example: <acronym title="{to}">{from}</acronym>');
 @define('PLUGIN_EVENT_CONTENTREWRITE_REWRITECHAR', 'Rewrite char');
 @define('PLUGIN_EVENT_CONTENTREWRITE_REWRITECHARDESC', 'If there is any char you append to force rewriting, enter it here. If you want to only replace \'serendipity*\' with what you entered for that word but want the \'*\' removed, enter that char here.');
-
+@define('PLUGIN_EVENT_CONTENTREWRITE_REWRITESTRING', 'The strings to perform replacements in your environment are %s and %s.');
 ?>
index 6467a93863155d2902ace6145ee67889c77686d0..10f5db3140a94915dd041fcd2ff2c224ca15245a 100644 (file)
@@ -12,6 +12,7 @@ class serendipity_event_contentrewrite extends serendipity_event
 {
     var $title = PLUGIN_EVENT_CONTENTREWRITE_NAME;
     var $rewrite_from, $rewrite_to;
+    var $fromstring, $tostring;
 
     function cleanup() {
         // Cleanup. Remove all empty configs on SAVECONF-Submit.
@@ -45,6 +46,19 @@ class serendipity_event_contentrewrite extends serendipity_event
         if (!empty($_POST['SAVECONF'])) $this->cleanup();
         $rows = serendipity_db_query("SELECT name, value FROM {$serendipity['dbPrefix']}config WHERE name LIKE '" . $this->instance . "/%' ORDER BY name");
 
+        $this->fromstring = $this->get_config('fromstring', null);
+        $this->tostring   = $this->get_config('tostring', null);
+
+        if (empty($this->fromstring)) {
+            $this->fromstring = PLUGIN_EVENT_CONTENTREWRITE_FROM;
+            $this->set_config('fromstring', $this->fromstring);
+        }
+
+        if (empty($this->tostring)) {
+            $this->tostring = PLUGIN_EVENT_CONTENTREWRITE_TO;
+            $this->set_config('tostring', $this->tostring);
+        }
+
         $counter = 0;
         $values  = array();
         $values[] = 'title';
@@ -117,6 +131,10 @@ class serendipity_event_contentrewrite extends serendipity_event
         $this->counter = $counter;
     }
 
+    function example() {
+        printf(PLUGIN_EVENT_CONTENTREWRITE_REWRITESTRING, $this->fromstring, $this->tostring);
+    }
+
     function install() {
         serendipity_plugin_api::hook_event('backend_cache_entries', $this->title);
     }
@@ -231,8 +249,8 @@ class serendipity_event_contentrewrite extends serendipity_event
                             $new =
                               str_replace(
                                 array(
-                                  '{' . PLUGIN_EVENT_CONTENTREWRITE_FROM . '}',
-                                  '{' . PLUGIN_EVENT_CONTENTREWRITE_TO . '}'
+                                  '{' . $this->fromstring . '}',
+                                  '{' . $this->tostring . '}'
                                 ),
 
                                 array(