Page 3 of 4

Re: time is running - solution!

Posted: Fri Apr 22, 2005 7:01 pm
by Timbalu
garvinhicking wrote:No, the "embed" mechanism is not used/needed. In fact, using Smarty, the whole embed structure of Serendipity is really not needed anymore since you can do everything you need via the Smarty Templating.

And you would only need embedding if you wanted to show Serendipity within Gallery. But you want to do it the other way round, so only Gallery needs to be embedded.
Hi Garvin,
Not really - the point is, that none of them needs to get embedded ;-)

Ok Guys, here we go:

- inside gallery/config.php

Code: Select all

$gallery->app->embedded_inside_type = "Serendipity";
$gallery->app->serendipity_dir = "/home/www/html/s9y/";
- make deinit.php and the .htaccess change like Garvin said.

- in gallery/init.php go to Standalone and include the Serendipity stuff

Code: Select all

	/* Standalone */
	include_once(dirname(__FILE__) . "/classes/gallery/UserDB.php");
	include_once(dirname(__FILE__) . "/classes/gallery/User.php");

	/* Load our user database (and user object) */
	$gallery->userDB = new Gallery_UserDB;

	/* Load their user object with their username as the key */
	if (isset($gallery->session->username) && !empty($gallery->session->username)) {
		$gallery->user = $gallery->userDB->getUserByUsername($gallery->session->username);
	}
	
	/* +++ Include Serendipity stuff start +++ */
			$serendipity_directory = $gallery->app->serendipity_dir;

			$cwd = getcwd();
			chdir($gallery->app->serendipity_dir);
			define('S9Y_INCLUDE_PATH', $gallery->app->serendipity_dir);
			include_once(S9Y_INCLUDE_PATH . 'serendipity_config.inc.php');
			include_once(S9Y_INCLUDE_PATH . 'include/functions.inc.php');
			include_once(S9Y_INCLUDE_PATH . 'include/plugin_api.inc.php');
			include_once(S9Y_INCLUDE_PATH . 'include/plugin_internal.inc.php');

			$serendipity['smarty_file'] = 'index.tpl';
			$serendipity['smarty_raw_mode'] = false;
			serendipity_smarty_init();
			$serendipity['smarty']->assign(
				array(
					'leftSidebarElements'       => serendipity_plugin_api::count_plugins('left'),
					'rightSidebarElements'      => serendipity_plugin_api::count_plugins('right')
				)
			);

			chdir($cwd);
			ob_start();
		/* --- include serendipity stuff end --- */
}
- modify if(!function_exists()) to all functions inside s9y/include/functions_smarty.inc.php

Code: Select all

<?php # $Id: functions_smarty.inc.php,v 1.22 2005/03/31 12:10:48 garvinhicking Exp $
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved.  See LICENSE file for licensing details

if( !function_exists("serendipity_smarty_fetch") ) {
  function &serendipity_smarty_fetch($block, $file, $echo = false) {
    global $serendipity;

    $output = $serendipity['smarty']->fetch('file:'. serendipity_getTemplateFile($file, 'serendipityPath'), null, null, ($echo === true && $serendipity['smarty_raw_mode']));
    $serendipity['smarty']->assign($block, $output);

    return $output;
  }
}

if( !function_exists("serendipity_emptyPrefix") ) {
  function serendipity_emptyPrefix($string, $prefix = ': ') {
    return (!empty($string) ? $prefix . htmlspecialchars($string) : '');
  }
}

if( !function_exists("serendipity_smarty_showPlugin") ) {
  function serendipity_smarty_showPlugin($params, &$smarty) {
    global $serendipity;

    if (!isset($params['class']) && !isset($params['id'])) {
        $smarty->trigger_error(__FUNCTION__ .": missing 'class' or 'id' parameter");
        return;
    }

    if (!isset($params['side'])) {
        $params['side'] = '*';
    }

    if (!isset($params['negate'])) {
        $params['negate'] = null;
    }

    return serendipity_plugin_api::generate_plugins($params['side'], null, $params['negate'], $params['class'], $params['id']);
  }
}

