Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10225
Modified Files:
Tag: branch-smarty
serendipity_functions.inc.php
Log Message:
- Move the entry summary to its own template
- Simplify logic when selecting between short or normal entry display mode. They are essentially the same, they just use a different template.
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.419.2.21
retrieving revision 1.419.2.22
diff -u -d -r1.419.2.21 -r1.419.2.22
--- serendipity_functions.inc.php 19 Sep 2004 20:06:35 -0000 1.419.2.21
+++ serendipity_functions.inc.php 19 Sep 2004 21:30:43 -0000 1.419.2.22
@@ -1118,145 +1118,114 @@
$dateref[$datekey] = $entries[$x]['timestamp'];
}
- 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);
+ foreach($bydate AS $date => $ents) {
+ foreach($ents AS $x => $_entry) {
+ $entry = &$bydate[$date][$x];
+ serendipity_plugin_api::hook_event('frontend_display', $entry);
- $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['commURL'] = serendipity_archiveURL($entry['id'], $entry['title'], 'baseURL', false);
+ $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['commURL'] = serendipity_archiveURL($entry['id'], $entry['title'], 'baseURL', false);
- if (strlen($entry['extended'])) {
- $entry['has_extended'] = true;
- }
+ if (strlen($entry['extended'])) {
+ $entry['has_extended'] = true;
+ }
- if (isset($entry['exflag']) && $entry['exflag'] && $extended) {
- $entry['is_extended'] = true;
- }
+ if (isset($entry['exflag']) && $entry['exflag'] && $extended) {
+ $entry['is_extended'] = true;
+ }
- if (!isset($serendipity['GET']['id']) && (serendipity_db_bool($entry['allow_comments']) || !isset($entry['allow_comments']) || $entry['comments'] > 0)) {
- $entry['has_comments'] = true;
- $entry['label_comments'] = $entry['comments'] == 1 ? COMMENT : COMMENTS;
- }
+ if (!isset($serendipity['GET']['id']) && (serendipity_db_bool($entry['allow_comments']) || !isset($entry['allow_comments']) || $entry['comments'] > 0)) {
+ $entry['has_comments'] = true;
+ $entry['label_comments'] = $entry['comments'] == 1 ? COMMENT : COMMENTS;
+ }
- if (!isset($serendipity['GET']['id']) && (serendipity_db_bool($entry['allow_comments']) || !isset($entry['allow_comments']) || $entry['trackbacks'] > 0)) {
- $entry['has_trackbacks'] = true;
- $entry['label_trackbacks'] = $entry['trackbacks'] == 1 ? TRACKBACK : TRACKBACKS;
- }
+ if (!isset($serendipity['GET']['id']) && (serendipity_db_bool($entry['allow_comments']) || !isset($entry['allow_comments']) || $entry['trackbacks'] > 0)) {
+ $entry['has_trackbacks'] = true;
+ $entry['label_trackbacks'] = $entry['trackbacks'] == 1 ? TRACKBACK : TRACKBACKS;
+ }
- if ($_SESSION['serendipityAuthedUser'] === true && ($_SESSION['serendipityUserlevel'] >= USERLEVEL_CHIEF || $_SESSION['serendipityAuthorid'] == $entry['authorid'])) {
- $entry['is_entry_owner'] = true;
- }
+ if ($_SESSION['serendipityAuthedUser'] === true && ($_SESSION['serendipityUserlevel'] >= USERLEVEL_CHIEF || $_SESSION['serendipityAuthorid'] == $entry['authorid'])) {
+ $entry['is_entry_owner'] = true;
+ }
- $eventData = array_merge(array('display_dat' => ''), $entry);
- serendipity_plugin_api::hook_event('frontend_display:html:per_entry', $eventData);
- $entry['plugin_display_dat'] = $eventData['display_dat'];
+ $eventData = array_merge(array('display_dat' => ''), $entry);
+ serendipity_plugin_api::hook_event('frontend_display:html:per_entry', $eventData);
+ $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 ($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(
- $entry['id'],
- $entry['title'],
- 'baseURL',
- false
- );
+ /* IF WE ARE DISPLAYING A FULL ENTRY */
+ if (isset($serendipity['GET']['id'])) {
+ $comm_url = serendipity_archiveURL($entry['id'], $entry['title'], 'baseURL', false);
- serendipity_printTrackbacks(
- serendipity_fetchTrackbacks(
- $entry['id']
- )
- );
+ serendipity_printTrackbacks(serendipity_fetchTrackbacks($entry['id']));
- ob_start(); // TODO: Remove recursion and output buffering
- serendipity_printComments(
- serendipity_fetchComments(
- $entry['id']
- ),
- (isset($entry['allow_comments']) ? $entry['allow_comments'] : true),
- true,
- $viewmode
- );
+ ob_start(); // TODO: Remove recursion and output buffering
+ serendipity_printComments(serendipity_fetchComments($entry['id']),(isset($entry['allow_comments']) ? $entry['allow_comments'] : true), true, $viewmode);
- if (!empty($serendipity['POST']['preview'])) {
- serendipity_printComments(
- array(
+ if (!empty($serendipity['POST']['preview'])) {
+ serendipity_printComments(
+ array(
array(
- 'email' => $serendipity['POST']['email'],
- 'username' => $serendipity['POST']['name'],
- 'body' => $serendipity['POST']['comment'],
- 'url' => $serendipity['POST']['url'],
- 'parent_id' => $serendipity['POST']['replyTo'],
- 'timestamp' => time()
+ 'email' => $serendipity['POST']['email'],
+ 'username' => $serendipity['POST']['name'],
+ 'body' => $serendipity['POST']['comment'],
+ 'url' => $serendipity['POST']['url'],
+ 'parent_id' => $serendipity['POST']['replyTo'],
+ 'timestamp' => time()
)
- ),
- false,
- false,
- $serendipity['POST']['replyTo']
- );
- }
- $serendipity['smarty']->assign('comments_list', ob_get_contents());
- ob_end_clean();
- serendipity_smarty_fetch('COMMENTS', 'comments.tpl');
+ ),
+ false,
+ false,
+ $serendipity['POST']['replyTo']
+ );
+ }
- if ($serendipity['GET']['cview'] == VIEWMODE_LINEAR) {
- $serendipity['smarty']->assign('is_cview_linear', true);
- } else {
- $serendipity['smarty']->assign('is_cview_linear', false);
- }
+ $serendipity['smarty']->assign('comments_list', ob_get_contents());
+ ob_end_clean();
+ serendipity_smarty_fetch('COMMENTS', 'comments.tpl');
- $serendipity['smarty']->assign(
- array(
+ if ($serendipity['GET']['cview'] == VIEWMODE_LINEAR) {
+ $serendipity['smarty']->assign('is_cview_linear', true);
+ } else {
+ $serendipity['smarty']->assign('is_cview_linear', false);
+ }
+
+ $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)
- } // end for-loop (dates)
+ )
+ );
- if (!isset($serendipity['GET']['id']) &&
- (!isset($serendipity['hidefooter']) || $serendipity['hidefooter'] == false) &&
- (count($entries) <= (!empty($serendipity['fetchLimit']) ? $serendipity['fetchLimit'] : 15))) {
- serendipity_printEntryFooter();
- } else {
- serendipity_printEntryFooter(true);
- }
- } else { // else short mode
- foreach($bydate AS $date => $ents) {
- foreach($ents AS $x => $_entry) {
- $entry = &$bydate[$date][$x];
- $entry['entryLink'] = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath');
- }
- }
+ serendipity_displayCommentForm(
+ $entry['id'],
+ $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?url=' . $comm_url,
+ true,
+ $serendipity['POST'],
+ true,
+ serendipity_db_bool($entry['moderate_comments'])
+ );
+ } /* END FULL ENTRY LOGIC */
+ } // end for-loop (entries)
+ } // end for-loop (dates)
- $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
+ if (!isset($serendipity['GET']['id']) &&
+ (!isset($serendipity['hidefooter']) || $serendipity['hidefooter'] == false) &&
+ (count($entries) <= (!empty($serendipity['fetchLimit']) ? $serendipity['fetchLimit'] : 15))) {
+ serendipity_printEntryFooter();
+ } else {
+ serendipity_printEntryFooter(true);
+ }
$serendipity['smarty']->assign(
array(
@@ -1265,7 +1234,11 @@
)
);
- serendipity_smarty_fetch('ENTRIES', 'entries.tpl', true);
+ if (isset($serendipity['short_archives']) && $serendipity['short_archives']) {
+ serendipity_smarty_fetch('ENTRIES', 'entries_summary.tpl', true);
+ } else {
+ serendipity_smarty_fetch('ENTRIES', 'entries.tpl', true);
+ }
} // end function serendipity_printEntries
|