Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12960
Modified Files:
Tag: branch-smarty
serendipity_functions.inc.php
Log Message:
- Replace some of this $bydate etc. logic, since it's really unnecessary and bad for performance
TODO: Fix entries_summary.tpl
- Don't attempt to show category images, if there are none
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.419.2.32
retrieving revision 1.419.2.33
diff -u -d -r1.419.2.32 -r1.419.2.33
--- serendipity_functions.inc.php 25 Sep 2004 23:29:19 -0000 1.419.2.32
+++ serendipity_functions.inc.php 26 Sep 2004 00:47:47 -0000 1.419.2.33
@@ -928,57 +928,43 @@
return; // no display of this item
}
+ // We shouldn't return here, because we want Smarty to handle the output
if (!is_array($entries) || $entries[0] == false || !isset($entries[0]['timestamp'])) {
- $serendipity['smarty']->assign('content_message', '<br />' . NO_ENTRIES_TO_PRINT);
- return;
+ $entries = array();
}
- /* 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;
+ $dategroup = array();
for ($x = 0, $num_entries = count($entries); $x < $num_entries; $x++) {
+ $ts = $key = date('Ymd', $entries[$x]['timestamp']);
if (!empty($entries[$x]['properties']['ep_is_sticky']) && serendipity_db_bool($entries[$x]['properties']['ep_is_sticky'])) {
- $timestamp = $ts = 'sticky';
- } else {
- $timestamp = $entries[$x]['timestamp'];
- $ts = date('Ymd', $timestamp);
+ $entries[$x]['is_sticky'] = true;
+ $key = 'sticky';
}
if (!empty($entries[$x]['properties']['ep_cache_body'])) {
- $entries[$x]['body'] =& $entries[$x]['properties']['ep_cache_body'];
+ $entries[$x]['body'] = &$entries[$x]['properties']['ep_cache_body'];
$entries[$x]['is_cached'] = true;
}
if (!empty($entries[$x]['properties']['ep_cache_extended'])) {
- $entries[$x]['extended'] =& $entries[$x]['properties']['ep_cache_extended'];
+ $entries[$x]['extended'] = &$entries[$x]['properties']['ep_cache_extended'];
$entries[$x]['is_cached'] = true;
}
- if (!isset($dateseen[$ts])) {
- // No entries existing for the same timestamp. Increment to the next numerical index
- $datekey++;
- }
-
- $bydate[$datekey][] =& $entries[$x];
- $dateseen[$ts] = true;
- $dateref[$datekey] = $timestamp;
+ $dategroup[$key]['date'] = $entries[$x]['timestamp'];
+ $dategroup[$key]['is_sticky'] = isset($entries[$x]['is_sticky']);
+ $dategroup[$key]['entries'][] = &$entries[$x];
}
- foreach($bydate AS $date => $ents) {
- foreach($ents AS $x => $_entry) {
- $entry = &$bydate[$date][$x];
+ foreach($dategroup as $properties) {
+ foreach($properties['entries'] as $x => $_entry) {
+ $entry = &$properties['entries'][$x]; // PHP4 Compat
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['link'] = 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;
@@ -1066,9 +1052,9 @@
serendipity_db_bool($entry['moderate_comments']),
$entry
);
- } /* END FULL ENTRY LOGIC */
- } // end for-loop (entries)
- } // end for-loop (dates)
+ } // END FULL ENTRY LOGIC
+ } // end foreach-loop (entries)
+ } // end foreach-loop (dates)
if (!isset($serendipity['GET']['id']) &&
(!isset($serendipity['hidefooter']) || $serendipity['hidefooter'] == false) &&
@@ -1078,12 +1064,7 @@
serendipity_printEntryFooter(true);
}
- $serendipity['smarty']->assign(
- array(
- 'bydate' => $bydate,
- 'dateref' => $dateref
- )
- );
+ $serendipity['smarty']->assign('entries', $dategroup);
if (isset($serendipity['short_archives']) && $serendipity['short_archives']) {
serendipity_smarty_fetch('ENTRIES', 'entries_summary.tpl', true);
|