diff --git a/website/agenda/planung/imageUpload.cgi b/website/agenda/planung/imageUpload.cgi
index 4a12a30..402fb95 100755
--- a/website/agenda/planung/imageUpload.cgi
+++ b/website/agenda/planung/imageUpload.cgi
@@ -21,6 +21,7 @@ use uac();
use studios();
use template();
use images();
+use localization();
binmode STDOUT, ":utf8";
@@ -121,8 +122,9 @@ if ( $error ne '' ) {
$params = update_database( $config, $params, $file_info, $user ) if $params->{error} eq '';
}
-print STDERR "upload error: $params->{error}\n" if $params->{error} ne '';
+print STDERR "upload error: $params->{error}\n" if $params->{error} ;
my $out = '';
+$params->{loc} = localization::get( $config, { user => $params->{presets}->{user}, file => 'image' } );
template::process( $config, 'print', $params->{template}, $params );
print $cgi->cgi_error() if ( defined $cgi ) && ( defined $cgi->cgi_error() );
@@ -133,26 +135,6 @@ $params->{filename} ||= '';
$params->{image_id} ||= '';
$params->{name} ||= '';
-if ( $params->{error} eq '' ) {
- print qq{
-
success
-
- $params->{action_result}
- {{thumbs//$params->{filename}}}
-
-
- $params->{image_id}
- $params->{filename}
- $params->{name}
- {{thumbs//$params->{filename}}}
-
- };
-} else {
- print qq{
- failed
- $params->{error}
- };
-}
sub upload_file {
my $config = shift;
@@ -388,6 +370,14 @@ sub check_params {
$checked->{$attr} = $params->{$attr};
}
}
+
+ #checkboxes
+ for my $param ('public') {
+ if ( ( defined $params->{$param} ) && ( $params->{$param} =~ /([01])/ ) ) {
+ $checked->{$param} = $1;
+ }
+ }
return $checked;
}
+
diff --git a/website/agenda/planung/js/fileUploader.js b/website/agenda/planung/js/fileUploader.js
deleted file mode 100644
index c905f9c..0000000
--- a/website/agenda/planung/js/fileUploader.js
+++ /dev/null
@@ -1,237 +0,0 @@
-/*
-* Class: fileUploader
-* Use: Upload multiple files the jQuery way
-* Author: John Lanz (http://pixelcone.com)
-* Version: 1.0
-*/
-
-(function($) {
- $.fileUploader = {version: '1.1'};
- $.fn.fileUploader = function(config){
-
- config = $.extend({}, {
- limit: '1',
- imageLoader: '',
- buttonUpload: '#pxUpload',
- buttonClear: '#pxClear',
- successOutput: 'File Uploaded',
- errorOutput: 'Failed',
- inputName: 'image',
- inputSize: 30,
- allowedExtension: 'jpg|jpeg|gif|png',
- callback: function() {},
- url: window.location.href
- }, config);
-
- var itr = 0; //number of files to uploaded
- var $limit = 1;
-
- //public function
- $.fileUploader.change = function(e){
- var fname = px.validateFile( $(e).val() );
- if (fname == -1){
- alert ("Invalid file!");
- $(e).val("");
- return false;
- }
- $('#px_button input').removeAttr("disabled");
- var imageLoader = '';
- if ($.trim(config.imageLoader) != ''){
- imageLoader = '
';
- }
- var display = '' +
- '
' +
- '
'+ fname +'' +
- '
'+ imageLoader +'' +
- '
'+
- '
';
-
- $("#px_display").append(display);
- if (config.limit == '' || $limit < config.limit) {
- px.appendForm();
- }
- $limit++;
- $(e).hide();
- //px.upload();
-
- }
-
- // To exactly match $("a.foo").live("click", fn), for example, you can write $(document).on("click", "a.foo", fn).
- // $(".close").live("click", function(){
- $(document).on("click", ".close", function(){
- $limit--;
- if ($limit == config.limit) {
- px.appendForm();
- }
- var id = "#" + $(this).parent().attr("title");
- $(id+"_frame").remove();
- $(id).remove();
- $(id+"_text").fadeOut("slow",function(){
- $(this).remove();
- });
- return false;
- });
-
- //$(config.buttonClear).click(function(){
- $(document).on("click", "config.buttonClear", function(){
- $("#px_display").fadeOut("slow",function(){
- $("#px_display").html("");
- $("#pxupload_form").html("");
- itr = 0;
- $limit = 1;
- px.appendForm();
- $('#px_button input').attr("disabled","disabled");
- $(this).show();
- });
- });
-
- //private function
- var px = {
- init: function(e){
- var form = $(e).parents('form');
- px.formAction = $(form).attr('action');
-
- $(form).before(' \
- \
- \
- \
- ');
- $(config.buttonUpload+','+config.buttonClear).appendTo('#px_button');
- if ( $(e).attr('name') != '' ){
- config.inputName = $(e).attr('name');
- }
- if ( $(e).attr('size') != '' ){
- config.inputSize = $(e).attr('size');
- }
- $(form).hide();
- $(config.buttonUpload).click(function(){
- px.upload()
- })
-
- this.appendForm();
- },
- appendForm: function(){
- itr++;
- var formId = "pxupload" + itr;
- var iframeId = "pxupload" + itr + "_frame";
- var inputId = "pxupload" + itr + "_input";
- var contents = ''
- contents += ''
-
- contents += '';
-
- $("#pxupload_form").append( contents );
- },
- validateFile: function(file) {
- if (file.indexOf('/') > -1){
- file = file.substring(file.lastIndexOf('/') + 1);
- }else if (file.indexOf('\\') > -1){
- file = file.substring(file.lastIndexOf('\\') + 1);
- }
- //var extensions = /(.jpg|.jpeg|.gif|.png)$/i;
- var extensions = new RegExp(config.allowedExtension + '$', 'i');
- if (extensions.test(file)){
- return file;
- } else {
- return -1;
- }
- },
-
- upload: function(){
- if (itr > 0){
- $('#px_button input').attr("disabled","disabled");
- $("#pxupload_form form").each(function(){
- e = $(this);
- var id = "#" + $(e).attr("id");
- var input_id = id + "_input";
- var input_val = $(input_id).val();
- if (input_val != ""){
- $(id + "_text .status").text("Uploading...");
- $(id + "_text").css("background-color", "#FFF0E1");
- $(id + "_text .loader").show();
- $(id + "_text .close").hide();
-
- $(id).submit();
- $(id +"_frame").load(function(){
- $(id + "_text .loader").hide();
- up_output = $(this).contents().find("#output").html();
- var success=0;
- if (up_output == "success"){
- success=1;
- $(id + "_text").css("background-color", "#F0F8FF");
- up_output = config.successOutput;
- px.redirect();
- }else{
- $(id + "_text").css("background-color", "#FF0000");
- up_output = config.errorOutput;
- }
-
- //custom code
- up_output += '
' + $(this).contents().find("#message").html();
- //alert($(this).contents())
- //console.log(JSON.stringify($(this).contents()));
- $(id + "_text .status").html(up_output);
-
- if(success==1){
- var image_id=$(this).contents().find("#upload_image_id").html();
- var filename=$(this).contents().find("#upload_image_filename").html();
- var title =$(this).contents().find("#upload_image_title").html();
- var quote="'";
-
- //remove existing image from list
- $('#imageList div.images #img_'+image_id).remove();
- //add image to list
- $('#imageList div.images').prepend(
- ''
- );
- }
- //end of custom code
- $(e).remove();
- $(config.buttonClear).removeAttr("disabled");
- config.callback($(this));
- });
- }
- });
- }
- },
-
- redirect: function(){
- //window.location.replace(config.url)
- //$('#pxupload_form').append('');
- //$('#redirect').submit();
- }
-
-
- }
-
- px.init(this);
-
- return this;
- }
-})(jQuery);
diff --git a/website/agenda/planung/js/image.js b/website/agenda/planung/js/image.js
index dc37966..7502b3e 100644
--- a/website/agenda/planung/js/image.js
+++ b/website/agenda/planung/js/image.js
@@ -202,102 +202,27 @@ function assignImage(filename, target, project_id, studio_id, series_id, event_i
$(document).ready(
function(){
+
+ $('div.images').on( 'click', 'div.image', function(){
+ var elem = $(this);
+ console.log(elem)
+ var filename = elem.attr("filename");
+ elem = elem.parent();
+ console.log(elem)
+ var target = elem.attr("target");
+ var projectId = elem.attr("projectId");
+ var studioId = elem.attr("studioId");
+ var seriesId = elem.attr("seriesId");
+ var eventId = elem.attr("eventId");
+ var pid = elem.attr("pid");
+
+ updateImageEditor($(this), filename, target, projectId, studioId, seriesId, eventId, pid);
+ return false;
+ });
+
if ( window.location.href.indexOf("&filename=") > 0)
setActiveImage();
}
);
-/*
-function hideContent(){
- $('.editor').hide();
-
- $(window).resize(function () {
- $('.ui-dialog').css({
- 'width': $(window).width() - windowOffsetX,
- 'height': $(window).height() - windowOffsetY,
- 'position': 'absolute',
- 'left': 0,
- 'top': 0,
- modal: true
- });
-
- var imagesPos= $('div.images').position();
- var height = ( $(window).height() - imagesPos.top );
- if(height<64) height = 64;
- console.log("windowHeight="+$(window).height()+" div.images.pos.top="+imagesPos.top)
- $('div.images').css("height", height +"px");
-
- }).resize();
-
- return false;
-}
-
-function showContent(){
- $('.editor').show();
- $('#selectImage').remove();
- return false;
-}
-
-
-//select image load into selectImage box
-function selectImageOld(project_id, studio_id, imageId, searchValue, imageUrl, series_id){
- selectImageId = imageId;
- searchValue = searchValue.replace(/[^a-zA-Z0-9]/g,'%');
-
- var url="image.cgi?search="+encodeURIComponent(searchValue)+'&project_id='+project_id+'&studio_id='+studio_id;
-
- if( (series_id!=null) && (series_id != '') ){
- url+='&series_id='+series_id;
- }
-
- if(imageUrl!=null){
- var filename=imageUrl.split('%2F').pop();
- url+='&filename='+filename;
- }
-
- var x = $(window).width() - windowOffsetX;
- var y = $(window).height() - windowOffsetY;
- console.log("selectImage(), load url="+url);
-
-
- $('#selectImage').remove();
- $('body').append('');
-
- $('#selectImage').load(
- url,
- function(){
- hideContent();
- $('#selectImage').dialog({
- appendTo: "#content",
- title: "select image",
- top: 0,
- left: 0,
- width: x,
- height: y,
- close: function( event, ui ) {
- showContent();
- $('#selectImage').remove();
- }
- });
- updateImageEditor(filename);
- }
- );
-
- return false;
-}
-
-// set editor image and image url to selected image
-function selectThisImage(filename){
- $('#'+selectImageId).val(filename);
-
- var url = 'showImage.cgi?project_id='+project_id+'&studio_id='+studio_id+'&filename=' + filename;
- console.log("select image "+url);
- $('#imagePreview').prop('src',url);
-
- showContent();
- return false;
-}
-
-*/
-
diff --git a/website/agenda/planung/js/image_upload.js b/website/agenda/planung/js/image_upload.js
index 203c8f8..4ecdbe7 100644
--- a/website/agenda/planung/js/image_upload.js
+++ b/website/agenda/planung/js/image_upload.js
@@ -1,67 +1,55 @@
-// init upload
function initUploadDialog(){
- //console.log("init upload dialog")
- if(!$('#uploader').hasClass("init")){
- $('#uploader').fileUploader();
- $('#uploader').addClass("init");
- //remove multiple buttons
- var c=0;
- $('#img_upload #px_button').each(
- function(){
- if (c>0){
- $(this).remove();
- }
- c++;
- }
- );
- }
- return false;
+ var url='imageUpload.cgi?project_id='+ getProjectId()+"&studio_id="+getStudioId();
+ updateContainer("image-tabs-upload", url);
}
-// prepare for new init
-function closeImageUpload(){
- $('#uploader').removeClass("init");
- $('#pxupload_form').remove();
- $('#pxupload1_frame').remove();
- $('#px_display').remove();
-}
+function uploadImage(){
+ console.log("upload")
+ var form=$("#img_upload");
+ var fd = new FormData(form[0]);
+ var rq = $.ajax({
+ url: 'imageUpload.cgi',
+ type: 'POST',
+ data: fd,
+ cache: false,
+ contentType: false,
+ processData: false
+ });
+ rq.done( function(data){
+ $("#image-tabs-upload").html(data);
-function insertPicture(name, description, filename) {
- try {
- markup='{{ thumbs//'+filename;
- if (description !=''){
- markup+=' | '+description;
- }else{
- if (name !='') markup+=' | '+name
- }
- markup+=' }}'
- markup+="\n"
- parent.$.markItUp( { replaceWith:markup } );
- parent.$('#images').dialog("close");
- } catch(e) {
- alert("No markItUp! Editor found");
- }
-}
+ var image_id = $("#upload_image_id").html();
+ var filename = $("#upload_image_filename").html();
+ var title = $("#upload_image_title").html();
+ var quote = "'";
+
+ //remove existing image from list
+ $('#imageList div.images #img_'+image_id).remove();
-function image_upload_dialog(){
- $('#img_upload').dialog({
- title:"image upload",
- width:600,
- height:320
- });
- return false;
-}
+ var url='showImage.cgi?project_id='+getProjectId()+'&studioId='+getStudioId()+'&type=icon&filename='+filename;
-function image_upload_callback(result){
- result.contents().find("#message").html();
- var output = '
' + $(this).contents().find("#message").html();
- $(id + "_text .status").html(output);
-}
+ var html = '';
+ html += '
'+title+'
';
+ html += '
';
-$(document).ready(
- function() {
- //$('#uploader').fileUploader();
- }
-)
+ //add image to list
+ $('#imageList div.images').prepend(html);
+
+ console.log("done")
+ return false;
+ });
+
+ rq.fail( function(){
+ console.log("Fail")
+ });
+
+ return false;
+};
diff --git a/website/agenda/planung/templates/image.html b/website/agenda/planung/templates/image.html
index b1afb94..1c12f3a 100644
--- a/website/agenda/planung/templates/image.html
+++ b/website/agenda/planung/templates/image.html
@@ -1,8 +1,5 @@
-
-
-
@@ -31,8 +28,6 @@
}
- // show images by default
- closeImageUpload();
$('#imageList').show();
}
});
@@ -68,15 +63,6 @@
@@ -96,13 +82,21 @@