if( !function_exists("serendipity_smarty_hookPlugin") ) {
  function serendipity_smarty_hookPlugin($params, &$smarty) {
    global $serendipity;
    static $hookable = array('frontend_header',
                             'entries_header',
                             'entries_footer',
                             'frontend_comment');

    if (!isset($params['hook'])) {
        $smarty->trigger_error(__FUNCTION__ .": missing 'hook' parameter");
        return;
    }

    if (!in_array($params['hook'], $hookable) && $params['hookAll'] != 'true') {
        $smarty->trigger_error(__FUNCTION__ .": illegal hook '". $params['hook'] ."'");
        return;
    }

    if (!isset($params['data'])) {
        $params['data'] = &$serendipity;
    }

    if (!isset($params['addData'])) {
        $params['addData'] = null;
    }

    serendipity_plugin_api::hook_event($params['hook'], $params['data'], $params['addData']);
  }
}

if( !function_exists("serendipity_smarty_printSidebar") ) {
  function serendipity_smarty_printSidebar($params, &$smarty) {
    if ( !isset($params['side']) ) {
        $smarty->trigger_error(__FUNCTION__ .": missing 'side' parameter");
        return;
    }
    return serendipity_plugin_api::generate_plugins($params['side']);
  }
}

if( !function_exists("serendipity_smarty_getFile") ) {
  function serendipity_smarty_getFile($params, &$smarty) {
    if ( !isset($params['file']) ) {
        $smarty->trigger_error(__FUNCTION__ .": missing 'file' parameter");
        return;
    }
    return serendipity_getTemplateFile($params['file']);
  }
}

if( !function_exists("serendipity_smarty_formatTime") ) {
  function serendipity_smarty_formatTime($timestamp, $format, $useOffset = true) {
    if (defined($format)) {
        return serendipity_formatTime(constant($format), $timestamp, $useOffset);
    } else {
        return serendipity_formatTime($format, $timestamp, $useOffset);
    }
  }
}

if( !function_exists("serendipity_smarty_printComments") ) {
  function &serendipity_smarty_printComments($params, &$smarty) {
    global $serendipity;

    if (!isset($params['entry'])) {
        $smarty->trigger_error(__FUNCTION__ .": missing 'entry' parameter");
        return;
    }

    if (!isset($params['mode'])) {
        $params['mode'] = VIEWMODE_THREADED;
    }

    $comments = serendipity_fetchComments($params['entry']);

    if (!empty($serendipity['POST']['preview'])) {
        $comments[] =
            array(
                    'email'     => $serendipity['POST']['email'],
                    'author'    => $serendipity['POST']['name'],
                    'body'      => $serendipity['POST']['comment'],
                    'url'       => $serendipity['POST']['url'],
                    'parent_id' => $serendipity['POST']['replyTo'],
                    'timestamp' => time()
            );
    }

    return serendipity_printComments($comments, $params['mode']);
  }
}

if( !function_exists("serendipity_smarty_printTrackbacks") ) {
  function serendipity_smarty_printTrackbacks($params, &$smarty) {
    if ( !isset($params['entry']) ) {
        $smarty->trigger_error(__FUNCTION__ .": missing 'entry' parameter");
        return;
    }

    return serendipity_printTrackbacks(serendipity_fetchTrackbacks($params['entry']));
  }
}

