getImageBlock Problem - correct embedUri

scroogie

Joined: 2005-02-21
Posts: 9
Posted: Mon, 2005-02-21 20:07

Hi, i ran into problems when playing around with the g2 embed class. first of all, is it possible to hand an existing smarty instance to g2? i don't feel good when having two seperate smarty instances in one little script. beyond that, i didnt get the getImageBlock right. I have to init() g2 before calling getImageBlock(), right? Then i have to pass an embedUri, and thats where my problem starts. If i pass the correct g2 integration URI, then the image URI isnt built right, because the current pagename isnt stripped (results in something like /path/news.phpgallery.php?g2view...), but if i pass the actual filename, then the link of the image doesnt point to my gallery any longer. isnt it possible to return just the filename and let the embedding application choose how to display it? would be nicer in my oppinion.
hopefully im not just acting stupid
regards

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-02-21 20:22

1. smarty: if it doesn't work with 2 smarty instances, we can analyze the issue. But please try it first as it is.
2. yes, call GalleryEmbed::init(array(,,,)) first, then GalleryEmbed::getImageBlock(array(,,,))
please give a detailed example of your case (url of G2, url of page where you want the block, embedUri used, resulting urls from G2 when using this embedUri).
3. yes, i would also like only the image url, thumb url and everything alse as strings instead of the complete html image block. we should definitely do this. i guess, there's even a RFE on sf.net for this.

 
scroogie

Joined: 2005-02-21
Posts: 9
Posted: Tue, 2005-02-22 10:36

Hi, i've no actual problem with two smarty instances, except that i have to manually define the SMARTY_CORE_DIR, because the smarty of gallery complains about the undefined constant otherwise.
about the block:
I want to display a random image block in some pages, for example the page news.html. The gallery integration page is galerie.html, so i set the embedUri parameter to 'galerie.html'. The 'relativeG2path' is therefor 'lib/gallery2/'. Resulting in

$ret = GalleryEmbed::init(array(
	           'embedUri' => 'galerie.html', 
	           'relativeG2Path' => 'lib/gallery2', 
	           'loginRedirect' => _BASE.'/login.html',
	           'activeUserId' => $auth->getProperty('authUserId'))
	        );

With this initialization the main integration works, but the randomimage block, displayed in news.html looks as follows:

<a href="http://localhost/jgv/news.htmlgalerie.html?g2_view=core:ShowItem&amp;g2_itemId=105" >
<img class="giThumbImage" src="http://localhost/jgv/news.htmllib/gallery2/main.php?g2_view=core:DownloadItem&amp;g2_itemId=106&amp;g2_serialNumber=2" width="150" height="113" alt="PC150019.JPG" longdesc=""/>

You see, the problem is that g2 misses to strip the 'news.html', because it just strips the embedUri. So if i set the embedUri to 'news.html', the URI is right, but the link doesnt point to the details-page anymore.
Details:
With embedUri = 'news.html' it is:

<a href="http://localhost/jgv/news.html?g2_view=core:ShowItem&amp;g2_itemId=14" >
<img class="giThumbImage" src="http://localhost/jgv/lib/gallery2/main.php?g2_view=core:DownloadItem&amp;g2_itemId=15&amp;g2_serialNumber=2" width="150" height="113" alt="PC140002.JPG" longdesc=""/>
	  </a>

So this time, the image is right, but the link is wrong.
Btw, Gallery2 is very nice, thanks a lot for your great work.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-02-22 11:03

I see, had the same problem with xaraya when displaying the imageblock outside the g2 module.
We didn't solve it in a good way up to now, but I hacked something together that works.

  $request_uri_backup = $_SERVER['REQUEST_URI'];
  $new_request_uri = preg_replace("|[^\/]*$|",'',$_SERVER['PHP_SELF']);
  // overide the current request uri so that G2 recognizes the embedUri and replaces it properly
  $_SERVER['REQUEST_URI'] = $new_request_uri . xarModGetVar('gallery2','g2.basefile');

xarModGetVar('gallery2','g2.basefile'); is in your case galerie.html (html?).

But as you showed, this is a problem that is more general than for a special case in xaraya. I guess, we will address it in a better way in future.
i.e.
instead of embedUri alone, embedUri (where the wrapper is) AND something else.

@smarty: more details please. is it the case that smarty of your app is loaded before G2 and then G2 uses the classes/files from your app with the parameters of G2? are the two smarty different versions?

 
scroogie

Joined: 2005-02-21
Posts: 9
Posted: Tue, 2005-02-22 12:09

Yes, i just checked, and that is the case. I have to look at it in detail, before i can tell you if other problems arise from that. But I have found another thing im a bit confused about, if i look at the code in my recent post, it looks as G2 increments the itemId for the thumbnail, is that correct behaviour?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-02-22 12:13

the entityId for all items is different in G2. so entityId of image != entityId of thumbnail != entityId of other resized versions of the same image.
but for the same thumbnail (same size, same item), the entityId should be the same.
If it's not the same for multiple requests, it would indicate, that G2 generates a new thumbnail for each request, which it shouldn't.

 
Voland

Joined: 2005-02-22
Posts: 5
Posted: Wed, 2005-02-23 16:26

Hi,
I have the same problem with xaraya and gallery2 integration. No pictures are displayed because of wrong path entry www.kovno.ru/index.phpgallery2/

