Support Forums | Demo Gallery [1.x] [2.x] | Downloads | News | Site Map ]
Nuked Gallery
  Create a FREE account or Login   As a guest, you don't have access to our FULL navigation system.
 Forum FAQForum FAQ   StatisticsStatistics   SearchSearch   UsergroupsUsergroups   FavoritesFavorites  

New integration version available for testing
Goto page 1, 2  Next
 
Post new topic   This topic is locked: you cannot edit posts or make replies.    NukedGallery.net Forum Index » phpBB Integration » phpBB3 / Gallery 2 Integration View previous topicPrinter friendly versionView next topic
Author Message
jettyrat

Moderator
Moderator


Joined: Nov 28, 2005
Posts: 1144

PostPosted: Mon Oct 06, 2008 11:31 am    Post subject: New integration version available for testing Reply with quote

Since the G2.3 release appears to be on the horizon, I'll go ahead and put up a temporary link to the new integration version for testing. Please post any problems encountered with it here and please note this is for testing only and is not the official release and as such things are subject to change!

Gallery2_Integration-1.2.1.zip [jettyfishing.com]

Changes since version 1.0.1a:
* Update - Small change(s) to find instructions for phpBB3.0.2
* Update - Mod is compatible with Gallery 2.3
* Change - Various suggestions by phpBB MOD team.
* Change - Only phpBB founders are mapped as Gallery admins by default during initial export.
* Added feature - Integration administration actions now logged in the phpBB admin log.
* Added feature - As of G2.3, Gallery meta tags now included in head of embedded pages.
* Added feature - As of G2.3, phpBB passwords accepted by Gallery via phpass so standalone access, Gallery Remote, etc. now work properly.
* Added feature - phpBB3 compliant Gallery 2 image selector for inserting Gallery images. Replaces 3rd party image chooser.
* Added feature - UCP control for links in messages, memberlist and profiles.
* Added feature - Select avatar from Gallery 2 now possible.
* Change - Revised code for automatic configuration.
* Change - Using slimbox instead of lightbox.
* Change - Removed phpbb3-lightbox.xml because the mods are not compatible with slimbox.
* Change - Removed gallery2-lightbox.xml because the mods are not compatible with slimbox and these types of mods are documented on the Gallery website.
* Update - Repackaged for new MODDB requirements.
Back to top
Offline View user's profile Send private message
AdBot
   Post subject: New integration version available for testing  

Back to top
PoPoutdoor

Wizard
Wizard


Joined: Jan 20, 2006
Posts: 129

PostPosted: Tue Oct 07, 2008 2:03 pm    Post subject: Re: New integration version available for testing Reply with quote

G2IS issue

Current code doesn't handle GalleryLinkItem Object well.

My fix is to skip displaying ALL linked objects:

find:

