From: Jan Schneider Date: Sun, 3 Oct 2010 01:22:39 +0000 (+0200) Subject: Remove getCharset(). X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=ee55e0993d8c6777bd26c789830e3bde251114cf;p=horde.git Remove getCharset(). --- diff --git a/agora/lib/Agora.php b/agora/lib/Agora.php index 174a12afc..23443d9d5 100644 --- a/agora/lib/Agora.php +++ b/agora/lib/Agora.php @@ -364,7 +364,7 @@ class Agora { $body = new Horde_Mime_Part(); $body->setType('text/plain'); - $body->setCharset($GLOBALS['registry']->getCharset()); + $body->setCharset('UTF-8'); $body->setContents($message['body']); $body->send($forum['forum_distribution_address'], $msg_headers, $conf['mailer']['type'], $conf['mailer']['params']); diff --git a/agora/lib/Messages.php b/agora/lib/Messages.php index 2214fce94..d450a801b 100644 --- a/agora/lib/Messages.php +++ b/agora/lib/Messages.php @@ -566,7 +566,7 @@ class Agora_Messages { strftime($GLOBALS['prefs']->getValue('date_format'), $message['message_timestamp'])) . "\n-------------------------------------------------------\n" . $message['body']; - $message['body'] = "\n> " . Horde_String::wrap($message['body'], 60, "\n> ", $GLOBALS['registry']->getCharset()); + $message['body'] = "\n> " . Horde_String::wrap($message['body'], 60, "\n> ", 'UTF-8'); return $message; } @@ -993,7 +993,7 @@ class Agora_Messages { foreach ($messages as $id => &$message) { $message['message_id'] = $id; $message['message_author'] = htmlspecialchars($message['message_author']); - $message['message_subject'] = htmlspecialchars($this->convertFromDriver($message['message_subject']), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message['message_subject'] = htmlspecialchars($this->convertFromDriver($message['message_subject']), ENT_COMPAT, 'UTF-8'); $message['message_date'] = $this->dateFormat($message['message_timestamp']); if ($format) { $message['body'] = $this->formatBody($this->convertFromDriver($message['body'])); @@ -1147,7 +1147,7 @@ class Agora_Messages { $message['forum_name'] = $this->convertFromDriver($forums_list[$message['forum_id']]); $message['message_id'] = $id; $message['message_author'] = htmlspecialchars($message['message_author']); - $message['message_subject'] = htmlspecialchars($this->convertFromDriver($message['message_subject']), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message['message_subject'] = htmlspecialchars($this->convertFromDriver($message['message_subject']), ENT_COMPAT, 'UTF-8'); $message['message_body'] = $GLOBALS['injector']->getInstance('Horde_Text_Filter')filter($this->convertFromDriver($message['body']), 'highlightquotes'); if ($message['attachments']) { $message['message_attachment'] = $this->getAttachmentLink($id); @@ -2121,7 +2121,7 @@ class Agora_Messages { } if (!empty($filter['author'])) { - $sql .= ' AND message_author = ' . $this->_db->quote(Horde_String::lower($filter['author'], $GLOBALS['registry']->getCharset())); + $sql .= ' AND message_author = ' . $this->_db->quote(Horde_String::lower($filter['author'], 'UTF-8')); } /* Sort by result column. */ @@ -2222,7 +2222,7 @@ class Agora_Messages { */ public function convertToDriver($value) { - return Horde_String::convertCharset($value, $GLOBALS['registry']->getCharset(), $this->_params['charset']); + return Horde_String::convertCharset($value, 'UTF-8', $this->_params['charset']); } /** diff --git a/agora/lib/View.php b/agora/lib/View.php index d530acdb8..d1c3d083d 100644 --- a/agora/lib/View.php +++ b/agora/lib/View.php @@ -19,7 +19,7 @@ class Agora_View extends Horde_View { { /* Set default data. */ parent::__construct(array('templatePath' => AGORA_TEMPLATES . '/', - 'encoding' => $GLOBALS['registry']->getCharset())); + 'encoding' => 'UTF-8')); } } diff --git a/agora/messages/abuse.php b/agora/messages/abuse.php index d1e4f44e4..24740b473 100644 --- a/agora/messages/abuse.php +++ b/agora/messages/abuse.php @@ -72,7 +72,7 @@ if ($form->validate()) { 'body' => $url . "\n\n" . $registry->getAuth() . "\n\n" . $_SERVER["REMOTE_ADDR"], 'to' => $emails, 'from' => $emails[0], - 'charset' => $GLOBALS['registry']->getCharset())); + 'charset' => 'UTF-8')); $mail->addHeader('User-Agent', 'Agora ' . $registry->getVersion()); $mail->send($injector->getInstance('Horde_Mail')); diff --git a/agora/rss/index.php b/agora/rss/index.php index 6f5ed9edb..441ac1a44 100644 --- a/agora/rss/index.php +++ b/agora/rss/index.php @@ -24,7 +24,7 @@ if (!$rss) { $forums = Agora_Messages::singleton($scope); $forums_list = $forums->getForums(0, true, 'forum_name', 0); - $rss = 'getCharset() . '" ?> + $rss = ' ' . htmlspecialchars($title) . ' @@ -50,5 +50,5 @@ if (!$rss) { $cache->set($cache_key, $rss); } -header('Content-type: text/xml; charset=' . $GLOBALS['registry']->getCharset()); +header('Content-type: text/xml; charset=' . 'UTF-8'); echo $rss; diff --git a/agora/rss/messages.php b/agora/rss/messages.php index 1b35d3749..a6432413c 100644 --- a/agora/rss/messages.php +++ b/agora/rss/messages.php @@ -31,7 +31,7 @@ if (!$rss) { exit; } - $rss = 'getCharset() . '" ?> + $rss = ' ' . htmlspecialchars($message['message_subject']) . ' @@ -59,5 +59,5 @@ if (!$rss) { $cache->set($cache_key, $rss); } -header('Content-type: text/xml; charset=' . $GLOBALS['registry']->getCharset()); +header('Content-type: text/xml; charset=' . 'UTF-8'); echo $rss; diff --git a/agora/rss/threads.php b/agora/rss/threads.php index 813843372..5e9b37a82 100644 --- a/agora/rss/threads.php +++ b/agora/rss/threads.php @@ -59,7 +59,7 @@ if (!$rss) { $threads_list = $threads->getThreads(0, false, 'message_modifystamp', 1, true, '', null, 0, 10); - $rss = 'getCharset() . '" ?> + $rss = ' ' . htmlspecialchars($title) . ' @@ -98,5 +98,5 @@ if (!$rss) { $cache->set($cache_key, $rss); } -header('Content-type: text/xml; charset=' . $GLOBALS['registry']->getCharset()); +header('Content-type: text/xml; charset=' . 'UTF-8'); echo $rss; diff --git a/agora/templates/common-header.inc b/agora/templates/common-header.inc index f9041ecef..d8a3bc7de 100644 --- a/agora/templates/common-header.inc +++ b/agora/templates/common-header.inc @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/ansel/gallery/sort.php b/ansel/gallery/sort.php index d386cd4f6..2a5c60077 100644 --- a/ansel/gallery/sort.php +++ b/ansel/gallery/sort.php @@ -69,7 +69,7 @@ require ANSEL_TEMPLATES . '/common-header.inc'; echo Horde::menu(); $notification->notify(array('listeners' => 'status')); ?> -

getCharset()) ?>

+

@@ -91,7 +91,7 @@ $notification->notify(array('listeners' => 'status')); getImages(); foreach ($images as $image) { - $caption = empty($image->caption) ? htmlspecialchars($image->filename, ENT_COMPAT, $GLOBALS['registry']->getCharset()) : htmlspecialchars($image->caption, ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $caption = empty($image->caption) ? htmlspecialchars($image->filename, ENT_COMPAT, 'UTF-8') : htmlspecialchars($image->caption, ENT_COMPAT, 'UTF-8'); echo '
' . '' . htmlspecialchars($image->filename) . '' diff --git a/ansel/img/ecard.php b/ansel/img/ecard.php index 1b38050fa..d0ec98001 100644 --- a/ansel/img/ecard.php +++ b/ansel/img/ecard.php @@ -35,7 +35,7 @@ case 'send': break; } - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; /* Create the text part. */ $textpart = new Horde_Mime_Part(); @@ -59,7 +59,7 @@ case 'send': $img_tag = '

'; $comments = $htmlpart->replaceEOL(Horde_Util::getFormData('ecard_comments')); if (!Horde_Util::getFormData('rtemode')) { - $comments = '

' . htmlspecialchars($comments, ENT_COMPAT, $GLOBALS['registry']->getCharset()) . '
'; + $comments = '
' . htmlspecialchars($comments, ENT_COMPAT, 'UTF-8') . '
'; } $htmlpart->setContents('' . $img_tag . $comments . ''); $related->setContentTypeParameter('start', $htmlpart->setContentID()); diff --git a/ansel/lib/Ansel.php b/ansel/lib/Ansel.php index 7582ea3e7..b8a27a7d2 100644 --- a/ansel/lib/Ansel.php +++ b/ansel/lib/Ansel.php @@ -610,7 +610,7 @@ class Ansel // Check for an active image if (!empty($image_id)) { - $text = '' . htmlspecialchars($image->filename, ENT_COMPAT, $GLOBALS['registry']->getCharset()) . ''; + $text = '' . htmlspecialchars($image->filename, ENT_COMPAT, 'UTF-8') . ''; $nav = $separator . $text . $nav; $levels++; } @@ -635,7 +635,7 @@ class Ansel } if (!empty($owner_title)) { - $owner_title = htmlspecialchars($owner_title, ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $owner_title = htmlspecialchars($owner_title, ENT_COMPAT, 'UTF-8'); $levels++; if ($gallery) { $nav = $separator . Ansel::getUrlFor('view', array('view' => 'List', 'groupby' => 'owner', 'owner' => $owner, 'havesearch' => $haveSearch))->link() . $owner_title . '
' . $nav; diff --git a/ansel/lib/Block/gallery.php b/ansel/lib/Block/gallery.php index 9095a0e4a..73e72099e 100644 --- a/ansel/lib/Block/gallery.php +++ b/ansel/lib/Block/gallery.php @@ -85,7 +85,7 @@ class Horde_Block_ansel_gallery extends Horde_Block true); return $viewurl->link() - . @htmlspecialchars($name, ENT_COMPAT, $GLOBALS['registry']->getCharset()) + . @htmlspecialchars($name, ENT_COMPAT, 'UTF-8') . ''; } diff --git a/ansel/lib/Block/my_galleries.php b/ansel/lib/Block/my_galleries.php index f154dae9f..62985af85 100644 --- a/ansel/lib/Block/my_galleries.php +++ b/ansel/lib/Block/my_galleries.php @@ -98,7 +98,7 @@ HEADER; $html .= '' . $url->link(array('onmouseout' => '$("ansel_preview").hide();$("ansel_preview").update("");', 'onmouseover' => 'previewImageMg(event, ' . $gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default')) . ');')) - . @htmlspecialchars($gallery->get('name'), ENT_COMPAT, $GLOBALS['registry']->getCharset()) . '' + . @htmlspecialchars($gallery->get('name'), ENT_COMPAT, 'UTF-8') . '' . strftime($GLOBALS['prefs']->getValue('date_format'), $gallery->get('last_modified')) . '' . (int)$gallery->countImages(true) . ''; } diff --git a/ansel/lib/Block/recent_comments.php b/ansel/lib/Block/recent_comments.php index 5efb862c5..301f3ed4b 100644 --- a/ansel/lib/Block/recent_comments.php +++ b/ansel/lib/Block/recent_comments.php @@ -64,7 +64,7 @@ class Horde_Block_ansel_recent_comments extends Horde_Block } // Build the gallery name. if (isset($this->_params['gallery'])) { - $name = @htmlspecialchars($gallery->get('name'), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $name = @htmlspecialchars($gallery->get('name'), ENT_COMPAT, 'UTF-8'); } $viewurl = Ansel::getUrlFor('view', array('gallery' => $gallery->id, diff --git a/ansel/lib/Block/recent_faces.php b/ansel/lib/Block/recent_faces.php index 762dd6116..c400aa83c 100644 --- a/ansel/lib/Block/recent_faces.php +++ b/ansel/lib/Block/recent_faces.php @@ -52,7 +52,7 @@ class Horde_Block_ansel_recent_faces extends Horde_Block $results = $faces->allFaces(0, $this->_params['limit']); $html = ''; foreach ($results as $face_id => $face) { - $facename = htmlspecialchars($face['face_name'], ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $facename = htmlspecialchars($face['face_name'], ENT_COMPAT, 'UTF-8'); $html .= '' . '' . $facename  . ''; diff --git a/ansel/lib/Block/recently_added.php b/ansel/lib/Block/recently_added.php index cd20dae0f..793daf143 100644 --- a/ansel/lib/Block/recently_added.php +++ b/ansel/lib/Block/recently_added.php @@ -68,7 +68,7 @@ class Horde_Block_ansel_recently_added extends Horde_Block return Ansel::getUrlFor('view', array('view' => 'List'), true)->link() . _("Gallery") . ''; } - $name = @htmlspecialchars($gallery->get('name'), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $name = @htmlspecialchars($gallery->get('name'), ENT_COMPAT, 'UTF-8'); $style = $gallery->getStyle(); $viewurl = Ansel::getUrlFor('view', array('slug' => $gallery->get('slug'), @@ -145,7 +145,7 @@ HEADER; true); $galleryLink = $galleryLink->link() . @htmlspecialchars($gallery->get('name'), ENT_COMPAT, - $GLOBALS['registry']->getCharset()) + 'UTF-8') . ''; $caption = substr($image->caption, 0, 30); @@ -168,7 +168,7 @@ HEADER; 'onmouseover' => 'previewImage(event, ' . $image->id . ');')) . @htmlspecialchars( strlen($caption) ? $caption : $image->filename, - ENT_COMPAT, $GLOBALS['registry']->getCharset()) + ENT_COMPAT, 'UTF-8') . '' . $galleryLink . ''; } $html .= ''; diff --git a/ansel/lib/GalleryMode/Date.php b/ansel/lib/GalleryMode/Date.php index 7684d4ae3..54bd0a2fd 100644 --- a/ansel/lib/GalleryMode/Date.php +++ b/ansel/lib/GalleryMode/Date.php @@ -111,7 +111,7 @@ class Ansel_GalleryMode_Date extends Ansel_GalleryMode_Base $trail[] = array('title' => _("All dates"), 'navdata' => $navdata); } - $text = htmlspecialchars($this->_gallery->get('name'), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $text = htmlspecialchars($this->_gallery->get('name'), ENT_COMPAT, 'UTF-8'); $navdata = array('view' => 'Gallery', 'gallery' => $this->_gallery->id, 'slug' => $this->_gallery->get('slug')); diff --git a/ansel/lib/Image.php b/ansel/lib/Image.php index da77f7ca2..5684c55bf 100644 --- a/ansel/lib/Image.php +++ b/ansel/lib/Image.php @@ -1206,7 +1206,7 @@ class Ansel_Image Implements Iterator $output[$field] = $value; } else { $description = isset($data['description']) ? $data['description'] : $field; - $output[] = '' . $description . '' . htmlspecialchars($value, ENT_COMPAT, $GLOBALS['registry']->getCharset()) . ''; + $output[] = '' . $description . '' . htmlspecialchars($value, ENT_COMPAT, 'UTF-8') . ''; } } diff --git a/ansel/lib/Storage.php b/ansel/lib/Storage.php index fc9ae21e8..442203f65 100644 --- a/ansel/lib/Storage.php +++ b/ansel/lib/Storage.php @@ -496,9 +496,9 @@ class Ansel_Storage Horde::logMessage($update, 'ERR'); throw new Ansel_Exception($update); } - $result = $update->execute(array(Horde_String::convertCharset($image->filename, $GLOBALS['registry']->getCharset(), $GLOBALS['conf']['sql']['charset']), + $result = $update->execute(array(Horde_String::convertCharset($image->filename, 'UTF-8', $GLOBALS['conf']['sql']['charset']), $image->type, - Horde_String::convertCharset($image->caption, $GLOBALS['registry']->getCharset(), $GLOBALS['conf']['sql']['charset']), + Horde_String::convertCharset($image->caption, 'UTF-8', $GLOBALS['conf']['sql']['charset']), $image->sort, $image->originalDate, $image->lat, @@ -536,9 +536,9 @@ class Ansel_Storage /* Perform the INSERT */ $result = $insert->execute(array($image_id, $image->gallery, - Horde_String::convertCharset($image->filename, $GLOBALS['registry']->getCharset(), $GLOBALS['conf']['sql']['charset']), + Horde_String::convertCharset($image->filename, 'UTF-8', $GLOBALS['conf']['sql']['charset']), $image->type, - Horde_String::convertCharset($image->caption, $GLOBALS['registry']->getCharset(), $GLOBALS['conf']['sql']['charset']), + Horde_String::convertCharset($image->caption, 'UTF-8', $GLOBALS['conf']['sql']['charset']), $image->uploaded, $image->sort, $image->originalDate, @@ -571,7 +571,7 @@ class Ansel_Storage public function saveImageAttribute($image_id, $attribute, $value) { $insert = $this->_db->prepare('INSERT INTO ansel_image_attributes (image_id, attr_name, attr_value) VALUES (?, ?, ?)'); - $result = $insert->execute(array($image_id, $attribute, Horde_String::convertCharset($value, $GLOBALS['registry']->getCharset(), $GLOBALS['conf']['sql']['charset']))); + $result = $insert->execute(array($image_id, $attribute, Horde_String::convertCharset($value, 'UTF-8', $GLOBALS['conf']['sql']['charset']))); if ($result instanceof PEAR_Error) { throw new Ansel_Exception($result); } @@ -899,7 +899,7 @@ class Ansel_Storage if ($galleries[$gallery_id]['perm']) { $data = array((string)Ansel::getImageUrl($image->id, $image_view, $full, $style), - htmlspecialchars($image->filename, ENT_COMPAT, $GLOBALS['registry']->getCharset()), + htmlspecialchars($image->filename, ENT_COMPAT, 'UTF-8'), $GLOBALS['injector']->getInstance('Horde_Text_Filter')->filter($image->caption, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO_LINKURL)), $image->id, 0); @@ -925,7 +925,7 @@ class Ansel_Storage } if (count($json)) { - return Horde_Serialize::serialize($json, Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()); + return Horde_Serialize::serialize($json, Horde_Serialize::JSON, 'UTF-8'); } else { return ''; } diff --git a/ansel/lib/Tile/DateGallery.php b/ansel/lib/Tile/DateGallery.php index 54a361a57..8873b5955 100644 --- a/ansel/lib/Tile/DateGallery.php +++ b/ansel/lib/Tile/DateGallery.php @@ -104,7 +104,7 @@ class Ansel_Tile_DateGallery /* Variables used in the template file */ $image_link = $view_link . $gallery_image . ''; - $text_link = $view_link . htmlspecialchars($caption, ENT_COMPAT, $GLOBALS['registry']->getCharset()) . ''; + $text_link = $view_link . htmlspecialchars($caption, ENT_COMPAT, 'UTF-8') . ''; $gallery_count = $dgallery->countImages(true); /* Background color is needed if displaying a mini tile */ diff --git a/ansel/lib/Tile/Gallery.php b/ansel/lib/Tile/Gallery.php index ef3188eaa..4e5217d0f 100644 --- a/ansel/lib/Tile/Gallery.php +++ b/ansel/lib/Tile/Gallery.php @@ -77,7 +77,7 @@ class Ansel_Tile_Gallery } $image_link = $view_link . $gallery_image . ''; - $text_link = $view_link . htmlspecialchars($gallery->get('name'), ENT_COMPAT, $GLOBALS['registry']->getCharset()) + $text_link = $view_link . htmlspecialchars($gallery->get('name'), ENT_COMPAT, 'UTF-8') . ''; if ($gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT) && !$mini) { @@ -101,7 +101,7 @@ class Ansel_Tile_Gallery if (empty($owner_string)) { $owner_string = $gallery->get('owner'); } - $owner_link .= htmlspecialchars($owner_string, ENT_COMPAT, $GLOBALS['registry']->getCharset()) . ''; + $owner_link .= htmlspecialchars($owner_string, ENT_COMPAT, 'UTF-8') . ''; } $gallery_count = $gallery->countImages(true); diff --git a/ansel/lib/View/Base.php b/ansel/lib/View/Base.php index feb8c1b8d..edb21eb54 100644 --- a/ansel/lib/View/Base.php +++ b/ansel/lib/View/Base.php @@ -264,7 +264,7 @@ abstract class Ansel_View_Base } $data = array((string)Ansel::getImageUrl($image->id, $params['image_view'], $params['full'], $style), - htmlspecialchars($image->filename, ENT_COMPAT, $GLOBALS['registry']->getCharset()), + htmlspecialchars($image->filename, ENT_COMPAT, 'UTF-8'), $GLOBALS['injector']->getInstance('Horde_Text_Filter')->filter($image->caption, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO_LINKURL)), $image->id, $curpage); @@ -286,7 +286,7 @@ abstract class Ansel_View_Base $json[] = $data; } - return Horde_Serialize::serialize($json, Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()); + return Horde_Serialize::serialize($json, Horde_Serialize::JSON, 'UTF-8'); } /** diff --git a/ansel/lib/Widget/Links.php b/ansel/lib/Widget/Links.php index 36e67bb1d..167a27873 100644 --- a/ansel/lib/Widget/Links.php +++ b/ansel/lib/Widget/Links.php @@ -24,7 +24,7 @@ class Ansel_Widget_Links extends Ansel_Widget_Base $html = $this->_htmlBegin(); $html .= Ansel::getUrlFor('rss_user', array('owner' => $owner))->link() . Horde::img('feed.png') . ' ' . ($owner ? sprintf(_("Recent photos by %s"), $owner) : _("Recent system photos")) . ''; $slug = $this->_view->gallery->get('slug'); - $html .= '
' . Ansel::getUrlFor('rss_gallery', array('gallery' => $this->_view->gallery->id, 'slug' => $slug))->link() . ' ' . Horde::img('feed.png') . ' ' . sprintf(_("Recent photos in %s"), htmlspecialchars($this->_view->gallery->get('name'), ENT_COMPAT, $GLOBALS['registry']->getCharset())) . ''; + $html .= '
' . Ansel::getUrlFor('rss_gallery', array('gallery' => $this->_view->gallery->id, 'slug' => $slug))->link() . ' ' . Horde::img('feed.png') . ' ' . sprintf(_("Recent photos in %s"), htmlspecialchars($this->_view->gallery->get('name'), ENT_COMPAT, 'UTF-8')) . ''; /* Embed html */ if (empty($this->_view->_params['image_id'])) { diff --git a/ansel/rss.php b/ansel/rss.php index ae6d82846..70f18e976 100644 --- a/ansel/rss.php +++ b/ansel/rss.php @@ -263,10 +263,10 @@ if (empty($rss)) { } } - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; $xsl = $registry->get('themesuri') . '/feed-rss.xsl'; - $stream_name = @htmlspecialchars($params['name'], ENT_COMPAT, $GLOBALS['registry']->getCharset()); - $stream_desc = @htmlspecialchars($params['desc'], ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $stream_name = @htmlspecialchars($params['name'], ENT_COMPAT, 'UTF-8'); + $stream_desc = @htmlspecialchars($params['desc'], ENT_COMPAT, 'UTF-8'); $stream_updated = htmlspecialchars(date('r', $params['last_modified'])); $stream_official = htmlspecialchars($params['link']); $image_url = htmlspecialchars($params['image_url']); diff --git a/ansel/templates/captions/captions.inc b/ansel/templates/captions/captions.inc index ad48c7528..39f2755bb 100644 --- a/ansel/templates/captions/captions.inc +++ b/ansel/templates/captions/captions.inc @@ -7,7 +7,7 @@

- getCharset()) ?> +

get('desc')): ?> @@ -33,7 +33,7 @@ if ($gallery->countImages()) { echo ''; echo '' . htmlspecialchars($image->filename) . '' . ''; + htmlspecialchars($image->caption, ENT_COMPAT, 'UTF-8') . ''; $count++; if (($count % 2) == 0) { diff --git a/ansel/templates/common-header.inc b/ansel/templates/common-header.inc index 6615acf66..72c02d322 100644 --- a/ansel/templates/common-header.inc +++ b/ansel/templates/common-header.inc @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> @@ -21,7 +21,7 @@ Horde::outputMetaTags(); Horde::includeScriptFiles(); ?> -<?php echo htmlspecialchars($page_title, ENT_COMPAT, $GLOBALS['registry']->getCharset()) ?> +<?php echo htmlspecialchars($page_title, ENT_COMPAT, 'UTF-8') ?> diff --git a/ansel/templates/faces/gallery.inc b/ansel/templates/faces/gallery.inc index acbaf3432..12a6c14b4 100644 --- a/ansel/templates/faces/gallery.inc +++ b/ansel/templates/faces/gallery.inc @@ -32,7 +32,7 @@ render() ?> -

getCharset()) ?>

+

getCharset()) ?> +

getCharset()) ?> +

copy()->add(array_merge( diff --git a/ansel/templates/image/preview_image.inc b/ansel/templates/image/preview_image.inc index 10cb18d84..d4063b16f 100644 --- a/ansel/templates/image/preview_image.inc +++ b/ansel/templates/image/preview_image.inc @@ -1,4 +1,4 @@ -

getCharset()) ?>

+

add( array_merge( diff --git a/ansel/templates/image/resize_image.inc b/ansel/templates/image/resize_image.inc index bfce02afc..0e6ef7b07 100644 --- a/ansel/templates/image/resize_image.inc +++ b/ansel/templates/image/resize_image.inc @@ -29,7 +29,7 @@ function resetImage() document.slider.setValue(); } -

getCharset()) ?>

+

- getCharset()) . ' ' . Horde::url($refresh_link)->link(array('title' => _("Refresh List"))) . Horde::img('reload.png', _("Refresh List")) . '' ?> + link(array('title' => _("Refresh List"))) . Horde::img('reload.png', _("Refresh List")) . '' ?>
diff --git a/ansel/templates/view/results.inc b/ansel/templates/view/results.inc index b9671982f..e7d9c89e1 100644 --- a/ansel/templates/view/results.inc +++ b/ansel/templates/view/results.inc @@ -66,7 +66,7 @@ $allLink = (!empty($this->_owner)) ? Horde::selfUrl()->add(array('view' => 'Resu if ($total) { echo '' . ($total > $this->_perPage ? sprintf(_("%d to %d of %d Items"), $this->_pagestart, $this->_pageend, $total) : sprintf(ngettext("%d Item", "%d Items", $total), $total)) . '' . $allLink . ''; } -echo htmlspecialchars($this->getTitle(), ENT_COMPAT, $GLOBALS['registry']->getCharset()) . $this->_search->getTagTrail(); +echo htmlspecialchars($this->getTitle(), ENT_COMPAT, 'UTF-8') . $this->_search->getTagTrail(); ?> diff --git a/ansel/templates/xppublish/new.inc b/ansel/templates/xppublish/new.inc index 4e9a16f1b..f42255dcc 100755 --- a/ansel/templates/xppublish/new.inc +++ b/ansel/templates/xppublish/new.inc @@ -21,7 +21,7 @@
- +
diff --git a/ansel/xppublish.php b/ansel/xppublish.php index cc6a9f960..64e0a3ed8 100644 --- a/ansel/xppublish.php +++ b/ansel/xppublish.php @@ -17,7 +17,7 @@ if (empty($cmd)) { $publisher->sendRegFile( $registry->getApp() . '-' . $conf['server']['name'], $registry->get('name'), - Horde_String::convertCharset(sprintf(_("Publish your photos to %s on %s."), $registry->get('name'), $conf['server']['name']), $registry->getCharset(), $registry->getCharset(true)), + Horde_String::convertCharset(sprintf(_("Publish your photos to %s on %s."), $registry->get('name'), $conf['server']['name']), 'UTF-8', $registry->getLanguageCharset()), Horde::url('xppublish.php', true, -1)->add('cmd', 'publish'), Horde::url(Horde_Themes::img('favicon.ico'), true, -1)); exit; diff --git a/babel/lib/Display.php b/babel/lib/Display.php new file mode 100644 index 000000000..e8ba4df19 --- /dev/null +++ b/babel/lib/Display.php @@ -0,0 +1,136 @@ + + * @package Babel + */ + +class Translate_Display { + + function header($msg, $msg2 = '') { + global $cnt_i, $registry; + $select_img = Horde::img('alerts/message.png'); + print sprintf('
%s%s%s
', $msg, $msg2, $select_img); + flush(); + } + + function warning($msg, $bold = true) { + global $cnt_i, $registry; + $item = ($cnt_i++ % 2); + $select_img = Horde::img('alerts/warning.png'); + if ($bold) { + print sprintf('
%s%s
', $item, $msg, $select_img); + } else { + print sprintf('
%s%s
', $item, $msg, $select_img); + } + flush(); + } + + function error($msg) { + global $cnt_i, $registry; + $item = ($cnt_i++ % 2); + $select_img = Horde::img('alerts/error.png'); + print sprintf('
%s%s
', $item, $msg, $select_img); + flush(); + } + + function info($msg = "", $bold = true) { + + global $cnt_i, $registry; + + if (empty($msg)) { + echo "
"; + } else { + + $item = ($cnt_i++ % 2); + + $select_img = Horde::img('alerts/select.png'); + if ($bold) { + print sprintf('
%s%s
', $item, $msg, $select_img); + } else { + print sprintf('
%s%s
', $item, $msg, ''); + } + flush(); + } + } + + function parseCharset($headers) + { + if (preg_match('/charset=(.*)/i', $headers, $m)) { + return $m[1]; + } + return 'UTF-8'; + } + + function convert_string($msg) { + global $po; + + $f = array('/</', '/>/'); + $t = array('<', '>'); + $msg = preg_replace($f, $t, $msg); + return Horde_String::convertCharset(html_entity_decode($msg), 'UTF-8', Translate_Display::parseCharset($po->meta['Content-Type'])); + } + + function display_string($msg) { + global $po; + + $f = array('//'); + $t = array('<', '>'); + $msg = preg_replace($f, $t, $msg); + return Horde_String::convertCharset($msg, Translate_Display::parseCharset($po->meta['Content-Type']), 'UTF-8'); + } + + function get_percent($used, $total) { + if ($total > 0) { + $percent = sprintf("%2.2f", (($used * 100) / $total)); + } else { + $percent = 0; + } + + return $percent; + } + + function create_bargraph ($used, $total, $text = true, $reverse = false, $small = false) { + if ($total > 0) { + $percent = round(($used * 100) / $total); + } else { + $percent = 0; + } + + $html = ''; + } +} +require FIMA_TEMPLATES . '/postings/footer.inc'; + +require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/fima/templates/common-header.inc b/fima/templates/common-header.inc new file mode 100644 index 000000000..1dc19c1ca --- /dev/null +++ b/fima/templates/common-header.inc @@ -0,0 +1,29 @@ + + + + + +' : '' ?> + +get('name'); +if (!empty($title)) { + $page_title .= ' :: ' . $title; +} + +Horde::outputMetaTags(); +Horde::includeScriptFiles(); + +?> +<?php echo htmlspecialchars($page_title) ?> + + + + + diff --git a/folks/config/hooks.php.dist b/folks/config/hooks.php.dist index 9501887d8..466105169 100644 --- a/folks/config/hooks.php.dist +++ b/folks/config/hooks.php.dist @@ -309,7 +309,7 @@ class Folks_Hooks $value = hash('md5', $value); } $fields[] = 'user_' . Horde_String::lower($field); - $values[] = Horde_String::convertCharset($value, $GLOBALS['registry']->getCharset(), $conf['sql']['charset']); + $values[] = Horde_String::convertCharset($value, 'UTF-8', $conf['sql']['charset']); } $values[] = $userID; diff --git a/folks/lib/Folks.php b/folks/lib/Folks.php index 591e656c6..022527922 100644 --- a/folks/lib/Folks.php +++ b/folks/lib/Folks.php @@ -235,7 +235,7 @@ class Folks { */ static public function sendMail($to, $subject, $body, $attaches = array()) { - $mail = new Horde_Mime_Mail(array('subject' => $subject, 'body' => $body, 'to' => $to, 'from' => $GLOBALS['conf']['support'], 'charset' => $GLOBALS['registry']->getCharset())); + $mail = new Horde_Mime_Mail(array('subject' => $subject, 'body' => $body, 'to' => $to, 'from' => $GLOBALS['conf']['support'], 'charset' => 'UTF-8')); $mail->addHeader('User-Agent', 'Folks ' . $GLOBALS['registry']->getVersion()); $mail->addHeader('X-Originating-IP', $_SERVER['REMOTE_ADDR']); @@ -243,7 +243,7 @@ class Folks { foreach ($attaches as $file) { if (file_exists($file)) { - $mail->addAttachment($file, null, null, $GLOBALS['registry']->getCharset()); + $mail->addAttachment($file, null, null, 'UTF-8'); } } diff --git a/folks/lib/Notification/mail.php b/folks/lib/Notification/mail.php index e921cd2be..e2da33d1b 100644 --- a/folks/lib/Notification/mail.php +++ b/folks/lib/Notification/mail.php @@ -57,7 +57,7 @@ class Folks_Notification_mail extends Folks_Notification { $mail = new Horde_Mime_Mail(array('subject' => $subject, 'body' => $body, 'from' => $this->_params['from_addr'], - 'charset' => $GLOBALS['registry']->getCharset())); + 'charset' => 'UTF-8')); $mail->addHeader('User-Agent', 'Folks ' . $GLOBALS['registry']->getVersion()); $mail->addHeader('X-Originating-IP', $_SERVER['REMOTE_ADDR']); @@ -65,7 +65,7 @@ class Folks_Notification_mail extends Folks_Notification { foreach ($attachments as $file) { if (file_exists($file)) { - $mail->addAttachment($file, null, null, $GLOBALS['registry']->getCharset()); + $mail->addAttachment($file, null, null, 'UTF-8'); } } @@ -78,7 +78,7 @@ class Folks_Notification_mail extends Folks_Notification { if (empty($to)) { continue; } - $mail->addHeader('To', $to, $GLOBALS['registry']->getCharset(), true); + $mail->addHeader('To', $to, 'UTF-8', true); $mail->send($GLOBALS['injector']->getInstance('Horde_Mail')); } diff --git a/folks/scripts/mail.php b/folks/scripts/mail.php index a17d8e5d9..20c3d4dec 100644 --- a/folks/scripts/mail.php +++ b/folks/scripts/mail.php @@ -110,7 +110,7 @@ while ($row =& $res->fetchRow()) { $body2 = sprintf($body, $row[0], $registry->get('name', 'horde'), Folks::getUrlFor('user', $row[0], true, -1)); // Send mail - $mail = new MIME_Mail($subject, $body2, $row[1], $conf['support'], $GLOBALS['registry']->getCharset()); + $mail = new MIME_Mail($subject, $body2, $row[1], $conf['support'], 'UTF-8'); $mail->addHeader('User-Agent', 'Folks' . $registry->getVersion()); $sent = $mail->send($conf['mailer']['type'], $conf['mailer']['params']); if ($sent instanceof PEAR_Error) { diff --git a/folks/templates/common-header.inc b/folks/templates/common-header.inc index 0a2ca344e..b35638e91 100644 --- a/folks/templates/common-header.inc +++ b/folks/templates/common-header.inc @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/folks/templates/feed/activities.php b/folks/templates/feed/activities.php index 731f5c564..6c7d321bb 100644 --- a/folks/templates/feed/activities.php +++ b/folks/templates/feed/activities.php @@ -1,4 +1,4 @@ -getCharset() . '"?>' ?> +' ?> diff --git a/folks/templates/feed/feed.php b/folks/templates/feed/feed.php index 5c53ee71f..d98eae04d 100644 --- a/folks/templates/feed/feed.php +++ b/folks/templates/feed/feed.php @@ -1,4 +1,4 @@ -getCharset() . '"?>' ?> +' ?> diff --git a/framework/Alarm/lib/Horde/Alarm/Sql.php b/framework/Alarm/lib/Horde/Alarm/Sql.php index dfe994e41..aabe49b8d 100644 --- a/framework/Alarm/lib/Horde/Alarm/Sql.php +++ b/framework/Alarm/lib/Horde/Alarm/Sql.php @@ -419,7 +419,7 @@ class Horde_Alarm_Sql extends Horde_Alarm */ protected function _toDriver($value) { - return Horde_String::convertCharset($value, $GLOBALS['registry']->getCharset(), $this->_params['charset']); + return Horde_String::convertCharset($value, 'UTF-8', $this->_params['charset']); } } diff --git a/framework/Block/lib/Horde/Block/Layout/Manager.php b/framework/Block/lib/Horde/Block/Layout/Manager.php index 36de35eff..0be4f4e11 100644 --- a/framework/Block/lib/Horde/Block/Layout/Manager.php +++ b/framework/Block/lib/Horde/Block/Layout/Manager.php @@ -241,7 +241,7 @@ class Horde_Block_Layout_Manager extends Horde_Block_Layout try { $message = Horde::callHook('perms_denied', array('horde:max_blocks')); } catch (Horde_Exception_HookNotSet $e) { - $message = @htmlspecialchars(sprintf(ngettext("You are not allowed to create more than %d block.", "You are not allowed to create more than %d blocks.", $max_blocks), $max_blocks), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(ngettext("You are not allowed to create more than %d block.", "You are not allowed to create more than %d blocks.", $max_blocks), $max_blocks), ENT_COMPAT, 'UTF-8'); } $GLOBALS['notification']->push($message, 'horde.error', array('content.raw')); break; diff --git a/framework/Core/lib/Horde.php b/framework/Core/lib/Horde.php index 2d0737565..745db8dc7 100644 --- a/framework/Core/lib/Horde.php +++ b/framework/Core/lib/Horde.php @@ -555,7 +555,7 @@ HTML; */ static public function sendHTTPResponse($data, $ct) { - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; // Output headers and encoded response. switch ($ct) { @@ -618,7 +618,7 @@ HTML; */ static public function escapeJson($data, array $options = array()) { - $json = Horde_Serialize::serialize($data, Horde_Serialize::JSON, empty($options['charset']) ? $GLOBALS['registry']->getCharset() : $options['charset']); + $json = Horde_Serialize::serialize($data, Horde_Serialize::JSON, empty($options['charset']) ? 'UTF-8' : $options['charset']); if (empty($options['nodelimit'])) { $json = '/*-secure-' . $json . '*/'; } @@ -1135,7 +1135,7 @@ HTML; } if (!empty($title)) { if ($escape) { - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; $old_error = error_reporting(0); $title = str_replace( array("\r", "\n"), '', @@ -1176,7 +1176,7 @@ HTML; $attributes = array()) { if (!empty($title)) { - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; $old_error = error_reporting(0); $title = '<pre>' . preg_replace(array('/\n/', '/((?))/em', '/

/', '/
/'), array('', 'str_repeat(" ", strlen("$1"))', '<br /> <br />', '<br />'), nl2br(htmlspecialchars(htmlspecialchars($title, ENT_QUOTES, $charset), ENT_QUOTES, $charset))) . '</pre>'; error_reporting($old_error); @@ -1276,7 +1276,7 @@ HTML; */ static public function img($src, $alt = '', $attr = '') { - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; /* If browser does not support images, simply return the ALT text. */ if (!$GLOBALS['browser']->hasFeature('images')) { @@ -1319,7 +1319,7 @@ HTML; */ static public function fullSrcImg($src, $options = array()) { - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; /* If browser does not support images, simply return the ALT text. */ if (!$GLOBALS['browser']->hasFeature('images')) { @@ -1575,7 +1575,7 @@ HTML; */ static public function stripAccessKey($label) { - $multibyte = isset($GLOBALS['registry']->nlsconfig['multibyte'][$GLOBALS['registry']->getCharset(true)]); + $multibyte = isset($GLOBALS['registry']->nlsconfig['multibyte'][$GLOBALS['registry']->getLanguageCharset()]); return preg_replace('/_([A-Za-z])/', $multibyte && preg_match('/[\x80-\xff]/', $label) ? '' : '\1', $label); @@ -1598,10 +1598,10 @@ HTML; return $stripped_label; } - if (isset($GLOBALS['registry']->nlsconfig['multibyte'][$GLOBALS['registry']->getCharset(true)])) { + if (isset($GLOBALS['registry']->nlsconfig['multibyte'][$GLOBALS['registry']->getLanguageCharset()])) { /* Prefix parenthesis with the UTF-8 representation of the LRO * (Left-to-Right-Override) Unicode codepoint U+202D. */ - $prefix = ($GLOBALS['registry']->getCharset() == 'UTF-8') + $prefix = ('UTF-8' == 'UTF-8') ? "\xe2\x80\xad" : ''; return $stripped_label . $prefix . '(' @@ -1801,7 +1801,7 @@ HTML; */ static public function addInlineJsVars($data, $ret = false, $onload = null) { - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; $out = array(); foreach ($data as $key => $val) { diff --git a/framework/Core/lib/Horde/Config.php b/framework/Core/lib/Horde/Config.php index b3e528ca3..f303a26b8 100644 --- a/framework/Core/lib/Horde/Config.php +++ b/framework/Core/lib/Horde/Config.php @@ -1604,7 +1604,7 @@ class Horde_Config return $apps; case 'list-horde-languages': - return array_map(create_function('$val', 'return preg_replace(array("/&#x([0-9a-f]{4});/ie", "/(&[^;]+;)/e"), array("Horde_String::convertCharset(pack(\"H*\", \"$1\"), \"ucs-2\", \"' . $GLOBALS['registry']->getCharset() . '\")", "Horde_String::convertCharset(html_entity_decode(\"$1\", ENT_COMPAT, \"iso-8859-1\"), \"iso-8859-1\", \"' . $GLOBALS['registry']->getCharset() . '\")"), $val);'), $GLOBALS['registry']->nlsconfig['languages']); + return array_map(create_function('$val', 'return preg_replace(array("/&#x([0-9a-f]{4});/ie", "/(&[^;]+;)/e"), array("Horde_String::convertCharset(pack(\"H*\", \"$1\"), \"ucs-2\", \"' . 'UTF-8' . '\")", "Horde_String::convertCharset(html_entity_decode(\"$1\", ENT_COMPAT, \"iso-8859-1\"), \"iso-8859-1\", \"' . 'UTF-8' . '\")"), $val);'), $GLOBALS['registry']->nlsconfig['languages']); case 'list-blocks': $collection = Horde_Block_Collection::singleton(); diff --git a/framework/Core/lib/Horde/Core/Ajax/Imple/SpellChecker.php b/framework/Core/lib/Horde/Core/Ajax/Imple/SpellChecker.php index baab9abe1..32c5c467a 100644 --- a/framework/Core/lib/Horde/Core/Ajax/Imple/SpellChecker.php +++ b/framework/Core/lib/Horde/Core/Ajax/Imple/SpellChecker.php @@ -73,7 +73,7 @@ class Horde_Core_Ajax_Imple_SpellChecker extends Horde_Core_Ajax_Imple } Horde::addInlineScript(array( - $this->_params['id'] . ' = new SpellChecker(' . Horde_Serialize::serialize($opts, Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()) . ')' + $this->_params['id'] . ' = new SpellChecker(' . Horde_Serialize::serialize($opts, Horde_Serialize::JSON, 'UTF-8') . ')' ), 'dom'); } diff --git a/framework/Core/lib/Horde/Core/Auth/Signup/Base.php b/framework/Core/lib/Horde/Core/Auth/Signup/Base.php index 4ae78bb7c..016f7fa3c 100644 --- a/framework/Core/lib/Horde/Core/Auth/Signup/Base.php +++ b/framework/Core/lib/Horde/Core/Auth/Signup/Base.php @@ -89,7 +89,7 @@ abstract class Horde_Core_Auth_Signup_Base 'body' => $message, 'to' => $conf['signup']['email'], 'from' => $conf['signup']['email'], - 'subject' => $GLOBALS['registry']->getCharset())); + 'subject' => 'UTF-8')); $mail->send($GLOBALS['injector']->getInstance('Horde_Mail')); } } diff --git a/framework/Core/lib/Horde/Core/Factory/Alarm.php b/framework/Core/lib/Horde/Core/Factory/Alarm.php index 8cc3ba895..a8bbc47aa 100644 --- a/framework/Core/lib/Horde/Core/Factory/Alarm.php +++ b/framework/Core/lib/Horde/Core/Factory/Alarm.php @@ -70,7 +70,7 @@ class Horde_Core_Factory_Alarm $handler_params = array( 'identity' => $injector->getInstance('Horde_Prefs_Identity'), 'mail' => $injector->getInstance('Horde_Mail'), - 'charset' => $GLOBALS['registry']->getCharset() + 'charset' => 'UTF-8' ); $alarm->addHandler('mail', new Horde_Alarm_Handler_Mail($handler_params)); diff --git a/framework/Core/lib/Horde/Core/Factory/Auth.php b/framework/Core/lib/Horde/Core/Factory/Auth.php index d417b4ad6..178d09061 100644 --- a/framework/Core/lib/Horde/Core/Factory/Auth.php +++ b/framework/Core/lib/Horde/Core/Factory/Auth.php @@ -126,7 +126,7 @@ class Horde_Core_Factory_Auth $params['backend'] = $this->getOb($params['backend']['driver'], $params['backend']['params']); } - $params['charset'] = $GLOBALS['registry']->getCharset(); + $params['charset'] = 'UTF-8'; break; case 'http_remote': @@ -136,7 +136,7 @@ class Horde_Core_Factory_Auth break; case 'imap': - $params['charset'] = $GLOBALS['registry']->getCharset(); + $params['charset'] = 'UTF-8'; break; case 'kolab': diff --git a/framework/Core/lib/Horde/Core/Factory/Crypt.php b/framework/Core/lib/Horde/Core/Factory/Crypt.php index 58b7cfc33..14d2b0a63 100644 --- a/framework/Core/lib/Horde/Core/Factory/Crypt.php +++ b/framework/Core/lib/Horde/Core/Factory/Crypt.php @@ -58,7 +58,7 @@ class Horde_Core_Factory_Crypt global $registry; $params = array_merge(array( - 'charset' => $registry->getCharset(), + 'charset' => 'UTF-8', 'email_charset' => $registry->getEmailCharset(), 'temp' => Horde::getTempDir() ), $params); diff --git a/framework/Core/lib/Horde/Core/Factory/Data.php b/framework/Core/lib/Horde/Core/Factory/Data.php index 7221368f6..c20cc8faf 100644 --- a/framework/Core/lib/Horde/Core/Factory/Data.php +++ b/framework/Core/lib/Horde/Core/Factory/Data.php @@ -59,7 +59,7 @@ class Horde_Core_Factory_Data $params['vars'] = Horde_Variables::getDefaultVariables(); if (strcasecmp($driver, 'csv') === 0) { - $params['charset'] = $GLOBALS['registry']->getCharset(); + $params['charset'] = 'UTF-8'; } return Horde_Data::factory($driver, $params); diff --git a/framework/Core/lib/Horde/Core/Factory/MimeViewer.php b/framework/Core/lib/Horde/Core/Factory/MimeViewer.php index b8f08fc07..2c5d7eaec 100644 --- a/framework/Core/lib/Horde/Core/Factory/MimeViewer.php +++ b/framework/Core/lib/Horde/Core/Factory/MimeViewer.php @@ -100,7 +100,7 @@ class Horde_Core_Factory_MimeViewer : $config['app'] . '_Mime_Viewer_' . $config['driver']; $params = array_merge($config, array( - 'charset' => $GLOBALS['registry']->getCharset(), + 'charset' => 'UTF-8', // TODO: Logging // 'logger' => $this->_injector->getInstance('Horde_Log_Logger'), 'temp_file' => array('Horde', 'getTempFile'), diff --git a/framework/Core/lib/Horde/Core/Factory/Prefs.php b/framework/Core/lib/Horde/Core/Factory/Prefs.php index 364612580..f3cf750f3 100644 --- a/framework/Core/lib/Horde/Core/Factory/Prefs.php +++ b/framework/Core/lib/Horde/Core/Factory/Prefs.php @@ -77,11 +77,11 @@ class Horde_Core_Factory_Prefs $opts = array_merge(array( 'cache' => true, - 'charset' => $GLOBALS['registry']->getCharset(), + 'charset' => 'UTF-8', 'logger' => $this->_injector->getInstance('Horde_Log_Logger'), 'password' => '', 'sizecallback' => ((isset($GLOBALS['conf']['prefs']['maxsize'])) ? array($this, 'sizeCallback') : null), - 'uicharset' => $GLOBALS['registry']->getCharset(), + 'uicharset' => 'UTF-8', 'user' => '' ), $opts); ksort($opts); diff --git a/framework/Core/lib/Horde/Core/Factory/TextFilter.php b/framework/Core/lib/Horde/Core/Factory/TextFilter.php index ee846abc9..cdc8355bd 100644 --- a/framework/Core/lib/Horde/Core/Factory/TextFilter.php +++ b/framework/Core/lib/Horde/Core/Factory/TextFilter.php @@ -145,7 +145,7 @@ class Horde_Core_Factory_TextFilter case 'html2text': case 'space2html': case 'text2html': - $params['charset'] = $GLOBALS['registry']->getCharset(); + $params['charset'] = 'UTF-8'; break; } } diff --git a/framework/Core/lib/Horde/Core/Notification/Status.php b/framework/Core/lib/Horde/Core/Notification/Status.php index 2a8f3c9cc..55ce913d5 100644 --- a/framework/Core/lib/Horde/Core/Notification/Status.php +++ b/framework/Core/lib/Horde/Core/Notification/Status.php @@ -29,7 +29,7 @@ class Horde_Core_Notification_Status extends Horde_Notification_Event_Status : (is_string($data) ? 'horde.message' : 'horde.error'); } - $this->charset = $GLOBALS['registry']->getCharset(); + $this->charset = 'UTF-8'; parent::__construct($data, $type, $flags); } diff --git a/framework/Core/lib/Horde/Core/Prefs/Identity.php b/framework/Core/lib/Horde/Core/Prefs/Identity.php index 25aa7f7ca..ab66ec8d9 100644 --- a/framework/Core/lib/Horde/Core/Prefs/Identity.php +++ b/framework/Core/lib/Horde/Core/Prefs/Identity.php @@ -56,7 +56,7 @@ class Horde_Core_Prefs_Identity extends Horde_Prefs_Identity $body = new Horde_Mime_Part(); $body->setType('text/plain'); $body->setContents(Horde_String::wrap($message, 76, "\n")); - $body->setCharset($GLOBALS['registry']->getCharset()); + $body->setCharset('UTF-8'); $body->send($new_addr, $msg_headers, $GLOBALS['injector']->getInstance('Horde_Mail')); diff --git a/framework/Core/lib/Horde/Core/Prefs/Ui.php b/framework/Core/lib/Horde/Core/Prefs/Ui.php index 6b2c208f5..46e7ae673 100644 --- a/framework/Core/lib/Horde/Core/Prefs/Ui.php +++ b/framework/Core/lib/Horde/Core/Prefs/Ui.php @@ -774,7 +774,7 @@ class Horde_Core_Prefs_Ui // Fall-through default: - $val2 = Horde_String::convertCharset($val, $GLOBALS['registry']->getCharset(), 'UTF-8'); + $val2 = Horde_String::convertCharset($val, 'UTF-8', 'UTF-8'); } // [0] = pref name diff --git a/framework/Core/lib/Horde/Core/Tree/Javascript.php b/framework/Core/lib/Horde/Core/Tree/Javascript.php index b65d9b3e7..52201d15f 100644 --- a/framework/Core/lib/Horde/Core/Tree/Javascript.php +++ b/framework/Core/lib/Horde/Core/Tree/Javascript.php @@ -103,7 +103,7 @@ class Horde_Core_Tree_Javascript extends Horde_Core_Tree_Html } Horde::addInlineScript(array( - 'window.' . $js_var . ' = new Horde_Tree(' . Horde_Serialize::serialize($opts, Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()) . ')' + 'window.' . $js_var . ' = new Horde_Tree(' . Horde_Serialize::serialize($opts, Horde_Serialize::JSON, 'UTF-8') . ')' ), 'dom'); return '
'; diff --git a/framework/Core/lib/Horde/Core/Ui/VarRenderer.php b/framework/Core/lib/Horde/Core/Ui/VarRenderer.php index e96840b02..2bf8d8433 100644 --- a/framework/Core/lib/Horde/Core/Ui/VarRenderer.php +++ b/framework/Core/lib/Horde/Core/Ui/VarRenderer.php @@ -38,7 +38,7 @@ class Horde_Core_Ui_VarRenderer public function __construct($params = array()) { $this->_params = $params; - $this->_charset = $GLOBALS['registry']->getCharset(); + $this->_charset = 'UTF-8'; } /** diff --git a/framework/Core/lib/Horde/Registry.php b/framework/Core/lib/Horde/Registry.php index 33b1d7c2d..dff0bcdb2 100644 --- a/framework/Core/lib/Horde/Registry.php +++ b/framework/Core/lib/Horde/Registry.php @@ -2152,20 +2152,14 @@ class Horde_Registry /** * Returns the charset for the current language. * - * @param boolean $original If true returns the original charset of the - * translation, the actually used one otherwise. - * * @return string The character set that should be used with the current * locale settings. */ - public function getCharset($original = false) + public function getLanguageCharset() { - if ($original) { - return empty($this->nlsconfig['charsets'][$GLOBALS['language']]) - ? 'ISO-8859-1' - : $this->nlsconfig['charsets'][$GLOBALS['language']]; - } - return 'UTF-8'; + return empty($this->nlsconfig['charsets'][$GLOBALS['language']]) + ? 'ISO-8859-1' + : $this->nlsconfig['charsets'][$GLOBALS['language']]; } /** @@ -2325,15 +2319,11 @@ class Horde_Registry * LC_MESSAGES directory resides. * @param string $charset The charset. */ - public function setTextdomain($app, $directory, $charset = null) + public function setTextdomain($app, $directory, $charset = 'UTF-8') { bindtextdomain($app, $directory); textdomain($app); - if (is_null($charset)) { - $charset = $this->getCharset(); - } - $this->_cachedCharset(0, bind_textdomain_codeset($app, $charset)); if (!Horde::contentSent()) { diff --git a/framework/DataTree/DataTree/sql.php b/framework/DataTree/DataTree/sql.php index dd0a0a395..004619ae8 100644 --- a/framework/DataTree/DataTree/sql.php +++ b/framework/DataTree/DataTree/sql.php @@ -451,7 +451,7 @@ class DataTree_sql extends DataTree { return null; } else { $name = Horde_String::convertCharset($name, $this->_params['charset'], - $GLOBALS['registry']->getCharset()); + 'UTF-8'); // Get the parent names, if any. $parent = $this->getParentById($id); if ($parent && !is_a($parent, 'PEAR_Error') && @@ -524,7 +524,7 @@ class DataTree_sql extends DataTree { } else { require_once 'Horde/Serialize.php'; $ser = Horde_Serialize::UTF7_BASIC; - $data = Horde_Serialize::serialize($object->getData(), $ser, $GLOBALS['registry']->getCharset()); + $data = Horde_Serialize::serialize($object->getData(), $ser, 'UTF-8'); } } else { $fullname = $object; @@ -599,7 +599,7 @@ class DataTree_sql extends DataTree { ' VALUES (?, ?, ?, ?, ?, ?, ?, ?)'; $values = array((int)$id, $this->_params['group'], - Horde_String::convertCharset($name, $GLOBALS['registry']->getCharset(), $this->_params['charset']), + Horde_String::convertCharset($name, 'UTF-8', $this->_params['charset']), is_null($order) ? NULL : (int)$order, $data, (string)$GLOBALS['registry']->getAuth(), @@ -978,7 +978,7 @@ class DataTree_sql extends DataTree { $id = $this->getId($old_object); $query = 'UPDATE ' . $this->_params['table'] . ' SET datatree_name = ? WHERE datatree_id = ?'; - $values = array(Horde_String::convertCharset($new_object_name, $GLOBALS['registry']->getCharset(), $this->_params['charset']), + $values = array(Horde_String::convertCharset($new_object_name, 'UTF-8', $this->_params['charset']), (int)$id); Horde::logMessage('SQL Query by DataTree_sql::rename(): ' . $query . ', ' . var_export($values, true), 'DEBUG'); @@ -1015,11 +1015,11 @@ class DataTree_sql extends DataTree { $data = array(); foreach ($result as $id => $row) { $data[$id] = Horde_Serialize::unserialize($row[0], $row[1], - $GLOBALS['registry']->getCharset()); + 'UTF-8'); /* Convert old data to the new format. */ if ($row[1] == Horde_Serialize::BASIC) { $data[$id] = Horde_String::convertCharset($data[$id], - $GLOBALS['registry']->getCharset(true)); + $GLOBALS['registry']->getLanguageCharset()); } $data[$id] = (is_null($data[$id]) || !is_array($data[$id])) @@ -1039,10 +1039,10 @@ class DataTree_sql extends DataTree { $data = Horde_Serialize::unserialize($row['datatree_data'], $row['datatree_serialized'], - $GLOBALS['registry']->getCharset()); + 'UTF-8'); /* Convert old data to the new format. */ if ($row['datatree_serialized'] == Horde_Serialize::BASIC) { - $data = Horde_String::convertCharset($data, $GLOBALS['registry']->getCharset(true)); + $data = Horde_String::convertCharset($data, $GLOBALS['registry']->getLanguageCharset()); } return (is_null($data) || !is_array($data)) ? array() : $data; } @@ -1090,7 +1090,7 @@ class DataTree_sql extends DataTree { } $data[$row['datatree_id']][] = array('name' => $row['name'], 'key' => $row['key'], - 'value' => Horde_String::convertCharset($row['value'], $this->_params['charset'], $GLOBALS['registry']->getCharset())); + 'value' => Horde_String::convertCharset($row['value'], $this->_params['charset'], 'UTF-8')); } return $data; } else { @@ -1104,7 +1104,7 @@ class DataTree_sql extends DataTree { for ($i = 0; $i < count($rows); $i++) { $rows[$i]['value'] = Horde_String::convertCharset($rows[$i]['value'], $this->_params['charset'], - $GLOBALS['registry']->getCharset()); + 'UTF-8'); } return $rows; } @@ -1808,7 +1808,7 @@ class DataTree_sql extends DataTree { $values = array((int)$id, $attr['name'], $attr['key'], - Horde_String::convertCharset($attr['value'], $GLOBALS['registry']->getCharset(), $this->_params['charset'])); + Horde_String::convertCharset($attr['value'], 'UTF-8', $this->_params['charset'])); Horde::logMessage('SQL Query by DataTree_sql::updateData(): ' . $query . ', ' . var_export($values, true), 'DEBUG'); @@ -1829,7 +1829,7 @@ class DataTree_sql extends DataTree { /* Write to the datatree_data field. */ require_once 'Horde/Serialize.php'; $ser = Horde_Serialize::UTF7_BASIC; - $data = Horde_Serialize::serialize($object->getData(), $ser, $GLOBALS['registry']->getCharset()); + $data = Horde_Serialize::serialize($object->getData(), $ser, 'UTF-8'); $query = 'UPDATE ' . $this->_params['table'] . ' SET datatree_data = ?, datatree_serialized = ?' . diff --git a/framework/Form/Form/Renderer.php b/framework/Form/Form/Renderer.php index 8984417d7..667a7723a 100644 --- a/framework/Form/Form/Renderer.php +++ b/framework/Form/Form/Renderer.php @@ -213,7 +213,7 @@ try { } } } - echo ''; + echo ''; } function renderFormActive(&$form, &$vars) diff --git a/framework/Group/lib/Horde/Group/Kolab.php b/framework/Group/lib/Horde/Group/Kolab.php index 8d7ba73af..1fcd03b56 100644 --- a/framework/Group/lib/Horde/Group/Kolab.php +++ b/framework/Group/lib/Horde/Group/Kolab.php @@ -304,7 +304,7 @@ class Horde_Group_Kolab extends Horde_Group_Ldap } $groups = array(); - $current_charset = $GLOBALS['registry']->getCharset(); + $current_charset = 'UTF-8'; for ($i = 0; $i < $result['count']; $i++) { $utf8_dn = Horde_String::convertCharset($result[$i]['dn'], 'UTF-8', $current_charset); $groups[$utf8_dn] = $this->getGroupName($utf8_dn); diff --git a/framework/Group/lib/Horde/Group/Ldap.php b/framework/Group/lib/Horde/Group/Ldap.php index 69c1feb99..f91cec5ac 100644 --- a/framework/Group/lib/Horde/Group/Ldap.php +++ b/framework/Group/lib/Horde/Group/Ldap.php @@ -280,7 +280,7 @@ class Horde_Group_Ldap extends Horde_Group */ public function getGroupName($dn) { - $dn = Horde_String::convertCharset($dn, $GLOBALS['registry']->getCharset(), 'UTF-8'); + $dn = Horde_String::convertCharset($dn, 'UTF-8', 'UTF-8'); $result = @ldap_explode_dn($dn, 1); if ($result === false) { throw new Horde_Group_Exception('Invalid group ID passed (bad DN syntax)'); @@ -530,7 +530,7 @@ class Horde_Group_Ldap extends Horde_Group } $this->_userCache[$user] = array(); - $current_charset = $GLOBALS['registry']->getCharset(); + $current_charset = 'UTF-8'; foreach ($search as $dn => $entry) { $utf8_dn = Horde_String::convertCharset($dn, 'UTF-8', $current_charset); $this->_userCache[$user][$utf8_dn] = $this->getGroupName($utf8_dn); diff --git a/framework/Icalendar/lib/Horde/Icalendar.php b/framework/Icalendar/lib/Horde/Icalendar.php index 853bb1554..655c7a5ea 100644 --- a/framework/Icalendar/lib/Horde/Icalendar.php +++ b/framework/Icalendar/lib/Horde/Icalendar.php @@ -1049,7 +1049,7 @@ class Horde_Icalendar // Add CHARSET as well. At least the synthesis client // gets confused otherwise if (empty($params['CHARSET'])) { - $params['CHARSET'] = $GLOBALS['registry']->getCharset(); + $params['CHARSET'] = 'UTF-8'; $params_str .= ';CHARSET=' . $params['CHARSET']; } } diff --git a/framework/Kolab/Kolab.php b/framework/Kolab/Kolab.php index ad3628b89..784c84a05 100644 --- a/framework/Kolab/Kolab.php +++ b/framework/Kolab/Kolab.php @@ -526,7 +526,7 @@ class Kolab { function &setElemStr(&$parent, $name, $value = '') { - return $this->setElemVal($parent, $name, Horde_String::convertCharset($value, $GLOBALS['registry']->getCharset(), 'utf-8')); + return $this->setElemVal($parent, $name, Horde_String::convertCharset($value, 'UTF-8', 'utf-8')); } function &setVal($name, $value = '') @@ -553,7 +553,7 @@ class Kolab { */ function encodeImapFolderName($name) { - return Horde_String::convertCharset($name, $GLOBALS['registry']->getCharset(), 'UTF7-IMAP'); + return Horde_String::convertCharset($name, 'UTF-8', 'UTF7-IMAP'); } /** diff --git a/framework/Kolab_Format/lib/Horde/Kolab/Format/Xml.php b/framework/Kolab_Format/lib/Horde/Kolab/Format/Xml.php index d2a78de55..a7d46bc92 100644 --- a/framework/Kolab_Format/lib/Horde/Kolab/Format/Xml.php +++ b/framework/Kolab_Format/lib/Horde/Kolab/Format/Xml.php @@ -775,7 +775,7 @@ class Horde_Kolab_Format_Xml */ protected function _createTextNode($parent, $name, $value) { - $value = Horde_String::convertCharset($value, $GLOBALS['registry']->getCharset(), + $value = Horde_String::convertCharset($value, 'UTF-8', 'utf-8'); $node = $this->_xmldoc->createElement($name); diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace.php index 67a7c115d..a5780e9d3 100644 --- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace.php +++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Driver/Namespace.php @@ -84,7 +84,7 @@ implements Iterator */ public function __construct() { - $this->_charset = $GLOBALS['registry']->getCharset(); + $this->_charset = 'UTF-8'; if (empty($this->_primaryPersonalNamespace)) { $personal = null; foreach ($this->_namespaces as $namespace) { diff --git a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder/Base.php b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder/Base.php index d77c6579a..e49342960 100644 --- a/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder/Base.php +++ b/framework/Kolab_Storage/lib/Horde/Kolab/Storage/Folder/Base.php @@ -902,7 +902,7 @@ implements Horde_Kolab_Storage_Folder $part = new Horde_Mime_Part(); $part->setType(isset($data['type']) ? $data['type'] : null); $part->setContents(isset($data['content']) ? $data['content'] : file_get_contents($data['path'])); - $part->setCharset($GLOBALS['registry']->getCharset()); + $part->setCharset('UTF-8'); $part->setTransferEncoding('quoted-printable'); $part->setDisposition('attachment'); $part->setName($attachment); @@ -925,7 +925,7 @@ implements Horde_Kolab_Storage_Folder $part = new Horde_Mime_Part(); $part->setType($handlers[$type]->getMimeType()); $part->setContents($new_content); - $part->setCharset($GLOBALS['registry']->getCharset()); + $part->setCharset('UTF-8'); $part->setTransferEncoding('quoted-printable'); $part->setDisposition($handlers[$type]->getDisposition()); $part->setDispositionParameter('x-kolab-type', $type); @@ -1056,8 +1056,8 @@ implements Horde_Kolab_Storage_Folder $part = new Horde_Mime_Part(); $part->setType('text/plain'); $part->setName('Kolab Groupware Information'); - $part->setContents(Horde_String::wrap($kolab_text, 76, "\r\n", $GLOBALS['registry']->getCharset())); - $part->setCharset($GLOBALS['registry']->getCharset()); + $part->setContents(Horde_String::wrap($kolab_text, 76, "\r\n", 'UTF-8')); + $part->setCharset('UTF-8'); $part->setTransferEncoding('quoted-printable'); $mime_message->addPart($part); diff --git a/framework/Kolab_Storage/test/Horde/Kolab/Storage/FolderTest.php b/framework/Kolab_Storage/test/Horde/Kolab/Storage/FolderTest.php index 2e24a985a..b757e78c5 100644 --- a/framework/Kolab_Storage/test/Horde/Kolab/Storage/FolderTest.php +++ b/framework/Kolab_Storage/test/Horde/Kolab/Storage/FolderTest.php @@ -88,7 +88,7 @@ class Horde_Kolab_Storage_FolderTest extends PHPUnit_Framework_TestCase $folder = new Horde_Kolab_Storage_Folder_Base('INBOX/Contacts'); $folder->restore($storage, $connection); $folder->setName('TestAÖÜ'); - $this->assertEquals(Horde_String::convertCharset('INBOX/TestAÖÜ', $GLOBALS['registry']->getCharset(), 'UTF7-IMAP'), $folder->new_name); + $this->assertEquals(Horde_String::convertCharset('INBOX/TestAÖÜ', 'UTF-8', 'UTF7-IMAP'), $folder->new_name); } /** diff --git a/framework/Model/lib/Horde/Form/Renderer/Xhtml.php b/framework/Model/lib/Horde/Form/Renderer/Xhtml.php index 39443239b..f3bf168ec 100644 --- a/framework/Model/lib/Horde/Form/Renderer/Xhtml.php +++ b/framework/Model/lib/Horde/Form/Renderer/Xhtml.php @@ -131,7 +131,7 @@ if (document.getElementById(%1$s)){ } } echo ''; } diff --git a/framework/Model/lib/Horde/Form/VarRenderer/Xhtml.php b/framework/Model/lib/Horde/Form/VarRenderer/Xhtml.php index 081092961..5f7ea305a 100644 --- a/framework/Model/lib/Horde/Form/VarRenderer/Xhtml.php +++ b/framework/Model/lib/Horde/Form/VarRenderer/Xhtml.php @@ -91,7 +91,7 @@ class Horde_Form_VarRenderer_Xhtml extends Horde_Form_VarRenderer . 'id="%2$s" value="%3$s"%4$s%5$s%6$s />', ($var->isDisabled() ? ' form-input-disabled" ' : ''), $var->getVarName(), - htmlspecialchars($var->getValue($vars), ENT_QUOTES, $GLOBALS['registry']->getCharset()), + htmlspecialchars($var->getValue($vars), ENT_QUOTES, 'UTF-8'), ($var->isDisabled() ? ' disabled="disabled" ' : ''), ($var->type->maxlength ? ' maxlength="' . $var->type->maxlength . '"' : ''), $this->_getActionScripts($form, $var) @@ -113,7 +113,7 @@ class Horde_Form_VarRenderer_Xhtml extends Horde_Form_VarRenderer return sprintf( '', $var->getVarName(), - htmlspecialchars($var->getValue($vars), ENT_QUOTES, $GLOBALS['registry']->getCharset()), + htmlspecialchars($var->getValue($vars), ENT_QUOTES, 'UTF-8'), ($var->isDisabled() ? ' disabled="disabled" ' : ''), $this->_getActionScripts($form, $var) ); @@ -128,7 +128,7 @@ class Horde_Form_VarRenderer_Xhtml extends Horde_Form_VarRenderer { return sprintf(' ', $var->getVarName(), - htmlspecialchars($var->getValue($vars), ENT_QUOTES, $GLOBALS['registry']->getCharset()), + htmlspecialchars($var->getValue($vars), ENT_QUOTES, 'UTF-8'), $var->isDisabled() ? ' disabled="disabled" ' : '', $this->_getActionScripts($form, $var) ); @@ -459,7 +459,7 @@ class Horde_Form_VarRenderer_Xhtml extends Horde_Form_VarRenderer $prompt = $var->type->prompt; $htmlchars = $var->getOption('htmlchars'); if ($prompt) { - $prompt = ''; + $prompt = ''; } return sprintf(' ', $var->getVarName(), @@ -488,7 +488,7 @@ class Horde_Form_VarRenderer_Xhtml extends Horde_Form_VarRenderer /* Hidden tag to store the current first level. */ $html = sprintf(' ', $varname, - htmlspecialchars($selected['1'], ENT_QUOTES, $GLOBALS['registry']->getCharset())); + htmlspecialchars($selected['1'], ENT_QUOTES, 'UTF-8')); /* First level. */ $values_1 = Horde_Array::valuesToKeys(array_keys($values)); @@ -497,7 +497,7 @@ class Horde_Form_VarRenderer_Xhtml extends Horde_Form_VarRenderer 'if (this.value) { document.' . $form->getName() . '.formname.value=\'\';' . 'document.' . $form->getName() . '.submit() }', ($var->hasAction() ? ' ' . $this->_genActionScript($form, $var->_action, $varname) : '')); if (!empty($prompts)) { - $html .= ''; + $html .= ''; } $html .= $this->_selectOptions($values_1, $selected['1']); $html .= ' '; @@ -507,7 +507,7 @@ class Horde_Form_VarRenderer_Xhtml extends Horde_Form_VarRenderer $varname, ($var->hasAction() ? ' ' . $this->_genActionScript($form, $var->_action, $varname) : '')); if (!empty($prompts)) { - $html .= ''; + $html .= ''; } $values_2 = array(); if (!empty($selected['1'])) { @@ -779,7 +779,7 @@ EOT; function _renderVarDisplayDefault($form, $var, $vars) { return nl2br(htmlspecialchars($var->getValue($vars), ENT_QUOTES, - $GLOBALS['registry']->getCharset())); + 'UTF-8')); } function _renderVarDisplay_html($form, $var, $vars) @@ -823,7 +823,7 @@ EOT; return Horde::link($mail_link, $email_val) . htmlspecialchars($display_email) . ''; } else { - return nl2br(htmlspecialchars($display_email, ENT_QUOTES, $GLOBALS['registry']->getCharset())); + return nl2br(htmlspecialchars($display_email, ENT_QUOTES, 'UTF-8')); } } @@ -854,7 +854,7 @@ EOT; if (count($values) == 0) { return _("No values"); } elseif (isset($values[$value]) && $value != '') { - return htmlspecialchars($values[$value], ENT_QUOTES, $GLOBALS['registry']->getCharset()); + return htmlspecialchars($values[$value], ENT_QUOTES, 'UTF-8'); } } @@ -864,7 +864,7 @@ EOT; if (count($values) == 0) { return _("No values"); } elseif (isset($values[$var->getValue($vars)])) { - return htmlspecialchars($values[$var->getValue($vars)], ENT_QUOTES, $GLOBALS['registry']->getCharset()); + return htmlspecialchars($values[$var->getValue($vars)], ENT_QUOTES, 'UTF-8'); } } @@ -881,7 +881,7 @@ EOT; $display[] = $name; } } - return htmlspecialchars(implode(', ', $display), ENT_QUOTES, $GLOBALS['registry']->getCharset()); + return htmlspecialchars(implode(', ', $display), ENT_QUOTES, 'UTF-8'); } } @@ -898,7 +898,7 @@ EOT; $display[] = $name; } } - return htmlspecialchars(implode(', ', $display), ENT_QUOTES, $GLOBALS['registry']->getCharset()); + return htmlspecialchars(implode(', ', $display), ENT_QUOTES, 'UTF-8'); } } @@ -1069,7 +1069,7 @@ EOT; } } - $html = nl2br(htmlspecialchars($var->getValue($vars), ENT_QUOTES, $GLOBALS['registry']->getCharset())); + $html = nl2br(htmlspecialchars($var->getValue($vars), ENT_QUOTES, 'UTF-8')); if (!empty($mapurl)) { $html .= '  ' . Horde::link(Horde::externalUrl($mapurl), $desc, null, '_blank') . Horde::img($icon, $desc) . ''; } @@ -1107,7 +1107,7 @@ EOT; function _renderVarDisplay_invalid($form, $var, $vars) { return '

' - . htmlspecialchars($var->type->message, ENT_QUOTES, $GLOBALS['registry']->getCharset()) + . htmlspecialchars($var->type->message, ENT_QUOTES, 'UTF-8') . '

'; } @@ -1226,7 +1226,7 @@ EOT; $selected = ''; } $result .= ' \n"; @@ -1246,7 +1246,7 @@ EOT; $selected = ''; } $result .= " \n"; } diff --git a/framework/Rampage/scripts/Horde/Rampage/rampage.php b/framework/Rampage/scripts/Horde/Rampage/rampage.php index 8d850f03b..86fa6e328 100644 --- a/framework/Rampage/scripts/Horde/Rampage/rampage.php +++ b/framework/Rampage/scripts/Horde/Rampage/rampage.php @@ -1214,7 +1214,7 @@ function field_get_quoted($field) case 'mediumtext': case 'longblob': case 'longtext': - return "Horde_String::convertCharset(\$this->_db->quote(\$zitem['$n']), $GLOBALS['registry']->getCharset(), \$this->_params['charset'])"; + return "Horde_String::convertCharset(\$this->_db->quote(\$zitem['$n']), 'UTF-8', \$this->_params['charset'])"; // Integer types case 'bit': diff --git a/framework/Rpc/lib/Horde/Rpc/Webdav.php b/framework/Rpc/lib/Horde/Rpc/Webdav.php index b41e109af..afad383d3 100644 --- a/framework/Rpc/lib/Horde/Rpc/Webdav.php +++ b/framework/Rpc/lib/Horde/Rpc/Webdav.php @@ -588,7 +588,7 @@ class Horde_Rpc_Webdav extends Horde_Rpc // Handle certain standard properties specially if (in_array('displayname', $properties['DAV:'])) { - $props[] = $this->mkprop('displayname', Horde_String::convertCharset($item['name'], $GLOBALS['registry']->getCharset(), 'UTF-8')); + $props[] = $this->mkprop('displayname', Horde_String::convertCharset($item['name'], 'UTF-8', 'UTF-8')); unset($properties['DAV:']['displayname']); } if (in_array('getlastmodified', $properties['DAV:'])) { diff --git a/framework/Share/lib/Horde/Share/Sql.php b/framework/Share/lib/Horde/Share/Sql.php index 2a2e5ccc2..06f59ed04 100644 --- a/framework/Share/lib/Horde/Share/Sql.php +++ b/framework/Share/lib/Horde/Share/Sql.php @@ -917,7 +917,7 @@ class Horde_Share_Sql extends Horde_Share foreach ($data as $key => $value) { if (substr($key, 0, 9) == 'attribute') { $data[$key] = Horde_String::convertCharset( - $data[$key], $GLOBALS['registry']->getCharset(), $this->_params['charset']); + $data[$key], 'UTF-8', $this->_params['charset']); } } diff --git a/framework/SpellChecker/lib/Horde/SpellChecker/Aspell.php b/framework/SpellChecker/lib/Horde/SpellChecker/Aspell.php index 32c900fc7..5fca5b6e0 100644 --- a/framework/SpellChecker/lib/Horde/SpellChecker/Aspell.php +++ b/framework/SpellChecker/lib/Horde/SpellChecker/Aspell.php @@ -46,7 +46,7 @@ class Horde_SpellChecker_Aspell extends Horde_SpellChecker throw new Horde_Exception('Spellcheck failed. Command line: ' . $this->_cmd()); } - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; // Write to stdin. if ($this->_encoding) { diff --git a/gollem/templates/common-header.inc b/gollem/templates/common-header.inc index b2b617327..eb116777c 100644 --- a/gollem/templates/common-header.inc +++ b/gollem/templates/common-header.inc @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/gollem/templates/javascript_defs.php b/gollem/templates/javascript_defs.php index fa1f02d7c..f93207b13 100644 --- a/gollem/templates/javascript_defs.php +++ b/gollem/templates/javascript_defs.php @@ -1,6 +1,6 @@ getCharset(); +$charset = 'UTF-8'; /* Variables used in core javascript files. */ $var = array( diff --git a/hermes/start.php b/hermes/start.php index 1d99cc156..95d9d3e3b 100644 --- a/hermes/start.php +++ b/hermes/start.php @@ -29,7 +29,7 @@ if ($form->validate($vars)) { } $now = time(); $timers[$now] = array('name' => Horde_String::convertCharset($vars->get('description'), - $GLOBALS['registry']->getCharset(), + 'UTF-8', $prefs->getCharset()), 'time' => $now); $prefs->setValue('running_timers', serialize($timers), false); diff --git a/hermes/templates/common-header.inc b/hermes/templates/common-header.inc index b29454993..73b60036c 100644 --- a/hermes/templates/common-header.inc +++ b/hermes/templates/common-header.inc @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/horde/admin/config/config.php b/horde/admin/config/config.php index dafcb8145..c3a055bd8 100644 --- a/horde/admin/config/config.php +++ b/horde/admin/config/config.php @@ -55,7 +55,7 @@ if (Horde_Util::getFormData('submitbutton') == _("Revert Configuration")) { } if ($fp = @fopen($path . '/conf.php', 'w')) { /* Can write, so output to file. */ - fwrite($fp, Horde_String::convertCharset($php, $GLOBALS['registry']->getCharset(), 'iso-8859-1')); + fwrite($fp, Horde_String::convertCharset($php, 'UTF-8', 'iso-8859-1')); fclose($fp); $notification->push(sprintf(_("Successfully wrote %s"), Horde_Util::realPath($path . '/conf.php')), 'horde.success'); $registry->clearCache(); diff --git a/horde/admin/config/scripts.php b/horde/admin/config/scripts.php index b09777f03..b4c4ed5ab 100644 --- a/horde/admin/config/scripts.php +++ b/horde/admin/config/scripts.php @@ -60,7 +60,7 @@ if ($setup == 'conf' && $type == 'php') { $data .= Horde_String::convertCharset(str_replace(array('\\', '\''), array('\\\\', '\\\''), $php), - $GLOBALS['registry']->getCharset(), 'iso-8859-1'); + 'UTF-8', 'iso-8859-1'); $data .= '\');' . "\n"; $data .= ' fclose($fp);' . "\n"; $data .= ' echo \'' . sprintf('Saved %s configuration.', $app) . '\' . "\n";' . "\n"; diff --git a/horde/admin/sqlshell.php b/horde/admin/sqlshell.php index 2beb4cc03..65cbf9b2f 100644 --- a/horde/admin/sqlshell.php +++ b/horde/admin/sqlshell.php @@ -44,7 +44,7 @@ if (Horde_Util::getFormData('list-tables')) { } // Parse out the query results. - $result = $db->execute(Horde_String::convertCharset($command, $GLOBALS['registry']->getCharset(), $conf['sql']['charset'])); + $result = $db->execute(Horde_String::convertCharset($command, 'UTF-8', $conf['sql']['charset'])); } if (isset($result)) { diff --git a/horde/config/hooks.php.dist b/horde/config/hooks.php.dist index 4f1c09e37..cca20f658 100644 --- a/horde/config/hooks.php.dist +++ b/horde/config/hooks.php.dist @@ -288,7 +288,7 @@ class Horde_Hooks // $ldapPort = '389'; // $searchBase = 'ou=people,o=example.com'; // $ldapcharset = 'utf-8'; -// $outputcharset = $GLOBALS['registry']->getCharset(); +// $outputcharset = 'UTF-8'; // // $ds = @ldap_connect($ldapServer, $ldapPort); // @@ -582,7 +582,7 @@ class Horde_Hooks // $fields = $values = array(); // foreach ($extra as $field => $value) { // $fields[] = 'object_' . Horde_String::lower($field); -// $values[] = $db->quote(Horde_String::convertCharset($value, $GLOBALS['registry']->getCharset(), $GLOBALS['conf']['sql']['charset'])); +// $values[] = $db->quote(Horde_String::convertCharset($value, 'UTF-8', $GLOBALS['conf']['sql']['charset'])); // } // $fields[] = 'object_id'; // $values[] = $db->quote($userId); diff --git a/horde/lib/Block/twitter_timeline.php b/horde/lib/Block/twitter_timeline.php index 3c2695f69..0c4ff095c 100644 --- a/horde/lib/Block/twitter_timeline.php +++ b/horde/lib/Block/twitter_timeline.php @@ -158,7 +158,7 @@ EOT; Horde::addInlineScript($script, 'dom'); /* Get the user's most recent tweet */ - $latestStatus = htmlspecialchars($this->_profile->status->text, ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $latestStatus = htmlspecialchars($this->_profile->status->text, ENT_COMPAT, 'UTF-8'); /* Build the UI */ $html = '
' diff --git a/horde/scripts/upgrades/convert_datatree_groups_to_sql.php b/horde/scripts/upgrades/convert_datatree_groups_to_sql.php index cc408b27e..0ed5fe5c1 100755 --- a/horde/scripts/upgrades/convert_datatree_groups_to_sql.php +++ b/horde/scripts/upgrades/convert_datatree_groups_to_sql.php @@ -40,9 +40,9 @@ foreach ($g->listGroups(true) as $id => $name) { $parents = implode(':', array_keys($parents)); $params = array($id, - Horde_String::convertCharset($object->name, $GLOBALS['registry']->getCharset(), $conf['sql']['charset']), - Horde_String::convertCharset($parents, $GLOBALS['registry']->getCharset(), $conf['sql']['charset']), - Horde_String::convertCharset($object->get('email'), $GLOBALS['registry']->getCharset(), $conf['sql']['charset']), + Horde_String::convertCharset($object->name, 'UTF-8', $conf['sql']['charset']), + Horde_String::convertCharset($parents, 'UTF-8', $conf['sql']['charset']), + Horde_String::convertCharset($object->get('email'), 'UTF-8', $conf['sql']['charset']), ); $result = $db->query($group_query, $params); if (is_a($result, 'PEAR_Error')) { diff --git a/horde/services/portal/index.php b/horde/services/portal/index.php index e2eb0c7ef..7de0e801c 100644 --- a/horde/services/portal/index.php +++ b/horde/services/portal/index.php @@ -29,7 +29,7 @@ if (!count($layout_pref)) { // If we're serving a request to the JS update client, just return the blocks // updated HTML content. if (Horde_Util::getFormData('httpclient')) { - header('Content-Type: text/html; charset=' . $GLOBALS['registry']->getCharset()); + header('Content-Type: text/html; charset=' . 'UTF-8'); $row = Horde_Util::getFormData('row'); $col = Horde_Util::getFormData('col'); if (!is_null($row) && !is_null($col) && !empty($layout_pref[$row][$col])) { diff --git a/horde/services/problem.php b/horde/services/problem.php index 2a822fd2f..a8229389b 100644 --- a/horde/services/problem.php +++ b/horde/services/problem.php @@ -108,7 +108,7 @@ case 'send_problem_report': 'body' => $body, 'to' => $conf['problems']['email'], 'from' => $email, - 'charset' => $GLOBALS['registry']->getCharset())); + 'charset' => 'UTF-8')); $mail->addHeader('Sender', 'horde-problem@' . $conf['problems']['maildomain']); /* Add attachment. */ diff --git a/horde/services/resetpassword.php b/horde/services/resetpassword.php index 93e92573b..374cc1fa5 100644 --- a/horde/services/resetpassword.php +++ b/horde/services/resetpassword.php @@ -76,7 +76,7 @@ if ($can_validate && $form->validate($vars)) { $password), 'to' => $email, 'from' => $email, - 'charset' => $GLOBALS['registry']->getCharset())); + 'charset' => 'UTF-8')); try { $mail->send($GLOBALS['injector']->getInstance('Horde_Mail')); $notification->push(_("Your password has been reset, check your email and log in with your new password."), 'horde.success'); diff --git a/horde/services/sidebar.php b/horde/services/sidebar.php index 1a148f74e..30d22dd69 100644 --- a/horde/services/sidebar.php +++ b/horde/services/sidebar.php @@ -31,7 +31,7 @@ if (!Horde_Util::getFormData('ajaxui') && $ajax_url = Horde::getServiceLink('ajax', 'horde'); $ajax_url->pathInfo = 'sidebarUpdate'; - $charset = $registry->getCharset(); + $charset = 'UTF-8'; $rtl = intval(isset($registry->nlsconfig['rtl'][$language])); $show_sidebar = !isset($_COOKIE['horde_sidebar_expanded']) || $_COOKIE['horde_sidebar_expanded']; $width = intval($prefs->getValue('sidebar_width')); diff --git a/horde/services/twitter.php b/horde/services/twitter.php index acd61b956..854907e98 100644 --- a/horde/services/twitter.php +++ b/horde/services/twitter.php @@ -97,8 +97,8 @@ case 'getPage': /* These are all referencing the *original* tweet */ $view->profileLink = Horde::externalUrl('http://twitter.com/' . htmlspecialchars($tweetObj->user->screen_name), true); $view->profileImg = $tweetObj->user->profile_image_url; - $view->authorName = htmlspecialchars($tweetObj->user->screen_name, ENT_COMPAT, $GLOBALS['registry']->getCharset()); - $view->authorFullname = htmlspecialchars($tweetObj->user->name, ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $view->authorName = htmlspecialchars($tweetObj->user->screen_name, ENT_COMPAT, 'UTF-8'); + $view->authorFullname = htmlspecialchars($tweetObj->user->name, ENT_COMPAT, 'UTF-8'); $view->createdAt = $tweetObj->created_at; $view->clientText = $filter->filter($tweet->source, 'xss'); $view->tweet = $tweet; diff --git a/horde/templates/admin/groups/edit.inc b/horde/templates/admin/groups/edit.inc index d91f3c172..2e555cdff 100644 --- a/horde/templates/admin/groups/edit.inc +++ b/horde/templates/admin/groups/edit.inc @@ -60,7 +60,7 @@ -getShortName()), ENT_COMPAT, $GLOBALS['registry']->getCharset()) ?>" /> +getShortName()), ENT_COMPAT, 'UTF-8') ?>" />


diff --git a/horde/templates/common-header.inc b/horde/templates/common-header.inc index afb74f670..cf665bfcb 100644 --- a/horde/templates/common-header.inc +++ b/horde/templates/common-header.inc @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/hylax/templates/common-header.inc b/hylax/templates/common-header.inc index 348944ae2..93ea201c8 100644 --- a/hylax/templates/common-header.inc +++ b/hylax/templates/common-header.inc @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/imp/attachment.php b/imp/attachment.php index 35a2d674f..72ba93b70 100644 --- a/imp/attachment.php +++ b/imp/attachment.php @@ -99,7 +99,7 @@ if ($conf['compose']['link_attachments_notify']) { $msg = new Horde_Mime_Part(); $msg->setType('text/plain'); - $msg->setCharset($registry->getCharset()); + $msg->setCharset('UTF-8'); $d_url = new Horde_Url(Horde::selfUrl(true, false, true)); $msg->setContents(Horde_String::wrap(sprintf(_("Your linked attachment has been downloaded by at least one user.\n\nAttachment name: %s\nAttachment date: %s\n\nClick on the following link to permanently delete the attachment:\n%s"), $file_name, date('r', $time_stamp), $d_url->add('d', $id)))); diff --git a/imp/compose-mimp.php b/imp/compose-mimp.php index 718b911d4..a36aa0cae 100644 --- a/imp/compose-mimp.php +++ b/imp/compose-mimp.php @@ -257,7 +257,7 @@ case _("Send"): switch ($vars->a) { case _("Save Draft"): try { - $notification->push($imp_compose->saveDraft($header, $message, $registry->getCharset(), false), 'horde.success'); + $notification->push($imp_compose->saveDraft($header, $message, 'UTF-8', false), 'horde.success'); if ($prefs->getValue('close_draft')) { $imp_compose->destroy('save_draft'); require IMP_BASE . '/mailbox-mimp.php'; diff --git a/imp/compose.php b/imp/compose.php index a82de6e84..a1cbee65f 100644 --- a/imp/compose.php +++ b/imp/compose.php @@ -202,8 +202,8 @@ case 'mailto': $header['to'] = $imp_headers->getValue('to'); } if (empty($header['to'])) { - ($header['to'] = Horde_Mime_Address::addrArray2String($imp_headers->getOb('from'), array('charset' => $registry->getCharset()))) || - ($header['to'] = Horde_Mime_Address::addrArray2String($imp_headers->getOb('reply-to'), array('charset' => $registry->getCharset()))); + ($header['to'] = Horde_Mime_Address::addrArray2String($imp_headers->getOb('from'), array('charset' => 'UTF-8'))) || + ($header['to'] = Horde_Mime_Address::addrArray2String($imp_headers->getOb('reply-to'), array('charset' => 'UTF-8'))); } break; @@ -367,7 +367,7 @@ case 'send_message': if (in_array($vars->actionID, array('auto_save_draft', 'save_draft'))) { if (!$readonly_drafts) { try { - $result = $imp_compose->saveDraft($header, $message, $registry->getCharset(), $rtemode); + $result = $imp_compose->saveDraft($header, $message, 'UTF-8', $rtemode); /* Closing draft if requested by preferences. */ if ($vars->actionID == 'save_draft') { @@ -618,7 +618,7 @@ if (!is_null($oldrtemode) && ($oldrtemode != $rtemode)) { /* If this is the first page load for this compose item, add auto BCC * addresses. */ if (!$vars->compose_formToken && ($vars->actionID != 'draft')) { - $header['bcc'] = Horde_Mime_Address::addrArray2String($identity->getBccAddresses(), array('charset' => $registry->getCharset())); + $header['bcc'] = Horde_Mime_Address::addrArray2String($identity->getBccAddresses(), array('charset' => 'UTF-8')); } foreach (array('to', 'cc', 'bcc', 'subject') as $val) { diff --git a/imp/config/hooks.php.dist b/imp/config/hooks.php.dist index e2520ec61..21aa1748e 100644 --- a/imp/config/hooks.php.dist +++ b/imp/config/hooks.php.dist @@ -197,7 +197,7 @@ class IMP_Hooks // public function pre_sent($message, $headers) // { // // Example: Add custom headers to outgoing message. -// $charset = $GLOBALS['registry']->getCharset(); +// $charset = 'UTF-8'; // $custom_hdrs = array(); // $hdr_charset = $message->getHeaderCharset(); // @@ -287,7 +287,7 @@ class IMP_Hooks // // the same domain. // $flags = array(); // -// $from_ob = Horde_Mime_Address::getAddressesFromObject($data['envelope']['from'], array('charset' => $GLOBALS['registry']->getCharset())); +// $from_ob = Horde_Mime_Address::getAddressesFromObject($data['envelope']['from'], array('charset' => 'UTF-8')); // if (!empty($from_ob) && // (strcasecmp($from_ob[0]['host'], 'example.com') === 0)) { // /* The '$indomain' flag in this example must have already been diff --git a/imp/contacts.php b/imp/contacts.php index 1ea317069..5770865d3 100644 --- a/imp/contacts.php +++ b/imp/contacts.php @@ -65,7 +65,7 @@ if ($vars->searched || $prefs->getValue('display_contact')) { $selected_addresses = array(); foreach (explode('|', $vars->sa) as $addr) { if (strlen(trim($addr))) { - $selected_addresses[] = @htmlspecialchars($addr, ENT_QUOTES, $registry->getCharset()); + $selected_addresses[] = @htmlspecialchars($addr, ENT_QUOTES, 'UTF-8'); } } @@ -92,11 +92,11 @@ $a_list = array(); foreach ($addresses as $addr) { if (!empty($addr['email'])) { if (strpos($addr['email'], ',') !== false) { - $a_list[] = @htmlspecialchars(Horde_Mime_Address::encode($addr['name'], 'personal') . ': ' . $addr['email'] . ';', ENT_QUOTES, $registry->getCharset()); + $a_list[] = @htmlspecialchars(Horde_Mime_Address::encode($addr['name'], 'personal') . ': ' . $addr['email'] . ';', ENT_QUOTES, 'UTF-8'); } else { $mbox_host = explode('@', $addr['email']); if (isset($mbox_host[1])) { - $a_list[] = @htmlspecialchars(Horde_Mime_Address::writeAddress($mbox_host[0], $mbox_host[1], $addr['name']), ENT_QUOTES, $registry->getCharset()); + $a_list[] = @htmlspecialchars(Horde_Mime_Address::writeAddress($mbox_host[0], $mbox_host[1], $addr['name']), ENT_QUOTES, 'UTF-8'); } } } diff --git a/imp/folders.php b/imp/folders.php index 412d585d2..fe9deda07 100644 --- a/imp/folders.php +++ b/imp/folders.php @@ -30,7 +30,7 @@ if (!$conf['user']['allow_folders']) { $subscribe = $prefs->getValue('subscribe'); $showAll = (!$subscribe || $_SESSION['imp']['showunsub']); -$charset = $registry->getCharset(); +$charset = 'UTF-8'; $vars = Horde_Variables::getDefaultVariables(); /* Get the base URL for this page. */ diff --git a/imp/lib/Ajax/Application.php b/imp/lib/Ajax/Application.php index ab4a67512..870a344d6 100644 --- a/imp/lib/Ajax/Application.php +++ b/imp/lib/Ajax/Application.php @@ -72,7 +72,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application $imptree = $GLOBALS['injector']->getInstance('IMP_Imap_Tree'); $imptree->eltDiffStart(); - $new = Horde_String::convertCharset($this->_vars->mbox, $GLOBALS['registry']->getCharset(), 'UTF7-IMAP'); + $new = Horde_String::convertCharset($this->_vars->mbox, 'UTF-8', 'UTF7-IMAP'); try { $new = $imptree->createMailboxName($this->_vars->parent, $new); @@ -165,7 +165,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application $result = false; try { - $new = Horde_String::convertCharset($imptree->createMailboxName($this->_vars->new_parent, $this->_vars->new_name), $GLOBALS['registry']->getCharset(), 'UTF7-IMAP'); + $new = Horde_String::convertCharset($imptree->createMailboxName($this->_vars->new_parent, $this->_vars->new_name), 'UTF-8', 'UTF7-IMAP'); if (($this->_vars->old_name != $new) && $GLOBALS['injector']->getInstance('IMP_Folder')->rename($this->_vars->old_name, $new)) { @@ -1847,7 +1847,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application } try { - $res = $imp_compose->saveDraft($headers, $this->_vars->message, $GLOBALS['registry']->getCharset(), $this->_vars->html); + $res = $imp_compose->saveDraft($headers, $this->_vars->message, 'UTF-8', $this->_vars->html); if ($this->_action == 'autoSaveDraft') { $GLOBALS['notification']->push(_("Draft automatically saved."), 'horde.message'); } else { diff --git a/imp/lib/Application.php b/imp/lib/Application.php index 7443a13f2..26b81b4c3 100644 --- a/imp/lib/Application.php +++ b/imp/lib/Application.php @@ -250,7 +250,7 @@ class IMP_Application extends Horde_Registry_Application $menu->addArray(array( 'class' => '__noselection', 'icon' => 'empty_trash.png', - 'onclick' => 'return window.confirm(' . Horde_Serialize::serialize(_("Are you sure you wish to empty your trash folder?"), Horde_Serialize::JSON, $registry->getCharset()) . ')', + 'onclick' => 'return window.confirm(' . Horde_Serialize::serialize(_("Are you sure you wish to empty your trash folder?"), Horde_Serialize::JSON, 'UTF-8') . ')', 'text' => _("Empty _Trash"), 'url' => IMP::generateIMPUrl($menu_mailbox_url, $trash_folder)->add(array('actionID' => 'empty_mailbox', 'mailbox_token' => Horde::getRequestToken('imp.mailbox'))) )); @@ -263,7 +263,7 @@ class IMP_Application extends Horde_Registry_Application $menu->addArray(array( 'class' => '__noselection', 'icon' => 'empty_spam.png', - 'onclick' => 'return window.confirm(' . Horde_Serialize::serialize(_("Are you sure you wish to empty your trash folder?"), Horde_Serialize::JSON, $registry->getCharset()) . ')', + 'onclick' => 'return window.confirm(' . Horde_Serialize::serialize(_("Are you sure you wish to empty your trash folder?"), Horde_Serialize::JSON, 'UTF-8') . ')', 'text' => _("Empty _Spam"), 'url' => IMP::generateIMPUrl($menu_mailbox_url, IMP::folderPref($spam_folder, true))->add(array('actionID' => 'empty_mailbox', 'mailbox_token' => Horde::getRequestToken('imp.mailbox'))) )); diff --git a/imp/lib/Block/Newmail.php b/imp/lib/Block/Newmail.php index f70521feb..83a209838 100644 --- a/imp/lib/Block/Newmail.php +++ b/imp/lib/Block/Newmail.php @@ -32,7 +32,7 @@ class IMP_Block_Newmail extends Horde_Block if (empty($indices)) { $html .= '
'; } else { - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; $imp_ui = new IMP_Ui_Mailbox('INBOX'); $shown = empty($this->_params['msgs_shown']) ? 3 diff --git a/imp/lib/Compose.php b/imp/lib/Compose.php index 1f302826e..b1576517a 100644 --- a/imp/lib/Compose.php +++ b/imp/lib/Compose.php @@ -382,7 +382,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator $identity_id = $identity->getMatchingIdentity($fromaddr); } - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; $header = array( 'to' => Horde_Mime_Address::addrArray2String($headers->getOb('to'), array('charset' => $charset)), 'cc' => Horde_Mime_Address::addrArray2String($headers->getOb('cc'), array('charset' => $charset)), @@ -556,7 +556,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator $mdn->addMdnRequestHeaders($barefrom); } - $browser_charset = $GLOBALS['registry']->getCharset(); + $browser_charset = 'UTF-8'; $headers->addHeader('From', Horde_String::convertCharset($header['from'], $browser_charset, $charset)); @@ -687,7 +687,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator } try { - $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->append(Horde_String::convertCharset($opts['sent_folder'], $GLOBALS['registry']->getCharset(), 'UTF-8'), array(array('data' => $fcc, 'flags' => $flags))); + $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->append(Horde_String::convertCharset($opts['sent_folder'], 'UTF-8', 'UTF-8'), array(array('data' => $fcc, 'flags' => $flags))); } catch (Horde_Imap_Client_Exception $e) { $notification->push(sprintf(_("Message sent successfully, but not saved to %s"), IMP::displayFolder($opts['sent_folder']))); $sent_saved = false; @@ -787,7 +787,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator try { $error = Horde::callHook('perms_denied', array('imp:max_timelimit')); } catch (Horde_Exception_HookNotSet $e) { - $error = @htmlspecialchars(sprintf(_("You are not allowed to send messages to more than %d recipients within %d hours."), $timelimit, $GLOBALS['conf']['sentmail']['params']['limit_period']), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $error = @htmlspecialchars(sprintf(_("You are not allowed to send messages to more than %d recipients within %d hours."), $timelimit, $GLOBALS['conf']['sentmail']['params']['limit_period']), ENT_COMPAT, 'UTF-8'); } throw new IMP_Compose_Exception($error); } @@ -802,7 +802,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator /* Properly encode the addresses we're sending to. */ try { - $email = Horde_Mime::encodeAddress($email, is_null($message) ? $GLOBALS['registry']->getCharset() : $message->getHeaderCharset(), $_SESSION['imp']['maildomain']); + $email = Horde_Mime::encodeAddress($email, is_null($message) ? 'UTF-8' : $message->getHeaderCharset(), $_SESSION['imp']['maildomain']); /* Validate the recipient addresses. */ Horde_Mime_Address::parseAddressList($email, array( @@ -837,7 +837,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator } try { - $r_array = Horde_Mime::encodeAddress($recipients, $GLOBALS['registry']->getCharset(), $_SESSION['imp']['maildomain']); + $r_array = Horde_Mime::encodeAddress($recipients, 'UTF-8', $_SESSION['imp']['maildomain']); $r_array = Horde_Mime_Address::parseAddressList($r_array, array('validate' => true)); } catch (Horde_Mime_Exception $e) {} @@ -972,7 +972,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator try { $message = Horde::callHook('perms_denied', array('imp:max_recipients')); } catch (Horde_Exception_HookNotSet $e) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to send messages to more than %d recipients."), $max_recipients), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to send messages to more than %d recipients."), $max_recipients), ENT_COMPAT, 'UTF-8'); } throw new IMP_Compose_Exception($message); } @@ -996,9 +996,9 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator // Convert IDN hosts to ASCII. if (function_exists('idn_to_ascii')) { $old_error = error_reporting(0); - $host = idn_to_ascii(Horde_String::convertCharset($host, $GLOBALS['registry']->getCharset(), 'UTF-8')); + $host = idn_to_ascii(Horde_String::convertCharset($host, 'UTF-8', 'UTF-8')); error_reporting($old_error); - } elseif (Horde_Mime::is8bit($ob['mailbox'], $GLOBALS['registry']->getCharset())) { + } elseif (Horde_Mime::is8bit($ob['mailbox'], 'UTF-8')) { throw new IMP_Compose_Exception(sprintf(_("Invalid character in e-mail address: %s."), $email)); } @@ -1033,7 +1033,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator protected function _createMimeMessage($to, $body, $charset, $options = array()) { - $nls_charset = $GLOBALS['registry']->getCharset(); + $nls_charset = 'UTF-8'; $body = Horde_String::convertCharset($body, $nls_charset, $charset); if (!empty($options['html'])) { @@ -1293,7 +1293,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator 'subject' => '' ); - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; $h = $contents->getHeaderOb(); $match_identity = $this->_getMatchingIdentity($h); $reply_type = 'reply'; @@ -1487,7 +1487,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator ); } - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; $h = $contents->getHeaderOb(); $from = Horde_Mime_Address::addrArray2String($h->getOb('from'), array('charset' => $charset)); @@ -1655,7 +1655,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator $h = $contents->getHeaderOb(); $from = Horde_Mime_Address::addrArray2String($h->getOb('from'), array( - 'charset' => $GLOBALS['registry']->getCharset() + 'charset' => 'UTF-8' )); $msg_pre = "\n----- " . @@ -1733,10 +1733,10 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator $resent_headers->addHeader('Resent-To', $recip['header']['to']); $resent_headers->addHeader('Resent-Message-ID', Horde_Mime::generateMessageId()); - $header_text = trim($resent_headers->toString(array('encode' => $GLOBALS['registry']->getCharset()))) . "\n" . trim($contents->getHeaderOb(false)); + $header_text = trim($resent_headers->toString(array('encode' => 'UTF-8'))) . "\n" . trim($contents->getHeaderOb(false)); $to = $this->_prepSendMessage($recipients); - $hdr_array = $headers->toArray(array('charset' => $GLOBALS['registry']->getCharset())); + $hdr_array = $headers->toArray(array('charset' => 'UTF-8')); $hdr_array['_raw'] = $header_text; try { @@ -1800,7 +1800,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator $headerob = $contents->getHeaderOb(); $part = new Horde_Mime_Part(); - $part->setCharset($GLOBALS['registry']->getCharset()); + $part->setCharset('UTF-8'); $part->setType('message/rfc822'); $part->setName(_("Forwarded Message")); $part->setContents($contents->fullMessageText(array('stream' => true))); @@ -1830,7 +1830,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator */ protected function _getMsgHeaders($h) { - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; $tmp = array(); if (($ob = $h->getValue('date'))) { @@ -1912,12 +1912,12 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator if ($part->getPrimaryType() == 'text') { if ($analyzetype = Horde_Mime_Magic::analyzeFile($tempfile, empty($conf['mime']['magic_db']) ? null : $conf['mime']['magic_db'], array('nostrip' => true))) { $analyzetype = Horde_Mime::decodeParam('Content-Type', $analyzetype); - $part->setCharset(isset($analyzetype['params']['charset']) ? $analyzetype['params']['charset'] : $GLOBALS['registry']->getCharset()); + $part->setCharset(isset($analyzetype['params']['charset']) ? $analyzetype['params']['charset'] : 'UTF-8'); } else { - $part->setCharset($GLOBALS['registry']->getCharset()); + $part->setCharset('UTF-8'); } } else { - $part->setHeaderCharset($GLOBALS['registry']->getCharset()); + $part->setHeaderCharset('UTF-8'); } $part->setName($filename); $part->setBytes($_FILES[$name]['size']); @@ -2373,14 +2373,14 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator $fullpath = sprintf('%s/%s/%d', self::VFS_LINK_ATTACH_PATH, $auth, $ts); $charset = $part->getCharset(); - $trailer = Horde_String::convertCharset(_("Attachments"), $GLOBALS['registry']->getCharset(), $charset); + $trailer = Horde_String::convertCharset(_("Attachments"), 'UTF-8', $charset); if ($prefs->getValue('delete_attachments_monthly')) { /* Determine the first day of the month in which the current * attachments will be ripe for deletion, then subtract 1 second * to obtain the last day of the previous month. */ $del_time = mktime(0, 0, 0, date('n') + $prefs->getValue('delete_attachments_monthly_keep') + 1, 1, date('Y')) - 1; - $trailer .= Horde_String::convertCharset(' (' . sprintf(_("Links will expire on %s"), strftime('%x', $del_time)) . ')', $GLOBALS['registry']->getCharset(), $charset); + $trailer .= Horde_String::convertCharset(' (' . sprintf(_("Links will expire on %s"), strftime('%x', $del_time)) . ')', 'UTF-8', $charset); } foreach ($this as $att) { @@ -2464,7 +2464,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator $part = $contents->getMIMEPart($body_id); $type = $part->getType(); $part_charset = $part->getCharset(); - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; $msg = Horde_String::convertCharset($part->getContents(), $part_charset, $charset); @@ -2560,7 +2560,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator $part = new Horde_Mime_Part(); $part->setType('text/x-vcard'); - $part->setCharset($GLOBALS['registry']->getCharset()); + $part->setCharset('UTF-8'); $part->setContents($vcard); $part->setName((strlen($name) ? $name : 'vcard') . '.vcf'); $this->_attachVCard = $part; diff --git a/imp/lib/Compose/Stationery.php b/imp/lib/Compose/Stationery.php index 1a4f52c48..30de0508e 100644 --- a/imp/lib/Compose/Stationery.php +++ b/imp/lib/Compose/Stationery.php @@ -34,7 +34,7 @@ class IMP_Compose_Stationery implements ArrayAccess, Countable, Iterator { $slist = @unserialize($GLOBALS['prefs']->getValue('stationery', false)); $this->_stationery = is_array($slist) - ? Horde_String::convertCharset($slist, $GLOBALS['prefs']->getCharset(), $GLOBALS['registry']->getCharset()) + ? Horde_String::convertCharset($slist, $GLOBALS['prefs']->getCharset(), 'UTF-8') : array(); } @@ -59,7 +59,7 @@ class IMP_Compose_Stationery implements ArrayAccess, Countable, Iterator switch ($this[$id]['t']) { case 'html': if (!$html) { - $s_content = $GLOBALS['injector']->getInstance('Horde_Text_Filter')->filter($s_content, 'Html2text', array('charset' => $GLOBALS['registry']->getCharset())); + $s_content = $GLOBALS['injector']->getInstance('Horde_Text_Filter')->filter($s_content, 'Html2text', array('charset' => 'UTF-8')); } break; @@ -84,7 +84,7 @@ class IMP_Compose_Stationery implements ArrayAccess, Countable, Iterator */ protected function _save() { - $GLOBALS['prefs']->setValue('stationery', serialize(Horde_String::convertCharset($this->_stationery, $GLOBALS['registry']->getCharset(), $GLOBALS['prefs']->getCharset())), false); + $GLOBALS['prefs']->setValue('stationery', serialize(Horde_String::convertCharset($this->_stationery, 'UTF-8', $GLOBALS['prefs']->getCharset())), false); } /* ArrayAccess methods. */ diff --git a/imp/lib/Contents.php b/imp/lib/Contents.php index 9131021c4..f6dbffd7b 100644 --- a/imp/lib/Contents.php +++ b/imp/lib/Contents.php @@ -420,7 +420,7 @@ class IMP_Contents 'text' => $status ) ), - 'type' => 'text/html; charset=' . $GLOBALS['registry']->getCharset() + 'type' => 'text/html; charset=' . 'UTF-8' ) ); } @@ -471,7 +471,7 @@ class IMP_Contents /* If this is a text/* part, AND the browser does not support * UTF-8, give the user a link to open the part in a new window * with the correct character set. */ - $default_charset = Horde_String::upper($GLOBALS['registry']->getCharset()); + $default_charset = Horde_String::upper('UTF-8'); if ($default_charset !== 'UTF-8') { $charset_upper = Horde_String::upper($mime_part->getCharset()); if (($charset_upper != 'US-ASCII') && @@ -533,7 +533,7 @@ class IMP_Contents // Retrieve 3x the size of $maxlen of bodytext data. This should // account for any content-encoding & HTML tags. $pmime = $this->getMIMEPart($mimeid, array('length' => $maxlen * 3)); - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; $ptext = Horde_String::convertCharset($pmime->getContents(), $pmime->getCharset(), $charset); @@ -711,7 +711,7 @@ class IMP_Contents (strpos($id, '.') === false)) { if ($mask & self::SUMMARY_STRIP_LINK) { $url = Horde::selfUrl(true)->remove(array('actionID', 'imapid', 'uid'))->add(array('actionID' => 'strip_attachment', 'imapid' => $id, 'uid' => $this->_uid, 'message_token' => Horde::getRequestToken('imp.impcontents'))); - $part['strip'] = Horde::link($url, _("Strip Attachment"), 'deleteImg', null, 'return window.confirm(' . Horde_Serialize::serialize(_("Are you sure you wish to PERMANENTLY delete this attachment?"), Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()) . ')') . ''; + $part['strip'] = Horde::link($url, _("Strip Attachment"), 'deleteImg', null, 'return window.confirm(' . Horde_Serialize::serialize(_("Are you sure you wish to PERMANENTLY delete this attachment?"), Horde_Serialize::JSON, 'UTF-8') . ')') . ''; } else { $part['strip'] = Horde::link('#', _("Strip Attachment"), 'deleteImg stripAtc', null, null, null, null, array('mimeid' => $id)) . ''; } diff --git a/imp/lib/Crypt/Pgp.php b/imp/lib/Crypt/Pgp.php index f860c1567..b014e1a81 100644 --- a/imp/lib/Crypt/Pgp.php +++ b/imp/lib/Crypt/Pgp.php @@ -616,7 +616,7 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp */ public function textWindowOutput($name, $msg) { - $GLOBALS['browser']->downloadHeaders($name, 'text/plain; charset=' . $GLOBALS['registry']->getCharset(), true, strlen($msg)); + $GLOBALS['browser']->downloadHeaders($name, 'text/plain; charset=' . 'UTF-8', true, strlen($msg)); echo $msg; } diff --git a/imp/lib/Crypt/Smime.php b/imp/lib/Crypt/Smime.php index 1cee6b110..944234083 100644 --- a/imp/lib/Crypt/Smime.php +++ b/imp/lib/Crypt/Smime.php @@ -450,7 +450,7 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime */ public function textWindowOutput($name, $msg, $html = false) { - $GLOBALS['browser']->downloadHeaders($name, $html ? 'text/html' : 'text/plain; charset=' . $GLOBALS['registry']->getCharset(), true, strlen($msg)); + $GLOBALS['browser']->downloadHeaders($name, $html ? 'text/html' : 'text/plain; charset=' . 'UTF-8', true, strlen($msg)); echo $msg; } diff --git a/imp/lib/Dimp.php b/imp/lib/Dimp.php index 0eba4f2b1..e3899083d 100644 --- a/imp/lib/Dimp.php +++ b/imp/lib/Dimp.php @@ -170,7 +170,7 @@ class IMP_Dimp static public function returnToDimp($mailbox = '') { print '' . - Horde::wrapInlineScript(array('window.parent.DimpBase.go(' . Horde_Serialize::serialize('folder:' . strval($mailbox), Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()) . ')')) . + Horde::wrapInlineScript(array('window.parent.DimpBase.go(' . Horde_Serialize::serialize('folder:' . strval($mailbox), Horde_Serialize::JSON, 'UTF-8') . ')')) . ''; exit; } diff --git a/imp/lib/Folder.php b/imp/lib/Folder.php index 944cd4f9d..9ca405068 100644 --- a/imp/lib/Folder.php +++ b/imp/lib/Folder.php @@ -114,7 +114,7 @@ class IMP_Folder try { $message = Horde::callHook('perms_denied', array('imp:create_folders')); } catch (Horde_Exception_HookNotSet $e) { - $message = @htmlspecialchars(_("You are not allowed to create folders."), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(_("You are not allowed to create folders."), ENT_COMPAT, 'UTF-8'); } $notification->push($message, 'horde.error', array('content.raw')); return false; @@ -122,7 +122,7 @@ class IMP_Folder try { $message = Horde::callHook('perms_denied', array('imp:max_folders')); } catch (Horde_Exception_HookNotSet $e) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_folders', array('opts' => array('value' => true)))), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_folders', array('opts' => array('value' => true)))), ENT_COMPAT, 'UTF-8'); } $notification->push($message, 'horde.error', array('content.raw')); return false; diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 34b566b18..36280402e 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -138,7 +138,7 @@ class IMP $result = $registry->call('contacts/import', array(array('name' => $newName, 'email' => $newAddress), 'array', $prefs->getValue('add_source'))); - $escapeName = @htmlspecialchars($newName, ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $escapeName = @htmlspecialchars($newName, ENT_COMPAT, 'UTF-8'); try { if ($contact_link = $registry->link('contacts/show', array('uid' => $result, 'source' => $prefs->getValue('add_source')))) { @@ -387,7 +387,7 @@ class IMP stripos($out, $key) === 0) { $len = strlen($key); if ((strlen($out) == $len) || ($out[$len] == $delimiter)) { - $out = substr_replace($out, Horde_String::convertCharset($val, $GLOBALS['registry']->getCharset(), 'UTF7-IMAP'), 0, $len); + $out = substr_replace($out, Horde_String::convertCharset($val, 'UTF-8', 'UTF7-IMAP'), 0, $len); break; } } @@ -1026,7 +1026,7 @@ class IMP static public function formMbox($mbox, $to) { return $to - ? htmlspecialchars(rawurlencode($mbox), ENT_COMPAT, $GLOBALS['registry']->getCharset()) + ? htmlspecialchars(rawurlencode($mbox), ENT_COMPAT, 'UTF-8') : rawurldecode($mbox); } diff --git a/imp/lib/Imap/Flags.php b/imp/lib/Imap/Flags.php index 219d0acf5..510417724 100644 --- a/imp/lib/Imap/Flags.php +++ b/imp/lib/Imap/Flags.php @@ -181,7 +181,7 @@ class IMP_Imap_Flags /* IMAP keywords must conform to RFC 3501 [9] (flag-keyword). Convert * whitespace to underscore. */ - $key = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->stripNonAtomChars(Horde_String::convertCharset(strtr($label, ' ', '_'), $GLOBALS['registry']->getCharset(), 'UTF7-IMAP')); + $key = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->getUtils()->stripNonAtomChars(Horde_String::convertCharset(strtr($label, ' ', '_'), 'UTF-8', 'UTF7-IMAP')); if (!isset($this->_flags[$key])) { $entry = $this->_createEntry($label); diff --git a/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php b/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php index 4c2b8e1dc..ca84d0da0 100644 --- a/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php +++ b/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php @@ -48,7 +48,7 @@ class IMP_LoginTasks_Task_DeleteSentmailMonthly extends Horde_LoginTasks_Task foreach ($imaptree as $k => $v) { foreach ($sent_mail_folders as $folder) { if (preg_match('/^' . str_replace('/', '\/', $folder) . '-([^-]+)-([0-9]{4})$/i', $k, $regs)) { - $folder_array[$k] = Horde_String::convertCharset((is_numeric($regs[1])) ? mktime(0, 0, 0, $regs[1], 1, $regs[2]) : strtotime("$regs[1] 1, $regs[2]"), $GLOBALS['registry']->getCharset(), 'UTF7-IMAP'); + $folder_array[$k] = Horde_String::convertCharset((is_numeric($regs[1])) ? mktime(0, 0, 0, $regs[1], 1, $regs[2]) : strtotime("$regs[1] 1, $regs[2]"), 'UTF-8', 'UTF7-IMAP'); } } } diff --git a/imp/lib/Message.php b/imp/lib/Message.php index 4093d78c1..56e254c13 100644 --- a/imp/lib/Message.php +++ b/imp/lib/Message.php @@ -362,7 +362,7 @@ class IMP_Message /* TODO: When Horde_iCalendar supports setting of charsets * we need to set it there instead of relying on the fact * that both Nag and IMP use the same charset. */ - $body = Horde_String::convertCharset($body, $body_part->getCharset(), $GLOBALS['registry']->getCharset()); + $body = Horde_String::convertCharset($body, $body_part->getCharset(), 'UTF-8'); /* Create a new iCalendar. */ $vCal = new Horde_iCalendar(); @@ -529,7 +529,7 @@ class IMP_Message /* Need to make sure all text is in the correct charset. */ $part_name = $part->getName(true); - $newPart->setCharset($GLOBALS['registry']->getCharset()); + $newPart->setCharset('UTF-8'); $newPart->setContents(sprintf(_("[Attachment stripped: Original attachment type: %s, name: %s]"), $part->getType(), $part_name ? $part_name : _("unnamed"))); $parts[] = array( diff --git a/imp/lib/Prefs/Ui.php b/imp/lib/Prefs/Ui.php index 0ef32ee2e..e80d515fb 100644 --- a/imp/lib/Prefs/Ui.php +++ b/imp/lib/Prefs/Ui.php @@ -1095,7 +1095,7 @@ class IMP_Prefs_Ui $t->set('personalkey-delete-help', Horde_Help::link('imp', 'pgp-personalkey-delete')); Horde::addInlineScript(array( - '$("delete_pgp_privkey").observe("click", function(e) { if (!window.confirm(' . Horde_Serialize::serialize(_("Are you sure you want to delete your keypair? (This is NOT recommended!)"), Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()) . ')) { e.stop(); } })' + '$("delete_pgp_privkey").observe("click", function(e) { if (!window.confirm(' . Horde_Serialize::serialize(_("Are you sure you want to delete your keypair? (This is NOT recommended!)"), Horde_Serialize::JSON, 'UTF-8') . ')) { e.stop(); } })' ), 'dom'); } else { $imp_identity = $GLOBALS['injector']->getInstance('IMP_Identity'); @@ -1108,7 +1108,7 @@ class IMP_Prefs_Ui $t->set('personalkey-create-passphrase-help', Horde_Help::link('imp', 'pgp-personalkey-create-passphrase')); Horde::addInlineScript(array( - '$("create_pgp_key").observe("click", function(e) { if (!window.confirm(' . Horde_Serialize::serialize(_("Key generation may take a long time to complete. Continue with key generation?"), Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()) . ')) { e.stop(); } })' + '$("create_pgp_key").observe("click", function(e) { if (!window.confirm(' . Horde_Serialize::serialize(_("Key generation may take a long time to complete. Continue with key generation?"), Horde_Serialize::JSON, 'UTF-8') . ')) { e.stop(); } })' ), 'dom'); if ($_SESSION['imp']['file_upload']) { @@ -1432,7 +1432,7 @@ class IMP_Prefs_Ui $sent_mail_folder = IMP::formMbox($ui->vars->sent_mail_folder, false); if (empty($sent_mail_folder) && $ui->vars->sent_mail_folder_new) { - $sent_mail_folder = Horde_String::convertCharset($ui->vars->sent_mail_folder_new, $GLOBALS['registry']->getCharset(), 'UTF7-IMAP'); + $sent_mail_folder = Horde_String::convertCharset($ui->vars->sent_mail_folder_new, 'UTF-8', 'UTF7-IMAP'); } elseif (strpos($sent_mail_folder, self::PREF_SPECIALUSE) === 0) { $sent_mail_folder = substr($folder, strlen(self::PREF_SPECIALUSE)); } elseif (($sent_mail_folder == self::PREF_DEFAULT) && @@ -1491,7 +1491,7 @@ class IMP_Prefs_Ui $t->set('personalkey-delete-help', Horde_Help::link('imp', 'smime-delete-personal-certs')); Horde::addInlineScript(array( - '$("delete_smime_personal").observe("click", function(e) { if (!window.confirm(' . Horde_Serialize::serialize(_("Are you sure you want to delete your keypair? (This is NOT recommended!)"), Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()) . ')) { e.stop(); } })' + '$("delete_smime_personal").observe("click", function(e) { if (!window.confirm(' . Horde_Serialize::serialize(_("Are you sure you want to delete your keypair? (This is NOT recommended!)"), Horde_Serialize::JSON, 'UTF-8') . ')) { e.stop(); } })' ), 'dom'); } elseif ($_SESSION['imp']['file_upload']) { $cacheSess = $GLOBALS['injector']->getInstance('Horde_SessionObjects'); @@ -1928,7 +1928,7 @@ class IMP_Prefs_Ui if (strpos($folder, self::PREF_SPECIALUSE) === 0) { $folder = substr($folder, strlen(self::PREF_SPECIALUSE)); } elseif (!empty($new)) { - $new = Horde_String::convertCharset($new, $GLOBALS['registry']->getCharset(), 'UTF7-IMAP'); + $new = Horde_String::convertCharset($new, 'UTF-8', 'UTF7-IMAP'); $folder = $GLOBALS['injector']->getInstance('IMP_Imap')->getOb()->appendNamespace($new); if (!$GLOBALS['injector']->getInstance('IMP_Folder')->create($folder, $prefs->getValue('subscribe'), array($type => true))) { $folder = null; diff --git a/imp/lib/Spam.php b/imp/lib/Spam.php index 3e23bb794..335f0d140 100644 --- a/imp/lib/Spam.php +++ b/imp/lib/Spam.php @@ -147,7 +147,7 @@ class IMP_Spam /* Send the message. */ try { - $imp_compose->sendMessage($to, $spam_headers, $mime, $GLOBALS['registry']->getCharset()); + $imp_compose->sendMessage($to, $spam_headers, $mime, 'UTF-8'); $report_flag = true; } catch (IMP_Compose_Exception $e) { Horde::logMessage($e, 'ERR'); diff --git a/imp/lib/Ui/Compose.php b/imp/lib/Ui/Compose.php index 7538b2f35..af946510b 100644 --- a/imp/lib/Ui/Compose.php +++ b/imp/lib/Ui/Compose.php @@ -344,7 +344,7 @@ class IMP_Ui_Compose // Sent mail display name 'smf_display' => IMP::displayFolder($identity->getValue('sent_mail_folder', $ident)), // Bcc addresses to add - 'bcc' => Horde_Mime_Address::addrArray2String($identity->getBccAddresses($ident), array('charset' => $GLOBALS['registry']->getCharset())) + 'bcc' => Horde_Mime_Address::addrArray2String($identity->getBccAddresses($ident), array('charset' => 'UTF-8')) ); } diff --git a/imp/lib/Ui/Mailbox.php b/imp/lib/Ui/Mailbox.php index f2a7bfd2c..0d6cbdbb9 100644 --- a/imp/lib/Ui/Mailbox.php +++ b/imp/lib/Ui/Mailbox.php @@ -76,7 +76,7 @@ class IMP_Ui_Mailbox $this->_cache['drafts_sm_folder'] = IMP::isSpecialFolder($this->_mailbox); } - $from = Horde_Mime_Address::getAddressesFromObject($ob['from'], array('charset' => $GLOBALS['registry']->getCharset())); + $from = Horde_Mime_Address::getAddressesFromObject($ob['from'], array('charset' => 'UTF-8')); $from = reset($from); if (empty($from)) { @@ -90,7 +90,7 @@ class IMP_Ui_Mailbox $ret['from'] = _("Undisclosed Recipients"); $ret['error'] = true; } else { - $to = Horde_Mime_Address::getAddressesFromObject($ob['to'], array('charset' => $GLOBALS['registry']->getCharset())); + $to = Horde_Mime_Address::getAddressesFromObject($ob['to'], array('charset' => 'UTF-8')); $first_to = reset($to); if (empty($first_to)) { $ret['from'] = _("Undisclosed Recipients"); @@ -257,7 +257,7 @@ class IMP_Ui_Mailbox */ public function getSubject($subject, $htmlspaces = false) { - $subject = Horde_Mime::decode($subject, $GLOBALS['registry']->getCharset()); + $subject = Horde_Mime::decode($subject, 'UTF-8'); if (empty($subject)) { return _("[No Subject]"); } diff --git a/imp/lib/Ui/Message.php b/imp/lib/Ui/Message.php index 3d9a3da5e..a2be22aea 100644 --- a/imp/lib/Ui/Message.php +++ b/imp/lib/Ui/Message.php @@ -132,7 +132,7 @@ class IMP_Ui_Message $GLOBALS['conf']['server']['name'], $GLOBALS['injector']->getInstance('IMP_Mail'), array( - 'charset' => $GLOBALS['registry']->getCharset(), + 'charset' => 'UTF-8', 'from_addr' => $GLOBALS['injector']->getInstance('Horde_Prefs_Identity')->getIdentity()->getDefaultFromAddress() ) ); @@ -329,7 +329,7 @@ class IMP_Ui_Message } catch (Horde_Exception $e) {} } - foreach (Horde_Mime_Address::getAddressesFromObject($addrlist, array('charset' => $registry->getCharset())) as $ob) { + foreach (Horde_Mime_Address::getAddressesFromObject($addrlist, array('charset' => 'UTF-8')) as $ob) { if (isset($ob['groupname'])) { $group_array = array(); foreach ($ob['addresses'] as $ad) { diff --git a/imp/lib/Views/Compose.php b/imp/lib/Views/Compose.php index 3bee373f5..a84d4219b 100644 --- a/imp/lib/Views/Compose.php +++ b/imp/lib/Views/Compose.php @@ -66,7 +66,7 @@ class IMP_Views_Compose 'num' => intval($num), 'size' => $mime->getSize(), 'type' => $mime->getType() - ), Horde_Serialize::JSON, $registry->getCharset()); + ), Horde_Serialize::JSON, 'UTF-8'); $result['jsonload'][] = 'DimpCompose.addAttach(' . $opts . ')'; } } diff --git a/imp/lib/Views/ListMessages.php b/imp/lib/Views/ListMessages.php index aa2d80c23..53b0f9abe 100644 --- a/imp/lib/Views/ListMessages.php +++ b/imp/lib/Views/ListMessages.php @@ -400,7 +400,7 @@ class IMP_Views_ListMessages /* Get mailbox information. */ $overview = $imp_mailbox->getMailboxArray($msglist, array('headers' => true, 'structure' => $GLOBALS['prefs']->getValue('atc_flag'))); - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; $imp_ui = new IMP_Ui_Mailbox($folder); $no_flags_hook = false; diff --git a/imp/lib/Views/ShowMessage.php b/imp/lib/Views/ShowMessage.php index 11a9fb771..289ad7064 100644 --- a/imp/lib/Views/ShowMessage.php +++ b/imp/lib/Views/ShowMessage.php @@ -30,7 +30,7 @@ class IMP_Views_ShowMessage $addr_array = array(); - foreach (Horde_Mime_Address::getAddressesFromObject($addrlist, array('charset' => $GLOBALS['registry']->getCharset())) as $ob) { + foreach (Horde_Mime_Address::getAddressesFromObject($addrlist, array('charset' => 'UTF-8')) as $ob) { if (!empty($ob['inner'])) { try { $tmp = array('raw' => Horde::callHook('dimp_addressformatting', array($ob), 'imp')); diff --git a/imp/mailbox-mimp.php b/imp/mailbox-mimp.php index 0163b5e93..3027c5fec 100644 --- a/imp/mailbox-mimp.php +++ b/imp/mailbox-mimp.php @@ -180,7 +180,7 @@ while (list(,$ob) = each($mbox_info['overview'])) { /* Get flag information. */ $flag_parse = $injector->getInstance('IMP_Imap_Flags')->parse(array( 'flags' => $ob['flags'], - 'personal' => Horde_Mime_Address::getAddressesFromObject($ob['envelope']['to'], array('charset' => $registry->getCharset())), + 'personal' => Horde_Mime_Address::getAddressesFromObject($ob['envelope']['to'], array('charset' => 'UTF-8')), 'priority' => $ob['headers'] )); diff --git a/imp/mailbox.php b/imp/mailbox.php index f21034474..10ad07f17 100644 --- a/imp/mailbox.php +++ b/imp/mailbox.php @@ -744,7 +744,7 @@ while (list(,$ob) = each($mbox_info['overview'])) { 'atc' => isset($ob['structure']) ? $ob['structure'] : null, 'div' => true, 'flags' => $ob['flags'], - 'personal' => Horde_Mime_Address::getAddressesFromObject($ob['envelope']['to'], array('charset' => $registry->getCharset())), + 'personal' => Horde_Mime_Address::getAddressesFromObject($ob['envelope']['to'], array('charset' => 'UTF-8')), 'priority' => $ob['headers'] )); @@ -791,7 +791,7 @@ while (list(,$ob) = each($mbox_info['overview'])) { } /* Format the From: Header. */ - $getfrom = $imp_ui->getFrom($ob['envelope'], array('fullfrom' => true, 'specialchars' => $registry->getCharset())); + $getfrom = $imp_ui->getFrom($ob['envelope'], array('fullfrom' => true, 'specialchars' => 'UTF-8')); $msg['from'] = $getfrom['from']; $msg['fullfrom'] = $getfrom['fullfrom']; switch ($fromlinkstyle) { diff --git a/imp/message-mimp.php b/imp/message-mimp.php index e82db7e5a..577495058 100644 --- a/imp/message-mimp.php +++ b/imp/message-mimp.php @@ -274,7 +274,7 @@ if (IMP::canCompose()) { $menu[] = array(_("Reply to List"), IMP::composeLink(array(), array('a' => 'rl') + $compose_params)); } - if (Horde_Mime_Address::addrArray2String(array_merge($envelope['to'], $envelope['cc']), array('charset' => $registry->getCharset(), 'filter' => array_keys($user_identity->getAllFromAddresses(true))))) { + if (Horde_Mime_Address::addrArray2String(array_merge($envelope['to'], $envelope['cc']), array('charset' => 'UTF-8', 'filter' => array_keys($user_identity->getAllFromAddresses(true))))) { $menu[] = array(_("Reply All"), IMP::composeLink(array(), array('a' => 'ra') + $compose_params)); } diff --git a/imp/message.php b/imp/message.php index 78189ba31..ffaaa2688 100644 --- a/imp/message.php +++ b/imp/message.php @@ -327,8 +327,8 @@ case 'low': /* Build Reply-To address link. */ if (!empty($envelope['reply-to']) && - (Horde_Mime_Address::bareAddress(Horde_Mime_Address::addrObject2String(reset($envelope['from']), array('charset' => $registry->getCharset()))) != - Horde_Mime_Address::bareAddress(Horde_Mime_Address::addrObject2String(reset($envelope['reply-to']), array('charset' => $registry->getCharset())))) && + (Horde_Mime_Address::bareAddress(Horde_Mime_Address::addrObject2String(reset($envelope['from']), array('charset' => 'UTF-8'))) != + Horde_Mime_Address::bareAddress(Horde_Mime_Address::addrObject2String(reset($envelope['reply-to']), array('charset' => 'UTF-8')))) && ($reply_to = $imp_ui->buildAddressLinks($envelope['reply-to'], $self_link))) { $display_headers['reply-to'] = $reply_to; } @@ -509,7 +509,7 @@ if (!$disable_compose) { $a_template->set('reply_list', Horde::widget(IMP::composeLink(array(), array('actionID' => 'reply_list') + $compose_params), _("To List"), 'widget', '', '', _("To _List"), true)); } - if (Horde_Mime_Address::addrArray2String(array_merge($envelope['to'], $envelope['cc']), array('charset' => $registry->getCharset(), 'filter' => array_keys($user_identity->getAllFromAddresses(true))))) { + if (Horde_Mime_Address::addrArray2String(array_merge($envelope['to'], $envelope['cc']), array('charset' => 'UTF-8', 'filter' => array_keys($user_identity->getAllFromAddresses(true))))) { $a_template->set('show_reply_all', Horde::widget(IMP::composeLink(array(), array('actionID' => 'reply_all') + $compose_params), _("To All"), 'widget', '', '', _("To _All"), true)); } diff --git a/imp/rss.php b/imp/rss.php index 6107ce2ab..88f49f70f 100644 --- a/imp/rss.php +++ b/imp/rss.php @@ -74,7 +74,7 @@ if (count($ids)) { 'description' => isset($ob['preview']) ? $ob['preview'] : '', 'url' => Horde::url(IMP::generateIMPUrl('message.php', $mailbox, $ob['uid'], $mailbox), true, array('append_session' => -1)), 'fromAddr' => $from_addr['fullfrom'], - 'toAddr' => Horde_Mime_Address::addrArray2String(isset($ob['envelope']['to']) ? $ob['envelope']['to'] : array(), array('charset' => $registry->getCharset())) + 'toAddr' => Horde_Mime_Address::addrArray2String(isset($ob['envelope']['to']) ? $ob['envelope']['to'] : array(), array('charset' => 'UTF-8')) )); } } @@ -84,7 +84,7 @@ $description = ($total_num == 0) : sprintf(_("%u of %u messages in %s unread."), $unseen_num, $total_num, IMP::getLabel($mailbox)); $t = $injector->createInstance('Horde_Template'); -$t->set('charset', $registry->getCharset()); +$t->set('charset', 'UTF-8'); $t->set('xsl', $registry->get('themesuri') . '/feed-rss.xsl'); $t->set('pubDate', htmlspecialchars(date('r'))); $t->set('desc', htmlspecialchars($description)); diff --git a/imp/templates/common-header.inc b/imp/templates/common-header.inc index 986cbb685..b4ffa1d37 100644 --- a/imp/templates/common-header.inc +++ b/imp/templates/common-header.inc @@ -19,7 +19,7 @@ default: } if (isset($GLOBALS['language'])) { - header('Content-type: text/html; charset=' . $GLOBALS['registry']->getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/imp/templates/dimp/javascript_defs_dimp.php b/imp/templates/dimp/javascript_defs_dimp.php index 4752f8c91..7cefe8e2f 100644 --- a/imp/templates/dimp/javascript_defs_dimp.php +++ b/imp/templates/dimp/javascript_defs_dimp.php @@ -240,5 +240,5 @@ if (in_array(basename($_SERVER['PHP_SELF']), array('compose-dimp.php', 'message- } Horde::addInlineScript(array( - 'var DIMP = ' . Horde_Serialize::serialize($code, Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()) + 'var DIMP = ' . Horde_Serialize::serialize($code, Horde_Serialize::JSON, 'UTF-8') ), null, true); diff --git a/imp/templates/imp/javascript_defs.php b/imp/templates/imp/javascript_defs.php index de5030c32..b7e61cadc 100644 --- a/imp/templates/imp/javascript_defs.php +++ b/imp/templates/imp/javascript_defs.php @@ -71,5 +71,5 @@ $code = array( ); Horde::addInlineScript(array( - 'var IMP = ' . Horde_Serialize::serialize($code, Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()) + 'var IMP = ' . Horde_Serialize::serialize($code, Horde_Serialize::JSON, 'UTF-8') ), null, true); diff --git a/imp/thread.php b/imp/thread.php index ea4e54141..6b0acb909 100644 --- a/imp/thread.php +++ b/imp/thread.php @@ -81,7 +81,7 @@ if ($mode == 'thread') { $imp_indices = new IMP_Indices(IMP::$mailbox, $thread); } -$charset = $registry->getCharset(); +$charset = 'UTF-8'; $imp_ui = new IMP_Ui_Message(); foreach ($imp_indices->indices() as $mbox => $idxlist) { diff --git a/imp/view.php b/imp/view.php index b933bc54e..e62d83b4b 100644 --- a/imp/view.php +++ b/imp/view.php @@ -41,7 +41,7 @@ function _sanitizeName($name) { - return Horde_String::convertCharset(trim(preg_replace('/[^\pL\pN-+_. ]/u', '_', Horde_String::convertCharset($name, $GLOBALS['registry']->getCharset(), 'UTF-8')), ' _'), 'UTF-8'); + return Horde_String::convertCharset(trim(preg_replace('/[^\pL\pN-+_. ]/u', '_', Horde_String::convertCharset($name, 'UTF-8', 'UTF-8')), ' _'), 'UTF-8'); } require_once dirname(__FILE__) . '/lib/Application.php'; diff --git a/ingo/filters.php b/ingo/filters.php index b1b9c0171..31fcfe629 100644 --- a/ingo/filters.php +++ b/ingo/filters.php @@ -62,7 +62,7 @@ case 'rule_enable': try { $message = Horde::callHook('perms_denied', array('ingo:allow_rules')); } catch (Horde_Exception_HookNotSet $e) { - $message = @htmlspecialchars(_("You are not allowed to create or edit custom rules."), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(_("You are not allowed to create or edit custom rules."), ENT_COMPAT, 'UTF-8'); } $notification->push($message, 'horde.error', array('content.raw')); break 2; @@ -71,7 +71,7 @@ case 'rule_enable': try { $message = Horde::callHook('perms_denied', array('ingo:max_rules')); } catch (Horde_Exception_HookNotSet $e) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d rules."), $perms->hasAppPermission('max_rules')), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d rules."), $perms->hasAppPermission('max_rules')), ENT_COMPAT, 'UTF-8'); } $notification->push($message, 'horde.error', array('content.raw')); break 2; @@ -210,7 +210,7 @@ if (count($filter_list) == 0) { /* Create description. */ if (!$edit_allowed) { - $entry['descriplink'] = @htmlspecialchars($name, ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $entry['descriplink'] = @htmlspecialchars($name, ENT_COMPAT, 'UTF-8'); } elseif (!empty($filter['conditions'])) { $descrip = ''; $condition_size = count($filter['conditions']) - 1; @@ -239,9 +239,9 @@ if (count($filter_list) == 0) { $descrip .= "\n[stop]"; } - $entry['descriplink'] = Horde::linkTooltip($editurl, sprintf(_("Edit %s"), $name), null, null, null, $descrip) . @htmlspecialchars($name, ENT_COMPAT, $GLOBALS['registry']->getCharset()) . ''; + $entry['descriplink'] = Horde::linkTooltip($editurl, sprintf(_("Edit %s"), $name), null, null, null, $descrip) . @htmlspecialchars($name, ENT_COMPAT, 'UTF-8') . ''; } else { - $entry['descriplink'] = Horde::link($editurl, sprintf(_("Edit %s"), $name)) . @htmlspecialchars($name, ENT_COMPAT, $GLOBALS['registry']->getCharset()) . ''; + $entry['descriplink'] = Horde::link($editurl, sprintf(_("Edit %s"), $name)) . @htmlspecialchars($name, ENT_COMPAT, 'UTF-8') . ''; } /* Create edit link. */ diff --git a/ingo/lib/Ingo.php b/ingo/lib/Ingo.php index 6c6e223be..47dfaa34b 100644 --- a/ingo/lib/Ingo.php +++ b/ingo/lib/Ingo.php @@ -153,7 +153,7 @@ class Ingo static public function createFolder($folder) { return $GLOBALS['registry']->hasMethod('mail/createFolder') - ? $GLOBALS['registry']->call('mail/createFolder', array('folder' => Horde_String::convertCharset($folder, $GLOBALS['registry']->getCharset(), 'UTF7-IMAP'))) + ? $GLOBALS['registry']->call('mail/createFolder', array('folder' => Horde_String::convertCharset($folder, 'UTF-8', 'UTF7-IMAP'))) : false; } @@ -457,7 +457,7 @@ class Ingo if ($GLOBALS['registry']->hasMethod('mail/createFolder')) { Horde::addScriptFile('new_folder.js', 'ingo'); Horde::addInlineScript(array( - 'IngoNewFolder.folderprompt = ' . Horde_Serialize::serialize(_("Please enter the name of the new folder:"), Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()) + 'IngoNewFolder.folderprompt = ' . Horde_Serialize::serialize(_("Please enter the name of the new folder:"), Horde_Serialize::JSON, 'UTF-8') )); } } diff --git a/ingo/lib/Script.php b/ingo/lib/Script.php index ce10adab7..b5bd7390e 100644 --- a/ingo/lib/Script.php +++ b/ingo/lib/Script.php @@ -127,7 +127,7 @@ class Ingo_Script $params['spam_char'] = $GLOBALS['conf']['spam']['char']; } if (!isset($params['charset'])) { - $params['charset'] = $GLOBALS['registry']->getCharset(); + $params['charset'] = 'UTF-8'; } if ($script == 'Sieve') { if (!isset($params['date_format'])) { diff --git a/ingo/lib/Storage/Filters/Sql.php b/ingo/lib/Storage/Filters/Sql.php index 0270a0a1a..ad54d6e9b 100644 --- a/ingo/lib/Storage/Filters/Sql.php +++ b/ingo/lib/Storage/Filters/Sql.php @@ -123,11 +123,11 @@ class Ingo_Storage_Filters_Sql extends Ingo_Storage_Filters { */ protected function _ruleToBackend($rule) { - return array(Horde_String::convertCharset($rule['name'], $GLOBALS['registry']->getCharset(), $this->_params['charset']), + return array(Horde_String::convertCharset($rule['name'], 'UTF-8', $this->_params['charset']), (int)$rule['action'], - isset($rule['action-value']) ? Horde_String::convertCharset($rule['action-value'], $GLOBALS['registry']->getCharset(), $this->_params['charset']) : null, + isset($rule['action-value']) ? Horde_String::convertCharset($rule['action-value'], 'UTF-8', $this->_params['charset']) : null, isset($rule['flags']) ? (int)$rule['flags'] : null, - isset($rule['conditions']) ? serialize(Horde_String::convertCharset($rule['conditions'], $GLOBALS['registry']->getCharset(), $this->_params['charset'])) : null, + isset($rule['conditions']) ? serialize(Horde_String::convertCharset($rule['conditions'], 'UTF-8', $this->_params['charset'])) : null, isset($rule['combine']) ? (int)$rule['combine'] : null, isset($rule['stop']) ? (int)$rule['stop'] : null, isset($rule['disable']) ? (int)(!$rule['disable']) : 1); diff --git a/ingo/lib/Storage/Prefs.php b/ingo/lib/Storage/Prefs.php index 3c1354caf..729b54f09 100644 --- a/ingo/lib/Storage/Prefs.php +++ b/ingo/lib/Storage/Prefs.php @@ -64,7 +64,7 @@ class Ingo_Storage_Prefs extends Ingo_Storage /* Convert rules from the old format. */ $data = @unserialize($prefs->getValue('rules')); } else { - $data = Horde_String::convertCharset($data, $prefs->getCharset(), $GLOBALS['registry']->getCharset()); + $data = Horde_String::convertCharset($data, $prefs->getCharset(), 'UTF-8'); } if ($data) { $ob->setFilterlist($data); @@ -145,7 +145,7 @@ class Ingo_Storage_Prefs extends Ingo_Storage return $prefs->setValue('blacklist', serialize($data)); case self::ACTION_FILTERS: - return $prefs->setValue('rules', serialize(Horde_String::convertCharset($ob->getFilterList(), $GLOBALS['registry']->getCharset(), $prefs->getCharset())), false); + return $prefs->setValue('rules', serialize(Horde_String::convertCharset($ob->getFilterList(), 'UTF-8', $prefs->getCharset())), false); case self::ACTION_FORWARD: $data = array( diff --git a/ingo/lib/Storage/Sql.php b/ingo/lib/Storage/Sql.php index 9593297de..434e56b61 100644 --- a/ingo/lib/Storage/Sql.php +++ b/ingo/lib/Storage/Sql.php @@ -272,10 +272,10 @@ class Ingo_Storage_Sql extends Ingo_Storage $values = array( implode("\n", $ob->getVacationAddresses()), Horde_String::convertCharset($ob->getVacationSubject(), - $GLOBALS['registry']->getCharset(), + 'UTF-8', $this->_params['charset']), Horde_String::convertCharset($ob->getVacationReason(), - $GLOBALS['registry']->getCharset(), + 'UTF-8', $this->_params['charset']), (int)$ob->getVacationDays(), (int)$ob->getVacationStart(), diff --git a/ingo/rule.php b/ingo/rule.php index b2347fe6f..b7be022e1 100644 --- a/ingo/rule.php +++ b/ingo/rule.php @@ -20,7 +20,7 @@ if (!$perms->hasAppPermission('allow_rules')) { try { $message = Horde::callHook('perms_denied', array('ingo:allow_rules')); } catch (Horde_Exception_HookNotSet $e) { - $message = @htmlspecialchars(_("You are not allowed to create or edit custom rules."), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(_("You are not allowed to create or edit custom rules."), ENT_COMPAT, 'UTF-8'); } $notification->push($message, 'horde.error', array('content.raw')); Horde::url('filters.php', true)->redirect(); @@ -171,7 +171,7 @@ default: try { $message = Horde::callHook('perms_denied', array('ingo:max_rules')); } catch (Horde_Exception_HookNotSet $e) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d rules."), $perms->hasAppPermission('max_rules')), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d rules."), $perms->hasAppPermission('max_rules')), ENT_COMPAT, 'UTF-8'); } $notification->push($message, 'horde.error', array('content.raw')); header('Location: ' . Horde::url('filters.php', true)); diff --git a/ingo/templates/common-header.inc b/ingo/templates/common-header.inc index 31c804e96..0580182b7 100644 --- a/ingo/templates/common-header.inc +++ b/ingo/templates/common-header.inc @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } $page_title = $GLOBALS['registry']->get('name'); diff --git a/ingo/templates/rule/header.inc b/ingo/templates/rule/header.inc index d226f5dd0..129de55da 100644 --- a/ingo/templates/rule/header.inc +++ b/ingo/templates/rule/header.inc @@ -18,7 +18,7 @@
'; + $html .= ''; + $html .= ''; + + if ($percent > 0) { + $html .= ''; + } + + if ($percent != 100) { + $html .= ''; + } + } + + $html .= '
'; + } else { + $html .= ' ' . $percent .'%
'; + + return $html; + } + +} diff --git a/babel/templates/common-header.inc b/babel/templates/common-header.inc new file mode 100644 index 000000000..bd2626d99 --- /dev/null +++ b/babel/templates/common-header.inc @@ -0,0 +1,25 @@ + + +' : '' ?> + +get('name'); +if (!empty($title)) { + $page_title .= ' :: ' . $title; +} + +Horde::outputMetaTags(); +Horde::includeScriptFiles(); + +?> +<?php echo $page_title ?> + + + + diff --git a/chora/templates/common-header.inc b/chora/templates/common-header.inc index 9540fd3e3..7be23e4a1 100644 --- a/chora/templates/common-header.inc +++ b/chora/templates/common-header.inc @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> @@ -16,7 +16,7 @@ if (!empty($title)) { Horde::outputMetaTags(); if (Horde_Util::nonInputVar('js_vars')) { - Horde::addInlineScript('var Chora = ' . Horde_Serialize::serialize($js_vars, Horde_Serialize::JSON, $GLOBALS['registry']->getCharset())); + Horde::addInlineScript('var Chora = ' . Horde_Serialize::serialize($js_vars, Horde_Serialize::JSON, 'UTF-8')); } Horde::includeScriptFiles(); diff --git a/crumb/templates/common-header.inc b/crumb/templates/common-header.inc new file mode 100644 index 000000000..1ad6d3968 --- /dev/null +++ b/crumb/templates/common-header.inc @@ -0,0 +1,29 @@ + + + + + +' : '' ?> + +get('name'); +if (!empty($title)) { + $page_title .= ' :: ' . $title; +} + +Horde::outputMetaTags(); +Horde::includeScriptFiles(); + +?> +<?php echo htmlspecialchars($page_title) ?> + + + + + diff --git a/drag_n_drop_portal/block.php b/drag_n_drop_portal/block.php new file mode 100644 index 000000000..e27b2aefa --- /dev/null +++ b/drag_n_drop_portal/block.php @@ -0,0 +1,37 @@ + + * @package Folks + */ +define('HORDE_BASE', dirname(__FILE__) . '/..'); +require_once HORDE_BASE . '/lib/base.php'; +require_once 'Horde/Loader.php'; + +// Block to load +$block_id = Horde_Util::getFormData('block'); +list($app, $name) = explode(':', $block_id); + +$block_data = array(); +$block = Horde_Block_Collection::getBlock($app, $name, Horde_Util::getFormData('defaults')); +if ($block instanceof PEAR_Error) { + $block_data['title'] = $block->getMessage(); + $block_data['content'] = $block->getDebugInfo(); +} else { + $block_data['title'] = @$block->getTitle(); + if ($block_data['title'] instanceof PEAR_Error) { + $block_data['title'] = $block_data['title']->getMessage(); + } + $block_data['content'] = @$block->getContent(); + if ($block_data['content'] instanceof PEAR_Error) { + $block_data['content'] = $block_data['content']->getDebugInfo(); + } +} + +echo Horde_Serialize::serialize($block_data, Horde_Serialize::JSON, 'UTF-8'); diff --git a/drag_n_drop_portal/lib/Block/Layout/View/js.php b/drag_n_drop_portal/lib/Block/Layout/View/js.php new file mode 100644 index 000000000..39a668469 --- /dev/null +++ b/drag_n_drop_portal/lib/Block/Layout/View/js.php @@ -0,0 +1,110 @@ + + * @package Horde_Block + */ +class Horde_Block_Layout_View_Js extends Horde_Block_Layout_View { + + /** + * Render the current layout as HTML. + * + * @return string HTML layout. + */ + function toHtml() + { + $html = '
'; + $js = ''; + + $js_init .= 'portal.addWidgetControls("control_buttons");' + . '}' + . 'document.observe("dom:loaded", init); +' + . ''; + + $html .= '
' . "\n" . $js . "\n" . $js_init; + + // Strip any CSS tags out of the returned content so + // they can be handled seperately. + if (preg_match_all('//', $html, $links)) { + $html = str_replace($links[0], '', $html); + $this->_linkTags = $links[0]; + } + + return $html; + } + + function _serializeBlock($js_id, $app, $name, $params, &$js_init, $col_num) + { + $block = Horde_Block_Collection::getBlock($app, $name, $params); + if ($block instanceof PEAR_Error) { + $title = $block->getMessage(); + $content = $block->getDebugInfo(); + $params = array(); + } else { + $content = @$block->getContent(); + if ($content instanceof PEAR_Error) { + $content = $content->getDebugInfo(); + } + $title = @$block->getTitle(); + if ($title instanceof PEAR_Error) { + $title = $title->getMessage(); + } else { + $title = strip_tags($title); + } + } + + $content = Horde_Serialize::serialize($content, Horde_Serialize::JSON, 'UTF-8'); + $title = Horde_Serialize::serialize($title, Horde_Serialize::JSON, 'UTF-8'); + $params = Horde_Serialize::serialize($params, Horde_Serialize::JSON, 'UTF-8'); + + $js_init .= 'portal.add(new Xilinus.Widget().' + . 'setTitle(title_' . $js_id .').' + . ' setContent(content_' . $js_id .'), ' . $col_num . ');' + . '_widgets_blocks[' . $js_id . '] = "' . $app . ':' . $name . '";' + . '_layout_params[' . $js_id . '] = \'' . $params . '\'.evalJSON();' + . 'delete title_' . $js_id .';' + . 'delete content_' . $js_id .';' . "\n"; + + return 'var content_' . $js_id . ' = ' . $content . ';' . "\n" + . 'var title_' . $js_id . ' = ' . $title . ';' . "\n"; + } +} diff --git a/fima/data.php b/fima/data.php new file mode 100644 index 000000000..e16630cab --- /dev/null +++ b/fima/data.php @@ -0,0 +1,227 @@ + + * + * See the enclosed file LICENSE for license information (ASL). If you + * did not receive this file, see http://www.horde.org/licenses/asl.php. + */ + +function _cleanupData() +{ + $GLOBALS['import_step'] = 1; + return Horde_Data::IMPORT_FILE; +} + +@define('FIMA_BASE', dirname(__FILE__)); +require_once FIMA_BASE . '/lib/base.php'; + +$ledger = Fima::getActiveLedger(); + +/* Importable file types. */ +$file_types = array('csv' => _("CSV"), + 'tsv' => _("TSV")); + +/* Templates for the different import steps. */ +$templates = array( + Horde_Data::IMPORT_CSV => array($registry->get('templates', 'horde') . '/data/csvinfo.inc'), + Horde_Data::IMPORT_TSV => array($registry->get('templates', 'horde') . '/data/tsvinfo.inc'), + Horde_Data::IMPORT_MAPPED => array($registry->get('templates', 'horde') . '/data/csvmap.inc'), + Horde_Data::IMPORT_DATETIME => array($registry->get('templates', 'horde') . '/data/datemap.inc'), + Horde_Data::IMPORT_FILE => array(FIMA_TEMPLATES . '/data/import.inc', FIMA_TEMPLATES . '/data/export.inc'), +); + +/* Field/clear name mapping. */ +$app_fields = array('date' => _("Date"), + 'asset' => _("Asset Account"), + 'account' => _("Account"), + 'desc' => _("Description"), + 'amount' => _("Amount"), + 'eo' => _("e.o.")); + +/* Date/time fields. */ +$time_fields = array('date' => 'date'); + +/* Initial values. */ +$param = array('time_fields' => $time_fields, + 'file_types' => $file_types); +$import_format = Horde_Util::getFormData('import_format', ''); +$import_step = Horde_Util::getFormData('import_step', 0) + 1; +$next_step = Horde_Data::IMPORT_FILE; +$actionID = Horde_Util::getFormData('actionID'); +$error = false; + +/* Loop through the action handlers. */ +switch ($actionID) { +case 'export': + $data = array(); + + /* Create a Fima storage instance. */ + $storage = &Fima_Driver::singleton($ledger); + if (is_a($storage, 'PEAR_Error')) { + $notification->push(sprintf(_("Failed to access the ledger: %s"), $storage->getMessage()), 'horde.error'); + $error = true; + break; + } + $params = $storage->getParams(); + + $filters = array(array('type', $prefs->getValue('active_postingtype'))); + + /* Get accounts and postings. */ + $accounts = Fima::listAccounts(); + $postings = Fima::listPostings($filters); + + foreach ($postings as $postingId => $posting) { + $row = array(); + foreach ($posting as $key => $value) { + switch ($key) { + case 'date': + $row[$key] = strftime(Fima::convertDateFormat($prefs->getValue('date_format')), $value); + break; + case 'asset': + case 'account': + $row[$key] = isset($accounts[$value]) ? $accounts[$value]['number'] : ''; + break; + case 'amount': + $row[$key] = Fima::convertValueToAmount($value); + break; + case 'eo': + case 'desc': + $row[$key] = Horde_String::convertCharset($value, 'UTF-8', $params['charset']); + break; + default: + break; + } + } + $data[] = $row; + } + + if (!count($data)) { + $notification->push(_("There were no postings to export."), 'horde.message'); + $error = true; + break; + } + + switch (Horde_Util::getFormData('exportID')) { + case EXPORT_CSV: + $injector->getInstance('Horde_Data')->getData('Csv', array('cleanup' => '_cleanupData'))->exportFile(_("postings.csv"), $data, true); + exit; + + case EXPORT_TSV: + $injector->getInstance('Horde_Data')->getData('Tsv', array('cleanup' => '_cleanupData'))->exportFile(_("postings.tsv"), $data, true); + exit; + } + break; + +case Horde_Data::IMPORT_FILE: + $storage = &Fima_Driver::singleton($ledger); + if (is_a($storage, 'PEAR_Error')) { + $notification->push(sprintf(_("Failed to access the ledger: %s"), $storage->getMessage()), 'horde.error'); + $error = true; + break; + } + + $_SESSION['import_data']['target'] = $ledger; + $_SESSION['import_data']['purge'] = Horde_Util::getFormData('purge'); + break; +} + +if (!$error) { + try { + $data = $injector->getInstance('Horde_Data')->getData($import_format, array('cleanup' => '_cleanupData')); + $next_step = $data->nextStep($actionID, $param); + } catch (Horde_Data_Exception $e) { + if ($data) { + $notification->push($e, 'horde.error'); + $next_step = $data->cleanup(); + } else { + $notification->push(_("This file format is not supported."), 'horde.error'); + $next_step = Horde_Data::IMPORT_FILE; + } + } +} + +/* We have a final result set. */ +if (is_array($next_step)) { + /* Create a Fima storage instance. */ + $storage = &Fima_Driver::singleton($ledger); + if (is_a($storage, 'PEAR_Error')) { + $notification->push(sprintf(_("Failed to access the ledger: %s"), $storage->getMessage()), 'horde.error'); + } + + $params = $storage->getParams(); + + /* Purge old postings if requested. */ + if ($_SESSION['import_data']['purge']) { + $result = $storage->deleteAll(false, $prefs->getValue('active_postingtype')); + if (is_a($result, 'PEAR_Error')) { + $notification->push(sprintf(_("The postings could not be purged: %s"), $result->getMessage()), 'horde.error'); + } else { + $notification->push(_("Postings successfully purged."), 'horde.success'); + } + } + + /* Get accounts and postings. */ + $accounts = Fima::listAccounts(); + $accounts_indices = array(); + foreach ($accounts as $account) { + $accounts_indices[$account['number']] = $account['account_id']; + } + + foreach ($next_step as $row) { + $row['type'] = $prefs->getValue('active_postingtype'); + $row['asset'] = sprintf('%\'04d', $row['asset']); + $row['asset'] = isset($accounts_indices[$row['asset']]) ? $accounts_indices[$row['asset']] : null; + $row['account'] = sprintf('%\'04d', $row['account']); + $row['account'] = isset($accounts_indices[$row['account']]) ? $accounts_indices[$row['account']] : null; + $row['date'] = Fima::convertDateToStamp($row['date'], Fima::convertDateFormat($prefs->getValue('date_format'))); + $row['amount'] = Fima::convertAmountToValue($row['amount']); + if ($prefs->getValue('expenses_sign') == 0) { + if ($row['account'] !== null) { + if ($accounts[$row['account']]['type'] == FIMA_ACCOUNTTYPE_EXPENSE) { + $row['amount'] *= -1; + } + } else { + $row['amount'] *= -1; + } + } + $row['desc'] = isset($row['desc']) ? trim($row['desc']) : ''; + $row['eo'] = isset($row['eo']) ? (bool)trim($row['eo']) : false; + $result = $storage->addPosting($row['type'], $row['date'], $row['asset'], $row['account'], $row['eo'], $row['amount'], $row['desc']); + if (is_a($result, 'PEAR_Error')) { + break; + } + } + + if (!count($next_step)) { + $notification->push(sprintf(_("The %s file didn't contain any postings."), + $file_types[$_SESSION['import_data']['format']]), 'horde.error'); + } else { + $notification->push(sprintf(_("%s successfully imported"), + $file_types[$_SESSION['import_data']['format']]), 'horde.success'); + } + $next_step = $data->cleanup(); +} + +$title = _("Import/Export Postings"); +require FIMA_TEMPLATES . '/common-header.inc'; +require FIMA_TEMPLATES . '/menu.inc'; + +if ($next_step == Horde_Data::IMPORT_FILE) { + /* Build the charset options. */ + $charsets = $registry->nlsconfig['encodings']; + asort($charsets); + $all_charsets = $registry->nlsconfig['charsets']; + natcasesort($all_charsets); + foreach ($all_charsets as $charset) { + if (!isset($charsets[$charset])) { + $charsets[$charset] = $charset; + } + } + $my_charset = $GLOBALS['registry']->getLanguageCharset(); +} + +foreach ($templates[$next_step] as $template) { + require $template; + echo '
'; +} +require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/fima/lib/Driver/sql.php b/fima/lib/Driver/sql.php new file mode 100644 index 000000000..6d8fe3c73 --- /dev/null +++ b/fima/lib/Driver/sql.php @@ -0,0 +1,1064 @@ + + * 'phptype' The database type (e.g. 'pgsql', 'mysql', etc.). + * 'table' The name of the foo table in 'database'. + * 'charset' The database's internal charset. + * + * Required by some database implementations:
+ *      'database'      The name of the database.
+ *      'hostspec'      The hostname of the database server.
+ *      'protocol'      The communication protocol ('tcp', 'unix', etc.).
+ *      'username'      The username with which to connect to the database.
+ *      'password'      The password associated with 'username'.
+ *      'options'       Additional options to pass to the database.
+ *      'tty'           The TTY on which to connect to the database.
+ *      'port'          The port on which to connect to the database.
+ * + * The table structure can be created by the scripts/sql/fima.sql + * script. + * + * Copyright 2007-2008 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (GPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. + * + * @author Thomas Trethan + * @package Fima + */ +class Fima_Driver_sql extends Fima_Driver { + + /** + * Handle for the current database connection. + * + * @var DB + */ + var $_db; + + /** + * Constructs a new SQL storage object. + * + * @param string $ledger The ledger to load. + * @param array $params A hash containing connection parameters. + */ + function Fima_Driver_sql($ledger, $params = array()) + { + $this->_ledger = $ledger; + $this->_params = $params; + } + + /** + * Retrieves accounts from the database. + * + * @param array $filters Any filters for restricting the retrieved accounts. + * + * @return mixed True on success, PEAR_Error on failure. + */ + function retrieveAccounts($filters = array()) + { + /* Build the SQL query. */ + $query = sprintf('SELECT * FROM %s WHERE account_owner = ?', $this->_params['table_accounts']); + $values = array($this->_ledger); + + /* Add filters. */ + $this->_addFilters($filters, $query, $values, 'account_'); + + /* Sorting. */ + $query .= ' ORDER BY account_number ASC'; + + /* Log the query at a DEBUG log level. */ + Horde::logMessage(sprintf('Fima_Driver_sql::retrieveAccounts(): %s', $query), 'DEBUG'); + + /* Execute the query. */ + $this->_accounts = array(); + $result = $this->_db->query($query, $values); + + if (isset($result) && !is_a($result, 'PEAR_Error')) { + $row = $result->fetchRow(DB_FETCHMODE_ASSOC); + if (is_a($row, 'PEAR_Error')) { + return $row; + } + + /* Store the retrieved values in the accounts variable. */ + $this->_accounts = array(); + while ($row && !is_a($row, 'PEAR_Error')) { + /* Add this new account to the $_account list. */ + $this->_accounts[$row['account_id']] = $this->_buildAccount($row); + + /* Advance to the new row in the result set. */ + $row = $result->fetchRow(DB_FETCHMODE_ASSOC); + } + $result->free(); + } else { + return $result; + } + + return true; + } + + /** + * Retrieves one account from the database. + * + * @param string $accountId The ID of the account to retrieve. + * + * @return array The array of account attributes. + */ + function getAccount($accountId) + { + /* Build the SQL query. */ + $query = sprintf('SELECT * FROM %s WHERE account_owner = ? AND account_id = ?', + $this->_params['table_accounts']); + $values = array($this->_ledger, $accountId); + + /* Log the query at a DEBUG log level. */ + Horde::logMessage(sprintf('Fima_Driver_sql::getAccount(): %s', $query), 'DEBUG'); + + /* Execute the query. */ + $result = $this->_db->query($query, $values); + if (is_a($result, 'PEAR_Error')) { + return $result; + } + + $row = $result->fetchRow(DB_FETCHMODE_ASSOC); + if (is_a($row, 'PEAR_Error')) { + return $row; + } + if ($row === null) { + return PEAR::raiseError(_("Not found")); + } + + /* Decode and return the account. */ + return $this->_buildAccount($row); + } + + /** + * Retrieves one account from the database by number. + * + * @param string $number The number of the account to retrieve. + * + * @return array The array of account attributes. + */ + function getAccountByNumber($number) + { + /* Build the SQL query. */ + $query = sprintf('SELECT * FROM %s WHERE account_owner = ? AND account_number = ?', + $this->_params['table_accounts']); + $values = array($this->_ledger, sprintf('%\'04s', $number)); + + /* Log the query at a DEBUG log level. */ + Horde::logMessage(sprintf('Fima_Driver_sql::getAccountByNumber(): %s', $query), 'DEBUG'); + + /* Execute the query. */ + $result = $this->_db->query($query, $values); + if (is_a($result, 'PEAR_Error')) { + return $result; + } + + $row = $result->fetchRow(DB_FETCHMODE_ASSOC); + if (is_a($row, 'PEAR_Error')) { + return $row; + } + if ($row === null) { + return PEAR::raiseError(_("Not found")); + } + + /* Decode and return the account. */ + return $this->_buildAccount($row); + } + + /** + * Retrieves postings from the database. + * + * @param array $filters Any filters for restricting the retrieved postings. + * @param array $sorting Sort order of retrieved postings. + * @param array $limit Limit of the retrieved postings, array(page, postings/page). + * + * @return mixed True on success, PEAR_Error on failure. + */ + function retrievePostings($filters = array(), $sorting = array(), $limit = array()) + { + /* Build the SQL query filter. */ + $queryfilter = ' WHERE posting_owner = ?'; + $values = array($this->_ledger); + + /* Add filters. */ + $this->_addFilters($filters, $queryfilter, $values, 'posting_'); + + $query = sprintf('SELECT count(p.posting_id) posting_count, SUM(p.posting_amount) posting_result FROM %s p', + $this->_params['table_postings']); + $query .= $queryfilter; + + /* Log the query at a DEBUG log level. */ + Horde::logMessage(sprintf('Fima_Driver_sql::retrievePostings(): %s', $query), 'DEBUG'); + + /* Execute the query. */ + $result = $this->_db->query($query, $values); + if (isset($result) && !is_a($result, 'PEAR_Error')) { + $row = $result->fetchRow(DB_FETCHMODE_ASSOC); + if (is_a($row, 'PEAR_Error')) { + return $row; + } + $this->_postingsCount = (int)$row['posting_count']; + $this->_postingsResult = $row['posting_result']; + $result->free(); + + // correct result when account is an asset account too + if ($this->_postingsCount > 0) { + $query = sprintf('SELECT SUM(p.posting_amount) posting_result ' . + 'FROM %s p JOIN %s a ON a.account_id = p.posting_account ' . + $queryfilter . ' AND a.account_type = ?', + $this->_params['table_postings'], $this->_params['table_accounts']); + $values2 = $values; + $values2[] = FIMA_ACCOUNTTYPE_ASSET; + $result = $this->_db->query($query, $values2); + if (isset($result) && !is_a($result, 'PEAR_Error')) { + $row = $result->fetchRow(DB_FETCHMODE_ASSOC); + if (is_a($row, 'PEAR_Error')) { + return $row; + } + } + $this->_postingsResult -= $row['posting_result']; + $result->free(); + } + } else { + return $result; + } + + /* Fetch the postings if necessary. */ + $this->_postings = array(); + if ($this->_postingsCount == 0) { + return true; + } + + $query = sprintf('SELECT p.*, asset.account_number posting_asset_number, account.account_number posting_account_number ' . + 'FROM %s p LEFT OUTER JOIN %s asset ON p.posting_asset = asset.account_id LEFT OUTER JOIN %s account ON p.posting_account = account.account_id', + $this->_params['table_postings'], $this->_params['table_accounts'], $this->_params['table_accounts']); + $query .= $queryfilter; + + /* Sorting. */ + if (!is_array($sorting)) { + $sorting = array($sorting); + } + if (count($sorting) == 0) { + $sorting = array('posting_date ASC'); + } + $query .= ' ORDER BY ' . implode(', ', $sorting); + + /* Limit. */ + if (count($limit) > 0) { + if ($limit[0] < 0) { + $limit[0] += ceil($this->_postingsCount / $limit[1]) + 1; + } + $limit[0] = ($limit[0] - 1) * $limit[1]; + /* Log the query at a DEBUG log level. */ + Horde::logMessage(sprintf('Fima_Driver_sql::retrievePostings() limitQuery: %s', $query), 'DEBUG'); + $result = $this->_db->queryLimit($query, $limit[0], $limit[1], $values); + } else { + /* Log the query at a DEBUG log level. */ + Horde::logMessage(sprintf('Fima_Driver_sql::retrievePostings(): %s', $query), 'DEBUG'); + $result = $this->_db->query($query, $values); + } + + /* Execute the query. */ + $result = $this->_db->query($query, $values); + if (isset($result) && !is_a($result, 'PEAR_Error')) { + $row = $result->fetchRow(DB_FETCHMODE_ASSOC); + if (is_a($row, 'PEAR_Error')) { + return $row; + } + + /* Store the retrieved values in the accounts variable. */ + while ($row && !is_a($row, 'PEAR_Error')) { + /* Add this new posting to the $_posting list. */ + $this->_postings[$row['posting_id']] = $this->_buildPosting($row); + + /* Advance to the new row in the result set. */ + $row = $result->fetchRow(DB_FETCHMODE_ASSOC); + } + $result->free(); + } else { + return $result; + } + + return true; + } + + /** + * Retrieves one posting from the database. + * + * @param string $postingId The ID of the posting to retrieve. + * + * @return array The array of posting attributes. + */ + function getPosting($postingId) + { + /* Build the SQL query. */ + $query = sprintf('SELECT * FROM %s WHERE posting_owner = ? AND posting_id = ?', + $this->_params['table_postings']); + $values = array($this->_ledger, $postingId); + + /* Log the query at a DEBUG log level. */ + Horde::logMessage(sprintf('Fima_Driver_sql::getPosting(): %s', $query), 'DEBUG'); + + /* Execute the query. */ + $result = $this->_db->query($query, $values); + + if (is_a($result, 'PEAR_Error')) { + return $result; + } + + $row = $result->fetchRow(DB_FETCHMODE_ASSOC); + if (is_a($row, 'PEAR_Error')) { + return $row; + } + if ($row === null) { + return PEAR::raiseError(_("Not found")); + } + + /* Decode and return the posting. */ + return $this->_buildPosting($row); + } + + /** + * Get grouped results. + * + * @param array $groups Fields to group. + * @param boolean $filters Filters for postings. + * + * @return array A matrix of the grouped results. + */ + function getResults($groups, $filters = array()) { + $matrix = array(); + + /* Fix grouping. */ + if (!is_array($groups)) { + $groups = array($groups); + } + if (!isset($groups[1])) { + $groups[1] = 'owner'; + } + foreach ($groups as $groupId => $group) { + switch($group) { + case 'date_month': $groups[$groupId] = 'FROM_UNIXTIME(posting_date, \'%Y%m\')'; break; + case 'date_year': $groups[$groupId] = 'FROM_UNIXTIME(posting_date, \'%Y\')'; break; + case 'asset_number': $groups[$groupId] = 'asset.account_number'; break; + case 'asset_parent': $groups[$groupId] = 'CONCAT(LEFT(asset.account_number, 2), \'00\')'; break; + case 'asset_type': $groups[$groupId] = 'asset.account_type'; break; + case 'account_number': $groups[$groupId] = 'account.account_number'; break; + case 'account_parent': $groups[$groupId] = 'CONCAT(LEFT(account.account_number, 2), \'00\')'; break; + case 'account_type': $groups[$groupId] = 'account.account_type'; break; + default: $groups[$groupId] = 'posting_'.$group; break; + } + } + + /* Build the SQL query filter. */ + $query = sprintf('SELECT %s x, %s y, sum(posting_amount) result ' . + 'FROM %s p LEFT OUTER JOIN %s asset ON p.posting_asset = asset.account_id AND p.posting_owner = asset.account_owner LEFT OUTER JOIN %s account ON p.posting_account = account.account_id AND p.posting_owner = account.account_owner ' . + 'WHERE posting_owner = ?', + $groups[0], $groups[1], $this->_params['table_postings'], $this->_params['table_accounts'], $this->_params['table_accounts']); + $values = array($this->_ledger); + + /* Add filters. */ + foreach ($filters as $filterId => $filter) { + switch($filter[0]) { + case 'date_month': $filters[$filterId][0] = 'FROM_UNIXTIME(posting_date, \'%Y%m\')'; break; + case 'date_year': $filters[$filterId][0] = 'FROM_UNIXTIME(posting_date, \'%Y%m\')'; break; + case 'asset_number': $filters[$filterId][0] = 'asset.account_number'; break; + case 'asset_parent': $filters[$filterId][0] = 'LEFT(asset.account_number, 2)'; break; + case 'asset_type': $filters[$filterId][0] = 'asset.account_type'; break; + case 'account_number': $filters[$filterId][0] = 'account.account_number'; break; + case 'account_parent': $filters[$filterId][0] = 'LEFT(account.account_number, 2)'; break; + case 'account_type': $filters[$filterId][0] = 'account.account_type'; break; + default: $filters[$filterId][0] = 'posting_'.$filter[0]; break; + } + } + $this->_addFilters($filters, $query, $values); + + /* Add grouping. */ + $query .= ' GROUP BY ' . implode(', ', $groups); + + /* Log the query at a DEBUG log level. */ + Horde::logMessage(sprintf('Fima_Driver_sql::getResults(): %s', $query), 'DEBUG'); + + /* Execute the query. */ + $result = $this->_db->query($query, $values); + if (isset($result) && !is_a($result, 'PEAR_Error')) { + $row = $result->fetchRow(DB_FETCHMODE_ASSOC); + if (is_a($row, 'PEAR_Error')) { + return $row; + } + + /* Store the retrieved values in the accounts variable. */ + while ($row && !is_a($row, 'PEAR_Error')) { + /* Add this new posting to the $_posting list. */ + if (!isset($matrix[$row['y']])) { + $matrix[$row['y']] = array(); + } + $matrix[$row['y']][$row['x']] = $row['result']; + + /* Advance to the new row in the result set. */ + $row = $result->fetchRow(DB_FETCHMODE_ASSOC); + } + $result->free(); + } + + return $matrix; + } + + /** + * Get the results of all asset accounts. + * + * @param string $postingtype Type of postings. + * @param boolean $perdate Date of asset results. + * + * @return array Array of asset accounts and results + */ + function getAssetResults($postingtype, $perdate = null) + { + $perdate = ($perdate === null) ? mktime() : (int)$perdate; + + /* Build the SQL query. */ + $query = sprintf('SELECT account_id, SUM(account_result) account_result FROM ( ' . + ' SELECT a1.account_id, SUM(p1.posting_amount) account_result ' . + ' FROM %s a1 LEFT OUTER JOIN %s p1 ON a1.account_id = p1.posting_asset AND p1.posting_owner = ? AND p1.posting_type = ? ' . + ' WHERE a1.account_owner = ? AND a1.account_type = ? and p1.posting_date <= ?' . + ' GROUP BY a1.account_id ' . + ' UNION ' . + ' SELECT a2.account_id, SUM(p2.posting_amount) * -1 account_result ' . + ' FROM %s a2 LEFT OUTER JOIN %s p2 ON a2.account_id = p2.posting_account AND p2.posting_owner = ? AND p2.posting_type = ? ' . + ' WHERE a2.account_owner = ? AND a2.account_type = ? and p2.posting_date <= ?' . + ' GROUP BY a2.account_id ' . + ') x ' . + 'GROUP BY account_id ', + $this->_params['table_accounts'], $this->_params['table_postings'], + $this->_params['table_accounts'], $this->_params['table_postings']); + $values = array($this->_ledger, $postingtype, $this->_ledger, FIMA_ACCOUNTTYPE_ASSET, $perdate, + $this->_ledger, $postingtype, $this->_ledger, FIMA_ACCOUNTTYPE_ASSET, $perdate); + + /* Log the query at a DEBUG log level. */ + Horde::logMessage(sprintf('Fima_Driver_sql::getAssetResults(): %s', $query), 'DEBUG'); + + /* Execute the query. */ + $assetresults = array(); + $result = $this->_db->query($query, $values); + if (isset($result) && !is_a($result, 'PEAR_Error')) { + $row = $result->fetchRow(DB_FETCHMODE_ASSOC); + if (is_a($row, 'PEAR_Error')) { + return $row; + } + + /* Store the retrieved values in the accounts variable. */ + while ($row && !is_a($row, 'PEAR_Error')) { + /* Add this new posting to the $_posting list. */ + $assetresults[] = $row; + + /* Advance to the new row in the result set. */ + $row = $result->fetchRow(DB_FETCHMODE_ASSOC); + } + $result->free(); + } else { + return $result; + } + + return $assetresults; + } + + /** + * Build an account. + * + * @param array $row Datasbase row holding account attributes. + * @param boolean $getparent Also get parent account. + * + * @return array The array of account attributes. + */ + function _buildAccount($row, $getparent = true) + { + $parent = null; + if ($getparent) { + if (($parent_number = Fima::getAccountParent($row['account_number'])) !== null) { + if (isset($this->_accounts[$parent_number])) { + $parent = $this->_accounts[$parent_number]; + } else { + $parent = $this->getAccountByNumber($parent_number); + if (is_a($parent, 'PEAR_Error')) { + $parent = null; + } + } + } + } + + /* Create a new account based on $row's values. */ + return array('account_id' => $row['account_id'], + 'owner' => $row['account_owner'], + 'number' => sprintf('%\'04d', $row['account_number']), + 'type' => $row['account_type'], + 'name' => Horde_String::convertCharset($row['account_name'], $this->_params['charset']), + 'eo' => $row['account_eo'], + 'desc' => Horde_String::convertCharset($row['account_desc'], $this->_params['charset']), + 'closed' => $row['account_closed'], + 'label' => trim($row['account_number'] . ' ' . + (($parent === null) ? '' : $parent['name'] . ' - ') . + Horde_String::convertCharset($row['account_name'], $this->_params['charset'])), + 'parent_id' => ($parent === null) ? null : $parent['account_id'], + 'parent_number' => ($parent === null) ? '' : $parent['number'], + 'parent_name' => ($parent === null) ? '' : $parent['name']); + } + + /** + * Adds an account to the backend storage. + * + * @param string $number The number of the account. + * @param string $type The type of the account. + * @param string $name The name (short) of the account. + * @param boolean $eo Extraordinary account. + * @param string $desc The description (long) of the account. + * @param boolean $closed Close account. + * + * @return mixed ID of the new account or PEAR_Error + */ + function _addAccount($number, $type, $name, $eo, $desc, $closed) + { + $accountId = strval(new Horde_Support_Uuid()); + + $query = sprintf( + 'INSERT INTO %s (account_id, account_owner, account_number, account_type, ' . + 'account_name, account_eo, account_desc, account_closed) ' . + 'VALUES (?, ?, ?, ?, ?, ?, ?, ?)', + $this->_params['table_accounts']); + $values = array($accountId, + $this->_ledger, + sprintf('%\'04d', $number), + $type, + Horde_String::convertCharset($name, 'UTF-8', $this->_params['charset']), + (int)(bool)$eo, + Horde_String::convertCharset($desc, 'UTF-8', $this->_params['charset']), + (int)(bool)$closed); + + /* Log the query at a DEBUG log level. */ + Horde::logMessage(sprintf('Fima_Driver_sql::_addAccount(): %s', $query), 'DEBUG'); + + /* Attempt the insertion query. */ + $result = $this->_db->query($query, $values); + if (is_a($result, 'PEAR_Error')) { + Horde::logMessage($result, 'ERR'); + return $result; + } + + return $accountId; + } + + /** + * Modifies an existing account. + * + * @param string $accountId The account to modify. + * @param string $number The number of the account. + * @param string $type The type of the account. + * @param string $name The name (short) of the account. + * @param boolean $eo Extraordinary account. + * @param string $desc The description (long) of the account. + * @param boolean $closed Close account. + * + * @return mixed True or PEAR_Error + */ + function _modifyAccount($accountId, $number, $type, $name, $eo, $desc, $closed) + { + $query = sprintf('UPDATE %s SET' . + ' account_number = ?, ' . + ' account_type = ?, ' . + ' account_name = ?, ' . + ' account_eo = ?, ' . + ' account_desc = ?, ' . + ' account_closed = ? ' . + 'WHERE account_owner = ? AND account_id = ?', + $this->_params['table_accounts']); + $values = array(sprintf('%\'04d', $number), + $type, + Horde_String::convertCharset($name, 'UTF-8', $this->_params['charset']), + (int)(bool)$eo, + Horde_String::convertCharset($desc, 'UTF-8', $this->_params['charset']), + (int)(bool)$closed, + $this->_ledger, + $accountId); + + /* Log the query at a DEBUG log level. */ + Horde::logMessage(sprintf('Fima_Driver_sql::_modifyAccount(): %s', $query), 'DEBUG'); + + /* Attempt the update query. */ + $result = $this->_db->query($query, $values); + if (is_a($result, 'PEAR_Error')) { + Horde::logMessage($result, 'ERR'); + return $result; + } + + return true; + } + + /** + * Deletes an account from the backend. + * + * @param string $accountId The account to delete. + * @param mixed $dsSubaccounts True/false when deleting subaccounts, + * accountId when shifting subaccounts + * @param mixed $dsPostings True/false when deleting postings, + * accountId when shifting postings + * + * @return mixed True or PEAR_Error + */ + function _deleteAccount($accountId, $dsSubaccounts = false, $dsPostings = true) + { + /* Get the account's details for use later. */ + $account = $this->getAccount($accountId); + + /* Handle subaccounts. */ + if ($dsSubaccounts !== false) { + /* Delete subaccounts. */ + $parent = (int)($account['number'] / 100) . '%'; + $this->retrieveAccounts(array(array('number', $parent, 'LIKE'), + array('number', (string)$account['number'], '!='))); + + foreach ($this->_accounts as $subaccountId => $subaccount) { + $delete = $this->_deleteAccount($subaccountId, false, $dsSubaccounts); + if (is_a($delete, 'PEAR_Error')) { + return $delete; + } + } + } + + /* Handle postings. */ + if ($dsPostings !== false) { + if ($dsPostings === true) { + /* Delete account postings. */ + $query = sprintf('DELETE FROM %s WHERE posting_owner = ? AND (posting_asset = ? OR posting_account = ?)', + $this->_params['table_postings']); + $values = array($this->_ledger, $accountId, $accountId); + + /* Log the query at a DEBUG log level. */ + Horde::logMessage(sprintf('Fima_Driver_sql::_deleteAccount(): %s', $query), 'DEBUG'); + + /* Attempt the delete query. */ + $result = $this->_db->query($query, $values); + if (is_a($result, 'PEAR_Error')) { + Horde::logMessage($result, 'ERR'); + return $result; + } + } else { + /* Shift account postings. */ + $shift = $this->_shiftPostings($accountId, $dsPostings); + if (is_a($shift, 'PEAR_Error')) { + return $shift; + } + } + } + + /* Delete account. */ + $query = sprintf('DELETE FROM %s WHERE account_owner = ? AND account_id = ?', + $this->_params['table_accounts']); + $values = array($this->_ledger, $accountId); + + /* Log the query at a DEBUG log level. */ + Horde::logMessage(sprintf('Fima_Driver_sql::_deleteAccount(): %s', $query), 'DEBUG'); + + /* Attempt the delete query. */ + $result = $this->_db->query($query, $values); + if (is_a($result, 'PEAR_Error')) { + Horde::logMessage($result, 'ERR'); + return $result; + } + + return true; + } + + /** + * Build a posting. + * + * @param array $row Datasbase row holding posting attributes; + * + * @return array The array of posting attributes. + */ + function _buildPosting($row) + { + /* Create a new account based on $row's values. */ + return array('posting_id' => $row['posting_id'], + 'owner' => $row['posting_owner'], + 'type' => $row['posting_type'], + 'date' => $row['posting_date'], + 'asset' => $row['posting_asset'], + 'account' => $row['posting_account'], + 'desc' => Horde_String::convertCharset($row['posting_desc'], $this->_params['charset']), + 'amount' => $row['posting_amount'], + 'eo' => (int)(bool)$row['posting_eo']); + } + + /** + * Adds a posting to the backend storage. + * + * @param string $type The posting type. + * @param integer $date The posting date. + * @param string $asset The ID of the asset account. + * @param string $account The ID of the account. + * @param boolean $eo Extraordinary posting. + * @param float $amount The posting amount. + * @param string $desc The posting description. + * + * @return mixed ID of the new posting or PEAR_Error + */ + function _addPosting($type, $date, $asset, $account, $eo, $amount, $desc) + { + $postingId = strval(new Horde_Support_Uuid()); + + $query = sprintf( + 'INSERT INTO %s (posting_id, posting_owner, posting_type, posting_date, ' . + 'posting_asset, posting_account, posting_eo, posting_amount, posting_desc) ' . + 'VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)', + $this->_params['table_postings']); + $values = array($postingId, + $this->_ledger, + $type, + (int)$date, + $asset, + $account, + (int)(bool)$eo, + (float)$amount, + Horde_String::convertCharset($desc, 'UTF-8', $this->_params['charset'])); + + /* Log the query at a DEBUG log level. */ + Horde::logMessage(sprintf('Fima_Driver_sql::_addPosting(): %s', $query), 'DEBUG'); + + /* Attempt the insertion query. */ + $result = $this->_db->query($query, $values); + if (is_a($result, 'PEAR_Error')) { + Horde::logMessage($result, 'ERR'); + return $result; + } + + return $postingId; + } + + /** + * Modifies an existing posting. + * + * @param string $postingId The posting to modify. + * @param string $type The posting type. + * @param integer $date The posting date. + * @param string $asset The ID of the asset account. + * @param string $account The ID of the account. + * @param boolean $eo Extraordinary posting. + * @param float $amount The posting amount. + * @param string $desc The posting description. + * + * @return mixed True or PEAR_Error + */ + function _modifyPosting($postingId, $type, $date, $asset, $account, $eo, $amount, $desc) + { + $query = sprintf('UPDATE %s SET' . + ' posting_type = ?, ' . + ' posting_date = ?, ' . + ' posting_asset = ?, ' . + ' posting_account = ?, ' . + ' posting_eo = ?, ' . + ' posting_amount = ?, ' . + ' posting_desc = ? ' . + 'WHERE posting_owner = ? AND posting_id = ?', + $this->_params['table_postings']); + $values = array($type, + (int)$date, + $asset, + $account, + (int)(bool)$eo, + (float)$amount, + Horde_String::convertCharset($desc, 'UTF-8', $this->_params['charset']), + $this->_ledger, + $postingId); + + /* Log the query at a DEBUG log level. */ + Horde::logMessage(sprintf('Fima_Driver_sql::_modifyPosting(): %s', $query), 'DEBUG'); + + /* Attempt the update query. */ + $result = $this->_db->query($query, $values); + if (is_a($result, 'PEAR_Error')) { + Horde::logMessage($result, 'ERR'); + return $result; + } + + return true; + } + + /** + * Deletes a posting from the backend. + * + * @param string $postingId The posting to delete. + * + * @return mixed True or PEAR_Error + */ + function _deletePosting($postingId) + { + /* Get the task's details for use later. */ + $posting = $this->getPosting($postingId); + + $query = sprintf('DELETE FROM %s WHERE posting_owner = ? AND posting_id = ?', + $this->_params['table_postings']); + $values = array($this->_ledger, $postingId); + + /* Log the query at a DEBUG log level. */ + Horde::logMessage(sprintf('Fima_Driver_sql::_deletePosting(): %s', $query), 'DEBUG'); + + /* Attempt the delete query. */ + $result = $this->_db->query($query, $values); + + if (is_a($result, 'PEAR_Error')) { + Horde::logMessage($result, 'ERR'); + return $result; + } + + return true; + } + + /** + * Shift an existing posting. + * + * @param string $postingId The posting to shift. + * @param string $type The posting type shifting to. + * @param string $asset The ID of the asset account. + * @param string $account The ID of the account. + * + * @return mixed True or PEAR_Error + */ + function _shiftPosting($postingId, $type, $asset, $account) + { + if (!$type && !$asset && !$account) { + return true; + } + + $query = sprintf('UPDATE %s SET' . + ($type ? ' posting_type = ?, ' : '') . + ($asset ? ' posting_asset = ?, ' : '') . + ($account ? ' posting_account = ?, ' : ''). + ' posting_eo = posting_eo ' . + 'WHERE posting_owner = ? AND posting_id = ?', + $this->_params['table_postings']); + $values = array(); + if ($type) { $values[] = $type; } + if ($asset) { $values[] = $asset; } + if ($account) { $values[] = $account; } + $values[] = $this->_ledger; + $values[] = $postingId; + + /* Log the query at a DEBUG log level. */ + Horde::logMessage(sprintf('Fima_Driver_sql::_shiftPosting(): %s', $query), 'DEBUG'); + + /* Attempt the update query. */ + $result = $this->_db->query($query, $values); + if (is_a($result, 'PEAR_Error')) { + Horde::logMessage($result, 'ERR'); + return $result; + } + + return true; + } + + /** + * Shift postings in the backend. + * + * @param mixed $accountIdFrom The account(s) to shift postings from. + * @param string $accountIdTo The account to shift postings to. + * + * @return mixed True or PEAR_Error + */ + function _shiftPostings($accountIdFrom, $accountIdTo) + { + if (!is_array($accountIdFrom)) { + $accountIdFrom = array($accountIdFrom); + } + + foreach ($accountIdFrom as $key => $value) { + $accountIdFrom[$key] = $this->_db->quoteSmart($value); + } + + $fields = array('posting_asset', 'posting_account'); + foreach ($fields as $field) { + $query = sprintf('UPDATE %s SET' . + ' %s = ? ' . + 'WHERE posting_owner = ? AND %s IN (!)', + $this->_params['table_postings'], $field, $field); + $values = array($accountIdTo, $this->_ledger, implode(',', $accountIdFrom)); + + /* Log the query at a DEBUG log level. */ + Horde::logMessage(sprintf('Fima_Driver_sql::_shiftPostings(): %s', $query), 'DEBUG'); + + /* Attempt the update query. */ + $result = $this->_db->query($query, $values); + + if (is_a($result, 'PEAR_Error')) { + Horde::logMessage($result, 'ERR'); + return $result; + } + } + + return true; + } + + /** + * Deletes all postings and accounts. + * + * @param mixed $accounts boolean or account_type + * @param mixed $accounts boolean or posting_type. + * + * @return mixed True or PEAR_Error + */ + function _deleteAll($accounts, $postings) + { + /* Delete postings. */ + if ($postings) { + $query = sprintf('DELETE FROM %s WHERE posting_owner = ?', + $this->_params['table_postings']); + $values = array($this->_ledger); + + /* Filter. */ + if ($postings !== true) { + $query .= ' AND posting_type = ?'; + $values[] = $postings; + } + + /* Log the query at a DEBUG log level. */ + Horde::logMessage(sprintf('Fima_Driver_sql::_deleteAll(): %s', $query), 'DEBUG'); + + /* Attempt the delete query. */ + $result = $this->_db->query($query, $values); + + if (is_a($result, 'PEAR_Error')) { + Horde::logMessage($result, 'ERR'); + return $result; + } + } else { + /* If postings aren't deleted, don't delete accounts. */ + return false; + } + + /* Delete Accounts */ + if ($accounts) { + $query = sprintf('DELETE FROM %s WHERE account_owner = ?', + $this->_params['table_accounts']); + $values = array($this->_ledger); + + /* Filter. */ + if ($accounts !== true) { + $query .= ' AND account_type = ?'; + $values[] = $accounts; + } + + /* Log the query at a DEBUG log level. */ + Horde::logMessage(sprintf('Fima_Driver_sql::_deleteAll(): %s', $query), 'DEBUG'); + + /* Attempt the delete query. */ + $result = $this->_db->query($query, $values); + + if (is_a($result, 'PEAR_Error')) { + Horde::logMessage($result, 'ERR'); + return $result; + } + } + + return true; + } + + + /** + * Build the where clause for a query using the passed filters + * Attention: does not include the WHERE keyword, add WHERE 1=1 manually in the query + * + * @param array $filters Array of filters, syntax: array(field, value [, operator = '=' [, andor = 'AND']]) + * @param array $prefix optional prefix for fields + * + * @return integer number of added filters + */ + function _addFilters($filters, &$query, &$values, $prefix = '') + { + $filtercnt = 0; + + foreach ($filters as $filter) { + // and/or + if (!isset($filter[3])) { + $filter[3] = 'AND'; + } else { + $filter[3] = strtoupper($filter[3]); + if (!in_array($filter[3], array('AND', 'OR'))) { + $filter[3] = 'AND'; + } + } + + // subfilter + if (is_array($filter[0])) { + $query .= ' ' . $filter[3] . ' (1=1'; + $filtercnt += $this->_addFilters($filter[0], $query, $values, $prefix); + $query .= ')'; + continue; + } + + // fix operator + if (!isset($filter[2])) { + $filter[2] = '='; + } else { + $filter[2] = strtoupper($filter[2]); + if (!in_array($filter[2], array('<', '>', '<=', '>=', '=', '<>', '!=', 'IN', 'NOT IN', 'IS', 'IS NOT', 'LIKE', 'NOT LIKE'))) { + $filter[2] = '='; + } + } + + // fix operator for null values + if ($filter[1] === null) { + if (!in_array($filter[2], array('IS', 'IS NOT'))) { + $filter[2] = in_array($filter[2], array('=', 'IN', 'LIKE')) ? 'IS' : 'IS NOT'; + } + } elseif (in_array($filter[2], array('IS', 'IS NOT'))) { + $filter[2] = ($filter[2] == 'IS') ? '=' : '!='; + } + + // fix operator for array value + prepare values + if (is_array($filter[1])) { + if (!in_array($filter[2], array('IN', 'NOT IN'))) { + $filter[2] = in_array($filter[2], array('=', 'IS', 'LIKE')) ? 'IN' : 'NOT IN'; + } + $filterph = '(!)'; + foreach ($filter[1] as $key => $value) { + $filter[1][$key] = $this->_db->quoteSmart($value); + } + $filter[1] = implode(',', $filter[1]); + } else { + if (in_array($filter[2], array('IN', 'NOT IN'))) { + $filter[2] = ($filter[2] == 'IN') ? '=' : '!='; + } + $filterph = '?'; + } + + // fix != operator + if ($filter[2] == '!=') { + $filter[2] = '<>'; + } + + $query .= sprintf(' ' . $filter[3] . ' ' . $prefix . '%s %s %s', $filter[0], $filter[2], $filterph); + $values[] = $filter[1]; + $filtercnt++; + } + + return $filtercnt; + } + + /** + * Attempts to open a connection to the SQL server. + * + * @return boolean True on success; PEAR_Error on failure. + */ + function initialize() + { + try { + $this->_db = $GLOBALS['injector']->getInstance('Horde_Db_Pear')->getDb('rw', 'fima', 'storage'); + } catch (Horde_Exception $e) { + return PEAR::raiseError($e->getMessage()); + } + + return true; + } + +} diff --git a/fima/postings.php b/fima/postings.php new file mode 100644 index 000000000..5766c364d --- /dev/null +++ b/fima/postings.php @@ -0,0 +1,733 @@ + + * + * See the enclosed file COPYING for license information (GPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/gpl.html. + * + * @author Thomas Trethan + */ + +@define('FIMA_BASE', dirname(__FILE__)); +require_once FIMA_BASE . '/lib/base.php'; + +$vars = Horde_Variables::getDefaultVariables(); + +/* Get the current action ID. */ +$actionID = Horde_Util::getFormData('actionID'); + +/* Change posting type. */ +if (($postingtype = Horde_Util::getFormData('postingtype')) !== null) { + $postingtypeold = $prefs->getValue('active_postingtype'); + $prefs->setValue('active_postingtype', $postingtype); +} + +/* Get closed period. */ +$closedperiod = (int)$prefs->getValue('closed_period'); + +/* Create page array. */ +$pageOb = array(); +$pageOb['url'] = Horde::url('postings.php'); +if (($pageOb['page'] = Horde_Util::getFormData('page')) === null) { + $pageOb['page'] = $prefs->getValue('startpage'); +} +$pageOb['mode'] = 'list'; + +$title = _("My Postings"); +$ledger = Fima::getActiveLedger(); +$filters = array(); + +switch ($actionID) { +case 'change_sort': + /* Sort out the sorting values. */ + if (($sortby = Horde_Util::getFormData('sortby')) !== null) { + $prefs->setValue('sortby', $sortby); + } + if (($sortdir = Horde_Util::getFormData('sortdir')) !== null) { + $prefs->setValue('sortdir', $sortdir); + } + break; + +case 'search_postings': + /* If we're searching, only list those postings that match the search result. */ + $_SESSION['fima_search'] = array('type' => Horde_Util::getFormData('search_type'), + 'date_start' => Horde_Util::getFormData('search_date_start'), + 'date_end' => Horde_Util::getFormData('search_date_end'), + 'asset' => Horde_Util::getFormData('search_asset'), + 'account' => Horde_Util::getFormData('search_account'), + 'desc' => Horde_Util::getFormData('search_desc'), + 'amount_start' => Horde_Util::getFormData('search_amount_start'), + 'amount_end' => Horde_Util::getFormData('search_amount_end'), + 'eo' => Horde_Util::getFormData('search_eo')); + + /* Build filters. */ + if ($_SESSION['fima_search']['type'] !== null) { + $prefs->setValue('active_postingtype', $_SESSION['fima_search']['type']); + } + if ($_SESSION['fima_search']['date_start'] !== null) { + if (is_array($_SESSION['fima_search']['date_start'])) { + $_SESSION['fima_search']['date_start'] = mktime(0, 0, 0, $_SESSION['fima_search']['date_start']['month'], + $_SESSION['fima_search']['date_start']['day'], + $_SESSION['fima_search']['date_start']['year']); + } else { + $_SESSION['fima_search']['date_start'] = (int)$_SESSION['fima_search']['date_start']; + } + } + if ($_SESSION['fima_search']['date_end'] !== null) { + if (is_array($_SESSION['fima_search']['date_end'])) { + $_SESSION['fima_search']['date_end'] = mktime(0, 0, 0, $_SESSION['fima_search']['date_end']['month'], + $_SESSION['fima_search']['date_end']['day'], + $_SESSION['fima_search']['date_end']['year']); + } else { + $_SESSION['fima_search']['date_end'] = (int)$_SESSION['fima_search']['date_end']; + } + } + if ($_SESSION['fima_search']['asset'] !== null) { + if (count($_SESSION['fima_search']['asset']) == 0) { + unset($_SESSION['fima_search']['asset']); + } + } + if ($_SESSION['fima_search']['account'] !== null) { + if (count($_SESSION['fima_search']['account']) == 0) { + unset($_SESSION['fima_search']['account']); + } + } + if ($_SESSION['fima_search']['desc'] !== null) { + if ($_SESSION['fima_search']['desc'] === '') { + unset($_SESSION['fima_search']['desc']); + } + } + if ($_SESSION['fima_search']['amount_start'] !== null) { + if ($_SESSION['fima_search']['amount_start'] === '') { + unset($_SESSION['fima_search']['amount_start']); + } + } + if ($_SESSION['fima_search']['amount_end'] !== null) { + if ($_SESSION['fima_search']['amount_end'] === '') { + unset($_SESSION['fima_search']['amount_end']); + } + } + if (isset($_SESSION['fima_search']['amount_start']) && isset($_SESSION['fima_search']['amount_end'])) { + if ((double)$_SESSION['fima_search']['amount_start'] > (double)$_SESSION['fima_search']['amount_end']) { + $tmp = $_SESSION['fima_search']['amount_start']; + $_SESSION['fima_search']['amount_start'] = $_SESSION['fima_search']['amount_end']; + $_SESSION['fima_search']['amount_end'] = $tmp; + } + } + if ($_SESSION['fima_search']['eo'] !== null) { + if ($_SESSION['fima_search']['eo'] == -1) { + unset($_SESSION['fima_search']['eo']); + } + } + + break; + +case 'clear_search': + unset($_SESSION['fima_search']); + break; + +case 'add_postings': + $pageOb['mode'] = 'edit'; + $pageOb['url'] = Horde_Util::addParameter($pageOb['url'], 'actionID', 'add_postings'); + $actionID = 'save_postings'; + $postings = array(); + $title = _("Add Postings"); + break; + +case 'edit_postings': + $postingset = Horde_Util::getFormData('indices'); + if ($postingset !== null) { + $pageOb['mode'] = 'edit'; + $pageOb['url'] = Horde_Util::addParameter($pageOb['url'], 'actionID', 'add_postings'); + $actionID = 'save_postings'; + $filters[] = array('id', $postingset); + $title = _("Edit Postings"); + } + break; + +case 'shift_postings': + $postingset = Horde_Util::getFormData('indices'); + if ($postingset !== null) { + $pageOb['mode'] = 'shift'; + $actionID = 'update_postings'; + $filters[] = array('id', $postingset); + $title = _("Shift Postings"); + } + break; + +case 'transfer_postings': + $pageOb['mode'] = 'transfer'; + $actionID = 'copymove_postings'; + $postings = array(); + $title = _("Transfer Postings"); + break; + +case 'save_postings': + /* Get the form values. */ + $postingset = Horde_Util::getFormData('posting_id'); + + $share = &$GLOBALS['fima_shares']->getShare($ledger); + if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { + $notification->push(sprintf(_("Access denied saving postings to %s."), $share->get('name')), 'horde.error'); + Horde::url('postings.php', true)->redirect(); + } + if ($postingset !== null) { + $pageOb['mode'] = 'edit'; + $title = _("Edit Postings"); + $posting_owner = $ledger; + $posting_type = $prefs->getValue('active_postingtype'); + + $posting_dates = Horde_Util::getFormData('date'); + $posting_assets = Horde_Util::getFormData('asset'); + $posting_accounts = Horde_Util::getFormData('account'); + $posting_eos = Horde_Util::getFormData('eo'); + $posting_amounts = Horde_Util::getFormData('amount'); + $posting_descs = Horde_Util::getFormData('desc'); + + $postings = array(); + $savecount = 0; + + $storage = &Fima_Driver::singleton($ledger); + foreach($postingset as $index => $posting_id) { + $posting_valid = true; + + if ($posting_dates[$index] !== '' || $posting_assets[$index] !== '' || $posting_accounts[$index] !== '' || + $posting_amounts[$index] !== '' || $posting_descs[$index] !== '') { + + $posting_date = Fima::convertDateToStamp($posting_dates[$index], Fima::convertDateFormat($prefs->getValue('date_format'))); + $posting_asset = $posting_assets[$index]; + $posting_account = $posting_accounts[$index]; + $posting_eo = (int)(bool)$posting_eos[$index]; + $posting_amount = Fima::convertAmountToValue($posting_amounts[$index]); + $posting_desc = $posting_descs[$index]; + + /* Check posting date. */ + if ($posting_date === false) { + $posting_valid = false; + } elseif ($posting_date <= $closedperiod) { + $posting_valid = false; + } + + /* Check asset account and account. */ + if ($posting_asset === '' || $posting_account === '') { + $posting_valid = false; + } elseif ($posting_asset === $posting_account) { + continue; + } + + /* Fix amount sign. */ + if ($prefs->getValue('expenses_sign') == 0) { + $account = Fima::getAccount($posting_account); + if (!is_a($account, 'PEAR_Error') && $account !== null) { + if ($account['type'] == FIMA_ACCOUNTTYPE_EXPENSE) { + $posting_amount *= -1; + } + } + } + + /* If $posting_id is set, we're modifying an existing account. Otherwise, + * we're adding a new posting with the provided attributes. */ + if ($posting_valid) { + if ($posting_id != null) { + $result = $storage->modifyPosting($posting_id, $posting_type, $posting_date, $posting_asset, + $posting_account, $posting_eo, $posting_amount, $posting_desc); + } else { + $result = $storage->addPosting($posting_type, $posting_date, $posting_asset, $posting_account, + $posting_eo, $posting_amount, $posting_desc); + } + + // Check our results. + if (is_a($result, 'PEAR_Error')) { + $notification->push(sprintf(_("There was a problem saving the posting: %s."), $result->getMessage()), 'horde.error'); + $posting_valid = false; + } else { + $savecount++; + } + } + + /* Reload invalid or unsaved postings. */ + if (!$posting_valid) { + $postings[] = array('posting_id' => $posting_id, + 'owner' => $ledger, + 'type' => $posting_type, + 'date' => $posting_date, + 'asset' => $posting_asset, + 'account' => $posting_account, + 'eo' => $posting_eo, + 'amount' => $posting_amount, + 'desc' => $posting_desc); + } + } + } + + if ($savecount > 0) { + $notification->push(sprintf(_("Saved %d postings."), $savecount), 'horde.success'); + } + if (count($postings) > 0) { + $notification->push(sprintf(_("%d postings not saved."), count($postings)), 'horde.error'); + } else { + /* Return to the posting list. */ + Horde::url('postings.php', true)->redirect(); + } + } else { + /* Return to the posting list. */ + Horde::url('postings.php', true)->redirect(); + } + break; + +case 'delete_postings': + /* Delete postings if we're provided with valid account IDs. */ + $postingset = Horde_Util::getFormData('indices'); + + $share = &$GLOBALS['fima_shares']->getShare($ledger); + if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) { + $notification->push(sprintf(_("Access denied deleting postings from %s."), $share->get('name')), 'horde.error'); + Horde::url('postings.php', true)->redirect(); + } + if ($postingset !== null) { + $storage = &Fima_Driver::singleton($ledger); + $delcount = 0; + foreach($postingset as $index => $posting_id) { + $result = $storage->deletePosting($posting_id); + if (is_a($result, 'PEAR_Error')) { + $notification->push(sprintf(_("There was a problem deleting posting #%d: %s"), + $index, $result->getMessage()), 'horde.error'); + } else { + $delcount++; + } + } + if ($delcount > 0) { + $notification->push(sprintf(_("Deleted %d postings."), $delcount), 'horde.success'); + } + } + + /* Return to the posting list. */ + Horde::url('postings.php', true)->redirect(); + +case 'update_postings': + /* Get the form values. */ + $postingset = Horde_Util::getFormData('posting_id'); + + $share = &$GLOBALS['fima_shares']->getShare($ledger); + if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { + $notification->push(sprintf(_("Access denied shifting postings in %s."), $share->get('name')), 'horde.error'); + Horde::url('postings.php', true)->redirect(); + } + if ($postingset !== null) { + $posting_type = Horde_Util::getFormData('type'); + $posting_asset = Horde_Util::getFormData('asset'); + $posting_account = Horde_Util::getFormData('account'); + + if ($posting_type || $posting_asset || $posting_account) { + $storage = &Fima_Driver::singleton($ledger); + $shiftcount = 0; + + foreach($postingset as $index => $posting_id) { + $result = $storage->ShiftPosting($posting_id, $posting_type, $posting_asset, $posting_account); + if (is_a($result, 'PEAR_Error')) { + $notification->push(sprintf(_("There was a problem shifting posting #%d: %s"), + $index, $result->getMessage()), 'horde.error'); + } else { + $shiftcount++; + } + } + if ($shiftcount > 0) { + $notification->push(sprintf(_("Shifted %d postings."), $shiftcount), 'horde.success'); + } + } + } + + /* Return to the posting list. */ + Horde::url('postings.php', true)->redirect(); + +case 'copymove_postings': + $share = &$GLOBALS['fima_shares']->getShare($ledger); + if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { + $notification->push(sprintf(_("Access denied transfering postings in %s."), $share->get('name')), 'horde.error'); + Horde::url('postings.php', true)->redirect(); + } + if (!$share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE) && (!Horde_Util::getFormData('keep') || Horde_Util::getFormData('delete'))) { + $notification->push(sprintf(_("Access denied transfering postings in %s."), $share->get('name')), 'horde.error'); + Horde::url('postings.php', true)->redirect(); + } + $type_from = Horde_Util::getFormData('type_from'); + $period_from = Horde_Util::getFormData('period_from'); + $keep = Horde_Util::getFormData('keep'); + $summarize = Horde_Util::getFormData('summarize'); + $summarize_account = Horde_Util::getFormData('summarize_post_account'); + $type_to = Horde_Util::getFormData('type_to'); + $period_to = Horde_Util::getFormData('period_to'); + $delete = Horde_Util::getFormData('delete'); + + $period_from_start = mktime(0, 0, 0, ($period_from['month'] === '') ? 1 : $period_from['month'], 1, (int)$period_from['year']); + $period_from_end = mktime(0, 0, 0, ($period_from['month'] === '') ? 12 : $period_from['month'] + 1, ($period_from['month'] === '') ? 31 : 0, (int)$period_from['year']); + $period_to_start = mktime(0, 0, 0, ($period_to['month'] === '') ? 1 : $period_to['month'], 1, (int)$period_to['year']); + $period_to_end = mktime(0, 0, 0, ($period_to['month'] === '') ? 12 : $period_to['month'] + 1, ($period_to['month'] === '') ? 31 : 0, (int)$period_to['year']); + + $storage = &Fima_Driver::singleton($ledger); + + /* Delete existing. */ + if ($delete) { + $transferfilters = array(array('type', $type_to), + array('date', $period_to_start, '>='), + array('date', $period_to_end, '<=')); + $postings = Fima::listPostings($transferfilters); + $delcount = 0; + foreach ($postings as $postingId => $posting) { + $result = $storage->deletePosting($postingId); + if (is_a($result, 'PEAR_Error')) { + $notification->push(sprintf(_("There was a problem deleting an existing posting: %s"), + $result->getMessage()), 'horde.error'); + } else { + $delcount++; + } + } + if ($delcount > 0) { + $notification->push(sprintf(_("Deleted %d existing postings."), $delcount), 'horde.success'); + } + } + + /* Copy postings. */ + $transferfilters = array(array('type', $type_from), + array('date', $period_from_start, '>='), + array('date', $period_from_end, '<=')); + $postings = Fima::listPostings($transferfilters); + + if ($summarize != 'none') { + $accounts = Fima::listAccounts(); + $postingscopy = array(); + + foreach ($postings as $postingId => $posting) { + $asset = (isset($accounts[$posting['asset']])) + ? (($accounts[$posting['asset']]['parent_id'] !== null) ? $accounts[$posting['asset']]['parent_id'] : $accounts[$posting['asset']]['account_id']) + : $posting['asset']; + $account = (isset($accounts[$posting['account']])) + ? (($accounts[$posting['account']]['parent_id'] !== null) ? $accounts[$posting['account']]['parent_id'] : $accounts[$posting['account']]['account_id']) + : $posting['account']; + + if ($summarize == 'combine') { + $copyId = $asset . '_' . $account . '_' . strftime('%Y%m', $posting['date']); + + if (isset($postingscopy[$copyId])) { + $postingscopy[$copyId]['amount'] += $posting['amount']; + } else { + $postingscopy[$copyId] = $posting; + $postingscopy[$copyId]['date'] = mktime(0, 0, 0, ($period_to['month'] === '') ? strftime('%m', $posting['date']) : $period_to['month'], 1, (int)$period_to['year']); + $postingscopy[$copyId]['asset'] = $asset; + $postingscopy[$copyId]['account'] = $account; + $postingscopy[$copyId]['eo'] = 0; + $postingscopy[$copyId]['desc'] = _("Summarized"); + } + } elseif ($summarize == 'post') { + $copyIdAsset = $asset . '_' . strftime('%Y%m', $posting['date']); + $copyIdAccount = $account . '_' . strftime('%Y%m', $posting['date']); + + if (isset($postingscopy[$copyIdAsset])) { + $postingscopy[$copyIdAsset]['amount'] += $posting['amount']; + } else { + $postingscopy[$copyIdAsset] = $posting; + $postingscopy[$copyIdAsset]['date'] = mktime(0, 0, 0, ($period_to['month'] === '') ? strftime('%m', $posting['date']) : $period_to['month'], 1, (int)$period_to['year']); + $postingscopy[$copyIdAsset]['asset'] = $asset; + $postingscopy[$copyIdAsset]['account'] = $summarize_account; + $postingscopy[$copyIdAsset]['eo'] = 0; + $postingscopy[$copyIdAsset]['desc'] = _("Summarized"); + } + + if (isset($postingscopy[$copyIdAccount])) { + $postingscopy[$copyIdAccount]['amount'] += $posting['amount']; + } else { + $postingscopy[$copyIdAccount] = $posting; + $postingscopy[$copyIdAccount]['date'] = mktime(0, 0, 0, ($period_to['month'] === '') ? strftime('%m', $posting['date']) : $period_to['month'], 1, (int)$period_to['year']); + $postingscopy[$copyIdAccount]['asset'] = $summarize_account; + $postingscopy[$copyIdAccount]['account'] = $account; + $postingscopy[$copyIdAccount]['eo'] = 0; + $postingscopy[$copyIdAccount]['desc'] = _("Summarized"); + } + } + } + } else { + $postingscopy = &$postings; + foreach ($postingscopy as $postingId => $posting) { + $postingscopy[$postingId]['date'] = mktime(0, 0, 0, ($period_to['month'] === '') ? strftime('%m', $posting['date']) : $period_to['month'], strftime('%d', $posting['date']), (int)$period_to['year']); + } + } + + $addcount = 0; + foreach ($postingscopy as $postingId => $posting) { + $result = $storage->addPosting($type_to, $posting['date'], $posting['asset'], $posting['account'], + $posting['eo'], $posting['amount'], $posting['desc']); + + // Check our results. + if (is_a($result, 'PEAR_Error')) { + $notification->push(sprintf(_("There was a problem saving the posting: %s."), $result->getMessage()), 'horde.error'); + } else { + $addcount++; + } + } + if ($addcount > 0) { + $notification->push(sprintf($summarize ? _("Summarized %d postings.") : _("Transfered %d postings."), $addcount), 'horde.success'); + } + + /* Delete original postings. */ + if (!$keep) { + $delcount = 0; + foreach ($postings as $postingId => $posting) { + $result = $storage->deletePosting($postingId); + if (is_a($result, 'PEAR_Error')) { + $notification->push(sprintf(_("There was a problem deleting an original posting: %s"), + $result->getMessage()), 'horde.error'); + } else { + $delcount++; + } + } + if ($delcount > 0) { + $notification->push(sprintf(_("Deleted %d original postings."), $delcount), 'horde.success'); + } + } + + /* Return to the posting list. */ + Horde::url('postings.php', true)->redirect(); + +default: + break; +} + +/* Print. */ +$print_view = (bool)Horde_Util::getFormData('print'); +if (!$print_view && $pageOb['mode'] == 'list') { + $print_link = Horde_Util::addParameter(Horde::url('postings.php'), array('print' => 1)); +} + +/* Filters. */ +$postingtype = $prefs->getValue('active_postingtype'); +$filters[] = array('type', $postingtype); +if (isset($_SESSION['fima_search'])) { + $title = _("Search Results"); + foreach ($_SESSION['fima_search'] as $searchId => $search) { + if ($search === null) { + continue; + } + switch ($searchId) { + case 'date_start': $filters[] = array('date', $search, '>='); break; + case 'date_end': $filters[] = array('date', $search, '<='); break; + case 'asset': $filters[] = array(array(array('asset', $search), array('account', $search, '=', 'OR'))); break; + case 'account': $filters[] = array('account', $search); break; + case 'desc': $filters[] = array('desc', Fima::convertWildcards($search), 'LIKE'); break; + case 'amount_start': $filters[] = array('amount', Fima::convertAmountToValue($search), '>='); break; + case 'amount_end': $filters[] = array('amount', Fima::convertAmountToValue($search), '<='); break; + case 'eo': $filters[] = array('eo', (int)(bool)$search); + default: break; + } + } +} + +/* Retrieve accounts, accounttypes and postings (if not set before). */ +$accounts = Fima::listAccounts(); +$accounttypes = Fima::getAccountTypes(); +if (!isset($postings)) { + $postings = Fima::listPostings($filters, ($pageOb['mode'] != 'list' || $print_view) ? null : $pageOb['page']); +} + +$pageOb['postings_perpage'] = $prefs->getValue('max_postings'); +$pageOb['postings_total'] = Fima::getPostingsCount(); + +if ($pageOb['mode'] == 'edit') { + /* Fix amount sign. */ + if ($prefs->getValue('expenses_sign') == 0) { + foreach ($postings as $postingId => $posting) { + if ($accounts[$posting['account']]['type'] == FIMA_ACCOUNTTYPE_EXPENSE) { + $postings[$postingId]['amount'] *= -1; + } + } + } + /* Add blank postings. */ + for ($i = count($postings); $i < max($pageOb['postings_perpage'], 12); $i++) { + $postings[] = array('posting_id' => null, + 'owner' => $ledger, + 'type' => $postingtype, + 'date' => null, + 'asset' => null, + 'account' => null, + 'eo' => null, + 'amount' => null, + 'desc' => null); + } +} + +/* Add account information to postings and create flags list. */ +if ($pageOb['mode'] == 'list') { + $flags = array(); + foreach ($postings as $postingId => $posting) { + $postings[$postingId]['desc'] = htmlspecialchars($posting['desc']); + + if (isset($accounts[$posting['asset']])) { + $postings[$postingId]['asset_label'] = htmlspecialchars($accounts[$posting['asset']]['label']); + $postings[$postingId]['asset_closed'] = $accounts[$posting['asset']]['closed']; + } else { + $postings[$postingId]['asset_label'] = _("Unknown"); + $postings[$postingId]['asset_closed'] = false; + } + if (isset($accounts[$posting['account']])) { + $postings[$postingId]['account_label'] = htmlspecialchars($accounts[$posting['account']]['label']); + $postings[$postingId]['account_type'] = $accounts[$posting['account']]['type']; + $postings[$postingId]['account_type_eo'] = sprintf($posting['eo'] ? _("e.o. %s") : _("%s") , $accounttypes[$accounts[$posting['account']]['type']]); + $postings[$postingId]['account_closed'] = $accounts[$posting['account']]['closed']; + } else { + $postings[$postingId]['account_label'] = _("Unknown"); + $postings[$postingId]['account_type'] = ''; + $postings[$postingId]['account_type_eo'] = ''; + $postings[$postingId]['account_closed'] = false; + } + + $flag = 0; + $flagpos = 0; + foreach ($accounttypes as $typeId => $typeLabel) { + if ($postings[$postingId]['account_type'] == $typeId) { + $flag |= pow(2, $flagpos); + } + $flagpos++; + } + $flags[] = $flag; + } +} + +/* Set up page information. */ +$pageOb['page_count'] = ceil($pageOb['postings_total'] / $pageOb['postings_perpage']); +if ($pageOb['page'] < 0) { + $pageOb['page'] += $pageOb['page_count'] + 1; +} +if ($pageOb['mode'] == 'list') { + if ($pageOb['postings_total'] == 0) { + $pageOb['postings_count'] = _("No Postings"); + } else { + $pageOb['postings_count'] = sprintf(_("%s to %s of %s Postings"), + ($pageOb['page'] - 1) * $pageOb['postings_perpage'] + 1, + min($pageOb['page'] * $pageOb['postings_perpage'], $pageOb['postings_total']), + $pageOb['postings_total']); + } +} + +/* Get sorting. */ +if ($pageOb['mode'] == 'list' || $pageOb['mode'] == 'edit') { + $sortby = $prefs->getValue('sortby'); + $sortdir = $prefs->getValue('sortdir'); + $sorturl = Horde_Util::addParameter($pageOb['url'], 'sortdir', ($sortdir) ? 0 : 1); +} + +/* Generate page links. */ +if ($pageOb['mode'] == 'list') { + $graphicsdir = Horde_Themes::img(null, 'horde'); + if ($pageOb['page'] == 1) { + $pageOb['pages_first'] = Horde::img('nav/first-grey.png', null, null, $graphicsdir); + $pageOb['pages_prev'] = Horde::img('nav/left-grey.png', null, null, $graphicsdir); + } else { + $first_url = Horde_Util::addParameter($pageOb['url'], 'page', 1); + $pageOb['pages_first'] = Horde::link($first_url, _("First Page")) . Horde::img('nav/first.png', '<<', null, $graphicsdir) . ''; + $prev_url = Horde_Util::addParameter($pageOb['url'], 'page', $pageOb['page'] - 1); + $pageOb['pages_prev'] = Horde::link($prev_url, _("Previous Page"), '', '', '', '', '', array('id' => 'prev')) . Horde::img('nav/left.png', '<', null, $graphicsdir) . ''; + } + if ($pageOb['page'] == $pageOb['page_count']) { + $pageOb['pages_last'] = Horde::img('nav/last-grey.png', null, null, $graphicsdir); + $pageOb['pages_next'] = Horde::img('nav/right-grey.png', null, null, $graphicsdir); + } else { + $next_url = Horde_Util::addParameter($pageOb['url'], 'page', $pageOb['page'] + 1); + $pageOb['pages_next'] = Horde::link($next_url, _("Next Page"), '', '', '', '', '', array('id' => 'next')) . Horde::img('nav/right.png', '>', null, $graphicsdir) . ''; + $last_url = Horde_Util::addParameter($pageOb['url'], 'page', $pageOb['page_count']); + $pageOb['pages_last'] = Horde::link($last_url, _("Last Page")) . Horde::img('nav/last.png', '>>', null, $graphicsdir) . ''; + } +} + +/* Some browsers have trouble with hidden overflow in table cells but not in divs. */ +if ($GLOBALS['browser']->hasQuirk('no_hidden_overflow_tables')) { + $overflow_begin = '
'; + $overflow_end = '
'; +} else { + $overflow_begin = ''; + $overflow_end = ''; +} + +/* Set up row Ids. */ +$rowId = 0; + +/* Get date and amount format. */ +$datefmt = $prefs->getValue('date_format'); +$amountfmt = $prefs->getValue('amount_format'); + +$js_onload = array(); + +if ($pageOb['mode'] == 'edit') { + /* Fix date format. */ + $datefmt = Fima::convertDateFormat($datefmt); + + /* Add current date in first field if no postings. */ + foreach ($postings as $key => $value) { + if ($value['date'] == '') { + $js_onload[] = '$("date1").setValue(' . Horde_Serialize::serialize(strftime($datefmt), Horde_Serialize::JSON, 'UTF-8') . ')'; + } + break; + } + + /* Select first date field. */ + $js_onload[] = 'updateResult()'; + $js_onload[] = 'updateAssetResult(_getall("asset[]")[0])'; + $js_onload[] = '$("date1").focus().select()'; +} + +Horde::addInlineScript($js_onload, 'dom'); + +require FIMA_TEMPLATES . '/common-header.inc'; +if ($print_view) { + require_once $registry->get('templates', 'horde') . '/javascript/print.js'; +} else { + require FIMA_TEMPLATES . '/menu.inc'; +} +if ($browser->hasFeature('javascript')) { + require FIMA_TEMPLATES . '/postings/javascript_' . $pageOb['mode'] . '.inc'; +} + +/* Get current asset results. */ +if ($pageOb['mode'] == 'edit') { + $assetresults = Fima::getAssetResults($prefs->getValue('active_postingtype')); +} + +/* Generate tabs. */ +if ($pageOb['mode'] != 'transfer' && !$print_view) { + $tabs = new Horde_Core_Ui_Tabs('postingtype', $vars); + $postingtypes = Fima::getPostingTypes(); + foreach ($postingtypes as $typeValue => $typeLabel) { + $tabs->addTab($typeLabel, $pageOb['url'], $typeValue); + } + echo $tabs->render($prefs->getValue('active_postingtype')); +} + +/* Generate list. */ +if (!$print_view) { + require FIMA_TEMPLATES . '/postings/header.inc'; +} + +if ($pageOb['mode'] == 'list' && $pageOb['page_count'] == 0) { + require FIMA_TEMPLATES . '/postings/empty.inc'; +} else { + $form = 1; + if (!$print_view) { + require FIMA_TEMPLATES . '/postings/navbar.inc'; + require FIMA_TEMPLATES . '/postings/actions.inc'; + } + + require FIMA_TEMPLATES . '/postings/posting_headers.inc'; + require FIMA_TEMPLATES . '/postings/' . $pageOb['mode'] . '.inc'; + require FIMA_TEMPLATES . '/postings/posting_footers.inc'; + + /* If there are 20 postings or less, don't show the actions/navbar again. */ + if ((count($postings) > 20 || $pageOb['mode'] != 'list') && !$print_view) { + $form = 2; + require FIMA_TEMPLATES . '/postings/actions.inc'; + require FIMA_TEMPLATES . '/postings/navbar.inc'; + } else { + /* TODO */ + echo '
' . _("No unread messages") . '
- + @@ -74,14 +74,14 @@ if ($this->event->initialized && $this->event->alarm > 0): - + - + diff --git a/luxor/templates/common-header.inc b/luxor/templates/common-header.inc index 07a341fa2..83626c71c 100644 --- a/luxor/templates/common-header.inc +++ b/luxor/templates/common-header.inc @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/mnemo/data.php b/mnemo/data.php index 93239ec06..88ed5e89b 100644 --- a/mnemo/data.php +++ b/mnemo/data.php @@ -34,7 +34,7 @@ $templates = array( ); if ($GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes') !== true && $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes') <= Mnemo::countMemos()) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d notes."), $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes')), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d notes."), $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes')), ENT_COMPAT, 'UTF-8'); if (!empty($conf['hooks']['permsdenied'])) { $message = Horde::callHook('_perms_hook_denied', array('mnemo:max_notes'), 'horde', $message); } @@ -121,7 +121,7 @@ if (is_array($next_step)) { $num_memos = Mnemo::countMemos(); foreach ($next_step as $row) { if ($max_memos !== true && $num_memos >= $max_memos) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d notes."), $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes')), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d notes."), $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_notes')), ENT_COMPAT, 'UTF-8'); if (!empty($conf['hooks']['permsdenied'])) { $message = Horde::callHook('_perms_hook_denied', array('mnemo:max_notes'), 'horde', $message); } diff --git a/mnemo/lib/Driver/sql.php b/mnemo/lib/Driver/sql.php index cf58f79bb..abc009e96 100644 --- a/mnemo/lib/Driver/sql.php +++ b/mnemo/lib/Driver/sql.php @@ -163,10 +163,10 @@ class Mnemo_Driver_sql extends Mnemo_Driver { ' VALUES (?, ?, ?, ?, ?, ?)'; $values = array($this->_notepad, $noteId, - Horde_String::convertCharset($desc, $GLOBALS['registry']->getCharset(), $this->_params['charset']), - Horde_String::convertCharset($body, $GLOBALS['registry']->getCharset(), $this->_params['charset']), - Horde_String::convertCharset($category, $GLOBALS['registry']->getCharset(), $this->_params['charset']), - Horde_String::convertCharset($uid, $GLOBALS['registry']->getCharset(), $this->_params['charset'])); + Horde_String::convertCharset($desc, 'UTF-8', $this->_params['charset']), + Horde_String::convertCharset($body, 'UTF-8', $this->_params['charset']), + Horde_String::convertCharset($category, 'UTF-8', $this->_params['charset']), + Horde_String::convertCharset($uid, 'UTF-8', $this->_params['charset'])); /* Log the query at a DEBUG log level. */ Horde::logMessage(sprintf('Mnemo_Driver_sql::add(): %s', $query), 'DEBUG'); @@ -208,13 +208,13 @@ class Mnemo_Driver_sql extends Mnemo_Driver { $query = 'UPDATE ' . $this->_params['table'] . ' SET memo_desc = ?, memo_body = ?'; - $values = array(Horde_String::convertCharset($desc, $GLOBALS['registry']->getCharset(), $this->_params['charset']), - Horde_String::convertCharset($body, $GLOBALS['registry']->getCharset(), $this->_params['charset'])); + $values = array(Horde_String::convertCharset($desc, 'UTF-8', $this->_params['charset']), + Horde_String::convertCharset($body, 'UTF-8', $this->_params['charset'])); // Don't change the category if it isn't provided. if (!is_null($category)) { $query .= ', memo_category = ?'; - $values[] = Horde_String::convertCharset($category, $GLOBALS['registry']->getCharset(), $this->_params['charset']); + $values[] = Horde_String::convertCharset($category, 'UTF-8', $this->_params['charset']); } $query .= ' WHERE memo_owner = ? AND memo_id = ?'; array_push($values, $this->_notepad, $noteId); diff --git a/mnemo/memo.php b/mnemo/memo.php index 3a5b47dd1..310b43a25 100644 --- a/mnemo/memo.php +++ b/mnemo/memo.php @@ -72,7 +72,7 @@ case 'add_memo': /* Check permissions. */ if ($injector->getInstance('Horde_Perms')->hasAppPermission('max_notes') !== true && $injector->getInstance('Horde_Perms')->hasAppPermission('max_notes') <= Mnemo::countMemos()) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d notes."), $injector->getInstance('Horde_Perms')->hasAppPermission('max_notes')), ENT_COMPAT, $registry->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d notes."), $injector->getInstance('Horde_Perms')->hasAppPermission('max_notes')), ENT_COMPAT, 'UTF-8'); if (!empty($conf['hooks']['permsdenied'])) { $message = Horde::callHook('_perms_hook_denied', array('mnemo:max_notes'), 'horde', $message); } diff --git a/mnemo/note/pdf.php b/mnemo/note/pdf.php index bc3efccc4..16022497a 100644 --- a/mnemo/note/pdf.php +++ b/mnemo/note/pdf.php @@ -58,8 +58,8 @@ if (!$note || !isset($note['memo_id'])) { /* Let's assume that the note content can be converted to ISO-8859-1 if this * is the current language's charset, as long as we don't have UTF-8 support * in File_PDF. */ -if ($GLOBALS['registry']->getCharset(true) == 'ISO-8859-1') { - $note = String::convertCharset($note, $GLOBALS['registry']->getCharset(), 'ISO-8859-1'); +if ($GLOBALS['registry']->getLanguageCharset() == 'ISO-8859-1') { + $note = String::convertCharset($note, 'UTF-8', 'ISO-8859-1'); } /* Set up the PDF object. */ diff --git a/mnemo/templates/common-header.inc b/mnemo/templates/common-header.inc index 5a446f99f..a329b56bf 100644 --- a/mnemo/templates/common-header.inc +++ b/mnemo/templates/common-header.inc @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/mnemo/templates/view/memo.inc b/mnemo/templates/view/memo.inc index e238a5b58..91f47d932 100644 --- a/mnemo/templates/view/memo.inc +++ b/mnemo/templates/view/memo.inc @@ -30,14 +30,14 @@ if (!$print_view) { - + - + diff --git a/nag/data.php b/nag/data.php index e75eb6038..afb9e4b37 100644 --- a/nag/data.php +++ b/nag/data.php @@ -41,7 +41,7 @@ if ($perms->hasAppPermission('max_tasks') !== true && try { $message = Horde::callHook('perms_denied', array('nag:max_tasks')); } catch (Horde_Exception_HookNotSet $e) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d tasks."), $perms->hasAppPermission('max_tasks')), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d tasks."), $perms->hasAppPermission('max_tasks')), ENT_COMPAT, 'UTF-8'); } $notification->push($message, 'horde.warning', array('content.raw')); $templates[Horde_Data::IMPORT_FILE] = array(NAG_TEMPLATES . '/data/export.inc'); @@ -169,7 +169,7 @@ if (is_array($next_step)) { try { $message = Horde::callHook('perms_denied', array('nag:max_tasks')); } catch (Horde_Exception_HookNotSet $e) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d tasks."), $perms->hasAppPermission('max_tasks')), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d tasks."), $perms->hasAppPermission('max_tasks')), ENT_COMPAT, 'UTF-8'); } $notification->push($message, 'horde.error', array('content.raw')); break; diff --git a/nag/lib/Api.php b/nag/lib/Api.php index 1edd00c14..02e1872f8 100644 --- a/nag/lib/Api.php +++ b/nag/lib/Api.php @@ -1060,7 +1060,7 @@ class Nag_Api extends Horde_Registry_Api $share = $GLOBALS['nag_shares']->getShare($tasklist); $iCal = new Horde_iCalendar($version); - $iCal->setAttribute('X-WR-CALNAME', Horde_String::convertCharset($share->get('name'), $GLOBALS['registry']->getCharset(), 'utf-8')); + $iCal->setAttribute('X-WR-CALNAME', Horde_String::convertCharset($share->get('name'), 'UTF-8', 'utf-8')); $tasks->reset(); while ($task = $tasks->each()) { diff --git a/nag/lib/Driver/Sql.php b/nag/lib/Driver/Sql.php index c5715a61b..18ded455a 100644 --- a/nag/lib/Driver/Sql.php +++ b/nag/lib/Driver/Sql.php @@ -131,17 +131,17 @@ class Nag_Driver_Sql extends Nag_Driver { $owner, $assignee, $taskId, - Horde_String::convertCharset($name, $GLOBALS['registry']->getCharset(), $this->_params['charset']), - Horde_String::convertCharset($uid, $GLOBALS['registry']->getCharset(), $this->_params['charset']), - Horde_String::convertCharset($desc, $GLOBALS['registry']->getCharset(), $this->_params['charset']), + Horde_String::convertCharset($name, 'UTF-8', $this->_params['charset']), + Horde_String::convertCharset($uid, 'UTF-8', $this->_params['charset']), + Horde_String::convertCharset($desc, 'UTF-8', $this->_params['charset']), (int)$start, (int)$due, (int)$priority, number_format($estimate, 2), (int)$completed, - Horde_String::convertCharset($category, $GLOBALS['registry']->getCharset(), $this->_params['charset']), + Horde_String::convertCharset($category, 'UTF-8', $this->_params['charset']), (int)$alarm, - serialize(Horde_String::convertCharset($methods, $GLOBALS['registry']->getCharset(), $this->_params['charset'])), + serialize(Horde_String::convertCharset($methods, 'UTF-8', $this->_params['charset'])), (int)$private, $parent); @@ -201,17 +201,17 @@ class Nag_Driver_Sql extends Nag_Driver { $this->_params['table']); $values = array($owner, $assignee, - Horde_String::convertCharset($name, $GLOBALS['registry']->getCharset(), $this->_params['charset']), - Horde_String::convertCharset($desc, $GLOBALS['registry']->getCharset(), $this->_params['charset']), + Horde_String::convertCharset($name, 'UTF-8', $this->_params['charset']), + Horde_String::convertCharset($desc, 'UTF-8', $this->_params['charset']), (int)$start, (int)$due, (int)$priority, number_format($estimate, 2), (int)$completed, (int)$completed_date, - Horde_String::convertCharset($category, $GLOBALS['registry']->getCharset(), $this->_params['charset']), + Horde_String::convertCharset($category, 'UTF-8', $this->_params['charset']), (int)$alarm, - serialize(Horde_String::convertCharset($methods, $GLOBALS['registry']->getCharset(), $this->_params['charset'])), + serialize(Horde_String::convertCharset($methods, 'UTF-8', $this->_params['charset'])), $parent, (int)$private, $this->_tasklist, diff --git a/nag/lib/Forms/task.php b/nag/lib/Forms/task.php index 801959fa6..b76b9f4a8 100644 --- a/nag/lib/Forms/task.php +++ b/nag/lib/Forms/task.php @@ -46,7 +46,7 @@ class Nag_TaskForm extends Horde_Form { if ($vars->get('task_id') == $task->id) { continue; } - $task_enums[htmlspecialchars($task->id)] = str_repeat(' ', $task->indent * 4) . htmlentities($task->name, ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $task_enums[htmlspecialchars($task->id)] = str_repeat(' ', $task->indent * 4) . htmlentities($task->name, ENT_COMPAT, 'UTF-8'); } $users = array(); $share = $GLOBALS['nag_shares']->getShare($tasklist); diff --git a/nag/lib/Nag.php b/nag/lib/Nag.php index 18aa91985..c6117dc89 100644 --- a/nag/lib/Nag.php +++ b/nag/lib/Nag.php @@ -673,11 +673,11 @@ class Nag 'mail/compose', array(array('to' => $email)))) . @htmlspecialchars($fullname . ' <' . $email . '>', - ENT_COMPAT, $GLOBALS['registry']->getCharset()) + ENT_COMPAT, 'UTF-8') . ''; } - return @htmlspecialchars($fullname, ENT_COMPAT, $GLOBALS['registry']->getCharset()); + return @htmlspecialchars($fullname, ENT_COMPAT, 'UTF-8'); } /** @@ -1003,7 +1003,7 @@ class Nag break; } - $mail->addHeader('Subject', $subject . ' ' . $task->name, $GLOBALS['registry']->getCharset()); + $mail->addHeader('Subject', $subject . ' ' . $task->name, 'UTF-8'); foreach ($twentyFour as $tf => $dateFormat) { foreach ($dateFormat as $df => $df_recipients) { @@ -1015,7 +1015,7 @@ class Nag $message .= "\n\n" . _("Task description:") . "\n\n" . $task->desc; } - $mail->setBody($message, $GLOBALS['registry']->getCharset()); + $mail->setBody($message, 'UTF-8'); $mail->clearRecipients(); $mail->addRecipients($df_recipients); diff --git a/nag/lib/Task.php b/nag/lib/Task.php index 0a88bdf89..01c84b16d 100644 --- a/nag/lib/Task.php +++ b/nag/lib/Task.php @@ -800,11 +800,11 @@ class Nag_Task { } if (!empty($this->name)) { - $vTodo->setAttribute('SUMMARY', $v1 ? $this->name : Horde_String::convertCharset($this->name, $GLOBALS['registry']->getCharset(), 'utf-8')); + $vTodo->setAttribute('SUMMARY', $v1 ? $this->name : Horde_String::convertCharset($this->name, 'UTF-8', 'utf-8')); } if (!empty($this->desc)) { - $vTodo->setAttribute('DESCRIPTION', $v1 ? $this->desc : Horde_String::convertCharset($this->desc, $GLOBALS['registry']->getCharset(), 'utf-8')); + $vTodo->setAttribute('DESCRIPTION', $v1 ? $this->desc : Horde_String::convertCharset($this->desc, 'UTF-8', 'utf-8')); } if (isset($this->priority)) { @@ -850,7 +850,7 @@ class Nag_Task { } if (!empty($this->category)) { - $vTodo->setAttribute('CATEGORIES', $v1 ? $this->category : Horde_String::convertCharset($this->category, $GLOBALS['registry']->getCharset(), 'utf-8')); + $vTodo->setAttribute('CATEGORIES', $v1 ? $this->category : Horde_String::convertCharset($this->category, 'UTF-8', 'utf-8')); } /* Get the task's history. */ @@ -891,8 +891,8 @@ class Nag_Task { $message = new Horde_ActiveSync_Message_Task(); /* Notes and Title */ - $message->setBody(Horde_String::convertCharset($this->desc, $GLOBALS['registry']->getCharset(), 'utf-8')); - $message->setSubject(Horde_String::convertCharset($this->name, $GLOBALS['registry']->getCharset(), 'utf-8')); + $message->setBody(Horde_String::convertCharset($this->desc, 'UTF-8', 'utf-8')); + $message->setSubject(Horde_String::convertCharset($this->name, 'UTF-8', 'utf-8')); /* Completion */ if ($this->completed) { @@ -1043,8 +1043,8 @@ class Nag_Task { function fromASTask(Horde_ActiveSync_Message_Task $message) { /* Notes and Title */ - $this->desc = Horde_String::convertCharset($message->getBody(), 'utf-8', $GLOBALS['registry']->getCharset()); - $this->name = Horde_String::convertCharset($message->getSubject(), 'utf-8', $GLOBALS['registry']->getCharset()); + $this->desc = Horde_String::convertCharset($message->getBody(), 'utf-8', 'UTF-8'); + $this->name = Horde_String::convertCharset($message->getSubject(), 'utf-8', 'UTF-8'); /* Completion */ if ($this->completed = $message->getComplete()) { diff --git a/nag/task.php b/nag/task.php index d5d9d3c15..92e53340a 100644 --- a/nag/task.php +++ b/nag/task.php @@ -71,7 +71,7 @@ case 'add_task': try { $message = Horde::callHook('perms_denied', array('nag:max_tasks')); } catch (Horde_Exception_HookNotSet $e) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d tasks."), $perms->hasAppPermission('max_tasks')), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d tasks."), $perms->hasAppPermission('max_tasks')), ENT_COMPAT, 'UTF-8'); } $notification->push($message, 'horde.error', array('content.raw')); Horde::url('list.php', true)->redirect(); diff --git a/nag/templates/common-header.inc b/nag/templates/common-header.inc index 2abfc8cb9..5d7a22df4 100644 --- a/nag/templates/common-header.inc +++ b/nag/templates/common-header.inc @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/nag/templates/view/task.inc b/nag/templates/view/task.inc index cdb4a6edb..3eece0307 100644 --- a/nag/templates/view/task.inc +++ b/nag/templates/view/task.inc @@ -59,14 +59,14 @@ - + - + diff --git a/news/mail.php b/news/mail.php new file mode 100644 index 000000000..292cf6b01 --- /dev/null +++ b/news/mail.php @@ -0,0 +1,62 @@ + + * @package News + */ + +require_once dirname(__FILE__) . '/lib/base.php'; + +$id = Horde_Util::getFormData('id'); +$row = $news->get($id); +if ($row instanceof PEAR_Error) { + $notification->push($row); + Horde::url('browse.php')->redirect(); +} + +/* Error handler */ +function _error($msg) +{ + $GLOBALS['notification']->push($msg, 'horde.error'); + News::getUrlFor('news', $GLOBALS['id'])->redirect(); +} + +if (!$registry->isAuthenticated()) { + _error(_("Only authenticated users can send mails.")); +} + +$to = Horde_Util::getFormData('email'); +if (empty($to)) { + _error(_("No mail entered.")); + exit; +} + +$from = $prefs->getValue('from_addr'); +if (empty($from)) { + _error(_("You have no email set.")); + exit; +} + +$body = sprintf(_("%s would you like to invite you to read the news\n Title: %s\n\n Published: %s \nLink: %s"), + $GLOBALS['registry']->getAuth(), + $row['title'], + $row['publish'], + News::getUrlFor('news', $id, true, -1)); + +$mail = new Horde_Mime_Mail(array('subject' => $row['title'], 'body' => $body, 'to' => $to, 'from' => $from, 'charset' => 'UTF-8')); +try { + $mail->send($injector->getInstance('Horde_Mail')); + $notification->push(sprintf(_("News succesfully send to %s"), $to), 'horde.success'); +} catch (Horde_Mime_Exception $e) { + $notification->push($e); +} + +News::getUrlFor('news', $id)->redirect(); diff --git a/news/pdf.php b/news/pdf.php new file mode 100644 index 000000000..d5fd9c9e4 --- /dev/null +++ b/news/pdf.php @@ -0,0 +1,60 @@ + + * @package News + */ + +$no_compress = true; +require_once dirname(__FILE__) . '/lib/base.php'; + +$id = Horde_Util::getFormData('id'); +$row = $news->get($id); + +// Check if the news exists +if ($row instanceof PEAR_Error) { + $notification->push($row); + Horde::url('browse.php')->redirect(); +} + +// Set up the PDF object. +$pdf = new Horde_Pdf_Writer(); + +$pdf->setInfo('title', $row['title']); +$pdf->setInfo('author', $row['user']); +$pdf->setInfo('CreationDate', 'D:' . date('Ymdhis')); + +$pdf->open(); +$pdf->addPage(); +$pdf->setAutoPageBreak(true); +$pdf->setFont('Arial', '', 12); + +if ($row['picture']) { + $file = $conf['vfs']['params']['vfsroot'] . '/' + . News::VFS_PATH . '/images/news/big/' + . $id . '.' . $conf['images']['image_type']; + try { + $pdf->image($file, 120, 20); + } catch (Horde_Pdf_Exception $e) { + Horde::logMessage($e, 'INFO'); + } +} + +$pdf->setFillColor('rgb', 200/255, 220/255, 255/255); +$pdf->cell(0, 6, $row['title'], 0, 1, 'L', 1); +$pdf->newLine(4); + +$pdf->write(12, _("On") . ': ' . News::dateFormat($row['publish']) . "\n"); +$pdf->write(12, _("Link") . ': ' . News::getUrlFor('news', $id, true) . "\n\n", News::getUrlFor('news', $id, true)); +$pdf->multiCell(0, 12, Horde_String::convertCharset(strip_tags($row['content']), 'UTF-8', 'UTF-8')); + +$browser->downloadHeaders($id . '.pdf', 'application/pdf'); +echo $pdf->getOutput(); diff --git a/news/rss/comments.php b/news/rss/comments.php new file mode 100644 index 000000000..3844b8f1f --- /dev/null +++ b/news/rss/comments.php @@ -0,0 +1,51 @@ + + */ + +$news_authentication = 'none'; +require_once dirname(__FILE__) . '/../lib/base.php'; + +$cache_key = 'news_rss_comments'; +$rss = $cache->get($cache_key, $conf['cache']['default_lifetime']); +if (!$rss) { + $list = News::getLastComments(50); + $title = _("Last comments"); + + $rss = ' + + + ' . htmlspecialchars($title) . ' + ' . str_replace('_', '-', strtolower($registry->preferredLang())) . ' + ' . date('r') . ' + ' . htmlspecialchars($title) . ' + ' . Horde::url('index.php', true, -1) . ' + ' . htmlspecialchars($registry->get('name')) . ''; + + foreach ($list as $comment) { + $rss .= ' + + ' . htmlspecialchars($comment['message_subject']) . ' + ' . $comment['read_url'] . ' + ' . $comment['read_url'] . ' + ' . date('r', strtotime($comment['message_date'])) . ' + + '; + } + + $rss .= ' + +'; + + $cache->set($cache_key, $rss); +} + +header('Content-type: text/xml; charset=' . 'UTF-8'); +echo $rss; diff --git a/news/rss/index.php b/news/rss/index.php new file mode 100644 index 000000000..be6ba6c3d --- /dev/null +++ b/news/rss/index.php @@ -0,0 +1,55 @@ + + */ + +$news_authentication = 'none'; +require_once dirname(__FILE__) . '/../lib/base.php'; + +// Show a specific user? +$cache_key = 'news_rss_index'; + +$rss = $cache->get($cache_key, $conf['cache']['default_lifetime']); +if (!$rss) { + + $title = $registry->get('name', 'horde'); + + $read_url = Horde::url('read.php', true, -1); + $rss = ' + + + ' . htmlspecialchars($title) . ' + ' . str_replace('_', '-', strtolower($registry->preferredLang())) . ' + ' . date('r') . ' + ' . htmlspecialchars($title) . ' + ' . Horde::url('index.php', true, -1) . ' + ' . htmlspecialchars($registry->get('name')) . ''; + + $rss .= ' + + ' . _("Last news") . ' + ' . Horde::url('rss/news.php', true, -1) . ' + '; + + $rss .= ' + + ' . _("Last comments") . ' + ' . Horde::url('rss/comments.php', true, -1) . ' + '; + + $rss .= ' + + '; + + $cache->set($cache_key, $rss); +} + +header('Content-type: text/xml'); +echo $rss; diff --git a/news/rss/news.php b/news/rss/news.php new file mode 100755 index 000000000..5df939eab --- /dev/null +++ b/news/rss/news.php @@ -0,0 +1,80 @@ + + * @author McLion + */ + +$news_authentication = 'none'; +require_once dirname(__FILE__) . '/../lib/base.php'; + +$cache_key = 'news_rss_news'; +$rss = $cache->get($cache_key, $conf['cache']['default_lifetime']); +if (empty($rss)) { + + /* query preparation */ + $query = 'SELECT n.id, publish, n.user, n.source, n.sourcelink, ' . + 'n.category1, n.category2, n.comments, n.picture, n.chars, nl.content, ' . + 'nl.title, nl.abbreviation ' . + 'FROM ' . $news->prefix . ' AS n, ' . $news->prefix . '_body AS nl ' . + 'WHERE n.status="' . News::CONFIRMED . '" AND n.publish<=NOW() ' . + 'AND nl.lang="' . $registry->preferredLang() . '" AND n.id=nl.id ORDER BY publish DESC'; + $rssbody = ''; + $query = $news->db->modifyLimitQuery($query, 0, 10); + $list = $news->db->getAssoc($query, true, array(), DB_FETCHMODE_ASSOC); + $categories = $news_cat->getCategories(false); + $title = sprintf(_("Last news"), $registry->get('name', 'horde')); + + $lastnewstime = 0; + foreach ($list as $news_id => $news) { + $news_link = News::getUrlFor('news', $news_id, true); + $rssbody .= ' + + + ' . htmlspecialchars($news['title']) . ' + ' . htmlspecialchars($news['user']). ' + ' . $news_link . ' + ' . $news_link . ' + ' . $news_link . '#comments + + ' . date('r', strtotime($news['publish'])) . ' + + '; + + if (strtotime($news['publish']) > $lastnewstime) { + $lastnewstime = strtotime($news['publish']); + } + } + + // Wee need the last published news time + $rssheader = ' + + + ' . htmlspecialchars($title) . ' + ' . str_replace('_', '-', strtolower($registry->preferredLang())) . ' + ' . date('r', $lastnewstime) . ' + ' . htmlspecialchars($title) . ' + ' . Horde::url('index.php', true, -1) . ' + ' . htmlspecialchars($registry->get('name')) . ''; + + $rssfooter = ' + +'; + + // build rss + $rss = $rssheader . $rssbody . $rssfooter; + + $cache->set($cache_key, $rss); +} + +header('Content-type: text/xml; charset=utf-8'); +echo $rss; diff --git a/news/templates/common-header.inc b/news/templates/common-header.inc new file mode 100644 index 000000000..991f28d04 --- /dev/null +++ b/news/templates/common-header.inc @@ -0,0 +1,31 @@ + + + + + +' : '' ?> + +get('name'); +if (!empty($title)) { + $page_title .= ' :: ' . $title; +} + +Horde::outputMetaTags(); +Horde::includeScriptFiles(); + +?> +<?php echo htmlspecialchars($page_title) ?> + +" href="" type="application/rss+xml" /> +" href="" type="application/rss+xml" /> + + + + diff --git a/operator/templates/common-header.inc b/operator/templates/common-header.inc index a91471912..3d3d06c39 100644 --- a/operator/templates/common-header.inc +++ b/operator/templates/common-header.inc @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/pastie/templates/common-header.inc b/pastie/templates/common-header.inc index 563c6c45b..90f306bee 100644 --- a/pastie/templates/common-header.inc +++ b/pastie/templates/common-header.inc @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/shout/templates/common-header.inc b/shout/templates/common-header.inc index dcd0d515b..a278cfa71 100644 --- a/shout/templates/common-header.inc +++ b/shout/templates/common-header.inc @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/shout/templates/dialplan/edit.inc b/shout/templates/dialplan/edit.inc index 9f6a52726..216fef795 100644 --- a/shout/templates/dialplan/edit.inc +++ b/shout/templates/dialplan/edit.inc @@ -94,10 +94,10 @@ var ajax_url = ''; var curmenu = null; var menuInfo = $H(); -var menuActions = $H(getCharset()); ?>); -var destinations = $H(getCharset()); ?>); -var conferences = $H(getCharset()); ?>); -var recordings = $H(getCharset()); ?>); +var menuActions = $H(); +var destinations = $H(); +var conferences = $H(); +var recordings = $H(); function empty(p) { diff --git a/skeleton/templates/common-header.inc b/skeleton/templates/common-header.inc index 563c6c45b..90f306bee 100644 --- a/skeleton/templates/common-header.inc +++ b/skeleton/templates/common-header.inc @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/skoli/templates/common-header.inc b/skoli/templates/common-header.inc new file mode 100644 index 000000000..df35f6c2b --- /dev/null +++ b/skoli/templates/common-header.inc @@ -0,0 +1,34 @@ + + + + + +' : '' ?> + +get('name'); +if (!empty($title)) { + $page_title .= ' :: ' . $title; +} + +Horde::outputMetaTags(); +Horde::includeScriptFiles(); + +$bc = $prefs->getValue('show_panel') + ? 'rightPanel' + : ''; + +?> +<?php echo htmlspecialchars($page_title) ?> + + + + + +> diff --git a/trean/add.php b/trean/add.php index 787c32bb6..95a1b9db5 100644 --- a/trean/add.php +++ b/trean/add.php @@ -20,7 +20,7 @@ case 'add_bookmark': /* Check permissions. */ if (Trean::hasPermission('max_bookmarks') !== true && Trean::hasPermission('max_bookmarks') <= $trean_shares->countBookmarks()) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d bookmarks."), Trean::hasPermission('max_bookmarks')), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d bookmarks."), Trean::hasPermission('max_bookmarks')), ENT_COMPAT, 'UTF-8'); if (!empty($conf['hooks']['permsdenied'])) { $message = Horde::callHook('_perms_hook_denied', array('trean:max_bookmarks'), 'horde', $message); } @@ -83,7 +83,7 @@ case 'add_folder': /* Check permissions. */ if (Trean::hasPermission('max_folders') !== true && Trean::hasPermission('max_folders') <= Trean::countFolders()) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), Trean::hasPermission('max_folders')), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), Trean::hasPermission('max_folders')), ENT_COMPAT, 'UTF-8'); if (!empty($conf['hooks']['permsdenied'])) { $message = Horde::callHook('_perms_hook_denied', array('trean:max_folders'), 'horde', $message); } diff --git a/trean/data.php b/trean/data.php index c2d27a70a..88a14ea6c 100644 --- a/trean/data.php +++ b/trean/data.php @@ -53,7 +53,7 @@ Horde_Registry::appInit('trean'); $folders_exceeded = Trean::hasPermission('max_folders') !== true && Trean::hasPermission('max_folders') <= Trean::countFolders(); if ($folders_exceeded) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), Trean::hasPermission('max_folders')), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), Trean::hasPermission('max_folders')), ENT_COMPAT, 'UTF-8'); if (!empty($conf['hooks']['permsdenied'])) { $message = Horde::callHook('_perms_hook_denied', array('trean:max_folders'), 'horde', $message); } @@ -62,7 +62,7 @@ if ($folders_exceeded) { $bookmarks_exceeded = Trean::hasPermission('max_bookmarks') !== true && Trean::hasPermission('max_bookmarks') <= $trean_shares->countBookmarks(); if ($bookmarks_exceeded) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d bookmarks."), Trean::hasPermission('max_bookmarks')), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d bookmarks."), Trean::hasPermission('max_bookmarks')), ENT_COMPAT, 'UTF-8'); if (!empty($conf['hooks']['permsdenied'])) { $message = Horde::callHook('_perms_hook_denied', array('trean:max_bookmarks'), 'horde', $message); } @@ -104,7 +104,7 @@ case 'import': continue; } if ($max_folders !== true && $num_folders >= $max_folders) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), Trean::hasPermission('max_folders')), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d folders."), Trean::hasPermission('max_folders')), ENT_COMPAT, 'UTF-8'); if (!empty($conf['hooks']['permsdenied'])) { $message = Horde::callHook('_perms_hook_denied', array('trean:max_folders'), 'horde', $message); } @@ -129,7 +129,7 @@ case 'import': $line, $temp)) { /* A bookmark. */ if ($max_bookmarks !== true && $num_bookmarks >= $max_bookmarks) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d bookmarks."), Trean::hasPermission('max_bookmarks')), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d bookmarks."), Trean::hasPermission('max_bookmarks')), ENT_COMPAT, 'UTF-8'); if (!empty($conf['hooks']['permsdenied'])) { $message = Horde::callHook('_perms_hook_denied', array('trean:max_bookmarks'), 'horde', $message); } diff --git a/trean/lib/Bookmarks.php b/trean/lib/Bookmarks.php index cdbc127ee..e705fac7c 100644 --- a/trean/lib/Bookmarks.php +++ b/trean/lib/Bookmarks.php @@ -1012,9 +1012,9 @@ class Trean_Bookmark { return $update; } $result = $update->execute(array($this->folder, - Horde_String::convertCharset($this->url, $GLOBALS['registry']->getCharset(), $GLOBALS['conf']['sql']['charset']), - Horde_String::convertCharset($this->title, $GLOBALS['registry']->getCharset(), $GLOBALS['conf']['sql']['charset']), - Horde_String::convertCharset($this->description, $GLOBALS['registry']->getCharset(), $GLOBALS['conf']['sql']['charset']), + Horde_String::convertCharset($this->url, 'UTF-8', $GLOBALS['conf']['sql']['charset']), + Horde_String::convertCharset($this->title, 'UTF-8', $GLOBALS['conf']['sql']['charset']), + Horde_String::convertCharset($this->description, 'UTF-8', $GLOBALS['conf']['sql']['charset']), $this->clicks, $this->rating, $this->id)); @@ -1048,9 +1048,9 @@ class Trean_Bookmark { $result = $insert->execute(array($bookmark_id, $this->folder, - Horde_String::convertCharset($this->url, $GLOBALS['registry']->getCharset(), $GLOBALS['conf']['sql']['charset']), - Horde_String::convertCharset($this->title, $GLOBALS['registry']->getCharset(), $GLOBALS['conf']['sql']['charset']), - Horde_String::convertCharset($this->description, $GLOBALS['registry']->getCharset(), $GLOBALS['conf']['sql']['charset']), + Horde_String::convertCharset($this->url, 'UTF-8', $GLOBALS['conf']['sql']['charset']), + Horde_String::convertCharset($this->title, 'UTF-8', $GLOBALS['conf']['sql']['charset']), + Horde_String::convertCharset($this->description, 'UTF-8', $GLOBALS['conf']['sql']['charset']), $this->clicks, $this->rating, )); diff --git a/trean/rss.php b/trean/rss.php index f710968c6..929fd2914 100644 --- a/trean/rss.php +++ b/trean/rss.php @@ -59,12 +59,12 @@ $cache = $GLOBALS['injector']->getInstance('Horde_Cache'); $cache_key = 'trean_rss_' . Horde_Auth::getAuth() . '_' . ($folderId === null ? 'all' : $folderId); $rss = $cache->get($cache_key, $conf['cache']['default_lifetime']); if (!$rss) { - $rss = 'getCharset() . '" ?> + $rss = ' ' . htmlspecialchars($folderId == null ? $registry->get('name') : $folder->get('name')) . ' ' . $registry->preferredLang() . ' - ' . $GLOBALS['registry']->getCharset() . ' + ' . 'UTF-8' . ' ' . date('Y-m-d H:i:s') . ' http://' . $_SERVER['SERVER_NAME'] . $registry->get('webroot') . '/themes/graphics/favicon.ico diff --git a/trean/templates/common-header.inc b/trean/templates/common-header.inc index bec332a6f..2d302e134 100644 --- a/trean/templates/common-header.inc +++ b/trean/templates/common-header.inc @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/turba/add.php b/turba/add.php index da3b00d39..8f2b37587 100644 --- a/turba/add.php +++ b/turba/add.php @@ -48,7 +48,7 @@ if ($source) { try { $message = Horde::callHook('perms_denied', array('turba:max_contacts')); } catch (Horde_Exception_HookNotSet $e) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $cfgSources[$source]['title']), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $cfgSources[$source]['title']), ENT_COMPAT, 'UTF-8'); } $notification->push($message, 'horde.error', array('content.raw')); $url = $url diff --git a/turba/config/backends.php.dist b/turba/config/backends.php.dist index 883c9bc7f..e2f87e127 100644 --- a/turba/config/backends.php.dist +++ b/turba/config/backends.php.dist @@ -591,7 +591,7 @@ $cfgSources['localsql'] = array( // 'type' => 'prefs', // 'params' => array( // 'name' => 'prefs', -// 'charset' => $GLOBALS['registry']->getCharset() +// 'charset' => 'UTF-8' // ), // 'map' => array( // '__key' => 'id', diff --git a/turba/data.php b/turba/data.php index d0784d2a0..754ddf32e 100644 --- a/turba/data.php +++ b/turba/data.php @@ -278,7 +278,7 @@ case 'export': } elseif ($attributes[$field]['type'] == 'datetime') { $row[$field] = strftime('%Y-%m-%d %R', $attribute); } else { - $row[$field] = Horde_String::convertCharset($attribute, $GLOBALS['registry']->getCharset(), $params['charset']); + $row[$field] = Horde_String::convertCharset($attribute, 'UTF-8', $params['charset']); } } } @@ -349,7 +349,7 @@ case Horde_Data::IMPORT_FILE: try { $message = Horde::callHook('perms_denied', array('turba:max_contacts')); } catch (Horde_Exception_HookNotSet $e) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $driver->title), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $driver->title), ENT_COMPAT, 'UTF-8'); } $notification->push($message, 'horde.error', array('content.raw')); $error = true; @@ -552,7 +552,7 @@ if ($next_step == Horde_Data::IMPORT_FILE) { $charsets[$charset] = $charset; } } - $my_charset = $GLOBALS['registry']->getCharset(true); + $my_charset = $GLOBALS['registry']->getLanguageCharset(); } foreach ($templates[$next_step] as $template) { diff --git a/turba/lib/Driver.php b/turba/lib/Driver.php index 0d04120f8..e49999399 100644 --- a/turba/lib/Driver.php +++ b/turba/lib/Driver.php @@ -964,7 +964,7 @@ class Turba_Driver implements Countable $vcard = new Horde_Icalendar_Vcard($version); $formattedname = false; $charset = ($version == '2.1') - ? array('CHARSET' => $GLOBALS['registry']->getCharset()) + ? array('CHARSET' => 'UTF-8') : array(); foreach ($hash as $key => $val) { @@ -973,7 +973,7 @@ class Turba_Driver implements Countable } if ($version != '2.1') { - $val = Horde_String::convertCharset($val, $GLOBALS['registry']->getCharset(), 'utf-8'); + $val = Horde_String::convertCharset($val, 'UTF-8', 'utf-8'); } switch ($key) { @@ -1642,8 +1642,8 @@ class Turba_Driver implements Countable ); $val = implode(';', $a); if ($version != '2.1') { - $val = Horde_String::convertCharset($val, $GLOBALS['registry']->getCharset(), 'utf-8'); - $a = Horde_String::convertCharset($a, $GLOBALS['registry']->getCharset(), 'utf-8'); + $val = Horde_String::convertCharset($val, 'UTF-8', 'utf-8'); + $a = Horde_String::convertCharset($a, 'UTF-8', 'utf-8'); } if (!$fields || isset($fields['N'])) { $vcard->setAttribute('N', $val, Horde_Mime::is8bit($val) ? $charset : array(), false, $a); @@ -1659,7 +1659,7 @@ class Turba_Driver implements Countable $val = ''; } if ($version != '2.1') { - $val = Horde_String::convertCharset($val, $GLOBALS['registry']->getCharset(), 'utf-8'); + $val = Horde_String::convertCharset($val, 'UTF-8', 'utf-8'); } $vcard->setAttribute('FN', $val, Horde_Mime::is8bit($val) ? $charset : array()); } @@ -1676,8 +1676,8 @@ class Turba_Driver implements Countable if (count($org) && (!$fields || isset($fields['ORG']))) { $val = implode(';', $org); if ($version != '2.1') { - $val = Horde_String::convertCharset($val, $GLOBALS['registry']->getCharset(), 'utf-8'); - $org = Horde_String::convertCharset($org, $GLOBALS['registry']->getCharset(), 'utf-8'); + $val = Horde_String::convertCharset($val, 'UTF-8', 'utf-8'); + $org = Horde_String::convertCharset($org, 'UTF-8', 'utf-8'); } $vcard->setAttribute('ORG', $val, Horde_Mime::is8bit($val) ? $charset : array(), false, $org); } @@ -1729,12 +1729,12 @@ class Turba_Driver implements Countable if ($version == '2.1') { $params = array(); if (Horde_Mime::is8bit($val)) { - $params['CHARSET'] = $GLOBALS['registry']->getCharset(); + $params['CHARSET'] = 'UTF-8'; } } else { $params = array('TYPE' => ''); - $val = Horde_String::convertCharset($val, $GLOBALS['registry']->getCharset(), 'utf-8'); - $a = Horde_String::convertCharset($a, $GLOBALS['registry']->getCharset(), 'utf-8'); + $val = Horde_String::convertCharset($val, 'UTF-8', 'utf-8'); + $a = Horde_String::convertCharset($a, 'UTF-8', 'utf-8'); } $vcard->setAttribute('ADR', $val, $params, true, $a); } @@ -1784,12 +1784,12 @@ class Turba_Driver implements Countable if ($version == '2.1') { $params = array('HOME' => null); if (Horde_Mime::is8bit($val)) { - $params['CHARSET'] = $GLOBALS['registry']->getCharset(); + $params['CHARSET'] = 'UTF-8'; } } else { $params = array('TYPE' => 'HOME'); - $val = Horde_String::convertCharset($val, $GLOBALS['registry']->getCharset(), 'utf-8'); - $a = Horde_String::convertCharset($a, $GLOBALS['registry']->getCharset(), 'utf-8'); + $val = Horde_String::convertCharset($val, 'UTF-8', 'utf-8'); + $a = Horde_String::convertCharset($a, 'UTF-8', 'utf-8'); } $vcard->setAttribute('ADR', $val, $params, true, $a); } @@ -1839,12 +1839,12 @@ class Turba_Driver implements Countable if ($version == '2.1') { $params = array('WORK' => null); if (Horde_Mime::is8bit($val)) { - $params['CHARSET'] = $GLOBALS['registry']->getCharset(); + $params['CHARSET'] = 'UTF-8'; } } else { $params = array('TYPE' => 'WORK'); - $val = Horde_String::convertCharset($val, $GLOBALS['registry']->getCharset(), 'utf-8'); - $a = Horde_String::convertCharset($a, $GLOBALS['registry']->getCharset(), 'utf-8'); + $val = Horde_String::convertCharset($val, 'UTF-8', 'utf-8'); + $a = Horde_String::convertCharset($a, 'UTF-8', 'utf-8'); } $vcard->setAttribute('ADR', $val, $params, true, $a); } @@ -2287,7 +2287,7 @@ class Turba_Driver implements Countable public function toASContact(Turba_Object $object) { $message = new Horde_ActiveSync_Message_Contact(array('logger' => $GLOBALS['injector']->getInstance('Horde_Log_Logger'))); - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; $hash = $object->getAttributes(); foreach ($hash as $field => $value) { switch ($field) { @@ -2446,7 +2446,7 @@ class Turba_Driver implements Countable public function fromASContact($message) { $hash = array(); - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; $formattedname = false; $textMap = array( diff --git a/turba/lib/Driver/Ldap.php b/turba/lib/Driver/Ldap.php index bd9918ba3..247e3c9f6 100644 --- a/turba/lib/Driver/Ldap.php +++ b/turba/lib/Driver/Ldap.php @@ -233,7 +233,7 @@ class Turba_Driver_Ldap extends Turba_Driver if (is_array($ids)) { $results = array(); foreach ($ids as $d) { - $res = @ldap_read($this->_ds, Horde_String::convertCharset($d, $GLOBALS['registry']->getCharset(), $this->_params['charset']), $filter, $attr); + $res = @ldap_read($this->_ds, Horde_String::convertCharset($d, 'UTF-8', $this->_params['charset']), $filter, $attr); if ($res) { $results = array_merge($results, $this->_getResults($fields, $res)); } else { @@ -244,7 +244,7 @@ class Turba_Driver_Ldap extends Turba_Driver return $results; } - $res = @ldap_read($this->_ds, Horde_String::convertCharset($ids, $GLOBALS['registry']->getCharset(), $this->_params['charset']), $filter, $attr); + $res = @ldap_read($this->_ds, Horde_String::convertCharset($ids, 'UTF-8', $this->_params['charset']), $filter, $attr); if (!$res) { throw new Turba_Exception(sprintf(_("Read failed: (%s) %s"), ldap_errno($this->_ds), ldap_error($this->_ds))); } @@ -298,8 +298,8 @@ class Turba_Driver_Ldap extends Turba_Driver $this->_encodeAttributes($attributes); - if (!@ldap_add($this->_ds, Horde_String::convertCharset($dn, $GLOBALS['registry']->getCharset(), $this->_params['charset']), $attributes)) { - throw new Turba_Exception('Failed to add an object: [' . ldap_errno($this->_ds) . '] "' . ldap_error($this->_ds) . '" DN: ' . $dn . ' (attributes: [' . serialize($attributes) . ']).' . "Charset:" . $GLOBALS['registry']->getCharset()); + if (!@ldap_add($this->_ds, Horde_String::convertCharset($dn, 'UTF-8', $this->_params['charset']), $attributes)) { + throw new Turba_Exception('Failed to add an object: [' . ldap_errno($this->_ds) . '] "' . ldap_error($this->_ds) . '" DN: ' . $dn . ' (attributes: [' . serialize($attributes) . ']).' . "Charset:" . 'UTF-8'); } } @@ -326,7 +326,7 @@ class Turba_Driver_Ldap extends Turba_Driver throw new Turba_Exception(_("Invalid key specified.")); } - if (!@ldap_delete($this->_ds, Horde_String::convertCharset($object_id, $GLOBALS['registry']->getCharset(), $this->_params['charset']))) { + if (!@ldap_delete($this->_ds, Horde_String::convertCharset($object_id, 'UTF-8', $this->_params['charset']))) { throw new Turba_Exception(sprintf(_("Delete failed: (%s) %s"), ldap_errno($this->_ds), ldap_error($this->_ds))); } } @@ -346,7 +346,7 @@ class Turba_Driver_Ldap extends Turba_Driver * values. These are needed so that we can delete any * attributes that have been removed by using ldap_mod_del. */ $filter = $this->_buildObjectclassFilter(); - $oldres = @ldap_read($this->_ds, Horde_String::convertCharset($object_id, $GLOBALS['registry']->getCharset(), $this->_params['charset']), $filter, array_merge(array_keys($attributes), array('objectclass'))); + $oldres = @ldap_read($this->_ds, Horde_String::convertCharset($object_id, 'UTF-8', $this->_params['charset']), $filter, array_merge(array_keys($attributes), array('objectclass'))); $info = ldap_get_attributes($this->_ds, ldap_first_entry($this->_ds, $oldres)); if ($this->_params['version'] == 3 && @@ -358,8 +358,8 @@ class Turba_Driver_Ldap extends Turba_Driver throw new Turba_Exception(_("Missing DN in LDAP source configuration.")); } - if (ldap_rename($this->_ds, Horde_String::convertCharset($object_id, $GLOBALS['registry']->getCharset(), $this->_params['charset']), - Horde_String::convertCharset($newrdn, $GLOBALS['registry']->getCharset(), $this->_params['charset']), $this->_params['root'], true)) { + if (ldap_rename($this->_ds, Horde_String::convertCharset($object_id, 'UTF-8', $this->_params['charset']), + Horde_String::convertCharset($newrdn, 'UTF-8', $this->_params['charset']), $this->_params['root'], true)) { $object_id = $newrdn . ',' . $this->_params['root']; } else { throw new Turba_Exception(sprintf(_("Failed to change name: (%s) %s; Old DN = %s, New DN = %s, Root = %s"), ldap_errno($this->_ds), ldap_error($this->_ds), $object_id, $newrdn, $this->_params['root'])); @@ -382,7 +382,7 @@ class Turba_Driver_Ldap extends Turba_Driver $attributes[$key] == '') { $oldval[$key] = $var[0]; - if (!@ldap_mod_del($this->_ds, Horde_String::convertCharset($object_id, $GLOBALS['registry']->getCharset(), $this->_params['charset']), $oldval)) { + if (!@ldap_mod_del($this->_ds, Horde_String::convertCharset($object_id, 'UTF-8', $this->_params['charset']), $oldval)) { throw new Turba_Exception(sprintf(_("Modify failed: (%s) %s"), ldap_errno($this->_ds), ldap_error($this->_ds))); } unset($attributes[$key]); @@ -398,7 +398,7 @@ class Turba_Driver_Ldap extends Turba_Driver unset($attributes['objectclass']['count']); $attributes['objectclass'] = array_values($attributes['objectclass']); - if (!@ldap_modify($this->_ds, Horde_String::convertCharset($object_id, $GLOBALS['registry']->getCharset(), $this->_params['charset']), $attributes)) { + if (!@ldap_modify($this->_ds, Horde_String::convertCharset($object_id, 'UTF-8', $this->_params['charset']), $attributes)) { throw new Turba_Exception(sprintf(_("Modify failed: (%s) %s"), ldap_errno($this->_ds), ldap_error($this->_ds))); } @@ -462,7 +462,7 @@ class Turba_Driver_Ldap extends Turba_Driver $clause .= '(&' . $this->_buildSearchQuery($vals) . ')'; } else { if (isset($vals['field'])) { - $rhs = Horde_String::convertCharset($vals['test'], $GLOBALS['registry']->getCharset(), $this->_params['charset']); + $rhs = Horde_String::convertCharset($vals['test'], 'UTF-8', $this->_params['charset']); $clause .= Horde_Ldap::buildClause($vals['field'], $vals['op'], $rhs, array('begin' => !empty($vals['begin']))); } else { foreach ($vals as $test) { @@ -471,7 +471,7 @@ class Turba_Driver_Ldap extends Turba_Driver } elseif (!empty($test['AND'])) { $clause .= '(&' . $this->_buildSearchQuery($test) . ')'; } else { - $rhs = Horde_String::convertCharset($test['test'], $GLOBALS['registry']->getCharset(), $this->_params['charset']); + $rhs = Horde_String::convertCharset($test['test'], 'UTF-8', $this->_params['charset']); $clause .= Horde_Ldap::buildClause($test['field'], $test['op'], $rhs, array('begin' => !empty($vals['begin']))); } } @@ -591,7 +591,7 @@ class Turba_Driver_Ldap extends Turba_Driver } if (!is_array($val)) { - $attributes[$key] = Horde_String::convertCharset($val, $GLOBALS['registry']->getCharset(), $this->_params['charset']); + $attributes[$key] = Horde_String::convertCharset($val, 'UTF-8', $this->_params['charset']); } } } diff --git a/turba/lib/Driver/Sql.php b/turba/lib/Driver/Sql.php index 6784f1b5e..3f63b185a 100644 --- a/turba/lib/Driver/Sql.php +++ b/turba/lib/Driver/Sql.php @@ -659,7 +659,7 @@ class Turba_Driver_Sql extends Turba_Driver */ protected function _convertToDriver($value) { - return Horde_String::convertCharset($value, $GLOBALS['registry']->getCharset(), $this->_params['charset']); + return Horde_String::convertCharset($value, 'UTF-8', $this->_params['charset']); } /** diff --git a/turba/lib/Object.php b/turba/lib/Object.php index cb9463cde..799478056 100644 --- a/turba/lib/Object.php +++ b/turba/lib/Object.php @@ -248,7 +248,7 @@ class Turba_Object { . ' ' . date($GLOBALS['prefs']->getValue('twentyFour') ? 'G:i' : 'g:i a', $entry['ts']) . ' ' - . @htmlspecialchars($by, ENT_COMPAT, $GLOBALS['registry']->getCharset()); + . @htmlspecialchars($by, ENT_COMPAT, 'UTF-8'); } } } catch (Exception $e) { diff --git a/turba/lib/View/Browse.php b/turba/lib/View/Browse.php index 773bc6fbf..8acdba60b 100644 --- a/turba/lib/View/Browse.php +++ b/turba/lib/View/Browse.php @@ -153,7 +153,7 @@ class Turba_View_Browse { try { $message = Horde::callHook('perms_denied', array('turba:max_contacts')); } catch (Horde_Exception_HookNotSet $e) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $cfgSources[$targetSource]['title']), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $cfgSources[$targetSource]['title']), ENT_COMPAT, 'UTF-8'); } $notification->push($message, 'horde.error', array('content.raw')); break; @@ -305,7 +305,7 @@ class Turba_View_Browse { try { $message = Horde::callHook('perms_denied', array('turba:max_contacts')); } catch (Horde_Exception $e) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $cfgSources[$source]['title']), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d contacts in \"%s\"."), $max_contacts, $cfgSources[$source]['title']), ENT_COMPAT, 'UTF-8'); } $notification->push($message, 'horde.error', array('content.raw')); break; diff --git a/turba/templates/common-header.inc b/turba/templates/common-header.inc index 269649ba3..566030a2e 100644 --- a/turba/templates/common-header.inc +++ b/turba/templates/common-header.inc @@ -1,7 +1,7 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/turba/vcard.php b/turba/vcard.php index 9b0007310..489d77034 100644 --- a/turba/vcard.php +++ b/turba/vcard.php @@ -40,4 +40,4 @@ if (!$filename) { $filename = _("contact"); } -$injector->getInstance('Horde_Data')->getData('Vcard')->exportFile($filename . '.vcf', array($driver->tovCard($object, '2.1', null, true)), $GLOBALS['registry']->getCharset()); +$injector->getInstance('Horde_Data')->getData('Vcard')->exportFile($filename . '.vcf', array($driver->tovCard($object, '2.1', null, true)), 'UTF-8'); diff --git a/vilma/templates/common-header.inc b/vilma/templates/common-header.inc index af209be4d..1f6b14452 100644 --- a/vilma/templates/common-header.inc +++ b/vilma/templates/common-header.inc @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/whups/lib/Driver.php b/whups/lib/Driver.php index f144e6b5d..5b3320722 100644 --- a/whups/lib/Driver.php +++ b/whups/lib/Driver.php @@ -391,14 +391,14 @@ class Whups_Driver { } elseif (!empty($conf['mail']['from_addr'])) { $mail->addHeader('From', $conf['mail']['from_addr']); } else { - $mail->addHeader('From', Whups::formatUser($from), $GLOBALS['registry']->getCharset()); + $mail->addHeader('From', Whups::formatUser($from), 'UTF-8'); } $subject = (is_null($ticket_id) ? '' : '[' . $registry->get('name') . ' #' . $ticket_id . '] ') . $subject; - $mail->addHeader('Subject', $subject, $GLOBALS['registry']->getCharset()); + $mail->addHeader('Subject', $subject, 'UTF-8'); /* Get our array of comments, sorted in the appropriate order. */ if (!is_null($ticket_id)) { @@ -474,7 +474,7 @@ class Whups_Driver { array('@@comment@@', '@@full_name@@'), array("\n\n" . $formattedComment, $full_name), $message); - $mail->setBody($body, $GLOBALS['registry']->getCharset()); + $mail->setBody($body, 'UTF-8'); $mail->addHeader('Message-ID', Horde_Mime::generateMessageId()); if ($ticket_id) { @@ -488,7 +488,7 @@ class Whups_Driver { } $mail->clearRecipients(); - $mail->addHeader('To', $to, $GLOBALS['registry']->getCharset()); + $mail->addHeader('To', $to, 'UTF-8'); try { $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'), true); diff --git a/whups/lib/Driver/sql.php b/whups/lib/Driver/sql.php index d40ef424f..ed4b58653 100644 --- a/whups/lib/Driver/sql.php +++ b/whups/lib/Driver/sql.php @@ -83,9 +83,9 @@ class Whups_Driver_sql extends Whups_Driver { . 'VALUES (?, ?, ?, ?, ?)'; $values = array( $new_id, - Horde_String::convertCharset($name, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($name, 'UTF-8', $this->_params['charset']), - Horde_String::convertCharset($description, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($description, 'UTF-8', $this->_params['charset']), $slug, $email); @@ -113,9 +113,9 @@ class Whups_Driver_sql extends Whups_Driver { $query = 'INSERT INTO whups_types' . ' (type_id, type_name, type_description) VALUES (?, ?, ?)'; $values = array($new_id, - Horde_String::convertCharset($name, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($name, 'UTF-8', $this->_params['charset']), - Horde_String::convertCharset($description, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($description, 'UTF-8', $this->_params['charset'])); Horde::logMessage( sprintf('Whups_Driver_sql::addType(): query="%s"; values="%s"', @@ -142,11 +142,11 @@ class Whups_Driver_sql extends Whups_Driver { . 'state_description, state_category) VALUES (?, ?, ?, ?, ?)'; $values = array($new_id, $typeId, - Horde_String::convertCharset($name, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($name, 'UTF-8', $this->_params['charset']), - Horde_String::convertCharset($description, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($description, 'UTF-8', $this->_params['charset']), - Horde_String::convertCharset($category, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($category, 'UTF-8', $this->_params['charset'])); Horde::logMessage( sprintf('Whups_Driver_sql::addState(): query="%s"; values="%s"', @@ -173,9 +173,9 @@ class Whups_Driver_sql extends Whups_Driver { . 'priority_name, priority_description) VALUES (?, ?, ?, ?)'; $values = array($new_id, $typeId, - Horde_String::convertCharset($name, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($name, 'UTF-8', $this->_params['charset']), - Horde_String::convertCharset($description, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($description, 'UTF-8', $this->_params['charset'])); Horde::logMessage( sprintf('Whups_Driver_sql::addPriority(): query="%s"; values="%s"', @@ -212,9 +212,9 @@ class Whups_Driver_sql extends Whups_Driver { . 'version_name, version_description, version_active) VALUES (?, ?, ?, ?, ?)'; $values = array((int)$new_id, (int)$queueId, - Horde_String::convertCharset($name, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($name, 'UTF-8', $this->_params['charset']), - Horde_String::convertCharset($description, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($description, 'UTF-8', $this->_params['charset']), (int)$active); Horde::logMessage( @@ -251,9 +251,9 @@ class Whups_Driver_sql extends Whups_Driver { . 'reply_name, reply_text) VALUES (?, ?, ?, ?)'; $values = array($type, $new_id, - Horde_String::convertCharset($name, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($name, 'UTF-8', $this->_params['charset']), - Horde_String::convertCharset($text, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($text, 'UTF-8', $this->_params['charset'])); Horde::logMessage( sprintf('Whups_Driver_sql::addReply(): query="%s"; values="%s"', @@ -296,7 +296,7 @@ class Whups_Driver_sql extends Whups_Driver { . 'ticket_timestamp, ticket_due, version_id)' . ' VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'; $values = array($ticketId, - Horde_String::convertCharset($summary, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($summary, 'UTF-8', $this->_params['charset']), $requester, $type, @@ -407,7 +407,7 @@ class Whups_Driver_sql extends Whups_Driver { array((int)$id, (int)$ticket_id, $creator, - Horde_String::convertCharset($comment, $GLOBALS['registry']->getCharset(), $this->_params['charset']), + Horde_String::convertCharset($comment, 'UTF-8', $this->_params['charset']), time())); if (is_a($result, 'PEAR_Error')) { Horde::logMessage($result, 'ERR'); @@ -458,7 +458,7 @@ class Whups_Driver_sql extends Whups_Driver { } $query .= $this->_map[$field] . ' = ?, '; - $values[] = Horde_String::convertCharset($value, $GLOBALS['registry']->getCharset(), $this->_params['charset']); + $values[] = Horde_String::convertCharset($value, 'UTF-8', $this->_params['charset']); } /* Don't try to execute an empty query (if we didn't find any updates @@ -1384,10 +1384,10 @@ class Whups_Driver_sql extends Whups_Driver { . 'queue_description = ?, queue_versioned = ?, ' . 'queue_slug = ?, queue_email = ? WHERE queue_id = ?'; $values = array(Horde_String::convertCharset($name, - $GLOBALS['registry']->getCharset(), + 'UTF-8', $this->_params['charset']), Horde_String::convertCharset($description, - $GLOBALS['registry']->getCharset(), + 'UTF-8', $this->_params['charset']), (empty($versioned) ? 0 : 1), $slug, @@ -1674,9 +1674,9 @@ class Whups_Driver_sql extends Whups_Driver { { $query = 'UPDATE whups_types' . ' SET type_name = ?, type_description = ? WHERE type_id = ?'; - $values = array(Horde_String::convertCharset($name, $GLOBALS['registry']->getCharset(), + $values = array(Horde_String::convertCharset($name, 'UTF-8', $this->_params['charset']), - Horde_String::convertCharset($description, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($description, 'UTF-8', $this->_params['charset']), $typeId); Horde::logMessage( @@ -1822,11 +1822,11 @@ class Whups_Driver_sql extends Whups_Driver { { $query = 'UPDATE whups_states SET state_name = ?, ' . 'state_description = ?, state_category = ? WHERE state_id = ?'; - $values = array(Horde_String::convertCharset($name, $GLOBALS['registry']->getCharset(), + $values = array(Horde_String::convertCharset($name, 'UTF-8', $this->_params['charset']), - Horde_String::convertCharset($description, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($description, 'UTF-8', $this->_params['charset']), - Horde_String::convertCharset($category, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($category, 'UTF-8', $this->_params['charset']), $stateId); Horde::logMessage( @@ -1929,7 +1929,7 @@ class Whups_Driver_sql extends Whups_Driver { $values = array($query->id, serialize($query->parameters), serialize($query->query)); } - $values = Horde_String::convertCharset($values, $GLOBALS['registry']->getCharset(), + $values = Horde_String::convertCharset($values, 'UTF-8', $this->_params['charset']); Horde::logMessage( sprintf('Whups_Driver_sql::saveQuery(): query="%s"; values="%s"', @@ -2047,9 +2047,9 @@ class Whups_Driver_sql extends Whups_Driver { $query = 'UPDATE whups_priorities' . ' SET priority_name = ?, priority_description = ?' . ' WHERE priority_id = ?'; - $values = array(Horde_String::convertCharset($name, $GLOBALS['registry']->getCharset(), + $values = array(Horde_String::convertCharset($name, 'UTF-8', $this->_params['charset']), - Horde_String::convertCharset($description, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($description, 'UTF-8', $this->_params['charset']), $priorityId); Horde::logMessage( @@ -2151,9 +2151,9 @@ class Whups_Driver_sql extends Whups_Driver { $query = 'UPDATE whups_versions SET version_name = ?, ' . 'version_description = ?, version_active = ? ' . 'WHERE version_id = ?'; - $values = array(Horde_String::convertCharset($name, $GLOBALS['registry']->getCharset(), + $values = array(Horde_String::convertCharset($name, 'UTF-8', $this->_params['charset']), - Horde_String::convertCharset($description, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($description, 'UTF-8', $this->_params['charset']), (int)$active, (int)$versionId); @@ -2233,9 +2233,9 @@ class Whups_Driver_sql extends Whups_Driver { { $query = 'UPDATE whups_replies SET reply_name = ?, ' . 'reply_text = ? WHERE reply_id = ?'; - $values = array(Horde_String::convertCharset($name, $GLOBALS['registry']->getCharset(), + $values = array(Horde_String::convertCharset($name, 'UTF-8', $this->_params['charset']), - Horde_String::convertCharset($text, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($text, 'UTF-8', $this->_params['charset']), $reply); Horde::logMessage( @@ -2376,13 +2376,13 @@ class Whups_Driver_sql extends Whups_Driver { . ' VALUES (?, ?, ?, ?, ?, ?, ?)'; $values = array($new_id, $type_id, - Horde_String::convertCharset($name, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($name, 'UTF-8', $this->_params['charset']), - Horde_String::convertCharset($desc, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($desc, 'UTF-8', $this->_params['charset']), $type, serialize( - Horde_String::convertCharset($params, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($params, 'UTF-8', $this->_params['charset'])), (int)($required == 'on')); @@ -2405,14 +2405,14 @@ class Whups_Driver_sql extends Whups_Driver { . 'SET attribute_name = ?, attribute_description = ?, ' . 'attribute_type = ?, attribute_params = ?, ' . 'attribute_required = ? WHERE attribute_id = ?'; - $values = array(Horde_String::convertCharset($newname, $GLOBALS['registry']->getCharset(), + $values = array(Horde_String::convertCharset($newname, 'UTF-8', $this->_params['charset']), - Horde_String::convertCharset($newdesc, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset($newdesc, 'UTF-8', $this->_params['charset']), $newtype, serialize( Horde_String::convertCharset($newparams, - $GLOBALS['registry']->getCharset(), + 'UTF-8', $this->_params['charset'])), (int)($newrequired == 'on'), $attribute_id); @@ -2607,7 +2607,7 @@ class Whups_Driver_sql extends Whups_Driver { function _setAttributeValue($ticket_id, $attribute_id, $attribute_value) { $db_attribute_value = Horde_String::convertCharset((string)$attribute_value, - $GLOBALS['registry']->getCharset(), + 'UTF-8', $this->_params['charset']); $this->_write_db->autoCommit(false); @@ -2808,7 +2808,7 @@ class Whups_Driver_sql extends Whups_Driver { time(), (string)$user, $type, - Horde_String::convertCharset((string)$value, $GLOBALS['registry']->getCharset(), + Horde_String::convertCharset((string)$value, 'UTF-8', $this->_params['charset']), (int)$value); Horde::logMessage( diff --git a/whups/opensearch.php b/whups/opensearch.php index 16e849c0e..5c0502622 100644 --- a/whups/opensearch.php +++ b/whups/opensearch.php @@ -20,7 +20,7 @@ $name = $registry->get('name', 'whups') . ' (' . $url . ')'; $icon = base64_encode(file_get_contents($registry->get('themesfs', 'whups') . '/graphics/whups.png')); // Charset. -$charset = $GLOBALS['registry']->getCharset(); +$charset = 'UTF-8'; header('Content-Type: text/xml; charset=' . $charset); echo <<createInstance('Horde_Template'); -$template->set('charset', $GLOBALS['registry']->getCharset()); +$template->set('charset', 'UTF-8'); $template->set('xsl', $registry->get('themesuri') . '/feed-rss.xsl'); $template->set('pubDate', htmlspecialchars(date('r'))); $template->set('title', htmlspecialchars($whups_query->name ? $whups_query->name : _("Query Results"))); diff --git a/whups/queue/rss.php b/whups/queue/rss.php index 2fd4307dd..22e1f5d91 100644 --- a/whups/queue/rss.php +++ b/whups/queue/rss.php @@ -86,7 +86,7 @@ foreach (array_keys($tickets) as $i) { } $template = $injector->createInstance('Horde_Template'); -$template->set('charset', $GLOBALS['registry']->getCharset()); +$template->set('charset', 'UTF-8'); $template->set('xsl', $registry->get('themesuri') . '/feed-rss.xsl'); $template->set('pubDate', htmlspecialchars(date('r'))); if (isset($type) && isset($queue['name'])) { diff --git a/whups/search/rss.php b/whups/search/rss.php index 38dd46285..95751601d 100644 --- a/whups/search/rss.php +++ b/whups/search/rss.php @@ -47,7 +47,7 @@ foreach (array_keys($tickets) as $i) { } $template = $injector->createInstance('Horde_Template'); -$template->set('charset', $GLOBALS['registry']->getCharset()); +$template->set('charset', 'UTF-8'); $template->set('xsl', $registry->get('themesuri') . '/feed-rss.xsl'); $template->set('pubDate', htmlspecialchars(date('r'))); $template->set('title', _("Search Results")); diff --git a/whups/templates/common-header.inc b/whups/templates/common-header.inc index 2fa8b206e..12b58f884 100644 --- a/whups/templates/common-header.inc +++ b/whups/templates/common-header.inc @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/whups/ticket/rss.php b/whups/ticket/rss.php index a07a11b5c..c3293067a 100644 --- a/whups/ticket/rss.php +++ b/whups/ticket/rss.php @@ -42,7 +42,7 @@ foreach (array_keys($history) as $i) { } $template = $injector->createInstance('Horde_Template'); -$template->set('charset', $GLOBALS['registry']->getCharset()); +$template->set('charset', 'UTF-8'); $template->set('xsl', $registry->get('themesuri') . '/feed-rss.xsl'); $template->set('pubDate', htmlspecialchars(date('r'))); $template->set('title', htmlspecialchars($details['summary'])); diff --git a/wicked/lib/Driver.php b/wicked/lib/Driver.php index b1bf5a47a..67687f999 100644 --- a/wicked/lib/Driver.php +++ b/wicked/lib/Driver.php @@ -462,7 +462,7 @@ class Wicked_Driver { */ function getCharset() { - return $GLOBALS['registry']->getCharset(); + return 'UTF-8'; } /** diff --git a/wicked/lib/Driver/sql.php b/wicked/lib/Driver/sql.php index 84e1881f9..b4c2268d2 100644 --- a/wicked/lib/Driver/sql.php +++ b/wicked/lib/Driver/sql.php @@ -850,7 +850,7 @@ class Wicked_Driver_sql extends Wicked_Driver { */ function _convertToDriver($value) { - return Horde_String::convertCharset($value, $GLOBALS['registry']->getCharset(), $this->getCharset()); + return Horde_String::convertCharset($value, 'UTF-8', $this->getCharset()); } /** diff --git a/wicked/lib/Page.php b/wicked/lib/Page.php index 4a15e7490..b1dbd4ca5 100644 --- a/wicked/lib/Page.php +++ b/wicked/lib/Page.php @@ -458,7 +458,7 @@ class Wicked_Page { $this->_proc->deleteRule('Embed'); } - $this->_proc->setFormatConf('Xhtml', 'charset', $GLOBALS['registry']->getCharset()); + $this->_proc->setFormatConf('Xhtml', 'charset', 'UTF-8'); $this->_proc->setFormatConf('Xhtml', 'translate', HTML_SPECIALCHARS); $create = $this->allows(Wicked::MODE_CREATE) ? 1 : 0; $linkConf = array( diff --git a/wicked/lib/Page/MergeOrRename.php b/wicked/lib/Page/MergeOrRename.php index 0d9e508c5..e47f8a05e 100644 --- a/wicked/lib/Page/MergeOrRename.php +++ b/wicked/lib/Page/MergeOrRename.php @@ -107,8 +107,8 @@ class MergeOrRename extends Wicked_Page { } foreach ($references as $key => $page) { - $references[$key]['page_url'] = @htmlspecialchars(Wicked::url($page['page_name']), ENT_QUOTES, $GLOBALS['registry']->getCharset()); - $references[$key]['page_name'] = @htmlspecialchars($page['page_name'], ENT_QUOTES, $GLOBALS['registry']->getCharset()); + $references[$key]['page_url'] = @htmlspecialchars(Wicked::url($page['page_name']), ENT_QUOTES, 'UTF-8'); + $references[$key]['page_name'] = @htmlspecialchars($page['page_name'], ENT_QUOTES, 'UTF-8'); // Since the page name can have [ and ] and other special // characters in it, and we don't want the browser or PHP decoding diff --git a/wicked/lib/Text_Wiki/Render/Xhtml/Code2.php b/wicked/lib/Text_Wiki/Render/Xhtml/Code2.php index f4aeeca73..0b31989cf 100644 --- a/wicked/lib/Text_Wiki/Render/Xhtml/Code2.php +++ b/wicked/lib/Text_Wiki/Render/Xhtml/Code2.php @@ -20,7 +20,7 @@ class Text_Wiki_Render_Xhtml_Code2 extends Text_Wiki_Render_Xhtml_Code $part->setContents($options['text']); $part->setType("x-extension/$type"); - $viewer = new Horde_Core_Mime_Viewer_Syntaxhighlighter($part, array('registry' => $GLOBALS['registry'], 'charset' => $GLOBALS['registry']->getCharset())); + $viewer = new Horde_Core_Mime_Viewer_Syntaxhighlighter($part, array('registry' => $GLOBALS['registry'], 'charset' => 'UTF-8')); $data = $viewer->render('inline'); $data = reset($data); return $data['data']; diff --git a/wicked/lib/Wicked.php b/wicked/lib/Wicked.php index 0140fdb3f..f4e5efbd2 100644 --- a/wicked/lib/Wicked.php +++ b/wicked/lib/Wicked.php @@ -179,7 +179,7 @@ class Wicked $conf['wicked']['notify_address'], 'from' => $from . '<' . $from_addr . '>', - 'charset' => $GLOBALS['registry']->getCharset())); + 'charset' => 'UTF-8')); $mail->addHeader('User-Agent', 'Wicked ' . $GLOBALS['registry']->getVersion()); $mail->addHeader('Precedence', 'bulk'); $mail->addHeader('Auto-Submitted', 'auto-replied'); diff --git a/wicked/opensearch.php b/wicked/opensearch.php index 9a6b5f619..80dd36eb9 100644 --- a/wicked/opensearch.php +++ b/wicked/opensearch.php @@ -24,7 +24,7 @@ $name = $registry->get('name', 'wicked') . ' (' . $url . ')'; $icon = base64_encode(file_get_contents($registry->get('themesfs', 'wicked') . '/graphics/wicked.png')); // Charset. -$charset = $GLOBALS['registry']->getCharset(); +$charset = 'UTF-8'; header('Content-Type: text/xml; charset=' . $charset); echo <<getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/wicked/templates/edit/new.inc b/wicked/templates/edit/new.inc index d36c17270..1abee7298 100644 --- a/wicked/templates/edit/new.inc +++ b/wicked/templates/edit/new.inc @@ -26,7 +26,7 @@ function preview()
- +
diff --git a/wicked/templates/edit/standard.inc b/wicked/templates/edit/standard.inc index 2b69b831f..621cb088b 100644 --- a/wicked/templates/edit/standard.inc +++ b/wicked/templates/edit/standard.inc @@ -45,7 +45,7 @@ if (!empty($GLOBALS['conf']['wicked']['captcha']) && !$GLOBALS['registry']->getA
- +
diff --git a/wicked/templates/history/summary.inc b/wicked/templates/history/summary.inc index 8d7efe963..956500552 100644 --- a/wicked/templates/history/summary.inc +++ b/wicked/templates/history/summary.inc @@ -40,5 +40,5 @@ if ($show_restore) {
- +
- +   diff --git a/jeta/templates/common-header.inc b/jeta/templates/common-header.inc new file mode 100644 index 000000000..4c9a50709 --- /dev/null +++ b/jeta/templates/common-header.inc @@ -0,0 +1,15 @@ + + +' : '' ?> + +<?php echo htmlspecialchars($registry->get('name')) ?> + + + + + diff --git a/jonah/delivery/rss.php b/jonah/delivery/rss.php index e6bfd9061..01bd5d800 100644 --- a/jonah/delivery/rss.php +++ b/jonah/delivery/rss.php @@ -65,22 +65,22 @@ try { // Build the template (@TODO: Use Horde_View) $template = new Horde_Template(); -$template->set('charset', $GLOBALS['registry']->getCharset()); +$template->set('charset', 'UTF-8'); $template->set('jonah', 'Jonah ' . $registry->getVersion() . ' (http://www.horde.org/jonah/)'); $template->set('xsl', $registry->get('themesuri') . '/feed-rss.xsl'); if (!empty($criteria['tag_id'])) { - $template->set('channel_name', sprintf(_("Stories tagged with %s in %s"), $tag_name, @htmlspecialchars($channel['channel_name'], ENT_COMPAT, $GLOBALS['registry']->getCharset()))); + $template->set('channel_name', sprintf(_("Stories tagged with %s in %s"), $tag_name, @htmlspecialchars($channel['channel_name'], ENT_COMPAT, 'UTF-8'))); } else { - $template->set('channel_name', @htmlspecialchars($channel['channel_name'], ENT_COMPAT, $GLOBALS['registry']->getCharset())); + $template->set('channel_name', @htmlspecialchars($channel['channel_name'], ENT_COMPAT, 'UTF-8')); } -$template->set('channel_desc', @htmlspecialchars($channel['channel_desc'], ENT_COMPAT, $GLOBALS['registry']->getCharset())); +$template->set('channel_desc', @htmlspecialchars($channel['channel_desc'], ENT_COMPAT, 'UTF-8')); $template->set('channel_updated', htmlspecialchars(date('r', $channel['channel_updated']))); $template->set('channel_official', htmlspecialchars($channel['channel_official'])); $template->set('channel_rss', htmlspecialchars(Horde_Util::addParameter(Horde::url('delivery/rss.php', true, -1), array('type' => 'rss', 'channel_id' => $channel['channel_id'])))); $template->set('channel_rss2', htmlspecialchars(Horde_Util::addParameter(Horde::url('delivery/rss.php', true, -1), array('type' => 'rss2', 'channel_id' => $channel['channel_id'])))); foreach ($stories as &$story) { - $story['title'] = @htmlspecialchars($story['title'], ENT_COMPAT, $GLOBALS['registry']->getCharset()); - $story['description'] = @htmlspecialchars($story['description'], ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $story['title'] = @htmlspecialchars($story['title'], ENT_COMPAT, 'UTF-8'); + $story['description'] = @htmlspecialchars($story['description'], ENT_COMPAT, 'UTF-8'); $story['permalink'] = htmlspecialchars($story['permalink']); $story['published'] = htmlspecialchars(date('r', $story['published'])); if (!empty($story['body_type']) && $story['body_type'] == 'text') { diff --git a/jonah/lib/Block/latest.php b/jonah/lib/Block/latest.php index beae9b77c..cd1b19cfc 100644 --- a/jonah/lib/Block/latest.php +++ b/jonah/lib/Block/latest.php @@ -56,13 +56,13 @@ class Horde_Block_Jonah_latest extends Horde_Block try { $story = $this->_fetch(); } catch (Exception $e) { - return @htmlspecialchars($e->getMessage(), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + return @htmlspecialchars($e->getMessage(), ENT_COMPAT, 'UTF-8'); } return ' ' - . @htmlspecialchars($story['title'], ENT_COMPAT, $GLOBALS['registry']->getCharset()); + . @htmlspecialchars($story['title'], ENT_COMPAT, 'UTF-8'); } /** diff --git a/jonah/lib/Block/news.php b/jonah/lib/Block/news.php index 744db8ba8..4aa09626d 100644 --- a/jonah/lib/Block/news.php +++ b/jonah/lib/Block/news.php @@ -59,15 +59,15 @@ class Horde_Block_Jonah_news extends Horde_Block { try { $channel = $GLOBALS['injector']->getInstance('Jonah_Driver')->getChannel($this->_params['source']); } catch (Jonah_Exception $e) { - return @htmlspecialchars($e->getMessage(), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + return @htmlspecialchars($e->getMessage(), ENT_COMPAT, 'UTF-8'); } if (!empty($channel['channel_link'])) { $title = Horde::link(htmlspecialchars($channel['channel_link']), '', '', '_blank') - . @htmlspecialchars($channel['channel_name'], ENT_COMPAT, $GLOBALS['registry']->getCharset()) + . @htmlspecialchars($channel['channel_name'], ENT_COMPAT, 'UTF-8') . ''; } else { - $title = @htmlspecialchars($channel['channel_name'], ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $title = @htmlspecialchars($channel['channel_name'], ENT_COMPAT, 'UTF-8'); } return $title; diff --git a/jonah/lib/Block/news_popular.php b/jonah/lib/Block/news_popular.php index 87db9351f..40cfbbdb0 100644 --- a/jonah/lib/Block/news_popular.php +++ b/jonah/lib/Block/news_popular.php @@ -56,15 +56,15 @@ class Horde_Block_Jonah_news_popular extends Horde_Block { try { $channel = $GLOBALS['injector']->getInstance('Jonah_Driver')->getChannel($this->_params['source']); } catch (Exception $e) { - return @htmlspecialchars($e->getMessage(), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + return @htmlspecialchars($e->getMessage(), ENT_COMPAT, 'UTF-8'); } if (!empty($channel['channel_link'])) { $title = Horde::link(htmlspecialchars($channel['channel_link']), '', '', '_blank') - . @htmlspecialchars($channel['channel_name'], ENT_COMPAT, $GLOBALS['registry']->getCharset()) + . @htmlspecialchars($channel['channel_name'], ENT_COMPAT, 'UTF-8') . _(" - Most read stories") . ''; } else { - $title = @htmlspecialchars($channel['channel_name'], ENT_COMPAT, $GLOBALS['registry']->getCharset()) + $title = @htmlspecialchars($channel['channel_name'], ENT_COMPAT, 'UTF-8') . _(" - Most read stories"); } diff --git a/jonah/lib/Block/story.php b/jonah/lib/Block/story.php index 093a4a158..d5d32c5a4 100644 --- a/jonah/lib/Block/story.php +++ b/jonah/lib/Block/story.php @@ -57,12 +57,12 @@ class Horde_Block_Jonah_story extends Horde_Block { try { $story = $this->_fetch(); } catch (Jonah_Exception $e) { - return htmlspecialchars($e->getMessage(), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + return htmlspecialchars($e->getMessage(), ENT_COMPAT, 'UTF-8'); } return ' ' - . htmlspecialchars($story['title'], ENT_COMPAT, $GLOBALS['registry']->getCharset()); + . htmlspecialchars($story['title'], ENT_COMPAT, 'UTF-8'); } /** diff --git a/jonah/lib/Driver.php b/jonah/lib/Driver.php index b15529eeb..f9fedb8ac 100644 --- a/jonah/lib/Driver.php +++ b/jonah/lib/Driver.php @@ -406,13 +406,13 @@ class Jonah_Driver /* Add the text version of the story to the base message. */ $message_text = new MIME_Part('text/plain'); - $message_text->setCharset($GLOBALS['registry']->getCharset()); + $message_text->setCharset('UTF-8'); $message_text->setContents($message_text->replaceEOL($body_text)); $message_text->setDescription(_("Plaintext Version of Story")); /* Add an HTML version of the story to the base message. */ $message_html = new MIME_Part('text/html', Horde_String::wrap($body_html), - $GLOBALS['registry']->getCharset(), 'inline'); + 'UTF-8', 'inline'); $message_html->setDescription(_("HTML Version of Story")); /* Add the two parts as multipart/alternative. */ @@ -426,7 +426,7 @@ class Jonah_Driver /* This is just a plain text story. */ $message_text = new MIME_Part('text/plain'); $message_text->setContents($message_text->replaceEOL($story['description'] . "\n\n" . $story['body'])); - $message_text->setCharset($GLOBALS['registry']->getCharset()); + $message_text->setCharset('UTF-8'); return $message_text; } diff --git a/jonah/lib/Driver/Sql.php b/jonah/lib/Driver/Sql.php index 0bf257ae7..bb97d9003 100644 --- a/jonah/lib/Driver/Sql.php +++ b/jonah/lib/Driver/Sql.php @@ -83,7 +83,7 @@ class Jonah_Driver_Sql extends Jonah_Driver array_unshift($values, (int)$info['channel_id'], - Horde_String::convertCharset($info['channel_name'], $GLOBALS['registry']->getCharset(), $this->_params['charset']), + Horde_String::convertCharset($info['channel_name'], 'UTF-8', $this->_params['charset']), (int)$info['channel_type'], isset($info['channel_desc']) ? $info['channel_desc'] : null, isset($info['channel_interval']) ? (int)$info['channel_interval'] : null, @@ -253,10 +253,10 @@ class Jonah_Driver_Sql extends Jonah_Driver array_unshift($values, (int)$info['id'], (int)$info['channel_id'], - Horde_String::convertCharset($info['title'], $GLOBALS['registry']->getCharset(), $this->_params['charset']), - Horde_String::convertCharset($info['description'], $GLOBALS['registry']->getCharset(), $this->_params['charset']), + Horde_String::convertCharset($info['title'], 'UTF-8', $this->_params['charset']), + Horde_String::convertCharset($info['description'], 'UTF-8', $this->_params['charset']), $info['body_type'], - isset($info['body']) ? Horde_String::convertCharset($info['body'], $GLOBALS['registry']->getCharset(), $this->_params['charset']) : null, + isset($info['body']) ? Horde_String::convertCharset($info['body'], 'UTF-8', $this->_params['charset']) : null, isset($info['url']) ? $info['url'] : null, isset($info['published']) ? (int)$info['published'] : null, time(), @@ -283,13 +283,13 @@ class Jonah_Driver_Sql extends Jonah_Driver */ protected function _convertFromBackend($story) { - $story['title'] = Horde_String::convertCharset($story['title'], $this->_params['charset'], $GLOBALS['registry']->getCharset()); - $story['description'] = Horde_String::convertCharset($story['description'], $this->_params['charset'], $GLOBALS['registry']->getCharset()); + $story['title'] = Horde_String::convertCharset($story['title'], $this->_params['charset'], 'UTF-8'); + $story['description'] = Horde_String::convertCharset($story['description'], $this->_params['charset'], 'UTF-8'); if (isset($story['body'])) { - $story['body'] = Horde_String::convertCharset($story['body'], $this->_params['charset'], $GLOBALS['registry']->getCharset()); + $story['body'] = Horde_String::convertCharset($story['body'], $this->_params['charset'], 'UTF-8'); } if (isset($story['tags'])) { - $story['tags'] = Horde_String::convertCharset($story['tags'], $this->_params['charset'], $GLOBALS['registry']->getCharset()); + $story['tags'] = Horde_String::convertCharset($story['tags'], $this->_params['charset'], 'UTF-8'); } return $story; diff --git a/jonah/stories/share.php b/jonah/stories/share.php index b84c58504..16de655ea 100644 --- a/jonah/stories/share.php +++ b/jonah/stories/share.php @@ -26,12 +26,12 @@ function _mail($story_part, $from, $recipients, $subject, $note) $mail = new Horde_Mime_Mail(array('subject' => $subject, 'to' => $recipients, 'from' => $from, - 'charset' => $GLOBALS['registry']->getCharset())); + 'charset' => 'UTF-8')); $mail->addHeader('User-Agent', 'Jonah ' . $GLOBALS['registry']->getVersion()); /* If a note has been provided, add it to the message as a text part. */ if (strlen($note) > 0) { - $message_note = new MIME_Part('text/plain', null, $GLOBALS['registry']->getCharset()); + $message_note = new MIME_Part('text/plain', null, 'UTF-8'); $message_note->setContents($message_note->replaceEOL($note)); $message_note->setDescription(_("Note")); $mail->addMIMEPart($message_note); diff --git a/jonah/templates/common-header.inc b/jonah/templates/common-header.inc index 36618dff2..dd26f7d8a 100644 --- a/jonah/templates/common-header.inc +++ b/jonah/templates/common-header.inc @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/kastalia/templates/common-header.inc b/kastalia/templates/common-header.inc new file mode 100755 index 000000000..1a7d8d154 --- /dev/null +++ b/kastalia/templates/common-header.inc @@ -0,0 +1,32 @@ + + + + + +' : '' ?> + + + + +get('name'); +if (!empty($title)) { + $page_title .= ' :: ' . $title; +} + +Horde::outputMetaTags(); +Horde::includeScriptFiles(); + +?> +<?php echo htmlspecialchars($page_title) ?> + + + + + diff --git a/koward/lib/Koward/View/shared/_header.html.php b/koward/lib/Koward/View/shared/_header.html.php index a5f9cdfa1..9735801b0 100644 --- a/koward/lib/Koward/View/shared/_header.html.php +++ b/koward/lib/Koward/View/shared/_header.html.php @@ -1,6 +1,6 @@ getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/kronolith/add.php b/kronolith/add.php index 199da4ba1..05ad79e4e 100644 --- a/kronolith/add.php +++ b/kronolith/add.php @@ -54,7 +54,7 @@ do { try { $message = Horde::callHook('perms_denied', array('kronolith:max_events')); } catch (Horde_Exception_HookNotSet $e) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')), ENT_COMPAT, 'UTF-8'); } $GLOBALS['notification']->push($message, 'horde.error', array('content.raw')); break; diff --git a/kronolith/data.php b/kronolith/data.php index 17a083f8c..5b54759de 100644 --- a/kronolith/data.php +++ b/kronolith/data.php @@ -46,7 +46,7 @@ if ($perms->hasAppPermission('max_events') !== true && try { $message = Horde::callHook('perms_denied', array('kronolith:max_events')); } catch (Horde_Exception_HookNotSet $e) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')), ENT_COMPAT, 'UTF-8'); } $notification->push($message, 'horde.warning', array('content.raw')); $templates[Horde_Data::IMPORT_FILE] = array(KRONOLITH_TEMPLATES . '/data/export.inc'); @@ -182,7 +182,7 @@ case 'export': $calNames[] = $share->get('name'); } - $iCal->setAttribute('X-WR-CALNAME', Horde_String::convertCharset(implode(', ', $calNames), $GLOBALS['registry']->getCharset(), 'utf-8')); + $iCal->setAttribute('X-WR-CALNAME', Horde_String::convertCharset(implode(', ', $calNames), 'UTF-8', 'utf-8')); $data = $iCal->exportvCalendar(); $browser->downloadHeaders(_("events.ics"), 'text/calendar', false, strlen($data)); echo $data; @@ -264,7 +264,7 @@ if (is_array($next_step)) { try { $message = Horde::callHook('perms_denied', array('kronolith:max_events')); } catch (Horde_Exception_HookNotSet $e) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')), ENT_COMPAT, 'UTF-8'); } $notification->push($message, 'horde.error', array('content.raw')); break; @@ -340,7 +340,7 @@ if (is_array($next_step)) { if (Horde_Util::getFormData('import_ajax')) { $stack = $notification->notify(array('listeners' => 'status', 'raw' => true)); if ($stack) { - Horde::addInlineScript('window.parent.KronolithCore.showNotifications(window.parent.$A(' . Horde_Serialize::serialize($stack, Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()) . '));'); + Horde::addInlineScript('window.parent.KronolithCore.showNotifications(window.parent.$A(' . Horde_Serialize::serialize($stack, Horde_Serialize::JSON, 'UTF-8') . '));'); } Horde::addInlineScript('window.parent.$(window.name).remove();'); Horde::outputInlineScript(); diff --git a/kronolith/edit.php b/kronolith/edit.php index 2f92f2181..c32e76de7 100644 --- a/kronolith/edit.php +++ b/kronolith/edit.php @@ -31,7 +31,7 @@ function _check_max() try { $message = Horde::callHook('perms_denied', array('kronolith:max_events')); } catch (Horde_Exception_HookNotSet $e) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')), ENT_COMPAT, 'UTF-8'); } $GLOBALS['notification']->push($message, 'horde.error', array('content.raw')); return false; diff --git a/kronolith/fb.php b/kronolith/fb.php index 19dc288c5..ce2384f48 100644 --- a/kronolith/fb.php +++ b/kronolith/fb.php @@ -59,7 +59,7 @@ if (!$fb) { } $browser->downloadHeaders(($user ? $user : $cal) . '.vfb', - 'text/calendar; charset=' . $GLOBALS['registry']->getCharset(), + 'text/calendar; charset=' . 'UTF-8', true, strlen($fb)); echo $fb; diff --git a/kronolith/feed/index.php b/kronolith/feed/index.php index 7ce6178ef..fcb499ec9 100644 --- a/kronolith/feed/index.php +++ b/kronolith/feed/index.php @@ -91,17 +91,17 @@ $history = $injector->getInstance('Horde_History'); $now = new Horde_Date(time()); $template = $injector->createInstance('Horde_Template'); -$template->set('charset', $GLOBALS['registry']->getCharset()); +$template->set('charset', 'UTF-8'); $template->set('updated', $now->format(DATE_ATOM)); $template->set('kronolith_name', 'Kronolith'); $template->set('kronolith_version', $registry->getVersion()); $template->set('kronolith_uri', 'http://www.horde.org/kronolith/'); $template->set('kronolith_icon', Horde::url(Horde_Themes::img('kronolith.png'), true, -1)); $template->set('xsl', $registry->get('themesuri') . '/feed-rss.xsl'); -$template->set('calendar_name', @htmlspecialchars($share->get('name'), ENT_COMPAT, $GLOBALS['registry']->getCharset())); -$template->set('calendar_desc', @htmlspecialchars($share->get('desc'), ENT_COMPAT, $GLOBALS['registry']->getCharset()), true); -$template->set('calendar_owner', @htmlspecialchars($identity->getValue('fullname'), ENT_COMPAT, $GLOBALS['registry']->getCharset())); -$template->set('calendar_email', @htmlspecialchars($identity->getValue('from_addr'), ENT_COMPAT, $GLOBALS['registry']->getCharset()), true); +$template->set('calendar_name', @htmlspecialchars($share->get('name'), ENT_COMPAT, 'UTF-8')); +$template->set('calendar_desc', @htmlspecialchars($share->get('desc'), ENT_COMPAT, 'UTF-8'), true); +$template->set('calendar_owner', @htmlspecialchars($identity->getValue('fullname'), ENT_COMPAT, 'UTF-8')); +$template->set('calendar_email', @htmlspecialchars($identity->getValue('from_addr'), ENT_COMPAT, 'UTF-8'), true); $template->set('self_url', $self_url); $twentyFour = $prefs->getValue('twentyFor'); @@ -117,7 +117,7 @@ foreach ($events as $day_events) { } $modified = new Horde_Date($modified); /* Description. */ - $desc = @htmlspecialchars($event->description, ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $desc = @htmlspecialchars($event->description, ENT_COMPAT, 'UTF-8'); if (strlen($desc)) { $desc .= '

'; } @@ -134,15 +134,15 @@ foreach ($events as $day_events) { $attendees[] = empty($status['name']) ? $attendee : Horde_Mime_Address::trimAddress($status['name'] . (strpos($attendee, '@') === false ? '' : ' <' . $attendee . '>')); } if (count($attendees)) { - $desc .= '
' . _("Who:") . ' ' . @htmlspecialchars(implode(', ', $attendees), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $desc .= '
' . _("Who:") . ' ' . @htmlspecialchars(implode(', ', $attendees), ENT_COMPAT, 'UTF-8'); } if (strlen($event->location)) { - $desc .= '
' . _("Where:") . ' ' . @htmlspecialchars($event->location, ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $desc .= '
' . _("Where:") . ' ' . @htmlspecialchars($event->location, ENT_COMPAT, 'UTF-8'); } $desc .= '
' . _("Event Status:") . ' ' . Kronolith::statusToString($event->status); - $entries[$id]['title'] = @htmlspecialchars($event->getTitle(), ENT_COMPAT, $GLOBALS['registry']->getCharset()); - $entries[$id]['desc'] = @htmlspecialchars($desc, ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $entries[$id]['title'] = @htmlspecialchars($event->getTitle(), ENT_COMPAT, 'UTF-8'); + $entries[$id]['desc'] = @htmlspecialchars($desc, ENT_COMPAT, 'UTF-8'); $entries[$id]['url'] = htmlspecialchars(Horde::url($event->getViewUrl(), true, -1)); $entries[$id]['modified'] = $modified->format(DATE_ATOM); } diff --git a/kronolith/lib/Ajax/Application.php b/kronolith/lib/Ajax/Application.php index 62cf4ef6c..7b075dd30 100644 --- a/kronolith/lib/Ajax/Application.php +++ b/kronolith/lib/Ajax/Application.php @@ -100,7 +100,7 @@ class Kronolith_Ajax_Application extends Horde_Core_Ajax_Application try { $message = Horde::callHook('perms_denied', array('kronolith:max_events')); } catch (Horde_Exception_HookNotSet $e) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')), ENT_COMPAT, 'UTF-8'); } $GLOBALS['notification']->push($message, 'horde.error', array('content.raw')); return $result; diff --git a/kronolith/lib/Api.php b/kronolith/lib/Api.php index f15ee95b7..2a5245f8d 100644 --- a/kronolith/lib/Api.php +++ b/kronolith/lib/Api.php @@ -785,7 +785,7 @@ class Kronolith_Api extends Horde_Registry_Api $share = $kronolith_shares->getShare($event->calendar); $iCal = new Horde_Icalendar($version); - $iCal->setAttribute('X-WR-CALNAME', Horde_String::convertCharset($share->get('name'), $GLOBALS['registry']->getCharset(), 'utf-8')); + $iCal->setAttribute('X-WR-CALNAME', Horde_String::convertCharset($share->get('name'), 'UTF-8', 'utf-8')); // Create a new vEvent. $iCal->addComponent($event->toiCalendar($iCal)); @@ -835,9 +835,9 @@ class Kronolith_Api extends Horde_Registry_Api $share = $kronolith_shares->getShare($calendar); $iCal = new Horde_Icalendar($version); - $iCal->setAttribute('X-WR-CALNAME', Horde_String::convertCharset($share->get('name'), $GLOBALS['registry']->getCharset(), 'UTF-8')); + $iCal->setAttribute('X-WR-CALNAME', Horde_String::convertCharset($share->get('name'), 'UTF-8', 'UTF-8')); if (strlen($share->get('desc'))) { - $iCal->setAttribute('X-WR-CALDESC', Horde_String::convertCharset($share->get('desc'), $GLOBALS['registry']->getCharset(), 'UTF-8')); + $iCal->setAttribute('X-WR-CALDESC', Horde_String::convertCharset($share->get('desc'), 'UTF-8', 'UTF-8')); } foreach ($events as $dayevents) { diff --git a/kronolith/lib/Application.php b/kronolith/lib/Application.php index 3425e6ead..d84ca63ac 100644 --- a/kronolith/lib/Application.php +++ b/kronolith/lib/Application.php @@ -523,7 +523,7 @@ class Kronolith_Application extends Horde_Registry_Application $tree->addNode( $parent . $calId . $event->id, $parent, - htmlspecialchars($event->getTitle(), ENT_COMPAT, $GLOBALS['registry']->getCharset()), + htmlspecialchars($event->getTitle(), ENT_COMPAT, 'UTF-8'), 1, false, array( diff --git a/kronolith/lib/Driver/Sql.php b/kronolith/lib/Driver/Sql.php index 557941a25..8df6d2d83 100644 --- a/kronolith/lib/Driver/Sql.php +++ b/kronolith/lib/Driver/Sql.php @@ -942,7 +942,7 @@ class Kronolith_Driver_Sql extends Kronolith_Driver */ public function convertToDriver($value) { - return Horde_String::convertCharset($value, $GLOBALS['registry']->getCharset(), $this->_params['charset']); + return Horde_String::convertCharset($value, 'UTF-8', $this->_params['charset']); } /** diff --git a/kronolith/lib/Event.php b/kronolith/lib/Event.php index 2349d7b33..4aa4d89d6 100644 --- a/kronolith/lib/Event.php +++ b/kronolith/lib/Event.php @@ -560,17 +560,17 @@ abstract class Kronolith_Event $vEvent->setAttribute('LAST-MODIFIED', $modified); } - $vEvent->setAttribute('SUMMARY', $v1 ? $this->getTitle() : Horde_String::convertCharset($this->getTitle(), $GLOBALS['registry']->getCharset(), 'utf-8')); + $vEvent->setAttribute('SUMMARY', $v1 ? $this->getTitle() : Horde_String::convertCharset($this->getTitle(), 'UTF-8', 'utf-8')); $name = Kronolith::getUserName($this->creator); if (!$v1) { - $name = Horde_String::convertCharset($name, $GLOBALS['registry']->getCharset(), 'utf-8'); + $name = Horde_String::convertCharset($name, 'UTF-8', 'utf-8'); } $vEvent->setAttribute('ORGANIZER', 'mailto:' . Kronolith::getUserEmail($this->creator), array('CN' => $name)); if (!$this->private || $this->creator == $GLOBALS['registry']->getAuth()) { if (!empty($this->description)) { - $vEvent->setAttribute('DESCRIPTION', $v1 ? $this->description : Horde_String::convertCharset($this->description, $GLOBALS['registry']->getCharset(), 'utf-8')); + $vEvent->setAttribute('DESCRIPTION', $v1 ? $this->description : Horde_String::convertCharset($this->description, 'UTF-8', 'utf-8')); } // Tags @@ -579,12 +579,12 @@ abstract class Kronolith_Event $tags = implode(', ', $tags); } if (!empty($tags)) { - $vEvent->setAttribute('CATEGORIES', $v1 ? $tags : Horde_String::convertCharset($tags, $GLOBALS['registry']->getCharset(), 'utf-8')); + $vEvent->setAttribute('CATEGORIES', $v1 ? $tags : Horde_String::convertCharset($tags, 'UTF-8', 'utf-8')); } // Location if (!empty($this->location)) { - $vEvent->setAttribute('LOCATION', $v1 ? $this->location : Horde_String::convertCharset($this->location, $GLOBALS['registry']->getCharset(), 'utf-8')); + $vEvent->setAttribute('LOCATION', $v1 ? $this->location : Horde_String::convertCharset($this->location, 'UTF-8', 'utf-8')); } if ($this->geoLocation) { $vEvent->setAttribute('GEO', array('latitude' => $this->geoLocation['lat'], 'longitude' => $this->geoLocation['lon'])); @@ -702,7 +702,7 @@ abstract class Kronolith_Event } } else { if (!empty($status['name'])) { - $params['CN'] = Horde_String::convertCharset($status['name'], $GLOBALS['registry']->getCharset(), 'utf-8'); + $params['CN'] = Horde_String::convertCharset($status['name'], 'UTF-8', 'utf-8'); } if (!empty($email)) { $email = 'mailto:' . $email; @@ -1104,7 +1104,7 @@ abstract class Kronolith_Event */ public function fromASAppointment(Horde_ActiveSync_Message_Appointment $message) { - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; /* New event? */ if ($this->id === null) { @@ -1231,7 +1231,7 @@ abstract class Kronolith_Event */ public function toASAppointment() { - $charset = $GLOBALS['registry']->getCharset(); + $charset = 'UTF-8'; $message = new Horde_ActiveSync_Message_Appointment(array('logger' => $GLOBALS['injector']->getInstance('Horde_Log_Logger'))); $message->setSubject(Horde_String::convertCharset($this->getTitle(), $charset, 'utf-8')); @@ -2023,7 +2023,7 @@ abstract class Kronolith_Event // Convert IDN hosts to ASCII. if (function_exists('idn_to_ascii')) { $old_error = error_reporting(0); - $url['host'] = idn_to_ascii(Horde_String::convertCharset($url['host'], $GLOBALS['registry']->getCharset(), 'UTF-8')); + $url['host'] = idn_to_ascii(Horde_String::convertCharset($url['host'], 'UTF-8', 'UTF-8')); error_reporting($old_error); } elseif (Horde_Mime::is8bit($url['host'])) { //throw new Kronolith_Exception(_("Invalid character in URL.")); @@ -2639,7 +2639,7 @@ abstract class Kronolith_Event '', array('style' => $this->getCSSColors(false))); } - $link .= @htmlspecialchars($event_title, ENT_QUOTES, $GLOBALS['registry']->getCharset()); + $link .= @htmlspecialchars($event_title, ENT_QUOTES, 'UTF-8'); if ($read_permission && $view_url) { $link .= ''; } diff --git a/kronolith/lib/Kronolith.php b/kronolith/lib/Kronolith.php index 2a7daa3a6..b62a3e5ac 100644 --- a/kronolith/lib/Kronolith.php +++ b/kronolith/lib/Kronolith.php @@ -79,7 +79,7 @@ class Kronolith Horde_Core_Ui_JsCalendar::init(array('short_weekdays' => true)); if (isset($GLOBALS['language'])) { - header('Content-type: text/html; charset=' . $GLOBALS['registry']->getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } @@ -333,7 +333,7 @@ class Kronolith // Maps $code['conf']['maps'] = $GLOBALS['conf']['maps']; - return array('var Kronolith = ' . Horde_Serialize::serialize($code, Horde_Serialize::JSON, $registry->getCharset()) . ';'); + return array('var Kronolith = ' . Horde_Serialize::serialize($code, Horde_Serialize::JSON, 'UTF-8') . ';'); } /** @@ -1732,7 +1732,7 @@ class Kronolith $userName = $identity->getName(); $mail = new Horde_Mime_Mail( array('from' => $identity->getDefaultFromAddress(true), - 'charset' => $GLOBALS['registry']->getCharset()) + 'charset' => 'UTF-8') ); $mail->addHeader('User-Agent', 'Kronolith ' . $GLOBALS['registry']->getVersion()); } @@ -1763,7 +1763,7 @@ class Kronolith } $mail->addHeader('Subject', _("Ownership assignment")); $mail->addHeader('To', $to); - $mail->setBody($message, $GLOBALS['registry']->getCharset()); + $mail->setBody($message, 'UTF-8'); $mail->send($GLOBALS['injector']->getInstance('Horde_Mail')); } } @@ -1917,7 +1917,7 @@ class Kronolith $share->get('name')); } $mail->addHeader('To', $to); - $mail->setBody($message, $GLOBALS['registry']->getCharset()); + $mail->setBody($message, 'UTF-8'); $mail->send($GLOBALS['injector']->getInstance('Horde_Mail')); } } @@ -1973,7 +1973,7 @@ class Kronolith $share->get('name')); } $mail->addHeader('To', $groupOb->getName() . ' <' . $groupOb->data['email'] . '>'); - $mail->setBody($message, $GLOBALS['registry']->getCharset()); + $mail->setBody($message, 'UTF-8'); $mail->send($GLOBALS['injector']->getInstance('Horde_Mail')); } } @@ -2166,7 +2166,7 @@ class Kronolith : $newAttendeeParsedPart->personal; try { - $newAttendeeParsedPartNew = Horde_Mime::encodeAddress(Horde_Mime_Address::writeAddress($newAttendeeParsedPart->mailbox, $newAttendeeParsedPart->host, $name), $GLOBALS['registry']->getCharset()); + $newAttendeeParsedPartNew = Horde_Mime::encodeAddress(Horde_Mime_Address::writeAddress($newAttendeeParsedPart->mailbox, $newAttendeeParsedPart->host, $name), 'UTF-8'); $newAttendeeParsedPartValidated = $parser->parseAddressList($newAttendeeParsedPartNew, array( 'default_domain' => null )); @@ -2316,7 +2316,7 @@ class Kronolith /* Build the iCalendar data */ $iCal = new Horde_Icalendar(); $iCal->setAttribute('METHOD', $method); - $iCal->setAttribute('X-WR-CALNAME', Horde_String::convertCharset($share->get('name'), $registry->getCharset(), 'utf-8')); + $iCal->setAttribute('X-WR-CALNAME', Horde_String::convertCharset($share->get('name'), 'UTF-8', 'utf-8')); $vevent = $event->toiCalendar($iCal); if ($action == self::ITIP_CANCEL && !empty($instance)) { // Recurring event instance deletion, need to specify the @@ -2333,18 +2333,18 @@ class Kronolith $ics->setContents($iCal->exportvCalendar()); $ics->setName($filename); $ics->setContentTypeParameter('METHOD', $method); - $ics->setCharset($registry->getCharset()); + $ics->setCharset('UTF-8'); $multipart = new Horde_Mime_Part(); $multipart->setType('multipart/alternative'); $bodyText = new Horde_Mime_Part(); $bodyText->setType('text/plain'); - $bodyText->setCharset($registry->getCharset()); + $bodyText->setCharset('UTF-8'); $bodyText->setContents($view->render('notification.plain.php')); $multipart->addPart($bodyText); $bodyHtml = new Horde_Mime_Part(); $bodyHtml->setType('text/html'); - $bodyHtml->setCharset($registry->getCharset()); + $bodyHtml->setCharset('UTF-8'); $bodyHtml->setContents($view->render('notification.html.php')); $multipart->addPart($bodyHtml); $multipart->addPart($ics); @@ -2352,7 +2352,7 @@ class Kronolith $mail = new Horde_Mime_Mail(array('subject' => $view->subject, 'to' => $recipient, 'from' => $ident->getDefaultFromAddress(true), - 'charset' => $registry->getCharset())); + 'charset' => 'UTF-8')); $mail->addHeader('User-Agent', 'Kronolith ' . $GLOBALS['registry']->getVersion()); $mail->setBasePart($multipart); @@ -2482,9 +2482,9 @@ class Kronolith $mime_mail = new Horde_Mime_Mail(array('subject' => $subject . ' ' . $event->title, 'to' => implode(',', $df_recipients), 'from' => $identity->getDefaultFromAddress(true), - 'charset' => $GLOBALS['registry']->getCharset())); + 'charset' => 'UTF-8')); $mime_mail->addHeader('User-Agent', 'Kronolith ' . $GLOBALS['registry']->getVersion()); - $mime_mail->setBody($message, $GLOBALS['registry']->getCharset(), true); + $mime_mail->setBody($message, 'UTF-8', true); Horde::logMessage(sprintf('Sending event notifications for %s to %s', $event->title, implode(', ', $df_recipients)), 'DEBUG'); $mime_mail->send($GLOBALS['injector']->getInstance('Horde_Mail'), false, false); } diff --git a/kronolith/lib/View/ExportEvent.php b/kronolith/lib/View/ExportEvent.php index 1e62fad44..856986a3c 100644 --- a/kronolith/lib/View/ExportEvent.php +++ b/kronolith/lib/View/ExportEvent.php @@ -30,7 +30,7 @@ class Kronolith_View_ExportEvent { $iCal->setAttribute( 'X-WR-CALNAME', Horde_String::convertCharset($share->get('name'), - $GLOBALS['registry']->getCharset(), + 'UTF-8', 'utf-8')); } catch (Exception $e) { } @@ -41,7 +41,7 @@ class Kronolith_View_ExportEvent { $GLOBALS['browser']->downloadHeaders( $event->getTitle() . '.ics', - 'text/calendar; charset=' . $GLOBALS['registry']->getCharset(), + 'text/calendar; charset=' . 'UTF-8', true, strlen($content)); echo $content; exit; diff --git a/kronolith/new.php b/kronolith/new.php index e1ebd52f3..a8aaf7075 100644 --- a/kronolith/new.php +++ b/kronolith/new.php @@ -26,7 +26,7 @@ if ($perms->hasAppPermission('max_events') !== true && try { $message = Horde::callHook('perms_denied', array('kronolith:max_events')); } catch (Horde_Exception_HookNotSet $e) { - $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')), ENT_COMPAT, $GLOBALS['registry']->getCharset()); + $message = @htmlspecialchars(sprintf(_("You are not allowed to create more than %d events."), $perms->hasAppPermission('max_events')), ENT_COMPAT, 'UTF-8'); } $notification->push($message, 'horde.error', array('content.raw')); $url->redirect(); diff --git a/kronolith/scripts/agenda.php b/kronolith/scripts/agenda.php index 38987e817..ad9a62398 100755 --- a/kronolith/scripts/agenda.php +++ b/kronolith/scripts/agenda.php @@ -54,7 +54,7 @@ function send_agendas() $runtime = new Horde_Date($runtime); $default_timezone = date_default_timezone_get(); $kronolith_driver = Kronolith::getDriver(); - $view = new Horde_View(array('templatePath' => KRONOLITH_TEMPLATES . '/agenda', 'encoding' => $GLOBALS['registry']->getCharset())); + $view = new Horde_View(array('templatePath' => KRONOLITH_TEMPLATES . '/agenda', 'encoding' => 'UTF-8')); new Horde_View_Helper_Text($view); // Loop through the users and generate an agenda for them @@ -135,7 +135,7 @@ function send_agendas() array('subject' => sprintf(_("Your daily agenda for %s"), $view->date), 'to' => $email, 'from' => $GLOBALS['conf']['reminder']['from_addr'], - 'charset' => $GLOBALS['registry']->getCharset())); + 'charset' => 'UTF-8')); $mime_mail->addHeader('User-Agent', 'Kronolith ' . $GLOBALS['registry']->getVersion()); try { $mime_mail->addRecipients($email); @@ -145,12 +145,12 @@ function send_agendas() $multipart->setType('multipart/alternative'); $bodyText = new Horde_Mime_Part(); $bodyText->setType('text/plain'); - $bodyText->setCharset($GLOBALS['registry']->getCharset()); + $bodyText->setCharset('UTF-8'); $bodyText->setContents($view->render('notification.plain.php')); $multipart->addPart($bodyText); $bodyHtml = new Horde_Mime_Part(); $bodyHtml->setType('text/html'); - $bodyHtml->setCharset($GLOBALS['registry']->getCharset()); + $bodyHtml->setCharset('UTF-8'); $bodyHtml->setContents($view->render('notification.html.php')); $multipart->addPart($bodyHtml); $mime_mail->setBasePart($multipart); diff --git a/kronolith/templates/common-header.inc b/kronolith/templates/common-header.inc index c763729a5..168fef538 100644 --- a/kronolith/templates/common-header.inc +++ b/kronolith/templates/common-header.inc @@ -5,7 +5,7 @@ Horde::addScriptFile('views.js', 'kronolith'); Horde::addScriptFile('stripe.js', 'horde'); if (isset($language)) { - header('Content-type: text/html; charset=' . $GLOBALS['registry']->getCharset()); + header('Content-type: text/html; charset=' . 'UTF-8'); header('Vary: Accept-Language'); } ?> diff --git a/kronolith/templates/javascript_defs.php b/kronolith/templates/javascript_defs.php index 50e40ca35..ae866485a 100644 --- a/kronolith/templates/javascript_defs.php +++ b/kronolith/templates/javascript_defs.php @@ -3,7 +3,7 @@ * JavaScript variables for the traditional interface. */ -$charset = $GLOBALS['registry']->getCharset(); +$charset = 'UTF-8'; $currentDate = Kronolith::currentDate(); /* Variables used in core javascript files. */ diff --git a/kronolith/templates/view/view.inc b/kronolith/templates/view/view.inc index 97d4ffb5d..5d2a308c4 100644 --- a/kronolith/templates/view/view.inc +++ b/kronolith/templates/view/view.inc @@ -26,7 +26,7 @@
  getCharset()) ?>
  strftime($dateFormat) . ' ' . $created->format($timeFormat) . ' ' . @htmlspecialchars($createdby, ENT_COMPAT, $GLOBALS['registry']->getCharset()) ?>strftime($dateFormat) . ' ' . $created->format($timeFormat) . ' ' . @htmlspecialchars($createdby, ENT_COMPAT, 'UTF-8') ?>
  strftime($dateFormat) . ' ' . $modified->format($timeFormat) . ' ' . @htmlspecialchars($modifiedby, ENT_COMPAT, $GLOBALS['registry']->getCharset()) ?>strftime($dateFormat) . ' ' . $modified->format($timeFormat) . ' ' . @htmlspecialchars($modifiedby, ENT_COMPAT, 'UTF-8') ?>
 getValue('date_format'), $created) . ' ' . date($prefs->getValue('twentyFour') ? 'G:i' : 'g:i a', $created) . ' ' . @htmlspecialchars($createdby, ENT_COMPAT, $GLOBALS['registry']->getCharset()) ?>getValue('date_format'), $created) . ' ' . date($prefs->getValue('twentyFour') ? 'G:i' : 'g:i a', $created) . ' ' . @htmlspecialchars($createdby, ENT_COMPAT, 'UTF-8') ?>
 getValue('date_format'), $modified) . ' ' . date($prefs->getValue('twentyFour') ? 'G:i' : 'g:i a', $modified) . ' ' . @htmlspecialchars($modifiedby, ENT_COMPAT, $GLOBALS['registry']->getCharset()) ?>getValue('date_format'), $modified) . ' ' . date($prefs->getValue('twentyFour') ? 'G:i' : 'g:i a', $modified) . ' ' . @htmlspecialchars($modifiedby, ENT_COMPAT, 'UTF-8') ?>
getValue('date_format'), $created) . ' ' . date($prefs->getValue('twentyFour') ? 'G:i' : 'g:i a', $created) . ' ' . @htmlspecialchars($createdby, ENT_COMPAT, $GLOBALS['registry']->getCharset()) ?>getValue('date_format'), $created) . ' ' . date($prefs->getValue('twentyFour') ? 'G:i' : 'g:i a', $created) . ' ' . @htmlspecialchars($createdby, ENT_COMPAT, 'UTF-8') ?>
getValue('date_format'), $modified) . ' ' . date($prefs->getValue('twentyFour') ? 'G:i' : 'g:i a', $modified) . ' ' . @htmlspecialchars($modifiedby, ENT_COMPAT, $GLOBALS['registry']->getCharset()) ?>getValue('date_format'), $modified) . ' ' . date($prefs->getValue('twentyFour') ? 'G:i' : 'g:i a', $modified) . ' ' . @htmlspecialchars($modifiedby, ENT_COMPAT, 'UTF-8') ?>
changeLog(), ENT_COMPAT, $GLOBALS['registry']->getCharset()) ?>changeLog(), ENT_COMPAT, 'UTF-8') ?>