1
0

Also support "last X" REST interface

This commit is contained in:
Garvin Hicking
2006-08-02 10:07:34 +00:00
commit 80e14346a5
1775 changed files with 195589 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
<?php # $Id$
/**
* @version $Revision$
* @author Ivan Cenov JWalker@abv.bg
* EN-Revision: 690
*/
@define('PLUGIN_EVENT_BBCODE_NAME', 'Текстово форматиране: BBCode');
@define('PLUGIN_EVENT_BBCODE_DESC', 'Форматиране на текст (постинг, коментар, HTML поле) с BBcode');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', 'Форматирането с <a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BBCode</a> е разрешено');
?>

View File

@@ -0,0 +1,5 @@
<?php # $Id: lang_ko.inc.php,v 1.0 2005/06/29 13:41:13 garvinhicking Exp $
@define('PLUGIN_EVENT_BBCODE_NAME', 'Textformatierung: BBCode');
@define('PLUGIN_EVENT_BBCODE_DESC', 'BBCode-Formatierung durchführen');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', '<a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BBCode</a>-Formatierung erlaubt');

View File

@@ -0,0 +1,12 @@
<?php # $Id: lang_es.inc.php,v 1.0 2005/08/20 11:37:42 garvinhicking Exp $
/**
* @version $Revision: 690 $
* @author Rodrigo Lazo Paz <rlazo.paz@gmail.com>
* EN-Revision: 690
*/
@define('PLUGIN_EVENT_BBCODE_NAME', 'Formato: BBCode');
@define('PLUGIN_EVENT_BBCODE_DESC', 'Dar formato al texto utilizando BBCode');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', 'Formato <a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BBCode</a> permitido');
?>

View File

@@ -0,0 +1,21 @@
<?php # $Id: lang_ja.inc.php,v 1.4 2005/05/17 11:37:42 garvinhicking Exp $
##########################################################################
# serendipity - another blogger... #
##########################################################################
# #
# (c) 2003 Jannis Hermanns <J@hacked.it> #
# http://www.jannis.to/programming/serendipity.html #
# #
# Translated by #
# Sebastian Mordziol <argh@php-tools.net> #
# http://sebastian.mordziol.de #
# #
##########################################################################
@define('PLUGIN_EVENT_BBCODE_NAME', 'Balises: BBCode');
@define('PLUGIN_EVENT_BBCODE_DESC', 'Permet l\'utilisation de balises BBCode dans le texte de vos billets');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', 'Syntaxe <a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BBCode</a> autorisée');
/* vim: set sts=4 ts=4 expandtab : */
?>

View File

@@ -0,0 +1,14 @@
<?php # $Id: lang_ja.inc.php 693 2005-11-13 07:25:16Z elf2000 $
/**
* @version $Revision$
* @author Tadashi Jokagi <elf2000@users.sourceforge.net>
* EN-Revision: 690
*/
@define('PLUGIN_EVENT_BBCODE_NAME', 'マークアップ: BB コード');
@define('PLUGIN_EVENT_BBCODE_DESC', 'BB コードを使用したテキストマークアップです。');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', '<a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BB コード</a> 書式を許可します。');
/* vim: set sts=4 ts=4 expandtab : */
?>

View File

@@ -0,0 +1,9 @@
<?php # $Id: lang_ko.inc.php,v 1.0 2005/06/29 13:41:13 garvinhicking Exp $
# Translated by: Wesley Hwang-Chung <wesley96@gmail.com>
# (c) 2005 http://www.tool-box.info/
@define('PLUGIN_EVENT_BBCODE_NAME', '마크업: BB코드');
@define('PLUGIN_EVENT_BBCODE_DESC', 'BB코드 마크업을 글에 적용함');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', '<a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BB코드</a>를 글에 쓸 수 있습니다.');
?>

View File

