diff --git a/e107_admin/image.php b/e107_admin/image.php index c56bf027b..dd7677795 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -340,7 +340,29 @@ class media_admin_ui extends e_admin_ui } if($this->getQuery('iframe')) - { + { + if($this->getQuery('bbcode')) + { + e107::getJs()->headerFile(e_PLUGIN_ABS.'tinymce/tiny_mce_popup.js',2); + e107::getJS()->headerInline(" + + /* Send the generated IMG bbcode back to the textarea/window */ + function saveBB() + { + var add = document.getElementById('bbcode_holder').value; + addtext(add); + + // tinyMCE.execCommand('mceInsertContent',false,'hi there'); + tinyMCEPopup.close(); + + //parent.e107Widgets.DialogManagerDefault.getWindow('e-dialog').close(); + return false; + } + + "); + + } + $this->getResponse()->setIframeMod(); // disable header/footer menus etc. if(!$this->getQuery('for')) { @@ -355,6 +377,8 @@ class media_admin_ui extends e_admin_ui $this->getModel()->set('media_category', $this->getQuery('for')); } } + + } // // if($this->getQuery('for') && $this->getMediaCategory($this->getQuery('for'))) @@ -387,11 +411,22 @@ class media_admin_ui extends e_admin_ui function imageSelectUpload() { + $frm = e107::getForm(); + $bbcodeMode = ($this->getQuery('bbcode')==1) ? 'bbcode=1' : FALSE; + $text = "
Library @@ -399,8 +434,7 @@ class media_admin_ui extends e_admin_ui "; - // This should really be replaced with the generic LIST function, but with it's own template for markup. - $text .= e107::getMedia()->mediaSelect($this->getQuery('for'),$this->getQuery('tagid')); // eg. news, news-thumbnail + $text .= e107::getMedia()->mediaSelect($this->getQuery('for'),$this->getQuery('tagid'),$bbcodeMode); // eg. news, news-thumbnail $text .= " @@ -417,10 +451,151 @@ class media_admin_ui extends e_admin_ui $text .= $this->CreatePage(); $text .= " -
-
- "; + "; + + /* In BBCODE-Mode this dialog rerturns an [img] bbcode to the 'tagid' container with the appropriate parms generated. + * eg. [img style=float:left;margin-right:3px]{e_MEDIA_IMAGE}someimage.jpg[/img] + * Then the dialog may be used as a bbcode img popup and within TinyMce also. + * + */ + + if($bbcodeMode) + { + $text .= "
+ Appearance + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Dimensions: + px + X px +
Text flow: ".$frm->selectbox('float', array('default'=>'Default','left'=>'Right','right'=>"Left"))."
Margin-Left:
Margin-Right:
Margin-Top:
Margin-Bottom:
+
"; + } + $text .= ""; + + // For BBCODE mode. //TODO image-float. + if($bbcodeMode) + { + $text .= "To be Hidden
+ bbcode:
+ html: +
src: + "; + + $text .= "
+ + + +
"; + + e107::getJs()->footerInline(" + + + /* Generate an IMG bbcode based on input by user */ + function updateBB() + { + var style = ''; + var bb = ''; + + var src = document.getElementById('src').value; + var width = document.getElementById('width').value; + var height = document.getElementById('height').value; + var margin_top = document.getElementById('margin-top').value; + var margin_bottom = document.getElementById('margin-bottom').value; + var margin_right = document.getElementById('margin-right').value; + var margin_left = document.getElementById('margin-left').value; + + if(width !='') + { + style = style + 'width:' + width + 'px;'; + } + + if(height !='') + { + style = style + 'height:' + height + 'px;'; + } + + if(margin_right !='') + { + style = style + 'margin-right:' + margin_right + 'px;'; + } + + if(margin_left !='') + { + style = style + 'margin-left:' + margin_left + 'px;'; + } + + if(margin_top !='') + { + style = style + 'margin-top:' + margin_top + 'px;'; + } + + if(margin_bottom !='') + { + style = style + 'margin-bottom:' + margin_bottom + 'px;'; + } + + bb = '[img'; + + if(style !='') + { + bb = bb + ' style='+style; + } + + bb = bb + ']'; + bb = bb + src; + bb = bb + '[/img]'; + + document.getElementById('bbcode_holder').value = bb; + + var html = ''; + document.getElementById('html_holder').value = html; + + } + + "); + + } + return $text; } diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 713b87c9e..921d01291 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -145,20 +145,22 @@ class e_form } // FIXME - Dialog JS no more working, investigate - public function mediaUrl($category = '', $label = '', $tagid='', $tabs=TRUE) + public function mediaUrl($category = '', $label = '', $tagid='', $bbcode='') { - if($category) $category = '&for='.$category; + $cat = ($category) ? '&for='.$category : ""; if(!$label) $label = ' Upload an image or file'; - if($tagid) $category .= '&tagid='.$tagid; - + if($tagid) $cat .= '&tagid='.$tagid; + if($bbcode) $cat .= '&bbcode=1'; // $tabs // TODO - option to choose which tabs to display. //TODO Parse selection data back to parent form. - $url = e_ADMIN_ABS."image.php?mode=main&action=dialog".$category; + $url = e_ADMIN_ABS."image.php?mode=main&action=dialog".$cat; $ret = "".$label.""; + // $footer = "
Save
"; + $footer = ''; if(!e107::getRegistry('core/form/mediaurl')) { e107::getJs()->requireCoreLib('core/admin.js') @@ -172,10 +174,10 @@ class e_form ev.stop(); new e107Widgets.URLDialog(element.href + "&iframe=1", { id: element["id"] || "e-dialog", - width: 900, - height: 600 + width: 830, + height: 650 - }).center().activate().show(); + }).center().setHeader("Media Manager : '.$category.'").setFooter('.$footer.').activate().show(); }); '); e107::setRegistry('core/form/mediaurl', true); diff --git a/e107_handlers/media_class.php b/e107_handlers/media_class.php index 12b301551..e60cfe5ae 100644 --- a/e107_handlers/media_class.php +++ b/e107_handlers/media_class.php @@ -334,29 +334,28 @@ class e_media public function mediaSelect($cat='',$tagid=null,$att=null) { - $onclick = null; // option to override onclick behavior. See ibrowser.php + $bbcode = null; // option to override onclick behavior. See ibrowser.php $cat = ($cat) ? $cat."+" : ""; // the '+' loads category '_common' as well as the chosen category. parse_str($att); // grab 'onclick' . // $total_images = $this->getImages($cat); // for use by next/prev in filter at some point. - $images = $this->getImages($cat,0,30); + $images = $this->getImages($cat,0,23); $att = 'aw=120&ah=100'; $prevId = $tagid."_prev"; // EXAMPLE of FILTER GUI. - - // This filter should run independently of admin_ui so that it can also be utilized by ibrowser.php + $text .= "
Filter: "; $text .= " "; // Manual filter, if onkeyup ajax fails for some reason. $text .= ""; // see previous page of images. $text .= ""; // see next page of images. - $text .= " Displaying 0-30 of 150 images.
 
+ $text .= " Displaying 0-24 of 150 images.
 
\n"; - if($onclick == null) // e107 Media Manager Only. TinyMce doesn't need it. + if($bbcode == null) // e107 Media Manager - new-image mode. { $onclick_clear = "parent.document.getElementById('{$tagid}').value = ''; parent.document.getElementById('".$prevId."').src = '".e_IMAGE_ABS."generic/blank.gif'; @@ -378,7 +377,7 @@ class e_media $diz = e107::getParser()->toAttribute($im['media_title']); $repl = array($im['media_url'],$media_path); - if($onclick == null) // e107 Media Manager + if($bbcode == null) // e107 Media Manager { $onclicki = "parent.document.getElementById('{$tagid}').value = '{$im['media_url']}'; parent.document.getElementById('".$prevId."').src = '{$realPath}'; @@ -387,7 +386,11 @@ class e_media } else // TinyMce and other applications. { - $onclicki = str_replace($srch,$repl,$onclick); + $onclicki = "document.getElementById('src').value = '{$im['media_url']}'; + updateBB(); + ; + + return false;"; } diff --git a/e107_plugins/tinymce/plugins/ibrowser/ibrowser.php b/e107_plugins/tinymce/plugins/ibrowser/ibrowser.php index 4236284dc..8d861f00a 100644 --- a/e107_plugins/tinymce/plugins/ibrowser/ibrowser.php +++ b/e107_plugins/tinymce/plugins/ibrowser/ibrowser.php @@ -22,6 +22,20 @@ // unset $tinyMCE_imglib_include require_once("../../../../class2.php"); +header("Location: ".e_ADMIN_ABS.'image.php?mode=main&action=dialog&for=news&tagid=news-thumbnail&iframe=1&bbcode=1'); +exit; + +$_GET['iframe'] = 1; +$_GET['mode'] = 'main'; +$_GET['action'] = 'dialog'; +$_GET['for'] = 'news'; +$_GET['tagid'] = 'news-thumbnail'; +$_GET['bbcode']= 1; + +// +require_once(e_ADMIN.'image.php'); +exit; + if (!defined('e107_INIT')) { exit; } @@ -133,7 +147,7 @@ echo "'; - // alert(html); + // alert(html); tinyMCE.execCommand('mceInsertContent',false,html); tinyMCEPopup.close();