Remove horde/Core dependency in horde/Notification
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 14 Jul 2010 02:17:27 +0000 (20:17 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 14 Jul 2010 04:31:25 +0000 (22:31 -0600)
framework/Core/lib/Horde/Core/Notification/Status.php
framework/Notification/lib/Horde/Notification/Event/Status.php
framework/Notification/test/Horde/Notification/Class/Notification/Event/StatusTest.php

index 4b5cd73..2a8f3c9 100644 (file)
@@ -29,6 +29,8 @@ class Horde_Core_Notification_Status extends Horde_Notification_Event_Status
                 : (is_string($data) ? 'horde.message' : 'horde.error');
         }
 
+        $this->charset = $GLOBALS['registry']->getCharset();
+
         parent::__construct($data, $type, $flags);
     }
 
index fafee18..045e049 100644 (file)
 class Horde_Notification_Event_Status extends Horde_Notification_Event
 {
     /**
+     * Charset of the message.
+     *
+     * @var string
+     */
+    public $charset = null;
+
+    /**
      * String representation of this object.
      *
      * @return string  String representation.
@@ -22,8 +29,8 @@ class Horde_Notification_Event_Status extends Horde_Notification_Event
     {
         $text = $this->message;
 
-        if (!in_array('content.raw', $this->flags) && class_exists('Horde_Nls')) {
-            $text = htmlspecialchars($text, ENT_COMPAT, $GLOBALS['registry']->getCharset());
+        if (!in_array('content.raw', $this->flags)) {
+            $text = htmlspecialchars($text, ENT_COMPAT, $charset);
         }
 
         return $text;
index 6279d81..6963a51 100644 (file)
@@ -32,11 +32,8 @@ class Horde_Notification_Class_Notification_Event_StatusTest extends PHPUnit_Fra
 {
     public function testMethodTostringHasResultTheTextOfTheEvent()
     {
-        if (!class_exists('Horde_Nls')) {
-            $this->markTestSkipped('The Horde_Nls class is not available!');
-        }
-        $GLOBALS['registry']->setCharset('ISO-8859-1');
         $event = new Horde_Notification_Event_Status('<b>test</b>');
+        $event->charset = 'ISO-8859-1';
         $this->assertEquals('&lt;b&gt;test&lt;/b&gt;', (string) $event);
     }