isSuccess()

treeleaf20

Joined: 2005-11-15
Posts: 64
Posted: Sun, 2006-02-26 02:44

I get the following error when I try and embed G2 into my site:

Fatal error: Call to undefined function: issuccess() in /home/website/.panel/web/gallery2/main2.php on line 60

This is the code I use:
$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('embed.php');
///echo $userId;
$data = array();

// if anonymous user, set g2 activeUser to ''
$uid = '';
if (isset($_SESSION['Username'])) {
$uid = $_SESSION['Username'];

}
// initiate G2
$ret = GalleryEmbed::init(array('embedUri' => 'main2.php',
'embedPath' => 'v-web/gallery2/',
'relativeG2Path' => '',
'loginRedirect' => 'http://www.website.com/pleaseregister.php',
'activeUserId' => $uid));
if (!$ret->isSuccess()) {
$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 */
if (!empty($javascript)) {
foreach ($javascript as $script) {
$data['javascript'] .= "\n".$script;
}
}

/* Add G2 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;
}

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sun, 2006-02-26 03:08

are you mixing code for G2.0 and 2.1? GalleryStatus::isSuccess is gone in 2.1
http://codex.gallery2.org/index.php/Gallery2:API_Changes_Since_The_Last_Release

 
treeleaf20

Joined: 2005-11-15
Posts: 64
Posted: Sun, 2006-02-26 03:50

Yes I believe I am, on the link you provided me I'm not sure what I need to change to use 2.1. Can you help?

Thanks.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sun, 2006-02-26 06:49

find the section in that doc about GalleryEmbed for changes to init() parameters.
then change your if (!$ret->isSuccess()) line to if ($ret)

 
treeleaf20

Joined: 2005-11-15
Posts: 64
Posted: Tue, 2006-02-28 01:13

Is there a link that you could point me to?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2006-02-28 02:02

the link a few posts up? not sure what you're asking..

 
treeleaf20

Joined: 2005-11-15
Posts: 64
Posted: Tue, 2006-02-28 14:25

What changes do I need to make as far as creating a user with the new API, has this changed at all?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2006-02-28 19:16

don't think so.. as I mentioned above, init parameters have changed and error handling has changed.

 
treeleaf20

Joined: 2005-11-15
Posts: 64
Posted: Wed, 2006-03-01 02:15

I got it to create a user and login me in with the embed feature. However with a person that I created I get the following error:

Fatal error: Call to a member function on a non-object in /home/website/.panel/web/gallery2/main2.php on line 61

This line is:
$data['bodyHtml'] = $ret->getAsHtml();

Which is part of the if statement:
if (!$ret) {
$data['bodyHtml'] = $ret->getAsHtml();
return $data;
}

What does this mean, and is how do I fix it?

Thanks.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Wed, 2006-03-01 04:30

change if (!$ret) to if ($ret)

 
treeleaf20

Joined: 2005-11-15
Posts: 64
Posted: Wed, 2006-03-15 02:11

I now have the following code:
$uid = '';
if (isset($_SESSION['Username'])) {
$uid = $_SESSION['Username'];

}
// initiate G2 'embedUri' => 'main2.php',
$ret = GalleryEmbed::init(array(
'embedUri' => 'main2.php',
'g2Uri' => '',
'loginRedirect' => 'index.php',
'activeUserId' => $uid));
if ($ret) {
$data['bodyHtml'] = $ret->getAsHtml();
return $data;
}

When I try and embed it I get the following error from Gallery:
Error (ERROR_MISSING_OBJECT) : tree20 GalleryUser

* in modules/core/classes/helpers/GalleryEntityHelper_simple.class at line 142 (gallerycoreapi::error)
* in modules/core/classes/GalleryCoreApi.class at line 2422 (galleryentityhelper_simple::loadentitybyexternalid)
* in modules/core/classes/GalleryEmbed.class at line 223 (gallerycoreapi::loadentitybyexternalid)
* in modules/core/classes/GalleryEmbed.class at line 130 (galleryembed::checkactiveuser)
* in main2.php at line 59 (galleryembed::init)
* in main2.php at line 19

I checked the database and that user is in the database, Any idea what could be causing this?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Wed, 2006-03-15 04:51

missing entry in ExternalIdMap