Use Horde_Url. Always include repository in URL.
authorJan Schneider <jan@horde.org>
Tue, 24 Aug 2010 13:32:48 +0000 (15:32 +0200)
committerJan Schneider <jan@horde.org>
Tue, 24 Aug 2010 13:32:48 +0000 (15:32 +0200)
chora/co.php
chora/lib/Chora.php
chora/patchsets.php
chora/templates/directory/header.inc
chora/templates/log/header.inc
chora/templates/log/rev.inc

index 470b834..a42898a 100644 (file)
@@ -12,7 +12,7 @@
 require_once dirname(__FILE__) . '/lib/Application.php';
 Horde_Registry::appInit('chora');
 
-/* If we know we're at a directory, just go to browse.php. */
+/* If we know we're at a directory, just go to browsedir.php. */
 if ($atdir) {
     require CHORA_BASE . '/browsedir.php';
     exit;
index 55b0efd..a05a639 100644 (file)
@@ -58,7 +58,7 @@ class Chora
             if (!empty($dir)) {
                 $url = self::url('browsedir', $path . ($i == $dir_count && !$GLOBALS['atdir'] ? '' : '/'));
                 if (!empty($onb)) {
-                    $url = Horde_Util::addParameter($url, array('onb' => $onb));
+                    $url = $url->add('onb', $onb);
                 }
                 $bar .= '/ <a href="' . $url . '">' . $GLOBALS['injector']->getInstance('Horde_Text_Filter')->filter($dir, 'space2html', array('encode' => true, 'encode_all' => true)) . '</a> ';
             }
@@ -105,22 +105,23 @@ class Chora
      *
      * @return string  The URL, with session information if necessary.
      */
-    static public function url($script, $uri = '', $args = array(), $anchor = '')
+    static public function url($script, $uri = '', $args = array(),
+                               $anchor = '')
     {
-        $arglist = self::_getArgList($GLOBALS['acts'], $GLOBALS['defaultActs'], $args);
+        $arglist = self::_getArgList($GLOBALS['acts'],
+                                     $GLOBALS['defaultActs'],
+                                     $args);
         $script .= '.php';
 
         if ($GLOBALS['conf']['options']['urls'] == 'rewrite') {
-            if (in_array($script, array('browse.php', 'browsedir.php'))) {
+            if (in_array($script, array('browsefile.php', 'browsedir.php'))) {
                 if (substr($uri, 0, 1) == '/') {
                     $script = "browse$uri";
                 } else {
                     $script = "browse/$uri";
                 }
-                if (isset($args['rt'])) {
-                    $script = urlencode($arglist['rt']) . "/-/$script";
-                    unset($arglist['rt']);
-                }
+                $script = urlencode(isset($args['rt']) ? $args['rt'] : $GLOBALS['acts']['rt']) . "/-/$script";
+                unset($arglist['rt']);
             } else {
                 $script .= '/' . $uri;
             }
@@ -128,9 +129,8 @@ class Chora
             $arglist['f'] = $uri;
         }
 
-        $url = Horde_Util::addParameter(Horde::applicationUrl($script), $arglist);
+        return Horde::applicationUrl($script)->add($arglist)->setAnchor($anchor);
 
-        return empty($anchor) ? $url : ($url . '#' . $anchor);
     }
 
     /**
@@ -219,7 +219,7 @@ class Chora
         return '<form action="#" id="repository-picker">' .
             '<select onchange="location.href=this[this.selectedIndex].value">' .
             '<option value="">' . _("Change repositories:") . '</option>' .
-            implode(' , ', $arr) . '</select></form>';
+            implode('', $arr) . '</select></form>';
     }
 
     /**
@@ -356,7 +356,7 @@ class Chora
         $tags = array();
 
         foreach ($lg->querySymbolicBranches() as $symb => $bra) {
-            $tags[] = '<a href="' . self::url('browsefile', $where, array('onb' => $bra)) . '">'. htmlspecialchars($symb) . '</a>';
+            $tags[] = self::url('browsefile', $where, array('onb' => $bra))->link() . htmlspecialchars($symb) . '</a>';
         }
 
         foreach ($lg->queryTags() as $tag) {
index b240d3d..6542b49 100644 (file)
@@ -70,28 +70,37 @@ $diff_img = Horde::img('diff.png', _("Diff"));
 
 reset($patchsets);
 while (list($id, $patchset) = each($patchsets)) {
-    $patchset_link = Horde::link(Chora::url('patchsets', $where, array('ps' => $id)), sprintf("Patchset for %s", $id)) . htmlspecialchars($VC->abbrev($id)) . '</a>';
+    $patchset_link = Chora::url('patchsets', $where, array('ps' => $id))
+        ->link(array('title' => sprintf("Patchset for %s", $id)))
+        . htmlspecialchars($VC->abbrev($id)) . '</a>';
 
     $files = $tags = array();
 
     foreach ($patchset['members'] as $member) {
         $file = array();
 
-        $file['file'] = Horde::link(Chora::url('co', $member['file'])) . htmlspecialchars($member['file']) . '</a>';
+        $file['file'] = Chora::url('co', $member['file'])->link()
+            . htmlspecialchars($member['file']) . '</a>';
 
         if ($member['status'] == Horde_Vcs_Patchset::ADDED) {
             $file['from'] = '<ins>' . _("New File") . '</ins>';
             $file['diff'] = '';
         } else {
-            $file['from'] = Horde::link(Chora::url('co', $member['file'], array('r' => $member['from'])), $member['from']) . htmlspecialchars($VC->abbrev($member['from'])) . '</a>';
-            $file['diff'] = Horde::link(Chora::url('diff', $member['file'], array('r1' => $member['from'], 'r2' => $member['to'])), _("Diff")) . ' ' . $diff_img . '</a>';
+            $file['from'] = Chora::url('co', $member['file'], array('r' => $member['from']))
+                ->link(array('title' => $member['from']))
+                . htmlspecialchars($VC->abbrev($member['from'])) . '</a>';
+            $file['diff'] = Chora::url('diff', $member['file'], array('r1' => $member['from'], 'r2' => $member['to']))
+                ->link(array('title' => _("Diff")))
+                . ' ' . $diff_img . '</a>';
         }
 
         if ($member['status'] == Horde_Vcs_Patchset::DELETED) {
             $file['to'] = '<del>' . _("Deleted") . '</del>';
             $file['diff'] = '';
         } else {
-            $file['to'] = Horde::link(Chora::url('co', $member['file'], array('r' => $member['to'])), $member['to']) . htmlspecialchars($VC->abbrev($member['to'])) . '</a>';
+            $file['to'] = Chora::url('co', $member['file'], array('r' => $member['to']))
+                ->link(array('title' => $member['to']))
+                . htmlspecialchars($VC->abbrev($member['to'])) . '</a>';
         }
 
         if (isset($member['added'])) {
index 4a70a57..c862379 100644 (file)
@@ -1,10 +1,8 @@
 <?php if (count($branches) > 1): ?>
 <div class="options">
  <span>
-  <form method="get" action="browsedir.php">
+  <form method="get" action="<?php echo Chora::url('browsedir', Horde_Util::getFormData('f')) ?>">
    <?php echo _("View Branch:") ?>
-   <?php echo Chora::formInputs() ?>
-   <input type="hidden" name="f" value="<?php echo htmlspecialchars(Horde_Util::getFormData('f')) ?>" />
    <select name="onb" onchange="this.form.submit()">
     <option value="0"<?php if (!isset($onb) || !$onb) echo ' selected="selected"' ?>><?php echo _("All Branches") ?></option>
 <?php foreach ($branches as $branch): ?>
index 3f5d153..4b34cf1 100644 (file)
@@ -20,9 +20,7 @@
 
 <?php if (!empty($selAllBranches)): ?>
  <span>
-  <form method="get" action="browsefile.php">
-   <?php echo Chora::formInputs() ?>
-   <input type="hidden" name="f" value="<?php echo htmlspecialchars(Horde_Util::getFormData('f')) ?>" />
+  <form method="get" action="<?php echo Chora::url('browsefile', Horde_Util::getFormData('f')) ?>">
    <?php echo _("Show Branch:") ?>
    <select name="onb" onchange="this.form.submit()">
     <option value="0"<?php if (!isset($onb) || !$onb) echo ' selected="selected"' ?>><?php echo _("All Branches") ?></option>
index 7f10c85..bfe47fa 100644 (file)
@@ -9,7 +9,7 @@
 <?php $branchlist = array_diff($branch_info, array($onb)); if (!empty($branchlist)): ?>
   <span class="branch">
 <?php foreach ($branchlist as $val): ?>
-  <?php echo Horde::link(Chora::url('browsefile', $where, array('onb' => $val))) . htmlspecialchars($val) ?></a>
+  <?php echo Chora::url('browsefile', $where, array('onb' => $val))->link() . htmlspecialchars($val) ?></a>
 <?php endforeach; endif; ?>
 <?php if (!empty($changedlines)): ?>
   <small class="difflines">(<?php printf('%s lines', htmlspecialchars($changedlines)) ?>)</small>