[prev in list] [next in list] [prev in thread] [next in thread]
List: gallery-checkins
Subject: [Gallery-checkins] CVS: gallery2/modules/core/classes GalleryItemHelper.class,NONE,1.1 GalleryDataIt
From: Bharat Mediratta <bharat () users ! sourceforge ! net>
Date: 2002-11-25 10:22:54
[Download RAW message or body]
Update of /cvsroot/gallery/gallery2/modules/core/classes
In directory sc8-pr-cvs1:/tmp/cvs-serv32227/modules/core/classes
Modified Files:
GalleryDataItem.class GalleryItem.class GalleryLayout.class
GalleryPermissionMap.class GalleryPhotoItem.class
GalleryUtilities.class
Added Files:
GalleryItemHelper.class
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
***** Error reading new file[Errno 2] No such file or directory: 'GalleryItemHelper.class'
Index: GalleryDataItem.class
===================================================================
RCS file: /cvsroot/gallery/gallery2/modules/core/classes/GalleryDataItem.class,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- GalleryDataItem.class 22 Nov 2002 23:42:09 -0000 1.11
+++ GalleryDataItem.class 25 Nov 2002 10:22:51 -0000 1.12
@@ -92,6 +92,19 @@
*/
/**
+ * Data items that can be viewed inline (photos, movies, etc) should return
+ * true. Items that can't be viewed inline (word documents, text, etc)
+ * should return false.
+ *
+ * Classes that return true for this query must implement getWidth() and getHeight()
+ *
+ * @return boolean true if this data item can be viewed inline
+ */
+ function canBeViewedInline() {
+ return false;
+ }
+
+ /**
* Create a new instance of this type in the persistent store.
*
* @access public
Index: GalleryItem.class
===================================================================
RCS file: /cvsroot/gallery/gallery2/modules/core/classes/GalleryItem.class,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- GalleryItem.class 21 Nov 2002 21:37:07 -0000 1.35
+++ GalleryItem.class 25 Nov 2002 10:22:51 -0000 1.36
@@ -24,20 +24,6 @@
* ****************************************
*/
-/**
- * Order in an ascending fashion
- *
- * @constant ORDER_ASCENDING
- */
-define('ORDER_ASCENDING', 1);
-
-/**
- * Order in an descending fashion
- *
- * @constant ORDER_DESCENDING
- */
-define('ORDER_DESCENDING', 2);
-
/* Load the parent class */
require_once(dirname(__FILE__) . '/GalleryFileSystemEntity.class');
@@ -365,142 +351,6 @@
}
/**
- * Return the id of the GalleryDerivativeImage that is the thumbnail for
- * this item.
- *
- * @return array object GalleryStatus a status code
- * int an id, null if there is none
- */
- function fetchThumbnailId() {
- global $gallery;
-
-
- list ($ret, $thumbnailTable) =
- GalleryDerivative::fetchDerivatives($this->getId(),
- DERIVATIVE_TYPE_IMAGE_THUMBNAIL);
- if ($ret->isError()) {
- return array($ret->wrap(__FILE__, __LINE__), null);
- }
-
- $thumbnailId = null;
- if (!empty($thumbnailTable[$this->getId()])) {
- $thumbnailId = $thumbnailTable[$this->getId()][0];
- }
-
- return array(GalleryStatus::success(), $thumbnailId);
- }
-
- /**
- * Return the number of children in this Entity that are visible to the
- * user specified.
- *
- * @access public
- * @return array object GalleryStatus a status code
- * int a count
- */
- function fetchChildCount($userId) {
- global $gallery;
-
- $where = '[GalleryChildEntity::parentId] = ?';
- $data[] = $this->getId();
-
- $where .= ' AND [GalleryPermissionMap::itemId] = [GalleryChildEntity::id]';
-
- /* Figure out what groups this user is in. */
- list ($ret, $groupIds) =
- GalleryUserGroupMap::fetchGroupsForUser($userId);
- if ($ret->isError()) {
- return array($ret->wrap(__FILE__, __LINE__), null);
- }
- $groupIdString = join(', ', array_values($groupIds));
-
- $where .= ' AND';
- $where .= ' ([GalleryItem::ownerId] = ? OR';
- $data[] = $userId;
- $where .= ' (([GalleryPermissionMap::groupId] IN (' .
- $groupIdString . ')';
- $where .= ' OR [GalleryPermissionMap::userId] = ?)';
- $data[] = $userId;
- $where .= ' AND';
- $where .= ' [GalleryPermissionMap::permission] IN (?, ?, ?)))';
- $data = array_merge($data, array('core.view', 'core.viewAll', 'core.all'));
-
- list ($ret, $searchResults) =
- $gallery->search(array('select' => 'COUNT(DISTINCT([GalleryChildEntity::id]))',
- 'where' => $where),
- $data);
- if ($ret->isError()) {
- return array($ret->wrap(__FILE__, __LINE__), null);
- }
-
- $ids = array();
- $result = $searchResults->nextResult();
- $count = $result[0];
- return array(GalleryStatus::success(), $count);
- }
-
- /**
- * Return the ids of the children of this entity, in the order specified
- * by the orderBy field and the direction specified by the orderDirection
- * field, that are visible to the given user.
- *
- * @param int the user id of the user making the request
- * @param int where to start
- * @param int how many to return
- *
- * @access public
- * @return array object GalleryStatus a status code
- * array integer ids
- */
- function fetchChildrenWithTypes($userId, $offset=null, $count=null) {
- global $gallery;
-
- $where = '[GalleryChildEntity::parentId] = ?';
- $data[] = $this->getId();
-
- $where .= ' AND [GalleryPermissionMap::itemId] = [GalleryChildEntity::id]';
-
- /* Figure out what groups this user is in. */
- list ($ret, $groupIds) =
- GalleryUserGroupMap::fetchGroupsForUser($userId);
- if ($ret->isError()) {
- return array($ret->wrap(__FILE__, __LINE__), null);
- }
- $groupIdString = join(', ', array_values($groupIds));
-
- $where .= ' AND';
- $where .= ' ([GalleryItem::ownerId] = ? OR';
- $data[] = $userId;
- $where .= ' (([GalleryPermissionMap::groupId] IN (' .
- $groupIdString . ')';
- $where .= ' OR [GalleryPermissionMap::userId] = ?)';
- $data[] = $userId;
- $where .= ' AND';
- $where .= ' [GalleryPermissionMap::permission] IN (?, ?, ?)))';
- $data = array_merge($data, array('core.view', 'core.viewAll', 'core.all'));
-
- $orderBy = $this->_fetchOrderClause();
- list ($ret, $searchResults) =
- $gallery->search(array('select' => ('DISTINCT([GalleryChildEntity::id]), ' .
- '[GalleryEntity::entityType]'),
- 'where' => $where,
- 'order-by' => $orderBy,
- 'limit' => array('count' => $count,
- 'offset' => $offset)),
- $data);
- if ($ret->isError()) {
- return array($ret->wrap(__FILE__, __LINE__), null);
- }
-
- $ids = array();
- while ($result = $searchResults->nextResult()) {
- $ids[$result[0]] = $result[1];
- }
-
- return array(GalleryStatus::success(), $ids);
- }
-
- /**
* Determine the sort order clause from this items settings
*
* @return string an order clause
@@ -571,7 +421,7 @@
* @return array object GalleryStatus a status code
* array integer ids
*/
- function fetchChildren($userId, $offset=null, $count=null) {
+ function fetchChildIds($userId, $offset=null, $count=null) {
global $gallery;
$where = '[GalleryChildEntity::parentId] = ?';
@@ -579,30 +429,15 @@
$where .= ' AND [GalleryPermissionMap::itemId] = [GalleryChildEntity::id]';
- /* Figure out what groups this user is in. */
- list ($ret, $groupIds) =
- GalleryUserGroupMap::fetchGroupsForUser($userId);
- if ($ret->isError()) {
- return array($ret->wrap(__FILE__, __LINE__), null);
- }
- $groupIdString = join(', ', array_values($groupIds));
-
- $where .= ' AND';
- $where .= ' ([GalleryItem::ownerId] = ? OR';
- $data[] = $userId;
- $where .= ' (([GalleryPermissionMap::groupId] IN (' .
- $groupIdString . ')';
- $where .= ' OR [GalleryPermissionMap::userId] = ?)';
- $data[] = $userId;
- $where .= ' AND';
- $where .= ' [GalleryPermissionMap::permission] IN (?, ?, ?)))';
- $data = array_merge($data, array('core.view', 'core.viewAll', 'core.all'));
+ list ($clause, $clauseData) =
+ GalleryItemHelper::getViewPermissionClause($userId);
+ $where .= ' AND ' . $clause;
+ $data = array_merge($data, $clauseData);
- $orderBy = $this->_fetchOrderClause();
list ($ret, $searchResults) =
$gallery->search(array('select' => 'DISTINCT([GalleryChildEntity::id])',
'where' => $where,
- 'order-by' => $orderBy,
+ 'order-by' => $this->_fetchOrderClause(),
'limit' => array('count' => $count,
'offset' => $offset)),
$data);
@@ -616,6 +451,35 @@
}
return array(GalleryStatus::success(), $ids);
+ }
+
+ /**
+ * Return the children of this entity, in the order specified by the
+ * orderBy field and the direction specified by the orderDirection field,
+ * that are visible to the given user.
+ *
+ * @param int the user id of the user making the request
+ * @param int where to start
+ * @param int how many to return
+ *
+ * @access public
+ * @return array object GalleryStatus a status code
+ * array integer ids
+ */
+ function fetchChildren($userId, $offset=null, $count=null) {
+ global $gallery;
+
+ list ($ret, $childIds) = $this->fetchChildIds($userId, $offset, $count);
+ if ($ret->isError()) {
+ return array($ret->wrap(__FILE__, __LINE__), null);
+ }
+
+ list ($ret, $children) = $gallery->loadEntitiesById($childIds);
+ if ($ret->isError()) {
+ return array($ret->wrap(__FILE__, __LINE__), null);
+ }
+
+ return array(GalleryStatus::success(), $children);
}
/**
Index: GalleryLayout.class
===================================================================
RCS file: /cvsroot/gallery/gallery2/modules/core/classes/GalleryLayout.class,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- GalleryLayout.class 5 Nov 2002 09:57:11 -0000 1.9
+++ GalleryLayout.class 25 Nov 2002 10:22:51 -0000 1.10
@@ -147,6 +147,10 @@
$links[$moduleName][$i]['url'] =
$templateAdapter->url($links[$moduleName][$i]['params']);
}
+
+ if (empty($links[$moduleName])) {
+ unset($links[$moduleName]);
+ }
}
GalleryProfiler::stop('GalleryLayout::_getModuleSystemLinks');
@@ -201,15 +205,12 @@
return array($ret->wrap(__FILE__, __LINE__), null);
}
- /* Turn the URL params into an actual URL */
- foreach ($moduleLinks as $itemId => $links) {
- $moduleLinks[$itemId]['url'] =
- $templateAdapter->url($moduleLinks[$itemId]['params']);
- }
-
/* Refactor into: array[itemId][moduleName][links] */
foreach ($moduleLinks as $itemId => $links) {
- $itemLinks[$itemId][$moduleName] = $links;
+ foreach ($links as $link) {
+ $link['url'] = $templateAdapter->url($link['params']);
+ $itemLinks[$itemId][$moduleName][] = $link;
+ }
}
}
Index: GalleryPermissionMap.class
===================================================================
RCS file: /cvsroot/gallery/gallery2/modules/core/classes/GalleryPermissionMap.class,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- GalleryPermissionMap.class 22 Nov 2002 23:42:09 -0000 1.10
+++ GalleryPermissionMap.class 25 Nov 2002 10:22:51 -0000 1.11
@@ -84,7 +84,10 @@
function registerPermission($id, $description, $isItemAdmin=false) {
$registry =& GalleryPermissionMap::_getPermissionRegistry();
$registry['id'][$id] = $description;
- $registry['itemAdmin'][$id] = $isItemAdmin;
+
+ if ($isItemAdmin) {
+ $registry['itemAdmin'][$id] = $isItemAdmin;
+ }
}
/**
Index: GalleryPhotoItem.class
===================================================================
RCS file: /cvsroot/gallery/gallery2/modules/core/classes/GalleryPhotoItem.class,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- GalleryPhotoItem.class 22 Nov 2002 23:42:09 -0000 1.6
+++ GalleryPhotoItem.class 25 Nov 2002 10:22:51 -0000 1.7
@@ -80,6 +80,13 @@
*/
/**
+ * @see GalleryDataItem::canBeViewedInline()
+ */
+ function canBeViewedInline() {
+ return true;
+ }
+
+ /**
* Create a new ImageContainer from an image file
*
* @param int the id of the parent GalleryItem
Index: GalleryUtilities.class
===================================================================
RCS file: /cvsroot/gallery/gallery2/modules/core/classes/GalleryUtilities.class,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- GalleryUtilities.class 22 Nov 2002 23:42:09 -0000 1.19
+++ GalleryUtilities.class 25 Nov 2002 10:22:51 -0000 1.20
@@ -325,6 +325,7 @@
'png' => 'image/png',
'gif' => 'image/gif',
'jpe' => 'image/jpeg',
+ 'txt' => 'text/plain',
// All the rest, sorted alphabetically
'Z' => 'application/x-compress',
@@ -440,7 +441,6 @@
'tiff' => 'image/tiff',
'tr' => 'application/x-troff',
'tsv' => 'text/tab-separated-values',
- 'txt' => 'text/plain',
'ustar' => 'application/x-ustar',
'vcd' => 'application/x-cdlink',
'vrml' => 'model/vrml',
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
__[ g a l l e r y - c h e c k i n s ]_________________________
[ list info/archive --> http://gallery.sf.net/lists.php ]
[ gallery info/FAQ/download --> http://gallery.sf.net ]
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic