mirror of
https://github.com/e107inc/e107.git
synced 2025-06-02 00:45:03 +02:00
TinyMce bbcode plugin work
This commit is contained in:
parent
2e5b305512
commit
047dfa1fcf
@ -1,7 +1,8 @@
|
||||
/* Tag: unordered list [list][*]line 1[*]line2[*]line 3[*]line 4[*]line5 etc[/list] - preferred */
|
||||
/* Tag: ordered list [list=<list type>][*]line 1[*]line2[*]line 3[*]line 4[*]line5 etc[/list] - preferred */
|
||||
/* Tag: unordered list [list]*line 1*line2*line 3*line 4*line5 etc[/list] - legacy*/
|
||||
/* Tag: ordered list [list=<list type>]*line 1*line2*line 3*line 4*line5 etc[/list] - legacy */
|
||||
//<?php
|
||||
/* Tag: unordered list [list]*line 1*line2*line 3*line 4*line5 etc[/list] */
|
||||
/* Tag: ordered list [list=<list type>]*line 1*line2*line 3*line 4*line5 etc[/list] */
|
||||
/* Tag: unordered list [list][*]line 1[*]line2[*]line 3[*]line 4[*]line5 etc[/list] - not compatible with TinyMce */
|
||||
/* Tag: ordered list [list=<list type>][*]line 1[*]line2[*]line 3[*]line 4[*]line5 etc[/list] - not compatible with TinyMce */
|
||||
/* valid list types:
|
||||
disc
|
||||
circle
|
||||
|
@ -29,7 +29,7 @@ class bbcode_shortcodes
|
||||
//FIXME - cachevars/getcachedvars!
|
||||
global $pref, $eplug_bb, $bbcode_func, $bbcode_help, $bbcode_filedir, $bbcode_imagedir, $bbcode_helpactive, $bbcode_helptag, $register_bb;
|
||||
|
||||
if(defsettrue('e_WYSIWYG')){ return; }
|
||||
// if(defsettrue('e_WYSIWYG')){ return; }
|
||||
|
||||
$bbcode_func = ($bbcode_func) ? $bbcode_func : "addtext";
|
||||
$bbcode_help = ($bbcode_help) ? $bbcode_help : "help";
|
||||
@ -133,7 +133,7 @@ class bbcode_shortcodes
|
||||
|
||||
function sc_bb_help($parm)
|
||||
{
|
||||
if(defsettrue('e_WYSIWYG')) { return; }
|
||||
// if(defsettrue('e_WYSIWYG')) { return; }
|
||||
global $bbcode_helpactive,$bbcode_helptag, $bbcode_helpsize;
|
||||
if($parm) $bbcode_helptag = $parm;
|
||||
elseif(!varset($bbcode_helptag)) $bbcode_helptag = 'helpb';
|
||||
|
@ -1361,7 +1361,7 @@ class e107
|
||||
* @param string $method_name
|
||||
* @return boolean FALSE
|
||||
*/
|
||||
public function callMethod($class_name, $method_name)
|
||||
public function callMethod($class_name, $method_name, $param='')
|
||||
{
|
||||
$mes = e107::getMessage();
|
||||
|
||||
@ -1371,7 +1371,7 @@ class e107
|
||||
if(method_exists($obj, $method_name))
|
||||
{
|
||||
$mes->debug('Executing <strong>'.$class_name.' :: '.$method_name.'()</strong>');
|
||||
return call_user_func(array($obj, $method_name));
|
||||
return call_user_func(array($obj, $method_name),$param);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2255,7 +2255,11 @@ class e107
|
||||
}*/
|
||||
|
||||
$eSelf = $_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_FILENAME'];
|
||||
define('e_SELF', $this->HTTP_SCHEME.'://'.$_SERVER['HTTP_HOST'].$eSelf);
|
||||
if(!deftrue('e_SELF_DISABLE'))
|
||||
{
|
||||
define('e_SELF', $this->HTTP_SCHEME.'://'.$_SERVER['HTTP_HOST'].$eSelf);
|
||||
}
|
||||
|
||||
|
||||
// START New - request uri/url detection, XSS protection
|
||||
$requestUri = $requestUrl = '';
|
||||
@ -2384,7 +2388,12 @@ class e107
|
||||
|
||||
if ($no_cbrace) $e_QUERY = str_replace(array('{', '}', '%7B', '%7b', '%7D', '%7d'), '', rawurldecode($e_QUERY));
|
||||
$e_QUERY = str_replace("&","&", self::getParser()->post_toForm($e_QUERY));
|
||||
define('e_QUERY', $e_QUERY);
|
||||
|
||||
if(!deftrue("e_QUERY_DISABLE"))
|
||||
{
|
||||
define('e_QUERY', $e_QUERY);
|
||||
}
|
||||
|
||||
|
||||
define('e_TBQS', $_SERVER['QUERY_STRING']);
|
||||
$_SERVER['QUERY_STRING'] = e_QUERY;
|
||||
|
@ -430,16 +430,20 @@ class e_form
|
||||
$options = array('class' => 'tbox bbarea '.($size ? ' '.$size : '').' e-wysiwyg');
|
||||
$bbbar = '';
|
||||
// FIXME - see ren_help.php
|
||||
if(!deftrue('e_WYSIWYG'))
|
||||
// if(!deftrue('e_WYSIWYG'))
|
||||
{
|
||||
require_once(e_HANDLER."ren_help.php");
|
||||
$options['other'] = "onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'";
|
||||
$bbbar = display_help($help_tagid, $help_mod, 'addtext', 'help', $size);
|
||||
}
|
||||
|
||||
|
||||
$toggleID = "bbcode-panel-".$help_tagid;
|
||||
$tinyMceID = str_replace("_","-",$name);
|
||||
|
||||
$ret = "
|
||||
<div class='bbarea {$size}'>
|
||||
".$this->textarea($name, $value, $rows, 50, $options, $counter)."
|
||||
<div><a href='#' onclick=\"tinyMCE.execCommand('mceToggleEditor',false,'".$tinyMceID."');expandit('".$toggleID."');\">Toggle WYSIWYG</a></div>
|
||||
<div class='field-spacer'><!-- --></div>
|
||||
{$bbbar}
|
||||
</div>
|
||||
@ -1821,6 +1825,7 @@ class e_form
|
||||
break;
|
||||
|
||||
case 'lanlist':
|
||||
case 'language':
|
||||
$options = e107::getLanguage()->getLanSelectArray();
|
||||
|
||||
$eloptions = vartrue($parms['__options'], array());
|
||||
|
@ -221,6 +221,39 @@ class e_media
|
||||
// TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an Array of Media Categories
|
||||
*/
|
||||
public function getCategories()
|
||||
{
|
||||
$ret = array();
|
||||
e107::getDb()->db_Select_gen("SELECT * FROM #core_media_cat ORDER BY media_cat_title");
|
||||
while($row = e107::getDb()->db_Fetch(mySQL_ASSOC))
|
||||
{
|
||||
$id = $row['media_cat_nick'];
|
||||
$ret[$id] = $row['media_cat_title'];
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return an array of Images in a particular category
|
||||
*/
|
||||
public function getImages($cat = '')
|
||||
{
|
||||
if(!$cat) return;
|
||||
// TODO check the category is valid.
|
||||
$ret = array();
|
||||
e107::getDb()->db_Select_gen("SELECT * FROM #core_media WHERE media_category = '".$cat."' ORDER BY media_name");
|
||||
while($row = e107::getDb()->db_Fetch(mySQL_ASSOC))
|
||||
{
|
||||
$id = $row['media_id'];
|
||||
$ret[$id] = $row;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Simple Thumbnail window for image-selection
|
||||
|
@ -30,7 +30,7 @@ function ren_help($mode = 1, $addtextfunc = "addtext", $helpfunc = "help")
|
||||
// FIXME - full rewrite, EVERYTHING - bbcode class (php + JS), core callbacks, tooltip help, optimize
|
||||
function display_help($tagid="helpb", $mode = 1, $addtextfunc = "addtext", $helpfunc = "help", $helpsize = '')
|
||||
{
|
||||
if(defsettrue('e_WYSIWYG')) { return; }
|
||||
// if(defsettrue('e_WYSIWYG')) { return; }
|
||||
global $tp, $pref, $eplug_bb, $bbcode_func, $register_bb, $bbcode_help, $bbcode_helpactive, $bbcode_helptag, $bbcode_helpsize;
|
||||
$bbcode_helpsize = $helpsize;
|
||||
|
||||
@ -80,10 +80,12 @@ function display_help($tagid="helpb", $mode = 1, $addtextfunc = "addtext", $help
|
||||
$BBCODE_TEMPLATE = $temp[$mode];
|
||||
}
|
||||
|
||||
$visible = deftrue('e_WYSIWYG') ? "style='display:none'" : "";
|
||||
|
||||
if(is_readable(e_CORE."shortcodes/batch/bbcode_shortcodes.php"))
|
||||
{
|
||||
require_once(e_CORE."shortcodes/batch/bbcode_shortcodes.php");
|
||||
return $tp->parseTemplate($BBCODE_TEMPLATE);
|
||||
return "<div id='bbcode-panel-".$tagid."' class='bbcode-panel' {$visible}>".$tp->parseTemplate($BBCODE_TEMPLATE)."</div>";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -43,10 +43,21 @@
|
||||
s = s.replace(re, str);
|
||||
};
|
||||
|
||||
|
||||
|
||||
rep(/<div style="text-align: center;">([\s\S]*)<\/div>/gi,"[center]$1[/center]"); // verified
|
||||
|
||||
|
||||
rep(/<li>/gi,"*"); // verified
|
||||
rep(/<\/li>/gi,""); // verified
|
||||
rep(/<ul>([\s\S]*?)<\/ul>/gim,"[list]$1[/list]\n"); // verified
|
||||
rep(/<ol .* style=\'list-style-type:\s*([\w]*).*\'>([\s\S]*)<\/ol>/gim,"[list=$1]$2[/list]\n"); // verified
|
||||
rep(/<ol>([\s\S]*?)<\/ol>/gim,"[list=decimal]$1[/list]\n"); // verified
|
||||
rep(/<span style="color: (#?.*?);">([\s\S]*)<\/span>/gi,"[color=$1]$2[/color]"); // verified
|
||||
|
||||
|
||||
|
||||
// example: <strong> to [b]
|
||||
rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");
|
||||
rep(/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/gi,"[link=$1]$2[/link]");
|
||||
rep(/<font.*?color=\"(.*?)\".*?class=\"codeStyle\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
|
||||
rep(/<font.*?color=\"(.*?)\".*?class=\"quoteStyle\".*?>(.*?)<\/font>/gi,"[quote][color=$1]$2[/color][/quote]");
|
||||
rep(/<font.*?class=\"codeStyle\".*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[code][color=$1]$2[/color][/code]");
|
||||
@ -55,10 +66,11 @@
|
||||
rep(/<font.*?color=\"(.*?)\".*?>(.*?)<\/font>/gi,"[color=$1]$2[/color]");
|
||||
rep(/<span style=\"font-size:(.*?);\">(.*?)<\/span>/gi,"[size=$1]$2[/size]");
|
||||
rep(/<font>(.*?)<\/font>/gi,"$1");
|
||||
// rep(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]");
|
||||
// rep(/<img.*?style=\"color: ?(.*?);\".*?>(.*?)\/>/gi,"[img style=$1]$2[/img]");
|
||||
|
||||
rep(/<img.*?style=\"(.*?)\".*?src=\"(.*?)\".*?\/>/gi,"[img style=$1]$2[/img]");
|
||||
rep(/<img.*?src=\"(.*?)\".*?\/>/gi,"[img]$1[/img]");
|
||||
// rep(/<img.*?style=\"(.*?)\".*?src=\"(.*?)\" alt=\"(.*?)\" .*?width=\"(.*?)\".*? .*?height=\"(.*?)\" .*?\/>/gi,"[img style=$1;width:$4px; height:$5;]$2[/img]");
|
||||
|
||||
rep(/<img.*?style=\"?(.*?);\".*? src=\"(.*?)\" alt=\"(.*?)\" .*?width=\"(.*?)\".*? .*?height=\"(.*?)\" .*?\/>/gi,"[img style=$1;width:$4px; height:$5;]$2[/img]");
|
||||
rep(/<span class=\"codeStyle\">(.*?)<\/span>/gi,"[code]$1[/code]");
|
||||
rep(/<span class=\"quoteStyle\">(.*?)<\/span>/gi,"[quote]$1[/quote]");
|
||||
rep(/<strong class=\"codeStyle\">(.*?)<\/strong>/gi,"[code][b]$1[/b][/code]");
|
||||
@ -88,12 +100,8 @@
|
||||
rep(/&/gi,"&");
|
||||
|
||||
// e107
|
||||
rep(/<ul>/gi,"[list]");
|
||||
rep(/<\/ul>/gi,"[/list]");
|
||||
rep(/<ol>/gi,"[list=decimal]");
|
||||
rep(/<\/ol>/gi,"[/list]");
|
||||
rep(/<li>/gi,"[*]");
|
||||
rep(/<\/li>/gi,"\n");
|
||||
|
||||
|
||||
return s;
|
||||
},
|
||||
|
||||
@ -106,28 +114,39 @@
|
||||
};
|
||||
|
||||
// example: [b] to <strong>
|
||||
rep(/\n/gi,"<br />");
|
||||
|
||||
|
||||
rep(/(\[list=.*\])\\*([\s\S]*)(\[\/list])/gim,"<ol>$2</ol>"); // verified
|
||||
rep(/(\[list\])\\*([\s\S]*)(\[\/list])/gim,"<ul>$2</ul>");// verified
|
||||
rep(/^ *?\*(.*)/gim,"<li>$1</li>");
|
||||
rep(/\[center\]([\s\S]*)\[\/center\]/gi,"<div style=\"text-align:center\">$1</div>"); // verified
|
||||
rep(/\[color=(.*?)\]([\s\S]*)\[\/color\]/gi,"<span style=\"color: $1;\">$2<\/span>"); // verified
|
||||
|
||||
// rep(/\n/gi,"<br \/>"); // breaks lists.. need a regex to exclude everything between [list]...[/list]
|
||||
|
||||
rep(/\[b\]/gi,"<strong>");
|
||||
rep(/\[\/b\]/gi,"</strong>");
|
||||
rep(/\[i\]/gi,"<em>");
|
||||
rep(/\[\/i\]/gi,"</em>");
|
||||
rep(/\[u\]/gi,"<u>");
|
||||
rep(/\[\/u\]/gi,"</u>");
|
||||
rep(/\[url=([^\]]+)\](.*?)\[\/url\]/gi,"<a href=\"$1\">$2</a>");
|
||||
rep(/\[link=([^\]]+)\](.*?)\[\/link\]/gi,"<a href=\"$1\">$2</a>");
|
||||
rep(/\[url\](.*?)\[\/url\]/gi,"<a href=\"$1\">$1</a>");
|
||||
rep(/\[img.*?style=(.*?).*?\](.*?)\[\/img\]/gi,"<img style=\"$1\" src=\"$2\" />");
|
||||
rep(/\[img.*?\](.*?)\[\/img\]/gi,"<img src=\"$1\" />");
|
||||
rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<font color=\"$1\">$2</font>");
|
||||
// rep(/\[color=(.*?)\](.*?)\[\/color\]/gi,"<font color=\"$1\">$2</font>");
|
||||
rep(/\[code\](.*?)\[\/code\]/gi,"<span class=\"codeStyle\">$1</span> ");
|
||||
rep(/\[quote.*?\](.*?)\[\/quote\]/gi,"<span class=\"quoteStyle\">$1</span> ");
|
||||
|
||||
// e107 FIXME!
|
||||
// rep("/\[list\](.+?)\[\/list\]/is", '<ul class="listbullet">$1</ul>');
|
||||
rep(/\[list\]/gi,"<ul>");
|
||||
rep(/\[\/list\]/gi,"</ul>");
|
||||
|
||||
rep(/\[list=decimal\]/gi,"<ol>");
|
||||
rep(/\[\/list\]/gi,"</ol>");
|
||||
|
||||
|
||||
// rep("/\[list\](.+?)\[\/list\]/is", '<ul class="listbullet">$1</ul>');
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
|
||||
return s;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user