Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1:/tmp/cvs-serv31047
Modified Files:
htaccess.tpl index.php serendipity.css.php serendipity.inc.php
serendipity_admin_installer.inc.php serendipity_config.inc.php
serendipity_config_local.tpl serendipity_functions.inc.php
serendipity_genpage.inc.php
Log Message:
o Added the ability to easily integrate serendipity into an existing
website.
For this to work, you need your existing layout and an additional wrapper
file. You specify the additional wrapper file in the serendipity
configuration ('indexFile') and set the 'embed' option to true.
The wrapper file is then used as the 404-Document and as the
DirectoryIndex file. When using the embedding parameter, the sidebars in
the default layout will not get generated, nor will html-
headers/footers be outputted.
A simple wrapper file I use for my homepage could be like this:
<?php
ob_start();
require 'index.php';
$redirect_data = ob_get_contents();
ob_end_clean();
chdir ($_SERVER['DOCUMENT_ROOT']);
require './inhalt.php';
?>
My mainfile (inhalt.php) then takes care of the $redirect_data variable
and prints it inside my table structure. You can have a look at
http://www.garvinhicking.de/serendipity/ to see a result of this. Be
warned that the serendipity stylesheet is not yet modified to meet my
page's style yet.
To get this to work I had to modify the getTemplate-Functions to use the
fully qualified path to the templates, otherwise the chdir() command in my
wrapper class gets serious problems.
o Corrected some indents/double quotes
o Replaced the hardcoded '/templates/' reference by the
$serendipity['templatePath'] variable
o Cut down the no longer used serendipity.inc.php to include the valid
serendipity_config.inc.php file.
For backwards compatibility of existing installations it now includes the
latter file and I did not move the filenames from
serendipity_config.inc.php to serendipity.inc.php (as shortly discussed on
the mailinglist)
o Neither did nor seen any such detailed, oversized changelog entry. Guess
nobody even reads it, though. ;)
Index: htaccess.tpl
===================================================================
RCS file: /cvsroot/php-blog/serendipity/htaccess.tpl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- htaccess.tpl 7 Jul 2003 12:25:14 -0000 1.4
+++ htaccess.tpl 9 Jul 2003 17:52:00 -0000 1.5
@@ -1,4 +1,5 @@
-ErrorDocument 404 {PREFIX}index.php
+ErrorDocument 404 {PREFIX}{indexFile}
+DirectoryIndex {PREFIX}{indexFile}
<Files *.tpl>
deny from all
@@ -13,5 +14,5 @@
</Files>
<Files sqlite.db>
- deny from all
+ deny from all
</Files>
Index: index.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/index.php,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- index.php 8 Jul 2003 14:40:00 -0000 1.20
+++ index.php 9 Jul 2003 17:52:00 -0000 1.21
@@ -123,7 +123,7 @@
header('Content-Type: text/html; charset=ISO-8859-1');
$serendipity['GET']['action'] = 'archives';
include_once('serendipity_genpage.inc.php');
-} else if (preg_match('@/(index\.(php|html))?@', $uri)) {
+} else if (preg_match('@/(index\.(php|html))?@', $uri) || preg_match('@/(' . preg_quote($serendipity['indexFile']) . ')?@')) {
header('Content-Type: text/html; charset=ISO-8859-1');
if (count($serendipity['GET']) == 2) {
ob_start();
@@ -141,7 +141,7 @@
$serendipity['GET']['action'] = 'read';
$serendipity['GET']['range'] = $serendipity['GET']['calendarZoom'];
}
- include_once("serendipity_genpage.inc.php");
+ include_once('serendipity_genpage.inc.php');
}
} else {
printf(DOCUMENT_NOT_FOUND, $uri);
Index: serendipity.css.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity.css.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- serendipity.css.php 8 Jul 2003 09:13:27 -0000 1.13
+++ serendipity.css.php 9 Jul 2003 17:52:00 -0000 1.14
@@ -5,7 +5,7 @@
if (!@include_once('serendipity_config.inc.php')) {
readfile('serendipity.css');
} else if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . serendipity_get_config_var('template', 'default') . '/style.css') ) {
- echo str_replace('{TEMPLATE_PATH}', $serendipity['baseURL'] . '/templates/' . serendipity_get_config_var('template', 'default'). '/', file_get_contents($serendipity['templatePath'] . serendipity_get_config_var('template', 'default') . '/style.css'));
+ echo str_replace('{TEMPLATE_PATH}', $serendipity['baseURL'] . $serendipity['templatePath'] . serendipity_get_config_var('template', 'default'). '/', file_get_contents($serendipity['serendipityPath'] . $serendipity['templatePath'] . serendipity_get_config_var('template', 'default') . '/style.css'));
} else if (file_exists($serendipity['templatePath'] . 'default/style.css')) {
readfile ($serendipity['templatePath'] . 'default/style.css');
} else {
Index: serendipity.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- serendipity.inc.php 9 Jul 2003 07:53:17 -0000 1.5
+++ serendipity.inc.php 9 Jul 2003 17:52:00 -0000 1.6
@@ -1,118 +1,7 @@
<?php # $Id$
-##########################################################################
-# serendipity - another blogger... #
-##########################################################################
-# #
-# (c) 2003 Jannis Hermanns <J...@ha...> #
-# http://www.jannis.to/programming/serendipity.html #
-# #
-##########################################################################
-define('IN_serendipity', true);
-include_once('compat.php');
-
-// For security reasons (serendipity relies on register_globals on)
-$serendipity = array();
-
-if (!file_exists('./serendipity_config_local.inc.php')) {
- die ('serendipity is not yet installed! Go to the <a href="serendipity_admin.php">Installation</a>');
-}
-include_once('./serendipity_config_local.inc.php');
-
-// Put your emoticons here
-$serendipity['smiles'] = array( ":'(" => $serendipity['serendipityHTTPPath'] . 'pixel/cry_smile.gif',
- ':-)' => $serendipity['serendipityHTTPPath'] . 'pixel/regular_smile.gif',
- ':-O' => $serendipity['serendipityHTTPPath'] . 'pixel/embaressed_smile.gif',
- ':O' => $serendipity['serendipityHTTPPath'] . 'pixel/embaressed_smile.gif',
- ':-(' => $serendipity['serendipityHTTPPath'] . 'pixel/sad_smile.gif',
- ':(' => $serendipity['serendipityHTTPPath'] . 'pixel/sad_smile.gif',
- ':)' => $serendipity['serendipityHTTPPath'] . 'pixel/regular_smile.gif',
- '8-)' => $serendipity['serendipityHTTPPath'] . 'pixel/shades_smile.gif',
- ':-D' => $serendipity['serendipityHTTPPath'] . 'pixel/teeth_smile.gif',
- ':D' => $serendipity['serendipityHTTPPath'] . 'pixel/teeth_smile.gif',
- '8)' => $serendipity['serendipityHTTPPath'] . 'pixel/shades_smile.gif',
- ':-P' => $serendipity['serendipityHTTPPath'] . 'pixel/tounge_smile.gif',
- ';-)' => $serendipity['serendipityHTTPPath'] . 'pixel/wink_smile.gif',
- ';)' => $serendipity['serendipityHTTPPath'] . 'pixel/wink_smile.gif',
- ':P' => $serendipity['serendipityHTTPPath'] . 'pixel/tounge_smile.gif',
-);
-
-// You're done :)
-
-/*************************************************************************
-* You shouldn't need to touch anything here. *
-*************************************************************************/
-
-// Make sure sessioning is running
-if (strlen(@session_id()) < 5) {
- die ('serendipity error: you _have_ to run session_start() before including serendipity_config.inc.php - exiting');
-}
-
-include($serendipity['serendipityPath'] . '/serendipity_functions.inc.php');
-if (serendipity_FUNCTIONS_LOADED!== true) {
- die ('serendipity error: could not include serendipity_functions.inc.php - exiting');
-}
-
-include($serendipity['serendipityPath'] . '/serendipity_lang_' . $serendipity['lang'] . '.inc.php');
-if (serendipity_LANG_LOADED !== true) {
- die ('serendipity error: could not include serendipity_lang_' . $serendipity['lang'] . '.inc.php - exiting');
-}
-
-// Connect to database
-if (!serendipity_db_connect()) {
- die ('serendipity error: unable to connect to database - exiting');
-}
-
-// Avoid magic_quotes_gpc issues
-// courtesy of il...@ph...
-function serendipity_strip_quotes(&$var) {
- if (is_array($var)) {
- foreach ($var as $k => $v) {
- if (is_array($v)) {
- array_walk($var[$k], 'serendipity_strip_quotes');
- } else {
- $var[$k] = stripslashes($v);
- }
- }
- } else {
- $var = stripslashes($var);
- }
-}
-
-if (ini_get('magic_quotes_gpc')) {
- if (@count($_GET)) {
- array_walk($_GET, 'serendipity_strip_quotes');
- }
- if (@count($_POST)) {
- array_walk($_POST, 'serendipity_strip_quotes');
- }
- if (@count($_COOKIES)) {
- array_walk($_COOKIES, 'serendipity_strip_quotes');
- }
- if (@count($_FILES)) {
- array_walk($_FILES, 'serendipity_strip_quotes');
- }
-}
-
-// Merge get and post into the serendipity array
-$serendipity['GET'] = &$_GET['serendipity'];
-$serendipity['POST'] = &$_POST['serendipity'];
-
-// We don't care who tells us what to do
-if (!$serendipity['GET']['action']) {
- $serendipity['GET']['action'] = $serendipity['POST']['action'];
-}
-
-if (!$serendipity['GET']['adminAction']) {
- $serendipity['GET']['adminAction'] = $serendipity['POST']['adminAction'];
-}
-
-// Some stuff...
-if (!$_SESSION['serendipityAuthedUser']) {
- $_SESSION['serendipityAuthedUser'] = false;
-}
+// This file has been replaced by serendipity_config.inc.php. It will get deleted eventually. Soon. Maybe.
+include_once 'serendipity_config.inc.php';
-$serendipity['user'] = $_SESSION['serendipityUser'];
-$serendipity['email'] = $_SESSION['serendipityEmail'];
/* vim: set sts=4 ts=4 expandtab : */
?>
Index: serendipity_admin_installer.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_installer.inc.php,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- serendipity_admin_installer.inc.php 8 Jul 2003 09:13:27 -0000 1.17
+++ serendipity_admin_installer.inc.php 9 Jul 2003 17:52:00 -0000 1.18
@@ -265,7 +265,7 @@
}
else {
for($x = 0; $x < count($a); $x++) {
- fwrite($fp, str_replace("{PREFIX}", $_POST["serendipityHTTPPath"],$a[$x])."\n");
+ fwrite($fp, str_replace(array('{PREFIX}','{indexFile}'), array($_POST['serendipityHTTPPath'], $_POST['indexFile']),$a[$x]));
}
fclose($fp);
}
Index: serendipity_config.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_config.inc.php,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- serendipity_config.inc.php 9 Jul 2003 07:53:17 -0000 1.16
+++ serendipity_config.inc.php 9 Jul 2003 17:52:00 -0000 1.17
@@ -45,6 +45,11 @@
$serendipity[$row['name']] = isset($translation[$row['value']]) ? $translation[$row['value']] : $row['value'];
}
+// defaults for newly added configuration directives. Should be removed after first release.
+if (!isset($serendipity['indexFile'])) {
+ $serendipity['indexFile'] = 'index.php';
+}
+
// Load basic language information
include_once("{$serendipity['serendipityPath']}/serendipity_lang_{$serendipity['lang']}.inc.php");
if (serendipity_LANG_LOADED !== true) {
Index: serendipity_config_local.tpl
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_config_local.tpl,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- serendipity_config_local.tpl 8 Jul 2003 09:13:27 -0000 1.9
+++ serendipity_config_local.tpl 9 Jul 2003 17:52:00 -0000 1.10
@@ -15,6 +15,7 @@
$serendipity['templatePath'] = '{Relative template path|templatePath|string|templates/}'; // The path to the folder containing your templates - Relative to the 'relative path'
$serendipity['uploadHTTPPath'] = '{Relative upload path|uploadHTTPPath|string|uploads/}'; // Path to your uploads for browsers - Relative to the 'relative path'.
$serendipity['baseURL'] = '{URL to blog|baseURL|string|http://www.example.com/serendipity/}'; // Base URL to your serendipity installation
+$serendipity['indexFile'] = '{Index file|indexFile|string|index.php}'; // Which file to use as index
// General settings
$serendipity['user'] = '{Admin username|user|string|John Doe}'; // Username for admin login
@@ -24,6 +25,7 @@
$serendipity['extCSS'] = '{External Stylesheet|extCSS|string|none}'; // You can define a stylesheet uri here, aditionally to the settings adjustable in the admin interface (enter 'none' if you don't need this)
$serendipity['wysiwyg'] = '{Use WYSIWYG editor|wysiwyg|bool|0}'; // Do you want to use the WYSIWYG editor (CAUTION: only turn this on if you use Microsoft's Internet Explorer!!!)?
$serendipity['XHTML11'] = '{Force XHTML 1.1 compliance|XHTML11|bool|0}'; // Do you want to force XHTML 1.1 compliance (may cause problems for back-/frontend on older 4th generation browsers)
+$serendipity['embed'] = '{Is serendipity embedded?|embed|bool|0}'; // If you want to embed serendipity within a regular page, set to true to discard any headers and just print the contents. You can make use of the indexFile option to use a wrapper class where you put your normal webpage headers.
$serendipity['blogTitle'] = '{Blog name|blogTitle|string|John Doe\'s personal blog}'; // The title of your blog
$serendipity['blogDescription'] = '{Blog description|blogDescription|string|Welcome to my blog...}'; // Description of your blog
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -d -r1.101 -r1.102
--- serendipity_functions.inc.php 8 Jul 2003 13:51:19 -0000 1.101
+++ serendipity_functions.inc.php 9 Jul 2003 17:52:00 -0000 1.102
@@ -7,19 +7,19 @@
function serendipity_getTemplateFile($file) {
global $serendipity;
- if ( file_exists($serendipity['templatePath'] . $serendipity['CONFIG']['template'] . '/'. $file) ) {
+ if ( file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['CONFIG']['template'] . '/'. $file) ) {
return $serendipity['serendipityHTTPPath'] . $serendipity['templatePath'] . $serendipity['CONFIG']['template'] . '/' . $file;
}
- if ( file_exists($serendipity['templatePath'] . 'default/'. $file) ) {
+ if ( file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . 'default/'. $file) ) {
return $serendipity['serendipityHTTPPath'] . $serendipity['templatePath'] . 'default/' . $file;
}
}
function serendipity_fetchTemplates() {
global $serendipity;
- $dir = opendir($serendipity['templatePath']);
+ $dir = opendir($serendipity['serendipityPath'] . $serendipity['templatePath']);
while ( ($file = readdir($dir)) !== false ) {
- if ( is_dir($serendipity['templatePath'] . $file) && !ereg('^(\.|CVS)', $file) ) {
+ if ( is_dir($serendipity['serendipityPath'] . $serendipity['templatePath'] . $file) && !ereg('^(\.|CVS)', $file) ) {
$rv[] = $file;
}
}
@@ -29,7 +29,7 @@
function serendipity_fetchTemplateInfo($theme) {
global $serendipity;
/* Blame jannis */
- $lines = file($serendipity['templatePath'] . $theme . '/info.txt');
+ $lines = file($serendipity['serendipityPath'] . $serendipity['templatePath'] . $theme . '/info.txt');
for($x=0; $x<count($lines); $x++) {
$j = preg_split('/([^\:]+)\:/', $lines[$x], -1, PREG_SPLIT_DELIM_CAPTURE);
@@ -61,7 +61,7 @@
<?php
foreach ($themelist as $theme) {
$info = serendipity_fetchTemplateInfo($theme);
- if ( file_exists($serendipity['templatePath'] . $theme . '/preview.png') ) {
+ if ( file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $theme . '/preview.png') ) {
$preview = '<img src="templates/' . $theme . '/preview.png" width="100" style="border: 1px #000000 solid" />';
} else {
$preview = ' ';
@@ -228,14 +228,14 @@
<table width="100%" class='serendipity_calendar' cellspacing="1">
<tr>
<td align="left" class="serendipity_calendarHeader">
- <a title="<?php echo BACK; ?>" href="<?php echo $serendipity['serendipityHTTPPath']; ?>index.php?serendipity[calendarZoom]=<?php echo $previousYear . sprintf('%02d',$previousMonth); ?>"><img alt="<?php echo BACK; ?>" src="<?php echo serendipity_getTemplateFile('img/back.png'); ?>" border="0" /></a></td>
+ <a title="<?php echo BACK; ?>" href="<?php echo $serendipity['serendipityHTTPPath'] . $serendipity['indexFile']; ?>?serendipity[calendarZoom]=<?php echo $previousYear . sprintf('%02d',$previousMonth); ?>"><img alt="<?php echo BACK; ?>" src="<?php echo serendipity_getTemplateFile('img/back.png'); ?>" border="0" /></a></td>
<td colspan="5" align="center" valign="bottom" class="serendipity_calendarHeader">
<b><nobr><a href="<?php echo $link; ?>"><?php echo $serendipity["months"][$month] . ' \'' . substr($year, 2); ?></a></nobr></b>
</td>
<td align="right" class="serendipity_calendarHeader">
- <a title="<?php echo FORWARD; ?>"href="<?php echo $serendipity['serendipityHTTPPath']; ?>index.php?serendipity[calendarZoom]=<?php echo $nextYear . sprintf('%02d', $nextMonth); ?>"><img alt="<?php echo FORWARD; ?>" src="<?php echo serendipity_getTemplateFile('img/forward.png'); ?>" border="0" /></a></td>
+ <a title="<?php echo FORWARD; ?>" href="<?php echo $serendipity['serendipityHTTPPath'] . $serendipity['indexFile']; ?>?serendipity[calendarZoom]=<?php echo $nextYear . sprintf('%02d', $nextMonth); ?>"><img alt="<?php echo FORWARD; ?>" src="<?php echo serendipity_getTemplateFile('img/forward.png'); ?>" border="0" /></a></td>
</tr>
<tr>
Index: serendipity_genpage.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_genpage.inc.php,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- serendipity_genpage.inc.php 8 Jul 2003 12:14:17 -0000 1.12
+++ serendipity_genpage.inc.php 9 Jul 2003 17:52:00 -0000 1.13
@@ -1,4 +1,7 @@
-<?php # $Id$ ?>
+<?php # $Id$
+if (!$serendipity['embed']) {
+ // serendipity is embedded into an existing structure. No need to output headers then.
+?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
@@ -8,28 +11,33 @@
<link rel="alternate" type="application/rss+xml" title="RSS" href="<?php echo $serendipity['baseURL']; ?>feeds/index.rss" />
<script language="Javascript" type="text/javascript" src="<?php echo $serendipity['serendipityHTTPPath']; ?>serendipity.js"></script>
<?php
- if (strtolower($serendipity['extCSS'])!='none') {
+ if (strtolower($serendipity['extCSS'])!='none') {
?>
<style type="text/css">@import <?php echo $serendipity['extCSS']; ?>";</style>
<?php
- }
+ }
?>
</head>
<body>
<?php
+} // end if (is serendipity embedded?)
+
include_once('serendipity_config.inc.php');
include_once('serendipity_plugin_api.php');
include_once('serendipity_sidebar_items.php');
if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . serendipity_get_config_var('template', 'default') . '/layout.php')) {
- include $serendipity['templatePath'] . serendipity_get_config_var('template', 'default') . '/layout.php';
+ include $serendipity['serendipityPath'] . $serendipity['templatePath'] . serendipity_get_config_var('template', 'default') . '/layout.php';
} else {
- include $serendipity['templatePath'] . 'default/layout.php';
+ include $serendipity['serendipityPath'] . $serendipity['templatePath'] . 'default/layout.php';
}
+
+if (!$serendipity['embed']) {
?>
</body>
</html>
<?php
+}
/* vim: set sts=4 ts=4 expandtab : */
?>
|