Merge lp:~vierbergenlars/remotecp-panel/jqueryui-sortable into lp:remotecp-panel/1.x
- jqueryui-sortable
- Merge into 1.x
Proposed by
Lars Vierbergen
Status: | Merged |
---|---|
Approved by: | Lars Vierbergen |
Approved revision: | 105 |
Merged at revision: | 99 |
Proposed branch: | lp:~vierbergenlars/remotecp-panel/jqueryui-sortable |
Merge into: | lp:remotecp-panel/1.x |
Diff against target: |
304 lines (+172/-8) 9 files modified
panel.php (+1/-0) scripts.php (+6/-1) scripts/permanent/sortable.js (+35/-0) system/plugins/cms/default.php (+37/-1) system/plugins/cms/scripts.php (+25/-1) system/plugins/col1/default.php (+16/-3) system/plugins/col1/scripts.php (+18/-0) system/plugins/col3/default.php (+16/-2) system/plugins/col3/scripts.php (+18/-0) |
To merge this branch: | bzr merge lp:~vierbergenlars/remotecp-panel/jqueryui-sortable |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Lars Vierbergen | Approve | ||
Review via email: mp+53164@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Lars Vierbergen (vierbergenlars) : | # |
review:
Approve
Revision history for this message
Lars Vierbergen (vierbergenlars) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'panel.php' |
2 | --- panel.php 2011-03-11 19:05:58 +0000 |
3 | +++ panel.php 2011-03-14 18:38:09 +0000 |
4 | @@ -36,6 +36,7 @@ |
5 | #tabs li .ui-icon-close { float: left; margin: 0.4em 0.2em 0 0; cursor: pointer; } |
6 | #tabs div a {cursor: pointer; text-decoration: underline; color: blue;} |
7 | .ui-progressbar-value { background-image: url(<?php echo URL_JQUERY; ?>/images/pbar-ani.gif); } |
8 | + .ui-sortable { list-style: none; padding: 1 em;} |
9 | </style> |
10 | <script language="JavaScript"> |
11 | window.onerror=function(msg, url, line) {$('#dlg_js-e').dialog('open'); $('#dlg_js-e').append('<div class="ui-state-highlight ui-corner-all" style="margin-top: 20px; padding: 0 .7em;"><p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>Fout beschrijving: <tt>!JS['+url+':'+line+'::'+msg+']!</tt></p></div>')} |
12 | |
13 | === modified file 'scripts.php' |
14 | --- scripts.php 2011-03-11 16:42:13 +0000 |
15 | +++ scripts.php 2011-03-14 18:38:09 +0000 |
16 | @@ -1,6 +1,11 @@ |
17 | <?php //@./scripts.php ?> |
18 | <?php |
19 | -$FILES=array('jquery/js/jquery.min.js','jquery/js/jquery-ui.min.js','scripts/permanent/prototypes.js','scripts/permanent/ajax.js','scripts/permanent/messages.js'); //Scripts to load |
20 | +$FILES=array('jquery/js/jquery.min.js','jquery/js/jquery-ui.min.js'); //Scripts to load |
21 | +$pfiles=scandir('scripts/permanent'); //Load all permanent scripts |
22 | +foreach($pfiles as $pfile) { |
23 | + if($pfile=='..'||$pfile=='.') continue; |
24 | + $FILES[]='scripts/permanent/'.$pfile; |
25 | +} |
26 | header('Content-Type: text/javascript'); |
27 | ob_start("ob_gzhandler"); |
28 | foreach($FILES as $file) { |
29 | |
30 | === added file 'scripts/permanent/sortable.js' |
31 | --- scripts/permanent/sortable.js 1970-01-01 00:00:00 +0000 |
32 | +++ scripts/permanent/sortable.js 2011-03-14 18:38:09 +0000 |
33 | @@ -0,0 +1,35 @@ |
34 | +function tableToSortable(obj,useCell,sortprops) { |
35 | + id=obj.attr('id'); |
36 | + if(id==undefined||id=='') { |
37 | + id=Math.round(Math.random()*10E16); |
38 | + obj.attr('id',id); |
39 | + } |
40 | + rows=obj.find('tr').get(); |
41 | + mainclass=obj.attr('class'); |
42 | + html=''; |
43 | + for(i=0;i<rows.length;i++) { |
44 | + cell=$(rows[i]).children('td').get(useCell); |
45 | + if(cell==undefined) continue; |
46 | + origclass=$(rows[i]).attr('class'); |
47 | + if(origclass.match('gui-nosort')) origclass+=' ui-state-disabled'; |
48 | + origid=$(rows[i]).attr('id'); |
49 | + orightml=$(cell).html(); |
50 | + html+='<li class="'+origclass+' ui-state-default" id="'+origid+'">'+orightml+'</li>'; |
51 | + } |
52 | + obj.after('<ul class="'+mainclass+'" id="'+id+'_new" style="display: none; width: 200px">'+html+'</ul>'); |
53 | + obj.hide('blind','slow',function() { |
54 | + obj.detach(); |
55 | + $('#'+id+'_new').attr('id',id); |
56 | + }); |
57 | + $('#'+id+'_new').sortable(sortprops); |
58 | + $('#'+id+'_new').show('blind','slow'); |
59 | +} |
60 | +function multiSortableToArray(obj) { |
61 | + end=new Array(); |
62 | + main=obj.sortable('toArray'); |
63 | + for(i=0;i<main.length;i++) { |
64 | + sub=$('#'+main[i]+' .sub-sortable').sortable('toArray'); |
65 | + end.push(sub); |
66 | + } |
67 | + return new Array(main,end); |
68 | +} |
69 | \ No newline at end of file |
70 | |
71 | === modified file 'system/plugins/cms/default.php' |
72 | --- system/plugins/cms/default.php 2011-02-22 19:58:54 +0000 |
73 | +++ system/plugins/cms/default.php 2011-03-14 18:38:09 +0000 |
74 | @@ -27,7 +27,25 @@ |
75 | <?php } }?> |
76 | <tr onclick="cms.page.add('<?php echo $site; ?>')"><td><img src="<?php echo URL_IMG; ?>/Silk/bullet_add.png" alt=""></td><td colspan="4"><?php echo $t->_('Add page'); ?></td></tr> |
77 | <tr onclick="cms.page.add_link('<?php echo $site; ?>')"><td><img src="<?php echo URL_IMG; ?>/Silk/link_add.png" alt=""></td><td colspan="4"><?php echo $t->_('Add link'); ?></td></tr> |
78 | - </table> |
79 | + </table> |
80 | + <ul style='display: none';> |
81 | + <?php $pagesq = cms::get_pages(); foreach($pagesq as $pages) { ?> |
82 | + <li class='ui-state-default' id='sort_<?php echo $site; ?>_cms_<?php echo $pages['id']; ?>'><?php echo $pages['page_title']; |
83 | + if($pages['type']==0||$pages['type']==2) { ?> |
84 | + <ul class='sort_<?php echo $site; ?>_cms_sub sub-sortable'> |
85 | + <?php $sectionsq=cms::get_sections($pages['id']); foreach($sectionsq as $sections) { ?> |
86 | + <li class='ui-state-default' id='sort_<?php echo $site; ?>_cms_sub_<?php echo $sections['id']; ?>'><?php echo $sections['section_title']; ?></li> |
87 | + <?php } ?> |
88 | + <li class='gui-nosort ui-state-disabled ui-state-default'><?php echo $t->_('Add a section to this page'); ?></li> |
89 | + </ul> |
90 | + <?php } ?> |
91 | + </li> |
92 | + <?php } ?> |
93 | + <li class='gui-nosort ui-state-disabled ui-state-default'><?php echo $t->_('Add page'); ?></li> |
94 | + <li class='gui-nosort ui-state-disabled ui-state-default'><?php echo $t->_('Add link'); ?></li> |
95 | + </ul> |
96 | + <input type='button' onclick='$(this).prevAll("table").hide("blind","slow");$(this).prev("ul").show("blind","slow").sortable({items:"li:not(.gui-nosort,li li)"});$(".sort_<?php echo $site; ?>_cms_sub").sortable({items:"li:not(.gui-nosort)",connectWith:".sort_<?php echo $site; ?>_cms_sub"});$(this).next().show("blind","slow");$(this).hide("blind","slow")' value='<?php echo $t->_('Sort'); ?>'> <input type='button' onclick='cms.sort("<?php echo $site; ?>",multiSortableToArray($(this).prevAll("ul")))' value='<?php echo $t->_('Save this order'); ?>' style='display:none'> |
97 | + |
98 | <?php } |
99 | else if($_GET['function']=="delete") { |
100 | if($_GET['type']=="page" && $_GET['id']!=1) { |
101 | @@ -62,6 +80,24 @@ |
102 | if($q) echo "true"; |
103 | else echo "false"; |
104 | } |
105 | +} |
106 | +else if($_GET['function']=='sort') { |
107 | + if(!isset($_POST['order_main'],$_POST['order_sub'])) echo "false"; |
108 | + else { |
109 | + $page_length=count($_POST['order_main']); |
110 | + for($i=0;$i<$page_length;$i++) { |
111 | + $x[]=$remote_connection->query('UPDATE `'.$site.'_pageindex` SET `page_order`='.$i.' WHERE `id`='.$_POST['order_main'][$i]); |
112 | + } |
113 | + foreach($_POST['order_sub'] as $pageid=>$sections) { |
114 | + $sect_length=count($sections); |
115 | + for($i=0;$i<$sect_length;$i++) { |
116 | + $x[]=$remote_connection->query('UPDATE `'.$site.'_pages` SET `page_id`='.$pageid.', `section_order`='.$i.' WHERE `id`='.$sections[$i]); |
117 | + } |
118 | + } |
119 | + if(!in_array(false,$x,true)) echo "true"; |
120 | + else echo "false"; |
121 | + } |
122 | + |
123 | } |
124 | else if($_GET['function']=="new") { |
125 | if($_GET['type']=="page") { |
126 | |
127 | === modified file 'system/plugins/cms/scripts.php' |
128 | --- system/plugins/cms/scripts.php 2011-01-30 17:23:45 +0000 |
129 | +++ system/plugins/cms/scripts.php 2011-03-14 18:38:09 +0000 |
130 | @@ -198,7 +198,7 @@ |
131 | success=ajax.get('?control=addons&site='+site+'&aref=cms&function=edit_title&type=section&id='+id+'&title='+cont.value); |
132 | if(success=="true") { |
133 | alert('<?php echo $t->_('Title saved'); ?>'); |
134 | - cms.section.edit_title.collapse(cont); |
135 | + refreshCurrentTab(); |
136 | } |
137 | else if(success=="false") { |
138 | alert('<?php echo $t->_('Error saving title'); ?>'); |
139 | @@ -309,5 +309,29 @@ |
140 | } |
141 | |
142 | } |
143 | + }, |
144 | + sort: function(site,order_array) { |
145 | + main=order_array[0]; |
146 | + sub=order_array[1]; |
147 | + q=''; |
148 | + for(i=0;i<main.length;i++) { |
149 | + pageid=main[i].substr(main[i].lastIndexOf('_')+1); |
150 | + q+='&order_main['+i+']='+pageid; |
151 | + thissub=sub[i] |
152 | + for(j=0;j<thissub.length;j++) { |
153 | + q+='&order_sub['+pageid+']['+j+']='+thissub[j].substr(thissub[j].lastIndexOf('_')+1); |
154 | + } |
155 | + } |
156 | + success=ajax.post('?control=addons&site='+site+'&aref=cms&function=sort','a=0'+q); |
157 | + if(success=="true") { |
158 | + alert('<?php echo $t->_('Pages reordered'); ?>'); |
159 | + refreshCurrentTab(); |
160 | + } |
161 | + else if(success=="false") { |
162 | + alert('<?php echo $t->_('Error reordering pages'); ?>'); |
163 | + } |
164 | + else { |
165 | + alert('FATAL ERROR:'+success); |
166 | + } |
167 | } |
168 | } |
169 | \ No newline at end of file |
170 | |
171 | === modified file 'system/plugins/col1/default.php' |
172 | --- system/plugins/col1/default.php 2011-02-22 19:58:54 +0000 |
173 | +++ system/plugins/col1/default.php 2011-03-14 18:38:09 +0000 |
174 | @@ -17,10 +17,11 @@ |
175 | $query = col1::gets(); ?> |
176 | <table><tr><th></th><th><?php echo $t->_('Title'); ?></th><th><?php echo $t->_('Actions'); ?></th></tr> |
177 | <?php foreach($query as $section) {?> |
178 | - <tr><td<?php if($section['plugin-reference']==NULL) { ?> ondblclick="col1.edit_rights.expand('<?php echo $site; ?>','<?php echo $section['id']; ?>',this,'<?php echo $section['access']; ?>')"><img src="<?php echo URL_IMG; ?>/Silk/bullet_<?php if($section['access']==0) { ?>green<?php } else if($section['access']==1) { ?>orange<?php } else if($section['access']==2) { ?>red<?php } ?>.png"> <?php } else { ?>><img src="<?php echo URL_IMG; ?>/Silk/bullet_black.png" alt=""><?php } ?></td><td ondblclick="col1.edit_title.expand('<?php echo $site; ?>','<?php echo $section['id']; ?>',this)"><?php echo $section['title']; ?></td><td><?php if($section['plugin-reference']==NULL) { ?><a onclick="col1.delete('<?php echo $site; ?>','<?php echo $section['id'] ?>');"><img src="<?php echo URL_IMG; ?>/Silk/delete.png" alt="<?php echo $t->_('Delete'); ?>" title="<?php echo $t->_('Delete section'); ?>"></a> <?php } ?><a onclick="col1.edit_order.down('<?php echo $site; ?>','<?php echo $section['id'];?>',this);"><img src="<?php echo URL_IMG ?>/Silk/arrow_down.png" alt="<?php echo $t->_('Down'); ?>" title="<?php echo $t->_('Move section down'); ?>"></a> <a onclick="col1.edit_order.up('<?php echo $site; ?>','<?php echo $section['id']; ?>');"><img src="<?php echo URL_IMG ?>/Silk/arrow_up.png" alt="<?php echo $t->_('Up'); ?>" title="<?php echo $t->_('Move section up'); ?>"></a><?php if($section['plugin-reference']==NULL) { ?> <a onclick="col1.open_mce('<?php echo $site; ?>','<?php echo $section['id']; ?>');"><img src="<?php echo URL_IMG; ?>/Silk/pencil.png" alt="<?php echo $t->_('Edit'); ?>" title="<?php echo $t->_('Edit section content'); ?>"></a><?php } ?></td></tr> |
179 | + <tr id='sort_<?php echo $site; ?>_col1_<?php echo $section['id']; ?>'><td<?php if($section['plugin-reference']==NULL) { ?> ondblclick="col1.edit_rights.expand('<?php echo $site; ?>','<?php echo $section['id']; ?>',this,'<?php echo $section['access']; ?>')"><img src="<?php echo URL_IMG; ?>/Silk/bullet_<?php if($section['access']==0) { ?>green<?php } else if($section['access']==1) { ?>orange<?php } else if($section['access']==2) { ?>red<?php } ?>.png"> <?php } else { ?>><img src="<?php echo URL_IMG; ?>/Silk/bullet_black.png" alt=""><?php } ?></td><td ondblclick="col1.edit_title.expand('<?php echo $site; ?>','<?php echo $section['id']; ?>',this)"><?php echo $section['title']; ?></td><td><?php if($section['plugin-reference']==NULL) { ?><a onclick="col1.delete('<?php echo $site; ?>','<?php echo $section['id'] ?>');"><img src="<?php echo URL_IMG; ?>/Silk/delete.png" alt="<?php echo $t->_('Delete'); ?>" title="<?php echo $t->_('Delete section'); ?>"></a> <?php } ?><a onclick="col1.edit_order.down('<?php echo $site; ?>','<?php echo $section['id'];?>',this);"><img src="<?php echo URL_IMG ?>/Silk/arrow_down.png" alt="<?php echo $t->_('Down'); ?>" title="<?php echo $t->_('Move section down'); ?>"></a> <a onclick="col1.edit_order.up('<?php echo $site; ?>','<?php echo $section['id']; ?>');"><img src="<?php echo URL_IMG ?>/Silk/arrow_up.png" alt="<?php echo $t->_('Up'); ?>" title="<?php echo $t->_('Move section up'); ?>"></a><?php if($section['plugin-reference']==NULL) { ?> <a onclick="col1.open_mce('<?php echo $site; ?>','<?php echo $section['id']; ?>');"><img src="<?php echo URL_IMG; ?>/Silk/pencil.png" alt="<?php echo $t->_('Edit'); ?>" title="<?php echo $t->_('Edit section content'); ?>"></a><?php } ?></td></tr> |
180 | <?php } ?> |
181 | - <tr onclick="col1.add('<?php echo $site; ?>')"><td><img src="<?php echo URL_IMG; ?>/Silk/bullet_add.png" alt=""></td><td colspan="2"><?php echo $t->_('Add section'); ?></td></tr> |
182 | + <tr class='gui-nosort' onclick="col1.add('<?php echo $site; ?>')"><td><img src="<?php echo URL_IMG; ?>/Silk/bullet_add.png" alt=""></td><td colspan="2"><?php echo $t->_('Add section'); ?></td></tr> |
183 | </table> |
184 | + <input type='button' onclick='tableToSortable($(this).prev("table"),1,{items:"li:not(.gui-nosort)"});$(this).next().show("blind","slow");$(this).hide("blind","slow")' value='<?php echo $t->_('Sort'); ?>'> <input type='button' onclick='col1.sort("<?php echo $site; ?>",$(this).prevAll("ul").sortable("toArray"))' value='<?php echo $t->_('Save this order'); ?>' style='display:none'> |
185 | <?php } |
186 | else if($_GET['function']=="delete") { |
187 | if(col1::delete($_GET['id'])) echo "true"; |
188 | @@ -33,7 +34,19 @@ |
189 | else if($_GET['function']=="move") { |
190 | if($_GET['move']=="up") $q=col1::move($_GET['id'],1); |
191 | else if($_GET['move']=="down") $q=col1::move($_GET['id'],-1); |
192 | -} |
193 | +} |
194 | +else if($_GET['function']='sort') { |
195 | + if(!isset($_POST['order'])) echo "false"; |
196 | + else { |
197 | + $sect_length=count($_POST['order']); |
198 | + for($i=0;$i<$sect_length;$i++) { |
199 | + $x[]=$remote_connection->query('UPDATE `'.$site.'_col1` SET `order`='.$i.' WHERE `id`='.$_POST['order'][$i]); |
200 | + } |
201 | + if(!in_array(false,$x,true)) echo "true"; |
202 | + else echo "false"; |
203 | + } |
204 | + |
205 | +} |
206 | else if($_GET['function']=="new") { |
207 | if(col1::add(array('title'=>$t->_('New section')))) echo "true"; |
208 | else echo "false"; |
209 | |
210 | === modified file 'system/plugins/col1/scripts.php' |
211 | --- system/plugins/col1/scripts.php 2011-01-30 17:23:45 +0000 |
212 | +++ system/plugins/col1/scripts.php 2011-03-14 18:38:09 +0000 |
213 | @@ -82,6 +82,24 @@ |
214 | alert('FATAL ERROR:'+success); |
215 | } |
216 | }, |
217 | + sort: function(site,new_order) { |
218 | + q=''; |
219 | + for(i=0;i<new_order.length;i++) { |
220 | + id=new_order[i].substr(new_order[i].lastIndexOf('_')+1); |
221 | + q+='&order[]='+id; |
222 | + } |
223 | + success=ajax.post('?control=addons&site='+site+'&aref=col1&function=sort','a=0'+q); |
224 | + if(success=="true") { |
225 | + alert('<?php echo $t->_('Sections reordered'); ?>'); |
226 | + refreshCurrentTab(); |
227 | + } |
228 | + else if(success=="false") { |
229 | + alert('<?php echo $t->_('Error reordering sections'); ?>'); |
230 | + } |
231 | + else { |
232 | + alert('FATAL ERROR:'+success); |
233 | + } |
234 | + }, |
235 | open_mce: function(site,id) { |
236 | window.open('?control=addons&site='+site+'&aref=col1&function=mce&id='+id); |
237 | }, |
238 | |
239 | === modified file 'system/plugins/col3/default.php' |
240 | --- system/plugins/col3/default.php 2011-02-22 19:58:54 +0000 |
241 | +++ system/plugins/col3/default.php 2011-03-14 18:38:09 +0000 |
242 | @@ -17,10 +17,12 @@ |
243 | $query = col3::gets(); ?> |
244 | <table><tr><th></th><th><?php echo $t->_('Title'); ?></th><th><?php echo $t->_('Actions'); ?></th></tr> |
245 | <?php foreach($query as $section) {?> |
246 | - <tr><td<?php if($section['plugin-reference']==NULL) { ?> ondblclick="col3.edit_rights.expand('<?php echo $site; ?>','<?php echo $section['id']; ?>',this,'<?php echo $section['access']; ?>')"><img src="<?php echo URL_IMG; ?>/Silk/bullet_<?php if($section['access']==0) { ?>green<?php } else if($section['access']==1) { ?>orange<?php } else if($section['access']==2) { ?>red<?php } ?>.png"> <?php } else { ?>><img src="<?php echo URL_IMG; ?>/Silk/bullet_black.png" alt=""><?php } ?></td><td ondblclick="col3.edit_title.expand('<?php echo $site; ?>','<?php echo $section['id']; ?>',this)"><?php echo $section['title']; ?></td><td><?php if($section['plugin-reference']==NULL) { ?><a onclick="col3.delete('<?php echo $site; ?>','<?php echo $section['id'] ?>');"><img src="<?php echo URL_IMG; ?>/Silk/delete.png" alt="<?php echo $t->_('Delete'); ?>" title="<?php echo $t->_('Delete section'); ?>"></a> <?php } ?><a onclick="col3.edit_order.down('<?php echo $site; ?>','<?php echo $section['id'];?>',this);"><img src="<?php echo URL_IMG ?>/Silk/arrow_down.png" alt="<?php echo $t->_('Down'); ?>" title="<?php echo $t->_('Move section down'); ?>"></a> <a onclick="col3.edit_order.up('<?php echo $site; ?>','<?php echo $section['id']; ?>');"><img src="<?php echo URL_IMG ?>/Silk/arrow_up.png" alt="<?php echo $t->_('Up'); ?>" title="<?php echo $t->_('Move section up'); ?>"></a><?php if($section['plugin-reference']==NULL) { ?> <a onclick="col3.open_mce('<?php echo $site; ?>','<?php echo $section['id']; ?>');"><img src="<?php echo URL_IMG; ?>/Silk/pencil.png" alt="<?php echo $t->_('Edit'); ?>" title="<?php echo $t->_('Edit section content'); ?>"></a><?php } ?></td></tr> |
247 | + <tr id='sort_<?php echo $site; ?>_col3_<?php echo $section['id']; ?>'><td<?php if($section['plugin-reference']==NULL) { ?> ondblclick="col3.edit_rights.expand('<?php echo $site; ?>','<?php echo $section['id']; ?>',this,'<?php echo $section['access']; ?>')"><img src="<?php echo URL_IMG; ?>/Silk/bullet_<?php if($section['access']==0) { ?>green<?php } else if($section['access']==1) { ?>orange<?php } else if($section['access']==2) { ?>red<?php } ?>.png"> <?php } else { ?>><img src="<?php echo URL_IMG; ?>/Silk/bullet_black.png" alt=""><?php } ?></td><td ondblclick="col3.edit_title.expand('<?php echo $site; ?>','<?php echo $section['id']; ?>',this)"><?php echo $section['title']; ?></td><td><?php if($section['plugin-reference']==NULL) { ?><a onclick="col3.delete('<?php echo $site; ?>','<?php echo $section['id'] ?>');"><img src="<?php echo URL_IMG; ?>/Silk/delete.png" alt="<?php echo $t->_('Delete'); ?>" title="<?php echo $t->_('Delete section'); ?>"></a> <?php } ?><a onclick="col3.edit_order.down('<?php echo $site; ?>','<?php echo $section['id'];?>',this);"><img src="<?php echo URL_IMG ?>/Silk/arrow_down.png" alt="<?php echo $t->_('Down'); ?>" title="<?php echo $t->_('Move section down'); ?>"></a> <a onclick="col3.edit_order.up('<?php echo $site; ?>','<?php echo $section['id']; ?>');"><img src="<?php echo URL_IMG ?>/Silk/arrow_up.png" alt="<?php echo $t->_('Up'); ?>" title="<?php echo $t->_('Move section up'); ?>"></a><?php if($section['plugin-reference']==NULL) { ?> <a onclick="col3.open_mce('<?php echo $site; ?>','<?php echo $section['id']; ?>');"><img src="<?php echo URL_IMG; ?>/Silk/pencil.png" alt="<?php echo $t->_('Edit'); ?>" title="<?php echo $t->_('Edit section content'); ?>"></a><?php } ?></td></tr> |
248 | <?php } ?> |
249 | - <tr onclick="col3.add('<?php echo $site; ?>')"><td><img src="<?php echo URL_IMG; ?>/Silk/bullet_add.png" alt=""></td><td colspan="2"><?php echo $t->_('Add section'); ?></td></tr> |
250 | + <tr class='gui-nosort' onclick="col3.add('<?php echo $site; ?>')"><td><img src="<?php echo URL_IMG; ?>/Silk/bullet_add.png" alt=""></td><td colspan="2"><?php echo $t->_('Add section'); ?></td></tr> |
251 | </table> |
252 | + <input type='button' onclick='tableToSortable($(this).prev("table"),1,{items:"li:not(.gui-nosort)"});$(this).next().show("blind","slow");$(this).hide("blind","slow")' value='<?php echo $t->_('Sort'); ?>'> <input type='button' onclick='col3.sort("<?php echo $site; ?>",$(this).prevAll("ul").sortable("toArray"))' value='<?php echo $t->_('Save this order'); ?>' style='display:none'> |
253 | + |
254 | <?php } |
255 | else if($_GET['function']=="delete") { |
256 | if(col3::delete($_GET['id'])) echo "true"; |
257 | @@ -33,6 +35,18 @@ |
258 | else if($_GET['function']=="move") { |
259 | if($_GET['move']=="up") $q=col3::move($_GET['id'],1); |
260 | else if($_GET['move']=="down") $q=col3::move($_GET['id'],-1); |
261 | +} |
262 | +else if($_GET['function']='sort') { |
263 | + if(!isset($_POST['order'])) echo "false"; |
264 | + else { |
265 | + $sect_length=count($_POST['order']); |
266 | + for($i=0;$i<$sect_length;$i++) { |
267 | + $x[]=$remote_connection->query('UPDATE `'.$site.'_col3` SET `order`='.$i.' WHERE `id`='.$_POST['order'][$i]); |
268 | + } |
269 | + if(!in_array(false,$x,true)) echo "true"; |
270 | + else echo "false"; |
271 | + } |
272 | + |
273 | } |
274 | else if($_GET['function']=="new") { |
275 | if(col3::add(array('title'=>$t->_('New section')))) echo "true"; |
276 | |
277 | === modified file 'system/plugins/col3/scripts.php' |
278 | --- system/plugins/col3/scripts.php 2011-01-30 17:23:45 +0000 |
279 | +++ system/plugins/col3/scripts.php 2011-03-14 18:38:09 +0000 |
280 | @@ -82,6 +82,24 @@ |
281 | alert('FATAL ERROR:'+success); |
282 | } |
283 | }, |
284 | + sort: function(site,new_order) { |
285 | + q=''; |
286 | + for(i=0;i<new_order.length;i++) { |
287 | + id=new_order[i].substr(new_order[i].lastIndexOf('_')+1); |
288 | + q+='&order[]='+id; |
289 | + } |
290 | + success=ajax.post('?control=addons&site='+site+'&aref=col3&function=sort','a=0'+q); |
291 | + if(success=="true") { |
292 | + alert('<?php echo $t->_('Sections reordered'); ?>'); |
293 | + refreshCurrentTab(); |
294 | + } |
295 | + else if(success=="false") { |
296 | + alert('<?php echo $t->_('Error reordering sections'); ?>'); |
297 | + } |
298 | + else { |
299 | + alert('FATAL ERROR:'+success); |
300 | + } |
301 | + }, |
302 | open_mce: function(site,id) { |
303 | window.open('?control=addons&site='+site+'&aref=col3&function=mce&id='+id); |
304 | }, |