### Eclipse Workspace Patch 1.0 #P MyAmetys-plugin-explorer Index: main/plugin-explorer/resources/pirobox_ext/prev.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: main\plugin-explorer\resources\pirobox_ext\prev.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: main/plugin-explorer/resources/pirobox_ext/new_skin.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: main\plugin-explorer\resources\pirobox_ext\new_skin.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: main/plugin-explorer/resources/pirobox_ext/caption.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: main\plugin-explorer\resources\pirobox_ext\caption.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: main/plugin-explorer/plugin.xml =================================================================== --- main/plugin-explorer/plugin.xml (revision 9428) +++ main/plugin-explorer/plugin.xml (working copy) @@ -99,10 +99,15 @@ js/org/ametys/explorer/view/ImageThumbnailViewer.js js/org/ametys/explorer/view/DetailsViewer.i18n.js ux/js/DataView-more.js + js/jquery.min.js + js/jquery-ui.min.js + pirobox_ext/pirobox_extended_min.js + css/history.css css/tooltip.css + pirobox_ext/style.css Index: main/plugin-explorer/resources/pirobox_ext/pirobox_extended.js =================================================================== --- main/plugin-explorer/resources/pirobox_ext/pirobox_extended.js (revision 0) +++ main/plugin-explorer/resources/pirobox_ext/pirobox_extended.js (revision 0) @@ -0,0 +1,381 @@ +/** +* Name: PiroBox Extended v.1.0 +* Date: Gen 2011 +* Autor: Diego Valobra (http://www.pirolab.it),(http://www.diegovalobra.com) +* Version: 1.0 +* Licence: CC-BY-SA http://creativecommons.org/licenses/by-sa/3/it/ +**/ + +(function($) { + $.fn.piroBox_ext = function(opt) { + opt = jQuery.extend({ + piro_speed : 700, + bg_alpha : 0.9, + piro_scroll : true + }, opt); + $.fn.piroFadeIn = function(speed, callback) { + $(this).fadeIn(speed, function() { + if(jQuery.browser.msie) + $(this).get(0).style.removeAttribute('filter'); + if(callback != undefined) + callback(); + }); + }; + $.fn.piroFadeOut = function(speed, callback) { + $(this).fadeOut(speed, function() { + if(jQuery.browser.msie) + $(this).get(0).style.removeAttribute('filter'); + if(callback != undefined) + callback(); + }); + }; + var my_gall_obj = $('a[class*="pirobox"]'); + var map = new Object(); + for (var i=0; i'+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + ''+ + '
'+ + '
'+ + '
'+ + ''+ + '
'+ + '
'+ + '
'+ + '
' + ); + $('body').append(struct); + var wrapper = $('.piro_html'), + piro_capt = $('.caption'), + piro_bg = $('.piro_overlay'), + piro_next = $('.piro_next'), + piro_prev = $('.piro_prev'), + piro_next_fake = $('.piro_next_fake'), + piro_prev_fake = $('.piro_prev_fake'), + piro_close = $('.piro_close'), + div_reg = $('.div_reg'), + piro_loader = $('.piro_loader'), + resize = $('.resize'), + btn_info = $('.btn_info'); + var rz_img =0.95; /*::::: ADAPT IMAGE TO BROWSER WINDOW SIZE :::::*/ + if ( $.browser.msie ) { + wrapper.draggable({ handle:'.h_t_c,.h_b_c,.div_reg img'}); + }else{ + wrapper.draggable({ handle:'.h_t_c,.h_b_c,.div_reg img',opacity: 0.80}); + } + var y = $(window).height(); + var x = $(window).width(); + $('.nav_container').hide(); + wrapper.css({left: ((x/2)-(250))+ 'px',top: parseInt($(document).scrollTop())+(100)}); + $(wrapper).add(piro_capt).add(piro_bg).hide(); + piro_bg.css({'opacity':opt.bg_alpha}); + $(piro_prev).add(piro_next).bind('click',function(c) { + $('.nav_container').hide(); + c.preventDefault(); + piro_next.add(piro_prev).hide(); + var obj_count = parseInt($('a[class*="pirobox_gall"]').filter('.item').attr('rev')); + var start = $(this).is('.piro_prev') ? $('a[class*="pirobox_gall"]').eq(obj_count - 1) : $('a[class*="pirobox_gall"]').eq(obj_count + 1); + start.click(); + }); + $('html').bind('keyup', function (c) { + if(c.keyCode == 27) { + c.preventDefault(); + if($(piro_close).is(':visible')){close_all();} + } + }); + $('html').bind('keyup' ,function(e) { + if ($('.item').is('.first')){ + }else if(e.keyCode == 37){ + e.preventDefault(); + if($(piro_close).is(':visible')){piro_prev.click();} + } + }); + $('html').bind('keyup' ,function(z) { + if ($('.item').is('.last')){ + }else if(z.keyCode == 39){ + z.preventDefault(); + if($(piro_close).is(':visible')){piro_next.click();} + } + }); + $(window).resize(function(){ + var new_y = $(window).height(); + var new_x = $(window).width(); + var new_h = wrapper.height(); + var new_w = wrapper.width(); + wrapper.css({ + left: ((new_x/2)-(new_w/2))+ 'px', + top: parseInt($(document).scrollTop())+(new_y-new_h)/2 + }); + }); + function scrollIt (){ + $(window).scroll(function(){ + var new_y = $(window).height(); + var new_x = $(window).width(); + var new_h = wrapper.height(); + var new_w = wrapper.width(); + wrapper.css({ + left: ((new_x/2)-(new_w/2))+ 'px', + top: parseInt($(document).scrollTop())+(new_y-new_h)/2 + }); + }); + } + if(opt.piro_scroll == true){ + scrollIt() + } + $(piro_gallery).each(function(){ + + var descr = $(this).attr('title'); + var params = $(this).attr('rel').split('-'); + var p_link = $(this).attr('href'); + $(this).unbind(); + $(this).bind('click', function(e) { + piro_bg.css({'opacity':opt.bg_alpha}); + e.preventDefault(); + piro_next.add(piro_prev).hide().css('visibility','hidden'); + $(piro_gallery).filter('.item').removeClass('item'); + $(this).addClass('item'); + open_all(); + if($(this).is('.first')){ + piro_prev.hide(); + piro_next.show(); + piro_prev_fake.show().css({'opacity':0.5,'visibility':'hidden'}); + }else{ + piro_next.add(piro_prev).show(); + piro_next_fake.add(piro_prev_fake).hide(); + } + if($(this).is('.last')){ + piro_prev.show(); + piro_next_fake.show().css({'opacity':0.5,'visibility':'hidden'}); + piro_next.hide(); + } + if($(this).is('.pirobox')){ + piro_next.add(piro_prev).hide(); + } + + }); + + function open_all(){ + wrapper.add(piro_bg).add(div_reg).add(piro_loader).show(); + function animate_html(){ + if(params[1] == 'full' && params[2] == 'full'){ + params[2] = $(window).height()-70; + params[1] = $(window).width()-55; + } + var y = $(window).height(); + var x = $(window).width(); + piro_close.hide(); + div_reg.add(resize).animate({ + 'height':+ (params[2]) +'px', + 'width':+ (params [1])+'px' + },opt.piro_speed).css('visibility','visible'); + + wrapper.animate({ + height:+ (params[2])+20 +'px', + width:+ (params[1]) +20+'px', + left: ((x/2)-((params[1])/2+10))+ 'px', + top: parseInt($(document).scrollTop())+(y-params[2])/2-10 + },opt.piro_speed ,function(){ + piro_next.add(piro_prev).css({'height':'20px','width':'20px'}); + piro_next.add(piro_prev).add(piro_prev_fake).add(piro_next_fake).css('visibility','visible'); + $('.nav_container').show(); + piro_close.show(); + }); + } + function animate_image (){ + var img = new Image(); + img.onerror = function (){ + piro_capt.html(''); + img.src = "http://www.pirolab.it/pirobox/js/error.jpg"; + } + img.onload = function() { + piro_capt.add(btn_info).hide(); + var y = $(window).height(); + var x = $(window).width(); + var imgH = img.height; + var imgW = img.width; + + //var rz_img =1.203; /*::::: ORIGINAL SIZE :::::*/ + if(imgH+20 > y || imgW+20 > x){ + var _x = (imgW + 20)/x; + var _y = (imgH + 20)/y; + if ( _y > _x ){ + imgW = Math.round(img.width* (rz_img/_y)); + imgH = Math.round(img.height* (rz_img/_y)); + }else{ + imgW = Math.round(img.width * (rz_img/_x)); + imgH = Math.round(img.height * (rz_img/_x)); + } + }else{ + imgH = img.height; + imgW = img.width; + } + + var y = $(window).height(); + var x = $(window).width(); + $(img).height(imgH).width(imgW).hide(); + + $(img).fadeOut(300,function(){}); + $('.div_reg img').remove(); + $('.div_reg').html(''); + div_reg.append(img).show(); + $(img).addClass('immagine'); + + div_reg.add(resize).animate({height:imgH+'px',width:imgW+'px'},opt.piro_speed); + wrapper.animate({ + height : (imgH+20) + 'px' , + width : (imgW+20) + 'px' , + left: ((x/2)-((imgW+20)/2)) + 'px', + top: parseInt($(document).scrollTop())+(y-imgH)/2-20 + },opt.piro_speed, function(){ + var cap_w = resize.width(); + piro_capt.css({width:cap_w+'px'}); + piro_loader.hide(); + $(img).fadeIn(300,function(){ + piro_close.add(btn_info).show(); + piro_capt.slideDown(200); + piro_next.add(piro_prev).css({'height':'20px','width':'20px'}); + piro_next.add(piro_prev).add(piro_prev_fake).add(piro_next_fake).css('visibility','visible'); + $('.nav_container').show(); + resize.resize(function(){ + NimgW = img.width;//1.50; + NimgH = img.heigh;//1.50; + piro_capt.css({width:(NimgW)+'px'}); + }); + }); + }); + } + + img.src = p_link; + piro_loader.click(function(){ + img.src = 'about:blank'; + }); + } + + switch (params[0]) { + + case 'iframe': + div_reg.html('').css('overflow','hidden'); + resize.css('overflow','hidden'); + piro_close.add(btn_info).add(piro_capt).hide(); + animate_html(); + div_reg.piroFadeIn(300,function(){ + div_reg.append( + '' + ); + $('.my_frame').css({'height':+ (params[2]) +'px','width':+ (params [1])+'px'}); + piro_loader.hide(); + }); + break; + + case 'content': + div_reg.html('').css('overflow','auto'); + resize.css('overflow','auto'); + $('.my_frame').remove(); + piro_close.add(btn_info).add(piro_capt).hide(); + animate_html() + div_reg.piroFadeIn(300,function(){ + div_reg.load(p_link); + piro_loader.hide(); + }); + break; + + case 'inline': + div_reg.html('').css('overflow','auto'); + resize.css('overflow','auto'); + $('.my_frame').remove(); + piro_close.add(btn_info).add(piro_capt).hide(); + animate_html() + div_reg.piroFadeIn(300,function(){ + $(p_link).clone(true).appendTo(div_reg).piroFadeIn(300); + piro_loader.hide(); + }); + break + + case 'gallery': + div_reg.css('overflow','hidden'); + resize.css('overflow','hidden'); + $('.my_frame').remove(); + piro_close.add(btn_info).add(piro_capt).hide(); + if(descr == ""){ + piro_capt.html(''); + }else{ + piro_capt.html('