Code: ›    // Recurse the desired items and build the display data
   foreach ($itemObjects as $itemObject)
   {


add after:

Code: ›       // Skip GalleryLinkItems
      if ($itemObject->getEntityType() == 'GalleryLinkItem')
      {
         $itemCount--;
         continue;
      }



find:

Code: ›    'TOTAL_ITEMS'     => ($itemCount == 1) ? sprintf($user->lang['G2IS_ITEM'], $itemCount) : sprintf($user->lang['G2IS_ITEMS'], $itemCount),


replace with:

Code: ›    'TOTAL_ITEMS'     => ($itemCount < 2) ? $itemCount . ' ' . $user->lang['G2IS_ITEM'] : sprintf($user->lang['G2IS_ITEMS'], $itemCount),


You can skip ALL non GalleryPhotoItem by changing getEntityType() == 'GalleryLinkItem' to getEntityType() != 'GalleryPhotoItem' Wink
Back to top
Offline View user's profile Send private message
jettyrat

Moderator
Moderator


Joined: Nov 28, 2005
Posts: 1144

PostPosted: Tue Oct 07, 2008 3:01 pm    Post subject: Re: New integration version available for testing Reply with quote

While I agree with the idea you have there, I don't necessarily agree with the implementation of it. Smile One could simply return GalleryPhotoItem's by adding the EntityType parameter to the LoadEntitiesById function. The problem with both of those approaches is that this is taking place at a point where the page is ready to be built using the itemLimit value to display a certain number of images per page and doing the filtering here means the number of items on the page will be off (and could possibly result in a page with no items).

The filtering should ideally be done at a lower level, but the problem with that is we are holding off on loading the objects until we have narrowed down the selection to the actual objects that will be displayed to save resources so checking the entity type is not so simple at a lower level unless there is a better way to do this. Will have to think about that some more...


Last edited by jettyrat on Tue Oct 07, 2008 3:26 pm; edited 1 time in total
Back to top
Offline View user's profile Send private message
jettyrat

Moderator
Moderator


Joined: Nov 28, 2005
Posts: 1144

PostPosted: Tue Oct 07, 2008 3:03 pm    Post subject: Re: New integration version available for testing Reply with quote

Did the original g2image have this capability? I don't recall seeing anything in the code that could distinguish between entity types Confused
Back to top
Offline View user's profile Send private message
jettyrat

Moderator
Moderator


Joined: Nov 28, 2005
Posts: 1144

PostPosted: Tue Oct 07, 2008 5:00 pm    Post subject: Re: New integration version available for testing Reply with quote

Maybe have to do something like this using a direct gallery query

Find:
Code: › // Subtract the albumItemIds from the childItemIds

Before, Add:
Code: › $query = 'SELECT [GalleryEntity::id] FROM [GalleryEntity] WHERE [GalleryEntity::entityType] = ? AND [GalleryEntity::id] IN (' . implode(',', $childItems) . ')';
list ($ret, $searchResults) = $gallery->search($query, array('GalleryPhotoItem'));
if ($ret) {
    echo 'Problem!';
}
$childItems = array();
while ($result = $searchResults->nextResult()) {
    $childItems[] = $result[0];
}

I couldn't figure out how to make the 'IN' part of the sql work with the gallery->search parameters where it should be, but didn't have much time to mess with it. Smile

I will be on the road until next week, so won't be able to do much with any of this or the forum support until then...
Back to top
Offline View user's profile Send private message
PoPoutdoor

Wizard
Wizard


Joined: Jan 20, 2006
Posts: 129

PostPosted: Wed Oct 08, 2008 2:48 am    Post subject: Re: New integration version available for testing Reply with quote

jettyrat wrote: › While I agree with the idea you have there, I don't necessarily agree with the implementation of it. Smile One could simply return GalleryPhotoItem's by adding the EntityType parameter to the LoadEntitiesById function. The problem with both of those approaches is that this is taking place at a point where the page is ready to be built using the itemLimit value to display a certain number of images per page and doing the filtering here means the number of items on the page will be off (and could possibly result in a page with no items)....

I'd been testing for a way doing the filter from your code, starting from GalleryCoreApi::fetchAlbumTree()...

The only way to do filtering is to place code there (see post above) without much overhead and code changes.

So, it is only a quick fix.

jettyrat wrote: › Maybe have to do something like this using a direct gallery query...


I think using gallery API call is the best and safe way...

BTW: I'm working on back port G2IS to phpbb2. Since the cache functions isn't in phpbb2, I have to find a way to reduce loading with no cache support.


Last edited by PoPoutdoor on Sun Oct 12, 2008 2:14 am; edited 1 time in total
Back to top
Offline View user's profile Send private message
GENCarter

Novice
Novice


Joined: Oct 08, 2008
Posts: 26

PostPosted: Wed Oct 08, 2008 3:56 pm    Post subject: Re: New integration version available for testing Reply with quote

Hello,

is it possible to use the location-information of phpbb3 instead of using the one of the gallery.

I think I have to modify this code in theme.tpl:

Code: › <div class="gbBreadCrumb">
     {g->block type="core.BreadCrumb"}
   </div>


What do I have to change?[/code]
Back to top
Offline View user's profile Send private message
PoPoutdoor

Wizard
Wizard


Joined: Jan 20, 2006
Posts: 129

PostPosted: Thu Oct 09, 2008 2:02 am    Post subject: Re: New integration version available for testing Reply with quote

jettyrat wrote: › Did the original g2image have this capability? I don't recall seeing anything in the code that could distinguish between entity types Confused

The 0.5.12 g2image doesn't deal with entity types, but handle 0 item code is there.
Back to top
Offline View user's profile Send private message
PoPoutdoor

Wizard
Wizard


Joined: Jan 20, 2006
Posts: 129

PostPosted: Thu Oct 09, 2008 12:45 pm    Post subject: Re: New integration version available for testing Reply with quote

[Delete outdated code mods]

Last edited by PoPoutdoor on Sun Oct 12, 2008 2:10 am; edited 2 times in total
Back to top
Offline View user's profile Send private message
GENCarter

Novice
Novice


Joined: Oct 08, 2008
Posts: 26

PostPosted: Fri Oct 10, 2008 9:51 am    Post subject: Re: New integration version available for testing Reply with quote

Can someone please provide a German gallery button for the memberlist!
That would be great.
Back to top
Offline View user's profile Send private message
PoPoutdoor

Wizard
Wizard


Joined: Jan 20, 2006
Posts: 129

PostPosted: Fri Oct 10, 2008 1:06 pm    Post subject: Re: New integration version available for testing Reply with quote

You can get one from phpbb2plus package Wink
Back to top
Offline View user's profile Send private message
PoPoutdoor

Wizard
Wizard


Joined: Jan 20, 2006
Posts: 129

PostPosted: Sun Oct 12, 2008 2:00 am    Post subject: Re: New integration version available for testing Reply with quote

G2IS - with Gallery permission + bug fix:

[EDIT; Remove outdated code mods]


Last edited by PoPoutdoor on Mon Oct 13, 2008 8:34 am; edited 2 times in total
Back to top
Offline View user's profile Send private message
PoPoutdoor

Wizard
Wizard


Joined: Jan 20, 2006
Posts: 129

PostPosted: Mon Oct 13, 2008 1:52 am    Post subject: Re: New integration version available for testing Reply with quote

G2IS - Update with Gallery permission + fix

Edit file: g2is.html

find:

Code: ›                {L_G2IS_BBCODE}<br /><select name="bbcode" onchange="toggleTextBoxes(this.selectedIndex);">{BBCODE_OPTIONS}</select>


replace with:

Code: ›                {L_G2IS_BBCODE}<br /><select name="bbcode" onchange="toggleTextBoxes(this);">{BBCODE_OPTIONS}</select>


Edit file: g2is.js

find:

Code: ›    var bbcode = (typeof(option) == 'undefined' ) ? document.getElementsByName('bbcode')[0].selectedIndex : option;
   var view_resizes = ((bbcode == '2') || (bbcode == '4') || (bbcode == '5') || (bbcode == '10')) ? false : true;


replace with:

Code: ›    var bbcode = (typeof(option) == 'undefined' ) ? src_form.bbcode.value : option.value;
   var view_resizes = ((bbcode == '0') || (bbcode == '3') || (bbcode == '6') || (bbcode == '7') || (bbcode == '8')) ? true : false;


find:

Code: ›    var mode = document.getElementsByName('bbcode')[0].selectedIndex;

   mode = (typeof(mode) == 'undefined') ? src_form.bbcode.value : mode.toString();


replace with:

Code: ›    var mode = src_form.bbcode.value;


find:

Code: ›       item_size[0] = src_form.sizes.value;
   }


