diff --git a/e107_admin/image.php b/e107_admin/image.php
index ddf2ec897..dd116c4e9 100644
--- a/e107_admin/image.php
+++ b/e107_admin/image.php
@@ -226,15 +226,22 @@ class media_form_ui extends e_admin_form_ui
// "featurebox-image" => "Featurebox Images",
// "featurebox-bbcode" => "Featurebox [img] bbcode",
);
- $text .= "
".NWSLAN_22.": |
- ".$frm->uc_select('news_userclass[]', $_POST['news_class'], 'nobody,public,guest,member,admin,classes,language', 'description=1&multiple=1')."
+ ".$frm->uc_select('news_userclass[]', vartrue($_POST['news_class'],0), 'nobody,public,guest,member,admin,classes,language', 'description=1&multiple=1')."
".NWSLAN_84."
diff --git a/e107_core/bbcodes/bb_img.php b/e107_core/bbcodes/bb_img.php
new file mode 100644
index 000000000..d95f42d02
--- /dev/null
+++ b/e107_core/bbcodes/bb_img.php
@@ -0,0 +1,170 @@
+getClass('img');
+
+
+
+ if (trim($code_text) == "") return ""; // Do nothing on empty file
+ if (preg_match("#\.php\?.*#",$code_text)){return "";}
+
+ $addlink = FALSE;
+
+
+ // Automatic Img Resizing --
+ $w = e107::getBB()->resizeWidth(); // varies depending on the class set by external script. see admin->media-manager->prefs
+ $h = e107::getBB()->resizeHeight();
+
+
+ if(strpos($code_text,"://")==false && ($w || $h)) // local file.
+ {
+ $code_text = $tp->thumbUrl($code_text,'w='.$w.'&h='.$h);
+ }
+ // ------------------------
+
+
+
+
+ $search = array('"', '{E_IMAGE}', '{E_FILE}', '{e_IMAGE}', '{e_FILE}');
+ $replace = array(''', e_IMAGE_ABS, e_FILE_ABS, e_IMAGE_ABS, e_FILE_ABS);
+ $replaceInt = array(''', e_IMAGE, e_FILE, e_IMAGE, e_FILE);
+ $intName = str_replace($search, $replaceInt, $code_text); // Server-relative file names
+ unset($imgParms);
+ $imgParms['class']="bbcode {$class}"; // This will be overridden if a new class is specified
+
+ $imgParms['alt']='';
+
+ $code_text = str_replace($search, $replace, $code_text);
+ $code_text = $tp -> toAttribute($code_text);
+ $img_file = pathinfo($code_text); // 'External' file name. N.B. - might still contain a constant such as e_IMAGE
+
+ if($parm)
+ {
+ $parm = preg_replace('#onerror *=#i','',$parm);
+ $parm = str_replace("amp;", "&", $parm);
+ parse_str($parm,$tmp);
+ foreach($tmp as $p => $v)
+ {
+ $imgParms[$p]=$v;
+ }
+ }
+ $parmStr="";
+ foreach($imgParms as $k => $v)
+ {
+ $parmStr .= $tp -> toAttribute($k)."='".$tp -> toAttribute($v)."' ";
+ }
+
+
+
+ // Select a random file if required
+ if (strpos($img_file['basename'],'*') !== FALSE)
+ {
+ $fileList = array();
+ $intFile = pathinfo($intName); // N.B. - might still contain a constant such as e_IMAGE
+ $matchString = '#'.str_replace('*','.*?',$intFile['basename']).'#';
+ $dirName = $tp->replaceConstants($intFile['dirname'].'/'); // we want server-relative directory
+ if (($h = opendir($dirName)) !== FALSE)
+ {
+ while (($f = readdir($h)) !== FALSE)
+ {
+ if (preg_match($matchString,$f))
+ {
+ $fileList[] = $f; // Just need to note file names
+ }
+ }
+ closedir($h);
+ }
+ else
+ {
+ echo "Error opening directory: {$dirName} ";
+ return '';
+ }
+ if (count($fileList))
+ {
+ $img_file['basename'] = $fileList[mt_rand(0,count($fileList)-1)]; // Just change name of displayed file - no change on directory
+ $code_text = $img_file['dirname']."/".$img_file['basename'];
+ }
+ else
+ {
+ echo 'No file: '.$code_text;
+ return '';
+ }
+ }
+
+
+ // Check for whether we can display image down here - so we can show image name if appropriate
+ if (!varsettrue($pref['image_post']) || !check_class($pref['image_post_class']))
+ {
+ switch ($pref['image_post_disabled_method'])
+ {
+ case '1' :
+ return CORE_LAN17;
+ case '2' :
+ return '';
+ }
+ return CORE_LAN18.$code_text;
+ }
+
+
+ // Check for link to main image if required
+ if (strpos($img_file['basename'],'th_') === 0)
+ {
+ $addlink = TRUE;
+ $main_name = $img_file['dirname']."/".substr($img_file['basename'],3); // delete the 'th' prefix from file name
+ }
+ elseif (strpos($img_file['basename'],'thumb_') === 0)
+ {
+ $addlink = TRUE;
+ $main_name = $img_file['dirname']."/".substr($img_file['basename'],6); // delete the 'thumb' prefix from file name
+ }
+
+
+
+ if ($addlink)
+ {
+ return " ";
+ }
+ else
+ {
+ return " ";
+ }
+ }
+
+}
+
+?>
\ No newline at end of file
diff --git a/e107_core/bbcodes/img.bb b/e107_core/bbcodes/img.bb
deleted file mode 100644
index c173f2960..000000000
--- a/e107_core/bbcodes/img.bb
+++ /dev/null
@@ -1,122 +0,0 @@
-//
-$class = e107::getBB()->getClass('img');
-// $Id$
-
-// General purpose image bbcode. As well as the obvious insertion of a picture:
-// a) if filname begins with 'th_' or 'thumb_', creates link to main image opening in new window
-// b) If filename contains '*', treats it as a wildcard, and displays a random image from all matching file names found
-//
-// Can use simple classes for float - e.g.:
-// .floatleft {clear: right; float: left; margin: 0px 5px 5px 0px; padding:2px; border: 0px;}
-// .floatright {clear: left; float: right; margin: 0px 0px 0px 5px; padding:2px; border: 0px;}
-// Currently defaults class to 'floatnone' - overridden by bbcode
-
-if (trim($code_text) == "") return ""; // Do nothing on empty file
-if (preg_match("#\.php\?.*#",$code_text)){return "";}
-$addlink = FALSE;
-
-global $pref;
-
-
-$search = array('"', '{E_IMAGE}', '{E_FILE}', '{e_IMAGE}', '{e_FILE}');
-$replace = array(''', e_IMAGE_ABS, e_FILE_ABS, e_IMAGE_ABS, e_FILE_ABS);
-$replaceInt = array(''', e_IMAGE, e_FILE, e_IMAGE, e_FILE);
-$intName = str_replace($search, $replaceInt, $code_text); // Server-relative file names
-unset($imgParms);
-$imgParms['class']="bbcode {$class}"; // This will be overridden if a new class is specified
-
-$imgParms['alt']='';
-
-$code_text = str_replace($search, $replace, $code_text);
-$code_text = $tp -> toAttribute($code_text);
-$img_file = pathinfo($code_text); // 'External' file name. N.B. - might still contain a constant such as e_IMAGE
-
-if($parm)
-{
- $parm = preg_replace('#onerror *=#i','',$parm);
- $parm = str_replace("amp;", "&", $parm);
- parse_str($parm,$tmp);
- foreach($tmp as $p => $v)
- {
- $imgParms[$p]=$v;
- }
-}
-$parmStr="";
-foreach($imgParms as $k => $v)
-{
- $parmStr .= $tp -> toAttribute($k)."='".$tp -> toAttribute($v)."' ";
-}
-
-
-
-// Select a random file if required
-if (strpos($img_file['basename'],'*') !== FALSE)
-{
- $fileList = array();
- $intFile = pathinfo($intName); // N.B. - might still contain a constant such as e_IMAGE
- $matchString = '#'.str_replace('*','.*?',$intFile['basename']).'#';
- $dirName = $tp->replaceConstants($intFile['dirname'].'/'); // we want server-relative directory
- if (($h = opendir($dirName)) !== FALSE)
- {
- while (($f = readdir($h)) !== FALSE)
- {
- if (preg_match($matchString,$f))
- {
- $fileList[] = $f; // Just need to note file names
- }
- }
- closedir($h);
- }
- else
- {
- echo "Error opening directory: {$dirName} ";
- return '';
- }
- if (count($fileList))
- {
- $img_file['basename'] = $fileList[mt_rand(0,count($fileList)-1)]; // Just change name of displayed file - no change on directory
- $code_text = $img_file['dirname']."/".$img_file['basename'];
- }
- else
- {
- echo 'No file: '.$code_text;
- return '';
- }
-}
-
-
-// Check for whether we can display image down here - so we can show image name if appropriate
-if (!varsettrue($pref['image_post']) || !check_class($pref['image_post_class']))
-{
- switch ($pref['image_post_disabled_method'])
- {
- case '1' :
- return CORE_LAN17;
- case '2' :
- return '';
- }
- return CORE_LAN18.$code_text;
-}
-
-
-// Check for link to main image if required
-if (strpos($img_file['basename'],'th_') === 0)
-{
- $addlink = TRUE;
- $main_name = $img_file['dirname']."/".substr($img_file['basename'],3); // delete the 'th' prefix from file name
-}
-elseif (strpos($img_file['basename'],'thumb_') === 0)
-{
- $addlink = TRUE;
- $main_name = $img_file['dirname']."/".substr($img_file['basename'],6); // delete the 'thumb' prefix from file name
-}
-
-
-if ($addlink)
-{
- return " ";
-}
-else
-{
- return " ";
-}
diff --git a/e107_core/shortcodes/batch/news_shortcodes.php b/e107_core/shortcodes/batch/news_shortcodes.php
index 65b74aab5..553d7c10a 100644
--- a/e107_core/shortcodes/batch/news_shortcodes.php
+++ b/e107_core/shortcodes/batch/news_shortcodes.php
@@ -43,12 +43,13 @@ class news_shortcodes extends e_shortcode
function sc_newsbody($parm)
{
+ e107::getBB()->setClass("news");
$news_body = $this->e107->tp->toHTML($this->news_item['news_body'], true, 'BODY, fromadmin', $this->news_item['news_author']);
if($this->news_item['news_extended'] && (isset($_POST['preview']) || $this->param['current_action'] == 'extend') && $parm != 'noextend')
{
$news_body .= $this->e107->tp->toHTML($this->news_item['news_extended'], true, 'BODY, fromadmin', $this->news_item['news_author']);
}
-
+ e107::getBB()->clearClass();
return $news_body;
}
@@ -316,9 +317,21 @@ class news_shortcodes extends e_shortcode
{
return '';
}
- // We store SC path in DB now + BC
- $src = $this->news_item['news_thumbnail'][0] == '{' ? e107::getParser()->replaceConstants($this->news_item['news_thumbnail'], 'abs') : e_IMAGE_ABS."newspost_images/".$this->news_item['news_thumbnail'];
-
+
+ $w = vartrue($pref['resize_dimensions']['news-image']['w']);
+ $h = vartrue($pref['resize_dimensions']['news-image']['h']);
+
+ if($this->news_item['news_thumbnail'][0] == '{' && ($w || $h))
+ {
+ $src = $tp->thumbUrl($this->news_item['news_thumbnail'],"w={$w}&h={$h}");
+ }
+ else
+ {
+ // We store SC path in DB now + BC
+ $src = $this->news_item['news_thumbnail'][0] == '{' ? e107::getParser()->replaceConstants($this->news_item['news_thumbnail'], 'abs') : e_IMAGE_ABS."newspost_images/".$this->news_item['news_thumbnail'];
+ }
+
+
switch($parm)
{
case 'src':
diff --git a/e107_files/jslib/core/mediaManager.js b/e107_files/jslib/core/mediaManager.js
index 14547e522..7b2596429 100644
--- a/e107_files/jslib/core/mediaManager.js
+++ b/e107_files/jslib/core/mediaManager.js
@@ -113,6 +113,20 @@ $(document).ready(function()
var preview = $(this).attr('data-preview');
var src = $(this).attr('data-src');
var bbcode = $(this).attr('data-bbcode');
+
+ // Create new offscreen image to test
+ // var theImage = new Image();
+ // theImage.src = $(this).attr('data-src');
+
+ // Get accurate measurements from that.
+ // var imageWidth = theImage.width;
+ // var imageHeight = theImage.height;
+
+ // $('#width').val(theImage.width);
+ // $('#height').val(theImage.height);
+ // alert('width='+imageWidth);
+
+
$(this).addClass("media-select-active");
$(this).closest("img").addClass("active");
diff --git a/e107_handlers/bbcode_handler.php b/e107_handlers/bbcode_handler.php
index bfe76d24f..8069ebf60 100644
--- a/e107_handlers/bbcode_handler.php
+++ b/e107_handlers/bbcode_handler.php
@@ -427,6 +427,33 @@ class e_bbcode
$this->class = $mode;
}
+ // return the Mode used by the class. eg. news | page | user | {plugin-folder}
+ function getMode()
+ {
+ return $this->class;
+ }
+
+
+ function resizeWidth()
+ {
+ $pref = e107::getPref();
+ if($this->class && vartrue($pref['resize_dimensions'][$this->class.'-bbcode']['w']))
+ {
+ return $pref['resize_dimensions'][$this->class.'-bbcode']['w'];
+ }
+ return false;
+ }
+
+ function resizeHeight()
+ {
+ $pref = e107::getPref();
+ if($this->class && vartrue($pref['resize_dimensions'][$this->class.'-bbcode']['h']))
+ {
+ return $pref['resize_dimensions'][$this->class.'-bbcode']['h'];
+ }
+ return false;
+ }
+
// return the class for a bbcode
function getClass($type='')
{
@@ -509,6 +536,25 @@ class e_bbcode
*/
function htmltoBBcode($text)
{
+
+ $text = preg_replace("/(.*?)<\/a>/i","[link=$1]$2[/link]",$text);
+ $text = preg_replace('/([\s\S]*)<\/div>/i',"[$1]$2[/$1]",$text); // verified
+ $text = preg_replace('/ ([\s\S]*)<\/div>/i',"[$1]$2[/$1]",$text); // left / right / center
+ $text = preg_replace('/ ![]() /i',"[img style=width:$4px;height:$5px;$1]$2[/img]",$text );
+ $text = preg_replace('/ ![]() /i',"[img style=width:$4px;height:$5px;$1]$2[/img]",$text );
+ // $text = preg_replace('/ (.*?)<\/span>/i',"[color=$1]$2[/color]",$text);
+ $text = preg_replace('/(.*?)<\/span>/i',"[u]$1[/u]",$text);
+ // $text = preg_replace('//i', "[table $1]",$text);
+ $text = preg_replace('//i', "[table style=$1]\n",$text);
+ $text = preg_replace('//i', "[table]\n",$text);
+ $text = preg_replace('//i', "[tbody]\n",$text);
+ $text = preg_replace('//i', "[code]\n",$text);
+
+ $ehttp = str_replace("/",'\/',e_HTTP);
+ $text = preg_replace('/thumb.php\?src='.$ehttp.'([^&]*)([^\[]*)/i', "$1",$text);
+ $text = preg_replace('/thumb.php\?src=([^&]*)([^\[]*)/i', "$1",$text);
+
+
//return $text;
$convert = array(
array( "\n", ' '),
@@ -548,31 +594,40 @@ class e_bbcode
array( "[/td]", ''),
array( "[blockquote]", ''),
array( "[blockquote]", ''),
- array( "[/blockquote]",' ')
+ array( "[/blockquote]",' '),
+ array( "]", ' style=]')
);
+ // thumb.php?src
+
+
+
+
+
+
foreach($convert as $arr)
{
$repl[] = $arr[0];
$srch[] = $arr[1];
}
- $text = preg_replace("/(.*?)<\/a>/i","[link=$1]$2[/link]",$text);
- $text = preg_replace('/([\s\S]*)<\/div>/i',"[$1]$2[/$1]",$text); // verified
- $text = preg_replace('/ ([\s\S]*)<\/div>/i',"[$1]$2[/$1]",$text); // left / right / center
- $text = preg_replace('/ ![]() /i',"[img style=width:$4px;height:$5px;$1]$2[/img]",$text );
- $text = preg_replace('/ ![]() /i',"[img style=width:$4px;height:$5px;$1]$2[/img]",$text );
- // $text = preg_replace('/ (.*?)<\/span>/i',"[color=$1]$2[/color]",$text);
- $text = preg_replace('/(.*?)<\/span>/i',"[u]$1[/u]",$text);
- // $text = preg_replace('//i', "[table $1]",$text);
- $text = preg_replace('//i', "[table style=$1]\n",$text);
- $text = preg_replace('//i', "[table]\n",$text);
- $text = preg_replace('//i', "[tbody]\n",$text);
- $text = preg_replace('//i', "[code]\n",$text);
-
+ $paths = array(
+ e107::getFolder('images'),
+ e107::getFolder('plugins'),
+ e107::getFolder('media_images'),
+ e107::getFolder('media_files'),
+ e107::getFolder('media_videos')
+ );
+ $tp = e107::getParser();
+ foreach($paths as $k=>$path)
+ {
+ $srch[] = $path;
+ $repl[] = $tp->createConstants($path);
+ }
+
$blank = array('','width:px;height:px;',"","");
$text = str_replace($blank,"",$text); // Cleanup
diff --git a/e107_handlers/media_class.php b/e107_handlers/media_class.php
index 24a36149d..e3e882c96 100644
--- a/e107_handlers/media_class.php
+++ b/e107_handlers/media_class.php
@@ -485,12 +485,29 @@ class e_media
$srch = array("{MEDIA_URL}","{MEDIA_PATH}");
+ $w = false;
+ $h = false;
+
+ if($bbcode)
+ {
+ e107::getBB()->setClass($category);
+ $w = e107::getBB()->resizeWidth(); // resize the image according to prefs.
+ $h = e107::getBB()->resizeHeight();
+ e107::getBB()->clearclass();
+ }
+
+
+
+ $tp = e107::getParser();
+ // e107::getParser()
+
foreach($images as $im)
{
$class = ($category !='_icon') ? "media-select-image" : "media-select-icon";
- $media_path = e107::getParser()->replaceConstants($im['media_url'],'full');
- $realPath = e107::getParser()->thumbUrl($im['media_url'], $att);
- $diz = e107::getParser()->toAttribute($im['media_title']);
+ $media_path = ($w || $h) ? $tp->thumbUrl($im['media_url'], "w={$w}&h={$h}") : $tp->replaceConstants($im['media_url'],'full'); // max-size
+
+ $realPath = $tp->thumbUrl($im['media_url'], $att);
+ $diz = $tp->toAttribute($im['media_title']);
$repl = array($im['media_url'],$media_path);
if($bbcode == null) // e107 Media Manager
diff --git a/e107_plugins/tinymce/plugins/e107bbcode/parser.php b/e107_plugins/tinymce/plugins/e107bbcode/parser.php
index c256ab9c2..283506c15 100644
--- a/e107_plugins/tinymce/plugins/e107bbcode/parser.php
+++ b/e107_plugins/tinymce/plugins/e107bbcode/parser.php
@@ -14,7 +14,9 @@ require_once("../../../../class2.php");
if($_POST['mode'] == 'tohtml')
{
- echo $tp->toHtml($_POST['content'],true);
+ e107::getBB()->setClass($_SESSION['media_category']);
+ echo $tp->toHtml($_POST['content'],true);
+ e107::getBB()->clearClass();
}
if($_POST['mode'] == 'tobbcode')
diff --git a/e107_plugins/tinymce/wysiwyg.php b/e107_plugins/tinymce/wysiwyg.php
index 1da8230ad..a10c6bdbe 100644
--- a/e107_plugins/tinymce/wysiwyg.php
+++ b/e107_plugins/tinymce/wysiwyg.php
@@ -305,7 +305,7 @@ class wysiwyg
// if(!in_array('e107bbcode',$plug_array))
{
- $this->config['cleanup_callback'] = 'tinymce_e107Paths';
+ $this->config['cleanup_callback'] = 'tinymce_e107Paths';
}
$paste_plugin = (strpos($config['tinymce_plugins'],'paste')!==FALSE) ? TRUE : FALSE;
|