@@ -0,0 +1,13 @@
<?php # $Id: lang_en.inc.php 690 2005-11-13 04:49:04Z elf2000 $
/**
* @version $Revision: 690 $
* @author Kostas CoSTa Brzezinski <costa@kofeina.net>
* EN-Revision: Revision of lang_en.inc.php
*/
@define('PLUGIN_EVENT_BBCODE_NAME', 'Znacznik: BBCode');
@define('PLUGIN_EVENT_BBCODE_DESC', 'Przekształcaj tekst stosując tagi BBCode');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', '<a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BBCode</a> format dozwolony');
?>

View File

@@ -0,0 +1,20 @@
<?php # $Id:$
##########################################################################
# serendipity - another blogger... #
##########################################################################
# #
# (c) 2003 Jannis Hermanns <J@hacked.it> #
# http://www.jannis.to/programming/serendipity.html #
# #
# Translated by #
# João P Matos <jmatos@math.ist.utl.pt> #
# #
##########################################################################
@define('PLUGIN_EVENT_BBCODE_NAME', 'Código: BBCode');
@define('PLUGIN_EVENT_BBCODE_DESC', 'Permite usar no texto codificação BBCode');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', 'Sintaxe <a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BBCode</a> autorizada');
/* vim: set sts=4 ts=4 expandtab : */
?>

View File

@@ -0,0 +1,18 @@
<?php # $Id: $
##########################################################################
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity #
# Developer Team) All rights reserved. See LICENSE file for licensing #
# details #
# #
# (c) 2003 Jannis Hermanns <J@hacked.it> #
# http://www.jannis.to/programming/serendipity.html #
# #
# Translated by #
# (c) 2004-2005 CapriSkye <admin@capriskye.com> #
# http://open.38.com #
##########################################################################
@define('PLUGIN_EVENT_BBCODE_NAME', '標記語言: BBCode');
@define('PLUGIN_EVENT_BBCODE_DESC', '使用 BBCode 的標記語言');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', '<a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BBCode</a> 可用的格式');
?>

View File

@@ -0,0 +1,18 @@
<?php # $Id: $
##########################################################################
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity #
# Developer Team) All rights reserved. See LICENSE file for licensing #
# details #
# #
# (c) 2003 Jannis Hermanns <J@hacked.it> #
# http://www.jannis.to/programming/serendipity.html #
# #
# Translated by #
# (c) 2006 Aphonex Li <aphonex.li@gmail.com> #
# http://www.exten.cn #
##########################################################################
@define('PLUGIN_EVENT_BBCODE_NAME', '标记语言: BBCode');
@define('PLUGIN_EVENT_BBCODE_DESC', '使用 BBCode 的标记语言');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', '参考<a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BBCode</a> 可用的格式');
?>

View File

