From 535c979ae1a30273fba849fae99c8c0be288ec6e Mon Sep 17 00:00:00 2001
From: Demian Katz <demian.katz@villanova.edu>
Date: Thu, 28 Jun 2012 11:21:35 -0400
Subject: [PATCH] Created mechanism for configuring character encoding via
 theme.ini; default to UTF-8.

---
 .../VuFind/src/VuFind/Theme/Initializer.php   |  5 ++++
 .../src/VuFind/Theme/ResourceContainer.php    | 23 +++++++++++++++++++
 .../Theme/Root/Helper/HeadThemeResources.php  |  6 +++++
 3 files changed, 34 insertions(+)

diff --git a/module/VuFind/src/VuFind/Theme/Initializer.php b/module/VuFind/src/VuFind/Theme/Initializer.php
index 5f218c81754..e507391fe1a 100644
--- a/module/VuFind/src/VuFind/Theme/Initializer.php
+++ b/module/VuFind/src/VuFind/Theme/Initializer.php
@@ -352,6 +352,11 @@ class Initializer
                 $this->resourceContainer->addJs($js);
             }
 
+            // Select encoding:
+            if ($encoding = $currentThemeInfo->get('encoding')) {
+                $this->resourceContainer->setEncoding($encoding);
+            }
+
             // Select favicon:
             if ($favicon = $currentThemeInfo->get('favicon')) {
                 $this->resourceContainer->setFavicon($favicon);
diff --git a/module/VuFind/src/VuFind/Theme/ResourceContainer.php b/module/VuFind/src/VuFind/Theme/ResourceContainer.php
index e0daaeac322..466ee7c0c14 100644
--- a/module/VuFind/src/VuFind/Theme/ResourceContainer.php
+++ b/module/VuFind/src/VuFind/Theme/ResourceContainer.php
@@ -41,6 +41,7 @@ class ResourceContainer
     protected $css = array();
     protected $js = array();
     protected $favicon = null;
+    protected $encoding = 'UTF-8';
 
     /**
      * Add a CSS file.
@@ -98,6 +99,28 @@ class ResourceContainer
         return array_unique($this->js);
     }
 
+    /**
+     * Set the encoding.
+     *
+     * @param string $e New encoding
+     *
+     * @return void
+     */
+    public function setEncoding($e)
+    {
+        $this->encoding = $e;
+    }
+
+    /**
+     * Get the encoding.
+     *
+     * @return void
+     */
+    public function getEncoding()
+    {
+        return $this->encoding;
+    }
+
     /**
      * Set the favicon.
      *
diff --git a/module/VuFind/src/VuFind/Theme/Root/Helper/HeadThemeResources.php b/module/VuFind/src/VuFind/Theme/Root/Helper/HeadThemeResources.php
index f112ae822e3..dfdc9972de4 100644
--- a/module/VuFind/src/VuFind/Theme/Root/Helper/HeadThemeResources.php
+++ b/module/VuFind/src/VuFind/Theme/Root/Helper/HeadThemeResources.php
@@ -49,6 +49,12 @@ class HeadThemeResources extends AbstractHelper
     {
         $resourceContainer = ThemeTools::getResourceContainer();
 
+        // Set up encoding:
+        $headMeta = $this->getView()->plugin('headmeta');
+        $headMeta()->appendHttpEquiv(
+            'Content-Type', 'text/html; charset=' . $resourceContainer->getEncoding()
+        );
+
         // Load CSS:
         $headLink = $this->getView()->plugin('headlink');
         foreach ($resourceContainer->getCss() as $current) {
-- 
GitLab