embedUri + G2 rewrite module

cschlatt

Joined: 2005-05-24
Posts: 17
Posted: Thu, 2005-06-30 10:35

I'm using G2 CVS current version.

It seems that a request string in $embedUri of the form ?param=value does not get appended to G2 URLs if the G2 rewrite module is activated.

As an example, I use GalleryEmbed's Init(..) with

$embedUri = '?module=gallery2'

and after calling HandleRequest(..), I get G2 URLs of the form http://www.example.com/pmwiki/v/album/ . What I would need is http://www.example.com/pmwiki/v/album/?module=gallery2.

Is there a way to enable that?

Thanks for any hints,
Christian

 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Mon, 2005-07-04 10:31

You should check your .htaccess file in the CMS directory. There the '?module=gallery2' part should be appended to the rewritten pattern.

 
cschlatt

Joined: 2005-05-24
Posts: 17
Posted: Mon, 2005-07-04 10:45

The .htaccess method is OK for static rewriting, e.g. always append ?module=gallery2 to the URL. The problem is that my application dynamically generates query string parameters (like e.g. ?action=insertimage) that should be appended to all G2 links.

IMHO, query strings in EmbedUri should be appended to G2 URLs (as it happens if G2 rewrite is deactivated) also if G2 rewrite is active.

 
pelle
pelle's picture

Joined: 2004-12-10
Posts: 389
Posted: Mon, 2005-07-04 12:05

Even if your CMS dynamically generates query string params there should be one that maps to Galllery (module=gallery2). How could there be more params that map to the gallery2 plugin? module=gallery2 should load the Gallery module which takes care of the request (the rest of the POST/GET action).

 
cschlatt

Joined: 2005-05-24
Posts: 17
Posted: Mon, 2005-07-04 12:31
Quote:
How could there be more params that map to the gallery2 plugin?

You're right, one parameter is enough to map to the g2 plugin. But as you mention

Quote:
module=gallery2 should load the Gallery module which takes care of the request (the rest of the POST/GET action).

the rest of the GET action can only be made if the GET params still exist in the URL (this would not be a problem for POST actions).

Imagine the following situation:
I call the G2 plugin with the URL http://www.example.com/pmwiki/g2page?module=g2&action=insertimage

The param action=insertimage tells the CMS to include a special link in the CMS page that shows embedded G2. Now if G2 rewrite is active, the action=insertimage param does not get appended to G2 URLs, and so if I click on an album link, the special link cannot be included anymore by the CMS.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-07-04 18:18

cschlatt, so the problem is not the param "?module=gallery2. " as you described in your initial post, correct?

the problem are additional parameters, right?

 
cschlatt

Joined: 2005-05-24
Posts: 17
Posted: Mon, 2005-07-04 18:33

Yes, the problem are additional params, I see now that my first post was a bit misleading :-?

I'm integrating G2 into PmWiki. Embedding a gallery view into a wiki page is simply made by writing something like (:g2:) in the wiki page. The G2 embedding code is triggered as soon the wiki parser sees the syntax (:g2:). This is why I don't use "?module=gallery2" at all, but would like to pass additional URL GET parameters to G2.

As already mentioned, this works if G2 rewrite is deactivated (GET params in $EmbedUri get appended to G2 links).

Thanks for any help,
Christian

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-07-04 19:34

can i see this in action? not sure if i fully understand what the result looks like.

 
cschlatt

Joined: 2005-05-24
Posts: 17
Posted: Mon, 2005-07-04 20:12

have a look at

http://www.schlatter.net/pmwikitest/pmwiki.php?n=Main.Image

If you look at the image links, there is always a "pref=Main.Image" request string. This is used to generate the back link on the gallery page. This link exists as long as the mentioned pref parameter is in the URL, so that one can navigate in the gallery without loosing the back link.

If I activate G2 rewrite, the "pref=Main.Image" param does not get appended any more.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-07-04 20:46

i get only errors on the page. because i wrote that part of G2, i know why i get errors.

you are using the GalleryEmbed::getImageBlock() functions.
therefore, you need to specify "fullInit" => true in the GalleryEmbed::init() call, if you omit this, anonymous users will get the errors i get right now.

to your request:
where / how do you add the param "pref=Main.Image" to G2 urls?

 
cschlatt

Joined: 2005-05-24
Posts: 17
Posted: Mon, 2005-07-04 21:52
Quote:
you are using the GalleryEmbed::getImageBlock() functions.
therefore, you need to specify "fullInit" => true in the GalleryEmbed::init() call, if you omit this, anonymous users will get the errors i get right now.

hmm, I did that, but I'm quite surprised, since I always tested it as anonymous user. In fact, I haven't implemented yet user management G2<->PmWiki at all ... Is this because I had still a cookie from a G2 standalone session?

Quote:
where / how do you add the param "pref=Main.Image" to G2 urls?

I set it via $EmbedUri, e.g.

$EmbedUri = 'pmwiki.php?pref=Main.Image'

When I enable PmWiki rewrite, this gets to

$EmbedUri = '?pref=Main.Image'
 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-07-04 22:07

@cookie / error: i don't get any error anymore. whatever it was, it's fixed now.

@param:
$EmbedUri = '?pref=Main.Image' won't quite work.
embedUri is the string directly after the host/path/ parts of the url, it's not something that is appended.
you could abuse
the 'embedSessionString' param of GalleryEmbed::init() just set
embedSessionString => pref=Main.Image, i guess this should work.

as for a better / cleaner solution...maybe we can add a better method later.

 
cschlatt

Joined: 2005-05-24
Posts: 17
Posted: Tue, 2005-07-05 17:07
Quote:
you could abuse
the 'embedSessionString' param of GalleryEmbed::init() just set
embedSessionString => pref=Main.Image, i guess this should work

Unfortunately, this doesn't work. The 'embedSessionString' only gets appended if in "cookie-less" mode. From GalleryUrlGenerator.class:

if ( (!isset($forceSessionId) && !($session->isUsingCookies())) ||
     (isset($forceSessionId) && $forceSessionId === true)) {
    if (!empty($this->_embedSessionString)) {
        $sessionString = $this->_embedSessionString;
    } else {
        $params[$session->getKey()] = $session->getId();
    }
}
...
if (isset($sessionString)) {
   $url .= ((strpos($url, '?') === false) ? '?' : '&amp;') . $sessionString;
}
Quote:
$EmbedUri = '?pref=Main.Image' won't quite work.
embedUri is the string directly after the host/path/ parts of the url, it's not something that is appended.

$EmbedUri = '?pref=Main.Image' works well as long as G2's rewrite module is not activated (I use it like this).

After enabling URL rewrite in PmWiki, the URLs of the form http://www.example.com/pmwiki.php?n=Group/Page get to http://www.example.com/Group/Page. And so the string directly after the host/path/ is empty (except any query strings).

IMHO, all query parameters in $EmbedUri should be appended to G2 URLs like with embedSessionString. This would also be consistent with the G2 embed docu:

Quote:
Use these to determine the following values:
embedURI = Filename (and any query parameters, but NO path) for access point

Thanks for your help,
Christian

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-07-05 17:22

we treat embedUri as a string, it is not separated in a file part and a parameter part.
of course we could do that and append the params then to all urls.

but i don't have time for this at the moment.

could you file an RFE on http://sf.net/projects/gallery/ ? thanks.