openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit ea040389adb001b0acf733f11d19862c053add26
parent 5c5c88e4151d6ad44971aca6c023e4020e0d277f
Author: Jan Dankert <devnull@localhost>
Date:   Sat, 30 Dec 2017 01:54:43 +0100

Requests aus dem HTML-UI, die JSON erwarten, über das Modul CMS-API abwickeln. CMS-UI kann ab jetzt nur noch HTML ausgeben.

Diffstat:
dav/Client.class.php | 2+-
modules/cms-ui/UI.class.php | 15---------------
modules/cms-ui/themes/default/js/plugin/jquery-plugin-orTree.js | 2+-
modules/cms-ui/themes/default/js/plugin/jquery-plugin-orTree.min.js | 4++--
modules/template-engine/components/html/link/link.js | 2+-
modules/template-engine/components/html/link/link.min.js | 4++--
modules/template-engine/components/html/table/table.js | 2+-
modules/template-engine/components/html/table/table.min.js | 43++-----------------------------------------
modules/template-engine/components/html/upload/upload.js | 2+-
modules/template-engine/components/html/upload/upload.min.js | 87++-----------------------------------------------------------------------------
webdav.php | 2+-
11 files changed, 14 insertions(+), 151 deletions(-)

diff --git a/dav/Client.class.php b/dav/Client.class.php @@ -36,7 +36,7 @@ class Client $path = $path.'/'; if ( substr($path,0,1 ) != '/' ) $path = '/'.$path; - $path .= '/dispatcher.php'; + $path .= '/api/'; // Methode: Fallback GET if ( empty($method)) diff --git a/modules/cms-ui/UI.class.php b/modules/cms-ui/UI.class.php @@ -50,21 +50,6 @@ class UI // The action is able to change its method name. $subaction = $dispatcher->subaction; - $httpAccept = getenv('HTTP_ACCEPT'); - $types = explode(',', $httpAccept); - - if (sizeof($types) == 1 && in_array('application/json', $types) || @$_REQUEST['output'] == 'json') { - $json = new JSON(); - header('Content-Type: application/json; charset=UTF-8'); - if (function_exists('json_encode')) - // Native Methode ist schneller.. - echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK | JSON_PARTIAL_OUTPUT_ON_ERROR); - else - // Fallback, falls json_encode() nicht existiert... - echo $json->encode($data); - exit; - } - header('Content-Type: text/html; charset=UTF-8'); $tplName = $action . '/' . $subaction; diff --git a/modules/cms-ui/themes/default/js/plugin/jquery-plugin-orTree.js b/modules/cms-ui/themes/default/js/plugin/jquery-plugin-orTree.js @@ -14,7 +14,7 @@ jQuery.fn.orTree = function( options ) $(this).each(function(idxx,treeEl) { $(treeEl).closest('div.content').addClass('loader'); - $.getJSON('./?action=tree&subaction=loadBranch&id='+settings.id+'&type='+settings.type+'&output=json', function(json) { + $.getJSON('./api/?action=tree&subaction=loadBranch&id='+settings.id+'&type='+settings.type+'&output=json', function(json) { $(treeEl).append('<ul class="tree" style="display:none;"/>'); var ul = $(treeEl).children('ul').first(); var output = json['output']; diff --git a/modules/cms-ui/themes/default/js/plugin/jquery-plugin-orTree.min.js b/modules/cms-ui/themes/default/js/plugin/jquery-plugin-orTree.min.js @@ -1 +1 @@ -;jQuery.fn.orTree=function(t){var e=$.extend({'onSelect':function(){},'type':'root','id':0,'selectable':Array()},t);$(this).each(function(n,t){$(t).closest('div.content').addClass('loader');$.getJSON('./?action=tree&subaction=loadBranch&id='+e.id+'&type='+e.type+'&output=json',function(i){$(t).append('<ul class="tree" style="display:none;"/>');var n=$(t).children('ul').first(),l=i['output'];$.each(l['branch'],function(i,t){if(!t.action||t.action=='folder'||e.selectable.length==0||e.selectable[0]==''||jQuery.inArray(t.action,e.selectable)!=-1){$(n).append('<li class="object" data-id="'+t.internalId+'" data-type="'+t.type+'"><div class="tree">&nbsp;</div><div class="entry" data-id="'+t.internalId+'" data-type="'+t.type+'" title="'+t.description+'"><img src="'+OR_THEMES_EXT_DIR+'default/images/icon_'+t['icon']+'.png" />'+t.text+'</div></li>');var l=$(n).children('li').last();if(t.type){$(l).children('div.tree').addClass('closed');$(l).children('div.tree').click(function(){$(this).parent().orTree({type:t.type,id:t.internalId,onSelect:e.onSelect,selectable:e.selectable})})};if(t.action&&(e.selectable.length==0||e.selectable[0]==''||jQuery.inArray(t.action,e.selectable)!=-1)){$(l).children('div.entry').click(function(){$(this).closest('div.content').find('div.entry').removeClass('selected');$(this).addClass('selected');e.onSelect($(this).text(),t.action,t.id)})};if($(l).parents('ul.tree').length<=2){$(l).children('div.tree').click()}}});$(n).slideDown('fast')}).fail(function(){}).always(function(){$(t).closest('div.content').removeClass('loader')});$(t).children('div.tree').unbind('click');$(t).children('div.tree').removeClass('closed').addClass('open');$(t).children('div.tree').click(function(t){i($(t.target).parent(),e.type,e.id)})});function i(t,i,n){$(t).children('ul').slideUp('fast',function(){$(t).children('ul').remove();$(t).children('div.tree').unbind('click');$(t).children('div.tree').removeClass('open').addClass('closed');$(t).children('div.tree').click(function(){$(this).parent().orTree({type:i,id:n,onSelect:e.onSelect,selectable:e.selectable})})})}};- \ No newline at end of file +;jQuery.fn.orTree=function(t){var e=$.extend({'onSelect':function(){},'type':'root','id':0,'selectable':Array()},t);$(this).each(function(n,t){$(t).closest('div.content').addClass('loader');$.getJSON('./api/?action=tree&subaction=loadBranch&id='+e.id+'&type='+e.type+'&output=json',function(i){$(t).append('<ul class="tree" style="display:none;"/>');var n=$(t).children('ul').first(),l=i['output'];$.each(l['branch'],function(i,t){if(!t.action||t.action=='folder'||e.selectable.length==0||e.selectable[0]==''||jQuery.inArray(t.action,e.selectable)!=-1){$(n).append('<li class="object" data-id="'+t.internalId+'" data-type="'+t.type+'"><div class="tree">&nbsp;</div><div class="entry" data-id="'+t.internalId+'" data-type="'+t.type+'" title="'+t.description+'"><img src="'+OR_THEMES_EXT_DIR+'default/images/icon_'+t['icon']+'.png" />'+t.text+'</div></li>');var l=$(n).children('li').last();if(t.type){$(l).children('div.tree').addClass('closed');$(l).children('div.tree').click(function(){$(this).parent().orTree({type:t.type,id:t.internalId,onSelect:e.onSelect,selectable:e.selectable})})};if(t.action&&(e.selectable.length==0||e.selectable[0]==''||jQuery.inArray(t.action,e.selectable)!=-1)){$(l).children('div.entry').click(function(){$(this).closest('div.content').find('div.entry').removeClass('selected');$(this).addClass('selected');e.onSelect($(this).text(),t.action,t.id)})};if($(l).parents('ul.tree').length<=2){$(l).children('div.tree').click()}}});$(n).slideDown('fast')}).fail(function(){}).always(function(){$(t).closest('div.content').removeClass('loader')});$(t).children('div.tree').unbind('click');$(t).children('div.tree').removeClass('closed').addClass('open');$(t).children('div.tree').click(function(t){i($(t.target).parent(),e.type,e.id)})});function i(t,i,n){$(t).children('ul').slideUp('fast',function(){$(t).children('ul').remove();$(t).children('div.tree').unbind('click');$(t).children('div.tree').removeClass('open').addClass('closed');$(t).children('div.tree').click(function(){$(this).parent().orTree({type:i,id:n,onSelect:e.onSelect,selectable:e.selectable})})})}};+ \ No newline at end of file diff --git a/modules/template-engine/components/html/link/link.js b/modules/template-engine/components/html/link/link.js @@ -25,7 +25,7 @@ $(document).on('orHeaderLoaded',function(event, data) { function submitLink(element,data) { var params = jQuery.parseJSON( data ); - var url = './dispatcher.php'; + var url = './api/'; params.output = 'json'; $.ajax( { 'type':'POST',url:url, data:params, success:function(data, textStatus, jqXHR) { diff --git a/modules/template-engine/components/html/link/link.min.js b/modules/template-engine/components/html/link/link.min.js @@ -1 +1 @@ -;$(document).on('orViewLoaded',function(e,n){$(e.target).closest('div.panel').find('.clickable').orLinkify()});$(document).on('orHeaderLoaded',function(e,n){$('div#header .clickable').orLinkify()});function submitLink(e,n){var i=jQuery.parseJSON(n),o='./dispatcher.php';i.output='json';$.ajax({'type':'POST',url:o,data:i,success:function(n,i,o){$('div.panel div.status div.loader').html('&nbsp;');doResponse(n,i,e)}})};- \ No newline at end of file +;$(document).on('orViewLoaded',function(e,n){$(e.target).closest('div.panel').find('.clickable').orLinkify()});$(document).on('orHeaderLoaded',function(e,n){$('div#header .clickable').orLinkify()});function submitLink(e,n){var i=jQuery.parseJSON(n),o='./api/';i.output='json';$.ajax({'type':'POST',url:o,data:i,success:function(n,i,o){$('div.panel div.status div.loader').html('&nbsp;');doResponse(n,i,e)}})};+ \ No newline at end of file diff --git a/modules/template-engine/components/html/table/table.js b/modules/template-engine/components/html/table/table.js @@ -10,7 +10,7 @@ $(document).on('orViewLoaded',function(event, data) { var objectid = $(this).data('id'); order.push( objectid ); }); - var url = './dispatcher.php'; + var url = './api/'; var params = {}; params.action = 'folder'; params.subaction = 'order'; diff --git a/modules/template-engine/components/html/table/table.min.js b/modules/template-engine/components/html/table/table.min.js @@ -1,40 +1 @@ -$(document).on('orViewLoaded',function(event, data) { - -// Sortieren von Tabellen - $(event.target).find('table.sortable > tbody').sortable({ - update: function(event, ui) - { - $(ui).addClass('loader'); - var order = []; - $(ui.item).closest('table.sortable').find('tbody > tr.data').each( function() { - var objectid = $(this).data('id'); - order.push( objectid ); - }); - var url = './dispatcher.php'; - var params = {}; - params.action = 'folder'; - params.subaction = 'order'; - params.token = $('div.action-folder.method-order input[name=token]').attr('value'); - params.order = order.join(','); - params.id = $('div#dialog').data('id'); - params.output = 'json'; - - $.ajax( { 'type':'POST',url:url, data:params, success:function(data, textStatus, jqXHR) - { - $(ui).removeClass('loader'); - doResponse(data,textStatus,ui); - }, - error:function(jqXHR, textStatus, errorThrown) { - alert( errorThrown ); - } - - } ); - } - }); - - // Alle Checkboxen setzen oder nicht setzen. - $(event.target).find('tr.headline > td > input.checkbox').click( function() { - $(this).closest('table').find('tr.data > td > input.checkbox').attr('checked',Boolean( $(this).attr('checked') ) ); - }); - -});- \ No newline at end of file +;$(document).on('orViewLoaded',function(t,e){$(t.target).find('table.sortable > tbody').sortable({update:function(a,t){$(t).addClass('loader');var o=[];$(t.item).closest('table.sortable').find('tbody > tr.data').each(function(){var t=$(this).data('id');o.push(t)});var d='./api/',e={};e.action='folder';e.subaction='order';e.token=$('div.action-folder.method-order input[name=token]').attr('value');e.order=o.join(',');e.id=$('div#dialog').data('id');e.output='json';$.ajax({'type':'POST',url:d,data:e,success:function(e,a,o){$(t).removeClass('loader');doResponse(e,a,t)},error:function(t,e,a){alert(a)}})}});$(t.target).find('tr.headline > td > input.checkbox').click(function(){$(this).closest('table').find('tr.data > td > input.checkbox').attr('checked',Boolean($(this).attr('checked')))})});+ \ No newline at end of file diff --git a/modules/template-engine/components/html/upload/upload.js b/modules/template-engine/components/html/upload/upload.js @@ -57,7 +57,7 @@ function handleFileUpload(form,files) $('#noticebar').prepend(status); // Notice anhängen. $(status).show(); - $.ajax( { 'type':'POST',url:'dispatcher.php', cache:false,contentType: false, processData: false, data:form_data, success:function(data, textStatus, jqXHR) + $.ajax( { 'type':'POST',url:'./api/', cache:false,contentType: false, processData: false, data:form_data, success:function(data, textStatus, jqXHR) { $(status).remove(); doResponse(data,textStatus,form); diff --git a/modules/template-engine/components/html/upload/upload.min.js b/modules/template-engine/components/html/upload/upload.min.js @@ -1,85 +1 @@ -$(document).on('orViewLoaded',function(event, data) { - - var form = $(event.target).find('form'); - - // Dateiupload über Drag and Drop - var dropzone = $(event.target).find('div.filedropzone > div.input'); - dropzone.on('dragenter', function (e) - { - e.stopPropagation(); - e.preventDefault(); - $(this).css('border', '1px dotted gray'); - }); - dropzone.on('dragover', function (e) - { - e.stopPropagation(); - e.preventDefault(); - }); - dropzone.on('drop', function (e) - { - $(this).css('border','1px dotted red'); - e.preventDefault(); - var files = e.originalEvent.dataTransfer.files; - - //We need to send dropped files to Server - handleFileUpload(form,files); - }); - - - // Dateiupload über File-Input-Button - $(event.target).find('input[type=file]').change( function() { - - var files = $(this).prop('files'); - - handleFileUpload(form,files); - }); - -}); - - - - - - -function handleFileUpload(form,files) -{ - for (var i = 0, f; f = files[i]; i++) - { - var form_data = new FormData(); - form_data.append('file' , f); - form_data.append('action' ,'folder'); - form_data.append('subaction','createfile'); - form_data.append('output' ,'json'); - form_data.append('token' ,$(form).find('input[name=token]').val() ); - form_data.append('id' ,$(form).find('input[name=id]' ).val() ); - - var status = $('<div class="notice info"><div class="text loader"></div></div>'); - $('#noticebar').prepend(status); // Notice anhängen. - $(status).show(); - - $.ajax( { 'type':'POST',url:'dispatcher.php', cache:false,contentType: false, processData: false, data:form_data, success:function(data, textStatus, jqXHR) - { - $(status).remove(); - doResponse(data,textStatus,form); - }, - error:function(jqXHR, textStatus, errorThrown) { - $(form).closest('div.content').removeClass('loader'); - $(status).remove(); - - var msg; - try - { - var error = jQuery.parseJSON( jqXHR.responseText ); - msg = error.error + '/' + error.description + ': ' + error.reason; - } - catch( e ) - { - msg = jqXHR.responseText; - } - - notify('error',msg); - } - - } ); - } -} +;$(document).on('orViewLoaded',function(e,n){var t=$(e.target).find('form'),o=$(e.target).find('div.filedropzone > div.input');o.on('dragenter',function(e){e.stopPropagation();e.preventDefault();$(this).css('border','1px dotted gray')});o.on('dragover',function(e){e.stopPropagation();e.preventDefault()});o.on('drop',function(e){$(this).css('border','1px dotted red');e.preventDefault();var n=e.originalEvent.dataTransfer.files;handleFileUpload(t,n)});$(e.target).find('input[type=file]').change(function(){var e=$(this).prop('files');handleFileUpload(t,e)})});function handleFileUpload(e,o){for(var a=0,r;r=o[a];a++){var n=new FormData();n.append('file',r);n.append('action','folder');n.append('subaction','createfile');n.append('output','json');n.append('token',$(e).find('input[name=token]').val());n.append('id',$(e).find('input[name=id]').val());var t=$('<div class="notice info"><div class="text loader"></div></div>');$('#noticebar').prepend(t);$(t).show();$.ajax({'type':'POST',url:'./api/',cache:!1,contentType:!1,processData:!1,data:n,success:function(n,o,a){$(t).remove();doResponse(n,o,e)},error:function(n,o,i){$(e).closest('div.content').removeClass('loader');$(t).remove();var r;try{var a=jQuery.parseJSON(n.responseText);r=a.error+'/'+a.description+': '+a.reason}catch(d){r=n.responseText};notify('error',r)}})}};+ \ No newline at end of file diff --git a/webdav.php b/webdav.php @@ -5,6 +5,6 @@ $_GET['action' ] = 'webdav'; $_GET['subaction'] = strtolower($_SERVER['REQUEST_METHOD']); -require( 'dispatcher.php' ); +require( 'index.php' ); ?> \ No newline at end of file