The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
|||
|
|||
Help integrating Menalto Gallery2 with VB4
I am trying to integrate gallery2 with vb4. The guides out there are for vb3.x so I want to try to adapt it with vb4. I tried it the vb3 way, which seemed to be missing some of my navbit just below the header.
Anyways... I am using the custom page mod as kind of a guide to get this done as they seem somewhat similar. My code for gallery.php is: Code:
<?php // ####################### SET PHP ENVIRONMENT ########################### error_reporting(E_ALL & ~E_NOTICE); // #################### DEFINE IMPORTANT CONSTANTS ####################### define('NO_REGISTER_GLOBALS', 1); define('THIS_SCRIPT', 'gallery'); // change this depending on your filename define('CSRF_PROTECTION', true); // ################### PRE-CACHE TEMPLATES AND DATA ###################### // get special phrase groups $phrasegroups = array(); // get special data templates from the datastore $specialtemplates = array(); // pre-cache templates used by all actions $globaltemplates = array( 'gallery2', ); // pre-cache templates used by specific actions $actiontemplates = array(); // ######################### REQUIRE BACK-END ############################ require_once('./global.php'); // ####################################################################### // ######################## START MAIN SCRIPT ############################ // ####################################################################### $navbits = array(); $navbits[$parent] = 'Gallery'; error_reporting(E_ALL ); $navbits = construct_navbits($navbits); $navbar = render_navbar_template($navbits); //eval('$navbar = "' . fetch_template('navbar') . '";'); // ####################################################################### // ###################### Begin G2 INTEGRATION CODE ###################### // ####################################################################### $data = runGallery(); $data['title'] = (isset($data['title']) && !empty($data['title'])) ? $data['title'] : 'Gallery'; function runGallery() { global $vbulletin, $userinfo; require_once('/data/www/mywebsite.net/gallery/embed.php'); $data = array(); // If it's an anonymous user, set the g2 activeUser to null $uid = $vbulletin->userinfo['userid'] = 0 ? '' : $vbulletin->userinfo['userid']; // initiate G2 // You need to edit the following 4 lines to suit your VB3 & G2 installations // This is set up for an install that looks like: // public_html/VB/<vb files> // public_html/gallery2/<gallery2 files> // and also setup for a VB3 template name of 'gallery2'. If you have any // differences, make those changes here! // You might need to change 'loginRedirect' if you have your VB3 setup to // where index.php is not the root page of VB3... Like if you've changed it // to forums.php or something of the like. $ret = GalleryEmbed::init(array('embedUri' => '/gallery.php', 'g2Uri' => 'http://www.mywebsite.net/gallery/', 'loginRedirect' => 'index.php', 'activeUserId' => $uid)); if ($ret) { if ($ret->getErrorCode() & ERROR_MISSING_OBJECT) { // Check if there's no G2 user mapped to the activeUserId $ret = GalleryEmbed::isExternalIdMapped($uid, 'GalleryUser'); if ($ret && ($ret->getErrorCode() & ERROR_MISSING_OBJECT)) { // User not mapped, create G2 user now // Get Arguments for the new user: $args['fullname'] = $vbulletin->userinfo['username']; $args['username'] = $vbulletin->userinfo['username']; $args['hashedpassword'] = $vbulletin->userinfo['password']; $args['hashmethod'] = 'md5'; $args['email'] = $vbulletin->userinfo['email']; $args['language'] = $vbulletin->userinfo['lang_code']; $args['creationtimestamp'] = $vbulletin->userinfo['joindate']; $retcreate = GalleryEmbed :: createUser($uid, $args); if ($retcreate) { echo '<HR>line: '.__LINE__.', Failed to create G2 user with extId ['.$uid.']. Here is the error message from G2: <br />'.$retcreate->getAsHtml(); return false; } $ret = GalleryEmbed::checkActiveUser($uid); if ($ret) { print $ret->getAsHtml(); return false; } } else { echo '<HR>line: '.__LINE__.', G2 did not return a success status. Here is the error message from G2: <br />'.$ret->getAsHtml(); return false; } } else { echo '<HR>line: '.__LINE__.', G2 did not return a success status. Here is the error message from G2: <br />'.$ret->getAsHtml(); return false; } } // user interface: disable sidebar in G2 and get it as separate HTML to put it into a block //GalleryCapabilities::set('showSidebar', 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; } // die if it was a binary data (image) request if ($g2moddata['isDone']) { exit; /* uploads module does this too */ } // 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['sidebarHtml']) && !empty($g2moddata['sidebarHtml'])) { $data['sidebarHtml'] = $g2moddata['sidebarHtml']; } return $data; } // ####################################################################### // ####################### End G2 integration code ####################### // ####################################################################### eval('print_output("' . fetch_template('gallery2') . '");'); ?> Code:
{vb:stylevar htmldoctype} <html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html"> <head> <title>{vb:raw vboptions.bbtitle} - Gallery</title> {vb:raw headinclude} {vb:raw headinclude_bottom} </head> <body> {vb:raw header} {vb:raw navbar} <div class="blockbody"> <div class="blockrow">$data[bodyHtml]</div> </div> {vb:raw footer} </body> </html> Code:
[Wed Apr 25 01:19:05 2012] [error] [client *.*.*.*] PHP Parse error: syntax error, unexpected T_STRING in /data/www/mywebsite.net/gallery.php(168) : eval()'d code on line 1 |
#2
|
|||
|
|||
Again any help is appreciated! I realized I forgot to add the code that they had for vb3. It seems to work, but like a said a few things appear to be missing (navbar tabs) so I am not sure if it needs converted to how vb4 does it, or if I am just missing something obvious.
Code:
$stylevar[htmldoctype] <html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]"> <head> $headinclude $data[headHtml] </head> <body> $header $navbar <table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center"> <tr><td class="tcat">Gallery</td></tr> <tr><td class="alt1">$data[bodyHtml]</td></tr> </table> $footer </body> </html> |
#3
|
|||
|
|||
At the end, instead of the eval(print_output(... line, try:
Code:
$templater = vB_Template::create('gallery2'); $templater->register_page_templates(); $templater->register('bodyHtml', $data['bodyHtml']); print_output($templater->render()); and then in the gallery2 template, change $data[bodyHtml] to {vb:raw bodyHtml} |
#4
|
|||
|
|||
Gallery3 is a far superior version to use. I use it on my site for all the picture goodies. But as for integration, I've had no luck. If you get it to work I'd really like to see it.
|
#5
|
|||
|
|||
Quote:
--------------- Added [DATE]1335874190[/DATE] at [TIME]1335874190[/TIME] --------------- Quote:
Then I imagine the other problem I will still have (that I found earlier with using the vb3 method, but didn't mention) is when I upload a photo through it, it gives me a message about the missing security token. Looks like this isn't going to be as easy as I thought. |
#6
|
|||
|
|||
If you have a form that posts data, you need to include the security token value as a hidden field in the form data. Or, I think you can put define('CSRF_PROTECTION', false); at the top of your php file (somewhere before global.php in included).
|
#7
|
|||
|
|||
Quote:
Now to figure out why the gallery is all mangled. Again I appreciate it! --------------- Added [DATE]1335884902[/DATE] at [TIME]1335884902[/TIME] --------------- I also just noticed the nav bar tabs still are not showing up. haha what a mess this seems to be. I'll have to mess with it some more when I have some time. |
#8
|
|||
|
|||
Quote:
I just can't figure out why running that template through stripped all the formatting. For instance, using the vb3 style way looked like the first screen shot. vb4 style is the 2nd. Maybe I'm missing something like another variable. Figured I would upload some screenshots in case something jumps out at someone. gallery2 css getting stripped out? edit: I got it! haha just messing around. Added the following to gallery.php: Code:
$templater->register('headHtml', $data['headHtml']); Thanks for all the help once again. |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|