Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1:/tmp/cvs-serv26830
Modified Files:
serendipity_entries.php serendipity_entries_overview.inc.php
serendipity_genpage.inc.php serendipity_plugin_api.php
Log Message:
Code style
Index: serendipity_entries.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_entries.php,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- serendipity_entries.php 8 Jul 2003 09:13:27 -0000 1.12
+++ serendipity_entries.php 8 Jul 2003 12:14:17 -0000 1.13
@@ -1,126 +1,139 @@
<?php # $Id$
session_start();
-if (file_exists("./serendipity_config_local.inc.php")) {
- include("serendipity_config.inc.php");
+if (file_exists('./serendipity_config_local.inc.php')) {
+ include('serendipity_config.inc.php');
} else {
$_SESSION['serendipityAuthedUser'] = true;
}
+
// User logs in?
-if($_SESSION['serendipityAuthedUser'] || serendipity_authenticate_author($serendipity["POST"]["user"], $serendipity["POST"]["pass"])) {
- $_SESSION["serendipityAuthedUser"] = true;
- $serendipity["authorid"] = $_SESSION["serendipityAuthorid"];
+if ($_SESSION['serendipityAuthedUser']
+ || serendipity_authenticate_author($serendipity['POST']['user'], $serendipity['POST']['pass'])) {
+ $_SESSION['serendipityAuthedUser'] = true;
+ $serendipity['authorid'] = $_SESSION['serendipityAuthorid'];
}
?>
<html>
- <head>
- <title>Serendipity Authoring Suite</title>
- <link rel="stylesheet" type="text/css" href="<?php echo $serendipity['serendipityHTTPPath']; ?>serendipity.css.php">
+<head>
+ <title><?php echo SERENDIPITY_AUTHORING_SUITE; ?></title>
+ <link rel="stylesheet" type="text/css" href="<?php echo $serendipity['serendipityHTTPPath']; ?>serendipity.css.php" />
<?php
- if (strtolower($serendipity['extCSS'])!='none') echo "<link rel='stylesheet' type='text/css' href='{$serendipity['extCSS']}'>";
+if (strtolower($serendipity['extCSS']) != 'none' && $serendipity['extCSS'] != '') {
+?>
+ <link rel="stylesheet" type="text/css" href="<?php echo $serendipity['extCSS']; ?>" />
+<?php
+}
?>
- </head>
- <body>
-<div id="serendipity_banner">
- <h1><?php echo $serendipity['blogTitle'] ; ?></h1>
+</head>
+
+<body>
+ <div id="serendipity_banner">
+ <h1><?php echo $serendipity['blogTitle'] ; ?></h1>
<?php
- $sub = isset($serendipity['blogSubTitle']) ? $serendipity['blogSubTitle'] : $serendipity['blogDescription'];
- if (strlen($sub)) {
+$sub = isset($serendipity['blogSubTitle']) ? $serendipity['blogSubTitle'] : $serendipity['blogDescription'];
+if (strlen($sub)) {
?>
- <h2><?php echo $sub ; ?></h2>
+ <h2><?php echo $sub ; ?></h2>
<?php
- }
+}
?>
-</div>
- <table id="mainpane">
- <tr id="content" valign="top">
+
+ </div>
+
+ <table id="mainpane">
+ <tr id="content" valign="top">
<?php
- // User has to log in
- if ($_SESSION["serendipityAuthedUser"] !== true
- && file_exists($serendipity["serendipityPath"]."serendipity_config_local.inc.php")) {
+// User has to log in
+if ($_SESSION['serendipityAuthedUser'] !== true
+ && file_exists($serendipity['serendipityPath'] . 'serendipity_config_local.inc.php')) {
?>
- <td class="serendipity_admin">
- <div class='serendipity_auth_required'>
- <?php echo HAVE_TO_BE_LOGGED_ON; ?>
- <form action="?" method="post">
- <input type="hidden" name="serendipity[action]" value="admin">
- <input type="text" value="username" name="serendipity[user]" onfocus="value='';">
- <input type="password" value="password" name="serendipity[pass]" onfocus="value='';">
- <input type="submit" value=">">
- </form>
- </div>
+ <td class="serendipity_admin">
+ <div class='serendipity_auth_required'>
+ <?php echo HAVE_TO_BE_LOGGED_ON; ?>
+ <form action="?" method="post">
+ <input type="hidden" name="serendipity[action]" value="admin" />
+ <input type="text" name="serendipity[user]" value="username" onfocus="value='';" />
+ <input type="password" name="serendipity[pass]" value="password" onfocus="value='';" />
+ <input type="submit" name="submit" value=">">
+ </form>
+ </div>
<?php
- } else {
- // User is logged in
+} else {
+ // User is logged in
?>
- <td class="serendipitySideBar">
+ <td class="serendipitySideBar">
+ <div class="serendipitySideBarItem">
+ <div class="serendipitySideBarTitle"><?php echo ENTRIES; ?></div>
+ <div class="serendipitySideBarContent">
+ • <a href="?serendipity[adminModule]=entries&serendipity[adminAction]=new"><?php echo NEW_ENTRY; ?></a><br />
+ • <a href="?serendipity[adminModule]=entries&serendipity[adminAction]=editSelect"><?php echo EDIT_ENTRIES; ?></a><br />
+ • <a href="?serendipity[adminModule]=entries&serendipity[adminAction]=deleteSelect"><?php echo DELETE_ENTRIES; ?></a><br />
+ </div>
+ </div>
- <div class="serendipitySideBarItem">
- <div class="serendipitySideBarTitle"><?php echo ENTRIES; ?></div>
- <div class="serendipitySideBarContent">
- • <a href='?serendipity[adminModule]=entries&serendipity[adminAction]=new'><?php echo NEW_ENTRY; ?></a><br>
- • <a href='?serendipity[adminModule]=entries&serendipity[adminAction]=editSelect'><?php echo EDIT_ENTRIES; ?></a><br>
- • <a href='?serendipity[adminModule]=entries&serendipity[adminAction]=deleteSelect'><?php echo DELETE_ENTRIES; ?></a><br>
- </div>
- </div>
+ <div class="serendipitySideBarItem">
+ <div class="serendipitySideBarTitle"><?php echo CATEGORIES; ?></div>
+ <div class="serendipitySideBarContent">
+ • <a href="?serendipity[adminModule]=category&serendipity[adminAction]=editSelect"><?php echo EDIT_CATEGORIES; ?></a><br />
+ </div>
+ </div>
- <div class="serendipitySideBarItem">
- <div class="serendipitySideBarTitle"><?php echo CATEGORIES; ?></div>
- <div class="serendipitySideBarContent">
- • <a href='?serendipity[adminModule]=category&serendipity[adminAction]=editSelect'><?php echo EDIT_CATEGORIES; ?></a><br>
- </div>
- </div>
+ <div class="serendipitySideBarItem">
+ <div class="serendipitySideBarTitle"><?php echo IMAGES; ?></div>
+ <div class="serendipitySideBarContent">
+ • <a href="?serendipity[adminModule]=images&serendipity[adminAction]=addSelect"><?php echo ADD_IMAGES; ?></a><br />
+ • <a href="?serendipity[adminModule]=images"><?php echo MANAGE_IMAGES; ?></a><br />
+ • <a href="?serendipity[adminModule]=images&serendipity[adminAction]=genThumbs" onClick="return confirm('<?php echo WARNING_THIS_BLAHBLAH; ?>');"><?php echo CREATE_THUMBS; ?></a><br />
+ </div>
+ </div>
- <div class="serendipitySideBarItem">
- <div class="serendipitySideBarTitle"><?php echo IMAGES; ?></div>
- <div class="serendipitySideBarContent">
- • <a href='?serendipity[adminModule]=images&serendipity[adminAction]=addSelect'><?php echo ADD_IMAGES; ?></a><br>
- • <a href='?serendipity[adminModule]=images'><?php echo MANAGE_IMAGES; ?></a><br>
- • <a href='?serendipity[adminModule]=images&serendipity[adminAction]=genThumbs' onClick="return confirm('<?php echo WARNING_THIS_BLAHBLAH; ?>');"><?php echo CREATE_THUMBS; ?></a><br>
- </div>
- </div>
- • <a href="<?php echo $serendipity['serendipityHTTPPath']; ?>serendipity_admin.php"><?php echo ADMIN_INTERFACE; ?></a><br />
- • <a href="<?php echo $serendipity['serendipityHTTPPath']; ?>"><?php echo BACK_TO_BLOG; ?></a><br />
- • <a href="?serendipity[adminModule]=logout"><?php echo LOGOUT; ?></a><br />
- <img src="<?php echo $serendipity[baseURL]."templates/default/img/leer.png"?>" height="1" width="130" />
- </td>
- <td class="serendipity_admin">
- <div class="serendipity_admin_title"><?php echo SERENDIPITY_AUTHORING_SUITE; ?></div>
- <?php
- if (!$serendipity["GET"]["adminModule"]) $serendipity["GET"]["adminModule"] = $serendipity["POST"]["adminModule"];
- switch($serendipity["GET"]["adminModule"]) {
+ <div class="serendipitySideBarContent">
+ • <a href="<?php echo $serendipity['serendipityHTTPPath']; ?>serendipity_admin.php"><?php echo ADMIN_INTERFACE; ?></a><br />
+ • <a href="<?php echo $serendipity['serendipityHTTPPath']; ?>" ><?php echo BACK_TO_BLOG; ?></a><br />
+ • <a href="?serendipity[adminModule]=logout" ><?php echo LOGOUT; ?></a><br />
+
+ <img src="<?php echo $serendipity['baseURL'] . 'templates/default/img/leer.png'; ?>" height="1" width="130" alt="" />
+ </div>
+ </td>
- case "entries":
- include("serendipity_admin_entries.inc.php");
- break;
+ <td class="serendipity_admin">
+ <div class="serendipity_admin_title"><?php echo SERENDIPITY_AUTHORING_SUITE; ?></div>
+<?php
+ if (!$serendipity['GET']['adminModule']) {
+ $serendipity['GET']['adminModule'] = $serendipity['POST']['adminModule'];
+ }
- case "images":
- include("serendipity_admin_images.inc.php");
- break;
+ switch($serendipity['GET']['adminModule']) {
+ case 'entries':
+ include 'serendipity_admin_entries.inc.php';
+ break;
- case "category":
- include "serendipity_admin_category.inc.php";
- break;
+ case 'images':
+ include 'serendipity_admin_images.inc.php';
+ break;
- case "logout":
- session_destroy();
- echo "Logged out.";
- break;
+ case 'category':
+ include 'serendipity_admin_category.inc.php';
+ break;
- default:
- include("serendipity_entries_overview.inc.php");
+ case 'logout':
+ session_destroy();
+ echo LOGGEDOUT;
+ break;
- }
- ?>
- <?php
- }
- ?>
+ default:
+ include 'serendipity_entries_overview.inc.php';
+ }
+?>
</td>
- </tr>
- </table>
-
- </body>
+ </tr>
+ </table>
+<?php
+}
+?>
+</body>
</html>
<?php
/* vim: set sts=4 ts=4 expandtab : */
Index: serendipity_entries_overview.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_entries_overview.inc.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- serendipity_entries_overview.inc.php 8 Jul 2003 09:13:27 -0000 1.5
+++ serendipity_entries_overview.inc.php 8 Jul 2003 12:14:17 -0000 1.6
@@ -1,17 +1,19 @@
<?php # $Id$
##########################################################################
-# serendipity - another blogger... #
+# serendipity - another blogger... #
##########################################################################
# #
# (c) 2003 Jannis Hermanns <J...@ha...> #
-# http://www.jannis.to/programming/serendipity.html #
+# http://www.jannis.to/programming/serendipity.html #
# #
##########################################################################
-if (IN_serendipity !== true) die ("Don't hack!");
-?>
-Welcome back, <?php echo $_SESSION['serendipityUser'] ; ?>.
-<?php
+if (IN_serendipity !== true) {
+ die ('Don\'t hack!');
+}
+
+echo WELCOME_BACK . ' ' . $_SESSION['serendipityUser'];
+
/* 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.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- serendipity_genpage.inc.php 8 Jul 2003 09:13:27 -0000 1.11
+++ serendipity_genpage.inc.php 8 Jul 2003 12:14:17 -0000 1.12
@@ -3,29 +3,31 @@
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
-<title><?php echo htmlentities($serendipity['blogTitle']); ?></title>
-<link rel="stylesheet" type="text/css" href="<?php echo $serendipity['serendipityHTTPPath']; ?>serendipity.css.php" />
+ <title><?php echo htmlentities($serendipity['blogTitle']); ?></title>
+ <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']; ?>feeds/index.rss" />
+ <script language="Javascript" type="text/javascript" src="<?php echo $serendipity['serendipityHTTPPath']; ?>serendipity.js"></script>
<?php
- if (strtolower($serendipity['extCSS'])!='none') echo "<style type='text/css'>@import \"{$serendipity['extCSS']}\";</style>\n";
+ if (strtolower($serendipity['extCSS'])!='none') {
+?>
+ <style type="text/css">@import <?php echo $serendipity['extCSS']; ?>";</style>
+<?php
+ }
?>
-<link rel="alternate" type="application/rss+xml" title="RSS" href="<?php echo $serendipity['baseURL']; ?>feeds/index.rss" />
-<script language="Javascript" type="text/javascript" src="<?php echo $serendipity['serendipityHTTPPath']; ?>serendipity.js"></script>
</head>
-
<body>
<?php
-include_once("serendipity_config.inc.php");
-include_once("serendipity_plugin_api.php");
-include_once("serendipity_sidebar_items.php");
+include_once('serendipity_config.inc.php');
+include_once('serendipity_plugin_api.php');
+include_once('serendipity_sidebar_items.php');
-if ( file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . serendipity_get_config_var('template', 'default') ."/layout.php") ) {
- include $serendipity['templatePath'] . serendipity_get_config_var('template', 'default') ."/layout.php";
+if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . serendipity_get_config_var('template', 'default') . '/layout.php')) {
+ include $serendipity['templatePath'] . serendipity_get_config_var('template', 'default') . '/layout.php';
} else {
- include ($serendipity['templatePath'] ."default/layout.php");
+ include $serendipity['templatePath'] . 'default/layout.php';
}
?>
-
</body>
</html>
<?php
Index: serendipity_plugin_api.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_plugin_api.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- serendipity_plugin_api.php 8 Jul 2003 09:13:27 -0000 1.4
+++ serendipity_plugin_api.php 8 Jul 2003 12:14:17 -0000 1.5
@@ -1,15 +1,16 @@
<?php # $Id$
-if (IN_serendipity !== true) die ("Don't hack!");
+if (IN_serendipity !== true) {
+ die ('Don\'t hack!');
+}
include_once 'serendipity_functions.inc.php';
/* This file defines the plugin API for serendipity.
* By extending these classes, you can add your own code
* to appear in the sidebar(s) of serendipity.
- */
-
-/*
+ *
+ *
* The system defines a number of built-in plugins; these are
* identified by @class_name.
*
@@ -26,265 +27,301 @@
class serendipity_plugin_api {
- function register_default_plugins()
- {
- $classes = serendipity_plugin_api::enum_plugin_classes();
- foreach ($classes as $class_name) {
- if ($class_name{0} == '@') {
- serendipity_plugin_api::create_plugin_instance($class_name);
- }
- }
- }
-
- /* Create an instance of a plugin.
- * $plugin_class_id is of the form:
- * @class_name for a built-in plugin
- * or
- * plugin_dir_name for a third-party plugin
- * returns the instance identifier for the newly created plugin.
- *
- * TO BE IMPLEMENTED:
- * If $copy_from_instance is not null, and identifies another plugin
- * of the same class, then the persistent state will be copied.
- * This allows the user to clone a plugin.
- */
- function create_plugin_instance($plugin_class_id, $copy_from_instance=null)
- {
- global $serendipity;
-
- $id = md5(uniqid(""));
-
- $key = $plugin_class_id . ":" . $id;
-
- $rs = serendipity_db_query("SELECT MAX(sort_order) as sort_order_max FROM $serendipity[dbPrefix]plugins",true,'num');
-
- if (is_array($rs))
- $nextidx = intval($rs[0]+1);
- else
- $nextidx = 0;
-
- serendipity_db_query("INSERT INTO $serendipity[dbPrefix]plugins (name, sort_order) values ('$key', $nextidx)");
+ function register_default_plugins()
+ {
+ $classes = serendipity_plugin_api::enum_plugin_classes();
+ foreach ($classes as $class_name) {
+ if ($class_name{0} == '@') {
+ serendipity_plugin_api::create_plugin_instance($class_name);
+ }
+ }
+ }
+
+ /* Create an instance of a plugin.
+ * $plugin_class_id is of the form:
+ * @class_name for a built-in plugin
+ * or
+ * plugin_dir_name for a third-party plugin
+ * returns the instance identifier for the newly created plugin.
+ *
+ * TO BE IMPLEMENTED:
+ * If $copy_from_instance is not null, and identifies another plugin
+ * of the same class, then the persistent state will be copied.
+ * This allows the user to clone a plugin.
+ */
+ function create_plugin_instance($plugin_class_id, $copy_from_instance = null)
+ {
+ global $serendipity;
+
+ $id = md5(uniqid(''));
+
+ $key = $plugin_class_id . ':' . $id;
+
+ $rs = serendipity_db_query("SELECT MAX(sort_order) as sort_order_max FROM {$serendipity['dbPrefix']}plugins", true, 'num');
+
+ if (is_array($rs)) {
+ $nextidx = intval($rs[0]+1);
+ } else {
+ $nextidx = 0;
+ }
+
+ serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}plugins (name, sort_order) values ('$key', $nextidx)");
+
+ return $key;
+ }
+
+ function remove_plugin_instance($plugin_instance_id)
+ {
+ global $serendipity;
+ serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}plugins where name='$plugin_instance_id'");
+ }
+
+ /* Retrieves a list of available plugins */
+ function enum_plugin_classes()
+ {
+ global $serendipity;
+
+ $classes = array();
+
+ /* built-in classes first */
+ $cls = get_declared_classes();
+ foreach ($cls as $class_name) {
+ if (strncmp($class_name, 'serendipity_', 6)) {
+ continue;
+ }
- return $key;
- }
-
- function remove_plugin_instance($plugin_instance_id)
- {
- global $serendipity;
- serendipity_db_query("DELETE FROM $serendipity[dbPrefix]plugins where name='$plugin_instance_id'");
- }
+ $p = get_parent_class($class_name);
+ while ($p != 'serendipity_plugin' && $p !== false) {
+ $p = get_parent_class($p);
+ }
- /* Retrieves a list of available plugins */
- function enum_plugin_classes()
- {
- global $serendipity;
+ if ($p == 'serendipity_plugin') {
+ $classes[] = '@' . $class_name;
+ }
+ }
- $classes = array();
+ /* third-party classes next */
+ $d = opendir($serendipity['serendipityPath'] . 'plugins');
+ while (($f = readdir($d)) !== false) {
+ if ($f{0} == '.' || $f == 'CVS') {
+ continue;
+ }
- /* built-in classes first */
- $cls = get_declared_classes();
- foreach ($cls as $class_name) {
- if (strncmp($class_name, 'serendipity_', 6)) {
- continue;
- }
- $p = get_parent_class($class_name);
- while ($p != 'serendipity_plugin' && $p !== false) {
- $p = get_parent_class($p);
- }
- if ($p == 'serendipity_plugin') {
- $classes[] = '@' . $class_name;
- }
- }
- /* third-party classes next */
- $d = opendir($serendipity['serendipityPath'] . "plugins");
- while (($f = readdir($d)) !== false) {
- if ($f{0} == '.' || $f == 'CVS')
- continue;
- $classes[] = $f;
- }
- return $classes;
- }
+ $classes[] = $f;
+ }
+ return $classes;
+ }
+
+ /* Retrieves a list of plugin instances */
+ function enum_plugins($filter = '*')
+ {
+ global $serendipity;
- /* Retrieves a list of plugin instances */
- function enum_plugins($filter = '*')
- {
- global $serendipity;
- $sql = "SELECT * from $serendipity[dbPrefix]plugins ";
- if ($filter !== '*') {
- $sql .= "WHERE placement='$filter' ";
- }
- $sql .= " ORDER BY placement, sort_order";
+ $sql = "SELECT * from {$serendipity['dbPrefix']}plugins ";
- return serendipity_db_query($sql);
- }
+ if ($filter !== '*') {
+ $sql .= "WHERE placement='$filter' ";
+ }
- /* Creates an instance of a named plugin */
- function &load_plugin($instance_id)
- {
- global $serendipity;
+ $sql .= " ORDER BY placement, sort_order";
+
+ return serendipity_db_query($sql);
+ }
+
+ /* Creates an instance of a named plugin */
+ function &load_plugin($instance_id)
+ {
+ global $serendipity;
+
+ list($name, $uniq) = explode(':', $instance_id);
+
+ if ($name{0} == '@') {
+ $class_name = substr($name, 1);
+ } else {
+ /* plugin from the plugins/ dir */
+ if (!class_exists($name)) {
+
+ include $serendipity['serendipityPath'] . 'plugins/' . $name . '/' . $name . '.php';
+
+ if (!class_exists($name)) {
+ return false;
+ }
+ }
- list($name, $uniq) = explode(":", $instance_id);
+ $class_name = $name;
+ }
+
+ $p =& new $class_name($instance_id);
+
+ return $p;
+ }
+
+ function update_plugin_placement($name, $placement, $order=null)
+ {
+ global $serendipity;
- if ($name{0} == '@') {
- $class_name = substr($name, 1);
- } else {
- /* plugin from the plugins/ dir */
- if (!class_exists($name)) {
+ $sql = "UPDATE {$serendipity['dbPrefix']}plugins set placement='$placement' ";
- include $serendipity['serendipityPath'] . 'plugins/' . $name . '/' . $name . '.php';
+ if ($order !== null) {
+ $sql .= ", sort_order=$order ";
+ }
+
+ $sql .= "WHERE name='$name'";
- if (!class_exists($name)) {
- return false;
- }
- }
- $class_name = $name;
- }
+ return serendipity_db_query($sql);
+ }
+
+ function generate_plugins($side, $tagname = 'div')
+ {
+ $plugins = serendipity_plugin_api::enum_plugins($side);
- $p =& new $class_name($instance_id);
-
- return $p;
- }
+ if (!is_array($plugins)) {
+ return;
+ }
+
+ echo "<$tagname id=\"serendipity" . ucfirst($side) . "SideBar\">\n";
+ foreach ($plugins as $plugin_data) {
+ $plugin =& serendipity_plugin_api::load_plugin($plugin_data['name']);
+ $title = get_class($plugin);
- function update_plugin_placement($name, $placement, $order=null)
- {
- global $serendipity;
- $sql = "UPDATE $serendipity[dbPrefix]plugins set placement='$placement' ";
- if ($order !== null)
- $sql .= ", sort_order=$order ";
- $sql .= "WHERE name='$name'";
- return serendipity_db_query($sql);
- }
+ ob_start();
+ $plugin->generate_content($title);
+ $content = ob_get_contents();
+ ob_end_clean();
- function generate_plugins($side, $tagname='div')
- {
- $plugins = serendipity_plugin_api::enum_plugins($side);
- if (!is_array($plugins))
- return;
- echo "<$tagname id=\"serendipity" . ucfirst($side) . "SideBar\">\n";
- foreach ($plugins as $plugin_data) {
- $plugin =& serendipity_plugin_api::load_plugin($plugin_data['name']);
- $title = get_class($plugin);
- ob_start();
- $plugin->generate_content($title);
- $content = ob_get_contents();
- ob_end_clean();
- echo " <div class=\"$plugin->wrap_class\">\n <h3 class=\"$plugin->title_class\">$title</h3>\n <div class=\"$plugin->content_class\">$content\n </div>\n </div>\n";
- }
- echo "</$tagname>\n";
- }
+ echo " <div class=\"$plugin->wrap_class\">\n";
+ echo " <h3 class=\"$plugin->title_class\">$title</h3>\n";
+ echo " <div class=\"$plugin->content_class\">\n";
+ echo " $content\n";
+ echo " </div>\n";
+ echo " </div>\n";
+ }
+ echo "</$tagname>\n";
+ }
}
/* holds a bunch of properties; you can have multiple
- * properties with the same name */
+* properties with the same name */
class serendipity_property_bag {
- var $properties = array();
- var $name = null;
-
- function add($name, $value)
- {
- $this->properties[] = array(
- 'name' => $name,
- 'value' => $value
- );
- }
+ var $properties = array();
+ var $name = null;
- function get($name)
- {
- $v = array();
- foreach ($this->properties as $data) {
- if ($data['name'] == $name) {
- $v[] = $data['value'];
- }
- }
- if (count($v) == 1)
- return $v[0];
+ function add($name, $value)
+ {
+ $this->properties[] = array(
+ 'name' => $name,
+ 'value' => $value
+ );
+ }
+
+ function get($name)
+ {
+ $v = array();
+ foreach ($this->properties as $data) {
+ if ($data['name'] == $name) {
+ $v[] = $data['value'];
+ }
+ }
- return implode(", ", $v);
- }
+ if (count($v) == 1) {
+ return $v[0];
+ }
+
+ return implode(', ', $v);
+ }
+
+ function is_set($name)
+ {
+ foreach ($this->properties as $data) {
+ if ($data['name'] == $name) {
+ return true;
+ }
+ }
- function is_set($name)
- {
- foreach ($this->properties as $data) {
- if ($data['name'] == $name) {
- return true;
- }
- }
- return false;
- }
+ return false;
+ }
}
class serendipity_plugin {
- var $instance = null;
- var $wrap_class = 'serendipitySideBarItem';
- var $title_class = 'serendipitySideBarTitle';
- var $content_class = 'serendipitySideBarContent';
- /* Be sure to call this method from your derived classes constructors,
- * otherwise your config data will not be stored or retrieved correctly */
- function serendipity_plugin($instance)
- {
- $this->instance = $instance;
- }
-
- /* Called by serendipity when it wants to display information
- * about your plugin.
- * You need to override this method in your child class.
- */
- function introspect(&$propbag)
- {
- $propbag->add('copyright', 'MIT License');
- $propbag->add('name', get_class($this));
-
-// $propbag->add('configuration', array(
-// 'text field',
-// 'foo bar'
-// ));
- return true;
- }
-
- /* Called by serendipity when it wants to display the configuration
- * editor for your plugin.
- * $name is the name of a configuration item you added in
- * your instrospect method.
- * You need to fill the property bag with appropriate items
- * that describe the type and value(s) for that particular
- * configuration option.
- * You need to override this method in your child class if
- * you have configuration options.
- */
- function introspect_config_item($name, &$propbag)
- {
- return false;
- }
+ var $instance = null;
+ var $wrap_class = 'serendipitySideBarItem';
+ var $title_class = 'serendipitySideBarTitle';
+ var $content_class = 'serendipitySideBarContent';
- /* Called by serendipity when it wants your plugin to display itself.
- * You need to set $title to be whatever text you want want to
- * appear in the item caption space.
- * Simply echo/print your content to the output; serendipity will
- * capture it and make things work.
- * You need to override this method in your child class.
- */
- function generate_content(&$title)
- {
- $title = "Sample!";
- echo "This is a sample!";
- }
+ /* Be sure to call this method from your derived classes constructors,
+ * otherwise your config data will not be stored or retrieved correctly
+ */
- /* Fetches a configuration value for this plugin */
- function get_config($name, $defaultvalue = null)
- {
- $name = $this->instance . "/" . $name;
- return serendipity_get_config_var($name, $defaultvalue);
- }
+ function serendipity_plugin($instance)
+ {
+ $this->instance = $instance;
+ }
+
+ /* Called by serendipity when it wants to display information
+ * about your plugin.
+ * You need to override this method in your child class.
+ */
+ function introspect(&$propbag)
+ {
+ $propbag->add('copyright', 'MIT License');
+ $propbag->add('name' , get_class($this));
+
+ // $propbag->add(
+ // 'configuration',
+ // array(
+ // 'text field',
+ // 'foo bar'
+ // )
+ // );
+ return true;
+ }
+
+ /* Called by serendipity when it wants to display the configuration
+ * editor for your plugin.
+ * $name is the name of a configuration item you added in
+ * your instrospect method.
+ * You need to fill the property bag with appropriate items
+ * that describe the type and value(s) for that particular
+ * configuration option.
+ * You need to override this method in your child class if
+ * you have configuration options.
+ */
+ function introspect_config_item($name, &$propbag)
+ {
+ return false;
+ }
+
+ /* Called by serendipity when it wants your plugin to display itself.
+ * You need to set $title to be whatever text you want want to
+ * appear in the item caption space.
+ * Simply echo/print your content to the output; serendipity will
+ * capture it and make things work.
+ * You need to override this method in your child class.
+ */
+ function generate_content(&$title)
+ {
+ $title = 'Sample!';
+ echo 'This is a sample!';
+ }
+
+ /* Fetches a configuration value for this plugin */
+ function get_config($name, $defaultvalue = null)
+ {
+ $name = $this->instance . '/' . $name;
- function set_config($name, $value)
- {
- $name = $this->instance . "/" . $name;
- return serendipity_set_config_var($name, $value);
- }
+ return serendipity_get_config_var($name, $defaultvalue);
+ }
+
+ function set_config($name, $value)
+ {
+ $name = $this->instance . '/' . $name;
+ return serendipity_set_config_var($name, $value);
+ }
}
-include_once "serendipity_sidebar_items.php";
+include_once 'serendipity_sidebar_items.php';
+
/* vim: set sts=4 ts=4 expandtab : */
?>
|