openrat-cms

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

commit 2d81a1d7d1439fddfaaa52e3cb401671d137bc0f
parent ca46bdd1d7fe2841d11d2c99a0a5e9d37154c79e
Author: Jan Dankert <devnull@localhost>
Date:   Tue, 29 Nov 2011 00:39:15 +0100

Sortieren von Ordnerinhalten mit JQuery.

Diffstat:
action/FolderAction.class.php | 30++++++++++++++++++++++++++++++
themes/default/include/elements.ini.php | 2+-
themes/default/include/html/row.inc.php | 3+++
themes/default/js/openrat.js | 28++++++++++++++++++++++++++++
themes/default/templates/folder/order.tpl.src.xml | 88+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
5 files changed, 146 insertions(+), 5 deletions(-)

diff --git a/action/FolderAction.class.php b/action/FolderAction.class.php @@ -376,6 +376,35 @@ class FolderAction extends ObjectAction } + /** + * Reihenfolge von Objekten aendern. + */ + function orderPost() + { + $ids = $this->folder->getObjectIds(); + $seq = 0; + + $order = explode(',',$this->getRequestVar('order') ); + + foreach( $order as $objectid ) + { + if ( ! in_array($objectid,$ids) ) + { + Http::serverError('Object-Id '.$objectid.' is not in this folder any more'); + } + $seq++; // Sequenz um 1 erhoehen + + $o = new Object( $objectid ); + $o->setOrderId( $seq ); + + unset( $o ); // Selfmade Garbage Collection :-) + } + + $this->addNotice($this->folder->getType(),$this->folder->name,'SEQUENCE_CHANGED','ok'); + $this->folder->setTimestamp(); + } + + // Reihenfolge von Objekten aendern function changesequencePost() { @@ -1097,6 +1126,7 @@ class FolderAction extends ObjectAction if ( $o->hasRight(ACL_READ) ) { + $list[$id]['id' ] = $id; $list[$id]['name'] = Text::maxLaenge( 30,$o->name ); $list[$id]['filename'] = Text::maxLaenge( 20,$o->filename ); $list[$id]['desc'] = Text::maxLaenge( 30,$o->desc ); diff --git a/themes/default/include/elements.ini.php b/themes/default/include/elements.ini.php @@ -35,7 +35,7 @@ part = id,class password = name:*,default:,class:,size:40,maxlength:256 radio = readonly:false,name:*,value,default:false,prefix:,suffix:,class:,onchange:,children raw = -row = class,classes +row = class,classes,id selectbox= list:*,name:*,default,onchange:,title:,class:,addempty:false,multiple:false,size:1,lang:false radiobox = list:*,name:*,default,onchange:,title:,class: set = var:*,value,key diff --git a/themes/default/include/html/row.inc.php b/themes/default/include/html/row.inc.php @@ -5,5 +5,8 @@ #IF-ATTR class# class="%class%" #END-IF# +#IF-ATTR id# + data-id="%id%" +#END-IF# > /* Ignore: */ </tr> \ No newline at end of file diff --git a/themes/default/js/openrat.js b/themes/default/js/openrat.js @@ -170,6 +170,34 @@ function loadView(jo, url ) //alert( "up: "+$('#upassword').attr('value') ); $(jo).find('input.focus').focus(); + // Sortieren von Tabellen + $(jo).find('table.sortable > tbody').sortable({ + update: function(event, ui) + { + var order = []; + $(ui.item).closest('table.sortable').find('tbody > tr.data').each( function() { + var objectid = $(this).data('id').substring(2); + order.push( objectid ); + }); + var url = './dispatcher.php'; + var params = {}; + params.action = 'folder'; + params.subaction = 'order'; + params.token = $('#id_token').attr('value'); + params.order = order.join(','); + + $.ajax( { 'type':'POST',url:url, data:params, success:function(data, textStatus, jqXHR) + { + doResponse(data,textStatus,form); + }, + error:function(jqXHR, textStatus, errorThrown) { + alert( errorThrown ); + } + + } ); + } + }); + if ( $(jo).find('textarea#pageelement_edit_editor').length > 0 ) { var instance = CKEDITOR.instances['pageelement_edit_editor']; diff --git a/themes/default/templates/folder/order.tpl.src.xml b/themes/default/templates/folder/order.tpl.src.xml @@ -1,3 +1,83 @@ -<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><window><table><row><cell colspan="7" class="help"><text text="GLOBAL_FOLDER_DESC"></text></cell></row><row class="headline"><cell class="help" colspan="4"><link type="url" url="var:flip_url" title="message:FOLDER_FLIP"><text key="FOLDER_ORDER"></text></link></cell><cell class="help"><link type="url" url="var:orderbytype_url" title="message:FOLDER_ORDERBYTYPE"><text key="GLOBAL_TYPE"></text></link><text raw="_/_"></text><link type="url" url="var:orderbyname_url" title="message:FOLDER_ORDERBYNAME"><text key="GLOBAL_NAME"></text></link></cell><cell class="help"><link type="url" url="var:orderbylastchange_url" title="message:FOLDER_ORDERBYLASTCHANGE"><text key="GLOBAL_LASTCHANGE"></text></link></cell></row><list list="object" extract="true"><row class="data"><cell width="3%"><if present="upurl"><link type="url" url="var:upurl" title="GLOBAL_UP"><set var="bild" value="arrow_up"></set><image file="var:bild"></image></link></if><if empty="upurl"><text raw="_"></text></if></cell><cell width="3%"><if present="topurl"><link type="url" url="var:topurl" title="GLOBAL_TOP"><set var="bild" value="arrow_top"></set><image file="var:bild"></image></link></if><if empty="topurl"><text raw="_"></text></if></cell><cell width="3%"><if present="bottomurl"><link type="url" url="var:bottomurl" title="GLOBAL_BOTTOM"><set var="bild" value="arrow_bottom"></set><image file="var:bild"></image></link></if><if empty="bottomurl"><text raw="_"></text></if></cell><cell width="3%"><if present="downurl"><link type="url" url="var:downurl" title="GLOBAL_DOWN"><set var="bild" value="arrow_down"></set><image file="var:bild"></image></link></if><if empty="downurl"><text raw="_"></text></if></cell><cell width="40%"><image type="var:icon"></image><text var="name"></text></cell><cell width="18%"><date date="var:date"></date></cell></row></list></table></window></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"> + <text text="GLOBAL_FOLDER_DESC"></text> + <input type="hidden" name="token" default="function:token"></input> + <table class="sortable"> + <row class="headline"> + <cell class="help" colspan="4"> + <link type="url" url="var:flip_url" title="message:FOLDER_FLIP"> + <text key="FOLDER_ORDER"></text> + </link> + </cell> + <cell class="help"> + <link type="url" url="var:orderbytype_url" title="message:FOLDER_ORDERBYTYPE"> + <text key="GLOBAL_TYPE"></text> + </link> + <text raw="_/_"></text> + <link type="url" url="var:orderbyname_url" title="message:FOLDER_ORDERBYNAME"> + <text key="GLOBAL_NAME"></text> + </link> + </cell> + <cell class="help"> + <link type="url" url="var:orderbylastchange_url" title="message:FOLDER_ORDERBYLASTCHANGE"> + <text key="GLOBAL_LASTCHANGE"></text> + </link> + </cell> + </row> + <list list="object" extract="true"> + <row class="data" id="o_{id}"> + <cell width="3%"> + <if present="upurl"> + <link type="url" url="var:upurl" title="GLOBAL_UP"> + <set var="bild" value="arrow_up"></set> + <image file="var:bild"></image> + </link> + </if> + <if empty="upurl"> + <text raw="_"></text> + </if> + </cell> + <cell width="3%"> + <if present="topurl"> + <link type="url" url="var:topurl" title="GLOBAL_TOP"> + <set var="bild" value="arrow_top"></set> + <image file="var:bild"></image> + </link> + </if> + <if empty="topurl"> + <text raw="_"></text> + </if> + </cell> + <cell width="3%"> + <if present="bottomurl"> + <link type="url" url="var:bottomurl" title="GLOBAL_BOTTOM"> + <set var="bild" value="arrow_bottom"></set> + <image file="var:bild"></image> + </link> + </if> + <if empty="bottomurl"> + <text raw="_"></text> + </if> + </cell> + <cell width="3%"> + <if present="downurl"> + <link type="url" url="var:downurl" title="GLOBAL_DOWN"> + <set var="bild" value="arrow_down"></set> + <image file="var:bild"></image> + </link> + </if> + <if empty="downurl"> + <text raw="_"></text> + </if> + </cell> + <cell width="40%"> + <image type="var:icon"></image> + <text var="name"></text> + </cell> + <cell width="18%"> + <date date="var:date"></date> + </cell> + </row> + </list> + </table> +</output>+ \ No newline at end of file