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