after add:

Code: ›
   itema = document.getElementById('_a').value;


find:

Code: ›          item = document.getElementById(item_id[i] + '_' + item_size[i]).value;
         itemw = '&width=' + document.getElementById(item_id[i] + '_' + item_size[i] + '_w').value;
         itemh = '&height=' + document.getElementById(item_id[i] + '_' + item_size[i] + '_h').value;
         itema = document.getElementById(item_id[i] + '_0_a').value;
         itemp = document.getElementById(item_id[i] + '_0_p').value;


replace with:

Code: ›
         itemp = document.getElementById(item_id[i] + '_t_p').value;

         if (document.getElementById(item_id[i] + '_' + item_size[i]))
         {
            item = document.getElementById(item_id[i] + '_' + item_size[i]).value;
            itemw = '&width=' + document.getElementById(item_id[i] + '_' + item_size[i] + '_w').value;
            itemh = '&height=' + document.getElementById(item_id[i] + '_' + item_size[i] + '_h').value;
         }


Edit file: g2is.php

find:

Code: › $link_options = array(
   'THUMB_LINK_IMAGE',
   'THUMB_LINK_PAGE',
   'THUMB_LINK_ALBUM',
   'THUMB_LINK_LIGHT',
   'THUMB_LINK_URL',
   'THUMB_NO_LINK',
   'FULL_LINK_PAGE',
   'FULL_NO_LINK',
   'TEXT_LINK_FULL',
   'TEXT_LINK_PAGE',
   'TEXT_LINK_ALBUM'
);

