Changeset 1794


Ignore:
Timestamp:
19.01.2012 22:37:09 (4 months ago)
Author:
zmsdev
Message:

Ticket#19 (uni-bern): CKEditor - crop relative urls

Location:
ZMS/trunk/plugins
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • ZMS/trunk/plugins/rte/ckeditor/manage_form.dtml

    r1793 r1794  
    5454                                // Get value from editor. 
    5555                                var data = CKEDITOR.instances['editor_'+elName].getData(); 
     56                                // Relativate urls. 
     57                                data = zmiRelativateUrls(data); 
    5658                                // Assign value to textarea. 
    5759                                $('#'+elName).val( data); 
  • ZMS/trunk/plugins/www/jquery/jquery-all.min.js

    r1784 r1794  
    9191else {$content.show('normal')} 
    9292$container.toggleClass('ui-state-active').toggleClass('ui-state-default');$icon.toggleClass('ui-icon-triangle-1-s').toggleClass('ui-icon-triangle-1-e');var zmi_form_section_id=$container.attr('id');if(typeof zmi_form_section_id !='undefined'){toggleCookie(zmi_form_section_id+'_collapsed')} 
    93 })});function confirmChanges(el){if(el&&self.name=='cameFromForm'){el.target='_parent'} 
     93})});function zmiRelativateUrl(path,url){var protocol=self.location.href;protocol=protocol.substr(0,protocol.indexOf(":")+3);var server_url=self.location.href;server_url=server_url.substr(protocol.length);server_url=protocol+server_url.substr(0,server_url.indexOf("/"));var currntPath=path;if(currntPath.indexOf(server_url)==0){currntPath=currntPath.substr(server_url.length+1)} 
     94else if(currntPath.indexOf('/')==0){currntPath=currntPath.substr(1)} 
     95var targetPath=url;if(targetPath.indexOf(server_url)==0){targetPath=targetPath.substr(server_url.length+1)} 
     96else if(targetPath.indexOf('/')==0){targetPath=targetPath.substr(1)} 
     97while(currntPath.length > 0&&targetPath.length > 0){var i=currntPath.indexOf('/');var j=targetPath.indexOf('/');if(i < 0){currntElmnt=currntPath} 
     98else {currntElmnt=currntPath.substring(0,i)} 
     99if(j < 0){targetElmnt=targetPath} 
     100else {targetElmnt=targetPath.substring(0,j)} 
     101if(currntElmnt !=targetElmnt){break} 
     102if(i < 0){currntPath=''} 
     103else {currntPath=currntPath.substring(i+1)} 
     104if(j < 0){targetPath=''} 
     105else {targetPath=targetPath.substring(j+1)}} 
     106while(currntPath.length > 0){var i=currntPath.indexOf('/');if(i < 0){currntElmnt=currntPath;currntPath=''} 
     107else {currntElmnt=currntPath.substring(0,i);currntPath=currntPath.substring(i+1)} 
     108targetPath='../'+targetPath} 
     109url='./'+targetPath;return url} 
     110function zmiRelativateUrls(s){var url0=self.location.href;url0=url0.substr(0,url0.lastIndexOf("/"));var splitTags=['<a href="','<img src="'];for(var j=0;j < splitTags.length;j++){var vSplit=s.split(splitTags[j]);var v=vSplit[0];for(var i=1;i < vSplit.length;i++){var j=vSplit[i].indexOf("\"");var url=vSplit[i].substring(0,j);if(url.indexOf('./')<0){url=zmiRelativateUrl(url0,url)} 
     111v+=splitTag+url+vSplit[i].substring(j)} 
     112s=v} 
     113return s} 
     114function confirmChanges(el){if(el&&self.name=='cameFromForm'){el.target='_parent'} 
    94115if(navigator.platform.indexOf("Mac")<0){var anyFormModified=false;for(i=0;i<document.forms.length;i++){anyFormModified|=isFormModified(document.forms[i])} 
    95116if(anyFormModified){if(!confirm(getZMILangStr('MSG_CONFIRM_DISCARD_CHANGES'))){return false}}} 
  • ZMS/trunk/plugins/www/jquery/plugin/jquery.plugin.zmi.js

    r1756 r1794  
    143143}); 
    144144 
     145// ############################################################################# 
     146// ### ZMI Pathcropping 
     147// ############################################################################# 
     148 
     149 
     150function zmiRelativateUrl(path, url) { 
     151        var protocol = self.location.href; 
     152        protocol = protocol.substr(0,protocol.indexOf(":")+3); 
     153        var server_url = self.location.href; 
     154        server_url = server_url.substr(protocol.length); 
     155        server_url = protocol + server_url.substr(0,server_url.indexOf("/")); 
     156        var currntPath = path; 
     157        if (currntPath.indexOf(server_url)==0) { 
     158                currntPath = currntPath.substr(server_url.length+1); 
     159        } 
     160        else if (currntPath.indexOf('/')==0) { 
     161                currntPath = currntPath.substr(1); 
     162        } 
     163        var targetPath = url; 
     164        if (targetPath.indexOf(server_url)==0) { 
     165                targetPath = targetPath.substr(server_url.length+1); 
     166        } 
     167        else if (targetPath.indexOf('/')==0) { 
     168                targetPath = targetPath.substr(1); 
     169        } 
     170        while ( currntPath.length > 0 && targetPath.length > 0) { 
     171                var i = currntPath.indexOf( '/'); 
     172                var j = targetPath.indexOf( '/'); 
     173                if ( i < 0) { 
     174                        currntElmnt = currntPath; 
     175                } 
     176                else { 
     177                        currntElmnt = currntPath.substring( 0, i); 
     178                } 
     179                if ( j < 0) { 
     180                        targetElmnt = targetPath; 
     181                } 
     182                else { 
     183                        targetElmnt = targetPath.substring( 0, j); 
     184                } 
     185                if ( currntElmnt != targetElmnt) { 
     186                        break; 
     187                } 
     188                if ( i < 0) { 
     189                        currntPath = ''; 
     190                } 
     191                else { 
     192                        currntPath = currntPath.substring( i + 1); 
     193                } 
     194                if ( j < 0) { 
     195                        targetPath = ''; 
     196                } 
     197                else { 
     198                        targetPath = targetPath.substring( j + 1); 
     199                } 
     200        } 
     201        while ( currntPath.length > 0) { 
     202                var i = currntPath.indexOf( '/'); 
     203                if ( i < 0) { 
     204                        currntElmnt = currntPath; 
     205                        currntPath = ''; 
     206                } 
     207                else { 
     208                        currntElmnt = currntPath.substring( 0, i); 
     209                        currntPath = currntPath.substring( i + 1); 
     210                } 
     211                targetPath = '../' + targetPath; 
     212        } 
     213        url = './' + targetPath; 
     214        return url; 
     215} 
     216 
     217function zmiRelativateUrls(s) { 
     218        var url0 = self.location.href; 
     219        url0 = url0.substr(0,url0.lastIndexOf("/")); 
     220        var splitTags = ['<a href="','<img src="']; 
     221        for ( var j = 0; j < splitTags.length; j++) { 
     222                var vSplit = s.split(splitTags[j]); 
     223                var v = vSplit[0]; 
     224                for ( var i = 1; i < vSplit.length; i++) { 
     225                        var j = vSplit[i].indexOf("\""); 
     226                        var url = vSplit[i].substring(0,j); 
     227                        if (url.indexOf('./')<0) { 
     228                                url = zmiRelativateUrl(url0,url); 
     229                        } 
     230                        v += splitTag + url + vSplit[i].substring(j); 
     231                } 
     232                s = v; 
     233        } 
     234        return s; 
     235} 
    145236 
    146237// ############################################################################# 
Note: See TracChangeset for help on using the changeset viewer.