if( !function_exists("serendipity_smarty_init") ) {
  function serendipity_smarty_init() {
    global $serendipity;

    if (!isset($serendipity['smarty'])) {
        @define('SMARTY_DIR', S9Y_INCLUDE_PATH . 'bundled-libs/Smarty/libs/');
        require_once SMARTY_DIR . 'Smarty.class.php';
        $serendipity['smarty'] = new Smarty;
        if ($serendipity['production'] === 'debug') {
            $serendipity['smarty']->force_compile   = true;
            $serendipity['smarty']->debugging       = true;
        }
        $serendipity['smarty']->template_dir  = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'];
        $serendipity['smarty']->compile_dir   = $serendipity['serendipityPath'] . PATH_SMARTY_COMPILE;
        $serendipity['smarty']->config_dir    = &$serendipity['smarty']->template_dir;
        $serendipity['smarty']->secure_dir    = array($serendipity['serendipityPath'] . $serendipity['templatePath']);
        $serendipity['smarty']->security_settings['MODIFIER_FUNCS'] = array('sprintf', 'sizeof', 'count', 'rand');
        $serendipity['smarty']->security      = true;
        $serendipity['smarty']->use_sub_dirs  = false;
        $serendipity['smarty']->compile_check = true;
        $serendipity['smarty']->compile_id    = &$serendipity['template'];

        $serendipity['smarty']->register_modifier('makeFilename', 'serendipity_makeFilename');
        $serendipity['smarty']->register_modifier('xhtml_target', 'serendipity_xhtml_target');
        $serendipity['smarty']->register_modifier('emptyPrefix', 'serendipity_emptyPrefix');
        $serendipity['smarty']->register_modifier('formatTime', 'serendipity_smarty_formatTime');
        $serendipity['smarty']->register_function('serendipity_printSidebar', 'serendipity_smarty_printSidebar');
        $serendipity['smarty']->register_function('serendipity_hookPlugin', 'serendipity_smarty_hookPlugin');
        $serendipity['smarty']->register_function('serendipity_showPlugin', 'serendipity_smarty_showPlugin');
        $serendipity['smarty']->register_function('serendipity_getFile', 'serendipity_smarty_getFile');
        $serendipity['smarty']->register_function('serendipity_printComments', 'serendipity_smarty_printComments');
        $serendipity['smarty']->register_function('serendipity_printTrackbacks', 'serendipity_smarty_printTrackbacks');
    }

    if (!isset($serendipity['smarty_raw_mode'])) {
        if (file_exists($serendipity['smarty']->template_dir . '/layout.php') && $serendipity['template'] != 'default') {
            $serendipity['smarty_raw_mode'] = true;
        } else {
            $serendipity['smarty_raw_mode'] = false;
        }
    }

    if (!isset($serendipity['smarty_file'])) {
        $serendipity['smarty_file'] = 'index.tpl';
    }

    $serendipity['smarty']->assign(
        array(
            'head_charset'              => LANG_CHARSET,
            'head_version'              => $serendipity['version'],
            'head_title'                => $serendipity['head_title'],
            'head_subtitle'             => $serendipity['head_subtitle'],
            'head_link_stylesheet'      => serendipity_rewriteURL('serendipity.css'),

            'CONST'                     => get_defined_constants(),

            'is_xhtml'                  => $serendipity['XHTML11'],
            'use_popups'                => $serendipity['enablePopup'],
            'is_embedded'               => (!$serendipity['embed'] || $serendipity['embed'] === 'false' || $serendipity['embed'] === false) ? false : true,
            'is_raw_mode'               => $serendipity['smarty_raw_mode'],

            'entry_id'                  => (isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])) ? $serendipity['GET']['id'] : false,
            'is_single_entry'           => (isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])),

            'blogTitle'                 => htmlspecialchars($serendipity['blogTitle']),
            'blogSubTitle'              => (!empty($serendipity['blogSubTitle']) ? htmlspecialchars($serendipity['blogSubTitle']) : ''),
            'blogDescription'           => htmlspecialchars($serendipity['blogDescription']),

            'serendipityHTTPPath'       => $serendipity['serendipityHTTPPath'],
            'serendipityBaseURL'        => $serendipity['baseURL'],
            'serendipityRewritePrefix'  => $serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '',
            'serendipityIndexFile'      => $serendipity['indexFile'],
            'serendipityVersion'        => $serendipity['version'],

            'dateRange'                 => (!empty($serendipity['range']) ? $serendipity['range'] : array())
        )
    );

    return true;
  }
}

