Update of /cvsroot/php-blog/serendipity/include
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29422/include
Modified Files:
functions_entries.inc.php functions_smarty.inc.php
genpage.inc.php plugin_internal.inc.php
Log Message:
* Move Smarty object instancing to a function call, so that is not
created when not needed (like for CSS)
* make head_title / head_subtitle globally available, so that plugins
can also use it
* Code optimizations: Queries, referenced variables, plugin API
* Improved entryproperties cache
* Improved Plugin API calls to fetch titles of entries
* Improved Plugin aPI calls to set the authorid of a plugin
* Improved some plugins to not create costy introspect() calls, and move
them to the introspect_config_item() part
* Fixed trackexits plugin to not abuse the query() function too often
Index: plugin_internal.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/plugin_internal.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- plugin_internal.inc.php 19 Nov 2004 11:05:31 -0000 1.2
+++ plugin_internal.inc.php 19 Nov 2004 11:24:51 -0000 1.3
@@ -1,6 +1,8 @@
<?php # $Id$
class serendipity_calendar_plugin extends serendipity_plugin {
+ var $title = CALENDAR;
+
function introspect(&$propbag)
{
$propbag->add('name', CALENDAR);
@@ -37,7 +39,7 @@
{
global $serendipity;
- $title = CALENDAR;
+ $title = $this->title;
// Usage of serendipity_serverOffsetHour is as follow:
// * Whenever a date to display needs to be set, apply the timezone offset
@@ -223,6 +225,8 @@
} // end class
class serendipity_quicksearch_plugin extends serendipity_plugin {
+ var $title = QUICKSEARCH;
+
function introspect(&$propbag)
{
$propbag->add('name', QUICKSEARCH);
@@ -236,7 +240,7 @@
{
global $serendipity;
- $title = QUICKSEARCH;
+ $title = $this->title;
?>
<form id="searchform" action="<?php echo $serendipity['serendipityHTTPPath'] . $serendipity['indexFile']; ?>" method="get">
<div>
@@ -251,6 +255,8 @@
}
class serendipity_archives_plugin extends serendipity_plugin {
+ var $title = ARCHIVES;
+
function introspect(&$propbag)
{
$propbag->add('name', ARCHIVES);
@@ -288,7 +294,7 @@
{
global $serendipity;
- $title = ARCHIVES;
+ $title = $this->title;
$ts = mktime(0, 0, 0);
@@ -323,6 +329,8 @@
}
class serendipity_topreferrers_plugin extends serendipity_plugin {
+ var $title = TOP_REFERRER;
+
function introspect(&$propbag)
{
$propbag->add('name', TOP_REFERRER);
@@ -360,7 +368,7 @@
{
global $serendipity;
- $title = TOP_REFERRER;
+ $title = $this->title;
// get local configuration (default, true, false)
$use_links = $this->get_config('use_links', 'default');
@@ -379,6 +387,8 @@
}
class serendipity_topexits_plugin extends serendipity_plugin {
+ var $title = TOP_EXITS;
+
function introspect(&$propbag)
{
$propbag->add('name', TOP_EXITS);
@@ -416,7 +426,7 @@
{
global $serendipity;
- $title = TOP_EXITS;
+ $title = $this->title;
// get local configuration (default, true, false)
$use_links = $this->get_config('use_links', 'default');
@@ -435,6 +445,8 @@
}
class serendipity_syndication_plugin extends serendipity_plugin {
+ var $title = SYNDICATE_THIS_BLOG;
+
function introspect(&$propbag)
{
$propbag->add('name', SYNDICATION);
@@ -578,7 +590,7 @@
{
global $serendipity;
- $title = SYNDICATE_THIS_BLOG;
+ $title = $this->title;
if (serendipity_db_bool($this->get_config('show_0.91', true))) {
?>
@@ -715,6 +727,8 @@
}
class serendipity_superuser_plugin extends serendipity_plugin {
+ var $title = SUPERUSER;
+
function introspect(&$propbag)
{
$propbag->add('name', SUPERUSER);
@@ -729,7 +743,7 @@
{
global $serendipity;
- $title = SUPERUSER;
+ $title = $this->title;
if ($this->get_config('https', 'false') == 'true') {
$base = str_replace('http://', 'https://', $serendipity['baseURL']);
} else {
@@ -759,6 +773,8 @@
}
class serendipity_plug_plugin extends serendipity_plugin {
+ var $title = POWERED_BY;
+
function introspect(&$propbag)
{
$propbag->add('name', POWERED_BY);
@@ -797,7 +813,7 @@
{
global $serendipity;
- $title = POWERED_BY;
+ $title = $this->title;
?>
<div class="serendipityPlug">
<?php if ( $this->get_config('image', 'true') == 'true' ) { ?>
@@ -814,8 +830,11 @@
}
class serendipity_html_nugget_plugin extends serendipity_plugin {
+ var $title = HTML_NUGGET;
+
function introspect(&$propbag)
{
+ $this->title = $this->get_config('title', $this->title);
$propbag->add('name', HTML_NUGGET);
$propbag->add('description', HOLDS_A_BLAHBLAH);
$propbag->add('stackable', true);
@@ -875,7 +894,7 @@
{
global $serendipity;
- $title = $this->get_config('title', $title);
+ $title = $this->get_config('title', $this->title);
$show_where = $this->get_config('show_where', 'both');
if ($show_where == 'extended' && (!isset($serendipity['GET']['id']) || !is_numeric($serendipity['GET']['id']))) {
@@ -895,6 +914,8 @@
}
class serendipity_categories_plugin extends serendipity_plugin {
+ var $title = CATEGORIES;
+
function introspect(&$propbag) {
global $serendipity;
@@ -904,26 +925,24 @@
$propbag->add('author', 'Serendipity Team');
$propbag->add('version', '1.0');
$propbag->add('configuration', array('authorid', 'image'));
-
- $row_authors = serendipity_db_query("SELECT username, authorid FROM {$serendipity['dbPrefix']}authors");
- $authors = array('all' => ALL_AUTHORS);
- if (is_array($authors)) {
- foreach($row_authors AS $rownr => $row) {
- $authors[$row['authorid']] = $row['username'];
- }
- }
-
- $this->author_select_values = $authors;
}
function introspect_config_item($name, &$propbag)
{
switch($name) {
case 'authorid':
+ $row_authors = serendipity_db_query("SELECT username, authorid FROM {$serendipity['dbPrefix']}authors");
+ $authors = array('all' => ALL_AUTHORS);
+ if (is_array($authors)) {
+ foreach($row_authors AS $rownr => $row) {
+ $authors[$row['authorid']] = $row['username'];
+ }
+ }
+
$propbag->add('type', 'select');
$propbag->add('name', CATEGORIES_TO_FETCH);
$propbag->add('description', CATEGORIES_TO_FETCH_DESC);
- $propbag->add('select_values', $this->author_select_values);
+ $propbag->add('select_values', $authors);
$propbag->add('default', 'all');
break;
@@ -945,7 +964,7 @@
$which_category = $this->get_config('authorid');
$categories = serendipity_fetchCategories(empty($which_category) ? 'all' : $which_category);
- $title = CATEGORIES;
+ $title = $this->title;
$html = '';
$image = $this->get_config('image', serendipity_getTemplateFile('img/xml.gif'));
$image = (($image == "'none'" || $image == 'none') ? '' : $image);
Index: functions_smarty.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/functions_smarty.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- functions_smarty.inc.php 19 Nov 2004 11:05:31 -0000 1.2
+++ functions_smarty.inc.php 19 Nov 2004 11:24:51 -0000 1.3
@@ -106,10 +106,55 @@
function serendipity_smarty_assignDefaults($smartyvars = null) {
global $serendipity;
+
+ if (!isset($serendipity['smarty'])) {
+ @define('SMARTY_DIR', S9Y_INCLUDE_PATH . 'bundled-libs/Smarty/libs/');
+ require_once SMARTY_DIR . 'Smarty.class.php';
+ $serendipity['smarty'] = new Smarty;
+ if (!$serendipity['production']) {
+ $serendipity['smarty']->force_compile = true;
+ $serendipity['smarty']->debugging = true;
+ }
+ $serendipity['smarty']->template_dir = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'];
+ $serendipity['smarty']->compile_dir = $serendipity['serendipityPath'] . PATH_SMARTY_COMPILE;
+ $serendipity['smarty']->config_dir = &$serendipity['smarty']->template_dir;
+ $serendipity['smarty']->secure_dir = array($serendipity['serendipityPath'] . $serendipity['templatePath']);
+ $serendipity['smarty']->security_settings['MODIFIER_FUNCS'] = array('sprintf', 'sizeof', 'count');
+ $serendipity['smarty']->security = true;
+ $serendipity['smarty']->use_sub_dirs = false;
+ $serendipity['smarty']->compile_check = true;
+ $serendipity['smarty']->compile_id = &$serendipity['template'];
+
+ $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('formatTime', 'serendipity_smarty_formatTime');
+ $serendipity['smarty']->register_function('serendipity_printSidebar', 'serendipity_smarty_printSidebar');
+ $serendipity['smarty']->register_function('serendipity_hookPlugin', 'serendipity_smarty_hookPlugin');
+ $serendipity['smarty']->register_function('serendipity_getFile', 'serendipity_smarty_getFile');
+ $serendipity['smarty']->register_function('serendipity_printComments', 'serendipity_smarty_printComments');
+ $serendipity['smarty']->register_function('serendipity_printTrackbacks', 'serendipity_smarty_printTrackbacks');
+ }
+
+ if (!isset($serendipity['smarty_raw_mode'])) {
+ if (file_exists($serendipity['smarty']->template_dir . '/layout.php')) {
+ $serendipity['smarty_raw_mode'] = true;
+ } else {
+ $serendipity['smarty_raw_mode'] = false;
+ }
+ }
+
+ if (!isset($serendipity['smarty_file'])) {
+ $serendipity['smarty_file'] = 'index.tpl';
+ }
+
$serendipity['smarty']->assign(
array(
'head_charset' => LANG_CHARSET,
'head_version' => $serendipity['version'],
+ 'head_title' => $serendipity['head_title'],
+ 'head_subTitle' => $serendipity['head_subtitle'],
+
'CONST' => get_defined_constants(),
'is_xhtml' => $serendipity['XHTML11'],
Index: functions_entries.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/functions_entries.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- functions_entries.inc.php 19 Nov 2004 11:05:30 -0000 1.2
+++ functions_entries.inc.php 19 Nov 2004 11:24:35 -0000 1.3
@@ -632,7 +632,7 @@
if (!isset($serendipity['GET']['id']) &&
(!isset($serendipity['hidefooter']) || $serendipity['hidefooter'] == false) &&
- (count($entries) <= $serendipity['fetchLimit'])) {
+ ($num_entries <= $serendipity['fetchLimit'])) {
serendipity_printEntryFooter();
} else {
serendipity_printEntryFooter(true);
Index: genpage.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/genpage.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- genpage.inc.php 19 Nov 2004 11:05:31 -0000 1.2
+++ genpage.inc.php 19 Nov 2004 11:24:51 -0000 1.3
@@ -3,15 +3,8 @@
include_once(S9Y_INCLUDE_PATH . 'include/plugin_api.inc.php');
include_once(S9Y_INCLUDE_PATH . 'include/plugin_internal.inc.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_assignDefaults();
+
$serendipity['smarty']->assign(
array(
'leftSidebarElements' => serendipity_plugin_api::count_plugins('left'),
|