Posted: Sat Mar 29, 2008 12:43 am Post subject: Re: Upgrade instructions (0.5.10 to 0.5.11)
I'm busy on living right now, the g2image resized image selection mod will not finished soon. The beta code will be ready by next week if my plan goes smooth.
For the current g2Image pop-up part, code doesn't check forum user's access right.
The next version needs to addrees the Guest viewable issue, I think a major rewrite on this part will be easier.
FYI: Check out the G2 module GetURLs, GetUrlsHelper.class code have everything about generate resized image URLs and Guest view access right.
Posted: Mon Apr 07, 2008 6:39 am Post subject: [beta] G2image with permission check and resizes support
Note: Beta code, do not used for production site.
1. Concepts from G2 module GetURLs, GetUrlsHelper.class.
2. Copyright: GPL
3.. The code changes based on my phpbb2 only mod, should work on patching original.
4. I don't know how to deal with the language part, just use print $string to display messages changed/aded.
Maybe someone can fix that part and fix my poor English descriptions too
5. [lburl] tags shows image fits the inner browser display area on 1024x768 screen.
Maybe we can change browser to full-screen mode with lightbox, then we can display larger resized image without scroll bars.
6. Current code can't change the Display mode as Gallery2 do.
Maybe someone can make that works.
7. Hidden images will not shown in the image selections.
Mod instruction:.
Code: › #
#-----[ OPEN ]------------------------------------
#
g2image/g2image.php
#
#-----[ FIND ]------------------------------------
#
require_once('init.php');
session_start();
#
#-----[ REPLACE WITH ]----------------------------
#
session_start();
require_once('init.php');
#
#-----[ FIND ]------------------------------------
#
// These are the universal image insertion options
$message['thumbnail_image'] = T_('Thumbnail with link to image');
$message['thumbnail_album'] = T_('Thumbnail with link to parent album');
$message['thumbnail_lightbox'] = T_('Thumbnail with LightBox link to Fullsized Image');
$message['thumbnail_custom_url'] = T_('Thumbnail with link to custom URL (from text box below)');
$message['thumbnail_only'] = T_('Thumbnail only - no link');
$message['fullsize_image'] = T_('Fullsized image with link to Gallery page for image');
$message['fullsize_only'] = T_('Fullsized image only - no link');
$message['link_image'] = T_('Text link to image');
$message['link_album'] = T_('Text link to parent album');
#
#-----[ REPLACE WITH ]----------------------------
#
// These are the universal image insertion options
$message['thumbnail_image'] = T_('Thumbnail with link to image');
$message['thumbnail_album'] = T_('Thumbnail with link to parent album');
$message['thumbnail_only'] = T_('Thumbnail only - no link');
if ($g2ic_options['guest_view']) {
$message['thumbnail_lightbox'] = 'Thumbnail with LightBox link to Max. screen size Image';
$message['fullsize_image'] = 'Max. Resized image with link to Gallery page for image';
$message['fullsize_only'] = T_('Max. Resized image only - no link');
}
else {
$message['thumbnail_lightbox'] = T_('Thumbnail with LightBox link to Fullsized Image');
$message['fullsize_image'] = T_('Fullsized image with link to Gallery page for image');
$message['fullsize_only'] = T_('Fullsized image only - no link');
}
$message['thumbnail_custom_url'] = T_('Thumbnail with link to custom URL (from text box below)');
$message['link_image'] = T_('Text link to image');
$message['link_album'] = T_('Text link to parent album');
#
#-----[ FIND ]------------------------------------
#
// Make the universal message array
$imginsert_selectoptions = array(
'thumbnail_image' => array(
'text' => $message['thumbnail_image'] ),
'thumbnail_album' => array(
'text' => $message['thumbnail_album'] ),
'thumbnail_lightbox' => array(
'text' => $message['thumbnail_lightbox'] ),
'thumbnail_custom_url' => array(
'text' => $message['thumbnail_custom_url'] ),
'thumbnail_only' => array(
'text' => $message['thumbnail_only'] ),
'fullsize_image' => array(
'text' => $message['fullsize_image'] ),
'fullsize_only' => array(
'text' => $message['fullsize_only'] ),
'link_image' => array(
'text' => $message['link_image'] ),
'link_album' => array(
'text' => $message['link_album'] ),
);
#
#-----[ REPLACE WITH ]----------------------------
#
// Make the universal message array
$imginsert_selectoptions = array(
'thumbnail_image' => array(
'text' => $message['thumbnail_image'] ),
'thumbnail_album' => array(
'text' => $message['thumbnail_album'] ),
'thumbnail_only' => array(
'text' => $message['thumbnail_only'] ),
'thumbnail_lightbox' => array(
'text' => $message['thumbnail_lightbox'] ),
'fullsize_image' => array(
'text' => $message['fullsize_image'] ),
'fullsize_only' => array(
'text' => $message['fullsize_only'] ),
'thumbnail_custom_url' => array(
'text' => $message['thumbnail_custom_url'] ),
'link_image' => array(
'text' => $message['link_image'] ),
'link_album' => array(
'text' => $message['link_album'] ),
);
#
#-----[ FIND ]------------------------------------
#
function g2ic_get_item_info($item_id) {
global $gallery;
#
#-----[ REPLACE WITH ]----------------------------
#
function g2ic_get_item_info($item_id) {
global $gallery, $g2ic_options;
#
#-----[ FIND ]------------------------------------
#
$urlGenerator =& $gallery->getUrlGenerator();
#
#-----[ AFTER, ADD ]------------------------------
#
// User permission check
$userId = $gallery->getActiveUserId();
if ($g2ic_options['guest_view']) {
list ($error, $GuestId) = GalleryCoreApi::getPluginParameter('module', 'core', 'id.anonymousUser');
// FIXME: Do we need error handling for this?
$userId = $GuestId;
}
// get the item permissions
list ($error, $acl) = GalleryCoreApi::getPermissions($item_id, $userId, false);
$canViewThumb = false;
$canViewResized = false;
$canViewOriginal = false;
// Note: array_key_exists (PHP 4 >= 4.0.7, PHP 5), use key_exists() in PHP 4.0.6.
if (array_key_exists('core.view', $acl)) {
$canViewThumb = true;
}
if (array_key_exists('core.viewAll', $acl)) {
$canViewResized = true;
$canViewOriginal = true;
}
else {
if (array_key_exists('core.viewResizes', $acl)) {
$canViewResized = true;
}
if (array_key_exists('core.viewSource', $acl)) {
$canViewOriginal = true;
}
}
#
#-----[ FIND ]------------------------------------
#
foreach ($items as $item) {
#
#-----[ AFTER, ADD ]------------------------------
#
// permission check
// FIXME: hidden image not shown
if ( !$canViewThumb || (!$canViewResized && !$canViewOriginal) ) {
return false; // skip those without any view permissions
}
#
#-----[ REPLACE WITH ]----------------------------
#
// Get original image url
if ($canViewOriginal) {
$item_info['fullsize_img'] = $urlGenerator->generateUrl(array('view' => 'core.DownloadItem', 'itemId' => $item->getid()), array('forceFullUrl' => true));
if (!$canViewResized && $item->getHeight() <= $g2ic_options['resize_maxH'] && $item->getWidth() <= $g2ic_options['resize_maxW'])
$item_info['dspsize_img'] = $item_info['fullsize_img'];
}
// Get max display size resized image url
if ($canViewResized) {
list ($error, $imgs) = GalleryCoreApi::fetchDerivativesBySourceIds(array($item_id)); // <- all resizes + thumb
//list ($error, $resizes) = GalleryCoreApi::fetchResizesByItemIds(array($item_id));
// FIXME: Assume resizes size in ascending order
if (!$error && isset($resizes[$item_id])) {
$i = count($resizes[$item_id]);
// Full-sized not permitted to view, assign the max resize image url
if (!isset($item_info['fullsize_img'])) {
$item_info['fullsize_img'] = $urlGenerator->generateUrl(array('view' => 'core.DownloadItem', 'itemId' => $resizes[$item_id][$i-1]->getid()), array('forceFullUrl' => true));
}
else { // Add Original to Resizes if user can view
array_push($resizes[$item_id], $item);
$i++;
}
// If Display size resized not set, assign to thumbnail image url
if (!isset($item_info['dspsize_img'])) {
$item_info['dspsize_img'] = $item_info['thumbnail_src'];
}
#
#-----[ FIND ]------------------------------------
#
. ' d = new dTree("d");' . "\n";
#
#-----[ REPLACE WITH ]----------------------------
#
. ' var d = new dTree("d");' . "\n";
#
#-----[ FIND ]------------------------------------
#
break; // Have gone past the range for this page
#
#-----[ AFTER, ADD ]------------------------------
#
$item_info = g2ic_get_item_info($image_id);
// User have no rights to view image or hidden, don't display this
if (!$item_info) {
continue;
}
// This sets the returned URLs be guest viewable image . If set to TRUE,
// returned URLs is guest viewable. If set to FALSE, g2image returns URLs of
// full size and max. resied image may not be viewable by guest.
$g2ic_images_guest_view = TRUE;
// Change this for limits of resized images.
// Default will fit the inner display area of browser under 1024x768 screen.
Posted: Mon Apr 07, 2008 9:20 am Post subject: Re: Upgrade instructions (0.5.10 to 0.5.11)
Wow, nice! I'll have to check that out later...I have real work to do now.
I've actually been thinking about abandoning g2image for the phpbb3 integration and adapting the mapAllGalleryLinks function in g2helper to do the same thing. I have it respecting Gallery permissions now for profile views.
Quote: › phpbb2 doesn't used "g2_GALLERYSID=...", is it better to filtered out before passing to the javascripts?
I filter it after the javascripts in the phpbb3 integration, before the message gets saved in the database. The js doesn't care if the sid is there or not. I use a piece of code modified from your fix posted earlier.
Posted: Tue Apr 08, 2008 12:58 pm Post subject: [beta-2] G2image with permission check and resizes support
Edit: Last code works on my test servedr, but not my personal site. code now fixed.
Update: Code cleanup, with g2-sid filtering from function.js
Code: › #
#-----[ OPEN ]------------------------------------
#
g2image/g2image.php
#
#-----[ FIND ]------------------------------------
#
require_once('init.php');
session_start();
#
#-----[ REPLACE WITH ]----------------------------
#
session_start();
require_once('init.php');
#
#-----[ FIND ]------------------------------------
#
// These are the universal image insertion options
$message['thumbnail_image'] = T_('Thumbnail with link to image');
$message['thumbnail_album'] = T_('Thumbnail with link to parent album');
$message['thumbnail_lightbox'] = T_('Thumbnail with LightBox link to Fullsized Image');
$message['thumbnail_custom_url'] = T_('Thumbnail with link to custom URL (from text box below)');
$message['thumbnail_only'] = T_('Thumbnail only no link');
$message['fullsize_image'] = T_('Fullsized image with link to Gallery page for image');
$message['fullsize_only'] = T_('Fullsized image only no link');
$message['link_image'] = T_('Text link to image');
$message['link_album'] = T_('Text link to parent album');
#
#-----[ REPLACE WITH ]----------------------------
#
// These are the universal image insertion options
$message['thumbnail_image'] = T_('Thumbnail with link to image');
$message['thumbnail_album'] = T_('Thumbnail with link to parent album');
$message['thumbnail_only'] = T_('Thumbnail only no link');
if ($g2ic_options['guest_view']) {
$message['thumbnail_lightbox'] = 'Thumbnail with LightBox link to Max. screen size Image';
$message['fullsize_image'] = 'Max. Resized image with link to Gallery page for image';
$message['fullsize_only'] = 'Max. Resized image only no link';
}
else {
$message['thumbnail_lightbox'] = T_('Thumbnail with LightBox link to Fullsized Image');
$message['fullsize_image'] = T_('Fullsized image with link to Gallery page for image');
$message['fullsize_only'] = T_('Fullsized image only no link');
}
$message['thumbnail_custom_url'] = T_('Thumbnail with link to custom URL (from text box below)');
$message['link_image'] = T_('Text link to image');
$message['link_album'] = T_('Text link to parent album');
#
#-----[ FIND ]------------------------------------
#
// Make the universal message array
$imginsert_selectoptions = array(
'thumbnail_image' => array(
'text' => $message['thumbnail_image'] ),
'thumbnail_album' => array(
'text' => $message['thumbnail_album'] ),
'thumbnail_lightbox' => array(
'text' => $message['thumbnail_lightbox'] ),
'thumbnail_custom_url' => array(
'text' => $message['thumbnail_custom_url'] ),
'thumbnail_only' => array(
'text' => $message['thumbnail_only'] ),
'fullsize_image' => array(
'text' => $message['fullsize_image'] ),
'fullsize_only' => array(
'text' => $message['fullsize_only'] ),
'link_image' => array(
'text' => $message['link_image'] ),
'link_album' => array(
'text' => $message['link_album'] ),
);
#
#-----[ REPLACE WITH ]----------------------------
#
// Make the universal message array
$imginsert_selectoptions = array(
'thumbnail_image' => array(
'text' => $message['thumbnail_image'] ),
'thumbnail_album' => array(
'text' => $message['thumbnail_album'] ),
'thumbnail_only' => array(
'text' => $message['thumbnail_only'] ),
'thumbnail_lightbox' => array(
'text' => $message['thumbnail_lightbox'] ),
'fullsize_image' => array(
'text' => $message['fullsize_image'] ),
'fullsize_only' => array(
'text' => $message['fullsize_only'] ),
'thumbnail_custom_url' => array(
'text' => $message['thumbnail_custom_url'] ),
'link_image' => array(
'text' => $message['link_image'] ),
'link_album' => array(
'text' => $message['link_album'] ),
);
#
#-----[ FIND ]------------------------------------
#
function g2ic_get_item_info($item_id) {
global $gallery;
:
:
:
return $item_info;
}
#
#-----[ REPLACE WITH ]----------------------------
#
function g2ic_get_item_info($item_id) {
global $gallery, $g2ic_options;
$urlGenerator =& $gallery->getUrlGenerator();
// User permission check
$userId = $gallery->getActiveUserId();
if ($g2ic_options['guest_view']) {
list ($error, $GuestId) = GalleryCoreApi::getPluginParameter('module', 'core', 'id.anonymousUser');
// FIXME: Do we need error handling for this?
$userId = $GuestId;
}
// get the item permissions
list ($error, $acl) = GalleryCoreApi::getPermissions($item_id, $userId, false);
// FIXME: Do we need error handling for this?
$canViewThumb = false;
$canViewResized = false;
$canViewOriginal = false;
// Note: array_key_exists (PHP 4 >= 4.0.7, PHP 5), use key_exists() in PHP 4.0.6.
if (array_key_exists('core.view', $acl)) {
$canViewThumb = true;
}
if (array_key_exists('core.viewAll', $acl)) {
$canViewResized = true;
$canViewOriginal = true;
}
else {
if (array_key_exists('core.viewResizes', $acl)) {
$canViewResized = true;
}
if (array_key_exists('core.viewSource', $acl)) {
$canViewOriginal = true;
}
}
list ($error,$items) = GalleryCoreApi::loadEntitiesById(array($item_id));
if(!$error) {
foreach ($items as $item) {
// permission check
// FIXME: hidden image not shown
if ( !$canViewThumb || (!$canViewResized && !$canViewOriginal) ) {
return false; // skip those without any view permissions
}
// Get resizes
list ($error, $AllVersions) = GalleryCoreApi::fetchResizesByItemIds(array($item_id));
if(!$error && isset($AllVersions[$item_id])) {
// put original in array
array_push($AllVersions[$item_id], $item);
$i = count($AllVersions[$item_id]);
// Original info
if ($canViewOriginal) {
$item_info['fullsize_img'] = $urlGenerator->generateUrl(array('view' => 'core.DownloadItem', 'itemId' => $item->getid()), array('forceFullUrl' => true));
// If no view resizes permission, set max display size resized image url to full if not over sized
if (!$canViewResized && $item->getHeight() <= $g2ic_options['resize_maxH'] && $item->getWidth() <= $g2ic_options['resize_maxW'])
$item_info['dspsize_img'] = $item_info['fullsize_img'];
}
// Max display size resized info
if ($canViewResized) {
// If no view Original permission, assign Full url to the max resize image
if (!$canViewOriginal) {
$i--;
$item_info['fullsize_img'] = $urlGenerator->generateUrl(array('view' => 'core.DownloadItem', 'itemId' => $AllVersions[$item_id][$i-1]->getid()), array('forceFullUrl' => true));
}
// FIXME: Assume resizes size in ascending order
while ($i--) {
if ($AllVersions[$item_id][$i]->getHeight() <= $g2ic_options['resize_maxH'] && $AllVersions[$item_id][$i]->getWidth() <= $g2ic_options['resize_maxW']) {
$item_info['dspsize_img'] = $urlGenerator->generateUrl(array('view' => 'core.DownloadItem', 'itemId' => $AllVersions[$item_id][$i]->getid()), array('forceFullUrl' => true));
break;
}
}
}
else {
print 'Error loading resizes';
}
}
}
// All resizes oversized or no view resizes permission, set max resize url to thumbnail
if (!isset($item_info['dspsize_img'])) {
$item_info['dspsize_img'] = $item_info['thumbnail_src'];
}
}
else {
print T_('Error loading album items');
}
return $item_info;
}
#
#-----[ FIND ]------------------------------------
#
. ' d = new dTree("d");' . "\n";
#
#-----[ REPLACE WITH ]----------------------------
#
. ' var d = new dTree("d");' . "\n";
#
#-----[ FIND ]------------------------------------
#
. ' <legend>' . T_('Display Options') . '</legend>' . "\n"
#
#-----[ REPLACE WITH ]----------------------------
#
. ' <legend>' . T_('Display Options');
// Display Guest viewable
if ($g2ic_options['guest_view']) {
$html .= ' (Guest View)';
}
$html .= '</legend>' . "\n"
#
#-----[ FIND ]------------------------------------
#
break; // Have gone past the range for this page
#
#-----[ AFTER, ADD ]------------------------------
#
$item_info = g2ic_get_item_info($image_id);
// User have no rights to view image or hidden, don't display this
if (!$item_info) {
continue;
}
// This sets the returned URLs be guest viewable image . If set to TRUE,
// returned URLs is guest viewable. If set to FALSE, g2image returns URLs of
// full size and max. resied image may not be viewable by guest.
$g2ic_images_guest_view = TRUE;
// Change this for limits of resized images.
// Default will fit the inner display area of browser under 1024x768 screen.
#
#-----[ OPEN ]----------------------------------
#
includes/bbcode.php
#
#-----[ FIND ]----------------------------------
#
# if you don't have my mod, skip to next FIND
// g2image G2 url rewrite support(for [img]...[/img] tags)
$text = preg_replace('((\?)(g2_GALLERYSID=[a-f0-9]+|g2_GALLERYSID=TMP_SESSION_ID_DI_NOISSES_PMT))', '', $text);
#
#-----[ REPLACE WITH ]----------------------------
#
# delete lines
#
#-----[ FIND ]----------------------------------
#
$text = preg_replace('((\&\;)(g2_GALLERYSID=[a-f0-9]+|g2_GALLERYSID=TMP_SESSION_ID_DI_NOISSES_PMT))', '', $text);
#
#-----[ REPLACE WITH ]----------------------------
#
# delete line
#
#-----[ SAVE/CLOSE ALL FILES ]---------------------
#
# EoM
Posted: Tue Jun 24, 2008 8:58 am Post subject: Re: Upgrade instructions (0.5.10 to 0.5.11)
Well, I don't have phpbb2 installed, but I think you are missing something there. If $ret is set then getAsHtml() should work because $ret is an object and getAsHtml is a method of that object. It should be passing text to the errorHandler function. There is no function by that name in the integration code because it is a status object returned by gallery when there is an error.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum