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