@@ -0,0 +1,13 @@
<?php # $Id:$
/**
* @version $Revision$
* @author Ivan Cenov JWalker@abv.bg
* EN-Revision: 690
*/
@define('PLUGIN_EVENT_BBCODE_NAME', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: BBCode');
@define('PLUGIN_EVENT_BBCODE_DESC', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, HTML <20><><EFBFBD><EFBFBD>) <20> BBcode');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BBCode</a> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
?>

View File

@@ -0,0 +1,5 @@
<?php # $Id: lang_ko.inc.php,v 1.0 2005/06/29 13:41:13 garvinhicking Exp $
@define('PLUGIN_EVENT_BBCODE_NAME', 'Textformatierung: BBCode');
@define('PLUGIN_EVENT_BBCODE_DESC', 'BBCode-Formatierung durchf<68>hren');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', '<a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BBCode</a>-Formatierung erlaubt');

View File

@@ -0,0 +1,13 @@
<?php # $Id$
/**
* @version $Revision$
* @author Translator Name <yourmail@example.com>
* EN-Revision: Revision of lang_en.inc.php
*/
@define('PLUGIN_EVENT_BBCODE_NAME', 'Markup: BBCode');
@define('PLUGIN_EVENT_BBCODE_DESC', 'Markup text using BBCode');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', '<a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BBCode</a> format allowed');
?>

View File

@@ -0,0 +1,12 @@
<?php # $Id: lang_es.inc.php,v 1.0 2005/08/20 11:37:42 garvinhicking Exp $
/**
* @version $Revision: 690 $
* @author Rodrigo Lazo Paz <rlazo.paz@gmail.com>
* EN-Revision: 690
*/
@define('PLUGIN_EVENT_BBCODE_NAME', 'Formato: BBCode');
@define('PLUGIN_EVENT_BBCODE_DESC', 'Dar formato al texto utilizando BBCode');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', 'Formato <a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BBCode</a> permitido');
?>

View File

@@ -0,0 +1,13 @@
<?php # $Id: lang_en.inc.php 690 2005-11-13 04:49:04Z elf2000 $
/**
* @version $Revision: 1 $
* @author Omid Mottaghi <webmaster@oxygenws.com>
* EN-Revision: Revision of lang_fa.inc.php
*/
@define('PLUGIN_EVENT_BBCODE_NAME', 'برچسب: BBCode');
@define('PLUGIN_EVENT_BBCODE_DESC', 'برچسب زدن به نوشته ها توسط BBCode');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', 'روش های <a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BB Code</a> مجاز می باشند');
?>

View File

@@ -0,0 +1,21 @@
<?php # $Id: lang_ja.inc.php,v 1.4 2005/05/17 11:37:42 garvinhicking Exp $
##########################################################################
# serendipity - another blogger... #
##########################################################################
# #
# (c) 2003 Jannis Hermanns <J@hacked.it> #
# http://www.jannis.to/programming/serendipity.html #
# #
# Translated by #
# Sebastian Mordziol <argh@php-tools.net> #
# http://sebastian.mordziol.de #
# #
##########################################################################
@define('PLUGIN_EVENT_BBCODE_NAME', 'Balises: BBCode');
@define('PLUGIN_EVENT_BBCODE_DESC', 'Permet l\'utilisation de balises BBCode dans le texte de vos billets');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', 'Syntaxe <a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BBCode</a> autoris<69>e');
/* vim: set sts=4 ts=4 expandtab : */
?>

View File

@@ -0,0 +1,14 @@
<?php # $Id$
/**
* @version $Revision$
* @author Tadashi Jokagi <elf2000@users.sourceforge.net>
* EN-Revision: 690
*/
@define('PLUGIN_EVENT_BBCODE_NAME', 'マークアップ: BB コード');
@define('PLUGIN_EVENT_BBCODE_DESC', 'BB コードを使用したテキストマークアップです。');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', '<a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BB コード</a> 書式を許可します。');
/* vim: set sts=4 ts=4 expandtab : */
?>

View File

@@ -0,0 +1,9 @@
<?php # $Id: lang_ko.inc.php,v 1.0 2005/06/29 13:41:13 garvinhicking Exp $
# Translated by: Wesley Hwang-Chung <wesley96@gmail.com>
# (c) 2005 http://www.tool-box.info/
@define('PLUGIN_EVENT_BBCODE_NAME', '마크업: BB코드');
@define('PLUGIN_EVENT_BBCODE_DESC', 'BB코드 마크업을 글에 적용함');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', '<a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BB코드</a>를 글에 쓸 수 있습니다.');
?>

View File

@@ -0,0 +1,13 @@
<?php # $Id: lang_en.inc.php 690 2005-11-13 04:49:04Z elf2000 $
/**
* @version $Revision: 690 $
* @author Kostas CoSTa Brzezinski <costa@kofeina.net>
* EN-Revision: Revision of lang_en.inc.php
*/
@define('PLUGIN_EVENT_BBCODE_NAME', 'Znacznik: BBCode');
@define('PLUGIN_EVENT_BBCODE_DESC', 'Przekszta<74>caj tekst stosuj<75>c tagi BBCode');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', '<a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BBCode</a> format dozwolony');
?>

View File

@@ -0,0 +1,20 @@
<?php # $Id:$
##########################################################################
# serendipity - another blogger... #
##########################################################################
# #
# (c) 2003 Jannis Hermanns <J@hacked.it> #
# http://www.jannis.to/programming/serendipity.html #
# #
# Translated by #
# Jo<4A>o P Matos <jmatos@math.ist.utl.pt> #
# #
##########################################################################
@define('PLUGIN_EVENT_BBCODE_NAME', 'C<>digo: BBCode');
@define('PLUGIN_EVENT_BBCODE_DESC', 'Permite usar no texto codifica<63><61>o BBCode');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', 'Sintaxe <a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BBCode</a> autorizada');
/* vim: set sts=4 ts=4 expandtab : */
?>

View File

@@ -0,0 +1,18 @@
<?php # $Id: $
##########################################################################
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity #
# Developer Team) All rights reserved. See LICENSE file for licensing #
# details #
# #
# (c) 2003 Jannis Hermanns <J@hacked.it> #
# http://www.jannis.to/programming/serendipity.html #
# #
# Translated by #
# (c) 2004-2005 CapriSkye <admin@capriskye.com> #
# http://open.38.com #
##########################################################################
@define('PLUGIN_EVENT_BBCODE_NAME', '標記語言: BBCode');
@define('PLUGIN_EVENT_BBCODE_DESC', '使用 BBCode 的標記語言');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', '<a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BBCode</a> 可用的格式');
?>

View File

@@ -0,0 +1,18 @@
<?php # $Id: $
##########################################################################
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity #
# Developer Team) All rights reserved. See LICENSE file for licensing #
# details #
# #
# (c) 2003 Jannis Hermanns <J@hacked.it> #
# http://www.jannis.to/programming/serendipity.html #
# #
# Translated by #
# (c) 2006 Aphonex Li <aphonex.li@gmail.com> #
# http://www.exten.cn #
##########################################################################
@define('PLUGIN_EVENT_BBCODE_NAME', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: BBCode');
@define('PLUGIN_EVENT_BBCODE_DESC', 'ʹ<><CAB9> BBCode <20>ı<EFBFBD><C4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
@define('PLUGIN_EVENT_BBCODE_TRANSFORM', '<27>ο<EFBFBD><a href="http://www.phpbb.com/phpBB/faq.php?mode=bbcode">BBCode</a> <20><><EFBFBD>õĸ<C3B5>ʽ');
?>

View File

@@ -0,0 +1,295 @@
<?php # $Id$
// Probe for a language include with constants. Still include defines later on, if some constants were missing
$probelang = dirname(__FILE__) . '/' . $serendipity['charset'] . 'lang_' . $serendipity['lang'] . '.inc.php';
if (file_exists($probelang)) {
include $probelang;
}
include dirname(__FILE__) . '/lang_en.inc.php';
class serendipity_event_bbcode extends serendipity_event
{
var $title = PLUGIN_EVENT_BBCODE_NAME;
function introspect(&$propbag)
{
global $serendipity;
$propbag->add('name', PLUGIN_EVENT_BBCODE_NAME);
$propbag->add('description', PLUGIN_EVENT_BBCODE_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Jez Hancock, Garvin Hicking');
$propbag->add('version', '2.04');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
$propbag->add('cachable_events', array('frontend_display' => true));
$propbag->add('event_hooks', array('frontend_display' => true, 'frontend_comment' => true, 'css' => true));
$propbag->add('groups', array('MARKUP'));
$this->markup_elements = array(
array(
'name' => 'ENTRY_BODY',
'element' => 'body',
),
array(
'name' => 'EXTENDED_BODY',
'element' => 'extended',
),
array(
'name' => 'COMMENT',
'element' => 'comment',
),
array(
'name' => 'HTML_NUGGET',
'element' => 'html_nugget',
)
);
$conf_array = array();
$conf_array[] = 'info';
foreach($this->markup_elements as $element) {
$conf_array[] = $element['name'];
}
$propbag->add('configuration', $conf_array);
}
function bbcode_callback($matches) {
$type = $matches[1];
$input = trim($matches[2], "\r\n");
switch ($type) {
case 'code':
$search_replace = array(
'&' => '&amp;',
' ' => '&#160;',
'&lt;' => '&#60;',
'<' => '&#60;',
'&gt;' => '&#62;',
'>' => '&#62;',
'&quot;' => '&#34;',
':' => '&#58;',
'[' => '&#91;',
']' => '&#93;',
')' => '&#41;',
'(' => '&#40;',
'*' => '&#42;',
'\t' => '&#160;&#160;&#160;&#160;',
'\\"' => '"',
"\\'" => "'"
);
$input = strtr($input, $search_replace);
break;
case 'php':
if (substr($input, 0, 2) != '<?') {
$input = "<?php\n\n$input\n\n?>";
}
ob_start();
highlight_string($input);
$input = ob_get_contents();
ob_end_clean();
$input = str_replace('<br />', "\n", $input);
break;
default:
return false;
}
$input = "<div class=\"bb-$type-title\">" . strtoupper($type) . ":</div>"
. "<div class=\"bb-$type\">$input</div>";
return($input);
}
function generate_content(&$title) {
$title = $this->title;
}
function introspect_config_item($name, &$propbag)
{
switch($name) {
case 'info':
$propbag->add('type', 'info');
$propbag->add('description', PLUGIN_EVENT_BBCODE_TRANSFORM);
break;
default:
$propbag->add('type', 'boolean');
$propbag->add('name', constant($name));
$propbag->add('description', sprintf(APPLY_MARKUP_TO, constant($name)));
$propbag->add('default', 'true');
break;
}
return true;
}
function install() {
serendipity_plugin_api::hook_event('backend_cache_entries', $this->title);
}
function uninstall() {
serendipity_plugin_api::hook_event('backend_cache_purge', $this->title);
serendipity_plugin_api::hook_event('backend_cache_entries', $this->title);
}
function bbcode($input) {
static $bbcodes = null;
// Only allow numbers and characters for CSS: "red", "#FF0000", ...
static $pattern_css = '([ 0-9a-z#-]+?)';
// Only allow strings occuring in emails: .-_@, 0-9, a-z
static $pattern_mail = '([\.\-\+~@_0-9a-z]+?)';
// Only allow strings occuring in URLs: &;?:.-_@/, 0-9, a-z
static $pattern_url = '([@!=~\?:&;0-9a-z#\.\-_\/,%\+]+?)';
// Disallow possibly evil HTML characters which may lead to Javascript XSS: '"();
static $pattern_query = '([^"\'\(\);]+?)';
// Note:
// * Anything between <xxx>...</xxx> tags will be caught by htmlspecialchars() and disallows custom HTML tags.
// * (?::\w+)? means "non capturing" match on any word character.
// * (?<!\\\\) means any bbcode which is not prefixed by \[...]
if ($bbcodes === null) {
$bbcodes = array(
'/(?<!\\\\)\[color(?::\w+)?=' . $pattern_css . '\](.*?)\[\/color(?::\w+)?\]/si' => "<span style=\"color:\\1\">\\2</span>",
'/(?<!\\\\)\[size(?::\w+)?=' . $pattern_css . '\](.*?)\[\/size(?::\w+)?\]/si' => "<span style=\"font-size:\\1\">\\2</span>",
'/(?<!\\\\)\[font(?::\w+)?=' . $pattern_css . '\](.*?)\[\/font(?::\w+)?\]/si' => "<span style=\"font-family:\\1\">\\2</span>",
'/(?<!\\\\)\[align(?::\w+)?=' . $pattern_css . '\](.*?)\[\/align(?::\w+)?\]/si' => "<div style=\"text-align:\\1\">\\2</div>",
'/(?<!\\\\)\[b(?::\w+)?\](.*?)\[\/b(?::\w+)?\]/si' => "<span style=\"font-weight:bold\">\\1</span>",
'/(?<!\\\\)\[i(?::\w+)?\](.*?)\[\/i(?::\w+)?\]/si' => "<span style=\"font-style:italic\">\\1</span>",
'/(?<!\\\\)\[u(?::\w+)?\](.*?)\[\/u(?::\w+)?\]/si' => "<span style=\"text-decoration:underline\">\\1</span>",
'/(?<!\\\\)\[center(?::\w+)?\](.*?)\[\/center(?::\w+)?\]/si' => "<div style=\"text-align:center\">\\1</div>",
'/(?<!\\\\)\[strike(?::\w+)?\](.*?)\[\/strike(?::\w+)?\]/si' => "<span style=\"text-decoration:line-through\">\\1</span>",
// [email]
'/(?<!\\\\)\[email(?::\w+)?\]' . $pattern_mail . '\[\/email(?::\w+)?\]/si' => "<a href=\"mailto:\\1\" class=\"bb-email\">\\1</a>",
'/(?<!\\\\)\[email(?::\w+)?=' . $pattern_mail . '\](.*?)\[\/email(?::\w+)?\]/si' => "<a href=\"mailto:\\1\" class=\"bb-email\">\\2</a>",
// [url]
'/(?<!\\\\)\[(google|search)\]' . $pattern_query . '\[\/(google|search)\]/si' => "<a href=\"http://www.google.com/search?q=\\2\" target=\"_blank\" class=\"bb-url\">\\2</a>",
'/(?<!\\\\)\[url(?::\w+)?\]www\.' . $pattern_url . '\[\/url(?::\w+)?\]/si' => "<a href=\"http://www.\\1\" target=\"_blank\" class=\"bb-url\">\\1</a>",
'/(?<!\\\\)\[url(?::\w+)?\]' . $pattern_url . '\[\/url(?::\w+)?\]/si' => "<a href=\"\\1\" target=\"_blank\" class=\"bb-url\">\\1</a>",
'/(?<!\\\\)\[url(?::\w+)?=' . $pattern_url . '?\](.*?)\[\/url(?::\w+)?\]/si' => "<a href=\"\\1\" target=\"_blank\" class=\"bb-url\">\\2</a>",
// [img]
'/(?<!\\\\)\[img(?::\w+)?\]' . $pattern_url . '\[\/img(?::\w+)?\]/si' => "<img src=\"\\1\" alt=\"\\1\" class=\"bb-image\" />",
'/(?<!\\\\)\[img(?::\w+)?=([0-9]*?)x([0-9]*?)\]' . $pattern_url . '\[\/img(?::\w+)?\]/si' => "<img width=\"\\1\" height=\"\\2\" src=\"\\3\" alt=\"\\3\" class=\"bb-image\" />",
// [quote]
'/(?<!\\\\)\[quote(?::\w+)?\](.*?)\[\/quote(?::\w+)?\]/si' => "<div class=\"bb-code-title\">QUOTE:<div class=\"bb-code\">\\1</div></div>",
'/(?<!\\\\)\[quote(?::\w+)?=(?:&quot;|"|\')?(.*?)["\']?(?:&quot;|"|\')?\](.*?)\[\/quote\]/si' => "<div class=\"bb-code-title\">QUOTE \\1:<div class=\"bb-code\">\\2</div></div>",
// [list]
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\*(?::\w+)?\](.*?)(?=(?:\s*<br\s*\/?>\s*)?\[\*|(?:\s*<br\s*\/?>\s*)?\[\/?list)/si' => "\n<li class=\"bb-listitem\">\\1</li>",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\/list(:(?!u|o)\w+)?\](?:<br\s*\/?>)?/si' => "\n</ul>",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\/list:u(:\w+)?\](?:<br\s*\/?>)?/si' => "\n</ul>",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\/list:o(:\w+)?\](?:<br\s*\/?>)?/si' => "\n</ul>",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(:(?!u|o)\w+)?\]\s*(?:<br\s*\/?>)?/si' => "\n<ul class=\"bb-list-unordered\">",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list:u(:\w+)?\]\s*(?:<br\s*\/?>)?/si' => "\n<ul class=\"bb-list-unordered\">",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list:o(:\w+)?\]\s*(?:<br\s*\/?>)?/si' => "\n<ul class=\"bb-list-ordered\">",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?::o)?(:\w+)?=1\]\s*(?:<br\s*\/?>)?/si' => "\n<ul class=\"bb-list-ordered bb-list-ordered-d\">",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?::o)?(:\w+)?=i\]\s*(?:<br\s*\/?>)?/s' => "\n<ul class=\"bb-list-ordered bb-list-ordered-lr\">",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?::o)?(:\w+)?=I\]\s*(?:<br\s*\/?>)?/s' => "\n<ul class=\"bb-list-ordered bb-list-ordered-ur\">",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?::o)?(:\w+)?=a\]\s*(?:<br\s*\/?>)?/s' => "\n<ul class=\"bb-list-ordered bb-list-ordered-la\">",
'/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?::o)?(:\w+)?=A\]\s*(?:<br\s*\/?>)?/s' => "\n<ul class=\"bb-list-ordered bb-list-ordered-ua\">",
// escaped tags like \[b], \[color], \[url], ...
'/\\\\(\[\/?\w+(?::\w+)*\])/' => "\\1"
);
}
/* Regular expressions taken from http://smarty.incutio.com/?page=BBCodePlugin Wiki (Andre Rabold) */
$input = preg_replace(array_keys($bbcodes), array_values($bbcodes), $input);
// [code] & [php]
$input = preg_replace_callback('/(?<!\\\\)\[(code|php)(?::\w+)?\](.*?)\[\/\\1(?::\w+)?\]/si', array($this, 'bbcode_callback'), $input);
return $input;
}
function event_hook($event, &$bag, &$eventData) {
global $serendipity;
$hooks = &$bag->get('event_hooks');
if (isset($hooks[$event])) {
switch($event) {
case 'frontend_display':
foreach ($this->markup_elements as $temp) {
if (serendipity_db_bool($this->get_config($temp['name'], true)) && isset($eventData[$temp['element']]) &&
!$eventData['properties']['ep_disable_markup_' . $this->instance] &&
!isset($serendipity['POST']['properties']['disable_markup_' . $this->instance])) {
$element = $temp['element'];
$eventData[$element] = $this->bbcode($eventData[$element]);
}
}
return true;
break;
case 'frontend_comment':
if (serendipity_db_bool($this->get_config('COMMENT', true))) {
echo '<div class="serendipity_commentDirection serendipity_comment_bbcode">' . PLUGIN_EVENT_BBCODE_TRANSFORM . '</div>';
}
return true;
break;
case 'css':
if (strpos($eventData, '.bb-code') !== false) {
// class exists in CSS, so a user has customized it and we don't need default
return true;
}
?>
.bb-code, .bb-php, .bb-code-title, .bb-php-title {
margin-left: 20px;
margin-right: 20px;
color: black;
direction: ltr;
}
.bb-code-title, .bb-php-title {
margin-bottom: 2px;
background-color:#CCCCCC;
font-weight: bold;
padding-left: 5px;
}
.bb-code, .bb-php {
font-family: courier, "courier new";
background-color: #DDDDDD;
padding: 10px;
}
.bb-list-ordered-d {
list-style-type: decimal;
}
.bb-list-ordered-la {
list-style-type: lower-alpha;
}
.bb-list-ordered-ua {
list-style-type: upper-alpha;
}
<?php
return true;
break;
default:
return false;
}
} else {
return false;
}
}
}
/* vim: set sts=4 ts=4 expandtab : */
?>