[ansel] Problem with sub-galleries and XP-publishing???
Heath S. Hendrickson
heath at outerspaceconsultants.com
Fri Mar 19 20:49:37 PST 2004
> Also, XP-publishing is still broken for me. I'm not sure if it's
> related to the same thing, but my guess is that it is... I'll see if
> I can do a quick fix, otherwise I'll leave it up to Ben to fix.
>
> h
Attached are patches to xppublish.php and templates/xppublish/list.inc
that accomodate the new output of Ansel::listGalleries(). I had to add
a little extra code to deal with the different array format for
groupby=owner, but not that much.
I also added a little code to the creation of the gallery select box to
make it add the full lineage of a gallery. I did this because with the
new listGalleries() code, the order that the galleries are returned in
is no longer guaranteed to be parent-child in all cases (maybe it wasn't
before either, but it always seemed to work that way for me).
h
Patched files:
xppublish.php
templates/xppublish/list.inc
-------------- next part --------------
Index: xppublish.php
===================================================================
RCS file: /usr/local/horde/cvs/ansel/xppublish.php,v
retrieving revision 1.18
diff -u -r1.18 xppublish.php
--- xppublish.php 4 Feb 2004 17:39:58 -0000 1.18
+++ xppublish.php 20 Mar 2004 04:43:33 -0000
@@ -82,10 +82,18 @@
}
// Check if a gallery was selected from the list.
+$allgalleries = Ansel::listGalleries(PERMS_EDIT);
+if ($prefs->getValue('groupby') == 'owner') {
+ foreach (array_keys($allgalleries) as $owner) {
+ $galleries = array_merge($galleries, $allgalleries[$owner]['galleries']);
+ }
+} else {
+ $galleries = $allgalleries['list']['galleries'];
+}
if ($cmd == 'select') {
if (!$galleryId) {
$error = _("No gallery specified.") . "<br />\n";
- } elseif (!array_key_exists($galleryId, Ansel::listGalleries(PERMS_EDIT))) {
+ } elseif (!array_key_exists($galleryId, $galleries)) {
$error = _("You cannot add photos in that gallery.");
} else {
$error = false;
-------------- next part --------------
Index: templates/xppublish/list.inc
===================================================================
RCS file: /usr/local/horde/cvs/ansel/templates/xppublish/list.inc,v
retrieving revision 1.8
diff -u -r1.8 list.inc
--- templates/xppublish/list.inc 14 Jan 2004 12:54:28 -0000 1.8
+++ templates/xppublish/list.inc 20 Mar 2004 04:26:51 -0000
@@ -12,10 +12,26 @@
// Display all galleries that the user can edit.
$galleries = Ansel::listGalleries(PERMS_EDIT);
-foreach ($galleries as $id => $gallery) {
- $sel = ($galleryId == $id) ? ' selected="selected"' : '';
- $indent = substr_count($id, ':');
- echo '<option value="' . htmlspecialchars($id) . '"' . $sel . '>' . str_repeat(' ', 2 * $indent) . htmlspecialchars($gallery->get('name')) . '</option>';
+if ($prefs->getValue('groupby') == 'owner') {
+ $keys = array_keys($galleries);
+} else {
+ $keys = array( 'list' );
+}
+foreach ($keys as $id => $key) {
+ foreach ($galleries[$key]['galleries'] as $id => $gallery) {
+ $sel = ($galleryId == $id) ? ' selected="selected"' : '';
+ //$indent = substr_count($id, ':');
+ $p = $gallery; $gs = array();
+ while (is_a($p = $p->getParent(),'DataTreeObject_Gallery')) {
+ $gs[] = $p->get('name');
+ }
+ if (count($gs)) {
+ $gs = array_reverse($gs);
+ $prename = implode(' : ',$gs) . ' : ';
+ }
+ //echo '<option value="' . htmlspecialchars($id) . '"' . $sel . '>' . str_repeat(' ', 2 * $indent) . htmlspecialchars($gallery->get('name')) . '</option>';
+ echo '<option value="' . htmlspecialchars($id) . '"' . $sel . '>' . $prename . htmlspecialchars($gallery->get('name')) . '</option>';
+ }
}
?>
</select>
More information about the ansel
mailing list