/* Nukes all Smarty compiled templates and cache */
if( !function_exists("serendipity_smarty_purge") ) {
  function serendipity_smarty_purge() {
    global $serendipity;

    /* Attempt to init Smarty, brrr */
    serendipity_smarty_init();

    $files = serendipity_traversePath($serendipity['smarty']->compile_dir, '', false, '/.+\.tpl\.php$/');


    if ( !is_array($files) ) {
        return false;
    }

    foreach ( $files as $file ) {
        @unlink($serendipity['smarty']->compile_dir . DIRECTORY_SEPARATOR . $file['name']);
    }
  }
}

if( !function_exists("serendipity_smarty_shutdown") ) {
/* Function can be called from foreign applications. ob_start() needs to
  have been called before, and will be parsed into Smarty here */
  function serendipity_smarty_shutdown($serendipity_directory = '') {
    global $serendipity;

    $cwd = getcwd();
    chdir($serendipity_directory);
    $raw_data = ob_get_contents();
    ob_end_clean();
    $serendipity['smarty']->assign('content_message', $raw_data);

    serendipity_smarty_fetch('CONTENT', 'content.tpl');
    if (empty($serendipity['smarty_file'])) {
        $serendipity['smarty_file'] = '404.tpl';
    }
    $serendipity['smarty']->display(serendipity_getTemplateFile($serendipity['smarty_file'], 'serendipityPath'));
  }
}
Hope to be helpfull!

Regards
Ian

Re: time is running - solution!

Posted: Fri Apr 22, 2005 7:37 pm
by garvinhicking
Timbalu,

modifyint the functions_smarty file the way you mentioned looks very wrong to me. You don't need to modify it like that, you are trying to bypass the functioons_smarty file getting loaded twice. But you need to find the real cause to this and not make an ugly hack like you did :)

The reason seems to be some include_once failing on your system. Sometimes this can happen with buggy PHP versions and ZEND Optimizeres which do not properly recognize include_once vs. include.

But don't hack the file like this, it is not advised. :)

Regards,
Garvin

Re: time is running - solution!

Posted: Fri Apr 22, 2005 8:06 pm
by Timbalu
garvinhicking wrote:..., you are trying to bypass the functioons_smarty file getting loaded twice. But you need to find the real cause to this and not make an ugly hack like you did :)
:oops: Yes, you are right! But I didn´t find the requested solution.
garvinhicking wrote:The reason seems to be some include_once failing on your system. Sometimes this can happen with buggy PHP versions and ZEND Optimizeres which do not properly recognize include_once vs. include.
no buggy php nor zend...
garvinhicking wrote: But don't hack the file like this, it is not advised. :)
:shock: Hoppla!, don´t get :x. It was just a quick and working solution - no one needs to copy it! :)

Regards,
Ian

Posted: Mon Apr 25, 2005 10:24 pm
by Guest
Did anyone manage to get Coppermine working with Serendipity ? At the moment I've just got the html displaying from my theme.php - it's not wrapped with the Serendipity site.

Anyone got any ideas ?

Posted: Sun May 08, 2005 1:56 pm
by Timbalu
Its me again. Hopefully the last time in this thread ;-)

Just to informe you. The stuff I said above is working on my windows computer.
But this one is a working version on my hosters system and I think its even better.
Maybe you still need these changes to functions_smarty.inc.php mentioned above.
I did not prove this version with the original functions_smarty.inc.php file.
Its still just an ugly hack!
Ian


Using Gallery( 1.5 ) inside Serendipity( 0.8 ) with Puretec, 1&1 Hosting.


Append to /gallery/config.php

Code: Select all

$gallery->app->serendipity_dir = "/homepages/xx/dxxxxxxxx/htdocs/serendipity/";

Create & Insert to /gallery/deinit.php

Code: Select all

<?php serendipity_smarty_shutdown($gallery->app->serendipity_dir); ?> 
Since the config directive <<embbed_inside_type>> Garvin mentioned did not work I did this:

Append to /gallery/init.php

Code: Select all

