Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions BBCodePlus/BBCodePlus.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function register() {
$this->name = plugin_lang_get( 'title' );
$this->description = plugin_lang_get( 'description' );
$this->page = 'config';
$this->version = '2.0.16';
$this->version = '2.0.17';

$this->requires['MantisCore'] = '2.0.0';
# this plugin can coexist with MantisCoreFormatting.
Expand Down Expand Up @@ -70,14 +70,16 @@ function resources( $p_event ) {
}
}

# turn off formatting options.
config_set_global("html_make_links", false);

# includes.
$resources = '<link rel="stylesheet" type="text/css" href="' . plugin_file( 'bbcodeplus.css' ) . '" />';
$resources .= '<script type="text/javascript" src="' . plugin_file( 'bbcodeplus-init.js' ) . '"></script>';

if ( ON == plugin_config_get( 'process_markitup' ) ) {
$resources .= '<link rel="stylesheet" type="text/css" href="' . plugin_file( 'markitup/skins/' . plugin_config_get( 'markitup_skin' ) . '/style.css' ) . '" />';
$resources .= '<link rel="stylesheet" type="text/css" href="' . plugin_file( 'markitup/sets/mantis/style.css' ) . '" />';
//$resources .= '<script type="text/javascript" src="' . plugin_file( 'jquery_migrate_min.js' ) . '"></script>';
$resources .= '<script type="text/javascript" src="' . plugin_file( 'markitup/jquery_markitup.js' ) . '"></script>';
$resources .= '<script type="text/javascript" src="' . plugin_file( 'markitup/sets/mantis/set.js' ) . '"></script>';
$resources .= '<script type="text/javascript" src="' . plugin_file( 'markitup-init.js' ) . '"></script>';
Expand Down Expand Up @@ -234,12 +236,12 @@ function string_process_bbcode( $p_string, $p_multiline = TRUE ) {
$t_extra_link_tags = 'target="_blank"';

# if there are any expressed links, images convert them to bbcode.
$p_string = preg_replace( "/^((http|https|ftp):\/\/[a-z0-9;\/\?:@=\&\$\-_\.\+!*'\(\),~%#]+)/i", "[url]$1[/url]", $p_string );
$p_string = preg_replace( "/([^='\"(\[url\]|\[img\])])((http|https|ftp):\/\/[a-z0-9;\/\?:@=\&\$\-_\.\+!*'\(\),~%#]+)/i", "$1[url]$2[/url]", $p_string );
$p_string = preg_replace( "/^((http|https|ftp|file):\/\/[a-z0-9;\/\?:@=\&\$\-_\.\+!*'\(\),~%#\|]+)/i", "[url]$1[/url]", $p_string );
$p_string = preg_replace( "/([^='\"(\[url\]|\[img\])])((http|https|ftp|file):\/\/[a-z0-9;\/\?:@=\&\$\-_\.\+!*'\(\),~%#\|]+)/i", "$1[url]$2[/url]", $p_string );

$t_search[] = "/\[img\]((http|https|ftp):\/\/[a-z0-9;\/\?:@=\&\$\-_\.\+!*'\(\),~%# ]+?)\[\/img\]/is";
$t_search[] = "/\[img\]([.]*[a-z0-9;\/\?:@=\&\$\-_\.\+!*'\(\),~%# ]+?)\[\/img\]/is";
$t_search[] = "/\[url\]((http|https|ftp|mailto):\/\/([a-z0-9\.\-@:]+)[a-z0-9;\/\?:@=\&\$\-_\.\+!*'\(\),\#%~ ]*?)\[\/url\]/is";
$t_search[] = "/\[url\]((http|https|ftp|mailto|file):\/\/([\/a-z0-9\.\-@:]+)[a-z0-9;\/\?:@=\&\$\-_\.\+!*'\(\),\#%~\| ]*?)\[\/url\]/is";
$t_search[] = "/\[url=((http|https|ftp|mailto):\/\/[^\]]+?)\](.+?)\[\/url\]/is";
$t_search[] = "/\[url=([a-z0-9;\/\?:@=\&\$\-_\.\+!*'\(\),~%# ]+?)\](.+?)\[\/url\]/is";
$t_search[] = "/\[email\]([a-z0-9\-_\.\+]+@[a-z0-9\-]+\.[a-z0-9\-\.]+?)\[\/email\]/is";
Expand Down Expand Up @@ -312,16 +314,16 @@ function string_process_bbcode( $p_string, $p_multiline = TRUE ) {

# code=lang
$p_string = preg_replace_callback('/\[code=(\w+)\](.+)\[\/code\]/imsU',
function ($m) {
create_function('$m', '
return "<pre><code class=\"language-" . strtolower($m[1]) . "\">" . $m[2] . "</code></pre>";
}
')
, $p_string);

# code=lang start=n
$p_string = preg_replace_callback('/\[code=(\w+)\ start=([0-9]+)\](.+)\[\/code\]/imsU',
function ($m) {
create_function('$m', '
return "<pre class=\"line-numbers\" data-start=\"" . $m[2] . "\"><code class=\"language-" . strtolower($m[1]) . "\">" . $m[3] . "</code></pre>";
}
')
, $p_string);

# process quotes.
Expand Down Expand Up @@ -434,16 +436,16 @@ function string_strip_bbcode( $p_string, $p_multiline = TRUE ) {

# code=lang
$p_string = preg_replace_callback('/\[code=(\w+)\](.+)\[\/code\]/imsU',
function ($m) {
create_function('$m', '
return $m[2];
}
')
, $p_string);

# code=lang start=n
$p_string = preg_replace_callback('/\[code=(\w+)\ start=([0-9]+)\](.+)\[\/code\]/imsU',
function ($m) {
create_function('$m', '
return $m[3];
}
')
, $p_string);

# process quotes.
Expand Down Expand Up @@ -480,9 +482,9 @@ function restore_pre_code_tags( $p_string, $p_multiline = true ) {
$tags = implode( '|', $tags );

$t_string = preg_replace_callback('/&lt;(' . $tags . ')(.*?)&gt;/ui',
function($m) {
create_function('$m', '
return "<" . $m[1] . str_replace("&quot;", "\"", $m[2]) . ">";
}
')
, $t_string);

$t_string = preg_replace( '/&lt;\/(' . $tags . ')\s*&gt;/ui', '</\\1>', $t_string );
Expand Down
80 changes: 40 additions & 40 deletions BBCodePlus/files/bbcodeplus.css
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
div.bbcodeplus-quote {
border: solid #c0c0c0 1px;
padding: 10px;
background-color: #d8d8d8;
}

pre {
border: 1px solid silver;
margin: 0 0 1.5em 0;
overflow: auto;
padding-left: 10px;
}

code span {
font-family: Consolas,Monaco,"Andale Mono","Ubuntu Mono",monospace;
font-size: 1em;
}

.bbcodeplus-list {
margin-left: 0px;
padding-left: 1.2em;
}

.bbcodeplus-bullet-list {
margin-left: 0px;
padding-left: 1.2em;
list-style-type: square;
}

.bbcodeplus-preview {
height:100%;
width:100%;
font-family: 'Open Sans', sans-serif;
font-size: 13px;
}

.bbcodeplus-preview-body {
background-image:none !important;
margin: 10px 10px;
}
div.bbcodeplus-quote {
border: solid #c0c0c0 1px;
padding: 10px;
background-color: #d8d8d8;
}
pre {
border: 1px solid silver;
margin: 0 0 1.5em 0;
overflow: auto;
padding-left: 10px;
}
code span {
font-family: Consolas,Monaco,"Andale Mono","Ubuntu Mono",monospace;
font-size: 1em;
}
.bbcodeplus-list {
margin-left: 0px;
padding-left: 1.2em;
}
.bbcodeplus-bullet-list {
margin-left: 0px;
padding-left: 1.2em;
list-style-type: square;
}
.bbcodeplus-preview {
height:100%;
width:100%;
font-family: 'Open Sans', sans-serif;
font-size: 13px;
}
.bbcodeplus-preview-body {
background-image:none !important;
margin: 10px 10px;
}
2 changes: 0 additions & 2 deletions BBCodePlus/files/jquery_migrate_min.js

This file was deleted.

3 changes: 2 additions & 1 deletion BBCodePlus/files/markitup-init.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

// declare the path to the previewer using the plugin file processor.
mySettings.previewParserPath = "./plugin.php?page=BBCodePlus/preview.php";

// apply to proper text areas.
if ( $("textarea[name='bugnote_text']") )
$("textarea[name='bugnote_text']").markItUp(mySettings);
Expand All @@ -13,6 +12,8 @@
$("textarea[name='steps_to_reproduce']").markItUp(mySettings);
if ( $("textarea[name='additional_info']") )
$("textarea[name='additional_info']").markItUp(mySettings);
if ( $("textarea[name='additional_information']") )
$("textarea[name='additional_information']").markItUp(mySettings);
if ( $("textarea[name='body']") )
$("textarea[name='body']").markItUp( mySettings );

Expand Down
60 changes: 30 additions & 30 deletions BBCodePlus/files/markitup/sets/default/set.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
// ----------------------------------------------------------------------------
// markItUp!
// ----------------------------------------------------------------------------
// Copyright (C) 2011 Jay Salvat
// http://markitup.jaysalvat.com/
// ----------------------------------------------------------------------------
// Html tags
// http://en.wikipedia.org/wiki/html
// ----------------------------------------------------------------------------
// Basic set. Feel free to add more tags
// ----------------------------------------------------------------------------
var mySettings = {
onShiftEnter: {keepDefault:false, replaceWith:'<br />\n'},
onCtrlEnter: {keepDefault:false, openWith:'\n<p>', closeWith:'</p>'},
onTab: {keepDefault:false, replaceWith:' '},
markupSet: [
{name:'Bold', key:'B', openWith:'(!(<strong>|!|<b>)!)', closeWith:'(!(</strong>|!|</b>)!)' },
{name:'Italic', key:'I', openWith:'(!(<em>|!|<i>)!)', closeWith:'(!(</em>|!|</i>)!)' },
{name:'Stroke through', key:'S', openWith:'<del>', closeWith:'</del>' },
{separator:'---------------' },
{name:'Bulleted List', openWith:' <li>', closeWith:'</li>', multiline:true, openBlockWith:'<ul>\n', closeBlockWith:'\n</ul>'},
{name:'Numeric List', openWith:' <li>', closeWith:'</li>', multiline:true, openBlockWith:'<ol>\n', closeBlockWith:'\n</ol>'},
{separator:'---------------' },
{name:'Picture', key:'P', replaceWith:'<img src="[![Source:!:http://]!]" alt="[![Alternative text]!]" />' },
{name:'Link', key:'L', openWith:'<a href="[![Link:!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>', placeHolder:'Your text to link...' },
{separator:'---------------' },
{name:'Clean', className:'clean', replaceWith:function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } },
{name:'Preview', className:'preview', call:'preview'}
]
}
// ----------------------------------------------------------------------------
// markItUp!
// ----------------------------------------------------------------------------
// Copyright (C) 2011 Jay Salvat
// http://markitup.jaysalvat.com/
// ----------------------------------------------------------------------------
// Html tags
// http://en.wikipedia.org/wiki/html
// ----------------------------------------------------------------------------
// Basic set. Feel free to add more tags
// ----------------------------------------------------------------------------
var mySettings = {
onShiftEnter: {keepDefault:false, replaceWith:'<br />\n'},
onCtrlEnter: {keepDefault:false, openWith:'\n<p>', closeWith:'</p>'},
onTab: {keepDefault:false, replaceWith:' '},
markupSet: [
{name:'Bold', key:'B', openWith:'(!(<strong>|!|<b>)!)', closeWith:'(!(</strong>|!|</b>)!)' },
{name:'Italic', key:'I', openWith:'(!(<em>|!|<i>)!)', closeWith:'(!(</em>|!|</i>)!)' },
{name:'Stroke through', key:'S', openWith:'<del>', closeWith:'</del>' },
{separator:'---------------' },
{name:'Bulleted List', openWith:' <li>', closeWith:'</li>', multiline:true, openBlockWith:'<ul>\n', closeBlockWith:'\n</ul>'},
{name:'Numeric List', openWith:' <li>', closeWith:'</li>', multiline:true, openBlockWith:'<ol>\n', closeBlockWith:'\n</ol>'},
{separator:'---------------' },
{name:'Picture', key:'P', replaceWith:'<img src="[![Source:!:http://]!]" alt="[![Alternative text]!]" />' },
{name:'Link', key:'L', openWith:'<a href="[![Link:!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>', placeHolder:'Your text to link...' },
{separator:'---------------' },
{name:'Clean', className:'clean', replaceWith:function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } },
{name:'Preview', className:'preview', call:'preview'}
]
}
68 changes: 34 additions & 34 deletions BBCodePlus/files/markitup/sets/default/style.css
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
/* -------------------------------------------------------------------
// markItUp!
// By Jay Salvat - http://markitup.jaysalvat.com/
// ------------------------------------------------------------------*/
.markItUp .markItUpButton1 a {
background-image:url(images/bold.png);
}
.markItUp .markItUpButton2 a {
background-image:url(images/italic.png);
}
.markItUp .markItUpButton3 a {
background-image:url(images/stroke.png);
}

.markItUp .markItUpButton4 a {
background-image:url(images/list-bullet.png);
}
.markItUp .markItUpButton5 a {
background-image:url(images/list-numeric.png);
}

.markItUp .markItUpButton6 a {
background-image:url(images/picture.png);
}
.markItUp .markItUpButton7 a {
background-image:url(images/link.png);
}

.markItUp .markItUpButton8 a {
background-image:url(images/clean.png);
}
.markItUp .preview a {
background-image:url(images/preview.png);
}
/* -------------------------------------------------------------------
// markItUp!
// By Jay Salvat - http://markitup.jaysalvat.com/
// ------------------------------------------------------------------*/
.markItUp .markItUpButton1 a {
background-image:url(images/bold.png);
}
.markItUp .markItUpButton2 a {
background-image:url(images/italic.png);
}
.markItUp .markItUpButton3 a {
background-image:url(images/stroke.png);
}
.markItUp .markItUpButton4 a {
background-image:url(images/list-bullet.png);
}
.markItUp .markItUpButton5 a {
background-image:url(images/list-numeric.png);
}
.markItUp .markItUpButton6 a {
background-image:url(images/picture.png);
}
.markItUp .markItUpButton7 a {
background-image:url(images/link.png);
}
.markItUp .markItUpButton8 a {
background-image:url(images/clean.png);
}
.markItUp .preview a {
background-image:url(images/preview.png);
}
Loading