Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv533
Modified Files:
Tag: branch-smarty
serendipity_functions.inc.php serendipity_genpage.inc.php
index.php serendipity_config.inc.php
Log Message:
initial smarty work
Index: serendipity_config.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_config.inc.php,v
retrieving revision 1.93
retrieving revision 1.93.2.1
diff -u -d -r1.93 -r1.93.2.1
--- serendipity_config.inc.php 6 Sep 2004 10:08:55 -0000 1.93
+++ serendipity_config.inc.php 9 Sep 2004 15:02:15 -0000 1.93.2.1
@@ -9,7 +9,7 @@
define('IS_installed', file_exists('serendipity_config_local.inc.php'));
-if ( IS_installed === true ) {
+if (IS_installed === true) {
define('IN_serendipity', true);
}
@@ -220,7 +220,22 @@
$serendipity['mailheaders'] = 'X-Mailer: Serendipity/'. $serendipity['version'] . "\n"
. 'X-Engine: PHP/'. phpversion();
+
+define('SMARTY_DIR', $serendipity['serendipityPath'] . 'bundled-libs/Smarty/libs/');
+require_once SMARTY_DIR . 'Smarty.class.php';
+$serendipity['smarty'] = new Smarty;
serendipity_plugin_api::hook_event('frontend_configure', $serendipity);
+$serendipity['smarty']->template_dir = dirname(serendipity_getTemplateFile('index.tpl', 'serendipityPath'));
+$serendipity['smarty']->compile_dir = $serendipity['serendipityPath'] . 'templates_c';
+$serendipity['smarty']->config_dir =& $serendipity['smarty']->template_dir;
+$serendipity['smarty']->secure_dir =& $serendipity['smarty']->template_dir;
+$serendipity['smarty']->security = true;
+
+$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('printf', 'serendipity_printf');
+$serendipity['smarty']->register_modifier('formatTime', 'serendipity_smarty_formatTime');
/* vim: set sts=4 ts=4 expandtab : */
?>
Index: serendipity_genpage.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_genpage.inc.php,v
retrieving revision 1.33
retrieving revision 1.33.2.1
diff -u -d -r1.33 -r1.33.2.1
--- serendipity_genpage.inc.php 27 Jul 2004 21:02:17 -0000 1.33
+++ serendipity_genpage.inc.php 9 Sep 2004 15:02:15 -0000 1.33.2.1
@@ -1,52 +1,59 @@
<?php # $Id$
-if (!$serendipity['embed'] || $serendipity['embed'] === 'false' || $serendipity['embed'] === false) {
- // serendipity is embedded into an existing structure. No need to output headers then.
- if ($serendipity['XHTML11']) {
-?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/xhtml1-transitional.dtd">
-<?php
- } else {
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
-<?php
- }
-?>
-<html>
-<head>
- <title><?php echo htmlspecialchars($serendipity['blogTitle']) . (isset($serendipity['blogSubTitle']) ? ' - '. htmlspecialchars($serendipity['blogSubTitle']) : '') ?></title>
- <meta http-equiv="Content-Type" content="text/html; charset=<?php echo LANG_CHARSET; ?>" />
- <meta name="Powered-By" content="Serendipity v.<?php echo $serendipity['version'] ?>" />
- <link rel="stylesheet" type="text/css" href="<?php echo $serendipity['serendipityHTTPPath']; ?>serendipity.css.php" />
- <link rel="alternate" type="application/rss+xml" title="RSS" href="<?php echo $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : ''); ?>feeds/index.rss2" />
- <link rel="alternate" type="application/x.atom+xml" title="Atom" href="<?php echo $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : ''); ?>feeds/atom.xml" />
-<?php if (strtolower($serendipity['extCSS'])!='none') { ?>
- <style type="text/css">@import "<?php echo $serendipity['extCSS']; ?>";</style>
-<?php }
- if (isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])) { ?>
- <link rel="pingback" href="<?php echo $serendipity['baseURL']; ?>comment.php?type=pingback&entry_id=<?php echo $serendipity['GET']['id']; ?>" />
-<?php } ?>
-<?php serendipity_plugin_api::hook_event('frontend_header', $serendipity); ?>
-</head>
-
-<body>
-<?php
-} // end if (is serendipity embedded?)
- else {
- serendipity_plugin_api::hook_event('frontend_header', $serendipity);
-}
-
include_once('serendipity_config.inc.php');
include_once(S9Y_INCLUDE_PATH . 'serendipity_plugin_api.php');
include_once(S9Y_INCLUDE_PATH . 'serendipity_sidebar_items.php');
-include_once(serendipity_getTemplateFile('layout.php', 'serendipityPath'));
-if (!$serendipity['embed'] || $serendipity['embed'] === 'false' || $serendipity['embed'] === false) {
-?>
-</body>
-</html>
-<?php
+$serendipity['smarty_file'] = 'index.tpl';
+
+if (file_exists($serendipity['smarty']->template_dir . '/layout.php')) {
+ $serendipity['smarty_raw_mode'] = true;
+} else {
+ $serendipity['smarty_raw_mode'] = false;
+}
+
+$serendipity['smarty']->assign(
+ array(
+ 'head_title' => htmlspecialchars($serendipity['blogTitle']) . (isset($serendipity['blogSubTitle']) ? ' - '. htmlspecialchars($serendipity['blogSubTitle']) : ''),
+ 'head_charset' => LANG_CHARSET,
+ 'head_version' => $serendipity['version'],
+ 'CONST' => get_defined_constants(),
+
+ 'is_xhtml' => $serendipity['XHTML11'],
+ 'is_popup' => $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,
+
+ 'blogTitle' => htmlspecialchars($serendipity['blogTitle']),
+ 'blogSubTitle' => htmlspecialchars($serendipity['blogSubTitle']),
+ 'blogDescription' => htmlspecialchars($serendipity['blogDescription']),
+
+ 'serendipityHTTPPath' => $serendipity['serendipityHTTPPath'],
+ 'serendipityBaseURL' => $serendipity['baseURL'],
+ 'serendipityRewritePrefix' => $serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '',
+ 'serendipityIndexFile' => $serendipity['indexFile']
+ )
+);
+
+ob_start();
+serendipity_plugin_api::hook_event('frontend_header', $serendipity);
+$serendipity['smarty']->assign('plugin_frontend_header', ob_get_contents());
+ob_end_clean();
+
+if ($serendipity['smarty_raw_mode']) {
+ // Fallback support using s9y_raw_data
+ include_once(serendipity_getTemplateFile('layout.php', 'serendipityPath'));
+} else {
+ // Use new Smarty driven templating
+ // Watchout: Included files from within the templates need to be fetched in reverse order!
+ include_once(serendipity_getTemplateFile('smarty_layout.php', 'serendipityPath'));
+ serendipity_smarty_fetch('TRACKBACKS', 'trackbacks.tpl');
+ serendipity_smarty_fetch('COMMENTS', 'comments.tpl');
+ serendipity_smarty_fetch('COMMENTFORM', 'commentform.tpl');
+ serendipity_smarty_fetch('ENTRIES', 'entries.tpl');
+ serendipity_smarty_fetch('CONTENT', 'content.tpl');
}
+
/* vim: set sts=4 ts=4 expandtab : */
-?>
+?>
\ No newline at end of file
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.419
retrieving revision 1.419.2.1
diff -u -d -r1.419 -r1.419.2.1
--- serendipity_functions.inc.php 9 Sep 2004 10:52:02 -0000 1.419
+++ serendipity_functions.inc.php 9 Sep 2004 15:02:14 -0000 1.419.2.1
@@ -209,76 +209,36 @@
function serendipity_displayCommentForm($id, $url = '', $comments = NULL, $data = NULL, $showToolbar = true, $moderate_comments = true) {
global $serendipity;
- if ( $comments == NULL ) {
+ if ($comments == NULL) {
$comments = serendipity_fetchComments($id);
}
-?>
-<div class="serendipityCommentForm">
- <a <?php echo ($serendipity['XHTML11'] ? 'id' : 'name'); ?>="serendipity_CommentForm"></a>
- <form <?php echo ($serendipity['XHTML11'] ? 'id' : 'name'); ?>="serendipity_comment" action="<?php echo $url; ?>" method="post">
- <div><input type="hidden" name="serendipity[entry_id]" value="<?php echo $id; ?>" /></div>
- <table border="0" width="100%" cellpadding="3">
- <tr>
- <td class="serendipity_commentsLabel"><?php echo NAME; ?></td>
- <td class="serendipity_commentsValue"><input type="text" name="serendipity[name]" value="<?php echo (isset($data['name']) ? $data['name'] : (isset($serendipity['COOKIE']['name']) ? $serendipity['COOKIE']['name'] : '')); ?>" size="30" /></td>
- </tr>
-
- <tr>
- <td class="serendipity_commentsLabel"><?php echo EMAIL; ?></td>
- <td class="serendipity_commentsValue"><input type="text" name="serendipity[email]" value="<?php echo (isset($data['email']) ? $data['email'] : (isset($serendipity['COOKIE']['email']) ? $serendipity['COOKIE']['email'] : '')); ?>" /></td>
- </tr>
-
- <tr>
- <td class="serendipity_commentsLabel"><?php echo HOMEPAGE; ?></td>
- <td class="serendipity_commentsValue"><input type="text" name="serendipity[url]" value="<?php echo (isset($data['url']) ? $data['url'] : (isset($serendipity['COOKIE']['url']) ? $serendipity['COOKIE']['url'] : '')); ?>" /></td>
- </tr>
+ ob_start();
+ serendipity_plugin_api::hook_event('frontend_comment', $nullParam);
+ $data['frontend_comment'] = ob_get_contents();
+ ob_end_clean();
- <tr>
- <td class="serendipity_commentsLabel"><?php echo IN_REPLY_TO; ?></td>
- <td class="serendipity_commentsValue"><?php echo serendipity_generateCommentList($id, $comments, ((isset($data['replyTo']) && ($data['replyTo'])) ? $data['replyTo'] : 0)); ?></td>
- </tr>
+ $serendipity['smarty']->assign(
+ array(
+ 'commentform_url' => $url,
+ 'commentform_id' => $id,
+ 'commentform_name' => isset($data['name']) ? $data['name'] : (isset($serendipity['COOKIE']['name']) ? $serendipity['COOKIE']['name'] : ''),
+ 'commentform_email' => isset($data['email']) ? $data['email'] : (isset($serendipity['COOKIE']['email']) ? $serendipity['COOKIE']['email'] : ''),
+ 'commentform_url' => isset($data['url']) ? $data['url'] : (isset($serendipity['COOKIE']['url']) ? $serendipity['COOKIE']['url'] : ''),
+ 'commentform_remember' => isset($data['remember']) ? 'checked="checked"' : (isset($serendipity['COOKIE']['remember']) ? $serendipity['COOKIE']['remember'] : ''),
+ 'commentform_replyTo' => serendipity_generateCommentList($id, $comments, ((isset($data['replyTo']) && ($data['replyTo'])) ? $data['replyTo'] : 0)),
+ 'commentform_subscribe' => isset($data['subscribe']) ? 'checked="checked"' : '',
+ 'commentform_data' => isset($data['comment']) ? $data['comment'] : '',
+ 'plugin_frontend_comment' => $data['frontend_comment'],
+ 'is_commentform_showToolbar' => $showToolbar,
+ 'is_allowSubscriptions' => $serendipity['allowSubscriptions'],
+ 'is_moderate_comments' => $moderate_comments
+ )
+ );
- <tr>
- <td class="serendipity_commentsLabel"><?php echo COMMENT; ?></td>
- <td class="serendipity_commentsValue">
- <textarea rows="10" cols="40" name="serendipity[comment]"><?php echo (isset($data['comment']) ? $data['comment'] : ''); ?></textarea><br />
- <?php serendipity_plugin_api::hook_event('frontend_comment', $nullParam); ?>
- </td>
- </tr>
-<?php if ( $showToolbar ) { ?>
- <tr>
- <td> </td>
- <td class="serendipity_commentsLabel">
- <input id="checkbox_remember" type="checkbox" name="serendipity[remember]" <?php echo (isset($data['remember']) ? 'checked="checked"' : isset($serendipity['COOKIE']['remember']) ? $serendipity['COOKIE']['remember'] : '') ; ?> /><label for="checkbox_remember"> <?php echo REMEMBER_INFO; ?></label>
-<?php
- if ($serendipity['allowSubscriptions']) {
-?>
- <br />
- <input id="checkbox_subscribe" type="checkbox" name="serendipity[subscribe]" <?php echo (isset($data['subscribe']) ? 'checked="checked"' : ''); ?> /><label for="checkbox_subscribe"> <?php echo SUBSCRIBE_TO_THIS_ENTRY; ?></label>
-<?php
- }
-?>
-<?php } ?>
- </td>
- </tr>
-<?php
- if ($moderate_comments==true) {
-?>
- <tr>
- <td class="serendipity_commentsValue serendipity_msg_important" colspan="2"><?php echo COMMENTS_WILL_BE_MODERATED ?></td>
- </tr>
-<?php
- }
-?>
- <tr>
- <td> </td>
- <td><input type="submit" name="serendipity[submit]" value="<?php echo SUBMIT_COMMENT; ?>" /> <input type="submit" name="serendipity[preview]" value="<?php echo PREVIEW; ?>" /></td>
- </tr>
- </table>
- </form>
-</div>
-<?php
+ if ($serendipity['smarty_raw_mode']) {
+ $serendipity['smarty']->display(serendipity_getTemplateFile('commentform.tpl', 'serendipityPath'));
+ }
}
function serendipity_setCookie($name,$value) {
@@ -1100,30 +1060,22 @@
if (!isset($serendipity['GET']['page'])) {
$serendipity['GET']['page'] = 1;
}
- }
-?>
-<div class='serendipity_entryFooter' style="text-align: center">
-<?php
- if (!$short_output) {
+
if ($serendipity['GET']['page'] > 1) {
-?>
-<a href="<?php echo $serendipity['baseURL'] . $serendipity['indexFile'] . '?serendipity[page]=' . ($serendipity['GET']['page'] - 1) . $add_query; ?>">« <?php echo PREVIOUS_PAGE; ?></a>
-<?php
+ $serendipity['smarty']->assign('footer_prev_page', $serendipity['baseURL'] . $serendipity['indexFile'] . '?serendipity[page]=' . ($serendipity['GET']['page'] - 1) . $add_query);
}
-?>
-(<?php printf(PAGE_BROWSE_ENTRIES, $serendipity['GET']['page'], $totalPages, $totalEntries); ?>)
-<?php
+
+ $serendipity['smarty']->assign('footer_info', sprintf(PAGE_BROWSE_ENTRIES, $serendipity['GET']['page'], $totalPages, $totalEntries));
+
if ($serendipity['GET']['page'] < $totalPages) {
-?>
- <a href="<?php echo $serendipity['baseURL'] . $serendipity['indexFile'] . '?serendipity[page]=' . ($serendipity['GET']['page'] + 1) . $add_query; ?>"><?php echo NEXT_PAGE; ?> »</a>
-<?php
+ $serendipity['smarty']->assign('footer_next_page', $serendipity['baseURL'] . $serendipity['indexFile'] . '?serendipity[page]=' . ($serendipity['GET']['page'] + 1) . $add_query);
}
}
+ ob_start();
serendipity_plugin_api::hook_event('entries_footer', $serendipity);
-?>
-</div>
-<?php
+ $serendipity['smarty']->assign('plugin_entries_footer', ob_get_contents());
+ ob_end_clean();
}
/**
@@ -1139,131 +1091,78 @@
return; // no display of this item
}
- /* pre-walk the array to collect them keyed by date */
- $bydate = array();
if (!is_array($entries) || $entries[0] == false || !isset($entries[0]['timestamp'])) {
- echo '<br />' . NO_ENTRIES_TO_PRINT . "\n";
+ $serendipity['smarty']->assign('content_message', '<br />' . NO_ENTRIES_TO_PRINT);
return;
}
- $lastDate = '';
+ /* pre-walk the array to collect them keyed by index. Retouch the array for Smarty section
+ logic. It needs to walk on numerical arrays, so we can now longer use an associative
+ index holding a date string. So we now see which entries are made on the same date ($ts)
+ and then create a referring array $dateref which tells s9y that 20040918 is index 0, 20040917 is
+ index 1 and so on, so that the key can later be reconstracted in the smarty loop. */
+ $bydate = array();
+ $dateref = array();
+ $dateseen = array();
+ $datekey = -1;
for ($x = 0, $num_entries = count($entries); $x < $num_entries; $x++) {
- $d = serendipity_formatTime(DATE_FORMAT_ENTRY, $entries[$x]['timestamp']);
- $bydate[$d][] = $entries[$x];
- }
+ $ts = date('Ymd', $entries[$x]['timestamp']);
- if (!isset($serendipity['short_archives']) || !$serendipity['short_archives']) {
- foreach ($bydate as $date => $ents) {
-?>
+ if (!isset($dateseen[$ts])) {
+ // No entries existing for the same timestamp. Increment to the next numerical index
+ $datekey++;
+ }
- <div class="serendipity_Entry_Date">
- <h3 class="serendipity_date"><?php echo $date; ?></h3>
+ $bydate[$datekey][] =& $entries[$x];
+ $dateseen[$ts] = true;
+ $dateref[$datekey] = $entries[$x]['timestamp'];
+ }
-<?php
- foreach ($ents as $x => $entry) {
- $entryLink = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath');
+ if (!isset($serendipity['short_archives']) || !$serendipity['short_archives']) {
+ foreach($bydate AS $date => $ents) {
+ foreach($ents AS $x => $_entry) {
+ $entry = &$bydate[$date][$x];
serendipity_plugin_api::hook_event('frontend_display', $entry);
- $html_extended = '';
- $extended_css = 'serendipity_entry_body_folded';
+ $entry['entryLink'] = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath');
+ $entry['rdf_ident'] = serendipity_archiveURL($entry['id'], $entry['title'], 'baseURL');
+ $entry['title'] = htmlspecialchars($entry['title']);
+ $entry['extended_css'] = 'serendipity_entry_body_folded';
+ $entry['commURL'] = serendipity_archiveURL($entry['id'], $entry['title'], 'baseURL', false);
+
if ($extended && strlen($entry['extended'])) {
- $html_extended = '<div class="serendipity_entry_extended"><a ' . ($serendipity['XHTML11'] ? 'id' : 'name') . '="extended"></a>';
- $html_extended .= $entry['extended'] . '</div>';
- $extended_css = 'serendipity_entry_body_unfolded';
+ $entry['is_extended'] = true;
+ $entry['extended_css'] = 'serendipity_entry_body_unfolded';
}
if (isset($entry['exflag']) && $entry['exflag'] && !$extended) {
- $html_extended = '<br /><a href="' . $entryLink . '#extended">' . sprintf(VIEW_EXTENDED_ENTRY, htmlspecialchars($entry['title'])) . '</a><br /><br />';
- }
-
-?>
- <h4 class="serendipity_title"><a href="<?php echo $entryLink; ?>"><?php echo htmlspecialchars($entry['title']); ?></a></h4>
-
- <div class="serendipity_entry">
-<?php
- if (is_array($entry['categories'])) {
- $icon_string = '';
- foreach ($entry['categories'] as $cat) {
- if ($cat['category_icon'] != '') {
- $icon_string .= '<a href="' . $serendipity['serendipityHTTPPath'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . PATH_CATEGORIES . '/' . $cat['categoryid'] . '-' . serendipity_makeFilename($cat['category_name']) . '"><img class="serendipity_entryIcon" title="' . htmlspecialchars($cat['category_name']) . (!empty($cat['category_description']) ? ': ' . htmlspecialchars($cat['category_description']) : '') . '" alt="' . htmlspecialchars($cat['category_name']) . '" src="' . htmlspecialchars($cat['category_icon']) . '"/></a>';
- }
- }
- if ($icon_string != '') {
- echo '<span class="serendipity_entryIcon">' . $icon_string . '</span>';
- }
- }
-?>
- <div class="<?php echo $extended_css; ?>"><?php echo $entry['body']; ?></div>
- <?php echo $html_extended; ?>
-
- <div class='serendipity_entryFooter'>
-<?php
- echo ' ' . POSTED_BY . ' ' . htmlspecialchars($entry['username']);
- if (is_array($entry['categories']) && sizeof($entry['categories']) > 0) {
- echo ' ' . IN . ' ';
- $cats = array();
- foreach ($entry['categories'] as $cat) {
- $cats[] = '<a href="' . $serendipity['serendipityHTTPPath'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . PATH_CATEGORIES . '/' . $cat['categoryid'] . '-' . serendipity_makeFilename($cat['category_name']) . '">' . $cat['category_name'] . '</a>';
- }
- echo implode(', ', $cats);
+ $entry['is_extended_link'] = true;
}
- echo ' ' . AT . ' <a href="' . $entryLink . '">' . date('H:i', $entry['timestamp']) . '</a>'. "\n";
-
- if (serendipity_db_bool($entry['allow_comments']) || !isset($entry['allow_comments']) || $entry['comments'] > 0) {
- if (!isset($serendipity['GET']['id'])) {
- $label = $entry['comments'] == 1 ? COMMENT : COMMENTS;
- if ($serendipity['enablePopup']) {
- $uriExtra = ' onclick="window.open(this.href, \'comments\', \'width=480,height=480,scrollbars=yes\'); return false;"';
- $commentUri = $serendipity['serendipityHTTPPath'] . 'comment.php?serendipity[entry_id]=' . $entry['id'] . '&serendipity[type]=comments';
- } else {
- $uriExtra = '';
- $commentUri = $entryLink .'#comments';
- }
- echo ' | <a href="' . $commentUri . '"' . $uriExtra . '>' . $label . ' (' . $entry['comments'] . ')</a>';
- }
+ if (!isset($serendipity['GET']['id']) && (serendipity_db_bool($entry['allow_comments']) || !isset($entry['allow_comments']) || $entry['comments'] > 0)) {
+ $entry['is_comments'] = true;
+ $entry['comments_label'] = $entry['comments'] == 1 ? COMMENT : COMMENTS;
}
- if (serendipity_db_bool($entry['allow_comments']) || !isset($entry['allow_comments']) || $entry['trackbacks'] > 0 ) {
- if ( $serendipity['enablePopup'] || !isset($serendipity['GET']['id'])) {
- $label = $entry['trackbacks'] == 1 ? TRACKBACK : TRACKBACKS;
- if ($serendipity['enablePopup']) {
- $uriExtra = ' onclick="window.open(this.href, \'comments\', \'width=480,height=480,scrollbars=yes\'); return false;"';
- $trackbackUri = $serendipity['serendipityHTTPPath'] . 'comment.php?serendipity[entry_id]=' . $entry['id'] . '&serendipity[type]=trackbacks';
- } else {
- $uriExtra = '';
- $trackbackUri = $entryLink .'#trackbacks';
- }
-
- echo ' | <a href="' . $trackbackUri .'"'. $uriExtra . '>' . $label . ' (' . $entry['trackbacks'] . ')</a>';
- }
+ if (!isset($serendipity['GET']['id']) && (serendipity_db_bool($entry['allow_comments']) || !isset($entry['allow_comments']) || $entry['trackbacks'] > 0)) {
+ $entry['is_trackbacks'] = true;
+ $entry['trackbacks_label'] = $entry['trackbacks'] == 1 ? TRACKBACK : TRACKBACKS;
}
if ($_SESSION['serendipityAuthedUser'] === true && ($_SESSION['serendipityUserlevel'] >= USERLEVEL_CHIEF || $_SESSION['serendipityAuthorid'] == $entry['authorid'])) {
- echo ' | <a href="' . $serendipity['baseURL'] . 'serendipity_entries.php?serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=edit&serendipity[id]=' . $entry['id'] . '">' . EDIT_ENTRY . '</a>';
+ $entry['is_owner'] = true;
}
- if (!empty($entry['add_footer'])) {
- echo $entry['add_footer'];
- }
-?>
- </div>
- </div>
- <!--
- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"
- xmlns:dc="http://purl.org/dc/elements/1.1/">
- <rdf:Description
- rdf:about="<?php echo $serendipity['baseURL'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : ''); ?>feeds/ei_<?php echo $entry['id']; ?>.rdf"
- trackback:ping="<?php echo $serendipity['baseURL']; ?>comment.php?type=trackback&entry_id=<?php echo $entry['id']; ?>"
- dc:title="<?php echo htmlspecialchars($entry['title']); ?>"
- dc:identifier="<?php echo serendipity_archiveURL($entry['id'], $entry['title'], 'baseURL'); ?>" />
- </rdf:RDF>
- -->
-<?php
$eventData = array_merge(array('display_dat' => ''), $entry);
serendipity_plugin_api::hook_event('frontend_display:html:per_entry', $eventData);
- echo $eventData['display_dat'];
+ $entry['plugin_display_dat'] = $eventData['display_dat'];
+
+ if ($preview) {
+ ob_start();
+ serendipity_plugin_api::hook_event('backend_preview', $entry);
+ $entry['backend_preview'] = ob_get_contents();
+ ob_end_clean();
+ }
if (isset($serendipity['GET']['id'])) {
$comm_url = serendipity_archiveURL(
@@ -1273,60 +1172,13 @@
false
);
- /********** MESSAGES *********/
- if (defined('DATA_UNSUBSCRIBED')) {
- echo '<br /><div class="serendipity_center serendipity_msg_notice">'. sprintf(UNSUBSCRIBE_OK, DATA_UNSUBSCRIBED) .'</div><br />';
- }
-
- if (defined('DATA_TRACKBACK_DELETED')) {
- echo '<br /><div class="serendipity_center serendipity_msg_notice">'. sprintf(TRACKBACK_DELETED, DATA_TRACKBACK_DELETED) .'</div><br />';
- }
-
- if (defined('DATA_TRACKBACK_APPROVED')) {
- echo '<br /><div class="serendipity_center serendipity_msg_notice">'. sprintf(TRACKBACK_APPROVED, DATA_TRACKBACK_APPROVED) .'</div><br />';
- }
-
- if (defined('DATA_COMMENT_DELETED')) {
- echo '<br /><div class="serendipity_center serendipity_msg_notice">'. sprintf(COMMENT_DELETED, DATA_COMMENT_DELETED) .'</div><br />';
- }
-
- if (defined('DATA_COMMENT_APPROVED')) {
- echo '<br /><div class="serendipity_center serendipity_msg_notice">'. sprintf(COMMENT_APPROVED, DATA_COMMENT_APPROVED) .'</div><br />';
- }
-
-
- if (!$serendipity['enablePopup']) {
- $tbu = $serendipity['baseURL'] . 'comment.php?type=trackback&entry_id=' . $entry['id'];
-?>
- <div class="serendipity_comments">
- <br />
- <a id="trackbacks"></a>
- <div class="serendipity_commentsTitle"><?php echo TRACKBACKS; ?></div>
- <div class="serendipity_center"><a style="font-weight: normal" href="<?php echo $tbu; ?>" onclick="alert('<?php echo htmlentities(TRACKBACK_SPECIFIC_ON_CLICK) ?>'); return false;" title="<?php echo htmlentities(TRACKBACK_SPECIFIC_ON_CLICK) ?>"><?php echo TRACKBACK_SPECIFIC; ?></a></div><br />
-<?php
- serendipity_printTrackbacks(serendipity_fetchTrackbacks($entry['id']));
-?>
- </div>
-<?php } ?>
- <div class="serendipity_comments">
- <br />
- <a id="comments"></a>
- <div class="serendipity_commentsTitle"><?php echo COMMENTS; ?></div>
- <?php
- $comment_viewmode_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?url=' . $comm_url . '&serendipity[cview]=';
- if ( $serendipity['GET']['cview'] == VIEWMODE_LINEAR ) {
- $linearLink = COMMENTS_VIEWMODE_LINEAR;
- $threadLink = '<a href="'. $comment_viewmode_url . VIEWMODE_THREADED .'#comments">'. COMMENTS_VIEWMODE_THREADED .'</a>';
- $viewmode = VIEWMODE_LINEAR;
- } else {
- $linearLink = '<a href="'. $comment_viewmode_url . VIEWMODE_LINEAR .'#comments">'. COMMENTS_VIEWMODE_LINEAR .'</a>';
- $threadLink = COMMENTS_VIEWMODE_THREADED;
- $viewmode = VIEWMODE_THREADED;
- }
+ serendipity_printTrackbacks(
+ serendipity_fetchTrackbacks(
+ $entry['id']
+ )
+ );
- ?>
- <div class="serendipity_center"><?php echo DISPLAY_COMMENTS_AS ?> (<?php echo $linearLink ?> | <?php echo $threadLink ?>)</div>
-<?php
+ ob_start(); // TODO: Remove recursion
serendipity_printComments(
serendipity_fetchComments(
$entry['id']
@@ -1353,52 +1205,34 @@
$serendipity['POST']['replyTo']
);
}
+ $serendipity['smarty']->assign('comments_list', ob_get_contents());
+ ob_end_clean();
- if (isset($serendipity['messagestack']['comments'])) {
- foreach ((array)$serendipity['messagestack']['comments'] as $message ) {
-?>
- <div class="serendipity_center serendipity_msg_important"><?php echo $message ?></div>
-<?php
- }
- }
-
- if (isset($serendipity['GET']['csuccess']) && $serendipity['GET']['csuccess'] == 'true') {
-?>
- <br />
- <div class="serendipity_center serendipity_msg_notice"><?php echo COMMENT_ADDED; ?></div>
-<?php
- } elseif (!serendipity_db_bool($entry['allow_comments'])) {
-?>
- <br />
- <div class="serendipity_center serendipity_msg_important"><?php echo COMMENTS_CLOSED; ?></div>
-<?php
+ if ($serendipity['GET']['cview'] == VIEWMODE_LINEAR) {
+ $serendipity['smarty']->assign('is_cview_linear', true);
} else {
-?>
- <br />
- <div class="serendipity_commentsTitle"><?php echo ADD_COMMENT; ?></div>
-<?php
- echo serendipity_displayCommentForm(
- $entry['id'],
- $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?url=' . $comm_url,
- true,
- $serendipity['POST'],
- true,
- serendipity_db_bool($entry['moderate_comments'])
- );
+ $serendipity['smarty']->assign('is_cview_linear', false);
}
-?>
- </div>
-<?php
- }
-?>
-<?php
- if ($preview) {
- serendipity_plugin_api::hook_event('backend_preview', $article);
+
+ $serendipity['smarty']->assign(
+ array(
+ 'is_cview_linear' => ($serendipity['GET']['cview'] == VIEWMODE_LINEAR ? true : false),
+ 'comments_messagestack' => (isset($serendipity['messagestack']['comments']) ? (array)$serendipity['messagestack']['comments'] : false),
+ 'is_comment_added' => (isset($serendipity['GET']['csuccess']) && $serendipity['GET']['csuccess'] == 'true' ? true: false),
+ 'is_comment_closed' => (!serendipity_db_bool($entry['allow_comments']) ? true : false)
+ )
+ );
+
+ serendipity_displayCommentForm(
+ $entry['id'],
+ $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?url=' . $comm_url,
+ true,
+ $serendipity['POST'],
+ true,
+ serendipity_db_bool($entry['moderate_comments'])
+ );
}
} // end for-loop (entries)
-?>
- </div>
-<?php
} // end for-loop (dates)
if (!isset($serendipity['GET']['id']) &&
@@ -1409,17 +1243,35 @@
serendipity_printEntryFooter(true);
}
} else { // else short mode
- $s = &$serendipity['GET']['range'];
-?>
- <div class='serendipity_date'><?php echo TOPICS_OF . ' ' . date('m/Y', mktime(0, 0, 0, substr($s, 4, 2), 1, substr($s, 0, 4))); ?></div>
-<?php
- foreach ($bydate as $date => $ents) {
- foreach ($ents as $x => $entry) {
- echo '<a href="' . serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath') . '">' . $entry['title'] . '</a>' . "\n";
- echo '<br />' . "\n";
+ foreach($bydate AS $date => $ents) {
+ foreach($ents AS $x => $_entry) {
+ $entry = &$bydate[$date][$x];
+ $entry['entryLink'] = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath');
}
}
+
+ $s = &$serendipity['GET']['range'];
+ $serendipity['smarty']->assign(
+ array(
+ 'is_short_mode' => true,
+ 'short_timestamp' => mktime(0, 0, 0, substr($s, 4, 2), 1, substr($s, 0, 4))
+ )
+ );
} // end else short mode
+
+ $serendipity['smarty']->assign(
+ array(
+ 'bydate' => $bydate,
+ 'dateref' => $dateref
+ )
+ );
+
+ if ($serendipity['smarty_raw_mode']) {
+ serendipity_smarty_fetch('TRACKBACKS', 'trackbacks.tpl');
+ serendipity_smarty_fetch('COMMENTS', 'comments.tpl');
+ serendipity_smarty_fetch('COMMENTFORM', 'commentform.tpl');
+ $serendipity['smarty']->display(serendipity_getTemplateFile('entries.tpl', 'serendipityPath'));
+ }
} // end function serendipity_printEntries
function serendipity_deleteComment($id, $entry_id, $type='comments')
@@ -1561,6 +1413,7 @@
return $retval;
}
+/*TODO: Don't know how to get recursion done with Smarty in a smarty way.*/
function serendipity_printComments($comments, $allow_comments = true, $show_admin = true, $parentid = 0, $indent = '')
{
global $serendipity;
@@ -1666,37 +1519,18 @@
{
global $serendipity;
- if (!count($comments)) {
-?>
- <div class="serendipity_center"><?php echo NO_TRACKBACKS; ?></div>
-<?php
+ if (count($comments)) {
+ $serendipity['smarty']->assign('is_trackbacks_owner', ($_SESSION["serendipityAuthedUser"] === true && ($_SESSION['serendipityUserlevel'] >= USERLEVEL_CHIEF || $_SESSION['serendipityAuthorid'] == $comment[0]['authorid'])) ? true : false);
+ $serendipity['smarty']->assign('trackbacks', $comments);
+ } else {
+ $serendipity['smarty']->assign('trackbacks', false);
}
- foreach ($comments as $comment) {
- $link = empty($comment['url']) ? $comment['email'] : $comment['url'];
- $name = empty($comment['author']) ? 'Anonymous' : $comment['author'];
- $title= strip_tags($comment['title']);
-?>
- <div class="serendipity_comment">
- <a href="<?php echo strip_tags($link); ?>" <?php echo serendipity_xhtml_target('_blank'); ?>><?php echo $title; ?></a><br />
- <b><?php echo EXCERPT; ?>: </b>
- <?php echo htmlspecialchars(strip_tags($comment['body'])); ?><br />
- <div class="serendipity_comment_source">
- <b>Weblog: </b> <?php echo strip_tags($name); ?><br />
- <b><?php echo TRACKED; ?>: </b> <?php echo date('M d, h:i', $comment['timestamp']); ?>
-<?php
- if ($_SESSION["serendipityAuthedUser"] === true && ($_SESSION['serendipityUserlevel'] >= USERLEVEL_CHIEF || $_SESSION['serendipityAuthorid'] == $comment['authorid'])) {
- echo ' (<a href="' . $serendipity['baseURL'] . 'comment.php?serendipity[delete]=' . $comment['id'] . '&serendipity[entry]=' . $comment['entry_id'] . '&serendipity[type]=trackbacks">' . DELETE . '</a>)';
- }
-?>
- </div>
- </div>
- <br />
-<?php
+ if ($serendipity['smarty_raw_mode']) {
+ $serendipity['smarty']->display(serendipity_getTemplateFile('trackbacks.tpl', 'serendipityPath'));
}
}
-
function serendipity_approveComment($cid, $entry_id, $force = false) {
global $serendipity;
@@ -1767,7 +1601,7 @@
$query .= " VALUES ('$id', '$parentid', '$ip', '$name', '$email', '$url', '$commentsFixed', '$type', '$t', '$title', '$subscribe', '$status')";
serendipity_db_query($query);
- $cid = serendipity_db_insert_id('comments', 'id');
+ $cid = serendipity_db_insert_id();
$query = "SELECT a.email, e.title, a.mail_comments, a.mail_trackbacks, e.moderate_comments
FROM {$serendipity['dbPrefix']}entries e, {$serendipity['dbPrefix']}authors a
@@ -2576,18 +2410,17 @@
if (!$_SESSION['serendipityRightPublish']) {
$entry['isdraft'] = 'true';
}
-
- if(!isset($entry['allow_comments'])){
- $entry['allow_comments']='false';
- }
- if(!isset($entry['moderate_comments'])){
- $entry['moderate_comments']='false';
- }
+ if(!isset($entry['allow_comments'])){
+ $entry['allow_comments']='false';
+ }
+ if(!isset($entry['moderate_comments'])){
+ $entry['moderate_comments']='false';
+ }
$res = serendipity_db_insert('entries', $entry);
if ($res) {
- $entry['id'] = serendipity_db_insert_id('entries', 'id');
+ $entry['id'] = serendipity_db_insert_id();
if (is_array($categories)) {
foreach ($categories as $cat) {
if (is_numeric($cat))
@@ -3583,6 +3416,38 @@
}
}
+function serendipity_smarty_fetch($block, $file) {
+global $serendipity;
+ $serendipity['smarty']->assign(
+ $block,
+ $serendipity['smarty']->fetch(
+ 'file:'. serendipity_getTemplateFile($file, 'serendipityPath'),
+ null,
+ 'static'
+ )
+ );
+}
+
+function serendipity_emptyPrefix($string, $prefix = ': ') {
+ return (!empty($string) ? $prefix . htmlspecialchars($string) : '');
+}
+
+function serendipity_printf($data, $constant) {
+ if (defined($constant)) {
+ return sprintf(constant($constant), $data);
+ } else {
+ return sprintf($constant, $data);
+ }
+}
+
+function serendipity_smarty_formatTime($timestamp, $format) {
+ if (defined($format)) {
+ return serendipity_formatTime(constant($format), $timestamp);
+ } else {
+ return serendipity_formatTime($format, $timestamp);
+ }
+}
+
define("serendipity_FUNCTIONS_LOADED", true);
/* vim: set sts=4 ts=4 expandtab : */
?>
Index: index.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/index.php,v
retrieving revision 1.49
retrieving revision 1.49.2.1
diff -u -d -r1.49 -r1.49.2.1
--- index.php 24 Aug 2004 17:32:45 -0000 1.49
+++ index.php 9 Sep 2004 15:02:15 -0000 1.49.2.1
@@ -6,6 +6,7 @@
// Session and serendipity_login() are needed to also remember an autologin
// user on the frontend
+ob_start();
session_start();
include_once('serendipity_config.inc.php');
serendipity_login();
@@ -176,7 +177,7 @@
} else if (preg_match(PAT_CATEGORIES, $uri, $matches) ||
preg_match('@/(index\.(php|html))?@', $uri) ||
preg_match('@/(' . preg_quote($serendipity['indexFile']) . ')?@', $uri)) {
-
+
if (count($serendipity['GET']) == 2) {
if (isset($matches) && is_array($matches) && isset($matches[1])) {
$serendipity['GET']['category'] = $matches[1];
@@ -211,5 +212,12 @@
serendipity_track_referrer();
}
+$raw_data = ob_get_contents();
+ob_end_clean();
+$serendipity['smarty']->assign('raw_data', $raw_data);
+if (empty($serendipity['smarty_file'])) {
+ $serendipity['smarty_file'] = '404.tpl';
+}
+$serendipity['smarty']->display(serendipity_getTemplateFile($serendipity['smarty_file'], 'serendipityPath'));
/* vim: set sts=4 ts=4 expandtab : */
-?>
+?>
\ No newline at end of file
|