Merge horde/Ui with horde/Core.
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 14 Jul 2010 22:02:24 +0000 (16:02 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 23 Jul 2010 20:43:59 +0000 (14:43 -0600)
94 files changed:
agora/forums.php
agora/lib/Comments.php
agora/messages/index.php
agora/moderate.php
agora/search.php
agora/threads.php
ansel/faces/gallery.php
ansel/faces/search/all.php
ansel/faces/search/image_search.php
ansel/faces/search/name.php
ansel/faces/search/named.php
ansel/faces/search/owner.php
ansel/faces/search/tabs.php
ansel/group.php
ansel/lib/Block/cloud.php
ansel/lib/View/GalleryRenderer/Gallery.php
ansel/lib/View/GalleryRenderer/GalleryLightbox.php
ansel/lib/View/List.php
ansel/lib/View/Results.php
babel/view.php
beatnik/listzones.php
fima/lib/UI/VarRenderer/fima.php
fima/postings.php
folks/account/tabs.php
folks/activity.php
folks/birthday.php
folks/edit/tabs.php
folks/list.php
folks/new.php
folks/online.php
folks/popularity.php
folks/search.php
framework/Core/lib/Horde/Core/Ui/FlagImage.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Ui/JsCalendar.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Ui/Language.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Ui/Pager.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Ui/Tabs.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Ui/TagCloud.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Ui/VarRenderer.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Ui/VarRenderer/Html.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Ui/VarRenderer/TablesetHtml.php [new file with mode: 0644]
framework/Core/lib/Horde/Core/Ui/Widget.php [new file with mode: 0644]
framework/Core/package.xml
framework/Form/Form/Renderer.php
framework/Ui/lib/Horde/Ui/FlagImage.php [deleted file]
framework/Ui/lib/Horde/Ui/JsCalendar.php [deleted file]
framework/Ui/lib/Horde/Ui/Language.php [deleted file]
framework/Ui/lib/Horde/Ui/Pager.php [deleted file]
framework/Ui/lib/Horde/Ui/Tabs.php [deleted file]
framework/Ui/lib/Horde/Ui/TagCloud.php [deleted file]
framework/Ui/lib/Horde/Ui/VarRenderer.php [deleted file]
framework/Ui/lib/Horde/Ui/VarRenderer/Html.php [deleted file]
framework/Ui/lib/Horde/Ui/VarRenderer/TablesetHtml.php [deleted file]
framework/Ui/lib/Horde/Ui/Widget.php [deleted file]
framework/Ui/package.xml [deleted file]
gollem/manager.php
hermes/lib/Hermes.php
hermes/lib/Table.php
hermes/search.php
hermes/time.php
horde/admin/sessions.php
horde/lib/Block/cloud.php
horde/services/help/index.php
horde/templates/admin/user/list.inc
imp/message.php
imp/search.php
ingo/lib/Ui/VarRenderer/Ingo.php
ingo/spam.php
jonah/lib/Block/cloud.php
jonah/stories/view.php
koward/lib/Koward/Controller/ObjectController.php
kronolith/attendees.php
kronolith/lib/Event.php
kronolith/lib/Kronolith.php
nag/lib/Ui/VarRenderer/Nag.php
nag/list.php
news/admin/tabs.php
news/lib/Forms/Search.php
news/lib/Search.php
news/lib/TagCloud.php
operator/search.php
shout/lib/Shout.php
skoli/entry.php
turba/contact.php
turba/lib/View/List.php
turba/search.php
vilma/lib/Vilma.php
vilma/users/index.php
whups/admin/index.php
whups/lib/Forms/VarRenderer.php
whups/lib/Query.php
whups/lib/Renderer/Query.php
whups/lib/Whups.php
whups/query/index.php

index 23702f2..187a405 100644 (file)
@@ -67,7 +67,7 @@ $view->actions = empty($actions) ? null : $actions;
 
 /* Set up pager. */
 $vars = Horde_Variables::getDefaultVariables();
-$pager_ob = new Horde_Ui_Pager('forum_page', $vars, array('num' => $forums_count, 'url' => 'forums.php', 'perpage' => $forums_per_page));
+$pager_ob = new Horde_Core_Ui_Pager('forum_page', $vars, array('num' => $forums_count, 'url' => 'forums.php', 'perpage' => $forums_per_page));
 $pager_ob->preserve('scope', $scope);
 $view->pager_link = $pager_ob->render();
 
index 5f2fac4..6569478 100644 (file)
@@ -99,7 +99,7 @@ class Agora_ViewComments {
 
             if ($messages->_forum['message_count'] > $thread_per_page && $view_bodies == 2) {
                 $vars = new Horde_Variables(array('comments_page' => $thread_page));
-                $pager_ob = new Horde_Ui_Pager('comments_page', $vars,
+                $pager_ob = new Horde_Core_Ui_Pager('comments_page', $vars,
                                                 array('num' => $messages->_forum['message_count'],
                                                       'url' => $base_url,
                                                       'perpage' => $thread_per_page));
index b3494e8..60959d0 100644 (file)
@@ -134,7 +134,7 @@ if ($threads_list instanceof PEAR_Error) {
 /* Set up pager. */
 if ($thread_count > $thread_per_page && $view_bodies == 2) {
     $vars = new Horde_Variables(array('thread_page' => $thread_page));
-    $pager_ob = new Horde_Ui_Pager('thread_page', $vars, array('num' => $thread_count, 'url' => 'messages/index.php', 'perpage' => $thread_per_page));
+    $pager_ob = new Horde_Core_Ui_Pager('thread_page', $vars, array('num' => $thread_count, 'url' => 'messages/index.php', 'perpage' => $thread_per_page));
     $pager_ob->preserve('agora', Horde_Util::getFormData('agora'));
     $view->pager_link = $pager_ob->render();
 }
index 4d2f275..abec439 100644 (file)
@@ -71,7 +71,7 @@ $view->notify = Horde::endBuffer();
 
 /* Set up pager. */
 $vars = Horde_Variables::getDefaultVariables();
-$pager_ob = new Horde_Ui_Pager('moderate_page', $vars, array('num' => $messages_count, 'url' => Horde::selfUrl(true), 'perpage' => $messages_per_page));
+$pager_ob = new Horde_Core_Ui_Pager('moderate_page', $vars, array('num' => $messages_count, 'url' => Horde::selfUrl(true), 'perpage' => $messages_per_page));
 $pager_ob->preserve('agora', Horde_Util::getFormData('agora'));
 $view->pager = $pager_ob->render();
 
index 9cce5d7..e03be90 100644 (file)
@@ -45,7 +45,7 @@ if ($form->isSubmitted() || $thread_page != null) {
     }
 
     if ($searchResults['total'] > count($searchResults['results'])) {
-        $pager_ob = new Horde_Ui_Pager('thread_page', $vars, array('num' => $searchResults['total'], 'url' => 'search.php', 'perpage' => $thread_per_page));
+        $pager_ob = new Horde_Core_Ui_Pager('thread_page', $vars, array('num' => $searchResults['total'], 'url' => 'search.php', 'perpage' => $thread_per_page));
         foreach ($info as $key => $val) {
             if ($val) {
                 if ($key == 'keywords') {
index acdbe28..e300818 100644 (file)
@@ -73,7 +73,7 @@ $view->rss = Horde_Util::addParameter(Horde::applicationUrl('rss/threads.php', t
 
 /* Set up pager. */
 $vars = Horde_Variables::getDefaultVariables();
-$pager_ob = new Horde_Ui_Pager('thread_page', $vars, array('num' => $threads_count, 'url' => 'threads.php', 'perpage' => $threads_per_page));
+$pager_ob = new Horde_Core_Ui_Pager('thread_page', $vars, array('num' => $threads_count, 'url' => 'threads.php', 'perpage' => $threads_per_page));
 $pager_ob->preserve('agora', Horde_Util::getFormData('agora'));
 $view->pager_link = $pager_ob->render();
 
index b30ddb8..7ff5e2f 100644 (file)
@@ -45,7 +45,7 @@ $face = $injector->getInstance('Ansel_Faces');
 $autogenerate = $face->canAutogenerate();
 
 $vars = Horde_Variables::getDefaultVariables();
-$pager = new Horde_Ui_Pager(
+$pager = new Horde_Core_Ui_Pager(
     'page',
     $vars,
     array(
index 88f1f61..4bc49be 100644 (file)
@@ -24,7 +24,7 @@ try {
     $results = array();
 }
 $vars = Horde_Variables::getDefaultVariables();
-$pager = new Horde_Ui_Pager(
+$pager = new Horde_Core_Ui_Pager(
     'page', $vars,
     array(
         'num' => $count,
index ae8b75f..99114bb 100644 (file)
@@ -41,7 +41,7 @@ if (($face_id = Horde_Util::getGet('face_id')) !== null) {
 
 $title = _("Photo search");
 $vars = Horde_Variables::getDefaultVariables();
-$pager = new Horde_Ui_Pager(
+$pager = new Horde_Core_Ui_Pager(
     'page',
     $vars,
     array(
index d042a90..8176595 100644 (file)
@@ -34,7 +34,7 @@ if (!empty($name)) {
 }
 
 $vars = Horde_Variables::getDefaultVariables();
-$pager = new Horde_Ui_Pager(
+$pager = new Horde_Core_Ui_Pager(
     'page', $vars,
     array('num' => $count,
             'url' => 'faces/search/name.php',
index 65116af..c2b2528 100644 (file)
@@ -24,7 +24,7 @@ try {
 }
 
 $vars = Horde_Variables::getDefaultVariables();
-$pager = new Horde_Ui_Pager(
+$pager = new Horde_Core_Ui_Pager(
     'page', $vars,
     array(
         'num' => $count,
index 8064237..ba4c4c1 100644 (file)
@@ -32,7 +32,7 @@ try {
 }
 
 $vars = Horde_Variables::getDefaultVariables();
-$pager = new Horde_Ui_Pager(
+$pager = new Horde_Core_Ui_Pager(
     'page',
     $vars,
     array(
index c76d665..a4a5796 100644 (file)
@@ -17,7 +17,7 @@ $faces = $GLOBALS['injector']->getInstance('Ansel_Faces');
 
 /* Show tabs */
 $vars = Horde_Variables::getDefaultVariables();
-$tabs = new Horde_Ui_Tabs('search_faces', $vars);
+$tabs = new Horde_Core_Ui_Tabs('search_faces', $vars);
 $tabs->addTab(_("All faces"), Horde::applicationUrl('faces/search/all.php'), 'all');
 $tabs->addTab(_("From my galleries"), Horde::applicationUrl('faces/search/owner.php'), 'owner');
 $tabs->addTab(_("Named faces"), Horde::applicationUrl('faces/search/named.php'), 'named');
index 15ca18d..93b7a79 100644 (file)
@@ -75,7 +75,7 @@ default:
 
 // Set up pager.
 $vars = Horde_Variables::getDefaultVariables();
-$group_pager = new Horde_Ui_Pager('gbpage',
+$group_pager = new Horde_Core_Ui_Pager('gbpage',
                                   $vars,
                                   array(
                                       'num' => $num_groups,
index 676bf3a..d2a2be4 100644 (file)
@@ -55,7 +55,7 @@ class Horde_Block_ansel_cloud extends Horde_Block
         /* Get the tags */
         $tags = Ansel_Tags::listTagInfo(null, $this->_params['count']);
         if (count($tags)) {
-            $cloud = new Horde_Ui_TagCloud();
+            $cloud = new Horde_Core_Ui_TagCloud();
             foreach ($tags as $id => $tag) {
                 $link = Ansel::getUrlFor('view', array('view' => 'Results',
                                                        'tag' => $tag['tag_name']));
index 44465f9..42775d2 100644 (file)
@@ -89,7 +89,7 @@ class Ansel_View_GalleryRenderer_Gallery extends Ansel_View_GalleryRenderer_Base
                         'perpage' => $this->perpage,
                         'url_callback' => $callback);
 
-        $pager = new Horde_Ui_Pager('page', $vars, $params);
+        $pager = new Horde_Core_Ui_Pager('page', $vars, $params);
 
         // Note that we can't use Horde_Util::bufferOutput() here since the
         // include file would be included inside that method's scope, and not
index af5d565..89cb213 100644 (file)
@@ -114,7 +114,7 @@ class Ansel_View_GalleryRenderer_GalleryLightbox extends Ansel_View_GalleryRende
                         'perpage' => $this->perpage,
                         'url_callback' => $callback);
 
-        $pager = new Horde_Ui_Pager('page', $vars, $params);
+        $pager = new Horde_Core_Ui_Pager('page', $vars, $params);
         Horde::startBuffer();
         /* Create the js variables to pass to the lightbox script */
         $jsvars = array('graphics_dir' => Horde::applicationUrl(Horde_Themes::img(), true, -1),
index 1faad19..076023d 100644 (file)
@@ -219,7 +219,7 @@ class Ansel_View_List extends Ansel_View_Base
         if ($override) {
             $p_params['url_callback'] = null;
         }
-        $this->_pager = new Horde_Ui_Pager('page', $vars, $p_params);
+        $this->_pager = new Horde_Core_Ui_Pager('page', $vars, $p_params);
         $preserve = array('sort_dir' => $this->_sortDir);
         if (!empty($this->_sortBy)) {
             $preserve['sort'] = $this->_sortBy;
index 18dc4e8..ea13917 100644 (file)
@@ -251,7 +251,7 @@ class Ansel_View_Results extends Ansel_View_Base
 
         $this->_pagestart = ($this->_page * $this->_perPage) + 1;
         $this->_pageend = min($this->_pagestart + $numimages - 1, $this->_pagestart + $this->_perPage - 1);
-        $this->_pager = new Horde_Ui_Pager('page', $vars, array('num' => $total,
+        $this->_pager = new Horde_Core_Ui_Pager('page', $vars, array('num' => $total,
                                                          'url' => $viewurl,
                                                          'perpage' => $this->_perPage));
         Horde::startBuffer();
index dd40c8f..c0125b3 100644 (file)
@@ -490,7 +490,7 @@ $viewurl = Horde_Util::addParameter($viewurl, array('editmode' => $editmode,
                                              'module' => $app,
                                              'filter' => $filter,
                                              'search' => $search));
- $pager = new Horde_Ui_Pager('page', $vars, array('num' => $numitem, 'url' => $viewurl, 'page_count' => 10, 'perpage' => $perpage));
+ $pager = new Horde_Core_Ui_Pager('page', $vars, array('num' => $numitem, 'url' => $viewurl, 'page_count' => 10, 'perpage' => $perpage));
  echo $pager->render($page, $numitem, $viewurl);
 ?>
 </td></tr></table>
index 5d8051d..d43fde6 100644 (file)
@@ -27,7 +27,7 @@ $_SESSION['beatnik']['curpage'] = $page;
 $pager_vars = Horde_Variables::getDefaultVariables();
 $pager_vars->set('page', $page);
 $perpage = $prefs->getValue('domains_perpage');
-$pager = new Horde_Ui_Pager('page', $pager_vars,
+$pager = new Horde_Core_Ui_Pager('page', $pager_vars,
                             array('num' => count($beatnik->domains),
                                   'url' => 'listzones.php',
                                   'page_count' => 10,
index 5818735..4d9b572 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /**
- * This file contains all Horde_Ui_VarRenderer extensions required for editing
- * accounts.
+ * This file contains all Horde_Core_Ui_VarRenderer extensions required for
+ * editing accounts.
  *
  * See the enclosed file COPYING for license information (GPL). If you
  * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
  */
 
 /**
- * The Horde_Ui_VarRenderer_fima class provides additional methods for
+ * The Horde_Core_Ui_VarRenderer_fima class provides additional methods for
  * rendering Fima specific Horde_Form_Type fields.
  *
  * @author  Thomas Trethan <thomas@trethan.net>
  * @package Fima
  */
-class Horde_Ui_VarRenderer_Fima extends Horde_Ui_VarRenderer_Html {
+class Horde_Core_Ui_VarRenderer_Fima extends Horde_Core_Ui_VarRenderer_Html {
 
     protected function _renderVarInput_fima_dspostings($form, &$var, &$vars)
     {
index 4fc0434..690ee52 100644 (file)
@@ -696,7 +696,7 @@ if ($pageOb['mode'] == 'edit') {
 
 /* Generate tabs. */
 if ($pageOb['mode'] != 'transfer' && !$print_view) {
-    $tabs = new Horde_Ui_Tabs('postingtype', $vars);
+    $tabs = new Horde_Core_Ui_Tabs('postingtype', $vars);
     $postingtypes = Fima::getPostingTypes();
     foreach ($postingtypes as $typeValue => $typeLabel) {
         $tabs->addTab($typeLabel, $pageOb['url'], $typeValue);
index 14cd20b..cd57efd 100644 (file)
@@ -16,7 +16,7 @@ require_once dirname(__FILE__) . '/../lib/base.php';
 $auth = $injector->getInstance('Horde_Auth')->getAuth();
 
 $vars = Horde_Variables::getDefaultVariables();
-$tabs = new Horde_Ui_Tabs('what', $vars);
+$tabs = new Horde_Core_Ui_Tabs('what', $vars);
 $tabs->addTab(_("Login"), Horde::applicationUrl('login.php'), 'login');
 
 if ($conf['signup']['allow'] === true && $auth->hasCapability('add')) {
index 5085afb..d9aa49d 100644 (file)
@@ -31,7 +31,7 @@ if ($users instanceof PEAR_Error) {
 }
 
 $vars = Horde_Variables::getDefaultVariables();
-$pager = new Horde_Ui_Pager('page',
+$pager = new Horde_Core_Ui_Pager('page',
                             $vars, array('num' => $count,
                                          'url' => 'activity.php',
                                          'perpage' => $perpage));
index 89bad27..8dd0922 100644 (file)
@@ -43,7 +43,7 @@ if ($users instanceof PEAR_Error) {
 }
 
 $vars = Horde_Variables::getDefaultVariables();
-$pager = new Horde_Ui_Pager('page',
+$pager = new Horde_Core_Ui_Pager('page',
                             $vars, array('num' => $count,
                                          'url' => 'birthday.php',
                                          'perpage' => $perpage));
index e4632a3..2ec6f01 100644 (file)
@@ -16,7 +16,7 @@ if (!$registry->isAuthenticated()) {
 }
 
 $vars = Horde_Variables::getDefaultVariables();
-$tabs = new Horde_Ui_Tabs('what', $vars);
+$tabs = new Horde_Core_Ui_Tabs('what', $vars);
 $tabs->addTab(_("Edit my profile"), Horde::applicationUrl('edit/edit.php'), 'edit');
 $tabs->addTab(_("Privacy"), Horde::applicationUrl('edit/privacy.php'), 'privacy');
 $tabs->addTab(_("Blacklist"), Horde::applicationUrl('edit/friends/blacklist.php'), 'blacklist');
index 1c055ff..3b07e0c 100644 (file)
@@ -43,7 +43,7 @@ if ($users instanceof PEAR_Error) {
 }
 
 $vars = Horde_Variables::getDefaultVariables();
-$pager = new Horde_Ui_Pager('page',
+$pager = new Horde_Core_Ui_Pager('page',
                             $vars, array('num' => $count,
                                          'url' => 'list.php',
                                          'perpage' => $perpage));
index 5996834..bec0f71 100644 (file)
@@ -31,7 +31,7 @@ if ($users instanceof PEAR_Error) {
 }
 
 $vars = Horde_Variables::getDefaultVariables();
-$pager = new Horde_Ui_Pager('page',
+$pager = new Horde_Core_Ui_Pager('page',
                             $vars, array('num' => $count,
                                          'url' => 'new.php',
                                          'perpage' => $perpage));
index b761dc3..dd85be3 100644 (file)
@@ -43,7 +43,7 @@ if ($users instanceof PEAR_Error) {
 }
 
 $vars = Horde_Variables::getDefaultVariables();
-$pager = new Horde_Ui_Pager('page',
+$pager = new Horde_Core_Ui_Pager('page',
                             $vars, array('num' => $count,
                                          'url' => 'online.php',
                                          'perpage' => $perpage));
index 8faec75..e493659 100644 (file)
@@ -31,7 +31,7 @@ if ($users instanceof PEAR_Error) {
 }
 
 $vars = Horde_Variables::getDefaultVariables();
-$pager = new Horde_Ui_Pager('page',
+$pager = new Horde_Core_Ui_Pager('page',
                             $vars, array('num' => $count,
                                          'url' => 'popularity.php',
                                          'perpage' => $perpage));
index 6bd39f5..00d09c2 100644 (file)
@@ -60,7 +60,7 @@ if (!empty($criteria)) {
     }
 
     $vars = Horde_Variables::getDefaultVariables();
-    $pager = new Horde_Ui_Pager('page',
+    $pager = new Horde_Core_Ui_Pager('page',
                                 $vars, array('num' => $count,
                                             'url' => 'search.php',
                                             'perpage' => $perpage));
diff --git a/framework/Core/lib/Horde/Core/Ui/FlagImage.php b/framework/Core/lib/Horde/Core/Ui/FlagImage.php
new file mode 100644 (file)
index 0000000..17f8bef
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+/**
+ * The Horde_Core_Ui_FlagImage:: class provides a widget for linking to a flag
+ * image.
+ *
+ * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Core
+ */
+class Horde_Core_Ui_FlagImage
+{
+    /**
+     * Render the language selection.
+     *
+     * @param boolean $form  Return the selection box as a complete standalone
+     *                       form.
+     *
+     * @return string  The HTML selection box.
+     */
+    static public function generateFlagImageByHost($host)
+    {
+        $data = Horde_Nls::getCountryByHost($host, empty($GLOBALS['conf']['geoip']['datafile']) ? null : $GLOBALS['conf']['geoip']['datafile']);
+        if ($data === false) {
+            return '';
+        }
+
+        $img = $data['code'] . '.png';
+        return file_exists($GLOBALS['registry']->get('themesfs', 'horde') . '/graphics/flags/' . $img)
+            ? Horde::img('flags/' . $img, $data['name'], array('title' => $data['name']))
+            : '[' . $data['name'] . ']';
+    }
+
+}
diff --git a/framework/Core/lib/Horde/Core/Ui/JsCalendar.php b/framework/Core/lib/Horde/Core/Ui/JsCalendar.php
new file mode 100644 (file)
index 0000000..47afb15
--- /dev/null
@@ -0,0 +1,85 @@
+<?php
+/**
+ * The Horde_Core_Ui_JsCalendar:: class generates the necessary javascript
+ * code to allow the javascript calendar widget to be displayed on the page.
+ *
+ * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Core
+ */
+class Horde_Core_Ui_JsCalendar
+{
+    /**
+     * Output the necessary javascript code to allow display of the calendar
+     * widget.
+     *
+     * @param array $params  Configuration parameters for the widget:
+     *                       - short_weekdays: display only the first letter of
+     *                         weekdays?
+     */
+    static public function init($params = array())
+    {
+        $params += array('short_weekdays' => false);
+        $weekdays = self::weekdays();
+        if ($params['short_weekdays']) {
+            foreach ($weekdays as &$day) {
+                $day = substr($day, 0, 1);
+            }
+        }
+
+        Horde::addScriptFile('calendar.js', 'horde');
+        Horde::addInlineScript(array(
+            'Horde_Calendar.firstDayOfWeek = ' . (isset($GLOBALS['prefs']) ? intval($GLOBALS['prefs']->getValue('first_week_day')) : 1),
+            'Horde_Calendar.weekdays = ' . Horde_Serialize::serialize($weekdays, Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()),
+            'Horde_Calendar.months = ' . Horde_Serialize::serialize(self::months(), Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()),
+        ));
+    }
+
+    /**
+     * Return the list of localized abbreviated weekdays.
+     *
+     * @return array  Abbreviated weekdays.
+     */
+    static public function weekdays()
+    {
+        return array(
+            _("Su"),
+            _("Mo"),
+            _("Tu"),
+            _("We"),
+            _("Th"),
+            _("Fr"),
+            _("Sa")
+        );
+    }
+
+    /**
+     * Return the localized list of months.
+     *
+     * @return array  Month list.
+     */
+    static public function months()
+    {
+        return array(
+            _("January"),
+            _("February"),
+            _("March"),
+            _("April"),
+            _("May"),
+            _("June"),
+            _("July"),
+            _("August"),
+            _("September"),
+            _("October"),
+            _("November"),
+            _("December")
+        );
+    }
+
+}
diff --git a/framework/Core/lib/Horde/Core/Ui/Language.php b/framework/Core/lib/Horde/Core/Ui/Language.php
new file mode 100644 (file)
index 0000000..1467f70
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+/**
+ * The Horde_Core_Ui_Language:: class provides a widget for changing the
+ * currently selected language.
+ *
+ * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Jason M. Felice <jason.m.felice@gmail.com>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Core
+ */
+class Horde_Core_Ui_Language {
+
+    /**
+     * Render the language selection.
+     *
+     * @param boolean $form  Return the selection box as a complete standalone
+     *                       form.
+     *
+     * @return string  The HTML selection box.
+     */
+    static public function render()
+    {
+        $html = '';
+
+        if (!$GLOBALS['prefs']->isLocked('language')) {
+            $_SESSION['horde_language'] = $GLOBALS['registry']->preferredLang();
+            $html = sprintf('<form name="language" action="%s">',
+                            Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/language.php', false, -1));
+            $html .= '<input type="hidden" name="url" value="' . @htmlspecialchars(Horde::selfUrl(false, false, true)) . '" />';
+            $html .= '<select name="new_lang" onchange="document.language.submit()">';
+            foreach ($GLOBALS['registry']->nlsconfig['languages'] as $key => $val) {
+                $sel = ($key == $_SESSION['horde_language']) ? ' selected="selected"' : '';
+                $html .= "<option value=\"$key\"$sel>$val</option>";
+            }
+            $html .= '</select></form>';
+        }
+
+        return $html;
+    }
+
+}
diff --git a/framework/Core/lib/Horde/Core/Ui/Pager.php b/framework/Core/lib/Horde/Core/Ui/Pager.php
new file mode 100644 (file)
index 0000000..7dab22f
--- /dev/null
@@ -0,0 +1,128 @@
+<?php
+/**
+ * The Horde_Core_Ui_Pager:: provides links to individual pages.
+ *
+ * Copyright 2004-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Ben Chavet <ben@chavet.net>
+ * @author   Joel Vandal <joel@scopserv.com>
+ * @author   Chuck Hagenbuch <chuck@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Core
+ */
+class Horde_Core_Ui_Pager extends Horde_Core_Ui_Widget
+{
+    /**
+     * Constructor.
+     *
+     * TODO
+     */
+    public function __construct($name, $vars, $config)
+    {
+        $config = array_merge(array(
+            'page_limit' => 10,
+            'perpage' => 100
+        ), $config);
+
+        parent::__construct($name, $vars, $config);
+    }
+
+    /**
+     * Render the pager.
+     *
+     * @return string  HTML code containing a centered table with the pager
+     *                 links.
+     */
+    public function render($data = null)
+    {
+        global $prefs, $registry, $conf;
+
+        $num = $this->_config['num'];
+        $url = $this->_config['url'];
+
+        $page_limit = $this->_config['page_limit'];
+        $perpage = $this->_config['perpage'];
+
+        $current_page = $this->_vars->get($this->_name);
+
+        // Figure out how many pages there will be.
+        $pages = ($num / $perpage);
+        if (is_integer($pages)) {
+            $pages--;
+        }
+        $pages = (int)$pages;
+
+        // Return nothing if there is only one page.
+        if ($pages == 0 || $num == 0) {
+            return '';
+        }
+
+        $html = '<div class="pager">';
+
+        if ($current_page > 0) {
+            // Create the '<< Prev' link if we are not on the first page.
+            $link = Horde_Util::addParameter($url, $this->_name, $current_page - 1);
+            $link = $this->_addPreserved($link);
+            $link = $this->_link($link);
+            if (isset($this->_config['previousHTML'])) {
+                $html .= Horde::link($link, '', 'prev') . $this->_config['previousHTML'] . '</a>';
+            } else {
+                $html .= Horde::link($link, '', 'prev') . htmlspecialchars(_("<Previous")) . '</a>';
+            }
+        }
+
+        // Figure out the top & bottom display limits.
+        $bottom = max(0, $current_page - ($page_limit / 2) + 1);
+        $top = $bottom + $page_limit - 1;
+        if ($top - 1 > $pages) {
+            $bottom -= ($top - 1) - $pages;
+            $top = $pages + 1;
+        }
+
+        // Create bottom '[x-y]' link if necessary.
+        $link = $this->_addPreserved(Horde_Util::addParameter($url, $this->_name, $bottom - 1));
+        $link = $this->_link($link);
+
+        if ($bottom > 0) {
+            $html .= ' ' . Horde::link($link, '', 'prevRange') . '[' . ($bottom == 1 ? $bottom : '1-' . $bottom) . ']</a>';
+        }
+
+        // Create links to individual pages between limits.
+        for ($i = $bottom; $i <= $top && $i <= $pages; ++$i) {
+            if ($i == $current_page) {
+                $html .= ' <strong>(' . ($i + 1) . ')</strong>';
+            } elseif ($i >= 0 && $i <= $pages) {
+                $link = $this->_addPreserved(Horde_Util::addParameter($url, $this->_name, $i));
+                $link = $this->_link($link);
+                $html .= ' ' . Horde::link($link) . ($i + 1) . '</a>';
+            }
+        }
+
+        // Create top '[x-y]' link if necessary.
+        if ($top < $pages) {
+            $link = $this->_addPreserved(Horde_Util::addParameter($url, $this->_name, $top + 1));
+            $link = $this->_link($link);
+
+            $html .= ' ' . Horde::link($link, '', 'nextRange') . '[' .
+                ($top + 2 == $pages + 1 ? $pages + 1 : ($top + 2) . '-' . ($pages + 1)) . ']</a>';
+        }
+
+        // Create the 'Next>>' link if we are not on the last page.
+        if ($current_page < $pages) {
+            $link = $this->_addPreserved(Horde_Util::addParameter($url, $this->_name, $current_page + 1));
+            $link = $this->_link($link);
+            if (isset($this->_config['nextHTML'])) {
+                $html .= Horde::link($link, '', 'next') . $this->_config['nextHTML'] . '</a>';
+            } else {
+                $html .= ' ' . Horde::link($link, '', 'next') . htmlspecialchars(_("Next>")) . '</a>';
+            }
+        }
+
+        return $html . '</div>';
+    }
+
+}
diff --git a/framework/Core/lib/Horde/Core/Ui/Tabs.php b/framework/Core/lib/Horde/Core/Ui/Tabs.php
new file mode 100644 (file)
index 0000000..bdc8783
--- /dev/null
@@ -0,0 +1,114 @@
+<?php
+/**
+ * The Horde_Core_Ui_Tabs:: class manages and renders a tab-like interface.
+ *
+ * Copyright 2001-2003 Robert E. Coyle <robertecoyle@hotmail.com>
+ * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Jason M. Felice <jason.m.felice@gmail.com>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Core
+ */
+class Horde_Core_Ui_Tabs extends Horde_Core_Ui_Widget
+{
+    /**
+     * The array of tabs.
+     *
+     * @var array
+     */
+    protected $_tabs = array();
+
+    /**
+     * Adds a tab to the interface.
+     *
+     * @param string $title  The text which appears on the tab.
+     * @param string $link   The target page.
+     * @param mixed $params  Either a string value to set the tab variable to,
+     *                       or a hash of parameters. If an array, the tab
+     *                       variable can be set by the 'tabname' key.
+     */
+    public function addTab($title, $link, $params = array())
+    {
+        if (!is_array($params)) {
+            $params = array('tabname' => $params);
+        }
+
+        $this->_tabs[] = array_merge(array('title' => $title,
+                                           'link' => $link,
+                                           'tabname' => null),
+                                     $params);
+    }
+
+    /**
+     * Returns the title of the tab with the specified name.
+     *
+     * @param string $tabname  The name of the tab.
+     *
+     * @return string  The tab's title.
+     */
+    public function getTitleFromAction($tabname)
+    {
+        foreach ($this->_tabs as $tab) {
+            if ($tab['tabname'] == $tabname) {
+                return $tab['title'];
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * Renders the tabs.
+     *
+     * @param string $active_tab  If specified, the name of the active tab. If
+     *                            not, the active tab is determined
+     *                            automatically.
+     */
+    public function render($active_tab = null)
+    {
+        $html = "<div class=\"tabset\"><ul>\n";
+
+        $first = true;
+        $active = $_SERVER['PHP_SELF'] . $this->_vars->get($this->_name);
+
+        foreach ($this->_tabs as $tab) {
+            $link = $this->_addPreserved($tab['link']);
+            if (!is_null($this->_name) && !is_null($tab['tabname'])) {
+                $link->add($this->_name, $tab['tabname']);
+            }
+
+            $class = '';
+            if ((!is_null($active_tab) && $active_tab == $tab['tabname']) ||
+                ($active == $tab['link'] . $tab['tabname'])) {
+                $class = ' class="activeTab"';
+            }
+
+            $id = '';
+            if (!empty($tab['id'])) {
+                $id = ' id="' . htmlspecialchars($tab['id']) . '"';
+            }
+
+            if (!isset($tab['target'])) {
+                $tab['target'] = '';
+            }
+
+            if (!isset($tab['onclick'])) {
+                $tab['onclick'] = '';
+            }
+
+            $accesskey = Horde::getAccessKey($tab['title']);
+
+            $html .= '<li' . $class . $id . '>'
+                . $link->link(array('target' => $tab['target'], 'onclick' => $tab['onclick'], 'accesskey' => $accesskey))
+                . Horde::highlightAccessKey(str_replace(' ', '&nbsp;', $tab['title']), $accesskey)
+                . "</a> </li>\n";
+        }
+
+        return $html . "</ul></div><br class=\"clear\" />\n";
+    }
+
+}
diff --git a/framework/Core/lib/Horde/Core/Ui/TagCloud.php b/framework/Core/lib/Horde/Core/Ui/TagCloud.php
new file mode 100644 (file)
index 0000000..3646202
--- /dev/null
@@ -0,0 +1,317 @@
+<?php
+/**
+ * Horde_Core_Ui_TagCloud:: for creating and displaying tag clouds.
+ *
+ * Based on a striped down version of Pear's HTML_TagCloud
+ *
+ * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Core
+ */
+class Horde_Core_Ui_TagCloud
+{
+    /**
+     * @var integer
+     */
+    public $basefontsize = 24;
+
+    /**
+     * @var integer
+     */
+    public $fontsizerange = 12;
+
+    /**
+     * @var string
+     */
+    public $css_class = 'tagcloud';
+
+    /**
+     * @var    string
+     * mm,cm,in,pt,pc,px,em
+     */
+    public $size_suffix = 'px';
+
+    /**
+     * @var integer
+     */
+    public $factor;
+
+    /**
+     * @var array
+     */
+    public $epoc_level = array(
+        'earliest',
+        'earlier',
+        'later',
+        'latest'
+    );
+
+    /**
+     * @var array
+     */
+    protected $_elements = array();
+
+    /**
+     * @var integer
+     */
+    protected $_max = 0;
+
+    /**
+     * @var integer
+     */
+    protected $_min = 0;
+
+    /**
+     * @var integer
+     */
+    protected $_max_epoc;
+
+    /**
+     * @var integer
+     */
+    protected $_min_epoc;
+
+    /**
+     * @var array
+     */
+    protected $_map = array();
+
+    /**
+     * Constructor
+     *
+     * @param integer $basefontsize   Base font size of output tag (option).
+     * @param integer $fontsizerange  Font size range.
+     */
+    public function __construct($basefontsize = 24, $fontsizerange = 12)
+    {
+        $this->basefontsize = $basefontsize;
+        $this->minfontsize = max($this->basefontsize - $this->fontsizerange, 0);
+        $this->maxfontsize = $this->basefontsize + $this->fontsizerange;
+    }
+
+    /**
+     * Add a Tag Element to build Tag Cloud.
+     *
+     * @param string $tag         TODO
+     * @param string $url         TODO
+     * @param integer $count      TODO
+     * @param integer $timestamp  UNIX timestamp.
+     * @param string $onclick     Javascript onclick event handler.
+     */
+    public function addElement($name, $url ='', $count = 0, $timestamp = null,
+                               $onclick = null)
+    {
+
+        if (isset($this->_map[$name])) {
+            $i = $this->_map[$name];
+            // Increase the count
+            $this->_elements[$i]['count'] += $count;
+
+            // Keep the latest timestamp
+            if (!empty($timestamp) &&
+                $timestamp > $this->_elements[$i]['timestamp']) {
+                $this->_elements[$i]['timestamp'] = $timestamp;
+            }
+            // For onclick and url we will simply overwrite the existing values
+            // instead of checking if they are empty, then overwriting.
+            $this->_elements[$i]['onclick'] = $onclick;
+            $this->elements[$i]['url'] = $url;
+        } else {
+            $i = count($this->_elements);
+            $this->_elements[$i]['name'] = $name;
+            $this->_elements[$i]['url'] = $url;
+            $this->_elements[$i]['count'] = $count;
+            $this->_elements[$i]['timestamp'] = $timestamp == null ? time() : $timestamp;
+            $this->_elements[$i]['onclick'] = $onclick;
+            $this->_map[$name] = $i;
+        }
+    }
+
+    /**
+     * Add a Tag Element to build Tag Cloud.
+     *
+     * @param array $tags  Associative array to $this->_elements.
+     */
+    public function addElements($tags)
+    {
+        $this->_elements = array_merge($this->_elements, $tags);
+    }
+
+    /**
+     * Clear Tag Elements.
+     */
+    public function clearElements()
+    {
+        $this->_elements = array();
+    }
+
+    /**
+     * Build HTML part.
+     *
+     * @param array $param  'limit' => int limit of generation tag num.
+     *
+     * @return string   HTML
+     */
+    public function buildHTML($param = array())
+    {
+        return $this->_wrapDiv($this->_buidHTMLTags($param));
+    }
+
+    /**
+     * Calc Tag level and create whole HTML of each Tags.
+     *
+     * @param array $param  Limit of Tag Number.
+     *
+     * @return string  HTML
+     */
+    protected function _buidHTMLTags($param)
+    {
+        $this->total = count($this->_elements);
+        // no tags elements
+        if ($this->total == 0) {
+            return '';
+        } elseif ($this->total == 1) {
+            $tag = $this->_elements[0];
+            return $this->_createHTMLTag($tag, 'latest', $this->basefontsize);
+        }
+
+        $limit = array_key_exists('limit', $param) ? $param['limit'] : 0;
+        $this->_sortTags($limit);
+        $this->_calcMumCount();
+        $this->_calcMumEpoc();
+
+        $range = $this->maxfontsize - $this->minfontsize;
+        $this->factor = ($this->_max == $this->_min)
+            ? 1
+            : $range / (sqrt($this->_max) - sqrt($this->_min));
+        $this->epoc_factor = ($this->_max_epoc == $this->_min_epoc)
+            ? 1
+            : count($this->epoc_level) / (sqrt($this->_max_epoc) - sqrt($this->_min_epoc));
+        $rtn = array();
+        foreach ($this->_elements as $tag){
+            $count_lv = $this->_getCountLevel($tag['count']);
+            if (!isset($tag['timestamp']) || empty($tag['timestamp'])) {
+                $epoc_lv = count($this->epoc_level) - 1;
+            } else {
+                $epoc_lv = $this->_getEpocLevel($tag['timestamp']);
+            }
+            $color_type = $this->epoc_level[$epoc_lv];
+            $font_size  = $this->minfontsize + $count_lv;
+            $rtn[] = $this->_createHTMLTag($tag, $color_type, $font_size);
+        }
+        return implode('', $rtn);
+    }
+
+    /**
+     * Create a Element of HTML part.
+     *
+     * @param array $tag         TODO
+     * @param string $type       CSS class of time line param.
+     * @param integer $fontsize  TODO
+     *
+     * @return  string a Element of Tag HTML
+     */
+    protected function _createHTMLTag($tag, $type, $fontsize)
+    {
+        return sprintf('<a style="font-size:%d%s" class="%s" href="%s"%s>%s</a>' . "\n",
+                       $fontsize,
+                       $this->size_suffix,
+                       $type,
+                       $tag['url'],
+                       (empty($tag['onclick']) ? '' : ' onclick="' . $tag['onclick'] . '"'),
+                       htmlspecialchars($tag['name']));
+    }
+
+    /**
+     * Sort tags by name.
+     *
+     * @param integer $limit  Limit element number of create TagCloud.
+     */
+    protected function _sortTags($limit = 0)
+    {
+        usort($this->_elements, array($this, 'cmpElementsName'));
+        if ($limit != 0){
+            $this->_elements = array_splice($this->_elements, 0, $limit);
+        }
+    }
+
+    /**
+     * Using for usort().
+     *
+     * @return integer  TODO
+     */
+    public function cmpElementsName($a, $b)
+    {
+        return ($a['name'] == $b['name'])
+            ? 0
+            : (($a['name'] < $b['name']) ? -1 : 1);
+    }
+
+    /**
+     * Calc max and min tag count of use.
+     */
+    protected function _calcMumCount()
+    {
+        foreach($this->_elements as $item){
+            $array[] = $item['count'];
+        }
+        $this->_min = min($array);
+        $this->_max = max($array);
+    }
+
+    /**
+     * Calc max and min timestamp.
+     */
+    protected function _calcMumEpoc()
+    {
+        foreach($this->_elements as $item){
+            $array[] = $item['timestamp'];
+        }
+        $this->_min_epoc = min($array);
+        $this->_max_epoc = max($array);
+    }
+
+    /**
+     * Calc Tag Level of size.
+     *
+     * @param integer $count  TODO
+     *
+     * @return integer  Level.
+     */
+    protected function _getCountLevel($count = 0)
+    {
+        return (int)((sqrt($count) - sqrt($this->_min)) * $this->factor);
+    }
+
+    /**
+     * Calc timeline level of Tag.
+     *
+     * @param integer $timestamp  TODO
+     *
+     * @return integer  Level of timeline.
+     */
+    protected function _getEpocLevel($timestamp = 0)
+    {
+        return (int)((sqrt($timestamp) - sqrt($this->_min_epoc)) * $this->epoc_factor);
+    }
+
+    /**
+     * Wrap div tag.
+     *
+     * @param string $html  TODO
+     *
+     * @return string  TODO
+     */
+    protected function _wrapDiv($html)
+    {
+        return ($html == '')
+            ? ''
+            : sprintf("<div class=\"%s\">\n%s</div>\n", $this->css_class, $html);
+    }
+
+}
diff --git a/framework/Core/lib/Horde/Core/Ui/VarRenderer.php b/framework/Core/lib/Horde/Core/Ui/VarRenderer.php
new file mode 100644 (file)
index 0000000..e96840b
--- /dev/null
@@ -0,0 +1,105 @@
+<?php
+/**
+ * The Horde_Core_Ui_VarRenderer:: class provides base functionality for
+ * other Horde UI elements.
+ *
+ * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Jason M. Felice <jason.m.felice@gmail.com>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Core
+ */
+class Horde_Core_Ui_VarRenderer
+{
+    /**
+     * Parameters which change this renderer's behavior.
+     *
+     * @var array
+     */
+    protected $_params;
+
+    /**
+     * Charset to use for output.
+     *
+     * @var string
+     */
+    protected $_charset;
+
+    /**
+     * Constructs a new renderer.
+     *
+     * @param array $params  The name of the variable which will track this UI
+     *                       widget's state.
+     */
+    public function __construct($params = array())
+    {
+        $this->_params = $params;
+        $this->_charset = $GLOBALS['registry']->getCharset();
+    }
+
+    /**
+     * Constructs a new instance.
+     *
+     * @param mixed $driver  This is the renderer subclass we will instantiate.
+     *                       If an array is passed, the first element is the
+     *                       library path and the second element is the driver
+     *                       name.
+     * @param array $params  Parameters specific to the subclass.
+     *
+     * @return Horde_Core_Ui_VarRenderer  A subclass instance.
+     * @throws Horde_Exception
+     */
+    static public function factory($driver, $params = array())
+    {
+        if (is_array($driver)) {
+            $app = $driver[0];
+            $driver = $driver[1];
+        }
+
+        $driver = ucfirst(basename($driver));
+        if (!empty($app)) {
+            include $GLOBALS['registry']->get('fileroot', $app) . '/lib/Ui/VarRenderer/' . $driver . '.php';
+        }
+
+        $class = __CLASS__ . '_' . $driver;
+        if (!class_exists($class)) {
+            throw new Horde_Exception('Class definition of ' . $class . ' not found.');
+        }
+
+        return new $class($params);
+    }
+
+    /**
+     * Renders a variable.
+     *
+     * @param Horde_Form $form           A Horde_Form instance,
+     *                                   or null if none is available.
+     * @param Horde_Form_Variable $va r  A Horde_Form_Variable.
+     * @param Variables $vars            A Horde_Variables instance.
+     * @param boolean $isInput           Whether this is an input field.
+     */
+    public function render($form, $var, $vars, $isInput = false)
+    {
+        $state = $isInput ? 'Input' : 'Display';
+        $method = "_renderVar${state}_" . $var->type->getTypeName();
+        if (!method_exists($this, $method)) {
+            $method = "_renderVar${state}Default";
+        }
+
+        return $this->$method($form, $var, $vars);
+    }
+
+    /**
+     * Finishes rendering after all fields are output.
+     *
+     * @return string  TODO
+     */
+    public function renderEnd()
+    {
+        return '';
+    }
+}
diff --git a/framework/Core/lib/Horde/Core/Ui/VarRenderer/Html.php b/framework/Core/lib/Horde/Core/Ui/VarRenderer/Html.php
new file mode 100644 (file)
index 0000000..4552635
--- /dev/null
@@ -0,0 +1,1673 @@
+<?php
+/**
+ * The Horde_Core_Ui_VarRenderer_html:: class renders variables to HTML.
+ *
+ * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Jason M. Felice <jason.m.felice@gmail.com>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Core
+ */
+class Horde_Core_Ui_VarRenderer_Html extends Horde_Core_Ui_VarRenderer
+{
+    protected $_onLoadJS = array();
+
+    protected function _renderVarInputDefault($form, &$var, &$vars)
+    {
+        return '<strong>Warning:</strong> Unknown variable type ' .
+            @htmlspecialchars($var->getTypeName(), ENT_QUOTES, $this->_charset);
+    }
+
+    protected function _renderVarInput_number($form, &$var, &$vars)
+    {
+        $value = $var->getValue($vars);
+        if ($var->type->getProperty('fraction')) {
+            $value = sprintf('%01.' . $var->type->getProperty('fraction') . 'f', $value);
+        }
+        $linfo = Horde_Nls::getLocaleInfo();
+        /* Only if there is a mon_decimal_point do the
+         * substitution. */
+        if (!empty($linfo['mon_decimal_point'])) {
+            $value = str_replace('.', $linfo['mon_decimal_point'], $value);
+        }
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<input type="number" size="5" name="%s" id="%s" value="%s"%s />',
+                       $varname,
+                       $varname,
+                       $value,
+                       $this->_getActionScripts($form, $var)
+               );
+    }
+
+    protected function _renderVarInput_int($form, &$var, &$vars)
+    {
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<input type="number" size="5" name="%s" id="%s" value="%s"%s />',
+                       $varname,
+                       $varname,
+                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset),
+                       $this->_getActionScripts($form, $var)
+               );
+    }
+
+    protected function _renderVarInput_octal($form, &$var, &$vars)
+    {
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<input type="text" size="5" name="%s" id="%s" value="%s"%s />',
+                       $varname,
+                       $varname,
+                       sprintf('0%o', octdec($var->getValue($vars))),
+                       $this->_getActionScripts($form, $var)
+               );
+    }
+
+    protected function _renderVarInput_intlist($form, &$var, &$vars)
+    {
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<input type="text" name="%s" id="%s" value="%s"%s />',
+                       $varname,
+                       $varname,
+                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset),
+                       $this->_getActionScripts($form, $var)
+               );
+    }
+
+    protected function _renderVarInput_text($form, &$var, &$vars)
+    {
+        $maxlength = $var->type->getMaxLength();
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<input type="text" name="%s" id="%s" size="%s" value="%s" %s%s%s />',
+                       $varname,
+                       $varname,
+                       $var->type->getSize(),
+                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset),
+                       $var->isDisabled() ? ' disabled="disabled" ' : '',
+                       empty($maxlength) ? '' : ' maxlength="' . $maxlength . '"',
+                       $this->_getActionScripts($form, $var)
+               );
+    }
+
+    protected function _renderVarInput_stringlist($form, &$var, &$vars)
+    {
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<input type="text" size="60" name="%s" id="%s" value="%s"%s />',
+                       $varname,
+                       $varname,
+                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset),
+                       $this->_getActionScripts($form, $var)
+               );
+    }
+
+    protected function _renderVarInput_stringarray($form, &$var, &$vars)
+    {
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<input type="text" size="60" name="%s" id="%s" value="%s"%s />',
+                       $varname,
+                       $varname,
+                       @htmlspecialchars(implode(', ', $var->getValue($vars)), ENT_QUOTES, $this->_charset),
+                       $this->_getActionScripts($form, $var)
+               );
+    }
+
+    protected function _renderVarInput_phone($form, &$var, &$vars)
+    {
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<input type="text" name="%s" id="%s" size="15" value="%s" %s%s />',
+                       $varname,
+                       $varname,
+                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset),
+                       $var->isDisabled() ? ' disabled="disabled" ' : '',
+                       $this->_getActionScripts($form, $var)
+               );
+    }
+
+    protected function _renderVarInput_cellphone($form, &$var, &$vars)
+    {
+        return $this->_renderVarInput_phone($form, $var, $vars);
+    }
+
+    protected function _renderVarInput_ipaddress($form, &$var, &$vars)
+    {
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<input type="text" name="%s" id="%s" size="16" value="%s" %s%s />',
+                       $varname,
+                       $varname,
+                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset),
+                       $var->isDisabled() ? ' disabled="disabled" ' : '',
+                       $this->_getActionScripts($form, $var)
+               );
+    }
+
+    protected function _renderVarInput_ip6address($form, &$var, &$vars)
+    {
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<input type="text" name="%s" id="%s" size="40" value="%s" %s%s />',
+                       $varname,
+                       $varname,
+                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset),
+                       $var->isDisabled() ? ' disabled="disabled" ' : '',
+                       $this->_getActionScripts($form, $var)
+               );
+    }
+
+    protected function _renderVarInput_file($form, &$var, &$vars)
+    {
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<input type="file" size="30" name="%s" id="%s"%s />',
+                       $varname,
+                       $varname,
+                       $this->_getActionScripts($form, $var));
+    }
+
+    /**
+     * @todo Show image dimensions in the width/height boxes.
+     */
+    protected function _renderVarInput_image($form, &$var, &$vars)
+    {
+        $varname = htmlspecialchars($var->getVarName());
+        $image = $var->type->getImage($vars, $var);
+        Horde::addScriptFile('image.js', 'horde');
+        $html = '';
+
+        /* Check if there is existing img information stored. */
+        if (isset($image['img'])) {
+            /* Hidden tag to store the preview image id. */
+            $html = sprintf('<input type="hidden" name="%s" id="%s" value="%s" />',
+                            $varname . '[hash]',
+                            $varname . '[hash]',
+                            $var->type->getRandomId());
+        }
+
+        /* Output MAX_FILE_SIZE parameter to limit large files. */
+        if ($var->type->getProperty('max_filesize')) {
+            $html .= sprintf('<input type="hidden" name="MAX_FILE_SIZE" value="%d" />',
+                             $var->type->getProperty('max_filesize'));
+        }
+
+        /* Output the input tag. */
+        $html .= sprintf('<input type="file" size="30" name="%s" id="%s" />',
+                         $varname . '[new]',
+                         $varname . '[new]');
+
+        /* Output the button to upload/reset the image. */
+        if ($var->type->getProperty('show_upload')) {
+            $html .= '&nbsp;';
+            $html .= sprintf('<input class="button" name="%s" id="%s" type="submit" value="%s" /> ',
+                             '_do_' . $varname,
+                             '_do_' . $varname,
+                             _("Upload"));
+        }
+
+        if (!empty($image['img'])) {
+            /* Image information stored, show preview, add buttons for image
+             * manipulation. */
+            $html .= '<br />';
+            $img = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/images/view.php');
+            if (isset($image['img']['vfs_id'])) {
+                /* Calling an image from VFS. */
+                $img = Horde_Util::addParameter($img, array('f' => $image['img']['vfs_id'],
+                                                      's' => 'vfs',
+                                                      'p' => $image['img']['vfs_path']));
+            } else {
+                /* Calling an image from a tmp directory (uploads). */
+                $img = Horde_Util::addParameter($img, 'f', $image['img']['file']);
+            }
+
+            /* Reset. */
+            $html .= Horde::link('#', _("Reset"), '', '', 'showImage(\'' . $img . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/refresh.png', _("Reset")) . '</a>';
+
+            /* Rotate 270. */
+            $html .= Horde::link('#', _("Rotate Left"), '', '', 'showImage(\'' . Horde_Util::addParameter($img, array('a' => 'rotate', 'v' => '270')) . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/rotate-270.png', _("Rotate Left")) . '</a>';
+
+            /* Rotate 180. */
+            $html .= Horde::link('#', _("Rotate 180"), '', '', 'showImage(\'' . Horde_Util::addParameter($img, array('a' => 'rotate', 'v' => '180')) . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/rotate-180.png', _("Rotate 180")) . '</a>';
+
+            /* Rotate 90. */
+            $html .= Horde::link('#', _("Rotate Right"), '', '', 'showImage(\'' . Horde_Util::addParameter($img, array('a' => 'rotate', 'v' => '90')) . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/rotate-90.png', _("Rotate Right")) . '</a>';
+
+            /* Flip image. */
+            $html .= Horde::link('#', _("Flip"), '', '', 'showImage(\'' . Horde_Util::addParameter($img, 'a', 'flip') . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/flip.png', _("Flip")) . '</a>';
+
+            /* Mirror image. */
+            $html .= Horde::link('#', _("Mirror"), '', '', 'showImage(\'' . Horde_Util::addParameter($img, 'a', 'mirror') . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/mirror.png', _("Mirror")) . '</a>';
+
+            /* Apply grayscale. */
+            $html .= Horde::link('#', _("Grayscale"), '', '', 'showImage(\'' . Horde_Util::addParameter($img, 'a', 'grayscale') . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/grayscale.png', _("Grayscale")) . '</a>';
+
+            /* Resize width. */
+            $html .= sprintf('%s<input type="text" size="4" onchange="src=getResizeSrc(\'%s\', \'%s\');showImage(src, \'_p_%s\', true);" %s />',
+                   _("w:"),
+                   Horde_Util::addParameter($img, 'a', 'resize'),
+                   $varname,
+                   $varname,
+                   $this->_genID('_w_' . $varname));
+
+            /* Resize height. */
+            $html .= sprintf('%s<input type="text" size="4" onchange="src=getResizeSrc(\'%s\', \'%s\');showImage(src, \'_p_%s\', true);" %s />',
+                   _("h:"),
+                   Horde_Util::addParameter($img, 'a', 'resize'),
+                   $varname,
+                   $varname,
+                   $this->_genID('_h_' . $varname));
+
+            /* Apply fixed ratio resize. */
+            $html .= Horde::link('#', _("Fix ratio"), '', '', 'src=getResizeSrc(\'' . Horde_Util::addParameter($img, 'a', 'resize') . '\', \'' . $varname . '\', \'1\');showImage(src, \'_p_' . $varname . '\', true);') . Horde::img('ratio.png', _("Fix ratio"), '', $img_dir) . '</a>';
+
+            /* Keep also original if it has been requested. */
+            if ($var->type->getProperty('show_keeporig')) {
+                $html .= sprintf('<input type="checkbox" class="checkbox" name="%s" id="%s"%s />%s' . "\n",
+                                 $varname . '[keep_orig]',
+                                 $varname . '[keep_orig]',
+                                 !empty($image['keep_orig']) ? ' checked="checked"' : '',
+                                 _("Keep original?"));
+            }
+
+            /* The preview image element. */
+            $html .= '<br /><img src="' . $img . '" ' . $this->_genID('_p_' . $varname) . ">\n";
+        }
+
+        return $html;
+    }
+
+    protected function _renderVarInput_longtext($form, &$var, &$vars)
+    {
+        global $browser;
+
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        $html = sprintf('<textarea id="%s" name="%s" cols="%s" rows="%s"%s%s>%s</textarea>',
+                        $varname,
+                        $varname,
+                        (int)$var->type->getCols(),
+                        (int)$var->type->getRows(),
+                        $this->_getActionScripts($form, $var),
+                        $var->isDisabled() ? ' disabled="disabled"' : '',
+                        @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset));
+
+        if ($var->type->hasHelper('rte')) {
+            $GLOBALS['injector']->getInstance('Horde_Editor')->getEditor('fckeditor', array('id' => $varname, 'relativelinks' => $var->type->hasHelper('relativelinks')));
+        }
+
+        if ($var->type->hasHelper() && $browser->hasFeature('javascript')) {
+            $html .= '<br /><table cellspacing="0"><tr><td>';
+            Horde::addScriptFile('open_html_helper.js', 'horde', array('direct' => false));
+            $imgId = $this->_genID($var->getVarName(), false) . 'ehelper';
+            if ($var->type->hasHelper('emoticons')) {
+                $html .= Horde::link('#', _("Emoticons"), '', '', 'openHtmlHelper(\'emoticons\', \'' . $var->getVarName() . '\'); return false;') . Horde::img('emoticons/smile.png', _("Emoticons"), 'id="' . $imgId . '"') . '</a>';
+            }
+            $html .= '</td></tr><tr><td><div ' . $this->_genID('htmlhelper_' . $var->getVarName()) . ' class="control"></div></td></tr></table>' . "\n";
+        }
+
+        return $html;
+    }
+
+    protected function _renderVarInput_countedtext($form, &$var, &$vars)
+    {
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<textarea name="%s" id="%s" cols="%s" rows="%s"%s%s>%s</textarea>',
+                       $varname,
+                       $varname,
+                       (int)$var->type->getCols(),
+                       (int)$var->type->getRows(),
+                       $this->_getActionScripts($form, $var),
+                       $var->isDisabled() ? ' disabled="disabled"' : '',
+                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset));
+    }
+
+    protected function _renderVarInput_address($form, &$var, &$vars)
+    {
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<textarea name="%s" id="%s" cols="%s" rows="%s"%s%s>%s</textarea>',
+                       $varname,
+                       $varname,
+                       (int)$var->type->getCols(),
+                       (int)$var->type->getRows(),
+                       $this->_getActionScripts($form, $var),
+                       $var->isDisabled() ? ' disabled="disabled"' : '',
+                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset));
+    }
+
+    protected function _renderVarInput_addresslink($form, &$var, &$vars)
+    {
+        return '';
+    }
+
+    protected function _renderVarInput_pgp($form, &$var, &$vars)
+    {
+        return $this->_renderVarInput_longtext($form, $var, $vars);
+    }
+
+    protected function _renderVarInput_smime($form, &$var, &$vars)
+    {
+        return $this->_renderVarInput_longtext($form, $var, $vars);
+    }
+
+    protected function _renderVarInput_country($form, &$var, &$vars)
+    {
+        return $this->_renderVarInput_enum($form, $var, $vars);
+    }
+
+    protected function _renderVarInput_date($form, &$var, &$vars)
+    {
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<input type="text" name="%s" id="%s" value="%s"%s />',
+                       $varname,
+                       $varname,
+                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset),
+                       $this->_getActionScripts($form, $var));
+    }
+
+    protected function _renderVarInput_time($form, &$var, &$vars)
+    {
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<input type="text" size="5" name="%s" id="%s" value="%s"%s />',
+                       $varname,
+                       $varname,
+                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset),
+                       $this->_getActionScripts($form, $var));
+    }
+
+    protected function _renderVarInput_hourminutesecond($form, &$var, &$vars)
+    {
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        $time = $var->type->getTimeParts($var->getValue($vars));
+
+        /* Output hours. */
+        $hours = array('' => _("hh"));
+        for ($i = 0; $i <= 23; $i++) {
+            $hours[$i] = $i;
+        }
+        $html = sprintf('<select name="%s[hour]" id="%s[hour]"%s>%s</select>',
+                        $varname,
+                        $varname,
+                        $this->_getActionScripts($form, $var),
+                        $this->selectOptions($hours, ($time['hour'] === '') ? '' : $time['hour']));
+
+        /* Output minutes. */
+        $minutes = array('' => _("mm"));
+        for ($i = 0; $i <= 59; $i++) {
+            $m = sprintf('%02d', $i);
+            $minutes[$m] = $m;
+        }
+        $html .= sprintf('<select name="%s[minute]" id="%s[minute]"%s>%s</select>',
+                         $varname,
+                         $varname,
+                         $this->_getActionScripts($form, $var),
+                         $this->selectOptions($minutes, ($time['minute'] === '') ? '' : sprintf('%02d', $time['minute'])));
+
+        /* Return if seconds are not required. */
+        if (!$var->type->getProperty('show_seconds')) {
+            return $html;
+        }
+
+        /* Output seconds. */
+        $seconds = array('' => _("ss"));
+        for ($i = 0; $i <= 59; $i++) {
+            $s = sprintf('%02d', $i);
+            $seconds[$s] = $s;
+        }
+        return $html . sprintf('<select name="%s[second]" id="%s[second]"%s>%s</select>',
+                               $varname,
+                               $varname,
+                               $this->_getActionScripts($form, $var),
+                               $this->selectOptions($seconds, ($time['second'] === '') ? '' : sprintf('%02d', $time['second'])));
+    }
+
+    protected function _renderVarInput_monthyear($form, &$var, &$vars)
+    {
+        $dates = array();
+        $dates['month'] = array('' => _("MM"),
+                                1 => _("January"),
+                                2 => _("February"),
+                                3 => _("March"),
+                                4 => _("April"),
+                                5 => _("May"),
+                                6 => _("June"),
+                                7 => _("July"),
+                                8 => _("August"),
+                                9 => _("September"),
+                                10 => _("October"),
+                                11 => _("November"),
+                                12 => _("December"));
+        $dates['year'] = array('' => _("YYYY"));
+        if ($var->type->getProperty('start_year') > $var->type->getProperty('end_year')) {
+            for ($i = $var->type->getProperty('start_year'); $i >= $var->type->getProperty('end_year'); $i--) {
+                $dates['year'][$i] = $i;
+            }
+        } else {
+            for ($i = $var->type->getProperty('start_year'); $i <= $var->type->getProperty('end_year'); $i++) {
+                $dates['year'][$i] = $i;
+            }
+        }
+        return sprintf('<select name="%s" id="%s"%s>%s</select>',
+                       $var->type->getMonthVar($var),
+                       $var->type->getMonthVar($var),
+                       $this->_getActionScripts($form, $var),
+                       $this->selectOptions($dates['month'], $vars->get($var->type->getMonthVar($var)))) .
+            sprintf('<select name="%s" id="%s"%s>%s</select>',
+                    $var->type->getYearVar($var),
+                    $var->type->getYearVar($var),
+                    $this->_getActionScripts($form, $var),
+                    $this->selectOptions($dates['year'], $vars->get($var->type->getYearVar($var))));
+    }
+
+    protected function _renderVarInput_monthdayyear($form, &$var, &$vars)
+    {
+        $dates = array();
+        $dates['month'] = array(''   => _("MM"),
+                                '1'  => _("January"),
+                                '2'  => _("February"),
+                                '3'  => _("March"),
+                                '4'  => _("April"),
+                                '5'  => _("May"),
+                                '6'  => _("June"),
+                                '7'  => _("July"),
+                                '8'  => _("August"),
+                                '9'  => _("September"),
+                                '10' => _("October"),
+                                '11' => _("November"),
+                                '12' => _("December"));
+        $dates['day'] = array('' => _("DD"));
+        for ($i = 1; $i <= 31; $i++) {
+            $dates['day'][$i] = $i;
+        }
+        $dates['year'] = array('' => _("YYYY"));
+        if ($var->type->getProperty('start_year') > $var->type->getProperty('end_year')) {
+            for ($i = $var->type->getProperty('start_year'); $i >= $var->type->getProperty('end_year'); $i--) {
+                $dates['year'][$i] = $i;
+            }
+        } else {
+            for ($i = $var->type->getProperty('start_year'); $i <= $var->type->getProperty('end_year'); $i++) {
+                $dates['year'][$i] = $i;
+            }
+        }
+        $date = $var->type->getDateParts($var->getValue($vars));
+
+        // TODO: use NLS to get the order right for the Rest Of The
+        // World.
+        $html = '';
+        $date_parts = array('month', 'day', 'year');
+        foreach ($date_parts as $part) {
+            $varname = @htmlspecialchars($var->getVarName() . '[' . $part . ']', ENT_QUOTES, $this->_charset);
+            $html .= sprintf('<select name="%s" id="%s"%s>%s</select>',
+                             $varname,
+                             $varname,
+                             $this->_getActionScripts($form, $var),
+                             $this->selectOptions($dates[$part], $date[$part]));
+        }
+
+        if ($var->type->getProperty('picker') &&
+            $GLOBALS['browser']->hasFeature('javascript')) {
+            Horde_Core_Ui_JsCalendar::init();
+            $imgId = $this->_genID($var->getVarName(), false) . 'goto';
+            $html .= Horde::link('#', _("Select a date"), '', '', 'Horde_Calendar.open(\'' . $imgId . '\', null)') . Horde::img('calendar.png', _("Calendar"), 'id="' . $imgId . '"') . "</a>\n";
+        }
+
+        return $html;
+    }
+
+    protected function _renderVarInput_datetime(&$form, &$var, &$vars)
+    {
+        $js = "document.observe('Horde_Calendar:select', " .
+              "function(e) {" .
+                  "var elt = e.element();" .
+                  "elt.up().previous('SELECT[name$=\"[month]\"]').setValue(e.memo.getMonth() + 1);" .
+                  "elt.up().previous('SELECT[name$=\"[day]\"]').setValue(e.memo.getDate());" .
+                  "elt.up().previous('SELECT[name$=\"[year]\"]').setValue(e.memo.getFullYear());" .
+              "});\n";
+        Horde::addInlineScript($js, 'dom');
+        return $this->_renderVarInput_monthdayyear($form, $var, $vars) .
+            $this->_renderVarInput_hourminutesecond($form, $var, $vars);
+    }
+
+    protected function _renderVarInput_sound(&$form, &$var, &$vars)
+    {
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        $value = @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset);
+        $html = '<ul class="sound-list">';
+        if (!$var->isRequired()) {
+            $html .= '<li><label><input type="radio" id="' . $varname . '" name="' . $varname . '" value=""' . (!$value ? ' checked="checked"' : '') . ' /> ' . _("No Sound") . '</label></li>';
+        }
+        foreach ($var->type->getSounds() as $sound) {
+            $sound = @htmlspecialchars($sound, ENT_QUOTES, $this->_charset);
+            $html .= '<li><label><input type="radio" id="' . $varname . '" name="' . $varname . '" value="' . $sound . '"' . ($value == $sound ? ' checked="checked"' : '') . ' />' . $sound . '</label>'
+                . ' <embed autostart="false" src="'. $GLOBALS['registry']->get('themesuri', 'horde') . '/sounds/' . $sound . '" /></li>';
+        }
+        return $html . '</ul>';
+    }
+
+    protected function _renderVarInput_colorpicker($form, &$var, &$vars)
+    {
+        global $registry, $browser;
+
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        $color = $var->getValue($vars);
+        if ($color) {
+            $style = ' style="background-color:' . $color . ';color:'
+                . (Horde_Image::brightness($color) < 128 ? '#fff' : '#000') . '"';
+        } else {
+            $style = '';
+        }
+        $html = '<table cellspacing="0"><tr><td>'
+            . '<input type="text" size="10" maxlength="7" name="'
+            . $varname . '" id="' . $varname . '"' . $style
+            . ' value="' . @htmlspecialchars($color, ENT_QUOTES, $this->_charset)
+            . '" /></td>';
+        if ($browser->hasFeature('javascript')) {
+            Horde::addScriptFile('prototype.js', 'horde');
+            Horde::addScriptFile('colorpicker.js', 'horde');
+            $html .= '<td>'
+                . Horde::link('#', _("Color Picker"), '', '',
+                              'new ColorPicker({ color: \'' . htmlspecialchars($color) . '\', offsetParent: Event.element(event), update: [[\'' . $varname . '\', \'value\'], [\'' . $varname . '\', \'background\']] }); return false;')
+                . Horde::img('colorpicker.png', _("Color Picker"), 'height="16"') . '</a></td>';
+        }
+        return $html . '</tr></table>';
+    }
+
+    protected function _renderVarInput_sorter($form, &$var, &$vars)
+    {
+        global $registry;
+
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        $instance = $var->type->getProperty('instance');
+
+        Horde::addScriptFile('sorter.js', 'horde');
+
+        return '<input type="hidden" name="' . $varname .
+            '[array]" value="" ' . $this->_genID($varname . '[array]') . '/>' .
+            '<select class="leftFloat" multiple="multiple" size="' .
+            (int)$var->type->getSize() . '" name="' . $varname .
+            '[list]" onchange="' . $instance . '.deselectHeader();" ' .
+            $this->_genID($varname . '[list]') . '>' .
+            $var->type->getOptions($var->getValue($vars)) . '</select><div class="leftFloat">' .
+            Horde::link('#', _("Move up"), '', '', $instance . '.moveColumnUp(); return false;') . Horde::img('nav/up.png', _("Move up")) . '</a><br />' .
+            Horde::link('#', _("Move up"), '', '', $instance . '.moveColumnDown(); return false;') . Horde::img('nav/down.png', _("Move down")) . '</a></div>' .
+            '<script type="text/javascript">' . "\n" .
+            sprintf('%1$s = new Horde_Form_Sorter(\'%1$s\', \'%2$s\', \'%3$s\');' . "\n",
+                    $instance, $varname, $var->type->getHeader()) .
+            sprintf("%s.setHidden();\n</script>\n", $instance);
+    }
+
+    protected function _renderVarInput_assign($form, &$var, &$vars)
+    {
+        global $registry;
+
+        Horde::addScriptFile('form_assign.js', 'horde');
+
+        $name = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        $size = $var->type->getSize();
+        $width = $var->type->getWidth();
+        $lhdr = (bool)$var->type->getHeader(0);
+        $rhdr = (bool)$var->type->getHeader(1);
+        $this->_addOnLoadJavascript('Horde_Form_Assign.setField(\'' . $form->getName() . '\', \'' . $var->getVarName() . '\');');
+
+        return '<input type="hidden" name="' . $name . '__values" />' .
+            '<table style="width:auto"><tr><td>' .
+            sprintf('<select name="%s__left" multiple="multiple" size="%d" style="width:%s"%s>',
+                    $name, $size, $width,
+                    $lhdr ? ' onchange="Horde_Form_Assign.deselectHeaders(\'' . $form->getName() . '\', \'' . $var->getVarName() . '\', 0);"' : '') .
+            $var->type->getOptions(0, $form->getName(), $var->getVarName()) .
+            '</select></td><td>' .
+            '<a href="#" onclick="Horde_Form_Assign.move(\'' . $form->getName() . '\', \'' . $var->getVarName() . '\', 0); return false;">' .
+            Horde::img('rhand.png', _("Add")) .
+            '</a><br /><a href="#" onclick="Horde_Form_Assign.move(\'' .
+            $form->getName() . '\', \'' . $var->getVarName() . '\', 1); return false;">' .
+            Horde::img('lhand.png', _("Remove")) .
+            '</a></td><td>' .
+            sprintf('<select name="%s__right" multiple="multiple" size="%d" style="width:%s"%s>',
+                    $name, $size, $width,
+                    $rhdr ? ' onchange="Horde_Form_Assign.deselectHeaders(\'' . $form->getName() . '\', \'' . $var->getVarName() . '\', 1);"' : '') .
+            $var->type->getOptions(1, $form->getName(), $var->getVarName()) .
+            '</select></td></tr></table>';
+    }
+
+    protected function _renderVarInput_invalid($form, &$var, &$vars)
+    {
+        return $this->_renderVarDisplay_invalid($form, $var, $vars);
+    }
+
+    protected function _renderVarInput_enum($form, &$var, &$vars)
+    {
+        $values = $var->getValues();
+        $prompt = $var->type->getPrompt();
+        $htmlchars = $var->getOption('htmlchars');
+        if (!empty($prompt)) {
+            $prompt = '<option value="">' . ($htmlchars ? $prompt : @htmlspecialchars($prompt, ENT_QUOTES, $this->_charset)) . '</option>';
+        }
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<select name="%s" id="%s" %s>%s%s</select>',
+                       $varname,
+                       $varname,
+                       $this->_getActionScripts($form, $var),
+                       $prompt,
+                       $this->selectOptions($values, $var->getValue($vars), $htmlchars));
+    }
+
+    protected function _renderVarInput_mlenum($form, &$var, &$vars)
+    {
+        $varname = $var->getVarName();
+        $hvarname = @htmlspecialchars($varname, ENT_QUOTES, $this->_charset);
+        $values = $var->getValues();
+        $prompts = $var->type->getPrompts();
+        $selected = $var->getValue($vars);
+        /* If passing a non-array value need to get the keys. */
+        if (!is_array($selected)) {
+            foreach ($values as $key_1 => $values_2) {
+                if (isset($values_2[$selected])) {
+                    $selected = array('1' => $key_1, '2' => $selected);
+                    break;
+                }
+            }
+        }
+
+        /* Hidden tag to store the current first level. */
+        $html = sprintf('<input type="hidden" name="%s[old]" value="%s" %s />',
+                        $hvarname,
+                        @htmlspecialchars($selected['1'], ENT_QUOTES, $this->_charset),
+                        $this->_genID($varname . '[old]'));
+
+        /* First level. */
+        $values_1 = Horde_Array::valuesToKeys(array_keys($values));
+        $html .= sprintf('<select %s name="%s[1]" onchange="%s"%s>',
+                         $this->_genID($varname . '[1]'),
+                         $hvarname,
+                         'if (this.value) { document.' . $form->getName() . '.formname.value=\'\';' . 'document.' . $form->getName() . '.submit() }',
+                         ($var->hasAction() ? ' ' . $this->_genActionScript($form, $var->_action, $varname) : ''));
+        if (!empty($prompts)) {
+            $html .= '<option value="">' . @htmlspecialchars($prompts[0], ENT_QUOTES, $this->_charset) . '</option>';
+        }
+        $html .= $this->selectOptions($values_1, $selected['1']);
+        $html .= '</select>';
+
+        /* Second level. */
+        $html .= sprintf('<select %s name="%s[2]"%s>',
+                         $this->_genID($varname . '[2]'),
+                         $hvarname,
+                         ($var->hasAction() ? ' ' . $this->_genActionScript($form, $var->_action, $varname) : ''));
+        if (!empty($prompts)) {
+            $html .= '<option value="">' . @htmlspecialchars($prompts[1], ENT_QUOTES, $this->_charset) . '</option>';
+        }
+        $values_2 = array();
+        if (!empty($selected['1'])) {
+            $values_2 = &$values[$selected['1']];
+        }
+        return $html . $this->selectOptions($values_2, $selected['2']) . '</select>';
+    }
+
+    protected function _renderVarInput_multienum($form, &$var, &$vars)
+    {
+        $values = $var->getValues();
+        $selected = $vars->getExists($var->getVarName(), $wasset);
+        if (!$wasset) {
+            $selected = $var->getDefault();
+        }
+        return sprintf('<select multiple="multiple" size="%s" name="%s[]" %s>%s</select>',
+                       (int)$var->type->size,
+                       @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset),
+                       $this->_getActionScripts($form, $var),
+                       $this->_multiSelectOptions($values, $selected)) .
+            "<br />\n" . _("To select multiple items, hold down the Control (PC) or Command (Mac) key while clicking.") . "\n";
+    }
+
+    protected function _renderVarInput_keyval_multienum($form, &$var, &$vars)
+    {
+        return $this->_renderVarInput_multienum($form, $var, $vars);
+    }
+
+    protected function _renderVarInput_radio($form, &$var, &$vars)
+    {
+        return $this->_radioButtons($var->getVarName(),
+                                    $var->getValues(),
+                                    $var->getValue($vars),
+                                    $this->_getActionScripts($form, $var));
+    }
+
+    protected function _renderVarInput_set($form, &$var, &$vars)
+    {
+        $html = $this->_checkBoxes($var->getVarName(),
+                                   $var->getValues(),
+                                   $var->getValue($vars),
+                                   $this->_getActionScripts($form, $var));
+
+        if ($var->type->getProperty('checkAll')) {
+            $form_name = $form->getName();
+            $var_name = $var->getVarName() . '[]';
+            $function_name = 'select'  . $form_name . $var->getVarName();
+            $enable = _("Select all");
+            $disable = _("Select none");
+            $invert = _("Invert selection");
+            $html .= <<<EOT
+<script type="text/javascript">
+function $function_name()
+{
+    for (var i = 0; i < document.$form_name.elements.length; i++) {
+        f = document.$form_name.elements[i];
+        if (f.name != '$var_name') {
+            continue;
+        }
+        if (arguments.length) {
+            f.checked = arguments[0];
+        } else {
+            f.checked = !f.checked;
+        }
+    }
+}
+</script>
+<a href="#" onclick="$function_name(true); return false;">$enable</a>,
+<a href="#" onclick="$function_name(false); return false;">$disable</a>,
+<a href="#" onclick="$function_name(); return false;">$invert</a>
+EOT;
+        }
+
+        return $html;
+    }
+
+    protected function _renderVarInput_link($form, &$var, &$vars)
+    {
+        return $this->_renderVarDisplay_link($form, $var, $vars);
+    }
+
+    protected function _renderVarInput_html($form, &$var, &$vars)
+    {
+        return $this->_renderVarDisplay_html($form, $var, $vars);
+    }
+
+    protected function _renderVarInput_email($form, &$var, &$vars)
+    {
+        return sprintf('<input type="email" name="%s" id="%s" value="%s"%s />',
+                       $var->getVarName(),
+                       $var->getVarName(),
+                       @htmlspecialchars($var->getValue($vars)),
+                       $this->_getActionScripts($form, $var));
+    }
+
+    protected function _renderVarInput_matrix($form, &$var, &$vars)
+    {
+        $varname   = $var->getVarName();
+        $var_array = $var->getValue($vars);
+        $cols      = $var->type->getCols();
+        $rows      = $var->type->getRows();
+        $matrix    = $var->type->getMatrix();
+        $new_input = $var->type->getNewInput();
+
+        $html = '<table cellspacing="0"><tr>';
+
+        $html .= '<td class="rightAlign" width="20%"></td>';
+        foreach ($cols as $col_title) {
+            $html .= '<td align="center" width="1%">' . htmlspecialchars($col_title) . '</td>';
+        }
+        $html .= '<td class="rightAlign" width="60%"></td></tr>';
+
+        /* Offer a new row of data to be added to the matrix? */
+        if ($new_input) {
+            $html .= '<tr><td>';
+            if (is_array($new_input)) {
+                $html .= sprintf('<select %s name="%s[n][r]"><option value="">%s</option>%s</select><br />',
+                       $this->_genID($varname . '[n][r]'),
+                       $varname,
+                       _("-- select --"),
+                       $this->selectOptions($new_input, $var_array['n']['r']));
+            } elseif ($new_input == true) {
+                $html .= sprintf('<input %s type="text" name="%s[n][r]" value="%s" />',
+                       $this->_genID($varname . '[n][r]'),
+                       $varname,
+                       $var_array['n']['r']);
+            }
+            $html .= ' </td>';
+            foreach ($cols as $col_id => $col_title) {
+                $html .= sprintf('<td align="center"><input type="checkbox" class="checkbox" name="%s[n][v][%s]" /></td>', $varname, $col_id);
+            }
+            $html .= '<td> </td></tr>';
+        }
+
+        /* Loop through the rows and create checkboxes for each column. */
+        foreach ($rows as $row_id => $row_title) {
+            $html .= sprintf('<tr><td>%s</td>', $row_title);
+            foreach ($cols as $col_id => $col_title) {
+                $html .= sprintf('<td align="center"><input type="checkbox" class="checkbox" name="%s[r][%s][%s]"%s /></td>', $varname, $row_id, $col_id, (!empty($matrix[$row_id][$col_id]) ? ' checked="checked"' : ''));
+            }
+            $html .= '<td> </td></tr>';
+        }
+
+        return $html . '</table>';
+    }
+
+    protected function _renderVarInput_password($form, &$var, &$vars)
+    {
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<input type="password" name="%s" id="%s" value="%s"%s />',
+                       $varname,
+                       $varname,
+                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset),
+                       $this->_getActionScripts($form, $var));
+    }
+
+    protected function _renderVarInput_emailconfirm($form, &$var, &$vars)
+    {
+        $email = $var->getValue($vars);
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<input type="email" name="%s[original]" id="%s[original]" value="%s"%s />',
+                       $varname,
+                       $varname,
+                       @htmlspecialchars($email['original'], ENT_QUOTES, $this->_charset),
+                       $this->_getActionScripts($form, $var)) .
+            ' ' . sprintf('<input type="email" name="%s[confirm]" id="%s[confirm]" value="%s"%s />',
+                          $varname,
+                          $varname,
+                          @htmlspecialchars($email['confirm'], ENT_QUOTES, $this->_charset),
+                          $this->_getActionScripts($form, $var));
+    }
+
+    protected function _renderVarInput_passwordconfirm($form, &$var, &$vars)
+    {
+        $password = $var->getValue($vars);
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<input type="password" name="%s[original]" id="%s[original]" value="%s"%s />',
+                       $varname,
+                       $varname,
+                       @htmlspecialchars($password['original'], ENT_QUOTES, $this->_charset),
+                       $this->_getActionScripts($form, $var)) .
+            ' ' . sprintf('<input type="password" name="%s[confirm]" id="%s[confirm]" value="%s"%s />',
+                          $varname,
+                          $varname,
+                          @htmlspecialchars($password['confirm'], ENT_QUOTES, $this->_charset),
+                          $this->_getActionScripts($form, $var));
+    }
+
+    protected function _renderVarInput_boolean($form, &$var, &$vars)
+    {
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        $html = '<input type="checkbox" class="checkbox" name="' .  $varname . '"' .
+            ' id="' . $varname . '"' . ($var->getValue($vars) ? ' checked="checked"' : '');
+        if ($var->hasAction()) {
+            $html .= $this->_genActionScript($form, $var->_action,
+                                             $var->getVarName());
+        }
+        return $html . ' />';
+    }
+
+    protected function _renderVarInput_creditcard($form, &$var, &$vars)
+    {
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        $html = '<input type="text" name="' . $varname . '" id="' . $varname . '" value="' .
+            @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset) . '"';
+        if ($var->hasAction()) {
+            $html .= $this->_genActionScript($form, $var->_action,
+                                             $var->getVarName());
+        }
+        return $html . ' />';
+    }
+
+    protected function _renderVarInput_obrowser($form, &$var, &$vars)
+    {
+        $varname = $var->getVarName();
+        $varvalue = $vars->get($varname);
+        $fieldId = $this->_genID(md5(uniqid(rand(), true)), false) . 'id';
+        $html = '
+            <script type="text/javascript">
+            var obrowserWindowName;
+            function obrowserCallback(name, oid)
+            {
+                if (name == obrowserWindowName) {
+                    document.getElementById(\'' . $fieldId . '\').value = oid;
+                    return false;
+                } else {
+                    return "Invalid window name supplied";
+                }
+            }
+            </script>
+            ';
+        $html .= sprintf('<input type="hidden" name="%s" id="%s"%s value="%s">',
+                         @htmlspecialchars($varname, ENT_QUOTES, $this->_charset),
+                         $fieldId,
+                         $this->_getActionScripts($form, $var),
+                         @htmlspecialchars($varvalue, ENT_QUOTES, $this->_charset));
+        if (!empty($varvalue)) {
+            $html .= $varvalue;
+        }
+
+        if ($GLOBALS['browser']->hasFeature('javascript')) {
+            $html .= Horde::link($GLOBALS['registry']->get('webroot', 'horde') . '/services/obrowser/', _("Select an object"), '', '_blank', 'obrowserWindow = ' . Horde::popupJs($GLOBALS['registry']->get('webroot', 'horde') . '/services/obrowser/', array('urlencode' => true)) . 'obrowserWindowName = obrowserWindow.name; return false;') . Horde::img('tree/leaf.png', _("Object")) . "</a>\n";
+        }
+
+        return $html;
+    }
+
+    protected function _renderVarInput_dblookup($form, &$var, &$vars)
+    {
+        return $this->_renderVarInput_enum($form, $var, $vars);
+    }
+
+    protected function _renderVarInput_figlet($form, &$var, &$vars)
+    {
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<input type="text" name="%s" id="%s" size="%s" value="%s" />',
+                       $varname,
+                       $varname,
+                       strlen($var->type->getText()),
+                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset)) .
+            '<br />' . _("Enter the letters below:") . '<br />' .
+            $this->_renderVarDisplay_figlet($form, $var, $vars);
+    }
+
+    protected function _renderVarInput_captcha($form, &$var, &$vars)
+    {
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        return sprintf('<input type="text" name="%s" id="%s" size="%s" value="%s" />',
+                       $varname,
+                       $varname,
+                       strlen($var->type->getText()),
+                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset)) .
+            '<br />' . _("Enter the letters below:") . '<br />' .
+            $this->_renderVarDisplay_captcha($form, $var, $vars);
+    }
+
+    protected function _renderVarDisplayDefault($form, &$var, &$vars)
+    {
+        return nl2br(@htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset));
+    }
+
+    protected function _renderVarDisplay_html($form, &$var, &$vars)
+    {
+        // Since this is an HTML type we explicitly don't escape
+        // it. User beware.
+        return $var->getValue($vars);
+    }
+
+    protected function _renderVarDisplay_email($form, &$var, &$vars)
+    {
+        $email_val = $var->getValue($vars);
+
+        if ($var->type->getProperty('link_compose')) {
+            // Multiple email addresses?
+            $addrs = $var->type->getProperty('allow_multi')
+                ? Horde_Mime_Address::explode($email_val)
+                : array($email_val);
+
+            $link = '';
+            foreach ($addrs as $addr) {
+                $addr = trim($addr);
+
+                $display_email = $addr;
+                if ($var->type->getProperty('strip_domain') && strpos($addr, '@') !== false) {
+                    $display_email = str_replace(array('@', '.'),
+                                                 array(' (at) ', ' (dot) '),
+                                                 $addr);
+                }
+
+                // Format the address according to RFC822.
+                $mailbox_host = explode('@', $addr);
+                if (!isset($mailbox_host[1])) {
+                    $mailbox_host[1] = '';
+                }
+
+                $name = $var->type->getProperty('link_name');
+
+                $address = Horde_Mime_Address::writeAddress($mailbox_host[0], $mailbox_host[1], $name);
+
+                // Get rid of the trailing @ (when no host is included in
+                // the email address).
+                $address = str_replace('@>', '>', $address);
+                try {
+                    $mail_link = $GLOBALS['registry']->call('mail/compose', array(array('to' => addslashes($address))));
+                } catch (Horde_Exception $e) {
+                    $mail_link = 'mailto:' . urlencode($address);
+                }
+
+                if (!empty($link)) {
+                    $link .= ', ';
+                }
+                $link .= Horde::link($mail_link, $addr) . @htmlspecialchars($display_email, ENT_QUOTES, $this->_charset) . '</a>';
+            }
+
+            return $link;
+        } else {
+            $email_val = trim($email_val);
+
+            if ($var->type->getProperty('strip_domain') && strpos($email_val, '@') !== false) {
+                $email_val = str_replace(array('@', '.'),
+                                         array(' (at) ', ' (dot) '),
+                                         $email_val);
+            }
+
+            return nl2br(@htmlspecialchars($email_val, ENT_QUOTES, $this->_charset));
+        }
+    }
+
+    protected function _renderVarDisplay_password($form, &$var, &$vars)
+    {
+        return '********';
+    }
+
+    protected function _renderVarDisplay_passwordconfirm($form, &$var, &$vars)
+    {
+        return '********';
+    }
+
+    protected function _renderVarDisplay_octal($form, &$var, &$vars)
+    {
+        return sprintf('0%o', octdec($var->getValue($vars)));
+    }
+
+    protected function _renderVarDisplay_boolean($form, &$var, &$vars)
+    {
+        return $var->getValue($vars) ? _("Yes") : _("No");
+    }
+
+    protected function _renderVarDisplay_enum($form, &$var, &$vars)
+    {
+        $values = $var->getValues();
+        $value = $var->getValue($vars);
+        if (count($values) == 0) {
+            return _("No values");
+        } elseif (isset($values[$value]) && $value != '') {
+            return @htmlspecialchars($values[$value], ENT_QUOTES, $this->_charset);
+        }
+    }
+
+    protected function _renderVarDisplay_radio($form, &$var, &$vars)
+    {
+        $values = $var->getValues();
+        if (count($values) == 0) {
+            return _("No values");
+        } elseif (isset($values[$var->getValue($vars)])) {
+            return @htmlspecialchars($values[$var->getValue($vars)], ENT_QUOTES, $this->_charset);
+        }
+    }
+
+    protected function _renderVarDisplay_multienum($form, &$var, &$vars)
+    {
+        $values = $var->getValues();
+        $on = $var->getValue($vars);
+        if (!count($values) || !count($on)) {
+            return _("No values");
+        } else {
+            $display = array();
+            foreach ($values as $value => $name) {
+                if (in_array($value, $on)) {
+                    $display[] = $name;
+                }
+            }
+            return @htmlspecialchars(implode(', ', $display), ENT_QUOTES, $this->_charset);
+        }
+    }
+
+    protected function _renderVarDisplay_set($form, &$var, &$vars)
+    {
+        $values = $var->getValues();
+        $on = $var->getValue($vars);
+        if (!count($values) || !count($on)) {
+            return _("No values");
+        } else {
+            $display = array();
+            foreach ($values as $value => $name) {
+                if (in_array($value, $on)) {
+                    $display[] = $name;
+                }
+            }
+            return @htmlspecialchars(implode(', ', $display), ENT_QUOTES, $this->_charset);
+        }
+    }
+
+    protected function _renderVarDisplay_image($form, &$var, &$vars)
+    {
+        $image = $var->getValue($vars);
+
+        /* Check if existing image data is being loaded. */
+        $var->type->loadImageData($image);
+
+        if (empty($image['img'])) {
+            return '';
+        }
+
+        $img = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/images/view.php');
+        if (isset($image['img']['vfs_id'])) {
+            /* Calling an image from VFS. */
+            $img = Horde_Util::addParameter($img, array('f' => $image['img']['vfs_id'],
+                                                  's' => 'vfs',
+                                                  'p' => $image['img']['vfs_path']));
+        } else {
+            /* Calling an image from a tmp directory (uploads). */
+            $img = (string)Horde_Util::addParameter($img, 'f', $image['img']['file']);
+        }
+
+        return Horde::img($img, '', '', '');
+    }
+
+    protected function _renderVarDisplay_phone($form, &$var, &$vars)
+    {
+        global $registry;
+
+        $number = $var->getValue($vars);
+        $html = @htmlspecialchars($number, ENT_QUOTES, $this->_charset);
+
+        if ($number && $registry->hasMethod('telephony/dial')) {
+            $url = $registry->call('telephony/dial', array($number));
+            $label = sprintf(_("Dial %s"), $number);
+            $html .= ' ' . Horde::link($url, $label) . Horde::img('phone.png', $label) . '</a>';
+        }
+
+        return $html;
+    }
+
+    protected function _renderVarDisplay_cellphone($form, &$var, &$vars)
+    {
+        global $registry;
+
+        $html = $this->_renderVarDisplay_phone($form, $var, $vars);
+
+        $number = $var->getValue($vars);
+        if ($number && $registry->hasMethod('sms/compose')) {
+            $url = $registry->link('sms/compose', array('to' => $number));
+            $html .= ' ' . Horde::link($url, _("Send SMS")) . Horde::img('mobile.png', _("Send SMS")) . '</a>';
+        }
+
+        return $html;
+    }
+
+    protected function _renderVarDisplay_address($form, &$var, &$vars, $text = true)
+    {
+        global $registry;
+
+        $address = $var->getValue($vars);
+        if (empty($address)) {
+            return '';
+        }
+
+        $info = $var->type->parse($address);
+
+        $google_icon = 'map.png';
+        if (!empty($info['country'])) {
+            switch ($info['country']) {
+            case 'uk':
+                /* Multimap.co.uk generated map */
+                $mapurl = 'http://www.multimap.com/map/browse.cgi?pc='
+                    . urlencode($info['zip']);
+                $desc = _("Multimap UK map");
+                $icon = 'map.png';
+                break;
+
+            case 'au':
+                /* Whereis.com.au generated map */
+                $mapurl = 'http://www.whereis.com.au/whereis/mapping/geocodeAddress.do?';
+                $desc = _("Whereis Australia map");
+                $icon = 'map.png';
+                /* See if it's the street number & name. */
+                if (isset($info['streetNumber']) &&
+                    isset($info['streetName'])) {
+                    $mapurl .= '&streetNumber='
+                        . urlencode($info['streetNumber']) . '&streetName='
+                        . urlencode($info['streetName']);
+                }
+                /* Look for "Suburb, State". */
+                if (isset($info['city'])) {
+                    $mapurl .= '&suburb=' . urlencode($info['city']);
+                }
+                /* Look for "State <4 digit postcode>". */
+                if (isset($info['state'])) {
+                    $mapurl .= '&state=' . urlencode($info['state']);
+                }
+                break;
+
+            case 'us':
+            case 'ca':
+                /* American/Canadian address style. */
+                /* Mapquest generated map */
+                $mapurl = 'http://www.mapquest.com/maps/map.adp?size=big&zoom=7';
+                $desc = _("MapQuest map");
+                $icon = 'map.png';
+                if (!empty($info['street'])) {
+                    $mapurl .= '&address=' . urlencode($info['street']);
+                }
+                if (!empty($info['city'])) {
+                    $mapurl .= '&city=' . urlencode($info['city']);
+                }
+                if (!empty($info['state'])) {
+                    $mapurl .= '&state=' . urlencode($info['state']);
+                }
+                if (!empty($info['zip'])) {
+                    if ($info['country'] == 'ca') {
+                        $mapurl .= '&country=CA';
+                    }
+                    $mapurl .= '&zipcode=' . urlencode($info['zip']);
+                }
+
+                /* Yahoo! generated map. */
+                $mapurl2 = 'http://us.rd.yahoo.com/maps/home/submit_a/*-http://maps.yahoo.com/maps?srchtype=a&getmap=Get+Map&';
+                $desc2 = _("Yahoo! map");
+                $icon2 = 'map.png';
+                if (!empty($info['street'])) {
+                    $mapurl2 .= '&addr=' . urlencode($info['street']);
+                }
+                /* Give precedence to zipcode over city/state */
+                if (empty($info['zip']) &&
+                    !empty($info['city']) && !empty($info['state'])) {
+                    $mapurl2 .= '&csz='
+                        . urlencode($info['city'] . ' ' . $info['state']);
+                }
+                if (!empty($info['zip'])) {
+                    if (preg_match('|([a-zA-Z]\d[a-zA-Z])\s?(\d[a-zA-Z]\d)|', $info['zip'], $pcParts)) {
+                        $mapurl2 .= '&country=ca';
+                        /* make sure the postal-code has a space */
+                        $info['zip'] = $pcParts[1] . ' ' . $pcParts[2];
+                    }
+                    $mapurl2 .= '&csz=' . urlencode($info['zip']);
+                }
+                break;
+
+            default:
+                if (!count($info)) {
+                    break;
+                }
+                /* European address style. */
+                $google_icon = 'map_eu.png';
+                /* Mapquest generated map. */
+                $mapurl2 = 'http://www.mapquest.com/maps/map.adp?country=' . Horde_String::upper($info['country']);
+                $desc2 = _("MapQuest map");
+                $icon2 = 'map_eu.png';
+                if (!empty($info['street'])) {
+                    $mapurl2 .= '&address=' . urlencode($info['street']);
+                }
+                if (!empty($info['zip'])) {
+                    $mapurl2 .= '&zipcode=' . urlencode($info['zip']);
+                }
+                if (!empty($info['city'])) {
+                    $mapurl2 .= '&city=' . urlencode($info['city']);
+                }
+                break;
+            }
+        }
+
+        $html = $text ? nl2br(@htmlspecialchars($address, ENT_QUOTES, $this->_charset)) : '';
+        if (!empty($mapurl)) {
+            $html .= '&nbsp;&nbsp;' . Horde::link(Horde::externalUrl($mapurl), $desc, null, '_blank') . Horde::img($icon, $desc) . '</a>';
+        }
+        if (!empty($mapurl2)) {
+            $html .= '&nbsp;' . Horde::link(Horde::externalUrl($mapurl2), $desc2, null, '_blank') . Horde::img($icon2, $desc2) . '</a>';
+        }
+
+        /* Google generated map. */
+        if ($address) {
+            $html .= '&nbsp;' . Horde::link(Horde::externalUrl('http://maps.google.com/maps?q=' . urlencode(preg_replace('/\r?\n/', ',', $address)) . '&hl=en'), _("Google Maps"), null, '_blank') . Horde::img($google_icon, _("Google Maps")) . '</a>';
+        }
+
+        return $html;
+    }
+
+    protected function _renderVarDisplay_addresslink($form, &$var, &$vars)
+    {
+        return $this->_renderVarDisplay_address($form, $var, $vars, false);
+    }
+
+    protected function _renderVarDisplay_pgp($form, &$var, &$vars)
+    {
+        $key = $var->getValue($vars);
+        if (empty($key)) {
+            return '';
+        }
+        return '<pre>' .
+            $GLOBALS['injector']->getInstance('Horde_Crypt')->getCrypr('Pgp', $var->type->getPGPParams())->pgpPrettyKey($key) .
+            '</pre>';
+    }
+
+    protected function _renderVarDisplay_smime($form, &$var, &$vars)
+    {
+        $cert = $var->getValue($vars);
+        if (empty($cert)) {
+            return '';
+        }
+        return $GLOBALS['injector']->getInstance('Horde_Crypt')->getCrypt('Smime', $var->type->getSMIMEParams())->certToHTML($cert);
+    }
+
+    protected function _renderVarDisplay_country($form, &$var, &$vars)
+    {
+        return $this->_renderVarDisplay_enum($form, $var, $vars);
+    }
+
+    protected function _renderVarDisplay_date($form, &$var, &$vars)
+    {
+        return htmlspecialchars($var->type->getFormattedTime($var->getValue($vars)));
+    }
+
+    protected function _renderVarDisplay_hourminutesecond($form, &$var, &$vars)
+    {
+        $time = $var->type->getTimeParts($var->getValue($vars));
+        if (!$var->type->getProperty('show_seconds')) {
+            return (int)$time['hour'] . ':' . sprintf('%02d', (int)$time['minute']);
+        } else {
+            return (int)$time['hour'] . ':' . sprintf('%02d', (int)$time['minute']) . ':' . sprintf('%02d', (int)$time['second']);
+        }
+    }
+
+    protected function _renderVarDisplay_monthyear($form, &$var, &$vars)
+    {
+        return (int)$vars->get($var->getVarName() . '[month]') . ', ' . (int)$vars->get($var->getVarName() . '[year]');
+    }
+
+    protected function _renderVarDisplay_monthdayyear($form, &$var, &$vars)
+    {
+        $date = $var->getValue($vars);
+        if ((is_array($date) && !empty($date['year']) &&
+             !empty($date['month']) && !empty($date['day'])) ||
+            (!is_array($date) && !empty($date) && $date != '0000-00-00')) {
+            return $var->type->formatDate($date);
+        }
+        return '';
+    }
+
+    protected function _renderVarDisplay_datetime($form, &$var, &$vars)
+    {
+        return htmlspecialchars($var->type->formatDate($var->getValue($vars))) . Horde_Form_Type_date::getAgo($var->getValue($vars));
+    }
+
+    protected function _renderVarDisplay_invalid($form, &$var, &$vars)
+    {
+        return '<span class="form-error">' . @htmlspecialchars($var->type->message, ENT_QUOTES, $this->_charset) . '</span>';
+    }
+
+    protected function _renderVarDisplay_link($form, &$var, &$vars)
+    {
+        $values = $var->type->values;
+        if (!isset($values[0])) {
+            $values = array($values);
+        }
+
+        $count = count($values);
+        $html = '';
+        for ($i = 0; $i < $count; $i++) {
+            if (empty($values[$i]['url']) || empty($values[$i]['text'])) {
+                continue;
+            }
+            if (!isset($values[$i]['target'])) {
+                $values[$i]['target'] = '';
+            }
+            if (!isset($values[$i]['onclick'])) {
+                $values[$i]['onclick'] = '';
+            }
+            if (!isset($values[$i]['title'])) {
+                $values[$i]['title'] = '';
+            }
+            if (!isset($values[$i]['accesskey'])) {
+                $values[$i]['accesskey'] = '';
+            }
+            if ($i > 0) {
+                $html .= ' | ';
+            }
+            $html .= Horde::link($values[$i]['url'], $values[$i]['text'], 'widget', $values[$i]['target'], $values[$i]['onclick'], $values[$i]['title'], $values[$i]['accesskey']) . @htmlspecialchars($values[$i]['text'], ENT_QUOTES, $this->_charset) . '</a>';
+        }
+
+        return $html;
+    }
+
+    protected function _renderVarDisplay_dblookup($form, &$var, &$vars)
+    {
+        return $this->_renderVarDisplay_enum($form, $var, $vars);
+    }
+
+    protected function _renderVarDisplay_figlet($form, &$var, &$vars)
+    {
+        static $figlet;
+
+        if (!isset($figlet)) {
+            $figlet = new Text_Figlet();
+        }
+
+        $result = $figlet->loadFont($var->type->getFont());
+        if (is_a($result, 'PEAR_Error')) {
+            return $result->getMessage();
+        }
+
+        return '<pre>' . $figlet->lineEcho($var->type->getText()) . '</pre>';
+    }
+
+    protected function _renderVarDisplay_captcha($form, &$var, &$vars)
+    {
+        static $captcha;
+
+        if (!isset($captcha)) {
+            $captcha = Text_CAPTCHA::factory('Image');
+        }
+
+        $image = $captcha->init(150, 60, $var->type->getText(),
+                                array('font_path' => dirname($var->type->getFont()) . '/',
+                                      'font_file' => basename($var->type->getFont())));
+        if (is_a($image, 'PEAR_Error')) {
+            return $image->getMessage();
+        }
+
+        $cid = md5($var->type->getText());
+        $cache = $GLOBALS['injector']->getInstance('Horde_Cache');
+
+        $cache->set($cid, serialize(array('data' => $captcha->getCAPTCHAAsJPEG(),
+                                          'ctype' => 'image/jpeg')));
+
+        $url = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/cacheview.php');
+        $url = Horde_Util::addParameter($url, 'cid', $cid, false);
+
+        return '<img src="' . $url . '" />';
+
+    }
+
+    protected function _renderVarInput_selectFiles($form, &$var, &$vars)
+    {
+        /* Needed for gollem js calls */
+        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
+        $html = sprintf('<input type="hidden" name="%s" id="%s" value="%s" />',
+                        'selectlist_selectid',
+                        'selectlist_selectid',
+                        $var->type->getProperty('selectid')) .
+            sprintf('<input type="hidden" name="%s" id="%s" />', 'actionID', 'actionID') .
+
+            /* Form field. */
+            sprintf('<input type="hidden" name="%s" id="%s" value="%s" />',
+                    $varname,
+                    $varname,
+                    $var->type->getProperty('selectid'));
+
+        /* Open window link. */
+        $param = array($var->type->getProperty('link_text'),
+                       $var->type->getProperty('link_style'),
+                       $form->getName(),
+                       $var->type->getProperty('icon'),
+                       $var->type->getProperty('selectid'));
+        $html .= $GLOBALS['registry']->call('files/selectlistLink', $param) . "<br />\n";
+
+        if ($var->type->getProperty('selectid')) {
+            $param = array($var->type->getProperty('selectid'));
+            $files = $GLOBALS['registry']->call('files/selectlistResults', $param);
+            if ($files) {
+                $html .= '<ol>';
+                foreach ($files as $id => $file) {
+                    $dir = key($file);
+                    $filename = current($file);
+                    if ($GLOBALS['registry']->hasMethod('files/getViewLink')) {
+                        $filename = basename($filename);
+                        $url = $GLOBALS['registry']->call('files/getViewLink', array($dir, $filename));
+                        $filename = Horde::link($url, _("Preview"), null, 'form_file_view') . @htmlspecialchars(Horde_Util::realPath($dir . '/' . $filename), ENT_QUOTES, $this->_charset) . '</a>';
+                    } else {
+                        if (!empty($dir) && ($dir != '.')) {
+                            $filename = $dir . '/' . $filename;
+                        }
+                        $filename = @htmlspecialchars($filename, ENT_QUOTES, $this->_charset);
+                    }
+                    $html .= '<li>' . $filename . "</li>\n";
+                }
+                $html .= '</ol>';
+            }
+        }
+
+        return $html;
+    }
+
+    protected function _renderVarInput_category($form, &$var, &$vars)
+    {
+        Horde::addScriptFile('form_helpers.js', 'horde');
+        $this->_addOnLoadJavascript('addEvent(document.getElementById(\'' . $form->getName() . '\'), \'submit\', checkCategory);');
+        return '<input type="hidden" name="new_category" />'
+            . Horde_Prefs_CategoryManager::getJavaScript($form->getName(), $var->getVarName())
+            . Horde_Prefs_CategoryManager::getSelect($var->getVarName(), $var->getValue($vars));
+    }
+
+    public function selectOptions(&$values, $selectedValue = false,
+                                  $htmlchars = false)
+    {
+        $result = '';
+        $sel = false;
+        foreach ($values as $value => $display) {
+            if (!is_null($selectedValue) && !$sel &&
+                $value == $selectedValue &&
+                strlen($value) == strlen($selectedValue)) {
+                $selected = ' selected="selected"';
+                $sel = true;
+            } else {
+                $selected = '';
+            }
+            $result .= ' <option value="';
+            $result .= $htmlchars
+                ? $value
+                : @htmlspecialchars($value, ENT_QUOTES, $this->_charset);
+            $result .= '"' . $selected . '>';
+            $result .= $htmlchars
+                ? $display
+                : @htmlspecialchars($display, ENT_QUOTES, $this->_charset);
+            $result .= "</option>\n";
+        }
+
+        return $result;
+    }
+
+    protected function _multiSelectOptions(&$values, $selectedValues)
+    {
+        if (!is_array($selectedValues)) {
+            $selectedValues = array();
+        } else {
+            $selectedValues = array_flip($selectedValues);
+        }
+
+        $result = '';
+        $sel = false;
+        foreach ($values as $value => $display) {
+            if (isset($selectedValues[$value])) {
+                $selected = ' selected="selected"';
+            } else {
+                $selected = '';
+            }
+            $result .= " <option value=\"" . @htmlspecialchars($value, ENT_QUOTES, $this->_charset) . "\"$selected>" . @htmlspecialchars($display, ENT_QUOTES, $this->_charset) . "</option>\n";
+        }
+
+        return $result;
+    }
+
+    protected function _checkBoxes($name, $values, $checkedValues, $actions = '')
+    {
+        $result = '';
+        if (!is_array($checkedValues)) {
+            $checkedValues = array();
+        }
+        $i = 0;
+        foreach ($values as $value => $display) {
+            $checked = (in_array($value, $checkedValues)) ? ' checked="checked"' : '';
+            $result .= sprintf('<input id="%s%s" type="checkbox" class="checkbox" name="%s[]" value="%s"%s%s /><label for="%s%s">&nbsp;%s</label><br />',
+                               @htmlspecialchars($name, ENT_QUOTES, $this->_charset),
+                               $i,
+                               @htmlspecialchars($name, ENT_QUOTES, $this->_charset),
+                               @htmlspecialchars($value, ENT_QUOTES, $this->_charset),
+                               $checked,
+                               $actions,
+                               @htmlspecialchars($name, ENT_QUOTES, $this->_charset),
+                               $i,
+                               @htmlspecialchars($display, ENT_QUOTES, $this->_charset));
+            $i++;
+        }
+
+        return $result;
+    }
+
+    protected function _radioButtons($name, $values, $checkedValue = null, $actions = '')
+    {
+        $result = '';
+        $i = 0;
+        foreach ($values as $value => $display) {
+            $checked = (!is_null($checkedValue) && $value == $checkedValue) ? ' checked="checked"' : '';
+            $result .= sprintf('<input id="%s%s" type="radio" class="checkbox" name="%s" value="%s"%s%s /><label for="%s%s">&nbsp;%s</label><br />',
+                               @htmlspecialchars($name, ENT_QUOTES, $this->_charset),
+                               $i,
+                               @htmlspecialchars($name, ENT_QUOTES, $this->_charset),
+                               @htmlspecialchars($value, ENT_QUOTES, $this->_charset),
+                               $checked,
+                               $actions,
+                               @htmlspecialchars($name, ENT_QUOTES, $this->_charset),
+                               $i,
+                               @htmlspecialchars($display, ENT_QUOTES, $this->_charset));
+            $i++;
+        }
+
+        return $result;
+    }
+
+    protected function _genID($name, $fulltag = true)
+    {
+        $name = @htmlspecialchars($name, ENT_QUOTES, $this->_charset);
+        return $fulltag ? 'id="' . $name . '"' : $name;
+    }
+
+    protected function _genActionScript($form, $action, $varname)
+    {
+        $html = '';
+        $triggers = $action->getTrigger();
+        if (!is_array($triggers)) {
+            $triggers = array($triggers);
+        }
+        $js = $action->getActionScript($form, $this, $varname);
+        foreach ($triggers as $trigger) {
+            if ($trigger == 'onload') {
+                $this->_addOnLoadJavascript($js);
+            } else {
+                $html .= ' ' . $trigger . '="' . $js . '"';
+            }
+        }
+        return $html;
+    }
+
+    protected function _getActionScripts($form, &$var)
+    {
+        $actions = '';
+        if ($var->hasAction()) {
+            $varname = $var->getVarName();
+            $action = &$var->_action;
+            $triggers = $action->getTrigger();
+            if (!is_array($triggers)) {
+                $triggers = array($triggers);
+            }
+            $js = $action->getActionScript($form, $this, $varname);
+            foreach ($triggers as $trigger) {
+                if ($trigger == 'onload') {
+                    $this->_addOnLoadJavascript($js);
+                } else {
+                    $actions .= ' ' . $trigger . '="' . $js . '"';
+                }
+            }
+        }
+        return $actions;
+    }
+
+    protected function _addOnLoadJavascript($script)
+    {
+        $this->_onLoadJS[] = $script;
+    }
+
+    public function renderEnd()
+    {
+        if (count($this->_onLoadJS)) {
+            return "<script type=\"text/javascript\">" .
+                "<!--\n" .  implode("\n", $this->_onLoadJS) . "\n// -->\n" .
+                "</script>";
+        } else {
+            return '';
+        }
+    }
+
+}
diff --git a/framework/Core/lib/Horde/Core/Ui/VarRenderer/TablesetHtml.php b/framework/Core/lib/Horde/Core/Ui/VarRenderer/TablesetHtml.php
new file mode 100644 (file)
index 0000000..7adc10d
--- /dev/null
@@ -0,0 +1,123 @@
+<?php
+/**
+ * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Core
+ */
+class Horde_Core_Ui_VarRenderer_TablesetHtml extends Horde_Core_Ui_VarRenderer_Html
+{
+    protected function _renderVarInput_tableset($form, &$var, &$vars)
+    {
+        $header = $var->type->getHeader();
+        $name   = $var->getVarName();
+        $values = $var->getValues();
+        $form_name = $form->getName();
+        $var_name = $var->getVarName() . '[]';
+        $checkedValues = $var->getValue($vars);
+        $actions = $this->_getActionScripts($form, $var);
+        $function_name = 'select'  . $form_name . $var->getVarName();
+        $enable = _("Select all");
+        $disable = _("Select none");
+        $invert = _("Invert selection");
+
+        Horde::addScriptFile('tables.js', 'horde');
+
+        $html = <<<EOT
+<script type="text/javascript">
+function $function_name()
+{
+    for (var i = 0; i < document.$form_name.elements.length; i++) {
+        f = document.$form_name.elements[i];
+        if (f.name != '$var_name') {
+            continue;
+        }
+        if (arguments.length) {
+            f.checked = arguments[0];
+        } else {
+            f.checked = !f.checked;
+        }
+    }
+}
+</script>
+<a href="#" onclick="$function_name(true); return false;">$enable</a>,
+<a href="#" onclick="$function_name(false); return false;">$disable</a>,
+<a href="#" onclick="$function_name(); return false;">$invert</a>
+<table style="width: 100%" class="sortable striped" id="tableset_' . $name . '"><thead><tr>
+<th>&nbsp;</th>
+EOT;
+
+        foreach ($header as $col_title) {
+            $html .= sprintf('<th class="leftAlign">%s</th>', $col_title);
+        }
+        $html .= '</tr></thead>';
+
+        if (!is_array($checkedValues)) {
+            $checkedValues = array();
+        }
+        $i = 0;
+        foreach ($values as $value => $displays) {
+            $checked = (in_array($value, $checkedValues)) ? ' checked="checked"' : '';
+            $html .= '<tr>' .
+                sprintf('<td style="text-align: center"><input id="%s[]" type="checkbox" name="%s[]" value="%s"%s%s /></td>',
+                        $name,
+                        $name,
+                        $value,
+                        $checked,
+                        $actions);
+            foreach ($displays as $col) {
+                $html .= sprintf('<td>&nbsp;%s</td>', $col);
+            }
+            $html .= '</tr>' . "\n";
+            $i++;
+        }
+
+        $html .= '</table>'
+              . '<a href="#" onclick="' . $function_name . '(true); return false;">' . $enable . '</a>, '
+              . '<a href="#" onclick="' . $function_name . '(false); return false;">' . $disable . '</a>, '
+              . '<a href="#" onclick="' . $function_name . '(); return false;">' . $invert . '</a>';
+
+        return $html;
+    }
+
+    protected function _renderVarDisplay_tableset($form, &$var, &$vars)
+    {
+        $header = $var->type->getHeader();
+        $name   = $var->getVarName();
+        $values = $var->getValues();
+        $checkedValues = $var->getValue($vars);
+        $actions = $this->_getActionScripts($form, $var);
+
+        Horde::addScriptFile('tables.js', 'horde');
+        $html = '<table style="width: 100%" class="sortable striped" id="tableset_' . $name . '"><thead><tr>' .
+            '<th>&nbsp;</th>';
+        foreach ($header as $col_title) {
+            $html .= sprintf('<th class="leftAlign">%s</th>', $col_title);
+        }
+        $html .= '</tr></thead>';
+
+        if (!is_array($checkedValues)) {
+            $checkedValues = array();
+        }
+        $i = 0;
+        foreach ($values as $value => $displays) {
+            $checked = '[ <span style="font-weight: bold; color: '
+                . (in_array($value, $checkedValues)) ? ' green">V' : 'red">X'
+                . '</span> ]';
+            $html .= '<tr>'.
+                sprintf('<td style="text-align: center">%s</td>', $checked);
+            foreach ($displays as $col) {
+                $html .= '<td>&nbsp;' . $col . '</td>';
+            }
+            $html .= '</tr>';
+            $i++;
+        }
+
+        return $html . '</table>';
+    }
+
+}
diff --git a/framework/Core/lib/Horde/Core/Ui/Widget.php b/framework/Core/lib/Horde/Core/Ui/Widget.php
new file mode 100644 (file)
index 0000000..89feffa
--- /dev/null
@@ -0,0 +1,129 @@
+<?php
+/**
+ * The Horde_Core_Ui_Widget:: class provides base functionality for other
+ * Horde UI elements.
+ *
+ * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Jason M. Felice <jason.m.felice@gmail.com>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Core
+ */
+abstract class Horde_Core_Ui_Widget
+{
+    /**
+     * Any variables that should be preserved in all of the widget's
+     * links.
+     *
+     * @var array
+     */
+    protected $_preserve = array();
+
+    /**
+     * The name of this widget.  This is used as the basename for variables
+     * we access and manipulate.
+     *
+     * @var string
+     */
+    protected $_name;
+
+    /**
+     * A reference to a Horde_Variables:: object this widget will use and
+     * manipulate.
+     *
+     * @var Horde_Variables
+     */
+    protected $_vars;
+
+    /**
+     * An array of name => value pairs which configure how this widget
+     * behaves.
+     *
+     * @var array
+     */
+    protected $_config;
+
+    /**
+     * Holds the name of a callback function to call on any URLS before they
+     * are used/returned. If an array, it is taken as an object/method name, if
+     * a string, it is taken as a php function.
+     *
+     * @var callable
+     */
+    protected $_url_callback = array('Horde', 'applicationUrl');
+
+    /**
+     * Construct a new UI Widget interface.
+     *
+     * @param string $name            The name of the variable which will
+     *                                track this UI widget's state.
+     * @param Horde_Variables &$vars  A Horde_Variables:: object.
+     * @param array $config           The widget's configuration.
+     */
+    public function __construct($name, &$vars, $config = array())
+    {
+        $this->_name = $name;
+        $this->_vars = &$vars;
+
+        if (array_key_exists('url_callback', $config)) {
+            $this->_url_callback = $config['url_callback'];
+            unset($config['url_callback']);
+        }
+        $this->_config = $config;
+    }
+
+    /**
+     * Instructs widget to preserve a variable or a set of variables.
+     *
+     * @param string|array $var  The name of the variable to preserve, or
+     *                           an array of variables to preserve.
+     * @param mixed $value       If preserving a single key, the value of the
+     *                           variable to preserve.
+     */
+    public function preserve($var, $value = null)
+    {
+        if (!is_array($var)) {
+            $var = array($var => $value);
+        }
+
+        foreach ($var as $key => $value) {
+            $this->_preserve[$key] = $value;
+        }
+    }
+
+    /**
+     * TODO
+     */
+    protected function _addPreserved($link)
+    {
+        foreach ($this->_preserve as $varName => $varValue) {
+            $link->add($varName, $varValue);
+        }
+
+        return $link;
+    }
+
+    /**
+     * Render the widget.
+     *
+     * @param mixed $data  The widget's state data.
+     */
+    abstract public function render($data = null);
+
+    /**
+     * TODO
+     */
+    protected function _link($link)
+    {
+        if (is_callable($this->_url_callback)) {
+            return call_user_func($this->_url_callback, $link);
+        }
+
+        return $link;
+    }
+
+}
index 67ad707..7838361 100644 (file)
@@ -34,7 +34,8 @@ Application Framework.</description>
   <api>beta</api>
  </stability>
  <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Absorb horde/Ajax package.
+ <notes>* Absorb horde/Ui package.
+ * Absorb horde/Ajax package.
  * Import application auth driver from horde/Auth.
  * Import signup code from horde/Auth.
  * Import Horde backend driver from horde/LoginTasks.
@@ -187,6 +188,20 @@ Application Framework.</description>
        <file name="Html.php" role="php" />
        <file name="Javascript.php" role="php" />
       </dir> <!-- /lib/Horde/Core/Tree -->
+      <dir name="Ui">
+       <dir name="VarRenderer">
+        <file name="Html.php" role="php" />
+        <file name="TablesetHtml.php" role="php" />
+       </dir> <!-- /lib/Horde/Core/Ui/VarRenderer -->
+       <file name="FlagImage.php" role="php" />
+       <file name="JsCalendar.php" role="php" />
+       <file name="Language.php" role="php" />
+       <file name="Pager.php" role="php" />
+       <file name="Tabs.php" role="php" />
+       <file name="TagCloud.php" role="php" />
+       <file name="VarRenderer.php" role="php" />
+       <file name="Widget.php" role="php" />
+      </dir> <!-- /lib/Horde/Core/Ui -->
       <file name="Autoloader.php" role="php" />
      </dir> <!-- /lib/Horde/Core -->
      <dir name="Exception">
@@ -428,6 +443,16 @@ Application Framework.</description>
    <install as="Horde/Core/Text/Filter/Highlightquotes.php" name="lib/Horde/Core/Text/Filter/Highlightquotes.php" />
    <install as="Horde/Core/Tree/Html.php" name="lib/Horde/Core/Tree/Html.php" />
    <install as="Horde/Core/Tree/Javascript.php" name="lib/Horde/Core/Tree/Javascript.php" />
+   <install as="Horde/Core/Ui/VarRenderer/Html.php" name="lib/Horde/Core/Ui/VarRenderer/Html.php" />
+   <install as="Horde/Core/Ui/VarRenderer/TablesetHtml.php" name="lib/Horde/Core/Ui/VarRenderer/TablesetHtml.php" />
+   <install as="Horde/Core/Ui/FlagImage.php" name="lib/Horde/Core/Ui/FlagImage.php" />
+   <install as="Horde/Core/Ui/JsCalendar.php" name="lib/Horde/Core/Ui/JsCalendar.php" />
+   <install as="Horde/Core/Ui/Language.php" name="lib/Horde/Core/Ui/Language.php" />
+   <install as="Horde/Core/Ui/Pager.php" name="lib/Horde/Core/Ui/Pager.php" />
+   <install as="Horde/Core/Ui/Tabs.php" name="lib/Horde/Core/Ui/Tabs.php" />
+   <install as="Horde/Core/Ui/TagCloud.php" name="lib/Horde/Core/Ui/TagCloud.php" />
+   <install as="Horde/Core/Ui/VarRenderer.php" name="lib/Horde/Core/Ui/VarRenderer.php" />
+   <install as="Horde/Core/Ui/Widget.php" name="lib/Horde/Core/Ui/Widget.php" />
    <install as="Horde/Core/Autoloader.php" name="lib/Horde/Core/Autoloader.php" />
    <install as="Horde/Exception/HookNotSet.php" name="lib/Horde/Exception/HookNotSet.php" />
    <install as="Horde/Registry/Api.php" name="lib/Horde/Registry/Api.php" />
index ca16689..8984417 100644 (file)
@@ -46,7 +46,7 @@ class Horde_Form_Renderer {
      * @param array $params  This is a hash of renderer-specific parameters.
      *                       Possible keys:<code>
      *                       'varrenderer_driver': specifies the driver
-     *                           parameter to Horde_Ui_VarRenderer::factory().
+     *                           parameter to Horde_Core_Ui_VarRenderer::factory().
      *                       'encode_title': @see $_encodeTitle</code>
      */
     function Horde_Form_Renderer($params = array())
@@ -68,7 +68,7 @@ class Horde_Form_Renderer {
         if (isset($params['varrenderer_driver'])) {
             $driver = $params['varrenderer_driver'];
         }
-        $this->_varRenderer = Horde_Ui_VarRenderer::factory($driver, $params);
+        $this->_varRenderer = Horde_Core_Ui_VarRenderer::factory($driver, $params);
     }
 
     function showHeader($bool)
diff --git a/framework/Ui/lib/Horde/Ui/FlagImage.php b/framework/Ui/lib/Horde/Ui/FlagImage.php
deleted file mode 100644 (file)
index 13b5587..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-/**
- * The Horde_Ui_FlagImage:: class provides a widget for linking to a flag
- * image.
- *
- * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author   Michael Slusarz <slusarz@horde.org>
- * @category Horde
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @package  Ui
- */
-class Horde_Ui_FlagImage
-{
-    /**
-     * Render the language selection.
-     *
-     * @param boolean $form  Return the selection box as a complete standalone
-     *                       form.
-     *
-     * @return string  The HTML selection box.
-     */
-    static public function generateFlagImageByHost($host)
-    {
-        $data = Horde_Nls::getCountryByHost($host, empty($GLOBALS['conf']['geoip']['datafile']) ? null : $GLOBALS['conf']['geoip']['datafile']);
-        if ($data === false) {
-            return '';
-        }
-
-        $img = $data['code'] . '.png';
-        return file_exists($GLOBALS['registry']->get('themesfs', 'horde') . '/graphics/flags/' . $img)
-            ? Horde::img('flags/' . $img, $data['name'], array('title' => $data['name']))
-            : '[' . $data['name'] . ']';
-    }
-
-}
diff --git a/framework/Ui/lib/Horde/Ui/JsCalendar.php b/framework/Ui/lib/Horde/Ui/JsCalendar.php
deleted file mode 100644 (file)
index ff7ff20..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-<?php
-/**
- * The Horde_Ui_JsCalendar:: class generates the necessary javascript code
- * to allow the javascript calendar widget to be displayed on the page.
- *
- * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author  Michael Slusarz <slusarz@horde.org>
- * @package Horde_Ui
- */
-class Horde_Ui_JsCalendar
-{
-    /**
-     * Output the necessary javascript code to allow display of the calendar
-     * widget.
-     *
-     * @param array $params  Configuration parameters for the widget:
-     *                       - short_weekdays: display only the first letter of
-     *                         weekdays?
-     */
-    static public function init($params = array())
-    {
-        $params += array('short_weekdays' => false);
-        $weekdays = self::weekdays();
-        if ($params['short_weekdays']) {
-            foreach ($weekdays as &$day) {
-                $day = substr($day, 0, 1);
-            }
-        }
-        Horde::addScriptFile('calendar.js', 'horde');
-        Horde::addInlineScript(array(
-            'Horde_Calendar.firstDayOfWeek = ' . (isset($GLOBALS['prefs']) ? intval($GLOBALS['prefs']->getValue('first_week_day')) : 1),
-            'Horde_Calendar.weekdays = ' . Horde_Serialize::serialize($weekdays, Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()),
-            'Horde_Calendar.months = ' . Horde_Serialize::serialize(self::months(), Horde_Serialize::JSON, $GLOBALS['registry']->getCharset()),
-        ));
-    }
-
-    /**
-     * Return the list of localized abbreviated weekdays.
-     *
-     * @return array  Abbreviated weekdays.
-     */
-    static public function weekdays()
-    {
-        return array(
-            _("Su"),
-            _("Mo"),
-            _("Tu"),
-            _("We"),
-            _("Th"),
-            _("Fr"),
-            _("Sa")
-        );
-    }
-
-    /**
-     * Return the localized list of months.
-     *
-     * @return array  Month list.
-     */
-    static public function months()
-    {
-        return array(
-            _("January"),
-            _("February"),
-            _("March"),
-            _("April"),
-            _("May"),
-            _("June"),
-            _("July"),
-            _("August"),
-            _("September"),
-            _("October"),
-            _("November"),
-            _("December")
-        );
-    }
-
-}
diff --git a/framework/Ui/lib/Horde/Ui/Language.php b/framework/Ui/lib/Horde/Ui/Language.php
deleted file mode 100644 (file)
index e75a211..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-<?php
-/**
- * The Horde_Ui_Language:: class provides a widget for changing the
- * currently selected language.
- *
- * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author  Jason M. Felice <jason.m.felice@gmail.com>
- * @package Horde_Ui
- */
-class Horde_Ui_Language {
-
-    /**
-     * Render the language selection.
-     *
-     * @param boolean $form  Return the selection box as a complete standalone
-     *                       form.
-     *
-     * @return string  The HTML selection box.
-     */
-    static public function render()
-    {
-        $html = '';
-
-        if (!$GLOBALS['prefs']->isLocked('language')) {
-            $_SESSION['horde_language'] = $GLOBALS['registry']->preferredLang();
-            $html = sprintf('<form name="language" action="%s">',
-                            Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/language.php', false, -1));
-            $html .= '<input type="hidden" name="url" value="' . @htmlspecialchars(Horde::selfUrl(false, false, true)) . '" />';
-            $html .= '<select name="new_lang" onchange="document.language.submit()">';
-            foreach ($GLOBALS['registry']->nlsconfig['languages'] as $key => $val) {
-                $sel = ($key == $_SESSION['horde_language']) ? ' selected="selected"' : '';
-                $html .= "<option value=\"$key\"$sel>$val</option>";
-            }
-            $html .= '</select></form>';
-        }
-
-        return $html;
-    }
-
-}
diff --git a/framework/Ui/lib/Horde/Ui/Pager.php b/framework/Ui/lib/Horde/Ui/Pager.php
deleted file mode 100644 (file)
index e5cebde..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-<?php
-/**
- * The Horde_Ui_Pager:: provides links to individual pages.
- *
- * Copyright 2004-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author  Ben Chavet <ben@chavet.net>
- * @author  Joel Vandal <joel@scopserv.com>
- * @author  Chuck Hagenbuch <chuck@horde.org>
- * @package Horde_Ui
- */
-class Horde_Ui_Pager extends Horde_Ui_Widget
-{
-    /**
-     * Constructor
-     *
-     * TODO
-     */
-    public function __construct($name, &$vars, $config)
-    {
-        if (!isset($config['page_limit'])) {
-            $config['page_limit'] = 10;
-        }
-
-        if (!isset($config['perpage'])) {
-            $config['perpage'] = 100;
-        }
-
-        parent::__construct($name, $vars, $config);
-    }
-
-    /**
-     * Render the pager.
-     *
-     * @return string  HTML code containing a centered table with the pager
-     *                 links.
-     */
-    public function render($data = null)
-    {
-        global $prefs, $registry, $conf;
-
-        $num = $this->_config['num'];
-        $url = $this->_config['url'];
-
-        $page_limit = $this->_config['page_limit'];
-        $perpage = $this->_config['perpage'];
-
-        $current_page = $this->_vars->get($this->_name);
-
-        // Figure out how many pages there will be.
-        $pages = ($num / $perpage);
-        if (is_integer($pages)) {
-            $pages--;
-        }
-        $pages = (int)$pages;
-
-        // Return nothing if there is only one page.
-        if ($pages == 0 || $num == 0) {
-            return '';
-        }
-
-        $html = '<div class="pager">';
-
-        if ($current_page > 0) {
-            // Create the '<< Prev' link if we are not on the first page.
-            $link = Horde_Util::addParameter($url, $this->_name, $current_page - 1);
-            $link = $this->_addPreserved($link);
-            $link = $this->_link($link);
-            if (isset($this->_config['previousHTML'])) {
-                $html .= Horde::link($link, '', 'prev') . $this->_config['previousHTML'] . '</a>';
-            } else {
-                $html .= Horde::link($link, '', 'prev') . htmlspecialchars(_("<Previous")) . '</a>';
-            }
-        }
-
-        // Figure out the top & bottom display limits.
-        $bottom = max(0, $current_page - ($page_limit / 2) + 1);
-        $top = $bottom + $page_limit - 1;
-        if ($top - 1 > $pages) {
-            $bottom -= ($top - 1) - $pages;
-            $top = $pages + 1;
-        }
-
-        // Create bottom '[x-y]' link if necessary.
-        $link = $this->_addPreserved(Horde_Util::addParameter($url, $this->_name, $bottom - 1));
-        $link = $this->_link($link);
-
-        if ($bottom > 0) {
-            $html .= ' ' . Horde::link($link, '', 'prevRange') . '[' . ($bottom == 1 ? $bottom : '1-' . $bottom) . ']</a>';
-        }
-
-        // Create links to individual pages between limits.
-        for ($i = $bottom; $i <= $top && $i <= $pages; ++$i) {
-            if ($i == $current_page) {
-                $html .= ' <strong>(' . ($i + 1) . ')</strong>';
-            } elseif ($i >= 0 && $i <= $pages) {
-                $link = $this->_addPreserved(Horde_Util::addParameter($url, $this->_name, $i));
-                $link = $this->_link($link);
-                $html .= ' ' . Horde::link($link) . ($i + 1) . '</a>';
-            }
-        }
-
-        // Create top '[x-y]' link if necessary.
-        if ($top < $pages) {
-            $link = $this->_addPreserved(Horde_Util::addParameter($url, $this->_name, $top + 1));
-            $link = $this->_link($link);
-
-            $html .= ' ' . Horde::link($link, '', 'nextRange') . '[' .
-                ($top + 2 == $pages + 1 ? $pages + 1 : ($top + 2) . '-' . ($pages + 1)) . ']</a>';
-        }
-
-        // Create the 'Next>>' link if we are not on the last page.
-        if ($current_page < $pages) {
-            $link = $this->_addPreserved(Horde_Util::addParameter($url, $this->_name, $current_page + 1));
-            $link = $this->_link($link);
-            if (isset($this->_config['nextHTML'])) {
-                $html .= Horde::link($link, '', 'next') . $this->_config['nextHTML'] . '</a>';
-            } else {
-                $html .= ' ' . Horde::link($link, '', 'next') . htmlspecialchars(_("Next>")) . '</a>';
-            }
-        }
-
-        return $html . '</div>';
-    }
-
-}
diff --git a/framework/Ui/lib/Horde/Ui/Tabs.php b/framework/Ui/lib/Horde/Ui/Tabs.php
deleted file mode 100644 (file)
index 18977bc..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-<?php
-/**
- * The Horde_Ui_Tabs:: class manages and renders a tab-like interface.
- *
- * Copyright 2001-2003 Robert E. Coyle <robertecoyle@hotmail.com>
- * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author  Jason M. Felice <jason.m.felice@gmail.com>
- * @package Horde_Ui
- */
-class Horde_Ui_Tabs extends Horde_Ui_Widget
-{
-    /**
-     * The array of tabs.
-     *
-     * @var array
-     */
-    protected $_tabs = array();
-
-    /**
-     * Adds a tab to the interface.
-     *
-     * @param string $title  The text which appears on the tab.
-     * @param string $link   The target page.
-     * @param mixed $params  Either a string value to set the tab variable to,
-     *                       or a hash of parameters. If an array, the tab
-     *                       variable can be set by the 'tabname' key.
-     */
-    public function addTab($title, $link, $params = array())
-    {
-        if (!is_array($params)) {
-            $params = array('tabname' => $params);
-        }
-
-        $this->_tabs[] = array_merge(array('title' => $title,
-                                           'link' => $link,
-                                           'tabname' => null),
-                                     $params);
-    }
-
-    /**
-     * Returns the title of the tab with the specified name.
-     *
-     * @param string $tabname  The name of the tab.
-     *
-     * @return string  The tab's title.
-     */
-    public function getTitleFromAction($tabname)
-    {
-        foreach ($this->_tabs as $tab) {
-            if ($tab['tabname'] == $tabname) {
-                return $tab['title'];
-            }
-        }
-
-        return null;
-    }
-
-    /**
-     * Renders the tabs.
-     *
-     * @param string $active_tab  If specified, the name of the active tab. If
-     *                            not, the active tab is determined
-     *                            automatically.
-     */
-    public function render($active_tab = null)
-    {
-        $html = "<div class=\"tabset\"><ul>\n";
-
-        $first = true;
-        $active = $_SERVER['PHP_SELF'] . $this->_vars->get($this->_name);
-
-        foreach ($this->_tabs as $tab) {
-            $link = $this->_addPreserved($tab['link']);
-            if (!is_null($this->_name) && !is_null($tab['tabname'])) {
-                $link->add($this->_name, $tab['tabname']);
-            }
-
-            $class = '';
-            if ((!is_null($active_tab) && $active_tab == $tab['tabname']) ||
-                ($active == $tab['link'] . $tab['tabname'])) {
-                $class = ' class="activeTab"';
-            }
-
-            $id = '';
-            if (!empty($tab['id'])) {
-                $id = ' id="' . htmlspecialchars($tab['id']) . '"';
-            }
-
-            if (!isset($tab['target'])) {
-                $tab['target'] = '';
-            }
-
-            if (!isset($tab['onclick'])) {
-                $tab['onclick'] = '';
-            }
-
-            $accesskey = Horde::getAccessKey($tab['title']);
-
-            $html .= '<li' . $class . $id . '>'
-                . $link->link(array('target' => $tab['target'], 'onclick' => $tab['onclick'], 'accesskey' => $accesskey))
-                . Horde::highlightAccessKey(str_replace(' ', '&nbsp;', $tab['title']), $accesskey)
-                . "</a> </li>\n";
-        }
-
-        return $html . "</ul></div><br class=\"clear\" />\n";
-    }
-
-}
diff --git a/framework/Ui/lib/Horde/Ui/TagCloud.php b/framework/Ui/lib/Horde/Ui/TagCloud.php
deleted file mode 100644 (file)
index ea8ca58..0000000
+++ /dev/null
@@ -1,315 +0,0 @@
-<?php
-/**
- * Horde_Ui_TagCloud:: for creating and displaying tag clouds.
- *
- * Based on a striped down version of Pear's HTML_TagCloud
- *
- * Copyright 2009-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @package Horde_Ui
- */
-class Horde_Ui_TagCloud
-{
-    /**
-     * @var integer
-     */
-    public $basefontsize = 24;
-
-    /**
-     * @var integer
-     */
-    public $fontsizerange = 12;
-
-    /**
-     * @var string
-     */
-    public $css_class = 'tagcloud';
-
-    /**
-     * @var    string
-     * mm,cm,in,pt,pc,px,em
-     */
-    public $size_suffix = 'px';
-
-    /**
-     * @var integer
-     */
-    public $factor;
-
-    /**
-     * @var array
-     */
-    public $epoc_level = array(
-        'earliest',
-        'earlier',
-        'later',
-        'latest'
-    );
-
-    /**
-     * @var array
-     */
-    protected $_elements = array();
-
-    /**
-     * @var integer
-     */
-    protected $_max = 0;
-
-    /**
-     * @var integer
-     */
-    protected $_min = 0;
-
-    /**
-     * @var integer
-     */
-    protected $_max_epoc;
-
-    /**
-     * @var integer
-     */
-    protected $_min_epoc;
-
-    /**
-     * @var array
-     */
-    protected $_map = array();
-
-    /**
-     * Constructor
-     *
-     * @param integer $basefontsize   Base font size of output tag (option).
-     * @param integer $fontsizerange  Font size range.
-     */
-    public function __construct($basefontsize = 24, $fontsizerange = 12)
-    {
-        $this->basefontsize = $basefontsize;
-        $this->minfontsize = max($this->basefontsize - $this->fontsizerange, 0);
-        $this->maxfontsize = $this->basefontsize + $this->fontsizerange;
-    }
-
-    /**
-     * Add a Tag Element to build Tag Cloud.
-     *
-     * @param string $tag         TODO
-     * @param string $url         TODO
-     * @param integer $count      TODO
-     * @param integer $timestamp  UNIX timestamp.
-     * @param string $onclick     Javascript onclick event handler.
-     */
-    public function addElement($name, $url ='', $count = 0, $timestamp = null,
-                               $onclick = null)
-    {
-
-        if (isset($this->_map[$name])) {
-            $i = $this->_map[$name];
-            // Increase the count
-            $this->_elements[$i]['count'] += $count;
-
-            // Keep the latest timestamp
-            if (!empty($timestamp) &&
-                $timestamp > $this->_elements[$i]['timestamp']) {
-                $this->_elements[$i]['timestamp'] = $timestamp;
-            }
-            // For onclick and url we will simply overwrite the existing values
-            // instead of checking if they are empty, then overwriting.
-            $this->_elements[$i]['onclick'] = $onclick;
-            $this->elements[$i]['url'] = $url;
-        } else {
-            $i = count($this->_elements);
-            $this->_elements[$i]['name'] = $name;
-            $this->_elements[$i]['url'] = $url;
-            $this->_elements[$i]['count'] = $count;
-            $this->_elements[$i]['timestamp'] = $timestamp == null ? time() : $timestamp;
-            $this->_elements[$i]['onclick'] = $onclick;
-            $this->_map[$name] = $i;
-        }
-    }
-
-    /**
-     * Add a Tag Element to build Tag Cloud.
-     *
-     * @param array $tags  Associative array to $this->_elements.
-     */
-    public function addElements($tags)
-    {
-        $this->_elements = array_merge($this->_elements, $tags);
-    }
-
-    /**
-     * Clear Tag Elements.
-     */
-    public function clearElements()
-    {
-        $this->_elements = array();
-    }
-
-    /**
-     * Build HTML part.
-     *
-     * @param array $param  'limit' => int limit of generation tag num.
-     *
-     * @return string   HTML
-     */
-    public function buildHTML($param = array())
-    {
-        return $this->_wrapDiv($this->_buidHTMLTags($param));
-    }
-
-    /**
-     * Calc Tag level and create whole HTML of each Tags.
-     *
-     * @param array $param  Limit of Tag Number.
-     *
-     * @return string  HTML
-     */
-    protected function _buidHTMLTags($param)
-    {
-        $this->total = count($this->_elements);
-        // no tags elements
-        if ($this->total == 0) {
-            return '';
-        } elseif ($this->total == 1) {
-            $tag = $this->_elements[0];
-            return $this->_createHTMLTag($tag, 'latest', $this->basefontsize);
-        }
-
-        $limit = array_key_exists('limit', $param) ? $param['limit'] : 0;
-        $this->_sortTags($limit);
-        $this->_calcMumCount();
-        $this->_calcMumEpoc();
-
-        $range = $this->maxfontsize - $this->minfontsize;
-        $this->factor = ($this->_max == $this->_min)
-            ? 1
-            : $range / (sqrt($this->_max) - sqrt($this->_min));
-        $this->epoc_factor = ($this->_max_epoc == $this->_min_epoc)
-            ? 1
-            : count($this->epoc_level) / (sqrt($this->_max_epoc) - sqrt($this->_min_epoc));
-        $rtn = array();
-        foreach ($this->_elements as $tag){
-            $count_lv = $this->_getCountLevel($tag['count']);
-            if (!isset($tag['timestamp']) || empty($tag['timestamp'])) {
-                $epoc_lv = count($this->epoc_level) - 1;
-            } else {
-                $epoc_lv = $this->_getEpocLevel($tag['timestamp']);
-            }
-            $color_type = $this->epoc_level[$epoc_lv];
-            $font_size  = $this->minfontsize + $count_lv;
-            $rtn[] = $this->_createHTMLTag($tag, $color_type, $font_size);
-        }
-        return implode('', $rtn);
-    }
-
-    /**
-     * Create a Element of HTML part.
-     *
-     * @param array $tag         TODO
-     * @param string $type       CSS class of time line param.
-     * @param integer $fontsize  TODO
-     *
-     * @return  string a Element of Tag HTML
-     */
-    protected function _createHTMLTag($tag, $type, $fontsize)
-    {
-        return sprintf('<a style="font-size:%d%s" class="%s" href="%s"%s>%s</a>' . "\n",
-                       $fontsize,
-                       $this->size_suffix,
-                       $type,
-                       $tag['url'],
-                       (empty($tag['onclick']) ? '' : ' onclick="' . $tag['onclick'] . '"'),
-                       htmlspecialchars($tag['name']));
-    }
-
-    /**
-     * Sort tags by name.
-     *
-     * @param integer $limit  Limit element number of create TagCloud.
-     */
-    protected function _sortTags($limit = 0)
-    {
-        usort($this->_elements, array($this, 'cmpElementsName'));
-        if ($limit != 0){
-            $this->_elements = array_splice($this->_elements, 0, $limit);
-        }
-    }
-
-    /**
-     * Using for usort().
-     *
-     * @return integer  TODO
-     */
-    public function cmpElementsName($a, $b)
-    {
-        return ($a['name'] == $b['name'])
-            ? 0
-            : (($a['name'] < $b['name']) ? -1 : 1);
-    }
-
-    /**
-     * Calc max and min tag count of use.
-     */
-    protected function _calcMumCount()
-    {
-        foreach($this->_elements as $item){
-            $array[] = $item['count'];
-        }
-        $this->_min = min($array);
-        $this->_max = max($array);
-    }
-
-    /**
-     * Calc max and min timestamp.
-     */
-    protected function _calcMumEpoc()
-    {
-        foreach($this->_elements as $item){
-            $array[] = $item['timestamp'];
-        }
-        $this->_min_epoc = min($array);
-        $this->_max_epoc = max($array);
-    }
-
-    /**
-     * Calc Tag Level of size.
-     *
-     * @param integer $count  TODO
-     *
-     * @return integer  Level.
-     */
-    protected function _getCountLevel($count = 0)
-    {
-        return (int)((sqrt($count) - sqrt($this->_min)) * $this->factor);
-    }
-
-    /**
-     * Calc timeline level of Tag.
-     *
-     * @param integer $timestamp  TODO
-     *
-     * @return integer  Level of timeline.
-     */
-    protected function _getEpocLevel($timestamp = 0)
-    {
-        return (int)((sqrt($timestamp) - sqrt($this->_min_epoc)) * $this->epoc_factor);
-    }
-
-    /**
-     * Wrap div tag.
-     *
-     * @param string $html  TODO
-     *
-     * @return string  TODO
-     */
-    protected function _wrapDiv($html)
-    {
-        return ($html == '')
-            ? ''
-            : sprintf("<div class=\"%s\">\n%s</div>\n", $this->css_class, $html);
-    }
-
-}
diff --git a/framework/Ui/lib/Horde/Ui/VarRenderer.php b/framework/Ui/lib/Horde/Ui/VarRenderer.php
deleted file mode 100644 (file)
index d0ce59a..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-<?php
-/**
- * The Horde_Ui_VarRenderer:: class provides base functionality for
- * other Horde UI elements.
- *
- * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author  Jason M. Felice <jason.m.felice@gmail.com>
- * @package Horde_Ui
- */
-class Horde_Ui_VarRenderer
-{
-    /**
-     * Parameters which change this renderer's behavior.
-     *
-     * @var array
-     */
-    protected $_params;
-
-    /**
-     * Charset to use for output.
-     *
-     * @var string
-     */
-    protected $_charset;
-
-    /**
-     * Constructs a new renderer.
-     *
-     * @param array $params  The name of the variable which will track this UI
-     *                       widget's state.
-     */
-    public function __construct($params = array())
-    {
-        $this->_params = $params;
-        $this->_charset = $GLOBALS['registry']->getCharset();
-    }
-
-    /**
-     * Constructs a new instance.
-     *
-     * @param mixed $driver  This is the renderer subclass we will instantiate.
-     *                       If an array is passed, the first element is the
-     *                       library path and the second element is the driver
-     *                       name.
-     * @param array $params  Parameters specific to the subclass.
-     *
-     * @return Horde_Ui_VarRenderer  A subclass instance.
-     * @throws Horde_Exception
-     */
-    static public function factory($driver, $params = array())
-    {
-        if (is_array($driver)) {
-            $app = $driver[0];
-            $driver = $driver[1];
-        }
-
-        $driver = ucfirst(basename($driver));
-        if (!empty($app)) {
-            include $GLOBALS['registry']->get('fileroot', $app) . '/lib/Ui/VarRenderer/' . $driver . '.php';
-        }
-
-        $class = 'Horde_Ui_VarRenderer_' . $driver;
-        if (!class_exists($class)) {
-            throw new Horde_Exception('Class definition of ' . $class . ' not found.');
-        }
-
-        return new $class($params);
-    }
-
-    /**
-     * Renders a variable.
-     *
-     * @param Horde_Form $form           A Horde_Form instance,
-     *                                   or null if none is available.
-     * @param Horde_Form_Variable $va r  A Horde_Form_Variable.
-     * @param Variables $vars            A Horde_Variables instance.
-     * @param boolean $isInput           Whether this is an input field.
-     */
-    public function render($form, $var, $vars, $isInput = false)
-    {
-        $state = $isInput ? 'Input' : 'Display';
-        $method = "_renderVar${state}_" . $var->type->getTypeName();
-        if (!method_exists($this, $method)) {
-            $method = "_renderVar${state}Default";
-        }
-
-        return $this->$method($form, $var, $vars);
-    }
-
-    /**
-     * Finishes rendering after all fields are output.
-     *
-     * @return string  TODO
-     */
-    public function renderEnd()
-    {
-        return '';
-    }
-}
diff --git a/framework/Ui/lib/Horde/Ui/VarRenderer/Html.php b/framework/Ui/lib/Horde/Ui/VarRenderer/Html.php
deleted file mode 100644 (file)
index 2a7b4fe..0000000
+++ /dev/null
@@ -1,1671 +0,0 @@
-<?php
-/**
- * The Horde_Ui_VarRenderer_html:: class renders variables to HTML.
- *
- * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author  Jason M. Felice <jason.m.felice@gmail.com>
- * @package Horde_Ui
- */
-class Horde_Ui_VarRenderer_Html extends Horde_Ui_VarRenderer
-{
-    protected $_onLoadJS = array();
-
-    protected function _renderVarInputDefault($form, &$var, &$vars)
-    {
-        return '<strong>Warning:</strong> Unknown variable type ' .
-            @htmlspecialchars($var->getTypeName(), ENT_QUOTES, $this->_charset);
-    }
-
-    protected function _renderVarInput_number($form, &$var, &$vars)
-    {
-        $value = $var->getValue($vars);
-        if ($var->type->getProperty('fraction')) {
-            $value = sprintf('%01.' . $var->type->getProperty('fraction') . 'f', $value);
-        }
-        $linfo = Horde_Nls::getLocaleInfo();
-        /* Only if there is a mon_decimal_point do the
-         * substitution. */
-        if (!empty($linfo['mon_decimal_point'])) {
-            $value = str_replace('.', $linfo['mon_decimal_point'], $value);
-        }
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<input type="number" size="5" name="%s" id="%s" value="%s"%s />',
-                       $varname,
-                       $varname,
-                       $value,
-                       $this->_getActionScripts($form, $var)
-               );
-    }
-
-    protected function _renderVarInput_int($form, &$var, &$vars)
-    {
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<input type="number" size="5" name="%s" id="%s" value="%s"%s />',
-                       $varname,
-                       $varname,
-                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset),
-                       $this->_getActionScripts($form, $var)
-               );
-    }
-
-    protected function _renderVarInput_octal($form, &$var, &$vars)
-    {
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<input type="text" size="5" name="%s" id="%s" value="%s"%s />',
-                       $varname,
-                       $varname,
-                       sprintf('0%o', octdec($var->getValue($vars))),
-                       $this->_getActionScripts($form, $var)
-               );
-    }
-
-    protected function _renderVarInput_intlist($form, &$var, &$vars)
-    {
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<input type="text" name="%s" id="%s" value="%s"%s />',
-                       $varname,
-                       $varname,
-                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset),
-                       $this->_getActionScripts($form, $var)
-               );
-    }
-
-    protected function _renderVarInput_text($form, &$var, &$vars)
-    {
-        $maxlength = $var->type->getMaxLength();
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<input type="text" name="%s" id="%s" size="%s" value="%s" %s%s%s />',
-                       $varname,
-                       $varname,
-                       $var->type->getSize(),
-                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset),
-                       $var->isDisabled() ? ' disabled="disabled" ' : '',
-                       empty($maxlength) ? '' : ' maxlength="' . $maxlength . '"',
-                       $this->_getActionScripts($form, $var)
-               );
-    }
-
-    protected function _renderVarInput_stringlist($form, &$var, &$vars)
-    {
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<input type="text" size="60" name="%s" id="%s" value="%s"%s />',
-                       $varname,
-                       $varname,
-                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset),
-                       $this->_getActionScripts($form, $var)
-               );
-    }
-
-    protected function _renderVarInput_stringarray($form, &$var, &$vars)
-    {
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<input type="text" size="60" name="%s" id="%s" value="%s"%s />',
-                       $varname,
-                       $varname,
-                       @htmlspecialchars(implode(', ', $var->getValue($vars)), ENT_QUOTES, $this->_charset),
-                       $this->_getActionScripts($form, $var)
-               );
-    }
-
-    protected function _renderVarInput_phone($form, &$var, &$vars)
-    {
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<input type="text" name="%s" id="%s" size="15" value="%s" %s%s />',
-                       $varname,
-                       $varname,
-                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset),
-                       $var->isDisabled() ? ' disabled="disabled" ' : '',
-                       $this->_getActionScripts($form, $var)
-               );
-    }
-
-    protected function _renderVarInput_cellphone($form, &$var, &$vars)
-    {
-        return $this->_renderVarInput_phone($form, $var, $vars);
-    }
-
-    protected function _renderVarInput_ipaddress($form, &$var, &$vars)
-    {
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<input type="text" name="%s" id="%s" size="16" value="%s" %s%s />',
-                       $varname,
-                       $varname,
-                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset),
-                       $var->isDisabled() ? ' disabled="disabled" ' : '',
-                       $this->_getActionScripts($form, $var)
-               );
-    }
-
-    protected function _renderVarInput_ip6address($form, &$var, &$vars)
-    {
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<input type="text" name="%s" id="%s" size="40" value="%s" %s%s />',
-                       $varname,
-                       $varname,
-                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset),
-                       $var->isDisabled() ? ' disabled="disabled" ' : '',
-                       $this->_getActionScripts($form, $var)
-               );
-    }
-
-    protected function _renderVarInput_file($form, &$var, &$vars)
-    {
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<input type="file" size="30" name="%s" id="%s"%s />',
-                       $varname,
-                       $varname,
-                       $this->_getActionScripts($form, $var));
-    }
-
-    /**
-     * @todo Show image dimensions in the width/height boxes.
-     */
-    protected function _renderVarInput_image($form, &$var, &$vars)
-    {
-        $varname = htmlspecialchars($var->getVarName());
-        $image = $var->type->getImage($vars, $var);
-        Horde::addScriptFile('image.js', 'horde');
-        $html = '';
-
-        /* Check if there is existing img information stored. */
-        if (isset($image['img'])) {
-            /* Hidden tag to store the preview image id. */
-            $html = sprintf('<input type="hidden" name="%s" id="%s" value="%s" />',
-                            $varname . '[hash]',
-                            $varname . '[hash]',
-                            $var->type->getRandomId());
-        }
-
-        /* Output MAX_FILE_SIZE parameter to limit large files. */
-        if ($var->type->getProperty('max_filesize')) {
-            $html .= sprintf('<input type="hidden" name="MAX_FILE_SIZE" value="%d" />',
-                             $var->type->getProperty('max_filesize'));
-        }
-
-        /* Output the input tag. */
-        $html .= sprintf('<input type="file" size="30" name="%s" id="%s" />',
-                         $varname . '[new]',
-                         $varname . '[new]');
-
-        /* Output the button to upload/reset the image. */
-        if ($var->type->getProperty('show_upload')) {
-            $html .= '&nbsp;';
-            $html .= sprintf('<input class="button" name="%s" id="%s" type="submit" value="%s" /> ',
-                             '_do_' . $varname,
-                             '_do_' . $varname,
-                             _("Upload"));
-        }
-
-        if (!empty($image['img'])) {
-            /* Image information stored, show preview, add buttons for image
-             * manipulation. */
-            $html .= '<br />';
-            $img = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/images/view.php');
-            if (isset($image['img']['vfs_id'])) {
-                /* Calling an image from VFS. */
-                $img = Horde_Util::addParameter($img, array('f' => $image['img']['vfs_id'],
-                                                      's' => 'vfs',
-                                                      'p' => $image['img']['vfs_path']));
-            } else {
-                /* Calling an image from a tmp directory (uploads). */
-                $img = Horde_Util::addParameter($img, 'f', $image['img']['file']);
-            }
-
-            /* Reset. */
-            $html .= Horde::link('#', _("Reset"), '', '', 'showImage(\'' . $img . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/refresh.png', _("Reset")) . '</a>';
-
-            /* Rotate 270. */
-            $html .= Horde::link('#', _("Rotate Left"), '', '', 'showImage(\'' . Horde_Util::addParameter($img, array('a' => 'rotate', 'v' => '270')) . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/rotate-270.png', _("Rotate Left")) . '</a>';
-
-            /* Rotate 180. */
-            $html .= Horde::link('#', _("Rotate 180"), '', '', 'showImage(\'' . Horde_Util::addParameter($img, array('a' => 'rotate', 'v' => '180')) . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/rotate-180.png', _("Rotate 180")) . '</a>';
-
-            /* Rotate 90. */
-            $html .= Horde::link('#', _("Rotate Right"), '', '', 'showImage(\'' . Horde_Util::addParameter($img, array('a' => 'rotate', 'v' => '90')) . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/rotate-90.png', _("Rotate Right")) . '</a>';
-
-            /* Flip image. */
-            $html .= Horde::link('#', _("Flip"), '', '', 'showImage(\'' . Horde_Util::addParameter($img, 'a', 'flip') . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/flip.png', _("Flip")) . '</a>';
-
-            /* Mirror image. */
-            $html .= Horde::link('#', _("Mirror"), '', '', 'showImage(\'' . Horde_Util::addParameter($img, 'a', 'mirror') . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/mirror.png', _("Mirror")) . '</a>';
-
-            /* Apply grayscale. */
-            $html .= Horde::link('#', _("Grayscale"), '', '', 'showImage(\'' . Horde_Util::addParameter($img, 'a', 'grayscale') . '\', \'_p_' . $varname . '\', true);') . Horde::img('image/grayscale.png', _("Grayscale")) . '</a>';
-
-            /* Resize width. */
-            $html .= sprintf('%s<input type="text" size="4" onchange="src=getResizeSrc(\'%s\', \'%s\');showImage(src, \'_p_%s\', true);" %s />',
-                   _("w:"),
-                   Horde_Util::addParameter($img, 'a', 'resize'),
-                   $varname,
-                   $varname,
-                   $this->_genID('_w_' . $varname));
-
-            /* Resize height. */
-            $html .= sprintf('%s<input type="text" size="4" onchange="src=getResizeSrc(\'%s\', \'%s\');showImage(src, \'_p_%s\', true);" %s />',
-                   _("h:"),
-                   Horde_Util::addParameter($img, 'a', 'resize'),
-                   $varname,
-                   $varname,
-                   $this->_genID('_h_' . $varname));
-
-            /* Apply fixed ratio resize. */
-            $html .= Horde::link('#', _("Fix ratio"), '', '', 'src=getResizeSrc(\'' . Horde_Util::addParameter($img, 'a', 'resize') . '\', \'' . $varname . '\', \'1\');showImage(src, \'_p_' . $varname . '\', true);') . Horde::img('ratio.png', _("Fix ratio"), '', $img_dir) . '</a>';
-
-            /* Keep also original if it has been requested. */
-            if ($var->type->getProperty('show_keeporig')) {
-                $html .= sprintf('<input type="checkbox" class="checkbox" name="%s" id="%s"%s />%s' . "\n",
-                                 $varname . '[keep_orig]',
-                                 $varname . '[keep_orig]',
-                                 !empty($image['keep_orig']) ? ' checked="checked"' : '',
-                                 _("Keep original?"));
-            }
-
-            /* The preview image element. */
-            $html .= '<br /><img src="' . $img . '" ' . $this->_genID('_p_' . $varname) . ">\n";
-        }
-
-        return $html;
-    }
-
-    protected function _renderVarInput_longtext($form, &$var, &$vars)
-    {
-        global $browser;
-
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        $html = sprintf('<textarea id="%s" name="%s" cols="%s" rows="%s"%s%s>%s</textarea>',
-                        $varname,
-                        $varname,
-                        (int)$var->type->getCols(),
-                        (int)$var->type->getRows(),
-                        $this->_getActionScripts($form, $var),
-                        $var->isDisabled() ? ' disabled="disabled"' : '',
-                        @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset));
-
-        if ($var->type->hasHelper('rte')) {
-            $GLOBALS['injector']->getInstance('Horde_Editor')->getEditor('fckeditor', array('id' => $varname, 'relativelinks' => $var->type->hasHelper('relativelinks')));
-        }
-
-        if ($var->type->hasHelper() && $browser->hasFeature('javascript')) {
-            $html .= '<br /><table cellspacing="0"><tr><td>';
-            Horde::addScriptFile('open_html_helper.js', 'horde', array('direct' => false));
-            $imgId = $this->_genID($var->getVarName(), false) . 'ehelper';
-            if ($var->type->hasHelper('emoticons')) {
-                $html .= Horde::link('#', _("Emoticons"), '', '', 'openHtmlHelper(\'emoticons\', \'' . $var->getVarName() . '\'); return false;') . Horde::img('emoticons/smile.png', _("Emoticons"), 'id="' . $imgId . '"') . '</a>';
-            }
-            $html .= '</td></tr><tr><td><div ' . $this->_genID('htmlhelper_' . $var->getVarName()) . ' class="control"></div></td></tr></table>' . "\n";
-        }
-
-        return $html;
-    }
-
-    protected function _renderVarInput_countedtext($form, &$var, &$vars)
-    {
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<textarea name="%s" id="%s" cols="%s" rows="%s"%s%s>%s</textarea>',
-                       $varname,
-                       $varname,
-                       (int)$var->type->getCols(),
-                       (int)$var->type->getRows(),
-                       $this->_getActionScripts($form, $var),
-                       $var->isDisabled() ? ' disabled="disabled"' : '',
-                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset));
-    }
-
-    protected function _renderVarInput_address($form, &$var, &$vars)
-    {
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<textarea name="%s" id="%s" cols="%s" rows="%s"%s%s>%s</textarea>',
-                       $varname,
-                       $varname,
-                       (int)$var->type->getCols(),
-                       (int)$var->type->getRows(),
-                       $this->_getActionScripts($form, $var),
-                       $var->isDisabled() ? ' disabled="disabled"' : '',
-                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset));
-    }
-
-    protected function _renderVarInput_addresslink($form, &$var, &$vars)
-    {
-        return '';
-    }
-
-    protected function _renderVarInput_pgp($form, &$var, &$vars)
-    {
-        return $this->_renderVarInput_longtext($form, $var, $vars);
-    }
-
-    protected function _renderVarInput_smime($form, &$var, &$vars)
-    {
-        return $this->_renderVarInput_longtext($form, $var, $vars);
-    }
-
-    protected function _renderVarInput_country($form, &$var, &$vars)
-    {
-        return $this->_renderVarInput_enum($form, $var, $vars);
-    }
-
-    protected function _renderVarInput_date($form, &$var, &$vars)
-    {
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<input type="text" name="%s" id="%s" value="%s"%s />',
-                       $varname,
-                       $varname,
-                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset),
-                       $this->_getActionScripts($form, $var));
-    }
-
-    protected function _renderVarInput_time($form, &$var, &$vars)
-    {
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<input type="text" size="5" name="%s" id="%s" value="%s"%s />',
-                       $varname,
-                       $varname,
-                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset),
-                       $this->_getActionScripts($form, $var));
-    }
-
-    protected function _renderVarInput_hourminutesecond($form, &$var, &$vars)
-    {
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        $time = $var->type->getTimeParts($var->getValue($vars));
-
-        /* Output hours. */
-        $hours = array('' => _("hh"));
-        for ($i = 0; $i <= 23; $i++) {
-            $hours[$i] = $i;
-        }
-        $html = sprintf('<select name="%s[hour]" id="%s[hour]"%s>%s</select>',
-                        $varname,
-                        $varname,
-                        $this->_getActionScripts($form, $var),
-                        $this->selectOptions($hours, ($time['hour'] === '') ? '' : $time['hour']));
-
-        /* Output minutes. */
-        $minutes = array('' => _("mm"));
-        for ($i = 0; $i <= 59; $i++) {
-            $m = sprintf('%02d', $i);
-            $minutes[$m] = $m;
-        }
-        $html .= sprintf('<select name="%s[minute]" id="%s[minute]"%s>%s</select>',
-                         $varname,
-                         $varname,
-                         $this->_getActionScripts($form, $var),
-                         $this->selectOptions($minutes, ($time['minute'] === '') ? '' : sprintf('%02d', $time['minute'])));
-
-        /* Return if seconds are not required. */
-        if (!$var->type->getProperty('show_seconds')) {
-            return $html;
-        }
-
-        /* Output seconds. */
-        $seconds = array('' => _("ss"));
-        for ($i = 0; $i <= 59; $i++) {
-            $s = sprintf('%02d', $i);
-            $seconds[$s] = $s;
-        }
-        return $html . sprintf('<select name="%s[second]" id="%s[second]"%s>%s</select>',
-                               $varname,
-                               $varname,
-                               $this->_getActionScripts($form, $var),
-                               $this->selectOptions($seconds, ($time['second'] === '') ? '' : sprintf('%02d', $time['second'])));
-    }
-
-    protected function _renderVarInput_monthyear($form, &$var, &$vars)
-    {
-        $dates = array();
-        $dates['month'] = array('' => _("MM"),
-                                1 => _("January"),
-                                2 => _("February"),
-                                3 => _("March"),
-                                4 => _("April"),
-                                5 => _("May"),
-                                6 => _("June"),
-                                7 => _("July"),
-                                8 => _("August"),
-                                9 => _("September"),
-                                10 => _("October"),
-                                11 => _("November"),
-                                12 => _("December"));
-        $dates['year'] = array('' => _("YYYY"));
-        if ($var->type->getProperty('start_year') > $var->type->getProperty('end_year')) {
-            for ($i = $var->type->getProperty('start_year'); $i >= $var->type->getProperty('end_year'); $i--) {
-                $dates['year'][$i] = $i;
-            }
-        } else {
-            for ($i = $var->type->getProperty('start_year'); $i <= $var->type->getProperty('end_year'); $i++) {
-                $dates['year'][$i] = $i;
-            }
-        }
-        return sprintf('<select name="%s" id="%s"%s>%s</select>',
-                       $var->type->getMonthVar($var),
-                       $var->type->getMonthVar($var),
-                       $this->_getActionScripts($form, $var),
-                       $this->selectOptions($dates['month'], $vars->get($var->type->getMonthVar($var)))) .
-            sprintf('<select name="%s" id="%s"%s>%s</select>',
-                    $var->type->getYearVar($var),
-                    $var->type->getYearVar($var),
-                    $this->_getActionScripts($form, $var),
-                    $this->selectOptions($dates['year'], $vars->get($var->type->getYearVar($var))));
-    }
-
-    protected function _renderVarInput_monthdayyear($form, &$var, &$vars)
-    {
-        $dates = array();
-        $dates['month'] = array(''   => _("MM"),
-                                '1'  => _("January"),
-                                '2'  => _("February"),
-                                '3'  => _("March"),
-                                '4'  => _("April"),
-                                '5'  => _("May"),
-                                '6'  => _("June"),
-                                '7'  => _("July"),
-                                '8'  => _("August"),
-                                '9'  => _("September"),
-                                '10' => _("October"),
-                                '11' => _("November"),
-                                '12' => _("December"));
-        $dates['day'] = array('' => _("DD"));
-        for ($i = 1; $i <= 31; $i++) {
-            $dates['day'][$i] = $i;
-        }
-        $dates['year'] = array('' => _("YYYY"));
-        if ($var->type->getProperty('start_year') > $var->type->getProperty('end_year')) {
-            for ($i = $var->type->getProperty('start_year'); $i >= $var->type->getProperty('end_year'); $i--) {
-                $dates['year'][$i] = $i;
-            }
-        } else {
-            for ($i = $var->type->getProperty('start_year'); $i <= $var->type->getProperty('end_year'); $i++) {
-                $dates['year'][$i] = $i;
-            }
-        }
-        $date = $var->type->getDateParts($var->getValue($vars));
-
-        // TODO: use NLS to get the order right for the Rest Of The
-        // World.
-        $html = '';
-        $date_parts = array('month', 'day', 'year');
-        foreach ($date_parts as $part) {
-            $varname = @htmlspecialchars($var->getVarName() . '[' . $part . ']', ENT_QUOTES, $this->_charset);
-            $html .= sprintf('<select name="%s" id="%s"%s>%s</select>',
-                             $varname,
-                             $varname,
-                             $this->_getActionScripts($form, $var),
-                             $this->selectOptions($dates[$part], $date[$part]));
-        }
-
-        if ($var->type->getProperty('picker') &&
-            $GLOBALS['browser']->hasFeature('javascript')) {
-            Horde_Ui_JsCalendar::init();
-            $imgId = $this->_genID($var->getVarName(), false) . 'goto';
-            $html .= Horde::link('#', _("Select a date"), '', '', 'Horde_Calendar.open(\'' . $imgId . '\', null)') . Horde::img('calendar.png', _("Calendar"), 'id="' . $imgId . '"') . "</a>\n";
-        }
-
-        return $html;
-    }
-
-    protected function _renderVarInput_datetime(&$form, &$var, &$vars)
-    {
-        $js = "document.observe('Horde_Calendar:select', " .
-              "function(e) {" .
-                  "var elt = e.element();" .
-                  "elt.up().previous('SELECT[name$=\"[month]\"]').setValue(e.memo.getMonth() + 1);" .
-                  "elt.up().previous('SELECT[name$=\"[day]\"]').setValue(e.memo.getDate());" .
-                  "elt.up().previous('SELECT[name$=\"[year]\"]').setValue(e.memo.getFullYear());" .
-              "});\n";
-        Horde::addInlineScript($js, 'dom');
-        return $this->_renderVarInput_monthdayyear($form, $var, $vars) .
-            $this->_renderVarInput_hourminutesecond($form, $var, $vars);
-    }
-
-    protected function _renderVarInput_sound(&$form, &$var, &$vars)
-    {
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        $value = @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset);
-        $html = '<ul class="sound-list">';
-        if (!$var->isRequired()) {
-            $html .= '<li><label><input type="radio" id="' . $varname . '" name="' . $varname . '" value=""' . (!$value ? ' checked="checked"' : '') . ' /> ' . _("No Sound") . '</label></li>';
-        }
-        foreach ($var->type->getSounds() as $sound) {
-            $sound = @htmlspecialchars($sound, ENT_QUOTES, $this->_charset);
-            $html .= '<li><label><input type="radio" id="' . $varname . '" name="' . $varname . '" value="' . $sound . '"' . ($value == $sound ? ' checked="checked"' : '') . ' />' . $sound . '</label>'
-                . ' <embed autostart="false" src="'. $GLOBALS['registry']->get('themesuri', 'horde') . '/sounds/' . $sound . '" /></li>';
-        }
-        return $html . '</ul>';
-    }
-
-    protected function _renderVarInput_colorpicker($form, &$var, &$vars)
-    {
-        global $registry, $browser;
-
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        $color = $var->getValue($vars);
-        if ($color) {
-            $style = ' style="background-color:' . $color . ';color:'
-                . (Horde_Image::brightness($color) < 128 ? '#fff' : '#000') . '"';
-        } else {
-            $style = '';
-        }
-        $html = '<table cellspacing="0"><tr><td>'
-            . '<input type="text" size="10" maxlength="7" name="'
-            . $varname . '" id="' . $varname . '"' . $style
-            . ' value="' . @htmlspecialchars($color, ENT_QUOTES, $this->_charset)
-            . '" /></td>';
-        if ($browser->hasFeature('javascript')) {
-            Horde::addScriptFile('prototype.js', 'horde');
-            Horde::addScriptFile('colorpicker.js', 'horde');
-            $html .= '<td>'
-                . Horde::link('#', _("Color Picker"), '', '',
-                              'new ColorPicker({ color: \'' . htmlspecialchars($color) . '\', offsetParent: Event.element(event), update: [[\'' . $varname . '\', \'value\'], [\'' . $varname . '\', \'background\']] }); return false;')
-                . Horde::img('colorpicker.png', _("Color Picker"), 'height="16"') . '</a></td>';
-        }
-        return $html . '</tr></table>';
-    }
-
-    protected function _renderVarInput_sorter($form, &$var, &$vars)
-    {
-        global $registry;
-
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        $instance = $var->type->getProperty('instance');
-
-        Horde::addScriptFile('sorter.js', 'horde');
-
-        return '<input type="hidden" name="' . $varname .
-            '[array]" value="" ' . $this->_genID($varname . '[array]') . '/>' .
-            '<select class="leftFloat" multiple="multiple" size="' .
-            (int)$var->type->getSize() . '" name="' . $varname .
-            '[list]" onchange="' . $instance . '.deselectHeader();" ' .
-            $this->_genID($varname . '[list]') . '>' .
-            $var->type->getOptions($var->getValue($vars)) . '</select><div class="leftFloat">' .
-            Horde::link('#', _("Move up"), '', '', $instance . '.moveColumnUp(); return false;') . Horde::img('nav/up.png', _("Move up")) . '</a><br />' .
-            Horde::link('#', _("Move up"), '', '', $instance . '.moveColumnDown(); return false;') . Horde::img('nav/down.png', _("Move down")) . '</a></div>' .
-            '<script type="text/javascript">' . "\n" .
-            sprintf('%1$s = new Horde_Form_Sorter(\'%1$s\', \'%2$s\', \'%3$s\');' . "\n",
-                    $instance, $varname, $var->type->getHeader()) .
-            sprintf("%s.setHidden();\n</script>\n", $instance);
-    }
-
-    protected function _renderVarInput_assign($form, &$var, &$vars)
-    {
-        global $registry;
-
-        Horde::addScriptFile('form_assign.js', 'horde');
-
-        $name = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        $size = $var->type->getSize();
-        $width = $var->type->getWidth();
-        $lhdr = (bool)$var->type->getHeader(0);
-        $rhdr = (bool)$var->type->getHeader(1);
-        $this->_addOnLoadJavascript('Horde_Form_Assign.setField(\'' . $form->getName() . '\', \'' . $var->getVarName() . '\');');
-
-        return '<input type="hidden" name="' . $name . '__values" />' .
-            '<table style="width:auto"><tr><td>' .
-            sprintf('<select name="%s__left" multiple="multiple" size="%d" style="width:%s"%s>',
-                    $name, $size, $width,
-                    $lhdr ? ' onchange="Horde_Form_Assign.deselectHeaders(\'' . $form->getName() . '\', \'' . $var->getVarName() . '\', 0);"' : '') .
-            $var->type->getOptions(0, $form->getName(), $var->getVarName()) .
-            '</select></td><td>' .
-            '<a href="#" onclick="Horde_Form_Assign.move(\'' . $form->getName() . '\', \'' . $var->getVarName() . '\', 0); return false;">' .
-            Horde::img('rhand.png', _("Add")) .
-            '</a><br /><a href="#" onclick="Horde_Form_Assign.move(\'' .
-            $form->getName() . '\', \'' . $var->getVarName() . '\', 1); return false;">' .
-            Horde::img('lhand.png', _("Remove")) .
-            '</a></td><td>' .
-            sprintf('<select name="%s__right" multiple="multiple" size="%d" style="width:%s"%s>',
-                    $name, $size, $width,
-                    $rhdr ? ' onchange="Horde_Form_Assign.deselectHeaders(\'' . $form->getName() . '\', \'' . $var->getVarName() . '\', 1);"' : '') .
-            $var->type->getOptions(1, $form->getName(), $var->getVarName()) .
-            '</select></td></tr></table>';
-    }
-
-    protected function _renderVarInput_invalid($form, &$var, &$vars)
-    {
-        return $this->_renderVarDisplay_invalid($form, $var, $vars);
-    }
-
-    protected function _renderVarInput_enum($form, &$var, &$vars)
-    {
-        $values = $var->getValues();
-        $prompt = $var->type->getPrompt();
-        $htmlchars = $var->getOption('htmlchars');
-        if (!empty($prompt)) {
-            $prompt = '<option value="">' . ($htmlchars ? $prompt : @htmlspecialchars($prompt, ENT_QUOTES, $this->_charset)) . '</option>';
-        }
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<select name="%s" id="%s" %s>%s%s</select>',
-                       $varname,
-                       $varname,
-                       $this->_getActionScripts($form, $var),
-                       $prompt,
-                       $this->selectOptions($values, $var->getValue($vars), $htmlchars));
-    }
-
-    protected function _renderVarInput_mlenum($form, &$var, &$vars)
-    {
-        $varname = $var->getVarName();
-        $hvarname = @htmlspecialchars($varname, ENT_QUOTES, $this->_charset);
-        $values = $var->getValues();
-        $prompts = $var->type->getPrompts();
-        $selected = $var->getValue($vars);
-        /* If passing a non-array value need to get the keys. */
-        if (!is_array($selected)) {
-            foreach ($values as $key_1 => $values_2) {
-                if (isset($values_2[$selected])) {
-                    $selected = array('1' => $key_1, '2' => $selected);
-                    break;
-                }
-            }
-        }
-
-        /* Hidden tag to store the current first level. */
-        $html = sprintf('<input type="hidden" name="%s[old]" value="%s" %s />',
-                        $hvarname,
-                        @htmlspecialchars($selected['1'], ENT_QUOTES, $this->_charset),
-                        $this->_genID($varname . '[old]'));
-
-        /* First level. */
-        $values_1 = Horde_Array::valuesToKeys(array_keys($values));
-        $html .= sprintf('<select %s name="%s[1]" onchange="%s"%s>',
-                         $this->_genID($varname . '[1]'),
-                         $hvarname,
-                         'if (this.value) { document.' . $form->getName() . '.formname.value=\'\';' . 'document.' . $form->getName() . '.submit() }',
-                         ($var->hasAction() ? ' ' . $this->_genActionScript($form, $var->_action, $varname) : ''));
-        if (!empty($prompts)) {
-            $html .= '<option value="">' . @htmlspecialchars($prompts[0], ENT_QUOTES, $this->_charset) . '</option>';
-        }
-        $html .= $this->selectOptions($values_1, $selected['1']);
-        $html .= '</select>';
-
-        /* Second level. */
-        $html .= sprintf('<select %s name="%s[2]"%s>',
-                         $this->_genID($varname . '[2]'),
-                         $hvarname,
-                         ($var->hasAction() ? ' ' . $this->_genActionScript($form, $var->_action, $varname) : ''));
-        if (!empty($prompts)) {
-            $html .= '<option value="">' . @htmlspecialchars($prompts[1], ENT_QUOTES, $this->_charset) . '</option>';
-        }
-        $values_2 = array();
-        if (!empty($selected['1'])) {
-            $values_2 = &$values[$selected['1']];
-        }
-        return $html . $this->selectOptions($values_2, $selected['2']) . '</select>';
-    }
-
-    protected function _renderVarInput_multienum($form, &$var, &$vars)
-    {
-        $values = $var->getValues();
-        $selected = $vars->getExists($var->getVarName(), $wasset);
-        if (!$wasset) {
-            $selected = $var->getDefault();
-        }
-        return sprintf('<select multiple="multiple" size="%s" name="%s[]" %s>%s</select>',
-                       (int)$var->type->size,
-                       @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset),
-                       $this->_getActionScripts($form, $var),
-                       $this->_multiSelectOptions($values, $selected)) .
-            "<br />\n" . _("To select multiple items, hold down the Control (PC) or Command (Mac) key while clicking.") . "\n";
-    }
-
-    protected function _renderVarInput_keyval_multienum($form, &$var, &$vars)
-    {
-        return $this->_renderVarInput_multienum($form, $var, $vars);
-    }
-
-    protected function _renderVarInput_radio($form, &$var, &$vars)
-    {
-        return $this->_radioButtons($var->getVarName(),
-                                    $var->getValues(),
-                                    $var->getValue($vars),
-                                    $this->_getActionScripts($form, $var));
-    }
-
-    protected function _renderVarInput_set($form, &$var, &$vars)
-    {
-        $html = $this->_checkBoxes($var->getVarName(),
-                                   $var->getValues(),
-                                   $var->getValue($vars),
-                                   $this->_getActionScripts($form, $var));
-
-        if ($var->type->getProperty('checkAll')) {
-            $form_name = $form->getName();
-            $var_name = $var->getVarName() . '[]';
-            $function_name = 'select'  . $form_name . $var->getVarName();
-            $enable = _("Select all");
-            $disable = _("Select none");
-            $invert = _("Invert selection");
-            $html .= <<<EOT
-<script type="text/javascript">
-function $function_name()
-{
-    for (var i = 0; i < document.$form_name.elements.length; i++) {
-        f = document.$form_name.elements[i];
-        if (f.name != '$var_name') {
-            continue;
-        }
-        if (arguments.length) {
-            f.checked = arguments[0];
-        } else {
-            f.checked = !f.checked;
-        }
-    }
-}
-</script>
-<a href="#" onclick="$function_name(true); return false;">$enable</a>,
-<a href="#" onclick="$function_name(false); return false;">$disable</a>,
-<a href="#" onclick="$function_name(); return false;">$invert</a>
-EOT;
-        }
-
-        return $html;
-    }
-
-    protected function _renderVarInput_link($form, &$var, &$vars)
-    {
-        return $this->_renderVarDisplay_link($form, $var, $vars);
-    }
-
-    protected function _renderVarInput_html($form, &$var, &$vars)
-    {
-        return $this->_renderVarDisplay_html($form, $var, $vars);
-    }
-
-    protected function _renderVarInput_email($form, &$var, &$vars)
-    {
-        return sprintf('<input type="email" name="%s" id="%s" value="%s"%s />',
-                       $var->getVarName(),
-                       $var->getVarName(),
-                       @htmlspecialchars($var->getValue($vars)),
-                       $this->_getActionScripts($form, $var));
-    }
-
-    protected function _renderVarInput_matrix($form, &$var, &$vars)
-    {
-        $varname   = $var->getVarName();
-        $var_array = $var->getValue($vars);
-        $cols      = $var->type->getCols();
-        $rows      = $var->type->getRows();
-        $matrix    = $var->type->getMatrix();
-        $new_input = $var->type->getNewInput();
-
-        $html = '<table cellspacing="0"><tr>';
-
-        $html .= '<td class="rightAlign" width="20%"></td>';
-        foreach ($cols as $col_title) {
-            $html .= '<td align="center" width="1%">' . htmlspecialchars($col_title) . '</td>';
-        }
-        $html .= '<td class="rightAlign" width="60%"></td></tr>';
-
-        /* Offer a new row of data to be added to the matrix? */
-        if ($new_input) {
-            $html .= '<tr><td>';
-            if (is_array($new_input)) {
-                $html .= sprintf('<select %s name="%s[n][r]"><option value="">%s</option>%s</select><br />',
-                       $this->_genID($varname . '[n][r]'),
-                       $varname,
-                       _("-- select --"),
-                       $this->selectOptions($new_input, $var_array['n']['r']));
-            } elseif ($new_input == true) {
-                $html .= sprintf('<input %s type="text" name="%s[n][r]" value="%s" />',
-                       $this->_genID($varname . '[n][r]'),
-                       $varname,
-                       $var_array['n']['r']);
-            }
-            $html .= ' </td>';
-            foreach ($cols as $col_id => $col_title) {
-                $html .= sprintf('<td align="center"><input type="checkbox" class="checkbox" name="%s[n][v][%s]" /></td>', $varname, $col_id);
-            }
-            $html .= '<td> </td></tr>';
-        }
-
-        /* Loop through the rows and create checkboxes for each column. */
-        foreach ($rows as $row_id => $row_title) {
-            $html .= sprintf('<tr><td>%s</td>', $row_title);
-            foreach ($cols as $col_id => $col_title) {
-                $html .= sprintf('<td align="center"><input type="checkbox" class="checkbox" name="%s[r][%s][%s]"%s /></td>', $varname, $row_id, $col_id, (!empty($matrix[$row_id][$col_id]) ? ' checked="checked"' : ''));
-            }
-            $html .= '<td> </td></tr>';
-        }
-
-        return $html . '</table>';
-    }
-
-    protected function _renderVarInput_password($form, &$var, &$vars)
-    {
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<input type="password" name="%s" id="%s" value="%s"%s />',
-                       $varname,
-                       $varname,
-                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset),
-                       $this->_getActionScripts($form, $var));
-    }
-
-    protected function _renderVarInput_emailconfirm($form, &$var, &$vars)
-    {
-        $email = $var->getValue($vars);
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<input type="email" name="%s[original]" id="%s[original]" value="%s"%s />',
-                       $varname,
-                       $varname,
-                       @htmlspecialchars($email['original'], ENT_QUOTES, $this->_charset),
-                       $this->_getActionScripts($form, $var)) .
-            ' ' . sprintf('<input type="email" name="%s[confirm]" id="%s[confirm]" value="%s"%s />',
-                          $varname,
-                          $varname,
-                          @htmlspecialchars($email['confirm'], ENT_QUOTES, $this->_charset),
-                          $this->_getActionScripts($form, $var));
-    }
-
-    protected function _renderVarInput_passwordconfirm($form, &$var, &$vars)
-    {
-        $password = $var->getValue($vars);
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<input type="password" name="%s[original]" id="%s[original]" value="%s"%s />',
-                       $varname,
-                       $varname,
-                       @htmlspecialchars($password['original'], ENT_QUOTES, $this->_charset),
-                       $this->_getActionScripts($form, $var)) .
-            ' ' . sprintf('<input type="password" name="%s[confirm]" id="%s[confirm]" value="%s"%s />',
-                          $varname,
-                          $varname,
-                          @htmlspecialchars($password['confirm'], ENT_QUOTES, $this->_charset),
-                          $this->_getActionScripts($form, $var));
-    }
-
-    protected function _renderVarInput_boolean($form, &$var, &$vars)
-    {
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        $html = '<input type="checkbox" class="checkbox" name="' .  $varname . '"' .
-            ' id="' . $varname . '"' . ($var->getValue($vars) ? ' checked="checked"' : '');
-        if ($var->hasAction()) {
-            $html .= $this->_genActionScript($form, $var->_action,
-                                             $var->getVarName());
-        }
-        return $html . ' />';
-    }
-
-    protected function _renderVarInput_creditcard($form, &$var, &$vars)
-    {
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        $html = '<input type="text" name="' . $varname . '" id="' . $varname . '" value="' .
-            @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset) . '"';
-        if ($var->hasAction()) {
-            $html .= $this->_genActionScript($form, $var->_action,
-                                             $var->getVarName());
-        }
-        return $html . ' />';
-    }
-
-    protected function _renderVarInput_obrowser($form, &$var, &$vars)
-    {
-        $varname = $var->getVarName();
-        $varvalue = $vars->get($varname);
-        $fieldId = $this->_genID(md5(uniqid(rand(), true)), false) . 'id';
-        $html = '
-            <script type="text/javascript">
-            var obrowserWindowName;
-            function obrowserCallback(name, oid)
-            {
-                if (name == obrowserWindowName) {
-                    document.getElementById(\'' . $fieldId . '\').value = oid;
-                    return false;
-                } else {
-                    return "Invalid window name supplied";
-                }
-            }
-            </script>
-            ';
-        $html .= sprintf('<input type="hidden" name="%s" id="%s"%s value="%s">',
-                         @htmlspecialchars($varname, ENT_QUOTES, $this->_charset),
-                         $fieldId,
-                         $this->_getActionScripts($form, $var),
-                         @htmlspecialchars($varvalue, ENT_QUOTES, $this->_charset));
-        if (!empty($varvalue)) {
-            $html .= $varvalue;
-        }
-
-        if ($GLOBALS['browser']->hasFeature('javascript')) {
-            $html .= Horde::link($GLOBALS['registry']->get('webroot', 'horde') . '/services/obrowser/', _("Select an object"), '', '_blank', 'obrowserWindow = ' . Horde::popupJs($GLOBALS['registry']->get('webroot', 'horde') . '/services/obrowser/', array('urlencode' => true)) . 'obrowserWindowName = obrowserWindow.name; return false;') . Horde::img('tree/leaf.png', _("Object")) . "</a>\n";
-        }
-
-        return $html;
-    }
-
-    protected function _renderVarInput_dblookup($form, &$var, &$vars)
-    {
-        return $this->_renderVarInput_enum($form, $var, $vars);
-    }
-
-    protected function _renderVarInput_figlet($form, &$var, &$vars)
-    {
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<input type="text" name="%s" id="%s" size="%s" value="%s" />',
-                       $varname,
-                       $varname,
-                       strlen($var->type->getText()),
-                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset)) .
-            '<br />' . _("Enter the letters below:") . '<br />' .
-            $this->_renderVarDisplay_figlet($form, $var, $vars);
-    }
-
-    protected function _renderVarInput_captcha($form, &$var, &$vars)
-    {
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        return sprintf('<input type="text" name="%s" id="%s" size="%s" value="%s" />',
-                       $varname,
-                       $varname,
-                       strlen($var->type->getText()),
-                       @htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset)) .
-            '<br />' . _("Enter the letters below:") . '<br />' .
-            $this->_renderVarDisplay_captcha($form, $var, $vars);
-    }
-
-    protected function _renderVarDisplayDefault($form, &$var, &$vars)
-    {
-        return nl2br(@htmlspecialchars($var->getValue($vars), ENT_QUOTES, $this->_charset));
-    }
-
-    protected function _renderVarDisplay_html($form, &$var, &$vars)
-    {
-        // Since this is an HTML type we explicitly don't escape
-        // it. User beware.
-        return $var->getValue($vars);
-    }
-
-    protected function _renderVarDisplay_email($form, &$var, &$vars)
-    {
-        $email_val = $var->getValue($vars);
-
-        if ($var->type->getProperty('link_compose')) {
-            // Multiple email addresses?
-            $addrs = $var->type->getProperty('allow_multi')
-                ? Horde_Mime_Address::explode($email_val)
-                : array($email_val);
-
-            $link = '';
-            foreach ($addrs as $addr) {
-                $addr = trim($addr);
-
-                $display_email = $addr;
-                if ($var->type->getProperty('strip_domain') && strpos($addr, '@') !== false) {
-                    $display_email = str_replace(array('@', '.'),
-                                                 array(' (at) ', ' (dot) '),
-                                                 $addr);
-                }
-
-                // Format the address according to RFC822.
-                $mailbox_host = explode('@', $addr);
-                if (!isset($mailbox_host[1])) {
-                    $mailbox_host[1] = '';
-                }
-
-                $name = $var->type->getProperty('link_name');
-
-                $address = Horde_Mime_Address::writeAddress($mailbox_host[0], $mailbox_host[1], $name);
-
-                // Get rid of the trailing @ (when no host is included in
-                // the email address).
-                $address = str_replace('@>', '>', $address);
-                try {
-                    $mail_link = $GLOBALS['registry']->call('mail/compose', array(array('to' => addslashes($address))));
-                } catch (Horde_Exception $e) {
-                    $mail_link = 'mailto:' . urlencode($address);
-                }
-
-                if (!empty($link)) {
-                    $link .= ', ';
-                }
-                $link .= Horde::link($mail_link, $addr) . @htmlspecialchars($display_email, ENT_QUOTES, $this->_charset) . '</a>';
-            }
-
-            return $link;
-        } else {
-            $email_val = trim($email_val);
-
-            if ($var->type->getProperty('strip_domain') && strpos($email_val, '@') !== false) {
-                $email_val = str_replace(array('@', '.'),
-                                         array(' (at) ', ' (dot) '),
-                                         $email_val);
-            }
-
-            return nl2br(@htmlspecialchars($email_val, ENT_QUOTES, $this->_charset));
-        }
-    }
-
-    protected function _renderVarDisplay_password($form, &$var, &$vars)
-    {
-        return '********';
-    }
-
-    protected function _renderVarDisplay_passwordconfirm($form, &$var, &$vars)
-    {
-        return '********';
-    }
-
-    protected function _renderVarDisplay_octal($form, &$var, &$vars)
-    {
-        return sprintf('0%o', octdec($var->getValue($vars)));
-    }
-
-    protected function _renderVarDisplay_boolean($form, &$var, &$vars)
-    {
-        return $var->getValue($vars) ? _("Yes") : _("No");
-    }
-
-    protected function _renderVarDisplay_enum($form, &$var, &$vars)
-    {
-        $values = $var->getValues();
-        $value = $var->getValue($vars);
-        if (count($values) == 0) {
-            return _("No values");
-        } elseif (isset($values[$value]) && $value != '') {
-            return @htmlspecialchars($values[$value], ENT_QUOTES, $this->_charset);
-        }
-    }
-
-    protected function _renderVarDisplay_radio($form, &$var, &$vars)
-    {
-        $values = $var->getValues();
-        if (count($values) == 0) {
-            return _("No values");
-        } elseif (isset($values[$var->getValue($vars)])) {
-            return @htmlspecialchars($values[$var->getValue($vars)], ENT_QUOTES, $this->_charset);
-        }
-    }
-
-    protected function _renderVarDisplay_multienum($form, &$var, &$vars)
-    {
-        $values = $var->getValues();
-        $on = $var->getValue($vars);
-        if (!count($values) || !count($on)) {
-            return _("No values");
-        } else {
-            $display = array();
-            foreach ($values as $value => $name) {
-                if (in_array($value, $on)) {
-                    $display[] = $name;
-                }
-            }
-            return @htmlspecialchars(implode(', ', $display), ENT_QUOTES, $this->_charset);
-        }
-    }
-
-    protected function _renderVarDisplay_set($form, &$var, &$vars)
-    {
-        $values = $var->getValues();
-        $on = $var->getValue($vars);
-        if (!count($values) || !count($on)) {
-            return _("No values");
-        } else {
-            $display = array();
-            foreach ($values as $value => $name) {
-                if (in_array($value, $on)) {
-                    $display[] = $name;
-                }
-            }
-            return @htmlspecialchars(implode(', ', $display), ENT_QUOTES, $this->_charset);
-        }
-    }
-
-    protected function _renderVarDisplay_image($form, &$var, &$vars)
-    {
-        $image = $var->getValue($vars);
-
-        /* Check if existing image data is being loaded. */
-        $var->type->loadImageData($image);
-
-        if (empty($image['img'])) {
-            return '';
-        }
-
-        $img = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/images/view.php');
-        if (isset($image['img']['vfs_id'])) {
-            /* Calling an image from VFS. */
-            $img = Horde_Util::addParameter($img, array('f' => $image['img']['vfs_id'],
-                                                  's' => 'vfs',
-                                                  'p' => $image['img']['vfs_path']));
-        } else {
-            /* Calling an image from a tmp directory (uploads). */
-            $img = (string)Horde_Util::addParameter($img, 'f', $image['img']['file']);
-        }
-
-        return Horde::img($img, '', '', '');
-    }
-
-    protected function _renderVarDisplay_phone($form, &$var, &$vars)
-    {
-        global $registry;
-
-        $number = $var->getValue($vars);
-        $html = @htmlspecialchars($number, ENT_QUOTES, $this->_charset);
-
-        if ($number && $registry->hasMethod('telephony/dial')) {
-            $url = $registry->call('telephony/dial', array($number));
-            $label = sprintf(_("Dial %s"), $number);
-            $html .= ' ' . Horde::link($url, $label) . Horde::img('phone.png', $label) . '</a>';
-        }
-
-        return $html;
-    }
-
-    protected function _renderVarDisplay_cellphone($form, &$var, &$vars)
-    {
-        global $registry;
-
-        $html = $this->_renderVarDisplay_phone($form, $var, $vars);
-
-        $number = $var->getValue($vars);
-        if ($number && $registry->hasMethod('sms/compose')) {
-            $url = $registry->link('sms/compose', array('to' => $number));
-            $html .= ' ' . Horde::link($url, _("Send SMS")) . Horde::img('mobile.png', _("Send SMS")) . '</a>';
-        }
-
-        return $html;
-    }
-
-    protected function _renderVarDisplay_address($form, &$var, &$vars, $text = true)
-    {
-        global $registry;
-
-        $address = $var->getValue($vars);
-        if (empty($address)) {
-            return '';
-        }
-
-        $info = $var->type->parse($address);
-
-        $google_icon = 'map.png';
-        if (!empty($info['country'])) {
-            switch ($info['country']) {
-            case 'uk':
-                /* Multimap.co.uk generated map */
-                $mapurl = 'http://www.multimap.com/map/browse.cgi?pc='
-                    . urlencode($info['zip']);
-                $desc = _("Multimap UK map");
-                $icon = 'map.png';
-                break;
-
-            case 'au':
-                /* Whereis.com.au generated map */
-                $mapurl = 'http://www.whereis.com.au/whereis/mapping/geocodeAddress.do?';
-                $desc = _("Whereis Australia map");
-                $icon = 'map.png';
-                /* See if it's the street number & name. */
-                if (isset($info['streetNumber']) &&
-                    isset($info['streetName'])) {
-                    $mapurl .= '&streetNumber='
-                        . urlencode($info['streetNumber']) . '&streetName='
-                        . urlencode($info['streetName']);
-                }
-                /* Look for "Suburb, State". */
-                if (isset($info['city'])) {
-                    $mapurl .= '&suburb=' . urlencode($info['city']);
-                }
-                /* Look for "State <4 digit postcode>". */
-                if (isset($info['state'])) {
-                    $mapurl .= '&state=' . urlencode($info['state']);
-                }
-                break;
-
-            case 'us':
-            case 'ca':
-                /* American/Canadian address style. */
-                /* Mapquest generated map */
-                $mapurl = 'http://www.mapquest.com/maps/map.adp?size=big&zoom=7';
-                $desc = _("MapQuest map");
-                $icon = 'map.png';
-                if (!empty($info['street'])) {
-                    $mapurl .= '&address=' . urlencode($info['street']);
-                }
-                if (!empty($info['city'])) {
-                    $mapurl .= '&city=' . urlencode($info['city']);
-                }
-                if (!empty($info['state'])) {
-                    $mapurl .= '&state=' . urlencode($info['state']);
-                }
-                if (!empty($info['zip'])) {
-                    if ($info['country'] == 'ca') {
-                        $mapurl .= '&country=CA';
-                    }
-                    $mapurl .= '&zipcode=' . urlencode($info['zip']);
-                }
-
-                /* Yahoo! generated map. */
-                $mapurl2 = 'http://us.rd.yahoo.com/maps/home/submit_a/*-http://maps.yahoo.com/maps?srchtype=a&getmap=Get+Map&';
-                $desc2 = _("Yahoo! map");
-                $icon2 = 'map.png';
-                if (!empty($info['street'])) {
-                    $mapurl2 .= '&addr=' . urlencode($info['street']);
-                }
-                /* Give precedence to zipcode over city/state */
-                if (empty($info['zip']) &&
-                    !empty($info['city']) && !empty($info['state'])) {
-                    $mapurl2 .= '&csz='
-                        . urlencode($info['city'] . ' ' . $info['state']);
-                }
-                if (!empty($info['zip'])) {
-                    if (preg_match('|([a-zA-Z]\d[a-zA-Z])\s?(\d[a-zA-Z]\d)|', $info['zip'], $pcParts)) {
-                        $mapurl2 .= '&country=ca';
-                        /* make sure the postal-code has a space */
-                        $info['zip'] = $pcParts[1] . ' ' . $pcParts[2];
-                    }
-                    $mapurl2 .= '&csz=' . urlencode($info['zip']);
-                }
-                break;
-
-            default:
-                if (!count($info)) {
-                    break;
-                }
-                /* European address style. */
-                $google_icon = 'map_eu.png';
-                /* Mapquest generated map. */
-                $mapurl2 = 'http://www.mapquest.com/maps/map.adp?country=' . Horde_String::upper($info['country']);
-                $desc2 = _("MapQuest map");
-                $icon2 = 'map_eu.png';
-                if (!empty($info['street'])) {
-                    $mapurl2 .= '&address=' . urlencode($info['street']);
-                }
-                if (!empty($info['zip'])) {
-                    $mapurl2 .= '&zipcode=' . urlencode($info['zip']);
-                }
-                if (!empty($info['city'])) {
-                    $mapurl2 .= '&city=' . urlencode($info['city']);
-                }
-                break;
-            }
-        }
-
-        $html = $text ? nl2br(@htmlspecialchars($address, ENT_QUOTES, $this->_charset)) : '';
-        if (!empty($mapurl)) {
-            $html .= '&nbsp;&nbsp;' . Horde::link(Horde::externalUrl($mapurl), $desc, null, '_blank') . Horde::img($icon, $desc) . '</a>';
-        }
-        if (!empty($mapurl2)) {
-            $html .= '&nbsp;' . Horde::link(Horde::externalUrl($mapurl2), $desc2, null, '_blank') . Horde::img($icon2, $desc2) . '</a>';
-        }
-
-        /* Google generated map. */
-        if ($address) {
-            $html .= '&nbsp;' . Horde::link(Horde::externalUrl('http://maps.google.com/maps?q=' . urlencode(preg_replace('/\r?\n/', ',', $address)) . '&hl=en'), _("Google Maps"), null, '_blank') . Horde::img($google_icon, _("Google Maps")) . '</a>';
-        }
-
-        return $html;
-    }
-
-    protected function _renderVarDisplay_addresslink($form, &$var, &$vars)
-    {
-        return $this->_renderVarDisplay_address($form, $var, $vars, false);
-    }
-
-    protected function _renderVarDisplay_pgp($form, &$var, &$vars)
-    {
-        $key = $var->getValue($vars);
-        if (empty($key)) {
-            return '';
-        }
-        return '<pre>' .
-            $GLOBALS['injector']->getInstance('Horde_Crypt')->getCrypr('Pgp', $var->type->getPGPParams())->pgpPrettyKey($key) .
-            '</pre>';
-    }
-
-    protected function _renderVarDisplay_smime($form, &$var, &$vars)
-    {
-        $cert = $var->getValue($vars);
-        if (empty($cert)) {
-            return '';
-        }
-        return $GLOBALS['injector']->getInstance('Horde_Crypt')->getCrypt('Smime', $var->type->getSMIMEParams())->certToHTML($cert);
-    }
-
-    protected function _renderVarDisplay_country($form, &$var, &$vars)
-    {
-        return $this->_renderVarDisplay_enum($form, $var, $vars);
-    }
-
-    protected function _renderVarDisplay_date($form, &$var, &$vars)
-    {
-        return htmlspecialchars($var->type->getFormattedTime($var->getValue($vars)));
-    }
-
-    protected function _renderVarDisplay_hourminutesecond($form, &$var, &$vars)
-    {
-        $time = $var->type->getTimeParts($var->getValue($vars));
-        if (!$var->type->getProperty('show_seconds')) {
-            return (int)$time['hour'] . ':' . sprintf('%02d', (int)$time['minute']);
-        } else {
-            return (int)$time['hour'] . ':' . sprintf('%02d', (int)$time['minute']) . ':' . sprintf('%02d', (int)$time['second']);
-        }
-    }
-
-    protected function _renderVarDisplay_monthyear($form, &$var, &$vars)
-    {
-        return (int)$vars->get($var->getVarName() . '[month]') . ', ' . (int)$vars->get($var->getVarName() . '[year]');
-    }
-
-    protected function _renderVarDisplay_monthdayyear($form, &$var, &$vars)
-    {
-        $date = $var->getValue($vars);
-        if ((is_array($date) && !empty($date['year']) &&
-             !empty($date['month']) && !empty($date['day'])) ||
-            (!is_array($date) && !empty($date) && $date != '0000-00-00')) {
-            return $var->type->formatDate($date);
-        }
-        return '';
-    }
-
-    protected function _renderVarDisplay_datetime($form, &$var, &$vars)
-    {
-        return htmlspecialchars($var->type->formatDate($var->getValue($vars))) . Horde_Form_Type_date::getAgo($var->getValue($vars));
-    }
-
-    protected function _renderVarDisplay_invalid($form, &$var, &$vars)
-    {
-        return '<span class="form-error">' . @htmlspecialchars($var->type->message, ENT_QUOTES, $this->_charset) . '</span>';
-    }
-
-    protected function _renderVarDisplay_link($form, &$var, &$vars)
-    {
-        $values = $var->type->values;
-        if (!isset($values[0])) {
-            $values = array($values);
-        }
-
-        $count = count($values);
-        $html = '';
-        for ($i = 0; $i < $count; $i++) {
-            if (empty($values[$i]['url']) || empty($values[$i]['text'])) {
-                continue;
-            }
-            if (!isset($values[$i]['target'])) {
-                $values[$i]['target'] = '';
-            }
-            if (!isset($values[$i]['onclick'])) {
-                $values[$i]['onclick'] = '';
-            }
-            if (!isset($values[$i]['title'])) {
-                $values[$i]['title'] = '';
-            }
-            if (!isset($values[$i]['accesskey'])) {
-                $values[$i]['accesskey'] = '';
-            }
-            if ($i > 0) {
-                $html .= ' | ';
-            }
-            $html .= Horde::link($values[$i]['url'], $values[$i]['text'], 'widget', $values[$i]['target'], $values[$i]['onclick'], $values[$i]['title'], $values[$i]['accesskey']) . @htmlspecialchars($values[$i]['text'], ENT_QUOTES, $this->_charset) . '</a>';
-        }
-
-        return $html;
-    }
-
-    protected function _renderVarDisplay_dblookup($form, &$var, &$vars)
-    {
-        return $this->_renderVarDisplay_enum($form, $var, $vars);
-    }
-
-    protected function _renderVarDisplay_figlet($form, &$var, &$vars)
-    {
-        static $figlet;
-
-        if (!isset($figlet)) {
-            $figlet = new Text_Figlet();
-        }
-
-        $result = $figlet->loadFont($var->type->getFont());
-        if (is_a($result, 'PEAR_Error')) {
-            return $result->getMessage();
-        }
-
-        return '<pre>' . $figlet->lineEcho($var->type->getText()) . '</pre>';
-    }
-
-    protected function _renderVarDisplay_captcha($form, &$var, &$vars)
-    {
-        static $captcha;
-
-        if (!isset($captcha)) {
-            $captcha = Text_CAPTCHA::factory('Image');
-        }
-
-        $image = $captcha->init(150, 60, $var->type->getText(),
-                                array('font_path' => dirname($var->type->getFont()) . '/',
-                                      'font_file' => basename($var->type->getFont())));
-        if (is_a($image, 'PEAR_Error')) {
-            return $image->getMessage();
-        }
-
-        $cid = md5($var->type->getText());
-        $cache = $GLOBALS['injector']->getInstance('Horde_Cache');
-
-        $cache->set($cid, serialize(array('data' => $captcha->getCAPTCHAAsJPEG(),
-                                          'ctype' => 'image/jpeg')));
-
-        $url = Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/cacheview.php');
-        $url = Horde_Util::addParameter($url, 'cid', $cid, false);
-
-        return '<img src="' . $url . '" />';
-
-    }
-
-    protected function _renderVarInput_selectFiles($form, &$var, &$vars)
-    {
-        /* Needed for gollem js calls */
-        $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
-        $html = sprintf('<input type="hidden" name="%s" id="%s" value="%s" />',
-                        'selectlist_selectid',
-                        'selectlist_selectid',
-                        $var->type->getProperty('selectid')) .
-            sprintf('<input type="hidden" name="%s" id="%s" />', 'actionID', 'actionID') .
-
-            /* Form field. */
-            sprintf('<input type="hidden" name="%s" id="%s" value="%s" />',
-                    $varname,
-                    $varname,
-                    $var->type->getProperty('selectid'));
-
-        /* Open window link. */
-        $param = array($var->type->getProperty('link_text'),
-                       $var->type->getProperty('link_style'),
-                       $form->getName(),
-                       $var->type->getProperty('icon'),
-                       $var->type->getProperty('selectid'));
-        $html .= $GLOBALS['registry']->call('files/selectlistLink', $param) . "<br />\n";
-
-        if ($var->type->getProperty('selectid')) {
-            $param = array($var->type->getProperty('selectid'));
-            $files = $GLOBALS['registry']->call('files/selectlistResults', $param);
-            if ($files) {
-                $html .= '<ol>';
-                foreach ($files as $id => $file) {
-                    $dir = key($file);
-                    $filename = current($file);
-                    if ($GLOBALS['registry']->hasMethod('files/getViewLink')) {
-                        $filename = basename($filename);
-                        $url = $GLOBALS['registry']->call('files/getViewLink', array($dir, $filename));
-                        $filename = Horde::link($url, _("Preview"), null, 'form_file_view') . @htmlspecialchars(Horde_Util::realPath($dir . '/' . $filename), ENT_QUOTES, $this->_charset) . '</a>';
-                    } else {
-                        if (!empty($dir) && ($dir != '.')) {
-                            $filename = $dir . '/' . $filename;
-                        }
-                        $filename = @htmlspecialchars($filename, ENT_QUOTES, $this->_charset);
-                    }
-                    $html .= '<li>' . $filename . "</li>\n";
-                }
-                $html .= '</ol>';
-            }
-        }
-
-        return $html;
-    }
-
-    protected function _renderVarInput_category($form, &$var, &$vars)
-    {
-        Horde::addScriptFile('form_helpers.js', 'horde');
-        $this->_addOnLoadJavascript('addEvent(document.getElementById(\'' . $form->getName() . '\'), \'submit\', checkCategory);');
-        return '<input type="hidden" name="new_category" />'
-            . Horde_Prefs_CategoryManager::getJavaScript($form->getName(), $var->getVarName())
-            . Horde_Prefs_CategoryManager::getSelect($var->getVarName(), $var->getValue($vars));
-    }
-
-    public function selectOptions(&$values, $selectedValue = false,
-                                  $htmlchars = false)
-    {
-        $result = '';
-        $sel = false;
-        foreach ($values as $value => $display) {
-            if (!is_null($selectedValue) && !$sel &&
-                $value == $selectedValue &&
-                strlen($value) == strlen($selectedValue)) {
-                $selected = ' selected="selected"';
-                $sel = true;
-            } else {
-                $selected = '';
-            }
-            $result .= ' <option value="';
-            $result .= $htmlchars
-                ? $value
-                : @htmlspecialchars($value, ENT_QUOTES, $this->_charset);
-            $result .= '"' . $selected . '>';
-            $result .= $htmlchars
-                ? $display
-                : @htmlspecialchars($display, ENT_QUOTES, $this->_charset);
-            $result .= "</option>\n";
-        }
-
-        return $result;
-    }
-
-    protected function _multiSelectOptions(&$values, $selectedValues)
-    {
-        if (!is_array($selectedValues)) {
-            $selectedValues = array();
-        } else {
-            $selectedValues = array_flip($selectedValues);
-        }
-
-        $result = '';
-        $sel = false;
-        foreach ($values as $value => $display) {
-            if (isset($selectedValues[$value])) {
-                $selected = ' selected="selected"';
-            } else {
-                $selected = '';
-            }
-            $result .= " <option value=\"" . @htmlspecialchars($value, ENT_QUOTES, $this->_charset) . "\"$selected>" . @htmlspecialchars($display, ENT_QUOTES, $this->_charset) . "</option>\n";
-        }
-
-        return $result;
-    }
-
-    protected function _checkBoxes($name, $values, $checkedValues, $actions = '')
-    {
-        $result = '';
-        if (!is_array($checkedValues)) {
-            $checkedValues = array();
-        }
-        $i = 0;
-        foreach ($values as $value => $display) {
-            $checked = (in_array($value, $checkedValues)) ? ' checked="checked"' : '';
-            $result .= sprintf('<input id="%s%s" type="checkbox" class="checkbox" name="%s[]" value="%s"%s%s /><label for="%s%s">&nbsp;%s</label><br />',
-                               @htmlspecialchars($name, ENT_QUOTES, $this->_charset),
-                               $i,
-                               @htmlspecialchars($name, ENT_QUOTES, $this->_charset),
-                               @htmlspecialchars($value, ENT_QUOTES, $this->_charset),
-                               $checked,
-                               $actions,
-                               @htmlspecialchars($name, ENT_QUOTES, $this->_charset),
-                               $i,
-                               @htmlspecialchars($display, ENT_QUOTES, $this->_charset));
-            $i++;
-        }
-
-        return $result;
-    }
-
-    protected function _radioButtons($name, $values, $checkedValue = null, $actions = '')
-    {
-        $result = '';
-        $i = 0;
-        foreach ($values as $value => $display) {
-            $checked = (!is_null($checkedValue) && $value == $checkedValue) ? ' checked="checked"' : '';
-            $result .= sprintf('<input id="%s%s" type="radio" class="checkbox" name="%s" value="%s"%s%s /><label for="%s%s">&nbsp;%s</label><br />',
-                               @htmlspecialchars($name, ENT_QUOTES, $this->_charset),
-                               $i,
-                               @htmlspecialchars($name, ENT_QUOTES, $this->_charset),
-                               @htmlspecialchars($value, ENT_QUOTES, $this->_charset),
-                               $checked,
-                               $actions,
-                               @htmlspecialchars($name, ENT_QUOTES, $this->_charset),
-                               $i,
-                               @htmlspecialchars($display, ENT_QUOTES, $this->_charset));
-            $i++;
-        }
-
-        return $result;
-    }
-
-    protected function _genID($name, $fulltag = true)
-    {
-        $name = @htmlspecialchars($name, ENT_QUOTES, $this->_charset);
-        return $fulltag ? 'id="' . $name . '"' : $name;
-    }
-
-    protected function _genActionScript($form, $action, $varname)
-    {
-        $html = '';
-        $triggers = $action->getTrigger();
-        if (!is_array($triggers)) {
-            $triggers = array($triggers);
-        }
-        $js = $action->getActionScript($form, $this, $varname);
-        foreach ($triggers as $trigger) {
-            if ($trigger == 'onload') {
-                $this->_addOnLoadJavascript($js);
-            } else {
-                $html .= ' ' . $trigger . '="' . $js . '"';
-            }
-        }
-        return $html;
-    }
-
-    protected function _getActionScripts($form, &$var)
-    {
-        $actions = '';
-        if ($var->hasAction()) {
-            $varname = $var->getVarName();
-            $action = &$var->_action;
-            $triggers = $action->getTrigger();
-            if (!is_array($triggers)) {
-                $triggers = array($triggers);
-            }
-            $js = $action->getActionScript($form, $this, $varname);
-            foreach ($triggers as $trigger) {
-                if ($trigger == 'onload') {
-                    $this->_addOnLoadJavascript($js);
-                } else {
-                    $actions .= ' ' . $trigger . '="' . $js . '"';
-                }
-            }
-        }
-        return $actions;
-    }
-
-    protected function _addOnLoadJavascript($script)
-    {
-        $this->_onLoadJS[] = $script;
-    }
-
-    public function renderEnd()
-    {
-        if (count($this->_onLoadJS)) {
-            return "<script type=\"text/javascript\">" .
-                "<!--\n" .  implode("\n", $this->_onLoadJS) . "\n// -->\n" .
-                "</script>";
-        } else {
-            return '';
-        }
-    }
-
-}
diff --git a/framework/Ui/lib/Horde/Ui/VarRenderer/TablesetHtml.php b/framework/Ui/lib/Horde/Ui/VarRenderer/TablesetHtml.php
deleted file mode 100644 (file)
index 057888c..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-<?php
-/**
- * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @package Horde_Ui
- */
-class Horde_Ui_VarRenderer_TablesetHtml extends Horde_Ui_VarRenderer_Html
-{
-    protected function _renderVarInput_tableset($form, &$var, &$vars)
-    {
-        $header = $var->type->getHeader();
-        $name   = $var->getVarName();
-        $values = $var->getValues();
-        $form_name = $form->getName();
-        $var_name = $var->getVarName() . '[]';
-        $checkedValues = $var->getValue($vars);
-        $actions = $this->_getActionScripts($form, $var);
-        $function_name = 'select'  . $form_name . $var->getVarName();
-        $enable = _("Select all");
-        $disable = _("Select none");
-        $invert = _("Invert selection");
-
-        Horde::addScriptFile('tables.js', 'horde');
-
-        $html = <<<EOT
-<script type="text/javascript">
-function $function_name()
-{
-    for (var i = 0; i < document.$form_name.elements.length; i++) {
-        f = document.$form_name.elements[i];
-        if (f.name != '$var_name') {
-            continue;
-        }
-        if (arguments.length) {
-            f.checked = arguments[0];
-        } else {
-            f.checked = !f.checked;
-        }
-    }
-}
-</script>
-<a href="#" onclick="$function_name(true); return false;">$enable</a>,
-<a href="#" onclick="$function_name(false); return false;">$disable</a>,
-<a href="#" onclick="$function_name(); return false;">$invert</a>
-<table style="width: 100%" class="sortable striped" id="tableset_' . $name . '"><thead><tr>
-<th>&nbsp;</th>
-EOT;
-
-        foreach ($header as $col_title) {
-            $html .= sprintf('<th class="leftAlign">%s</th>', $col_title);
-        }
-        $html .= '</tr></thead>';
-
-        if (!is_array($checkedValues)) {
-            $checkedValues = array();
-        }
-        $i = 0;
-        foreach ($values as $value => $displays) {
-            $checked = (in_array($value, $checkedValues)) ? ' checked="checked"' : '';
-            $html .= '<tr>' .
-                sprintf('<td style="text-align: center"><input id="%s[]" type="checkbox" name="%s[]" value="%s"%s%s /></td>',
-                        $name,
-                        $name,
-                        $value,
-                        $checked,
-                        $actions);
-            foreach ($displays as $col) {
-                $html .= sprintf('<td>&nbsp;%s</td>', $col);
-            }
-            $html .= '</tr>' . "\n";
-            $i++;
-        }
-
-        $html .= '</table>'
-              . '<a href="#" onclick="' . $function_name . '(true); return false;">' . $enable . '</a>, '
-              . '<a href="#" onclick="' . $function_name . '(false); return false;">' . $disable . '</a>, '
-              . '<a href="#" onclick="' . $function_name . '(); return false;">' . $invert . '</a>';
-
-        return $html;
-    }
-
-    protected function _renderVarDisplay_tableset($form, &$var, &$vars)
-    {
-        $header = $var->type->getHeader();
-        $name   = $var->getVarName();
-        $values = $var->getValues();
-        $checkedValues = $var->getValue($vars);
-        $actions = $this->_getActionScripts($form, $var);
-
-        Horde::addScriptFile('tables.js', 'horde');
-        $html = '<table style="width: 100%" class="sortable striped" id="tableset_' . $name . '"><thead><tr>' .
-            '<th>&nbsp;</th>';
-        foreach ($header as $col_title) {
-            $html .= sprintf('<th class="leftAlign">%s</th>', $col_title);
-        }
-        $html .= '</tr></thead>';
-
-        if (!is_array($checkedValues)) {
-            $checkedValues = array();
-        }
-        $i = 0;
-        foreach ($values as $value => $displays) {
-            $checked = '[ <span style="font-weight: bold; color: '
-                . (in_array($value, $checkedValues)) ? ' green">V' : 'red">X'
-                . '</span> ]';
-            $html .= '<tr>'.
-                sprintf('<td style="text-align: center">%s</td>', $checked);
-            foreach ($displays as $col) {
-                $html .= '<td>&nbsp;' . $col . '</td>';
-            }
-            $html .= '</tr>';
-            $i++;
-        }
-
-        return $html . '</table>';
-    }
-
-}
diff --git a/framework/Ui/lib/Horde/Ui/Widget.php b/framework/Ui/lib/Horde/Ui/Widget.php
deleted file mode 100644 (file)
index feeafc1..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-<?php
-/**
- * The Horde_Ui_Widget:: class provides base functionality for other Horde
- * UI elements.
- *
- * Copyright 2003-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author  Jason M. Felice <jason.m.felice@gmail.com>
- * @package Horde_Ui
- */
-abstract class Horde_Ui_Widget
-{
-    /**
-     * Any variables that should be preserved in all of the widget's
-     * links.
-     *
-     * @var array
-     */
-    protected $_preserve = array();
-
-    /**
-     * The name of this widget.  This is used as the basename for variables
-     * we access and manipulate.
-     *
-     * @var string
-     */
-    protected $_name;
-
-    /**
-     * A reference to a Horde_Variables:: object this widget will use and
-     * manipulate.
-     *
-     * @var Horde_Variables
-     */
-    protected $_vars;
-
-    /**
-     * An array of name => value pairs which configure how this widget
-     * behaves.
-     *
-     * @var array
-     */
-    protected $_config;
-
-    /**
-     * Holds the name of a callback function to call on any URLS before they
-     * are used/returned. If an array, it is taken as an object/method name, if
-     * a string, it is taken as a php function.
-     *
-     * @var callable
-     */
-    protected $_url_callback = array('Horde', 'applicationUrl');
-
-    /**
-     * Construct a new UI Widget interface.
-     *
-     * @param string $name            The name of the variable which will
-     *                                track this UI widget's state.
-     * @param Horde_Variables &$vars  A Horde_Variables:: object.
-     * @param array $config           The widget's configuration.
-     */
-    public function __construct($name, &$vars, $config = array())
-    {
-        $this->_name = $name;
-        $this->_vars = &$vars;
-
-        if (array_key_exists('url_callback', $config)) {
-            $this->_url_callback = $config['url_callback'];
-            unset($config['url_callback']);
-        }
-        $this->_config = $config;
-    }
-
-    /**
-     * Instructs widget to preserve a variable or a set of variables.
-     *
-     * @param string|array $var  The name of the variable to preserve, or
-     *                           an array of variables to preserve.
-     * @param mixed $value       If preserving a single key, the value of the
-     *                           variable to preserve.
-     */
-    public function preserve($var, $value = null)
-    {
-        if (!is_array($var)) {
-            $var = array($var => $value);
-        }
-
-        foreach ($var as $key => $value) {
-            $this->_preserve[$key] = $value;
-        }
-    }
-
-    /**
-     * TODO
-     */
-    protected function _addPreserved($link)
-    {
-        foreach ($this->_preserve as $varName => $varValue) {
-            $link->add($varName, $varValue);
-        }
-
-        return $link;
-    }
-
-    /**
-     * Render the widget.
-     *
-     * @param mixed $data  The widget's state data.
-     */
-    abstract public function render($data = null);
-
-    /**
-     * TODO
-     */
-    protected function _link($link)
-    {
-        if (is_callable($this->_url_callback)) {
-            return call_user_func($this->_url_callback, $link);
-        }
-
-        return $link;
-    }
-
-}
diff --git a/framework/Ui/package.xml b/framework/Ui/package.xml
deleted file mode 100644 (file)
index bcd189e..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<package packagerversion="1.4.9" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
-http://pear.php.net/dtd/tasks-1.0.xsd
-http://pear.php.net/dtd/package-2.0
-http://pear.php.net/dtd/package-2.0.xsd">
- <name>Ui</name>
- <channel>pear.horde.org</channel>
- <summary>Horde&apos;s User Interface Classes</summary>
- <description>The Horde_Ui package provides several classes for handling UI elements in Horde.
- </description>
- <lead>
-  <name>Chuck Hagenbuch</name>
-  <user>chuck</user>
-  <email>chuck@horde.org</email>
-  <active>yes</active>
- </lead>
- <developer>
-  <name>Jay Felice</name>
-  <user>eraserhd</user>
-  <email>jason.m.felice@gmail.com</email>
-  <active>yes</active>
- </developer>
- <date>2009-11-19</date>
- <version>
-  <release>0.1.0</release>
-  <api>0.1.0</api>
- </version>
- <stability>
-  <release>beta</release>
-  <api>beta</api>
- </stability>
- <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>* Added Horde_Ui_FlagImage::.
- * Initial Horde 4 package.
- </notes>
- <contents>
-  <dir name="/">
-   <dir name="lib">
-    <dir name="Horde">
-     <dir name="Ui">
-      <dir name="VarRenderer">
-       <file name="Html.php" role="php" />
-       <file name="TablesetHtml.php" role="php" />
-      </dir> <!-- /lib/Horde/Ui/VarRenderer -->
-      <file name="FlagImage.php" role="php" />
-      <file name="JsCalendar.php" role="php" />
-      <file name="Language.php" role="php" />
-      <file name="Pager.php" role="php" />
-      <file name="Tabs.php" role="php" />
-      <file name="TagCloud.php" role="php" />
-      <file name="VarRenderer.php" role="php" />
-      <file name="Widget.php" role="php" />
-     </dir> <!-- /lib/Horde/Ui -->
-    </dir> <!-- /lib/Horde -->
-   </dir> <!-- /lib -->
-  </dir> <!-- / -->
- </contents>
- <dependencies>
-  <required>
-   <php>
-    <min>5.2.0</min>
-   </php>
-   <pearinstaller>
-    <min>1.7.0</min>
-   </pearinstaller>
-   <package>
-    <name>Core</name>
-    <channel>pear.horde.org</channel>
-   </package>
-   <package>
-    <name>Nls</name>
-    <channel>pear.horde.org</channel>
-   </package>
-  </required>
- </dependencies>
- <phprelease>
-  <filelist>
-   <install name="lib/Horde/Ui/VarRenderer/Html.php" as="Horde/Ui/VarRenderer/Html.php" />
-   <install name="lib/Horde/Ui/VarRenderer/TablesetHtml.php" as="Horde/Ui/VarRenderer/TablesetHtml.php" />
-   <install name="lib/Horde/Ui/FlagImage.php" as="Horde/Ui/FlagImage.php" />
-   <install name="lib/Horde/Ui/JsCalendar.php" as="Horde/Ui/JsCalendar.php" />
-   <install name="lib/Horde/Ui/Language.php" as="Horde/Ui/Language.php" />
-   <install name="lib/Horde/Ui/Pager.php" as="Horde/Ui/Pager.php" />
-   <install name="lib/Horde/Ui/Tabs.php" as="Horde/Ui/Tabs.php" />
-   <install name="lib/Horde/Ui/TagCloud.php" as="Horde/Ui/TagCloud.php" />
-   <install name="lib/Horde/Ui/VarRenderer.php" as="Horde/Ui/VarRenderer.php" />
-   <install name="lib/Horde/Ui/Widget.php" as="Horde/Ui/Widget.php" />
-  </filelist>
- </phprelease>
- <changelog>
-  <release>
-   <version>
-    <release>0.0.2</release>
-    <api>0.0.2</api>
-   </version>
-   <stability>
-    <release>alpha</release>
-    <api>alpha</api>
-   </stability>
-   <date>2006-05-08</date>
-   <time>23:54:10</time>
-   <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
-   <notes>* Added Horde_UI_JsCalendar::.
-   * Converted to package.xml 2.0 for pear.horde.org
-   </notes>
-  </release>
-  <release>
-   <version>
-    <release>0.0.1</release>
-    <api>0.0.1</api>
-   </version>
-   <stability>
-    <release>alpha</release>
-    <api>alpha</api>
-   </stability>
-   <date>2003-11-14</date>
-   <license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
-   <notes>Initial release as a PEAR package
-   </notes>
-  </release>
- </changelog>
-</package>
index 00df09a..a03075c 100644 (file)
@@ -455,7 +455,7 @@ if (is_array($list) && $numitem && $read_perms) {
 
         $vars = Horde_Variables::getDefaultVariables();
         $vars->set('page', $page);
-        $pager = new Horde_Ui_Pager('page', $vars, array('num' => $total, 'url' => $refresh_url, 'page_count' => 10, 'perpage' => $perpage));
+        $pager = new Horde_Core_Ui_Pager('page', $vars, array('num' => $total, 'url' => $refresh_url, 'page_count' => 10, 'perpage' => $perpage));
         $page_caption = $pager->render();
     }
 
