1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 06:38:00 +02:00

Default image resize pref is now used correctly by TinyMce media-manager. Image captions may now be added to inline images. TinyMce media-manager 'cancel' button is working again.

This commit is contained in:
Cameron
2016-01-11 20:53:05 -08:00
parent 39cee385f7
commit b1c2e030d5
9 changed files with 151 additions and 46 deletions

View File

@@ -1065,18 +1065,31 @@ class media_admin_ui extends e_admin_ui
return '';
}
// if 'for' has no value, files are placed in /temp and not added to the db.
$text = '<div id="uploader" rel="'.e_JS.'plupload/upload.php?for='.$this->getQuery('for').'">
// if 'for' has no value, files are placed in /temp and not added to the db.
$text = "<h4>From your computer</h4>";
$text .= '<div id="uploader" rel="'.e_JS.'plupload/upload.php?for='.$this->getQuery('for').'">
<p>No HTML5 support.</p>
</div>';
$text .= '<hr />';
$frm = e107::getForm();
$text .= $frm->open('upload-url-form','post');
$text .= '<div class="plupload_header_content">';
$text .= "<div class='plupload_header_text form-inline' style='padding:20px'>Or upload a remote image or file ";
$text .= "<input type='text' name='upload_url' size='255' style='width:70%' placeholder='eg. http://website.com/some-image.jpg' />";
$text .= $frm->admin_button('upload_remote_url',1,'create','Start Upload');
$text .= "<h4>From a remote location</h4>";
$text .= "<div class='plupload_header_text form-inline' style='padding-left:20px;padding-right:20px'>";
$text .= "<table class='table'>";
$text .= "<tr>
<td class='text-nowrap'>Image/File URL:</td>
<td><input type='text' name='upload_url' size='255' style='width:100%' placeholder='eg. http://website.com/some-image.jpg' /></td>
<td style='text-align:left'>".$frm->admin_button('upload_remote_url',1,'create','Start Upload')."</td>
</tr>";
$text .= "<tr><td>Caption (optional):</td><td><input type='text' name='upload_caption' size='255' style='width:100%' placeholder='eg. My Image Caption' /></td>
<td></td></tr>";
$text .= "</table>";
// $text .= ;
$text .= "</div>";
$text .= "</div>\n\n";
@@ -1182,7 +1195,7 @@ class media_admin_ui extends e_admin_ui
*
*/
if($options['bbcode'])
if($options['bbcode']) //TODO LAN lan_image.php
{
$text .= "<div class='tab-pane' id='core-media-style'>
@@ -1194,11 +1207,17 @@ class media_admin_ui extends e_admin_ui
<col class='col-control' />
</colgroup>
<tbody>
<tr>
<td>Caption: </td>
<td>
<input type='text' class='e-media-attribute' id='alt' name='alt' size='4' style='width:100%' value='' />
</td>
</tr>
<tr>
<td>Dimensions: </td>
<td>
<input type='text' class='e-media-attribute' id='width' name='width' size='4' style='width:50px' value='' /> px
X <input type='text' class='e-media-attribute' id='height' name='height' size='4' style='width:50px' value='' /> px
<input type='text' class='e-media-attribute' id='width' name='width' size='4' style='width:50px' value='' /> px &nbsp;
&#10060; &nbsp;<input type='text' class='e-media-attribute' id='height' name='height' size='4' style='width:50px' value='' /> px
</td>
</tr>
@@ -1230,7 +1249,7 @@ class media_admin_ui extends e_admin_ui
</tbody></table>
</div>
<div class='col-md-6 span6'>
<h5>Preview</h5>
<h5>".LAN_PREVIEW."</h5>
<img class='well' id='preview' src='".e_IMAGE_ABS."generic/blank.gif' style='min-width:220px; min-height:180px;' />
@@ -1269,14 +1288,15 @@ class media_admin_ui extends e_admin_ui
$text .= "</div>";
// For BBCODE mode. //TODO image-float.
// For BBCODE/TinyMce mode.
// e-dialog-save
if($options['bbcode'] || E107_DEBUG_LEVEL > 0)
{
$text .= "<div style='text-align:right;padding:5px'>
<button type='submit' class='btn btn-success submit e-dialog-save e-dialog-close' data-bbcode='".$options['bbcode']."' data-target='".$this->getQuery('tagid')."' name='save_image' value='Save it' >
<button type='submit' class='btn btn-success submit e-dialog-save' data-bbcode='".$options['bbcode']."' data-target='".$this->getQuery('tagid')."' name='save_image' value='Save it' >
<span>Save</span>
</button>
<button type='submit' class=' btn btn-default submit e-dialog-close' name='cancel_image' value='Cancel' >
@@ -1612,13 +1632,20 @@ class media_admin_ui extends e_admin_ui
list($fileName,$bla) = explode("?", $fileName);
}
// remove script extensions.
if(substr($fileName,-4) == ".php" || substr($fileName,-4) == ".htm" || substr($fileName,-5) == ".html" || substr($fileName,-4) == ".asp")
{
$fileName = empty($_POST['upload_caption']) ? str_replace(array(".php",".html",".asp",".htm"),'',$fileName)."_".time() : eHelper::dasherize(strtolower($_POST['upload_caption']));
}
if(!$fl->getRemoteFile($_POST['upload_url'], $fileName, 'import'))
{
$mes->addError("There was a problem grabbing the file");
}
elseif($import == true)
{
$result = e107::getMedia()->importFile($fileName,$cat);
$data = array('media_caption' => e107::getParser()->filter($_POST['upload_caption'],'str'));
$result = e107::getMedia()->importFile($fileName,$cat, null, $data);
}
}
}

