use Horde_Url methods in turba
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 30 Jul 2010 18:10:36 +0000 (12:10 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 30 Jul 2010 18:10:36 +0000 (12:10 -0600)
13 files changed:
turba/contact.php
turba/lib/Block/tree_menu.php
turba/lib/Driver.php
turba/lib/Form/EditContactGroup.php
turba/lib/Object.php
turba/lib/Object/Group.php
turba/lib/View/List.php
turba/search.php
turba/templates/addressbook_list.php
turba/templates/browse/actions.inc
turba/templates/browse/column_headers.inc
turba/templates/browse/row.inc
turba/templates/list/alphaPager.inc

index 2948bd5..42ab9d9 100644 (file)
@@ -94,7 +94,7 @@ if ($own_source == $source && $own_id == $contact->getValue('__key')) {
 } else {
     $own_icon = '';
     $own_link = '<span class="smallheader rightFloat">'
-        . Horde::link(Horde_Util::addParameter($url, array('action' => 'mark_own')))
+        . $url->copy()->add('action', 'mark_own')->link()
         . _("Mark this as your own contact") . '</a></span>';
 }
 
index 0b12378..2f78694 100644 (file)
@@ -36,7 +36,7 @@ class Horde_Block_turba_tree_menu extends Horde_Block
                                false,
                                array('icon' => 'new.png',
                                      'icondir' => $icondir,
-                                     'url' => Horde_Util::addParameter($add, array('source' => $addressbook))));
+                                     'url' => $add->copy()->add('source', $addressbook)));
             }
         }
 
@@ -49,7 +49,7 @@ class Horde_Block_turba_tree_menu extends Horde_Block
                                false,
                                array('icon' => 'browse.png',
                                      'icondir' => $icondir,
-                                     'url' => Horde_Util::addParameter($browse, array('source' => $addressbook))));
+                                     'url' => $browse->copy()->add('source', $addressbook)));
             }
         }
 
index 1c59de2..ce912ca 100644 (file)
@@ -658,7 +658,7 @@ class Turba_Driver
                 'recurrence' => array('type' => Horde_Date_Recurrence::RECUR_YEARLY_DATE,
                                       'interval' => 1),
                 'params' => array('source' => $this->name, 'key' => $key),
-                'link' => Horde_Util::addParameter(Horde::applicationUrl('contact.php', true), array('source' => $this->name, 'key' => $key), null, false));
+                'link' => Horde::applicationUrl('contact.php', true)->add(array('source' => $this->name, 'key' => $key))->setRaw(true));
         }
 
         return $t_objects;
index 77f4172..a443caa 100644 (file)
@@ -53,42 +53,42 @@ class Turba_Form_EditContactGroup extends Turba_Form_EditContact
 
         $this->getInfo($this->_vars, $info);
 
-        $next_page = Horde::applicationUrl('edit.php', true);
-        $next_page = Horde_Util::addParameter($next_page,
-                                        array('source' => $info['source'],
-                                              'original_source' => $info['original_source'],
-                                              'objectkeys' => $info['objectkeys'],
-                                              'url' => $info['url'],
-                                              'actionID' => 'groupedit'),
-                                        null, false);
+        $next_page = Horde::applicationUrl('edit.php', true)->add(array(
+            'source' => $info['source'],
+            'original_source' => $info['original_source'],
+            'objectkeys' => $info['objectkeys'],
+            'url' => $info['url'],
+            'actionID' => 'groupedit'
+        );
+
         $objectkey = array_search($info['source'] . ':' . $info['key'], $info['objectkeys']);
 
         $submitbutton = $this->_vars->get('submitbutton');
         if ($submitbutton == _("Finish")) {
             $next_page = Horde::url('browse.php', true);
             if ($info['original_source'] == '**search') {
-                $next_page = Horde_Util::addParameter($next_page, 'key', $info['original_source'], false);
+                $next_page->add('key', $info['original_source']);
             } else {
-                $next_page = Horde_Util::addParameter($next_page, 'source', $info['original_source'], false);
+                $next_page->add('source', $info['original_source']);
             }
         } elseif ($submitbutton == _("Previous") && $info['source'] . ':' . $info['key'] != $info['objectkeys'][0]) {
             /* Previous contact */
             list(, $previous_key) = explode(':', $info['objectkeys'][$objectkey - 1]);
-            $next_page = Horde_Util::addParameter($next_page, 'key', $previous_key, false);
+            $next_page->add('key', $previous_key);
             if ($this->getOpenSection()) {
-                $next_page = Horde_Util::addParameter($next_page, '__formOpenSection', $this->getOpenSection(), false);
+                $next_page->add('__formOpenSection', $this->getOpenSection());
             }
         } elseif ($submitbutton == _("Next") &&
                   $info['source'] . ':' . $info['key'] != $info['objectkeys'][count($info['objectkeys']) - 1]) {
             /* Next contact */
             list(, $next_key) = explode(':', $info['objectkeys'][$objectkey + 1]);
-            $next_page = Horde_Util::addParameter($next_page, 'key', $next_key, false);
+            $next_page->add('key', $next_key);
             if ($this->getOpenSection()) {
-                $next_page = Horde_Util::addParameter($next_page, '__formOpenSection', $this->getOpenSection(), false);
+                $next_page->add('__formOpenSection', $this->getOpenSection());
             }
         }
 
-        header('Location: ' . $next_page);
+        header('Location: ' . $next_page->setRaw(true));
         exit;
     }
 
