mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 12:20:44 +02:00
Media-Manager Bbcode inserts for [img] and [file]
This commit is contained in:
@@ -253,11 +253,13 @@ class media_form_ui extends e_admin_form_ui
|
||||
//return print_a($_GET,true);
|
||||
$tagid = $_GET['tagid'];
|
||||
$path = $this->getController()->getListModel()->get('media_url');
|
||||
$title = $this->getController()->getListModel()->get('media_name');
|
||||
$id = $this->getController()->getListModel()->get('media_id');
|
||||
$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()
|
||||
{
|
||||
$frm = e107::getForm();
|
||||
$bbcodeMode = ($this->getQuery('bbcode')==1) ? 'bbcode=1' : FALSE;
|
||||
|
||||
|
||||
|
||||
|
||||
$bbcodeMode = ($this->getQuery('bbcode')=='img') ? 'bbcode=img' : FALSE;
|
||||
|
||||
$text = "
|
||||
<div class='admintabs' id='tab-container'>
|
||||
<ul class='e-tabs' id='core-emote-tabs'>
|
||||
@@ -1267,6 +1266,10 @@ class media_admin_ui extends e_admin_ui
|
||||
$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)
|
||||
{
|
||||
|
||||
@@ -1304,7 +1307,10 @@ class media_admin_ui extends e_admin_ui
|
||||
|
||||
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);
|
||||
@@ -1333,7 +1339,7 @@ class media_admin_ui extends e_admin_ui
|
||||
'media_category' => $_POST['batch_category'],
|
||||
'media_datestamp' => $f['modified'],
|
||||
'media_url' => $tp->createConstants($newpath,'rel'),
|
||||
'media_userclass' => 0,
|
||||
'media_userclass' => '0',
|
||||
'media_name' => $newname,
|
||||
'media_author' => USERID,
|
||||
'media_size' => $f['fsize'],
|
||||
|
@@ -1,8 +1,18 @@
|
||||
//<?
|
||||
$class = e107::getBB()->getClass('file');
|
||||
|
||||
|
||||
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))
|
||||
{
|
||||
list($fname, $uc) = explode("^", $parm."^");
|
||||
|
@@ -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.
|
||||
}
|
||||
$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 .= "</a>\n";
|
||||
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.
|
||||
}
|
||||
$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 .= "</a>\n";
|
||||
return $text;
|
||||
|
@@ -105,39 +105,34 @@ $(document).ready(function()
|
||||
|
||||
|
||||
// console.log(this);
|
||||
|
||||
|
||||
|
||||
|
||||
var id = $(this).attr('data-id');
|
||||
var target = $(this).attr('data-target');
|
||||
var path = $(this).attr('data-path');
|
||||
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);
|
||||
|
||||
|
||||
var name = $(this).attr('data-name');
|
||||
|
||||
$(this).addClass("media-select-active");
|
||||
$(this).closest("img").addClass("active");
|
||||
|
||||
if(bbcode) // not needed for Tinymce
|
||||
{
|
||||
// $('input#' + target, window.top.document).attr('value',path); // set new value
|
||||
// bbpath = '['+bbcode+']'+ path + '[/' + bbcode + ']';
|
||||
if(bbcode == "file") // not needed for Tinymce
|
||||
{
|
||||
bbpath = '[file='+ id +']'+ name + '[/file]';
|
||||
$('#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);
|
||||
}
|
||||
|
||||
if(bbcode == "img")
|
||||
{
|
||||
// bbpath = '['+bbcode+']'+ path + '[/' + bbcode + ']';
|
||||
//alert(bbpath);
|
||||
}
|
||||
|
||||
$('#src').attr('value',src); // working old
|
||||
$('#preview').attr('src',preview); // working old
|
||||
|
||||
|
@@ -536,6 +536,9 @@ class e_bbcode
|
||||
*/
|
||||
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('/<div style="text-align: ([\w]*);">([\s\S]*)<\/div>/i',"[$1]$2[/$1]",$text); // verified
|
||||
|
@@ -535,7 +535,7 @@ class e_media
|
||||
|
||||
$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 .= "</a>\n\n";
|
||||
}
|
||||
@@ -677,7 +677,7 @@ class e_media
|
||||
$img_data['media_caption'] = $new_data['media_caption'];
|
||||
$img_data['media_category'] = $category;
|
||||
$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))
|
||||
{
|
||||
|
@@ -23,7 +23,7 @@
|
||||
// unset $tinyMCE_imglib_include
|
||||
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;
|
||||
|
||||
|
||||
|
26
request.php
26
request.php
@@ -30,6 +30,23 @@ if (!e_QUERY || isset($_POST['userlogin']))
|
||||
}
|
||||
|
||||
$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 ($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"))
|
||||
{ // Download from mirror
|
||||
list($action, $download_id, $mirror_id) = explode(".", e_QUERY);
|
||||
@@ -343,13 +361,17 @@ else
|
||||
// File retrieval function. by Cam.
|
||||
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'])
|
||||
{
|
||||
header("Location: ".SITEURL.$file);
|
||||
exit();
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
@set_time_limit(10 * 60);
|
||||
@session_write_close();
|
||||
|
Reference in New Issue
Block a user