(You can see at www.kovno.ru/?module=gallery2 )

What is wrong ?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-02-23 16:40

Voland, first, what is this "www.kovno.ru/?module=gallery2" ? and how does it work without index.php ? mod rewrite?
actually, it should work and works for xaraya.

http://www.kovno.ru/index.phpgalereja/themes/matrix/styles/theme.css

there is the same error.
what are your paths? relative Url path to G2? relative filesystem path?

 
Voland

Joined: 2005-02-22
Posts: 5
Posted: Wed, 2005-02-23 17:33

I removed index.php trying to fix this error. It removes by uncommenting stings
$systemConfiguration['BaseURI'] = '';
$systemConfiguration['BaseModURL'] = '';

in Xaraya file config.system.php

My paths are :

g2.relativeurl galereja/
g2.includepath C:\Inetpub\wwwroot\kovno\galereja\
g2.loginredirect C:\Inetpub\wwwroot\kovno\module=roles&func=register
g2.basefile ?module=gallery2

After installing gallery2 module basefile was with includepath, and menu links were wrong. I edited basefile, menu is working, I can upload pictures, everything is fine but I can`t see any pictures ( links are genereted like: http://www.kovno.ru/index.phpgalereja/modules/newitems/images/new.gif)

I guess my Windows 2003 IIS server includes index.php to path. Maybe you can tell in witch file variable relativeG2path is added to xaraya path ?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-02-23 17:54

Did you try it with index.php as xaraya base file? Did G2 work with your setup when the urls were index.php?module=gallery2&... ? I've never seen something like that "?module=gallery2&...".
Perhaps you're the first IIS/windows user to try the xaraya Gallery2 module, don't know.

Does G2 standalone work on your webserver, did you try that before?

I'll have to take a look at my code...

 
Voland

Joined: 2005-02-22
Posts: 5
Posted: Thu, 2005-02-24 15:13

Yes, I tried with index.php anf G2 as standalone is working perfectly (some small bugs after integration)

I guess I don`t have global variable, wich should return xaraya path for gallery. All functions in gallery2helper.php are working. I think bug could be in place, where variabe relativeG2path is added to Xaraya path.

I can`t try short urls because IIS doesn`t have support for mod_rewrite.

 
Voland

Joined: 2005-02-22
Posts: 5
Posted: Thu, 2005-02-24 16:06

I changed GalleryUrlGenerator.class :

function getCurrentUrl() {

$this->_currentUrl = '/';

except

$this->_currentUrl = GalleryUrlGenerator::makeUrl($path);

And it started to work. I am not shure this is correct and it is better to find out where is global variable problem.

 
yonie

Joined: 2005-02-21
Posts: 9
Posted: Thu, 2005-02-24 17:51

same problem here, sometimes the url doesnt get created correctly, resulting in broken links and not showing of images.

it seems to have to do with the recent cookie/session problems if you ask me.

php sourcecode follows:

// require de gallery php
require_once("mod/gallery2/embed.php");

// init de gallery
$ret = GalleryEmbed::init(array(
// notice: zoals het nu staat, werkt het. dont fuck up. :)
'embedUri'=>'mod/gallery2/index.php', // verplicht
'relativeG2Path'=>'mod/gallery2/', // verplicht
'embedSessionString' => 'sid='.session_id(), // ?
'gallerySessionId' => session_id(), // ?
// 'fullInit' => 'true', // wat zou dit doen?
));

// check voor errors
if ($ret->isError()) {
echo("<tr class=\"index-text\"><td>Gallery2::Init() error: ".$ret->getAsHtml()."</td></tr>");
}
else {
$g2data[0] = GalleryEmbed::getImageBlock(array('blocks'=>'recentImage','show'=>'title'));
$g2data[1] = GalleryEmbed::getImageBlock(array('blocks'=>'recentAlbum','show'=>'title'));
$g2data[2] = GalleryEmbed::getImageBlock(array('blocks'=>'viewedImage','show'=>'title'));
$g2data[3] = GalleryEmbed::getImageBlock(array('blocks'=>'randomAlbum','show'=>'title'));
$g2data[4] = GalleryEmbed::getImageBlock(array('blocks'=>'randomImage','show'=>'title'));
// begin overzicht
echo "<tr class=\"index-text\"><td>";
echo "<table class=\"index-gallerytabel\"><tr>";
echo "<td><b>Nieuwste foto</b>:".$g2data[0][1]."</td>";
echo "<td><b>Nieuwste album</b>:".$g2data[1][1]."</td>";
echo "<td><b>Meest bekeken foto</b>:".$g2data[2][1]."</td>";
echo "<td><b>Random album</b>:".$g2data[3][1]."</td>";
echo "<td><b>Random foto</b>:".$g2data[4][1]."</td>";
echo "</tr></table></td></tr>";
// eind overzicht
}
$ret = GalleryEmbed::done();

if you need more info drop me a line: yonie at yonie dot org

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-02-26 16:21

Voland, sorry, i was very busy.

- I installed the current cvs version of G2 today and it works.
Don't activate the short urls / mod_rewrite in G2 and it will work.

- getImageblock still working in G2/xaraya

I'll look into the rest now.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-07-02 15:27

sorry, forgot to update this thread.
all issues in this thread should be fixed by now.
(all but the "my application uses smarty too" issue)