mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-10-06 02:02:24 +02:00
make UploadImage plugin actualy work (beta1)
This commit is contained in:
parent
8d833331ff
commit
dd1ed0f786
@ -21,5 +21,6 @@ UploadImage.I18N = {
|
|||||||
"Document title:": "Document title:",
|
"Document title:": "Document title:",
|
||||||
"OK": "OK",
|
"OK": "OK",
|
||||||
"Primary style-sheet:": "Primary style-sheet:",
|
"Primary style-sheet:": "Primary style-sheet:",
|
||||||
"Text color:": "Text color:"
|
"Text color:": "Text color:",
|
||||||
|
"Upload Image": "Upload Image"
|
||||||
};
|
};
|
||||||
|
@ -413,7 +413,6 @@ Class Image_Transform_Driver_GD extends Image_Transform
|
|||||||
imagesetpixel($this->imageHandle, $right, $j, $t);
|
imagesetpixel($this->imageHandle, $right, $j, $t);
|
||||||
$left++; $right--;
|
$left++; $right--;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -36,6 +36,7 @@ include '../ImageManager/config.inc.php';
|
|||||||
|
|
||||||
// set this to whatever subdir you make
|
// set this to whatever subdir you make
|
||||||
$path = $BASE_ROOT.'/';
|
$path = $BASE_ROOT.'/';
|
||||||
|
//$path = $BASE_DIR.'/';
|
||||||
|
|
||||||
//***************************************************************************
|
//***************************************************************************
|
||||||
|
|
||||||
@ -76,12 +77,14 @@ if(isset($params)) {
|
|||||||
//manipulate the images
|
//manipulate the images
|
||||||
function manipulate($img_file, $action, $values)
|
function manipulate($img_file, $action, $values)
|
||||||
{
|
{
|
||||||
global $path, $save_file, $BASE_DIR;
|
global $path, $save_file, $BASE_DIR,$BASE_ROOT;
|
||||||
|
|
||||||
|
$img_location=$BASE_DIR.$BASE_ROOT.'/';
|
||||||
//Load the Image Manipulation Driver
|
//Load the Image Manipulation Driver
|
||||||
$img = Image_Transform::factory(IMAGE_CLASS);
|
$img = Image_Transform::factory(IMAGE_CLASS);
|
||||||
$img->load($BASE_DIR.$path.$img_file);
|
|
||||||
//var_dump($_SERVER['DOCUMENT_ROOT'].$path.$img_file);
|
|
||||||
|
$img->load($img_location.$img_file);
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'crop':
|
case 'crop':
|
||||||
$img->crop(intval($values[0]),intval($values[1]),intval($values[2]),intval($values[3]));
|
$img->crop(intval($values[0]),intval($values[1]),intval($values[2]),intval($values[3]));
|
||||||
@ -105,15 +108,15 @@ function manipulate($img_file, $action, $values)
|
|||||||
$quality = intval($values[1]);
|
$quality = intval($values[1]);
|
||||||
if($quality <0)
|
if($quality <0)
|
||||||
$quality = 85;
|
$quality = 85;
|
||||||
$img->save($BASE_DIR.$path.$save_file, $values[0], $quality);
|
$img->save($img_location.$save_file, $values[0], $quality);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//get the unique file name
|
//get the unique file name
|
||||||
$filename = $img->createUnique($BASE_DIR.$path);
|
$filename = $img->createUnique($img_location);
|
||||||
//save the manipulated image
|
//save the manipulated image
|
||||||
$img->save($BASE_DIR.$path.$filename);
|
$img->save($img_location.$filename);
|
||||||
$img->free();
|
$img->free();
|
||||||
|
|
||||||
$imagesize = @getimagesize($filename);
|
$imagesize = @getimagesize($filename);
|
||||||
|
@ -5,14 +5,23 @@
|
|||||||
//example, this is the actual file system path
|
//example, this is the actual file system path
|
||||||
//of the web server document root. e.g.
|
//of the web server document root. e.g.
|
||||||
// Filesystem == /home/web/www.yourdomain.com
|
// Filesystem == /home/web/www.yourdomain.com
|
||||||
$BASE_DIR = $_SERVER['DOCUMENT_ROOT'];
|
$BASE_DIR = $GLOBALS[UploadImageBaseDir];
|
||||||
|
$BASE_URL = $GLOBALS[UploadImageBaseURL];
|
||||||
|
$BASE_ROOT = $GLOBALS[UploadImageRelativePath];
|
||||||
|
|
||||||
|
var_dump($BASE_DIR);
|
||||||
|
var_dump($BASE_URL);
|
||||||
|
var_dump($BASE_ROOT);
|
||||||
|
|
||||||
|
//$BASE_DIR = $_SERVER['DOCUMENT_ROOT'];
|
||||||
|
//$BASE_DIR = '/home/www';
|
||||||
|
|
||||||
//the path where the browser sees the document root (i.e. http://www.yourdomain.com/)
|
//the path where the browser sees the document root (i.e. http://www.yourdomain.com/)
|
||||||
$BASE_URL = '/';
|
//$BASE_URL = 'https://192.168.0.2/';
|
||||||
|
|
||||||
//this is where the images will be stored relative to the $BASE_DIR (and $BASE_URL)
|
//this is where the images will be stored relative to the $BASE_DIR (and $BASE_URL)
|
||||||
//this directory MUST be readable AND writable by the web server.
|
//this directory MUST be readable AND writable by the web server.
|
||||||
$BASE_ROOT = 'test';
|
//$BASE_ROOT = '';
|
||||||
|
|
||||||
//The image manipulation library to use, either GD or ImageMagick or NetPBM
|
//The image manipulation library to use, either GD or ImageMagick or NetPBM
|
||||||
//valid definitions are 'GD' or 'IM' or 'NetPBM'.
|
//valid definitions are 'GD' or 'IM' or 'NetPBM'.
|
||||||
|
@ -58,7 +58,8 @@
|
|||||||
var id = fields[i];
|
var id = fields[i];
|
||||||
var el = MM_findObj(id);
|
var el = MM_findObj(id);
|
||||||
if(id == "f_url")
|
if(id == "f_url")
|
||||||
param[id] = "<? echo 'http://'.$_SERVER['SERVER_NAME']; ?>" + el.value;
|
// param[id] = "<? echo 'http://'.$_SERVER['SERVER_NAME']; ?>" + el.value;
|
||||||
|
param[id] = "" + el.value;
|
||||||
else
|
else
|
||||||
param[id] = el.value;
|
param[id] = el.value;
|
||||||
}
|
}
|
||||||
|
@ -16,18 +16,23 @@ function UploadImage(editor) {
|
|||||||
this.editor = editor;
|
this.editor = editor;
|
||||||
|
|
||||||
var cfg = editor.config;
|
var cfg = editor.config;
|
||||||
cfg.fullPage = true;
|
// cfg.fullPage = true;
|
||||||
var tt = UploadImage.I18N;
|
var tt = UploadImage.I18N;
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
cfg.registerButton("FP-docprop", tt["Document properties"], editor.imgURL("up_image.gif", "UploadImage"), false,
|
/* cfg.registerButton("UploadImage", tt["Upload Image"], editor.imgURL("up_image.gif", "UploadImage"), false,
|
||||||
function(editor, id) {
|
function(editor, id) {
|
||||||
self.buttonPress(editor, id);
|
self.buttonPress(editor, id);
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
|
cfg.registerButton("UploadImage", tt["Upload Image"], editor.imgURL("up_image.gif", "UploadImage"), false,
|
||||||
|
function(editor, id) {
|
||||||
|
self.buttonPress();
|
||||||
|
});
|
||||||
|
|
||||||
// add a new line in the toolbar
|
// add a new line in the toolbar
|
||||||
cfg.toolbar[0].splice(0, 0, "separator");
|
cfg.toolbar[0].splice(29, 0, "separator");
|
||||||
cfg.toolbar[0].splice(0, 0, "FP-docprop");
|
cfg.toolbar[0].splice(30, 0, "UploadImage");
|
||||||
};
|
};
|
||||||
|
|
||||||
UploadImage._pluginInfo = {
|
UploadImage._pluginInfo = {
|
||||||
@ -41,12 +46,12 @@ UploadImage._pluginInfo = {
|
|||||||
license : "GPL"
|
license : "GPL"
|
||||||
};
|
};
|
||||||
|
|
||||||
UploadImage.prototype.buttonPress = function(editor, id)
|
UploadImage.prototype.zzzbuttonPress = function(editor, id)
|
||||||
{
|
{
|
||||||
var self = this;
|
var self = this;
|
||||||
switch (id)
|
switch (id)
|
||||||
{
|
{
|
||||||
case "FP-docprop":
|
case "UploadImage":
|
||||||
var doc = editor._doc;
|
var doc = editor._doc;
|
||||||
var links = doc.getElementsByTagName("link");
|
var links = doc.getElementsByTagName("link");
|
||||||
var style1 = '';
|
var style1 = '';
|
||||||
@ -64,6 +69,7 @@ UploadImage.prototype.buttonPress = function(editor, id)
|
|||||||
}
|
}
|
||||||
var title = doc.getElementsByTagName("title")[0];
|
var title = doc.getElementsByTagName("title")[0];
|
||||||
title = title ? title.innerHTML : '';
|
title = title ? title.innerHTML : '';
|
||||||
|
|
||||||
var init =
|
var init =
|
||||||
{
|
{
|
||||||
f_doctype : editor.doctype,
|
f_doctype : editor.doctype,
|
||||||
@ -75,9 +81,12 @@ UploadImage.prototype.buttonPress = function(editor, id)
|
|||||||
|
|
||||||
editor : editor
|
editor : editor
|
||||||
};
|
};
|
||||||
Dialog(_editor_url+"plugins/UploadImage/popups/insert_image.php", function(params)
|
|
||||||
|
Dialog(_editor_url+"plugins/UploadImage/popups/insert_image.php", function(image)
|
||||||
{
|
{
|
||||||
self.setDocProp(params);
|
self._insertImage(image);
|
||||||
|
// self.setDocProp(params);
|
||||||
|
// alert(params[1]);
|
||||||
}, init);
|
}, init);
|
||||||
|
|
||||||
/* editor._popupDialog("plugin://UploadImage/insert_image.php", function(params) {
|
/* editor._popupDialog("plugin://UploadImage/insert_image.php", function(params) {
|
||||||
@ -87,6 +96,79 @@ UploadImage.prototype.buttonPress = function(editor, id)
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Called when the user clicks on "InsertImage" button. If an image is already
|
||||||
|
// there, it will just modify it's properties.
|
||||||
|
UploadImage.prototype.buttonPress = function(image) {
|
||||||
|
|
||||||
|
var doc = editor._doc;
|
||||||
|
// var editor = this; // for nested functions
|
||||||
|
var outparam = null;
|
||||||
|
|
||||||
|
var init =
|
||||||
|
{
|
||||||
|
f_doctype : editor.doctype,
|
||||||
|
editor : editor
|
||||||
|
};
|
||||||
|
|
||||||
|
if (typeof image == "undefined") {
|
||||||
|
image = editor.getParentElement();
|
||||||
|
if (image && !/^img$/i.test(image.tagName))
|
||||||
|
image = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (image) outparam = {
|
||||||
|
f_url : HTMLArea.is_ie ? editor.stripBaseURL(image.src) : image.getAttribute("src"),
|
||||||
|
f_alt : image.alt,
|
||||||
|
f_border : image.border,
|
||||||
|
f_align : image.align,
|
||||||
|
f_vert : image.vspace,
|
||||||
|
f_horiz : image.hspace
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Dialog(_editor_url+"plugins/UploadImage/popups/insert_image.php", function(param){
|
||||||
|
if (!param) { // user must have pressed Cancel
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var img = image;
|
||||||
|
// alert(param.f_url);
|
||||||
|
if (!img) {
|
||||||
|
var sel = editor._getSelection();
|
||||||
|
var range = editor._createRange(sel);
|
||||||
|
editor._doc.execCommand("insertimage", false, param.f_url);
|
||||||
|
|
||||||
|
if (HTMLArea.is_ie) {
|
||||||
|
img = range.parentElement();
|
||||||
|
// wonder if this works...
|
||||||
|
if (img.tagName.toLowerCase() != "img") {
|
||||||
|
img = img.previousSibling;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
img = range.startContainer.previousSibling;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
img.src = param.f_url;
|
||||||
|
}
|
||||||
|
for (field in param) {
|
||||||
|
var value = param[field];
|
||||||
|
switch (field) {
|
||||||
|
case "f_alt" : img.alt = value; break;
|
||||||
|
case "f_border" : img.border = parseInt(value || "0"); break;
|
||||||
|
case "f_align" : img.align = value; break;
|
||||||
|
case "f_vert" : img.vspace = parseInt(value || "0"); break;
|
||||||
|
case "f_horiz" : img.hspace = parseInt(value || "0"); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, outparam);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
UploadImage.prototype.setDocProp = function(params) {
|
UploadImage.prototype.setDocProp = function(params) {
|
||||||
var txt = "";
|
var txt = "";
|
||||||
var doc = this.editor._doc;
|
var doc = this.editor._doc;
|
||||||
@ -124,7 +206,35 @@ UploadImage.prototype.setDocProp = function(params) {
|
|||||||
else if (style2)
|
else if (style2)
|
||||||
head.removeChild(style2);
|
head.removeChild(style2);
|
||||||
|
|
||||||
|
|
||||||
|
//cfg.registerButton("my-sample", "Class: sample", "ed_custom.gif", false,
|
||||||
|
function testinsert(arg1,arg2) {
|
||||||
|
if (HTMLArea.is_ie) {
|
||||||
|
editor.insertHTML("<img src=\"arg1\" alt=\"\" />");
|
||||||
|
var r = editor._doc.selection.createRange();
|
||||||
|
r.move("character", -2);
|
||||||
|
r.moveEnd("character", 2);
|
||||||
|
r.select();
|
||||||
|
} else { // Gecko/W3C compliant
|
||||||
|
var n = editor._doc.createElement("img");
|
||||||
|
n.className = "sample";
|
||||||
|
editor.insertNodeAtSelection(n);
|
||||||
|
var sel = editor._iframe.contentWindow.getSelection();
|
||||||
|
sel.removeAllRanges();
|
||||||
|
var r = editor._doc.createRange();
|
||||||
|
r.setStart(n, 0);
|
||||||
|
r.setEnd(n, 0);
|
||||||
|
sel.addRange(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
testinsert(params[1]);
|
||||||
|
|
||||||
for (var i in params) {
|
for (var i in params) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// alert(params[i]);
|
||||||
var val = params[i];
|
var val = params[i];
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case "f_title":
|
case "f_title":
|
||||||
|
Loading…
Reference in New Issue
Block a user