Pman.Tab.CmsBlog.bjs
[Pman.Cms] / Pman.Tab.CmsBlog.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Pman.Tab');
6
7 Pman.Tab.CmsBlog = new Roo.XComponent({
8
9  _strings : {
10   '30a2a59b5adaa49803297d4c06e09e67' :"Displaying cms_page{0} - {1} of {2}",
11   'a517747c3d12f99244ae598910d979c5' :"Author",
12   '63a6a88c066880c5ac42394a22803ca6' :"Refresh",
13   'ec211f7c20af43e742bf2570c3cb84f9' :"Add",
14   '0eceeb45861f9585dd7a97a3e36f85c6' :"Created",
15   '695e93e1d9db8283a9dd66782625065d' :"Child Elements",
16   'ebd9bec4d70abc789d439c1f136b0538' :"Layout",
17   '30269022e9d8f51beaabb52e5d0de2b7' :"Parent",
18   'a4863ff1cdfa709d5bf80939cd2e6757' :"T#",
19   'd7efa19fbe7d3972fd5adb6024223d74' :"C#",
20   '08d0135e24822f43171ed4944fc3bdda' :"Preview (resize by dragging next to this bar)",
21   '2cbaa804531fc7367ccc699fb1eef52a' :"Page link / Name / Order",
22   '3adbdb3ac060038aa0e6e6c138ef9873' :"Category",
23   'b8a00b5928fbead0626546550667b2b5' :"Pages, Menu and Blog Entries",
24   'c8043f5cd3d28cb76c548338497b06ab' :"Show Deleted",
25   'd645920e395fedad7bbbed0eca3fe2e0' :"40",
26   'be53a0541a6d36f6ecb879fa2c584b08' :"Image",
27   '9b9d8a976b42e0bd66381797644943d5' :"Published",
28   'b78a3223503896721cca1303f776159b' :"Title",
29   'f17755c3f16cb257f7793b9865ebafb3' :"No cms_page found",
30   'a9581db07856efb481fddef1b3e168f8' :"No page found",
31   'ce5bf551379459c1c61d2a204061c455' :"Location",
32   '0ecfa7150815d4ddb07470e3862c92c4' :"Export CMS (ZIP)",
33   '7ee49db2b46c732d681edc761cf487ae' :"Postion",
34   '5fb63579fc981698f97d55bfecb213ea' :"Copy",
35   '040dcb21af4618f18d04e667c07ef314' :"{0} - {1} of {2}",
36   'f46885d21c98f597303699f41b3d7afd' :"Ex?",
37   'f2a6c498fb90ee345d997f888fce3b18' :"Delete",
38   '4d3d769b812b6faa6b76e1a8abaece2d' :"Active",
39   'a1fa27779242b4902f7ae3bdd5c6d508' :"Type",
40   'f7070be7ec7d2443714a2e5dc63f4de2' :"Links to",
41   '75ae2cfdf786e5577f1b619f4ca8d728' :"To replace"
42  },
43
44   part     :  ["Cms", "Blog" ],
45   order    : '001-Pman.Tab.CmsBlog',
46   region   : 'center',
47   parent   : 'Pman.Tab.Cms',
48   name     : "Pman.Tab.CmsBlog",
49   disabled : false, 
50   permname : '', 
51   _tree : function(_data)
52   {
53    var _this = this;
54    var MODULE = this;
55    return {
56    xtype : 'NestedLayoutPanel',
57    title : _this._strings['b8a00b5928fbead0626546550667b2b5'] /* Pages, Menu and Blog Entries */,
58    xns : Roo,
59    '|xns' : 'Roo',
60    layout : {
61     xtype : 'BorderLayout',
62     xns : Roo,
63     '|xns' : 'Roo',
64     center : {
65      xtype : 'LayoutRegion',
66      xns : Roo,
67      '|xns' : 'Roo'
68     },
69     east : {
70      xtype : 'LayoutRegion',
71      collapsed : false,
72      collapsedTitle : 'Child Elements',
73      collapsible : true,
74      split : true,
75      title : _this._strings['695e93e1d9db8283a9dd66782625065d'] /* Child Elements */,
76      titlebar : true,
77      width : 400,
78      xns : Roo,
79      '|xns' : 'Roo'
80     },
81     west : {
82      xtype : 'LayoutRegion',
83      split : true,
84      titlebar : false,
85      width : 320,
86      xns : Roo,
87      '|xns' : 'Roo'
88     },
89     items  : [
90      {
91       xtype : 'GridPanel',
92       background : false,
93       fitContainer : true,
94       fitToframe : true,
95       region : 'center',
96       tableName : 'cms_page',
97       title : _this._strings['b8a00b5928fbead0626546550667b2b5'] /* Pages, Menu and Blog Entries */,
98       listeners : {
99        activate : function() {
100             _this.panel = this;
101             if (_this.grid) {
102                 _this.grid.footer.onClick('first');
103             }
104             
105         }
106       },
107       xns : Roo,
108       '|xns' : 'Roo',
109       grid : {
110        xtype : 'Grid',
111        autoExpandColumn : 'title',
112        loadMask : true,
113        trigger_link_click : function(g, rowIndex, columnIndex, e) 
114        { 
115            e.preventDefault();
116            
117            var target = e.getTarget();
118            
119            if(target.nodeName.toLowerCase() != 'a'){
120                return;
121            }
122            
123            var rec = _this.grid.ds.getAt(rowIndex);
124            
125            var el = Roo.get(target);
126            
127            var element_id = el.attr('data-element-id');
128            
129            var element_id_name = el.attr('data-element-name');
130            var page_type_id = el.attr('data-page-type-id');
131            var parent_id = el.attr('data-parent-id');
132            var parent_id_title = el.attr('data-parent-title');
133            
134            var params =   {
135                id : 0,
136                element_id : element_id,
137                element_id_name : element_id_name,
138                page_type_id : page_type_id,
139                page_type_id_name : 'element',
140                page_type_id_display_name : 'Elements',
141                parent_id : parent_id,
142                parent_id_title : parent_id_title
143            };
144           
145            _this.dialog.show( params, function() {
146                _this.grid.footer.onClick('first');
147            });
148            
149            return;
150            
151        },
152        listeners : {
153         cellclick : function (g, ri,ci, e)\r
154          {
155              var h = this.colModel.getDataIndex(ci);
156              \r
157              if (h != 'is_draft') {\r
158                  return;\r
159              }\r
160              var rec = g.ds.getAt(ri);
161              
162              if(rec.data.is_system_page * 1 == 1){
163                  Roo.MessageBox.alert('Error', 'You cannot de-active the system page');
164                  return;
165              }\r
166              rec.set('is_draft', rec.data.is_draft ? 0 : 1);\r
167              rec.commit();\r
168          },
169         render : function() 
170          {
171             _this.grid = this; 
172              _this.dialog = Pman.Dialog.CmsBlog;
173              if (_this.panel.active) {
174                 this.footer.onClick('first');
175              }
176          },
177         rowclick : function (_self, rowIndex, e)
178          {
179              var s = this.dataSource.getAt(rowIndex);
180          
181              _this.prepanel.el.dom.innerHTML = '';
182              
183              if(s.data.id * 1 < 1){
184                  return;\r
185              }
186              
187              _this.prepanel.el.dom.src =  baseURL + '/Cms/PageThumb/' +  s.data.id;
188              
189              _this.targetData = s;
190              
191              _this.child_element_grid.footer.onClick('first');
192              
193          },
194         rowdblclick : function (_self, rowIndex, e)
195          {
196              var s = this.dataSource.getAt(rowIndex);
197              /*  
198              if (s.data.language.length) {
199                  Roo.log('in lang');
200                  _this.dialog.show({ id : s.data.parent_id } , function() {
201                      _this.grid.footer.onClick('refresh');
202                  });
203                  return;
204              }*/
205              _this.dialog.show(s.data, function() {
206                  _this.grid.footer.onClick('refresh');
207              }); 
208              
209          }
210        },
211        xns : Roo.grid,
212        '|xns' : 'Roo.grid',
213        footer : {
214         xtype : 'PagingToolbar',
215         displayInfo : true,
216         displayMsg : _this._strings['30a2a59b5adaa49803297d4c06e09e67'] /* Displaying cms_page{0} - {1} of {2} */,
217         emptyMsg : _this._strings['f17755c3f16cb257f7793b9865ebafb3'] /* No cms_page found */,
218         pageSize : 25,
219         xns : Roo,
220         '|xns' : 'Roo',
221         items  : [
222          {
223           xtype : 'Button',
224           enableToggle : true,
225           text : _this._strings['c8043f5cd3d28cb76c548338497b06ab'] /* Show Deleted */,
226           listeners : {
227            click : function (_self, e)
228             {
229                 _this.grid.footer.onClick.defer(100, _this.grid.footer, ['first'] );
230                 this.setText( this.pressed ? "Hide Deleted" : "Show Deleted");
231             },
232            render : function (_self)
233             {
234               _this.showDeleted = this;
235             }
236           },
237           xns : Roo.Toolbar,
238           '|xns' : 'Roo.Toolbar'
239          },
240          {
241           xtype : 'Separator',
242           xns : Roo.Toolbar,
243           '|xns' : 'Roo.Toolbar'
244          },
245          {
246           xtype : 'Button',
247           text : _this._strings['0ecfa7150815d4ddb07470e3862c92c4'] /* Export CMS (ZIP) */,
248           listeners : {
249            click : function (_self, e)
250             {
251                 new Pman.Download({
252                     url: baseURL + '/Roo/Cms_page',
253                     newWindow : true,
254                     params: {
255                         _dump_pages : 1
256                     }
257                 });
258                 
259                 Roo.MessageBox.alert("Downloading", "The file is downloading");
260             }
261           },
262           xns : Roo.Toolbar,
263           '|xns' : 'Roo.Toolbar'
264          },
265          {
266           xtype : 'Separator',
267           xns : Roo.Toolbar,
268           '|xns' : 'Roo.Toolbar'
269          },
270          {
271           xtype : 'ComboBox',
272           allowBlank : false,
273           displayField : 'value',
274           editable : false,
275           mode : 'local',
276           triggerAction : 'all',
277           value : 40,
278           valueField : 'key',
279           width : 100,
280           listeners : {
281            render : function (_self)
282             {
283                 _this.image_size_sel = _self;
284             },
285            select : function (combo, record, index)
286             {
287                 _this.grid.footer.onClick('first');
288             }
289           },
290           xns : Roo.form,
291           '|xns' : 'Roo.form',
292           store : {
293            xtype : 'SimpleStore',
294            data : [
295                 [ 40, "Small" ],
296                 [ 150, "Medium" ],
297                 [ 0, "None" ]
298            ],
299            fields : [ 'key', 'value'],
300            xns : Roo.data,
301            '|xns' : 'Roo.data'
302           }
303          }
304         ]
305        },
306        toolbar : {
307         xtype : 'Toolbar',
308         xns : Roo,
309         '|xns' : 'Roo',
310         items  : [
311          {
312           xtype : 'TextField',
313           listeners : {
314            render : function (_self)
315             {
316             _this.searchBox=  _self;
317             },
318            specialkey : function (_self, e)
319             {
320             _this.grid.footer.onClick('first');
321             }
322           },
323           xns : Roo.form,
324           '|xns' : 'Roo.form'
325          },
326          {
327           xtype : 'Button',
328           cls : 'x-btn-icon',
329           icon : rootURL + '/Pman/templates/images/search.gif',
330           listeners : {
331            click : function (_self, e)
332             {
333             _this.grid.footer.onClick('first');
334             }
335           },
336           xns : Roo.Toolbar,
337           '|xns' : 'Roo.Toolbar'
338          },
339          {
340           xtype : 'Button',
341           cls : 'x-btn-icon',
342           icon : rootURL + '/Pman/templates/images/edit-clear.gif',
343           listeners : {
344            click : function (_self, e)
345             {
346                 _this.searchBox.setValue('');
347                 
348                 _this.grid.footer.onClick('first');
349             }
350           },
351           xns : Roo.Toolbar,
352           '|xns' : 'Roo.Toolbar'
353          },
354          {
355           xtype : 'Separator',
356           xns : Roo.Toolbar,
357           '|xns' : 'Roo.Toolbar'
358          },
359          {
360           xtype : 'Button',
361           cls : 'x-btn-text-icon',
362           icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
363           text : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
364           listeners : {
365            click : function()
366             {
367                 var ds = false;
368                 
369                 
370                 if(_this.grid.selModel.getSelections().length == 1){
371                    ds = _this.grid.selModel.getSelected().data;
372                 }
373                 
374                 var page_type_id = 0;
375                 var page_type_id_name = '';
376                 var page_type_id_display_name = '';
377                 
378                 var sel = _this.category_grid.getSelectionModel().getSelected();
379                 
380                 if(!ds && sel && sel.data.pid * 1 > 0 && sel.data.type == 'page_type'){
381                     page_type_id = sel.data.pid;
382                     page_type_id_name = sel.data.name;
383                     page_type_id_display_name = sel.data.display_name;
384                     
385                     if(sel.data.name == 'page'){
386                         page_type_id_display_name = 'Pages';
387                     }
388                     
389                     if(sel.data.name == 'blog'){
390                         page_type_id_display_name = 'Blog Entries';
391                     }
392                     
393                 }
394             
395                 /*
396                 var s = _this.page_type.selectedData;
397                 
398                 if(!ds){
399                     page_type_id = s.id;
400                     page_type_id_name = s.name;
401                     page_type_id_display_name = s.display_name;
402                     
403                     if(s.name == 'page'){
404                         page_type_id_display_name = 'Pages';
405                     }
406                 }
407                */
408                
409                 var q =   {
410                     id : 0,
411                     parent_id : ds ? ds.id : '',
412                     parent_id_title : ds ? ds.title : '',
413                     page_link : ds && !ds.is_element ? (ds.page_link + '/') : '',
414                     page_type_id : ds ? ds.page_type_id : page_type_id,
415                     page_type_id_name : ds ? ds.page_type_id_name : page_type_id_name,
416                     page_type_id_display_name : ds ? ds.page_type_id_display_name : page_type_id_display_name
417                 };
418                
419                _this.dialog.show( q, function() {
420                  _this.grid.footer.onClick('first');
421                });
422             }
423           },
424           xns : Roo.Toolbar,
425           '|xns' : 'Roo.Toolbar'
426          },
427          {
428           xtype : 'Separator',
429           xns : Roo.Toolbar,
430           '|xns' : 'Roo.Toolbar'
431          },
432          {
433           xtype : 'Button',
434           cls : 'x-btn-text-icon',
435           icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
436           text : _this._strings['5fb63579fc981698f97d55bfecb213ea'] /* Copy */,
437           listeners : {
438            click : function()
439             {
440                 var s = _this.grid.selModel.getSelections();
441                 
442                 if(_this.grid.selModel.getSelections().length != 1){
443                     Roo.MessageBox.alert('Error', 'Please select one row to copy');
444                     return;
445                 }
446                 
447                 var sel = _this.grid.selModel.getSelected();
448                 
449                 if(!sel || sel.data.id * 1 < 1){
450                     Roo.MessageBox.alert('Error', 'Please select one row to copy');
451                     return;
452                 }
453                 
454                 new Pman.Request({
455                     url : baseURL + '/Roo/cms_page.php',
456                     method : 'GET',
457                     params : {
458                         _id : sel.data.id
459                     }, 
460                     success : function(res) {
461                     
462                         Roo.log(res.data);
463                         
464                         var params = Roo.apply({}, res.data);
465                         
466                         params.id = 0;
467                         params._is_copy = 1;
468                         
469                         _this.dialog.show( params, function() {
470                             _this.grid.footer.onClick('first');
471                         });
472                     }
473                 });
474                 
475                 return;
476                 
477                 
478                 var ds = false;
479                 if(_this.grid.selModel.getSelections().length == 1){
480                    ds = _this.grid.selModel.getSelected().data;
481                 }
482                 
483                 var page_type_id = 0;
484                 var page_type_id_name = '';
485                 var page_type_id_display_name = '';
486                 
487                 var sel = _this.category_grid.getSelectionModel().getSelected();
488                 
489                 if(!ds && sel && sel.data.pid * 1 > 0 && sel.data.type == 'page_type'){
490                     page_type_id = sel.data.pid;
491                     page_type_id_name = sel.data.name;
492                     page_type_id_display_name = sel.data.display_name;
493                     
494                     if(sel.data.name == 'page'){
495                         page_type_id_display_name = 'Pages';
496                     }
497                     
498                     if(sel.data.name == 'blog'){
499                         page_type_id_display_name = 'Blog Entries';
500                     }
501                     
502                 }
503             
504                 /*
505                 var s = _this.page_type.selectedData;
506                 
507                 if(!ds){
508                     page_type_id = s.id;
509                     page_type_id_name = s.name;
510                     page_type_id_display_name = s.display_name;
511                     
512                     if(s.name == 'page'){
513                         page_type_id_display_name = 'Pages';
514                     }
515                 }
516                */
517                
518                 var q =   {
519                     id : 0,
520                     parent_id : ds ? ds.id : '',
521                     parent_id_title : ds ? ds.title : '',
522                     page_link : ds && !ds.is_element ? (ds.page_link + '/') : '',
523                     page_type_id : ds ? ds.page_type_id : page_type_id,
524                     page_type_id_name : ds ? ds.page_type_id_name : page_type_id_name,
525                     page_type_id_display_name : ds ? ds.page_type_id_display_name : page_type_id_display_name
526                 };
527                
528                _this.dialog.show( q, function() {
529                  _this.grid.footer.onClick('first');
530                });
531             }
532           },
533           xns : Roo.Toolbar,
534           '|xns' : 'Roo.Toolbar'
535          },
536          {
537           xtype : 'Fill',
538           xns : Roo.Toolbar,
539           '|xns' : 'Roo.Toolbar'
540          },
541          {
542           xtype : 'Button',
543           cls : 'x-btn-text-icon',
544           icon : rootURL + '/Pman/templates/images/trash.gif',
545           text : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
546           listeners : {
547            click : function()
548             {
549                 var ds = false;
550                 if(_this.grid.selModel.getSelections().length != 1){
551                     Roo.MessageBox.alert("Error", "Select page to delete");
552                     return;
553                 }
554                 var  sel = _this.grid.selModel.getSelected();
555                 if(sel.data.is_system_page){
556                     Roo.MessageBox.alert("Error", "System pages can not be deleted.");
557                     return;
558                 }
559                 
560                 /*
561                 Roo.MessageBox.confirm("Confirm", 
562                     "Are you sure you want to delete this, it can not be recovered if you make a mistake!", 
563                     function(res) {
564                         if (res != 'yes') {
565                             return;
566                         }
567                         new Pman.Request({
568                             method : 'POST',
569                             url : baseURL + '/Roo/cms_page',
570                             params : {
571                                 _delete : sel.data.id
572                             },
573                             success : function() { 
574                                 _this.grid.footer.onClick('refresh');
575                             }
576                         });
577                         
578                             
579                     }
580                 );
581                 
582                 */
583                 
584                 new Pman.Request({
585                     method : 'POST',
586                     url : baseURL + '/Roo/cms_page',
587                     params : {
588                         id : sel.data.id,
589                         is_deleted : 1
590                     },
591                     success : function() { 
592                         _this.grid.footer.onClick('refresh');
593                     }
594                 });
595                 
596             }
597           },
598           xns : Roo.Toolbar,
599           '|xns' : 'Roo.Toolbar'
600          }
601         ]
602        },
603        dataSource : {
604         xtype : 'Store',
605         remoteSort : true,
606         sortInfo : { field : 'created' , direction : 'DESC' },
607         listeners : {
608          beforeload : function (_self, options)
609           {
610               if (Pman.building || !Pman.Tab.Cms.panel.active) {
611                   return false;
612               }
613               
614               var sel = _this.category_grid.getSelectionModel().getSelected();
615               
616               if(!sel || sel.data.pid * 1 < 1){
617                   this.removeAll();
618                   return false;
619               }
620               
621               options.params._with_primary_image = 1;
622               
623               var cm = _this.grid.colModel;
624               var vis = {
625                   category_type_id_name : true,
626                   menu_page_id_title : true
627               };
628               
629               var cm = _this.grid.getColumnModel();
630               
631               function cid(str) {
632                   return cm.getIndexByDataIndex(str);
633               }
634               
635               options.params['search[name]'] = _this.searchBox.getValue();
636               
637               options.params._exclude_columns = 'body,extended';
638               
639               if(sel.data.type == 'page_type'){
640                   options.params._page_type_id = sel.data.pid;
641               }
642               
643               if(sel.data.type == 'category'){
644                   options.params._category_id = sel.data.pid;
645               }
646               
647               var size = _this.image_size_sel.getValue() * 1;
648               
649               cm.setHidden(cid('primary_image_id'), false);
650               cm.setColumnWidth(cid('primary_image_id'), size + 10);
651               
652               if(size == 0){
653                   cm.setHidden(cid('primary_image_id'), true);
654               }
655               
656              // options.params._treeview = 1;
657               options.params._pman_short = 1;
658               
659               options.params.translation_of_id = 0;
660               
661               options.params._with_translation_type = 1;
662               
663               //options.params._requestMeta  = 1; // always fetch meta.. as different types return different data..
664               
665               
666               switch(sel.data.name) {
667                   case 'page' : 
668                    //   options.params.limit = 9999;
669                 //      _this.grid.footer.pageSize = 9999;
670                       vis.menu_page_id_title = false;
671                       cm.setHidden(cid('created'), true);
672                       cm.setHidden(cid('published'), true);
673                       cm.setHidden(cid('template_id_template'), false);   
674                       this.sortInfo.field = 'tree_sequence'; // force sort.
675                       this.sortInfo.direction = 'ASC'; // force sort.
676                                    
677                       break;
678                   case 'blog' :
679                    //   options.params.limit = 20;
680                    //   options.params['search[category]'] = _this.category_type.getValue();
681                    //   _this.grid.footer.pageSize = 20;
682                       vis.menu_page_id_title = false;
683                       cm.setHidden(cid('created'), false);
684                       cm.setHidden(cid('published'), false);
685                       cm.setHidden(cid('template_id_template'), true);
686                       this.sortInfo.field = 'published'; // force sort.
687                       this.sortInfo.direction = 'DESC'; // force sort.
688                       
689                       break;
690                   
691                   case 'menu' :
692                   //    options.params.limit = 9999;
693                   //    _this.grid.footer.pageSize = 9999;
694                       vis.category_type_id_name = false;
695                       cm.setHidden(cid('created'), true);
696                       cm.setHidden(cid('published'), true);
697                       cm.setHidden(cid('template_id_template'), true);
698                       this.sortInfo.field = 'tree_sequence'; // force sort.
699                       this.sortInfo.direction = 'ASC'; // force sort.
700                       
701                       break;
702                   case 'category' :
703                  //     options.params.limit = 20;
704                 //      _this.grid.footer.pageSize = 20;
705                       vis.menu_page_id_title = false;
706                       cm.setHidden(cid('created'), false);
707                       cm.setHidden(cid('published'), false);
708                       cm.setHidden(cid('template_id_template'), true);
709                       this.sortInfo.field = 'tree_sequence'; // force sort.
710                       this.sortInfo.direction = 'ASC'; // force sort.
711                        
712                       break;
713               }
714               
715               if (_this.showDeleted.pressed) {
716                   options.params._show_deleted = 1;
717               }
718               
719               for (var i in vis) {
720                   cm.setHidden(cm.getIndexByDataIndex(i), !vis[i]);
721               }
722               
723           },
724          load : function (_self, records, options)
725           {
726               _this.child_element_panel.region.collapse();
727           },
728          update : function (_self, record, operation)
729           {
730               if (operation != 'commit') {
731                   return;
732               }
733               // only used to change active status.
734               
735               new Pman.request({\r
736                   method : 'POST',\r
737                   url : baseURL + '/Roo/Cms_page',\r
738                   params : {\r
739                       id : record.data.id,\r
740                       is_draft : record.data.is_draft\r
741                   },
742                   success : function(res) {
743                      _this.grid.footer.onClick('refresh');
744                  }\r
745               });
746           }
747         },
748         xns : Roo.data,
749         '|xns' : 'Roo.data',
750         proxy : {
751          xtype : 'HttpProxy',
752          method : 'GET',
753          url : baseURL + '/Roo/cms_page.php',
754          xns : Roo.data,
755          '|xns' : 'Roo.data'
756         },
757         reader : {
758          xtype : 'JsonReader',
759          fields : [
760              {
761                  'name': 'id',
762                  'type': 'int'
763              },
764              {
765                  'name': 'title',
766                  'type': 'string'
767              },
768              {
769                  'name': 'published',
770                  'type': 'date',
771                  'format' : 'Y-m-d H:i:s'
772              },
773              {
774                  'name': 'body',
775                  'type': 'string'
776              },
777              {
778                  'name': 'comments_no',
779                  'type': 'int'
780              },
781              {
782                  'name': 'trackbacks_no',
783                  'type': 'int'
784              },
785              {
786                  'name': 'extended',
787                  'type': 'string'
788              },
789              {
790                  'name': 'has_extended',
791                  'type': 'int'
792              },
793              {
794                  'name': 'author_id',
795                  'type': 'int'
796              },
797              {
798                  'name': 'category_id',
799                  'type': 'int'
800              },
801              {
802                  'name': 'category_id_title',
803                  'type': 'string'
804              },
805              {
806                  'name': 'is_draft',
807                  'type': 'int'
808              },
809              {
810                  'name': 'updated',
811                  'type': 'date',
812                  'format' : 'Y-m-d H:i:s'
813              },
814              {
815                  'name': 'created',
816                  'type': 'date',
817                  'format' : 'Y-m-d H:i:s'
818              },
819              {
820                  'name': 'to_replace_id',
821                  'type': 'int'
822              },
823              {
824                  'name': 'page_link',
825                  'type': 'string'
826              },
827              {
828                  'name': 'in_rss',
829                  'type': 'int'
830              },
831              {
832                  'name': 'parent_id',
833                  'type': 'int'
834              },
835              {
836                  'name': 'parent_id_title',
837                  'type': 'string'
838              },
839          
840              {
841                  'name': 'author_id_id',
842                  'type': 'int'
843              },
844              {
845                  'name': 'author_id_office_id',
846                  'type': 'int'
847              },
848              {
849                  'name': 'author_id_name',
850                  'type': 'string'
851              },
852              {
853                  'name': 'author_id_phone',
854                  'type': 'string'
855              },
856              {
857                  'name': 'author_id_fax',
858                  'type': 'string'
859              },
860              {
861                  'name': 'author_id_email',
862                  'type': 'string'
863              },
864              {
865                  'name': 'author_id_company_id',
866                  'type': 'int'
867              },
868              {
869                  'name': 'author_id_role',
870                  'type': 'string'
871              },
872              {
873                  'name': 'author_id_active',
874                  'type': 'int'
875              },
876              {
877                  'name': 'author_id_remarks',
878                  'type': 'string'
879              },
880              {
881                  'name': 'author_id_passwd',
882                  'type': 'string'
883              },
884              {
885                  'name': 'author_id_owner_id',
886                  'type': 'int'
887              },
888              {
889                  'name': 'author_id_lang',
890                  'type': 'string'
891              },
892              {
893                  'name': 'author_id_no_reset_sent',
894                  'type': 'int'
895              },
896              {
897                  'name': 'author_id_action_type',
898                  'type': 'string'
899              },
900              {
901                  'name': 'author_id_project_id',
902                  'type': 'int'
903              },
904              {
905                  'name': 'category_id_id',
906                  'type': 'int'
907              },
908              {
909                  'name': 'category_id_parent_id',
910                  'type': 'int'
911              },
912              {
913                  'name': 'category_id_short_name',
914                  'type': 'string'
915              },
916              {
917                  'name': 'category_id_title',
918                  'type': 'string'
919              },
920              {
921                  'name': 'category_id_page_text',
922                  'type': 'string'
923              },
924              {
925                  'name': 'category_id_type',
926                  'type': 'string'
927              },
928              {
929                  'name': 'category_id_search_on',
930                  'type': 'string'
931              },
932              {
933                  'name': 'category_id_image_menu_id',
934                  'type': 'int'
935              },
936              {
937                  'name': 'category_id_image_menuover_id',
938                  'type': 'int'
939              },
940              {
941                  'name': 'category_id_image_leftactive_id',
942                  'type': 'int'
943              },
944              {
945                  'name': 'category_id_image_page_id',
946                  'type': 'int'
947              },
948              {
949                  'name': 'category_id_display_order',
950                  'type': 'int'
951              },
952              {
953                  'name': 'category_id_more_info_title',
954                  'type': 'string'
955              },
956              {
957                  'name': 'category_id_more_info_text',
958                  'type': 'string'
959              },
960              {
961                  'name': 'category_id_visible',
962                  'type': 'int'
963              },
964              {
965                  'name': 'to_replace_id_id',
966                  'type': 'int'
967              },
968              {
969                  'name': 'to_replace_id_title',
970                  'type': 'string'
971              },
972              {
973                  'name': 'to_replace_id_published',
974                  'type': 'string'
975              },
976              {
977                  'name': 'to_replace_id_body',
978                  'type': 'string'
979              },
980              {
981                  'name': 'to_replace_id_comments_no',
982                  'type': 'int'
983              },
984              {
985                  'name': 'to_replace_id_trackbacks_no',
986                  'type': 'int'
987              },
988              {
989                  'name': 'to_replace_id_extended',
990                  'type': 'string'
991              },
992              {
993                  'name': 'to_replace_id_has_extended',
994                  'type': 'int'
995              },
996              {
997                  'name': 'to_replace_id_author_id',
998                  'type': 'int'
999              },
1000              {
1001                  'name': 'to_replace_id_category_id',
1002                  'type': 'int'
1003              },
1004              {
1005                  'name': 'to_replace_id_is_draft',
1006                  'type': 'int'
1007              },
1008              {
1009                  'name': 'to_replace_id_updated',
1010                  'type': 'string'
1011              },
1012              {
1013                  'name': 'to_replace_id_created',
1014                  'type': 'string'
1015              },
1016              {
1017                  'name': 'to_replace_id_to_replace_id',
1018                  'type': 'int'
1019              },
1020              {
1021                  'name': 'to_replace_id_page_link',
1022                  'type': 'string'
1023              },
1024              {
1025                  'name': 'to_replace_id_in_rss',
1026                  'type': 'int'
1027              },
1028              {
1029                  'name': 'to_replace_id_parent_id',
1030                  'type': 'int'
1031              },
1032              {
1033                  'name': 'parent_id_id',
1034                  'type': 'int'
1035              },
1036              {
1037                  'name': 'parent_id_title',
1038                  'type': 'string'
1039              },
1040              {
1041                  'name': 'parent_id_published',
1042                  'type': 'string'
1043              },
1044              {
1045                  'name': 'parent_id_body',
1046                  'type': 'string'
1047              },
1048              {
1049                  'name': 'parent_id_comments_no',
1050                  'type': 'int'
1051              },
1052              {
1053                  'name': 'parent_id_trackbacks_no',
1054                  'type': 'int'
1055              },
1056              {
1057                  'name': 'parent_id_extended',
1058                  'type': 'string'
1059              },
1060              {
1061                  'name': 'parent_id_has_extended',
1062                  'type': 'int'
1063              },
1064              {
1065                  'name': 'parent_id_author_id',
1066                  'type': 'int'
1067              },
1068              {
1069                  'name': 'parent_id_category_id',
1070                  'type': 'int'
1071              },
1072              {
1073                  'name': 'parent_id_is_draft',
1074                  'type': 'int'
1075              },
1076              {
1077                  'name': 'parent_id_updated',
1078                  'type': 'string'
1079              },
1080              {
1081                  'name': 'parent_id_created',
1082                  'type': 'string'
1083              },
1084              {
1085                  'name': 'parent_id_to_replace_id',
1086                  'type': 'int'
1087              },
1088              {
1089                  'name': 'parent_id_page_link',
1090                  'type': 'string'
1091              },
1092              {
1093                  'name': 'parent_id_in_rss',
1094                  'type': 'int'
1095              },
1096              {
1097                  'name': 'parent_id_parent_id',
1098                  'type': 'int'
1099              }
1100          ],
1101          id : 'id',
1102          root : 'data',
1103          totalProperty : 'total',
1104          xns : Roo.data,
1105          '|xns' : 'Roo.data'
1106         }
1107        },
1108        colModel : [
1109         {
1110          xtype : 'ColumnModel',
1111          dataIndex : 'is_draft',
1112          header : _this._strings['4d3d769b812b6faa6b76e1a8abaece2d'] /* Active */,
1113          renderer : function(v,x,r) {
1114               
1115              var state = v> 0 ?  '' : '-checked';
1116          
1117              return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1118          },
1119          width : 75,
1120          xns : Roo.grid,
1121          '|xns' : 'Roo.grid'
1122         },
1123         {
1124          xtype : 'ColumnModel',
1125          dataIndex : 'primary_image_id',
1126          header : _this._strings['be53a0541a6d36f6ecb879fa2c584b08'] /* Image */,
1127          renderer : function(v,x,r) 
1128          { 
1129              var size = _this.image_size_sel.getValue() * 1;
1130              
1131              if(v * 1 < 1 || size == 0){
1132                  return;
1133              }
1134              
1135              return String.format('<img src="{0}/Images/Thumb/{1}/{2}" width="{1}">', baseURL, size, v); 
1136          },
1137          sortable : false,
1138          width : 75,
1139          xns : Roo.grid,
1140          '|xns' : 'Roo.grid'
1141         },
1142         {
1143          xtype : 'ColumnModel',
1144          dataIndex : 'created',
1145          header : _this._strings['0eceeb45861f9585dd7a97a3e36f85c6'] /* Created */,
1146          renderer : function(v) { return v? v.format('d/M/Y') : '--' },
1147          width : 75,
1148          xns : Roo.grid,
1149          '|xns' : 'Roo.grid'
1150         },
1151         {
1152          xtype : 'ColumnModel',
1153          dataIndex : 'published',
1154          header : _this._strings['9b9d8a976b42e0bd66381797644943d5'] /* Published */,
1155          renderer : function(v,x,r) { 
1156              if (r.data.is_draft) { 
1157                  return '[DRAFT]';
1158              }
1159          
1160              return v? v.format('d/M/Y') : '--' 
1161          },
1162          width : 75,
1163          xns : Roo.grid,
1164          '|xns' : 'Roo.grid'
1165         },
1166         {
1167          xtype : 'ColumnModel',
1168          dataIndex : 'page_link',
1169          header : _this._strings['2cbaa804531fc7367ccc699fb1eef52a'] /* Page link / Name / Order */,
1170          renderer : function(v,x,r) { 
1171          
1172              if (r.data.page_type_id_name == 'page') {
1173                  return String.format('{0}', v); 
1174                  
1175              }
1176              
1177              if (r.data.page_type_id_name == 'blog') {
1178                  return String.format('{0}', v); 
1179              }
1180              // what about categories.??
1181              
1182              // menu, or elements.. ??
1183              
1184              var d = r.json.depth || 0;
1185              var pr = ''; 
1186              for (i = 0; i < d; i++) {
1187                pr += ' ..  ';
1188              }
1189              if (r.data.page_type_id_name == 'element') {    
1190                  return String.format('{0}<i>{1}</i>', pr,  v);     
1191              }
1192              // menu..
1193              return String.format('{0}{1}', pr,  v);
1194              
1195              
1196          },
1197          width : 150,
1198          xns : Roo.grid,
1199          '|xns' : 'Roo.grid'
1200         },
1201         {
1202          xtype : 'ColumnModel',
1203          dataIndex : 'title',
1204          header : _this._strings['b78a3223503896721cca1303f776159b'] /* Title */,
1205          renderer : function(v,x,r) { 
1206          
1207              var d = r.json.tree_depth || 0;
1208              var pr = ''; 
1209              for (i = 0; i < d; i++) {
1210                pr += ' ..  ';
1211              }
1212              
1213              var fmt = '<span style="color:blue">{2}{3}</span>' + 
1214                      (r.data.is_draft ? '<s>{0}</s> <b style="color:#a94442;">{1}</b>' : '{0} <b style="color:#a94442;">{1}</b>');
1215              
1216              return String.format( fmt,
1217                  pr + v,
1218                  (r.data.has_child * 1 > 0) ? '[has child]' : '',
1219                  
1220                  (r.data.page_type_id_name == 'menu'  ? '('+r.data.seq_id +')' : ''),
1221                  (r.data.category_page_id *1 ? ( '[' + r.data.category_page_id_title +'] ' ): '')
1222                  );
1223                  
1224           },
1225          width : 200,
1226          xns : Roo.grid,
1227          '|xns' : 'Roo.grid'
1228         },
1229         {
1230          xtype : 'ColumnModel',
1231          dataIndex : 'template_id_template',
1232          header : _this._strings['ebd9bec4d70abc789d439c1f136b0538'] /* Layout */,
1233          renderer : function(v) { return String.format('{0}', v  || ''); },
1234          width : 75,
1235          xns : Roo.grid,
1236          '|xns' : 'Roo.grid'
1237         },
1238         {
1239          xtype : 'ColumnModel',
1240          dataIndex : 'category_type_id_name',
1241          header : _this._strings['a1fa27779242b4902f7ae3bdd5c6d508'] /* Type */,
1242          renderer : function(v, x, r) 
1243          {
1244              var ret = [];
1245              
1246              if (r.data.language.length) {
1247                  ret.push('&gt;&gt; ' + Pman.I18n.toName('l', r.data.language));
1248              }
1249              
1250              if(r.data.translation_type.length){
1251              
1252                  var types = r.data.translation_type.split(',');
1253                  
1254                  Roo.each(types, function(t){
1255                      ret.push('&gt;&gt; ' + Pman.I18n.toName('l', t));
1256                  });
1257              }
1258              
1259              return ret.join("<br/>");
1260              
1261              /*
1262              if (r.data.language.length) {
1263                  return '&gt;&gt; ' + Pman.I18n.toName('l', r.data.language);
1264              }
1265              */
1266              
1267            /*  if (r.data.in_rss) {
1268                  return String.format('{0}', v); 
1269              }
1270              if (r.data.is_element) {
1271                  return String.format('[Element:{0}]', r.data.element_id_name.length ? r.data.element_id_name : ''); 
1272              }
1273              */
1274          
1275          },
1276          width : 100,
1277          xns : Roo.grid,
1278          '|xns' : 'Roo.grid'
1279         },
1280         {
1281          xtype : 'ColumnModel',
1282          dataIndex : 'menu_page_id_title',
1283          header : _this._strings['f7070be7ec7d2443714a2e5dc63f4de2'] /* Links to */,
1284          renderer : function(v,x,r) { 
1285          
1286             if (r.data.is_attachment) {
1287                  return "[ATTACHMENT]";
1288              }
1289             return String.format('{0}', v); 
1290           },
1291          width : 200,
1292          xns : Roo.grid,
1293          '|xns' : 'Roo.grid'
1294         },
1295         {
1296          xtype : 'ColumnModel',
1297          dataIndex : 'author_id_name',
1298          header : _this._strings['a517747c3d12f99244ae598910d979c5'] /* Author */,
1299          renderer : function(v) { return String.format('{0}', v); },
1300          width : 75,
1301          xns : Roo.grid,
1302          '|xns' : 'Roo.grid'
1303         },
1304         {
1305          xtype : 'ColumnModel',
1306          dataIndex : 'parent_id_title',
1307          header : _this._strings['30269022e9d8f51beaabb52e5d0de2b7'] /* Parent */,
1308          hidden : true,
1309          renderer : function(v) { return String.format('{0}', v  || ''); },
1310          width : 75,
1311          xns : Roo.grid,
1312          '|xns' : 'Roo.grid'
1313         },
1314         {
1315          xtype : 'ColumnModel',
1316          dataIndex : 'to_replace_id_title',
1317          header : _this._strings['75ae2cfdf786e5577f1b619f4ca8d728'] /* To replace */,
1318          hidden : true,
1319          renderer : function(v) { return String.format('{0}', v); },
1320          width : 75,
1321          xns : Roo.grid,
1322          '|xns' : 'Roo.grid'
1323         },
1324         {
1325          xtype : 'ColumnModel',
1326          dataIndex : 'has_extended',
1327          header : _this._strings['f46885d21c98f597303699f41b3d7afd'] /* Ex? */,
1328          renderer : function(v) { return String.format('{0}', v); },
1329          width : 25,
1330          xns : Roo.grid,
1331          '|xns' : 'Roo.grid'
1332         },
1333         {
1334          xtype : 'ColumnModel',
1335          dataIndex : 'trackbacks_no',
1336          header : _this._strings['a4863ff1cdfa709d5bf80939cd2e6757'] /* T# */,
1337          hidden : true,
1338          renderer : function(v) { return String.format('{0}', v); },
1339          width : 25,
1340          xns : Roo.grid,
1341          '|xns' : 'Roo.grid'
1342         },
1343         {
1344          xtype : 'ColumnModel',
1345          dataIndex : 'comments_no',
1346          header : _this._strings['d7efa19fbe7d3972fd5adb6024223d74'] /* C# */,
1347          renderer : function(v) { return String.format('{0}', v); },
1348          width : 25,
1349          xns : Roo.grid,
1350          '|xns' : 'Roo.grid'
1351         },
1352         {
1353          xtype : 'ColumnModel',
1354          dataIndex : 'seq_id',
1355          header : _this._strings['7ee49db2b46c732d681edc761cf487ae'] /* Postion */,
1356          hidden : true,
1357          renderer : function(v,x,r) 
1358          { 
1359              
1360              return v *1;
1361              
1362          },
1363          width : 50,
1364          xns : Roo.grid,
1365          '|xns' : 'Roo.grid'
1366         }
1367        ]
1368       }
1369      },
1370      {
1371       xtype : 'NestedLayoutPanel',
1372       background : false,
1373       fitContainer : true,
1374       fitToFrame : true,
1375       region : 'west',
1376       xns : Roo,
1377       '|xns' : 'Roo',
1378       layout : {
1379        xtype : 'BorderLayout',
1380        xns : Roo,
1381        '|xns' : 'Roo',
1382        center : {
1383         xtype : 'LayoutRegion',
1384         titlebar : false,
1385         xns : Roo,
1386         '|xns' : 'Roo'
1387        },
1388        south : {
1389         xtype : 'LayoutRegion',
1390         height : 300,
1391         split : true,
1392         xns : Roo,
1393         '|xns' : 'Roo'
1394        },
1395        items  : [
1396         {
1397          xtype : 'GridPanel',
1398          autoScroll : true,
1399          background : false,
1400          fitContainer : true,
1401          fitToframe : true,
1402          region : 'center',
1403          tableName : 'cms_page_category',
1404          title : _this._strings['3adbdb3ac060038aa0e6e6c138ef9873'] /* Category */,
1405          listeners : {
1406           activate : function() {
1407            
1408                _this.category_panel = this;
1409                
1410                if (_this.category_grid) {
1411                    _this.category_grid.ds.load({});
1412                }
1413            }
1414          },
1415          xns : Roo,
1416          '|xns' : 'Roo',
1417          grid : {
1418           xtype : 'Grid',
1419           autoExpandColumn : 'display_name',
1420           loadMask : true,
1421           listeners : {
1422            render : function() 
1423             {
1424                _this.category_grid = this; 
1425                
1426                 if (_this.category_panel.active) {
1427                    this.ds.load({});
1428                 }
1429             }
1430           },
1431           xns : Roo.grid,
1432           '|xns' : 'Roo.grid',
1433           toolbar : {
1434            xtype : 'Toolbar',
1435            xns : Roo,
1436            '|xns' : 'Roo',
1437            items  : [
1438             {
1439              xtype : 'Button',
1440              text : _this._strings['63a6a88c066880c5ac42394a22803ca6'] /* Refresh */,
1441              listeners : {
1442               click : function (_self, e)
1443                {
1444                    _this.category_grid.ds.load({});
1445                }
1446              },
1447              xns : Roo.Toolbar,
1448              '|xns' : 'Roo.Toolbar'
1449             }
1450            ]
1451           },
1452           dataSource : {
1453            xtype : 'Store',
1454            remoteSort : true,
1455            sortInfo : { field : 'category_id' , direction : 'ASC' },
1456            listeners : {
1457             beforeload : function (_self, o)
1458              {
1459                  o.params = o.params || {};
1460                  
1461                  o.params._category_list = 1;
1462              }
1463            },
1464            xns : Roo.data,
1465            '|xns' : 'Roo.data',
1466            proxy : {
1467             xtype : 'HttpProxy',
1468             method : 'GET',
1469             url : baseURL + '/Roo/cms_page_category.php',
1470             xns : Roo.data,
1471             '|xns' : 'Roo.data'
1472            },
1473            reader : {
1474             xtype : 'JsonReader',
1475             fields : [
1476                 {
1477                     'name': 'id',
1478                     'type': 'int'
1479                 },
1480                 {
1481                     'name': 'pid',
1482                     'type': 'int'
1483                 },
1484                 {
1485                     'name': 'display_name',
1486                     'type': 'string'
1487                 },
1488                 {
1489                     'name': 'name',
1490                     'type': 'string'
1491                 },
1492                 {
1493                     'name': 'type',
1494                     'type': 'string'
1495                 }
1496             ],
1497             id : 'id',
1498             root : 'data',
1499             totalProperty : 'total',
1500             xns : Roo.data,
1501             '|xns' : 'Roo.data'
1502            }
1503           },
1504           sm : {
1505            xtype : 'RowSelectionModel',
1506            singleSelect : true,
1507            listeners : {
1508             afterselectionchange : function (_self)
1509              {
1510                  _this.grid.footer.onClick('first');
1511              }
1512            },
1513            xns : Roo.grid,
1514            '|xns' : 'Roo.grid'
1515           },
1516           colModel : [
1517            {
1518             xtype : 'ColumnModel',
1519             dataIndex : 'display_name',
1520             header : _this._strings['3adbdb3ac060038aa0e6e6c138ef9873'] /* Category */,
1521             renderer : function(v,x,r) { 
1522                 return String.format('{0}', v ? v : '');
1523             },
1524             width : 200,
1525             xns : Roo.grid,
1526             '|xns' : 'Roo.grid'
1527            }
1528           ]
1529          }
1530         },
1531         {
1532          xtype : 'ContentPanel',
1533          autoCreate : { tag: 'iframe', src : 'about:blank' },
1534          fitContainer : true,
1535          fitToFrame : true,
1536          region : 'south',
1537          title : _this._strings['08d0135e24822f43171ed4944fc3bdda'] /* Preview (resize by dragging next to this bar) */,
1538          listeners : {
1539           render : function (_self)
1540            {
1541                _this.prepanel = _self;
1542                
1543                this.el.dom.onload = function(){
1544                
1545                    if(
1546                        !_this.targetData || 
1547                        !_this.targetData.data.page_link.length ||
1548                        !uiConfig || 
1549                        typeof(uiConfig.cms_page_preview_base) == 'undefined'
1550                    ){
1551                        return;
1552                    }
1553                    
1554                    Roo.get(this.contentDocument.body).on('click', function(){
1555                        var url = uiConfig.cms_page_preview_base + _this.targetData.data.page_link;
1556                        window.open(url);
1557                    });
1558                }
1559            }
1560          },
1561          xns : Roo,
1562          '|xns' : 'Roo'
1563         }
1564        ]
1565       }
1566      },
1567      {
1568       xtype : 'GridPanel',
1569       background : false,
1570       fitContainer : true,
1571       fitToframe : true,
1572       region : 'east',
1573       tableName : 'cms_page',
1574       title : _this._strings['695e93e1d9db8283a9dd66782625065d'] /* Child Elements */,
1575       listeners : {
1576        activate : function() {
1577             _this.child_element_panel = this;
1578             if (_this.child_element_grid) {
1579                 //_this.child_element_grid.footer.onClick('first');
1580             }
1581             
1582         }
1583       },
1584       xns : Roo,
1585       '|xns' : 'Roo',
1586       grid : {
1587        xtype : 'Grid',
1588        autoExpandColumn : 'title',
1589        loadMask : true,
1590        trigger_link_click : function(g, rowIndex, columnIndex, e) 
1591        { 
1592            e.preventDefault();
1593            
1594            var target = e.getTarget();
1595            
1596            if(target.nodeName.toLowerCase() != 'a'){
1597                return;
1598            }
1599            
1600            var rec = _this.grid.ds.getAt(rowIndex);
1601            
1602            var el = Roo.get(target);
1603            
1604            if(!el.hasClass('down') && !el.hasClass('up')){
1605                return;
1606            }
1607            
1608            var s = this.dataSource.getAt(rowIndex);
1609            
1610            if(!s || s.data.id * 1 < 1){
1611                return;
1612            }
1613            
1614            new Pman.Request({
1615                method : 'POST',
1616                url : baseURL + '/Roo/cms_page',
1617                params : {
1618                    id : s.data.id,
1619                    _move : el.hasClass('down') ? 'down' : 'up'
1620                },
1621                success : function() { 
1622                    _this.child_element_grid.footer.onClick('refresh');
1623                }
1624            });
1625            
1626            return;
1627            
1628        },
1629        listeners : {
1630         cellclick : function (g, ri,ci, e)\r
1631          {
1632              var h = this.colModel.getDataIndex(ci);
1633              
1634              
1635              if(h == 'seq_id'){
1636                  _this.child_element_grid.trigger_link_click(g, ri, ci, e);
1637                  return;
1638              }
1639              
1640              \r
1641              if (h != 'is_draft') {\r
1642                  return;\r
1643              }
1644              \r
1645              var rec = g.ds.getAt(ri);
1646              \r
1647              rec.set('is_draft', rec.data.is_draft ? 0 : 1);\r
1648              rec.commit();
1649              \r
1650          },
1651         render : function() 
1652          {
1653             _this.child_element_grid = this; 
1654              if (_this.child_element_panel.active) {
1655                // this.footer.onClick('first');
1656              }
1657          },
1658         rowdblclick : function (_self, rowIndex, e)
1659          {
1660              var s = this.dataSource.getAt(rowIndex);
1661              
1662              _this.dialog.show(s.data, function() {
1663                  _this.child_element_grid.footer.onClick('refresh');
1664              }); 
1665              
1666          }
1667        },
1668        xns : Roo.grid,
1669        '|xns' : 'Roo.grid',
1670        footer : {
1671         xtype : 'PagingToolbar',
1672         displayInfo : true,
1673         displayMsg : _this._strings['040dcb21af4618f18d04e667c07ef314'] /* {0} - {1} of {2} */,
1674         emptyMsg : _this._strings['a9581db07856efb481fddef1b3e168f8'] /* No page found */,
1675         pageSize : 25,
1676         xns : Roo,
1677         '|xns' : 'Roo',
1678         items  : [
1679          {
1680           xtype : 'Button',
1681           enableToggle : true,
1682           text : _this._strings['c8043f5cd3d28cb76c548338497b06ab'] /* Show Deleted */,
1683           listeners : {
1684            click : function (_self, e)
1685             {
1686                 _this.child_element_grid.footer.onClick.defer(100, _this.child_element_grid.footer, ['first'] );
1687                 this.setText( this.pressed ? "Hide Deleted" : "Show Deleted");
1688             },
1689            render : function (_self)
1690             {
1691               _this.child_show_deleted = this;
1692             }
1693           },
1694           xns : Roo.Toolbar,
1695           '|xns' : 'Roo.Toolbar'
1696          }
1697         ]
1698        },
1699        toolbar : {
1700         xtype : 'Toolbar',
1701         xns : Roo,
1702         '|xns' : 'Roo',
1703         items  : [
1704          {
1705           xtype : 'Button',
1706           cls : 'x-btn-text-icon',
1707           icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
1708           text : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
1709           listeners : {
1710            click : function()
1711             {
1712                 var s = _this.grid.selModel.getSelected();
1713                 
1714                 if(!s || s.data.id * 1 < 1 || s.data.template_id * 1 < 1){
1715                     Roo.MessageBox.alert('Error', 'Please select a page');
1716                     return;
1717                 }
1718                 
1719                 Pman.Dialog.AddChildElementToPage.show({
1720                     template_id : s.data.template_id
1721                 }, function(res) {
1722                 
1723                     Roo.log(res);
1724                     
1725                 });
1726                 
1727                 
1728             }
1729           },
1730           xns : Roo.Toolbar,
1731           '|xns' : 'Roo.Toolbar'
1732          },
1733          {
1734           xtype : 'Fill',
1735           xns : Roo.Toolbar,
1736           '|xns' : 'Roo.Toolbar'
1737          },
1738          {
1739           xtype : 'Button',
1740           cls : 'x-btn-text-icon',
1741           icon : rootURL + '/Pman/templates/images/trash.gif',
1742           text : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
1743           listeners : {
1744            click : function()
1745             {
1746                 var sel = _this.child_element_grid.selModel.getSelected();
1747                 
1748                 if(!sel || sel.data.id * 1< 1){
1749                     Roo.MessageBox.alert("Error", "Select page to delete");
1750                     return;
1751                 }
1752                 
1753                 new Pman.Request({
1754                     method : 'POST',
1755                     url : baseURL + '/Roo/cms_page',
1756                     params : {
1757                         id : sel.data.id,
1758                         is_deleted : 1
1759                     },
1760                     success : function() { 
1761                         _this.child_element_grid.footer.onClick('refresh');
1762                     }
1763                 });
1764             }
1765           },
1766           xns : Roo.Toolbar,
1767           '|xns' : 'Roo.Toolbar'
1768          }
1769         ]
1770        },
1771        dataSource : {
1772         xtype : 'Store',
1773         remoteSort : true,
1774         sortInfo : { field : 'created' , direction : 'DESC' },
1775         listeners : {
1776          beforeload : function (_self, options)
1777           {
1778               options.params = options.params || {};
1779               
1780               var  sel = _this.grid.selModel.getSelected();
1781               
1782               if(
1783                   !sel || 
1784                   sel.data.id * 1< 1 || 
1785                   sel.data.page_type_id_name != 'page' ||
1786                   sel.data.template_id * 1 < 1
1787               ){
1788                   this.removeAll();
1789                   
1790                   _this.child_element_panel.region.collapse();
1791                   
1792                   return false;
1793               }
1794               
1795               _this.child_element_panel.region.expand();
1796               
1797               options.params._list_elements = sel.data.id;
1798               
1799               if (_this.child_show_deleted.pressed) {
1800                   options.params._show_deleted = 1;
1801               }
1802               
1803           },
1804          update : function (_self, record, operation)
1805           {
1806               if (operation != 'commit') {
1807                   return;
1808               }
1809               // only used to change active status.
1810               
1811               new Pman.request({\r
1812                   method : 'POST',\r
1813                   url : baseURL + '/Roo/Cms_page',\r
1814                   params : {\r
1815                       id : record.data.id,\r
1816                       is_draft : record.data.is_draft\r
1817                   },
1818                   success : function(res) {
1819                      _this.child_element_grid.footer.onClick('refresh');
1820                  }\r
1821               });
1822           }
1823         },
1824         xns : Roo.data,
1825         '|xns' : 'Roo.data',
1826         proxy : {
1827          xtype : 'HttpProxy',
1828          method : 'GET',
1829          url : baseURL + '/Roo/cms_page.php',
1830          xns : Roo.data,
1831          '|xns' : 'Roo.data'
1832         },
1833         reader : {
1834          xtype : 'JsonReader',
1835          fields : [
1836              {
1837                  'name': 'id',
1838                  'type': 'int'
1839              },
1840              {
1841                  'name': 'title',
1842                  'type': 'string'
1843              },
1844              {
1845                  'name': 'element_id_name',
1846                  'type': 'string'
1847              },
1848              {
1849                  'name': 'seq_id',
1850                  'type': 'int'
1851              },
1852              {
1853                  'name': 'is_draft',
1854                  'type': 'int'
1855              },
1856              {
1857                  'name': 'is_deleted',
1858                  'type': 'int'
1859              },
1860              {
1861                  'name': 'language',
1862                  'type': 'string'
1863              },
1864              {
1865                  'name': 'translation_type',
1866                  'type': 'string'
1867              }
1868          ],
1869          id : 'id',
1870          root : 'data',
1871          totalProperty : 'total',
1872          xns : Roo.data,
1873          '|xns' : 'Roo.data'
1874         }
1875        },
1876        sm : {
1877         xtype : 'RowSelectionModel',
1878         singleSelect : true,
1879         xns : Roo.grid,
1880         '|xns' : 'Roo.grid'
1881        },
1882        cm : [
1883         {
1884          xtype : 'ColumnModel',
1885          dataIndex : 'is_draft',
1886          header : _this._strings['4d3d769b812b6faa6b76e1a8abaece2d'] /* Active */,
1887          renderer : function(v,x,r) {
1888               
1889              var state = v> 0 ?  '' : '-checked';
1890          
1891              return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
1892          },
1893          width : 50,
1894          xns : Roo.grid,
1895          '|xns' : 'Roo.grid'
1896         },
1897         {
1898          xtype : 'ColumnModel',
1899          dataIndex : 'element_id_name',
1900          header : _this._strings['ce5bf551379459c1c61d2a204061c455'] /* Location */,
1901          renderer : function(v,x,r) { 
1902          
1903              var fmt = (r.data.is_deleted ? '<s>{0}</s>' : '{0}');
1904              
1905              return String.format( fmt, v);
1906           },
1907          width : 100,
1908          xns : Roo.grid,
1909          '|xns' : 'Roo.grid'
1910         },
1911         {
1912          xtype : 'ColumnModel',
1913          dataIndex : 'title',
1914          header : _this._strings['b78a3223503896721cca1303f776159b'] /* Title */,
1915          renderer : function(v,x,r) { 
1916          
1917              var fmt = (r.data.is_deleted ? '<s>{0}</s>' : '{0}');
1918              
1919              return String.format( fmt, v);
1920           },
1921          width : 75,
1922          xns : Roo.grid,
1923          '|xns' : 'Roo.grid'
1924         },
1925         {
1926          xtype : 'ColumnModel',
1927          dataIndex : 'language',
1928          header : _this._strings['a1fa27779242b4902f7ae3bdd5c6d508'] /* Type */,
1929          renderer : function(v, x, r) 
1930          {
1931              var ret = [];
1932              
1933              if (r.data.language.length) {
1934                  ret.push('&gt;&gt; ' + Pman.I18n.toName('l', r.data.language));
1935              }
1936              
1937              if(r.data.translation_type.length){
1938              
1939                  var types = r.data.translation_type.split(',');
1940                  
1941                  Roo.each(types, function(t){
1942                      ret.push('&gt;&gt; ' + Pman.I18n.toName('l', t));
1943                  });
1944              }
1945              
1946              return ret.join("<br/>");
1947              
1948          },
1949          width : 100,
1950          xns : Roo.grid,
1951          '|xns' : 'Roo.grid'
1952         },
1953         {
1954          xtype : 'ColumnModel',
1955          dataIndex : 'seq_id',
1956          header : _this._strings['7ee49db2b46c732d681edc761cf487ae'] /* Postion */,
1957          renderer : function(v,x,r) 
1958          { 
1959              
1960              var fmt = String.format(
1961                          '<a href="#" class="down" style="font-weight: bold; font-size: 20px; text-decoration: none;" tooltip="Down">&uarr;</a>' +
1962                          '<a href="#" class="up" style="font-weight: bold; font-size: 20px; text-decoration: none; margin-left: 15px;" tooltip="Up">&darr;</a>'
1963                      );
1964                      
1965              return fmt;
1966              
1967          },
1968          width : 75,
1969          xns : Roo.grid,
1970          '|xns' : 'Roo.grid'
1971         },
1972         {
1973          xtype : 'ColumnModel',
1974          dataIndex : 'seq_id',
1975          header : _this._strings['7ee49db2b46c732d681edc761cf487ae'] /* Postion */,
1976          hidden : true,
1977          renderer : function(v,x,r) 
1978          { 
1979              
1980              return v *1;
1981              
1982          },
1983          width : 50,
1984          xns : Roo.grid,
1985          '|xns' : 'Roo.grid'
1986         }
1987        ]
1988       }
1989      }
1990     ]
1991    }
1992   };  }
1993 });