index 8851f10..b6f0a17 100644 (file)
@@ -314,14 +314,16 @@ class Turba_Object {
      */
     function url($view = null, $full = false)
     {
-        $url = Horde_Util::addParameter('contact.php',
-                                  array('source' => $this->driver->name,
-                                        'key' => $this->getValue('__key')));
+        $url = Horde::applicationUrl('contact.php', $full)->add(array(
+            'source' => $this->driver->name,
+            'key' => $this->getValue('__key')
+        ));
+
         if (!is_null($view)) {
-            $url = Horde_Util::addParameter($url, 'view', $view);
+            $url->add('view', $view);
         }
 
-        return Horde::applicationUrl($url, $full);
+        return $url;
     }
 
     /**
@@ -433,9 +435,7 @@ class Turba_Object {
 
         // Let's see if we can view this one, too.
         if ($viewer && !is_a($viewer, 'Horde_Mime_Viewer_default')) {
-            $url = Horde::applicationUrl('view.php');
-            $url_params['actionID'] = 'view_file';
-            $url = Horde_Util::addParameter($url, $url_params);
+            $url = Horde::applicationUrl('view.php')->add('actionID', 'view_file');
             $link = Horde::link($url, $file['name'], null, '_blank') . $file['name'] . '</a>';
         } else {
             $link = $file['name'];
index 4f6dbe7..4e9b914 100644 (file)
@@ -37,10 +37,10 @@ class Turba_Object_Group extends Turba_Object {
      */
     function url($view = null, $full = false)
     {
-        $url = Horde_Util::addParameter('browse.php',
-                                  array('source' => $this->getSource(),
-                                        'key' => $this->getValue('__key')));
-        return Horde::applicationUrl($url, $full);
+        return Horde::applicationUrl('browse.php', $full)->add(array(
+            'source' => $this->getSource(),
+            'key' => $this->getValue('__key')
+        ));
     }
 
     /**
index 1ac2c8f..04dff44 100644 (file)
@@ -174,10 +174,10 @@ class Turba_View_List {
         }
         list($addToList, $addToListSources) = $this->getAddSources();
 
-        $viewurl = urldecode(Horde_Util::addParameter(
-            'browse.php',
-            array('key' => Horde_Util::getFormData('key'),
-                  'url' => Horde::selfUrl(true, false, true))));
+        $viewurl = Horde::applicationUrl('browse.php')->add(array(
+            'key' => Horde_Util::getFormData('key'),
+            'url' => Horde::selfUrl(true, false, true)
+        ));
 
         if ($this->type == 'search') {
             $page = Horde_Util::getFormData('page', 0);
@@ -214,7 +214,7 @@ class Turba_View_List {
                 'val' => Horde_Util::getFormData('val'),
                 'source' => Horde_Util::getFormData('source', $default_source)
             ));
-            $viewurl = urldecode(Horde_Util::addParameter('search.php', $params));
+            $viewurl = Horde::applicationUrl('search.php')-add($params);
 
             $vars = Horde_Variables::getDefaultVariables();
             $pager = new Horde_Core_Ui_Pager('page', $vars,
index 8bbb8c8..9b5384b 100644 (file)
@@ -159,9 +159,8 @@ if (is_a($driver, 'PEAR_Error')) {
             }
             $notification->push(sprintf(_("Successfully created virtual address book \"%s\""), $vname), 'horde.success');
 
-            $url = Horde::applicationURL('browse.php', true);
-            $url = Horde_Util::addParameter($url, array('source' => $vid, null, false));
-            header('Location: ' . $url);
+            $url = Horde::applicationURL('browse.php', true)->add('source', $vid);;
+            header('Location: ' . $url->setRaw(true));
             exit;
         }
 
index a980e6f..1b26efe 100644 (file)
 <?php foreach (array_keys($sorted_addressbooks) as $addressbook_id): ?>
  <?php $addressbook = $addressbooks[$addressbook_id] ?>
   <tr>
-   <td><a href="<?php echo Horde_Util::addParameter($browse_url_base, 'source', $addressbook->getName()) ?>" title="<?php echo _("Browse") ?>"><?php echo $browse_img ?></a></td>
+   <td><a href="<?php echo $browse_url_base->copy()->add('source', $addressbook->getName()) ?>" title="<?php echo _("Browse") ?>"><?php echo $browse_img ?></a></td>
    <td><?php echo htmlspecialchars($addressbook->get('name')) ?></td>
-   <td><a href="<?php echo Horde_Util::addParameter($edit_url_base, 'a', $addressbook->getName()) ?>" title="<?php echo _("Edit") ?>"><?php echo $edit_img ?></a></td>
+   <td><a href="<?php echo $edit_url_base->copy()->add('a', $addressbook->getName()) ?>" title="<?php echo _("Edit") ?>"><?php echo $edit_img ?></a></td>
 <?php if (empty($conf['share']['no_sharing'])): ?>
    <td><?php echo $perms_url_base->add('share', $addressbook->getName())->link(array('title' => _("Change Permissions"), 'target' => '_blank', 'onclick' => Horde::popupJs($perms_url_base, array('params' => array('share' => $addressbook->getName()), 'urlencode' => true)) . 'return false;')) . $perms_img . '</a>';?>
 <?php endif; ?>
-   <td><a href="<?php echo Horde_Util::addParameter($delete_url_base, 'a', $addressbook->getName()) ?>" title="<?php echo _("Delete") ?>"><?php echo $delete_img ?></a></td>
+   <td><a href="<?php echo $delete_url_base->copy()->add('a', $addressbook->getName()) ?>" title="<?php echo _("Delete") ?>"><?php echo $delete_img ?></a></td>
   </tr>
 <?php endforeach; ?>
  </tbody>
index 96dee8f..7676038 100644 (file)
@@ -46,9 +46,9 @@
 $browse_link = Horde::applicationUrl('browse.php');
 if ($this->getType() == 'directory' &&
     !empty($cfgSources[$default_source]['map']['__type'])) {
-    printf(_("Show %s"), Horde::widget(Horde_Util::addParameter($browse_link, 'show', 'lists'), _("Show Lists"), 'widget', '', '', _("_Lists")) . ', ' .
-        Horde::widget(Horde_Util::addParameter($browse_link, 'show', 'contacts'), _("Show Contacts"), 'widget', '', '', _("_Contacts")) . ', ' .
-        Horde::widget(Horde_Util::addParameter($browse_link, 'show', 'all'), _("Show Both"), 'widget', '', '', _("Both")));
+    printf(_("Show %s"), Horde::widget($browse_link->copy()->add('show', 'lists'), _("Show Lists"), 'widget', '', '', _("_Lists")) . ', ' .
+        Horde::widget($browse_link->copy()->add('show', 'contacts'), _("Show Contacts"), 'widget', '', '', _("_Contacts")) . ', ' .
+        Horde::widget($browse_link->copy()->add('show', 'all'), _("Show Both"), 'widget', '', '', _("Both")));
 }
 ?>
 </div>
index b543be7..5e2a60a 100644 (file)
    <?php if ($this->isSortColumn($i)): ?>
       <?php $sortdir = $this->getColumnSortDirection($i); ?>
       <?php $changetitle = sprintf(_("Change %s sort to %s"), $columnlabel, $sortdir == 0 ? _("descending") : _("ascending")) ?>
-      <a class="widget" title="<?php echo $changetitle ?>" href="<?php echo Horde_Util::addParameter($s_url, array('sortadd' => 1, 'sortby' => $i, 'sortdir' => abs(1 - $sortdir))) ?>"><?php echo $this->getColumnSortImage($i) ?></a>
+      <a class="widget" title="<?php echo $changetitle ?>" href="<?php echo $s_url->copy()->add(array('sortadd' => 1, 'sortby' => $i, 'sortdir' => abs(1 - $sortdir))) ?>"><?php echo $this->getColumnSortImage($i) ?></a>
       <?php $changetitle = sprintf(_("Sort by %s only"), $columnlabel) ?>
-      <a class="widget" title="<?php echo $changetitle ?>" href="<?php echo Horde_Util::addParameter($s_url, array('sortby' => $i, 'sortdir' => abs(1 - $sortdir))) ?>">
+      <a class="widget" title="<?php echo $changetitle ?>" href="<?php echo $s_url->copy()->add(array('sortby' => $i, 'sortdir' => abs(1 - $sortdir))) ?>">
    <?php else: ?>
       <?php $sorttitle = sprintf(_("Sort by %s, then by %s"), $this->getSortOrderDescription(), $columnlabel) ?>
-      <a class="widget" title="<?php echo $sorttitle ?>" href="<?php echo Horde_Util::addParameter($s_url, array('sortadd' => 1, 'sortby' => $i, 'sortdir' => 0)) ?>"><?php echo $this->getColumnSortImage($i, $sorttitle) ?></a>
-      <a class="widget" title="<?php echo sprintf(_("Sort by %s"), $columnlabel) ?>" href="<?php echo Horde_Util::addParameter($s_url, array('sortby' => $i, 'sortdir' => 0)) ?>">
+      <a class="widget" title="<?php echo $sorttitle ?>" href="<?php echo $s_url->copy()->add(array('sortadd' => 1, 'sortby' => $i, 'sortdir' => 0)) ?>"><?php echo $this->getColumnSortImage($i, $sorttitle) ?></a>
+      <a class="widget" title="<?php echo sprintf(_("Sort by %s"), $columnlabel) ?>" href="<?php echo $s_url->copy()->add(array('sortby' => $i, 'sortdir' => 0)) ?>">
    <?php endif; ?>
 <?php endif; ?>
    <?php echo $columnlabel ?>
index e2a31d7..cff32f8 100644 (file)
@@ -19,9 +19,10 @@ if ($own_source == $ob->getSource() && $own_id == $ob->getValue('__key')) {
 
 $edit_url = $vcard_url = '&nbsp;';
 if ($ob->hasValue('__key')) {
-    $vcard_url = Horde_Util::addParameter('vcard.php',
-                                    array('source' => $ob->getSource(),
-                                          'key' => $ob->getValue('__key')));
+    $vcard_url = Horde::applicationUrl('vcard.php')->add(array(
+        'source' => $ob->getSource(),
+        'key' => $ob->getValue('__key')
+    ));
     $vcard_url = Horde::link(Horde::applicationUrl($vcard_url),
                              _("Download vCard"))
         . Horde::img('mime/vcard.png', _("Download vCard"))
@@ -29,12 +30,12 @@ if ($ob->hasValue('__key')) {
 
     $cell = Horde::link($ob->url()) . $link_text . '</a>';
     if ($ob->hasPermission(Horde_Perms::EDIT)) {
-        $edit_url = Horde_Util::addParameter(
-            'contact.php',
-            array('view' => 'EditContact',
-                  'source' => $ob->getSource(),
-                  'key' => $ob->getValue('__key'),
-                  'url' => Horde::selfUrl(true, false, true)));
+        $edit_url = Horde::applicationUrl('contact.php')->add(array(
+            'view' => 'EditContact',
+            'source' => $ob->getSource(),
+            'key' => $ob->getValue('__key'),
+            'url' => Horde::selfUrl(true, false, true)
+        ));
         $edit_url = Horde::link(Horde::applicationUrl($edit_url), _("Edit"))
             . Horde::img('edit.png', _("Edit"))
             . '</a>';
index 5eeac3f..f96579e 100644 (file)
@@ -6,17 +6,14 @@ $currentPage = Horde_String::upper($page);
 if ($currentPage == '*') {
     echo '<strong>(' . _("All") . ')</strong>&nbsp;';
 } else {
-    echo Horde::link(Horde::applicationUrl(Horde_Util::addParameter($viewurl, array('page' => '*',
-                                                                              'show' => $show)))) . _("All") . '</a>&nbsp;';
+    Horde::applicationUrl($viewurl)->add(array('page' => '*', 'show' => $show))->link() . _("All") . '</a>&nbsp;';
 }
 for ($i = 65; $i < 91; $i++) {
     $a = chr($i);
     if ($currentPage == $a) {
         echo '<strong>(' . $a . ')</strong>&nbsp;';
     } else {
-        $link = Horde_Util::addParameter($viewurl, array('page' => $a,
-                                                   'show' => $show));
-        echo Horde::link(Horde::applicationUrl($link)) . $a . '</a>&nbsp;';
+        echo Horde::applicationUrl($viewurl)->add(array('page' => $a, 'show' => $show))->link() . $a . '</a>&nbsp;';
     }
 }
 ?>