Correctly pass branch between browse screens
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 19 Jun 2009 18:23:34 +0000 (12:23 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 19 Jun 2009 18:23:34 +0000 (12:23 -0600)
chora/browsedir.php
chora/co.php
chora/lib/Chora.php
chora/templates/directory/header.inc
chora/templates/headerbar.inc

index 99f2e4e..18e9ae1 100644 (file)
@@ -17,13 +17,13 @@ if (!$atdir) {
     exit;
 }
 
-$rev = $VC->hasFeature('snapshots')
-    ? Horde_Util::getFormData('rev')
+$onb = $VC->hasFeature('snapshots')
+    ? Horde_Util::getFormData('onb')
     : null;
 
 try {
     $atticFlags = (bool)$acts['sa'];
-    $dir = $VC->getDirObject($where, array('quicklog' => true, 'rev' => $rev, 'showattic' => $atticFlags));
+    $dir = $VC->getDirObject($where, array('quicklog' => true, 'rev' => $onb, 'showattic' => $atticFlags));
     $dir->applySort($acts['sbt'], $acts['ord']);
     $dirList = $dir->queryDirList();
     $fileList = $dir->queryFileList($atticFlags);
@@ -37,7 +37,7 @@ $title = ($where == '')
     : sprintf(_("Source Directory of /%s"), $where);
 
 $extraLink = $VC->hasFeature('deleted')
-    ? Horde::widget(Chora::url('browsedir', $where . '/', array('rev' => $rev, 'sa' => ($acts['sa'] ? 0 : 1))), $acts['sa'] ? _("Hide Deleted Files") : _("Show Deleted Files"), 'widget', '', '', $acts['sa'] ? _("Hide _Deleted Files") : _("Show _Deleted Files"))
+    ? Horde::widget(Chora::url('browsedir', $where . '/', array('onb' => $onb, 'sa' => ($acts['sa'] ? 0 : 1))), $acts['sa'] ? _("Hide Deleted Files") : _("Show Deleted Files"), 'widget', '', '', $acts['sa'] ? _("Hide _Deleted Files") : _("Show _Deleted Files"))
     : '';
 
 $umap = array(
@@ -52,14 +52,14 @@ foreach ($umap as $key => $val) {
     if ($acts['sbt'] == $val) {
         $arg['ord'] = !$acts['ord'];
     }
-    $url[$key] = Chora::url('browsedir', $where . '/', $arg, array('rev' => $rev));
+    $url[$key] = Chora::url('browsedir', $where . '/', $arg, array('onb' => $onb));
 }
 
 $branches = array();
 if ($VC->hasFeature('branches')) {
     $branches = $dir->getBranches();
-    if (is_null($rev)) {
-        $rev = $VC->getDefaultBranch();
+    if (is_null($onb)) {
+        $onb = $VC->getDefaultBranch();
     }
 }
 
@@ -76,7 +76,7 @@ require CHORA_TEMPLATES . '/directory/header.inc';
 
 /* Unless we're at the top, display the 'back' bar. */
 if ($where != '') {
-    $url = Chora::url('browsedir', preg_replace('|[^/]+$|', '', $where), array('rev' => $rev));
+    $url = Chora::url('browsedir', preg_replace('|[^/]+$|', '', $where), array('onb' => $onb));
     require CHORA_TEMPLATES . '/directory/back.inc';
 }
 
@@ -87,7 +87,7 @@ if ($dirList) {
         if ($conf['hide_restricted'] && Chora::isRestricted($currentDir)) {
             continue;
         }
-        $url = Chora::url('browsedir', $where . '/' . $currentDir . '/', array('rev' => $rev));
+        $url = Chora::url('browsedir', $where . '/' . $currentDir . '/', array('onb' => $onb));
         $currDir = Horde_Text_Filter::filter($currentDir, 'space2html', array('charset' => NLS::getCharset(), 'encode' => true, 'encode_all' => true));
         require CHORA_TEMPLATES . '/directory/dir.inc';
     }
@@ -116,7 +116,7 @@ if ($fileList) {
         $attic = $currFile->isDeleted();
         $fileName = $where . ($attic ? '/' . 'Attic' : '') . '/' . $realname;
         $name = Horde_Text_Filter::filter($realname, 'space2html', array('charset' => NLS::getCharset(), 'encode' => true, 'encode_all' => true));
-        $url = Chora::url('browsefile', $fileName, array('onb' => $rev));
+        $url = Chora::url('browsefile', $fileName, array('onb' => $onb));
         $readableDate = Chora::readableTime($date);
         if ($log) {
             $shortLog = str_replace("\n", ' ', trim(substr($log, 0, $conf['options']['shortLogLength'] - 1)));
index 6d04959..d93e6e0 100644 (file)
@@ -75,7 +75,7 @@ if (!$plain) {
     );
     if ($VC->hasFeature('snapshots')) {
         $snapdir = dirname($file->queryPath());
-        $views[] = Horde::widget(Chora::url('browsedir', $snapdir == '.' ? '' : $snapdir . '/', array('rev' => $r)), _("Snapshot"), 'widget', '', '', _("_Snapshot"));
+        $views[] = Horde::widget(Chora::url('browsedir', $snapdir == '.' ? '' : $snapdir . '/', array('onb' => $r)), _("Snapshot"), 'widget', '', '', _("_Snapshot"));
     }
     $extraLink = _("View:") . ' ' . implode(' | ', $views);
 
index bbcb2a5..e20a5b8 100644 (file)
@@ -185,10 +185,12 @@ class Chora
      * Create the breadcrumb directory listing.
      *
      * @param string $where  The current filepath.
+     * @param string $onb    If not null, the branch to add to the generated
+     *                       URLs.
      *
      * @return string  The directory string.
      */
-    static public function whereMenu($where)
+    static public function whereMenu($where, $onb = null)
     {
         $bar = '';
         $dirs = explode('/', $where);
@@ -201,7 +203,11 @@ class Chora
             }
             $path .= $dir;
             if (!empty($dir)) {
-                $bar .= '/ <a href="' . self::url('browsedir', $path . ($i == $dir_count && !$GLOBALS['atdir'] ? '' : '/')) . '">'. Horde_Text_Filter::filter($dir, 'space2html', array('charset' => NLS::getCharset(), 'encode' => true, 'encode_all' => true)) . '</a> ';
+                $url = self::url('browsedir', $path . ($i == $dir_count && !$GLOBALS['atdir'] ? '' : '/'));
+                if (!empty($onb)) {
+                    $url = Horde_Util::addParameter($url, array('onb' => $onb));
+                }
+                $bar .= '/ <a href="' . $url . '">'. Horde_Text_Filter::filter($dir, 'space2html', array('charset' => NLS::getCharset(), 'encode' => true, 'encode_all' => true)) . '</a> ';
             }
         }
 
index 1b5950c..e2ff29d 100644 (file)
@@ -5,9 +5,9 @@
    <?php echo _("View Branch:") ?>
    <?php echo Chora::formInputs() ?>
    <input type="hidden" name="f" value="<?php echo htmlspecialchars(Horde_Util::getFormData('f')) ?>" />
-   <select name="rev" onchange="this.form.submit()">
+   <select name="onb" onchange="this.form.submit()">
 <?php foreach ($branches as $branch): ?>
-    <option value="<?php echo htmlspecialchars($branch) ?>"<?php echo ($branch == $rev) ? ' selected="selected"' : '' ?>><?php echo htmlspecialchars($branch) ?></option>
+    <option value="<?php echo htmlspecialchars($branch) ?>"<?php echo ($branch == $onb) ? ' selected="selected"' : '' ?>><?php echo htmlspecialchars($branch) ?></option>
 <?php endforeach; ?>
    </select>
    <noscript><input class="button" type="submit" value="<?php echo _("View") ?>" /></noscript>
index 7a3b527..08d7bb1 100644 (file)
@@ -4,7 +4,7 @@
   <td class="browseLocation">
    <?php echo _("Location:") ?>
    <strong>[ <a href="<?php echo Chora::url('browsedir') ?>"><?php echo $conf['options']['sourceRootName'] ?></a> ]
-   <?php echo Chora::whereMenu($where) ?></strong>
+   <?php echo Chora::whereMenu($where, isset($onb) ? $onb : null) ?></strong>
 <?php if (!empty($onb)): ?>
     <em><?php echo _("Tracking Branch") ?>: <strong><?php echo $onb ?></strong></em>
 <?php endif; ?>