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