I just started to use S9y and i felt a bit low featured with an HTML Block alone..
So i made up a lil Plugin to add a PHP Block.
Features:
- Parses PHP Code entered no more no less.
- Create a plugin folder e.g.: serendipity_plugin_phpbox
Put the code into the file: serendipity_plugin_phpbox.php
Move to your adminpanel and add the "PhpBox" Plugin.
Code: Select all
<?php # $Id: serendipity_plugin_phpbox.php,v 1.0 2004/06/22 13:45:48 garvinhicking Exp $
switch ($serendipity['lang']) {
case 'de': {
@define('PLUGIN_SIDEBAR_PHPBOX_NAME', 'PhpBox');
@define('PLUGIN_SIDEBAR_PHPBOX_DESC', 'PhpBox für PHP Code');
@define('THE_PHPBOX', 'Auszuführende Code.');
@define('TITLE_FOR_PHPBOX', 'Angezeigter box Titel.');
}
break;
case 'en':
default: {
@define('PLUGIN_SIDEBAR_PHPBOX_NAME', 'PhpBox');
@define('PLUGIN_SIDEBAR_PHPBOX_DESC', 'PhpBox for PHP Code.');
@define('THE_PHPBOX', 'Code to be evaled.');
@define('TITLE_FOR_PHPBOX', 'Box Title to be shown.');
}
break;
}
class serendipity_plugin_phpbox extends serendipity_plugin {
function introspect(&$propbag)
{
$propbag->add('name', PLUGIN_SIDEBAR_PHPBOX_NAME);
$propbag->add('description', PLUGIN_SIDEBAR_PHPBOX_DESC);
$propbag->add('configuration', array(
'title',
'content',
'markup',
'show_where'
)
);
$this->protected = TRUE; // If set to TRUE, only allows the owner of the plugin to modify its configuration
}
function introspect_config_item($name, &$propbag)
{
switch($name) {
case 'title':
$propbag->add('type', 'string');
$propbag->add('name', TITLE);
$propbag->add('description', TITLE_FOR_PHPBOX);
$propbag->add('default', '');
break;
case 'content':
$propbag->add('type', 'html');
$propbag->add('name', CONTENT);
$propbag->add('description', THE_PHPBOX);
$propbag->add('default', '');
break;
case 'show_where':
$select = array('extended' => PLUGIN_ITEM_DISPLAY_EXTENDED, 'overview' => PLUGIN_ITEM_DISPLAY_OVERVIEW, 'both' => PLUGIN_ITEM_DISPLAY_BOTH);
$propbag->add('type', 'select');
$propbag->add('select_values', $select);
$propbag->add('name', PLUGIN_ITEM_DISPLAY);
$propbag->add('description', '');
$propbag->add('default', 'both');
break;
default:
return false;
}
return true;
}
function generate_content(&$title)
{
global $serendipity;
$title = $this->get_config('title', $title);
$show_where = $this->get_config('show_where', 'both');
if ($show_where == 'extended' && (!isset($serendipity['GET']['id']) || !is_numeric($serendipity['GET']['id']))) {
return false;
} else if ($show_where == 'overview' && isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id'])) {
return false;
}
eval($this->get_config('content')); # Actualy this is the only BIG change to the HTML Block code.
}
}
?>