readfile not supporting urls in external random image block

conorboyd

Joined: 2005-03-29
Posts: 166
Posted: Tue, 2005-06-28 04:59

Hi,

I'm a bit of a beginner with php, so not sure how to work round this issue.

I was successfully using the random image php block from my gallery in another php page.

However my ISP has just turned off URL-style fopen support.

For example, say my current random image block call is as follows:

<? readfile('http://[mydomain]/gallery/main.php?g2_view=imageblock:External&g2_blocks=randomImage');
?>

If I change this to use a relative path, php seems to fail to find the main.php script due to the parameters after the question mark.

Can anybody provide me with a workaround for this issue, as I found the random block/new album feature very nice.

Hopefully I've explained this clearly enough.

Thanks in advance,

Conor Boyd

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-06-28 06:37

you'll have to use the GalleryEmbed API, something like:

include('path/to/gallery2/embed.php');
$ret = GalleryEmbed::init(array('embedUri' => , 'embedPath' => , 'relativeG2Path' => ));

if ($ret->isError()) {
print $ret->getAsHtml();
exit;
}

list ($ret, $html, ...) = GalleryEmbed::getImageBlock(array(....));

if ($ret->isError()) {
print $ret->getAsHtml();
exit;
}

print $html;
etc.

see docs/EMBEDDING for correct values for embedUri, embedPath, relativeG2Path.
getImageBlock() accepts the same arguments as imageblock:External, see modules/core/classes/GalleryEmbed.class for more information.

 
conorboyd

Joined: 2005-03-29
Posts: 166
Posted: Tue, 2005-06-28 10:03

Thanks Valiant,

I've give that a go when I have a spare minute.

Sounds perfect.

Cheers,

Conor

 
conorboyd

Joined: 2005-03-29
Posts: 166
Posted: Wed, 2005-06-29 09:31

I've worked through the example above and looked at the EMBEDDING doc and the class (BTW, I'm on G2 Beta 3).

My test script seems to be initializing Gallery okay, but I get the following error when I call the getImageBlock method as follows:

list ($ret, $html) = GalleryEmbed::getImageBlock(array('blocks' => 'randomImage', 'show' => 'none', 'maxSize' => 450));

gives me this:

Input Array does not match ?: SELECT DISTINCT g2_AccessMap.g_accessListId FROM g2_AccessMap WHERE (g2_AccessMap.g_userId = NULL OR g2_AccessMap.g_groupId IN (1)) AND g2_AccessMap.g_permission & 1 =
Error (ERROR_STORAGE_FAILURE)

    * in modules/core/classes/GalleryStorage/DatabaseStorage.class at line 1164 (gallerystatus::error)
    * in modules/core/classes/GalleryStorage.class at line 220 (mysqldatabasestorage::search)
    * in modules/core/classes/Gallery.class at line 223 (gallerystorage::search)
    * in modules/core/classes/helpers/GalleryPermissionHelper_simple.class at line 82 (gallery::search)
    * in modules/core/classes/GalleryCoreApi.class at line 399 (gallerypermissionhelper_simple::fetchaccesslistids)
    * in modules/imageblock/classes/ImageBlockHelper.class at line 426 (gallerycoreapi::fetchaccesslistids)
    * in modules/imageblock/classes/ImageBlockHelper.class at line 331 (imageblockhelper::cacheviewabletree)
    * in modules/imageblock/classes/ImageBlockHelper.class at line 193 (imageblockhelper::fetchviewabledata)
    * in modules/imageblock/classes/ImageBlockHelper.class at line 86 (imageblockhelper::_addblock)
    * in modules/core/classes/GalleryEmbed.class at line 748 (imageblockhelper::loadimageblocks)
    * in /hsphere/local/home/conorboy/ildica.com/test.php at line 11 (galleryembed::getimageblock) 

Have I done something stupid? Easy fix? ;-)

Thanks again for any help...

Cheers,

Conor

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-06-29 09:39

you have to use GalleryEmbed::init(array(..., 'fullInit' => true));

sorry, forgot about that.
and it may be a good idea to use g2 beta 3+ aka the current nightly snapshot from http://galleryupdates.jpmullan.com

 
conorboyd

Joined: 2005-03-29
Posts: 166
Posted: Wed, 2005-06-29 20:22

Spot on.

That's brilliant Valiant, thanks very much!

I'll check out the latest snapshot.

Cheers,

Conor