GalleryChildEntity * @g2 GalleryEntity * @g2 * @g2 1 * @g2 0 * @g2 * @g2 * * @package GalleryCore * @subpackage Classes * @author Bharat Mediratta * @version $Revision: 17580 $ */ class GalleryChildEntity extends GalleryEntity { /** * The id of the parent of this GalleryChildEntity * @var int * * @g2 * @g2 parentId * @g2 INTEGER * @g2 * @g2 * @g2 */ var $parentId; /** * Create this item in our persistent store * * @param int $parentId the id of the GalleryItem parent * @return GalleryStatus a status code */ function create($parentId) { global $gallery; if (empty($parentId)) { return GalleryCoreApi::error(ERROR_BAD_PARAMETER); } $ret = parent::create(); if ($ret) { return $ret; } /* Set the parent id */ $this->setParentId($parentId); return null; } /** * @see GalleryEntity::createLink */ function createLink($entity, $parentId) { global $gallery; $ret = parent::createLink($entity); if ($ret) { return $ret; } /* Set the parent id */ $this->setParentId($parentId); return null; } /** * Move this item to a new parent * * @param int $newParentId the id of the GalleryItem parent * @return GalleryStatus a status code */ function move($newParentId) { global $gallery; if (empty($newParentId)) { return GalleryCoreApi::error(ERROR_BAD_PARAMETER); } /* Set the new parent id */ $this->setParentId($newParentId); return null; } /** * Create a root level item. * This is a special case; every other GalleryChildEntry will have a * parent. But the root items don't have one. */ function createRoot() { $ret = parent::create(); if ($ret) { return $ret; } /* No parent for root */ $this->setParentId(0); return null; } /** * Get the parent instance * * @return array GalleryStatus a status code * GalleryItem the parent item */ function fetchParent() { global $gallery; $parentId = $this->getParentId(); if (isset($parentId)) { list ($ret, $parent) = GalleryCoreApi::loadEntitiesById($this->getParentId(), 'GalleryEntity'); if ($ret) { return array($ret, null); } } else { $parent = null; } return array(null, $parent); } /** * @see GalleryEntity::getClassName */ function getClassName() { return 'GalleryChildEntity'; } function getParentId() { return $this->parentId; } function setParentId($parentId) { $this->parentId = $parentId; } } ?>