commit 84e2041635b40598788e52beee80722b5fa762e3
parent 7a81b508fda442c8537fd25e5ba02e1f6e27fc51
Author: Jan Dankert <devnull@localhost>
Date: Tue, 3 Jul 2018 01:35:10 +0200
Der Server muss einen Parameter "embed" erhalten um zu prüfen, ob die Antwort nur das Fragment oder die ganze Seite enthalten soll.
Diffstat:
8 files changed, 39 insertions(+), 18 deletions(-)
diff --git a/modules/cms-core/action/LoginAction.class.php b/modules/cms-core/action/LoginAction.class.php
@@ -2192,6 +2192,11 @@ class LoginAction extends Action
$db = null;
unset($db);
}
+
+
+ public function showView() {
+ $this->nextSubAction('login');
+ }
}
diff --git a/modules/cms-core/action/RequestParams.class.php b/modules/cms-core/action/RequestParams.class.php
@@ -3,6 +3,7 @@
namespace {
/* Request Parameter Names */
+ define('REQ_PARAM_EMBED' ,'embed' );
define('REQ_PARAM_TOKEN' ,'token' );
define('REQ_PARAM_ACTION' ,'action' );
define('REQ_PARAM_SUBACTION' ,'subaction' );
diff --git a/modules/cms-core/action/StartAction.class.php b/modules/cms-core/action/StartAction.class.php
@@ -1120,7 +1120,7 @@ class StartAction extends Action
}
- function show()
+ function showView()
{
global $conf;
global $PHP_AUTH_USER;
diff --git a/modules/cms-ui/UI.class.php b/modules/cms-ui/UI.class.php
@@ -17,6 +17,7 @@ use template_engine\TemplateEngineInfo;
define('CMS_UI_REQ_PARAM_SUBACTION', 'subaction');
define('CMS_UI_REQ_PARAM_ACTION', 'action');
+define('CMS_UI_REQ_PARAM_EMBED', 'embed');
class UI
@@ -24,16 +25,24 @@ class UI
public static function execute()
{
try {
- if (!empty($_REQUEST[CMS_UI_REQ_PARAM_ACTION]))
- $action = $_REQUEST[CMS_UI_REQ_PARAM_ACTION];
- else
- $action = 'index';
- if (!empty($_REQUEST[CMS_UI_REQ_PARAM_SUBACTION]))
- $subaction = $_REQUEST[CMS_UI_REQ_PARAM_SUBACTION];
- else {
+ if(empty($_REQUEST[CMS_UI_REQ_PARAM_EMBED])) {
+ $action = 'index';
$subaction = 'show';
}
+ else
+ {
+ if (!empty($_REQUEST[CMS_UI_REQ_PARAM_ACTION]))
+ $action = $_REQUEST[CMS_UI_REQ_PARAM_ACTION];
+ else
+ $action = 'index';
+
+ if (!empty($_REQUEST[CMS_UI_REQ_PARAM_SUBACTION]))
+ $subaction = $_REQUEST[CMS_UI_REQ_PARAM_SUBACTION];
+ else {
+ $subaction = 'show';
+ }
+ }
header('Content-Type: text/html; charset=UTF-8');
self::setContentSecurityPolicy();
diff --git a/modules/cms-ui/themes/default/layout/index.php b/modules/cms-ui/themes/default/layout/index.php
@@ -55,8 +55,8 @@
<header>
<span class="title"></span>
</header>
- <div id="editor" class="view view-loader" data-method="edit">
- <?php embedView('login','login'); ?>
+ <div id="editor" class="view view-loader" data-method="show">
+ <?php embedView($action,'show'); ?>
</div>
</main>
@@ -66,7 +66,7 @@
<a href=""></a>
</header>
<div id="info" class="view view-loader" data-method="info">
- <?php embedView('login','login'); ?>
+ <?php embedView($action,'info'); ?>
</div>
</aside>
@@ -95,6 +95,8 @@
</html>
<?php
function embedView( $action, $method ) {
+ if (DEVELOPMENT)
+ echo "<!-- $action - $method -->";
echo cms_ui\UI::executeEmbedded($action,$method);
}
?>
\ No newline at end of file
diff --git a/modules/cms-ui/themes/default/script/openrat.js b/modules/cms-ui/themes/default/script/openrat.js
@@ -128,7 +128,7 @@ var Workbench = new function()
var targetDOMElement = $(this);
var method = targetDOMElement.data('method');
- var url = createUrl(action,method,id,params); // URL für das Laden erzeugen.
+ var url = createUrl(action,method,id,params,true); // URL für das Laden erzeugen.
targetDOMElement.empty().fadeTo(1,0.7).addClass('loader').html('').load(url,function(response, status, xhr) {
targetDOMElement.fadeTo(350,1);
@@ -981,15 +981,18 @@ else
* @param extraid
* @returns URL
*/
-function createUrl(action,subaction,id,extraid)
+function createUrl(action,subaction,id,extraid,embed)
{
var url = './';
- url += '?action=' + action + ';';
+ url += '?action=' + action;
if (subaction != null)
- url += '&subaction='+subaction+';'
+ url += '&subaction='+subaction;
url += '&id='+id;
+ if(embed)
+ url += '&embed=1';
+
if ( typeof extraid === 'string')
{
jQuery.each(jQuery.parseJSON(extraid), function(name, value) {
diff --git a/modules/cms-ui/themes/default/script/openrat.min.js b/modules/cms-ui/themes/default/script/openrat.min.js
@@ -1,4 +1,4 @@
-;var DEFAULT_CONTENT_ACTION='edit',OR_THEMES_EXT_DIR='modules/cms-ui/themes/';$(function(){$('html').removeClass('nojs');$('.initial-hidden').removeClass('initial-hidden');refreshAll();registerHeaderEvents();$('#workbench .view').each(function(e){registerViewEvents(this)});window.onpopstate=function(e){History.fromHistory(e.state)};initActualHistoryState();Workbench.initialize();loadTree()});function initActualHistoryState(){var e={};e.name=window.document.title;e.action=$('#editor').data('action');e.id=$('#editor').data('id');History.toActualHistory(e)};var History=new function(){'use strict';this.fromHistory=function(e){var i=e.state;Workbench.loadNewAction(i.action,i.id)};this.toHistory=function(e){window.history.pushState(e,e.name,'./?action='+e.action+'&id='+e.subaction)};this.toActualHistory=function(e){window.history.replaceState(e,e.name,'./?action='+e.action+'&id='+e.subaction)}},Workbench=new function(){'use strict';this.initialize=function(){this.initializePingTimer();this.loadInitialViews()};this.loadInitialViews=function(){};this.initializePingTimer=function(){var e=function(){$.ajax(createUrl('title','ping',0))},i=5;window.setInterval(e,i*60*1000)};this.loadNewAction=function(e,i,t,a){var n={action:e,method:i,id:t,data:a};History.toHistory(n);$('#workbench .view-loader').each(function(i){var n=$(this),s=n.data('method'),o=createUrl(e,s,t,a);n.empty().fadeTo(1,0.7).addClass('loader').html('').load(o,function(e,i,t){n.fadeTo(350,1);if(i=='error'){$(n).html('');$(n).removeClass('loader');notify('error',e);return};$(n).removeClass('loader');registerViewEvents(n)})})}};function refreshAll(){refreshTitleBar();refreshWorkbench();$('div#filler').click(function(){if($('div#dialog').hasClass('modal')){}
+;var DEFAULT_CONTENT_ACTION='edit',OR_THEMES_EXT_DIR='modules/cms-ui/themes/';$(function(){$('html').removeClass('nojs');$('.initial-hidden').removeClass('initial-hidden');refreshAll();registerHeaderEvents();$('#workbench .view').each(function(e){registerViewEvents(this)});window.onpopstate=function(e){History.fromHistory(e.state)};initActualHistoryState();Workbench.initialize();loadTree()});function initActualHistoryState(){var e={};e.name=window.document.title;e.action=$('#editor').data('action');e.id=$('#editor').data('id');History.toActualHistory(e)};var History=new function(){'use strict';this.fromHistory=function(e){var i=e.state;Workbench.loadNewAction(i.action,i.id)};this.toHistory=function(e){window.history.pushState(e,e.name,'./?action='+e.action+'&id='+e.subaction)};this.toActualHistory=function(e){window.history.replaceState(e,e.name,'./?action='+e.action+'&id='+e.subaction)}},Workbench=new function(){'use strict';this.initialize=function(){this.initializePingTimer();this.loadInitialViews()};this.loadInitialViews=function(){};this.initializePingTimer=function(){var e=function(){$.ajax(createUrl('title','ping',0))},i=5;window.setInterval(e,i*60*1000)};this.loadNewAction=function(e,i,t,a){var n={action:e,method:i,id:t,data:a};History.toHistory(n);$('#workbench .view-loader').each(function(i){var n=$(this),s=n.data('method'),o=createUrl(e,s,t,a,!0);n.empty().fadeTo(1,0.7).addClass('loader').html('').load(o,function(e,i,t){n.fadeTo(350,1);if(i=='error'){$(n).html('');$(n).removeClass('loader');notify('error',e);return};$(n).removeClass('loader');registerViewEvents(n)})})}};function refreshAll(){refreshTitleBar();refreshWorkbench();$('div#filler').click(function(){if($('div#dialog').hasClass('modal')){}
else{$('div#dialog').html('').hide();$('div#filler').fadeOut(500)}})};function refreshAllRefreshables(){$('#workbench div.panel > div.header > ul.views > li.active').each(function(){if($(this).hasClass('static'))return;var e=$(this).data('method'),i=$(this).data('action'),t=$(this).data('id'),a=$(this).data('extra');loadView($(this).closest('div.panel').find('div.content'),i,e,t,a)})};function refreshActualView(e){$(e).closest('div.panel').find('li.active').each(function(){var e=$(this).attr('data-method'),i=$(this).attr('data-action'),t=$(this).attr('data-id');loadView($(this).closest('div.panel').find('div.content'),i,e,t)})};function refreshWorkbench(){$('ul#history').empty();resizeWorkbench();$('div.modaldialog').fadeOut(500);$('#workbench').removeClass('modal');$('div#filler').fadeOut(500);$('#workbench').fadeIn(750).find('li.active').each(function(){var i=$(this).attr('data-method'),e=$(this).attr('data-action');if(e)loadView($(this).closest('div.panel').find('div.content'),e,i,0)});$('div.backward_link').click(function(){var e=$(this).closest('div.header').find('ul.views'),i=e.find('li.action.active').prev();e.scrollTo(i,500,{'axis':'x'});i.click()});$('div.forward_link').click(function(){var e=$(this).closest('div.header').find('ul.views'),i=e.find('li.action.active').next();e.scrollTo(i,500,{'axis':'x'});i.click()});registerWorkbenchEvents();$(window).resize(function(){resizeWorkbench()})};function registerWorkbenchEvents(){$('ul.views > li.action').draggable({cursor:'move',revert:'invalid'});$('ul.views').droppable({accept:'li.action',hoverClass:'drophover',activeClass:'dropactive',drop:function(e,i){var a=i.draggable,s=$(this),n=a.parent();if($(a).closest('div.panel').attr('id')==$(s).closest('div.panel').attr('id'))$(a).css({top:0,left:0});else $(a).detach().css({top:0,left:0}).appendTo(s).click();if(n.find('li').size()==0){var t=n.closest('div.container');n.closest('div.panel').remove();if(t.hasClass('autosize'))t.children('div.panel').addClass('autosize').removeClass('resizable');else t.children('div.panel').addClass('resizable').removeClass('autosize');t.replaceWith(t.children('div.panel'));resizeWorkbench()}}});$('div.content').droppable({accept:'li.action',hoverClass:'drophover',activeClass:'dropactive',drop:function(e,i){var n=i.draggable,s=$(this),d=n.parent(),o=n.offset(),r=s.offset(),f=o.left-r.left,v=r.left+s.width()-o.left,l=o.top-r.top,c=r.top+s.height()-o.top,t=$('<div class="container"><div class="first" /><div class="divider" /><div class="second"></div>');if(f<Math.min(v,Math.min(l,c))){t.addClass('axle-x');t.children('div.divider').addClass('to-right');t.children('div.first').removeClass('first').addClass('resizable');t.children('div.second').removeClass('first').addClass('autosize')}
else if(v<Math.min(l,c)){t.addClass('axle-x');t.children('div.divider').addClass('to-left');t.children('div.first').removeClass('first').addClass('autosize');t.children('div.second').removeClass('first').addClass('resizable')}
else if(l<c){t.addClass('axle-y');t.children('div.divider').addClass('to-bottom');t.children('div.first').removeClass('first').addClass('resizable');t.children('div.second').removeClass('first').addClass('autosize')}
@@ -8,6 +8,6 @@ else if(Notification.permission!=='denied'){Notification.requestPermission(funct
else{o.moveStart('character',i.length+n.length+t.length)};o.select()}
else if(typeof a.selectionStart!='undefined'){var r=a.selectionStart,d=a.selectionEnd,n=a.value.substring(r,d);a.value=a.value.substr(0,r)+i+n+t+a.value.substr(d);var s;if(n.length==0){s=r+i.length}
else{s=r+i.length+n.length+t.length};a.selectionStart=s;a.selectionEnd=s}
-else{s=a.value.length;var n=prompt('Text');a.value=a.value.substr(0,s)+i+n+t+a.value.substr(s)}};function createUrl(e,i,t,a){var n='./';n+='?action='+e+';';if(i!=null)n+='&subaction='+i+';';n+='&id='+t;if(typeof a==='string'){jQuery.each(jQuery.parseJSON(a),function(e,i){n=n+'&'+e+'='+i})}
+else{s=a.value.length;var n=prompt('Text');a.value=a.value.substr(0,s)+i+n+t+a.value.substr(s)}};function createUrl(e,i,t,a,s){var n='./';n+='?action='+e;if(i!=null)n+='&subaction='+i;n+='&id='+t;if(s)n+='&embed=1';if(typeof a==='string'){jQuery.each(jQuery.parseJSON(a),function(e,i){n=n+'&'+e+'='+i})}
else if(typeof a==='object'){jQuery.each(a,function(e,i){n=n+'&'+e+'='+i})}
else{};return n};function resizeWorkbenchContainer(e){};function resizeWorkbench(){};function resizeTabs(e){};function help(e,i,t){var a=$(e).closest('div.panel').find('li.action.active').attr('data-action'),n=$(e).closest('div.panel').find('li.action.active').attr('data-method');window.open(i+a+'/'+n+t,'OpenRat_Help','location=no,menubar=no,scrollbars=yes,toolbar=no,resizable=yes')};function notify(e,i){var t=$('<div class="notice '+e+'"><div class="text">'+i+'</div></div>');$('#noticebar').prepend(t);notifyBrowser(i);$(t).fadeIn().click(function(){$(this).fadeOut('fast',function(){$(this).remove()})})};
\ No newline at end of file
diff --git a/modules/template-engine/components/html/form/Form.class.php b/modules/template-engine/components/html/form/Form.class.php
@@ -25,7 +25,7 @@ class FormComponent extends Component
public $enctype = 'application/x-www-form-urlencoded';
- public $async = false;
+ public $async = true;
public $autosave = false;
@@ -57,6 +57,7 @@ class FormComponent extends Component
// Enable Submit on Enter
echo '<input type="submit" class="invisible" />';
+ echo '<input type="hidden" name="<?php echo REQ_PARAM_EMBED ?>" value="'.$this->htmlvalue($this->async).'" />';
echo '<input type="hidden" name="<?php echo REQ_PARAM_TOKEN ?>" value="<?php echo token() ?>" />';
echo '<input type="hidden" name="<?php echo REQ_PARAM_ACTION ?>" value="' . $this->htmlvalue($this->action) . '" />';
echo '<input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="' . $this->htmlvalue($this->subaction) . '" />';