mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 06:38:00 +02:00
More Media-Manager (work in progress)
This commit is contained in:
@@ -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 = "
|
||||
<div class='admintabs' id='tab-container'>
|
||||
<ul class='e-tabs e-hideme' id='core-emote-tabs'>
|
||||
<li id='tab-select'><a href='#core-media-select'>Choose from Library</a></li>
|
||||
<li id='tab-upload'><a href='#core-media-upload'>Upload a File</a></li>
|
||||
<li id='tab-upload'><a href='#core-media-upload'>Upload a File</a></li>";
|
||||
|
||||
if($bbcodeMode)
|
||||
{
|
||||
$text .= "<li id='tab-style'><a href='#core-media-style'>Appearance</a></li>\n";
|
||||
}
|
||||
|
||||
|
||||
$text .= "
|
||||
</ul>
|
||||
<fieldset id='core-media-select'>
|
||||
<legend>Library</legend>
|
||||
@@ -399,8 +434,7 @@ class media_admin_ui extends e_admin_ui
|
||||
<tbody><tr><td>
|
||||
";
|
||||
|
||||
// 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 .= "
|
||||
</td></tr>
|
||||
@@ -417,10 +451,151 @@ class media_admin_ui extends e_admin_ui
|
||||
$text .= $this->CreatePage();
|
||||
|
||||
$text .= "
|
||||
</fieldset>
|
||||
</div>
|
||||
";
|
||||
</fieldset>";
|
||||
|
||||
/* 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 .= "<fieldset id='core-media-style'>
|
||||
<legend>Appearance</legend>
|
||||
<table cellpadding='0' cellspacing='0' class='adminedit'>
|
||||
<colgroup span='2'>
|
||||
<col class='col-label' />
|
||||
<col class='col-control' />
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Dimensions: </td>
|
||||
<td>
|
||||
<input type='text' id='width' name='width' size='4' style='width:50px' value='' onkeyup='updateBB()' /> px
|
||||
X <input type='text' id='height' name='height' size='4' style='width:50px' value='' onkeyup='updateBB()' /> px
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Text flow: </td>
|
||||
<td>".$frm->selectbox('float', array('default'=>'Default','left'=>'Right','right'=>"Left"))."</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Margin-Left: </td>
|
||||
<td><input type='text' id='margin-left' name='margin_left' value='' onkeyup='updateBB()' /></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Margin-Right: </td>
|
||||
<td><input type='text' id='margin-right' name='margin_right' value='' onkeyup='updateBB()' /></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Margin-Top: </td>
|
||||
<td><input type='text' id='margin-top' name='margin_top' value='' onkeyup='updateBB()' /></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>Margin-Bottom: </td>
|
||||
<td><input type='text' id='margin-bottom' name='margin_bottom' value='' onkeyup='updateBB()' /></td>
|
||||
</tr>
|
||||
|
||||
</tbody></table>
|
||||
</fieldset>";
|
||||
}
|
||||
$text .= "</div>";
|
||||
|
||||
// For BBCODE mode. //TODO image-float.
|
||||
if($bbcodeMode)
|
||||
{
|
||||
$text .= "To be Hidden<br />
|
||||
bbcode: <input type='text' style='width:800px' id='bbcode_holder' name='bbcode_holder' value='' /><br />
|
||||
html: <input type='text' style='width:800px' id='html_holder' name='html_holder' value='' />
|
||||
<br />src: <input type='text' style='width:600px' id='src' name='src' value='' />
|
||||
";
|
||||
|
||||
$text .= "<div style='text-align:right;padding:5px'>
|
||||
|
||||
<button type='submit' class='submit' name='save_image' value='Save' onclick=\"saveBB();\" >
|
||||
<span>Save</span>
|
||||
</button>
|
||||
<button type='submit' class='submit' name='cancel_image' value='Cancel' onclick=\"parent.e107Widgets.DialogManagerDefault.getWindow('e-dialog').close();\" >
|
||||
<span>Cancel</span>
|
||||
</button>
|
||||
</div>";
|
||||
|
||||
|
||||
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 = '<img src=\''+ src +'\' style=\'' + style + '\' />';
|
||||
document.getElementById('html_holder').value = html;
|
||||
|
||||
}
|
||||
|
||||
");
|
||||
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
@@ -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 = "<a title='Click to Change' rel='external' class='e-dialog' href='".$url."'>".$label."</a>";
|
||||
|
||||
// $footer = "<div style=\'padding:5px;text-align:center\' <a href=\'#\' >Save</a></div>";
|
||||
$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);
|
||||
|
@@ -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 .= "<div>Filter: <input type='text' name='non-working-filter-example' value='' />";
|
||||
$text .= "<input type='button' value='Go' /> "; // Manual filter, if onkeyup ajax fails for some reason.
|
||||
$text .= "<input type='button' value='«' />"; // see previous page of images.
|
||||
$text .= "<input type='button' value='»' />"; // see next page of images.
|
||||
$text .= " Displaying 0-30 of 150 images.<br /> </div>
|
||||
$text .= " Displaying 0-24 of 150 images.<br /> </div>
|
||||
<div>\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;";
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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 "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://
|
||||
|
||||
var html = '<img src=\''+ src +'\' alt=\''+ alt +'\' style=\'' + css_style + '\' />';
|
||||
|
||||
// alert(html);
|
||||
// alert(html);
|
||||
tinyMCE.execCommand('mceInsertContent',false,html);
|
||||
tinyMCEPopup.close();
|
||||
|
||||
|
Reference in New Issue
Block a user