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