' + descr + '

'); + } + animate_image(); + break; + + case 'single': + piro_close.add(btn_info).add(piro_capt).hide(); + div_reg.html('').css('overflow','hidden'); + resize.css('overflow','hidden'); + $('.my_frame').remove(); + if(descr == ""){ + piro_capt.html(''); + }else{ + piro_capt.html('

' + descr + '

'); + } + animate_image(); + break + } + } + }); + $('.immagine').live('click',function(){ + piro_capt.slideToggle(200); + }); + + function close_all (){ + if($('.piro_close').is(':visible')){ + $('.my_frame').remove(); + wrapper.add(div_reg).add(resize).stop(); + var ie_sucks = wrapper; + if ( $.browser.msie ) { + ie_sucks = div_reg.add(piro_bg); + $('.div_reg img').remove(); + }else{ + ie_sucks = wrapper.add(piro_bg); + } + ie_sucks.piroFadeOut(200,function(){ + div_reg.html(''); + piro_loader.add(piro_capt).add(btn_info).hide(); + $('.nav_container').hide(); + piro_bg.add(wrapper).hide().css('visibility','visible'); + }); + } + } + piro_close.add(piro_loader).add(piro_bg).bind('click',function(y){y.preventDefault(); close_all(); }); + } +})(jQuery); \ No newline at end of file Index: main/plugin-explorer/resources/pirobox_ext/new_skin_left.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: main\plugin-explorer\resources\pirobox_ext\new_skin_left.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: main/plugin-explorer/resources/pirobox_ext/next.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: main\plugin-explorer\resources\pirobox_ext\next.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: main/plugin-explorer/resources/pirobox_ext/style.css =================================================================== --- main/plugin-explorer/resources/pirobox_ext/style.css (revision 0) +++ main/plugin-explorer/resources/pirobox_ext/style.css (revision 0) @@ -0,0 +1,44 @@ +*{ + margin:0; + padding:0; +} +.piro_html {position:absolute; top:0; left:0; padding:0; width:500px; height: 500px; margin:0; display:block; padding:0; z-index:150001; padding:0; } +.piro_html table,.piro_html tbody,.piro_html tr,.piro_html th,.piro_html td{margin:0;padding:0;border:none;} +.piro_html img{ margin:0; padding:0; border:none;} + +.piro_html .h_t_l{ width:10px; height:10px; background: url(caption.png);} +.piro_html .h_t_r{ width:10px; height:10px; background: url(caption.png);} +.piro_html .h_t_c{ cursor:move; height:10px;background: url(caption.png);} + +.piro_html .h_c_l{width:10px; background: url(caption.png); } +.piro_html .h_c_c{background: url(caption.png);margin:0; padding:0;} +.piro_html .h_c_c .div_reg{ background: url(caption.png); width:480px; overflow:hidden; height:480px; margin:0; padding:0; } +.piro_html .h_c_c .div_reg img{ cursor:move;} +.piro_html .h_c_r{width:10px; background: url(caption.png);} + +.piro_html .h_b_c{ cursor:move; height:10px;background: url(caption.png);} +.piro_html .h_b_l{ width:10px; height:10px;background: url(caption.png);} +.piro_html .h_b_r{ width:10px; height:10px;background: url(caption.png);} + +.piro_overlay{position:fixed; top:0; left:0; width:100%; height:100%; z-index:150000;background:#fff;display:none; cursor:pointer;} +.piro_loader{position:absolute;top:50%;left:50%;margin:-59px 0 0 -59px;width:118px;height:118px;display:block;z-index:150005; cursor:pointer; } +.piro_loader span{position:absolute;top:50%;left:50%;margin-top:-36px;margin-left:-36px;width:72px;height:72px;display:block;z-index:150009; background: url(loadinfo.gif) center top no-repeat; } +.piro_title{position:fixed; background: url(bg_title.png) bottom repeat-x;top:0;left:0;width:100%; text-align:center;display:block; padding:6px 0 10px 0; color:white; z-index:150000; font-size:18px; display:none;} +.btn_info{position:absolute;bottom:-7px;right:-7px;width:25px; height:25px;margin:0;display:block; padding:0px; color:black; cursor:pointer; background: url(b_w/info.png) no-repeat; z-index:1500440} +.caption{position:absolute;bottom:10px;left:10px;margin:0;display:block; padding:0px; color:black; cursor:text; background: url(caption.png); z-index:150018} +.caption p{ display:block; margin:0;padding:7px 5px; text-align:center; font-weight:normal; font-size:14px; color:white; z-index:150019; color:white;} + +.nav_container{position:absolute; bottom:-20px; right:0; height:20px; width:60px; background: url(caption.png); z-index:1500190000000;} +.piro_close{position:absolute;right:20px;height:20px;width:20px;background: transparent url(close.png) no-repeat center center;cursor:pointer;margin:0 0 0 0;z-index:150022;display:none;} +a.piro_next{position:absolute;width:20px; right:0px; height:20px;text-indent:-999em;outline:none; display:block; margin:0;background:url(next.png) center right no-repeat; border:none; cursor:pointer;z-index:150023} +a:hover.piro_next{background:url(next.png) center right no-repeat;} +.piro_next_fake{position:absolute;width:20px; right:0px; height:20px;outline:none; text-indent:-999em; display:none; margin:0;background: url(next.png) center right no-repeat; border:none; cursor:auto;z-index:150020} +.piro_prev_fake{position:absolute;width:20px; right:40px; height:20px;outline:none; text-indent:-999em; display:none; margin:0;background: url(prev.png) center right no-repeat; border:none; cursor:auto;z-index:150020} + +a.piro_prev{position:absolute;width:20px; right:40px; height:20px; text-indent:-999em; outline:none;display:block;margin:0;background: url(prev.png) center left no-repeat;border:none; cursor:pointer; z-index:150024} +a:hover.piro_prev{background:url(prev.png) center left no-repeat;} +a.close_pirobox{color:#bb0f05;} + + + + Index: main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/toolbar/ToolbarActions.i18n.js =================================================================== --- main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/toolbar/ToolbarActions.i18n.js (revision 9428) +++ main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/toolbar/ToolbarActions.i18n.js (working copy) @@ -14,21 +14,9 @@ * limitations under the License. */ -Ext.namespace('org.ametys.explorer.applications.resources.toolbar'); -Ext.namespace('org.ametys.explorer.applications.resources.toolbar.Folder.add'); -Ext.namespace('org.ametys.explorer.applications.resources.toolbar.Folder.rename'); -Ext.namespace('org.ametys.explorer.applications.resources.toolbar.Folder.remove'); -Ext.namespace('org.ametys.explorer.applications.resources.toolbar.Folder.archive'); -Ext.namespace('org.ametys.explorer.applications.resources.toolbar.File.add'); -Ext.namespace('org.ametys.explorer.applications.resources.toolbar.File.rename'); -Ext.namespace('org.ametys.explorer.applications.resources.toolbar.File.viewHistory'); -Ext.namespace('org.ametys.explorer.applications.resources.toolbar.File.editDublinCore'); -Ext.namespace('org.ametys.explorer.applications.resources.toolbar.File.remove'); -Ext.namespace('org.ametys.explorer.applications.resources.toolbar.File.move'); -Ext.namespace('org.ametys.explorer.applications.resources.toolbar.File.copy'); -Ext.namespace('org.ametys.explorer.applications.resources.toolbar.File.download'); -Ext.namespace('org.ametys.explorer.applications.resources.toolbar.View.icons'); -Ext.namespace('org.ametys.explorer.applications.resources.toolbar.View.details'); +Ext.namespace('org.ametys.explorer.applications.resources.toolbar.Folder'); +Ext.namespace('org.ametys.explorer.applications.resources.toolbar.File'); +Ext.namespace('org.ametys.explorer.applications.resources.toolbar.View'); /*------------------------------------------------------------------------*/ org.ametys.explorer.applications.resources.toolbar.Folder.add = function (application) @@ -372,7 +360,42 @@ { application.queryCommandState ('resourceMoved', {'id': files[0], 'parentID': parentID}); } +/*------------------------------------------------------------------------*/ +org.ametys.explorer.applications.resources.toolbar.File.slideshow = function (btn, state, application) +{ + var divEl = Ext.get("div-slideshow"); + if (divEl == null) + { + var div = document.createElement("div"); + div.id = "div-slideshow"; + div.style.display = "none"; + document.body.appendChild(div); + divEl = Ext.get("div-slideshow"); + } + else + { + divEl.dom.innerHTML = ""; + } + + for (var i = 0; i < btn._ids.length; i++) + { + var link = document.createElement("a"); + link.id = "div-slideshow-" + i; + link.className = "pirobox" + (btn._ids.length == 1 ? "" : "_gall"); + link.rel = (btn._ids.length == 1 ? "single" : "gallery"); + link.href = getPluginDirectUrl("explorer") + "/resource?id=" + btn._ids[i]; + divEl.dom.appendChild(link); + } + + $('.piro_html').remove(); + $('.piro_overlay').remove(); + + $().piroBox_ext({bg_alpha : 0.5}); + + $('#div-slideshow-0').click(); +} + /*------------------------------------------------------------------------*/ org.ametys.explorer.applications.resources.toolbar.View.icons = function (btn, state, application) { @@ -390,6 +413,7 @@ } } /*------------------------------------------------------------------------*/ +/*------------------------------------------------------------------------*/ org.ametys.explorer.applications.resources.toolbar.AssignRights = function (btn, state, application) { application._explorer.showHideRightsPanel (state); Index: main/plugin-explorer/resources/pirobox_ext/new_skin_top.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: main\plugin-explorer\resources\pirobox_ext\new_skin_top.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: main/plugin-explorer/resources/pirobox_ext/pirobox_extended_min.js =================================================================== --- main/plugin-explorer/resources/pirobox_ext/pirobox_extended_min.js (revision 0) +++ main/plugin-explorer/resources/pirobox_ext/pirobox_extended_min.js (revision 0) @@ -0,0 +1,33 @@ +/** +* Name: PiroBox Extended v.1.0 +* Date: Gen 2011 +* Autor: Diego Valobra (http://www.pirolab.it),(http://www.diegovalobra.com) +* Version: 1.0 +* Licence: CC-BY-SA http://creativecommons.org/licenses/by-sa/3/it/ +**/ +(function($){$.fn.piroBox_ext=function(opt){opt=jQuery.extend({piro_speed:700,bg_alpha:0.9,piro_scroll:true},opt);$.fn.piroFadeIn=function(speed,callback){$(this).fadeIn(speed,function(){if(jQuery.browser.msie) +$(this).get(0).style.removeAttribute('filter');if(callback!=undefined) +callback();});};$.fn.piroFadeOut=function(speed,callback){$(this).fadeOut(speed,function(){if(jQuery.browser.msie) +$(this).get(0).style.removeAttribute('filter');if(callback!=undefined) +callback();});};var my_gall_obj=$('a[class*="pirobox"]');var map=new Object();for(var i=0;i'+''+''+''+''+''+''+''+''+''+''+''+''+''+''+''+''+'
'+'
'+'
'+''+'
'+'
'+'
'+'
');$('body').append(struct);var wrapper=$('.piro_html'),piro_capt=$('.caption'),piro_bg=$('.piro_overlay'),piro_next=$('.piro_next'),piro_prev=$('.piro_prev'),piro_next_fake=$('.piro_next_fake'),piro_prev_fake=$('.piro_prev_fake'),piro_close=$('.piro_close'),div_reg=$('.div_reg'),piro_loader=$('.piro_loader'),resize=$('.resize'),btn_info=$('.btn_info');var rz_img=0.95;if($.browser.msie){wrapper.draggable({handle:'.h_t_c,.h_b_c,.div_reg img'});}else{wrapper.draggable({handle:'.h_t_c,.h_b_c,.div_reg img',opacity:0.80});} +var y=$(window).height();var x=$(window).width();$('.nav_container').hide();wrapper.css({left:((x/2)-(250))+'px',top:parseInt($(document).scrollTop())+(100)});$(wrapper).add(piro_capt).add(piro_bg).hide();piro_bg.css({'opacity':opt.bg_alpha});$(piro_prev).add(piro_next).bind('click',function(c){$('.nav_container').hide();c.preventDefault();piro_next.add(piro_prev).hide();var obj_count=parseInt($('a[class*="pirobox_gall"]').filter('.item').attr('rev'));var start=$(this).is('.piro_prev')?$('a[class*="pirobox_gall"]').eq(obj_count-1):$('a[class*="pirobox_gall"]').eq(obj_count+1);start.click();});$('html').bind('keyup',function(c){if(c.keyCode==27){c.preventDefault();if($(piro_close).is(':visible')){close_all();}}});$('html').bind('keyup',function(e){if($('.item').is('.first')){}else if(e.keyCode==37){e.preventDefault();if($(piro_close).is(':visible')){piro_prev.click();}}});$('html').bind('keyup',function(z){if($('.item').is('.last')){}else if(z.keyCode==39){z.preventDefault();if($(piro_close).is(':visible')){piro_next.click();}}});$(window).resize(function(){var new_y=$(window).height();var new_x=$(window).width();var new_h=wrapper.height();var new_w=wrapper.width();wrapper.css({left:((new_x/2)-(new_w/2))+'px',top:parseInt($(document).scrollTop())+(new_y-new_h)/2});});function scrollIt(){$(window).scroll(function(){var new_y=$(window).height();var new_x=$(window).width();var new_h=wrapper.height();var new_w=wrapper.width();wrapper.css({left:((new_x/2)-(new_w/2))+'px',top:parseInt($(document).scrollTop())+(new_y-new_h)/2});});} +if(opt.piro_scroll==true){scrollIt()} +$(piro_gallery).each(function(){var descr=$(this).attr('title');var params=$(this).attr('rel').split('-');var p_link=$(this).attr('href');$(this).unbind();$(this).bind('click',function(e){piro_bg.css({'opacity':opt.bg_alpha});e.preventDefault();piro_next.add(piro_prev).hide().css('visibility','hidden');$(piro_gallery).filter('.item').removeClass('item');$(this).addClass('item');open_all();if($(this).is('.first')){piro_prev.hide();piro_next.show();piro_prev_fake.show().css({'opacity':0.5,'visibility':'hidden'});}else{piro_next.add(piro_prev).show();piro_next_fake.add(piro_prev_fake).hide();} +if($(this).is('.last')){piro_prev.show();piro_next_fake.show().css({'opacity':0.5,'visibility':'hidden'});piro_next.hide();} +if($(this).is('.pirobox')){piro_next.add(piro_prev).hide();}});function open_all(){wrapper.add(piro_bg).add(div_reg).add(piro_loader).show();function animate_html(){if(params[1]=='full'&¶ms[2]=='full'){params[2]=$(window).height()-70;params[1]=$(window).width()-55;} +var y=$(window).height();var x=$(window).width();piro_close.hide();div_reg.add(resize).animate({'height':+(params[2])+'px','width':+(params[1])+'px'},opt.piro_speed).css('visibility','visible');wrapper.animate({height:+(params[2])+20+'px',width:+(params[1])+20+'px',left:((x/2)-((params[1])/2+10))+'px',top:parseInt($(document).scrollTop())+(y-params[2])/2-10},opt.piro_speed,function(){piro_next.add(piro_prev).css({'height':'20px','width':'20px'});piro_next.add(piro_prev).add(piro_prev_fake).add(piro_next_fake).css('visibility','visible');$('.nav_container').show();piro_close.show();});} +function animate_image(){var img=new Image();img.onerror=function(){piro_capt.html('');img.src="http://www.pirolab.it/pirobox/js/error.jpg";} +img.onload=function(){piro_capt.add(btn_info).hide();var y=$(window).height();var x=$(window).width();var imgH=img.height;var imgW=img.width;if(imgH+20>y||imgW+20>x){var _x=(imgW+20)/x;var _y=(imgH+20)/y;if(_y>_x){imgW=Math.round(img.width*(rz_img/_y));imgH=Math.round(img.height*(rz_img/_y));}else{imgW=Math.round(img.width*(rz_img/_x));imgH=Math.round(img.height*(rz_img/_x));}}else{imgH=img.height;imgW=img.width;} +var y=$(window).height();var x=$(window).width();$(img).height(imgH).width(imgW).hide();$(img).fadeOut(300,function(){});$('.div_reg img').remove();$('.div_reg').html('');div_reg.append(img).show();$(img).addClass('immagine');div_reg.add(resize).animate({height:imgH+'px',width:imgW+'px'},opt.piro_speed);wrapper.animate({height:(imgH+20)+'px',width:(imgW+20)+'px',left:((x/2)-((imgW+20)/2))+'px',top:parseInt($(document).scrollTop())+(y-imgH)/2-20},opt.piro_speed,function(){var cap_w=resize.width();piro_capt.css({width:cap_w+'px'});piro_loader.hide();$(img).fadeIn(300,function(){piro_close.add(btn_info).show();piro_capt.slideDown(200);piro_next.add(piro_prev).css({'height':'20px','width':'20px'});piro_next.add(piro_prev).add(piro_prev_fake).add(piro_next_fake).css('visibility','visible');$('.nav_container').show();resize.resize(function(){NimgW=img.width;NimgH=img.heigh;piro_capt.css({width:(NimgW)+'px'});});});});} +img.src=p_link;piro_loader.click(function(){img.src='about:blank';});} +switch(params[0]){case'iframe':div_reg.html('').css('overflow','hidden');resize.css('overflow','hidden');piro_close.add(btn_info).add(piro_capt).hide();animate_html();div_reg.piroFadeIn(300,function(){div_reg.append('');$('.my_frame').css({'height':+(params[2])+'px','width':+(params[1])+'px'});piro_loader.hide();});break;case'content':div_reg.html('').css('overflow','auto');resize.css('overflow','auto');$('.my_frame').remove();piro_close.add(btn_info).add(piro_capt).hide();animate_html() +div_reg.piroFadeIn(300,function(){div_reg.load(p_link);piro_loader.hide();});break;case'inline':div_reg.html('').css('overflow','auto');resize.css('overflow','auto');$('.my_frame').remove();piro_close.add(btn_info).add(piro_capt).hide();animate_html() +div_reg.piroFadeIn(300,function(){$(p_link).clone(true).appendTo(div_reg).piroFadeIn(300);piro_loader.hide();});break +case'gallery':div_reg.css('overflow','hidden');resize.css('overflow','hidden');$('.my_frame').remove();piro_close.add(btn_info).add(piro_capt).hide();if(descr==""){piro_capt.html('');}else{piro_capt.html('

