Embedding G2 as Module
Shadow_Wolf
Joined: 2004-04-03
Posts: 181 |
Posted: Sun, 2005-03-27 19:25 |
I am slowly going through the Xaraya integration code as I learn how it was integrated with it so I can learn to apply that to a IPB integration. That is only for the member database part. The visual aspect of the integration will be within my portal system (MK Portal) as a module. I have turned off registration and have created a module within MK Portal. When you go to its link (http://www.protoculturex.com/test/index.php?ind=private) it properly shows Gallery 2 within the portal system. Now of course the issue arises if you click on any link it will break out of the Portal Module and go to the direct link within Gallery 2. From what I understand I modify the index.php/main.php according to the embed dos and need to add something simlar to the following: // initiate G2 $ret = GalleryEmbed::init(array('embedUri' => 'index.php?module=gallery2', 'relativeG2Path' => './gallery2', 'loginRedirect' => 'index.php', 'activeUserId' => $uid)); If I read properly the embedUri is how it calls upon the module gallery. In this case in MK Portal to pull up the module it uses index.php?ind=private. The relativeG2Path is the path to the real G2 gallery, which is in a root folder gallery2 so it would be ./gallery2. I'm using a test demo script that valiant wrote as an example of embedding in another note. I believe I have things setup properly but it seems to have an error with the following line which looks correct. $data['title'] = (isset($data['title'] && !empty($data['title'])) ? $data['title'] : 'Gallery'; Full code for that section: <?php $data = runGallery(); $data['title'] = (isset($data['title'] && !empty($data['title'])) ? $data['title'] : 'Gallery'; if (isset($data['bodyHtml'])) { print '<html> <head> <title>'.$data['bodyHtml'].'</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> .'$data['javascript'].' '.$data['css'].' </head> <body> '.$data['bodyHtml'].' </body> </html> '; } Am I doing something wrong or is it just this test embed file that I was using has errors (the note said it probably does have errors). |
|
Posts: 32509
there's a missing closing brace...
isset($data['title'])
Posts: 181
Bah I can't believe it was right in front of me the whole time, something simple. That is the problem when you look at something for so long you can't see sometimes what is right in front of you. LOL!
I corrected another error on line 13 which had:
Should of been:
It unfortunately gave me another error dealing with line 26
I believe it had an issue finding the path to embed even though it looked correct so I corrected by just doing the full path:
The seemed to fix those errors. But this one I can't seem fix probably due to me not understanding what it is calling upon:
Fatal error: Call to undefined function: galleryinitfirstpass() in /home/protocul/public_html/test/gallery2/embed.php on line 62
Checking line 62 in embed.php I see this:
$ret = GalleryInitFirstPass($initParams);
Posts: 8601
embed.php includes main.php which includes init.inc.. i don't know how you could get that error..
Posts: 32509
you shouldn't get this error.
however, thanks for the report of the typos. as i said, i wrote this minimal embed.php wrapper just as a rough guide. i updated the file and it works now.
http://gallery.menalto.com/index.php?name=PNphpBB2&file=viewtopic&p=122603#122603
Posts: 181
I'm still receiving the following error:
Fatal error: Call to undefined function: galleryinitfirstpass() in /home/protocul/public_html/test/gallery2/embed.php on line 62
I see where embed.php includes main.php
require(dirname(__FILE__) . '/main.php');
I don't see where main.php includes init.inc though unless it is called something else. The original main.php seems to include a init.php if that is the same thing here:
require_once(dirname(__FILE__) . '/init.php');
The modified main.php which I'm using to try to create the module test doesn't seem to include the init.php. I added the above line to the modified main.php but that didn't seem to fix the issue so I'm at a loss. I made the section public so you can see the error when it tries to pull up the gallery:
http://www.protoculturex.com/test/index.php?ind=private
I don't believe it is an issue with the module within the portal because originally the Gallery 2 displays if I use the original main.php. It just comes up if I use the modified main.php. The module inside the portal is fairly simple it is just using a php implode to the actually gallery link.
Posts: 32509
hey, my main.php does not replace the main.php of G2. it's meant to be placed into another directory, or rename it.
and you should never have to edit any G2 file (besides the local/ themes/,...).
and if you still get errors, upgrade your G2.
Posts: 181
That explains it, it was just my misunderstanding. Since it was called main.php I figured it replaced main.php. I renamed it to index2.php and placed it within the G2 directory. I now get no errors when I go into it, although it seems to have broken any link to the theme/skin that it was using.
According to the embed.php instructions:
1. G2 was installed seperately (/home/gallery2) and the portal system was installed seperately (/home/mkportal).
2. Since there isn't any real code written for the emApp (which I assume means embedded application which is the portal) I'm starting with the base embedded code written by Valiant.
3. I'm not worried about user database sychronization at this time, that is dealt as a seperate project and this one is just to get the visualization of the embedded gallery.
4. Registration is disabled and session timer is set to infinite.
5. Now I'm currently testing the integration and here is where I'm having some issues.
Now if you currently go to the module link:
http://www.protoculturex.com/test/index.php?ind=private
You'll see that it is as the links to the themes, etc have been broken. From what I can see originally when it was included in the module the direct link to the one of the galleries as an example was:
http://www.protoculturex.com/test/gallery2/main.php/v/swisslad/
I assume there is some sort method of renaming the links to operate within the embedded application. Now currently the link for that same gallery shows:
http://www.protoculturex.com/test/gallery2/index2.phpindex.php?ind=private/v/swisslad/?g2_GALLERYSID=ef1cfc9cbd0beb272b6c868b842afa04
From the looks of it, it seems like it believes that Gallery 2 should of been nstalled within the portal directory structure instead of in the root structure. Or am I just not properly understanding how the embedding is working?
Posts: 32509
upgrade your G2 beta 1 to the current cvs / nightly snapshot. at the time of beta 1, there were major UI changes that corrupted / exposed an error in my code in embed.php for css styles. it was fixed only days after beta 1...
Posts: 181
I used the night snapshot from "Chetan Sarva's snapshot page". It uploaded fine, seemed to go through the upgrade process without any errors or issues at all. I am receiving the following error though:
Parse error: parse error, unexpected $ in /home/protocul/public_html/test/gallery2/modules/core/classes/GalleryDataItem.class on line 436
Line 436 in GalleryDataItem.class is:
I compared it to the Beta 1 GalleryDataItem.class don't see any differences between that line unless there is something else within the body that effects that line that has changed.
Posts: 32509
strange. can you post the file modules/core/classes/GalleryDataItem.class (.zip it, attach it to the next post)?
Posts: 181
Sure, here is the one from the snapshot.
Posts: 32509
zero difference to my local GalleryDataItem.class.
are you running any php cache/accelerator?
i don't think this will help, but try FlushCache/FlushTemplates in
http://www.protoculturex.com/test/gallery2/lib/tools/test/ .
Posts: 181
I'm not running any php cache/accelerator's that I know of than of. Unfortunately I did already try that just in case that it didn't happen properly during the upgrade. I also ReInitializeGallery which at least it now lets me into the gallery without any errors. I can seem to access the admin controls and setup a new album now. Unfortunately I can't add any pictures though it pulls up the error I had originally:
Parse error: parse error, unexpected $ in /home/protocul/public_html/test/gallery2/modules/core/classes/GalleryDataItem.class on line 436
Perhaps the issue came about with the way I upgraded from Beta-1 to the snapshot. I unzipped the snapshot and then just copied everything back overwriting the files from Beta-1. When I went to the gallery URL it then had a Upgrade install script I believe from version 0.9.0 to 0.9.5 or something like that. I went through that, didn't seem to be any errors. Then when I went into gallery I received the error. I then did flush cache/templates, still no help. ReInitialize did clear let me back in, can create albums but can not add images.
Maybe it had an issue with the upgrader, I guess if no one else is having an issue then maybe I should try a fresh install. I could also try downloading a snapshop from Jesse Mullan's snapshot page in case there was a problem with the snapshot I have and try it again.
Edit: All fixed! It was a corrupt file. I swear I reuploaded GalleryDataItem.class again just to make sure there was no corruption. When I compared them they looked the same. However I was just double checking it by viewing the file online and it didn't seem complete. So I ftp'd in from work (different ftp program than at home) and there was a file size difference between what I should have and what was there. Reuploaded it and works fine now.
Posts: 181
Ok theme-wise it looks like the images are working, it displays nicely within the module as it should. However whenever you click on an album or image I'm still dealing with the issue that it doesn't go to the right place. From what I can see originally when it was included in the module the direct link to the one of the galleries as an example was:
http://www.protoculturex.com/test/gallery2/main.php/v/swisslad/
I assume there is some sort method of renaming the links to operate within the embedded application. Now currently the link for that same gallery shows:
Code:
http://www.protoculturex.com/test/gallery2/index2.phpindex.php?ind=private/v/swisslad/?g2_GALLERYSID=ef1cfc9cbd0beb272b6c868b842afa04
From the looks of it, it seems like it believes that Gallery 2 should of been installed within the portal directory structure instead of in the root structure. Or am I just not properly understanding how the embedding is working? Am I supposed to install the G2 directory inside the module directory of the embedded App? Or is there some writing and changing to links that I have to do so that you can actually browse within the gallery from the module?
Posts: 32509
G2 can be installed anywhere. take a look at the explanations in docs/EMBEDDING.
some examples: all paths start in your www document root
- index.php (the single entry point to your CMS)
- modules/gallery2/somefile.php (this file is never accessed from the webbrowser, but included by your CMS. it is the wrapper that calls embed.php)
- G2 can be installed anywhere, i.e. in
gallery2/ (embed.php, main.php, ... are here) or in some/deep/path/g2/
the relative path for the GalleryEmbed::init call in modules/gallery2/somefile.php would be gallery2 for the first case and some/deep/path/g2/ in the second case.
the baseFile for the GalleryEmbed::init call has to be the single entry point to your G2/CMS. in this case it would be "index.php?someargument=somevalue". the argument tells your CMS that it is a G2 request within your CMS. And this baseFile must be part of all links linking to the G2 within your CMS.
the problems with what you do right now are...
1. that you called the file "index2.php" but you say in GalleryEmbed::init that the basefile is "index.php?ind=private".
2. That you have the url rewrite module activated in G2. i'm sorry if you haven't heard it yet, but it is incompatible with embedding at the moment. we are working on a fix.
Posts: 181
Ok after messing with it for a few hours I got it to work. I'm not sure how or what I did that caused it to work though but it works. Although theme-wise still needs a lot of work functionality is there. So the next step would be after getting the theme/skinning to work right then to actually integrate G2 member database with my IPB database.
The strange thing is that I couldn't get the images to work properly. It would display the actual gallery and you can browse through the albums, however all the image's were not displaying. No matter what combination of links and php to try to get them to display to no avail. As I was cutting and pasting links into my browser's URL I didn't complete erase all of it and so it was added to the back of the link I was using and "BHAM" it was working. Although sloppy and strange it allowed me to browse through Gallery 2 while staying within my Portal. The links were all screwed up completely so unfortunately it makes it impossible for people to link too or remember a simple link to it but this is further than I've gotten before.
You can see it semi working - Click Here -
The actual link to the portal module should of been:
http://www.protoculturex.com/test/index.php?ind=private
If you go to it then you'll see the gallery but it won't work. However I can go to the main gallery page inside my portal if I use the following link:Note: I split the link into three lines since the board doesn't wrap and I don't like to stretch message boards
So now that is left is to clean things up but I'm still not understanding how it is all working together. I know it using the modified main.php you wrote which I placed in my private folder in my portal and renamed index.php. I also know it is using it renamed inside the Gallery2 directory. If I remove either of them it stops working so somehow they are working together... but I suspect I probably only need one.
The main issues at this point are:
1) Integration of IPB member database and Gallery 2 database. This is a seperate project though so not main issue yet.
2) URL cleanup. Since I don't know how it is working I'm not sure how to begin this. There looks like some things repeat in the URL, it is a long and bulky URL as well. I suspect that I might be able to use the url_rewrite mod however I believe you said it currently won't work with embedded galleries.
3) Theme/skin cleanup. It seems to be pulling some of the theme information, although that might just be pulling the information from the portals CSS. I'm still looking into how to clean that up and what is effecting what.
Posts: 32509
all that doesn't look how it should. it seems that you don't understand the concept of the parameters you give to GalleryEmbed::init(...).
@1: as you said, this topic isn't about this.
@2:
- change the baseFile in the init(...) call to index2.php?ind=private to index.php?ind=private
- why do you have an absolute path the second url you posted there??
Posts: 181
I'm trying to understand the parameters that are explained. There needs to be an entry point in the emApp (embedded application) which I assume is my portal. There has to be something in which will call upon G2. Using the main.php you wrote, I renamed it index.php placing it inside a directory inside my portal. To call upon that directory you go to /index.php?ind=private
embedUri: This is the method used to call upon the entry point, in root it is index.php?ind=private.
relativeG2Path: This is the relative path to G2 directory so it wouldn't be a URL. The example shows ../gallery2, that doesn't work for me. I was only able to get it to work if I used the absolute path /home/www/test/gallery2
I have tried multiple settings with bot the embedUri and relativeG2Path and could not seem to get it to work. For some reason the method it is using now works.
Edit: I thought I had already used gallery2 as the relativeG2Path and it didn't work. Using that instead of absolute path and ../gallery2 fixed it. Although still a long URL name it is at least half of what it was and no absolute path in URL.
The URL Rewrite module is what changes the URL to a short url that uses the gallery album name? But that doesn't work with an embedded gallery yet?
Posts: 32509
- don't use the frickin url rewrite module when using embedded G2.
- relativepath gallery2
- embedurl index.php?ind=private
i guess i'll change 2 things in the way GalleryEmbed::init works.
there's the need to separate embedUri into two separate things: 1. urls for pictures, 2. urls for G2 requests. and it needs to be decoupled from the current URI. G2 parses the the request string vs. the embedUri, that's why you get your duplicate urls because you didn't set up the embedUri to match your actual url.
but this is something that will happen in the future, for now, get it right with relativepath+embedUri.