Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1:/tmp/cvs-serv6792
Modified Files:
db.sql serendipity.css.php serendipity_admin.php
serendipity_config_local.tpl serendipity_functions.inc.php
serendipity_genpage.inc.php
Log Message:
The big update, we now have much better template management and some minor tweeks
Index: db.sql
===================================================================
RCS file: /cvsroot/php-blog/serendipity/db.sql,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- db.sql 7 Apr 2003 05:52:17 -0000 1.14
+++ db.sql 22 Jun 2003 18:06:52 -0000 1.15
@@ -92,16 +92,6 @@
PRIMARY KEY (host,day,entry_id)
);
-#
-# Table structure for table 'serendipity_css'
-#
-
-CREATE TABLE {PREFIX}css (
- cssid {AUTOINCREMENT},
- name varchar(40) default NULL,
- data text
-);
-
create table {PREFIX}config (
name varchar(255) not null primary key,
value text not null
Index: serendipity.css.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity.css.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- serendipity.css.php 29 Apr 2003 20:58:18 -0000 1.3
+++ serendipity.css.php 22 Jun 2003 18:06:52 -0000 1.4
@@ -1,11 +1,11 @@
<?php
header("Content-type: text/css");
session_start();
-if (!file_exists("./serendipity_config_local.inc.php")) {
- readfile('serendipity.css');
+include("serendipity_config.inc.php");
+if ( file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . serendipity_get_config_var('template', 'default') ."/style.css") ) {
+ readfile ($serendipity['templatePath'] . serendipity_get_config_var('template', 'default') ."/style.css");
} else {
- include_once("serendipity_config.inc.php");
- $css = serendipity_getCSS($_REQUEST['style']);
- echo $css['data'];
+ readfile ($serendipity['templatePath'] ."default/style.css");
}
+
?>
Index: serendipity_admin.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin.php,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- serendipity_admin.php 18 Jun 2003 13:56:58 -0000 1.10
+++ serendipity_admin.php 22 Jun 2003 18:06:52 -0000 1.11
@@ -63,7 +63,7 @@
<div class="serendipitySideBarItem">
<div class="serendipitySideBarTitle"><?=APPEARANCE?>:</div>
<div class="serendipitySideBarContent">
- • <a href='?serendipity[adminModule]=css'><?=MANAGE_CSS?></a><br>
+ • <a href='?serendipity[adminModule]=templates'><?=MANAGE_STYLES?></a><br>
• <a href='?serendipity[adminModule]=plugins'><?=CONFIGURE_PLUGINS?></a><br>
</div>
</div>
@@ -93,8 +93,8 @@
include("serendipity_admin_images.inc.php");
break;
- case "css":
- include("serendipity_admin_css.inc.php");
+ case "templates":
+ include("serendipity_admin_templates.inc.php");
break;
case "plugins":
Index: serendipity_config_local.tpl
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_config_local.tpl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- serendipity_config_local.tpl 16 Jun 2003 00:33:56 -0000 1.5
+++ serendipity_config_local.tpl 22 Jun 2003 18:06:52 -0000 1.6
@@ -12,6 +12,7 @@
$serendipity["serendipityPath"] = "{Full path|serendipityPath|string|/webroot/serendipity/}"; // The full and aboslute path to your serendipity installation.
$serendipity["uploadPath"] = "{Upload path|uploadPath|string|uploads/}"; // All uploads will go here, relative to the 'Full path' - typically 'uploads/'
$serendipity["serendipityHTTPPath"] = "{Relative path|serendipityHTTPPath|string|/serendipity/}"; // Path to serendipity for your browser, typically '/serendipity/'
+$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
@@ -19,19 +20,17 @@
$serendipity["user"] = "{Admin username|user|string|John Doe}"; // Username for admin login
$serendipity["pass"] = "{Admin password|pass|protected|john}"; // Password for admin login
$serendipity["email"] = "{Admin email|email|string|j}"; // Email for admin login
-$serendipity["want_mail"] = "{Send mails to admin?|want_mail|bool|true}"; // Do you want to receive emails when comments are posted to your serendipity?
+$serendipity["want_mail"] = "{Send mails to admin?|want_mail|bool|true}"; // Do you want to receive emails when comments are posted to your entries?
$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?
-$serendipity["layout_mode"] = "{Template file?|layout_mode|string|table}"; // Layout mode (table is default)
-$serendipity["blogTitle"] = "{Blog name|blogTitle|string|Foo Bar}"; // The title of your blog
-$serendipity["blogDescription"] = "{Blog description|blogDescription|string|Welcome to Foobarblog}"; // Description of your blog
+$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
$serendipity["lang"] = "{Language file|lang|string|en}"; // Language (for 'en' you need serendipity_lang_en.inc.php).
-$serendipity["rewrite"] = "{Use mod_rewrite|rewrite|bool|true}"; // Is mod_rewrite activated? Can we use 20030201.html?
$serendipity["track_exits"] = "{Track exit URLs|track_exits|bool|1}"; // Do you want to track exit targets?
// Imageconversion Settings
-$serendipity["magick"] = "{Use Imagemagick|magick|bool|true}"; // Do you have image magick installed
+$serendipity["magick"] = "{Use Imagemagick|magick|bool|0}"; // Do you have image magick installed
$serendipity["convert"] = "{Path to convert binary|convert|string|/usr/local/bin/convert}"; // Full path & name of your image magick convert binary
$serendipity["thumbSuffix"] = "{Thumbnail suffix|thumbSuffix|string|serendipityThumb}"; // Thumbnails will be named original.Suffix.ext
$serendipity["thumbSize"] = "{Thumbnail dimensions|thumbSize|int|110}"; // Dimensions of auto-generated thumbnails
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- serendipity_functions.inc.php 22 Jun 2003 16:40:22 -0000 1.73
+++ serendipity_functions.inc.php 22 Jun 2003 18:06:52 -0000 1.74
@@ -1,6 +1,88 @@
<?php
include_once("./serendipity_db.inc.php");
include_once("./compat.php");
+function serendipity_getTemplateFile($file) {
+ global $serendipity;
+ if ( file_exists($serendipity['templatePath'] . $serendipity['CONFIG']['template'] . '/'. $file) ) {
+ return $serendipity['serendipityHTTPPath'] . $serendipity['templatePath'] . $serendipity['CONFIG']['template'] . '/'. $file;
+ }
+ if ( file_exists($serendipity['templatePath'] . 'default/'. $file) ) {
+ return $serendipity['serendipityHTTPPath']. $serendipity['templatePath'] . $serendipity['CONFIG']['template'] . '/'. $file;
+ }
+
+}
+
+function serendipity_fetchTemplates() {
+ global $serendipity;
+ $dir = opendir($serendipity['templatePath']);
+ while ( ($file = readdir($dir)) !== false ) {
+ if ( is_dir($serendipity['templatePath'] . $file) && !ereg("^(\.|CVS)", $file) ) {
+ $rv[] = $file;
+ }
+ }
+ return $rv;
+}
+
+function serendipity_fetchTemplateInfo($theme) {
+ global $serendipity;
+ /* Blame jannis */
+ $lines = file($serendipity['templatePath'] . $theme . "/info.txt");
+ for($x=0; $x<count($lines); $x++) {
+ $j = preg_split("/([^\:]+)\:/", $lines[$x], -1, PREG_SPLIT_DELIM_CAPTURE);
+ if ($j[2]) {
+ $currSec = $j[1];
+ $data[strtolower($currSec)][] = trim($j[2]);
+ } else {
+ $data[strtolower($currSec)][] = trim($j[0]);
+ }
+ }
+ foreach ($data as $k=>$v) {
+ $data[$k] = implode("\n", $v);
+ }
+ return $data;
+}
+
+function serendipity_saveTemplateSelection($theme='default') {
+ serendipity_set_config_var('template', $theme);
+}
+
+function serendipity_printTemplates($themelist) {
+ global $serendipity;
+
+ echo "<form method='post' action='{$serendipity['serendipityHTTPPath']}serendipity_admin.php?serendipity[adminModule]=templates&serendipity[adminAction]=save'>";
+ echo "<table width='100%' class='prettyTable'>";
+ foreach ($themelist as $theme) {
+ $info = serendipity_fetchTemplateInfo($theme);
+ echo "<tr>";
+ echo "<td colspan='3'><strong>";
+ echo $info['name'];
+ echo "</strong></td>";
+ echo "</tr>";
+ echo "<tr>";
+ echo "<td width='100'>";
+ if ( file_exists($serendipity['templatePath'] . $theme . '/preview.png') ) {
+ echo "<img src='templates/$theme/preview.png' width='100' style='border: 1px #000000 solid'>";
+ }
+ echo "</td>";
+ echo "<td valign='top'>";
+ echo "Author: ". $info['author'] . "<br>";
+ echo "Last Updated: ". $info['date'];
+ echo "</td>";
+ echo "<td valign='middle'>";
+ echo "<input type='radio' name='serendipity[theme]' value='$theme' ". ( (serendipity_get_config_var('template', 'default') == $theme) ? 'CHECKED' : '') .">";
+ echo "</td>";
+ echo "</tr>";
+ }
+ echo "<tr>";
+ echo "<td align='right' colspan='3'>";
+ echo "<input type='submit' name='submit' value='Set as template'>";
+ echo "</td>";
+ echo "</tr>";
+ echo "</table>";
+ echo "</form>";
+
+
+}
$serendipity["imageList"] = array();
function serendipity_displayCommentForm($id) {
@@ -107,9 +189,9 @@
// Prepare the table
?>
-<TABLE CLASS='serendipity_calendar' CELLSPACING=0>
+<TABLE width='100%' CLASS='serendipity_calendar' CELLSPACING=0>
<TR>
-<TD ALIGN='left' class='serendipity_calendarHeader'><A HREF='<?= $serendipity['serendipityHTTPPath'] ?>index.php?serendipity[calendarZoom]=<?= $previousYear.sprintf("%02d",$previousMonth)?>'><IMG ALT="<?=BACK?>" SRC='<?= $serendipity["serendipityHTTPPath"] ?>pixel/back.png' BORDER='0'></A></TD>
+<TD ALIGN='left' class='serendipity_calendarHeader'><A HREF='<?= $serendipity['serendipityHTTPPath'] ?>index.php?serendipity[calendarZoom]=<?= $previousYear.sprintf("%02d",$previousMonth)?>'><IMG ALT="<?=BACK?>" SRC='<?= serendipity_getTemplateFile('img/back.png') ?>' BORDER='0'></A></TD>
<TD COLSPAN='5' ALIGN='center' VALIGN='bottom' CLASS='serendipity_calendarHeader'><B><nobr>
<?php
if ($serendipity["rewrite"]==true) {
@@ -123,7 +205,7 @@
</nobr></B></TD>
<TD ALIGN='right' class='serendipity_calendarHeader'>
<A HREF='<?= $serendipity['serendipityHTTPPath'] ?>index.php?serendipity[calendarZoom]=<?= $nextYear.sprintf("%02d",$nextMonth) ?>'>
- <IMG ALT="<?=FORWARD?>" SRC='<?= $serendipity["serendipityHTTPPath"] ?>pixel/forward.png' BORDER='0'>
+ <IMG ALT="<?=FORWARD?>" SRC='<?= serendipity_getTemplateFile('img/forward.png') ?>' BORDER='0'>
</A>
</TD>
</TR>
@@ -1100,27 +1182,6 @@
serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}references WHERE entry_id='$id'");
}
-function serendipity_updateCSS($css) {
- global $serendipity;
-
- $newEntry = 0;
- $exflag = 0;
-
-
- if ($css["cssid"] == 0) {
- unset($css['cssid']);
- $res = serendipity_db_insert('css', $css);
- $newEntry = 1;
- $css['cssid'] = serendipity_db_insert_id();
- } else {
- $res = serendipity_db_update('css', array('cssid' => $css['cssid']), $css);
- }
-
- if (is_string($res)) {
- return $res;
- }
- return (int)$css['cssid'];
-}
/**
* Get a list of images
@@ -1425,107 +1486,6 @@
}
}
-function serendipity_printCSSForm($targetURL, $mode, $hiddens = array(), $entry = null, $errMsg = "") {
- global $serendipity;
-
-
- if ($mode == "edit") {
-
- if ($entry === null || is_numeric($entry)) {
- $css = serendipity_getCSS($entry);
- } else {
- $css = $entry;
- }
-
- } else {
-
- /* list all the defined stylesheets */
- $avail = serendipity_getCSS_avail();
- $default_css = serendipity_get_config_var("default_css", "default");
-
- $avail_options = "";
- foreach ($avail as $cssid => $cssname) {
- $avail_options .= "<option value=\"$cssid\"";
- if ($cssname == $default_css) {
- $avail_options .= " selected";
- $marker = "* ";
- } else {
- $marker = "";
- }
-
-
- $avail_options .= ">$marker" . htmlentities($cssname) . "</option>";
- }
- }
-
- ?>
- <font color="#ff0000"><?=$errMsg?></font>
- <table class='serendipityEntryEdit'>
- <form action='<?=$targetURL?>' method="post" name="serendipityCSS">
- <?php
- foreach($hiddens as $key => $value) {
- echo "<input type='hidden' name='$key' value='$value'>\n";
- }
-
- if ($mode == "edit") {
- echo "<input type='hidden' name='serendipity[cssid]' value='{$css[cssid]}'>\n";
- ?>
- <tr>
- <td align="left"><?=TEMPLATE_NAME?></td>
- </tr>
- <tr>
- <td align="left">
- <input type="text" name="serendipity[name]" value="<?=htmlentities($css[name])?>" size=40>
- </td>
- </tr>
- <tr>
- <td colspan="2">CSS</td>
- </tr>
- <tr>
- <td colspan="2">
- <textarea name="serendipity[data]" cols=80 rows=20><?=htmlentities($css["data"])?></textarea>
- </td>
- </tr>
- <tr>
- <td colspan="2" align="right">
- <input type="submit" value="<?=SAVE?>">
- </td>
- </tr>
- <?php
- } else { /* admin */
- ?>
- <tr>
- <td><?=CHOOSE_STYLESHEET?></td>
- </tr>
- <tr>
- <td align="left">
- <select name="serendipity[cssid]"><?= $avail_options ?></select>
- </td>
- </tr>
- <tr>
- <td>
- <input type="submit" name="EDIT" value="<?=EDIT?>">
- <input type="submit" name="DELETE" value="<?=DELETE?>">
- <input type="submit" name="DEFAULT" value="<?=MAKE_DEFAULT?>">
- </td>
- </tr>
- <tr>
- <td>
- <input type="submit" name="NEW" value="<?=CREATE_NEW_STYLESHEET?>">
- </td>
- </tr>
-
-
- <?php
-
- }
-
- ?>
- </form>
- </table>
- <?php
-}
-
function serendipity_authenticate_author($username, $password) {
global $serendipity;
@@ -1702,43 +1662,11 @@
function serendipity_get_config_var($name, $defval = false) {
global $serendipity;
- $name = serendipity_db_escape_string($name);
- $c = serendipity_db_query("SELECT value from $serendipity[dbPrefix]config where name='$name'", true);
- if (is_array($c)) {
- return $c[0];
- }
- return $defval;
-}
-
-function serendipity_getCSS_avail() {
- global $serendipity;
-
- $names = array();
-
- $query = "SELECT cssid, name FROM $serendipity[dbPrefix]css ORDER BY name";
- $rows = serendipity_db_query($query);
- foreach ($rows as $row) {
- $names[$row['cssid']] = $row['name'];
- }
- return $names;
-
-}
-
-function serendipity_getCSS($name = null) {
- global $serendipity;
-
- if (is_numeric($name)) {
- $query = "select * from $serendipity[dbPrefix]css where cssid = '$name'";
+ if ( isset($serendipity['CONFIG'][$name]) ) {
+ return $serendipity['CONFIG'][$name];
} else {
- if ($name === null) {
- $name = serendipity_get_config_var("default_css", "default");
- }
- $query = "select * from $serendipity[dbPrefix]css where name = '$name'";
+ return $defval;
}
-
- $qh = serendipity_db_query($query, true);
-
- return $qh;
}
function serendipity_emit_htmlarea_code($item)
Index: serendipity_genpage.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_genpage.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- serendipity_genpage.inc.php 28 Mar 2003 20:05:25 -0000 1.1.1.1
+++ serendipity_genpage.inc.php 22 Jun 2003 18:06:52 -0000 1.2
@@ -9,10 +9,10 @@
<body>
<?php
-if (isset($serendipity['layout_mode']) && file_exists($serendipity['serendipityPath'] . "serendipity_layout_" . $serendipity['layout_mode'] . '.inc.php')) {
- include "serendipity_layout_" . $serendipity['layout_mode'] . '.inc.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";
} else {
- include ("serendipity_layout.inc.php");
+ include ($serendipity['templatePath'] ."default/layout.php");
}
?>
</body>
|