1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 20:30:39 +02:00

Media-Manager Bbcode inserts for [img] and [file]

This commit is contained in:
CaMer0n
2012-07-11 04:46:09 +00:00
parent 9d9c48594c
commit f67cfc40d9
8 changed files with 74 additions and 38 deletions

View File

@@ -253,11 +253,13 @@ class media_form_ui extends e_admin_form_ui
//return print_a($_GET,true); //return print_a($_GET,true);
$tagid = $_GET['tagid']; $tagid = $_GET['tagid'];
$path = $this->getController()->getListModel()->get('media_url'); $path = $this->getController()->getListModel()->get('media_url');
$title = $this->getController()->getListModel()->get('media_name');
$id = $this->getController()->getListModel()->get('media_id');
$preview = basename($path); $preview = basename($path);
$bbcode = ($_GET['bbcode']==1) ? "file" : ""; $bbcode = ($_GET['bbcode']=='file') ? "file" : "";
return "<input type='button' value='Select' class='e-media-select e-dialog-close' data-target='{$tagid}' data-bbcode='{$bbcode}' data-path='{$path}' data-preview='{$preview}' title=\"Select\" />"; return "<input type='button' value='Select' class='e-media-select e-dialog-close' data-id='{$id}' data-name=\"".$title."\" data-target='{$tagid}' data-bbcode='{$bbcode}' data-path='{$path}' data-preview='{$preview}' title=\"".$title."\" />";
} }
@@ -598,11 +600,8 @@ class media_admin_ui extends e_admin_ui
function imageSelectUpload() function imageSelectUpload()
{ {
$frm = e107::getForm(); $frm = e107::getForm();
$bbcodeMode = ($this->getQuery('bbcode')==1) ? 'bbcode=1' : FALSE; $bbcodeMode = ($this->getQuery('bbcode')=='img') ? 'bbcode=img' : FALSE;
$text = " $text = "
<div class='admintabs' id='tab-container'> <div class='admintabs' id='tab-container'>
<ul class='e-tabs' id='core-emote-tabs'> <ul class='e-tabs' id='core-emote-tabs'>
@@ -1267,6 +1266,10 @@ class media_admin_ui extends e_admin_ui
$WM = FALSE; $WM = FALSE;
} }
// Disable resize-on-import and watermark for now.
$img_import_w = false;
$img_import_h = false;
foreach($_POST['batch_selected'] as $key=>$file) foreach($_POST['batch_selected'] as $key=>$file)
{ {
@@ -1304,7 +1307,10 @@ class media_admin_ui extends e_admin_ui
if(!$f['mime']) if(!$f['mime'])
{ {
$mes->add("Couldn't get file info from : ".$oldpath, E_MESSAGE_ERROR);
$mes->add("Couldn't get file info from : ".$oldpath, E_MESSAGE_WARNING);
// $mes->add(print_a($f,true), E_MESSAGE_ERROR);
$f['mime'] = "other/file";
} }
$newpath = $this->checkDupe($oldpath,$this->getPath($f['mime']).'/'.$file); $newpath = $this->checkDupe($oldpath,$this->getPath($f['mime']).'/'.$file);
@@ -1333,7 +1339,7 @@ class media_admin_ui extends e_admin_ui
'media_category' => $_POST['batch_category'], 'media_category' => $_POST['batch_category'],
'media_datestamp' => $f['modified'], 'media_datestamp' => $f['modified'],
'media_url' => $tp->createConstants($newpath,'rel'), 'media_url' => $tp->createConstants($newpath,'rel'),
'media_userclass' => 0, 'media_userclass' => '0',
'media_name' => $newname, 'media_name' => $newname,
'media_author' => USERID, 'media_author' => USERID,
'media_size' => $f['fsize'], 'media_size' => $f['fsize'],

View File

@@ -1,8 +1,18 @@
//<? //<?
$class = e107::getBB()->getClass('file');
global $pref, $fromadmin; global $pref, $fromadmin;
$class = e107::getBB()->getClass('file');
if(is_numeric($parm)) // Media-Manager file.
{
return "<a class='".$class."' href='".e_BASE."request.php?file={$parm}'>".$code_text."</a>";
}
if ((e_PAGE == 'page.php') || (array_key_exists('forum_attach', $pref) && $pref['forum_attach'] && FILE_UPLOADS || ADMIN || $fromadmin)) if ((e_PAGE == 'page.php') || (array_key_exists('forum_attach', $pref) && $pref['forum_attach'] && FILE_UPLOADS || ADMIN || $fromadmin))
{ {
list($fname, $uc) = explode("^", $parm."^"); list($fname, $uc) = explode("^", $parm."^");

View File

@@ -106,7 +106,7 @@ class bbcode_shortcodes extends e_shortcode
{ {
list($tag,$tmp) = explode("--",$this->var['tagid']); // works with $frm->bbarea to detect textarea from first half of tag. list($tag,$tmp) = explode("--",$this->var['tagid']); // works with $frm->bbarea to detect textarea from first half of tag.
} }
$text = "<a class='e-dialog' id='{$id}' href='".e_ADMIN."image.php?mode=main&action=dialog&for=".$this->var['template']."&tagid=".$tag."&iframe=1&bbcode=1' >"; $text = "<a class='e-dialog' id='{$id}' href='".e_ADMIN."image.php?mode=main&action=dialog&for=".$this->var['template']."&tagid=".$tag."&iframe=1&bbcode=img' >";
$text .= "<img class='bbcode_buttons e-pointer' src='".e_IMAGE_ABS."bbcode/preimage.png' title='".LANHELP_45."' alt='' />"; $text .= "<img class='bbcode_buttons e-pointer' src='".e_IMAGE_ABS."bbcode/preimage.png' title='".LANHELP_45."' alt='' />";
$text .= "</a>\n"; $text .= "</a>\n";
return $text; return $text;
@@ -122,7 +122,7 @@ class bbcode_shortcodes extends e_shortcode
{ {
list($tag,$tmp) = explode("--",$this->var['tagid']); // works with $frm->bbarea to detect textarea from first half of tag. list($tag,$tmp) = explode("--",$this->var['tagid']); // works with $frm->bbarea to detect textarea from first half of tag.
} }
$text = "<a class='e-dialog' id='{$id}' href='".e_ADMIN."image.php?mode=dialog&action=list&for=download_file&tagid=".$tag."&iframe=1&bbcode=1' >"; $text = "<a class='e-dialog' id='{$id}' href='".e_ADMIN."image.php?mode=dialog&action=list&for=_common_file&tagid=".$tag."&iframe=1&bbcode=file' >";
$text .= "<img class='bbcode_buttons e-pointer' src='".e_IMAGE_ABS."bbcode/prefile.png' title='".LANHELP_39."' alt='' />"; $text .= "<img class='bbcode_buttons e-pointer' src='".e_IMAGE_ABS."bbcode/prefile.png' title='".LANHELP_39."' alt='' />";
$text .= "</a>\n"; $text .= "</a>\n";
return $text; return $text;

View File

@@ -105,39 +105,34 @@ $(document).ready(function()
// console.log(this); // console.log(this);
var id = $(this).attr('data-id');
var target = $(this).attr('data-target'); var target = $(this).attr('data-target');
var path = $(this).attr('data-path'); var path = $(this).attr('data-path');
var preview = $(this).attr('data-preview'); var preview = $(this).attr('data-preview');
var src = $(this).attr('data-src'); var src = $(this).attr('data-src');
var bbcode = $(this).attr('data-bbcode'); var bbcode = $(this).attr('data-bbcode');
var name = $(this).attr('data-name');
// 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).addClass("media-select-active");
$(this).closest("img").addClass("active"); $(this).closest("img").addClass("active");
if(bbcode) // not needed for Tinymce if(bbcode == "file") // not needed for Tinymce
{ {
// $('input#' + target, window.top.document).attr('value',path); // set new value bbpath = '[file='+ id +']'+ name + '[/file]';
// bbpath = '['+bbcode+']'+ path + '[/' + bbcode + ']'; $('#bbcode_holder').val(bbpath);
alert(bbpath); //FIXME bbcode - Insert into correct caret in text-area.
return;
// $('input#' + target, window.top.document).attr('value',path); // set new value
// $('textarea#' + target, window.top.document).attr('value',bbpath); // $('textarea#' + target, window.top.document).attr('value',bbpath);
} }
if(bbcode == "img")
{
// bbpath = '['+bbcode+']'+ path + '[/' + bbcode + ']';
//alert(bbpath);
}
$('#src').attr('value',src); // working old $('#src').attr('value',src); // working old
$('#preview').attr('src',preview); // working old $('#preview').attr('src',preview); // working old

View File

@@ -536,6 +536,9 @@ class e_bbcode
*/ */
function htmltoBBcode($text) function htmltoBBcode($text)
{ {
$text = preg_replace("/<a.*?href=\"(.*?)?request.php\?file=([\d]*)\".*?>(.*?)<\/a>/i","[file=$2]$3[/file]",$text);
$text = preg_replace("/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/i","[link=$1]$2[/link]",$text); $text = preg_replace("/<a.*?href=\"(.*?)\".*?>(.*?)<\/a>/i","[link=$1]$2[/link]",$text);
$text = preg_replace('/<div style="text-align: ([\w]*);">([\s\S]*)<\/div>/i',"[$1]$2[/$1]",$text); // verified $text = preg_replace('/<div style="text-align: ([\w]*);">([\s\S]*)<\/div>/i',"[$1]$2[/$1]",$text); // verified

View File

@@ -535,7 +535,7 @@ class e_media
$img_url = ($cat !='_icon') ? e107::getParser()->thumbUrl($im['media_url'], $att) : $media_path; $img_url = ($cat !='_icon') ? e107::getParser()->thumbUrl($im['media_url'], $att) : $media_path;
$text .= "<a class='{$class} ' 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 class='{$class} ' data-id='{$im['media_id']}' 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 .= "<img src='".$img_url."' alt=\"".$im['media_title']."\" />"; $text .= "<img src='".$img_url."' alt=\"".$im['media_title']."\" />";
$text .= "</a>\n\n"; $text .= "</a>\n\n";
} }
@@ -677,7 +677,7 @@ class e_media
$img_data['media_caption'] = $new_data['media_caption']; $img_data['media_caption'] = $new_data['media_caption'];
$img_data['media_category'] = $category; $img_data['media_category'] = $category;
$img_data['media_description'] = $new_data['media_description']; $img_data['media_description'] = $new_data['media_description'];
$img_data['media_userclass'] = 0; $img_data['media_userclass'] = '0';
if($sql->db_Insert("core_media",$img_data)) if($sql->db_Insert("core_media",$img_data))
{ {

View File

@@ -23,7 +23,7 @@
// unset $tinyMCE_imglib_include // unset $tinyMCE_imglib_include
require_once("../../../../class2.php"); require_once("../../../../class2.php");
header("Location: ".e_ADMIN_ABS.'image.php?mode=main&action=dialog&for='.$_SESSION['media_category'].'&tagid=&iframe=1&bbcode=1'); header("Location: ".e_ADMIN_ABS.'image.php?mode=main&action=dialog&for='.$_SESSION['media_category'].'&tagid=&iframe=1&bbcode=img');
exit; exit;

View File

@@ -30,6 +30,23 @@ if (!e_QUERY || isset($_POST['userlogin']))
} }
$id = FALSE; $id = FALSE;
//TODO e_request.php - allow plugins like 'downloads' to hook into request.php which should only be a generic file-downloading function.
// Media-Manager direct file download.
if(vartrue($_GET['file']) && is_numeric($_GET['file']))
{
if ($sql->db_Select('core_media', 'media_url', "media_id= ".intval($_GET['file'])." AND media_userclass IN (".USERCLASS_LIST.") LIMIT 1 "))
{
$row = $sql->db_Fetch();
$file = $tp->replaceConstants($row['media_url'],'rel');
// echo 'file='.$file;
send_file($file);
exit();
}
}
if (!is_numeric(e_QUERY)) if (!is_numeric(e_QUERY))
{ {
if ($sql->db_Select('download', 'download_id', "download_url='".$tp -> toDB(e_QUERY)."'")) if ($sql->db_Select('download', 'download_id', "download_url='".$tp -> toDB(e_QUERY)."'"))
@@ -51,6 +68,7 @@ if (!is_numeric(e_QUERY))
} }
if(strstr(e_QUERY, "mirror")) if(strstr(e_QUERY, "mirror"))
{ // Download from mirror { // Download from mirror
list($action, $download_id, $mirror_id) = explode(".", e_QUERY); list($action, $download_id, $mirror_id) = explode(".", e_QUERY);
@@ -343,13 +361,17 @@ else
// File retrieval function. by Cam. // File retrieval function. by Cam.
function send_file($file) function send_file($file)
{ {
global $pref, $DOWNLOADS_DIRECTORY,$FILES_DIRECTORY, $e107; global $DOWNLOADS_DIRECTORY,$FILES_DIRECTORY, $e107;
$pref = e107::getPref();
/* PHP handling by default.
if (!$pref['download_php']) if (!$pref['download_php'])
{ {
header("Location: ".SITEURL.$file); header("Location: ".SITEURL.$file);
exit(); exit();
} }
*/
@set_time_limit(10 * 60); @set_time_limit(10 * 60);
@session_write_close(); @session_write_close();