Update of /cvsroot/php-blog/jBlog
In directory sc8-pr-cvs1:/tmp/cvs-serv23662
Modified Files:
db.sql htaccess.tpl index.php jBlog.css
jBlog_admin_entries.inc.php jBlog_functions.inc.php
jBlog_genpage.php jBlog_layout.php
Log Message:
added support for 'extended entries'
some code cleanup
some aesthetic changes to titles
Index: db.sql
===================================================================
RCS file: /cvsroot/php-blog/jBlog/db.sql,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- db.sql 27 Feb 2003 16:55:34 -0000 1.1.1.1
+++ db.sql 4 Mar 2003 00:43:58 -0000 1.2
@@ -1,3 +1,3 @@
-CREATE TABLE {PREFIX}entries (id int(10) unsigned NOT NULL auto_increment, title varchar(200) default NULL, timestamp int(10) unsigned default NULL, body text, comments int (4) unsigned default 0, PRIMARY KEY (id), FULLTEXT (title,body)) TYPE=MyISAM
+CREATE TABLE {PREFIX}entries (id int(10) unsigned NOT NULL auto_increment, title varchar(200) default NULL, timestamp int(10) unsigned default NULL, body text, comments int (4) unsigned default 0, extended text, exflag int(1), PRIMARY KEY (id), FULLTEXT (title,body,extended)) TYPE=MyISAM
CREATE TABLE {PREFIX}comments (id int(10) unsigned NOT NULL auto_increment, entry_id int(10) unsigned NOT NULL, timestamp int(10) unsigned default NULL, title VARCHAR(150), author VARCHAR(80), email VARCHAR(200), url VARCHAR(200), ip VARCHAR(15), body text, type enum ('TRACKBACK', 'REGULAR'), PRIMARY KEY (id), FULLTEXT (body))
CREATE TABLE {PREFIX}references ( id int(10) unsigned not null auto_increment, entry_id int(10) unsigned not null, link text, name text, PRIMARY KEY(id))
Index: htaccess.tpl
===================================================================
RCS file: /cvsroot/php-blog/jBlog/htaccess.tpl,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- htaccess.tpl 27 Feb 2003 16:55:34 -0000 1.1.1.1
+++ htaccess.tpl 4 Mar 2003 00:43:58 -0000 1.2
@@ -1 +1 @@
-ErrorDocument 404 {PREFIX}index.php
+ErrorDocument 404 /index.php
Index: index.php
===================================================================
RCS file: /cvsroot/php-blog/jBlog/index.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- index.php 1 Mar 2003 20:49:29 -0000 1.3
+++ index.php 4 Mar 2003 00:43:58 -0000 1.4
@@ -15,7 +15,7 @@
$date = date("d/m/Y", strtotime($range));
}
- $jBlog['blogTitle'] = $jBlog['blogTitle'] . ": Entries for $date";
+ $jBlog['blogSubTitle'] = "Entries for $date";
ob_start();
include_once("jBlog_genpage.php");
$data = ob_get_contents();
@@ -38,7 +38,7 @@
$title = mysql_fetch_row($cursor);
$title = $title[0];
- $jBlog['blogTitle'] = $jBlog['blogTitle'] . ": $title";
+ $jBlog['blogSubTitle'] = $title;
ob_start();
include_once("jBlog_genpage.php");
Index: jBlog.css
===================================================================
RCS file: /cvsroot/php-blog/jBlog/jBlog.css,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- jBlog.css 27 Feb 2003 16:55:34 -0000 1.1.1.1
+++ jBlog.css 4 Mar 2003 00:43:58 -0000 1.2
@@ -2,6 +2,20 @@
background: #d4dce8;
}
+.jBlog_banner {
+ font-size: 30px;
+ color: #1a3c5a;
+ border: 0px;
+ padding-left: 5px;
+}
+
+.jBlog_subbanner {
+ font-size: 20px;
+ color: #1a3c5a;
+ border: 0px;
+ padding-left: 5px;
+}
+
.jBlog_title {
font-size: 20px;
color: #1a3c5a;
Index: jBlog_admin_entries.inc.php
===================================================================
RCS file: /cvsroot/php-blog/jBlog/jBlog_admin_entries.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- jBlog_admin_entries.inc.php 27 Feb 2003 16:55:35 -0000 1.1.1.1
+++ jBlog_admin_entries.inc.php 4 Mar 2003 00:43:58 -0000 1.2
@@ -39,23 +39,23 @@
// Print the entries
for ($x=0; $x<$half; $x++) {
- echo "<tr>";
- echo "<td>";
- echo date("d.m.y, H:i", $entries[$x]["timestamp"]).": ";
- echo "<br><a href='?jBlog[action]=admin&jBlog[adminModule]=entries&jBlog[adminAction]=$action";
- echo "&jBlog[id]=".$entries[$x]["id"]."'>";
- echo htmlentities(substr($entries[$x]["title"],0,40))."</a>";
- echo "</a>";
- echo "</td>";
- echo "<td>".str_repeat(" ", 7)."</td>";
- echo "<td>";
- echo date("d.m.y, H:i", $entries[$x+$half]["timestamp"]).": ";
- echo "<br><a href='?jBlog[action]=admin&jBlog[adminModule]=entries&jBlog[adminAction]=$action";
- echo "&jBlog[id]=".$entries[$x+$half]["id"]."'>";
- echo htmlentities(substr($entries[$x+$half]["title"],0,40))."</a>";
- echo "</a>";
- echo "</td>";
- echo "</tr>";
+ ?>
+ <tr>
+ <td>
+ <?= date("d.m.y, H:i", $entries[$x]["timestamp"]).": " ?>
+ <br><a href='?jBlog[action]=admin&jBlog[adminModule]=entries&jBlog[adminAction]=<?= $action ?>&jBlog[id]=<?= $entries[$x]["id"] ?>'>
+ <?= htmlentities(substr($entries[$x]["title"],0,40)) ?></a>
+ </a>
+ </td>
+ <td><?= str_repeat(" ", 7)?></td>
+ <td>
+ <?= date("d.m.y, H:i", $entries[$x+$half]["timestamp"]).": "?>
+ <br><a href='?jBlog[action]=admin&jBlog[adminModule]=entries&jBlog[adminAction]=<?= $action ?>&jBlog[id]=<?= $entries[$x+$half]["id"] ?>'>
+ <?= htmlentities(substr($entries[$x+$half]["title"],0,40)) ?></a>
+ </a>
+ </td>
+ </tr>
+<?php
}
echo "</table>";
}
@@ -67,7 +67,8 @@
$entry = array("id" => $jBlog["POST"]["id"],
"title"=>$jBlog["POST"]["title"],
"timestamp" => $jBlog["POST"]["timestamp"],
- "body" =>$jBlog["POST"]["body"]);
+ "body" =>$jBlog["POST"]["body"],
+ "extended" => $jBlog["POST"]["extended"]);
$res = jBlog_updertEntry($entry);
if ($res != "")
jBlog_printEntryForm("?", array("jBlog[action]" => "admin", "jBlog[adminModule]" => "entries",
Index: jBlog_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/jBlog/jBlog_functions.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- jBlog_functions.inc.php 1 Mar 2003 19:34:35 -0000 1.2
+++ jBlog_functions.inc.php 4 Mar 2003 00:43:58 -0000 1.3
@@ -85,19 +85,30 @@
}
// Prepare the table
- print ("<TABLE CLASS='jBlog_calendar' CELLSPACING=0>");
- print ("<TR>");
- print ("<TD ALIGN='left'><A HREF='{$jBlog['jBlogHTTPPath']}index.php?jBlog[calendarZoom]=$previousYear".sprintf("%02d",$previousMonth)."'><IMG SRC='".$jBlog["jBlogHTTPPath"]."pixel/back.png' BORDER='0'></A></TD>");
- print ("<TD COLSPAN='5' ALIGN='center' VALIGN='bottom' CLASS='calendarHeader'><B><nobr>");
- if ($jBlog["rewrite"]==true)
+?>
+<TABLE CLASS='jBlog_calendar' CELLSPACING=0>
+<TR>
+<TD ALIGN='left'><A HREF='<?= $jBlog['jBlogHTTPPath'] ?>index.php?jBlog[calendarZoom]=<?= $previousYear.sprintf("%02d",$previousMonth)?>'><IMG SRC='<?= $jBlog["jBlogHTTPPath"] ?>pixel/back.png' BORDER='0'></A></TD>
+<TD COLSPAN='5' ALIGN='center' VALIGN='bottom' CLASS='calendarHeader'><B><nobr>
+<?php
+ if ($jBlog["rewrite"]==true) {
$link = $jBlog["jBlogHTTPPath"]."archives/d_".$year.sprintf("%02d",$month).".html";
- else
+ }
+ else {
$link = "fixme";
- print ("<a href='$link'>".$jBlog["months"][$month]." '".substr($year, 2)."</a>");
- print ("</nobr></B></TD>");
- print ("<TD ALIGN='right'><A HREF='{$jBlog['jBlogHTTPPath']}/index.php?jBlog[calendarZoom]=$nextYear".sprintf("%02d",$nextMonth)."'><IMG SRC='".$jBlog["jBlogHTTPPath"]."pixel/forward.png' BORDER='0'></a></TD>");
- print ("</TR>");
- print ("<TR><TD CLASS='jBlog_weekDayName' ALIGN='center'>".implode("</TD><TD CLASS='jBlog_weekDayName' ALIGN='center'>", $jBlog["weekDayAbb"])."</TD>");
+ }
+?>
+<a href='<?= $link ?>'><?= $jBlog["months"][$month]." '".substr($year, 2) ?></a>
+</nobr></B></TD>
+<TD ALIGN='right'>
+ <A HREF='<?= $jBlog['jBlogHTTPPath'] ?>/index.php?jBlog[calendarZoom]=<?= $nextYear.sprintf("%02d",$nextMonth) ?>'>
+ <IMG SRC='<?= $jBlog["jBlogHTTPPath"] ?>pixel/forward.png' BORDER='0'>
+ </A>
+</TD>
+</TR>
+<TR><TD CLASS='jBlog_weekDayName' ALIGN='center'><?= implode("</TD><TD CLASS='jBlog_weekDayName' ALIGN='center'>", $jBlog["weekDayAbb"])?>
+</TD>
+<?php
// Print the calendar
$currDay = 1;
@@ -152,7 +163,7 @@
$where = "";
if ($full === true)
- $body = ',body';
+ $body = ',body, extended';
if (is_numeric($range)) {
$where = "WHERE FROM_UNIXTIME(timestamp, '%Y%m%d') LIKE '$range%' ";
@@ -162,7 +173,7 @@
$limit = "LIMIT $limit";
}
- $query = "SELECT id,timestamp,comments,title{$body} FROM {$jBlog['dbPrefix']}entries " . $where .
+ $query = "SELECT * FROM {$jBlog['dbPrefix']}entries " . $where .
"ORDER BY timestamp DESC $limit";
$cursor = mysql_db_query($jBlog["dbName"], $query);
@@ -170,12 +181,14 @@
die("Query failed: " . mysql_error() . "\n");
}
- while($row = mysql_fetch_row($cursor)) {
- $ret[] = array("id" => $row[0],
- "timestamp" => $row[1],
- "comments" => $row[2],
- "title" => $row[3],
- "body" => $row[4]);
+ while($row = mysql_fetch_assoc($cursor)) {
+ $ret[] = array("id" => $row['id'],
+ "timestamp" => $row['timestamp'],
+ "comments" => $row['comments'],
+ "title" => $row['title'],
+ "body" => $row['body'],
+ "extended" => $row['extended'],
+ "exflag" => $row['exflag']);
}
return $ret;
@@ -187,12 +200,12 @@
function jBlog_fetchEntry($key, $val, $full = true) {
global $jBlog;
- if ($full === true) $body = ", body";
- $querystring = "SELECT id, timestamp, comments, title$body FROM ".$jBlog["dbPrefix"]."entries
+ if ($full === true) $body = ", body, extended";
+ $querystring = "SELECT * FROM ".$jBlog["dbPrefix"]."entries
WHERE $key LIKE $val LIMIT 1";
$query = mysql_db_query($jBlog["dbName"], $querystring);
- return mysql_fetch_array($query);
+ return mysql_fetch_assoc($query);
}
/**
@@ -204,15 +217,16 @@
if (strlen($term)<4)
return false;
- $querystring = "SELECT id, timestamp, comments, title, body FROM ".$jBlog["dbPrefix"]."entries
- WHERE MATCH (title, body) AGAINST ('".addslashes($term)."') ORDER BY timestamp DESC";
+ $querystring = "SELECT id, timestamp, comments, title, body, extended FROM ".$jBlog["dbPrefix"]."entries
+ WHERE MATCH (title, extended) AGAINST ('".addslashes($term)."') ORDER BY timestamp DESC";
$query = mysql_db_query($jBlog["dbName"], $querystring);
while($row = mysql_fetch_row($query)) {
$ret[] = array("id" => $row[0],
"timestamp" => $row[1],
"comments" => $row[2],
"title" => $row[3],
- "body" => $row[4]);
+ "body" => $row[4],
+ "extended" => $row[5]);
}
return $ret;
@@ -222,7 +236,7 @@
/**
* Prints the entries you fetched with jBlog_fetchEntries/searchEntries in HTML.
**/
-function jBlog_printEntries($entries) {
+function jBlog_printEntries($entries, $extended=0) {
global $jBlog;
if ($entries !== false) {
@@ -237,7 +251,18 @@
echo $entries[$x]["title"];
echo "</span>";
echo "<div class='jBlog_entry'>";
- echo nl2br(jBlog_emoticate(jBlog_markup_text($entries[$x]["body"])));
+ if($extended) {
+ echo nl2br(jBlog_emoticate(jBlog_markup_text($entries[$x]["extended"])));
+ } else {
+ echo nl2br(jBlog_emoticate(jBlog_markup_text($entries[$x]["body"])));
+ }
+ if($entries[$x]["exflag"] && !$extended) {
+ ?>
+ <div class='jBlog_time'><br>
+ <a href="<?= $jBlog['jBlogHTTPPath'] ?>archives/e_<?= $entries[$x]['id'] ?>.html">View Extended Entry</a>
+ </div><br>
+ <?php
+ }
echo "<div class='jBlog_time'><br>";
echo "<a href=\"{$jBlog['jBlogHTTPPath']}archives/e_{$entries[$x]['id']}.html\">Posted by ".$jBlog["user"]." at ";
echo date("H:i", $entries[$x]["timestamp"]);
@@ -625,22 +650,33 @@
global $jBlog;
$newEntry = 0;
+ $exflag = 0;
if (!is_numeric($entry["id"])) $entry["id"] = "NULL";
if (!is_numeric($entry["timestamp"])) $entry["timestamp"] = time();
-
- $querystring = "REPLACE INTO ".$jBlog["dbPrefix"]."entries VALUES (
+ if(!preg_match("/\S/", $entry["extended"])) {
+ $entry["extended"] = $entry["body"];
+ } else {
+ if($entry["extended"] !== $entry["body"]) {
+ $exflag = 1;
+ }
+ }
+ $querystring = "REPLACE INTO ".$jBlog["dbPrefix"]."entries
+ (id, title, timestamp, body, extended, comments, exflag)
+ VALUES (
".$entry["id"].",
'".mysql_escape_string($entry["title"])."',
".$entry["timestamp"].",
- '".mysql_escape_string($entry["body"])."', 0)";
+ '".mysql_escape_string($entry["body"])."',
+ '".mysql_escape_string($entry["extended"])."',
+ 0, $exflag)";
$query = mysql_db_query($jBlog["dbName"], $querystring);
if ($entry['id'] == "NULL") {
$newEntry = 1;
$entry['id'] = mysql_insert_id();
}
- jBlog_handle_references($entry['id'], $jBlog['blogTitle'], $entry['title'], $entry['body'], $newEntry);
+ jBlog_handle_references($entry['id'], $jBlog['blogTitle'], $entry['title'], $entry['extended'], $newEntry);
jBlog_purgeEntry($entry['id'], $entry['timestamp']);
@@ -816,9 +852,20 @@
<input type="button" value="Link" onClick="jBlog_insLink(document.forms['entry']['jBlog[body]'])">
</td>
</tr>
+ <tr>
+ <td colspan="2">Entry Body</td>
+ </tr>
<tr>
<td colspan="2">
<textarea name="jBlog[body]" cols=80 rows=20><?=htmlentities($entry["body"])?></textarea>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">Extended Body</td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <textarea name="jBlog[extended]" cols=80 rows=20><?=htmlentities($entry["extended"])?></textarea>
</td>
</tr>
<tr>
Index: jBlog_genpage.php
===================================================================
RCS file: /cvsroot/php-blog/jBlog/jBlog_genpage.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- jBlog_genpage.php 27 Feb 2003 16:55:35 -0000 1.1.1.1
+++ jBlog_genpage.php 4 Mar 2003 00:43:58 -0000 1.2
@@ -1,27 +1,8 @@
<?php
+
?><html><head><title><?=$jBlog['blogTitle']?></title>
<link rel="stylesheet" type="text/css" href="<?=$jBlog['jBlogHTTPPath']?>jBlog.css">
<link rel="alternate" type="application/rss+xml" title="RSS" href="<?=$jBlog['baseURL']?>feeds/index.rss" />
-<style type="text/css">
-<!--
-.body {
- font-family: Tahoma, Verdana, Arial;
-}
-
-.td {
- font-family: Tahoma, Verdana, Arial;
- }
-
-.input {
- width:100px;
- font-size:12px;
- font-family: Tahoma, Verdana, Arial;
- background: #cdcdcd;
-
-
-}
-//-->
-</style>
<body>
<?php
include ("jBlog_layout.php");
Index: jBlog_layout.php
===================================================================
RCS file: /cvsroot/php-blog/jBlog/jBlog_layout.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- jBlog_layout.php 1 Mar 2003 20:49:29 -0000 1.2
+++ jBlog_layout.php 4 Mar 2003 00:43:58 -0000 1.3
@@ -15,6 +15,30 @@
// file in your own layout. This is just to demonstrate, how to use the
// API (e.g. how do I draw the calendar, fetch blog entries, etc...)
?>
+<table class="jBlog_banner" cellpadding="0">
+ <tr>
+ <td>
+ <?= $jBlog['blogTitle'] ?>
+ </td>
+ </tr>
+ <tr>
+<?php
+ if($jBlog['blogSubTitle']) {
+?>
+ <td class="jBlog_subbanner">
+ <?= $jBlog['blogSubTitle'] ?>
+ </td>
+<?php
+ } else {
+?>
+ <td class="jBlog_subbanner">
+ <?= $jBlog['blogDescription'] ?>
+ </td>
+ </tr>
+<?php
+ }
+?>
+</table>
<table class="jBlog" cellpadding="20">
<tr>
<td class="jBlogGreyBox" valign="top">
@@ -28,7 +52,7 @@
// User wants to read the diary
case "read":
if (isset($jBlog['GET']['id'])) {
- jBlog_printEntries(array(jBlog_fetchEntry("id", $jBlog['GET']['id'])));
+ jBlog_printEntries(array(jBlog_fetchEntry("id", $jBlog['GET']['id'])), 1);
} else {
jBlog_printEntries(jBlog_fetchEntries($jBlog["GET"]["range"]));
}
|