index c42f944..af45441 100644 (file)
@@ -218,7 +218,7 @@ class Hermes {
     {
         /* Build search mode tabs. */
         $sUrl = Horde::selfUrl();
-        $tabs = new Horde_Ui_Tabs('search_mode', Horde_Variables::getDefaultVariables());
+        $tabs = new Horde_Core_Ui_Tabs('search_mode', Horde_Variables::getDefaultVariables());
         $tabs->addTab(_("Summary"), $sUrl, 'summary');
         $tabs->addTab(_("By Date"), $sUrl, 'date');
         $tabs->addTab(_("By Employee"), $sUrl, 'employee');
index 7286290..1e3eb78 100644 (file)
@@ -7,10 +7,8 @@
  *
  * See the enclosed file LICENSE for license information (BSD). If you
  * did not receive this file, see http://www.horde.org/licenses/bsdl.php.
- *
- * @package Horde_Ui
  */
-class Horde_Ui_Table extends Horde_Ui_Widget {
+class Horde_Core_Ui_Table extends Horde_Core_Ui_Widget {
 
     /**
      * Data loaded from the getTableMetaData API.
@@ -120,7 +118,7 @@ class Horde_Ui_Table extends Horde_Ui_Widget {
             return false;
         }
 
-        $varRenderer = new Horde_Ui_VarRenderer_Html();
+        $varRenderer = new Horde_Core_Ui_VarRenderer_Html();
 
         $html = '<h1 class="header">';
 
@@ -180,7 +178,7 @@ class Horde_Ui_Table extends Horde_Ui_Widget {
             $html .= ($secname == 'footer') ? '<tfoot>' : '<tbody>';
 
             /* This Horde_Variables object is populated for each table row
-             * so that we can use the Horde_Ui_VarRenderer. */
+             * so that we can use the Horde_Core_Ui_VarRenderer. */
             $vars = new Horde_Variables();
             $form = null;
             foreach ($data[$secname] as $row) {
index dc0bde0..33d3e89 100644 (file)
@@ -110,7 +110,7 @@ if (isset($_SESSION['hermes_search_criteria'])) {
         $criteria = $form->getSearchCriteria($searchVars);
     }
 
-    $table = new Horde_Ui_Table('results', $vars,
+    $table = new Horde_Core_Ui_Table('results', $vars,
                                 array('title' => _("Search Results"),
                                       'name' => 'hermes/hours',
                                       'params' => $criteria));
index 415125b..2e389c9 100644 (file)
@@ -57,7 +57,7 @@ $tabs = Hermes::tabs();
 $criteria = array('employee' => $GLOBALS['registry']->getAuth(),
                   'submitted' => false,
                   'link_page' => 'time.php');
-$table = new Horde_Ui_Table('week', $vars,
+$table = new Horde_Core_Ui_Table('week', $vars,
                             array('title' => _("My Unsubmitted Time"),
                                   'name' => 'hermes/hours',
                                   'params' => $criteria));
index d64b752..1116744 100644 (file)
@@ -47,7 +47,7 @@ try {
             } else {
                 $host = @gethostbyaddr($data['remoteAddr']);
             }
-            $entry[_("Remote Host:")] = $host . ' [' . $data['remoteAddr'] . '] ' . Horde_Ui_FlagImage::generateFlagImageByHost($host);
+            $entry[_("Remote Host:")] = $host . ' [' . $data['remoteAddr'] . '] ' . Horde_Core_Ui_FlagImage::generateFlagImageByHost($host);
         }
 
         echo '<li><div class="sesstoggle">' . $plus . $minus . htmlspecialchars($data['userid']) . ' [' . htmlspecialchars($id) . ']'
index d991560..fab6d04 100644 (file)
@@ -32,7 +32,7 @@ class Horde_Block_Horde_cloud extends Horde_Block
     {
         Horde::addScriptFile('prototype.js', 'horde');
 
-        $cloud = new Horde_Ui_TagCloud();
+        $cloud = new Horde_Core_Ui_TagCloud();
         foreach ($this->_getTags() as $tag) {
             $cloud->addElement($tag['tag_name'], '#', $tag['total'],
                                null,
index d1a362c..b3bdbdc 100644 (file)
@@ -66,7 +66,7 @@ case 'sidebar':
     }
 
     /* Generate Tabs */
-    $tabs = new Horde_Ui_Tabs('side_show', $vars);
+    $tabs = new Horde_Core_Ui_Tabs('side_show', $vars);
     $tabs->addTab(_("Help _Topics"), $sidebar_url, 'index');
     $tabs->addTab(_("Sea_rch"), $sidebar_url, 'search');
 
index de858d0..a503f03 100644 (file)
@@ -38,7 +38,7 @@ foreach ($users as $user):
 </table>
 <?php
 if ($numitem) {
-    $pager = new Horde_Ui_Pager('page', $vars, array('num' => $total, 'url' => $viewurl, 'page_count' => 10, 'perpage' => $perpage));
+    $pager = new Horde_Core_Ui_Pager('page', $vars, array('num' => $total, 'url' => $viewurl, 'page_count' => 10, 'perpage' => $perpage));
     echo $pager->render($page, $total, $viewurl);
 }
 ?>
index 0dc7682..750c831 100644 (file)
@@ -249,14 +249,14 @@ if ($origin_host) {
         $origin_host = array($origin_host);
     }
     foreach ($origin_host as $host) {
-        $from_img .= Horde_Ui_FlagImage::generateFlagImageByHost($host) . ' ';
+        $from_img .= Horde_Core_Ui_FlagImage::generateFlagImageByHost($host) . ' ';
     }
     trim($from_img);
 }
 
 if (empty($from_img) && !empty($envelope['from'])) {
     $from_ob = reset($envelope['from']);
-    $from_img .= Horde_Ui_FlagImage::generateFlagImageByHost($from_ob['host']) . ' ';
+    $from_img .= Horde_Core_Ui_FlagImage::generateFlagImageByHost($from_ob['host']) . ' ';
 }
 
 if (!empty($from_img)) {
index 69e747c..eb7763b 100644 (file)
@@ -179,7 +179,7 @@ foreach ($imp_search->flagFields() as $key => $val) {
 }
 $t->set('f_fields', $f_fields);
 
-Horde_Ui_JsCalendar::init();
+Horde_Core_Ui_JsCalendar::init();
 
 /* Gettext strings for this page. */
 $gettext_strings = array(
@@ -198,7 +198,7 @@ $gettext_strings = array(
 
 /* Javascript data for this page. */
 $js_data = array(
-    'months' => Horde_Ui_JsCalendar::months(),
+    'months' => Horde_Core_Ui_JsCalendar::months(),
     'searchmbox' => $search_mailbox,
     'types' => $types
 );
index f553e61..3635d0d 100644 (file)
@@ -11,7 +11,7 @@
  * @author  Jan Schneider <jan@horde.org>
  * @package Ingo
  */
-class Horde_Ui_VarRenderer_Ingo extends Horde_Ui_VarRenderer_Html
+class Horde_Core_Ui_VarRenderer_Ingo extends Horde_Core_Ui_VarRenderer_Html
 {
     protected function _renderVarInput_ingo_folders(&$form, &$var, &$vars)
     {
index 3d682e9..999404e 100644 (file)
@@ -17,7 +17,7 @@ Horde_Registry::appInit('ingo');
 /**
  * Dummy class to hold the select box created by {@link Ingo::flistSelect()}.
  *
- * @see Horde_Ui_VarRenderer_Ingo
+ * @see Horde_Core_Ui_VarRenderer_Ingo
  * @see Ingo::flistSelect()
  */
 class Horde_Form_Type_ingo_folders extends Horde_Form_Type {
index 2cf1c1a..e0fe33b 100644 (file)
@@ -40,7 +40,7 @@ class Horde_Block_jonah_cloud extends Horde_Block {
         /* Get the tags */
         $tags = $news->listTagInfo();
         if (count($tags)) {
-            $cloud = new Horde_Ui_TagCloud();
+            $cloud = new Horde_Core_Ui_TagCloud();
             foreach ($tags as $id => $tag) {
                 $cloud->addElement($tag['tag_name'], str_replace(array('@id@', '@tag@'), array($id, $tag['tag_name']), $this->_params['results_url']), $tag['total']);
             }
index 62e2061..994d42f 100644 (file)
@@ -41,7 +41,7 @@ if (is_a($story, 'PEAR_Error')) {
 }
 
 /* Grab tag related content for entire channel */
-$cloud = new Horde_Ui_TagCloud();
+$cloud = new Horde_Core_Ui_TagCloud();
 $allTags = $news->listTagInfo(array(), $channel_id);
 foreach ($allTags as $tag_id => $taginfo) {
     $cloud->addElement($taginfo['tag_name'], Horde_Util::addParameter('results.php', array('tag_id' => $tag_id, 'channel_id' => $channel_id)), $taginfo['total']);
index cd73b43..a22cf2b 100644 (file)
@@ -65,7 +65,7 @@ class ObjectController extends Koward_Controller_Application
             }
         }
 
-        $this->tabs = new Horde_Ui_Tabs(null, Horde_Variables::getDefaultVariables());
+        $this->tabs = new Horde_Core_Ui_Tabs(null, Horde_Variables::getDefaultVariables());
         foreach ($this->koward->objects as $key => $configuration) {
             if (!$this->koward->hasAccess($this->getPermissionId() . '/' . $key)) {
                 continue;
index 6ba870a..be23be6 100644 (file)
@@ -182,7 +182,7 @@ $delimg = Horde::img('delete.png', _("Remove Attendee"));
 $ident = $injector->getInstance('Horde_Prefs_Identity')->getIdentity();
 $identities = $ident->getAll('id');
 $vars = Horde_Variables::getDefaultVariables();
-$tabs = new Horde_Ui_Tabs(null, $vars);
+$tabs = new Horde_Core_Ui_Tabs(null, $vars);
 $tabs->addTab(_("Day"), new Horde_Url('javascript:switchView(\'Day\')'), 'Day');
 $tabs->addTab(_("Work Week"), new Horde_Url('javascript:switchView(\'Workweek\')'), 'Workweek');
 $tabs->addTab(_("Week"), new Horde_Url('javascript:switchView(\'Week\')'), 'Week');
index 19cb5a1..9d53774 100644 (file)
@@ -230,7 +230,7 @@ abstract class Kronolith_Event
     /**
      * The VarRenderer class to use for printing select elements.
      *
-     * @var Horde_Ui_VarRenderer
+     * @var Horde_Core_Ui_VarRenderer
      */
     private $_varRenderer;
 
@@ -2531,7 +2531,7 @@ abstract class Kronolith_Event
         }
 
         if (!$this->_varRenderer) {
-            $this->_varRenderer = Horde_Ui_VarRenderer::factory('Html');
+            $this->_varRenderer = Horde_Core_Ui_VarRenderer::factory('Html');
         }
 
         return '<label for="' . $this->_formIDEncode($property) . '" class="hidden">' . $label . '</label>' .
index 4101611..16172df 100644 (file)
@@ -76,7 +76,7 @@ class Kronolith
         Horde::addScriptFile('date/' . $datejs, 'horde');
         Horde::addScriptFile('date/date.js', 'horde');
         Horde::addScriptFile('kronolith.js', 'kronolith');
-        Horde_Ui_JsCalendar::init(array('short_weekdays' => true));
+        Horde_Core_Ui_JsCalendar::init(array('short_weekdays' => true));
 
         if (isset($GLOBALS['language'])) {
             header('Content-type: text/html; charset=' . $GLOBALS['registry']->getCharset());
@@ -2527,7 +2527,7 @@ class Kronolith
         $date = self::currentDate();
         $date_stamp = $date->dateString();
 
-        $tabs = new Horde_Ui_Tabs('view', Horde_Variables::getDefaultVariables());
+        $tabs = new Horde_Core_Ui_Tabs('view', Horde_Variables::getDefaultVariables());
         $tabs->preserve('date', $date_stamp);
 
         $tabs->addTab(_("Day"), Horde::applicationUrl('day.php'),
@@ -2557,7 +2557,7 @@ class Kronolith
             return;
         }
 
-        $tabs = new Horde_Ui_Tabs('event', Horde_Variables::getDefaultVariables());
+        $tabs = new Horde_Core_Ui_Tabs('event', Horde_Variables::getDefaultVariables());
 
         $date = self::currentDate();
         $tabs->preserve('datetime', $date->dateString());
index 8d22477..016e616 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /**
- * This file contains all Horde_Ui_VarRenderer extensions required for editing
- * tasks.
+ * This file contains all Horde_Core_Ui_VarRenderer extensions required for
+ * editing tasks.
  *
  * See the enclosed file COPYING for license information (GPL). If you
  * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
  */
 
 /**
- * The Horde_Ui_VarRenderer_Nag class provides additional methods for
+ * The Horde_Core_Ui_VarRenderer_Nag class provides additional methods for
  * rendering Nag specific fields.
  *
  * @todo    Clean this hack up with Horde_Form/H4
  * @author  Jan Schneider <jan@horde.org>
  * @package Nag
  */
-class Horde_Ui_VarRenderer_Nag extends Horde_Ui_VarRenderer_Html
+class Horde_Core_Ui_VarRenderer_Nag extends Horde_Core_Ui_VarRenderer_Html
 {
     protected function _renderVarInput_nag_method($form, $var, $vars)
     {
index d0df3a8..763667b 100644 (file)
@@ -95,7 +95,7 @@ echo '<div id="page">';
 
 if (!$prefs->isLocked('show_completed')) {
     $listurl = Horde::applicationUrl('list.php');
-    $tabs = new Horde_Ui_Tabs('show_completed', $vars);
+    $tabs = new Horde_Core_Ui_Tabs('show_completed', $vars);
     $tabs->addTab(_("_All tasks"), $listurl, Nag::VIEW_ALL);
     $tabs->addTab(_("Incom_plete tasks"), $listurl, Nag::VIEW_INCOMPLETE);
     $tabs->addTab(_("_Future tasks"), $listurl, Nag::VIEW_FUTURE);
index bda8b0d..f5d715d 100644 (file)
@@ -17,7 +17,7 @@ if (!$registry->isAdmin(array('permission' => 'news:admin'))) {
 }
 
 $vars = Horde_Variables::getDefaultVariables();
-$tabs = new Horde_Ui_Tabs('admin', $vars);
+$tabs = new Horde_Core_Ui_Tabs('admin', $vars);
 
 $tabs->addTab(_("Sources"), Horde::applicationUrl('admin/sources/index.php'), 'sources');
 $tabs->addTab(_("Categories"), Horde::applicationUrl('admin/categories/index.php'), 'categories');
index 85059a1..97cb035 100644 (file)
@@ -60,7 +60,7 @@ class News_Search extends Horde_Form {
      */
     public function getPager($info, $count, $url)
     {
-        $pager = new Horde_Ui_Pager('news_page',
+        $pager = new Horde_Core_Ui_Pager('news_page',
                                     Horde_Variables::getDefaultVariables(),
                                     array('num' => $count,
                                           'url' => $url,
index 969d247..2d4e761 100644 (file)
@@ -62,7 +62,7 @@ class News_Search extends Horde_Form {
      */
     static public function getPager($info, $count, $url)
     {
-        $pager = new Horde_Ui_Pager('news_page',
+        $pager = new Horde_Core_Ui_Pager('news_page',
                                     Horde_Variables::getDefaultVariables(),
                                     array('num' => $count,
                                           'url' => $url,
index 5c540e4..2bb1652 100644 (file)
@@ -12,7 +12,7 @@
  * @author  Duck <duck@obala.net>
  * @package News
  */
-class News_TagCloud extends Horde_Ui_TagCloud {
+class News_TagCloud extends Horde_Core_Ui_TagCloud {
 
     /**
      * create a Element of HTML part
index 3b3f648..ca944b4 100644 (file)
@@ -70,7 +70,7 @@ $page = Horde_Util::getGet('page', 0);
 $pager_vars = Horde_Variables::getDefaultVariables();
 $pager_vars->set('page', $page);
 $perpage = $prefs->getValue('rowsperpage');
-$pager = new Horde_Ui_Pager('page', $pager_vars,
+$pager = new Horde_Core_Ui_Pager('page', $pager_vars,
                             array('num' => count($data),
                                   'url' => 'search.php',
                                   'page_count' => 10,
index 8701a7b..334b621 100644 (file)
@@ -245,7 +245,7 @@ class Shout
     static public function getAdminTabs()
     {
         $tabname = Horde_Util::getFormData('view');
-        $tabs = new Horde_Ui_Tabs('view', Horde_Variables::getDefaultVariables());
+        $tabs = new Horde_Core_Ui_Tabs('view', Horde_Variables::getDefaultVariables());
         $tabs->addTab(_("Telephone Numbers"),
                       Horde::applicationUrl('admin/numbers.php'),
                       array('view' => 'numbers', id => 'tabnumbers'));
index 6f4a186..b10ee2a 100644 (file)
@@ -81,7 +81,7 @@ if ($actionID == 'delete') {
 
 // Get tabs.
 $url = Horde_Util::addParameter(Horde::applicationUrl('entry.php'), 'entry', $entry['object_id']);
-$tabs = new Horde_Ui_Tabs('view', $vars);
+$tabs = new Horde_Core_Ui_Tabs('view', $vars);
 $tabs->addTab(_("View"), $url, array('tabname' => 'Entry', 'id' => 'tabEntry'));
 if ($share->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
     $tabs->addTab(_("Edit"), $url, array('tabname' => 'EditEntry', 'id' => 'tabEditEntry'));
index df928ed..2948bd5 100644 (file)
@@ -74,7 +74,7 @@ case 'DeleteContact':
 
 // Get tabs.
 $url = $contact->url();
-$tabs = new Horde_Ui_Tabs('view', $vars);
+$tabs = new Horde_Core_Ui_Tabs('view', $vars);
 $tabs->addTab(_("_View"), $url,
               array('tabname' => 'Contact', 'id' => 'tabContact', 'onclick' => 'return ShowTab(\'Contact\');'));
 if ($contact->hasPermission(Horde_Perms::EDIT)) {
index 4aec864..1ac2c8f 100644 (file)
@@ -61,7 +61,7 @@ class Turba_View_List {
     /**
      * The HTML renderer.
      *
-     * @var Horde_Ui_VarRenderer_Html
+     * @var Horde_Core_Ui_VarRenderer_Html
      */
     var $renderer;
 
@@ -114,7 +114,7 @@ class Turba_View_List {
         $this->list = &$list;
         $this->setControls($controls);
 
-        $this->renderer = Horde_Ui_VarRenderer::factory('Html');
+        $this->renderer = Horde_Core_Ui_VarRenderer::factory('Html');
         $this->vars = new Horde_Variables();
     }
 
@@ -217,7 +217,7 @@ class Turba_View_List {
             $viewurl = urldecode(Horde_Util::addParameter('search.php', $params));
 
             $vars = Horde_Variables::getDefaultVariables();
-            $pager = new Horde_Ui_Pager('page', $vars,
+            $pager = new Horde_Core_Ui_Pager('page', $vars,
                                         array('num' => $numitem,
                                               'url' => $viewurl,
                                               'page_limit' => $maxpage,
index fd92403..122ef34 100644 (file)
@@ -212,7 +212,7 @@ foreach ($addressBooks as $key => $entry) {
 /* Build search mode tabs. */
 $sUrl = Horde::applicationUrl('search.php');
 $vars = Horde_Variables::getDefaultVariables();
-$tabs = new Horde_Ui_Tabs('search_mode', $vars);
+$tabs = new Horde_Core_Ui_Tabs('search_mode', $vars);
 $tabs->addTab(_("Basic Search"), $sUrl, 'basic');
 $tabs->addTab(_("Advanced Search"), $sUrl, 'advanced');
 if (count($editableAddressBooks)) {
index ed2e8f1..2705c8c 100644 (file)
@@ -72,12 +72,12 @@ class Vilma {
     /**
      * Create tabs to navigate the user manager area
      *
-     * return object Horde_Ui_Tabs object
+     * return object Horde_Core_Ui_Tabs object
      */
     function getUserMgrTabs(&$vars)
     {
         $url = Horde::applicationUrl('users/index.php');
-        $tabs = new Horde_Ui_Tabs('section', $vars);
+        $tabs = new Horde_Core_Ui_Tabs('section', $vars);
         foreach (Vilma::getUserMgrTypes() as $section => $desc) {
             $tabs->addTab($desc['plural'], $url, $section);
         }
index b3d3257..0affc5d 100644 (file)
@@ -39,7 +39,7 @@ $page = Horde_Util::getGet('page', 0);
 $perpage = $prefs->getValue('addresses_perpage');
 $url = 'users/index.php';
 $url = Horde_Util::addParameter($url, 'section', $section);
-$pager = new Horde_Ui_Pager('page',
+$pager = new Horde_Core_Ui_Pager('page',
                             Horde_Variables::getDefaultVariables(),
                             array('num' => count($addresses),
                                   'url' => $url,
index aa7856f..3c6413b 100644 (file)
@@ -26,7 +26,7 @@ if (!$vars->exists('action')) {
 
 // Admin actions.
 $adminurl = Horde::selfUrl(false, false);
-$tabs = new Horde_Ui_Tabs('action', $vars);
+$tabs = new Horde_Core_Ui_Tabs('action', $vars);
 $tabs->addTab(_("_Edit Queues"), $adminurl, 'queue');
 $tabs->addTab(_("Edit _Types"), $adminurl, 'type');
 $tabs->addTab(_("Queue/Type Matri_x"), $adminurl, 'mtmatrix');
index 725c36a..2b218d5 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /**
- * This file contains all Horde_UI_VarRenderer extensions for Whups specific
- * form fields.
+ * This file contains all Horde_Core_Ui_VarRenderer extensions for Whups
+ * specific form fields.
  *
  * Copyright 2008-2010 The Horde Project (http://www.horde.org/)
  *
@@ -9,17 +9,17 @@
  * did not receive this file, see http://www.horde.org/licenses/bsdl.php.
  *
  * @author  Jan Schneider <jan@horde.org>
- * @package Horde_UI
+ * @package Whups
  */
 
 /**
- * The Horde_UI_VarRenderer_whups class provides additional methods for
+ * The Horde_Core_Ui_VarRenderer_whups class provides additional methods for
  * rendering Horde_Form_Type_whups_email fields.
  *
  * @author  Jan Schneider <jan@horde.org>
- * @package Horde_UI
+ * @package Whups
  */
-class Horde_Ui_VarRenderer_whups extends Horde_Ui_VarRenderer_Html {
+class Horde_Core_Ui_VarRenderer_whups extends Horde_Core_Ui_VarRenderer_Html {
 
     function _renderVarInput_whups_email($form, &$var, &$vars)
     {
index 200832a..5ddf99a 100644 (file)
@@ -207,7 +207,7 @@ class Whups_Query {
         $edit = $this->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT);
         $delete = $this->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE);
 
-        $tabs = new Horde_Ui_Tabs('action', $vars);
+        $tabs = new Horde_Core_Ui_Tabs('action', $vars);
         $tabs->addTab(_("Ne_w Query"), $queryurl, 'new');
         if (!$this->id || $edit) {
             $tabs->addTab(_("_Edit Query"), $queryurl, 'edit');
index f8ad7eb..f7e50f6 100644 (file)
@@ -17,7 +17,7 @@
     {
         global $whups_driver;
 
-        $droptext = Horde_UI_VarRenderer_html::selectOptions($whups_driver->getAllTypes());
+        $droptext = Horde_Core_Ui_VarRenderer_html::selectOptions($whups_driver->getAllTypes());
         include WHUPS_TEMPLATES . '/renderer/querysetcurrenttype.inc';
     }
 
index 9bf8b01..d372470 100644 (file)
@@ -288,7 +288,7 @@ class Whups {
      */
     function getTicketTabs(&$vars, $id)
     {
-        $tabs = new Horde_Ui_Tabs(null, $vars);
+        $tabs = new Horde_Core_Ui_Tabs(null, $vars);
         $queue = $vars->get('queue');
 
         $tabs->addTab(_("_History"), Whups::urlFor('ticket', $id), 'history');
index bc6e96e..1ef651a 100644 (file)
@@ -148,7 +148,7 @@ $queryTabs = $whups_query->getTabs($vars);
 // Criterion form types.
 $queryurl = Horde::applicationUrl('query/index.php');
 $vars->set('action', $_SESSION['whups']['query_form']);
-$criteriaTabs = new Horde_Ui_Tabs('action', $vars);
+$criteriaTabs = new Horde_Core_Ui_Tabs('action', $vars);
 $criteriaTabs->preserve('path', $vars->get('path'));
 $criteriaTabs->addTab(_("_Property Criteria"), $queryurl, 'props');
 $criteriaTabs->addTab(_("_User Criteria"), $queryurl, 'user');