consistent plugin usage - bbcode
this and followup commits touches: use load_languiage API class method parenthesis "\n{\n <code>\n}\n", case break switches, consistent boolean usage, append css to eventData and other cleanups
This commit is contained in:
parent
a8218e8de3
commit
c29849f06a
@ -1,4 +1,8 @@
|
|||||||
<?php # $Id$
|
<?php
|
||||||
|
|
||||||
|
if (IN_serendipity !== true) {
|
||||||
|
die ("Don't hack!");
|
||||||
|
}
|
||||||
|
|
||||||
@serendipity_plugin_api::load_language(dirname(__FILE__));
|
@serendipity_plugin_api::load_language(dirname(__FILE__));
|
||||||
|
|
||||||
@ -13,9 +17,9 @@ class serendipity_event_bbcode extends serendipity_event
|
|||||||
$propbag->add('description', PLUGIN_EVENT_BBCODE_DESC);
|
$propbag->add('description', PLUGIN_EVENT_BBCODE_DESC);
|
||||||
$propbag->add('stackable', false);
|
$propbag->add('stackable', false);
|
||||||
$propbag->add('author', 'Jez Hancock, Garvin Hicking');
|
$propbag->add('author', 'Jez Hancock, Garvin Hicking');
|
||||||
$propbag->add('version', '2.09');
|
$propbag->add('version', '2.10');
|
||||||
$propbag->add('requirements', array(
|
$propbag->add('requirements', array(
|
||||||
'serendipity' => '0.8',
|
'serendipity' => '1.6',
|
||||||
'smarty' => '2.6.7',
|
'smarty' => '2.6.7',
|
||||||
'php' => '4.1.0'
|
'php' => '4.1.0'
|
||||||
));
|
));
|
||||||
@ -51,8 +55,8 @@ class serendipity_event_bbcode extends serendipity_event
|
|||||||
$propbag->add('configuration', $conf_array);
|
$propbag->add('configuration', $conf_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bbcode_callback($matches)
|
||||||
function bbcode_callback($matches) {
|
{
|
||||||
$type = $matches[1];
|
$type = $matches[1];
|
||||||
$input = trim($matches[2], "\r\n");
|
$input = trim($matches[2], "\r\n");
|
||||||
|
|
||||||
@ -102,11 +106,11 @@ class serendipity_event_bbcode extends serendipity_event
|
|||||||
return($input);
|
return($input);
|
||||||
}
|
}
|
||||||
|
|
||||||
function generate_content(&$title) {
|
function generate_content(&$title)
|
||||||
|
{
|
||||||
$title = $this->title;
|
$title = $this->title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function introspect_config_item($name, &$propbag)
|
function introspect_config_item($name, &$propbag)
|
||||||
{
|
{
|
||||||
switch($name) {
|
switch($name) {
|
||||||
@ -131,16 +135,19 @@ class serendipity_event_bbcode extends serendipity_event
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function install() {
|
function install()
|
||||||
|
{
|
||||||
serendipity_plugin_api::hook_event('backend_cache_entries', $this->title);
|
serendipity_plugin_api::hook_event('backend_cache_entries', $this->title);
|
||||||
}
|
}
|
||||||
|
|
||||||
function uninstall(&$propbag) {
|
function uninstall(&$propbag)
|
||||||
|
{
|
||||||
serendipity_plugin_api::hook_event('backend_cache_purge', $this->title);
|
serendipity_plugin_api::hook_event('backend_cache_purge', $this->title);
|
||||||
serendipity_plugin_api::hook_event('backend_cache_entries', $this->title);
|
serendipity_plugin_api::hook_event('backend_cache_entries', $this->title);
|
||||||
}
|
}
|
||||||
|
|
||||||
function bbcode($input) {
|
function bbcode($input)
|
||||||
|
{
|
||||||
static $bbcodes = null;
|
static $bbcodes = null;
|
||||||
|
|
||||||
// Only allow numbers and characters for CSS: "red", "#FF0000", ...
|
// Only allow numbers and characters for CSS: "red", "#FF0000", ...
|
||||||
@ -224,39 +231,42 @@ class serendipity_event_bbcode extends serendipity_event
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function event_hook($event, &$bag, &$eventData, $addData = null) {
|
function event_hook($event, &$bag, &$eventData, $addData = null)
|
||||||
|
{
|
||||||
global $serendipity;
|
global $serendipity;
|
||||||
|
|
||||||
$hooks = &$bag->get('event_hooks');
|
$hooks = &$bag->get('event_hooks');
|
||||||
|
|
||||||
if (isset($hooks[$event])) {
|
if (isset($hooks[$event])) {
|
||||||
|
|
||||||
switch($event) {
|
switch($event) {
|
||||||
|
|
||||||
case 'frontend_display':
|
case 'frontend_display':
|
||||||
|
|
||||||
foreach ($this->markup_elements as $temp) {
|
foreach ($this->markup_elements as $temp) {
|
||||||
if (serendipity_db_bool($this->get_config($temp['name'], true)) && isset($eventData[$temp['element']]) &&
|
if (serendipity_db_bool($this->get_config($temp['name'], 'true')) && isset($eventData[$temp['element']]) &&
|
||||||
!$eventData['properties']['ep_disable_markup_' . $this->instance] &&
|
!$eventData['properties']['ep_disable_markup_' . $this->instance] &&
|
||||||
!isset($serendipity['POST']['properties']['disable_markup_' . $this->instance])) {
|
!isset($serendipity['POST']['properties']['disable_markup_' . $this->instance])) {
|
||||||
$element = $temp['element'];
|
$element = $temp['element'];
|
||||||
$eventData[$element] = $this->bbcode($eventData[$element]);
|
$eventData[$element] = $this->bbcode($eventData[$element]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'frontend_comment':
|
case 'frontend_comment':
|
||||||
if (serendipity_db_bool($this->get_config('COMMENT', true))) {
|
if (serendipity_db_bool($this->get_config('COMMENT', 'true'))) {
|
||||||
echo '<div class="serendipity_commentDirection serendipity_comment_bbcode">' . PLUGIN_EVENT_BBCODE_TRANSFORM . '</div>';
|
echo '<div class="serendipity_commentDirection serendipity_comment_bbcode">' . PLUGIN_EVENT_BBCODE_TRANSFORM . '</div>';
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'css':
|
case 'css':
|
||||||
if (strpos($eventData, '.bb-code') !== false) {
|
// CSS class does NOT exist by user customized template styles, include default
|
||||||
// class exists in CSS, so a user has customized it and we don't need default
|
if (strpos($eventData, '.bb-code') === false) {
|
||||||
return true;
|
$eventData .= '
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
/* serendipity_event_bbcode start */
|
||||||
|
|
||||||
.bb-quote, .bb-code, .bb-php, .bb-code-title, .bb-php-title {
|
.bb-quote, .bb-code, .bb-php, .bb-code-title, .bb-php-title {
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
margin-right: 20px;
|
margin-right: 20px;
|
||||||
@ -294,17 +304,22 @@ class serendipity_event_bbcode extends serendipity_event
|
|||||||
.bb-list-ordered-ua {
|
.bb-list-ordered-ua {
|
||||||
list-style-type: upper-alpha;
|
list-style-type: upper-alpha;
|
||||||
}
|
}
|
||||||
<?php
|
|
||||||
return true;
|
/* serendipity_event_bbcode end */
|
||||||
|
|
||||||
|
';
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set sts=4 ts=4 expandtab : */
|
/* vim: set sts=4 ts=4 expandtab : */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user