Posted below is the code im working with. Now my next question is, how do you remove the sidebar from the page? When your actually going to view a single image in gallery 2, I want to remove the sidebar so there is more screen to work with. Is this doable?
Code: Select all
<?php
# (c) by Aaron Axelsen
# Much copied from the wrap url plugin
#
// Probe for a language include with constants. Still include defines later on, if some constants were missing
$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
if (file_exists($probelang)) {
include $probelang;
}
@define('G2EMBED_TITLE', 'Gallery2 Embed');
@define('G2EMBED_TITLE_DESC', 'Embeds Gallery2 within Serendipity');
@define('G2EMBED_G2DIR', 'Gallery2 Directory');
@define('G2EMBED_G2DIR_DESC', 'Absolute path to the Gallery2 directory on the server.');
@define('G2EMBED_EMBEDPATH', 'Embed Path');
@define('G2EMBED_EMBEDPATH_DESC', 'Absolute path to directory were the embedded file will reside.');
@define('G2EMBED_EMBEDURI', 'Embeded file name');
@define('G2EMBED_EMBEDURI_DESC', 'Name of the file to embed gallery 2 into.');
@define('G2EMBED_PAGETITLE', 'URL shorthand name (Backwards compatibility)');
@define('G2EMBED_PERMALINK', 'Permalink');
@define('G2EMBED_PERMALINK_DESC', 'Defines permalink for the URL.');
@define('G2EMBED_HEADLINE', 'Headline');
@define('G2EMBED_HEADLINE_DESC', 'Defines the heading for the document.');
@define('G2EMBED_RELG2PATH', 'Relative path to Gallery2 directory.');
@define('G2EMBED_RELG2PATH_DESC', 'This should be the relative path to the Gallery2 installation.');
class serendipity_event_G2EMBED extends serendipity_event {
function introspect(&$propbag) {
global $serendipity;
$propbag->add('name', G2EMBED_TITLE . ': ' . $this->get_config('pagetitle', ''));
$propbag->add('description', G2EMBED_TITLE_DESC);
$propbag->add('event_hooks', array('entries_header' => true, 'entry_display' => true, 'genpage' => true));
$propbag->add('configuration', array('g2dir', 'embedPath', 'relativeG2Path', 'embedUri', 'headline', 'permalink', 'pagetitle'));
$propbag->add('author', 'Aaron Axelsen');
$propbag->add('version', '0.1');
$propbag->add('requirements', array(
'serendipity' => '0.9.1',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
$propbag->add('groups', array('FRONTEND_EXTERNAL_SERVICES'));
$propbag->add('stackable', true);
$this->pagetitle = $this->get_config('pagetitle', 'pagetitle');
}
function introspect_config_item($name, &$propbag)
{
global $serendipity;
switch($name) {
case 'headline':
$propbag->add('type', 'string');
$propbag->add('name', G2EMBED_HEADLINE);
$propbag->add('description', G2EMBED_HEADLINE_DESC);
$propbag->add('default', 'Photo Gallery');
break;
case 'g2dir':
$propbag->add('type', 'string');
$propbag->add('name', G2EMBED_G2DIR);
$propbag->add('description', G2EMBED_G2DIR_DESC);
$propbag->add('default', '/var/www/html/gallery2');
break;
case 'embedPath':
$propbag->add('type', 'string');
$propbag->add('name', G2EMBED_EMBEDPATH);
$propbag->add('description', G2EMBED_EMBEDPATH_DESC);
$propbag->add('default', $serendipity['serendipityHTTPPath']);
break;
case 'relativeG2Path':
$propbag->add('type', 'string');
$propbag->add('name', G2EMBED_RELG2PATH);
$propbag->add('description', G2EMBED_RELG2PATH_DESC);
$propbag->add('default', '../gallery2');
break;
case 'embedUri':
$propbag->add('type', 'string');
$propbag->add('name', G2EMBED_EMBEDURI);
$propbag->add('description', G2EMBED_EMBEDURI_DESC);
$propbag->add('default', 'gallery2.html');
break;
case 'permalink':
$propbag->add('type', 'string');
$propbag->add('name', G2EMBED_PERMALINK);
$propbag->add('description', G2EMBED_PERMALINK_DESC);
$propbag->add('default', $serendipity['rewrite'] != 'none'
? $serendipity['serendipityHTTPPath'] . 'gallery2.html'
: $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/gallery2.html');
break;
case 'pagetitle':
$propbag->add('type', 'string');
$propbag->add('name', G2EMBED_PAGETITLE);
$propbag->add('description', '');
$propbag->add('default', 'gallery2');
break;
default:
return false;
}
return true;
}
function show() {
global $serendipity;
if ($this->selected()) {
if (!headers_sent()) {
header('HTTP/1.0 200');
}
require_once( $this->get_config('g2dir') . 'embed.php');
$ret = GalleryEmbed::init(array(
'embedPath' => $this->get_config('embedPath'),
'relativeG2Path' => $this->get_config('relativeG2Path'),
'embedUri' => $this->get_config('embedUri'),
'fullInit' => 'false',
'gallerySessionId' => $_COOKIE['PHPSESSID']
));
GalleryCapabilities::set('login',true);
// handle the G2 request
$g2moddata = GalleryEmbed::handleRequest();
// show error message if isDone is not defined
if (!isset($g2moddata['isDone']))
{
print 'isDone is not defined, something very bad must have happened.';
exit;
}
// die if it was a binary data (image) request
if ($g2moddata['isDone'])
{
exit; /* uploads module does this too */
}
if ($ret->isError())
{
print $ret->getAsHtml();
}
echo '<h4 class="serendipity_title"><a href="' . $this->get_config('embedUri') . '">' . $this->get_config('headline') . '</a></h4>';
echo '<div id="gallery">' . $g2moddata['headHtml'] . $g2moddata['bodyHtml'] .'</div>';
}
}
function selected() {
global $serendipity;
if ($serendipity['GET']['subpage'] == $this->get_config('pagetitle') ||
preg_match('@^' . preg_quote($this->get_config('permalink')) . '@i', $serendipity['GET']['subpage'])) {
return true;
}
return false;
}
function generate_content(&$title) {
$title = G2EMBED_TITLE.' ('.$this->get_config('pagetitle').')';
}
function event_hook($event, &$bag, &$eventData, $addData = null) {
global $serendipity;
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch($event) {
case 'genpage':
$args = implode('/', serendipity_getUriArguments($eventData, true));
if ($serendipity['rewrite'] != 'none') {
$nice_url = $serendipity['serendipityHTTPPath'] . $args;
} else {
$nice_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/' . $args;
}
if (empty($serendipity['GET']['subpage'])) {
$serendipity['GET']['subpage'] = $nice_url;
}
break;
case 'entry_display':
if ($this->selected()) {
if (is_array($eventData)) {
$eventData['clean_page'] = true; // This is important to not display an entry list!
} else {
$eventData = array('clean_page' => true);
}
}
if (version_compare($serendipity['version'], '0.7.1', '<=')) {
$this->show();
}
return true;
break;
case 'entries_header':
$this->show();
return true;
break;
default:
return false;
break;
}
} else {
return false;
}
}
}