View File

@@ -718,7 +718,8 @@ class news_admin_ui extends e_admin_ui
$this->cats[$cat] = $row['category_name'];
}
asort($this->cats);
$this->fields['news_category']['writeParms'] = $this->cats;
$this->fields['news_category']['writeParms']['optArray'] = $this->cats;
$this->fields['news_category']['writeParms']['size'] = 'xlarge';
$this->fields['news_render_type']['writeParms']['optArray'] = $this->news_renderTypes; // array(NWSLAN_75,NWSLAN_76,NWSLAN_77,NWSLAN_77." 2","Featurebox");
$this->fields['news_render_type']['writeParms']['multiple'] = 1;
// $this->newspost = new admin_newspost;
@@ -1443,6 +1444,7 @@ class news_form_ui extends e_admin_form_ui
$text .= $frm->imagepicker('news_thumbnail[3]', varset($thumbTmp[3]),'','media=news&video=1');
$text .= $frm->imagepicker('news_thumbnail[4]', varset($thumbTmp[4]),'','media=news&video=1');
// $text .= "<div class='field-help'>Insert image/video into designated area of template.</div>";
return $text;
}

View File

@@ -23,6 +23,8 @@ class bb_img extends e_bb_base
if(vartrue($parms['class'])) $safe['class'] = eHelper::secureClassAttr($parms['class']);
if(vartrue($parms['id'])) $safe['id'] = eHelper::secureIdAttr($parms['id']);
if(vartrue($parms['style'])) $safe['style'] = eHelper::secureStyleAttr($parms['style']);
if(vartrue($parms['alt'])) $safe['alt'] = e107::getParser()->filter($parms['style'],'str');
if($safe)
{
return '[img '.eHelper::buildAttr($safe).']'.$code_text.'[/img]';
@@ -43,6 +45,15 @@ class bb_img extends e_bb_base
$code_text = str_replace('{e_MEDIA_IMAGE}', e_HTTP."thumb.php?src=e_MEDIA_IMAGE/", $code_text);
$code_text = str_replace('{e_THEME}', e_HTTP."thumb.php?src=e_THEME/", $code_text);
$imgParms = $this->processParm($code_text, $parm);
$figcaption = false;
if($imgParms['figcaption'])
{
$figcaption = $imgParms['figcaption'];
unset($imgParms['figcaption']);
}
foreach($imgParms as $k => $v)
{
@@ -51,7 +62,7 @@ class bb_img extends e_bb_base
}
$w = e107::getBB()->resizeWidth(); // varies depending on the class set by external script. see admin->media-manager->prefs
// $w = e107::getBB()->resizeWidth(); // varies depending on the class set by external script. see admin->media-manager->prefs
$w = vartrue($imgParms['width']) ? intval($imgParms['width']) : vartrue(e107::getBB()->resizeWidth(),0);
@@ -62,10 +73,25 @@ class bb_img extends e_bb_base
// print_a($imgParms);
// print_a($parmStr);
return "<img src=\"".$code_text.$resize."\" {$parmStr} />";
if(!empty($figcaption))
{
$html = "<figure>\n";
$html .= "<img src=\"".$code_text.$resize."\" {$parmStr} />\n";
$html .= "<figcaption>".e107::getParser()->filter($figcaption,'str')."</figcaption>\n";
$html .= "</figure>";
return $html;
}
else
{
return "<img src=\"".$code_text.$resize."\" {$parmStr} />";
}
}
/**
* Process the [img] bbcode parm. ie. [img parms]something[/img]
*/
@@ -98,6 +124,12 @@ class bb_img extends e_bb_base
preg_match("/([\w]*)(?:\.png|\.jpg|\.jpeg|\.gif)/i", $code_text, $match); // Generate required Alt attribute.
$imgParms['alt'] = ucwords(str_replace("_"," ",$match[1]));
}
else
{
$imgParms['figcaption'] = $imgParms['alt'] ;
}
$imgParms['title'] = $imgParms['alt'] ;
$imgParms['class'] = "img-rounded bbcode ".e107::getBB()->getClass('img');; // This will be overridden if a new class is specified
@@ -116,7 +148,8 @@ class bb_img extends e_bb_base
return $imgParms;
}
function toHTML($code_text, $parm)
{

View File

@@ -690,8 +690,11 @@ class news_shortcodes extends e_shortcode
}
}
if($tmp['count'] > 1 && empty($parm['type'])) // link first image by default, but not others.
{
$parm['type'] = 'tag';
}
switch(vartrue($parm['type']))
{
case 'src':

View File

@@ -2834,8 +2834,8 @@ class e_parser
protected $allowedTags = array('html', 'body','div','a','img','table','tr', 'td', 'th', 'tbody', 'thead', 'colgroup', 'b',
'i', 'pre','code', 'strong', 'u', 'em','ul', 'ol', 'li','img','h1','h2','h3','h4','h5','h6','p',
'div','pre','section','article', 'blockquote','hgroup','aside','figure','span', 'audio', 'video', 'br',
'small', 'caption', 'noscript', 'hr'
'div','pre','section','article', 'blockquote','hgroup','aside','figure','figcaption', 'abbr','span', 'audio', 'video', 'br',
'small', 'caption', 'noscript', 'hr', 'section'
);
protected $scriptTags = array('script','applet','iframe','form','input','button'); //allowed when $pref['post_script'] is enabled.

View File

@@ -694,17 +694,17 @@ class e_media
$srch = array("{MEDIA_URL}","{MEDIA_PATH}");
$w = false;
$w = false; //
$h = false;
$defaultResizeWidth = 400;
if($bbcode) // ie. TinyMce Editor, not imagepicker();
{
e107::getBB()->setClass($category);
$w = e107::getBB()->resizeWidth(); // resize the image according to prefs.
$defaultResizeWidth = e107::getBB()->resizeWidth(); // resize the image according to prefs.
$h = e107::getBB()->resizeHeight();
e107::getBB()->clearclass();
}
// print_a($option);
@@ -722,7 +722,7 @@ class e_media
{
list($dbWidth,$dbHeight) = explode(" x ",$im['media_dimensions']);
$w = ($dbWidth > 400) ? 400 : intval($dbWidth);
$w = ($dbWidth > $defaultResizeWidth) ? $defaultResizeWidth : intval($dbWidth);
// $w = vartrue($w,0);
// $h = vartrue($w,0);
@@ -733,6 +733,8 @@ class e_media
$diz = $tp->toAttribute(varset($im['media_title']))."\n".varset($im['media_dimensions']);
$repl = array($im['media_url'],$media_path);
$media_alt = $tp->toAttribute(vartrue($im['media_caption']));
if($bbcode == null) // e107 Media Manager
{
@@ -759,7 +761,7 @@ class e_media
$img_url = ($cat !='_icon') ? e107::getParser()->thumbUrl($im['media_url'], $thumbAtt) : $media_path;
$text .= "<a data-toggle='context' class='thumbnail {$class} e-tip' data-id='{$im['media_id']}' data-width='{$w}' data-height='{$h}' data-src='{$media_path}' data-bbcode='{$data_bb}' data-target='{$tagid}' data-path='{$im['media_url']}' data-preview='{$realPath}' title=\"".$diz."\" style='float:left' href='#' onclick=\"{$onclicki}\" >";
$text .= "<a data-toggle='context' class='thumbnail {$class} e-tip' data-id='{$im['media_id']}' data-width='{$w}' data-height='{$h}' data-src='{$media_path}' data-bbcode='{$data_bb}' data-target='{$tagid}' data-path='{$im['media_url']}' data-preview='{$realPath}' data-alt=\"".$media_alt."\" title=\"".$diz."\" style='float:left' href='#' onclick=\"{$onclicki}\" >";
$text .= "<img class='image-rounded' src='".$img_url."' alt=\"".$im['media_title']."\" title=\"{$diz}\" />";
$text .= "</a>\n\n";
}
@@ -1043,6 +1045,7 @@ class e_media
}
$newpath = $this->checkDupe($oldpath,$typePath.'/'.$file);
$newpath = $this->checkFileExtension($newpath, $img_data['media_type']);
if(!rename($oldpath, $newpath)) // e_MEDIA.$newpath was working before.
{
@@ -1052,7 +1055,7 @@ class e_media
};
$img_data['media_url'] = $tp->createConstants($newpath,'rel');
$img_data['media_name'] = $tp->toDB($file);
$img_data['media_name'] = $tp->toDB(basename($newpath));
$img_data['media_caption'] = $new_data['media_caption'];
$img_data['media_category'] = vartrue($category,'_common_image');
$img_data['media_description'] = $new_data['media_description'];
@@ -1073,7 +1076,37 @@ class e_media
}
/**
* Check File-name against mime-type and add missing extension if necessary.
* @param $path
* @param $mime
* @return string
*/
private function checkFileExtension($path, $mime)
{
if(empty($mime))
{
return $path;
}
list($type,$ext) = explode("/",$mime);
$ext = str_replace("jpeg",'jpg',$ext);
if($type == 'image' && (substr($path,-3) != $ext))
{
return $path.".".$ext;
}
else
{
return $path;
}
}
function browserCarouselItem($row = array())
{

View File

@@ -113,7 +113,7 @@ if((e107::wysiwyg() === true && check_class($pref['post_html'])) || strpos(e_SEL
var s = $('#bbcode_holder').val();
// alert(s);
alert(s);
var p = $.ajax({
type: 'POST',
@@ -130,7 +130,7 @@ if((e107::wysiwyg() === true && check_class($pref['post_html'])) || strpos(e_SEL
}).responseText;
html = p;
// alert(s);
// alert(p);
if(html === undefined)
{
@@ -145,7 +145,7 @@ if((e107::wysiwyg() === true && check_class($pref['post_html'])) || strpos(e_SEL
$('.e-dialog-close').click(function(){
// top.tinymce.activeEditor.windowManager.close();
top.tinymce.activeEditor.windowManager.close();
});

View File

@@ -220,6 +220,7 @@ TEMPL;
$style = vartrue($img['style']) ? ' style="'.$img['style'].'"' : '';
$class = vartrue($img['class']) ? ' class="'.$img['class'].'"' : '';
$alt = vartrue($img['alt']) ? ' alt="'.$img['alt'].'"' : '';
$title = vartrue($img['title']) ? ' title="'.$img['title'].'"' : '';
list($url,$qry) = explode("?",$img['src']);
@@ -233,7 +234,7 @@ TEMPL;
$src = $url."?".urldecode(http_build_query($qr));
$replacement = '<img'.$class.$style.' src="'.$src.'"'.$width.$height.$alt.' />';
$replacement = '<img'.$class.$style.' src="'.$src.'"'.$width.$height.$alt.$title.' />';
$text = preg_replace($regexp, $replacement, $text);

View File

@@ -33,10 +33,11 @@ $(document).ready(function()
var margin_bottom = $('#margin-bottom').val();
var margin_right = $('#margin-right').val();
var margin_left = $('#margin-left').val();
var _float = $('#float').val();
var _float = $('#float').val();
var alt = $('#alt').val();
if(margin_right !='' && margin_right !== undefined)
if(margin_right !='' && margin_right !== undefined)
{
style = style + 'margin-right:' + margin_right + 'px;';
}
@@ -95,7 +96,12 @@ $(document).ready(function()
{
bb = bb + ' style='+style;
}
if(alt != '')
{
bb = bb + '&alt=' + alt;
}
bb = bb + ']';
bb = bb + path;
bb = bb + '[/img]';
@@ -129,7 +135,7 @@ $(document).ready(function()
var width = $(this).attr('data-width');
var height = ''; // disable for now - will be updated by bb parser. // $(this).attr('data-height');
var type = $(this).attr('data-type');
var alt = $(this).attr('data-alt');
// return;
// alert(width);
@@ -169,13 +175,13 @@ $(document).ready(function()
$('#src').attr('src',src); // working old
$('#width').val(width);
$('#height').val(height);
$('img#' + target + "_prev", window.top.document).attr('src',preview); // set new value
$('#height').val(height);
$('#alt').val(alt);
$('img#' + target + "_prev", window.top.document).attr('src',preview); // set new value
if(type == 'glyph')