summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbitweaver.org <bitweaver@users.sourceforge.net>2005-06-19 04:36:24 +0000
committerbitweaver.org <bitweaver@users.sourceforge.net>2005-06-19 04:36:24 +0000
commitcf071b67f1000864b864aedb3e294cbaf0509f73 (patch)
tree641097ba8de3271ac243806c9ec90b1237e8c9f6
downloadfisheye-cf071b67f1000864b864aedb3e294cbaf0509f73.tar.gz
fisheye-cf071b67f1000864b864aedb3e294cbaf0509f73.tar.bz2
fisheye-cf071b67f1000864b864aedb3e294cbaf0509f73.zip
IMPORT TikiPro CLYDE FINAL
-rw-r--r--.htaccess5
-rw-r--r--FisheyeBase.php243
-rw-r--r--FisheyeGallery.php511
-rw-r--r--FisheyeImage.php427
-rw-r--r--admin/admin_fisheye_inc.php136
-rw-r--r--admin/schema_inc.php97
-rw-r--r--bit_setup_inc.php20
-rw-r--r--browse.php15
-rw-r--r--display_fisheye_gallery_inc.php54
-rw-r--r--display_fisheye_image_inc.php41
-rw-r--r--edit.php111
-rw-r--r--edit_gallery_perms.php55
-rw-r--r--edit_image.php98
-rw-r--r--find_user.php21
-rw-r--r--gallery_lookup_inc.php24
-rw-r--r--gallery_tree.php11
-rw-r--r--icons/locked.gifbin0 -> 571 bytes
-rw-r--r--icons/pkg_fisheye.pngbin0 -> 5111 bytes
-rw-r--r--icons/rotate_ccw.pngbin0 -> 646 bytes
-rw-r--r--icons/rotate_cw.pngbin0 -> 661 bytes
-rw-r--r--image/generating_thumbnails.pngbin0 -> 4410 bytes
-rw-r--r--image/no_image.pngbin0 -> 1840 bytes
-rw-r--r--image_lookup_inc.php42
-rw-r--r--image_order.php129
-rw-r--r--index.php3
-rw-r--r--list_galleries.php39
-rw-r--r--templates/admin_fisheye.tpl121
-rw-r--r--templates/authenticate.tpl21
-rw-r--r--templates/browse_galleries.tpl25
-rw-r--r--templates/center_list_galleries.php30
-rw-r--r--templates/center_list_galleries.tpl1
-rw-r--r--templates/center_list_images.php37
-rw-r--r--templates/center_list_images.tpl24
-rw-r--r--templates/create_collection.tpl29
-rw-r--r--templates/edit_collection.tpl13
-rw-r--r--templates/edit_gallery.tpl116
-rw-r--r--templates/edit_gallery_perms.tpl73
-rw-r--r--templates/edit_image.tpl122
-rw-r--r--templates/find_user.tpl62
-rw-r--r--templates/gallery_nav.tpl42
-rw-r--r--templates/gallery_tree.tpl12
-rw-r--r--templates/image_order.tpl153
-rw-r--r--templates/list_galleries.tpl101
-rw-r--r--templates/menu_fisheye.tpl27
-rw-r--r--templates/menu_fisheye_admin.tpl1
-rw-r--r--templates/resize_image_select.tpl17
-rw-r--r--templates/upload_fisheye.tpl63
-rw-r--r--templates/user_galleries.tpl1
-rw-r--r--templates/view_gallery.tpl79
-rw-r--r--templates/view_image.tpl51
-rwxr-xr-xthumbnailer.php80
-rw-r--r--upload.php253
-rw-r--r--view.php25
-rw-r--r--view_image.php26
54 files changed, 3687 insertions, 0 deletions
diff --git a/.htaccess b/.htaccess
new file mode 100644
index 0000000..2179703
--- /dev/null
+++ b/.htaccess
@@ -0,0 +1,5 @@
+<IfModule mod_rewrite.c>
+ RewriteEngine on
+ RewriteRule ^image/([0-9]+)(/[0-9/]+)*/?([A-Za-z]+)*$ view_image.php?image_id=$1&gallery_path=$2&size=$3 [L,QSA]
+ RewriteRule ^gallery([0-9/]+)*/([0-9]+)/?$ view.php?gallery_id=$2&gallery_path=$1 [L,QSA]
+</IfModule>
diff --git a/FisheyeBase.php b/FisheyeBase.php
new file mode 100644
index 0000000..eab66cf
--- /dev/null
+++ b/FisheyeBase.php
@@ -0,0 +1,243 @@
+<?php
+require_once( LIBERTY_PKG_PATH.'LibertyAttachable.php' ); // FisheyeGallery base class
+
+class FisheyeBase extends LibertyAttachable
+{
+ // Path of gallery images to get breadcrumbs
+ var $mGalleryPath;
+
+ function FisheyeBase() {
+ $this->mGalleryPath = '';
+ if( get_class( $this ) == 'fisheyegallery' ) {
+ LibertyContent::LibertyContent();
+ } else {
+ LibertyAttachable::LibertyAttachable();
+ }
+ }
+
+ // regular expression to determine if the title was computer generated
+ function isMachineName( $pString ) {
+ return( preg_match( '/(^[0-9][-0-9 ]*$)|(^[-0-9 ]*(img|dsc|dscn|pict|htg|dscf)[-0-9 ]*$)/i', $pString ) );
+ }
+
+ // Gets a list of galleries which this item is attached to
+ function getParentGalleries( $pContentId=NULL ) {
+ if( empty( $pContentId ) ) {
+ $pContentId = $this->mContentId;
+ }
+ $ret = NULL;
+
+ if( is_numeric( $pContentId ) ) {
+ $sql = "SELECT tfg.`gallery_id` AS `hash_key`, tfg.*, tc.`title`
+ FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery` tfg, `".BIT_DB_PREFIX."tiki_content` tc, `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map` tfgim
+ WHERE tfgim.`item_content_id` = ? AND tfgim.`gallery_content_id`=tfg.`content_id` AND tfg.`content_id`=tc.`content_id`";
+ $ret = $this->getAssoc( $sql, array( $pContentId ) );
+ }
+ return $ret;
+ }
+
+ function loadParentGalleries() {
+ if( $this->isValid() ) {
+ $this->mInfo['parent_galleries'] = $this->getParentGalleries();
+ }
+ }
+
+ function updatePosition($pGalleryContentId, $newPosition = NULL) {
+ if( $pGalleryContentId && $newPosition && !empty($this->mContentId) ) {
+ $sql = "UPDATE `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map` SET `position` = ? WHERE `item_content_id` = ? AND `gallery_content_id` = ?";
+ $rs = $this->query($sql, array($newPosition, $this->mContentId, $pGalleryContentId));
+ }
+ }
+
+ function setGalleryPath( $pPath ) {
+ $this->mGalleryPath = rtrim( $pPath, '/' );
+ }
+
+
+ // THis is a function that creates a mack daddy function to get a breadcrumb path with a single query.
+ // Do not muck with this query unless you really, truly understand what is going on.
+ function getBreadcrumbLinks() {
+ $ret = '';
+ if( !empty( $this->mGalleryPath ) ) {
+ $path = split( '/', ltrim( $this->mGalleryPath, '/' ) );
+ $p = 0;
+ $c = 1;
+ $joinSql = '';
+ $selectSql = '';//AS title$g, tfg$g.gallery_id AS gallery_id$g";
+ $whereSql = '';
+ $bindVars = array();
+ foreach( $path as $galleryId ) {
+ if( $galleryId ) {
+ $p++; $c++;
+ $selectSql .= " tc$p.`title` AS `title$p`, tfg$p.`gallery_id` AS `gallery_id$p`,";
+ $joinSql .= " `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map` tfgim$p
+ INNER JOIN `".BIT_DB_PREFIX."tiki_content` tc$p ON(tfgim$p.`gallery_content_id`=tc$p.`content_id`)
+ INNER JOIN `".BIT_DB_PREFIX."tiki_fisheye_gallery` tfg$p ON(tfg$p.`content_id`=tc$p.`content_id`),";
+ $whereSql .= " tfg$p.`gallery_id`=? AND tfgim$p.`item_content_id`=tc$c.`content_id` AND ";
+ array_push( $bindVars, $galleryId );
+ }
+ }
+// $selectSql .= " tc$c.title AS title$c ";//AS title$g, tfg$g.gallery_id AS gallery_id$g";
+ $joinSql .= " `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map` tfgim$c
+ INNER JOIN `".BIT_DB_PREFIX."tiki_content` tc$c ON(tfgim$c.`item_content_id`=tc$c.`content_id`) ";
+ $whereSql .= " tc$c.`content_id`=? AND tfgim$c.`gallery_content_id`=tc$p.`content_id` ";
+ array_push( $bindVars, $this->mContentId );
+ $rs = $this->query( "SELECT ".rtrim( $selectSql, ',')." FROM ".rtrim( $joinSql, ',')." WHERE $whereSql", $bindVars );
+ if( !empty( $rs->fields ) ) {
+ $path = '';
+ for( $i = 1; $i <= (count( $rs->fields ) / 2); $i++ ) {
+ $ret .= ' <a href="'.FisheyeGallery::getDisplayUrl( $rs->fields['gallery_id'.$i], $path ).'" >'.$rs->fields['title'.$i].'</a> &raquo; ';
+ $path .= '/'.$rs->fields['gallery_id'.$i];
+ }
+ }
+ $ret .= $this->getTitle();
+ }
+ return $ret;
+ }
+
+
+ function addToGalleries( $pGalleryArray ) {
+ if( $this->isValid() ) {
+ $inGalleries = $this->GetAssoc( "SELECT `gallery_id`,`gallery_content_id` FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map` tfgim INNER JOIN `".BIT_DB_PREFIX."tiki_fisheye_gallery` tfg ON (tfgim.`gallery_content_id`=tfg.`content_id`) WHERE `item_content_id` = ?", array( $this->mContentId ) );
+ $galleries = array();
+ if( count( $pGalleryArray ) ) {
+ foreach( $pGalleryArray as $galleryId ) {
+ // image has been requested to be put in a new gallery
+ if( empty( $inGalleries[$galleryId] ) ) {
+ if( empty( $galleries[$galleryId] ) ) {
+ $galleries[$galleryId] = new FisheyeGallery( $galleryId );
+ $galleries[$galleryId]->load();
+ }
+ if( $galleries[$galleryId]->isValid() ) {
+ if( $galleries[$galleryId]->hasUserPermission( 'bit_p_edit_fisheye' ) ) {
+ $galleries[$galleryId]->addItem( $this->mContentId );
+ } else {
+ $this->mErrors[] = "You do not have permission to attach ".$this->getTitle()." to ".$galleries[$galleryId]->getTitle();
+ }
+ }
+ } else {
+ // image already in an existing gallery.
+ unset( $inGalleries[$galleryId] );
+ }
+ }
+ }
+ if( count( $inGalleries ) ) {
+ // if we have any left over in the inGalleries array, we should delete them. these were the "unchecked" boxes
+ foreach( $inGalleries as $galleryId ) {
+ $sql = "DELETE FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map` WHERE `gallery_content_id` = ? AND `item_content_id` = ?";
+ $rs = $this->query($sql, array( $galleryId, $this->mContentId ) );
+ }
+ }
+ }
+ }
+
+ function isInGallery( $pGalleryContentId, $pItemContentId = NULL) {
+ if( empty( $pItemContentId ) ) {
+ $pItemContentId = $this->mContentId;
+ }
+ $ret = FALSE;
+ if ($this->mGalleryId && $pGalleryContentId) {
+ $sql = "SELECT count(`item_content_id`) as `item_count`
+ FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map`
+ WHERE `gallery_content_id` = ? AND `item_content_id` = ?";
+ $rs = $this->query($sql, array($pGalleryContentId, $pItemContentId));
+ if ($rs->fields['item_count'] > 0) {
+ $ret = TRUE;
+ }
+ }
+ return $ret;
+ }
+
+ function isProtected() {
+ $ret = FALSE;
+ if (!empty($this->mInfo['access_level']) && ($this->mInfo['access_level'] == GATEKEEPER_ACCESS_PROTECTED || $this->mInfo['access_level'] == GATEKEEPER_ACCESS_PROTECTED_HIDDEN)) {
+ $ret = TRUE;
+ }
+ return $ret;
+ }
+
+
+ function validateUserAccess( $pAnswer=NULL ) {
+ $ret = FALSE;
+ if( isset( $_SESSION['gatekeeper_security'][$this->mInfo['security_id']] ) && ($_SESSION['gatekeeper_security'][$this->mInfo['security_id']] == md5( $this->mInfo['access_answer'] )) ) {
+ $ret = TRUE;
+ } elseif( strtoupper( trim( $pAnswer ) ) == strtoupper( trim($this->mInfo['access_answer']) ) ) {
+ $_SESSION['gatekeeper_security'][$this->mInfo['security_id']] = md5( $this->mInfo['access_answer'] );
+ $ret = TRUE;
+ }
+ return $ret;
+ }
+
+
+ /**
+ * Overloaded function that determines if this content can be edited by the current gBitUser
+ * @return the fully specified path to file to be included
+ */
+ function hasUserAccess( $pPermName ) {
+ // assume true for now
+ $ret = FALSE;
+ if( $this->isValid() && !($ret = $this->isOwner()) ) {
+ if( !($ret = empty($this->mInfo['security_id'] ) ) ) {
+ // order matters here!
+ if( $this->mInfo['is_hidden'] == 'y' ) {
+ $ret = TRUE;
+ }
+ if( $this->mInfo['is_private'] == 'y' ) {
+ $ret = $this->isOwner();
+ }
+ if( !empty( $this->mInfo['access_answer'] ) ) {
+ $ret = $this->validateUserAccess();
+ }
+ }
+/*
+ if( $pPermName == 'bit_p_edit_fisheye' ) {
+ if( !($ret = $this->isOwner()) ) {
+ global $gBitUser;
+ if( !($ret = $gBitUser->isAdmin()) ) {
+ if( $this->loadPermissions() ) {
+ $userPerms = $this->getUserPermissions( $gBitUser->mUserId );
+ $ret = isset( $userPerms[$pPermName]['user_id'] ) && ( $userPerms[$pPermName]['user_id'] == $gBitUser->mUserId );
+ }
+ }
+ vd( $ret );
+ }
+
+ } else {
+ $ret = LibertyContent::hasUserPermission( $pPermName );
+ }
+*/
+ }
+ return( $ret );
+ }
+
+
+ /**
+ * Overloaded function that determines if this content can be edited by the current gBitUser
+ * @return the fully specified path to file to be included
+ */
+ function hasUserPermission( $pPermName, $pFatalIfFalse=FALSE, $pFatalMessage=NULL ) {
+ $ret = FALSE;
+ if( $pPermName == 'bit_p_edit_fisheye' ) {
+ if( !($ret = $this->isOwner()) ) {
+ global $gBitUser;
+ if( !($ret = $gBitUser->isAdmin()) ) {
+ if( $this->loadPermissions() ) {
+ $userPerms = $this->getUserPermissions( $gBitUser->mUserId );
+ $ret = isset( $userPerms[$pPermName]['user_id'] ) && ( $userPerms[$pPermName]['user_id'] == $gBitUser->mUserId );
+ }
+ }
+ }
+ } else {
+ $ret = LibertyContent::hasUserPermission( $pPermName, $pFatalMessage );
+ }
+ if( !$ret && $pFatalIfFalse ) {
+ global $gBitSystem;
+ $gBitSystem->fatalPermission( $pPermName, $pFatalIfFalse=FALSE, $pFatalMessage=NULL );
+ }
+
+ return( $ret );
+ }
+
+
+}
+?>
diff --git a/FisheyeGallery.php b/FisheyeGallery.php
new file mode 100644
index 0000000..d5c354d
--- /dev/null
+++ b/FisheyeGallery.php
@@ -0,0 +1,511 @@
+<?php
+require_once( FISHEYE_PKG_PATH.'FisheyeImage.php' ); // A gallery is composed of FisheyeImages
+
+define('FISHEYEGALLERY_CONTENT_TYPE_GUID', 'fisheyegallery' );
+
+// FisheyeBase extends LibertyAttachable, which this class doesn't need, but we need a common base class
+
+class FisheyeGallery extends FisheyeBase {
+ var $mGalleryId; // tiki_fisheye_gallery.gallery_id
+ var $mItems; // Array of FisheyeImage class instances which belong to this gallery
+
+ function FisheyeGallery($pGalleryId = NULL, $pContentId = NULL) {
+ FisheyeBase::FisheyeBase(); // Call base constructor
+ $this->mGalleryId = $pGalleryId; // Set member variables according to the parameters we were passed
+ $this->mContentId = $pContentId; // tiki_content.content_id which this gallery references
+ $this->mItems = NULL; // Assume no images (if $pAutoLoad is TRUE we will populate this array later)
+
+ // This registers the content type for FishEye galleries
+ // FYI: Any class which uses a table which inherits from tiki_content should create their own content type(s)
+ $this->registerContentType(FISHEYEGALLERY_CONTENT_TYPE_GUID, array('content_type_guid' => FISHEYEGALLERY_CONTENT_TYPE_GUID,
+ 'content_description' => 'Image Gallery',
+ 'handler_class' => 'FisheyeGallery',
+ 'handler_package' => 'fisheye',
+ 'handler_file' => 'FisheyeGallery.php',
+ 'maintainer_url' => 'http://www.bitweaver.org'
+ ) );
+ }
+
+ function isValid() {
+ return( !empty( $this->mGalleryId ) || !empty( $this->mContentId ) );
+ }
+
+ function load( $pCurrentImageId=NULL ) {
+ global $gBitSystem;
+ if(!empty($this->mGalleryId)) {
+ $mid = " WHERE fg.`gallery_id` = ?";
+ $bindVars = array($this->mGalleryId);
+ } elseif (!empty($this->mContentId)) {
+ $mid = " WHERE fg.`content_id` = ?";
+ $bindVars = array($this->mContentId);
+ } else {
+ $mid = $bindVars = NULL;
+ }
+
+ if ($mid) { // If we have some way to know what tiki_fisheye_gallery row to load...
+ $gateSql = NULL;
+ if( $gBitSystem->isPackageActive( 'gatekeeper' ) ) {
+ $gateSql = ' ,ts.`security_id`, ts.`security_description`, ts.`is_private`, ts.`is_hidden`, ts.`access_question`, ts.`access_answer` ';
+ $mid = " LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_content_security_map` tcs ON ( tc.`content_id`=tcs.`content_id` ) LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_security` ts ON ( tcs.`security_id`=ts.`security_id` ) ".$mid;
+ }
+
+ $query = "SELECT fg.*, tc.* $gateSql
+ , uue.`login` AS modifier_user, uue.`real_name` AS `modifier_real_name`
+ , uuc.`login` AS creator_user, uuc.`real_name` AS `creator_real_name`
+ FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery` fg, `".BIT_DB_PREFIX."tiki_content` tc
+ LEFT JOIN `".BIT_DB_PREFIX."users_users` uue ON (uue.`user_id` = tc.`modifier_user_id`)
+ LEFT JOIN `".BIT_DB_PREFIX."users_users` uuc ON (uuc.`user_id` = tc.`user_id`)
+ $mid AND fg.`content_id` = tc.`content_id`";
+
+ if( $rs = $this->query($query, $bindVars) ) {
+ $this->mInfo = $rs->fields;
+ $this->mContentId = $rs->fields['content_id'];
+ LibertyContent::load();
+ if (!empty($this->mInfo['gallery_id'])) {
+
+ $this->mGalleryId = $this->mInfo['gallery_id'];
+ $this->mContentId = $this->mInfo['content_id'];
+
+ $this->mInfo['creator'] = (isset( $rs->fields['creator_real_name'] ) ? $rs->fields['creator_real_name'] : $rs->fields['creator_user'] );
+ $this->mInfo['editor'] = (isset( $rs->fields['modifier_real_name'] ) ? $rs->fields['modifier_real_name'] : $rs->fields['modifier_user'] );
+
+ // Set some basic defaults for how to display a gallery if they're not already set
+ if (empty($this->mInfo['thumbnail_size'])) {
+ $this->mInfo['thumbnail_size'] = $this->getPreference('fisheye_gallery_default_thumbnail_size',FISHEYE_DEFAULT_THUMBNAIL_SIZE);
+ }
+ if (empty($this->mInfo['rows_per_page'])) {
+ $this->mInfo['rows_per_page'] = $this->getPreference('fisheye_gallery_default_rows_per_page', FISHEYE_DEFAULT_ROWS_PER_PAGE);
+ }
+ if (empty($this->mInfo['cols_per_page'])) {
+ $this->mInfo['cols_per_page'] = $this->getPreference('fisheye_gallery_default_cols_per_page', FISHEYE_DEFAULT_COLS_PER_PAGE);
+ }
+ if (empty($this->mInfo['access_answer'])) {
+ $this->mInfo['access_answer'] = '';
+ }
+
+ $this->mInfo['images_per_page'] = ($this->mInfo['cols_per_page'] * $this->mInfo['rows_per_page']);
+
+ $this->mInfo['num_images'] = $this->getImageCount();
+ $this->mInfo['num_pages'] = (int)($this->mInfo['num_images'] / $this->mInfo['images_per_page'] + ($this->mInfo['num_images'] % $this->mInfo['images_per_page'] == 0 ? 0 : 1));
+
+ } else {
+ unset( $this->mContentId );
+ unset( $this->mGalleryId );
+ }
+ if( !empty( $pCurrentImageId ) ) {
+ // this code sucks but works - XOXO spiderr
+ $query = "SELECT tfgim.*,tfi.`image_id`
+ FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map` tfgim
+ INNER JOIN `".BIT_DB_PREFIX."tiki_fisheye_image` tfi ON ( tfi.`content_id`=tfgim.`item_content_id` )
+ WHERE tfgim.`gallery_content_id` = ?
+ ORDER BY tfgim.`position`, tfi.`content_id` ";
+ if( $rs = $this->query($query, array( $this->mContentId ) ) ) {
+ $rows = $rs->getRows();
+ for( $i = 0; $i < count( $rows ); $i++ ) {
+ if( $rows[$i]['image_id'] == $pCurrentImageId ) {
+ if( $i > 0 ) {
+ $this->mInfo['previous_image_id'] = $rows[$i-1]['image_id'];
+ }
+ if( $i + 1 < count( $rows ) ) {
+ $this->mInfo['next_image_id'] = $rows[$i+1]['image_id'];
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return count($this->mInfo);
+ }
+
+ function loadImages($pOffset = NULL, $pMaxRows = NULL) {
+ global $gLibertySystem, $gBitSystem, $gBitUser;
+ if (!$this->mGalleryId || !$this->mContentId) {
+ return NULL;
+ }
+
+ $bindVars = array($this->mContentId);
+ $mid = '';
+ $where = '';
+ $select = '';
+ $join = '';
+ if( $gBitSystem->isPackageActive( 'gatekeeper' ) ) {
+ $select .= ' ,ts.`security_id`, ts.`security_description`, ts.`is_private`, ts.`is_hidden`, ts.`access_question`, ts.`access_answer` ';
+ $join .= " LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_content_security_map` tcs ON (tc.`content_id`=tcs.`content_id`) LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_security` ts ON (ts.`security_id`=tcs.`security_id` )";
+// $where = ' AND (tcs.`security_id` IS NULL OR tc.`user_id`=?) ';
+// $bindVars[] = $gBitUser->mUserId;
+ }
+ $this->mItems = NULL;
+
+ $query = "SELECT tfgim.*, tc.`content_type_guid`, tc.`user_id` $select
+ FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map` tfgim INNER JOIN `".BIT_DB_PREFIX."tiki_content` tc ON ( tc.`content_id`=tfgim.`item_content_id` ) $join
+ WHERE tfgim.`gallery_content_id` = ? $where
+ ORDER BY tfgim.`position`, tfgim.`item_content_id` $mid";
+ $rs = $this->query($query, $bindVars, $pMaxRows, $pOffset);
+
+ $rows = $rs->getRows();
+ foreach ($rows as $row) {
+ $pass = TRUE;
+ if( $gBitSystem->isPackageActive( 'gatekeeper' ) ) {
+ $pass = empty( $row['security_id'] ) || ( $row['user_id'] == $gBitUser->mUserId ) || !empty( $_SESSION['gatekeeper_security'][$row['security_id']] );
+ }
+ if( $pass && $item = $gLibertySystem->getLibertyObject( $row['item_content_id'], $row['content_type_guid'] ) ) {
+ $item->loadThumbnail( $this->mInfo['thumbnail_size'] );
+ $item->setGalleryPath( $this->mGalleryPath.'/'.$this->mGalleryId );
+ $item->mInfo['position'] = $row['position'];
+ $this->mItems[] = $item;
+ }
+ }
+ return count( $this->mItems );
+ }
+
+ function exportHtml( $pData = NULL ) {
+ $ret = NULL;
+ $ret[] = array( 'type' => FISHEYEGALLERY_CONTENT_TYPE_GUID,
+ 'landscape' => FALSE,
+ 'url' => $this->getDisplayUrl(),
+ 'content_id' => $this->mContentId,
+ );
+ if( $this->loadImages() ) {
+ foreach( array_keys( $this->mItems ) as $key ) {
+ $ret[] = $this->mItems[$key]->exportHtml();
+ }
+ }
+ return $ret;
+ }
+
+ function getImageCount() {
+ $ret = 0;
+
+ if ($this->mGalleryId) {
+ $query = "SELECT COUNT(*) AS `count`
+ FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map`
+ WHERE `gallery_content_id` = ?";
+ $rs = $this->query($query, array($this->mContentId));
+ $ret = $rs->fields['count'];
+ }
+ return $ret;
+ }
+
+ function verifyGalleryData(&$pStorageHash) {
+ global $gBitSystem;
+
+ if (empty($pStorageHash['rows_per_page'])) {
+ $pStorageHash['rows_per_page'] = $gBitSystem->getPreference('fisheye_gallery_default_rows_per_page', (!empty($this->mInfo['rows_per_page']) ? $this->mInfo['rows_per_page'] : FISHEYE_DEFAULT_ROWS_PER_PAGE));
+ }
+
+ if (empty($pStorageHash['cols_per_page'])) {
+ $pStorageHash['cols_per_page'] = $gBitSystem->getPreference('fisheye_gallery_default_cols_per_page', (!empty($this->mInfo['cols_per_page']) ? $this->mInfo['cols_per_page'] : FISHEYE_DEFAULT_COLS_PER_PAGE));
+ }
+
+ if (empty($pStorageHash['thumbnail_size'])) {
+ $pStorageHash['thumbnail_size'] = $gBitSystem->getPreference('fisheye_gallery_default_thumbnail_size', (!empty($this->mInfo['thumbnail_size']) ? $this->mInfo['thumbnail_size'] : FISHEYE_DEFAULT_THUMBNAIL_SIZE));
+ }
+
+ if (empty($pStorageHash['title'])) {
+ $this->mErrors[] = "You must specify a title for this image gallery";
+ }
+
+ if (empty($pStorageHash['edit'])) {
+ $pStorageHash['edit'] = (!empty($this->mInfo['data']) ? $this->mInfo['data'] : '');
+ }
+
+ $pStorageHash['content_type_guid'] = FISHEYEGALLERY_CONTENT_TYPE_GUID;
+
+ return (count($this->mErrors) == 0);
+ }
+
+
+ function generateThumbnails() {
+ if( $this->isValid() ) {
+ if( $this->loadImages() ) {
+ foreach( array_keys( $this->mItems ) as $key ) {
+ $this->mItems[$key]->generateThumbnails();
+ }
+ }
+ }
+ }
+
+
+ function getThumbnailUrl() {
+ if( empty( $this->mInfo['preview_content'] ) ) {
+ $this->loadThumbnail();
+ }
+
+ if( is_object( $this->mInfo['preview_content'] ) ) {
+ return $this->mInfo['preview_content']->getThumbnailUrl();
+ }
+ }
+
+
+ function getThumbnailImage( $pContentId=NULL, $pThumbnailContentId=NULL, $pThumbnailContentType=NULL ) {
+ global $gLibertySystem;
+ $ret = NULL;
+
+ if( empty( $pContentId ) ) {
+ $pContentId = $this->mContentId;
+ }
+
+ if( empty( $pThumbnailContentId ) ) {
+ if( !empty( $this->mInfo['preview_content_id'] ) ) {
+ $pThumbnailContentId = $this->mInfo['preview_content_id'];
+ } else {
+ $query = "SELECT tfgim.`item_content_id`, tc.`content_type_guid`
+ FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map` tfgim INNER JOIN `".BIT_DB_PREFIX."tiki_content` tc ON ( tfgim.`item_content_id`=tc.`content_id` )
+ WHERE tfgim.`gallery_content_id` = ?
+ ORDER BY ".$this->convert_sortmode('random');
+ $rs = $this->query($query, array( $pContentId ), 1);
+ $pThumbnailContentId = $rs->fields['item_content_id'];
+ $pThumbnailContentType = $rs->fields['content_type_guid'];
+ }
+ }
+
+ if( !empty( $pThumbnailContentId ) ) {
+ $ret = $gLibertySystem->getLibertyObject( $pThumbnailContentId, $pThumbnailContentType );
+ $ret->load();
+ if( get_class( $ret ) == 'fisheyegallery' ) {
+ //recurse down in to find the first image
+ $ret = $ret->getThumbnailImage();
+ }
+ }
+ return $ret;
+ }
+
+
+ function loadThumbnail( $pSize='small', $pContentId=NULL ) {
+ $this->mInfo['preview_content'] = $this->getThumbnailImage( $pContentId );
+ }
+
+
+ function storeGalleryThumbnail($pContentId = NULL) {
+ $ret = FALSE;
+ if ($pContentId && !$this->isInGallery( $this->mContentId, $pContentId ) ) {
+ return FALSE;
+ }
+ if ($this->mGalleryId) {
+ if (!$pContentId)
+ $pContentId = NULL;
+ $query = "UPDATE `".BIT_DB_PREFIX."tiki_fisheye_gallery` SET `preview_content_id` = ? WHERE `gallery_id`= ?";
+ $rs = $this->query($query, array($pContentId, $this->mGalleryId));
+ $ret = TRUE;
+ }
+ return $ret;
+ }
+
+ function store(&$pStorageHash) {
+ if ($this->verifyGalleryData($pStorageHash)) {
+ $this->mDb->StartTrans();
+ if( LibertyContent::store($pStorageHash)) {
+ $this->mContentId = $pStorageHash['content_id'];
+ $this->mInfo['content_id'] = $this->mContentId;
+ if ($this->galleryExistsInDatabase()) {
+ $query = "UPDATE `".BIT_DB_PREFIX."tiki_fisheye_gallery`
+ SET `rows_per_page` = ?, `cols_per_page` = ?, `thumbnail_size` = ?
+ WHERE `gallery_id` = ?";
+ $bindVars = array($pStorageHash['rows_per_page'], $pStorageHash['cols_per_page'], $pStorageHash['thumbnail_size'], $this->mGalleryId);
+ } else {
+ $this->mGalleryId = $this->mDb->GenID('tiki_fisheye_gallery_id_seq');
+ $this->mInfo['gallery_id'] = $this->mGalleryId;
+ $query = "INSERT INTO `".BIT_DB_PREFIX."tiki_fisheye_gallery` (`gallery_id`, `content_id`, `rows_per_page`, `cols_per_page`, `thumbnail_size`) VALUES (?,?,?,?,?)";
+ $bindVars = array($this->mGalleryId, $this->mContentId, $pStorageHash['rows_per_page'], $pStorageHash['cols_per_page'], $pStorageHash['thumbnail_size']);
+ }
+ $rs = $this->query($query, $bindVars);
+ $this->mDb->mDb->CompleteTrans();
+ } else {
+ $this->mDb->mDb->RollbackTrans();
+ $this->mErrors[] = "There were errors while attempting to save this gallery";
+ }
+ } else {
+ $this->mErrors[] = "There were errors while attempting to save this gallery";
+ }
+
+ return (count($this->mErrors) == 0);
+ }
+
+ function removeItem( $pContentId ) {
+ $ret = FALSE;
+ if( $this->isValid() && is_numeric( $pContentId ) ) {
+ $query = "DELETE FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map`
+ WHERE `item_content_id`=? AND `gallery_content_id`=?";
+ $rs = $this->query($query, array($pContentId, $this->mContentId ) );
+ $ret = TRUE;
+ }
+ return $ret;
+ }
+
+ function addItem( $pContentId ) {
+ $ret = FALSE;
+ if( $this->isValid() && is_numeric( $pContentId ) && ( $this->mContentId != $pContentId ) && !$this->isInGallery( $this->mContentId, $pContentId ) ) {
+ $query = "INSERT INTO `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map` (`item_content_id`, `gallery_content_id`) VALUES (?,?)";
+ $rs = $this->query($query, array($pContentId, $this->mContentId ) );
+ $ret = TRUE;
+ }
+ return $ret;
+ }
+
+ function expunge( $pRecursiveDelete = FALSE ) {
+//$this->debug();
+ if( $this->isValid() ) {
+ $this->mDb->StartTrans();
+
+
+ if( $this->loadImages() ) {
+ foreach( array_keys( $this->mItems ) as $key ) {
+ if( $pRecursiveDelete ) {
+ $this->mItems[$key]->expunge( $pRecursiveDelete );
+ } elseif( $this->mItems[$key]->mInfo['content_type_guid'] == FISHEYEIMAGE_CONTENT_TYPE_GUID ) {
+ $query = "SELECT COUNT(`item_content_id`) AS `other_gallery`
+ FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map`
+ WHERE `item_content_id`=? AND `gallery_content_id`!=?";
+ if( $rs = $this->query($query, array($this->mItems[$key]->mContentId, $this->mContentId ) ) ) {
+ if( empty( $rs->fields['other_gallery'] ) ) {
+ $this->mItems[$key]->expunge();
+ }
+ }
+ }
+ }
+ }
+
+ $query = "DELETE FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map` WHERE `gallery_content_id`=?";
+ $rs = $this->query($query, array( $this->mContentId ) );
+ $query = "DELETE FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map` WHERE `item_content_id`=?";
+ $rs = $this->query($query, array( $this->mContentId ) );
+ $query = "DELETE FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery` WHERE `content_id`=?";
+ $rs = $this->query($query, array( $this->mContentId ) );
+ if( LibertyContent::expunge() ) {
+ $this->mDb->CompleteTrans();
+ } else {
+ $this->mDb->RollbackTrans();
+vd( $this->mErrors );
+ }
+ }
+//$this->debug(0);
+ return( count( $this->mErrors ) == 0 );
+ }
+
+
+ function galleryExistsInDatabase() {
+ $ret = FALSE;
+
+ if (!empty($this->mGalleryId)) {
+ $query = "SELECT COUNT(`gallery_id`) AS `count`
+ FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery`
+ WHERE `gallery_id` = ?";
+ $rs = $this->query($query, array($this->mGalleryId));
+ if ($rs->fields['count'] > 0)
+ $ret = TRUE;
+ }
+
+ return $ret;
+ }
+
+ /**
+ * Returns include file that will
+ * @return the fully specified path to file to be included
+ */
+ function getRenderFile() {
+ return FISHEYE_PKG_PATH."display_fisheye_gallery_inc.php";
+ }
+
+ /**
+ * Function that returns link to display a piece of content
+ * @param pGalleryId id of gallery to link
+ * @return the url to display the gallery.
+ */
+ function getDisplayUrl( $pGalleryId=NULL, $pPath=NULL ) {
+ $ret = FISHEYE_PKG_URL;
+ if( empty( $pGalleryId ) ) {
+ $pGalleryId = $this->mGalleryId;
+ $pPath = $this->mGalleryPath;
+ }
+ if( is_numeric( $pGalleryId ) ) {
+ global $gBitSystem;
+ if( $gBitSystem->isFeatureActive( 'pretty_urls' ) ) {
+ $ret .= 'gallery'.$pPath.'/'.$pGalleryId;
+ } else {
+ $ret .= 'view.php?gallery_id='.$pGalleryId;
+ if( !empty( $pPath ) ) {
+ $ret .= '&gallery_path='.$pPath;
+ }
+ }
+ } elseif( !empty( $pImageId['content_id'] ) ) {
+ $ret = FISHEYE_PKG_URL.'view_image.php?content_id='.$pImageId['content_id'];
+ }
+ return $ret;
+ }
+
+
+
+ function getList( &$pListHash ) {
+// function getList($pUserId = NULL, $pFindString = NULL, $pSortMode = NULL, $pMaxRows = NULL) {
+ global $gBitUser,$gBitSystem, $commentsLib;
+
+ $this->prepGetList( $pListHash );
+ $bindVars = array();
+ $select = '';
+ $mid = '';
+ $join = '';
+
+ $mapJoin = empty( $pListHash['show_empty'] ) ? ' INNER JOIN ' : ' LEFT OUTER JOIN ';
+ // this *has* to go first because of bindVars order
+ if( empty( $pListHash['show_empty'] ) ) {
+ // This will nicely pull out the unused rows, but it is dog slow
+// $join .= " INNER JOIN `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map` tfgim ON (tfgim.`gallery_content_id`=tc.`content_id`) ";
+ $mid = '';
+ }
+
+ if( !empty( $pListHash['root_only'] ) ) {
+ $join .= " LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map` tfgim2 ON (tfgim2.`item_content_id`=tc.`content_id`)";
+ $mid .= ' AND tfgim2.`item_content_id` IS NULL ';
+ }
+ if( !empty( $pListHash['contain_item'] ) ) {
+ $select = " , tfgim3.`item_content_id` AS `in_gallery` ";
+ $join .= " LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map` tfgim3 ON (tfgim3.`gallery_content_id`=tc.`content_id`) AND tfgim3.`item_content_id`=? ";
+ $bindVars[] = $pListHash['contain_item'];
+ }
+ if( !empty( $pListHash['user_id'] ) && is_numeric( $pListHash['user_id'] )) {
+ $mid .= " AND tc.`user_id` = ? ";
+ $bindVars[] = $pListHash['user_id'];
+ }
+ if( !empty( $pListHash['search'] ) ) {
+ $mid .= " AND UPPER(tc.`title`) LIKE ? ";
+ $bindVars[] = '%'.strtoupper( $pListHash['search'] ).'%';
+ }
+ if( $gBitSystem->isPackageActive( 'gatekeeper' ) ) {
+ $select .= ' ,ts.`security_id`, ts.`security_description`, ts.`is_private`, ts.`is_hidden`, ts.`access_question`, ts.`access_answer` ';
+ $join .= " LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_content_security_map` tcs ON (tc.`content_id`=tcs.`content_id`) LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_security` ts ON (ts.`security_id`=tcs.`security_id` )";
+ $mid .= ' AND (tcs.`security_id` IS NULL OR tc.`user_id`=?) ';
+ $bindVars[] = $gBitUser->mUserId;
+ }
+
+ if ( !empty( $pListHash['sort_mode'] ) ) {
+ //converted in prepGetList()
+ $mid .= " ORDER BY ".$this->convert_sortmode( $pListHash['sort_mode'] )." ";
+ }
+
+ $query = "SELECT DISTINCT( tfg.`gallery_id` ) AS `hash_key`, tfg.*, tc.*, uu.`login`, uu.`real_name`, ptc.`content_type_guid` AS `preview_content_type_guid` $select
+ FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery` tfg LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_content` ptc ON( tfg.`preview_content_id`=ptc.`content_id` ), `".BIT_DB_PREFIX."users_users` uu, `".BIT_DB_PREFIX."tiki_content` tc $join
+ WHERE tfg.`content_id` = tc.`content_id` AND uu.`user_id` = tc.`user_id` $mid";
+ if( $rs = $this->query( $query, $bindVars, $pListHash['max_records'],$pListHash['offset'] ) ) {
+ $ret = $rs->GetAssoc();
+ if( empty( $pListHash['no_thumbnails'] ) ) {
+ $thumbsize = !empty( $pListHash['thumbnail_size'] ) ? $pListHash['thumbnail_size'] : 'small';
+ foreach( array_keys( $ret ) as $galleryId ) {
+ $ret[$galleryId]['display_url'] = $this->getDisplayUrl( $galleryId );
+ if( $thumbImage = $this->getThumbnailImage( $ret[$galleryId]['content_id'], $ret[$galleryId]['preview_content_id'], $ret[$galleryId]['preview_content_type_guid'] ) ) {
+ $ret[$galleryId]['thumbnail_url'] = $thumbImage->getThumbnailUrl( $thumbsize );
+ } elseif( !empty( $pListHash['show_empty'] ) ) {
+ $ret[$galleryId]['thumbnail_url'] = FISHEYE_PKG_URL.'image/no_image.png';
+ } else {
+ unset( $ret[$galleryId] );
+ }
+ }
+ }
+ }
+
+ return $ret;
+ }
+}
+
+?>
diff --git a/FisheyeImage.php b/FisheyeImage.php
new file mode 100644
index 0000000..ce33e0a
--- /dev/null
+++ b/FisheyeImage.php
@@ -0,0 +1,427 @@
+<?php
+require_once( FISHEYE_PKG_PATH.'FisheyeBase.php' );
+
+define('FISHEYEIMAGE_CONTENT_TYPE_GUID', 'fisheyeimage');
+
+class FisheyeImage extends FisheyeBase {
+ var $mImageId;
+
+ function FisheyeImage($pImageId = NULL, $pContentId = NULL) {
+ FisheyeBase::FisheyeBase();
+ $this->mImageId = $pImageId;
+ $this->mContentId = $pContentId;
+
+ $this->registerContentType(FISHEYEIMAGE_CONTENT_TYPE_GUID, array('content_type_guid' => FISHEYEIMAGE_CONTENT_TYPE_GUID,
+ 'content_description' => 'Image',
+ 'handler_class' => 'FisheyeImage',
+ 'handler_package' => 'fisheye',
+ 'handler_file' => 'FisheyeImage.php',
+ 'maintainer_url' => 'http://www.bitweaver.org'
+ ) );
+ }
+
+ function load() {
+ if( $this->isValid() ) {
+ global $gBitSystem, $gBitUser;
+ $gateSql = NULL;
+ $mid = NULL;
+ if ($this->mImageId && is_numeric($this->mImageId)) {
+ $mid = " WHERE tfi.`image_id` = ?";
+ $bindVars = array($this->mImageId);
+ } elseif ($this->mContentId && is_numeric($this->mContentId)) {
+ $mid = " WHERE tfi.`content_id` = ?";
+ $bindVars = array($this->mContentId);
+ }
+ if( $gBitSystem->isPackageActive( 'gatekeeper' ) ) {
+ $gateSql = ' ,ts.`security_id`, ts.`security_description`, ts.`is_private`, ts.`is_hidden`, ts.`access_question`, ts.`access_answer` ';
+ $mid = " LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_content_security_map` tcs ON ( tc.`content_id`=tcs.`content_id` ) LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_security` ts ON ( tcs.`security_id`=ts.`security_id` ) ".$mid;
+ }
+ $sql = "SELECT tfi.*, tc.* $gateSql
+ , uue.`login` AS `modifier_user`, uue.`real_name` AS `modifier_real_name`
+ , uuc.`login` AS `creator_user`, uuc.`real_name` AS `creator_real_name`
+ FROM `".BIT_DB_PREFIX."tiki_fisheye_image` tfi, `".BIT_DB_PREFIX."tiki_content` tc
+ LEFT JOIN `".BIT_DB_PREFIX."users_users` uue ON (uue.`user_id` = tc.`modifier_user_id`)
+ LEFT JOIN `".BIT_DB_PREFIX."users_users` uuc ON (uuc.`user_id` = tc.`user_id`)
+ $mid AND tc.`content_id` = tfi.`content_id`";
+ if( $rs = $this->query($sql, array($bindVars)) ) {
+ $this->mInfo = $rs->fields;
+
+ $this->mImageId = $this->mInfo['image_id'];
+ $this->mContentId = $this->mInfo['content_id'];
+
+ $this->mInfo['creator'] = (isset( $rs->fields['creator_real_name'] ) ? $rs->fields['creator_real_name'] : $rs->fields['creator_user'] );
+ $this->mInfo['editor'] = (isset( $rs->fields['modifier_real_name'] ) ? $rs->fields['modifier_real_name'] : $rs->fields['modifier_user'] );
+
+ LibertyAttachable::load();
+
+ if (!empty($this->mStorage) && count($this->mStorage) > 0) {
+ reset($this->mStorage);
+ $this->mInfo['image_file'] = current($this->mStorage);
+ } else {
+ $this->mInfo['image_file'] = NULL;
+ }
+ }
+ } else {
+ // We don't have an image_id or a content_id so there is no way to know what to load
+ return NULL;
+ }
+
+ return count($this->mInfo);
+ }
+
+ function exportHtml( $pData = NULL ) {
+// if( empty( $pData ) ) {
+// $pData = $this->mInfo['data'];
+// }
+// $ret = FisheyeBase::parseData( $pData );
+// $ret .= '<img src="'.$this->mInfo['image_file']['source_url'].'" width="400" height="300" />';
+ $ret = array( 'type' => FISHEYEIMAGE_CONTENT_TYPE_GUID,
+ 'landscape' => $this->isLandscape(),
+ 'url' => $this->getDisplayUrl(),
+ 'content_id' => $this->mContentId,
+ 'bleed' => TRUE,
+ );
+ return $ret;
+ }
+
+ function isLandscape() {
+ return( !empty( $this->mInfo['width'] ) && !empty( $this->mInfo['height'] ) && ($this->mInfo['width'] > $this->mInfo['height']) );
+ }
+
+ function verifyImageData(&$pStorageHash) {
+ $pStorageHash['content_type_guid'] = FISHEYEIMAGE_CONTENT_TYPE_GUID;
+
+ if ( empty($pStorageHash['purge_from_galleries']) ) {
+ $pStorageHash['purge_from_galleries'] = FALSE;
+ }
+
+ // let's add a default title
+ if( empty( $pStorageHash['title'] ) && !empty( $pStorageHash['upload']['name'] ) ) {
+ if( strpos( '.', $pStorageHash['upload']['name'] ) ) {
+ list( $defaultName, $ext ) = explode( '.', $pStorageHash['upload']['name'] );
+ } else {
+ $defaultName = $pStorageHash['upload']['name'];
+ }
+ $pStorageHash['title'] = str_replace( '_', ' ', substr( $defaultName, 0, strrpos( $defaultName, '.' ) ) );
+ }
+
+ if( !empty( $pStorageHash['resize'] ) ) {
+ $pStorageHash['upload']['max_height'] = $pStorageHash['upload']['max_width'] = $pStorageHash['resize'];
+ }
+
+ return (count($this->mErrors) == 0);
+ }
+
+ function store(&$pStorageHash) {
+ global $gBitSystem;
+ if ($this->verifyImageData($pStorageHash)) {
+ // Save the current attachment ID for the image attached to this FisheyeImage so we can
+ // delete it after saving the new one
+ if (!empty($this->mInfo['image_file']) && !empty($this->mInfo['image_file']['attachment_id']) && !empty($pStorageHash['upload'])) {
+ $currentImageAttachmentId = $this->mInfo['image_file']['attachment_id'];
+ } else {
+ $currentImageAttachmentId = NULL;
+ }
+
+ // LibertyAttachable will take care of thumbnail generation of the offline thumbnailer is not active
+ if( !empty( $pStorageHash['upload'] ) ) {
+ $pStorageHash['upload']['thumbnail'] = !$gBitSystem->isFeatureActive( 'feature_offline_thumbnailer' );
+ }
+ if( LibertyAttachable::store( $pStorageHash ) ) {
+ if ($currentImageAttachmentId) {
+ $this->expungeAttachment($currentImageAttachmentId);
+ }
+ $this->mContentId = $pStorageHash['content_id'];
+ $this->mInfo['content_id'] = $this->mContentId;
+
+ if (!empty($pStorageHash['STORAGE']['bitfile']['upload']['source_file'])) {
+ $imageDetails = $this->getImageDetails($pStorageHash['STORAGE']['bitfile']['upload']['source_file']);
+ } else {
+ $imageDetails = NULL;
+ }
+
+ if (!$imageDetails) {
+ $imageDetails['width'] = (!empty($this->mInfo['width']) ? $this->mInfo['width'] : NULL);
+ $imageDetails['height'] = (!empty($this->mInfo['height']) ? $this->mInfo['height'] : NULL);
+ }
+
+ if ($this->imageExistsInDatabase()) {
+ $sql = "UPDATE `".BIT_DB_PREFIX."tiki_fisheye_image`
+ SET `content_id` = ?, `width` = ?, `height` = ?
+ WHERE `image_id` = ?";
+ $bindVars = array($this->mContentId, $imageDetails['width'], $imageDetails['height'], $this->mImageId);
+ } else {
+ $this->mImageId = $this->mDb->GenID('tiki_fisheye_image_id_seq');
+ $this->mInfo['image_id'] = $this->mImageId;
+ $sql = "INSERT INTO `".BIT_DB_PREFIX."tiki_fisheye_image` (`image_id`, `content_id`, `width`, `height`) VALUES (?,?,?,?)";
+ $bindVars = array($this->mImageId, $this->mContentId, $imageDetails['width'], $imageDetails['height']);
+ }
+ $rs = $this->query($sql, $bindVars);
+
+ // check to see if we need offline thumbnailing
+ if( $gBitSystem->isFeatureActive( 'feature_offline_thumbnailer' ) ) {
+ $this->generateThumbnails();
+ }
+ }
+ } else {
+ $this->mErrors[] = "There were errors while attempting to save this gallery image";
+ }
+
+ return (count($this->mErrors) == 0);
+ }
+
+
+ function rotateImage( $pDegrees ) {
+ global $gBitSystem;
+ if( !empty( $this->mInfo['image_file'] ) || $this->load() ) {
+ $fileHash['source_file'] = BIT_ROOT_PATH.$this->mInfo['image_file']['storage_path'];
+ $fileHash['dest_base_name'] = preg_replace('/(.+)\..*$/', '$1', basename( $fileHash['source_file'] ) );
+ $fileHash['type'] = 'image/'.strtolower( substr( $fileHash['source_file'], (strrpos( $fileHash['source_file'], '.' )+1) ) );
+ $fileHash['size'] = filesize( $fileHash['source_file'] );
+ $fileHash['dest_path'] = dirname( $this->mInfo['image_file']['storage_path'] ).'/';
+ $fileHash['name'] = $this->mInfo['image_file']['filename'];
+ $fileHash['degrees'] = $pDegrees;
+ $rotateFunc = ($gBitSystem->getPreference( 'image_processor' ) == 'imagick' ) ? 'liberty_imagick_rotate_image' : 'liberty_gd_rotate_image';
+ if( $rotateFunc( $fileHash ) ) {
+ liberty_clear_thumbnails( $fileHash );
+ $this->generateThumbnails();
+ } else {
+ $this->mErrors['rotate'] = $fileHash['error'];
+ }
+ }
+ return (count($this->mErrors) == 0);
+ }
+
+
+ function resizeOriginal( $pResizeOriginal ) {
+ global $gBitSystem;
+ if( !empty( $this->mInfo['image_file'] ) || $this->load() ) {
+ $fileHash['source_file'] = BIT_ROOT_PATH.$this->mInfo['image_file']['storage_path'];
+ $fileHash['dest_base_name'] = preg_replace('/(.+)\..*$/', '$1', basename( $fileHash['source_file'] ) );
+ $fileHash['type'] = 'image/'.strtolower( substr( $fileHash['source_file'], (strrpos( $fileHash['source_file'], '.' )+1) ) );
+ $fileHash['size'] = filesize( $fileHash['source_file'] );
+ $fileHash['dest_path'] = dirname( $this->mInfo['image_file']['storage_path'] ).'/';
+ $fileHash['name'] = $this->mInfo['image_file']['filename'];
+ $fileHash['max_height'] = $fileHash['max_width'] = $pResizeOriginal;
+ $resizeFunc = ($gBitSystem->getPreference( 'image_processor' ) == 'imagick' ) ? 'liberty_imagick_resize_image' : 'liberty_gd_resize_image';
+ if( !$resizeFunc( $fileHash ) ) {
+ $this->mErrors['upload'] = $fileHash['errors'];
+ }
+ // Ack this is evil direct bashing of the liberty tables! XOXO spiderr
+ // should be a cleaner way eventually
+ $details = $this->getImageDetails( $fileHash['source_file'] );
+ $query = "UPDATE `".BIT_DB_PREFIX."tiki_files` SET `size`=? WHERE `file_id`=?";
+ $this->query( $query, array( $details['size'], $this->mInfo['image_file']['file_id'] ) );
+ $query = "UPDATE `".BIT_DB_PREFIX."tiki_fisheye_image` SET `width`=?, `height`=? WHERE `content_id`=?";
+ $this->query( $query, array( $details['width'], $details['height'], $this->mContentId ) );
+ }
+ return (count($this->mErrors) == 0);
+ }
+
+
+ function generateThumbnails( $pResizeOriginal=NULL ) {
+ global $gBitSystem;
+ // LibertyAttachable will take care of thumbnail generation of the offline thumbnailer is not active
+ if( $gBitSystem->isFeatureActive( 'feature_offline_thumbnailer' ) ) {
+ $query = "DELETE FROM `".BIT_DB_PREFIX."tiki_thumbnail_queue`
+ WHERE `content_id`=?";
+ $this->query( $query, array( $this->mContentId ) );
+ $query = "INSERT INTO `".BIT_DB_PREFIX."tiki_thumbnail_queue`
+ (`content_id`, `queue_date`, `resize_original`) VALUES (?,?,?)";
+ $this->query( $query, array( $this->mContentId, date('U'), $pResizeOriginal ) );
+ } else {
+ $this->renderThumbnails();
+ }
+ }
+
+
+ function renderThumbnails() {
+ if( !empty( $this->mInfo['image_file'] ) || $this->load() ) {
+ $fileHash['source_file'] = BIT_ROOT_PATH.$this->mInfo['image_file']['storage_path'];
+ $fileHash['type'] = 'image/'.strtolower( substr( $fileHash['source_file'], (strrpos( $fileHash['source_file'], '.' )+1) ) );
+ $fileHash['size'] = filesize( $fileHash['source_file'] );
+ $fileHash['dest_path'] = dirname( $this->mInfo['image_file']['storage_path'] ).'/';
+ $fileHash['name'] = $this->mInfo['image_file']['filename'];
+ // just generate thumbnails
+ liberty_generate_thumbnails( $fileHash );
+ if( !empty( $fileHash['error'] ) ) {
+ $this->mErrors['thumbnail'] = $fileHash['error'];
+ }
+ }
+ return( count($this->mErrors) == 0 );
+ }
+
+ // Get resolution, etc
+ function getImageDetails($pFilePath = NULL) {
+ $info = NULL;
+ $pFilePath = ($pFilePath ? $pFilePath : (empty($this->mInfo['image_file']['storage_path']) ? NULL : BIT_ROOT_PATH.$this->mInfo['image_file']['storage_path']));
+
+ if ($pFilePath && file_exists($pFilePath)) {
+ if( $info = getimagesize(rtrim($pFilePath)) ) {
+ $info['width'] = $info[0];
+ $info['height'] = $info[1];
+ $info['size'] = filesize($pFilePath);
+ }
+ }
+
+ return $info;
+ }
+
+ /**
+ * Returns include file that will
+ * @return the fully specified path to file to be included
+ */
+ function getRenderFile() {
+ return FISHEYE_PKG_PATH."display_fisheye_image_inc.php";
+ }
+
+ /**
+ * Function that returns link to display a piece of content
+ * @param pImageId id of gallery to link
+ * @param pMixed if a string, it is assumed to be the size, if an array, it is assumed to be a mInfo hash
+ * @return the url to display the gallery.
+ */
+ function getDisplayUrl( $pImageId=NULL, $pMixed=NULL ) {
+ if( empty( $pImageId ) ) {
+ $pImageId = $this->mImageId;
+ }
+
+ $size = ( !empty( $pMixed ) && isset( $this->mInfo['image_file']['thumbnail_url'][$pMixed] ) ) ? $pMixed : NULL ;
+ global $gBitSystem;
+ if( is_numeric( $pImageId ) ) {
+ if( $gBitSystem->isFeatureActive( 'pretty_urls' ) ) {
+ $ret = FISHEYE_PKG_URL.'image/'.$pImageId;
+ if( !empty( $this->mGalleryPath ) ) {
+ $ret .= $this->mGalleryPath;
+ }
+ if( $size ) {
+ $ret .= '/'.$pMixed;
+ }
+ } else {
+ $ret = FISHEYE_PKG_URL.'view_image.php?image_id='.$pImageId;
+ if( !empty( $this->mGalleryPath ) ) {
+ $ret .= '&gallery_path='.$this->mGalleryPath;
+ }
+ if( $size ) {
+ $ret .= '&size='.$pMixed;
+ }
+ }
+ } elseif( !empty( $pMixed['content_id'] ) ) {
+ $ret = FISHEYE_PKG_URL.'view_image.php?content_id='.$pMixed['content_id'];
+ }
+ return $ret;
+ }
+
+
+ function loadThumbnail( $pSize='small' ) {
+ $this->mInfo['image_file']['gallery_thumbnail_url'] = &$this->mInfo['image_file']['thumbnail_url'][$pSize];
+ }
+
+ function getThumbnailUrl( $pSize='small' ) {
+ if( empty( $this->mInfo['image_file']['gallery_thumbnail_url'] ) ) {
+ $this->loadThumbnail( $pSize );
+ }
+ // this is not the cleanest file_exists check, but has to be this way since $this->mInfo['image_file']*
+ // have BIT_ROOT_URL in them, and you will end up with dual prefixes if you do somethingn like
+ // file_exists( BIT_ROOT_PATH.$this->mInfo['image_file']['gallery_thumbnail_url'] )
+ if( !empty( $this->mInfo['image_file']['storage_path'] ) && file_exists( BIT_ROOT_PATH.dirname( $this->mInfo['image_file']['storage_path'] )."/$pSize.jpg" ) ) {
+ $ret = $this->mInfo['image_file']['gallery_thumbnail_url'];
+ } else {
+ $ret = FISHEYE_PKG_URL.'image/generating_thumbnails.png';
+ }
+
+ return $ret;
+ }
+
+ function expunge() {
+ if( $this->isValid() ) {
+ $this->mDb->StartTrans();
+ $query = "DELETE FROM `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map` WHERE `item_content_id` = ?";
+ $rs = $this->query($query, array( $this->mContentId ));
+ $query = "UPDATE `".BIT_DB_PREFIX."tiki_fisheye_gallery` SET `preview_content_id`=NULL WHERE `preview_content_id` = ?";
+ $rs = $this->query($query, array( $this->mContentId ));
+ $query = "DELETE FROM `".BIT_DB_PREFIX."tiki_fisheye_image` WHERE `content_id` = ?";
+ $rs = $this->query($query, array( $this->mContentId ));
+ if( LibertyAttachable::expunge() ) {
+ $this->mDb->CompleteTrans();
+ } else {
+ $this->mDb->RollbackTrans();
+ }
+ }
+ return( count( $this->mErrors ) == 0 );
+ }
+
+ function isValid() {
+ return( !empty( $this->mImageId ) || !empty( $this->mContentId ) );
+ }
+
+ function imageExistsInDatabase() {
+ $ret = FALSE;
+ if( $this->isValid() && $this->mImageId ) {
+ $sql = "SELECT COUNT(`image_id`) AS `count`
+ FROM `".BIT_DB_PREFIX."tiki_fisheye_image`
+ WHERE `image_id` = ?";
+ $rs = $this->query($sql, array($this->mImageId));
+
+ if ($rs->fields['count'] > 0)
+ $ret = TRUE;
+ }
+ return $ret;
+ }
+
+
+ function getList( &$pListHash ) {
+ global $gBitUser,$gBitSystem, $commentsLib;
+
+ $this->prepGetList( $pListHash );
+ $bindVars = array();
+ $select = '';
+ $mid = '';
+ $join = '';
+
+ if( !empty( $pListHash['user_id'] ) && is_numeric( $pListHash['user_id'] )) {
+ $mid .= " AND tc.`user_id` = ? ";
+ $bindVars[] = $pListHash['user_id'];
+ }
+ if( !empty( $pListHash['search'] ) ) {
+ $mid .= " AND UPPER(tc.`title`) LIKE ? ";
+ $bindVars[] = '%'.strtoupper( $pListHash['search'] ).'%';
+ }
+ if( $gBitSystem->isPackageActive( 'gatekeeper' ) ) {
+ $select .= ' ,ts.`security_id`, ts.`security_description`, ts.`is_private`, ts.`is_hidden`, ts.`access_question`, ts.`access_answer` ';
+ $join .= " LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_content_security_map` tcs ON (tc.`content_id`=tcs.`content_id`) LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_security` ts ON (ts.`security_id`=tcs.`security_id` ) LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_fisheye_gallery_image_map` tfgim ON (tfgim.`item_content_id`=tc.`content_id`) LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_content_security_map` tcs2 ON (tfgim.`gallery_content_id`=tcs2.`content_id`) LEFT OUTER JOIN `".BIT_DB_PREFIX."tiki_security` ts2 ON (ts2.`security_id`=tcs2.`security_id` )";
+ $mid .= ' AND (tcs2.`security_id` IS NULL OR tc.`user_id`=?) ';
+ $bindVars[] = $gBitUser->mUserId;
+ }
+
+ if ( !empty( $pListHash['sort_mode'] ) ) {
+ //converted in prepGetList()
+ $mid .= " ORDER BY ".$this->convert_sortmode( $pListHash['sort_mode'] )." ";
+ }
+
+ $query = "SELECT tfi.`image_id` AS `hash_key`, tfi.*, tf.*, tc.*, uu.`login`, uu.`real_name` $select
+ FROM `".BIT_DB_PREFIX."tiki_fisheye_image` tfi
+ INNER JOIN `".BIT_DB_PREFIX."tiki_attachments` ta ON(ta.`content_id`=tfi.`content_id`)
+ INNER JOIN `".BIT_DB_PREFIX."tiki_files` tf ON(ta.`foreign_id`=tf.`file_id`)
+ , `".BIT_DB_PREFIX."users_users` uu, `".BIT_DB_PREFIX."tiki_content` tc $join
+ WHERE tfi.`content_id` = tc.`content_id` AND uu.`user_id` = tc.`user_id` $mid";
+ if( $rs = $this->query( $query, $bindVars, $pListHash['max_records'],$pListHash['offset'] ) ) {
+ $ret = $rs->GetAssoc();
+ if( empty( $pListHash['no_thumbnails'] ) ) {
+ foreach( array_keys( $ret ) as $imageId ) {
+ $trailingName = dirname( $ret[$imageId]['storage_path'] )."/avatar.jpg";
+ if( file_exists( BIT_ROOT_PATH.$trailingName ) ) {
+ $ret[$imageId]['thumbnail_url'] = BIT_ROOT_URL.$trailingName;
+ } else {
+ $ret[$imageId]['thumbnail_url'] = FISHEYE_PKG_URL.'image/generating_thumbnails.png';
+ }
+ $ret[$imageId]['display_url'] = $this->getDisplayUrl( $imageId );
+ $ret[$imageId]['has_machine_name'] = $this->isMachineName( $ret[$imageId]['title'] );
+ }
+ }
+ }
+ return $ret;
+ }
+}
+
+?>
diff --git a/admin/admin_fisheye_inc.php b/admin/admin_fisheye_inc.php
new file mode 100644
index 0000000..e5ef429
--- /dev/null
+++ b/admin/admin_fisheye_inc.php
@@ -0,0 +1,136 @@
+<?php
+//This holds the checkbox options for what to display on the 'list galleries' page
+$formGalleryGeneral = array(
+ "fisheye_menu_text" => array(
+ 'label' => 'Menu Text',
+ 'note' => '',
+ 'type' => 'text'
+ ),
+/* Disabled for now - spiderr
+ "feature_megaupload" => array(
+ 'label' => 'Use <a href="http://sourceforge.net/projects/megaupload">MegaUpload</a>',
+ 'note' => 'Upload progress meter that requires Perl and ExecCGI permission',
+ 'type' => 'checkbox'
+ ),
+*/
+ "feature_offline_thumbnailer" => array(
+ 'label' => 'Background Thumbnailer',
+ 'note' => 'Thumbnails will be queued and regenerated by a background command-line script. For more information, see '.FISHEYE_PKG_PATH.'thumbaniler.php or you can <a href="'.FISHEYE_PKG_URL.'thumbnailer.php">run it manually</a>',
+ 'type' => 'checkbox'
+ )
+);
+$smarty->assign('formGalleryGeneral', $formGalleryGeneral);
+
+$formGalleryListLists = array(
+ "fisheye_list_title" => array(
+ 'label' => 'Gallery title',
+ 'note' => 'List the title of the gallery.',
+ ),
+ "fisheye_list_thumbnail" => array(
+ 'label' => 'Thumbnail',
+ 'note' => 'Display a small thumbnail associated with a gallery',
+ ),
+ "fisheye_list_description" => array(
+ 'label' => 'Description',
+ 'note' => 'List the description of a gallery',
+ ),
+ "fisheye_list_user" => array(
+ 'label' => 'Creator',
+ 'note' => 'List the name of the user who created the gallery',
+ ),
+ "fisheye_list_hits" => array(
+ 'label' => 'Hits',
+ 'note' => 'List number of hits this gallery has receieved',
+ ),
+ "fisheye_list_created" => array(
+ 'label' => 'Creation date',
+ 'note' => 'List the creation date of the gallery',
+ ),
+ "fisheye_list_lastmodif" => array(
+ 'label' => 'Last modification',
+ 'note' => 'List date this gallery was last modified',
+ )
+);
+$smarty->assign('formGalleryListLists', $formGalleryListLists);
+
+// This holds the checkbox options for what to display on a 'view gallery' page
+$formGalleryLists = array(
+ "fisheye_gallery_list_title" => array(
+ 'label' => 'Gallery title',
+ 'note' => 'When viewing a gallery, display the title of the gallery',
+ ),
+ "fisheye_gallery_list_description" => array(
+ 'label' => 'Gallery description',
+ 'note' => 'When viewing a gallery, display the description of the gallery below the title',
+ ),
+ "fisheye_gallery_list_image_titles" => array(
+ 'label' => 'Image titles',
+ 'note' => 'Show image titles underneath each thumbnail',
+ ),
+ "fisheye_gallery_hide_modules" => array(
+ 'label' => 'Hide modules for galleries',
+ 'note' => 'When viewing a gallery, hide the left and right module columns',
+ ),
+ "fisheye_gallery_list_image_descriptions" => array(
+ 'label' => 'Image description',
+ 'note' => 'Show image descriptions underneath each thumbnail',
+ )
+);
+$smarty->assign( 'formGalleryLists',$formGalleryLists );
+
+// This holds the checkbox options for what to display on an 'image details' page
+$formImageLists = array(
+ "fisheye_image_list_title" => array(
+ 'label' => 'Image title',
+ 'note' => 'When viewing an image, display the title of the image',
+ ),
+ "fisheye_image_list_description" => array(
+ 'label' => 'Image description',
+ 'note' => 'When viewing an image, display the description of the image below the title',
+ ),
+ "fisheye_image_hide_modules" => array(
+ 'label' => 'Hide modules for images',
+ 'note' => 'When viewing an image, hide the left and right module columns',
+ ),
+ "gallerybar_use_icons" => array(
+ 'label' => 'Use icons in the gallery bar',
+ 'note' => 'When viewing an image, show <strong>previous</strong> and <strong>next</strong> links as images instead of words',
+ ),
+);
+$smarty->assign( 'formImageLists', $formImageLists);
+
+//vd($_REQUEST);
+if (!empty($_REQUEST['fisheyeAdminSubmit'])) {
+ // General Settings
+ foreach ($formGalleryGeneral as $item=>$data) {
+ if( $data['type'] == 'checkbox' ) {
+ simple_set_toggle($item);
+ } else {
+ $gBitSystem->storePreference($item, $_REQUEST[$item]);
+ }
+ }
+
+ // Gallery List Display Settings
+ foreach ($formGalleryListLists as $item=>$data) {
+ simple_set_toggle($item);
+ }
+
+ // Gallery Display Settings
+ foreach ($formGalleryLists as $item => $data) {
+ simple_set_toggle($item);
+ }
+ $gBitSystem->storePreference('fisheye_gallery_default_thumbnail_size', $_REQUEST['default_gallery_thumbnail_size']);
+ $gBitSystem->storePreference('fisheye_gallery_default_rows_per_page', $_REQUEST['rows_per_page']);
+ $gBitSystem->storePreference('fisheye_gallery_default_cols_per_page', $_REQUEST['cols_per_page']);
+
+ // Image Display Settings
+ foreach ($formImageLists as $item => $data) {
+ simple_set_toggle( $item );
+ }
+ if( !empty( $_REQUEST['default_image_thumbnail_size'] ) ) {
+ $gBitSystem->storePreference('fisheye_image_default_thumbnail_size', $_REQUEST['default_image_thumbnail_size']);
+ }
+
+}
+
+?>
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
new file mode 100644
index 0000000..82cb00c
--- /dev/null
+++ b/admin/schema_inc.php
@@ -0,0 +1,97 @@
+<?php
+
+$tables = array(
+
+'tiki_fisheye_gallery' => "
+ gallery_id I4 PRIMARY,
+ content_id I4,
+ rows_per_page I4,
+ cols_per_page I4,
+ thumbnail_size C(32),
+ preview_content_id I4
+",
+
+'tiki_fisheye_gallery_image_map' => "
+ gallery_content_id I4 NOTNULL,
+ item_content_id I4 NOTNULL,
+ position I4
+",
+
+'tiki_fisheye_image' => "
+ image_id I4 PRIMARY,
+ content_id I4 NOTNULL,
+ photo_date I8,
+ width I4,
+ height I4
+",
+/*
+'tiki_fisheye_image_exif' => "
+ content_id I4 PRIMARY,
+ exif_title C(250),
+ exif_data X
+",
+*/
+'tiki_thumbnail_queue' => "
+ content_id I4 PRIMARY,
+ queue_date I8 NOTNULL,
+ begin_date I8,
+ end_date I8,
+ resize_original integer
+"
+
+);
+
+global $gBitInstaller;
+
+$gBitInstaller->makePackageHomeable('fisheye');
+
+foreach( array_keys( $tables ) AS $tableName ) {
+ $gBitInstaller->registerSchemaTable( FISHEYE_PKG_NAME, $tableName, $tables[$tableName] );
+}
+
+$indices = array (
+ 'tiki_fisheye_gallery_id_idx' => array( 'table' => 'tiki_fisheye_gallery', 'cols' => 'gallery_id', 'opts' => NULL ),
+ 'tiki_fisheye_image_id_idx' => array( 'table' => 'tiki_fisheye_image', 'cols' => 'image_id', 'opts' => NULL )
+);
+$gBitInstaller->registerSchemaIndexes( FISHEYE_PKG_NAME, $indices );
+
+$gBitInstaller->registerPackageInfo( FISHEYE_PKG_NAME, array(
+ 'description' => "FishEye is a package for creating image galleries",
+ 'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>'
+) );
+
+// ### Sequences
+$sequences = array (
+ 'tiki_fisheye_gallery_id_seq' => array( 'start' => 1 )
+);
+$gBitInstaller->registerSchemaSequences( FISHEYE_PKG_NAME, $sequences );
+
+// ### Default Preferences
+$gBitInstaller->registerPreferences( FISHEYE_PKG_NAME, array(
+ array( FISHEYE_PKG_NAME, 'fisheye_list_title','y'),
+ array( FISHEYE_PKG_NAME, 'fisheye_list_created','y'),
+ array( FISHEYE_PKG_NAME, 'fisheye_list_user','y'),
+ array( FISHEYE_PKG_NAME, 'fisheye_list_hits','y'),
+ array( FISHEYE_PKG_NAME, 'fisheye_list_thumbnail','y'),
+ array( FISHEYE_PKG_NAME, 'fisheye_gallery_list_title','y'),
+ array( FISHEYE_PKG_NAME, 'fisheye_gallery_list_description','y'),
+ array( FISHEYE_PKG_NAME, 'fisheye_gallery_list_image_titles','y'),
+ array( FISHEYE_PKG_NAME, 'fisheye_gallery_default_rows_per_page','5'),
+ array( FISHEYE_PKG_NAME, 'fisheye_gallery_default_cols_per_page','3'),
+ array( FISHEYE_PKG_NAME, 'fisheye_gallery_default_thumbnail_size','small'),
+ array( FISHEYE_PKG_NAME, 'fisheye_image_list_description',''),
+ array( FISHEYE_PKG_NAME, 'fisheye_image_default_thumbnail_size',''),
+ array( FISHEYE_PKG_NAME, 'fisheye_menu_text','Image Galleries'),
+ )
+);
+
+// ### Default User Permissions
+$gBitInstaller->registerUserPermissions( FISHEYE_PKG_NAME, array(
+ array('bit_p_view_fisheye', 'Can view image galleries', 'basic', 'fisheye'),
+ array('bit_p_create_fisheye', 'Can create an image gallery', 'registered', 'fisheye'),
+ array('bit_p_edit_fisheye', 'Can edit image gallery', 'registered', 'fisheye'),
+ array('bit_p_upload_fisheye', 'Can upload images to gallery', 'registered', 'fisheye'),
+ array('bit_p_admin_fisheye', 'Can admin image galleries', 'editors', 'fisheye')
+) );
+
+?>
diff --git a/bit_setup_inc.php b/bit_setup_inc.php
new file mode 100644
index 0000000..c7cc3c9
--- /dev/null
+++ b/bit_setup_inc.php
@@ -0,0 +1,20 @@
+<?php
+global $gBitSystem, $smarty;
+
+$gBitSystem->registerPackage( 'fisheye', dirname( __FILE__).'/' );
+
+if( $gBitSystem->isPackageActive( 'fisheye' ) ) {
+ // Default Preferences Defines
+ define ( 'FISHEYE_DEFAULT_ROWS_PER_PAGE', 5 );
+ define ( 'FISHEYE_DEFAULT_COLS_PER_PAGE', 2 );
+ define ( 'FISHEYE_DEFAULT_THUMBNAIL_SIZE', 'small' );
+
+ $smarty->assign( 'FISHEYE_DEFAULT_ROWS_PER_PAGE', FISHEYE_DEFAULT_ROWS_PER_PAGE );
+ $smarty->assign( 'FISHEYE_DEFAULT_COLS_PER_PAGE', FISHEYE_DEFAULT_COLS_PER_PAGE );
+ $smarty->assign( 'FISHEYE_DEFAULT_THUMBNAIL_SIZE', FISHEYE_DEFAULT_THUMBNAIL_SIZE );
+
+ $gBitSystem->registerAppMenu( 'fisheye', $gBitSystem->getPreference('fisheye_menu_text','Fisheye'), FISHEYE_PKG_URL.'index.php', 'bitpackage:fisheye/menu_fisheye.tpl', 'Image Galleries');
+
+ include_once( FISHEYE_PKG_PATH.'FisheyeGallery.php' );
+}
+?>
diff --git a/browse.php b/browse.php
new file mode 100644
index 0000000..7eac5b3
--- /dev/null
+++ b/browse.php
@@ -0,0 +1,15 @@
+<?php
+
+require_once( '../bit_setup_inc.php' );
+
+require_once( FISHEYE_PKG_PATH.'FisheyeGallery.php');
+require_once( FISHEYE_PKG_PATH.'FisheyeImage.php');
+global $gBitSystem, $smarty;
+
+$gFisheyeGallery = new FisheyeGallery();
+$galleryList = $gFisheyeGallery->getList( $_REQUEST );
+$smarty->assign_by_ref('galleryList', $galleryList);
+
+$gBitSystem->display("bitpackage:fisheye/browse_galleries.tpl");
+
+?>
diff --git a/display_fisheye_gallery_inc.php b/display_fisheye_gallery_inc.php
new file mode 100644
index 0000000..8c13510
--- /dev/null
+++ b/display_fisheye_gallery_inc.php
@@ -0,0 +1,54 @@
+<?php
+
+if( !$gContent->hasUserAccess( 'bit_p_view_fisheye' ) ) {
+ if ( !empty($_REQUEST['submit_answer'])) { // User is attempting to authenticate themseleves to view this gallery
+ if( !$gContent->validateUserAccess( $_REQUEST['try_access_answer']) ) {
+ $smarty->assign("failedLogin", "Incorrect Answer");
+ $gBitSystem->display("bitpackage:fisheye/authenticate.tpl", "Password Required to view: ".$gContent->getTitle() );
+ die;
+ }
+ } else {
+ if( !empty( $gContent->mInfo['access_answer'] ) ) {
+ $gBitSystem->display("bitpackage:fisheye/authenticate.tpl", "Password Required to view: ".$gContent->getTitle() );
+ die;
+ }
+ $gBitSystem->fatalError( tra( "You cannot view this image gallery" ) );
+ }
+}
+
+
+if( $gBitSystem->isPackageActive( 'categories' ) ) {
+ $cat_obj_type = FISHEYEGALLERY_CONTENT_TYPE_GUID;
+ $cat_objid =$gContent->mContentId;
+ include_once( CATEGORIES_PKG_PATH.'categories_display_inc.php' );
+}
+
+
+if (!empty($_REQUEST['page']) && is_numeric($_REQUEST['page'])) {
+ $page = $_REQUEST['page'];
+} else {
+ $page = 0;
+}
+
+if ($page > $gContent->mInfo['num_pages']) {
+ $page = $gContent->mInfo['num_pages'];
+} elseif ($page < 1) {
+ $page = 1;
+}
+
+$imagesPerPage = $gContent->mInfo['rows_per_page'] * $gContent->mInfo['cols_per_page'];
+$imageOffset = $imagesPerPage * ($page-1);
+
+$smarty->assign_by_ref('page', $page);
+$smarty->assign_by_ref('imagesPerPage', $imagesPerPage);
+$smarty->assign_by_ref('imageOffset', $imageOffset);
+$smarty->assign_by_ref('rows_per_page', $gContent->mInfo['rows_per_page']);
+$smarty->assign_by_ref('cols_per_page', $gContent->mInfo['cols_per_page']);
+
+$gContent->loadImages($imageOffset, $imagesPerPage);
+$gContent->addHit();
+
+$gBitSystem->setBrowserTitle( $gContent->getTitle().' '.tra('Gallery') );
+$gBitSystem->display("bitpackage:fisheye/view_gallery.tpl");
+
+?>
diff --git a/display_fisheye_image_inc.php b/display_fisheye_image_inc.php
new file mode 100644
index 0000000..7be7c1e
--- /dev/null
+++ b/display_fisheye_image_inc.php
@@ -0,0 +1,41 @@
+<?php
+
+if( !$gContent->isValid() ) {
+ $gBitSystem->fatalError( "No image exists with the given ID" );
+}
+
+if( !$gContent->hasUserAccess( 'bit_p_view_fisheye' ) ) {
+ if ( !empty($_REQUEST['submit_answer'])) { // User is attempting to authenticate themseleves to view this gallery
+ if( !$gContent->validateUserAccess( $_REQUEST['try_access_answer']) ) {
+ $smarty->assign("failedLogin", "Incorrect Answer");
+ $gBitSystem->display("bitpackage:fisheye/authenticate.tpl", "Password Required to view: ".$gContent->getTitle() );
+ die;
+ }
+ } else {
+ if( !empty( $gContent->mInfo['access_answer'] ) ) {
+ $gBitSystem->display("bitpackage:fisheye/authenticate.tpl", "Password Required to view: ".$gContent->getTitle() );
+ die;
+ }
+ $gBitSystem->fatalError( tra( "You cannot view this image gallery" ) );
+ }
+}
+
+if( $gBitSystem->isPackageActive( 'categories' ) ) {
+ $cat_obj_type = FISHEYEIMAGE_CONTENT_TYPE_GUID;
+ $cat_objid = $gContent->mContentId;
+ include_once( CATEGORIES_PKG_PATH.'categories_display_inc.php' );
+}
+
+// Get the proper thumbnail size to display on this page
+reset($gContent->mStorage);
+$imageStorage = current($gContent->mStorage);
+
+$thumbSize = (!empty( $_REQUEST['size'] ) ? $_REQUEST['size'] :
+ (!empty( $_COOKIE['fisheyeviewsize'] ) ? $_COOKIE['fisheyeviewsize'] :
+ $gBitSystem->getPreference('fisheye_image_default_thumbnail_size', FISHEYE_DEFAULT_THUMBNAIL_SIZE)));
+$gContent->mInfo['display_url'] = $gContent->getThumbnailUrl( $thumbSize );
+
+$gBitSystem->setBrowserTitle( $gContent->getTitle() );
+$gBitSystem->display("bitpackage:fisheye/view_image.tpl");
+
+?>
diff --git a/edit.php b/edit.php
new file mode 100644
index 0000000..d385b75
--- /dev/null
+++ b/edit.php
@@ -0,0 +1,111 @@
+<?php
+
+require_once( '../bit_setup_inc.php' );
+
+require_once( FISHEYE_PKG_PATH.'FisheyeGallery.php');
+require_once( FISHEYE_PKG_PATH.'FisheyeImage.php');
+
+global $gBitSystem;
+
+include_once( FISHEYE_PKG_PATH.'gallery_lookup_inc.php' );
+
+// Ensure the user has the permission to create new image galleries
+if (empty($_REQUEST['gallery_id'])) {
+ $gBitSystem->verifyPermission('bit_p_create_fisheye');
+} elseif( !$gContent->hasUserPermission( 'bit_p_edit_fisheye' ) ) {
+ // This user does not own this gallery and they have not been granted the permission to edit this gallery
+ $gBitSystem->fatalError( tra( "You cannot edit this image gallery" ) );
+}
+
+if( $gBitUser->hasPermission( 'bit_p_change_thumbnail_size' ) ) {
+ $thumbnailSizes = array(
+ 'xsmall' => 'Avatar (100x75)',
+ 'small' => 'Small (160x120)',
+ 'medium' => 'Medium (400x300)',
+ 'large' => 'Large (800x600)',
+ );
+ $smarty->assign( 'thumbnailSizes', $thumbnailSizes );
+}
+
+if( !empty($_REQUEST['savegallery']) ) {
+ if( $gContent->store( $_REQUEST ) ) {
+ // set the mappings, or if nothing checked, nuke them all
+ $gContent->addToGalleries( !empty( $_REQUEST['galleryAdditions'] ) ? $_REQUEST['galleryAdditions'] : NULL );
+
+ if( !empty( $_REQUEST['generate_thumbnails'] ) ) {
+ $gContent->generateThumbnails();
+ }
+
+ // nexus menu item storage
+ if( $gBitSystem->isPackageActive( 'nexus' ) && $gBitUser->hasPermission( 'bit_p_insert_nexus_item' ) ) {
+ $nexusHash['title'] = ( isset( $_REQUEST['title'] ) ? $_REQUEST['title'] : NULL );
+ $nexusHash['hint'] = ( isset( $_REQUEST['edit'] ) ? $_REQUEST['edit'] : NULL );
+ include_once( NEXUS_PKG_PATH.'insert_menu_item_inc.php' );
+ }
+ if ( $gBitSystem->isPackageActive('categories') ) {
+ $cat_desc = $gLibertySystem->mContentTypes[FISHEYEGALLERY_CONTENT_TYPE_GUID]['content_description'].' by '.$gBitUser->getDisplayName( FALSE, array( 'real_name' => $gContent->mInfo['creator_real_name'], 'user' => $gContent->mInfo['creator_user'], 'user_id'=>$gContent->mInfo['user_id'] ) );
+ $cat_name = $gContent->getTitle();
+ $cat_href = $gContent->getDisplayUrl();
+ $cat_objid = $gContent->mContentId;
+ $cat_content_id = $gContent->mContentId;
+ $cat_obj_type = FISHEYEGALLERY_CONTENT_TYPE_GUID;
+ include_once( CATEGORIES_PKG_PATH.'categorize_inc.php' );
+ }
+ header("location: ".$gContent->getDisplayUrl() );
+ die();
+ }
+}elseif( !empty($_REQUEST['delete']) ) {
+ $gContent->hasUserPermission( 'bit_p_admin_fisheye', TRUE, tra( "You do not have permission to delete this image gallery" ) );
+
+ if( !empty( $_REQUEST['cancel'] ) ) {
+ // user cancelled - just continue on, doing nothing
+ } elseif( empty( $_REQUEST['confirm'] ) ) {
+ $formHash['delete'] = TRUE;
+ $formHash['gallery_id'] = $gContent->mGalleryId;
+ $formHash['input'] = array(
+ '<input name="recurse" value="" type="radio" checked="checked" />'.tra( 'Delete only images in this gallery. Sub-galleries will not be removed.' ),
+ '<input name="recurse" value="all" type="radio" /> '.tra( 'Permanently delete all contents, even if they appear in other galleries.' ),
+ );
+ $gBitSystem->confirmDialog( $formHash, array( 'warning' => 'Are you sure you want to delete the gallery '.$gContent->getTitle().'?', 'error' => 'This cannot be undone!' ) );
+ } else {
+ $recurseDelete = (!empty( $_REQUEST['recurse'] ) && ($_REQUEST['recurse'] == 'all') );
+
+ if( $gContent->expunge( $recurseDelete ) ) {
+ header( "Location: ".FISHEYE_PKG_URL );
+ }
+ }
+
+} elseif( !empty($_REQUEST['cancelgallery'] ) ) {
+ header("location:".FISHEYE_PKG_URL."view.php?gallery_id=".$gContent->mGalleryId);
+ die();
+}
+
+// Nexus menus
+if( $gBitSystem->isPackageActive( 'nexus' ) && $gBitUser->hasPermission( 'bit_p_insert_nexus_item' ) ) {
+ include_once( NEXUS_PKG_PATH.'insert_menu_item_inc.php' );
+}
+
+if ( $gBitSystem->isPackageActive('categories') ) {
+ $cat_type = FISHEYEGALLERY_CONTENT_TYPE_GUID;
+ $cat_objid = $gContent->mContentId;
+ include_once( CATEGORIES_PKG_PATH.'categorize_list_inc.php' );
+}
+
+
+// Initalize the errors list which contains any errors which occured during storage
+$errors = (!empty($gContent->mErrors) ? $gContent->mErrors : array());
+$smarty->assign_by_ref('errors', $errors);
+
+$smarty->assign_by_ref( 'parentGalleries', $gContent->getParentGalleries() );
+$getHash = array( 'user_id' => $gBitUser->mUserId, 'contain_item' => $gContent->mContentId );
+$galleryList = $gContent->getList( $getHash );
+$smarty->assign_by_ref('galleryList', $galleryList);
+
+if( $gBitSystem->isPackageActive( 'gatekeeper' ) ) {
+ global $gGatekeeper;
+ $smarty->assign( 'securities', $gGatekeeper->getSecurityList( $gBitUser->mUserId ) );
+}
+
+$gBitSystem->display( 'bitpackage:fisheye/edit_gallery.tpl', 'Edit Gallery: '.$gContent->getTitle() );
+
+?>
diff --git a/edit_gallery_perms.php b/edit_gallery_perms.php
new file mode 100644
index 0000000..26ee9e6
--- /dev/null
+++ b/edit_gallery_perms.php
@@ -0,0 +1,55 @@
+<?php
+
+require_once( '../bit_setup_inc.php' );
+
+require_once( FISHEYE_PKG_PATH.'FisheyeGallery.php');
+require_once( FISHEYE_PKG_PATH.'FisheyeImage.php');
+
+global $gBitSystem, $fisheyePermNameMap;
+
+// Make sure an gallery has been specified
+if (empty($_REQUEST['gallery_id'])) {
+ $smarty->assign('msg', tra("No gallery specified"));
+ $gBitSystem->display( "error.tpl" );
+ die;
+}
+
+include_once( FISHEYE_PKG_PATH.'gallery_lookup_inc.php' );
+
+if (empty($gContent->mContentId)) {
+ $smarty->assign( 'msg', tra( "The specified gallery does not exist" ));
+ $gBitSystem->display("error.tpl");
+ die;
+} elseif ($gContent->mInfo['user_id'] != $gBitUser->mUserId && $gContent->mInfo['perm_level'] < FISHEYE_PERM_ADMIN) {
+ // This user does not own this gallery and they have not been granted the permission to edit user permissions for this gallery
+ $smarty->assign( 'msg', tra( "You cannot edit this image gallery" ) );
+ $gBitSystem->display( "error.tpl" );
+ die;
+}
+
+if (!empty($_REQUEST['submitNewPermissions'])) {
+ $gContent->grantUserPermissions($_REQUEST['new_perm_user_id'], $_REQUEST['new_perm_level']);
+ $fisheyeSuccess[] = $_REQUEST['found_username']." given ".$fisheyePermNameMap[$_REQUEST['name_perm_level']]." permissions";
+}elseif (!empty($_REQUEST['remove_perm_user_id'])) {
+ $gContent->revokeUserPermission($_REQUEST['remove_perm_user_id']);
+ $fisheyeSuccess[] = tra("User permissions successfully revoked");
+}
+
+$userPerms = $gContent->getAllUserPermissions();
+$smarty->assign_by_ref('userPerms', $userPerms);
+
+if (!empty($_REQUEST['submitUpdatePerms'])) {
+ $existingPerms = $_REQUEST['existingPerms'];
+ foreach ($userPerms as $userPerm) {
+ if ($existingPerms[$userPerm['user_id']]['perm_level'] != $userPerm['perm_level']) {
+ // Permisson level for this user has been altered
+ $gContent->grantUserPermissions($userPerm['user_id'], $existingPerms[$userPerm['user_id']]);
+ $fisheyeSuccess[] = $userPerm['real_name']." given ".$fisheyePermNameMap[$existingPerms[$userPerm['user_id']]]." permissions.";
+ }
+ }
+ $userPerms = $gContent->getAllUserPermissions();
+}
+
+$gBitSystem->display('bitpackage:fisheye/edit_gallery_perms.tpl');
+
+?>
diff --git a/edit_image.php b/edit_image.php
new file mode 100644
index 0000000..07ec5bf
--- /dev/null
+++ b/edit_image.php
@@ -0,0 +1,98 @@
+<?php
+
+require_once( '../bit_setup_inc.php' );
+
+require_once( FISHEYE_PKG_PATH.'FisheyeGallery.php');
+require_once( FISHEYE_PKG_PATH.'FisheyeImage.php');
+
+global $gBitSystem;
+
+include_once( FISHEYE_PKG_PATH.'gallery_lookup_inc.php' );
+include_once( FISHEYE_PKG_PATH.'image_lookup_inc.php' );
+
+if ( (!empty($gContent->mImageId)) && ($gContent->mInfo['user_id'] != $gBitUser->mUserId && !$gBitUser->isAdmin()) ) {
+ // This user does not own this image and they are not an Administrator
+ $smarty->assign( 'msg', tra( "You do not own this image!" ) );
+ $gBitSystem->display( "error.tpl" );
+ die;
+}
+
+if( !empty($_REQUEST['saveImage']) || !empty($_REQUEST['regenerateThumbnails'] ) ) {
+ if (empty($_REQUEST['gallery_id']) && empty($_REQUEST['image_id'])) {
+ // We have no way to know what gallery to add an image to or what image to edit!
+ $smarty->assign( 'msg', tra( "No gallery or image was specified" ) );
+ $gBitSystem->display( "error.tpl" );
+ die;
+ }
+
+ // Store/Update the image
+ if (isset($_FILES['imageFile']) && is_uploaded_file($_FILES['imageFile']['tmp_name'])) {
+ $_REQUEST['upload'] = &$_FILES['imageFile'];
+ $_REQUEST['upload']['process_storage'] = STORAGE_IMAGE;
+ }
+ $_REQUEST['purge_from_galleries'] = TRUE;
+ if( !empty( $_REQUEST['rotate_image'] ) ) {
+ $gContent->rotateImage( $_REQUEST['rotate_image'] );
+ }
+ if( $gContent->store($_REQUEST) ) {
+ $gContent->addToGalleries( $_REQUEST['galleryAdditions'] );
+ // maybe we need to resize the original and generate thumbnails
+ if( !empty( $_REQUEST['resize'] ) ) {
+ $gContent->resizeOriginal( $_REQUEST['resize'] );
+ }
+ if( !empty( $_REQUEST['generate_thumbnails'] ) ) {
+ $gContent->generateThumbnails();
+ }
+ if ( $gBitSystem->isPackageActive('categories') ) {
+ $cat_desc = $gLibertySystem->mContentTypes[FISHEYEIMAGE_CONTENT_TYPE_GUID]['content_description'].' by '.$gBitUser->getDisplayName( FALSE, array( 'real_name' => $gContent->mInfo['creator_real_name'], 'user' => $gContent->mInfo['creator_user'], 'user_id'=>$gContent->mInfo['user_id'] ) );
+ $cat_name = $gContent->getTitle();
+ $cat_href = $gContent->getDisplayUrl();
+ $cat_objid = $gContent->mContentId;
+ $cat_obj_type = FISHEYEIMAGE_CONTENT_TYPE_GUID;
+ include_once( CATEGORIES_PKG_PATH.'categorize_inc.php' );
+ }
+ if( empty( $gContent->mErrors ) ) {
+ // add a refresh parameter to the URL so the thumbnails will properly refresh first go reload
+ header( 'Location: '.$gContent->getDisplayUrl().($gBitSystem->isFeatureActive( 'pretty_urls' ) ? '?' : '&' ).'refresh=1' );
+ die;
+ }
+ }
+} elseif( !empty($_REQUEST['delete']) ) {
+ $gContent->hasUserPermission( 'bit_p_admin_fisheye', TRUE, tra( "You do not have permission to delete this image." ) );
+
+ if( !empty( $_REQUEST['cancel'] ) ) {
+ // user cancelled - just continue on, doing nothing
+ } elseif( empty( $_REQUEST['confirm'] ) ) {
+ $formHash['delete'] = TRUE;
+ $formHash['image_id'] = $gContent->mImageId;
+ $gBitSystem->confirmDialog( $formHash, array( 'warning' => 'Are you sure you want to delete the image '.$gContent->getTitle().'? <p> It will be removed from all galleries to which it belongs.</p>' ) );
+ } else {
+ if( $gContent->expunge() ) {
+ $url = ( is_object( $gGallery ) ? $gGallery->getDisplayUrl() : FISHEYE_PKG_URL );
+ header( "Location: $url" );
+ }
+ }
+
+}
+
+$errors = $gContent->mErrors;
+$smarty->assign_by_ref('errors', $errors);
+
+$gContent->loadParentGalleries();
+
+// Get a list of all existing galleries
+$gFisheyeGallery = new FisheyeGallery();
+$listHash = array( 'user_id'=>$gContent->mInfo['user_id'], 'max_records' => -1 );
+$galleryList = $gFisheyeGallery->getList( $listHash );
+$smarty->assign_by_ref('galleryList', $galleryList);
+
+$smarty->assign('requested_gallery', !empty($_REQUEST['gallery_id']) ? $_REQUEST['gallery_id'] : NULL);
+
+if( $gBitSystem->isPackageActive( 'gatekeeper' ) ) {
+ global $gGatekeeper;
+ $smarty->assign( 'securities', $gGatekeeper->getSecurityList( $gBitUser->mUserId ) );
+}
+
+$gBitSystem->display( 'bitpackage:fisheye/edit_image.tpl', 'Edit Image: '.$gContent->getTitle() );
+
+?>
diff --git a/find_user.php b/find_user.php
new file mode 100644
index 0000000..16d10a0
--- /dev/null
+++ b/find_user.php
@@ -0,0 +1,21 @@
+<?php
+include_once( "../bit_setup_inc.php" );
+
+if (empty($gBitLoc['styleSheet'])) {
+ $gBitLoc['styleSheet'] = $gBitSystem->getStyleCss();
+}
+$gBitLoc['browserStyleSheet'] = $gBitSystem->getBrowserStyleCss();
+$gBitLoc['customStyleSheet'] = $gBitSystem->getCustomStyleCss();
+$gBitLoc['THEMES_STYLE_URL'] = $gBitSystem->getStyleUrl();
+
+if (!empty($_REQUEST['submitUserSearch'])) {
+ $searchParams = array('find' => $_REQUEST['find']);
+ $gBitUser->getList($searchParams);
+ $foundUsers = $searchParams['data'];
+} else {
+ $foundUsers = NULL;
+}
+$smarty->assign_by_ref('foundUsers', $foundUsers);
+
+$smarty->display('bitpackage:fisheye/find_user.tpl');
+?>
diff --git a/gallery_lookup_inc.php b/gallery_lookup_inc.php
new file mode 100644
index 0000000..7d628a4
--- /dev/null
+++ b/gallery_lookup_inc.php
@@ -0,0 +1,24 @@
+<?php
+global $gContent;
+
+if (!empty($_REQUEST['gallery_id']) && is_numeric($_REQUEST['gallery_id'])) {
+ $gContent = new FisheyeGallery( $_REQUEST['gallery_id'] );
+ if( !$gContent->load() ) {
+ }
+} elseif (!empty($_REQUEST['content_id']) && is_numeric($_REQUEST['content_id'])) {
+ $gContent = new FisheyeGallery( NULL, $_REQUEST['content_id'] );
+ if( !$gContent->load() ) {
+ }
+} else {
+ $gContent = new FisheyeGallery();
+ $galleryId = NULL;
+}
+
+if( !empty( $_REQUEST['gallery_path'] ) ) {
+ $gContent->setGalleryPath( $_REQUEST['gallery_path'] );
+}
+
+$smarty->assign_by_ref('gContent', $gContent);
+$smarty->assign_by_ref('galleryId', $gContent->mGalleryId);
+
+?>
diff --git a/gallery_tree.php b/gallery_tree.php
new file mode 100644
index 0000000..619a83e
--- /dev/null
+++ b/gallery_tree.php
@@ -0,0 +1,11 @@
+<?php
+
+require_once( '../bit_setup_inc.php' );
+
+require_once( FISHEYE_PKG_PATH.'FisheyeGallery.php');
+require_once( FISHEYE_PKG_PATH.'FisheyeImage.php');
+global $gBitSystem, $smarty;
+
+$gBitSystem->display("bitpackage:fisheye/gallery_tree.tpl");
+
+?>
diff --git a/icons/locked.gif b/icons/locked.gif
new file mode 100644
index 0000000..5d61d1e
--- /dev/null
+++ b/icons/locked.gif
Binary files differ
diff --git a/icons/pkg_fisheye.png b/icons/pkg_fisheye.png
new file mode 100644
index 0000000..85a419e
--- /dev/null
+++ b/icons/pkg_fisheye.png
Binary files differ
diff --git a/icons/rotate_ccw.png b/icons/rotate_ccw.png
new file mode 100644
index 0000000..87f2fc2
--- /dev/null
+++ b/icons/rotate_ccw.png
Binary files differ
diff --git a/icons/rotate_cw.png b/icons/rotate_cw.png
new file mode 100644
index 0000000..caf2fc7
--- /dev/null
+++ b/icons/rotate_cw.png
Binary files differ
diff --git a/image/generating_thumbnails.png b/image/generating_thumbnails.png
new file mode 100644
index 0000000..7fbb59d
--- /dev/null
+++ b/image/generating_thumbnails.png
Binary files differ
diff --git a/image/no_image.png b/image/no_image.png
new file mode 100644
index 0000000..ed3a9aa
--- /dev/null
+++ b/image/no_image.png
Binary files differ
diff --git a/image_lookup_inc.php b/image_lookup_inc.php
new file mode 100644
index 0000000..536f2e5
--- /dev/null
+++ b/image_lookup_inc.php
@@ -0,0 +1,42 @@
+<?php
+global $gContent, $gGallery;
+
+if (!empty($_REQUEST['image_id']) && is_numeric($_REQUEST['image_id'])) {
+ $gContent = new FisheyeImage( $_REQUEST['image_id'] );
+ $gContent->load();
+ //vd($gContent->mInfo['image_file']);
+} elseif (!empty($_REQUEST['content_id']) && is_numeric($_REQUEST['content_id'])) {
+ $gContent = new FisheyeImage( NULL, $_REQUEST['content_id'] );
+ $gContent->load();
+} else {
+ $gContent = new FisheyeImage();
+ $imageId = NULL;
+}
+
+if( !empty( $_REQUEST['gallery_path'] ) ) {
+ $_REQUEST['gallery_path'] = rtrim( $_REQUEST['gallery_path'], '/' );
+ $gContent->setGalleryPath( $_REQUEST['gallery_path'] );
+ $matches = array();
+ $tail = strrpos( $_REQUEST['gallery_path'], '/' );
+ $_REQUEST['gallery_id'] = substr( $_REQUEST['gallery_path'], $tail + 1 );
+}
+if( empty( $_REQUEST['gallery_id'] ) ) {
+ if( $parents = $gContent->getParentGalleries() ) {
+ $gal = current( $parents );
+ $gContent->setGalleryPath( '/'.$gal['gallery_id'] );
+ $_REQUEST['gallery_id'] = $gal['gallery_id'];
+ }
+}
+// the image is considered the primary content, however the gallery is useful
+if( !empty($_REQUEST['gallery_id']) && is_numeric($_REQUEST['gallery_id']) ) {
+ $gGallery = new FisheyeGallery( $_REQUEST['gallery_id'], NULL, FALSE );
+ $gGallery->load( $gContent->mImageId );
+ $smarty->assign_by_ref('gGallery', $gGallery);
+ $smarty->assign_by_ref('galleryId', $_REQUEST['gallery_id']);
+}
+
+$smarty->assign_by_ref('gContent', $gContent);
+$smarty->assign_by_ref('imageId', $gContent->mImageId );
+
+
+?>
diff --git a/image_order.php b/image_order.php
new file mode 100644
index 0000000..3aa1cae
--- /dev/null
+++ b/image_order.php
@@ -0,0 +1,129 @@
+<?php
+require_once( '../bit_setup_inc.php' );
+
+require_once( FISHEYE_PKG_PATH.'FisheyeGallery.php');
+require_once( FISHEYE_PKG_PATH.'FisheyeImage.php');
+
+global $gBitSystem;
+
+include_once( FISHEYE_PKG_PATH.'gallery_lookup_inc.php' );
+
+if( $gBitSystem->isPackageActive( 'gatekeeper' ) ) {
+ global $gGatekeeper;
+ $smarty->assign( 'securities', $gGatekeeper->getSecurityList( $gBitUser->mUserId ) );
+}
+
+// Ensure the user has the permission to create new image galleries
+if( !$gContent->hasUserPermission( 'bit_p_edit_fisheye' ) ) {
+ // This user does not own this gallery and they have not been granted the permission to edit this gallery
+ $gBitSystem->fatalError( tra( "You cannot edit this image gallery" ) );
+}
+
+if (!empty($_REQUEST['updateImageOrder'])) {
+ if( !empty( $_REQUEST['batch'] ) ) {
+ // flip so we can do instant has lookup
+ $batchCon = array_flip( $_REQUEST['batch'] );
+ }
+
+ if( !empty( $_REQUEST['reorder_gallery'] ) && $gContent->loadImages() ) {
+ switch( $_REQUEST['reorder_gallery'] ){
+ case 'upload_date':
+ foreach( array_keys( $gContent->mItems ) as $imageId ) {
+ $reorder[$gContent->mItems[$imageId]->mContentId] = $gContent->mItems[$imageId]->mInfo['created'];
+ }
+ break;
+ case 'caption':
+ foreach( array_keys( $gContent->mItems ) as $imageId ) {
+ $reorder[$gContent->mItems[$imageId]->mContentId] = $gContent->mItems[$imageId]->mInfo['title'];
+ }
+ break;
+ case 'file_name':
+ foreach( array_keys( $gContent->mItems ) as $imageId ) {
+ $reorder[$gContent->mItems[$imageId]->mContentId] = $gContent->mItems[$imageId]->mInfo['image_file']['filename'];
+ }
+ break;
+ }
+ asort( $reorder );
+ $sortPos = 100;
+ foreach( $reorder as $conId => $sortVal ) {
+ $newOrder[$conId] = $sortPos;
+ $sortPos += 10;
+ }
+ }
+
+ foreach ($_REQUEST['imagePosition'] as $contentId=>$newPos) {
+ $galleryItem = $gLibertySystem->getLibertyObject( $contentId );
+ if( $galleryItem->load() ) {
+ if( isset( $batchCon[$contentId] ) ) {
+ if( !empty( $_REQUEST['batch_command'] ) ) {
+ list( $batchCommand, $batchParam ) = split( ':', $_REQUEST['batch_command'] );
+ switch( $batchCommand ) {
+ case 'delete':
+ $galleryItem->expunge();
+ $galleryItem = NULL;
+ break;
+ case 'thumbnail':
+ $galleryItem->generateThumbnails();
+ $feedback['success'] = tra( "Thumbnail regeneration queued" );
+ break;
+ case 'security':
+ $storageHash['security_id'] = $batchParam;
+ $feedback['success'] = tra( "Items security assigned" );
+ break;
+ case 'gallerymove':
+ if( empty( $destGallery ) ) {
+ $destGallery = new FisheyeGallery( NULL, $batchParam );
+ $destGallery->load();
+ }
+ if( $batchParam != $contentId ) {
+ $gContent->removeItem( $contentId );
+ }
+ case 'gallerycopy':
+ if( empty( $destGallery ) ) {
+ $destGallery = new FisheyeGallery( NULL, $batchParam );
+ $destGallery->load();
+ }
+ if( $destGallery->addItem( $contentId ) ) {
+ $feedback['success'][] = $galleryItem->getTitle().' '.tra( "added to" ).' '.$destGallery->getTitle();
+ } else {
+ $feedback['error'][] = $galleryItem->getTitle().' '.tra( "could not be added to" ).' '.$destGallery->getTitle();
+ }
+ break;
+ }
+ }
+ }
+ if( is_object( $galleryItem ) ) {
+ if( !empty( $_REQUEST['batch_security_id'] ) ) {
+ }
+ // if we are reordered, that takes precident
+ $newPos = (!empty( $newOrder[$contentId] ) ? $newOrder[$contentId] : $newPos);
+ if ($galleryItem->mInfo['title'] != $_REQUEST['imageTitle'][$contentId]) {
+ $storageHash = array('title' => $_REQUEST['imageTitle'][$contentId]);
+ }
+ if( !empty( $storageHash ) ) {
+ $galleryItem->store($storageHash);
+ }
+ $galleryItem->updatePosition($gContent->mContentId, $newPos);
+ }
+ }
+ unset( $storageHash );
+ }
+
+ if ($gContent->storeGalleryThumbnail($_REQUEST['gallery_preview_content_id'])) {
+ $gContent->mInfo['preview_content_id'] = $_REQUEST['gallery_preview_content_id'];
+ }
+
+}
+
+// Get a list of all existing galleries
+$listHash = array( 'user_id'=>$gBitUser->mUserId );
+$galleryList = $gContent->getList( $listHash );
+$smarty->assign_by_ref('galleryList', $galleryList);
+$gContent->loadImages();
+$smarty->assign_by_ref('galleryImages', $gContent->mItems);
+
+$smarty->assign_by_ref('formfeedback', $feedback);
+
+$gBitSystem->display( 'bitpackage:fisheye/image_order.tpl', 'Edit Gallery Images: '.$gContent->getTitle() );
+
+?>
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..d29793b
--- /dev/null
+++ b/index.php
@@ -0,0 +1,3 @@
+<?php
+require_once( 'list_galleries.php' );
+?>
diff --git a/list_galleries.php b/list_galleries.php
new file mode 100644
index 0000000..e7107fa
--- /dev/null
+++ b/list_galleries.php
@@ -0,0 +1,39 @@
+<?php
+
+require_once( '../bit_setup_inc.php' );
+
+require_once( FISHEYE_PKG_PATH.'FisheyeGallery.php');
+require_once( FISHEYE_PKG_PATH.'FisheyeImage.php');
+global $gBitSystem, $smarty, $gFisheyeGallery;
+
+$gFisheyeGallery = new FisheyeGallery();
+
+/* Get a list of galleries which matches the imput paramters (default is to list every gallery in the system) */
+$_REQUEST['root_only'] = TRUE;
+/* Process the input parameters this page accepts */
+if (!empty($_REQUEST['user_id']) && is_numeric($_REQUEST['user_id'])) {
+ if( $_REQUEST['user_id'] == $gBitUser->mUserId ) {
+ $_REQUEST['show_empty'] = TRUE;
+ }
+ $smarty->assign_by_ref('gQueryUserId', $_REQUEST['user_id']);
+ $template = 'user_galleries.tpl';
+} else {
+ $template = 'list_galleries.tpl';
+}
+
+$galleryList = $gFisheyeGallery->getList( $_REQUEST );
+$smarty->assign_by_ref('galleryList', $galleryList);
+
+if (!empty($_REQUEST['offset']) && is_numeric($_REQUEST['offset'])) {
+ $smarty->assign_by_ref('iMaxRows', $iMaxRows);
+}
+if (!empty($_REQUEST['sort_mode'])) {
+ $smarty->assign_by_ref('iSortMode', $_REQUEST['sort_mode']);
+}
+if (!empty($_REQUEST['search'])) {
+ $smarty->assign_by_ref('iSearchString', $iSearchtring);
+}
+
+$gBitSystem->display("bitpackage:fisheye/$template", "List Galleries" );
+
+?>
diff --git a/templates/admin_fisheye.tpl b/templates/admin_fisheye.tpl
new file mode 100644
index 0000000..89a69ac
--- /dev/null
+++ b/templates/admin_fisheye.tpl
@@ -0,0 +1,121 @@
+{strip}
+
+{form}
+ {jstabs}
+ {jstab title="General Settings"}
+ {legend legend="General Settings"}
+ {formhelp note="To change the Image Processing engine, see the Admin --&gt; Liberty --&gt; Liberty Settings</a>"}
+
+ {foreach from=$formGalleryGeneral key=item item=output}
+ <div class="row">
+ {formlabel label=`$output.label` for=$item}
+ {forminput}
+ {if $output.type=='text'}
+ <input type="text" name="{$item}" id="{$item}" value="{$gBitSystemPrefs.$item}"/>
+ {elseif $output.type=='checkbox'}
+ {html_checkboxes name="$item" values="y" checked=`$gBitSystemPrefs.$item` labels=false id=$item}
+ {/if}
+ {formhelp note=`$output.note`}
+ {/forminput}
+ </div>
+ {/foreach}
+ {/legend}
+ {/jstab}
+
+ {jstab title="List Settings"}
+ {legend legend="Gallery List Options"}
+ {formhelp note="The options below determine what information is shown on the List Galleries page."}
+
+ {foreach from=$formGalleryListLists key=item item=output}
+ <div class="row">
+ {formlabel label=`$output.label` for=$item}
+ {forminput}
+ {html_checkboxes name="$item" values="y" checked=`$gBitSystemPrefs.$item` labels=false id=$item}
+ {formhelp note=`$output.note`}
+ {/forminput}
+ </div>
+ {/foreach}
+ {/legend}
+ {/jstab}
+
+ {jstab title="Gallery Display Settings"}
+ {legend legend="Gallery Display Settings"}
+ <input type="hidden" name="page" value="{$page}" />
+ {formhelp note="The options below determine what information is shown on a gallery display page."}
+
+ {foreach from=$formGalleryLists key=item item=output}
+ <div class="row">
+ {formlabel label=`$output.label` for=$item}
+ {forminput}
+ {html_checkboxes name="$item" values="y" checked=`$gBitSystemPrefs.$item` labels=false id=$item}
+ {formhelp note=`$output.note`}
+ {/forminput}
+ </div>
+ {/foreach}
+ {/legend}
+
+ {legend legend="Default Gallery Display Settings"}
+ {formhelp note="The settings below determine what the default display options will be set to for new galleries."}
+
+ <div class="row">
+ {formlabel label="Default number of rows and columns"}
+ {forminput}
+ <label>
+ <input type="text" size="2" maxlength="2" name="rows_per_page" value="{$gBitSystemPrefs.fisheye_gallery_default_rows_per_page}"/>&nbsp;
+ {tr}Rows Per Page{/tr}
+ </label>
+ <br />
+ <label>
+ <input type="text" size="2" maxlength="2" name="cols_per_page" value="{$gBitSystemPrefs.fisheye_gallery_default_cols_per_page}"/>&nbsp;
+ {tr}Columns Per Page{/tr}
+ </label>
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Default Thumbnail Size"}
+ {forminput}
+ {html_radios values="avatar" output="Avatar (100x100)" name="default_gallery_thumbnail_size" checked=$gContent->mInfo.thumbnail_size}<br />
+ {html_radios values="small" output="Small (160x120)" name="default_gallery_thumbnail_size" checked=$gBitSystemPrefs.fisheye_gallery_default_thumbnail_size}<br />
+ {html_radios values="medium" output="Medium (400x300)" name="default_gallery_thumbnail_size" checked=$gBitSystemPrefs.fisheye_gallery_default_thumbnail_size}<br />
+ {html_radios values="large" output="Large (800x600)" name="default_gallery_thumbnail_size" checked=$gBitSystemPrefs.fisheye_gallery_default_thumbnail_size}
+ {/forminput}
+ </div>
+
+ {/legend}
+ {/jstab}
+
+ {jstab title="Image Display Settings"}
+ {legend legend="Image Display Settings"}
+ {formhelp note="The options below determine what information is displayed on the image display page."}
+
+ {foreach from=$formImageLists key=item item=output}
+ <div class="row">
+ {formlabel label=`$output.label` for=$item}
+ {forminput}
+ {html_checkboxes name="$item" values="y" checked=`$gBitSystemPrefs.$item` labels=false id=$item}
+ {formhelp note=`$output.note`}
+ {/forminput}
+ </div>
+ {/foreach}
+ {/legend}
+
+ {legend legend="Default Image Display Settings"}
+ <div class="row">
+ {formlabel label="Default Thumbnail Size"}
+ {forminput}
+ {html_radios values="small" output="Small (160x120)" name="default_image_thumbnail_size" checked=$gBitSystemPrefs.fisheye_image_default_thumbnail_size}<br />
+ {html_radios values="medium" output="Medium (400x300)" name="default_image_thumbnail_size" checked=$gBitSystemPrefs.fisheye_image_default_thumbnail_size}<br />
+ {html_radios values="large" output="Large (800x600)" name="default_image_thumbnail_size" checked=$gBitSystemPrefs.fisheye_image_default_thumbnail_size}
+ {/forminput}
+ </div>
+ {/legend}
+ {/jstab}
+
+ <div class="row submit">
+ <input type="submit" name="fisheyeAdminSubmit" value="{tr}Change Preferences{/tr}" />
+ </div>
+ {/jstabs}
+{/form}
+
+{/strip}
diff --git a/templates/authenticate.tpl b/templates/authenticate.tpl
new file mode 100644
index 0000000..46bd2eb
--- /dev/null
+++ b/templates/authenticate.tpl
@@ -0,0 +1,21 @@
+{strip}
+<div class="body">
+ {formfeedback error=$failedLogin}
+ <h2>{$gContent->mInfo.title}</h2>
+
+ This gallery has been password protected by the owner. "{$PHP_SELF}"
+
+ {form ifile="$PHP_SELF" legend="Authenticate"}
+ <input type="hidden" name="content_id" value="{$gContent->mContentId}" />
+
+ <h3>{$gContent->mInfo.access_question}:</h3>
+ <div class="row">
+ {formlabel label="Answer" for="try-access-answer"}
+ {forminput}
+ <input type="text" name="try_access_answer" id="try-access-answer" value="" maxlength="128" size="50"/>
+ <input type="submit" name="submit_answer" value="Submit Answer"/>
+ {/forminput}
+ </div>
+ {/form}
+</div>
+{/strip}
diff --git a/templates/browse_galleries.tpl b/templates/browse_galleries.tpl
new file mode 100644
index 0000000..596b06b
--- /dev/null
+++ b/templates/browse_galleries.tpl
@@ -0,0 +1,25 @@
+{strip}
+
+<div class="display fisheye">
+ <div class="header">
+ <h1>{tr}Image Galleries{/tr}</h1>
+ </div>
+
+ <div class="body">
+
+ <table class="data">
+ <tr>
+ <th><a href="{$gBitLoc.FISHEYE_PKG_URL}browse.php?offset={$offset}&amp;sort_mode={if $sort_mode eq 'title_desc'}title_asc{else}title_desc{/if}">{tr}Gallery Name{/tr}</a></th>
+ </tr>
+
+ {section name=ix loop=$galleryList}
+ <tr>
+ <td>{$galleryList[ix].title}</td>
+ </tr>
+ {/section}
+ </table>
+
+ </div> <!-- end .body -->
+</div> <!-- end .fisheye -->
+
+{/strip}
diff --git a/templates/center_list_galleries.php b/templates/center_list_galleries.php
new file mode 100644
index 0000000..317f607
--- /dev/null
+++ b/templates/center_list_galleries.php
@@ -0,0 +1,30 @@
+<?php
+ global $gQueryUser;
+ $gFisheyeGallery = new FisheyeGallery();
+
+ /* Get a list of galleries which matches the imput paramters (default is to list every gallery in the system) */
+ $_REQUEST['root_only'] = TRUE;
+ $_REQUEST['get_thumbnails'] = TRUE;
+ $galleryList = $gFisheyeGallery->getList( $_REQUEST );
+ $smarty->assign_by_ref('galleryList', $galleryList);
+
+ /* Process the input parameters this page accepts */
+ if (!empty($gQueryUser) && $gQueryUser->isRegistered()) {
+ $smarty->assign_by_ref('gQuerUserId', $gQueryUser->mUserId);
+ $template = 'user_galleries.tpl';
+ } else {
+ $template = 'list_galleries.tpl';
+ }
+
+ if (!empty($_REQUEST['offset']) && is_numeric($_REQUEST['offset'])) {
+ $smarty->assign_by_ref('iMaxRows', $iMaxRows);
+ }
+ if (!empty($_REQUEST['sort_mode'])) {
+ $smarty->assign_by_ref('iSortMode', $_REQUEST['sort_mode']);
+ }
+ if (!empty($_REQUEST['search'])) {
+ $smarty->assign_by_ref('iSearchString', $iSearchtring);
+ }
+
+
+?>
diff --git a/templates/center_list_galleries.tpl b/templates/center_list_galleries.tpl
new file mode 100644
index 0000000..8b2aed4
--- /dev/null
+++ b/templates/center_list_galleries.tpl
@@ -0,0 +1 @@
+{include file="bitpackage:fisheye/user_galleries.tpl"} \ No newline at end of file
diff --git a/templates/center_list_images.php b/templates/center_list_images.php
new file mode 100644
index 0000000..bb6a640
--- /dev/null
+++ b/templates/center_list_images.php
@@ -0,0 +1,37 @@
+<?php
+ global $gQueryUser, $module_rows;
+ $gFisheyeImage = new FisheyeImage();
+
+ if( !empty( $module_rows ) ) {
+ $_REQUEST['max_records'] = $module_rows;
+ } elseif (!empty($_REQUEST['offset']) && is_numeric($_REQUEST['offset'])) {
+ $smarty->assign_by_ref('iMaxRows', $iMaxRows);
+ }
+ if (empty($_REQUEST['sort_mode'])) {
+ $_REQUEST['sort_mode'] = 'random';
+ }
+ if (!empty($_REQUEST['search'])) {
+ $smarty->assign_by_ref('iSearchString', $iSearchtring);
+ }
+
+ $smarty->assign_by_ref('iSortMode', $_REQUEST['sort_mode']);
+
+ /* Get a list of galleries which matches the imput paramters (default is to list every gallery in the system) */
+ if( !empty( $gQueryUser ) && $gQueryUser->mUserId ) {
+ $_REQUEST['user_id'] = $gQueryUser->mUserId;
+ }
+ $_REQUEST['root_only'] = TRUE;
+ $_REQUEST['get_thumbnails'] = TRUE;
+ $thumbnailList = $gFisheyeImage->getList( $_REQUEST );
+ $smarty->assign_by_ref('thumbnailList', $thumbnailList);
+
+ /* Process the input parameters this page accepts */
+ if (!empty($gQueryUser) && $gQueryUser->isRegistered()) {
+ $smarty->assign_by_ref('gQuerUserId', $gQueryUser->mUserId);
+ $template = 'user_galleries.tpl';
+ } else {
+ $template = 'list_galleries.tpl';
+ }
+
+
+?>
diff --git a/templates/center_list_images.tpl b/templates/center_list_images.tpl
new file mode 100644
index 0000000..998a1e7
--- /dev/null
+++ b/templates/center_list_images.tpl
@@ -0,0 +1,24 @@
+{strip}
+{if $thumbnailList or $showEmpty}
+ <div class="listing fisheye">
+ <div class="header">
+ <h1>{tr}Random Images{/tr}</h1>
+ </div>
+
+ <div class="clear"></div>
+
+ <div class="body">
+ {foreach from=$thumbnailList key=galleryId item=gal}
+ {if $fisheye_list_thumbnail eq 'y'}
+ <a href="{$gal.display_url}">
+ <img class="thumb" src="{$gal.thumbnail_url}" alt="{$gal.title}" title="{$gal.title}" />
+ </a>
+ {/if}
+ {foreachelse}
+ {tr}No records found{/tr}
+ {/foreach}
+ <p><a href="{$gBitLoc.FISHEYE_PKG_URL}list_galleries.php?user_id={$gQueryUserId}">{tr}View More{/tr}...</a></p>
+ </div><!-- end .body -->
+ </div><!-- end .fisheye -->
+{/if}
+{/strip}
diff --git a/templates/create_collection.tpl b/templates/create_collection.tpl
new file mode 100644
index 0000000..46d2748
--- /dev/null
+++ b/templates/create_collection.tpl
@@ -0,0 +1,29 @@
+{* $Header: /cvsroot/bitweaver/_bit_fisheye/templates/Attic/create_collection.tpl,v 1.1 2005/06/19 04:36:24 bitweaver Exp $ *}
+{strip}
+<div class="floaticon">{bithelp}</div>
+
+<div class="admin structure">
+ <div class="header">
+ <h1>{tr}Collections{/tr}</h1>
+ </div>
+
+ <div class="body">
+ {form legend="Create A New Collection"}
+ <p>{tr}Once you have created your collection, you can add galleries or images, and organize them.{/tr}</p>
+
+ <div class="row">
+ {formfeedback error=`$errors.title`}
+ {formlabel label="Collection Name" for="name"}
+ {forminput}
+ <input type="text" name="name" id="name" size="50" maxlength="240"/>
+ {formhelp note="This is the name of your collection."}
+ {/forminput}
+ </div>
+
+ <div class="row submit">
+ <input type="submit" value="{tr}create collection{/tr}" name="createstructure" />
+ </div>
+ {/form}
+ </div><!-- end .body -->
+</div><!-- end .admin -->
+{/strip} \ No newline at end of file
diff --git a/templates/edit_collection.tpl b/templates/edit_collection.tpl
new file mode 100644
index 0000000..854d52c
--- /dev/null
+++ b/templates/edit_collection.tpl
@@ -0,0 +1,13 @@
+<div class="floaticon">{bithelp}</div>
+
+<div class="admin structure">
+<div class="header">
+<h1>{tr}Edit {$gStructure->mInfo.content_type.content_description}{/tr}</h1>
+</div>
+
+<div class="body">
+
+{include file="bitpackage:liberty/edit_structure.tpl"}
+
+</div> {* end .body *}
+</div> {* end .admin *}
diff --git a/templates/edit_gallery.tpl b/templates/edit_gallery.tpl
new file mode 100644
index 0000000..ba98d0d
--- /dev/null
+++ b/templates/edit_gallery.tpl
@@ -0,0 +1,116 @@
+<div class="edit fisheye">
+ {if $gContent->mInfo.title}{assign var=tabTitle value="{tr}Edit Gallery{/tr} `$gContent->mInfo.title`"}{else}{assign var=tabTitle value="{tr}Create Image Gallery{/tr}"}{/if}</h4>
+ <div class="header">
+ <h1>{$tabTitle}</h1>
+ </div>
+
+ <div class="body">
+ {form id="editGalleryForm" ipackage="fisheye" ifile="edit.php"}
+ {jstabs}
+ {jstab title="Edit Gallery"}
+ {legend legend="Edit Gallery"}
+ {formfeedback error=$errors warning=$fisheyeWarnings success=$fisheyeSuccess}
+
+ <input type="hidden" name="gallery_id" value="{$galleryId|escape}"/>
+
+ <div class="row">
+ {formlabel label="Title" for="gallery-title"}
+ {forminput}
+ <input type="text" name="title" id="gallery-title" value="{$gContent->mInfo.title}" maxlength="160" size="50"/>
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Description" for="gallery-desc"}
+ {forminput}
+ <textarea name="edit" id="gallery-desc" rows="4" cols="40">{$gContent->mInfo.data}</textarea>
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Rows per page" for="gallery-rows-per-page"}
+ {forminput}
+ <input type="text" id="gallery-rows-per-page" name="rows_per_page" size="2" maxlength="2" value="{$gContent->mInfo.rows_per_page|default:$gBitSystemPrefs.fisheye_gallery_default_rows_per_page}"/>
+ {formhelp note="Number of rows of images per gallery page"}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Columns per page" for="gallery-cols-per-page"}
+ {forminput}
+ <input type="text" id="gallery-cols-per-page" name="cols_per_page" size="2" maxlength="2" value="{$gContent->mInfo.cols_per_page|default:$gBitSystemPrefs.fisheye_gallery_default_cols_per_page}"/>
+ {formhelp note="Number of columns of images per gallery page"}
+ {/forminput}
+ </div>
+
+ {if $thumbnailSizes}
+ <div class="row">
+ {formlabel label="Thumbnail Size"}
+ {forminput}
+ {if $gContent->mInfo.thumbnail_size}
+ {assign var=thumb_size value=$gContent->mInfo.thumbnail_size}
+ {else}
+ {assign var=thumb_size value=$gBitSystemPrefs.fisheye_gallery_default_thumbnail_size}
+ {/if}
+ {html_radios options=$thumbnailSizes name="thumbnail_size" checked=$thumb_size separator="<br />"}
+ {/forminput}
+ </div>
+ {/if}
+ {/legend}
+ {/jstab}
+
+ {if $gBitSystem->isPackageActive( 'categories' )}
+ {jstab title="Categorize"}
+ {legend legend="Categorize"}
+ {include file="bitpackage:categories/categorize.tpl"}
+ {/legend}
+ {/jstab}
+ {/if}
+
+
+ {jstab title="Advanced Options"}
+ {if $galleryList}
+ {legend legend="Advanced Options"}
+ <div class="row">
+ {formlabel label="`$gContent->mInfo.content_description` Belongs to These Galleries"}
+ {forminput}
+ {foreach from=$galleryList key=galId item=gal}
+ {if $galId != $gContent->mGalleryId}
+ <input type="checkbox" name="galleryAdditions[]" value="{$gal.gallery_id}"
+ {if $gal.in_gallery}
+ checked="checked"
+ {/if}
+ />
+ <a href="{$gBitLoc.FISHEYE_PKG_URL}view.php?gallery_id={$gal.gallery_id}">{$gal.title}</a>
+ <br />
+ {/if}
+ {foreachelse}
+ {tr}No Galleries Found{/tr}.
+ {/foreach}
+ {/forminput}
+ </div>
+ {/legend}
+ {/if}
+
+ {if $gBitSystem->isPackageActive( 'gatekeeper' ) }
+ {legend legend="Security Settings"}
+ {include file="bitpackage:gatekeeper/choose_security.tpl"}
+ {/legend}
+ {/if}
+
+ {if $gBitSystemPrefs.package_nexus eq 'y'}
+ {legend legend="Insert Link in Menu"}
+ {include file="bitpackage:nexus/insert_menu_item_inc.tpl"}
+ {/legend}
+ {/if}
+ {/jstab}
+ {/jstabs}
+
+ <div class="row submit">
+ <input type="submit" name="cancelgallery" value="Cancel"/>
+ <input type="submit" name="savegallery" value="Save Gallery"/>
+ </div>
+ {/form}
+
+ </div> <!-- end .body -->
+</div> <!-- end .fisheye -->
diff --git a/templates/edit_gallery_perms.tpl b/templates/edit_gallery_perms.tpl
new file mode 100644
index 0000000..5f6b491
--- /dev/null
+++ b/templates/edit_gallery_perms.tpl
@@ -0,0 +1,73 @@
+<div class="admin fisheye">
+{formfeedback error=$fisheyeErrors warning=$fisheyeWarnings success=$fisheyeSuccess}
+ <div class="header">
+ <h1>{tr}Edit Gallery Permissions{/tr}: {$gContent->mInfo.title}</h1>
+ </div>
+
+ <div class="body">
+ <!-- Add New User Permissions -->
+ {legend legend="Add New User Permissions"}
+ <form name="newUserPermLevelForm" method="POST" action="{$PHP_SELF}">
+ <div class="row">
+ <input type="hidden" id="found_user_id" name="new_perm_user_id" value="" />
+ <input type="hidden" name="gallery_id" value="{$gContent->mGalleryId}" />
+ <input type="hidden" name="found_username" id="found_username_form_element" />
+ {tr}User{/tr}:
+ <span id="found_username"></span>
+ <a href="{$gBitLoc.FISHEYE_PKG_URL}find_user.php" title="{tr}Opens user search tool in a new window{/tr}" onkeypress="popUpWin(this.href,'standard',600,400);" onclick="popUpWin(this.href,'standard',600,400);return false;">{tr}User Browser{/tr}</a>
+ </div>
+ <div class="row">
+ {tr}Permission Level:{/tr}
+ <select name="new_perm_level">
+ <option value="{$FISHEYE_PERM_VIEWER}">{tr}Viewer{/tr}</option>
+ <option value="{$FISHEYE_PERM_CONTRIBUTOR}">{tr}Contributor{/tr}</option>
+ <option value="{$FISHEYE_PERM_EDITOR}">{tr}Editor{/tr}</option>
+ <option value="{$FISHEYE_PERM_ADMIN}">{tr}Admin{/tr}</option>
+ </select>
+ </div>
+ <div class="row submit">
+ <input type="submit" name="submitNewPermissions" value="Add New Permission"/>
+ </div>
+ </form>
+ {/legend}
+
+ <!-- Existing User Permissions -->
+ {legend legend="Existing User Permissions"}
+ <form name="updateUserPermsForm" method="POST" action="{$PHP_SELF}">
+ <input type="hidden" name="gallery_id" value="{$gContent->mGalleryId}"/>
+ <table>
+ <tr><th>User</th><th>Access Level</th><th>Action</th></tr>
+ {section name=ix loop=$userPerms}
+ <tr>
+ <td class="row">
+ {displayname hash=$userPerms[ix]}
+ </td>
+ <td class="row">
+ <select name="existingPerms[{$userPerms[ix].user_id}]">
+ <option value="{$FISHEYE_PERM_VIEWER}" {if $userPerms[ix].perm_level == $FISHEYE_PERM_VIEWER}selected="selected"{/if}>{tr}Viewer{/tr}</option>
+ <option value="{$FISHEYE_PERM_CONTRIBUTOR}" {if $userPerms[ix].perm_level == $FISHEYE_PERM_CONTRIBUTOR}selected="selected"{/if}>{tr}Contributor{/tr}</option>
+ <option value="{$FISHEYE_PERM_EDITOR}" {if $userPerms[ix].perm_level == $FISHEYE_PERM_EDITOR}selected="selected"{/if}">{tr}Editor{/tr}</option>
+ <option value="{$FISHEYE_PERM_ADMIN}" {if $userPerms[ix].perm_level == $FISHEYE_PERM_ADMIN}selected="selected"{/if}>{tr}Admin{/tr}</option>
+ </select>
+ </td>
+ <td>
+ <a href="{$gBitLoc.FISHEYE_PKG_URL}edit_gallery_perms.php?gallery_id={$gContent->mGalleryId}&remove_perm_user_id={$userPerms[ix].user_id}">{biticon ipackage=liberty iname="delete_small" iexplain="Remove Permission"}</a>
+ </td>
+ </tr>
+ {sectionelse}
+ <div class="row">
+ <span class="norecords">{tr}No User Permssions Found{/tr}</span>
+ </div>
+ {/section}
+ {if $userPerms}
+ <tr class="row submit">
+ <td colspan="3">
+ <input type="submit" name="submitUpdatePerms" value="Update Permissions"/>
+ </td>
+ </tr>
+ {/if}
+ </table>
+ </form>
+ {/legend}
+ </div>
+</div>
diff --git a/templates/edit_image.tpl b/templates/edit_image.tpl
new file mode 100644
index 0000000..c2a0dd1
--- /dev/null
+++ b/templates/edit_image.tpl
@@ -0,0 +1,122 @@
+{strip}
+<div class="floaticon">
+ <a href="{$gBitLoc.FISHEYE_PKG_URL}edit_image.php">{biticon ipackage="liberty" iname="upload" iexplain="upload new image"}</a>
+</div>
+
+<div class="admin fisheye">
+ <div class="header">
+ <h1>{if $gContent->mInfo.image_id}{tr}Edit Image{/tr}: {$gContent->mInfo.title} {else}{tr}Add New Image{/tr} {/if}</h1>
+ </div>
+
+ <div class="body">
+ {form enctype="multipart/form-data" legend="Edit Image"}
+ {formfeedback error=$errors}
+
+ <input type="hidden" name="gallery_id" value="{$galleryId|escape}"/>
+ <input type="hidden" name="image_id" value="{$imageId}"/>
+ <input type="hidden" name="MAX_FILE_SIZE" value="1000000000" />
+
+ <div class="row">
+ {formlabel label="Title" for="image-title"}
+ {forminput}
+ <input type="text" name="title" id="image-title" value="{$gContent->mInfo.title|escape}" maxlength="160" size="50"/>
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Description" for="image-desc"}
+ {forminput}
+ <textarea name="edit" id="image-desc" rows="4" cols="40">{$gContent->mInfo.data}</textarea>
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {if $gContent->mInfo.image_file.source_url}
+ {formfeedback warning="Uploading a new image will replace the currently existing one."}
+ {assign var=repl value=Replacement}
+ {/if}
+ {formlabel label="Upload $repl Image" for="image-upload"}
+ {forminput}
+ <input type="file" name="imageFile" id="image-upload"/>
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Current Image"}
+ {forminput}
+ {if $gContent->mInfo.image_file.storage_path}
+ <a href="{$gBitLoc.FISHEYE_PKG_URL}view_image.php?image_id={$gContent->mImageId}"><img src="{$gContent->mInfo.image_file.thumbnail_url.medium}" alt="{$gContent->mInfo.title|escape}" /></a>
+ <br />
+ <small>
+ {if $gContent->mInfo.width && $gContent->mInfo.height}
+ {tr}Full size{/tr} - <a href="{$gContent->mInfo.image_file.source_url}">{$gContent->mInfo.width} x {$gContent->mInfo.height}</a>
+ {elseif $gContent->mInfo.image_file.source_url}
+ <a href="{$gContent->mInfo.image_file.source_url}">{tr}Full size{/tr}</a>
+ {/if}
+ </small>
+ {else}
+ <img src="{$gBitLoc.FISHEYE_PKG_URL}image/no_image.png" alt="{$gContent->mInfo.title|escape}" />
+ {/if}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Regenerate Thumbnails"}
+ {forminput}
+ <input type="checkbox" name="generate_thumbnails" value="1"/>
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Rotate Image"}
+ {forminput}
+ <label><input type="radio" name="rotate_image" value="-90"/>{biticon ipackage="fisheye" iname="rotate_ccw" iexplain="Rotate Counter Clockwise"}</label> &nbsp;&nbsp;&nbsp;&nbsp;
+ <label>{biticon ipackage="fisheye" iname="rotate_cw" iexplain="Rotate Clockwise"} <input type="radio" name="rotate_image" value="90"/></label>
+ <br />
+ <label><input type="radio" name="rotate_image" value="" checked="checked"/>{tr}don't rotate{/tr}</label>
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {include file="bitpackage:fisheye/resize_image_select.tpl"}
+ </div>
+
+ {if $gBitSystem->isPackageActive( 'gatekeeper' ) }
+ {include file="bitpackage:gatekeeper/choose_security.tpl"}
+ {/if}
+
+ {if $gBitSystem->isPackageActive( 'categories' )}
+ {include file="bitpackage:categories/categorize.tpl"}
+ {/if}
+
+
+
+ <div class="row">
+ {formlabel label="Add This Image to These Galleries"}
+ {forminput}
+ {foreach from=$galleryList item=gal key=galleryId}
+ <input type="checkbox" name="galleryAdditions[]" value="{$galleryId}"
+ {if $requested_gallery == $galleryId}
+ checked="checked"
+ {else}
+ {if $gContent->mInfo.parent_galleries[$galleryId]}
+ checked="checked"
+ {/if}
+ {/if}
+ />
+ <a href="{$gBitLoc.FISHEYE_PKG_URL}view.php?gallery_id={$galleryId}">{$gal.title}</a>
+ <br />
+ {foreachelse}
+ <div>{tr}No Galleries Found{/tr}</div>
+ {/foreach}
+ {/forminput}
+ </div>
+
+ <div class="row submit">
+ <input type="submit" name="saveImage" value="Save Image"/>
+ </div>
+ {/form}
+ </div> <!-- class="body" -->
+</div> <!-- class="admin fisheye" -->
+
+{/strip}
diff --git a/templates/find_user.tpl b/templates/find_user.tpl
new file mode 100644
index 0000000..c6d1c70
--- /dev/null
+++ b/templates/find_user.tpl
@@ -0,0 +1,62 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Find User</title>
+ <!--[if gte IE 5.5000]>
+ <script type="text/javascript" src="{$gBitLoc.THEMES_PKG_URL}pngfix.js"></script>
+ <![endif]-->
+
+ <script type="text/javascript" src="{$gBitLoc.KERNEL_PKG_URL}bitweaver.js"></script>
+ <style type="text/css">
+ <!--
+ @import url({$gBitLoc.THEMES_PKG_URL}base.css);
+ {if $gBitLoc.styleSheet}@import url({$gBitLoc.styleSheet});{/if}
+ {if $gBitLoc.browserStyleSheet}@import url({$gBitLoc.browserStyleSheet});{/if}
+ {if $gBitLoc.customStyleSheet}@import url({$gBitLoc.customStyleSheet});{/if}
+ -->
+ </style>
+
+ {literal}
+ <script type="text/javascript"><!--
+ function returnUserInfo(userId, username) {
+ self.opener.document.getElementById("found_user_id").value = userId;
+ self.opener.document.getElementById("found_username").innerHTML = username;
+ self.opener.document.getElementById("found_username_form_element").value = username;
+ self.close();
+ }
+ --></script>
+ {/literal}
+{strip}
+</head>
+<body>
+ <div class="finduser">
+ <h2>User Search</h2>
+ <form name="formUserSearch" action="{$PHP_SELF}">
+ <div class="row">
+ Username: <input type="text" name="find" value="{$find}"/>
+ </div>
+ <div class="formsubmit">
+ <input type="submit" name="submitUserSearch" value="Search"/>
+ </div>
+ </form>
+ </div>
+
+ {if $foundUsers}
+ <div class="body">
+ <h2>Search Results</h2>
+ <table>
+ <tr><th>Username</th><th>Real Name</th><th>User Id</th><th>Actions</th></tr>
+ {section name=ix loop=$foundUsers}
+ <tr class="row">
+ <td>{$foundUsers[ix].login}</td>
+ <td>{$foundUsers[ix].real_name}</td>
+ <td>{$foundUsers[ix].user_id}</td>
+ <td><a href="javascript:void(null);" style="cursor:hand;" onclick="returnUserInfo({$foundUsers[ix].user_id},'{$foundUsers[ix].real_name}');">Select User</a></td>
+ </tr>
+ {/section}
+ </table>
+ </div>
+ {/if}
+</body>
+</html>
+{/strip}
diff --git a/templates/gallery_nav.tpl b/templates/gallery_nav.tpl
new file mode 100644
index 0000000..750bb54
--- /dev/null
+++ b/templates/gallery_nav.tpl
@@ -0,0 +1,42 @@
+{strip}
+ <div class="gallerybar">
+ <span class="path">
+ {displayname user=$gContent->mInfo.creator_user user_id=$gContent->mInfo.creator_user_id real_name=$gContent->mInfo.creator_real_name} :: <a href="{$gBitLoc.FISHEYE_PKG_URL}?user_id={$gContent->mInfo.user_id}">{tr}Galleries{/tr}</a> &raquo;
+ {$gContent->getBreadcrumbLinks()}
+ </span>
+
+ {if $gBitSystem->isPackageActive( 'categories' )}
+ {include file="bitpackage:categories/categories_nav.tpl"}
+ {/if}
+
+ {if $gGallery}
+ <span class="navigation">
+ <span class="left">
+ {if $gGallery->mInfo.previous_image_id}
+ <a href="{$gContent->getDisplayUrl($gGallery->mInfo.previous_image_id)|escape}">
+ {if $gallerybar_use_icons eq 'y'}
+ {biticon ipackage=liberty iname=nav_prev iexplain=previous}
+ {else}
+ &laquo;&nbsp;{tr}previous{/tr}
+ {/if}
+ </a>
+ {else}&nbsp;{/if}
+ </span>
+
+ <span class="right">
+ {if $gGallery->mInfo.next_image_id}
+ <a href="{$gContent->getDisplayUrl($gGallery->mInfo.next_image_id)|escape}">
+ {if $gallerybar_use_icons eq 'y'}
+ {biticon ipackage=liberty iname=nav_next iexplain=next}
+ {else}
+ {tr}next{/tr}&nbsp;&raquo;
+ {/if}
+ </a>
+ {else}&nbsp;{/if}
+ </span>
+ </span><!-- end .navigation -->
+ {/if}
+
+ <div class="clear"></div>
+ </div><!-- end .structure -->
+{/strip}
diff --git a/templates/gallery_tree.tpl b/templates/gallery_tree.tpl
new file mode 100644
index 0000000..60156a0
--- /dev/null
+++ b/templates/gallery_tree.tpl
@@ -0,0 +1,12 @@
+{strip}
+<div class="display fisheye">
+
+ <div class="header">
+ <h1>{tr}Image Galleries Tree{/tr}</h1>
+ </div>
+
+ <div class="body">
+
+ </div>
+</div>
+{/strip}
diff --git a/templates/image_order.tpl b/templates/image_order.tpl
new file mode 100644
index 0000000..e76200d
--- /dev/null
+++ b/templates/image_order.tpl
@@ -0,0 +1,153 @@
+{literal}
+<script type="text/javascript">
+function MoveUp(imageId) {
+
+}
+
+function MoveDown(imageId) {
+
+}
+</script>
+{/literal}
+<div class="admin fisheye">
+ <div class="header">
+ <h1>{tr}Image Order{/tr}</h1>
+ </div>
+
+ <div class="body">
+ {form id="batch_order" legend="Edit Image Order for <a href=\"`$gBitLoc.FISHEYE_PKG_URL`view.php?gallery_id=`$gContent->mGalleryId`\">`$gContent->mInfo.title`</a>"}
+{strip}
+ <input type="hidden" name="gallery_id" value="{$gContent->mGalleryId}"/>
+
+ {formfeedback hash=$formfeedback}
+
+ <table class="data">
+ <caption>{tr}Image Order{/tr}</caption>
+ <tr>
+ <td style="width:1px;"></td>
+ <th scope="col" style="width:1px;">{tr}Thumbnail{/tr}</th>
+ <th scope="col">{tr}Title and Position{/tr}</th>
+ <th scope="col">{tr}Miscellaneous{/tr}</th>
+ </tr>
+ {counter start=0 print=false assign=imageCount}
+ {section name=ix loop=$galleryImages}
+ <tr class="{cycle values='even,odd'}">
+ {if $imageCount % $gContent->mInfo.images_per_page == 0}
+ {if $imageCount ne 0}
+ <td colspan="5">&nbsp;</td>
+ </tr>
+ <tr class="{cycle}">
+ {/if}
+ <th style="block-progression:rl;writing-mode:tb-rl;filter:flipv fliph;text-align:center;" rowspan="{$gContent->mInfo.images_per_page}">
+ {tr}Page{/tr} {math equation="imgCount / imagesPerPage + 1"
+ imgCount=$imageCount
+ imagesPerPage=$gContent->mInfo.images_per_page}
+ </th>
+ {/if}
+ {counter print=false}
+ <td class="{$galleryImages[ix]->mType.content_type_guid}">
+ <a href="{$galleryImages[ix]->getDisplayUrl()|escape}"><img class="thumb" src="{$galleryImages[ix]->getThumbnailUrl()|replace:"&":"&amp;"}" alt="{$galleryImages[ix]->mInfo.title}" /></a>
+ </td>
+ <td>
+ <div class="row">
+ {formlabel label="Title" for="imageTitle-`$galleryImages[ix]->mContentId`"}
+ {forminput}
+ <input type="text" maxlength="160" size="20" name="imageTitle[{$galleryImages[ix]->mContentId}]" id="imageTitle-{$galleryImages[ix]->mContentId}" value="{$galleryImages[ix]->mInfo.title}"/>
+ {if $galleryImages[ix]->mInfo.user_id == $gBitUser->mUserId || $gBitUser->isAdmin()}
+ &nbsp;<a href="{$gBitLoc.FISHEYE_PKG_URL}edit_image.php?content_id={$gContent->mItems[ix]->mInfo.content_id}">{biticon ipackage=liberty iname="edit" iexplain="Edit Image"}</a>
+ {/if}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {formlabel label="Position" for="imagePosition-`$galleryImages[ix]->mContentId`"}
+ {forminput}
+ <input type="text" size="3" maxlength="3" name="imagePosition[{$galleryImages[ix]->mContentId}]" id="imagePosition-{$galleryImages[ix]->mContentId}" value="{$galleryImages[ix]->mInfo.position}"/>
+ {/forminput}
+ </div>
+ <div class="row">
+ {formlabel label="Uploaded" for="imagePosition-`$galleryImages[ix]->mContentId`"}
+ {forminput}
+ {$galleryImages[ix]->mInfo.created|bit_short_datetime}
+ {/forminput}
+ </div>
+ <div class="row">
+ {formlabel label="File name" for="imagePosition-`$galleryImages[ix]->mContentId`"}
+ {forminput}
+ {$galleryImages[ix]->mInfo.image_file.filename}
+ {/forminput}
+ </div>
+ </td>
+ <td style="text-align:right;">
+ <label>{tr}Gallery Image{/tr}: <input type="radio" name="gallery_preview_content_id" value="{$galleryImages[ix]->mContentId}" {if $gContent->mInfo.preview_content_id == $galleryImages[ix]->mContentId}checked="checked"{/if}/></label><br />
+ <label>{tr}Batch Select{/tr}: <input type="checkbox" name="batch[]" value="{$galleryImages[ix]->mContentId}" /></label>
+ </td>
+ </tr>
+ {/section}
+ <tr>
+ <td colspan="5" style="text-align:right;">
+ <label>{tr}Use random image{/tr} <input type="radio" name="gallery_preview_content_id" value="" {if $gContent->mInfo.preview_content_id == ""}checked="checked"{/if} /></label>
+ </td>
+ </tr>
+{/strip}
+ <tr>
+ <td colspan="5" style="text-align:right;">
+ <script type="text/javascript"><!--
+ document.write("<label for=\"switcher\">{tr}Select all images{/tr}</label> ");
+ document.write("<input name=\"switcher\" id=\"switcher\" type=\"checkbox\" onclick=\"switchCheckboxes(this.form.id,'batch[]','switcher')\" />");
+ --></script>
+ </td>
+ </tr>
+{strip}
+ <tr>
+ <td colspan="5" style="text-align:right;">
+ {tr}Batch command for checked items{/tr}: &nbsp;
+ <select name="batch_command">
+ <option value=""></option>
+ <option value="delete">{tr}Delete{/tr}</option>
+ <option value="thumbnail">{tr}Regenerate Thumbnails{/tr}</option>
+ {if $gBitSystem->isPackageActive( 'gatekeeper' ) }
+ <option value="security:">{tr}Set Security to{/tr} ~~ {tr}Publically Visible{/tr} ~~</option>
+ {foreach from=$securities key=secId item=sec}
+ <option value="security:{$secId}">{tr}Set Security to{/tr} "{$sec.security_description}"</option>
+ {/foreach}
+ {/if}
+ {foreach from=$galleryList item=gal key=galleryId}
+ {if $gContent->mInfo.content_id ne $gal.content_id}
+ <option value="gallerycopy:{$gal.content_id}">{tr}Copy to gallery{/tr} "{$gal.title|truncate:30}"</option>
+ {/if}
+ {/foreach}
+ {foreach from=$galleryList item=gal key=galleryId}
+ {if $gContent->mInfo.content_id ne $gal.content_id}
+ <option value="gallerymove:{$gal.content_id}">{tr}Move to gallery{/tr} "{$gal.title|truncate:30}"</option>
+ {/if}
+ {/foreach}
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="5" style="text-align:right;">
+ {tr}Re-order gallery by{/tr}: &nbsp;
+ <select name="reorder_gallery">
+ <option value=""></option>
+ <option value="upload_date">{tr}Date Uploaded{/tr}</option>
+ <option value="caption">{tr}Image Title{/tr}</option>
+ <option value="file_name">{tr}File Name{/tr}</option>
+ </select>
+ </td>
+ </tr>
+
+
+ </table>
+
+ <div class="row submit">
+ <input type="submit" name="updateImageOrder" value="Save Changes"/>
+ </div>
+
+ <div class="row">
+ {formhelp note="Using the Gallery Image radio button you can spcify what image is used to identify this particular gallery."}
+ </div>
+{/strip}
+ {/form}
+ </div><!-- end .body -->
+</div><!-- end .fisheye -->
diff --git a/templates/list_galleries.tpl b/templates/list_galleries.tpl
new file mode 100644
index 0000000..d241f97
--- /dev/null
+++ b/templates/list_galleries.tpl
@@ -0,0 +1,101 @@
+{strip}
+<div class="listing fisheye">
+ <div class="header">
+ <h1>{tr}Image Galleries{/tr}{if $gQueryUserId} {tr}by{/tr} {displayname user_id=$gQueryUserId}{/if}</h1>
+ </div>
+
+ <div class="body">
+ <div class="navbar">
+ <ul class="sortby">
+ <li>{biticon ipackage=liberty iname=sort iexplain="sort by"}</li>
+ {if $fisheye_list_title eq 'y'}
+ <li>{smartlink ititle="Gallery Name" isort="title" user_id=$gQuerUserId offset=$iMaxRows home=$userInfo.login search=$iSearchString}</li>
+ {/if}
+ {if $fisheye_list_user eq 'y'}
+ <li>{smartlink ititle="Owner" isort=`$gBitSystemPrefs.display_name` user_id=$gQuerUserId offset=$iMaxRows home=$userInfo.login search=$iSearchString}</li>
+ {/if}
+ {if $fisheye_list_created eq 'y'}
+ <li>{smartlink ititle="Created" isort="created" user_id=$gQuerUserId offset=$iMaxRows home=$userInfo.login search=$iSearchString}</li>
+ {/if}
+ {if $fisheye_list_lastmodif eq 'y'}
+ <li>{smartlink ititle="Last Modified" isort="last_modified" user_id=$gQuerUserId offset=$iMaxRows home=$userInfo.login search=$iSearchString}</li>
+ {/if}
+ {if $fisheye_list_hits eq 'y'}
+ <li>{smartlink ititle="Hits" isort="hits" user_id=$gQuerUserId offset=$iMaxRows home=$userInfo.login search=$iSearchString}</li>
+ {/if}
+ </ul>
+ </div>
+
+ <div class="clear"></div>
+
+ <ul class="data">
+ {foreach from=$galleryList key=galleryId item=gal}
+ <li class="item {cycle values='odd,even'} {$gal.content_type_guid}">
+ <div class="floaticon">
+ {if $gal.is_hidden=='y'}
+ {biticon ipackage=liberty iname="hidden" iexplain="Hidden"}
+ {/if}
+ {if $gal.is_private=='y'}
+ {biticon ipackage=liberty iname="private" iexplain="Private"}
+ {/if}
+ {* if $gal.access_answer}
+ {biticon ipackage=liberty iname="protected" iexplain="Protected"}
+ {/if}
+ {if $galleryList[ix]->hasUserPermission('bit_p_edit_fisheye')}
+ <a title="{tr}Edit{/tr}" href="{$gBitLoc.FISHEYE_PKG_URL}edit.php?gallery_id={$galleryId}">{biticon ipackage=liberty iname="config" iexplain="Edit"}</a>
+ {/if}
+ {if $galleryList[ix]->hasUserPermission('bit_p_edit_fisheye')}
+ <a title="{tr}Image Order{/tr}" href="{$gBitLoc.FISHEYE_PKG_URL}image_order.php?gallery_id={$galleryId}">{biticon ipackage=liberty iname="current" iexplain="Item Order"}</a>
+ {/if}
+ {if $galleryList[ix]->hasUserPermission('bit_p_upload_fisheye')}
+ <a title="{tr}Add Image{/tr}" href="{$gBitLoc.FISHEYE_PKG_URL}upload.php?gallery_id={$galleryId}">{biticon ipackage=liberty iname="upload" iexplain="Add Image"}</a>
+ {/if}
+ {if $galleryList[ix]->hasUserPermission('bit_p_admin_fisheye')}
+ <a title="{tr}User Permissions{/tr}" href="{$gBitLoc.FISHEYE_PKG_URL}edit_gallery_perms.php?gallery_id={$galleryId}">{biticon ipackage=liberty iname="permissions" iexplain="User Permissions"}</a>
+ {/if *}
+ </div>
+
+ <h2><a href="{$gal.display_url}">{if $fisheye_list_title eq 'y'}{$gal.title}{else}Gallery {$gal.gallery_id}{/if}</a></h2>
+
+ {if $fisheye_list_thumbnail eq 'y' && $gal.display_url}
+ <a href="{$gal.display_url}">
+ <img class="thumb" src="{$gal.thumbnail_url}" alt="{$gal.title}" title="{$gal.title}" />
+ </a>
+ {/if}
+
+ {if $fisheye_list_user eq 'y'}
+ {displayname hash=$gal nolink=TRUE} &raquo; <a href="{$gBitLoc.FISHEYE_PKG_URL}list_galleries.php?user_id={$gal.user_id}">{tr}Galleries{/tr}</a>
+ {/if}
+ {* if $galleryList[ix]->isProtected()}
+ {biticon ipackage="fisheye" iname="locked" iexplain="Protected"}
+ {/if *}
+ {if $fisheye_list_description eq 'y'}
+ <p>{$gal.data|truncate:200}</p>
+ {/if}
+
+ <div class="date">
+ {if $gBitSystem->isFeatureActive( 'fisheye_list_created' ) }
+ Created: {$gal.created|bit_short_date}<br />
+ {/if}
+ {if $gBitSystem->isFeatureActive( 'fisheye_list_lastmodif' )}
+ Modified: {$gal.last_modified|bit_short_date}<br />
+ {/if}
+ </div>
+
+ {if $fisheye_list_hits eq 'y'}
+ {tr}Hits{/tr}: {$gal.hits}<br />
+ {/if}
+
+ <div class="clear"></div>
+ </li>
+ {foreachelse}
+ <li class="item norecords">
+ {tr}No records found{/tr}
+ </li>
+ {/foreach}
+ </ul>
+
+ <div class="clear"></div>
+ </div> <!-- end .body -->
+</div> <!-- end .fisheye -->
+{/strip}
diff --git a/templates/menu_fisheye.tpl b/templates/menu_fisheye.tpl
new file mode 100644
index 0000000..b32e310
--- /dev/null
+++ b/templates/menu_fisheye.tpl
@@ -0,0 +1,27 @@
+{strip}
+<ul>
+ <li><a class="item" href="{$gBitLoc.FISHEYE_PKG_URL}list_galleries.php">{biticon ipackage=liberty iname=list iexplain="list galleries" iforce="icon"} {tr}List Galleries{/tr}</a></li>
+ {if $gBitUser->hasPermission('bit_p_create_fisheye')}
+ <li><a class="item" href="{$gBitLoc.FISHEYE_PKG_URL}list_galleries.php?user_id={$gBitUser->mUserId}">{biticon ipackage=liberty iname=spacer iexplain="my galleries" iforce="icon"} {tr}My Galleries{/tr}</a></li>
+ <li><a class="item" href="{$gBitLoc.FISHEYE_PKG_URL}edit.php">{biticon ipackage=liberty iname=new iexplain="create galleries" iforce="icon"} {tr}Create a Gallery{/tr}</a></li>
+ <!--<li><a class="item" href="{$gBitLoc.FISHEYE_PKG_URL}edit_collection.php">{tr}Create a Collection{/tr}</a></li>-->
+ {/if}
+ {if $gBitUser->hasPermission('bit_p_upload_fisheye')}
+ <li><a class="item" href="{$gBitLoc.FISHEYE_PKG_URL}upload.php">{biticon ipackage=liberty iname=upload iexplain="upload images" iforce="icon"} {tr}Upload Images{/tr}</a></li>
+ {/if}
+{* if $gBitUser->hasPermission('bit_p_view_fisheye')}
+ <!--<li><a class="item" href="{$gBitLoc.FISHEYE_PKG_URL}browse.php">{tr}Browse Galleries{/tr}</a></li>-->
+ <!--<li><a class="item" href="{$gBitLoc.FISHEYE_PKG_URL}collection.php">{tr}List Collections{/tr}</a></li>-->
+ <li><a class="item" href="{$gBitLoc.FISHEYE_PKG_URL}gallery_tree.php">{biticon ipackage=liberty iname=tree iexplain="growser gallery tree" iforce="icon"} {tr}Browse Gallery Tree{/tr}</a></li>
+ {/if *}
+ {if $gBitUser->isRegistered() && $gBitSystem->isPackageActive('quota')}
+ <li><a class="item" href="{$gBitLoc.QUOTA_PKG_URL}">{biticon ipackage=liberty iname=spacer iexplain="usage" iforce="icon"} {tr}Usage{/tr}</a></li>
+ {/if}
+ {if $gBitUser->isRegistered() && $gBitSystem->isPackageActive('gatekeeper')}
+ <li><a class="item" href="{$gBitLoc.GATEKEEPER_PKG_URL}">{biticon ipackage=gatekeeper iname=security iexplain="security" iforce="icon"} {tr}Security{/tr}</a></li>
+ {/if}
+ {if $gBitUser->hasPermission('bit_p_admin_fisheye')}
+ <!--<li><a class="item" href="{$gBitLoc.FISHEYE_PKG_URL}admin/admin_imagegals.php">{tr}Admin Galleries{/tr}</a></li>-->
+ {/if}
+</ul>
+{/strip}
diff --git a/templates/menu_fisheye_admin.tpl b/templates/menu_fisheye_admin.tpl
new file mode 100644
index 0000000..b2ebf1e
--- /dev/null
+++ b/templates/menu_fisheye_admin.tpl
@@ -0,0 +1 @@
+<ul><li><a class="item" href="{$gBitLoc.KERNEL_PKG_URL}admin/index.php?page=fisheye">{tr}Fisheye Settings{/tr}</a></li></ul> \ No newline at end of file
diff --git a/templates/resize_image_select.tpl b/templates/resize_image_select.tpl
new file mode 100644
index 0000000..7e6018c
--- /dev/null
+++ b/templates/resize_image_select.tpl
@@ -0,0 +1,17 @@
+ {formlabel label="Reduce Original Size" for="resize"}
+ {forminput}
+ <select name="resize" id="resize">
+ <option value="">Don't Resize</option>
+ <option value="640">1/3 MegaPixel ( 640 x 480 )</option>
+ <option value="1024">3/4 MegaPixel ( 1024 x 768 )</option>
+ <option value="1280">1 MegaPixel ( 1280 x 1024 )</option>
+ <option value="1600">2 MegaPixel ( 1600 x 1200 )</option>
+ <option value="2048">3 MegaPixel ( 2048 x 1536 )</option>
+ <option value="2272">4 MegaPixel ( 2272 x 1704 )</option>
+ <option value="2560">5 MegaPixel ( 2560 x 1920 )</option>
+ <option value="2800">6 MegaPixel ( 2800 x 2100 )</option>
+ <option value="3000">7 MegaPixel ( 3000 x 2300 )</option>
+ <option value="3264">8 MegaPixel ( 3264 x 2448 )</option>
+ </select>
+ {formhelp note="Select the size your image should be resized to. This will only have an effect on the image if it is larger than the selected size. If your image is smaller than the selected size, it will not be resized at all."}
+ {/forminput}
diff --git a/templates/upload_fisheye.tpl b/templates/upload_fisheye.tpl
new file mode 100644
index 0000000..fec408b
--- /dev/null
+++ b/templates/upload_fisheye.tpl
@@ -0,0 +1,63 @@
+<div class="admin fisheye">
+ <div class="header">
+ <h1>{tr}Upload Images{/tr}</h1>
+ </div>
+
+ <div class="body">
+ {form enctype="multipart/form-data" legend="Upload Images"}
+ {formfeedback note=$quotaMessage}
+ {formfeedback warning="The maximum file size you can upload is `$uploadMax` Megabytes"}
+ {formfeedback error=$errors}
+
+ {formhelp note="Here you can upload images. You can upload single image files, or you can upload archived files (.zip's, .sit's, .tar's, etc.) Archvied uploads will automatically be decompressed, and a gallery will created for every gallery in it. If you have nested folders, the hierarchy will be maintained for you with nested galleries." force=true}
+
+ <input type="hidden" name="gallery_id" value="{$galleryId|escape}"/>
+ <input type="hidden" name="image_id" value="{$imageId}"/>
+ <input type="hidden" name="MAX_FILE_SIZE" value="1000000000" />
+
+ <div class="uploadarray">
+ {assign var=uploads value=10 }
+ {section name=ix loop=$uploads name=uploads start=0 step=1 max=10}
+ <div class="row upload">
+ {formlabel label="Upload Image `$smarty.section.uploads.iteration`" for="image-upload-`$smarty.section.uploads.iteration`"}
+ {forminput}
+ <input type="file" name="{$smarty.section.uploads.iteration}" size="40" id="image-upload-{$smarty.section.uploads.iteration}" />
+ {/forminput}
+ </div>
+ {/section}
+ </div>
+
+ <div class="row">
+ {formlabel label="Add This Image to These Galleries"}
+ {forminput}
+ {foreach from=$galleryList key=galId item=gal}
+ <input type="checkbox" name="galleryAdditions[]" value="{$galId}"
+ {if $gContent->mGalleryId == $galId}
+ checked="checked"
+ {else}
+ {section name=gx loop=$gContent->mInfo.parent_galleries}
+ {if ($gContent->mInfo.parent_galleries[gx].gallery_id == $galId)}
+ checked="checked"
+ {/if}
+ {/section}
+ {/if}
+ />
+ <a href="{$gBitLoc.FISHEYE_PKG_URL}view.php?gallery_id={$gal.gallery_id}">{$gal.title}</a>
+ <br />
+ {foreachelse}
+ <div>{tr}No Galleries Found{/tr}. {tr}A gallery named <strong>{displayname hash=$gBitUser->mInfo nolink=1}'s Gallery</strong> will be created for you and images will be added to it.{/tr}</div>
+ {/foreach}
+ {/forminput}
+ </div>
+
+ <div class="row">
+ {include file="bitpackage:fisheye/resize_image_select.tpl"}
+ </div>
+
+ <div class="row submit">
+ <strong>{tr}Please don't press the save button more than once!<br />Depending on what you are uploading and the system, this can take a few minutes.{/tr}</strong><br/>
+ <input type="submit" name="save_image" value="Save Image(s)"/>
+ </div>
+ {/form}
+ </div> <!-- end .body -->
+</div> <!-- end .fisheye -->
diff --git a/templates/user_galleries.tpl b/templates/user_galleries.tpl
new file mode 100644
index 0000000..0a143f4
--- /dev/null
+++ b/templates/user_galleries.tpl
@@ -0,0 +1 @@
+{include file="bitpackage:fisheye/list_galleries.tpl"}
diff --git a/templates/view_gallery.tpl b/templates/view_gallery.tpl
new file mode 100644
index 0000000..a799742
--- /dev/null
+++ b/templates/view_gallery.tpl
@@ -0,0 +1,79 @@
+{strip}
+{include file="bitpackage:fisheye/gallery_nav.tpl"}
+
+<div class="listing fisheye">
+ <div class="header">
+ <div class="floaticon">
+ {if $gBitSystem->isPackageActive( 'pdf' ) && $gContent->hasUserPermission( 'bit_p_pdf_generation' )}
+ {if $structureInfo.root_structure_id}
+ <a title="{tr}create PDF{/tr}" href="{$gBitLoc.PDF_PKG_URL}?structure_id={$structureInfo.root_structure_id}">{biticon ipackage="pdf" iname="pdf" iexplain="PDF"}</a>
+ {else}
+ <a title="{tr}create PDF{/tr}" href="{$gBitLoc.PDF_PKG_URL}?content_id={$gContent->mContentId}">{biticon ipackage="pdf" iname="pdf" iexplain="PDF"}</a>
+ {/if}
+ {/if}
+ {if $gContent->hasUserPermission( 'bit_p_edit_fisheye' )}
+ <a title="{tr}Edit{/tr}" href="{$gBitLoc.FISHEYE_PKG_URL}edit.php?gallery_id={$gContent->mGalleryId}">{biticon ipackage=liberty iname="config" iexplain="Edit"}</a>
+ <a title="{tr}Image Order{/tr}" href="{$gBitLoc.FISHEYE_PKG_URL}image_order.php?gallery_id={$gContent->mGalleryId}">{biticon ipackage=liberty iname="current" iexplain="Image Order"}</a>
+ {/if}
+ {if $gContent->hasUserPermission( 'bit_p_upload_fisheye' )}
+ <a title="{tr}Add Image{/tr}" href="{$gBitLoc.FISHEYE_PKG_URL}upload.php?gallery_id={$gContent->mGalleryId}">{biticon ipackage=liberty iname="upload" iexplain="Add Image"}</a>
+ {/if}
+ {if $gContent->hasUserPermission( 'bit_p_admin_fisheye' )}
+ <a title="{tr}User Permissions{/tr}" href="{$gBitLoc.FISHEYE_PKG_URL}edit.php?gallery_id={$gContent->mGalleryId}&amp;delete=1">{biticon ipackage=liberty iname="delete" iexplain="Delete Gallery"}</a>
+ <a title="{tr}User Permissions{/tr}" href="{$gBitLoc.FISHEYE_PKG_URL}edit_gallery_perms.php?gallery_id={$gContent->mGalleryId}">{biticon ipackage=liberty iname="permissions" iexplain="User Permissions"}</a>
+ {/if}
+ </div>
+
+ <h1>{$gContent->mInfo.title}</h1>
+
+ {if $gContent->mInfo.data}
+ <h2>{$gContent->mInfo.data}</h2>
+ {/if}
+ </div>
+
+ <div class="body">
+ {formfeedback success=$fisheyeSuccess error=$fisheyeErrors warning=$fisheyeWarnings}
+ <table class="thumbnailblock">
+ {counter assign="imageCount" start="0" print=false}
+ {assign var="max" value=100}
+ {assign var="tdWidth" value="`$max/$cols_per_page`"}
+ {section name=ix loop=$gContent->mItems}
+ {assign var=item value=$gContent->mItems[ix]}
+ {if $imageCount % $cols_per_page == 0}
+ <tr > <!-- Begin Image Row -->
+ {/if}
+
+ <td style="width:{$tdWidth}%; vertical-align:top;"> <!-- Begin Image Cell -->
+ {box class="box `$gContent->mItems[ix]->mInfo.content_type_guid`"}
+ <a href="{$gContent->mItems[ix]->getDisplayUrl()|escape}">
+ <img class="thumb" src="{$gContent->mItems[ix]->getThumbnailUrl()}" alt="{$gContent->mItems[ix]->mInfo.title|default:'image'}" />
+ </a>
+ {if $gBitSystemPrefs.fisheye_gallery_list_image_titles eq 'y'}
+ <h2>{$gContent->mItems[ix]->mInfo.title}</h2>
+ {/if}
+ {if $gBitSystemPrefs.fisheye_gallery_list_image_descriptions eq 'y'}
+ <p>{$gContent->mImages[ix]->mInfo.data}</p>
+ {/if}
+ {/box}
+ </td> <!-- End Image Cell -->
+ {counter}
+
+ {if $imageCount % $cols_per_page == 0}
+ </tr> <!-- End Image Row -->
+ {/if}
+
+ {sectionelse}
+ <tr><td class="norecords">{tr}This gallery is empty{/tr}. <a href="{$gBitLoc.FISHEYE_PKG_URL}upload.php?gallery_id={$gContent->mGalleryId}">Upload pictures!</a></td></tr>
+ {/section}
+
+ {if $imageCount % $cols_per_page != 0}</tr>{/if}
+ </table>
+ </div> <!-- end .body -->
+ {libertypagination numPages=$gContent->mInfo.num_pages gallery_id=$gContent->mGalleryId gallery_path=$gContent->mGalleryPath page=$page}
+ {if $gBitSystem->isPackageActive( 'categories' )}
+ {include file="bitpackage:categories/categories_objects.tpl"}
+ {/if}
+
+</div> <!-- end .fisheye -->
+
+{/strip}
diff --git a/templates/view_image.tpl b/templates/view_image.tpl
new file mode 100644
index 0000000..99e7d38
--- /dev/null
+++ b/templates/view_image.tpl
@@ -0,0 +1,51 @@
+{strip}
+{include file="bitpackage:fisheye/gallery_nav.tpl"}
+
+<div class="display fisheye">
+ <div class="floaticon">
+ {if $gBitSystem->isPackageActive( 'pdf' ) && $gContent->hasUserPermission( 'bit_p_pdf_generation' )}
+ {if $structureInfo.root_structure_id}
+ <a title="{tr}create PDF{/tr}" href="{$gBitLoc.PDF_PKG_URL}index.php?structure_id={$structureInfo.root_structure_id}">{biticon ipackage="pdf" iname="pdf" iexplain="PDF"}</a>
+ {else}
+ <a title="{tr}create PDF{/tr}" href="{$gBitLoc.PDF_PKG_URL}index.php?content_id={$gContent->mContentId}">{biticon ipackage="pdf" iname="pdf" iexplain="PDF"}</a>
+ {/if}
+ {/if}
+ {if $gContent->hasUserPermission('bit_p_admin')}
+ <a title="{tr}Edit{/tr}" href="{$gBitLoc.FISHEYE_PKG_URL}edit_image.php?image_id={$gContent->mImageId}">{biticon ipackage=liberty iname="edit" iexplain="Edit Image"}</a>
+ <a title="{tr}Delete{/tr}" href="{$gBitLoc.FISHEYE_PKG_URL}edit_image.php?image_id={$gContent->mImageId}&amp;delete=1">{biticon ipackage=liberty iname="delete" iexplain="Delete Image"}</a>
+ {/if}
+ </div>
+
+ <div class="header">
+ <h1>{$gGallery->mInfo.title}</h1>
+ </div>
+
+ <div class="body">
+ {box class="box image"}
+ <img src="{$gContent->mInfo.display_url}{$refresh}" alt="{$gContent->mInfo.title|default:$gContent->mInfo.image_file.filename}" title="{$gContent->mInfo.data|default:$gContent->mInfo.filename}" />
+
+ {if $gBitSystemPrefs.fisheye_image_list_title eq 'y'}
+ <h1>{$gContent->mInfo.title|default:$gContent->mInfo.image_file.filename}</h1>
+ {/if}
+
+ {if $gBitSystemPrefs.fisheye_image_list_description eq 'y' and $gContent->mInfo.data ne ''}
+ <p>{$gContent->mInfo.data}</p>
+ {/if}
+ {/box}
+
+ <div class="pagination">
+ {if $gContent->mInfo.width && $gContent->mInfo.height}
+ {tr}View other sizes{/tr}<br />
+ {foreach key=size from=$gContent->mInfo.image_file.thumbnail_url item=url}
+ {if $url != $gContent->mInfo.display_url}<a href="{$gContent->getDisplayUrl(0,$size)|escape}">{/if}{$size}{if $url != $gContent->mInfo.display_url}</a>{/if}&nbsp;&bull;&nbsp;
+ {/foreach}
+ <a href="{$gContent->mInfo.image_file.source_url}">Original</a> {$gContent->mInfo.width}x{$gContent->mInfo.height}
+ {/if}
+ </div>
+ </div> <!-- end .body -->
+ {if $gBitSystem->isPackageActive( 'categories' )}
+ {include file="bitpackage:categories/categories_objects.tpl"}
+ {/if}
+</div> <!-- end .fisheye -->
+
+{/strip}
diff --git a/thumbnailer.php b/thumbnailer.php
new file mode 100755
index 0000000..6ec5734
--- /dev/null
+++ b/thumbnailer.php
@@ -0,0 +1,80 @@
+<?php
+ // usage is simple:
+ // php -q thumbnailer.php [# of thumbnails]
+ // example:
+ // php -q thumbnailer.php 20
+ // suggested crontab entry runs the thumbnailer every minute:
+ // * * * * * apache php -q /path/to/tikipro/fisheye/thumbnailer.php 20 >> /var/log/httpd/thumbnail_log
+
+ global $gBitSystem, $_SERVER;
+
+ $_SERVER['SCRIPT_URL'] = '';
+ $_SERVER['HTTP_HOST'] = '';
+ $_SERVER['HTTP_HOST'] = '';
+ $_SERVER['HTTP_HOST'] = '';
+ $_SERVER['SERVER_NAME'] = '';
+
+ if( !empty( $argc ) ) {
+ // reduce feedback for command line to keep log noise way down
+ define( 'BIT_PHP_ERROR_REPORTING', E_ERROR | E_PARSE );
+ }
+
+ require_once( '../bit_setup_inc.php' );
+ require_once( FISHEYE_PKG_PATH.'FisheyeImage.php' );
+
+ // add some protection for arbitrary thumbail execution.
+ // if argc is present, we will trust it was exec'ed command line.
+ if( empty( $argc ) && !$gBitUser->isAdmin() ) {
+ $gBitSystem->fatalError( 'You cannot run the thumbnailer' );
+ }
+
+ $thumbCount = ( !empty( $argv[1] ) ) ? $argv[1] : ( !empty( $_REQUEST['thumbnails'] ) ? $_REQUEST['thumbnails'] : 10);
+
+ $gBitSystem->mDb->StartTrans();
+
+ $sql = "SELECT tq.content_id AS hash_key, tq.*
+ FROM `".BIT_DB_PREFIX."tiki_thumbnail_queue` tq
+ WHERE tq.begin_date IS NULL
+ ORDER BY tq.queue_date";
+ $rs = $gBitSystem->mDb->query( $sql, NULL, $thumbCount );
+
+ $processContent = array();
+ while( !$rs->EOF ) {
+ $processContent[$rs->fields['content_id']] = $rs->fields;
+ $sql2 = "UPDATE `".BIT_DB_PREFIX."tiki_thumbnail_queue` SET `begin_date`=? WHERE `content_id`=?";
+ $rs2 = $gBitSystem->mDb->query( $sql2, array( date( 'U' ), $rs->fields['content_id'] ) );
+ $rs->MoveNext();
+ }
+
+ $gBitSystem->mDb->CompleteTrans();
+
+ $log = array();
+ $total = date( 'U' );
+ foreach( array_keys( $processContent ) as $contentId ) {
+ $image = new FisheyeImage( NULL, $contentId );
+ $begin = date( 'U' );
+ if( $processContent[$contentId]['resize_original'] ) {
+ $image->resizeOriginal( $processContent[$contentId]['resize_original'] );
+ }
+ if( $image->renderThumbnails() ) {
+ $log[$contentId]['message'] = 'SUCCESS: Thumbnails created';
+ $sql3 = "UPDATE `".BIT_DB_PREFIX."tiki_thumbnail_queue` SET `begin_date`=?, `end_date`=? WHERE `content_id`=?";
+ $rs3 = $gBitSystem->mDb->query( $sql3, array( $begin, date('U'), $contentId ) );
+ } else {
+ $log[$contentId]['message'] = ' ERROR: '.$image->mErrors['thumbnail'];
+ }
+ $log[$contentId]['time'] = date( 'd/M/Y:H:i:s O' );
+ $log[$contentId]['duration'] = date( 'U' ) - $begin;
+ $log[$contentId]['delay'] = date( 'U' ) - $total;
+ }
+
+ foreach( array_keys( $log ) as $contentId ) {
+ // generate something that kinda looks like apache common log format
+ print $contentId.' - - ['.$log[$contentId]['time'].'] "'.$log[$contentId]['message'].'" '.$log[$contentId]['duration']."seconds <br/>\n";
+ }
+
+ if( count($processContent) ) {
+ print '# '.count($processContent)." images processed in ".(date( 'U' ) - $total)." seconds<br/>\n";
+ }
+
+?>
diff --git a/upload.php b/upload.php
new file mode 100644
index 0000000..6b654c0
--- /dev/null
+++ b/upload.php
@@ -0,0 +1,253 @@
+<?php
+
+require_once( '../bit_setup_inc.php' );
+
+require_once( FISHEYE_PKG_PATH.'FisheyeGallery.php');
+require_once( FISHEYE_PKG_PATH.'FisheyeImage.php');
+
+global $gBitSystem;
+global $fisheyeErrors, $fisheyeWarnings, $fisheyeSuccess;
+
+include_once( FISHEYE_PKG_PATH.'gallery_lookup_inc.php' );
+
+if (!empty($_REQUEST['save_image'])) {
+ // first of all set the execution time for this process to unlimited
+ set_time_limit(0);
+
+ $upImages = array();
+ $upArchives = array();
+ $upErrors = array();
+ foreach( array_keys( $_FILES ) as $key ) {
+ if( preg_match( '/^image/', $_FILES[$key]['type'] ) ) {
+ $upImages[$key] = $_FILES[$key];
+ } elseif( !empty( $_FILES[$key]['size'] ) ) {
+ $upArchives[$key] = $_FILES[$key];
+ }
+ }
+
+ $galleryAdditions = array();
+
+ // No gallery was specified, let's try to find one or create one.
+ if( empty( $_REQUEST['galleryAdditions'] ) ) {
+ $_REQUEST['galleryAdditions'] = array( fisheye_get_default_gallery_id( $gBitUser->mUserId, $gBitUser->getDisplayName()."'s Gallery" ) );
+ }
+
+ $newGalleries = array();
+ foreach( array_keys( $upArchives ) as $key ) {
+ $upErrors = fisheye_process_archive( $upArchives[$key], $gContent, TRUE );
+ }
+
+ foreach( array_keys( $upImages ) as $key ) {
+ if( ($upImages[$key]['size'] > 0) && is_uploaded_file( $upImages[$key]['tmp_name'] ) ) {
+ // make a copy for each image we need to store
+ $storeHash = $_REQUEST;
+ $image = new FisheyeImage();
+ // Store/Update the image
+ if (isset($_FILES[$key])) {
+ $storeHash['upload'] = &$_FILES[$key];
+ $storeHash['upload']['process_storage'] = STORAGE_IMAGE;
+ }
+ $storeHash['purge_from_galleries'] = TRUE;
+ if( !$image->store( $storeHash ) ) {
+ array_merge( $upErrors, array_values( $image->mErrors ) );
+ }
+
+ $image->addToGalleries( $_REQUEST['galleryAdditions'] );
+ }
+ }
+
+ if( !is_object( $gContent ) || !$gContent->isValid() ) {
+ $gContent = new FisheyeGallery( $_REQUEST['galleryAdditions'][0] );
+ $gContent->load();
+ }
+
+ if( empty( $upErrors ) ) {
+ header( 'Location: '.$gContent->getDisplayUrl() );
+ die;
+ } else {
+ $smarty->assign( 'errors', $upErrors );
+ }
+}
+
+if( $gBitSystem->isPackageActive( 'quota' ) ) {
+ require_once( QUOTA_PKG_PATH.'LibertyQuota.php' );
+ $quota = new LibertyQuota();
+ if( !$gBitUser->isAdmin() && !$quota->isUserUnderQuota( $gBitUser->mUserId ) ) {
+ $gBitSystem->fatalError( 'You are over your quota and have no space to upload new files.' );
+ }
+ if( !$gBitUser->isAdmin() ) {
+ // Prevent people from uploading more than there quota
+ $q = $quota->getUserQuota( $gBitUser->mUserId );
+ $u = $quota->getUserUsage( $gBitUser->mUserId );
+ $smarty->assign('quotaMessage', tra( 'Your remaining disk quota is' ).' '.round(($q-$u)/1000000, 2).' '.tra('Megabytes') );
+ }
+}
+
+// Get a list of all existing galleries
+$gFisheyeGallery = new FisheyeGallery();
+$listHash = array( 'user_id' => $gBitUser->mUserId, 'show_empty' => true );
+$galleryList = $gFisheyeGallery->getList( $listHash );
+$smarty->assign_by_ref('galleryList', $galleryList);
+
+// settings that are useful to know about at upload time
+$postMax = str_replace( 'M', '', ini_get( 'post_max_size' ));
+$uploadMax = str_replace( 'M', '', ini_get( 'upload_max_filesize' ) );
+
+if( $postMax < $uploadMax ) {
+ $uploadMax = $postMax;
+}
+
+$smarty->assign( 'uploadMax', $uploadMax );
+
+$gBitSystem->display( 'bitpackage:fisheye/upload_fisheye.tpl', 'Upload Images' );
+
+function fisheye_get_default_gallery_id( $pUserId, $pNewName ) {
+ $gal = new FisheyeGallery();
+ $getHash = array( 'user_id' => $pUserId, 'max_records' => 1, 'sort_mode' => 'created_desc' );
+ if( $upList = $gal->getList( $getHash ) ) {
+ $ret = key( $upList );
+ } else {
+ $galleryHash = array( 'title' => $pNewName );
+ if( $gal->store( $galleryHash ) ) {
+ $ret = $gal->mGalleryId;
+ }
+ }
+
+ global $gContent;
+ if( !is_object( $gContent ) || !$gContent->isValid() ) {
+ $gContent = new FisheyeGallery( $ret );
+ $gContent->load();
+ }
+ return $ret;
+}
+
+function liberty_process_archive( &$pFileHash ) {
+ $cwd = getcwd();
+ $dir = dirname( $pFileHash['tmp_name'] );
+ $upExt = substr( $pFileHash['name'], (strrpos( $pFileHash['name'], '.' ) + 1) );
+ $baseDir = $dir.'/';
+ if( is_uploaded_file( $pFileHash['tmp_name'] ) ) {
+ global $gBitUser;
+ $baseDir .= $gBitUser->mUserId;
+ }
+ $destDir = $baseDir.'/'.basename( $pFileHash['tmp_name'] );
+ if( (is_dir( $baseDir ) || mkdir( $baseDir )) && @mkdir( $destDir ) ) {
+ // Some commands don't nicely support extracting to other directories
+ chdir( $destDir );
+ list( $mimeType, $mimeExt ) = split( '/', $pFileHash['type'] );
+ switch( $mimeExt ) {
+ case 'x-rar';
+ $shellResult = shell_exec( "rar x -w\"$destDir\" $pFileHash[tmp_name] " );
+ break;
+ case 'x-bzip2':
+ case 'bzip2':
+ case 'x-gzip':
+ case 'gzip':
+ case 'x-tgz':
+ case 'x-tar':
+ case 'tar':
+ switch( $upExt ) {
+ case 'gz':
+ case 'tgz': $compressFlag = '-z'; break;
+ case 'bz2': $compressFlag = '-j'; break;
+ default: $compressFlag = ''; break;
+ }
+ $shellResult = shell_exec( "tar -x $compressFlag -f $pFileHash[tmp_name] -C \"$destDir\"" );
+ break;
+ case 'x-zip':
+ case 'zip':
+ $shellResult = shell_exec( "unzip $pFileHash[tmp_name] -d \"$destDir\"" );
+ break;
+ case 'x-stuffit':
+ case 'stuffit':
+ default:
+ $shellResult = shell_exec( "unstuff -d=\"$destDir\" $pFileHash[tmp_name] " );
+ break;
+ }
+ }
+ chdir( $cwd );
+ return $destDir;
+}
+
+
+// Recursively builds a tree where each directory represents a gallery, and files are assumed to be images.
+function fisheye_process_archive( &$pFileHash, &$pParentGallery, $pRoot=FALSE ) {
+ $errors = NULL;
+ $destDir = liberty_process_archive( $pFileHash );
+
+ if( empty( $pParentGallery ) && !is_uploaded_file( $pFileHash['tmp_name'] ) ) {
+ $pParentGallery = new FisheyeGallery();
+ $galleryHash = array( 'title' => basename( $destDir ) );
+ if( !$pParentGallery->store( $galleryHash ) ) {
+ $errors = array_merge( $errors, array_values( $pParentGallery->mErrors ) );
+ }
+ global $gContent;
+ $gContent = &$pParentGallery;
+ }
+
+ if( $archiveDir = opendir( $destDir ) ) {
+ while( $fileName = readdir($archiveDir) ) {
+ if( !preg_match( '/^\./', $fileName ) ) {
+ $scanFile = array(
+ 'name' => $fileName,
+ 'size' => filesize( "$destDir/$fileName" ),
+ 'tmp_name' => "$destDir/$fileName",
+ );
+
+ if( !empty( $_REQUEST['resize'] ) && is_numeric( $_REQUEST['resize'] ) ) {
+ $scanFile['max_height'] = $scanFile['max_width'] = $_REQUEST['resize'];
+ }
+
+ if( is_dir( $destDir.'/'.$fileName ) ) {
+ // We found a new Gallery!
+ $newGallery = new FisheyeGallery();
+ $galleryHash = array( 'title' => str_replace( '_', ' ', $fileName ) );
+ if( $newGallery->store( $galleryHash ) ) {
+ if( $pRoot ) {
+ $newGallery->addToGalleries( $_REQUEST['galleryAdditions'] );
+ }
+ if( is_object( $pParentGallery ) ) {
+ $pParentGallery->addItem( $newGallery->mContentId );
+ }
+ //recurse down in!
+ $errors = array_merge( $errors, fisheye_process_archive( $scanFile, $newGallery ) );
+ } else {
+ $errors = array_merge( $errors, array_values( $newGallery->mErrors ) );
+ }
+ } else {
+ // support for the fileinfo pecl package: http://pecl.php.net/package/fileinfo
+ if( function_exists( 'finfo_open' ) ) {
+ $res = finfo_open(FILEINFO_MIME);
+ $scanFile['type'] = finfo_file($res, $scanFile['tmp_name']);
+ finfo_close($res);
+ }
+ if( empty( $scanFile['type'] ) ) {
+ $scanFile['type'] = ( "image/unknown" );
+ }
+
+ $newImage = new FisheyeImage();
+ $imageHash = array( 'upload' => $scanFile );
+ if( $newImage->store( $imageHash ) ) {
+ if( $pRoot ) {
+ $newImage->addToGalleries( $_REQUEST['galleryAdditions'] );
+ }
+ if( !is_object( $pParentGallery ) ) {
+ global $gBitUser;
+ $pParentGallery = new FisheyeGallery( fisheye_get_default_gallery_id( $gBitUser->mUserId, $gBitUser->getDisplayName()."'s Gallery" ) );
+ $pParentGallery->load();
+ }
+ $pParentGallery->addItem( $newImage->mContentId );
+ } else {
+ $errors = array_merge( $errors, array_values( $newImage->mErrors ) );
+ }
+ }
+ }
+ }
+ }
+ return $errors;
+}
+
+
+
+
+?>
diff --git a/view.php b/view.php
new file mode 100644
index 0000000..df6e379
--- /dev/null
+++ b/view.php
@@ -0,0 +1,25 @@
+<?php
+
+require_once( '../bit_setup_inc.php' );
+
+require_once( FISHEYE_PKG_PATH.'FisheyeGallery.php');
+require_once( FISHEYE_PKG_PATH.'FisheyeImage.php');
+
+global $gBitSystem, $fisheyeErrors, $fisheyeWarnings, $fisheyeSuccess;
+
+//$gDebug = TRUE;
+
+include_once( FISHEYE_PKG_PATH.'gallery_lookup_inc.php' );
+
+global $gHideModules;
+$gHideModules = $gBitSystem->isFeatureActive( 'fisheye_gallery_hide_modules' );
+
+if ( !$gContent->isValid() ) {
+ // No gallery was indicated so we will redirect to the browse galleries page
+ header("location: list_galleries.php");
+ die;
+}
+
+require_once( FISHEYE_PKG_PATH.'display_fisheye_gallery_inc.php' );
+
+?>
diff --git a/view_image.php b/view_image.php
new file mode 100644
index 0000000..c9eef75
--- /dev/null
+++ b/view_image.php
@@ -0,0 +1,26 @@
+<?php
+require_once( '../bit_setup_inc.php' );
+
+require_once( FISHEYE_PKG_PATH.'FisheyeGallery.php');
+require_once( FISHEYE_PKG_PATH.'FisheyeImage.php');
+
+global $gBitSystem, $gDebug;
+
+//$gDebug = TRUE;
+
+if( !empty( $_REQUEST['size'] ) ) {
+ setcookie( 'fisheyeviewsize', $_REQUEST['size'], 0, $gBitSystem->getPreference('cookie_path'), $gBitSystem->getPreference('cookie_domain') );
+}
+
+if( !empty( $_REQUEST['refresh'] ) ) {
+ $smarty->assign( 'refresh', '?refresh='.time() );
+}
+
+include_once( FISHEYE_PKG_PATH.'image_lookup_inc.php' );
+
+global $gHideModules;
+$gHideModules = $gBitSystem->isFeatureActive( 'fisheye_image_hide_modules' );
+
+require_once( FISHEYE_PKG_PATH.'display_fisheye_image_inc.php' );
+
+?>