/* --- include serendipity stuff start --- */
$GALLERY_EMBEDDED_INSIDE='Serendipity';
$GALLERY_EMBEDDED_INSIDE_TYPE = 'Serendipity';
/* --- include serendipity stuff end --- */

if (isset($GALLERY_EMBEDDED_INSIDE)) {
	/* Okay, we are embedded */
	switch($GALLERY_EMBEDDED_INSIDE_TYPE) {
		/* --- include serendipity stuff start --- */
		case 'Serendipity':
			include(dirname(__FILE__) . "/classes/gallery/UserDB.php");
			include(dirname(__FILE__) . "/classes/gallery/User.php");
			
			/* Load our user database (and user object) */
			$gallery->userDB = new Gallery_UserDB;
			
			/* Load their user object with their username as the key */
			if (isset($gallery->session->username) && !empty($gallery->session->username)) {
			           $gallery->user = $gallery->userDB->getUserByUsername($gallery->session->username);
			}
			
			$serendipity_directory = $gallery->app->serendipity_dir;
			
			$cwd = getcwd();
			chdir($gallery->app->serendipity_dir);
			define('S9Y_INCLUDE_PATH', $gallery->app->serendipity_dir);
			include_once(S9Y_INCLUDE_PATH . 'serendipity_config.inc.php');
			include_once(S9Y_INCLUDE_PATH . 'include/functions.inc.php');
			include_once(S9Y_INCLUDE_PATH . 'include/plugin_api.inc.php');
			include_once(S9Y_INCLUDE_PATH . 'include/plugin_internal.inc.php');
			
			$serendipity['smarty_file'] = 'index.tpl';
			$serendipity['smarty_raw_mode'] = false;
			serendipity_smarty_init();
			$serendipity['smarty']->assign(
			array(
					'leftSidebarElements'       => serendipity_plugin_api::count_plugins('left'),
					'rightSidebarElements'     => serendipity_plugin_api::count_plugins('right')
			)
			);
			
			chdir($cwd);
			ob_start();
			break; 			
			/* --- include serendipity stuff end --- */

Since I could not use php_value auto_append_file in my .htaccess file:

Create & Insert to /gallery/php.ini

Code: Select all

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

;max_execution_time = 30     ; Maximum execution time of each script, in seconds
;max_input_time = 60	; Maximum amount of time each script may spend parsing request data
memory_limit = 100M      ; Maximum amount of memory a script may consume (8MB)

;;;;;;;;;;;;;;;;;
; Data Handling ;
;;;;;;;;;;;;;;;;;

; Automatically add files before or after any PHP document.
;;;;auto_prepend_file =
auto_append_file = "/homepages/xx/dxxxxxxxx/htdocs/gallery/deinit.php"

Gallery instead of s9y Media?

Posted: Mon May 09, 2005 5:55 am
by andy
Didn't see any posts on this, but has anyone considered using Gallery for the media storage. I know 1.5x isn't the friendliest for this, but what about Gallery2? Or at least offer Gallery as an option in the install?

Seems like it would be a nice fit since it handles multiple levels, formats, users, etc.

-andy

Posted: Fri May 13, 2005 3:41 pm
by Timbalu
I just discovered why the change of functions_smarty.inc.php mentioned above is no good. You need these functions more then one time.

For this thread I just need to say, that Gallery will work like a charm if you use it with the last mentioned install, without changing functions_smarty.inc.php.

@RobA missing login
change line 217 and 222 in albums.php from
if (!$GALLERY_EMBEDDED_INSIDE) {
to
if ($GALLERY_EMBEDDED_INSIDE) {

This will give you back the login/logout links.
Ian

Posted: Mon May 23, 2005 12:48 pm
by Oliver
When trying to include Coppermine, I get the following error:
Kritischer Fehler
There was an error while processing a database query
I edited theme.php:

Code: Select all

<?php
/* SERENDIPITY HOOK START */ 
    $serendipity_directory = '/is/htdocs/www.forum4winde.de/mods/s9y/'; 

    $cwd = getcwd(); 
    chdir($serendipity_directory); 
    define('S9Y_INCLUDE_PATH', $serendipity_directory); 
    include_once(S9Y_INCLUDE_PATH . 'serendipity_config.inc.php'); 
    include_once(S9Y_INCLUDE_PATH . 'include/functions.inc.php'); 
    include_once(S9Y_INCLUDE_PATH . 'include/plugin_api.inc.php'); 
    include_once(S9Y_INCLUDE_PATH . 'include/plugin_internal.inc.php'); 

    $serendipity['smarty_file'] = 'index.tpl'; 
    $serendipity['smarty_raw_mode'] = false; 
    serendipity_smarty_init(); 
    $serendipity['smarty']->assign( 
        array( 
            'leftSidebarElements'       => serendipity_plugin_api::count_plugins('left'), 
            'rightSidebarElements'      => serendipity_plugin_api::count_plugins('right') 
        ) 
    ); 

    chdir($cwd); 
    ob_start(); 
/* SERENDIPITY HOOK END */

/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2005 Coppermine Dev Team
  v1.1 originaly written by Gregory DEMAR

... much more
In template.html I removed everything before <body> and everything after </body> including these tags, too. After that I created a file called deinit.php as said in the third post of this threat and a file .htaccess

deinit.php:

Code: Select all

php_value auto_append_file /is/htdocs/www.forum4winde.de/mods/s9y_cpg133/deinit.php
.

I put these 2 files in my Coppermine-rootdirectory.

When I call my Coppermine-Gallery, the error mentioned above comes up :(

I am using s9y 0.8 (no beta) and CPP v1.3.3 (, using Serendipity with my first and Coppermine with my second database).

What went wrong?

Regards,

Oliver

Posted: Mon May 23, 2005 2:05 pm
by garvinhicking
Seems that coppermine is having a larger problem, as one of its DB queries fails. Don't know what's that about...

Regards,
Garvin

Posted: Mon May 23, 2005 2:09 pm
by Oliver
Ok, thx Garvin, then I'll create a template for coppermine, so that it looks like my blog :)

[update] I found the error I made: Coppermine does not support separate databases when being includet to another application like s9y, phpBB... CPP and the application, where it should be includet, must use the same database.

Regards,

Olli

Posted: Sun Aug 07, 2005 3:04 pm
by Col. Kurtz
OK I´ve just tried this with Serendipity 0.8.1. and Coppermine Photo Gallery 1.3.3. I followed Garvins instructions and I have two problems. First the text I put into theme.php is shown on top of the page. And "Fatal error: Call to undefined function: serendipity_smarty_shutdown() in /www/htdocs/boogada/cm/deinit.php on line 1" is shown on the buttom of the page.

By the way, those two use the same database.

see here:
http://www.hohle-phrasen.de/cm/

what to do? has anyone ever gotten this to work?

Posted: Sun Aug 07, 2005 3:31 pm
by garvinhicking
The Fatal error happens because the s9y framework is not loaded via the prepend directives, or however you want to include it...that function needs to be included, so there seems to be an inclusion issue...

Regards,
Garvin

Posted: Sun Aug 07, 2005 9:04 pm
by Col. Kurtz
Ok I found the errors I made! I got it to work! Thx.

Only one question left: I had to remove all before the <body> tag in the template.html. This included a java-script:

Code: Select all

<script type="text/javascript" src="scripts.js"></script>
Of course this script wont work anymore now. Does this have to be removed or can I put it back in?

Posted: Sat Aug 27, 2005 1:49 pm
by Col. Kurtz
Im still looking for an answer to the javascript question:

There is a script that will open the pictures in a seperate new window in the largest version the pic is available. Usually if the pic is larger than the gallery itself, for example if the pics are 1024x786 or larger. So its a usefull feature that gets disabled. How to keep this script going?

(Maybe I can change this to a simple link with a target=_blank?)

Posted: Wed Sep 28, 2005 3:37 pm
by Guest
I cant find init.php in my gallery2 install folder. Any help here would be appreciated please.