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