Hi,
I have installed gallery on my server.We have different site and database.I want to integrate gallery in our site.I get succeeds in modifying template as per requirement.But now I don't want Gallery Login.want to use our site login session.About the user table.I have similar data in both site user table and gallery user table.Need help only to set the session user.Can anyone please guide me?
Posts: 16503
For something like that I can only point you to the documentation:
http://codex.gallery2.org/Gallery2:Embedding
And suggest to check out existing integrations to see how they do it..
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here
Posts: 5
hi, thanks for your reply. The documentation is somehow difficult to understand.Well after spending 2-3 days I am getting 2 errors:-
1]I am able to send session id to gallery.But now I am getting error.
Error (ERROR_MISSING_OBJECT) : 51 GalleryUser
* in modules\core\classes\helpers\GalleryEntityHelper_simple.class at line 155 (GalleryCoreApi::error)
* in modules\core\classes\GalleryCoreApi.class at line 2404 (GalleryEntityHelper_simple::loadEntityByExternalId)
* in modules\core\classes\GalleryEmbed.class at line 294 (GalleryCoreApi::loadEntityByExternalId)
* in modules\core\classes\GalleryEmbed.class at line 270 (GalleryEmbed::login)
* in modules\core\classes\GalleryEmbed.class at line 120 (GalleryEmbed::checkActiveUser)
* in C:\xampp\htdocs\ddb\casebook\gallery2.php at line 53 (GalleryEmbed::init)
* in C:\xampp\htdocs\ddb\casebook\gallery2.php at line 19
I have same data in both my site user table and gallery user table.This 51 user exist in the gallery user table.Still its giving problem.Here is my code:-
<?php
session_start();
/*
* This is an example of how G2 can be wrapped into your own website
* If you only want to embed G2 visually in your website, you don't need GalleryEmbed (so this
* approach is not necessarily what you want). But if you want to embed G2 in your website,
* including a unified user management, a single login etc., then this is the correct file to
* start with.
*/
/*
* runGallery() exits if G2 tells it to so (by isDone = true). It's important that you don't
* output any html / anything before you call runGallery (which calls
* GalleryEmbed::handleRequest), else, G2 won't work correctly.
* Reason: G2 does a lot of redirects. E.g. when you login, it redirects to the next page, etc.
* and redirects won't work if there was already some output before the redirect call.
*/
$data = runGallery();
$data['title'] = (isset($data['title']) && !empty($data['title'])) ? $data['title'] : 'Gallery';
if (isset($data['bodyHtml'])) {
print <<<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>{$data['title']}</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
{$data['javascript']}
{$data['css']}
</head>
<body>
{$data['bodyHtml']}
</body>
</html>
EOF;
}
function runGallery() {
require_once('gallery2/embed.php');
$data = array();
// if anonymous user, set g2 activeUser to ''
$uid = $_SESSION['SessMemberId'];
// initiate G2
$ret = GalleryEmbed::init(array('g2Uri' => 'gallery2/',
'embedUri' => 'gallery2.php',
'activeUserId' => $uid));
if ($ret) {
$data['bodyHtml'] = $ret->getAsHtml();
return $data;
}
// user interface: you could disable sidebar in G2 and get it as separate HTML to put it into a block
// GalleryCapabilities::set('showSidebarBlocks', false);
// handle the G2 request
$g2moddata = GalleryEmbed::handleRequest();
// show error message if isDone is not defined
if (!isset($g2moddata['isDone'])) {
$data['bodyHtml'] = 'isDone is not defined, something very bad must have happened.';
return $data;
}
// exit if it was an immediate view / request (G2 already outputted some data)
if ($g2moddata['isDone']) {
exit;
}
// put the body html from G2 into the xaraya template
$data['bodyHtml'] = isset($g2moddata['bodyHtml']) ? $g2moddata['bodyHtml'] : '';
// get the page title, javascript and css links from the <head> html from G2
$title = ''; $javascript = array(); $css = array();
if (isset($g2moddata['headHtml'])) {
list($data['title'], $css, $javascript) = GalleryEmbed::parseHead($g2moddata['headHtml']);
$data['headHtml'] = $g2moddata['headHtml'];
}
/* Add G2 javascript */
$data['javascript'] = '';
if (!empty($javascript)) {
foreach ($javascript as $script) {
$data['javascript'] .= "\n".$script;
}
}
/* Add G2 css */
$data['css'] = '';
if (!empty($css)) {
foreach ($css as $style) {
$data['css'] .= "\n".$style;
}
}
// sidebar block
if (isset($g2moddata['sidebarBlocksHtml']) && !empty($g2moddata['sidebarBlocksHtml'])) {
$data['sidebarHtml'] = $g2moddata['sidebarBlocksHtml'];
}
return $data;
}
?>
I am trying to debug it.
2] From the above code:-
// if anonymous user, set g2 activeUser to ''
$uid = $_SESSION['SessMemberId'];
here I am sending my site session id.If am not sending anything to the uis, like
// if anonymous user, set g2 activeUser to ''
$uid = '';
which was the original code.The gallery css and javascripts are not working.I am able to view the page but without css,images.
Please let me know if anything can be done.
Thanks,
Rose
Posts: 16503
I'm sorry I really don't know. I can only suggest to try looking at other integrations that do single sign on with Gallery and that application.
Maybe someone else can help, but right now all of the main Gallery devs are working on G3 so getting someone who'd know this would be a bit difficult.
Here's more of the Development docs for G2, I don't know if they'd help you or not.
http://codex.gallery2.org/Development
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here
Posts: 6136
Adding css, js:
function getHeaderCode() { $header_text = '<!-- Begin G2 Javascript and CSS includes -->'."\n"; /* First initialize gallery */ G2_init(); $g2_data = GalleryEmbed::handleRequest(); // get the javascript and css links from the <head> html from G2 if (isset($g2_data['headHtml'])) { $javascript = array(); $css = array(); list($title, $css, $javascript) = GalleryEmbed::parseHead($g2_data['headHtml']); foreach ($css as $stylesheet) { $header_text .= $stylesheet."\n"; } foreach ($javascript as $script) { $header_text .= $script."\n"; } } GalleryEmbed::done(); $header_text .= '<!-- End G2 includes -->'."\n"; return $header_text; }Don't forget GalleryEmbed::done();
Everything you do with GalleryEmbed must start with GalleryEmbed::init and end with GalleryEmbed::done();
Except logout does not require GalleryEmbed::done();
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 16503
Thanks man! I had a feeling you'd have an idea on how to do this.
____________________________________________
Like Gallery? Like the support? Donate now!!! See G2 live here
Posts: 5
Thanks. I will try this.