diff --git a/fp-interface/themes/leggero/leggero/res/admin.css b/fp-interface/themes/leggero/leggero/res/admin.css
index 632e0bc..567c09a 100755
--- a/fp-interface/themes/leggero/leggero/res/admin.css
+++ b/fp-interface/themes/leggero/leggero/res/admin.css
@@ -468,11 +468,11 @@ li.widget-class {
/* ===== CONFIG PANEL ===== */
-#admin-config dl {
+.option-set dl {
margin-bottom: 4em;
}
-#admin-config dt {
+.option-set dt {
width: 33%;
text-align:right;
margin-top: 1.8em;
@@ -480,23 +480,23 @@ li.widget-class {
font-weight: bold;
}
-#admin-config dt label {
+.option-set dt label {
padding-top: .2em;
}
-#admin-config dd {
+.option-set dd {
margin-left: 35%;
margin-top: -1.7em;
line-height: 1.5em;
}
-#admin-config dd p {
+.option-set dd p {
margin: 0;
}
-#admin-config dd input{
+.option-set dd input{
margin-bottom: .2em;
}
@@ -508,18 +508,18 @@ li.widget-class {
font-weight: bold;
}
-#admin-config input.textinput ,
-#admin-config select.textinput {
+.option-set input.textinput ,
+.option-set select.textinput {
width: 20em;
}
-#admin-config input.bigtextinput {
+.option-set input.bigtextinput {
width: 30em;
}
-#admin-config input.smalltextinput {
+.option-set input.smalltextinput {
width: 5em;
}
diff --git a/fp-plugins/bbcode/lang/lang.en-us.php b/fp-plugins/bbcode/lang/lang.en-us.php
new file mode 100644
index 0000000..5b8d91a
--- /dev/null
+++ b/fp-plugins/bbcode/lang/lang.en-us.php
@@ -0,0 +1,56 @@
+ 'BBCode Configuration',
+ 'desc1' => 'This plugin allows using
BBCode markup and provides '.
+ 'automatic integration with lightbox (when also enabled).',
+
+ 'options' => 'Options',
+
+ 'editing' => 'Editing',
+ 'allow_html'=> 'Inline HTML',
+ 'allow_html_long' => 'Enable using HTML along with BBCode',
+ 'toolbar' => 'Toolbar',
+ 'toolbar_long' => 'Enable the editor toolbar.',
+
+ 'other' => 'Other options',
+ 'comments' => 'Comments',
+ 'comments_long' => 'Allow BBCode in comments',
+ 'urlmaxlen' => 'URL max length',
+ 'urlmaxlen_long_pre' => 'Shorten URLs longer than ',
+ 'urlmaxlen_long_post'=>' characters.',
+ 'submit' => 'Save configuration',
+ 'msgs' => array(
+ 1 => 'BBCode configuration successful saved.',
+ -1 => 'BBCode configuration not saved.'
+ ),
+
+ 'editor' => array(
+ 'formatting' => 'Formatting',
+ 'textarea' => 'Textarea: ',
+ 'expand' => 'Expand',
+ 'expandtitle' => 'Expand Textarea Height',
+ 'reduce' => 'Reduce',
+ 'reducetitle' => 'Reduce Textarea Height',
+ // note: accesskeys are not internationalized...
+ // btw. why not :-D
+ 'bold' => 'B',
+ 'boldtitle' => 'Bold',
+ 'italic' => 'I',
+ 'italictitle' => 'Italic',
+ 'underline' => 'U',
+ 'underlinetitle' => 'Underlined',
+ 'quote' => 'Quote',
+ 'quotetitle' => 'Quote',
+ 'code' => 'Code',
+ 'codetitle' => 'Code',
+ 'help' => 'BBCode Help',
+ // currently not used
+ 'status' => 'Status bar',
+ 'statusbar' => 'Normal mode. Press <Esc> to switch editing mode.'
+ )
+);
+
+?>
diff --git a/fp-plugins/bbcode/panels/admin.plugin.panel.bbcode.php b/fp-plugins/bbcode/panels/admin.plugin.panel.bbcode.php
new file mode 100644
index 0000000..0406e58
--- /dev/null
+++ b/fp-plugins/bbcode/panels/admin.plugin.panel.bbcode.php
@@ -0,0 +1,69 @@
+smarty->assign('admin_resource', "plugin:bbcode/admin.plugin.bbcode");
+ }
+
+ /**
+ * Setups the default panel.
+ */
+ function main() {
+ $bbconf = plugin_getoptions('bbcode');
+
+ // pass sane values to form... is this really needed?
+ $this->smarty->assign(
+ 'bbchecked',
+ array(
+ isset($bbconf['escape-html']) && $bbconf['escape-html']
+ ? 1
+ : 0,
+ isset($bbconf['escape-html']) && $bbconf['comments']
+ ? 1
+ : 0,
+ isset($bbconf['escape-html']) && $bbconf['editor']
+ ? 1
+ : 0
+ )
+ );
+ $bbconf['number'] = isset($bbconf['url-maxlen']) && is_numeric($bbconf['url-maxlen'])
+ ? $bbconf['url-maxlen']
+ : 40;
+ $this->smarty->assign('bbconf', $bbconf);
+ }
+
+ /**
+ * Will be executed when the BBCode configuration is send.
+ *
+ * @return int
+ */
+ function onsubmit() {
+ if (isset($_POST['bb-conf'])){
+ $maxlen = isset($_POST['bb-maxlen']) && is_numeric($_POST['bb-maxlen'])
+ ? (int)$_POST['bb-maxlen']
+ : 40;
+ plugin_addoption('bbcode', 'escape-html', isset($_POST['bb-allow-html']));
+ plugin_addoption('bbcode', 'comments', isset($_POST['bb-comments']));
+ plugin_addoption('bbcode', 'editor', isset($_POST['bb-toolbar']));
+ plugin_addoption('bbcode', 'url-maxlen', $maxlen);
+ plugin_saveoptions('bbcode');
+ $this->smarty->assign('success', 1);
+ } else {
+ $this->smarty->assign('success', -1);
+ }
+ return 2;
+ }
+ }
+ admin_addpanelaction('plugin', 'bbcode', true);
+}
+
+?>
diff --git a/fp-plugins/bbcode/plugin.bbcode.php b/fp-plugins/bbcode/plugin.bbcode.php
index 9a51630..c52fe45 100644
--- a/fp-plugins/bbcode/plugin.bbcode.php
+++ b/fp-plugins/bbcode/plugin.bbcode.php
@@ -1,167 +1,193 @@
BBCode markup; provides automatic integration with lightbox
+Description: Allows using
BBCode markup; provides automatic integration with lightbox.
Author: Hydra, NoWhereMan
Author URI: http://flatpress.sf.net
*/
-define('BBCODE_ESCAPE_HTML', true);
-define('BBCODE_ENABLE_COMMENTS', false);
-define('BBCODE_USE_EDITOR', true);
-define('BBCODE_URL_MAXLEN', 40);
+require(plugin_getdir('bbcode') .'/inc/stringparser_bbcode.class.php');
+require(plugin_getdir('bbcode') .'/panels/admin.plugin.panel.bbcode.php');
-
-
-require plugin_getdir('bbcode') . '/inc/stringparser_bbcode.class.php';
-
-function plugin_bbcode_defines() {
-
- $funcs = explode(',', ini_get('disable_functions'));
-
+/**
+ * Setups the plugin.
+ */
+function plugin_bbcode_init() {
+ // defintions part
+ // load options
+ $bbconf = plugin_getoptions('bbcode');
+ // get defaults if not configured
+ define('BBCODE_ESCAPE_HTML', isset($bbconf['escape-html'])
+ ? $bbconf['escape-html']
+ : true
+ );
+ define('BBCODE_ENABLE_COMMENTS', isset($bbconf['comments'])
+ ? $bbconf['comments']
+ : false
+ );
+ define('BBCODE_USE_EDITOR', isset($bbconf['editor'])
+ ? $bbconf['editor']
+ : true
+ );
+ define('BBCODE_URL_MAXLEN', isset($bbconf['url-maxlen'])
+ ? $bbconf['url-maxlen']
+ : 40
+ );
if (!file_exists('getfile.php')) {
define('BBCODE_USE_WRAPPER', false);
- return;
- }
-
- if (in_array('readfile',$funcs)) {
- define('BBCODE_USE_WRAPPER', false);
} else {
- define('BBCODE_USE_WRAPPER', true);
+ $funcs = explode(',', ini_get('disable_functions'));
+ if (in_array('readfile', $funcs)) {
+ define('BBCODE_USE_WRAPPER', false);
+ } else {
+ define('BBCODE_USE_WRAPPER', true);
+ }
}
+ // filter part
+ #add_filter('comment_text', 'plugin_bbcode_comment');
+ add_filter('title_save_pre', 'wp_specialchars', 1);
+ if (BBCODE_ESCAPE_HTML) {
+ add_filter('content_save_pre', 'wp_specialchars', 1);
+ }
+ add_filter('pre_comment_author_name', 'wp_specialchars');
+ add_filter('pre_comment_content', 'wp_specialchars');
+ add_filter('the_content', 'BBCode', 1);
+ add_filter('the_excerpt', 'BBCode', 1);
+ add_filter('the_content', 'plugin_bbcode_undoHtml', 30);
+ if (BBCODE_USE_EDITOR) {
+ add_filter('editor_toolbar', 'plugin_bbcode_toolbar');
+ }
+ if (BBCODE_ENABLE_COMMENTS) {
+ add_filter('comment_text', 'plugin_bbcode_comment', 1);
+ }
}
+plugin_bbcode_init();
-plugin_bbcode_defines();
-
-
-
+/**
+ * Adds special stlye definitions into the HTML head.
+ *
+ */
function plugin_bbcode_style() {
- echo "\n\n";
- echo '
', "\n";
- echo "\n";
+ echo " \n";
+ echo '
\n";
+ echo " \n";
}
add_action('wp_head', 'plugin_bbcode_style');
-
+/**
+ * Remaps the URL so that there's no hint to your attachs/ directory.
+ *
+ * @param string $d
+ * @return boolean
+ */
function bbcode_remap_url(&$d) {
-
// NWM: "attachs/" is interpreted as a keyword, and it is translated to the actual path of ATTACHS_DIR
// CHANGE! we use the getfile.php script to mask the actual path of the attachs dir!
+ // DMKE: I got an idea about an integer-id based download/media manager... work-in-progress
-
- if (strpos($d, ':')===false) { // if is relative url
-
+ if (strpos($d, ':') === false) {
+ // if is relative url
// absolute path, relative to this server
- if ($d{0} == '/') {
- // BLOG_BASEURL contains a trailing slash in the end
- // if $d begins with a slash, we first strip it
- // otherwise the string would look like
- // http://mysite.com/flatpress//path/you/entered
- // ^^^ ugly double slash :P
+ if ($d[0] == '/') {
+ /*
+ BLOG_BASEURL contains a trailing slash in the end. If
+ $d begins with a slash, we first strip it otherwise
+ the string would look like
+ http://mysite.com/flatpress//path/you/entered
+ ^^ ugly double slash :P
+ */
$d = BLOG_BASEURL . substr($d, 1);
}
-
if (substr($d, 0, 8) == 'attachs/') {
-
- if (BBCODE_USE_WRAPPER) {
- $d = "getfile.php?f=" . basename($d) . "&dl=true";
- } else {
- $d = substr_replace ($d, ATTACHS_DIR, 0, 8 );
- }
-
- return true;
-
+ $d = BBCODE_USE_WRAPPER
+ ? 'getfile.php?f='. basename($d) .'&dl=true'
+ : substr_replace ($d, ATTACHS_DIR, 0, 8 );
+ return true;
}
-
if (substr($d, 0, 7) == 'images/') {
-
$d = substr_replace ($d, IMAGES_DIR, 0, 7 );
- $d = BBCODE_USE_WRAPPER? ("getfile.php?f=" . basename($d)) : $d;
-
+ $d = BBCODE_USE_WRAPPER
+ ? 'getfile.php?f='. basename($d)
+ : $d;
}
-
-
return true;
-
}
-
-
- if (strpos($d, 'www.')===0) {
+ if (strpos($d, 'www.') === 0) {
$d = 'http://' . $d;
}
-
return false;
}
-
-
+/**
+ * Function to link documents.
+ *
+ * @param string $action
+ * @param array $attributes
+ * @param string $content
+ * @param mixed $params Not used
+ * @param mixed $node_object Not used
+ * @return string
+ */
function do_bbcode_url ($action, $attributes, $content, $params, $node_object) {
if ($action == 'validate') {
return true;
}
-
// the code was specified as follows: [url]http://.../[/url]
-
-
if (!isset ($attributes['default'])) {
-
- /* cut url if longer than > BBCODE_URL_MAXLEN */
-
- $url = $content;
-
- if (($l = strlen($url))>BBCODE_URL_MAXLEN) {
- $t = (int)(BBCODE_URL_MAXLEN/2);
- $content = substr($url, 0, $t) .
- ' … ' .
- substr($url, $l-$t);
- }
-
-
+ // cut url if longer than > BBCODE_URL_MAXLEN
+ $url = $content;
+ if (($l = strlen($url)) > BBCODE_URL_MAXLEN) {
+ $t = (int)(BBCODE_URL_MAXLEN / 2);
+ $content = substr($url, 0, $t) .' … '. substr($url, $l-$t);
+ }
} else {
- // else the code was specified as follows: [url=http://.../]Text[/url]
+ // else the code was specified as follows: [url=http://.../]Text[/url]
$url = $attributes['default'];
}
-
- $the_url = ($local = bbcode_remap_url($url))? (BLOG_BASEURL . $url) : $url ;
+ $local = bbcode_remap_url($url);
+ $the_url = $local
+ ? (BLOG_BASEURL . $url)
+ : $url;
+ // DMKE: uh?
$content = $content;
-
-
-
- return '
'.$content.'';
+ $rel = isset($attributes['rel'])
+ ? ' rel="' . $attributes['rel'] . '"'
+ : '';
+ $extern = !$local
+ ? ' class="externlink" title="Go to '.$the_url.'"'
+ : '';
+ return '
'. $content .'';
}
-// Function to include images
-function do_bbcode_img ($action, $attributes, $content, $params, $node_object) {
-
+/**
+ * Function to include images.
+ *
+ * @param string $action
+ * @param array $attributes
+ * @param string $content
+ * @param mixed $params Not used
+ * @param mixed $node_object Not used
+ * @return string
+ */
+function do_bbcode_img($action, $attributes, $content, $params, $node_object) {
if ($action == 'validate') {
return true;
}
-
- if (!isset($attributes['default'])) return '[No valid img specified]';
-
+ if (!isset($attributes['default'])) {
+ return '[No valid img specified]';
+ }
$absolutepath = $actualpath = $attributes['default'];
- $image_is_local = false;
-
-
// NWM: "images/" is interpreted as a keyword, and it is translated to the actual path of IMAGES_DIR
$image_is_local = bbcode_remap_url($actualpath);
-
-
-
$float = ' class="center" ';
$popup_start = '';
$popup_end = '';
$alt = $title = basename($actualpath);
$img_size = array();
-
// let's disable socket functions for remote files
// slow remote servers may otherwise lockup the system
if ($image_is_local) {
@@ -182,128 +208,129 @@ function do_bbcode_img ($action, $attributes, $content, $params, $node_object) {
}
}
}
-
-
- $orig_w = $width = isset($img_size[0])? $img_size[0] : 0;
- $orig_h = $height = isset($img_size[1])? $img_size[1] : 0;
- $thumbpath = null;
-
-
-
- $scalefact = 0; // default: resize to 0, which means leaving it as it is, as width and hiehgt will be ignored ;)
- // scale attribute has priority over width and height
- // if scale is set popup is set to true automatically, unless it is explicitly set to false
+ $orig_w = $width = isset($img_size[0])
+ ? $img_size[0]
+ : 0;
+ $orig_h = $height = isset($img_size[1])
+ ? $img_size[1]
+ : 0;
+ $thumbpath = null;
+ // default: resize to 0, which means leaving it as it is, as width and hight will be ignored ;)
+ $scalefact = 0;
+ /*
+ scale attribute has priority over width and height if scale is
+ set popup is set to true automatically, unless it is explicitly
+ set to false
+ */
if (isset($attributes['scale'])) {
-
- if (substr($attributes['scale'], -1, 1) == '%') {
- $val = substr($attributes['scale'], 0,-1); // NN%, we ignore %
- } else { $val = $attributes['scale'] ; }
-
+ if (substr($attributes['scale'], -1, 1) == '%') {
+ // Format: NN%. We ignore %
+ $val = substr($attributes['scale'], 0, -1);
+ } else {
+ $val = $attributes['scale'];
+ }
$scalefact = $val / 100.0;
-
- $width = (int)($scalefact*$width);
- $height= (int)($scalefact*$height);
-
- // if both width and height are set, we assume proportions are ok
- }elseif (isset($attributes['width']) && isset($attributes['height'])) {
+ $width = (int)($scalefact * $width);
+ $height = (int)($scalefact * $height);
+ } elseif (isset($attributes['width']) && isset($attributes['height'])) {
+ // if both width and height are set, we assume proportions are ok
$width = (int)$attributes['width'];
$height = (int)$attributes['height'];
- // if width or height are set we calc proportions
- }elseif (isset($attributes['width'])) {
+ } elseif (isset($attributes['width'])) {
+ // if only width is set we calc proportions
$scalefact = $orig_w? ($attributes['width'] / $orig_w) : 0;
- $width = (int) $attributes['width'];
- $height = (int) ($scalefact*$orig_h);
-
- }elseif (isset($attributes['height'])) {
+ $width = (int)$attributes['width'];
+ $height = (int)($scalefact * $orig_h);
+ } elseif (isset($attributes['height'])) {
+ // if only height is set we calc proportions
$scalefact = $orig_w? ($attributes['height'] / $orig_h) : 0;
- $height = (int) $attributes['height'];
- $width = (int) ($scalefact*$orig_w);
+ $height = (int)$attributes['height'];
+ $width = (int)($scalefact * $orig_w);
+ }
+ if ($height < $orig_h) {
+ $attributes['popup'] = true;
}
-
-
- if ($height<$orig_h) $attributes['popup']=true;
-
-
-
if ($height != $orig_h) {
- /**
- * bbcode_img_scale_filter($actualpath, $img_props, $newsize)
- *
- */
-
+ #bbcode_img_scale_filter($actualpath, $img_props, $newsize)
$thumbpath = apply_filters(
- 'bbcode_img_scale',
- $actualpath,
- $img_size,
- array($width,$height)
+ 'bbcode_img_scale',
+ $actualpath,
+ $img_size,
+ array($width, $height)
);
}
+
if (isset($attributes['popup']) && ($attributes['popup'])) {
- $pop_width = ($orig_w) ? $orig_w : 800;
- $pop_height = ($orig_h) ? $orig_h : 600;
-
- $popup = ' onclick="' .
- "Popup=window.open('$absolutepath','Popup','toolbar=no,location=no,status=no,".
- "menubar=no,scrollbars=yes,resizable=yes,width=$pop_width,height=$pop_height');"
- .' return false;"';
-
- /**
- * plugin hook, here lightbox attachs
- */
-
- $popup = apply_filters('bbcode_img_popup', $popup, $absolutepath);
-
- $popup_start = ($attributes['popup']=='true') ?
- '
' : '';
- $popup_end = ($attributes['popup']=='true') ? '' : '';
- }
-
+ $pop_width = $orig_w
+ ? $orig_w
+ : 800;
+ $pop_height = $orig_h
+ ? $orig_h
+ : 600;
+ $popup = ' onclick="Popup=window.open("'. $absolutepath
+ .'","Popup","toolbar=no,location=no,status=no,"
+ ."menubar=no,scrollbars=yes,resizable=yes,width='
+ . $pop_width .',height='. $pop_height .'"); return false;"';
-
-
- $img_width = ($width)? ' width="'.$width.'"' : '';
- $img_height = ($height) ? ' height="'.$height.'"' : '' ;
-
- if (isset ($attributes['float'])
- && ($attributes['float']=='left' || $attributes['float']=='right')) {
- $float = ' class="float'.$attributes['float'].'" ' ;
+ // Plugin hook, here lightbox attachs
+ $popup = apply_filters('bbcode_img_popup', $popup, $absolutepath);
+ $popup_start = $attributes['popup'] == 'true'
+ ? '
'
+ : '';
+ $popup_end = $attributes['popup'] == 'true'
+ ? ''
+ : '';
}
-
-
- return $popup_start.'
 : ($absolutepath)). // $attributes['default'])
- ')
'.$popup_end;
+ $img_width = $width
+ ? ' width="'.$width.'"'
+ : '';
+ $img_height = $height
+ ? ' height="'.$height.'"'
+ : '' ;
+ if (isset($attributes['float'])) {
+ $float = ($attributes['float'] == 'left' || $attributes['float'] == 'right')
+ ? ' class="float'. $attributes['float'] .'"'
+ : ' class="center"';
+ }
+ $src = $thumbpath
+ ? (BLOG_BASEURL . $thumbpath)
+ : $absolutepath; // $attributes['default'])
+ $pop = $popup_start
+ ? ''
+ : ' title="'.$title.'" ';
+ return $popup_start .'

'. $popup_end;
}
-
-
-// Function for embedding videos
+/**
+ * Function for embedding videos
+ *
+ * @param string $action
+ * @param array $attr
+ * @param string $content
+ * @param mixed $params Not used
+ * @param mixed $node_object Not used
+ * @return string
+ */
function do_bbcode_video($action, $attr, $content, $params, $node_object) {
-
- if ($action=='validate') {
+ if ($action == 'validate') {
return true;
}
-
-
$vurl = parse_url($attr['default']);
if (isset($attr['type'])) {
$type = $attr['type'];
} else {
-
// is it http://www.MYSITE.com or http://MYSITE.com ?
$web = explode('.', $vurl['host']);
array_pop($web);
- $type = isset($web[1])? $web[1] : $web[0];
-
+ $type = isset($web[1])
+ ? $web[1]
+ : $web[0];
}
-
$query = utils_kexplode($vurl['query'], '=&');
-
$the_url = null;
$others = '';
switch ($type) {
@@ -315,139 +342,173 @@ function do_bbcode_video($action, $attr, $content, $params, $node_object) {
$the_url = "http://youtube.com/v/{$query['v']}";
break;
case 'default':
+ default:
$the_url = null;
}
-
if ($the_url) {
-
- $width = isset($attr['width'])? $attr['width'] : '400';
- $height = isset($attr['height'])? $attr['height'] : '326';
- $float = isset($attr['float'])? "float: {$attr['float']}" : '';
-
-
- return
- '
';
+ $width = isset($attr['width'])
+ ? $attr['width']
+ : '400';
+ $height = isset($attr['height'])
+ ? $attr['height']
+ : '326';
+ $float = isset($attr['float'])
+ ? "style=\"float: {$attr['float']}\" "
+ : '';
+ return '
';
}
-
return '[unsupported video]';
-
}
-
-
-
-// Function to return code
+/**
+ * Function to return code
+ *
+ * @param string $action
+ * @param array $attributes
+ * @param string $content
+ * @param mixed $params Not used
+ * @param mixed $node_object Not used
+ * @return string
+ */
function do_bbcode_code ($action, $attributes, $content, $params, $node_object) {
if ($action == 'validate') {
return true;
}
-
$temp_str = $content;
- $temp_str = str_replace( '
', chr(10), $temp_str );
- $temp_str = str_replace( chr(10).chr(10), chr(10), $temp_str );
- $temp_str = str_replace( chr(32), ' ', $temp_str );
-
+ $temp_str = str_replace('
', chr(10), $temp_str);
+ $temp_str = str_replace(chr(10). chr(10), chr(10), $temp_str);
+ $temp_str = str_replace(chr(32), ' ', $temp_str);
if (!BBCODE_ESCAPE_HTML) {
$temp_str = wp_specialchars($temp_str);
}
-
$a = '';
-
if (function_exists('plugin_syntaxhighlighter_foot')) {
if (isset($attributes['default'])) {
$a = $attributes['default'];
-
$p = explode(':', $a);
plugin_syntaxhighlighter_add($p[0]);
-
}
}
-
- return "
$temp_str
";
+ if ($a) {
+ $a = ' class="'. $a;
+ }
+ return '
'. $temp_str .'
';
}
-// Function to return html
-
+/**
+ * Function to return html
+ *
+ * @param string $action
+ * @param array $attributes
+ * @param string $content
+ * @param mixed $params Not used
+ * @param mixed $node_object Not used
+ * @return string
+ */
function do_bbcode_html ($action, $attributes, $content, $params, $node_object) {
-
if ($action == 'validate') {
return true;
}
-
static $count = 0;
-
// NWM: life is hell -___-'
-
- if(!isset($GLOBALS['BBCODE_TEMP_HTML']))
+ if (!isset($GLOBALS['BBCODE_TEMP_HTML'])) {
$GLOBALS['BBCODE_TEMP_HTML'] = array();
-
+ }
$GLOBALS['BBCODE_TEMP_HTML'][$count] = $content;
-
$str = "";
$count++;
-
return $str;
}
+/**
+ * Function to colorize text.
+ *
+ * @param string $action
+ * @param array $attributes
+ * @param string $content
+ * @param mixed $params Not used
+ * @param mixed $node_object Not used
+ * @return string
+ */
function do_bbcode_color ($action, $attributes, $content, $params, $node_object) {
if ($action == 'validate') {
return true;
}
- return "
$content";
-
+ return '
'. $content .'';
}
+
+/**
+ * Function to set font size.
+ *
+ * @param string $action
+ * @param array $attributes
+ * @param string $content
+ * @param mixed $params Not used
+ * @param mixed $node_object Not used
+ * @return string
+ */
function do_bbcode_size ($action, $attributes, $content, $params, $node_object) {
if ($action == 'validate') {
return true;
}
- return "
$content";
-
+ return '
'. $content .'';
}
-
+/**
+ * Function to align elements.
+ *
+ * @param string $action
+ * @param array $attributes
+ * @param string $content
+ * @param mixed $params Not used
+ * @param mixed $node_object Not used
+ * @return string
+ */
function do_bbcode_align($action, $attr, $content, $params, $node_object) {
- return "
{$content}
";
+ return '
'. $content .'
';
}
+/**
+ * Function to make a list.
+ *
+ * @param string $action
+ * @param array $attributes
+ * @param string $content
+ * @param mixed $params Not used
+ * @param mixed $node_object Not used
+ * @return string
+ */
function do_bbcode_list ($action, $attributes, $content, $params, $node_object) {
if ($action == 'validate') {
return true;
}
-
- if (isset($attributes['default']) &&
- $attributes['default']=='#') {
-
+ if (isset($attributes['default']) && $attributes['default'] == '#'
+ ) {
$list = 'ol';
-
} else {
$list = 'ul';
}
-
return "<$list>$content$list>";
}
-
-function &plugin_bbcode_init() {
-
+/**
+ * Initializes the BBCode parser.
+ *
+ * @return object
+ */
+function &plugin_bbcode_filter() {
static $bbcode = null;
-
if (!defined('BBCODE_INIT_DONE')) {
-
- $bbcode = new StringParser_BBCode ();
-
+ $bbcode = new StringParser_BBCode();
// If you set it to false the case-sensitive will be ignored for all codes
- $bbcode->setGlobalCaseSensitive (false);
+ $bbcode->setGlobalCaseSensitive(false);
$bbcode->setMixedAttributeTypes(true);
-
$BBCODE_TAGS_SIMPLE = array(
-
- 'b'=>'strong',
- 'i'=>'em',
- 'quote'=>'blockquote',
+ 'b' => 'strong',
+ 'i' => 'em',
+ 'quote' => 'blockquote',
'blockquote',
'strong',
'em',
@@ -455,325 +516,433 @@ function &plugin_bbcode_init() {
'del',
'hr','h2','h3','h4','h5','h6'
// u for underlined: see below
-
);
-
foreach ($BBCODE_TAGS_SIMPLE as $key => $val) {
-
if (!is_numeric($key)) {
$bbtag = $key;
$htmltag = $val;
} else {
$htmltag = $bbtag = $val;
}
-
- $bbcode->addCode ( $bbtag,
- 'simple_replace',
- null,
- array ('start_tag' => "<$htmltag>",
- 'end_tag' => "$htmltag>"),
- 'inline',
- array ('listitem',
- 'block',
- 'inline',
- 'link'),
- array ()
- );
-
- $bbcode->setCodeFlag ( $bbtag,
- 'closetag',
- BBCODE_CLOSETAG_MUSTEXIST
- );
-
+ $bbcode->addCode (
+ $bbtag,
+ 'simple_replace',
+ null,
+ array(
+ 'start_tag' => "<$htmltag>",
+ 'end_tag' => "$htmltag>"
+ ),
+ 'inline',
+ array(
+ 'listitem', 'block', 'inline', 'link'
+ ),
+ array()
+ );
+ $bbcode->setCodeFlag($bbtag, 'closetag', BBCODE_CLOSETAG_MUSTEXIST);
}
/* other tags */
-
- $bbcode->addCode ('u',
- 'simple_replace',
- null,
- array ('start_tag' => "
",
- 'end_tag' => ""),
- 'inline',
- array ('listitem',
- 'block',
- 'inline',
- 'link'),
- array ()
- );
-
-
-
- $bbcode->addCode (
- 'color',
- 'callback_replace',
- 'do_bbcode_color',
- array('usecontent_param' => array ('default')),
- 'inline',
- array ('listitem', 'block', 'inline', 'link'),
- array ());
-
- $bbcode->setCodeFlag ('color', 'closetag', BBCODE_CLOSETAG_MUSTEXIST);
-
- $bbcode->addCode (
- 'size',
- 'callback_replace',
- 'do_bbcode_size',
- array('usecontent_param' => array ('default')),
- 'inline',
- array ('listitem', 'block', 'inline', 'link'),
- array ());
-
- $bbcode->setCodeFlag ('color', 'closetag', BBCODE_CLOSETAG_MUSTEXIST);
-
-
-
- $bbcode->addCode (
- 'code',
- 'usecontent',
- 'do_bbcode_code',
- array (),
- 'inline',
- array ('listitem', 'block', 'inline', 'link'),
- array ());
-
- $bbcode->setCodeFlag ('code', 'closetag', BBCODE_CLOSETAG_MUSTEXIST);
-
-
-
- $bbcode->addCode (
- 'html',
- 'usecontent',
- 'do_bbcode_html',
- array (),
- 'inline',
- array ('listitem', 'block', 'inline', 'link'),
- array ());
-
- $bbcode->setCodeFlag ('html', 'closetag', BBCODE_CLOSETAG_MUSTEXIST);
-
-
-
- $bbcode->addCode (
- 'url',
- 'callback_replace',
- 'do_bbcode_url',
- array('usecontent_param' => array ('default', 'new')),
- 'link', array ('listitem', 'block', 'inline'),
- array ('link')
+ $bbcode->addCode(
+ 'u',
+ 'simple_replace',
+ null,
+ array(
+ 'start_tag' => '
',
+ 'end_tag' => ''
+ ),
+ 'inline',
+ array(
+ 'listitem', 'block', 'inline', 'link'),
+ array()
);
-
-
+ $bbcode->addCode(
+ 'color',
+ 'callback_replace',
+ 'do_bbcode_color',
+ array(
+ 'usecontent_param' => array('default')
+ ),
+ 'inline',
+ array(
+ 'listitem', 'block', 'inline', 'link'
+ ),
+ array()
+ );
+ $bbcode->setCodeFlag('color', 'closetag', BBCODE_CLOSETAG_MUSTEXIST);
+ $bbcode->addCode(
+ 'size',
+ 'callback_replace',
+ 'do_bbcode_size',
+ array(
+ 'usecontent_param' => array('default')
+ ),
+ 'inline',
+ array(
+ 'listitem', 'block', 'inline', 'link'
+ ),
+ array()
+ );
+ $bbcode->setCodeFlag('color', 'closetag', BBCODE_CLOSETAG_MUSTEXIST);
+ $bbcode->addCode(
+ 'code',
+ 'usecontent',
+ 'do_bbcode_code',
+ array(),
+ 'inline',
+ array(
+ 'listitem', 'block', 'inline', 'link'
+ ),
+ array()
+ );
+ $bbcode->setCodeFlag('code', 'closetag', BBCODE_CLOSETAG_MUSTEXIST);
+ $bbcode->addCode(
+ 'html',
+ 'usecontent',
+ 'do_bbcode_html',
+ array(),
+ 'inline',
+ array(
+ 'listitem', 'block', 'inline', 'link'
+ ),
+ array()
+ );
+ $bbcode->setCodeFlag('html', 'closetag', BBCODE_CLOSETAG_MUSTEXIST);
+ $bbcode->addCode(
+ 'url',
+ 'callback_replace',
+ 'do_bbcode_url',
+ array(
+ 'usecontent_param' => array('default', 'new')
+ ),
+ 'link',
+ array(
+ 'listitem', 'block', 'inline'
+ ),
+ array('link')
+ );
+ $bbcode->addCode(
+ 'img',
+ 'callback_replace_single',
+ 'do_bbcode_img',
+ array(
+ 'usecontent_param' => array(
+ 'default', 'float', 'alt', 'popup', 'width', 'height', 'title'
+ )
+ ),
+ 'image',
+ array(
+ 'listitem', 'block', 'inline', 'link'
+ ),
+ array());
+ $bbcode->setCodeFlag('img', 'closetag', 'BBCODE_CLOSETAG_FORBIDDEN');
+ $bbcode->addCode(
+ 'video',
+ 'callback_replace_single',
+ 'do_bbcode_video',
+ array(
+ 'usecontent_param' => array(
+ 'default', 'float', 'width', 'height'
+ )
+ ),
+ 'image',
+ array(
+ 'listitem', 'block', 'inline', 'link'
+ ),
+ array()
+ );
+ $bbcode->setCodeFlag('video', 'closetag', 'BBCODE_CLOSETAG_FORBIDDEN');
$bbcode->addCode (
- 'img',
- 'callback_replace_single',
- 'do_bbcode_img',
- array ('usecontent_param' =>
- array ('default', 'float', 'alt',
- 'popup', 'width', 'height', 'title')
- ),
- 'image', array ('listitem', 'block',
- 'inline', 'link'),
- array ());
- $bbcode->setCodeFlag ('img', 'closetag', 'BBCODE_CLOSETAG_FORBIDDEN');
-
-
- $bbcode->addCode (
- 'video',
- 'callback_replace_single',
- 'do_bbcode_video',
- array ('usecontent_param' =>
- array ('default', 'float', 'width', 'height')),
- 'image', array ('listitem', 'block', 'inline', 'link'),
- array ());
- $bbcode->setCodeFlag ('video', 'closetag', 'BBCODE_CLOSETAG_FORBIDDEN');
-
-
-
- $bbcode->addCode ( 'list',
- 'callback_replace',
- 'do_bbcode_list',
- array ('start_tag' => '
'),
- 'list',
- array ('block', 'listitem'),
- array ());
- $bbcode->setCodeFlag ('list', 'closetag', BBCODE_CLOSETAG_MUSTEXIST);
- $bbcode->setCodeFlag ('list', 'paragraph_type', BBCODE_PARAGRAPH_BLOCK_ELEMENT);
- $bbcode->setCodeFlag ('list', 'opentag.before.newline', BBCODE_NEWLINE_DROP);
- $bbcode->setCodeFlag ('list', 'closetag.before.newline', BBCODE_NEWLINE_DROP);
-
-
-
- $bbcode->addCode ('*', 'simple_replace', null, array ('start_tag' => '
', 'end_tag' => ''),
- 'listitem', array ('list'), array ());
- $bbcode->setCodeFlag ('*', 'closetag', BBCODE_CLOSETAG_OPTIONAL);
- $bbcode->setCodeFlag ('*', 'paragraphs', false);
-
-
- $bbcode->addCode (
- 'align',
- 'callback_replace',
- 'do_bbcode_align',
- array ('usecontent_param' =>
- array ('default')
- ),
- 'block', array ('listitem', 'block',
- 'inline', 'link'),
- array ());
-
-
-
-
+ 'list',
+ 'callback_replace',
+ 'do_bbcode_list',
+ array(
+ 'start_tag' => '
'
+ ),
+ 'list',
+ array(
+ 'block', 'listitem'
+ ),
+ array()
+ );
+ $bbcode->setCodeFlag('list', 'closetag', BBCODE_CLOSETAG_MUSTEXIST);
+ $bbcode->setCodeFlag('list', 'paragraph_type', BBCODE_PARAGRAPH_BLOCK_ELEMENT);
+ $bbcode->setCodeFlag('list', 'opentag.before.newline', BBCODE_NEWLINE_DROP);
+ $bbcode->setCodeFlag('list', 'closetag.before.newline', BBCODE_NEWLINE_DROP);
+ $bbcode->addCode(
+ '*',
+ 'simple_replace',
+ null,
+ array(
+ 'start_tag' => '
',
+ 'end_tag' => ''
+ ),
+ 'listitem',
+ array('list'),
+ array()
+ );
+ $bbcode->setCodeFlag('*', 'closetag', BBCODE_CLOSETAG_OPTIONAL);
+ $bbcode->setCodeFlag('*', 'paragraphs', false);
+ $bbcode->addCode(
+ 'align',
+ 'callback_replace',
+ 'do_bbcode_align',
+ array(
+ 'usecontent_param' => array('default')
+ ),
+ 'block',
+ array(
+ 'listitem', 'block', 'inline', 'link'
+ ),
+ array()
+ );
define('BBCODE_INIT_DONE', true);
-
+ // DMKE: there's no bbcode_init filter defined
$bbcode = apply_filters('bbcode_init', $bbcode);
-
- }
-
+ }
return $bbcode;
-
}
-
-
+/**
+ * Enter description here...
+ *
+ * @param string $text
+ * @return string
+ */
function BBCode($text) {
-
- $bbcode =& plugin_bbcode_init();
-
+ $bbcode =& plugin_bbcode_filter();
return $bbcode->parse($text);
}
-
-
-
-
+/**
+ * Adds a Toolbar to admin panels write entry.
+ *
+ * @global $_FP_SMARTY
+ */
function plugin_bbcode_toolbar() {
-
+ global $_FP_SMARTY;
+ // get all available images
$indexer = new fs_filelister(IMAGES_DIR);
$imageslist = $indexer->getList();
array_unshift($imageslist, '--');
-
+ $_FP_SMARTY->assign('images_list', $imageslist);
+ // get all available attachements
$indexer = new fs_filelister(ATTACHS_DIR);
$attachslist = $indexer->getList();
array_unshift($attachslist, '--');
-
- global $_FP_SMARTY;
-
- $_FP_SMARTY->assign('images_list', $imageslist);
$_FP_SMARTY->assign('attachs_list', $attachslist);
-
-
- echo "\n\n";
-
- echo '', "\n";
+ // DMKE: does not work
+ #$bblang = lang_load('plugin:bbcode');
+ #$_FP_SMARTY->assign('bblang', $bblang);
+ echo "\n";
+ echo ''."\n";
echo $_FP_SMARTY->fetch('plugin:bbcode/toolbar');
-
echo "\n";
-
}
-
+/**
+ * Simplified codes for comments.
+ *
+ * @param string $text
+ * @return strng
+ */
function plugin_bbcode_comment($text) {
-
- $bbcode = new StringParser_BBCode ();
-
+ $bbcode = new StringParser_BBCode();
// If you set it to false the case-sensitive will be ignored for all codes
$bbcode->setGlobalCaseSensitive (false);
$bbcode->setMixedAttributeTypes(true);
-
-
- // [B]
- $bbcode->addCode ('b', 'simple_replace', null, array ('start_tag' => '
', 'end_tag' => ''),
- 'inline', array ('listitem', 'block', 'inline', 'link'), array ());
- // [STRONG]
- $bbcode->addCode ('strong', 'simple_replace', null, array ('start_tag' => '
', 'end_tag' => ''),
- 'inline', array ('listitem', 'block', 'inline', 'link'), array ());
-
- // [I]
- $bbcode->addCode ('i', 'simple_replace', null, array ('start_tag' => '
', 'end_tag' => ''),
- 'inline', array ('listitem', 'block', 'inline', 'link'), array ());
- // [EM]
- $bbcode->addCode ('em', 'simple_replace', null, array ('start_tag' => '
', 'end_tag' => ''),
- 'inline', array ('listitem', 'block', 'inline', 'link'), array ());
- // [INS]
- $bbcode->addCode ('ins', 'simple_replace', null, array ('start_tag' => '
', 'end_tag' => ''),
- 'inline', array ('listitem', 'block', 'inline', 'link'), array ());
- // [U]
- $bbcode->addCode ('u', 'simple_replace', null, array ('start_tag' => '
', 'end_tag' => ''),
- 'inline', array ('listitem', 'block', 'inline', 'link'), array ());
- // [DEL]
- $bbcode->addCode ('del', 'simple_replace', null, array ('start_tag' => '
', 'end_tag' => ''),
- 'inline', array ('listitem', 'block', 'inline', 'link'), array ());
- // [STRIKE]
- $bbcode->addCode ('strike', 'simple_replace', null, array ('start_tag' => '
', 'end_tag' => ''),
- 'inline', array ('listitem', 'block', 'inline', 'link'), array ());
- // [BLOCKQUOTE]
- $bbcode->addCode ('blockquote', 'simple_replace', null, array ('start_tag' => '
', 'end_tag' => '
'),
- 'inline', array ('listitem', 'block', 'inline', 'link'), array ());
- // [QUOTE]
- $bbcode->addCode ('quote', 'simple_replace', null, array ('start_tag' => '
', 'end_tag' => '
'),
- 'inline', array ('listitem', 'block', 'inline', 'link'), array ());
- // [PRE]
- $bbcode->addCode ('pre', 'simple_replace', null, array ('start_tag' => '
', 'end_tag' => '
'),
- 'inline', array ('listitem', 'block', 'inline', 'link'), array ());
- // [CODE]
- $bbcode->addCode ('code', 'usecontent', 'do_bbcode_code', array (),
- 'inline', array ('listitem', 'block', 'inline', 'link'), array ());
-
+ $bbcode->addCode(
+ 'b',
+ 'simple_replace',
+ null,
+ array(
+ 'start_tag' => '
',
+ 'end_tag' => ''
+ ),
+ 'inline',
+ array(
+ 'listitem', 'block', 'inline', 'link'
+ ),
+ array()
+ );
+ $bbcode->addCode(
+ 'strong',
+ 'simple_replace',
+ null,
+ array(
+ 'start_tag' => '
',
+ 'end_tag' => ''
+ ),
+ 'inline',
+ array(
+ 'listitem', 'block', 'inline', 'link'
+ ),
+ array()
+ );
+ $bbcode->addCode(
+ 'i',
+ 'simple_replace',
+ null,
+ array(
+ 'start_tag' => '
',
+ 'end_tag' => ''
+ ),
+ 'inline',
+ array(
+ 'listitem', 'block', 'inline', 'link'
+ ),
+ array()
+ );
+ $bbcode->addCode(
+ 'em',
+ 'simple_replace',
+ null,
+ array(
+ 'start_tag' => '
',
+ 'end_tag' => ''
+ ),
+ 'inline',
+ array(
+ 'listitem', 'block', 'inline', 'link'
+ ),
+ array()
+ );
+ $bbcode->addCode(
+ 'ins',
+ 'simple_replace',
+ null,
+ array(
+ 'start_tag' => '
',
+ 'end_tag' => ''
+ ),
+ 'inline',
+ array(
+ 'listitem', 'block', 'inline', 'link'
+ ),
+ array());
+ $bbcode->addCode(
+ 'u',
+ 'simple_replace',
+ null,
+ array(
+ 'start_tag' => '
',
+ 'end_tag' => ''
+ ),
+ 'inline',
+ array(
+ 'listitem', 'block', 'inline', 'link'
+ ),
+ array());
+ $bbcode->addCode(
+ 'del',
+ 'simple_replace',
+ null,
+ array(
+ 'start_tag' => '
',
+ 'end_tag' => ''
+ ),
+ 'inline',
+ array(
+ 'listitem', 'block', 'inline', 'link'
+ ),
+ array());
+ $bbcode->addCode(
+ 'strike',
+ 'simple_replace',
+ null,
+ array(
+ 'start_tag' => '
',
+ 'end_tag' => ''
+ ),
+ 'inline',
+ array(
+ 'listitem', 'block', 'inline', 'link'
+ ),
+ array());
+ $bbcode->addCode(
+ 'blockquote',
+ 'simple_replace',
+ null,
+ array(
+ 'start_tag' => '
',
+ 'end_tag' => '
'
+ ),
+ 'inline',
+ array(
+ 'listitem', 'block', 'inline', 'link'
+ ),
+ array()
+ );
+ $bbcode->addCode(
+ 'quote',
+ 'simple_replace',
+ null,
+ array(
+ 'start_tag' => '
',
+ 'end_tag' => '
'
+ ),
+ 'inline',
+ array(
+ 'listitem', 'block', 'inline', 'link'
+ ),
+ array()
+ );
+ $bbcode->addCode(
+ 'pre',
+ 'simple_replace',
+ null,
+ array(
+ 'start_tag' => '
',
+ 'end_tag' => '
'
+ ),
+ 'inline',
+ array(
+ 'listitem', 'block', 'inline', 'link'
+ ),
+ array());
+ $bbcode->addCode(
+ 'code',
+ 'usecontent',
+ 'do_bbcode_code',
+ array(),
+ 'inline',
+ array(
+ 'listitem', 'block', 'inline', 'link'
+ ),
+ array()
+ );
return $bbcode->parse($text);
-
}
-// this is for [html] tag postprocess
-
+/**
+ * This is for [html] tag postprocess
+ *
+ * @param unknown_type $match
+ * @return unknown
+ */
function plugin_bbcode_undoHtmlCallback($match) {
- return clean_pre($match[1]); //builtin function (see core.wp-formatting)
-
+ //builtin function (see core.wp-formatting)
+ return clean_pre($match[1]);
}
+/**
+ * Enter description here...
+ *
+ * @param string $text
+ * @return string
+ */
function plugin_bbcode_undoHtml($text) {
-
- //return preg_replace_callback('|(.*)|sU', 'plugin_bbcode_undoHtmlCallback', $text);
+ #return preg_replace_callback('|(.*)|sU', 'plugin_bbcode_undoHtmlCallback', $text);
if (isset($GLOBALS['BBCODE_TEMP_HTML'])) {
foreach ($GLOBALS['BBCODE_TEMP_HTML'] as $n => $content) {
-
// html_entity_decode($content)
$content = str_replace('<', '<', $content);
$content = str_replace('>', '>', $content);
-
$text = str_replace("", $content, $text);
}
-
$GLOBALS['BBCODE_TEMP_HTML'] = array();
-
}
-
return $text;
-
-}
-
-
-//add_filter('comment_text', 'plugin_bbcode_comment');
-
-add_filter('title_save_pre', 'wp_specialchars',1);
-
-if (BBCODE_ESCAPE_HTML)
- add_filter('content_save_pre', 'wp_specialchars',1);
-
-add_filter('pre_comment_author_name', 'wp_specialchars');
-add_filter('pre_comment_content', 'wp_specialchars');
-
-add_filter('the_content', 'BBCode', 1);
-add_filter('the_excerpt', 'BBCode', 1);
-
-add_filter('the_content', 'plugin_bbcode_undoHtml', 30);
-
-if (BBCODE_USE_EDITOR) {
- add_filter('editor_toolbar', 'plugin_bbcode_toolbar');
-}
-
-if (BBCODE_ENABLE_COMMENTS) {
- add_filter('comment_text', 'plugin_bbcode_comment', 1);
}
?>
diff --git a/fp-plugins/bbcode/res/bbcode.css b/fp-plugins/bbcode/res/bbcode.css
index 11a31b2..b1c5266 100755
--- a/fp-plugins/bbcode/res/bbcode.css
+++ b/fp-plugins/bbcode/res/bbcode.css
@@ -1,12 +1,9 @@
-img.floatleft
-{
-float:left;
-padding-right:10px;
-}
-
-img.floatright
-{
-float:right;
-padding-left:10px;
+img.floatleft {
+ float:left;
+ padding-right:10px;
}
+img.floatright {
+ float:right;
+ padding-left:10px;
+}
\ No newline at end of file
diff --git a/fp-plugins/bbcode/res/editor.js b/fp-plugins/bbcode/res/editor.js
index 729192b..a116737 100755
--- a/fp-plugins/bbcode/res/editor.js
+++ b/fp-plugins/bbcode/res/editor.js
@@ -1,88 +1,66 @@
-
-// --------------------------------------------------------------------------
-
-
function insertAtCursor(element, start, end) {
- element = document.getElementById(element);
-
- // IE
- if (document.selection) {
- element.focus();
- caretPos = document.selection.createRange().duplicate();
-
- caretPos.text = start + caretPos.text + end;
-
- if (caretPos.text.length == 0)
- {
- caretPos.moveStart("character", -end.length);
- caretPos.moveEnd("character", -end.length);
- caretPos.select();
- }
-
-
- element.focus(caretPos);
-
- // MOZILLA
-
- } else if (element.selectionStart || element.selectionStart == '0') {
-
- element.focus();
-
- var startPos = element.selectionStart;
- var endPos = element.selectionEnd;
- var preTxt = element.value.substring(0, startPos);
- var selTxt = element.value.substring(startPos, endPos) ;
- var follTxt = element.value.substring(endPos, element.value.length);
- var scrollPos = element.scrollTop;
-
-
- element.value = preTxt + start + selTxt + end + follTxt;
-
-
- if (element.setSelectionRange)
- {
- if (selTxt.length == 0)
- element.setSelectionRange(startPos + start.length, startPos + start.length);
- else
- element.setSelectionRange(startPos, startPos + start.length + selTxt.length + end.length);
+ element = document.getElementById(element);
+ if (document.selection) {
+ // IE
element.focus();
+ caretPos = document.selection.createRange().duplicate();
+ caretPos.text = start + caretPos.text + end;
+ if (caretPos.text.length == 0) {
+ caretPos.moveStart("character", -end.length);
+ caretPos.moveEnd("character", -end.length);
+ caretPos.select();
+ }
+ element.focus(caretPos);
+ } else if (element.selectionStart || element.selectionStart == '0') {
+ // MOZILLA
+ element.focus();
+ var startPos = element.selectionStart;
+ var endPos = element.selectionEnd;
+ var preTxt = element.value.substring(0, startPos);
+ var selTxt = element.value.substring(startPos, endPos) ;
+ var follTxt = element.value.substring(endPos, element.value.length);
+ var scrollPos = element.scrollTop;
+ element.value = preTxt + start + selTxt + end + follTxt;
+ if (element.setSelectionRange) {
+ if (selTxt.length == 0) {
+ element.setSelectionRange(startPos + start.length, startPos + start.length);
+ } else {
+ element.setSelectionRange(startPos, startPos + start.length + selTxt.length + end.length);
+ }
+ element.focus();
+ }
+ element.scrollTop = scrollPos;
+ } else {
+ element.value += start + end;
}
- element.scrollTop = scrollPos;
-
- } else {
-
- element.value += start + end;
- }
}
+
// calling the function
// insertAtCursor(document.formName.fieldName, ‘this value’);
-
function insBBCode(code) {
-
insertAtCursor('content', '[' + code + ']','[/' + code + ']');
}
-
function insImage(val) {
- if (val !='--')
- insertAtCursor('content', '[img=images/'+val+']',' ');
+ if (val != '--') {
+ insertAtCursor('content', '[img=images/'+val+']',' ');
+ }
}
-
function insAttach(val) {
-if (val !='--')
- insertAtCursor('content', '[url=attachs/'+val+']','[/url]');
+ if (val !='--') {
+ insertAtCursor('content', '[url=attachs/'+val+']','[/url]');
+ }
}
-//-------------------------------------------------------------------------
+// if false, tab move to next element
+var bbcode_editmode = true;
-var bbcode_editmode = true; // if false, tab move to next element
function tabKeyOverrider() {
-
// Observe keypress on these fields
- if (Event.observe)
+ if (Event.observe) {
Event.observe($('content'), 'keypress', checkTab);
-
+ }
}
var bbcode_mode_trapTab = false;
@@ -93,7 +71,6 @@ var bbcode_mode_trapTab = false;
// At this time we're just using the altkey function (which is not that bad anyway)
function checkTab(evt) {
-
if (evt.keyCode == Event.KEY_ESC) {
if (bbcode_mode_trapTab) {
var bar = $('bbcode_statusbar');
@@ -107,50 +84,43 @@ function checkTab(evt) {
bbcode_mode_trapTab = true;
}
}
-
- if (!bbcode_mode_trapTab)
+ if (!bbcode_mode_trapTab) {
return;
-
-
+ }
// Set desired tab- defaults to four space softtab
var tab = "\t";
-
- var t = evt.target;
- var ss = t.selectionStart;
- var se = t.selectionEnd;
-
- // Tab key - insert tab expansion
- if (evt.keyCode == 9) {
- evt.preventDefault();
-
- // Special case of multi line selection
- if (ss != se && t.value.slice(ss,se).indexOf("\n") != -1) {
- // In case selection was not of entire lines (e.g. selection begins in the middle of a line)
- // we ought to tab at the beginning as well as at the start of every following line.
- var pre = t.value.slice(0,ss);
- var sel = t.value.slice(ss,se).replace(/\n/g,"\n"+tab);
- var post = t.value.slice(se,t.value.length);
- t.value = pre.concat(tab).concat(sel).concat(post);
-
- t.selectionStart = ss + tab.length;
- t.selectionEnd = se + tab.length;
- }
-
+ var t = evt.target;
+ var ss = t.selectionStart;
+ var se = t.selectionEnd;
+ // Tab key - insert tab expansion
+ if (evt.keyCode == 9) {
+ evt.preventDefault();
+ // Special case of multi line selection
+ if (ss != se && t.value.slice(ss,se).indexOf("\n") != -1) {
+ // In case selection was not of entire lines (e.g. selection begins in the middle of a line)
+ // we ought to tab at the beginning as well as at the start of every following line.
+ var pre = t.value.slice(0, ss);
+ var sel = t.value.slice(ss, se).replace(/\n/g, "\n"+tab);
+ var post = t.value.slice(se, t.value.length);
+ t.value = pre.concat(tab).concat(sel).concat(post);
+ t.selectionStart = ss + tab.length;
+ t.selectionEnd = se + tab.length;
+ }
// "Normal" case (no selection or selection on one line only)
else {
- t.value = t.value.slice(0,ss).concat(tab).concat(t.value.slice(ss,t.value.length));
- if (ss == se) {
- t.selectionStart = t.selectionEnd = ss + tab.length;
- }
- else {
- t.selectionStart = ss + tab.length;
- t.selectionEnd = se + tab.length;
- }
+ t.value = t.value.slice(0, ss).concat(tab).concat(t.value.slice(ss, t.value.length));
+ if (ss == se) {
+ t.selectionStart = t.selectionEnd = ss + tab.length;
+ }
+ else {
+ t.selectionStart = ss + tab.length;
+ t.selectionEnd = se + tab.length;
+ }
}
}
}
-
-
-if (typeof(Event.observe)=='function') //prototype is loaded
- { Event.observe(window, 'load', tabKeyOverrider, false) }
+if (typeof(Event.observe) == 'function') {
+ //prototype is loaded
+ Event.observe(window, 'load', tabKeyOverrider, false)
+}
\ No newline at end of file
diff --git a/fp-plugins/bbcode/tpls/admin.plugin.bbcode.tpl b/fp-plugins/bbcode/tpls/admin.plugin.bbcode.tpl
new file mode 100644
index 0000000..a32a3ff
--- /dev/null
+++ b/fp-plugins/bbcode/tpls/admin.plugin.bbcode.tpl
@@ -0,0 +1,60 @@
+
{$plang.head}
+
{$plang.desc1}
+
+{include file=shared:errorlist.tpl}
+
+{html_form class="config-panel"}
+
{$plang.editing}
+
+
+
+ -
+
+ {$plang.allow_html_long}
+
+
+
+ -
+
+ {$plang.toolbar_long}
+
+
+
+
+
+
{$plang.other}
+
+
+
+ -
+
+ {$plang.comments_long}
+
+
+
+ -
+
{$plang.urlmaxlen_long_pre}
+
+ {$plang.urlmaxlen_long_post}
+
+
+
+
+
+
+
+
+
+{/html_form}
diff --git a/fp-plugins/bbcode/tpls/toolbar.tpl b/fp-plugins/bbcode/tpls/toolbar.tpl
index 536a4f0..fb09016 100755
--- a/fp-plugins/bbcode/tpls/toolbar.tpl
+++ b/fp-plugins/bbcode/tpls/toolbar.tpl
@@ -1,30 +1,34 @@
-
+
+
+ {$lang.admin.plugin.bbcode.editor.help}
+
+
+{*
+{if function_exists('plugin_jsutils_head')}
+
+
+
+ {$lang.admin.plugin.bbcode.editor.statusbar}
+
+
+{/if}
+*}
\ No newline at end of file