From: Bharat M. <bh...@us...> - 2002-11-25 10:22:54
|
Update of /cvsroot/gallery/gallery2/layouts/classic In directory sc8-pr-cvs1:/tmp/cvs-serv32227/layouts/classic Modified Files: layout.inc Log Message: * Classic layout now displays number of children each album contains * GalleryDataItems have a new propery, "canBeViewedInline". The layout will use that to determine if the full size image should be displayed inline (like a photo) or if it should be downloaded externally (like a word document) - XXX: might want to make this an actual property of the item instead of a property of a specific class, so that we can support some GalleryMovieItem's that are inline and others that aren't * Fixed minor open_basedir issue with imagemagick module * Fixed bugs in the way that GalleryModule::getItemLinks were returning links. * Added GalleryItemHelper * Registered GalleryUnknownItem to hold any items with mime types that we don't explicitly support Index: layout.inc =================================================================== RCS file: /cvsroot/gallery/gallery2/layouts/classic/layout.inc,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- layout.inc 23 Nov 2002 01:06:19 -0000 1.17 +++ layout.inc 25 Nov 2002 10:22:50 -0000 1.18 @@ -85,15 +85,22 @@ $children = array(); /* Count the total number of children */ + /* XXX: we could combine this with the other getChildCounts() call below */ list ($ret, $totalChildCount) = - $item->fetchChildCount($gallery->getActiveUserId()); + GalleryItemHelper::getChildCounts(array($item->getId()), + $gallery->getActiveUserId()); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); } + if (empty($totalChildCount)) { + $totalChildCount = 0; + } else { + $totalChildCount = $totalChildCount[$item->getId()]; + } /* Get the child id => child types */ list ($ret, $childIds) = - $item->fetchChildren($gallery->getActiveUserId(), $start, $perPage); + $item->fetchChildIds($gallery->getActiveUserId(), $start, $perPage); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); } @@ -112,6 +119,13 @@ return array($ret->wrap(__FILE__, __LINE__), null); } + /* Get the "grandchild" counts */ + list ($ret, $childCounts) = + GalleryItemHelper::getChildCounts($childIds, $gallery->getActiveUserId()); + if ($ret->isError()) { + return array($ret->wrap(__FILE__, __LINE__), null); + } + /* Create a table of child id -> child data */ $childTable = array(); foreach ($childEntities as $child) { @@ -123,6 +137,10 @@ } else { $childTable[$childId]['moduleSummaries'] = array(); } + + if (!empty($childCounts[$childId])) { + $childTable[$childId]['childCount'] = $childCounts[$childId]; + } } /* Load the thumbnails */ @@ -233,6 +251,7 @@ $imageViews = array(); /* Load the resizes */ + $gallery->debug('XXX: missing view-resize permission check'); list ($ret, $resizes) = GalleryDerivativeHelper::fetchResizesByItemIds(array($item->getId())); if ($ret->isError()) { @@ -243,13 +262,15 @@ if (empty($imageViewsIndex)) { $imageViewsIndex = 0; } - - $gallery->debug('XXX: missing view-resize permission check'); - foreach ($resizes[$item->getId()] as $resize) { - $imageViews[] = array('height' => $resize->getHeight(), - 'width' => $resize->getWidth(), - 'size' => $resize->getDerivativeSize(), - 'id' => $resize->getId()); + + if (!empty($resizes)) { + foreach ($resizes[$item->getId()] as $resize) { + $imageViews[] = array('inline' => true, + 'height' => $resize->getHeight(), + 'width' => $resize->getWidth(), + 'size' => $resize->getDerivativeSize(), + 'id' => $resize->getId()); + } } /* Add the full version */ @@ -265,16 +286,21 @@ if (is_subclass_of($item, 'GalleryDataItem')) { $dataItem = array('size' => $item->getSize(), 'id' => $item->getId()); - - if (is_subclass_of($item, 'GalleryDataItem')) { + + if ($item->canBeViewedInline()) { + $dataItem['inline'] = true; $dataItem['height'] = $item->getHeight(); $dataItem['width'] = $item->getWidth(); + } else { + $dataItem['inline'] = false; } + $imageViews[] = $dataItem; } } else { $preferred = $preferred[$item->getId()]; - $imageViews[] = array('height' => $preferred->getHeight(), + $imageViews[] = array('inline' => true, + 'height' => $preferred->getHeight(), 'width' => $preferred->getWidth(), 'size' => $preferred->getDerivativeSize(), 'id' => $preferred->getId()); @@ -296,7 +322,7 @@ /* Count the total number peers */ /* Get the child id => child types */ list ($ret, $peerIds) = - $parent->fetchChildren($gallery->getActiveUserId()); + $parent->fetchChildIds($gallery->getActiveUserId()); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); } |