'+descr+'

');} +animate_image();break;case'single':piro_close.add(btn_info).add(piro_capt).hide();div_reg.html('').css('overflow','hidden');resize.css('overflow','hidden');$('.my_frame').remove();if(descr==""){piro_capt.html('');}else{piro_capt.html('

'+descr+'

');} +animate_image();break}}});$('.immagine').live('click',function(){piro_capt.slideToggle(200);});function close_all(){if($('.piro_close').is(':visible')){$('.my_frame').remove();wrapper.add(div_reg).add(resize).stop();var ie_sucks=wrapper;if($.browser.msie){ie_sucks=div_reg.add(piro_bg);$('.div_reg img').remove();}else{ie_sucks=wrapper.add(piro_bg);} +ie_sucks.piroFadeOut(200,function(){div_reg.html('');piro_loader.add(piro_capt).add(btn_info).hide();$('.nav_container').hide();piro_bg.add(wrapper).hide().css('visibility','visible');});}} +piro_close.add(piro_loader).add(piro_bg).bind('click',function(y){y.preventDefault();close_all();});}})(jQuery); \ No newline at end of file Index: main/plugin-explorer/resources/pirobox_ext/close.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: main\plugin-explorer\resources\pirobox_ext\close.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/ResourcesApplication.i18n.js =================================================================== --- main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/ResourcesApplication.i18n.js (revision 9428) +++ main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/ResourcesApplication.i18n.js (working copy) @@ -1,979 +0,0 @@ -/* - * Copyright 2010 Anyware Services - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -Ext.namespace('org.ametys.explorer.applications.resources'); - -org.ametys.explorer.applications.resources.ResourcesApplication = function(explorer, id, pluginName) -{ - org.ametys.explorer.applications.resources.ResourcesApplication.superclass.constructor.call(this, id, pluginName); - this._explorer = explorer; -}; - -Ext.extend(org.ametys.explorer.applications.resources.ResourcesApplication, org.ametys.explorer.applications.Application, {}); - - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._appPrefix = 'resources-app-'; -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._explorer; - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype.createPanel = function(index) -{ - //org.ametys.explorer.applications.resources.Application.setApplication (this); - - this._store = this._getStore(); - - this._thumbnailView = new org.ametys.explorer.view.ImageThumbnailViewer ({ - id: this._appPrefix + 'resources-icons-view', - - store : this._store - }); - this._thumbnailView.addListener ('selectionchange', this._onSelectFiles, this); - this._thumbnailView.addListener ('dblclick', this._onDblClick, this); - this._thumbnailView.addListener ('beforeselect', this._onBeforeSelect, this); - - this._detailsView = new org.ametys.explorer.view.DetailsViewer ({ - id : this._appPrefix + 'resources-details-view', - store : this._store, - border: false, - columns: this._getColumns (this._detailsView) - }); - this._detailsView.getSelectionModel().addListener ('selectionchange', this._onSelectFiles, this); - this._detailsView.addListener ('celldblclick', this._onDblClick, this); - this._detailsView.addListener ('cellclick', this._onClick, this); - - this._panel = new Ext.Panel({ - layout: 'card', - activeItem : 0, - border: false, - autoScroll: true, - - items: [this._detailsView, this._thumbnailView] - }); - - this._panel.addListener ('afterrender', this._initView, this); - - return this._panel; -}; - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._getColumns = function (view) -{ - return [ - {header: "", hideable: false, sortable: true, width: 220, renderer: this._renderFilename, dataIndex: 'name'}, - {header: "", sortable: true, width: 100, dataIndex: 'keywords', hidden: true}, - {header: "", sortable: true, width: 150, dataIndex: 'path', renderer: {fn: this._renderPath, scope:this}, hidden: true}, - {header: "", sortable: true, width: 120, renderer: Ext.util.Format.dateRenderer('d/m/Y H:i'), dataIndex: 'lastModified'}, - {header: "", sortable: true, width: 160, dataIndex: 'author'}, - {header: "", sortable: true, width: 70, dataIndex: 'size', renderer: Ext.util.Format.fileSize, align: 'right'} - ]; -} - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._renderFilename = function (value, p, record) -{ - function iconPath (name) - { - var extension = "unknown"; - var index = value.indexOf('.'); - if (index > 0) - { - extension = value.substring(index + 1).toLowerCase(); - } - return getPluginDirectUrl('explorer') + "/icon/" + extension + ".png"; - } - - record.data.iconPath = iconPath (value); - record.data.shortName = Ext.util.Format.ellipsis(value, 15); - - return '<img class="icon" src="' + record.data.iconPath + '"/>' + value; -} - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._renderPath = function (value, p, record) -{ - var index = value.lastIndexOf ('/'); - var path = '/' + value.substring(0, index); - - return '<a class="location" href="#" onClick="org.ametys.explorer.applications.resources.ResourcesApplication.selectNodeByPath (\'' + this._explorer._tree.getId() + '\', \'' + path + '\'); return(false);">' + path + '</a>' -} - -org.ametys.explorer.applications.resources.ResourcesApplication.selectNodeByPath = function (treeId, path) -{ - Ext.getCmp(treeId).selectNodeByPath (path); -} - - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._getStore = function () -{ - var store = new Ext.data.XmlStore({ - autoDestroy: true, - - url: getPluginDirectUrl(this.getPluginName()) + '/files', // automatically configures a HttpProxy - - record: 'Node', - - fields: [{name: 'id', mapping: '@id'}, - {name: 'name', mapping: '@name', type: 'string', sortType: Ext.data.SortTypes.asUCString}, - {name: 'author', mapping: '@author', type: 'string'}, - {name: 'path', mapping: '@path'}, - {name: 'keywords', mapping: '@keywords'}, - {name: 'size', type: 'float', mapping: '@size'}, - {name: 'lastModified', type:'date', dateFormat:'c', mapping: '@lastModified'}, - {name: 'isModifiable', mapping: '@isModifiable'} - ] - }); - - store.on('update', this._renameFile, this); - - return store; -} - -/** - * Determines if the node application can be rename. - */ -org.ametys.explorer.applications.resources.ResourcesApplication.prototype.createToolbar = function (node) -{ - // folder button group - var folderGp = new Ext.ButtonGroup ({ - columns: 3, - height: 90, - title: "", - defaults: { - scale: 'small' - }, - items:[ - { - id: this._appPrefix + 'toolbar-btn-folder-add', - text: "", - tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/folder_new_32.png'), - icon: getPluginResourcesUrl ('explorer') + '/img/resources/folder_new_32.png', - iconAlign: 'top', - scale: 'large', - minWidth: 34, - rowspan: 3, - application: this, - handler: function () { - org.ametys.explorer.applications.resources.toolbar.Folder.add (this.application); - }, - rightId: 'Plugin_Explorer_Folder_Add', - disabled: true - }, - { - id: this._appPrefix + 'toolbar-btn-cmis-add', - text: "", - tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/cmis/cmis_32.png'), - icon: getPluginResourcesUrl ('explorer') + '/img/cmis/cmis_16.png', - scale: 'small', - application: this, - handler: function () { - org.ametys.explorer.applications.resources.toolbar.Folder.addCMIS (this.application); - }, - rightId: 'Plugin_Explorer_CMIS_Add', - disabled: true - }, - { - id: this._appPrefix + 'toolbar-btn-search', - text: "", - icon: getPluginResourcesUrl ('explorer') + '/img/resources/search_32.png', - iconAlign: 'top', - tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/search_32.png'), - scale: 'large', - width: 34, - rowspan: 3, - application: this, - handler: function (btn, state) { - org.ametys.explorer.applications.resources.toolbar.File.search(this.application); - }, - disabled: true - }, - { - id: this._appPrefix + 'toolbar-btn-folder-rename', - text: "", - tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/folder_rename_32.png'), - icon: getPluginResourcesUrl ('explorer') + '/img/resources/folder_rename_16.png', - scale: 'small', - application: this, - handler: function () { - org.ametys.explorer.applications.resources.toolbar.Folder.rename (this.application); - }, - rightId: 'Plugin_Explorer_Folder_Edit', - disabled: true - }, - { - id: this._appPrefix + 'toolbar-btn-folder-delete', - text: "", - tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/folder_delete_32.png'), - icon: getPluginResourcesUrl ('explorer') + '/img/resources/folder_delete_16.png', - scale: 'small', - application: this, - handler: function () { - org.ametys.explorer.applications.resources.toolbar.Folder.remove (this.application); - }, - rightId: 'Plugin_Explorer_Folder_Delete', - disabled: true - } - ] - }); - - - // file button group - var fileGp = new Ext.ButtonGroup ({ - columns: 3, - height: 90, - title: "", - defaults: { - scale: 'small' - }, - items: [ - { - id: this._appPrefix + 'toolbar-btn-file-add', - text: "", - icon: getPluginResourcesUrl ('explorer') + '/img/resources/file_new_32.png', - tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/file_new_32.png'), - iconAlign: 'top', - scale: 'large', - boxMinWidth: 34, - rowspan: 3, - application: this, - handler: function () { - org.ametys.explorer.applications.resources.toolbar.File.add (this.application); - }, - rightId: 'Plugin_Explorer_File_Add', - disabled: true - }, - { - id: this._appPrefix + 'toolbar-btn-file-rename', - text: "", - icon: getPluginResourcesUrl ('explorer') + '/img/resources/file_rename_16.png', - tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/file_rename_32.png'), - application: this, - rightId: 'Plugin_Explorer_File_Rename', - handler: function () { - org.ametys.explorer.applications.resources.toolbar.File.rename (this.application); - }, - disabled: true - }, - { - id: this._appPrefix + 'toolbar-btn-file-history', - icon: getPluginResourcesUrl ('explorer') + '/img/resources/history_16.png', - text: "", - tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/history_32.png'), - application: this, - handler: function () { - org.ametys.explorer.applications.resources.toolbar.File.viewHistory (this.application); - }, - disabled: true - }, - { - id: this._appPrefix + 'toolbar-btn-file-delete', - text: "", - icon: getPluginResourcesUrl ('explorer') + '/img/resources/file_delete_16.png', - tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/file_delete_32.png'), - application: this, - // EXPLORER-108 rowspan: 2, - rightId: 'Plugin_Explorer_File_Delete', - handler: function () { - org.ametys.explorer.applications.resources.toolbar.File.remove (this.application); - }, - disabled: true - }, - { - id: this._appPrefix + 'toolbar-btn-file-download', - text: "", - icon: getPluginResourcesUrl ('explorer') + '/img/resources/file_download_16.png', - tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/file_download_32.png'), - application: this, - handler: function () { - org.ametys.explorer.applications.resources.toolbar.File.download (this.application); - }, - disabled: true - }, - { - id: this._appPrefix + 'toolbar-btn-file-dublincore', - icon: getPluginResourcesUrl ('explorer') + '/img/resources/dublincore_16.png', - text: "", - tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/dublincore_32.png'), - rightId: 'Plugin_Explorer_File_Edit_DC_Metadata', - // EXPLORER-108 rowspan: 2, - application: this, - handler: function () { - org.ametys.explorer.applications.resources.toolbar.File.editDublinCore (this.application); - }, - disabled: true - } - /* EXPLORER-108, - { - id: this._appPrefix + 'toolbar-btn-file-export-rdf', - text: "", - icon: getPluginResourcesUrl ('explorer') + '/img/resources/export_rdf_16.png', - tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/export_rdf_32.png'), - application: this, - handler: function () { - org.ametys.explorer.applications.resources.toolbar.File.exportRDF (this.application); - }, - disabled: true - }*/ - ] - }); - - // clipboard button group - var clipboardGp = new Ext.ButtonGroup ({ - columns: 2, - height: 90, - title: "", - defaults: { - scale: 'small' - }, - items: [ - { - id: this._appPrefix + 'toolbar-btn-file-cut', - text: "", - icon: getPluginResourcesUrl ('explorer') + '/img/resources/clipboard/cut_32.png', - tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/clipboard/cut_32.png'), - iconAlign: 'top', - scale: 'large', - boxMinWidth: 34, - application: this, - handler: function () { - org.ametys.explorer.applications.resources.toolbar.File.cut (this.application); - }, - rightId: 'Plugin_Explorer_File_Delete', - disabled: true - }, - { - id: this._appPrefix + 'toolbar-btn-file-paste', - text: "", - icon: getPluginResourcesUrl ('explorer') + '/img/resources/clipboard/paste_32.png', - tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/clipboard/paste_32.png'), - iconAlign: 'top', - scale: 'large', - boxMinWidth: 34, - application: this, - handler: function () { - org.ametys.explorer.applications.resources.toolbar.File.paste (this.application); - }, - rightId: 'Plugin_Explorer_File_Add', - disabled: true - } - ] - }); - - // view button group - var viewGp = new Ext.ButtonGroup ({ - columns: 2, - height: 90, - title: "", - cls: 'x-btn-group-ribbonstyle', - defaults: { - scale: 'small' - }, - items: [ - { - id: this._appPrefix + 'toolbar-btn-view-details', - icon: getPluginResourcesUrl ('explorer') + '/img/view_details_32.png', - iconAlign: 'top', - text: "", - tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/view_details_32.png'), - scale: 'large', - boxMinWidth: 34, - application: this, - toggleGroup: this._appPrefix + 'toolbar-btn-view-group', - enableToggle: true, - allowDepress: false, - toggleHandler: function (btn, state) { - org.ametys.explorer.applications.resources.toolbar.View.details (btn, state, this.application); - }, - pressed: true, - disabled: false - }, - { - id: this._appPrefix + 'toolbar-btn-view-icons', - icon: getPluginResourcesUrl ('explorer') + '/img/view_icon_32.png', - iconAlign: 'top', - text: "", - tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/view_icon_32.png'), - scale: 'large', - boxMinWidth: 34, - application: this, - enableToggle: true, - allowDepress: false, - toggleGroup: this._appPrefix + 'toolbar-btn-view-group', - toggleHandler: function (btn, state) { - org.ametys.explorer.applications.resources.toolbar.View.icons (btn, state, this.application); - }, - disabled: false - } - ] - }); - - this._toolbar = new Ext.Panel ({ - height: 95, - border: false, - tbar : [ folderGp, - fileGp, - clipboardGp, - viewGp - ] - }); - - var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/user-rights', {'explorerNodeId': this._explorer._tree.getRootNode().childNodes[0].id}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); - var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); - - if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.ResourcesApplication")) - { - return false; - } - - if (response.selectSingleNode ("user-rights/right[@id='Runtime_Rights_Rights_Handle']") != null) - { - var rightsGp = org.ametys.explorer.rights.RightsAssignment.getToolbarGroupItems (this); - this._toolbar.getTopToolbar().add (rightsGp); - } - - return this._toolbar; -} - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._getUserRights = function (folder) -{ - var rights = []; - if (folder != null) - { - var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/user-rights', {'explorerNodeId': folder}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); - var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); - - if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.ResourcesApplication")) - { - return false; - } - - var rightNodes = response.selectNodes ('user-rights/right'); - for (var i=0; i < rightNodes.length; i++) - { - rights.push (rightNodes[i].getAttribute("id")); - } - } - return rights; -} -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._updateToolbar = function (folder, files, rightNode) -{ - var isRoot = this._explorer._params.id == folder; - - var isRightsPanelActive = this._explorer._profilesTree != null && this._explorer._mainPanel.items.get(1).getLayout().activeItem.id == this._explorer._profilesTree.id; - - // check rights - var rights = this._getUserRights (folder); - - var node = folder != null ? this._explorer._tree.getNodeById(folder) : null; - var isModifiable = node != null ? node.attributes.isModifiable == 'true' : false; - var canCreateChild = node != null ? node.attributes.canCreateChild == 'true' : false; - - var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-folder-add'); - btn.setDisabled (folder == null || (!isRoot && (!isModifiable || !canCreateChild)) || !this._hasRight (rights, btn.rightId)); - - var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-cmis-add'); - btn.setDisabled (folder == null || (!isRoot && !isModifiable) || !this._hasRight (rights, btn.rightId)); - - btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-folder-rename') - btn.setDisabled (isRoot || folder == null || !isModifiable || !this._hasRight (rights, btn.rightId)); - - btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-folder-delete'); - btn.setDisabled (isRoot || folder == null || !isModifiable || !this._hasRight (rights, btn.rightId)); - - var isCmis = folder != null && folder.indexOf ('cmis-root-collection') == 0; - btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-search'); - btn.setDisabled (folder == null || isRightsPanelActive || isCmis || !this._hasRight (rights, btn.rightId)); - - btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-file-add'); - btn.setDisabled (folder == null || isRightsPanelActive || (!isRoot && (!isModifiable || !canCreateChild)) || !this._hasRight (rights, btn.rightId)); - - var notEditable = false; - if (files != null) - { - for (var i=0; i < files.length; i++) - { - if (files[i].data.isModifiable != "true") - { - notEditable = true; - } - } - } - - btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-file-rename'); - btn.setDisabled (files == null || files.length == 0 || notEditable || !this._hasRight (rights, btn.rightId)); - - btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-file-delete'); - btn.setDisabled (files == null || files.length == 0 || notEditable || !this._hasRight (rights, btn.rightId)); - - btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-file-download'); - btn.setDisabled (files == null || files.length == 0 || !this._hasRight (rights, btn.rightId)); - - /* EXPLORER-108 - btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-file-export-rdf'); - btn.setDisabled (files == null || files.length == 0 || !this._hasRight (rights, btn.rightId)); - */ - - btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-file-dublincore'); - btn.setDisabled (files == null || files.length == 0 || notEditable || !this._hasRight (rights, btn.rightId)); - - btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-file-history'); - btn.setDisabled (files == null || files.length == 0 || notEditable || !this._hasRight (rights, btn.rightId)); - - btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-file-cut'); - btn.setDisabled (files == null || files.length == 0 || notEditable || !this._hasRight (rights, btn.rightId)); - - btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-file-paste'); - btn.setDisabled (folder == null || isRightsPanelActive || notEditable || !this._hasRight (rights, btn.rightId)); - - btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-view-details'); - btn.setDisabled (isRightsPanelActive); - - btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-view-icons'); - btn.setDisabled (isRightsPanelActive); - - btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-assign-users'); - if (btn != null) - { - btn.setDisabled (!isRightsPanelActive || rightNode == null || rightNode.attributes.type != 'profile'); - } - - btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-assign-groups'); - if (btn != null) - { - btn.setDisabled (!isRightsPanelActive || rightNode == null || rightNode.attributes.type != 'profile'); - } - - btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-remove'); - if (btn != null) - { - btn.setDisabled (!isRightsPanelActive || rightNode == null || rightNode.attributes.type == 'profile' || rightNode.attributes.inherit == 'true'); - } -} - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._hasRight = function (rights, rightId) -{ - if (rightId == null) - { - return true; - } - - for (var i=0; rights != null && i < rights.length; i++) - { - if (rightId == rights[i]) - { - return true; - } - } -} - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._renameFile = function (store, record, operation) -{ - if (operation == 'edit') - { - var name = record.data.name; - var id = record.data.id; - org.ametys.explorer.applications.resources.File.rename (id, name); - } -} - -/** - * Determines if the node application can be rename. - */ -org.ametys.explorer.applications.resources.ResourcesApplication.prototype.canRenameNode = function (node) -{ - // check rights - var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/user-rights', {'explorerNodeId': node.attributes.id}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); - var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); - - if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.ResourcesApplication")) - { - return false; - } - - if (response.selectSingleNode ("user-rights/right[@id='Plugin_Explorer_Folder_Edit']") == null) - { - return false; - } - - return true; -} - -/** - * Determines if the node application can be rename. - */ -org.ametys.explorer.applications.resources.ResourcesApplication.prototype.canRenameFile = function (nodeId) -{ - // check rights - var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/user-rights', {'explorerNodeId': nodeId}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); - var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); - - if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.ResourcesApplication")) - { - return false; - } - - if (response.selectSingleNode ("user-rights/right[@id='Plugin_Explorer_File_Rename']") == null) - { - return false; - } - - return true; -} - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype.renameNode = function (id, value) -{ - if (!this.canRenameNode()) - return; - - return org.ametys.explorer.applications.resources.Folder.doRename (id, value); -}; - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._preventClickOnSelection = false; -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._currentFilesId; -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._onSelectFiles = function (dv) // (sm) -{ - this._preventClickOnSelection = true; - function a() {this._preventClickOnSelection = false}; - a.defer(50, this); - - var records = typeof dv.getSelectedRecords == 'function' ? dv.getSelectedRecords() : dv.getSelections(); - - var selectedFilesId = []; - for (var i=0; i < records.length; i++) - { - selectedFilesId.push (records[i].id); - } - - if (!this._areTheSame (this._currentFilesId, selectedFilesId)) - { - this._currentFilesId = selectedFilesId; - this._explorer._onSelectRecords (records, 'resource'); - } -} -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._areTheSame = function (files1, files2) -{ - if (files1 == files2) - { - return true; - } - - if (files1 == null || files2 == null || files1.length != files2.length) - { - return false; - } - - for (var i=0; i < files1.length; i++) - { - if (files2.indexOf(files1[i]) == -1) - { - return false; - } - } - - return true; -} - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._preventSingleClick = false; -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._timeout = null; -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._onDblClick = function (dv, index, node, e) -{ - // prevent click event (if double click event occurs before single click event) - this._preventSingleClick = true; - function a() {this._preventSingleClick = false}; - a.defer(200, this); - - if (this._timeout != null) - { - // prevent click event (if double click event occurs after single click event) - window.clearTimeout(this._timeout); - this._timeout = null; - } - - var record = dv.getStore().getAt(index); - if (record != null) - { - org.ametys.explorer.applications.resources.File.download (record.data.id); - } -} - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._onClick = function (dv, index, node, e) -{ - if (this._preventSingleClick || this._preventClickOnSelection) - return; - - if (this._timeout != null) - { - // prevent click event - window.clearTimeout(this._timeout); - this._timeout = null; - } - - // prevent click event on double click - this._timeout = this._deferedClick.defer (200, this, [dv, index, node, e]); -} - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._deferedClick = function (dv, index, node, e) -{ - var record = dv.getStore().getAt(index); - var selections = typeof dv.getSelectedRecords == 'function' ? dv.getSelectedRecords() : dv.getSelectionModel().getSelections(); - - if (e.type = 'click' && record != null && selections.length == 1 && selections[0].data.id == record.data.id) - { - if (!this.canRenameFile (this._explorer._tree.getSelectionModel().getSelectedNode().id)) - return; - - // edit record - dv.startEditRecord (record.data.id); - } -} - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._initView = function () -{ - this._explorer._onViewChange (this.getId(), 'details'); -} - -/** - * Get the selected files' ids - * @return {Array} the selected files' ids - */ -org.ametys.explorer.applications.resources.ResourcesApplication.prototype.getSelectedFiles = function () -{ - var dv = this._panel.getLayout().activeItem; - var records = typeof dv.getSelectedRecords == 'function' ? dv.getSelectedRecords() : dv.getSelectionModel().getSelections(); - - var ids = []; - for (var i=0; i < records.length; i++) - { - ids.push (records[i].data.id); - } - return ids; -} - -/** - * Get the selected files' ids - * @return {Array} the selected files' ids - */ -org.ametys.explorer.applications.resources.ResourcesApplication.prototype.getFile = function (id) -{ - var dv = this._panel.getLayout().activeItem; - return dv.getStore().getById(id); -} - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype.refresh = function(id, reload) -{ - if (reload) - { - this._store.load({params: {id: id}}); - this._explorer._refreshNode (id); - } - else - { - this._store.load({params: {id: id}}); - } -} - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype.execCommand = function (cmd, params) -{ - switch (cmd) - { - case 'move-node': - var target = params.target; // New parent folder - var id = params.id; // Folder moved - - if (this._explorer._tree.getNodeById(id).attributes.isModifiable != 'true') - { - return false; - } - if (this._explorer._tree.getNodeById(target).attributes.isModifiable != 'true' || this._explorer._tree.getNodeById(target).attributes.canCreateChild != 'true') - { - return false; - } - - // check rights - var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/user-rights', {'explorerNodeId': target}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); - var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); - - if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.ResourcesApplication")) - { - return false; - } - - if (response.selectSingleNode ("user-rights/right[@id='Plugin_Explorer_Folder_Add']") == null) - { - return false; - } - - return org.ametys.explorer.applications.resources.Folder.move (target, [id]); - - case 'move': - var target = params.target; - var ids = params.ids; - - if (this._explorer._tree.getNodeById(target).attributes.isModifiable != 'true' || this._explorer._tree.getNodeById(target).attributes.canCreateChild != 'true') - { - return false; - } - - var store = this._panel.getLayout().activeItem.getStore(); - for (var i=0; i < ids.length; i++) - { - var record = store.getAt(store.find('id', ids[i])); - if (record != null && record.data.isModifiable != 'true') - { - return false; - } - } - - // check rights - var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/user-rights', {'explorerNodeId': target}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); - var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); - - if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.ResourcesApplication")) - { - return false; - } - - if (response.selectSingleNode ("user-rights/right[@id='Plugin_Explorer_File_Add']") == null) - { - return false; - } - - return org.ametys.explorer.applications.resources.File.move (target, ids); - - case 'rename': - return org.ametys.explorer.applications.resources.Folder.rename (params.id, params.value); - - case 'renameFile': - if (!this.canRenameFile(params.parentID)) - return false; - - if (this._panel.getLayout().activeItem.id == this._appPrefix + 'resources-details-view') - { - this._detailsView.startEditRecord (params.id); - } - else - { - this._thumbnailView.startEditRecord (params.id); - } - - break; - - case 'refresh': - var id = params.id; - this.refresh(id, params.reload); - - case 'changeView': - if (params.mode == 'details') - { - this._panel.getLayout().setActiveItem(0); - } - else if (params.mode == 'icons') - { - this._panel.getLayout().setActiveItem(1); - } - break; - - case 'updateToolbar': - this._updateToolbar (params.id, params.files, params.rightNode); - break; - default: - throw "The command '" + cmd + "' is unknown"; - break; - } -} - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype.queryCommandState = function (cmd, params) -{ - switch (cmd) - { - case 'changeView': - if (params.view == 'details') - { - return this._panel.getLayout().activeItem.id == this._appPrefix + 'resources-details-view'; - } - else if (params.view == 'icons') - { - return this._panel.getLayout().activeItem.id == this._appPrefix + 'resources-icons-view'; - } - break; - case 'resourceRenamed': - this._updateFileName (params.id); - break; - case 'resourceMoved': - this._moveFile (params.id, params.parentID); - break; - default: - throw "The command '" + cmd + "' is unknown"; - break; - } -} - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._addFile = function (id, parentID) -{ - this.refresh(parentID); -} - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._moveFile = function (id, parentID) -{ - this.refresh(parentID); -} - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._updateFileName = function (id, name) -{ - var index = this._store.find('id', id); - var record = this._store.getAt(index); - if (record != null) - { - var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/exporer-entity', {'id': id}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); - var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); - if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.ResourcesApplication.prototype._updateFileName")) - { - return false; - } - - var name = response.selectSingleNode('Node').getAttribute('name'); - record.set('name', name); - } -} - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._removeFiles = function (ids) -{ - for (var i=0; i < ids.length; i++) - { - var index = this._store.find('id', ids[i]); - var record = this._store.getAt(index); - if (record != null) - { - this._store.remove (record); - } - } -} - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._pasteFiles = function (id) -{ - this.refresh(id); -} - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._onFocus = function () -{ - var records = this._detailsView.getSelectedRecords(); - if (records != null && records.length > 0) - { - this._explorer._onSelectRecords (records, 'resource'); - } -} - -org.ametys.explorer.applications.resources.ResourcesApplication.prototype._onBeforeSelect = function (dv, node, selections) -{ - if (dv._preventSelection) - return false; -} - Index: main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/ResourcesApplication.i18n.js =================================================================== --- main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/ResourcesApplication.i18n.js (revision 0) +++ main/plugin-explorer/resources/js/org/ametys/explorer/applications/resources/ResourcesApplication.i18n.js (revision 9428) @@ -0,0 +1,1100 @@ +/* + * Copyright 2010 Anyware Services + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +Ext.namespace('org.ametys.explorer.applications.resources'); + +org.ametys.explorer.applications.resources.ResourcesApplication = function(explorer, id, pluginName) +{ + org.ametys.explorer.applications.resources.ResourcesApplication.superclass.constructor.call(this, id, pluginName); + this._explorer = explorer; +}; + +Ext.extend(org.ametys.explorer.applications.resources.ResourcesApplication, org.ametys.explorer.applications.Application, {}); + + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._appPrefix = 'resources-app-'; +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._explorer; + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype.createPanel = function(index) +{ + //org.ametys.explorer.applications.resources.Application.setApplication (this); + + this._store = this._getStore(); + this._store.addListener ('load', this._onLoadFiles, this); + this._thumbnailView = new org.ametys.explorer.view.ImageThumbnailViewer ({ + id: this._appPrefix + 'resources-icons-view', + + store : this._store + }); + this._thumbnailView.addListener ('selectionchange', this._onSelectFiles, this); + this._thumbnailView.addListener ('dblclick', this._onDblClick, this); + this._thumbnailView.addListener ('beforeselect', this._onBeforeSelect, this); + + this._detailsView = new org.ametys.explorer.view.DetailsViewer ({ + id : this._appPrefix + 'resources-details-view', + store : this._store, + border: false, + columns: this._getColumns (this._detailsView) + }); + this._detailsView.getSelectionModel().addListener ('selectionchange', this._onSelectFiles, this); + this._detailsView.addListener ('celldblclick', this._onDblClick, this); + this._detailsView.addListener ('cellclick', this._onClick, this); + + this._panel = new Ext.Panel({ + layout: 'card', + activeItem : 0, + border: false, + autoScroll: true, + + items: [this._detailsView, this._thumbnailView] + }); + + this._panel.addListener ('afterrender', this._initView, this); + + return this._panel; +}; + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._getColumns = function (view) +{ + return [ + {header: "", hideable: false, sortable: true, width: 220, renderer: this._renderFilename, dataIndex: 'name'}, + {header: "", sortable: true, width: 100, dataIndex: 'keywords', hidden: true}, + {header: "", sortable: true, width: 150, dataIndex: 'path', renderer: {fn: this._renderPath, scope:this}, hidden: true}, + {header: "", sortable: true, width: 120, renderer: Ext.util.Format.dateRenderer('d/m/Y H:i'), dataIndex: 'lastModified'}, + {header: "", sortable: true, width: 160, dataIndex: 'author'}, + {header: "", sortable: true, width: 70, dataIndex: 'size', renderer: Ext.util.Format.fileSize, align: 'right'} + ]; +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._renderFilename = function (value, p, record) +{ + function iconPath (name) + { + var extension = "unknown"; + var index = value.indexOf('.'); + if (index > 0) + { + extension = value.substring(index + 1).toLowerCase(); + } + return getPluginDirectUrl('explorer') + "/icon/" + extension + ".png"; + } + + record.data.iconPath = iconPath (value); + record.data.shortName = Ext.util.Format.ellipsis(value, 15); + + return '<img class="icon" src="' + record.data.iconPath + '"/>' + value; +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._renderPath = function (value, p, record) +{ + var index = value.lastIndexOf ('/'); + var path = '/' + value.substring(0, index); + + return '<a class="location" href="#" onClick="org.ametys.explorer.applications.resources.ResourcesApplication.selectNodeByPath (\'' + this._explorer._tree.getId() + '\', \'' + path + '\'); return(false);">' + path + '</a>' +} + +org.ametys.explorer.applications.resources.ResourcesApplication.selectNodeByPath = function (treeId, path) +{ + Ext.getCmp(treeId).selectNodeByPath (path); +} + + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._getStore = function () +{ + var store = new Ext.data.XmlStore({ + autoDestroy: true, + + url: getPluginDirectUrl(this.getPluginName()) + '/files', // automatically configures a HttpProxy + + record: 'Node', + + fields: [{name: 'id', mapping: '@id'}, + {name: 'name', mapping: '@name', type: 'string', sortType: Ext.data.SortTypes.asUCString}, + {name: 'author', mapping: '@author', type: 'string'}, + {name: 'path', mapping: '@path'}, + {name: 'keywords', mapping: '@keywords'}, + {name: 'size', type: 'float', mapping: '@size'}, + {name: 'lastModified', type:'date', dateFormat:'c', mapping: '@lastModified'}, + {name: 'isModifiable', mapping: '@isModifiable'} + ] + }); + + store.on('update', this._renameFile, this); + + return store; +} + +/** + * Determines if the node application can be rename. + */ +org.ametys.explorer.applications.resources.ResourcesApplication.prototype.createToolbar = function (node) +{ + // folder button group + var folderGp = new Ext.ButtonGroup ({ + columns: 3, + height: 90, + title: "", + defaults: { + scale: 'small' + }, + items:[ + { + id: this._appPrefix + 'toolbar-btn-folder-add', + text: "", + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/folder_new_32.png'), + icon: getPluginResourcesUrl ('explorer') + '/img/resources/folder_new_32.png', + iconAlign: 'top', + scale: 'large', + minWidth: 34, + rowspan: 3, + application: this, + handler: function () { + org.ametys.explorer.applications.resources.toolbar.Folder.add (this.application); + }, + rightId: 'Plugin_Explorer_Folder_Add', + disabled: true + }, + { + id: this._appPrefix + 'toolbar-btn-cmis-add', + text: "", + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/cmis/cmis_32.png'), + icon: getPluginResourcesUrl ('explorer') + '/img/cmis/cmis_16.png', + scale: 'small', + application: this, + handler: function () { + org.ametys.explorer.applications.resources.toolbar.Folder.addCMIS (this.application); + }, + rightId: 'Plugin_Explorer_CMIS_Add', + disabled: true + }, + { + id: this._appPrefix + 'toolbar-btn-search', + text: "", + icon: getPluginResourcesUrl ('explorer') + '/img/resources/search_32.png', + iconAlign: 'top', + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/search_32.png'), + scale: 'large', + width: 34, + rowspan: 3, + application: this, + handler: function (btn, state) { + org.ametys.explorer.applications.resources.toolbar.File.search(this.application); + }, + disabled: true + }, + { + id: this._appPrefix + 'toolbar-btn-folder-rename', + text: "", + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/folder_rename_32.png'), + icon: getPluginResourcesUrl ('explorer') + '/img/resources/folder_rename_16.png', + scale: 'small', + application: this, + handler: function () { + org.ametys.explorer.applications.resources.toolbar.Folder.rename (this.application); + }, + rightId: 'Plugin_Explorer_Folder_Edit', + disabled: true + }, + { + id: this._appPrefix + 'toolbar-btn-folder-delete', + text: "", + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/folder_delete_32.png'), + icon: getPluginResourcesUrl ('explorer') + '/img/resources/folder_delete_16.png', + scale: 'small', + application: this, + handler: function () { + org.ametys.explorer.applications.resources.toolbar.Folder.remove (this.application); + }, + rightId: 'Plugin_Explorer_Folder_Delete', + disabled: true + } + ] + }); + + + // file button group + var fileGp = new Ext.ButtonGroup ({ + columns: 3, + height: 90, + title: "", + defaults: { + scale: 'small' + }, + items: [ + { + id: this._appPrefix + 'toolbar-btn-file-add', + text: "", + icon: getPluginResourcesUrl ('explorer') + '/img/resources/file_new_32.png', + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/file_new_32.png'), + iconAlign: 'top', + scale: 'large', + boxMinWidth: 34, + rowspan: 3, + application: this, + handler: function () { + org.ametys.explorer.applications.resources.toolbar.File.add (this.application); + }, + rightId: 'Plugin_Explorer_File_Add', + disabled: true + }, + { + id: this._appPrefix + 'toolbar-btn-file-rename', + text: "", + icon: getPluginResourcesUrl ('explorer') + '/img/resources/file_rename_16.png', + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/file_rename_32.png'), + application: this, + rightId: 'Plugin_Explorer_File_Rename', + handler: function () { + org.ametys.explorer.applications.resources.toolbar.File.rename (this.application); + }, + disabled: true + }, + { + id: this._appPrefix + 'toolbar-btn-file-history', + icon: getPluginResourcesUrl ('explorer') + '/img/resources/history_16.png', + text: "", + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/history_32.png'), + application: this, + handler: function () { + org.ametys.explorer.applications.resources.toolbar.File.viewHistory (this.application); + }, + disabled: true + }, + { + id: this._appPrefix + 'toolbar-btn-file-delete', + text: "", + icon: getPluginResourcesUrl ('explorer') + '/img/resources/file_delete_16.png', + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/file_delete_32.png'), + application: this, + // EXPLORER-108 rowspan: 2, + rightId: 'Plugin_Explorer_File_Delete', + handler: function () { + org.ametys.explorer.applications.resources.toolbar.File.remove (this.application); + }, + disabled: true + }, + { + id: this._appPrefix + 'toolbar-btn-file-download', + text: "", + icon: getPluginResourcesUrl ('explorer') + '/img/resources/file_download_16.png', + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/file_download_32.png'), + application: this, + handler: function () { + org.ametys.explorer.applications.resources.toolbar.File.download (this.application); + }, + disabled: true + }, + { + id: this._appPrefix + 'toolbar-btn-file-dublincore', + icon: getPluginResourcesUrl ('explorer') + '/img/resources/dublincore_16.png', + text: "", + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/dublincore_32.png'), + rightId: 'Plugin_Explorer_File_Edit_DC_Metadata', + // EXPLORER-108 rowspan: 2, + application: this, + handler: function () { + org.ametys.explorer.applications.resources.toolbar.File.editDublinCore (this.application); + }, + disabled: true + } + /* EXPLORER-108, + { + id: this._appPrefix + 'toolbar-btn-file-export-rdf', + text: "", + icon: getPluginResourcesUrl ('explorer') + '/img/resources/export_rdf_16.png', + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/export_rdf_32.png'), + application: this, + handler: function () { + org.ametys.explorer.applications.resources.toolbar.File.exportRDF (this.application); + }, + disabled: true + }*/ + ] + }); + + // clipboard button group + var clipboardGp = new Ext.ButtonGroup ({ + columns: 2, + height: 90, + title: "", + defaults: { + scale: 'small' + }, + items: [ + { + id: this._appPrefix + 'toolbar-btn-file-cut', + text: "", + icon: getPluginResourcesUrl ('explorer') + '/img/resources/clipboard/cut_32.png', + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/clipboard/cut_32.png'), + iconAlign: 'top', + scale: 'large', + boxMinWidth: 34, + application: this, + handler: function () { + org.ametys.explorer.applications.resources.toolbar.File.cut (this.application); + }, + rightId: 'Plugin_Explorer_File_Delete', + disabled: true + }, + { + id: this._appPrefix + 'toolbar-btn-file-paste', + text: "", + icon: getPluginResourcesUrl ('explorer') + '/img/resources/clipboard/paste_32.png', + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/resources/clipboard/paste_32.png'), + iconAlign: 'top', + scale: 'large', + boxMinWidth: 34, + application: this, + handler: function () { + org.ametys.explorer.applications.resources.toolbar.File.paste (this.application); + }, + rightId: 'Plugin_Explorer_File_Add', + disabled: true + } + ] + }); + + // view button group + var viewGp = new Ext.ButtonGroup ({ + columns: 2, + height: 90, + title: "", + cls: 'x-btn-group-ribbonstyle', + defaults: { + scale: 'small' + }, + items: [ + { + id: this._appPrefix + 'toolbar-btn-view-details', + icon: getPluginResourcesUrl ('explorer') + '/img/view_details_32.png', + iconAlign: 'top', + text: "", + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/view_details_32.png'), + scale: 'large', + boxMinWidth: 34, + application: this, + toggleGroup: this._appPrefix + 'toolbar-btn-view-group', + enableToggle: true, + allowDepress: false, + toggleHandler: function (btn, state) { + org.ametys.explorer.applications.resources.toolbar.View.details (btn, state, this.application); + }, + pressed: true, + disabled: false + }, + { + id: this._appPrefix + 'toolbar-btn-view-icons', + icon: getPluginResourcesUrl ('explorer') + '/img/view_icon_32.png', + iconAlign: 'top', + text: "", + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/view_icon_32.png'), + scale: 'large', + boxMinWidth: 34, + application: this, + enableToggle: true, + allowDepress: false, + toggleGroup: this._appPrefix + 'toolbar-btn-view-group', + toggleHandler: function (btn, state) { + org.ametys.explorer.applications.resources.toolbar.View.icons (btn, state, this.application); + }, + disabled: false + } + ] + }); + + var imagesGp = new Ext.ButtonGroup ({ + columns: 1, + height: 90, + title : 'Images', + //title: "", + cls: 'x-btn-group-ribbonstyle', + defaults: { + scale: 'small' + }, + items: [ + { + id: this._appPrefix + 'toolbar-btn-view-slideshow', + icon: getPluginResourcesUrl ('explorer') + '/img/view_details_32.png', + iconAlign: 'top', + text : 'Diaporama', + //text: "", + tooltip : org.ametys.explorer.utils.Tooltip.createTooltipContent ("", "", getPluginResourcesUrl ('explorer') + '/img/view_details_32.png'), + scale: 'large', + boxMinWidth: 34, + application: this, + handler: function (btn, state) { + org.ametys.explorer.applications.resources.toolbar.File.slideshow(btn, state, this.application); + }, + + disabled: false + + }, + ] + }); + + this._toolbar = new Ext.Panel ({ + height: 95, + border: false, + tbar : [ folderGp, + fileGp, + clipboardGp, + viewGp, + imagesGp + ] + }); + + var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/user-rights', {'explorerNodeId': this._explorer._tree.getRootNode().childNodes[0].id}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); + var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); + + if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.ResourcesApplication")) + { + return false; + } + + if (response.selectSingleNode ("user-rights/right[@id='Runtime_Rights_Rights_Handle']") != null) + { + var rightsGp = org.ametys.explorer.rights.RightsAssignment.getToolbarGroupItems (this); + this._toolbar.getTopToolbar().add (rightsGp); + } + + return this._toolbar; +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._getUserRights = function (folder) +{ + var rights = []; + if (folder != null) + { + var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/user-rights', {'explorerNodeId': folder}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); + var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); + + if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.ResourcesApplication")) + { + return false; + } + + var rightNodes = response.selectNodes ('user-rights/right'); + for (var i=0; i < rightNodes.length; i++) + { + rights.push (rightNodes[i].getAttribute("id")); + } + } + return rights; +} +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._updateToolbar = function (folder, files, rightNode) +{ + var isRoot = this._explorer._params.id == folder; + + var isRightsPanelActive = this._explorer._profilesTree != null && this._explorer._mainPanel.items.get(1).getLayout().activeItem.id == this._explorer._profilesTree.id; + + // check rights + var rights = this._getUserRights (folder); + + var node = folder != null ? this._explorer._tree.getNodeById(folder) : null; + var isModifiable = node != null ? node.attributes.isModifiable == 'true' : false; + var canCreateChild = node != null ? node.attributes.canCreateChild == 'true' : false; + + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-folder-add'); + btn.setDisabled (folder == null || (!isRoot && (!isModifiable || !canCreateChild)) || !this._hasRight (rights, btn.rightId)); + + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-cmis-add'); + btn.setDisabled (folder == null || (!isRoot && !isModifiable) || !this._hasRight (rights, btn.rightId)); + + btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-folder-rename') + btn.setDisabled (isRoot || folder == null || !isModifiable || !this._hasRight (rights, btn.rightId)); + + btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-folder-delete'); + btn.setDisabled (isRoot || folder == null || !isModifiable || !this._hasRight (rights, btn.rightId)); + + var isCmis = folder != null && folder.indexOf ('cmis-root-collection') == 0; + btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-search'); + btn.setDisabled (folder == null || isRightsPanelActive || isCmis || !this._hasRight (rights, btn.rightId)); + + btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-file-add'); + btn.setDisabled (folder == null || isRightsPanelActive || (!isRoot && (!isModifiable || !canCreateChild)) || !this._hasRight (rights, btn.rightId)); + + var notEditable = false; + if (files != null) + { + for (var i=0; i < files.length; i++) + { + if (files[i].data.isModifiable != "true") + { + notEditable = true; + } + } + } + + btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-file-rename'); + btn.setDisabled (files == null || files.length == 0 || notEditable || !this._hasRight (rights, btn.rightId)); + + btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-file-delete'); + btn.setDisabled (files == null || files.length == 0 || notEditable || !this._hasRight (rights, btn.rightId)); + + btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-file-download'); + btn.setDisabled (files == null || files.length == 0 || !this._hasRight (rights, btn.rightId)); + + /* EXPLORER-108 + btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-file-export-rdf'); + btn.setDisabled (files == null || files.length == 0 || !this._hasRight (rights, btn.rightId)); + */ + + btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-file-dublincore'); + btn.setDisabled (files == null || files.length == 0 || notEditable || !this._hasRight (rights, btn.rightId)); + + btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-file-history'); + btn.setDisabled (files == null || files.length == 0 || notEditable || !this._hasRight (rights, btn.rightId)); + + btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-file-cut'); + btn.setDisabled (files == null || files.length == 0 || notEditable || !this._hasRight (rights, btn.rightId)); + + btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-file-paste'); + btn.setDisabled (folder == null || isRightsPanelActive || notEditable || !this._hasRight (rights, btn.rightId)); + + btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-view-details'); + btn.setDisabled (isRightsPanelActive); + + btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-view-icons'); + btn.setDisabled (isRightsPanelActive); +/*---------------------------------------------------------------------------*/ + + btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-view-slideshow'); + + this._checkFilesForSlideShow(); + +/*---------------------------------------------------------------------------*/ + btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-assign-users'); + if (btn != null) + { + btn.setDisabled (!isRightsPanelActive || rightNode == null || rightNode.attributes.type != 'profile'); + } + + btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-assign-groups'); + if (btn != null) + { + btn.setDisabled (!isRightsPanelActive || rightNode == null || rightNode.attributes.type != 'profile'); + } + + btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-remove'); + if (btn != null) + { + btn.setDisabled (!isRightsPanelActive || rightNode == null || rightNode.attributes.type == 'profile' || rightNode.attributes.inherit == 'true'); + } +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._onLoadFiles = function () +{ + this._checkFilesForSlideShow(); +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._checkFilesForSlideShow = function () +{ + var btn = Ext.getCmp(this._appPrefix + 'toolbar-btn-view-slideshow'); + + if (btn) + { + var filesToTest = this.getSelectedRecords(); + + if (filesToTest.length == 0) + { + filesToTest = this.getRecords(); + } + + var ids = []; + + for (var i = 0; i < filesToTest.length; i++) + { + var filename = filesToTest[i].data.name; + var extension = ""; + + var j = filename.lastIndexOf("."); + if (j >= 0); + { + extension = filename.substring(j); + } + + if (/^(.jpg|.jpeg|.png|.gif)$/i.test(extension)) + { + ids.push(filesToTest[i].data.id); + } + + } + + btn._ids = ids; + + btn.setDisabled(ids.length == 0); + } +} + + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._hasRight = function (rights, rightId) +{ + if (rightId == null) + { + return true; + } + + for (var i=0; rights != null && i < rights.length; i++) + { + if (rightId == rights[i]) + { + return true; + } + } +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._renameFile = function (store, record, operation) +{ + if (operation == 'edit') + { + var name = record.data.name; + var id = record.data.id; + org.ametys.explorer.applications.resources.File.rename (id, name); + } +} + +/** + * Determines if the node application can be rename. + */ +org.ametys.explorer.applications.resources.ResourcesApplication.prototype.canRenameNode = function (node) +{ + // check rights + var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/user-rights', {'explorerNodeId': node.attributes.id}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); + var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); + + if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.ResourcesApplication")) + { + return false; + } + + if (response.selectSingleNode ("user-rights/right[@id='Plugin_Explorer_Folder_Edit']") == null) + { + return false; + } + + return true; +} + +/** + * Determines if the node application can be rename. + */ +org.ametys.explorer.applications.resources.ResourcesApplication.prototype.canRenameFile = function (nodeId) +{ + // check rights + var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/user-rights', {'explorerNodeId': nodeId}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); + var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); + + if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.ResourcesApplication")) + { + return false; + } + + if (response.selectSingleNode ("user-rights/right[@id='Plugin_Explorer_File_Rename']") == null) + { + return false; + } + + return true; +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype.renameNode = function (id, value) +{ + if (!this.canRenameNode()) + return; + + return org.ametys.explorer.applications.resources.Folder.doRename (id, value); +}; + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._preventClickOnSelection = false; +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._currentFilesId; +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._onSelectFiles = function (dv) // (sm) +{ + this._preventClickOnSelection = true; + function a() {this._preventClickOnSelection = false}; + a.defer(50, this); + + var records = this.getSelectedRecords(); + + var selectedFilesId = []; + for (var i=0; i < records.length; i++) + { + selectedFilesId.push (records[i].id); + } + + if (!this._areTheSame (this._currentFilesId, selectedFilesId)) + { + this._currentFilesId = selectedFilesId; + this._explorer._onSelectRecords (records, 'resource'); + } +} +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._areTheSame = function (files1, files2) +{ + if (files1 == files2) + { + return true; + } + + if (files1 == null || files2 == null || files1.length != files2.length) + { + return false; + } + + for (var i=0; i < files1.length; i++) + { + if (files2.indexOf(files1[i]) == -1) + { + return false; + } + } + + return true; +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._preventSingleClick = false; +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._timeout = null; +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._onDblClick = function (dv, index, node, e) +{ + // prevent click event (if double click event occurs before single click event) + this._preventSingleClick = true; + function a() {this._preventSingleClick = false}; + a.defer(200, this); + + if (this._timeout != null) + { + // prevent click event (if double click event occurs after single click event) + window.clearTimeout(this._timeout); + this._timeout = null; + } + + var record = dv.getStore().getAt(index); + if (record != null) + { + org.ametys.explorer.applications.resources.File.download (record.data.id); + } +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._onClick = function (dv, index, node, e) +{ + if (this._preventSingleClick || this._preventClickOnSelection) + return; + + if (this._timeout != null) + { + // prevent click event + window.clearTimeout(this._timeout); + this._timeout = null; + } + + // prevent click event on double click + this._timeout = this._deferedClick.defer (200, this, [dv, index, node, e]); +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._deferedClick = function (dv, index, node, e) +{ + var record = dv.getStore().getAt(index); + var selections = this.getSelectedRecords(); + + if (e.type = 'click' && record != null && selections.length == 1 && selections[0].data.id == record.data.id) + { + if (!this.canRenameFile (this._explorer._tree.getSelectionModel().getSelectedNode().id)) + return; + + // edit record + dv.startEditRecord (record.data.id); + } +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._initView = function () +{ + this._explorer._onViewChange (this.getId(), 'details'); +} + +/** + * Get the selected files' ids + * @return {Array} the selected files' ids + */ +org.ametys.explorer.applications.resources.ResourcesApplication.prototype.getSelectedFiles = function () +{ + var records = this.getSelectedRecords(); + + var ids = []; + for (var i=0; i < records.length; i++) + { + ids.push (records[i].data.id); + } + return ids; +} + +/** + * Get the all files' ids + * @return {Array} the selected files' ids + */ +org.ametys.explorer.applications.resources.ResourcesApplication.prototype.getFiles = function () +{ + var records = this.getRecords(); + + var ids = []; + for (var i=0; i < records.length; i++) + { + ids.push (records[i].data.id); + } + return ids; +} + +/** + * Get the selected files' records + * @return {Array} the selected files' records + */ +org.ametys.explorer.applications.resources.ResourcesApplication.prototype.getSelectedRecords = function () +{ + var dv = this._panel.getLayout().activeItem; + var records = typeof dv.getSelectedRecords == 'function' ? dv.getSelectedRecords() : dv.getSelectionModel().getSelections(); + + return records; +} + +/** + * Get the files' records + * @return {Array} the files' records + */ +org.ametys.explorer.applications.resources.ResourcesApplication.prototype.getRecords = function () +{ + var dv = this._panel.getLayout().activeItem; + var records = dv.getStore().getRange(); + + return records; +} + +/** + * Get the selected files' ids + * @return {Array} the selected files' ids + */ +org.ametys.explorer.applications.resources.ResourcesApplication.prototype.getFile = function (id) +{ + var dv = this._panel.getLayout().activeItem; + return dv.getStore().getById(id); +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype.refresh = function(id, reload) +{ + if (reload) + { + this._store.load({params: {id: id}}); + this._explorer._refreshNode (id); + } + else + { + this._store.load({params: {id: id}}); + } +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype.execCommand = function (cmd, params) +{ + switch (cmd) + { + case 'move-node': + var target = params.target; // New parent folder + var id = params.id; // Folder moved + + if (this._explorer._tree.getNodeById(id).attributes.isModifiable != 'true') + { + return false; + } + if (this._explorer._tree.getNodeById(target).attributes.isModifiable != 'true' || this._explorer._tree.getNodeById(target).attributes.canCreateChild != 'true') + { + return false; + } + + // check rights + var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/user-rights', {'explorerNodeId': target}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); + var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); + + if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.ResourcesApplication")) + { + return false; + } + + if (response.selectSingleNode ("user-rights/right[@id='Plugin_Explorer_Folder_Add']") == null) + { + return false; + } + + return org.ametys.explorer.applications.resources.Folder.move (target, [id]); + + case 'move': + var target = params.target; + var ids = params.ids; + + if (this._explorer._tree.getNodeById(target).attributes.isModifiable != 'true' || this._explorer._tree.getNodeById(target).attributes.canCreateChild != 'true') + { + return false; + } + + var store = this._panel.getLayout().activeItem.getStore(); + for (var i=0; i < ids.length; i++) + { + var record = store.getAt(store.find('id', ids[i])); + if (record != null && record.data.isModifiable != 'true') + { + return false; + } + } + + // check rights + var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/user-rights', {'explorerNodeId': target}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); + var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); + + if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.ResourcesApplication")) + { + return false; + } + + if (response.selectSingleNode ("user-rights/right[@id='Plugin_Explorer_File_Add']") == null) + { + return false; + } + + return org.ametys.explorer.applications.resources.File.move (target, ids); + + case 'rename': + return org.ametys.explorer.applications.resources.Folder.rename (params.id, params.value); + + case 'renameFile': + if (!this.canRenameFile(params.parentID)) + return false; + + if (this._panel.getLayout().activeItem.id == this._appPrefix + 'resources-details-view') + { + this._detailsView.startEditRecord (params.id); + } + else + { + this._thumbnailView.startEditRecord (params.id); + } + + break; + + case 'refresh': + var id = params.id; + this.refresh(id, params.reload); + + case 'changeView': + if (params.mode == 'details') + { + this._panel.getLayout().setActiveItem(0); + } + else if (params.mode == 'icons') + { + this._panel.getLayout().setActiveItem(1); + } + break; + + case 'updateToolbar': + this._updateToolbar (params.id, params.files, params.rightNode); + break; + default: + throw "The command '" + cmd + "' is unknown"; + break; + } +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype.queryCommandState = function (cmd, params) +{ + switch (cmd) + { + case 'changeView': + if (params.view == 'details') + { + return this._panel.getLayout().activeItem.id == this._appPrefix + 'resources-details-view'; + } + else if (params.view == 'icons') + { + return this._panel.getLayout().activeItem.id == this._appPrefix + 'resources-icons-view'; + } + break; + case 'resourceRenamed': + this._updateFileName (params.id); + break; + case 'resourceMoved': + this._moveFile (params.id, params.parentID); + break; + default: + throw "The command '" + cmd + "' is unknown"; + break; + } +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._addFile = function (id, parentID) +{ + this.refresh(parentID); +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._moveFile = function (id, parentID) +{ + this.refresh(parentID); +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._updateFileName = function (id, name) +{ + var index = this._store.find('id', id); + var record = this._store.getAt(index); + if (record != null) + { + var serverMessage = new org.ametys.servercomm.ServerMessage('explorer', '/exporer-entity', {'id': id}, org.ametys.servercomm.ServerComm.PRIORITY_SYNCHRONOUS, null, this, null); + var response = org.ametys.servercomm.ServerComm.getInstance().send(serverMessage); + if (org.ametys.servercomm.ServerComm.handleBadResponse("", response, "org.ametys.explorer.applications.resources.ResourcesApplication.prototype._updateFileName")) + { + return false; + } + + var name = response.selectSingleNode('Node').getAttribute('name'); + record.set('name', name); + } +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._removeFiles = function (ids) +{ + for (var i=0; i < ids.length; i++) + { + var index = this._store.find('id', ids[i]); + var record = this._store.getAt(index); + if (record != null) + { + this._store.remove (record); + } + } +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._pasteFiles = function (id) +{ + this.refresh(id); +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._onFocus = function () +{ + var records = this._detailsView.getSelectedRecords(); + if (records != null && records.length > 0) + { + this._explorer._onSelectRecords (records, 'resource'); + } +} + +org.ametys.explorer.applications.resources.ResourcesApplication.prototype._onBeforeSelect = function (dv, node, selections) +{ + if (dv._preventSelection) + return false; +} + Index: main/plugin-explorer/resources/pirobox_ext/loadinfo.gif =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: main\plugin-explorer\resources\pirobox_ext\loadinfo.gif ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Index: main/plugin-explorer/resources/pirobox_ext/bottom_nav.png =================================================================== Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: main\plugin-explorer\resources\pirobox_ext\bottom_nav.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream