Update of /cvsroot/gallery/gallery2/modules/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4692/modules/core Modified Files: ItemAddChildren.inc ItemAdmin.inc ItemEditAlbum.inc ItemMove.inc ItemReorder.inc module.inc Log Message: * Moved the code to fetch child ids into GalleryChildEntityHelper_simple and made it part of the core API. Now, we always return child ids in the desired album order and pay attention to permissions, except when we specifically use the API that ignores permissions (which is useful in cases where we're doing system level data maintenance like rebalancing an item's children) * Changed GalleryItem::itemTypeName() to return two names, one for embedding and one for titles. Index: ItemAddChildren.inc =================================================================== RCS file: /cvsroot/gallery/gallery2/modules/core/ItemAddChildren.inc,v retrieving revision 1.44 retrieving revision 1.45 diff -u -d -r1.44 -r1.45 --- ItemAddChildren.inc 27 Feb 2004 09:58:26 -0000 1.44 +++ ItemAddChildren.inc 29 Feb 2004 07:31:40 -0000 1.45 @@ -329,18 +329,21 @@ if (!$platform->is_dir($filePath) && $platform->is_readable($filePath)){ $mimeType = GalleryUtilities::getMimeType($fileName); if (!isset($mimeTypeItemMap[$mimeType])) { - list ($ret, $mimeTypeItemMap[$mimeType]) = + list ($ret, $mimeTypeItemMap[$mimeType]['instance']) = GalleryCoreApi::newItemByMimeType($mimeType); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); } + + $mimeTypeItemMap[$mimeType]['names'] = + $mimeTypeItemMap[$mimeType]['instance']->itemTypeName(); } $form['localServerFiles'][] = array('dirName' => $path, 'fileName' => $fileName, 'stat' => $platform->stat($filePath), - 'itemType' => $mimeTypeItemMap[$mimeType]->itemTypeName(), + 'itemType' => $mimeTypeItemMap[$mimeType]['names'][0], 'fileKey' => $fileName); } } @@ -349,10 +352,13 @@ } else if ($platform->is_file($path) && !$platform->is_link($path)) { $mimeType = GalleryUtilities::getMimeType($path); if (!isset($mimeTypeItemMap[$mimeType])) { - list ($ret, $mimeTypeItemMap[$mimeType]) = GalleryCoreApi::newItemByMimeType($mimeType); + list ($ret, $mimeTypeItemMap[$mimeType]['instance']) = + GalleryCoreApi::newItemByMimeType($mimeType); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); } + $mimeTypeItemMap[$mimeType]['names'] = + $mimeTypeItemMap[$mimeType]['instance']->itemTypeName(); } $dirName = dirname($path); @@ -361,7 +367,7 @@ array('dirName' => $dirName, 'fileName' => $fileName, 'stat' => $platform->stat($path), - 'itemType' => $mimeTypeItemMap[$mimeType]->itemTypeName(), + 'itemType' => $mimeTypeItemMap[$mimeType]['names'][0], 'fileKey' => htmlentities($fileName)); } $localServerFileCount = sizeof($form['localServerFiles']); @@ -485,11 +491,13 @@ } if (!isset($mimeTypeItemMap[$mimeType])) { - list ($ret, $mimeTypeItemMap[$mimeType]) = + list ($ret, $mimeTypeItemMap[$mimeType]['instance']) = GalleryCoreApi::newItemByMimeType($mimeType); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); } + $mimeTypeItemMap[$mimeType]['names'] = + $mimeTypeItemMap[$mimeType]['instance']->itemTypeName(); } if (empty($urlComponents['host'])) { @@ -510,7 +518,7 @@ $form['webPageUrls'][] = array('url' => $tmp, - 'itemType' => $mimeTypeItemMap[$mimeType]->itemTypeName()); + 'itemType' => $mimeTypeItemMap[$mimeType]['names'][0]); } $webPageUrlCount = sizeof($form['webPageUrls']); } Index: ItemAdmin.inc =================================================================== RCS file: /cvsroot/gallery/gallery2/modules/core/ItemAdmin.inc,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- ItemAdmin.inc 14 Feb 2004 07:22:49 -0000 1.28 +++ ItemAdmin.inc 29 Feb 2004 07:31:40 -0000 1.29 @@ -140,7 +140,7 @@ } /* Load the item's parents */ - list ($ret, $parents) = $item->fetchParents(); + list ($ret, $parents) = GalleryCoreApi::fetchParents($item); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); } Index: ItemEditAlbum.inc =================================================================== RCS file: /cvsroot/gallery/gallery2/modules/core/ItemEditAlbum.inc,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- ItemEditAlbum.inc 14 Feb 2004 07:22:49 -0000 1.30 +++ ItemEditAlbum.inc 29 Feb 2004 07:31:40 -0000 1.31 @@ -111,20 +111,20 @@ /* Load the children if we might need them */ if (isset($form['recreateThumbnails']) || isset($form['recreateResizes']) ) { - /* Get the child id => child types */ - list ($ret, $childIds) = $item->fetchChildIds(); + /* Get the child id => child types */ + list ($ret, $childIds) = GalleryCoreApi::fetchChildItemIds($item); + if ($ret->isError()) { + return array($ret->wrap(__FILE__, __LINE__), null); + } + + $childItems = array(); + if (!empty($childIds)) { + /* Load the children */ + list ($ret, $childItems) = GalleryCoreApi::loadEntitiesById($childIds); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); } - - $childItems = array(); - if (!empty($childIds)) { - /* Load the children */ - list ($ret, $childItems) = GalleryCoreApi::loadEntitiesById($childIds); - if ($ret->isError()) { - return array($ret->wrap(__FILE__, __LINE__), null); - } - } + } } $lockIds = array(); Index: ItemMove.inc =================================================================== RCS file: /cvsroot/gallery/gallery2/modules/core/ItemMove.inc,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- ItemMove.inc 14 Feb 2004 07:22:49 -0000 1.20 +++ ItemMove.inc 29 Feb 2004 07:31:40 -0000 1.21 @@ -74,7 +74,7 @@ } /* Load its parents: we don't want recursive moves */ - list($ret, $newParentAncestors) = $newParent->fetchParents(); + list($ret, $newParentAncestors) = GalleryCoreApi::fetchParents($newParent); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); } Index: ItemReorder.inc =================================================================== RCS file: /cvsroot/gallery/gallery2/modules/core/ItemReorder.inc,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- ItemReorder.inc 14 Feb 2004 07:22:49 -0000 1.8 +++ ItemReorder.inc 29 Feb 2004 07:31:40 -0000 1.9 @@ -200,7 +200,7 @@ } else { /* Get all peers that we can see */ - list ($ret, $peerIds) = $item->fetchChildIds(); + list ($ret, $peerIds) = GalleryCoreApi::fetchChildItemIds($item); if ($ret->isError()) { return array($ret->wrap(__FILE__, __LINE__), null); } Index: module.inc =================================================================== RCS file: /cvsroot/gallery/gallery2/modules/core/module.inc,v retrieving revision 1.95 retrieving revision 1.96 diff -u -d -r1.95 -r1.96 --- module.inc 14 Feb 2004 07:22:49 -0000 1.95 +++ module.inc 29 Feb 2004 07:31:40 -0000 1.96 @@ -560,22 +560,12 @@ 'subView' => 'core:ItemEditPermissions', 'itemId' => $item->getId())); } - - if (!$isRoot && isset($permissions['core.delete'])) { - if (GalleryUtilities::isA($item, 'GalleryAnimationItem')) { - $text = $this->translate('delete animation'); - } else if (GalleryUtilities::isA($item, 'GalleryPhotoItem')) { - $text = $this->translate('delete image'); - } else if (GalleryUtilities::isA($item, 'GalleryMovieItem')) { - $text = $this->translate('delete movie'); - } else if (GalleryUtilities::isA($item, 'GalleryAlbumItem')) { - $text = $this->translate('delete album'); - } else { - $text = $this->translate('delete item'); - } + $itemTypeNames = $item->itemTypeName(); + if (!$isRoot && isset($permissions['core.delete'])) { $links[$item->getId()][] = - array('text' => $text, + array('text' => $this->translate(array('text' => 'delete %s', + 'arg1' => $itemTypeNames[1])), 'params' => array('view' => 'core:ItemAdmin', 'return' => true, 'subView' => 'core:ItemDelete', @@ -592,20 +582,9 @@ } if (!$isRoot && isset($permissions['core.delete'])) { - if (GalleryUtilities::isA($item, 'GalleryAnimationItem')) { - $text = $this->translate('move animation'); - } else if (GalleryUtilities::isA($item, 'GalleryPhotoItem')) { - $text = $this->translate('move image'); - } else if (GalleryUtilities::isA($item, 'GalleryMovieItem')) { - $text = $this->translate('move movie'); - } else if (GalleryUtilities::isA($item, 'GalleryAlbumItem')) { - $text = $this->translate('move album'); - } else { - $text = $this->translate('move item'); - } - $links[$item->getId()][] = - array('text' => $text, + array('text' => $this->translate(array('text' => 'move %s', + 'arg1' => $itemTypeNames[1])), 'params' => array('view' => 'core:ItemAdmin', 'subView' => 'core:ItemMove', 'itemId' => $item->getParentId(), |