$link_opt_default = $link_options[0]; // prefered default link option


replace with:

Code: › $link_options = array(
   '0' => 'THUMB_LINK_IMAGE',
   '1' => 'THUMB_LINK_PAGE',
   '2' => 'THUMB_LINK_ALBUM',
   '3' => 'THUMB_LINK_LIGHT',
   '4' => 'THUMB_LINK_URL',
   '5' => 'THUMB_NO_LINK',
   '6' => 'FULL_LINK_PAGE',
   '7' => 'FULL_NO_LINK',
   '8' => 'TEXT_LINK_FULL',
   '9' => 'TEXT_LINK_PAGE',
   '10' => 'TEXT_LINK_ALBUM'
);

$link_opt_default = 0; // prefered default link option


find:

Code: › $g2is_url = append_sid("{$phpbb_root_path}g2is.$phpEx", $form_target);


after add:

Code: › $rootAlbum_url = htmlspecialchars_decode("$g2is_url&amp;albumId=$rootAlbumId");


find:

Code: › $itemCount = sizeof($itemIds);

// Make sure currentItem is within range
$currentItem = ($currentItem > $itemCount - 1) ? $itemCount - 1 : $currentItem;

// Display the desired items
if ($itemCount)
{
   // First, determine the item limit if it exceeds the size of the item array
   $sliceLimit = ($currentItem + $itemLimit > $itemCount) ? $itemCount : $currentItem + $itemLimit;

   // Grab the current items of interest to be displayed on this page view
   $itemIds = array_slice($itemIds, $currentItem, $sliceLimit);

   $itemObjects = fetchEntities($itemIds);

   // Recurse the desired items and build the display data
   foreach ($itemObjects as $itemObject)
   {
      list($ret, $thumbnail) = GalleryCoreApi::fetchThumbnailsByItemIds(array($itemObject->getId()));
      if (isset($ret))
      {
         trigger_error(sprintf($user->lang['G2_FETCHTHUMBSBYITEMS_FAILED'], $itemObject->getId()) . $user->lang['G2_ERROR'] . $ret->getAsHtml(), E_USER_ERROR);
      }

      list($ret, $resizes) = GalleryCoreApi::fetchResizesByItemIds(array($itemObject->getId()));
      if (isset($ret))
      {
         trigger_error(sprintf($user->lang['G2_FETCHRESIZESBYITEMS_FAILED'], $itemObject->getId()) . $user->lang['G2_ERROR'] . $ret->getAsHtml(), E_USER_ERROR);
      }

      // Build options for the thumbnail
      $index = 't';
      list ($s_hidden_data, $void) = buildOptions($itemObject->getId(), $index, $thumbnail[$itemObject->getId()], $urlGenerator, false);

      // Build options for the original image
      $index = 0;
      list ($s_hidden_data, $size_options) = buildOptions($itemObject->getId(), $index, $itemObject, $urlGenerator, true);

      // Build options for the resized images
      for ($i = 0, $size = sizeof($resizes); $i < $size; $i++)
      {
         $index++;

         list ($s_hidden_data, $options) = buildOptions($itemObject->getId(), $index, $resizes[$itemObject->getId()][$i], $urlGenerator, false);

         $size_options .= $options;
      }


replace with:

Code: › if (sizeof($itemIds))
{
   // Get item permissions
   list ($ret, $acl) = GalleryCoreApi::fetchPermissionsForItems($itemIds);
   if (isset($ret))
   {
      trigger_error(sprintf($user->lang['G2_FETCHPERMISSIONS_FAILED'], $itemObject->getId()) . $user->lang['G2_ERROR'] . $ret->getAsHtml(), E_USER_ERROR);
   }

   // Filter GalleryObjects
   $itemObjects = array();
   $GalleryItems = fetchEntities($itemIds);

   foreach ($GalleryItems as $Item)
   {
      // PhotoItem only
      if ($Item->getEntityType() == 'GalleryPhotoItem')
      {
         $itemObjects[] = $Item;
      }
   }
}

$itemCount = sizeof($itemObjects);

// Make sure currentItem is within range
$currentItem = ($currentItem > $itemCount - 1) ? $itemCount - 1 : $currentItem;

// Display the desired items
if ($itemCount)
{
   // First, determine the item limit if it exceeds the size of the item array
   $sliceLimit = ($currentItem + $itemLimit > $itemCount) ? $itemCount : $itemLimit;

   // Grab the current items of interest to be displayed on this page view
   $itemIds = array_slice($itemIds, $currentItem, $sliceLimit);

   // Recurse the desired items and build the display data
   foreach ($itemObjects as $itemObject)
   {
      $id = $itemObject->getId();

      // Build options for the thumbnail
      list($ret, $thumbnail) = GalleryCoreApi::fetchThumbnailsByItemIds(array($id));
      if (isset($ret))
      {
         trigger_error(sprintf($user->lang['G2_FETCHTHUMBSBYITEMS_FAILED'], $itemObject->getId()) . $user->lang['G2_ERROR'] . $ret->getAsHtml(), E_USER_ERROR);
      }

      $index = 't';
      list ($s_hidden_data, $void) = buildOptions($id, $index, $thumbnail[$id], $urlGenerator, true);

      // Build options for the original image
      $index = 0;
      // Build options for the original image
      if ( array_key_exists('core.viewSource', $acl[$id]) )
      {
         list ($s_hidden_data, $size_options) = buildOptions($id, $index, $itemObject, $urlGenerator);
      }

      // Build options for the resized images
      if ( array_key_exists('core.viewResizes', $acl[$id]) )
      {
         list($ret, $resizes) = GalleryCoreApi::fetchResizesByItemIds(array($id));
         if (isset($ret))
         {
            trigger_error(sprintf($user->lang['G2_FETCHRESIZESBYITEMS_FAILED'], $itemObject->getId()) . $user->lang['G2_ERROR'] . $ret->getAsHtml(), E_USER_ERROR);
         }

         $size = sizeof($resizes[$id]);
         if ( $size )
         {
            if ( !array_key_exists('core.viewSource', $acl[$id]) )
            {
               $size--;
               list ($s_hidden_data, $size_options) = buildOptions($id, $index, $resizes[$id][$size], $urlGenerator);
            }

            for ($i = 0; $i < $size; $i++)
            {
               $index++;
               list ($s_hidden_data, $options) = buildOptions($id, $index, $resizes[$id][$i], $urlGenerator);
               $size_options .= $options;
            }
         }
      }

      // Build Parent Album page link
      $s_hidden_data['_a'] = $urlGenerator->generateUrl(array('itemId' => $itemObject->getParentId()), array('forceFullUrl' => true, 'forceSessionId' => false));



find:

Code: ›          'ITEM_ID'      => $itemObject->getId(),


replace with:

Code: ›          'ITEM_ID'      => $id,


find:

Code: ›          'THUMB_URL'      => $urlGenerator->generateUrl(array('view' => 'core.DownloadItem', 'itemId' => $thumbnail[$itemObject->getId()]->getId()), array('forceFullUrl' => true, 'forceSessionId' => false)),
         'THUMB_WIDTH'   => $thumbnail[$itemObject->getId()]->getWidth(),
         'THUMB_HEIGHT'   => $thumbnail[$itemObject->getId()]->getHeight(),
         'THUMB_LINK'   => $urlGenerator->generateUrl(array('view' => 'core.DownloadItem', 'itemId' => $itemObject->getId()), array('forceFullUrl' => true, 'forceSessionId' => false)),


replace with:

Code: ›          'THUMB_URL'      => $urlGenerator->generateUrl(array('view' => 'core.DownloadItem', 'itemId' => $thumbnail[$id]->getId()), array('forceFullUrl' => true, 'forceSessionId' => false)),
         'THUMB_WIDTH'   => $thumbnail[$id]->getWidth(),
         'THUMB_HEIGHT'   => $thumbnail[$id]->getHeight(),
         'THUMB_LINK'   => $urlGenerator->generateUrl(array('view' => 'core.DownloadItem', 'itemId' => $id), array('forceFullUrl' => true, 'forceSessionId' => false)),


find:

Code: › // Build bbcode link options
$index = 0;
$bbcode_options = '';
foreach ($link_options as $key)
{
   $bbcode_options .= "<option value=\"$index\"";
   $bbcode_options .= ($link_opt_default == $key) ? ' selected="selected">' : '>';
   $bbcode_options .= $user->lang[$key] . '</option>';
   $index++;
}


replace with:

Code: › // Build valid bbcode link options
$CanViewDevs = false;
foreach ($acl as $key)
{
   $CanViewDevs = $CanViewDevs || $key['core.viewResizes'];
   $CanViewDevs = $CanViewDevs || $key['core.viewSource'];
}

if ( !$CanViewDevs )
{
   $link_options = array(
      '2' => 'THUMB_LINK_ALBUM',
      '4' => 'THUMB_LINK_URL',
      '5' => 'THUMB_NO_LINK',
      '10' => 'TEXT_LINK_ALBUM'
   );

   $link_opt_preferred = 2;
}

// Build bbcode link options
$bbcode_options = '';
foreach ($link_options as $key => $dat)
{
   $bbcode_options .= "<option value=\"$key\"";
   $bbcode_options .= ($link_opt_preferred == $key) ? ' selected="selected">' : '>';
   $bbcode_options .= $lang[$dat] . '</option>';
}


find:

Code: › // Output common page data
$template->assign_vars(array(
   'L_IMGSIZELIMIT'  => ($config['max_post_img_width'] == 0 && $config['max_post_img_height'] == 0) ? $user->lang['G2IS_IMGUNLMTD'] : sprintf($user->lang['G2IS_IMGSIZE'], $config['max_post_img_width'], $config['max_post_img_height']),

   'IN_UCP'        => ($target_form == 'ucp') ? true : false,
   'BBCODE_OPTIONS'  => $bbcode_options,
   'ROOT_COLOR'     => ($currentAlbum == $rootAlbumId) ? '#00aeff' : '#696d78',

   'PAGINATION'     => generate_pagination($g2is_url, $itemCount, $itemLimit, $currentItem),
   'PAGE_NUMBER'     => on_page($itemCount, $itemLimit, $currentItem),
   'TOTAL_ITEMS'     => ($itemCount == 1) ? sprintf($user->lang['G2IS_ITEM'], $itemCount) : sprintf($user->lang['G2IS_ITEMS'], $itemCount),

   'U_G2IS_REFRESH'  => "$g2is_url&amp;refresh=true",
   'U_ROOT_ALBUM'     => htmlspecialchars_decode("$g2is_url&amp;albumId=$rootAlbumId"),

   'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields, false, false, true),
   'S_G2IS'        => true)
);


replace with:

Code: › if ($itemCount)
{
   $template->assign_vars(array(
      'PAGINATION'     => generate_pagination($g2is_url, $itemCount, $itemLimit, $currentItem),
      'PAGE_NUMBER'     => on_page($itemCount, $itemLimit, $currentItem),
      'TOTAL_ITEMS'     => ($itemCount == 1) ? $itemCount . ' ' . $user->lang['G2IS_ITEM'] : sprintf($user->lang['G2IS_ITEMS'], $itemCount))
   );
}
else
{
   // Display No Item message and jump to page generation
   $template->assign_vars(array(
      'TOTAL_ITEMS'     => $user->lang['G2IS_NOITEM'])
   );
}

// Output common page data
$template->assign_vars(array(
   'L_IMGSIZELIMIT'  => ($config['max_post_img_width'] == 0 && $config['max_post_img_height'] == 0) ? $user->lang['G2IS_IMGUNLMTD'] : sprintf($user->lang['G2IS_IMGSIZE'], $config['max_post_img_width'], $config['max_post_img_height']),

   'IN_UCP'        => ($target_form == 'ucp') ? true : false,
   'BBCODE_OPTIONS'  => $bbcode_options,
   'ROOT_COLOR'     => ($currentAlbum == $rootAlbumId) ? '#00aeff' : '#696d78',

   'U_G2IS_REFRESH'  => "$g2is_url&amp;refresh=true",
   'U_ROOT_ALBUM'     => $rootAlbum_url,

   'S_HIDDEN_FIELDS' => build_hidden_fields($s_hidden_fields, false, false, true),
   'S_G2IS'        => true)
);


find:

Code: › function buildOptions($id, $index, $item, &$urlGenerator, $getRootLinks)
{
   static $hidden_data = array();

   $id = "_$id";
   $hidden_data[$id . '_' . $index] = $urlGenerator->generateUrl(array('view' => 'core.DownloadItem', 'itemId' => $item->getId()), array('forceFullUrl' => true, 'forceSessionId' => false));

   if ($getRootLinks)
   {
      $hidden_data[$id . '_' . $index . '_p'] = $urlGenerator->generateUrl(array('itemId' => $item->getId()), array('forceFullUrl' => true, 'forceSessionId' => false));
      $hidden_data[$id . '_' . $index . '_a'] = $urlGenerator->generateUrl(array('itemId' => $item->getParentId()), array('forceFullUrl' => true, 'forceSessionId' => false));
   }

   $hidden_data[$id . '_' . $index . '_w'] = $item->getWidth();
   $hidden_data[$id . '_' . $index . '_h'] = $item->getHeight();

   $options = "<option value=\"$index\">" . $item->getWidth() . ' x ' . $item->getHeight() . '</option>';

   return array($hidden_data, $options);
}


replace with:

Code: › function buildOptions($id, $index, $item, &$urlGenerator, $getRootLinks = false)
{
   static $hidden_data = array();

   $id = "_$id";

   if ($getRootLinks)
   {
      $hidden_data[$id . '_' . $index . '_p'] = $urlGenerator->generateUrl(array('itemId' =>$item->getParentId()), array('forceFullUrl' => true, 'forceSessionId' => false));
   }

   $hidden_data[$id . '_' . $index] = $urlGenerator->generateUrl(array('view' => 'core.DownloadItem', 'itemId' => $item->getId()), array('forceFullUrl' => true, 'forceSessionId' => false));
   $hidden_data[$id . '_' . $index . '_w'] = $item->getWidth();
   $hidden_data[$id . '_' . $index . '_h'] = $item->getHeight();

   $options = "<option value=\"$index\">" . $item->getWidth() . ' x ' . $item->getHeight() . '</option>';

   return array($hidden_data, $options);
}


Note:

1. Have to add 2 entries to the language file, and add template code to display "No item" message.
2. Generate only one parent album link.
3. Move gallery page url generation for current item to thumbnail.
4. Modify function buildOptions.
5. Update g2is.js for code changes.
Back to top
Offline View user's profile Send private message
jettyrat

Moderator
Moderator


Joined: Nov 28, 2005
Posts: 1144

PostPosted: Tue Oct 14, 2008 9:54 am    Post subject: Re: New integration version available for testing Reply with quote

PoPoutdoor wrote: › I think using gallery API call is the best and safe way...
I don't see a problem using a gallery query to get what is needed at that point in the code. That is the way gallery queries the db for all of it's api calls, so I see nothing unsafe about it, especially since it does not rely on user input to build the query.

I will attempt to figure out all the code posted above. It would help a lot and save a lot of time if you would please post more details on what the actual problem is!
Back to top
Offline View user's profile Send private message
PoPoutdoor

Wizard
Wizard


Joined: Jan 20, 2006
Posts: 129

PostPosted: Tue Oct 14, 2008 11:37 am    Post subject: Re: New integration version available for testing Reply with quote

Oops! I removed the outdate code with the related code descriptions Razz

First of all, what I'd done is not going to heavily altered your code while adding the feature with a few lines of code.

Filter non GalleryPhotoItem and fetch the item permissions:

Code: › if (sizeof($itemIds))
{
   // Get item permissions
   list ($ret, $acl) = GalleryCoreApi::fetchPermissionsForItems($itemIds);
   if (isset($ret))
   {
      trigger_error(sprintf($user->lang['G2_LOADPERMISSIONS_FAILED'] . $user->lang['G2_ERROR'] . $ret->getAsHtml(), E_USER_ERROR));
   }

   // Filter GalleryObjects
   $itemObjects = array();
   $GalleryItems = fetchEntities($itemIds);

   foreach ($GalleryItems as $Item)
   {
      // PhotoItem only
      if ($Item->getEntityType() == 'GalleryPhotoItem')
      {
         $itemObjects[] = $Item;
      }
   }
}


Handle permission:

Code: › // Display the desired items
if ($itemCount)
{
        :
}

        :
        :

$CanViewDevs = false;
foreach ($acl as $key)
{
   $CanViewDevs = $CanViewDevs || $key['core.viewResizes'];
   $CanViewDevs = $CanViewDevs || $key['core.viewSource'];
}

if ( !$CanViewDevs )
{
   $link_options = array(
      '2' => 'THUMB_LINK_ALBUM',
      '4' => 'THUMB_LINK_URL',
      '5' => 'THUMB_NO_LINK',
      '10' => 'TEXT_LINK_ALBUM'
   );

   $link_opt_preferred = 2;
}



Handle "no item", split template generation to 3 parts:

Code: › if ($itemCount)
{
   $template->assign_vars(array(
      'PAGINATION'     => generate_pagination($g2is_url, $itemCount, $itemLimit, $currentItem),
      'PAGE_NUMBER'     => on_page($itemCount, $itemLimit, $currentItem),
      'TOTAL_ITEMS'     => ($itemCount == 1) ? $itemCount . ' ' . $user->lang['G2IS_ITEM'] : sprintf($user->lang['G2IS_ITEMS'], $itemCount))
   );
}
else
{
   // Display No Item message
   $template->assign_vars(array(
      'NO_ITEM'     => $user->lang['G2IS_NO_ITEM'])
   );
}

// Output common page data
$template->assign_vars(array(
        :


Change $link_options' array structure to pass valid bbcode options, update javascript code and template file to reflects the changes. With the change, site admin can customize which option available for G2IS too!

Modify function buildOptions to merge original/resizes generation, to honor album permission. In case, current user doesn't have core.viewSource permission, size option index _0_ will be the largest resizes.

Current mod doesn't update valid bbcode options with mixed item permissions, bbcode options only changed if and only if ALL items without core.viewResizes and core.viewSource, i.e. core.view only.

You can add "Guest view mode" to G2IS as on Gallery item page does with the permission mods.
Back to top
Offline View user's profile Send private message
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    NukedGallery.net Forum Index » phpBB Integration » phpBB3 / Gallery 2 Integration View previous topicPrinter friendly versionView next topic
Goto page 1, 2  Next

 
Jump to:  
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
All times are GMT - 5 Hours

Powered by phpBB © phpBB Group



Sponsors: Dedicated ServersDomain NamesWeb HostingDomain Name RegistrationDedicated Web HostingWeb Design New YorkCompare VoIPseo packagesSEO CompanyNew York Yellow PagesFind LocationsVOIP Phone ServiceNeckermannBluetooth HeadsetOnline internetSEOchina factoryDressesRestaurant Locatorandroid tablet

8th year online! 2003-2011
Legal • Use of this site consitutes agreement to the Acceptable Use Policy
Hosted by Implosion WorksSourceForge.net Logo • Theme by TonicMedia