openrat-cms

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

commit 54dcc6aa939f58e0ad92b26c98752106defb5ea9
parent f2cbb2336da17f775f9d6ee945a38b7195716927
Author: Jan Dankert <devnull@localhost>
Date:   Sat, 22 Sep 2012 04:35:02 +0200

Unterstützung für GET-Requests aus Formularen, damit Werte an eine andere View übertragen werden können.

Diffstat:
action/PageelementAction.class.php | 2+-
themes/default/include/html/form.inc.php | 2+-
themes/default/js/openrat.js | 63++++++++++++++++++++++++++++++++++++++++++++++++---------------
themes/default/templates/pageelement/archive.tpl.src.xml | 92+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
themes/default/templates/pageelement/diff.tpl.src.xml | 52++++++++++++++++++++++++++++++++++++++++++++++++----
5 files changed, 186 insertions(+), 25 deletions(-)

diff --git a/action/PageelementAction.class.php b/action/PageelementAction.class.php @@ -761,7 +761,7 @@ class PageelementAction extends Action /** * Vergleicht 2 Versionen eines Inhaltes */ - function diff() + function diffView() { $value1id = $this->getRequestVar('compareid'); $value2id = $this->getRequestVar('withid' ); diff --git a/themes/default/include/html/form.inc.php b/themes/default/include/html/form.inc.php @@ -48,7 +48,7 @@ <input type="hidden" name="<?php echo REQ_PARAM_TOKEN ?>" value="<?php echo token() ?>" /> <input type="hidden" name="<?php echo REQ_PARAM_ACTION ?>" value="<?php echo $this->actionName ?>" /> -<input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="<?php echo $this->subActionName ?>" /> +<input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="<?php echo empty($attr_subaction)?$this->subActionName:$attr_subaction ?>" /> <input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo $this->getRequestId() ?>" /><?php if ( $conf['interface']['url_sessionid'] ) echo '<input type="hidden" name="'.session_name().'" value="'.session_id().'" />'."\n"; diff --git a/themes/default/js/openrat.js b/themes/default/js/openrat.js @@ -783,21 +783,42 @@ function formSubmit(form) var params = $(form).serializeArray(); var url = './dispatcher.php'; // Alle Parameter befinden sich im Formular - $.ajax( { 'type':'POST',url:url, data:params, success:function(data, textStatus, jqXHR) - { - $(status).find('div.loader').remove(); - doResponse(data,textStatus,form); - }, - error:function(jqXHR, textStatus, errorThrown) { - $(status).find('div.loader').remove(); - alert( errorThrown ); - } - - } ); - $(form).fadeIn(); + var method = $(form).attr('method').toUpperCase(); + if ( method == 'GET' ) + { + var method = $(form).closest('div.frame').attr('data-method'); + var p = $(form).closest('div.frame'); + var action = p.attr('data-action'); + var id = p.attr('data-id'); + //alert(method+'/'+action+'/'+id); + loadView( $(form).closest('div.content'),createUrl(action,method,id,params)); + } + else + { + $.ajax( { 'type':'POST',url:url, data:params, success:function(data, textStatus, jqXHR) + { + $(status).find('div.loader').remove(); + doResponse(data,textStatus,form); + }, + error:function(jqXHR, textStatus, errorThrown) { + $(status).find('div.loader').remove(); + alert( 'OpenRat: Error while performing the POST request: ' + errorThrown ); + } + + } ); + $(form).fadeIn(); + } } + +/** + * HTTP-Antwort auf einen POST-Request auswerten. + * + * @param data Formulardaten + * @param status Status + * @param element + */ function doResponse(data,status,element) { if ( status != 'success' ) @@ -1049,14 +1070,26 @@ function loadWindow( el, actionName, subactionName ) function createUrl(action,subaction,id,extraid) { - var url = './dispatcher.php?action='+action+'&subaction='+subaction+'&id='+id; - if ( extraid !== undefined ) + var url = './dispatcher.php'; + if ( typeof extraid === 'string') { + url += '?action='+action+'&subaction='+subaction+'&id='+id; jQuery.each(jQuery.parseJSON(extraid), function(name, value) { url = url + '&' + name + '=' + value; }); - } + else if ( typeof extraid === 'object') + { + url += '?0=0'; + jQuery.each(extraid, function(name, field) { + url = url + '&' + field.name + '=' + field.value; + }); + } + else + { + url += '?action='+action+'&subaction='+subaction+'&id='+id; + } + return url; } diff --git a/themes/default/templates/pageelement/archive.tpl.src.xml b/themes/default/templates/pageelement/archive.tpl.src.xml @@ -1,3 +1,87 @@ -<output xmlns="http://www.openrat.de/template" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.openrat.de/template ../template.xsd"><dummy><form><window><fieldset><table widths="5%,5%,5%,15%,15%,35%,10%,10%"><row class="headline"><cell class="help"><text text="GLOBAL_NR"></text></cell><cell class="help" colspan="2"><if present="compareid"><text text="GLOBAL_COMPARE"></text></if></cell><cell class="help"><text text="DATE"></text></cell><cell class="help"><text text="GLOBAL_USER"></text></cell><cell class="help"><text text="GLOBAL_VALUE"></text></cell><cell class="help"><text text="GLOBAL_STATE"></text></cell><cell class="help"><text text="GLOBAL_ACTION"></text></cell></row><if empty="el"><row><cell colspan="8"><text text="GLOBAL_NOT_FOUND"></text></cell></row></if><list list="el" extract="true"><row class="data"><cell><text var="lfd_nr"></text></cell><cell><if present="compareid"><radio name="compareid" value="var:id"></radio></if></cell><cell><if present="compareid"><radio name="withid" value="var:id"></radio></if></cell><cell><date date="var:date"></date></cell><cell><text var="user"></text></cell><cell><text var="value"></text></cell><cell><if true="var:public"><text key="GLOBAL_PUBLIC" type="strong"></text></if><else><if present="releaseUrl"><link url="var:releaseUrl" title="message:GLOBAL_RELEASE_DESC"><text key="GLOBAL_RELEASE" type="strong"></text></link></if><else><text key="GLOBAL_INACTIVE" type="emphatic"></text></else></else></cell><cell><if true="var:active"><text key="GLOBAL_ACTIVE" type="emphatic"></text></if><else><if present="useUrl"><link url="var:useUrl" title="message:GLOBAL_USE_DESC"><text key="GLOBAL_USE"></text></link></if></else></cell></row></list></table></fieldset><if present="compareid"><row><cell colspan="8" class="act"><button type="ok"></button></cell></row></if></window></form></dummy></output>- \ No newline at end of file +<output xmlns="http://www.openrat.de/template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.openrat.de/template ../template.xsd"> + <form method="get" subaction="diff"> + <table widths="5%,5%,5%,15%,15%,35%,10%,10%"> + <row class="headline"> + <cell class="help"> + <text text="GLOBAL_NR"></text> + </cell> + <cell class="help" colspan="2"> + <if present="compareid"> + <text text="GLOBAL_COMPARE"></text> + </if> + </cell> + <cell class="help"> + <text text="DATE"></text> + </cell> + <cell class="help"> + <text text="GLOBAL_USER"></text> + </cell> + <cell class="help"> + <text text="GLOBAL_VALUE"></text> + </cell> + <cell class="help"> + <text text="GLOBAL_STATE"></text> + </cell> + <cell class="help"> + <text text="GLOBAL_ACTION"></text> + </cell> + </row> + <if empty="el"> + <row> + <cell colspan="8"> + <text text="GLOBAL_NOT_FOUND"></text> + </cell> + </row> + </if> + <list list="el" extract="true"> + <row class="data"> + <cell> + <text var="lfd_nr"></text> + </cell> + <cell> + <if present="compareid"> + <radio name="compareid" value="var:id"></radio> + </if> + </cell> + <cell> + <if present="compareid"> + <radio name="withid" value="var:id"></radio> + </if> + </cell> + <cell> + <date date="var:date"></date> + </cell> + <cell> + <text var="user"></text> + </cell> + <cell> + <text var="value"></text> + </cell> + <cell> + <if true="var:public"> + <text key="GLOBAL_PUBLIC" type="strong"></text> + </if> + <else><if present="releaseUrl"><link url="var:releaseUrl" title="message:GLOBAL_RELEASE_DESC"><text + key="GLOBAL_RELEASE" type="strong"></text></link></if><else><text + key="GLOBAL_INACTIVE" type="emphatic"></text></else></else> + </cell> + <cell> + <if true="var:active"> + <text key="GLOBAL_ACTIVE" type="emphatic"></text> + </if> + <else><if present="useUrl"><link url="var:useUrl" title="message:GLOBAL_USE_DESC"><text + key="GLOBAL_USE"></text></link></if></else> + </cell> + </row> + </list> + </table> + <if present="compareid"> + <row> + <cell colspan="8" class="act"> + <button type="ok"></button> + </cell> + </row> + </if> + </form> +</output>+ \ No newline at end of file diff --git a/themes/default/templates/pageelement/diff.tpl.src.xml b/themes/default/templates/pageelement/diff.tpl.src.xml @@ -1,3 +1,47 @@ -<output xmlns="http://www.openrat.de/template" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.openrat.de/template ../template.xsd"><dummy><form><window><fieldset><table><row><cell></cell><cell><text type="emphatic" text="GLOBAL_COMPARE"></text><text raw="_"></text><date date="var:date_left"></date></cell><cell></cell><cell><text type="emphatic" text="GLOBAL_WITH"></text><text raw="_"></text><date date="var:date_right"></date></cell></row><row><cell colspan="4"></cell></row><list list="diff" extract="true"><row class="diff"><if present="left"><cell width="5%" class="line"><text value="arrayvar:left:line" type="tt"></text></cell><cell width="45%" class="arrayvar:left:type"><text value="arrayvar:left:text"></text></cell></if><else><cell colspan="2" class="help" width="50%"><text raw="_"></text></cell></else><if present="right"><cell width="5%" class="line"><text value="arrayvar:right:line" type="tt"></text></cell><cell width="45%" class="arrayvar:right:type"><text value="arrayvar:right:text"></text></cell></if><else><cell colspan="2" class="help" width="50%"><text raw="_"></text></cell></else></row><set var="left"></set><set var="right"></set></list></table></fieldset><button text="BUTTON_BACK"></button></window></form></dummy></output>- \ No newline at end of file +<output xmlns="http://www.openrat.de/template" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.openrat.de/template ../template.xsd"> + <table> + <row> + <cell></cell> + <cell> + <text type="emphatic" text="GLOBAL_COMPARE"></text> + <text raw="_"></text> + <date date="var:date_left"></date> + </cell> + <cell></cell> + <cell> + <text type="emphatic" text="GLOBAL_WITH"></text> + <text raw="_"></text> + <date date="var:date_right"></date> + </cell> + </row> + <row> + <cell colspan="4"></cell> + </row> + <list list="diff" extract="true"> + <row class="diff"> + <if present="left"> + <cell width="5%" class="line"> + <text value="arrayvar:left:line" type="tt"></text> + </cell> + <cell width="45%" class="arrayvar:left:type"> + <text value="arrayvar:left:text"></text> + </cell> + </if> + <else><cell colspan="2" class="help" width="50%"><text raw="_"></text></cell></else> + <if present="right"> + <cell width="5%" class="line"> + <text value="arrayvar:right:line" type="tt"></text> + </cell> + <cell width="45%" class="arrayvar:right:type"> + <text value="arrayvar:right:text"></text> + </cell> + </if> + <else><cell colspan="2" class="help" width="50%"><text raw="_"></text></cell></else> + </row> + <set var="left"></set> + <set var="right"></set> + </list> + </table> + <button text="BUTTON_BACK"></button> +</output>+ \ No newline at end of file