From 975284055d122ed737c49d9cf39b2e7710ece18f Mon Sep 17 00:00:00 2001
From: Chris Hallberg <crhallberg@gmail.com>
Date: Mon, 25 Aug 2014 13:41:12 -0400
Subject: [PATCH] Siblings form fix for VuDL.

---
 themes/bootstrap3/css/vudl.css                |  7 +++++-
 themes/bootstrap3/templates/vudl/record.phtml | 24 ++++++++++++-------
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/themes/bootstrap3/css/vudl.css b/themes/bootstrap3/css/vudl.css
index 47c836c0fb4..89426de89f0 100644
--- a/themes/bootstrap3/css/vudl.css
+++ b/themes/bootstrap3/css/vudl.css
@@ -37,4 +37,9 @@ div.xml.collapsed > div { display:none;margin-left:2px }
 .fa.file-audio:before {content: "\f1c7";}
 .fa.file-msexcel:before {content: "\f1c3";}
 .fa.file-msword:before {content: "\f1c2";}
-.fa.file-pdf:before {content: "\f1c1";}
\ No newline at end of file
+.fa.file-pdf:before {content: "\f1c1";}
+
+.siblings-form .trail {
+  display:inline-block;
+  vertical-align:bottom;
+}
\ No newline at end of file
diff --git a/themes/bootstrap3/templates/vudl/record.phtml b/themes/bootstrap3/templates/vudl/record.phtml
index 81b0d44b292..268efd5fc4b 100644
--- a/themes/bootstrap3/templates/vudl/record.phtml
+++ b/themes/bootstrap3/templates/vudl/record.phtml
@@ -51,22 +51,28 @@
 <form class="form-horizontal text-center siblings-form" action="<?=$this->url('vudl-sibling') ?>" method="get">
   <input type="hidden" name="id" value="<?=$this->layout()->vudlID ?>"/>
   <button class="btn btn-default" type="submit" name="prev_x" value="1" title="<?=$this->transEsc('Prev Item in Collection')?>">&larr; <?=$this->transEsc('Prev Item')?></button>
-  <? $uniqueParents = array(); ?>
+  <? $parents = array(); ?>
+  <? $parentKeys = array(); ?>
   <? foreach($this->parents as $trail): ?>
-    <? if(!in_array(key($trail), $uniqueParents)): ?>
-      <? $uniqueParents[] = key($trail); ?>
+    <? if(is_array($trail)): ?>
+      <? end($trail); ?>
+    <? endif; ?>
+    <? if(!in_array(key($trail), $parentKeys)): ?>
+      <? $uniqueParents[] = array(
+        'id'    => key($trail),
+        'title' => current($trail)
+      ); ?>
+      <? $parentKeys[] = key($trail); ?>
     <? endif; ?>
   <? endforeach; ?>
   <? if(count($uniqueParents) > 1): ?>
-    <select name="trail" id="trail">
-      <? foreach($this->parents as $trail): ?>
-        <? if(in_array(key($trail), $uniqueParents)): ?>
-          <option value="<?=key($trail) ?>"><?=current($trail) ?></option>
-        <? endif; ?>
+    <select class="form-control trail" name="trail">
+      <? foreach($uniqueParents as $trail): ?>
+        <option value="<?=$trail['id'] ?>"><?=$trail['title'] ?></option>
       <? endforeach; ?>
     </select>
   <? else: ?>
-    <input type="hidden" name="trail" value="<?=current(array_keys($this->parents[0]))?>"/>
+    <input type="hidden" name="trail" value="<?=$uniqueParents[0]['id'] ?>"/>
   <? endif; ?>
   <button class="btn btn-default" type="submit" name="next_x" value="1" title="<?=$this->transEsc('Next Item in Collection')?>"><?=$this->transEsc('Next Item')?> &rarr;</button>
 </form>
-- 
GitLab