Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23834
Modified Files:
Tag: branch-smarty
index.php serendipity_config.inc.php
serendipity_functions.inc.php serendipity_genpage.inc.php
serendipity_plugin_api.php
Log Message:
- Turn sidebars into smarty templates
TODO: Add some {if} logic to index.tpl so we don't display the sidebar when there are no plugins in it
- Add process time to index.php, for benchmark during development
Index: serendipity_config.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_config.inc.php,v
retrieving revision 1.93.2.4
retrieving revision 1.93.2.5
diff -u -d -r1.93.2.4 -r1.93.2.5
--- serendipity_config.inc.php 10 Sep 2004 15:48:28 -0000 1.93.2.4
+++ serendipity_config.inc.php 19 Sep 2004 00:31:25 -0000 1.93.2.5
@@ -15,7 +15,7 @@
include_once(S9Y_INCLUDE_PATH . 'compat.php');
-$serendipity['version'] = '0.7-beta1';
+$serendipity['version'] = '0.7-beta3';
$serendipity['defaultTemplate'] = 'default'; // Name of folder for the default theme
$serendipity['production'] = 1;
$serendipity['rewrite'] = 'none';
@@ -244,6 +244,8 @@
$serendipity['smarty']->register_modifier('emptyPrefix', 'serendipity_emptyPrefix');
$serendipity['smarty']->register_modifier('printf', 'serendipity_printf');
$serendipity['smarty']->register_modifier('formatTime', 'serendipity_smarty_formatTime');
+$serendipity['smarty']->register_function('serendipity_sidebar', 'serendipity_printSidebar');
+
/* vim: set sts=4 ts=4 expandtab : */
?>
Index: serendipity_plugin_api.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_plugin_api.php,v
retrieving revision 1.23
retrieving revision 1.23.2.1
diff -u -d -r1.23 -r1.23.2.1
--- serendipity_plugin_api.php 17 Jun 2004 20:57:10 -0000 1.23
+++ serendipity_plugin_api.php 19 Sep 2004 00:31:25 -0000 1.23.2.1
@@ -295,39 +295,34 @@
return serendipity_db_query($sql);
}
- function generate_plugins($side, $tagname = 'div')
+ function generate_plugins($side)
{
+ global $serendipity;
$plugins = serendipity_plugin_api::enum_plugins($side);
if (!is_array($plugins)) {
return;
}
-
- echo "<$tagname id=\"serendipity" . ucfirst($side) . "SideBar\">\n";
+
+ $pluginData = array();
foreach ($plugins as $plugin_data) {
$plugin =& serendipity_plugin_api::load_plugin($plugin_data['name']);
+ $class = get_class($plugin);
$title = '';
+ /* TODO: make generate_content NOT echo its output */
ob_start();
- if ($plugin->generate_content($title) !== false) {
- $content = ob_get_contents();
- $class = get_class($plugin);
- ob_end_clean();
+ $plugin->generate_content($title);
+ $content = ob_get_contents();
+ ob_end_clean();
- echo " <div class=\"$plugin->wrap_class sidebar_wrap_$class\">\n";
- if (!empty($title)) {
- echo " <h3 class=\"$plugin->title_class sidebar_title_$class\">$title</h3>\n";
- }
- echo " <div class=\"$plugin->content_class sidebar_content_$class\">\n";
- echo " $content\n";
- echo " </div>\n";
- echo " </div>\n";
- } else {
- ob_end_clean();
- }
+ $pluginData[] = array('side' => $side,
+ 'class' => get_class($plugin),
+ 'title' => $title,
+ 'content' => $content);
}
-
- echo "</$tagname>\n";
+ $serendipity['smarty']->assign('plugindata', $pluginData);
+ return serendipity_smarty_fetch('sidebar_'. $side, 'sidebar.tpl', true);
}
function get_plugin_title(&$plugin, $default_title = '')
Index: serendipity_genpage.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_genpage.inc.php,v
retrieving revision 1.33.2.6
retrieving revision 1.33.2.7
diff -u -d -r1.33.2.6 -r1.33.2.7
--- serendipity_genpage.inc.php 10 Sep 2004 22:20:25 -0000 1.33.2.6
+++ serendipity_genpage.inc.php 19 Sep 2004 00:31:25 -0000 1.33.2.7
@@ -34,7 +34,7 @@
'serendipityHTTPPath' => $serendipity['serendipityHTTPPath'],
'serendipityBaseURL' => $serendipity['baseURL'],
'serendipityRewritePrefix' => $serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '',
- 'serendipityIndexFile' => $serendipity['indexFile']
+ 'serendipityIndexFile' => $serendipity['indexFile'],
)
);
Index: index.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/index.php,v
retrieving revision 1.49.2.2
retrieving revision 1.49.2.3
diff -u -d -r1.49.2.2 -r1.49.2.3
--- index.php 14 Sep 2004 13:11:16 -0000 1.49.2.2
+++ index.php 19 Sep 2004 00:31:24 -0000 1.49.2.3
@@ -1,5 +1,14 @@
<?php # $Id$
+function microtime_float()
+{
+ list($usec, $sec) = explode(" ", microtime());
+ return ((float)$usec + (float)$sec);
+}
+
+$time_start = microtime_float();
+
+
// We need to set this to return a 200 since we use .htaccess ErrorDocument
// rules to handle archives.
header('HTTP/1.0 200\r\n');
@@ -218,5 +227,7 @@
$serendipity['smarty_file'] = '404.tpl';
}
$serendipity['smarty']->display(serendipity_getTemplateFile($serendipity['smarty_file'], 'serendipityPath'));
+
+echo '<center style="color: red; font-size: large">Process complete in '. (microtime_float()-$time_start) .' ms</center>';
/* 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.2.19
retrieving revision 1.419.2.20
diff -u -d -r1.419.2.19 -r1.419.2.20
--- serendipity_functions.inc.php 17 Sep 2004 09:44:55 -0000 1.419.2.19
+++ serendipity_functions.inc.php 19 Sep 2004 00:31:25 -0000 1.419.2.20
@@ -3453,6 +3453,8 @@
$output = $serendipity['smarty']->fetch('file:'. serendipity_getTemplateFile($file, 'serendipityPath'), null, null, ($echo === true && $serendipity['smarty_raw_mode']));
$serendipity['smarty']->assign($block, $output);
+
+ return $output;
}
function serendipity_emptyPrefix($string, $prefix = ': ') {
@@ -3467,6 +3469,13 @@
}
}
+function serendipity_printSidebar($params, &$smarty) {
+ if ( !isset($params['side']) ) {
+ $smarty->trigger_error(__FUNCTION__ .": missing 'side' parameter");
+ }
+ echo serendipity_plugin_api::generate_plugins($params['side']);
+}
+
function serendipity_smarty_formatTime($timestamp, $format) {
if (defined($format)) {
return serendipity_formatTime(constant($format), $timestamp);
|