DataObjects/Cms_page.php
[Pman.Cms] / Pman.Dialog.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.Dialog');
6
7 Pman.Dialog.CmsBlog = {
8
9  _strings : {
10   '2f26e35d61be90501e099089dc533638' :"Select Images",
11   'f3912172e6bf57f8979782f4a2342233' :"Appears in Block",
12   '95cb4f45ab7ff3984f25ab8668499020' :"Select Parent",
13   'c1df1da7a1ce305a3b60af9d5733ac1d' :"Contents",
14   'f2a6c498fb90ee345d997f888fce3b18' :"Delete",
15   'ebd9bec4d70abc789d439c1f136b0538' :"Layout",
16   '20bec77364d863100a1f9325873a8504' :"Select Page Type",
17   'a517747c3d12f99244ae598910d979c5' :"Author",
18   '31fde7b05ac8952dacf4af8a704074ec' :"Preview",
19   '779e2624ddf330fb05b51ae59faf212d' :"Select Status Type",
20   '6a5b847af3d97df722040debdbccfbed' :"Page Type",
21   '30d1a216420426fcbd43ca70acd4aa48' :"Select interests",
22   'cc6892c9705afcfa61c53698756ba51b' :"Page Class",
23   'e6b391a8d2c4d45902a23a8b6585703d' :"URL",
24   '03368e3c1eb4d2a9048775874301b19f' :"Select category",
25   'ec211f7c20af43e742bf2570c3cb84f9' :"Add",
26   '778551900655782c5c7827332b08cf3f' :"Save and close",
27   '77174410b72decfd0b259961f1f65a8f' :"Attributes:",
28   'b28a711cf7e94ec793ef926633997529' :"Seq",
29   '1243daf593fa297e07ab03bf06d925af' :"Searching...",
30   '8a53accfc94c2500b00575ce0e0d786f' :"Primary Image",
31   '580b21aac58f1b73cece26e272cdfbee' :"Add Link",
32   '8bc84316c4078bf66723fd019616d920' :"Descriptions",
33   '83dad8107f9459efe2b4fabcf5b63108' :"Select Language",
34   '76729937a5eb6b0fd88c42581161facd' :"Select Category ",
35   '14c21301c0faf9d5561b8a580be21a13' :"Select class",
36   '0b8d92bc19b720bb1065649535463409' :"Translations",
37   'd41d8cd98f00b204e9800998ecf8427e' :"",
38   '867343577fa1f33caa632a19543bd252' :"Keywords",
39   '340c2ee497b85d5954b01c64de7f44f6' :"Select Person",
40   '69dd756ae9c23191a5bb9b61f0857432' :"Date to Publish",
41   '3adbdb3ac060038aa0e6e6c138ef9873' :"Category",
42   '57e195426892c5515935f21d97228814' :"Extended Contents",
43   'd88aa1eee60ba140f07d5f81769cec74' :"<< Edit Translations",
44   'b9c49611cfda3259a2b837b39489e650' :"Add Image",
45   'ea4788705e6873b424c65e91c2846b19' :"Cancel",
46   'cfcd208495d565ef66e7dff9f98764da' :"0",
47   'd8e4d1f5e445107e505b2cf63a1fb65c' :"Extra CSS",
48   'bd88a20b53a47f7b5704a83a15ff5506' :"Saved Version",
49   '31bb2f6e9b8fb11cbb7fb63c6025223f' :"Select Template",
50   'c02bd0c22c290ae599ee2f3ff2023fd3' :"Manage Images / Attachments >>",
51   'b78a3223503896721cca1303f776159b' :"Title",
52   '39f64cc9436cacfbceda3b7bdeb8e24c' :"Styles (CSS)",
53   'e64df1d7c22b9638f084ce8a4aff3ff3' :"Target URL",
54   '98e93e8f7adfe14832db6caed713d849' :"Meta Tags",
55   'a240fa27925a635b08dc28c9e4f9216d' :"Order",
56   '287234a1ff35a314b5b6bc4e5828e745' :"Attributes",
57   '99e7707748ae048e17c5810fad119e0b' :"Select Page",
58   '06933067aafd48425d67bcb01bba5cb6' :"Update",
59   '8adedb6a6226807ba810215dd3b3c61b' :"Menu links to Page",
60   'b5216c9b4e0ac0afd9c76eb1d12ad1b9' :"Select Section",
61   '308f2757bfc9ce92fb00ff93fdffd279' :"Images / Attachments",
62   '76eb64a1725ee953c664e15c9213b2fd' :"Extended Content",
63   '1351017ac6423911223bc19a8cb7c653' :"Filename",
64   'c9cc8cce247e49bae79f15173ce97354' :"Save",
65   'e659b52eba1f0299b2d8ca3483919e72' :"Type:",
66   'c70952e4ab3806c049737cd7d2b8896b' :"Interests",
67   'aa6356b678bc4fc78253c9edf65bff03' :"Edit Page / Blog Entry",
68   'd52f80f80467bb575253a5a39ca016a7' :"Page link /  Name / Order",
69   'fff0d600f8a0b5e19e88bfb821dd1157' :"Images",
70   '30269022e9d8f51beaabb52e5d0de2b7' :"Parent",
71   'fb3f11443065d5f4d8303ad913db9680' :"Replaces (ignore)"
72  },
73
74  dialog : false,
75  callback:  false,
76
77  show : function(data, cb)
78  {
79   if (!this.dialog) {
80    this.create();
81   }
82
83   this.callback = cb;
84   this.data = data;
85   this.dialog.show(this.data._el);
86   if (this.form) {
87    this.form.reset();
88    this.form.setValues(data);
89    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
90   }
91
92  },
93
94  create : function()
95  {
96    var _this = this;
97    this.dialog = Roo.factory({
98     xtype : 'LayoutDialog',
99     background : true,
100     closable : true,
101     collapsible : false,
102     height : 600,
103     modal : true,
104     resizable : false,
105     setStylesheets : function() {
106         var sheets = [];
107         
108         sheets.push(rootURL + '/Pman/Cms/templates/undoreset.css');
109         
110         if(typeof(uiConfig) !== 'undefined'  && typeof(uiConfig.cms_css) != 'undefined'){
111             Roo.each(uiConfig.cms_css, function(v){
112                 sheets.push(rootURL + v);
113             })
114         }
115         
116         new Pman.Request({
117            url : baseURL + '/Roo/Cms_page.php',
118            method : 'GET',
119            params : {
120                _stylesheets : 1
121            }, 
122            success : function(res) {
123                 Roo.log(res);
124                 if(res.data._stylesheets.length){
125                     var setting = res.data._stylesheets.split("\n");
126                     
127                     Roo.each(setting, function(s){
128                         sheets.push(s.replace('{rootURL}', rootURL));
129                     });
130                     
131                 }
132     
133                 _this.form1.findField('body').removeStylesheets();
134                 _this.form2.findField('extended').removeStylesheets();
135     
136                 _this.form1.findField('body').setStylesheets(sheets);
137                 _this.form2.findField('extended').setStylesheets(sheets);
138     
139                 _this.trform1.findField('body').removeStylesheets();
140                 _this.trform2.findField('extended').removeStylesheets();
141                 
142                 _this.trform1.findField('body').setStylesheets(sheets);
143                 _this.trform2.findField('extended').setStylesheets(sheets);
144            }
145        });
146     
147     },
148     title : _this._strings['aa6356b678bc4fc78253c9edf65bff03'] /* Edit Page / Blog Entry */,
149     width : 850,
150     listeners : {
151      show : function (_self)
152       {
153           // @see the contentpanel - center - resize handler.
154       
155           _this.centerLayoutPanel.getLayout().getRegion('south').showPanel(0);
156           
157           var w = Roo.lib.Dom.getViewWidth();
158           var h = Roo.lib.Dom.getViewHeight();
159           this.resizeTo(w-50, h-50);
160           this.center();
161           
162           _this.centerLayoutPanel.getLayout().getRegion('south').resizeTo(h - 450);
163           
164           _this.westLayoutPanel.getLayout().getRegion('south').resizeTo(h - 450);
165           
166           Pman.Cms.pageEditAddCustomFields();
167           
168           /*
169           var ew = Math.max(250, w-150); // was 350?/ why?
170           //var eh = Math.max(250, h-350) ;
171           var eh = 200;
172           
173           var bd = _this.form1.findField('body');
174           
175           if (bd.resizeEl) { 
176               bd.width = ew;
177               bd.height = eh;
178               // since render delays resize.. 
179              bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );
180               //_this.bodycol.el.setWidth(bd.width+20);
181           }
182           var bd = _this.form2.findField('extended');
183           if (bd.resizeEl) { 
184               bd.width = ew;
185               bd.height = eh;
186               // since render delays resize.. 
187              bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );
188            //  _this.extendcol.el.setWidth(bd.width+20);
189           }
190            var bd = _this.form3.findField('extra_css');
191           if (bd) { 
192               bd.el.setWidth(ew);
193              //_this.keywordscol.el.setWidth(ew+20);
194           }
195           
196           // fix messed up scroll.
197           _this.dialog.layout.el.dom.scrollTop = 0;
198           
199           */
200       }
201     },
202     xns : Roo,
203     '|xns' : 'Roo',
204     center : {
205      xtype : 'LayoutRegion',
206      titlebar : false,
207      xns : Roo,
208      '|xns' : 'Roo'
209     },
210     east : {
211      xtype : 'LayoutRegion',
212      collapsed : true,
213      collapsedTitle : 'Images / Attachments',
214      collapsible : true,
215      fitToFrame : true,
216      split : true,
217      title : _this._strings['308f2757bfc9ce92fb00ff93fdffd279'] /* Images / Attachments */,
218      titlebar : true,
219      listeners : {
220       expanded : function (_self)
221        {
222            var id = _this.form.findField('id').getValue() * 1;
223            
224            if(id < 1){
225                Roo.MessageBox.alert('Error', 'Save first');
226                this.collapse();
227                return;
228            }
229            
230            var w = Roo.lib.Dom.getViewWidth();
231            var h = Roo.lib.Dom.getViewHeight();
232            
233            _self.resizeTo.defer(110, _self,[ w-400,  h] );
234            _this.dialog.getLayout().getRegion('west').collapse();
235        }
236      },
237      xns : Roo,
238      '|xns' : 'Roo'
239     },
240     west : {
241      xtype : 'LayoutRegion',
242      collapsed : true,
243      collapsedTitle : 'Translations',
244      collapsible : true,
245      fitToFrame : true,
246      split : true,
247      title : _this._strings['0b8d92bc19b720bb1065649535463409'] /* Translations */,
248      titlebar : true,
249      listeners : {
250       beforecollapse : function (_self)
251        {
252            if(!_this.trform || !_this.trform1 || !_this.trform2){
253                return true;
254            }
255            
256            if(
257                !_this.trform.isDirty() &&
258                !_this.trform1.isDirty() &&
259                !_this.trform2.isDirty() &&
260                !_this.trform3.isDirty()
261            ) {
262                return true;
263            }
264            
265            Roo.MessageBox.confirm(
266                "Confirm", 
267                "Do you want to save the translation",
268                function(res) {
269                    if(res != 'yes') {
270                        _self.collapse(true, true);
271                        return true;
272                    }
273                    
274                    return false;
275                }
276            );
277            
278            return false;
279        },
280       expanded : function (_self)
281        {
282            var id = _this.form.findField('id').getValue() * 1;
283            
284            if(id < 1){
285                Roo.MessageBox.alert('Error', 'Save first');
286                this.collapse();
287                return;
288            }
289            
290            var w = Roo.lib.Dom.getViewWidth();
291            var h = Roo.lib.Dom.getViewHeight();
292            
293            _self.resizeTo.defer(110, _self,[ w-400,  h-350] );
294            
295            _this.panel.region.collapse();
296            
297        }
298      },
299      xns : Roo,
300      '|xns' : 'Roo'
301     },
302     buttons : [
303      {
304       xtype : 'Button',
305       text : _this._strings['31fde7b05ac8952dacf4af8a704074ec'] /* Preview */,
306       listeners : {
307        click : function() {
308             
309             var page_link = _this.form.findField('page_link').getValue();
310             
311             if(!page_link.length){
312                 Roo.MessageBox.alert('Error', 'Please fill in the page link');
313                 return;
314             }
315             
316             if(!uiConfig || typeof(uiConfig.cms_page_preview_base) == 'undefined'){
317                 Roo.MessageBox.alert('Error', 'Please setup [cms_page_preivew_base] in uiConfig');
318                 return;
319             }
320             
321             var url = uiConfig.cms_page_preview_base + page_link;
322             
323             window.open(url);
324         }
325       },
326       xns : Roo,
327       '|xns' : 'Roo'
328      },
329      {
330       xtype : 'Button',
331       text : _this._strings['ea4788705e6873b424c65e91c2846b19'] /* Cancel */,
332       listeners : {
333        click : function() {
334         
335             if(
336                 _this.trform.isDirty() ||
337                 _this.trform1.isDirty() ||
338                 _this.trform2.isDirty() ||
339                 _this.trform3.isDirty()
340             ) {
341                 Roo.MessageBox.confirm(
342                     "Confirm", 
343                     "Do you want to save the translation",
344                     function(res) {
345                         if(res != 'yes') {
346                             _this.form.reset();
347         
348                             _this.dialog.hide();
349                             return;
350                         }
351                         
352                     }
353                 );
354                 
355                 return;
356             }
357             
358             _this.form.reset();
359         
360             _this.dialog.hide();
361         
362         }
363       },
364       xns : Roo,
365       '|xns' : 'Roo'
366      },
367      {
368       xtype : 'Button',
369       text : _this._strings['c9cc8cce247e49bae79f15173ce97354'] /* Save */,
370       listeners : {
371        click : function() {
372             _this.exit = false;
373             
374             if(!_this.form1.findField('body').editorcore.sourceEditMode){
375                 _this.form1.findField('body').syncValue();
376                 _this.form2.findField('extended').syncValue();
377                 Roo.log('syncValue');
378             }else{
379                 _this.form1.findField('body').pushValue();
380                 _this.form2.findField('extended').pushValue();
381                 Roo.log('pushValue');
382             }
383             
384             if(_this.data.page_type_id_name != 'blog' && AppModules.indexOf("Crm") == -1){
385                 _this.interests.reset();
386             }
387                 
388             if(
389                 _this.trform.isDirty() ||
390                 _this.trform1.isDirty() ||
391                 _this.trform2.isDirty() ||
392                 _this.trform3.isDirty()
393             ) {
394                 Roo.MessageBox.confirm(
395                     "Confirm", 
396                     "Do you want to save the translation",
397                     function(res) {
398                         if(res != 'yes') {
399                             _this.dialog.el.mask("Saving");
400                             _this.form.doAction("submit");
401                             return;
402                         }
403                         
404                     }
405                 );
406                     
407                 return;
408             }
409             
410             _this.dialog.el.mask("Saving");
411             _this.form.doAction("submit");
412         
413         }
414       },
415       xns : Roo,
416       '|xns' : 'Roo'
417      },
418      {
419       xtype : 'Button',
420       text : _this._strings['778551900655782c5c7827332b08cf3f'] /* Save and close */,
421       listeners : {
422        click : function() {
423         
424                 _this.exit = true;
425                
426                if(!_this.form1.findField('body').editorcore.sourceEditMode){
427                     _this.form1.findField('body').syncValue();
428                     _this.form2.findField('extended').syncValue();
429                 }else{
430                     _this.form1.findField('body').pushValue();
431                     _this.form2.findField('extended').pushValue();
432                 }
433                 
434                 if(_this.data.page_type_id_name != 'blog' && AppModules.indexOf("Crm") == -1){
435                     _this.interests.reset();
436                 }
437                 
438                 
439                 if(
440                     _this.trform.isDirty() ||
441                     _this.trform1.isDirty() ||
442                     _this.trform2.isDirty() ||
443                     _this.trform3.isDirty()
444                 ) {
445                     Roo.MessageBox.confirm(
446                         "Confirm", 
447                         "Do you want to save the translation",
448                         function(res) {
449                             if(res != 'yes') {
450                                 _this.dialog.el.mask("Saving");
451                                 _this.form.doAction("submit");
452                                 return;
453                             }
454                             
455                         }
456                     );
457                     
458                     return;
459                 }
460                 
461             _this.dialog.el.mask("Saving");
462              _this.form.doAction("submit");
463         
464         }
465       },
466       xns : Roo,
467       '|xns' : 'Roo'
468      }
469     ],
470     items  : [
471      {
472       xtype : 'NestedLayoutPanel',
473       background : false,
474       fitContainer : true,
475       fitToFrame : true,
476       region : 'center',
477       listeners : {
478        render : function (_self)
479         {
480             _this.centerLayoutPanel = this;
481             
482         }
483       },
484       xns : Roo,
485       '|xns' : 'Roo',
486       layout : {
487        xtype : 'BorderLayout',
488        xns : Roo,
489        '|xns' : 'Roo',
490        center : {
491         xtype : 'LayoutRegion',
492         tabPosition : 'top',
493         xns : Roo,
494         '|xns' : 'Roo'
495        },
496        south : {
497         xtype : 'LayoutRegion',
498         height : 250,
499         split : true,
500         tabPosition : 'top',
501         xns : Roo,
502         '|xns' : 'Roo'
503        },
504        items  : [
505         {
506          xtype : 'ContentPanel',
507          autoScroll : true,
508          fitToFrame : true,
509          region : 'center',
510          listeners : {
511           render : function (_self)
512            {
513              _this.cpanel = _self;
514            },
515           resize : function (_self, width, height)
516            {
517                Roo.log("RESIZE, " + width + ',' + height);
518                
519                var ew = Math.max(250, width - 10);
520                var eh = _this.centerLayoutPanel.getLayout().getRegion('south').el.getHeight() - 30;
521                
522                if (!_this.form) {
523                    return;
524                }
525                var bd;
526                if (_this.form1) {
527                    bd = _this.form1.findField('body');
528                    if (bd.resizeEl) { 
529                        bd.width = ew;
530                        bd.height = eh;
531                        // since render delays resize.. 
532                        Roo.log('resizing body to ' + bd.width);        
533                       bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );
534                     //   _this.bodycol.el.setWidth(bd.width+20);
535                    }
536                }
537                
538                if (_this.form2) {
539                    bd = _this.form2.findField('extended');
540                    
541                    if (bd.resizeEl) { 
542                        bd.width = ew;
543                        bd.height = eh;
544                        
545                        Roo.log('resizing extended to ' + bd.width);
546                        // since render delays resize.. 
547                       bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );
548                    //   _this.extendcol.el.setWidth(bd.width+20);
549                    }
550                }
551                if (_this.form3) {
552                    
553                    bd = _this.form3.findField('extra_css');
554                    if (bd) { 
555                        bd.el.setWidth(ew);
556                        bd.el.setHeight(eh);
557                   //    _this.keywordscol.el.setWidth(ew+20);
558                    }
559                // fix for messed up rendering of dialog?
560                }
561                
562                try { 
563                    _this.dialog.layout.el.dom.scrollTop = 0;
564                } catch (e) { 
565                    // noop... - the above sometimes fails...
566                }
567            }
568          },
569          xns : Roo,
570          '|xns' : 'Roo',
571          toolbar : {
572           xtype : 'Toolbar',
573           xns : Roo,
574           '|xns' : 'Roo',
575           items  : [
576            {
577             xtype : 'Button',
578             text : _this._strings['d88aa1eee60ba140f07d5f81769cec74'] /* << Edit Translations */,
579             listeners : {
580              click : function (_self, e)
581               {
582                   if (_this.dialog.getLayout().getRegion('west').collapsed) {
583                       _this.dialog.getLayout().getRegion('west').expand();
584                   } else {
585                       _this.dialog.getLayout().getRegion('west').collapse();
586                   }
587                   
588               }
589             },
590             xns : Roo.Toolbar,
591             '|xns' : 'Roo.Toolbar'
592            },
593            {
594             xtype : 'Fill',
595             xns : Roo.Toolbar,
596             '|xns' : 'Roo.Toolbar'
597            },
598            {
599             xtype : 'Button',
600             text : _this._strings['c02bd0c22c290ae599ee2f3ff2023fd3'] /* Manage Images / Attachments >> */,
601             listeners : {
602              click : function (_self, e)
603               {
604                   if (_this.panel.region.collapsed) {
605                       _this.panel.region.expand();
606                   } else {
607                       _this.panel.region.collapse();
608                   }
609                   
610               }
611             },
612             xns : Roo.Toolbar,
613             '|xns' : 'Roo.Toolbar'
614            }
615           ]
616          },
617          items  : [
618           {
619            xtype : 'Form',
620            is_copy : function() 
621            { 
622                _this.form.setValues(_this.data);
623                
624                var d = _this.data;
625            
626                _this.dialog.el.unmask();
627               _this.grid.getDataSource().load();
628               
629               _this.trform.reset();
630               _this.trform1.reset();
631               _this.trform2.reset();
632               
633               _this.form1.findField('body').originalValue = _this.form1.findField('body').getValue();
634               _this.form2.findField('extended').originalValue = _this.form2.findField('extended').getValue();
635               
636               /*
637                var catlabel= _this.form.findField('category_page_id').fieldEl.select('label',true).first()
638                catlabel.dom.innerHTML = 'Category';            
639                
640                if(_this.data.page_type_id_name == 'category'){
641                    catlabel.dom.innerHTML = 'Parent Category';
642                }
643                */
644                /*
645                var catlabel= _this.form.findField('parent_id').fieldEl.select('label',true).first();
646                catlabel.dom.innerHTML = 'Parent page';            
647                if(_this.data.page_type_id_name == 'category'){
648                    catlabel.dom.innerHTML = 'Parent';
649                }
650                */
651                // better if this was not here... - not sure which project uses it?
652                
653                if(_this.data.page_type_id_name == 'blog' && AppModules.indexOf("Crm") !== -1){
654                    _this.interestsCol.show();
655                }
656                
657                if(typeof(d['interests']) != 'undefined'){
658                    _this.form.findField('interest').setValue(Roo.decode(d['interests']));
659                }
660                
661                if(typeof(d['categories']) != 'undefined'){
662                    _this.form.findField('category').setValue(Roo.decode(d['categories']));
663                }
664                
665                if(typeof(d['page_classes']) != 'undefined'){
666                    _this.form.findField('page_cls').setValue(Roo.decode(d['page_classes']));
667                }
668                
669                _this.trpanel.el.unmask();
670                _this.panel.el.unmask();
671                
672                // fix scrolling..
673                _this.cpanel.el.dom.scrollTop = 0;
674                
675                // fix messed up scroll.
676                _this.dialog.layout.el.dom.scrollTop = 0;
677                return;
678            },
679            labelAlign : 'right',
680            labelWidth : 120,
681            method : 'POST',
682            showHide : function()
683            {
684                var in_rss= 0;
685                var is_menu= 0;
686                var is_element  = 0;
687                var is_category = 0;
688                
689                var page_type_name = _this.form.findField('page_type_id_name').getValue();
690                
691                switch(page_type_name){
692                    case 'page' :
693                        is_element = 0;
694                    break;
695                    
696                    case 'element' :
697                        is_element = 1;
698                    break;
699                    
700                    case 'blog' :
701                        in_rss = 1;
702                    break;
703                    
704                    case 'menu' :
705                        is_menu = 1;
706                    break;
707                    
708                    case 'category' :
709                        in_rss = 1;
710                        is_category = 1;
711                    break;
712                }
713                
714                var is_system_page = _this.form.findField('is_system_page').getValue() * 1;
715                var is_attachment = _this.form.findField('is_attachment').getValue() * 1;
716                var has_extended = _this.form.findField('has_extended').getValue() * 1;
717                
718                var vis = {
719                    is_attachment : !in_rss,
720                    
721                    category_type_id : in_rss && !is_menu,
722                    page_link : 1, //!in_rss, // always show page link.. may not be needed though..
723                    target_url : is_menu,
724                    
725                    category : !is_category,
726                    
727                    parent_id : !in_rss || is_category ,
728                    published : in_rss ,
729                    
730                    to_replace_id :false, // !in_rss, // is this used.
731                    is_draft : !is_system_page,
732                    author_id : in_rss && !is_menu  && !is_attachment,
733                    
734                    template_id : !is_attachment && !is_menu && !is_system_page,
735                    element_id : is_element &&   !is_menu, 
736                    menu_page_id : is_menu,
737                    page_cls : is_element
738             
739                  //  has_extended : !is_menu && !is_attachment, // always shown.
740                  //  extended : has_extended && !is_menu  && !is_attachment,
741                   // body : !is_attachment && !is_menu,
742                    //keywords : !is_attachment && !is_menu, 
743                   // descriptions : !is_attachment && !is_menu
744                   // extra_css : !is_attachment && !is_menu
745                };
746            
747                for(var k in vis) {
748                    var el = _this.form.findField(k);
749                    
750                    if (!el) {
751                        Roo.log("missing field " + k);
752                        continue;
753                    }
754                    
755                    el.actionMode = 'fieldEl';
756                    
757                    if (vis[k]) {
758                        el.show();
759                    } else{
760                        el.hide();
761                    }
762                    
763                }
764                
765                _this.centerLayoutPanel.getLayout().getRegion('south').show();
766                _this.centerLayoutPanel.getLayout().getRegion('south').unhidePanel(0);
767                _this.centerLayoutPanel.getLayout().getRegion('south').unhidePanel(1);
768                _this.centerLayoutPanel.getLayout().getRegion('south').unhidePanel(2);
769                _this.centerLayoutPanel.getLayout().getRegion('south').unhidePanel(3);
770                
771                if(is_attachment || is_menu){
772                
773                    _this.centerLayoutPanel.getLayout().getRegion('south').hide();
774                    
775                }
776                
777                if(!has_extended && !is_attachment && !is_menu){
778                    _this.centerLayoutPanel.getLayout().getRegion('south').hidePanel(1);
779                    _this.centerLayoutPanel.getLayout().getRegion('south').showPanel(0);
780                }
781                
782                
783                _this.trform.showHide();
784                
785                if(typeof(_this.form.editors) == 'undefined'){
786                    _this.form.editors = {
787                        body : _this.form1.findField('body').wrap.isVisible(),
788                        extended : _this.form2.findField('extended').wrap.isVisible()
789                   };
790                   
791                   if(_this.form.editors.body){
792                        setInterval(_this.form1.findField('body').autosave, 60000);
793                   }
794                   
795                   if(_this.form.editors.extended){
796                        setInterval(_this.form2.findField('extended').autosave, 60000);
797                   }
798               }
799               
800               if(!_this.form.editors.body && _this.form1.findField('body').wrap.isVisible()){
801                    setInterval(_this.form1.findField('body').autosave, 60000);
802                    _this.form.editors.body = true;
803               }
804               
805               if(!_this.form.editors.extended && _this.form2.findField('extended').wrap.isVisible()){
806                    setInterval(_this.form2.findField('extended').autosave, 60000);
807                    _this.form.editors.extended = true;
808               }
809                
810                
811                
812            },
813            style : 'margin: 5px',
814            url : baseURL + '/Roo/cms_page.php',
815            listeners : {
816             actioncomplete : function (_self, action)
817              {
818              
819                 if (action.type == 'setdata') {
820              
821                      _this.form.addForm(_this.form1);
822                      _this.form.addForm(_this.form2);
823                      _this.form.addForm(_this.form3);
824                      _this.form.addForm(_this.form4);
825                      
826                      _this.dialog.setStylesheets();
827                      
828                      _this.dialog.getLayout().getRegion('west').collapse();
829                      _this.panel.region.collapse();
830                      
831                      _this.trpanel.el.mask('Save first');
832                      _this.panel.el.mask('Save first');
833                      
834                      _this.loaded = false;
835                      _this.interestsCol.hide();
836                      
837                      //_this.form.findField('category_page_id').fieldEl.select('label',true).first().dom.innerHTML = 'Category';
838                      
839                      if ( _this.data.id) {
840                          _this.dialog.el.mask("Loading");
841                          this.load({ method: 'GET', params: { '_id' : _this.data.id, '_with_primary_image' : 1 }});
842                      } else {
843              
844                          _this.loaded = true;
845                          var is_draft = typeof(_this.data.is_draft) != 'undefined' ? _this.data.is_draft : 1;
846                          this.findField('is_draft').setValue(is_draft);
847                          _this.page_type.setValue(_this.data.page_type_id);
848                          _this.page_type.el.dom.value = _this.data.page_type_id_display_name;
849                          
850                          if(_this.data.page_type_id_name == 'blog' && AppModules.indexOf("Crm") !== -1){
851                              _this.interestsCol.show();
852                          }
853                          
854                          _this.form.showHide();
855                          
856                          /*
857                          var catlabel= _this.form.findField('category_page_id').fieldEl.select('label',true).first()
858                          catlabel.dom.innerHTML = 'Category';            
859                          if(_this.data.page_type_id_name == 'category'){
860                              catlabel.dom.innerHTML = 'Parent Category';
861                          } 
862                          */
863                          
864                          /*
865                          var catlabel= _this.form.findField('parent_id').fieldEl.select('label',true).first();
866                          catlabel.dom.innerHTML = 'Parent page';
867                          if(_this.data.page_type_id_name == 'category'){
868                              catlabel.dom.innerHTML = 'Parent';
869                          }
870                          */
871                          
872                      }
873                      
874                      if(_this.data._is_copy){
875                          _this.form.is_copy();
876                      }
877                      
878                      return;
879                  }
880                  
881                  if (action.type == 'load') {
882                  
883                      //_this.data = action.result.data;
884                      
885                      var d = action.result.data;
886                      
887                      _this.dialog.el.unmask();
888                     _this.grid.getDataSource().load();
889                     
890                     _this.trform.reset();
891                     _this.trform1.reset();
892                     _this.trform2.reset();
893                     
894                     _this.trform.addForm(_this.trform1);
895                     _this.trform.addForm(_this.trform2);
896                      
897                     _this.form1.findField('body').originalValue = _this.form1.findField('body').getValue();
898                     _this.form2.findField('extended').originalValue = _this.form2.findField('extended').getValue();
899                     _this.form3.findField('extra_css').originalValue = _this.form3.findField('extra_css').getValue();
900                     _this.form4.findField('keywords').originalValue = _this.form4.findField('keywords').getValue();
901                     _this.form4.findField('descriptions').originalValue = _this.form4.findField('descriptions').getValue();
902                     
903                     /*
904                      var catlabel= _this.form.findField('category_page_id').fieldEl.select('label',true).first()
905                      catlabel.dom.innerHTML = 'Category';            
906                      
907                      if(_this.data.page_type_id_name == 'category'){
908                          catlabel.dom.innerHTML = 'Parent Category';
909                      }
910                      */
911                      /*
912                      var catlabel= _this.form.findField('parent_id').fieldEl.select('label',true).first();
913                      catlabel.dom.innerHTML = 'Parent page';            
914                      if(_this.data.page_type_id_name == 'category'){
915                          catlabel.dom.innerHTML = 'Parent';
916                      }
917                      */
918                      // better if this was not here... - not sure which project uses it?
919                      
920                      if(_this.data.page_type_id_name == 'blog' && AppModules.indexOf("Crm") !== -1){
921                          _this.interestsCol.show();
922                      }
923                      
924                      if(typeof(d['interests']) != 'undefined'){
925                          _this.form.findField('interest').setValue(Roo.decode(d['interests']));
926                      }
927                      
928                      if(typeof(d['categories']) != 'undefined'){
929                          _this.form.findField('category').setValue(Roo.decode(d['categories']));
930                      }
931                      
932                      if(typeof(d['page_classes']) != 'undefined'){
933                          _this.form.findField('page_cls').setValue(Roo.decode(d['page_classes']));
934                      }
935                      
936                      _this.trpanel.el.unmask();
937                      _this.panel.el.unmask();
938                      
939                      // fix scrolling..
940                      _this.cpanel.el.dom.scrollTop = 0;
941                      
942                      // fix messed up scroll.
943                      _this.dialog.layout.el.dom.scrollTop = 0;
944                      
945                      return;
946                  }
947                  if (action.type =='submit') {
948                     
949                     _this.dialog.el.unmask();
950                     
951                     if(!_this.exit){
952                          this.load({ method: 'GET', params: { '_id' : action.result.data.id }});
953                          return;
954                     }
955                     
956                     _this.dialog.hide();
957                     
958              
959                      if (_this.callback) {
960                         _this.callback.call(_this, action.result.data);
961                      }
962                      _this.form.reset();
963                      return;
964                  }
965              },
966             actionfailed : function (_self, action)
967              {
968                  _this.dialog.el.unmask(); 
969                  Pman.standardActionFailed(_self, action);
970              },
971             rendered : function (_self)
972              {
973                  _this.form = _self;
974              }
975            },
976            xns : Roo.form,
977            '|xns' : 'Roo.form',
978            items  : [
979             {
980              xtype : 'Column',
981              labelWidth : 200,
982              width : 750,
983              xns : Roo.form,
984              '|xns' : 'Roo.form',
985              items  : [
986               {
987                xtype : 'Row',
988                hideLabels : false,
989                labelAlign : 'right',
990                labelWidth : 200,
991                style : 'height:30px;overflow:hidden',
992                width : 850,
993                xns : Roo.form,
994                '|xns' : 'Roo.form',
995                items  : [
996                 {
997                  xtype : 'Hidden',
998                  fieldLabel : _this._strings['e659b52eba1f0299b2d8ca3483919e72'] /* Type: */,
999                  width : 1,
1000                  xns : Roo.form,
1001                  '|xns' : 'Roo.form'
1002                 },
1003                 {
1004                  xtype : 'Row',
1005                  hideLabels : true,
1006                  labelWidth : 0,
1007                  style : 'height:30px;overflow:hidden',
1008                  width : 600,
1009                  xns : Roo.form,
1010                  '|xns' : 'Roo.form',
1011                  items  : [
1012                   {
1013                    xtype : 'ComboBox',
1014                    alwaysQuery : true,
1015                    displayField : 'display_name',
1016                    editable : false,
1017                    emptyText : _this._strings['779e2624ddf330fb05b51ae59faf212d'] /* Select Status Type */,
1018                    fieldLabel : _this._strings['6a5b847af3d97df722040debdbccfbed'] /* Page Type */,
1019                    forceSelection : true,
1020                    hiddenName : 'page_type_id',
1021                    listWidth : 400,
1022                    loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
1023                    minChars : 2,
1024                    name : 'page_type_id_display_name',
1025                    pageSize : 20,
1026                    qtip : _this._strings['20bec77364d863100a1f9325873a8504'] /* Select Page Type */,
1027                    selectOnFocus : true,
1028                    tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> </div>',
1029                    triggerAction : 'all',
1030                    typeAhead : false,
1031                    valueField : 'id',
1032                    listeners : {
1033                     render : function (_self)
1034                      {
1035                          _this.page_type = _self;
1036                      },
1037                     select : function (combo, record, index)
1038                      {
1039                      //    _this.grid.footer.onClick('first');
1040                          var page_type_name = record.data.name;
1041                          _this.form.findField('page_type_id_name').setValue(page_type_name);
1042                          if(page_type_name == 'blog' || page_type_name == 'category'){ // blog || category unset attachment
1043                              _this.form.findField('is_attachment').setValue(0);
1044                              return;
1045                          }
1046                          if (_this.form) { 
1047                              _this.form.showHide.defer(100, _this.form);      
1048                          } 
1049                          
1050                      }
1051                    },
1052                    xns : Roo.form,
1053                    '|xns' : 'Roo.form',
1054                    store : {
1055                     xtype : 'Store',
1056                     remoteSort : true,
1057                     sortInfo : { direction : 'ASC', field: 'seqid' },
1058                     listeners : {
1059                      beforeload : function (_self, o){
1060                           o.params = o.params || {};
1061                           // set more here
1062                           o.params.etype = 'cms_page_type'; 
1063                       }
1064                     },
1065                     xns : Roo.data,
1066                     '|xns' : 'Roo.data',
1067                     proxy : {
1068                      xtype : 'HttpProxy',
1069                      method : 'GET',
1070                      url : baseURL + '/Roo/core_enum.php',
1071                      xns : Roo.data,
1072                      '|xns' : 'Roo.data'
1073                     },
1074                     reader : {
1075                      xtype : 'JsonReader',
1076                      fields : [{"name":"id","type":"int"},{"name":"display_name","type":"string"}],
1077                      id : 'id',
1078                      root : 'data',
1079                      totalProperty : 'total',
1080                      xns : Roo.data,
1081                      '|xns' : 'Roo.data'
1082                     }
1083                    }
1084                   },
1085                   {
1086                    xtype : 'Column',
1087                    labelWidth : 60,
1088                    style : 'padding-left:  -70px;',
1089                    width : 200,
1090                    xns : Roo.form,
1091                    '|xns' : 'Roo.form',
1092                    items  : [
1093                     {
1094                      xtype : 'NumberField',
1095                      decimalPrecision : 0,
1096                      fieldLabel : _this._strings['b28a711cf7e94ec793ef926633997529'] /* Seq */,
1097                      name : 'seq_id',
1098                      width : 50,
1099                      xns : Roo.form,
1100                      '|xns' : 'Roo.form'
1101                     }
1102                    ]
1103                   }
1104                  ]
1105                 }
1106                ]
1107               },
1108               {
1109                xtype : 'Row',
1110                hideLabels : false,
1111                labelAlign : 'right',
1112                labelWidth : 200,
1113                style : 'height:30px;overflow:hidden',
1114                width : 800,
1115                xns : Roo.form,
1116                '|xns' : 'Roo.form',
1117                items  : [
1118                 {
1119                  xtype : 'Hidden',
1120                  fieldLabel : _this._strings['77174410b72decfd0b259961f1f65a8f'] /* Attributes: */,
1121                  width : 1,
1122                  xns : Roo.form,
1123                  '|xns' : 'Roo.form'
1124                 },
1125                 {
1126                  xtype : 'Row',
1127                  hideLabels : true,
1128                  labelWidth : 0,
1129                  style : 'height:30px;overflow:hidden',
1130                  width : 540,
1131                  xns : Roo.form,
1132                  '|xns' : 'Roo.form',
1133                  items  : [
1134                   {
1135                    xtype : 'Checkbox',
1136                    boxLabel : 'Draft',
1137                    fieldLabel : _this._strings['287234a1ff35a314b5b6bc4e5828e745'] /* Attributes */,
1138                    name : 'is_draft',
1139                    width : 100,
1140                    xns : Roo.form,
1141                    '|xns' : 'Roo.form'
1142                   },
1143                   {
1144                    xtype : 'Checkbox',
1145                    boxLabel : 'Has Extended content?',
1146                    inputValue : 1,
1147                    name : 'has_extended',
1148                    width : 180,
1149                    listeners : {
1150                     check : function (_self, checked)
1151                      {  
1152                         if (_this.form) {
1153                      
1154                             (function() { 
1155                                  _this.form.showHide();
1156                                  _this.panel.fireEvent('resize', _this.panel, [ _this.panel.el.getWidth(), _this.panel.el.getHeight() ]  );
1157                                  
1158                             }).defer(100);
1159                          }
1160                      }
1161                    },
1162                    xns : Roo.form,
1163                    '|xns' : 'Roo.form'
1164                   },
1165                   {
1166                    xtype : 'Checkbox',
1167                    boxLabel : 'Downloads first Attachment',
1168                    inputValue : 1,
1169                    name : 'is_attachment',
1170                    width : 180,
1171                    listeners : {
1172                     check : function (_self, checked)
1173                      {  
1174                         if (_this.form) { 
1175                       
1176                           _this.form.showHide.defer(100, _this.form);      
1177                         }
1178                      }
1179                    },
1180                    xns : Roo.form,
1181                    '|xns' : 'Roo.form'
1182                   }
1183                  ]
1184                 }
1185                ]
1186               },
1187               {
1188                xtype : 'ComboBox',
1189                allowBlank : true,
1190                displayField : 'name',
1191                editable : true,
1192                emptyText : _this._strings['340c2ee497b85d5954b01c64de7f44f6'] /* Select Person */,
1193                fieldLabel : _this._strings['a517747c3d12f99244ae598910d979c5'] /* Author */,
1194                forceSelection : true,
1195                hiddenName : 'author_id',
1196                listWidth : 400,
1197                loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
1198                minChars : 2,
1199                name : 'author_id_name',
1200                pageSize : 40,
1201                qtip : _this._strings['340c2ee497b85d5954b01c64de7f44f6'] /* Select Person */,
1202                queryParam : 'query[name]',
1203                selectOnFocus : true,
1204                tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b>  - {company_id_name}</div>',
1205                triggerAction : 'all',
1206                typeAhead : false,
1207                valueField : 'id',
1208                width : 300,
1209                xns : Roo.form,
1210                '|xns' : 'Roo.form',
1211                store : {
1212                 xtype : 'Store',
1213                 remoteSort : true,
1214                 sortInfo : { direction : 'ASC', field: 'name' },
1215                 listeners : {
1216                  beforeload : function (_self, o){
1217                       o.params = o.params || {};
1218                   
1219                       o.params.active = 1;
1220                       o.params['query[is_owner]'] = 1;
1221                   }
1222                 },
1223                 xns : Roo.data,
1224                 '|xns' : 'Roo.data',
1225                 proxy : {
1226                  xtype : 'HttpProxy',
1227                  method : 'GET',
1228                  url : baseURL + '/Roo/core_person',
1229                  xns : Roo.data,
1230                  '|xns' : 'Roo.data'
1231                 },
1232                 reader : {
1233                  xtype : 'JsonReader',
1234                  fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}],
1235                  id : 'id',
1236                  root : 'data',
1237                  totalProperty : 'total',
1238                  xns : Roo.data,
1239                  '|xns' : 'Roo.data'
1240                 }
1241                }
1242               },
1243               {
1244                xtype : 'ComboBoxArray',
1245                fieldLabel : _this._strings['3adbdb3ac060038aa0e6e6c138ef9873'] /* Category */,
1246                hiddenName : 'category',
1247                name : 'category_name',
1248                width : 400,
1249                xns : Roo.form,
1250                '|xns' : 'Roo.form',
1251                combo : {
1252                 xtype : 'ComboBox',
1253                 allowBlank : false,
1254                 alwaysQuery : true,
1255                 displayField : 'display_fullpath',
1256                 editable : true,
1257                 emptyText : _this._strings['03368e3c1eb4d2a9048775874301b19f'] /* Select category */,
1258                 fieldLabel : _this._strings['3adbdb3ac060038aa0e6e6c138ef9873'] /* Category */,
1259                 forceSelection : true,
1260                 listWidth : 400,
1261                 minChars : 2,
1262                 pageSize : 40,
1263                 queryParam : 'search[name]',
1264                 selectOnFocus : true,
1265                 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{fullpath}</b> </div>',
1266                 triggerAction : 'all',
1267                 valueField : 'id',
1268                 width : 385,
1269                 xns : Roo.form,
1270                 '|xns' : 'Roo.form',
1271                 store : {
1272                  xtype : 'Store',
1273                  remoteSort : true,
1274                  sortInfo : { field: 'tree_sequence', direction: 'ASC' },
1275                  listeners : {
1276                   beforeload : function (_self, o){
1277                        o.params = o.params || {};
1278                        
1279                        o.params.page_type_id_name= 'CATEGORY';
1280                        
1281                        o.params._with_fullpath = 1;
1282                    }
1283                  },
1284                  xns : Roo.data,
1285                  '|xns' : 'Roo.data',
1286                  proxy : {
1287                   xtype : 'HttpProxy',
1288                   method : 'GET',
1289                   url : baseURL + '/Roo/cms_page.php',
1290                   xns : Roo.data,
1291                   '|xns' : 'Roo.data'
1292                  },
1293                  reader : {
1294                   xtype : 'JsonReader',
1295                   fields : [
1296                       {"name":"id","type":"int"},
1297                       {"name":"name","type":"string"},
1298                       {"name":"display_name","type":"string"}
1299                   ],
1300                   id : 'id',
1301                   root : 'data',
1302                   totalProperty : 'total',
1303                   xns : Roo.data,
1304                   '|xns' : 'Roo.data'
1305                  }
1306                 }
1307                }
1308               },
1309               {
1310                xtype : 'ComboBox',
1311                allowBlank : true,
1312                alwaysQuery : true,
1313                displayField : 'page_link',
1314                editable : true,
1315                emptyText : _this._strings['95cb4f45ab7ff3984f25ab8668499020'] /* Select Parent */,
1316                fieldLabel : _this._strings['30269022e9d8f51beaabb52e5d0de2b7'] /* Parent */,
1317                forceSelection : true,
1318                hiddenName : 'parent_id',
1319                listWidth : 600,
1320                loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
1321                minChars : 2,
1322                name : 'parent_id_title',
1323                pageSize : 40,
1324                qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
1325                selectOnFocus : true,
1326                tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{title}</b> <i>{page_link}</i> </div>',
1327                triggerAction : 'all',
1328                typeAhead : true,
1329                valueField : 'id',
1330                width : 400,
1331                listeners : {
1332                 select : function (combo, record, index)
1333                  {
1334                     var page_type_name = _this.form.findField('page_type_id_name').getValue();
1335                     if (page_type_name == 'page') { // page
1336                          return;
1337                     }
1338                     // do not default to put 'Home' at the beginning.
1339                     if (!record || !(record.data.parent_id *1)) {
1340                          return;
1341                     }
1342                     var pl = _this.form.findField('page_link');
1343                     var lk = pl.getValue();
1344                     var new_link = record.data.page_link + '/';
1345                     if (lk.length) {
1346                          new_link += lk.split('/').pop();
1347                     }
1348                     pl.setValue(new_link);
1349                     
1350                  }
1351                },
1352                xns : Roo.form,
1353                '|xns' : 'Roo.form',
1354                store : {
1355                 xtype : 'Store',
1356                 remoteSort : true,
1357                 sortInfo : { field: 'page_link', direction: 'ASC' },
1358                 listeners : {
1359                  beforeload : function (_self, options)
1360                   {
1361                        options.params['search[page_link_no_empty]'] =1;
1362                        
1363                        if(_this.form.findField('page_type_id').getRawValue() == 'Elements'){
1364                           options.params._page_type = 'page,element';
1365                        } else {
1366                           options.params.page_type_id = _this.form.findField('page_type_id').getValue() * 1;
1367                        }
1368                        
1369                        var id = _this.form.findField('id').getValue() * 1;
1370                        
1371                        if(id > 0){
1372                           options.params['!id'] = id;
1373                        }
1374                        
1375                        
1376                        /*
1377                        options.params.is_element = 0;
1378                        var page_type_name = _this.page_type.findRecord() ? _this.page_type.findRecord().data.name: _this.firstPageType.name;
1379                        options.params.is_menuitem = page_type_name == 'menu' ? 1 : 0;    
1380                        */
1381                   }
1382                 },
1383                 xns : Roo.data,
1384                 '|xns' : 'Roo.data',
1385                 proxy : {
1386                  xtype : 'HttpProxy',
1387                  method : 'GET',
1388                  url : baseURL + '/Roo/cms_page.php',
1389                  xns : Roo.data,
1390                  '|xns' : 'Roo.data'
1391                 },
1392                 reader : {
1393                  xtype : 'JsonReader',
1394                  fields : [
1395                   { name: 'id', type: 'int' },
1396                   'title',
1397                   'page_link' 
1398                  ],
1399                  id : 'id',
1400                  root : 'data',
1401                  totalProperty : 'total',
1402                  xns : Roo.data,
1403                  '|xns' : 'Roo.data'
1404                 }
1405                }
1406               },
1407               {
1408                xtype : 'Row',
1409                labelWidth : 200,
1410                xns : Roo.form,
1411                '|xns' : 'Roo.form',
1412                items  : [
1413                 {
1414                  xtype : 'DateField',
1415                  altFormats : 'Y-m-d H:i:s',
1416                  fieldLabel : _this._strings['69dd756ae9c23191a5bb9b61f0857432'] /* Date to Publish */,
1417                  format : 'Y-m-d',
1418                  name : 'published',
1419                  width : 200,
1420                  xns : Roo.form,
1421                  '|xns' : 'Roo.form'
1422                 },
1423                 {
1424                  xtype : 'TextField',
1425                  fieldLabel : _this._strings['fb3f11443065d5f4d8303ad913db9680'] /* Replaces (ignore) */,
1426                  name : 'to_replace_id',
1427                  width : 75,
1428                  xns : Roo.form,
1429                  '|xns' : 'Roo.form'
1430                 }
1431                ]
1432               },
1433               {
1434                xtype : 'TextField',
1435                fieldLabel : _this._strings['b78a3223503896721cca1303f776159b'] /* Title */,
1436                name : 'title',
1437                width : 400,
1438                listeners : {
1439                 keyup : function (_self, e)
1440                  {
1441                      if (_this.page_type.getRawValue() == 'Category') {
1442                      
1443                          _this.form.findField('page_link').setValue(this.getValue().replace(/[\s]/ig, '-').toLowerCase());
1444                      
1445                      }
1446                  }
1447                },
1448                xns : Roo.form,
1449                '|xns' : 'Roo.form'
1450               },
1451               {
1452                xtype : 'TextField',
1453                fieldLabel : _this._strings['d52f80f80467bb575253a5a39ca016a7'] /* Page link /  Name / Order */,
1454                name : 'page_link',
1455                width : 400,
1456                xns : Roo.form,
1457                '|xns' : 'Roo.form'
1458               },
1459               {
1460                xtype : 'TextField',
1461                fieldLabel : _this._strings['e64df1d7c22b9638f084ce8a4aff3ff3'] /* Target URL */,
1462                name : 'target_url',
1463                width : 400,
1464                xns : Roo.form,
1465                '|xns' : 'Roo.form'
1466               },
1467               {
1468                xtype : 'ComboBox',
1469                allowBlank : true,
1470                alwaysQuery : true,
1471                displayField : 'template_clean',
1472                editable : true,
1473                emptyText : _this._strings['31bb2f6e9b8fb11cbb7fb63c6025223f'] /* Select Template */,
1474                fieldLabel : _this._strings['ebd9bec4d70abc789d439c1f136b0538'] /* Layout */,
1475                forceSelection : true,
1476                hiddenName : 'template_id',
1477                listWidth : 400,
1478                loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
1479                minChars : 2,
1480                name : 'template_id_template_clean',
1481                pageSize : 20,
1482                qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
1483                selectOnFocus : true,
1484                tpl : '<div class="x-grid-cell-text x-btn button"><b>{template_clean}</b></div>',
1485                triggerAction : 'all',
1486                typeAhead : true,
1487                valueField : 'id',
1488                width : 400,
1489                xns : Roo.form,
1490                '|xns' : 'Roo.form',
1491                store : {
1492                 xtype : 'Store',
1493                 remoteSort : true,
1494                 sortInfo : { field: 'template', direction: 'ASC' },
1495                 listeners : {
1496                  beforeload : function (_self, options)
1497                   {
1498                    
1499                       options.params._rescan = 1;
1500                      options.params._clean_name = 1;
1501                   //    options.params.lang = 'en';
1502                       options.params['!template[0]'] = 'master.html';
1503                       //options.params['!template[1]'] = 'index.html';
1504                   }
1505                 },
1506                 xns : Roo.data,
1507                 '|xns' : 'Roo.data',
1508                 proxy : {
1509                  xtype : 'HttpProxy',
1510                  method : 'GET',
1511                  url : baseURL + '/Roo/Cms_template',
1512                  xns : Roo.data,
1513                  '|xns' : 'Roo.data'
1514                 },
1515                 reader : {
1516                  xtype : 'JsonReader',
1517                  fields : [
1518                   { name: 'id', type: 'int' }, {name: 'template', type: 'string'}
1519                  ],
1520                  id : 'id',
1521                  root : 'data',
1522                  totalProperty : 'total',
1523                  xns : Roo.data,
1524                  '|xns' : 'Roo.data'
1525                 }
1526                }
1527               },
1528               {
1529                xtype : 'ComboBox',
1530                allowBlank : true,
1531                alwaysQuery : true,
1532                displayField : 'name',
1533                editable : true,
1534                emptyText : _this._strings['b5216c9b4e0ac0afd9c76eb1d12ad1b9'] /* Select Section */,
1535                fieldLabel : _this._strings['f3912172e6bf57f8979782f4a2342233'] /* Appears in Block */,
1536                forceSelection : true,
1537                hiddenName : 'element_id',
1538                listWidth : 400,
1539                loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
1540                minChars : 2,
1541                name : 'element_id_name',
1542                pageSize : 20,
1543                qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
1544                selectOnFocus : true,
1545                tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b></div>',
1546                triggerAction : 'all',
1547                typeAhead : true,
1548                valueField : 'id',
1549                width : 400,
1550                xns : Roo.form,
1551                '|xns' : 'Roo.form',
1552                store : {
1553                 xtype : 'Store',
1554                 remoteSort : true,
1555                 sortInfo : { field: 'name', direction: 'ASC' },
1556                 listeners : {
1557                  beforeload : function (_self, options)
1558                   {
1559                       var par = _this.form.findField('parent_id').getValue() * 1;
1560                       if (!par) {
1561                           Roo.MessageBox.alert("Error", "Select on what parent page it appears");
1562                           return false;
1563                       }
1564                       
1565                       options.params._cms_page_id = par;
1566                   }
1567                 },
1568                 xns : Roo.data,
1569                 '|xns' : 'Roo.data',
1570                 proxy : {
1571                  xtype : 'HttpProxy',
1572                  method : 'GET',
1573                  url : baseURL + '/Roo/Cms_template_element',
1574                  xns : Roo.data,
1575                  '|xns' : 'Roo.data'
1576                 },
1577                 reader : {
1578                  xtype : 'JsonReader',
1579                  fields : [
1580                   { name: 'id', type: 'int' }, {name: 'template', type: 'string'}
1581                  ],
1582                  id : 'id',
1583                  root : 'data',
1584                  totalProperty : 'total',
1585                  xns : Roo.data,
1586                  '|xns' : 'Roo.data'
1587                 }
1588                }
1589               },
1590               {
1591                xtype : 'ComboBox',
1592                allowBlank : true,
1593                alwaysQuery : true,
1594                displayField : 'page_link',
1595                editable : true,
1596                emptyText : _this._strings['99e7707748ae048e17c5810fad119e0b'] /* Select Page */,
1597                fieldLabel : _this._strings['8adedb6a6226807ba810215dd3b3c61b'] /* Menu links to Page */,
1598                forceSelection : true,
1599                hiddenName : 'menu_page_id',
1600                listWidth : 600,
1601                loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
1602                minChars : 2,
1603                name : 'menu_page_id_page_link',
1604                pageSize : 40,
1605                qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
1606                selectOnFocus : true,
1607                tpl : '<div class=\"x-grid-cell-text x-btn button\"><span style=\"color:#1b809e\">[{page_type_id_display_name}] </span><b>{title} </b><i>{page_link}</i></div>',
1608                triggerAction : 'all',
1609                typeAhead : true,
1610                valueField : 'id',
1611                width : 400,
1612                xns : Roo.form,
1613                '|xns' : 'Roo.form',
1614                store : {
1615                 xtype : 'Store',
1616                 remoteSort : true,
1617                 sortInfo : { field: 'title', direction: 'ASC' },
1618                 listeners : {
1619                  beforeload : function (_self, options)
1620                   {
1621                       options.params = options.params || {};
1622                       
1623                       options.params['search[page_link_no_empty]'] =1;
1624                        
1625                       options.params['page_type_id_name[0]'] = 'page';
1626                       options.params['page_type_id_name[1]'] = 'blog';
1627                        /*
1628                        options.params.is_element = 0;
1629                        options.params.is_menuitem = 0;     
1630                        */
1631                   }
1632                 },
1633                 xns : Roo.data,
1634                 '|xns' : 'Roo.data',
1635                 proxy : {
1636                  xtype : 'HttpProxy',
1637                  method : 'GET',
1638                  url : baseURL + '/Roo/cms_page.php',
1639                  xns : Roo.data,
1640                  '|xns' : 'Roo.data'
1641                 },
1642                 reader : {
1643                  xtype : 'JsonReader',
1644                  fields : [
1645                      {
1646                          "name":"id",
1647                          "type":"int"
1648                      },
1649                      {
1650                          "name":"title",
1651                          "type":"string"
1652                      },
1653                      {
1654                          "name":"page_link",
1655                          "type":"string"
1656                      },
1657                      {
1658                          "name":"page_type_id_display_name",
1659                          "type":"string"
1660                      }
1661                  ],
1662                  id : 'id',
1663                  root : 'data',
1664                  totalProperty : 'total',
1665                  xns : Roo.data,
1666                  '|xns' : 'Roo.data'
1667                 }
1668                }
1669               },
1670               {
1671                xtype : 'ComboBoxArray',
1672                fieldLabel : _this._strings['cc6892c9705afcfa61c53698756ba51b'] /* Page Class */,
1673                hiddenName : 'page_cls',
1674                name : 'page_cls_name',
1675                width : 400,
1676                xns : Roo.form,
1677                '|xns' : 'Roo.form',
1678                combo : {
1679                 xtype : 'ComboBox',
1680                 allowBlank : true,
1681                 alwaysQuery : true,
1682                 displayField : 'display_name',
1683                 editable : true,
1684                 emptyText : _this._strings['14c21301c0faf9d5561b8a580be21a13'] /* Select class */,
1685                 fieldLabel : _this._strings['cc6892c9705afcfa61c53698756ba51b'] /* Page Class */,
1686                 forceSelection : true,
1687                 listWidth : 400,
1688                 minChars : 2,
1689                 queryParam : 'query[search]',
1690                 selectOnFocus : true,
1691                 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> </div>',
1692                 triggerAction : 'all',
1693                 valueField : 'name',
1694                 width : 385,
1695                 xns : Roo.form,
1696                 '|xns' : 'Roo.form',
1697                 store : {
1698                  xtype : 'Store',
1699                  remoteSort : true,
1700                  sortInfo : { direction : 'ASC', field: 'seqid' },
1701                  listeners : {
1702                   beforeload : function (_self, o){
1703                        o.params = o.params || {};
1704                    
1705                        o.params.etype = 'cms_page_class'; 
1706                    }
1707                  },
1708                  xns : Roo.data,
1709                  '|xns' : 'Roo.data',
1710                  proxy : {
1711                   xtype : 'HttpProxy',
1712                   method : 'GET',
1713                   url : baseURL + '/Roo/core_enum.php',
1714                   xns : Roo.data,
1715                   '|xns' : 'Roo.data'
1716                  },
1717                  reader : {
1718                   xtype : 'JsonReader',
1719                   fields : [
1720                       {"name":"id","type":"int"},
1721                       {"name":"name","type":"string"},
1722                       {"name":"display_name","type":"string"}
1723                   ],
1724                   id : 'id',
1725                   root : 'data',
1726                   totalProperty : 'total',
1727                   xns : Roo.data,
1728                   '|xns' : 'Roo.data'
1729                  }
1730                 }
1731                }
1732               }
1733              ]
1734             },
1735             {
1736              xtype : 'Column',
1737              labelWidth : 200,
1738              width : 250,
1739              xns : Roo.form,
1740              '|xns' : 'Roo.form',
1741              items  : [
1742               {
1743                xtype : 'FieldSet',
1744                hideLabels : true,
1745                labelAlign : 'top',
1746                legend : _this._strings['8a53accfc94c2500b00575ce0e0d786f'] /* Primary Image */,
1747                style : 'width: 165px;',
1748                xns : Roo.form,
1749                '|xns' : 'Roo.form',
1750                items  : [
1751                 {
1752                  xtype : 'DisplayField',
1753                  height : 150,
1754                  icon : 'rootURL + \'images/default/dd/drop-add.gif\'',
1755                  name : 'primary_image_id',
1756                  style : 'border: 1px solid #ccc;',
1757                  valueRenderer : function(v) {
1758                  
1759                      if (!v || v * 1 < 1) {
1760                          return '<div style="width: 150px; height: 150px; background-color: grey;" title="Using zero order image">&nbsp;</div>';
1761                      }
1762                      
1763                      return String.format('<img src="{0}/Images/Thumb/150/{1}" width="150" title="Using zero order image">', baseURL, v); 
1764                  },
1765                  width : 150,
1766                  xns : Roo.form,
1767                  '|xns' : 'Roo.form'
1768                 }
1769                ]
1770               }
1771              ]
1772             },
1773             {
1774              xtype : 'Column',
1775              listeners : {
1776               render : function (_self)
1777                {
1778                    _this.interestsCol = _self;
1779                }
1780              },
1781              xns : Roo.form,
1782              '|xns' : 'Roo.form',
1783              items  : [
1784               {
1785                xtype : 'ComboBoxArray',
1786                fieldLabel : _this._strings['c70952e4ab3806c049737cd7d2b8896b'] /* Interests */,
1787                hiddenName : 'interest',
1788                name : 'interest_name',
1789                width : 300,
1790                listeners : {
1791                 render : function (_self)
1792                  {
1793                      _this.interests = _self;
1794                      /*
1795                      _self.combo.addicon.setStyle( {
1796                          position : 'absolute',
1797                          right: '9px',
1798                          top : '2px',
1799                          float : 'left'
1800                      });
1801                      */
1802                  }
1803                },
1804                xns : Roo.form,
1805                '|xns' : 'Roo.form',
1806                combo : {
1807                 xtype : 'ComboBox',
1808                 allowBlank : true,
1809                 alwaysQuery : true,
1810                 displayField : 'display_name',
1811                 editable : true,
1812                 emptyText : _this._strings['30d1a216420426fcbd43ca70acd4aa48'] /* Select interests */,
1813                 fieldLabel : _this._strings['c70952e4ab3806c049737cd7d2b8896b'] /* Interests */,
1814                 forceSelection : true,
1815                 listWidth : 400,
1816                 minChars : 2,
1817                 queryParam : 'query[name]',
1818                 selectOnFocus : true,
1819                 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> </div>',
1820                 triggerAction : 'all',
1821                 valueField : 'id',
1822                 width : 285,
1823                 xns : Roo.form,
1824                 '|xns' : 'Roo.form',
1825                 store : {
1826                  xtype : 'Store',
1827                  remoteSort : true,
1828                  sortInfo : { direction : 'ASC', field: 'name' },
1829                  listeners : {
1830                   beforeload : function (_self, o){
1831                        o.params = o.params || {};
1832                        o.params.etype = 'crm_interest';
1833                    }
1834                  },
1835                  xns : Roo.data,
1836                  '|xns' : 'Roo.data',
1837                  proxy : {
1838                   xtype : 'HttpProxy',
1839                   method : 'GET',
1840                   url : baseURL + '/Roo/Core_enum.php',
1841                   xns : Roo.data,
1842                   '|xns' : 'Roo.data'
1843                  },
1844                  reader : {
1845                   xtype : 'JsonReader',
1846                   fields : [
1847                       {"name":"id","type":"int"},
1848                       {"name":"name","type":"string"},
1849                       {"name":"display_name","type":"string"}
1850                   ],
1851                   id : 'id',
1852                   root : 'data',
1853                   totalProperty : 'total',
1854                   xns : Roo.data,
1855                   '|xns' : 'Roo.data'
1856                  }
1857                 }
1858                }
1859               }
1860              ]
1861             },
1862             {
1863              xtype : 'Hidden',
1864              name : 'id',
1865              xns : Roo.form,
1866              '|xns' : 'Roo.form'
1867             },
1868             {
1869              xtype : 'Hidden',
1870              name : 'is_system_page',
1871              xns : Roo.form,
1872              '|xns' : 'Roo.form'
1873             },
1874             {
1875              xtype : 'Hidden',
1876              name : 'is_menuitem',
1877              xns : Roo.form,
1878              '|xns' : 'Roo.form'
1879             },
1880             {
1881              xtype : 'Hidden',
1882              name : 'page_type_id_name',
1883              xns : Roo.form,
1884              '|xns' : 'Roo.form'
1885             },
1886             {
1887              xtype : 'Column',
1888              listeners : {
1889               render : function (_self)
1890                {
1891                    _this.user_defined_fields = _self;
1892                }
1893              },
1894              xns : Roo.form,
1895              '|xns' : 'Roo.form'
1896             }
1897            ]
1898           }
1899          ]
1900         },
1901         {
1902          xtype : 'ContentPanel',
1903          background : false,
1904          fitContainer : true,
1905          fitToFrame : true,
1906          region : 'south',
1907          title : _this._strings['c1df1da7a1ce305a3b60af9d5733ac1d'] /* Contents */,
1908          xns : Roo,
1909          '|xns' : 'Roo',
1910          items  : [
1911           {
1912            xtype : 'Form',
1913            labelAlign : 'top',
1914            labelWidth : 80,
1915            method : 'POST',
1916            url : baseURL + '/Roo/cms_page.php',
1917            listeners : {
1918             rendered : function (form)
1919              {
1920                  _this.form1 = form;
1921              }
1922            },
1923            xns : Roo.form,
1924            '|xns' : 'Roo.form',
1925            items  : [
1926             {
1927              xtype : 'Row',
1928              hideLabels : true,
1929              xns : Roo.form,
1930              '|xns' : 'Roo.form',
1931              items  : [
1932               {
1933                xtype : 'HtmlEditor',
1934                autosave : function() {
1935                    
1936                    var body = _this.form1.findField('body');
1937                    
1938                    if(!body.wrap.isVisible(true) || body.getValue() == '' || !body.isDirty()){
1939                        Roo.log('body not dirty');
1940                        return;
1941                    }
1942                    
1943                    Roo.log('body dirty, auto save!');
1944                    
1945                    body.fireEvent('autosave', body);
1946                        
1947                   
1948                },
1949                fieldLabel : _this._strings['c1df1da7a1ce305a3b60af9d5733ac1d'] /* Contents */,
1950                height : 150,
1951                name : 'body',
1952                resizable : 's',
1953                white : [ 'iframe' ],
1954                width : 550,
1955                listeners : {
1956                 autosave : function (_self)
1957                  {
1958                      Roo.log('autosave');
1959                      
1960                      var id = _this.form.findField('id').getValue() * 1;
1961                      /*
1962                      if(!_self.editorcore.sourceEditMode){
1963                          _self.syncValue();
1964                      }else{
1965                          _self.pushValue();
1966                      }
1967                      */
1968                      new Pman.Request({
1969                          url : baseURL + '/Roo/Events.php',
1970                          method :'POST',
1971                          params : {
1972                              id : 0,
1973                              action : 'AUTOSAVE',
1974                              on_id : (id > 0) ? id : 0,
1975                              on_table : 'cms_page',
1976                              remarks : 'BODY',
1977                              source: _self.getValue()
1978                          },
1979                          success : function() {
1980                              _self.originalValue = _self.getValue();
1981                              
1982                          },
1983                          failure : function() 
1984                          {
1985                              //Roo.MessageBox.alert("Error", "autosave failed");
1986                              Roo.log('body autosave failed?!');
1987                          }
1988                      });
1989                      
1990                  },
1991                 savedpreview : function (_self)
1992                  {
1993                      Roo.log('saved preview');
1994                      
1995                      var id = _this.form.findField('id').getValue() * 1;
1996                      
1997                      var successFn = function(res){
1998                          return res.data.POST.source;
1999                      };
2000                      
2001                      var params = {
2002                          action : 'AUTOSAVE',
2003                          remarks : 'BODY',
2004                          on_id : (id < 1) ? 0 : id,
2005                          on_table : 'cms_page',
2006                          successFn : successFn
2007                      };
2008                      
2009                      
2010                      Pman.Dialog.CoreAutoSavePreview.show(params, function(res){
2011                          _self.setValue(res);
2012                          _self.originalValue = res;
2013                      });
2014                  },
2015                 stylesheetsclick : function (_self)
2016                  {
2017                      Pman.Dialog.CmsApplyStyleSheets.show({}, function(res){
2018                          _this.dialog.setStylesheets();
2019                      })
2020                      
2021                  }
2022                },
2023                xns : Roo.form,
2024                '|xns' : 'Roo.form',
2025                toolbars : [
2026                 {
2027                  xtype : 'ToolbarStandard',
2028                  xns : Roo.form.HtmlEditor,
2029                  '|xns' : 'Roo.form.HtmlEditor',
2030                  btns : [
2031                   {
2032                    xtype : 'ComboBox',
2033                    alwaysQuery : true,
2034                    displayField : 'name',
2035                    editable : false,
2036                    emptyText : _this._strings['b9c49611cfda3259a2b837b39489e650'] /* Add Image */,
2037                    fieldLabel : _this._strings['fff0d600f8a0b5e19e88bfb821dd1157'] /* Images */,
2038                    forceSelection : true,
2039                    listWidth : 400,
2040                    loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
2041                    minChars : 2,
2042                    pageSize : 20,
2043                    qtip : _this._strings['2f26e35d61be90501e099089dc533638'] /* Select Images */,
2044                    queryParam : 'search',
2045                    selectOnFocus : true,
2046                    tpl : '<div class="x-grid-cell-text x-btn button"><img src="' + baseURL + '/Images/Thumb/150x150/{id}.jpg" height="150" width="150"><b>{filename}</b> </div>',
2047                    triggerAction : 'all',
2048                    typeAhead : true,
2049                    valueField : 'id',
2050                    width : 100,
2051                    listeners : {
2052                     beforequery : function (combo, query, forceAll, cancel, e)
2053                      {
2054                       
2055                          var id = _this.form.findField('id').getValue() * 1;    
2056                          if (!id) {
2057                              Roo.MessageBox.alert("Error", "Save Document First before adding images");
2058                              return false;
2059                          }
2060                      },
2061                     render : function (_self)
2062                      {
2063                          _this.bodyimgselect = _self;
2064                      },
2065                     select : function (combo, record, index)
2066                      {
2067                          Roo.log(record);
2068                          (function() { 
2069                              combo.setValue('');
2070                          }).defer(100);
2071                          
2072                          var editor = _this.form.findField('body').editorcore;
2073                          
2074                          var curnode = editor.getSelectedNode();
2075                          
2076                          if (curnode && curnode.tagName == 'IMG') {
2077                              curnode.src= String.format('{0}/Images/{1}/{2}#attachment-{1}',
2078                                      baseURL,  record.data.id, record.data.filename
2079                                  );
2080                                  // note -forces an update... hopefully...
2081                              editor.owner.fireEvent('editorevent', editor, false);
2082                          } else {
2083                          
2084                              editor.insertAtCursor(
2085                                  String.format('<img src="{0}/Images/{1}/{2}#attachment-{1}">',
2086                                  baseURL,  record.data.id, record.data.filename
2087                                  )
2088                              );
2089                      
2090                          }
2091                          
2092                      }
2093                    },
2094                    xns : Roo.form,
2095                    '|xns' : 'Roo.form',
2096                    store : {
2097                     xtype : 'Store',
2098                     remoteSort : true,
2099                     sortInfo : { direction : 'ASC', field: 'id' },
2100                     listeners : {
2101                      beforeload : function (_self, o){
2102                           o.params = o.params || {};
2103                       
2104                           var id = _this.form.findField('id').getValue() * 1;    
2105                           if (!id) {
2106                               Roo.MessageBox.alert("Error", "Save press release first");
2107                               return false;
2108                           }
2109                           o.params.onid = id;
2110                           o.params.ontable = 'cms_page';
2111                          // o.params.imgtype = 'PressRelease';
2112                           //o.params['query[imagesize]'] = '150x150';
2113                           // set more here
2114                       }
2115                     },
2116                     xns : Roo.data,
2117                     '|xns' : 'Roo.data',
2118                     proxy : {
2119                      xtype : 'HttpProxy',
2120                      method : 'GET',
2121                      url : baseURL + '/Roo/Images.php',
2122                      xns : Roo.data,
2123                      '|xns' : 'Roo.data'
2124                     },
2125                     reader : {
2126                      xtype : 'JsonReader',
2127                      fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}],
2128                      id : 'id',
2129                      root : 'data',
2130                      totalProperty : 'total',
2131                      xns : Roo.data,
2132                      '|xns' : 'Roo.data'
2133                     }
2134                    }
2135                   },
2136                   {
2137                    xtype : 'ComboBox',
2138                    allowBlank : true,
2139                    displayField : 'page_link',
2140                    editable : true,
2141                    emptyText : _this._strings['580b21aac58f1b73cece26e272cdfbee'] /* Add Link */,
2142                    forceSelection : true,
2143                    hiddenName : 'add_link_id',
2144                    listWidth : 200,
2145                    loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
2146                    minChars : 2,
2147                    name : 'add_link',
2148                    pageSize : 40,
2149                    qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
2150                    selectOnFocus : true,
2151                    tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{title}</b> <i>{page_link}</i> </div>',
2152                    triggerAction : 'all',
2153                    typeAhead : true,
2154                    valueField : 'id',
2155                    width : 100,
2156                    listeners : {
2157                     select : function (combo, record, index)
2158                      {
2159                          Roo.log(record);
2160                          (function() { 
2161                              combo.setValue('');
2162                          }).defer(100);
2163                          var editor = _this.form.findField('body');
2164                          editor.editorcore.insertAtCursor(
2165                                  String.format('<a href="#page-{0}">{1}</a>',
2166                                  record.data.page_link,  record.data.title
2167                                  )
2168                           );
2169                      
2170                          
2171                       }
2172                    },
2173                    xns : Roo.form,
2174                    '|xns' : 'Roo.form',
2175                    store : {
2176                     xtype : 'Store',
2177                     remoteSort : true,
2178                     sortInfo : { field: 'page_link', direction: 'ASC' },
2179                     listeners : {
2180                      beforeload : function (_self, options)
2181                       {
2182                            options.params['search[page_link_no_empty]'] =1;
2183                            /*
2184                            options.params.is_element = 0;
2185                            options.params.is_menuitem = _this.form.findField('is_menuitem').getValue() * 1;     
2186                            */
2187                       }
2188                     },
2189                     xns : Roo.data,
2190                     '|xns' : 'Roo.data',
2191                     proxy : {
2192                      xtype : 'HttpProxy',
2193                      method : 'GET',
2194                      url : baseURL + '/Roo/cms_page.php',
2195                      xns : Roo.data,
2196                      '|xns' : 'Roo.data'
2197                     },
2198                     reader : {
2199                      xtype : 'JsonReader',
2200                      fields : [
2201                       { name: 'id', type: 'int' },
2202                       'title',
2203                       'page_link' 
2204                      ],
2205                      id : 'id',
2206                      root : 'data',
2207                      totalProperty : 'total',
2208                      xns : Roo.data,
2209                      '|xns' : 'Roo.data'
2210                     }
2211                    }
2212                   },
2213                   {
2214                    xtype : 'Separator',
2215                    xns : Roo.Toolbar,
2216                    '|xns' : 'Roo.Toolbar'
2217                   },
2218                   {
2219                    xtype : 'Button',
2220                    cls : 'x-init-enable',
2221                    text : _this._strings['bd88a20b53a47f7b5704a83a15ff5506'] /* Saved Version */,
2222                    listeners : {
2223                     click : function (_self, e)
2224                      {
2225                          this.scope.owner.fireEvent('savedpreview', this.scope.owner);
2226                      }
2227                    },
2228                    xns : Roo.Toolbar,
2229                    '|xns' : 'Roo.Toolbar'
2230                   }
2231                  ]
2232                 },
2233                 {
2234                  xtype : 'ToolbarContext',
2235                  xns : Roo.form.HtmlEditor,
2236                  '|xns' : 'Roo.form.HtmlEditor'
2237                 }
2238                ]
2239               }
2240              ]
2241             }
2242            ]
2243           }
2244          ]
2245         },
2246         {
2247          xtype : 'ContentPanel',
2248          background : false,
2249          fitContainer : true,
2250          fitToFrame : true,
2251          region : 'south',
2252          title : _this._strings['76eb64a1725ee953c664e15c9213b2fd'] /* Extended Content */,
2253          xns : Roo,
2254          '|xns' : 'Roo',
2255          items  : [
2256           {
2257            xtype : 'Form',
2258            labelAlign : 'top',
2259            labelWidth : 80,
2260            method : 'POST',
2261            url : baseURL + '/Roo/cms_page.php',
2262            listeners : {
2263             rendered : function (form)
2264              {
2265                  _this.form2 = form;
2266              }
2267            },
2268            xns : Roo.form,
2269            '|xns' : 'Roo.form',
2270            items  : [
2271             {
2272              xtype : 'Row',
2273              hideLabels : true,
2274              xns : Roo.form,
2275              '|xns' : 'Roo.form',
2276              items  : [
2277               {
2278                xtype : 'HtmlEditor',
2279                autosave : function() {
2280                    
2281                    var extended = _this.form2.findField('extended');
2282                    
2283                    if(!extended.wrap.isVisible(true) || extended.getValue() == '' || !extended.isDirty()){
2284                        Roo.log('extend not dirty');
2285                        return;
2286                    }
2287                
2288                    
2289                    Roo.log('extend dirty, auto save!');
2290                    
2291                    extended.fireEvent('autosave', extended);
2292                },
2293                fieldLabel : _this._strings['57e195426892c5515935f21d97228814'] /* Extended Contents */,
2294                height : 150,
2295                name : 'extended',
2296                resizable : 's',
2297                white : [ 'iframe' ],
2298                width : 550,
2299                listeners : {
2300                 autosave : function (_self)
2301                  {
2302                      var id = _this.form.findField('id').getValue() * 1;
2303                      
2304                      /*
2305                      if(!_self.editorcore.sourceEditMode){
2306                          _self.syncValue();
2307                      }else{
2308                          _self.pushValue();
2309                      }
2310                      */
2311                      new Pman.Request({
2312                          url : baseURL + '/Roo/Events.php',
2313                          method :'POST',
2314                          params : {
2315                              id : 0,
2316                              action : 'AUTOSAVE',
2317                              on_id : (id > 0) ? id : 0,
2318                              on_table : 'cms_page',
2319                              remarks : 'EXTENDED',
2320                              source: _self.getValue()
2321                          },
2322                          success : function() {
2323                              _self.originalValue = _self.getValue();
2324                              
2325                          },
2326                          failure : function() 
2327                          {
2328                              //Roo.MessageBox.alert("Error", "autosave failed");
2329                              Roo.log('extended autosave failed?!');
2330                          }
2331                      });
2332                  },
2333                 savedpreview : function (_self)
2334                  {
2335                      var id = _this.form.findField('id').getValue() * 1;
2336                      
2337                      var successFn = function(res){
2338                          return res.data.POST.source;
2339                      };
2340                      
2341                      var params = {
2342                          action : 'AUTOSAVE',
2343                          remarks : 'EXTENDED',
2344                          on_id : (id < 1) ? 0 : id,
2345                          on_table : 'cms_page',
2346                          successFn : successFn
2347                      };
2348                      
2349                      
2350                      Pman.Dialog.CoreAutoSavePreview.show(params, function(res){
2351                          _self.setValue(res);
2352                          _self.originalValue = res;
2353                      });
2354                  },
2355                 stylesheetsclick : function (_self)
2356                  {
2357                      Pman.Dialog.CmsApplyStyleSheets.show({}, function(res){
2358                          _this.dialog.setStylesheets();
2359                      })
2360                      
2361                  }
2362                },
2363                xns : Roo.form,
2364                '|xns' : 'Roo.form',
2365                toolbars : [
2366                 {
2367                  xtype : 'ToolbarStandard',
2368                  xns : Roo.form.HtmlEditor,
2369                  '|xns' : 'Roo.form.HtmlEditor',
2370                  btns : [
2371                   {
2372                    xtype : 'ComboBox',
2373                    alwaysQuery : true,
2374                    displayField : 'name',
2375                    editable : false,
2376                    emptyText : _this._strings['b9c49611cfda3259a2b837b39489e650'] /* Add Image */,
2377                    fieldLabel : _this._strings['fff0d600f8a0b5e19e88bfb821dd1157'] /* Images */,
2378                    forceSelection : true,
2379                    listWidth : 400,
2380                    loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
2381                    minChars : 2,
2382                    pageSize : 20,
2383                    qtip : _this._strings['2f26e35d61be90501e099089dc533638'] /* Select Images */,
2384                    selectOnFocus : true,
2385                    tpl : '<div class=\"x-grid-cell-text x-btn button\"><img src=\"{url_thumb}\" height=\"150\" width=\"150\"><b>{filename}</b> </div>',
2386                    triggerAction : 'all',
2387                    typeAhead : true,
2388                    valueField : 'id',
2389                    width : 100,
2390                    listeners : {
2391                     beforequery : function (combo, query, forceAll, cancel, e)
2392                      {
2393                       
2394                          var id = _this.form.findField('id').getValue() * 1;    
2395                          if (!id) {
2396                              Roo.MessageBox.alert("Error", "Save Document First before adding images");
2397                              return false;
2398                          }
2399                      },
2400                     render : function (_self)
2401                      {
2402                          _this.extendimgselect = _self;
2403                      },
2404                     select : function (combo, record, index)
2405                      {
2406                          Roo.log(record);
2407                          (function() { 
2408                              combo.setValue('');
2409                          }).defer(100);
2410                          
2411                          var editor = _this.form.findField('extended').editorcore;
2412                          
2413                          var curnode = editor.getSelectedNode();
2414                          
2415                          if (curnode && curnode.tagName == 'IMG') {
2416                              curnode.src= String.format('{0}/Images/{1}/{2}#image-{1}',
2417                                      baseURL,  record.data.id, record.data.filename
2418                                  );
2419                                  // note -forces an update... hopefully...
2420                              editor.owner.fireEvent('editorevent', editor, false);
2421                          } else {
2422                          
2423                              editor.insertAtCursor(
2424                                  String.format('<img src="{0}/Images/{1}/{2}#image-{1}">',
2425                                  baseURL,  record.data.id, record.data.filename
2426                                  )
2427                              );
2428                      
2429                          }
2430                          
2431                      }
2432                    },
2433                    xns : Roo.form,
2434                    '|xns' : 'Roo.form',
2435                    store : {
2436                     xtype : 'Store',
2437                     remoteSort : true,
2438                     sortInfo : { direction : 'ASC', field: 'id' },
2439                     listeners : {
2440                      beforeload : function (_self, o){
2441                           o.params = o.params || {};
2442                       
2443                           var id = _this.form.findField('id').getValue() * 1;    
2444                           if (!id) {
2445                               Roo.MessageBox.alert("Error", "Save press release first");
2446                               return false;
2447                           }
2448                           o.params.onid = id;
2449                           o.params.ontable = 'cms_page';
2450                          // o.params.imgtype = 'PressRelease';
2451                           //o.params['query[imagesize]'] = '150x150';
2452                           // set more here
2453                       }
2454                     },
2455                     xns : Roo.data,
2456                     '|xns' : 'Roo.data',
2457                     proxy : {
2458                      xtype : 'HttpProxy',
2459                      method : 'GET',
2460                      url : baseURL + '/Roo/Images.php',
2461                      xns : Roo.data,
2462                      '|xns' : 'Roo.data'
2463                     },
2464                     reader : {
2465                      xtype : 'JsonReader',
2466                      fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}],
2467                      id : 'id',
2468                      root : 'data',
2469                      totalProperty : 'total',
2470                      xns : Roo.data,
2471                      '|xns' : 'Roo.data'
2472                     }
2473                    }
2474                   },
2475                   {
2476                    xtype : 'ComboBox',
2477                    allowBlank : true,
2478                    displayField : 'page_link',
2479                    editable : true,
2480                    emptyText : _this._strings['580b21aac58f1b73cece26e272cdfbee'] /* Add Link */,
2481                    forceSelection : true,
2482                    hiddenName : 'add_link_id',
2483                    listWidth : 200,
2484                    loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
2485                    minChars : 2,
2486                    name : 'add_link',
2487                    pageSize : 40,
2488                    qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
2489                    selectOnFocus : true,
2490                    tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{title}</b> <i>{page_link}</i> </div>',
2491                    triggerAction : 'all',
2492                    typeAhead : true,
2493                    valueField : 'id',
2494                    width : 100,
2495                    listeners : {
2496                     select : function (combo, record, index)
2497                      {
2498                          Roo.log(record);
2499                          (function() { 
2500                              combo.setValue('');
2501                          }).defer(100);
2502                          var editor = _this.form.findField('body');
2503                          editor.editorcore.insertAtCursor(
2504                                  String.format('<a href="#page-{0}">{1}</a>',
2505                                  record.data.page_link,  record.data.title
2506                                  )
2507                           );
2508                      
2509                          
2510                       }
2511                    },
2512                    xns : Roo.form,
2513                    '|xns' : 'Roo.form',
2514                    store : {
2515                     xtype : 'Store',
2516                     remoteSort : true,
2517                     sortInfo : { field: 'page_link', direction: 'ASC' },
2518                     listeners : {
2519                      beforeload : function (_self, options)
2520                       {
2521                            options.params['search[page_link_no_empty]'] =1;
2522                            /*
2523                            options.params.is_element = 0;
2524                            options.params.is_menuitem = _this.form.findField('is_menuitem').getValue() * 1;     
2525                            */
2526                       }
2527                     },
2528                     xns : Roo.data,
2529                     '|xns' : 'Roo.data',
2530                     proxy : {
2531                      xtype : 'HttpProxy',
2532                      method : 'GET',
2533                      url : baseURL + '/Roo/cms_page.php',
2534                      xns : Roo.data,
2535                      '|xns' : 'Roo.data'
2536                     },
2537                     reader : {
2538                      xtype : 'JsonReader',
2539                      fields : [
2540                       { name: 'id', type: 'int' },
2541                       'title',
2542                       'page_link' 
2543                      ],
2544                      id : 'id',
2545                      root : 'data',
2546                      totalProperty : 'total',
2547                      xns : Roo.data,
2548                      '|xns' : 'Roo.data'
2549                     }
2550                    }
2551                   },
2552                   {
2553                    xtype : 'Separator',
2554                    xns : Roo.Toolbar,
2555                    '|xns' : 'Roo.Toolbar'
2556                   },
2557                   {
2558                    xtype : 'Button',
2559                    text : _this._strings['bd88a20b53a47f7b5704a83a15ff5506'] /* Saved Version */,
2560                    listeners : {
2561                     click : function (_self, e)
2562                      {
2563                          this.scope.owner.fireEvent('savedpreview', this.scope.owner);
2564                      }
2565                    },
2566                    xns : Roo.Toolbar,
2567                    '|xns' : 'Roo.Toolbar'
2568                   }
2569                  ]
2570                 },
2571                 {
2572                  xtype : 'ToolbarContext',
2573                  styles : typeof(uiConfig) != 'undefined' ? (uiConfig['Roo.form.HtmlEditor.ToolbarContext.styles'] || {}) : {},
2574                  xns : Roo.form.HtmlEditor,
2575                  '|xns' : 'Roo.form.HtmlEditor'
2576                 }
2577                ]
2578               }
2579              ]
2580             }
2581            ]
2582           }
2583          ]
2584         },
2585         {
2586          xtype : 'ContentPanel',
2587          background : false,
2588          fitContainer : true,
2589          fitToFrame : true,
2590          region : 'south',
2591          title : _this._strings['d8e4d1f5e445107e505b2cf63a1fb65c'] /* Extra CSS */,
2592          xns : Roo,
2593          '|xns' : 'Roo',
2594          items  : [
2595           {
2596            xtype : 'Form',
2597            labelAlign : 'top',
2598            labelWidth : 80,
2599            method : 'POST',
2600            url : baseURL + '/Roo/cms_page.php',
2601            listeners : {
2602             rendered : function (form)
2603              {
2604                  _this.form3 = form;
2605              }
2606            },
2607            xns : Roo.form,
2608            '|xns' : 'Roo.form',
2609            items  : [
2610             {
2611              xtype : 'Row',
2612              hideLabels : true,
2613              xns : Roo.form,
2614              '|xns' : 'Roo.form',
2615              items  : [
2616               {
2617                xtype : 'TextArea',
2618                fieldLabel : _this._strings['39f64cc9436cacfbceda3b7bdeb8e24c'] /* Styles (CSS) */,
2619                height : 200,
2620                name : 'extra_css',
2621                width : 700,
2622                xns : Roo.form,
2623                '|xns' : 'Roo.form'
2624               }
2625              ]
2626             }
2627            ]
2628           }
2629          ]
2630         },
2631         {
2632          xtype : 'ContentPanel',
2633          background : false,
2634          fitContainer : true,
2635          fitToFrame : true,
2636          region : 'south',
2637          title : _this._strings['98e93e8f7adfe14832db6caed713d849'] /* Meta Tags */,
2638          xns : Roo,
2639          '|xns' : 'Roo',
2640          items  : [
2641           {
2642            xtype : 'Form',
2643            labelAlign : 'top',
2644            labelWidth : 80,
2645            method : 'POST',
2646            url : baseURL + '/Roo/cms_page.php',
2647            listeners : {
2648             rendered : function (form)
2649              {
2650                  _this.form4 = form;
2651              }
2652            },
2653            xns : Roo.form,
2654            '|xns' : 'Roo.form',
2655            items  : [
2656             {
2657              xtype : 'Row',
2658              xns : Roo.form,
2659              '|xns' : 'Roo.form',
2660              items  : [
2661               {
2662                xtype : 'TextArea',
2663                fieldLabel : _this._strings['867343577fa1f33caa632a19543bd252'] /* Keywords */,
2664                height : 100,
2665                name : 'keywords',
2666                width : 340,
2667                xns : Roo.form,
2668                '|xns' : 'Roo.form'
2669               },
2670               {
2671                xtype : 'TextArea',
2672                fieldLabel : _this._strings['8bc84316c4078bf66723fd019616d920'] /* Descriptions */,
2673                height : 100,
2674                name : 'descriptions',
2675                width : 340,
2676                xns : Roo.form,
2677                '|xns' : 'Roo.form'
2678               }
2679              ]
2680             }
2681            ]
2682           }
2683          ]
2684         }
2685        ]
2686       }
2687      },
2688      {
2689       xtype : 'GridPanel',
2690       background : false,
2691       fitContainer : true,
2692       fitToframe : true,
2693       region : 'east',
2694       tableName : 'Images',
2695       title : _this._strings['308f2757bfc9ce92fb00ff93fdffd279'] /* Images / Attachments */,
2696       listeners : {
2697        activate : function() {
2698             _this.panel = this;
2699             if (_this.grid) {
2700                 _this.grid.footer.onClick('first');
2701             }
2702         }
2703       },
2704       xns : Roo,
2705       '|xns' : 'Roo',
2706       grid : {
2707        xtype : 'EditorGrid',
2708        autoExpandColumn : 'title',
2709        clicksToEdit : 1,
2710        loadMask : true,
2711        listeners : {
2712         render : function() { 
2713              _this.grid = this; 
2714              //_this.dialog = Pman.Dialog.FILL_IN
2715              if (_this.panel.active) {
2716                 //this.footer.onClick('first');
2717              }
2718          },
2719         rowdblclick : function (_self, rowIndex, e)
2720          {
2721              var rd = _this.grid.getDataSource().getAt(rowIndex);
2722              var id = rd.data.id;
2723              var url = String.format('{0}/Images/{1}/{2}', baseURL, rd.data.id, rd.data.filename);
2724              _this.form.findField('contents').execCmd('insertimage', url);
2725          
2726          }
2727        },
2728        xns : Roo.grid,
2729        '|xns' : 'Roo.grid',
2730        toolbar : {
2731         xtype : 'Toolbar',
2732         xns : Roo,
2733         '|xns' : 'Roo',
2734         items  : [
2735          {
2736           xtype : 'Button',
2737           cls : 'x-btn-text-icon',
2738           icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
2739           text : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
2740           listeners : {
2741            click : function()
2742             {
2743                 var id = _this.form.findField('id').getValue() * 1;
2744                 
2745                 if(id < 1){
2746                     return;
2747                 }
2748                 
2749                 Pman.Dialog.Image.show( { id : 0, onid : id, ontable: 'cms_page' }, function() {
2750                     _this.grid.ds.load({});
2751                 }); 
2752             
2753             }
2754           },
2755           xns : Roo,
2756           '|xns' : 'Roo'
2757          },
2758          {
2759           xtype : 'Button',
2760           cls : 'x-btn-text-icon',
2761           icon : rootURL + '/Pman/templates/images/trash.gif',
2762           text : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
2763           listeners : {
2764            click : function()
2765             {
2766                 var selection = _this.grid.getSelectionModel().getSelectedCell();
2767                 var sn = _this.grid.ds.getAt(selection[0]);
2768                 if (!sn || isNaN(sn.id *1)) {
2769                     Roo.MessageBox.alert("Error", "Select a image"); 
2770                     return;
2771                 }
2772                 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete this image?", function (v){
2773                     if (v != 'yes') {
2774                         return;
2775                     }
2776                     
2777                     new Pman.Request({
2778                         url : baseURL + '/Roo/Images.php',
2779                         method: 'POST',
2780                         params : {
2781                             _delete : sn.id
2782                         },
2783                         success : function()
2784                         {
2785                             Roo.log('Got Success!!');
2786                            _this.grid.ds.load({});
2787                         }
2788                     });
2789                 });
2790             }
2791           },
2792           xns : Roo,
2793           '|xns' : 'Roo'
2794          }
2795         ]
2796        },
2797        dataSource : {
2798         xtype : 'Store',
2799         listeners : {
2800          beforeload : function (_self, o)
2801           {
2802               var id = _this.form.findField('id').getValue() * 1;
2803           
2804               if (id < 1) {
2805                   this.removeAll();
2806                   return false;
2807               } 
2808               o.params = o.params || {};    
2809               o.params.limit = 9999;          
2810               o.params.onid = id;
2811               o.params.ontable = 'cms_page';
2812           },
2813          update : function (_self, rec, operation)
2814           {
2815               
2816               new Pman.Request({
2817                   url : baseURL+'/Roo/Images.php',
2818                   method : 'POST',
2819                   params : rec.data,
2820                   success: function(res)
2821                   {
2822                       Roo.log("GOT success");
2823                       // update the data...
2824                       _this.grid.ds.load({});
2825                   },
2826                   failure : function(res)
2827                   {
2828                       Roo.MessageBox.alert('Error', res.errorMsg);
2829                       _this.grid.ds.load({});
2830                   }
2831                   
2832                   
2833               });
2834           }
2835         },
2836         xns : Roo.data,
2837         '|xns' : 'Roo.data',
2838         proxy : {
2839          xtype : 'HttpProxy',
2840          method : 'GET',
2841          url : baseURL + '/Roo/Images.php',
2842          xns : Roo.data,
2843          '|xns' : 'Roo.data'
2844         },
2845         reader : {
2846          xtype : 'JsonReader',
2847          fields : [
2848              {
2849                  'name': 'id',
2850                  'type': 'int'
2851              },
2852              {
2853                  'name': 'filename',
2854                  'type': 'string'
2855              },
2856              {
2857                  'name': 'ontable',
2858                  'type': 'string'
2859              },
2860              {
2861                  'name': 'onid',
2862                  'type': 'int'
2863              },
2864              {
2865                  'name': 'mimetype',
2866                  'type': 'string'
2867              },
2868              {
2869                  'name': 'width',
2870                  'type': 'int'
2871              },
2872              {
2873                  'name': 'height',
2874                  'type': 'int'
2875              },
2876              {
2877                  'name': 'filesize',
2878                  'type': 'int'
2879              },
2880              {
2881                  'name': 'displayorder',
2882                  'type': 'int'
2883              },
2884              {
2885                  'name': 'language',
2886                  'type': 'string'
2887              },
2888              {
2889                  'name': 'parent_image_id',
2890                  'type': 'int'
2891              },
2892              {
2893                  'name': 'created',
2894                  'type': 'date',
2895                  'dateFormat': 'Y-m-d'
2896              },
2897              {
2898                  'name': 'imgtype',
2899                  'type': 'string'
2900              },
2901              {
2902                  'name': 'linkurl',
2903                  'type': 'string'
2904              },
2905              {
2906                  'name': 'descript',
2907                  'type': 'string'
2908              },
2909              {
2910                  'name': 'title',
2911                  'type': 'string'
2912              },
2913              {
2914                  'name': 'parent_image_id_id',
2915                  'type': 'int'
2916              },
2917              {
2918                  'name': 'parent_image_id_filename',
2919                  'type': 'string'
2920              },
2921              {
2922                  'name': 'parent_image_id_ontable',
2923                  'type': 'string'
2924              },
2925              {
2926                  'name': 'parent_image_id_onid',
2927                  'type': 'int'
2928              },
2929              {
2930                  'name': 'parent_image_id_mimetype',
2931                  'type': 'string'
2932              },
2933              {
2934                  'name': 'parent_image_id_width',
2935                  'type': 'int'
2936              },
2937              {
2938                  'name': 'parent_image_id_height',
2939                  'type': 'int'
2940              },
2941              {
2942                  'name': 'parent_image_id_filesize',
2943                  'type': 'int'
2944              },
2945              {
2946                  'name': 'parent_image_id_displayorder',
2947                  'type': 'int'
2948              },
2949              {
2950                  'name': 'parent_image_id_language',
2951                  'type': 'string'
2952              },
2953              {
2954                  'name': 'parent_image_id_parent_image_id',
2955                  'type': 'int'
2956              },
2957              {
2958                  'name': 'parent_image_id_created',
2959                  'type': 'date'
2960              },
2961              {
2962                  'name': 'parent_image_id_imgtype',
2963                  'type': 'string'
2964              },
2965              {
2966                  'name': 'parent_image_id_linkurl',
2967                  'type': 'string'
2968              },
2969              {
2970                  'name': 'parent_image_id_descript',
2971                  'type': 'string'
2972              },
2973              {
2974                  'name': 'parent_image_id_title',
2975                  'type': 'string'
2976              }
2977          ],
2978          id : 'id',
2979          root : 'data',
2980          totalProperty : 'total',
2981          xns : Roo.data,
2982          '|xns' : 'Roo.data'
2983         }
2984        },
2985        colModel : [
2986         {
2987          xtype : 'ColumnModel',
2988          dataIndex : 'id',
2989          header : _this._strings['d41d8cd98f00b204e9800998ecf8427e'] /*  */,
2990          renderer : function(v,x,r) { 
2991              return  String.format('<img src="{0}/Images/Thumb/100/{1}/{2}" height="100">', baseURL, v, r.data.filename); 
2992          },
2993          sortable : false,
2994          width : 75,
2995          xns : Roo.grid,
2996          '|xns' : 'Roo.grid'
2997         },
2998         {
2999          xtype : 'ColumnModel',
3000          dataIndex : 'filename',
3001          header : _this._strings['1351017ac6423911223bc19a8cb7c653'] /* Filename */,
3002          renderer : function(v) { return String.format('{0}', v); },
3003          width : 200,
3004          xns : Roo.grid,
3005          '|xns' : 'Roo.grid'
3006         },
3007         {
3008          xtype : 'ColumnModel',
3009          dataIndex : 'displayorder',
3010          header : _this._strings['a240fa27925a635b08dc28c9e4f9216d'] /* Order */,
3011          renderer : function(v) { return String.format('{0}', v); },
3012          width : 50,
3013          xns : Roo.grid,
3014          '|xns' : 'Roo.grid',
3015          editor : {
3016           xtype : 'GridEditor',
3017           xns : Roo.grid,
3018           '|xns' : 'Roo.grid',
3019           field : {
3020            xtype : 'NumberField',
3021            decimalPrecision : 0,
3022            listeners : {
3023             focus : function (_self)
3024              {
3025                  if (this.value == 0) {
3026                      this.el.dom.value = '';
3027                  }
3028              }
3029            },
3030            xns : Roo.form,
3031            '|xns' : 'Roo.form'
3032           }
3033          }
3034         },
3035         {
3036          xtype : 'ColumnModel',
3037          dataIndex : 'title',
3038          header : _this._strings['b78a3223503896721cca1303f776159b'] /* Title */,
3039          renderer : function(v) { return String.format('{0}', v); },
3040          width : 100,
3041          xns : Roo.grid,
3042          '|xns' : 'Roo.grid',
3043          editor : {
3044           xtype : 'GridEditor',
3045           xns : Roo.grid,
3046           '|xns' : 'Roo.grid',
3047           field : {
3048            xtype : 'TextField',
3049            xns : Roo.form,
3050            '|xns' : 'Roo.form'
3051           }
3052          }
3053         },
3054         {
3055          xtype : 'ColumnModel',
3056          dataIndex : 'linkurl',
3057          header : _this._strings['e6b391a8d2c4d45902a23a8b6585703d'] /* URL */,
3058          renderer : function(v)
3059          {
3060              return String.format('{0}', (v) ? v : '');
3061          },
3062          width : 300,
3063          xns : Roo.grid,
3064          '|xns' : 'Roo.grid',
3065          editor : {
3066           xtype : 'GridEditor',
3067           xns : Roo.grid,
3068           '|xns' : 'Roo.grid',
3069           field : {
3070            xtype : 'TextField',
3071            xns : Roo.form,
3072            '|xns' : 'Roo.form'
3073           }
3074          }
3075         }
3076        ]
3077       }
3078      },
3079      {
3080       xtype : 'NestedLayoutPanel',
3081       background : false,
3082       fitContainer : true,
3083       fitToFrame : true,
3084       region : 'west',
3085       listeners : {
3086        render : function (_self)
3087         {
3088             _this.westLayoutPanel = this;
3089             
3090         }
3091       },
3092       xns : Roo,
3093       '|xns' : 'Roo',
3094       layout : {
3095        xtype : 'BorderLayout',
3096        xns : Roo,
3097        '|xns' : 'Roo',
3098        center : {
3099         xtype : 'LayoutRegion',
3100         tabPosition : 'top',
3101         xns : Roo,
3102         '|xns' : 'Roo'
3103        },
3104        south : {
3105         xtype : 'LayoutRegion',
3106         height : 250,
3107         split : true,
3108         tabPosition : 'top',
3109         xns : Roo,
3110         '|xns' : 'Roo'
3111        },
3112        items  : [
3113         {
3114          xtype : 'ContentPanel',
3115          autoScroll : true,
3116          fitToFrame : true,
3117          region : 'center',
3118          listeners : {
3119           render : function (_self)
3120            {
3121              _this.trpanel = _self;
3122            },
3123           resize : function (_self, width, height)
3124            {
3125                Roo.log('resize called');
3126                
3127                var ew = Math.max(250, width - 10);
3128                var eh = _this.westLayoutPanel.getLayout().getRegion('south').el.getHeight() - 30;
3129                
3130                
3131                if (!_this.trform) {
3132                    return;
3133                }
3134                
3135                var bd = _this.trform1.findField('body');
3136                
3137                if (bd.resizeEl) { 
3138                    bd.width = ew;
3139                    bd.height = eh;
3140                    // since render delays resize.. 
3141                    bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );
3142                   // _this.trbodycol.el.setWidth(bd.width+20);
3143                }
3144                var bd = _this.trform2.findField('extended');
3145                if (bd.resizeEl) { 
3146                    bd.width = ew;
3147                    bd.height = eh;
3148                    // since render delays resize.. 
3149                    bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );
3150                   // _this.trextendcol.el.setWidth(bd.width+20);
3151                }
3152            
3153            }
3154          },
3155          xns : Roo,
3156          '|xns' : 'Roo',
3157          items  : [
3158           {
3159            xtype : 'Form',
3160            labelAlign : 'right',
3161            labelWidth : 120,
3162            method : 'POST',
3163            showHide : function() {
3164            
3165              //  var in_rss= _this.form.findField('in_rss').getValue() * 1;
3166                var has_extended = _this.form.findField('has_extended').getValue() * 1;
3167                var has_lang = _this.trform.findField('language').getValue().length;
3168                
3169                _this.westLayoutPanel.getLayout().getRegion('south').show();
3170                _this.westLayoutPanel.getLayout().getRegion('south').unhidePanel(0);
3171                _this.westLayoutPanel.getLayout().getRegion('south').unhidePanel(1);
3172                _this.westLayoutPanel.getLayout().getRegion('south').unhidePanel(2);
3173                
3174                if(!has_lang){
3175                    _this.westLayoutPanel.getLayout().getRegion('south').hide();
3176                }
3177                
3178                if(!has_extended && has_lang){
3179                    _this.westLayoutPanel.getLayout().getRegion('south').hidePanel(1);
3180                    _this.westLayoutPanel.getLayout().getRegion('south').showPanel(0);
3181                }
3182                
3183                var vis = {
3184                    title : has_lang
3185                    
3186                };
3187                for(var k in vis) {
3188                    var el = _this.trform.findField(k);
3189                    el.actionMode = 'fieldEl';
3190                    if (    vis[k]) {
3191                        Roo.log("show: " + k);
3192                        el.show();
3193                    } else{ 
3194                        Roo.log("hide: " + k);
3195                        el.hide();
3196                    }
3197                }
3198            
3199                _this.updateRow.el[has_lang ? 'show' : 'hide']();
3200               
3201                
3202                if(typeof(_this.trform.editors) == 'undefined'){
3203                    _this.trform.editors = {
3204                        body : _this.trform1.findField('body').wrap.isVisible(),
3205                        extended : _this.trform2.findField('extended').wrap.isVisible()
3206                   };
3207                   if(_this.trform.editors.body){
3208                        setInterval(_this.trform1.findField('body').autosave, 60000);
3209                   }
3210                   
3211                   if(_this.trform.editors.extended){
3212                        setInterval(_this.trform2.findField('extended').autosave, 60000);
3213                   }
3214               }
3215               
3216               if(!_this.trform.editors.body && _this.trform1.findField('body').wrap.isVisible()){
3217                    setInterval(_this.trform1.findField('body').autosave, 60000);
3218                    _this.trform.editors.body = true;
3219               }
3220               
3221               if(!_this.trform.editors.extended && _this.trform2.findField('extended').wrap.isVisible()){
3222                    setInterval(_this.trform2.findField('extended').autosave, 60000);
3223                    _this.trform.editors.extended = true;
3224               }
3225                
3226                
3227            },
3228            style : 'margin: 5px',
3229            trackResetOnLoad : true,
3230            url : baseURL + '/Roo/cms_page.php',
3231            listeners : {
3232             actioncomplete : function (_self, action)
3233              {
3234                  if (action.type =='submit') {
3235                      return;
3236                  }
3237                  
3238                  if (action.type == 'setdata') {
3239                      _this.trform.addForm(_this.trform1);
3240                      _this.trform.addForm(_this.trform2);
3241                      _this.trform.addForm(_this.trform3);
3242                      
3243                      if ( _this.data.id) {
3244                          
3245                              this.load({ method: 'GET', params: { '_id' : _this.data.id }});
3246                      } else {
3247                          this.trpanel.el.mask("save first");
3248                      }
3249              
3250                     return;
3251                    
3252                  }
3253                  
3254                  if (action.type == 'load') {
3255              //        _this.dialog.el.unmask();
3256                      this.showHide();
3257                      
3258                      _this.trform1.findField('body').originalValue = _this.trform1.findField('body').getValue();
3259                     _this.trform2.findField('extended').originalValue = _this.trform2.findField('extended').getValue();
3260                     _this.trform3.findField('keywords').originalValue = _this.trform3.findField('keywords').getValue();
3261                     _this.trform3.findField('descriptions').originalValue = _this.trform3.findField('descriptions').getValue();
3262                      
3263                      return;
3264                  }
3265              },
3266             actionfailed : function (_self, action)
3267              {
3268                  _this.dialog.el.unmask();
3269               
3270                  Pman.standardActionFailed(_self, action);
3271              },
3272             rendered : function (_self)
3273              {
3274                  _this.trform = _self;
3275              }
3276            },
3277            xns : Roo.form,
3278            '|xns' : 'Roo.form',
3279            items  : [
3280             {
3281              xtype : 'Column',
3282              labelAlign : 'top',
3283              width : 500,
3284              xns : Roo.form,
3285              '|xns' : 'Roo.form',
3286              items  : [
3287               {
3288                xtype : 'Row',
3289                labelAlign : 'top',
3290                width : 400,
3291                xns : Roo.form,
3292                '|xns' : 'Roo.form',
3293                items  : [
3294                 {
3295                  xtype : 'ComboBox',
3296                  alwaysQuery : true,
3297                  displayField : 'language_name',
3298                  editable : false,
3299                  emptyText : _this._strings['83dad8107f9459efe2b4fabcf5b63108'] /* Select Language */,
3300                  fieldLabel : _this._strings['83dad8107f9459efe2b4fabcf5b63108'] /* Select Language */,
3301                  forceSelection : true,
3302                  hiddenName : 'language',
3303                  listWidth : 400,
3304                  loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
3305                  minChars : 2,
3306                  name : 'language_name',
3307                  pageSize : 20,
3308                  qtip : _this._strings['83dad8107f9459efe2b4fabcf5b63108'] /* Select Language */,
3309                  selectOnFocus : true,
3310                  tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{language_name}</b> </div>',
3311                  triggerAction : 'all',
3312                  typeAhead : false,
3313                  valueField : 'language',
3314                  listeners : {
3315                   add : function (combo)
3316                    {
3317                        Pman.Dialog.CmsLanguagePick.show({_with_name : true}, function( res) {
3318                           // Roo.log(res);
3319                           
3320                           _this.trform.reset();
3321                            _this.trform1.reset();
3322                            _this.trform2.reset();
3323                            
3324                            combo.setValue(res.lang);
3325                            combo.el.dom.value = res.lang_name;
3326                            (function() { 
3327                                
3328                                _this.trform.showHide();
3329                               _this.trpanel.fireEvent('resize', _this.trpanel, [ _this.trpanel.el.getWidth(), _this.trpanel.el.getHeight() ]  );
3330                           }).defer(100); 
3331                        });
3332                        
3333                    },
3334                   render : function (_self)
3335                    {
3336                        _this.language = _self;
3337                    },
3338                   select : function (combo, record, index)
3339                    {
3340                        (function() { 
3341                            _this.trform.showHide();
3342                           _this.trpanel.fireEvent('resize', _this.trpanel, [ _this.trpanel.el.getWidth(), _this.trpanel.el.getHeight() ]  );
3343                       }).defer(100); 
3344                        
3345                       _this.trform.load({
3346                        
3347                            method: 'GET', 
3348                            params: {
3349                                'lookup[language]' : record.data.language,
3350                                'lookup[translation_of_id]' : _this.data.id,
3351                                'lookup[_id]' : 1
3352                            }
3353                       });
3354                    }
3355                  },
3356                  xns : Roo.form,
3357                  '|xns' : 'Roo.form',
3358                  store : {
3359                   xtype : 'Store',
3360                   remoteSort : true,
3361                   sortInfo : { direction : 'ASC', field: 'language' },
3362                   listeners : {
3363                    beforeload : function (_self, o){
3364                         o.params = o.params || {};
3365                         
3366                         o.params._distinct = 'language';
3367                         o.params._columns ='language_name,language';
3368                         o.params._with_name = true;
3369                         
3370                         if(_this.form.findField('id').getValue()*1 > 0){
3371                             o.params.translation_of_id = _this.form.findField('id').getValue();
3372                         }
3373                         
3374                     }
3375                   },
3376                   xns : Roo.data,
3377                   '|xns' : 'Roo.data',
3378                   proxy : {
3379                    xtype : 'HttpProxy',
3380                    method : 'GET',
3381                    url : baseURL + '/Roo/Cms_page.php',
3382                    xns : Roo.data,
3383                    '|xns' : 'Roo.data'
3384                   },
3385                   reader : {
3386                    xtype : 'JsonReader',
3387                    fields : [{"name":"language","type":"string"}],
3388                    id : 'id',
3389                    root : 'data',
3390                    totalProperty : 'total',
3391                    xns : Roo.data,
3392                    '|xns' : 'Roo.data'
3393                   }
3394                  }
3395                 },
3396                 {
3397                  xtype : 'Row',
3398                  style : 'padding-top:12px;padding-left:30px;float:left',
3399                  width : 100,
3400                  listeners : {
3401                   render : function (_self)
3402                    {
3403                    _this.updateRow = _self;
3404                    }
3405                  },
3406                  xns : Roo.form,
3407                  '|xns' : 'Roo.form',
3408                  items  : [
3409                   {
3410                    xtype : 'Button',
3411                    text : _this._strings['06933067aafd48425d67bcb01bba5cb6'] /* Update */,
3412                    listeners : {
3413                     click : function()
3414                       {
3415                          //   _this.dialog.el.mask("Saving");
3416                          if(!_this.trform1.findField('body').editorcore.sourceEditMode){
3417                              _this.trform1.findField('body').syncValue(); 
3418                              _this.trform2.findField('extended').syncValue();
3419                          }else{
3420                              _this.trform1.findField('body').pushValue();
3421                              _this.trform2.findField('extended').pushValue();
3422                          }
3423                          
3424                          _this.trform.findField('parent_id').setValue(_this.form.findField('parent_id').getValue());
3425                          _this.trform.findField('element_id').setValue(_this.form.findField('element_id').getValue());
3426                          _this.trform.findField('translation_of_id').setValue(_this.form.findField('id').getValue());
3427                          _this.trform.findField('is_menuitem').setValue(_this.form.findField('is_menuitem').getValue());
3428                          _this.trform.findField('menu_page_id').setValue(_this.form.findField('menu_page_id').getValue());
3429                          
3430                          if(_this.trform.findField('element_id').getValue()*1 > 0){
3431                              _this.trform.findField('is_element').setValue(1);
3432                          }
3433                          
3434                          _this.trform.doAction("submit");
3435                      }
3436                    },
3437                    xns : Roo,
3438                    '|xns' : 'Roo'
3439                   }
3440                  ]
3441                 }
3442                ]
3443               },
3444               {
3445                xtype : 'TextField',
3446                fieldLabel : _this._strings['b78a3223503896721cca1303f776159b'] /* Title */,
3447                name : 'title',
3448                width : 400,
3449                xns : Roo.form,
3450                '|xns' : 'Roo.form'
3451               }
3452              ]
3453             },
3454             {
3455              xtype : 'Hidden',
3456              name : 'id',
3457              xns : Roo.form,
3458              '|xns' : 'Roo.form'
3459             },
3460             {
3461              xtype : 'Hidden',
3462              name : 'element_id',
3463              xns : Roo.form,
3464              '|xns' : 'Roo.form'
3465             },
3466             {
3467              xtype : 'Hidden',
3468              name : 'menu_page_id',
3469              xns : Roo.form,
3470              '|xns' : 'Roo.form'
3471             },
3472             {
3473              xtype : 'Hidden',
3474              name : 'is_menuitem',
3475              xns : Roo.form,
3476              '|xns' : 'Roo.form'
3477             },
3478             {
3479              xtype : 'Hidden',
3480              name : 'is_element',
3481              value : 0,
3482              xns : Roo.form,
3483              '|xns' : 'Roo.form'
3484             },
3485             {
3486              xtype : 'Hidden',
3487              name : 'translation_of_id',
3488              xns : Roo.form,
3489              '|xns' : 'Roo.form'
3490             },
3491             {
3492              xtype : 'Hidden',
3493              name : 'parent_id',
3494              xns : Roo.form,
3495              '|xns' : 'Roo.form'
3496             }
3497            ]
3498           }
3499          ]
3500         },
3501         {
3502          xtype : 'ContentPanel',
3503          background : false,
3504          fitContainer : true,
3505          fitToFrame : true,
3506          region : 'south',
3507          title : _this._strings['c1df1da7a1ce305a3b60af9d5733ac1d'] /* Contents */,
3508          xns : Roo,
3509          '|xns' : 'Roo',
3510          items  : [
3511           {
3512            xtype : 'Form',
3513            labelAlign : 'top',
3514            labelWidth : 80,
3515            method : 'POST',
3516            url : baseURL + '/Roo/cms_page.php',
3517            listeners : {
3518             rendered : function (form)
3519              {
3520                  _this.trform1 = form;
3521              }
3522            },
3523            xns : Roo.form,
3524            '|xns' : 'Roo.form',
3525            items  : [
3526             {
3527              xtype : 'Row',
3528              hideLabels : true,
3529              xns : Roo.form,
3530              '|xns' : 'Roo.form',
3531              items  : [
3532               {
3533                xtype : 'HtmlEditor',
3534                autosave : function() {
3535                    
3536                    var body = _this.trform1.findField('body');
3537                    
3538                    if(!body.wrap.isVisible(true) || body.getValue() == '' || !body.isDirty()){
3539                        Roo.log('tr body not dirty');
3540                        return;
3541                    }
3542                
3543                    Roo.log('tr body dirty, auto save!');
3544                    
3545                    body.fireEvent('autosave', body);
3546                },
3547                fieldLabel : _this._strings['c1df1da7a1ce305a3b60af9d5733ac1d'] /* Contents */,
3548                height : 140,
3549                name : 'body',
3550                resizable : 's',
3551                white : [ 'iframe' ],
3552                listeners : {
3553                 autosave : function (_self)
3554                  {
3555                      var id = _this.trform.findField('id').getValue() * 1;
3556                      
3557                      /*
3558                      if(!_self.editorcore.sourceEditMode){
3559                          _self.syncValue();
3560                      }else{
3561                          _self.pushValue();
3562                      }
3563                      */
3564                      new Pman.Request({
3565                          url : baseURL + '/Roo/Events.php',
3566                          method :'POST',
3567                          params : {
3568                              id : 0,
3569                              action : 'AUTOSAVE',
3570                              on_id : (id > 0) ? id : 0,
3571                              on_table : 'cms_page',
3572                              remarks : 'BODY',
3573                              source: _self.getValue()
3574                          },
3575                          success : function() {
3576                              _self.originalValue = _self.getValue();
3577                              
3578                          },
3579                          failure : function() 
3580                          {
3581                              //Roo.MessageBox.alert("Error", "autosave failed");
3582                              Roo.log('tr body autosave failed?!');
3583                          }
3584                      });
3585                  },
3586                 savedpreview : function (_self)
3587                  {
3588                      var id = _this.trform.findField('id').getValue() * 1;
3589                      
3590                      var successFn = function(res){
3591                          return res.data.POST.source;
3592                      };
3593                      
3594                      var params = {
3595                          action : 'AUTOSAVE',
3596                          remarks : 'BODY',
3597                          on_id : (id < 1) ? 0 : id,
3598                          on_table : 'cms_page',
3599                          successFn : successFn
3600                      };
3601                      
3602                      
3603                      Pman.Dialog.CoreAutoSavePreview.show(params, function(res){
3604                          _self.setValue(res);
3605                          _self.originalValue = res;
3606                      });
3607                  },
3608                 stylesheetsclick : function (_self)
3609                  {
3610                      Pman.Dialog.CmsApplyStyleSheets.show({}, function(res){
3611                          _this.dialog.setStylesheets();
3612                      })
3613                      
3614                  }
3615                },
3616                xns : Roo.form,
3617                '|xns' : 'Roo.form',
3618                toolbars : [
3619                 {
3620                  xtype : 'ToolbarStandard',
3621                  xns : Roo.form.HtmlEditor,
3622                  '|xns' : 'Roo.form.HtmlEditor',
3623                  btns : [
3624                   {
3625                    xtype : 'ComboBox',
3626                    alwaysQuery : true,
3627                    displayField : 'name',
3628                    editable : false,
3629                    emptyText : _this._strings['b9c49611cfda3259a2b837b39489e650'] /* Add Image */,
3630                    fieldLabel : _this._strings['fff0d600f8a0b5e19e88bfb821dd1157'] /* Images */,
3631                    forceSelection : true,
3632                    listWidth : 400,
3633                    loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
3634                    minChars : 2,
3635                    pageSize : 20,
3636                    qtip : _this._strings['2f26e35d61be90501e099089dc533638'] /* Select Images */,
3637                    selectOnFocus : true,
3638                    tpl : '<div class="x-grid-cell-text x-btn button"><img src="' + baseURL + '/Images/Thumb/150x150/{id}.jpg" height="150" width="150"><b>{filename}</b> </div>',
3639                    triggerAction : 'all',
3640                    typeAhead : true,
3641                    valueField : 'id',
3642                    width : 100,
3643                    listeners : {
3644                     beforequery : function (combo, query, forceAll, cancel, e)
3645                      {
3646                       
3647                          var id = _this.form.findField('id').getValue() * 1;    
3648                          if (!id) {
3649                              Roo.MessageBox.alert("Error", "Save press release first");
3650                              return false;
3651                          }
3652                      },
3653                     render : function (_self)
3654                      {
3655                          _this.trbodyimgselect = _self;
3656                      },
3657                     select : function (combo, record, index)
3658                      {
3659                          Roo.log(record);
3660                          (function() { 
3661                              combo.setValue('');
3662                          }).defer(100);
3663                          
3664                          var editor = _this.trform.findField('body').editorcore;
3665                          
3666                          var curnode = editor.getSelectedNode();
3667                          
3668                          if (curnode && curnode.tagName == 'IMG') {
3669                              curnode.src= String.format('{0}/Images/{1}/{2}#attachment-{1}',
3670                                      baseURL,  record.data.id, record.data.filename
3671                                  );
3672                                  // note -forces an update... hopefully...
3673                              editor.owner.fireEvent('editorevent', editor, false);
3674                          } else {
3675                          
3676                              editor.insertAtCursor(
3677                                  String.format('<img src="{0}/Images/{1}/{2}#attachment-{1}">',
3678                                  baseURL,  record.data.id, record.data.filename
3679                                  )
3680                              );
3681                      
3682                          }
3683                          
3684                      }
3685                    },
3686                    xns : Roo.form,
3687                    '|xns' : 'Roo.form',
3688                    store : {
3689                     xtype : 'Store',
3690                     remoteSort : true,
3691                     sortInfo : { direction : 'ASC', field: 'id' },
3692                     listeners : {
3693                      beforeload : function (_self, o){
3694                           o.params = o.params || {};
3695                       
3696                           var id = _this.form.findField('id').getValue() * 1;    
3697                           if (!id) {
3698                               Roo.MessageBox.alert("Error", "Save press release first");
3699                               return false;
3700                           }
3701                           o.params.onid = id;
3702                           o.params.ontable = 'cms_page';
3703                          // o.params.imgtype = 'PressRelease';
3704                           //o.params['query[imagesize]'] = '150x150';
3705                           // set more here
3706                       }
3707                     },
3708                     xns : Roo.data,
3709                     '|xns' : 'Roo.data',
3710                     proxy : {
3711                      xtype : 'HttpProxy',
3712                      method : 'GET',
3713                      url : baseURL + '/Roo/Images.php',
3714                      xns : Roo.data,
3715                      '|xns' : 'Roo.data'
3716                     },
3717                     reader : {
3718                      xtype : 'JsonReader',
3719                      fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}],
3720                      id : 'id',
3721                      root : 'data',
3722                      totalProperty : 'total',
3723                      xns : Roo.data,
3724                      '|xns' : 'Roo.data'
3725                     }
3726                    }
3727                   },
3728                   {
3729                    xtype : 'ComboBox',
3730                    allowBlank : true,
3731                    displayField : 'page_link',
3732                    editable : true,
3733                    emptyText : _this._strings['580b21aac58f1b73cece26e272cdfbee'] /* Add Link */,
3734                    forceSelection : true,
3735                    hiddenName : 'add_link_id',
3736                    listWidth : 200,
3737                    loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
3738                    minChars : 2,
3739                    name : 'add_link',
3740                    pageSize : 40,
3741                    qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
3742                    selectOnFocus : true,
3743                    tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{title}</b> <i>{page_link}</i> </div>',
3744                    triggerAction : 'all',
3745                    typeAhead : true,
3746                    valueField : 'id',
3747                    width : 100,
3748                    listeners : {
3749                     select : function (combo, record, index)
3750                      {
3751                        //  Roo.log(record);
3752                          (function() { 
3753                              combo.setValue('');
3754                          }).defer(100);
3755                          var editor = _this.form.findField('body');
3756                          editor.insertAtCursor(
3757                                  String.format('<a href="#page-{0}">{1}</a>',
3758                                  record.data.page_link,  record.data.title
3759                                  )
3760                           );
3761                      
3762                          
3763                       }
3764                    },
3765                    xns : Roo.form,
3766                    '|xns' : 'Roo.form',
3767                    store : {
3768                     xtype : 'Store',
3769                     remoteSort : true,
3770                     sortInfo : { field: 'page_link', direction: 'ASC' },
3771                     listeners : {
3772                      beforeload : function (_self, options)
3773                       {
3774                            options.params['search[page_link_no_empty]'] =1; 
3775                            /*
3776                            options.params.is_element = 0;
3777                            options.params.is_menuitem = _this.form.findField('is_menuitem').getValue() * 1;     
3778                            */
3779                       }
3780                     },
3781                     xns : Roo.data,
3782                     '|xns' : 'Roo.data',
3783                     proxy : {
3784                      xtype : 'HttpProxy',
3785                      method : 'GET',
3786                      url : baseURL + '/Roo/cms_page.php',
3787                      xns : Roo.data,
3788                      '|xns' : 'Roo.data'
3789                     },
3790                     reader : {
3791                      xtype : 'JsonReader',
3792                      fields : [
3793                       { name: 'id', type: 'int' },
3794                       'title',
3795                       'page_link' 
3796                      ],
3797                      id : 'id',
3798                      root : 'data',
3799                      totalProperty : 'total',
3800                      xns : Roo.data,
3801                      '|xns' : 'Roo.data'
3802                     }
3803                    }
3804                   },
3805                   {
3806                    xtype : 'Separator',
3807                    xns : Roo.Toolbar,
3808                    '|xns' : 'Roo.Toolbar'
3809                   },
3810                   {
3811                    xtype : 'Button',
3812                    text : _this._strings['bd88a20b53a47f7b5704a83a15ff5506'] /* Saved Version */,
3813                    listeners : {
3814                     click : function (_self, e)
3815                      {
3816                          this.scope.owner.fireEvent('savedpreview', this.scope.owner);
3817                      }
3818                    },
3819                    xns : Roo.Toolbar,
3820                    '|xns' : 'Roo.Toolbar'
3821                   }
3822                  ]
3823                 },
3824                 {
3825                  xtype : 'ToolbarContext',
3826                  xns : Roo.form.HtmlEditor,
3827                  '|xns' : 'Roo.form.HtmlEditor'
3828                 }
3829                ]
3830               }
3831              ]
3832             }
3833            ]
3834           }
3835          ]
3836         },
3837         {
3838          xtype : 'ContentPanel',
3839          background : false,
3840          fitContainer : true,
3841          fitToFrame : true,
3842          region : 'south',
3843          title : _this._strings['76eb64a1725ee953c664e15c9213b2fd'] /* Extended Content */,
3844          xns : Roo,
3845          '|xns' : 'Roo',
3846          items  : [
3847           {
3848            xtype : 'Form',
3849            labelAlign : 'top',
3850            labelWidth : 80,
3851            method : 'POST',
3852            url : baseURL + '/Roo/cms_page.php',
3853            listeners : {
3854             rendered : function (form)
3855              {
3856                  _this.trform2 = form;
3857              }
3858            },
3859            xns : Roo.form,
3860            '|xns' : 'Roo.form',
3861            items  : [
3862             {
3863              xtype : 'Row',
3864              hideLabels : true,
3865              xns : Roo.form,
3866              '|xns' : 'Roo.form',
3867              items  : [
3868               {
3869                xtype : 'HtmlEditor',
3870                autosave : function() {
3871                    
3872                    var extended = _this.trform2.findField('extended');
3873                    
3874                    if(!extended.wrap.isVisible(true) || extended.getValue() == '' || !extended.isDirty()){
3875                        Roo.log('tr extend not dirty');
3876                        return;
3877                    }
3878                
3879                    
3880                    Roo.log('tr extend dirty, auto save!');
3881                    
3882                    extended.fireEvent('autosave', extended);
3883                        
3884                   
3885                },
3886                fieldLabel : _this._strings['57e195426892c5515935f21d97228814'] /* Extended Contents */,
3887                height : 140,
3888                name : 'extended',
3889                resizable : 's',
3890                white : [ 'iframe' ],
3891                listeners : {
3892                 autosave : function (_self)
3893                  {
3894                      var id = _this.trform.findField('id').getValue() * 1;
3895                      
3896                      /*
3897                      if(!_self.editorcore.sourceEditMode){
3898                          _self.syncValue();
3899                      }else{
3900                          _self.pushValue();
3901                      }
3902                      */
3903                      
3904                      new Pman.Request({
3905                          url : baseURL + '/Roo/Events.php',
3906                          method :'POST',
3907                          params : {
3908                              id : 0,
3909                              action : 'AUTOSAVE',
3910                              on_id : (id > 0) ? id : 0,
3911                              on_table : 'cms_page',
3912                              remarks : 'EXTENDED',
3913                              source: _self.getValue()
3914                          },
3915                          success : function() {
3916                              _self.originalValue = _self.getValue();
3917                              
3918                          },
3919                          failure : function() 
3920                          {
3921                              //Roo.MessageBox.alert("Error", "autosave failed");
3922                              Roo.log('tr extended autosave failed?!');
3923                          }
3924                      });
3925                  },
3926                 savedpreview : function (_self)
3927                  {
3928                      var id = _this.trform.findField('id').getValue() * 1;
3929                      
3930                      var successFn = function(res){
3931                          return res.data.POST.source;
3932                      };
3933                      
3934                      var params = {
3935                          action : 'AUTOSAVE',
3936                          remarks : 'EXTENDED',
3937                          on_id : (id < 1) ? 0 : id,
3938                          on_table : 'cms_page',
3939                          successFn : successFn
3940                      };
3941                      
3942                      
3943                      Pman.Dialog.CoreAutoSavePreview.show(params, function(res){
3944                          _self.setValue(res);
3945                          _self.originalValue = res;
3946                      });
3947                  },
3948                 stylesheetsclick : function (_self)
3949                  {
3950                      Pman.Dialog.CmsApplyStyleSheets.show({}, function(res){
3951                          _this.dialog.setStylesheets();
3952                      })
3953                      
3954                  }
3955                },
3956                xns : Roo.form,
3957                '|xns' : 'Roo.form',
3958                toolbars : [
3959                 {
3960                  xtype : 'ToolbarStandard',
3961                  xns : Roo.form.HtmlEditor,
3962                  '|xns' : 'Roo.form.HtmlEditor',
3963                  btns : [
3964                   {
3965                    xtype : 'Separator',
3966                    xns : Roo.Toolbar,
3967                    '|xns' : 'Roo.Toolbar'
3968                   },
3969                   {
3970                    xtype : 'Button',
3971                    text : _this._strings['bd88a20b53a47f7b5704a83a15ff5506'] /* Saved Version */,
3972                    listeners : {
3973                     click : function (_self, e)
3974                      {
3975                          this.scope.owner.fireEvent('savedpreview', this.scope.owner);
3976                      }
3977                    },
3978                    xns : Roo.Toolbar,
3979                    '|xns' : 'Roo.Toolbar'
3980                   }
3981                  ]
3982                 },
3983                 {
3984                  xtype : 'ToolbarContext',
3985                  styles : typeof(uiConfig) != 'undefined' ? (uiConfig['Roo.form.HtmlEditor.ToolbarContext.styles'] || {}) : {},
3986                  xns : Roo.form.HtmlEditor,
3987                  '|xns' : 'Roo.form.HtmlEditor'
3988                 }
3989                ]
3990               }
3991              ]
3992             }
3993            ]
3994           }
3995          ]
3996         },
3997         {
3998          xtype : 'ContentPanel',
3999          background : false,
4000          fitContainer : true,
4001          fitToFrame : true,
4002          region : 'south',
4003          title : _this._strings['98e93e8f7adfe14832db6caed713d849'] /* Meta Tags */,
4004          xns : Roo,
4005          '|xns' : 'Roo',
4006          items  : [
4007           {
4008            xtype : 'Form',
4009            labelAlign : 'top',
4010            labelWidth : 80,
4011            method : 'POST',
4012            url : baseURL + '/Roo/cms_page.php',
4013            listeners : {
4014             rendered : function (form)
4015              {
4016                  _this.trform3 = form;
4017              }
4018            },
4019            xns : Roo.form,
4020            '|xns' : 'Roo.form',
4021            items  : [
4022             {
4023              xtype : 'Row',
4024              xns : Roo.form,
4025              '|xns' : 'Roo.form',
4026              items  : [
4027               {
4028                xtype : 'TextArea',
4029                fieldLabel : _this._strings['867343577fa1f33caa632a19543bd252'] /* Keywords */,
4030                height : 100,
4031                name : 'keywords',
4032                width : 340,
4033                xns : Roo.form,
4034                '|xns' : 'Roo.form'
4035               },
4036               {
4037                xtype : 'TextArea',
4038                fieldLabel : _this._strings['8bc84316c4078bf66723fd019616d920'] /* Descriptions */,
4039                height : 100,
4040                name : 'descriptions',
4041                width : 340,
4042                xns : Roo.form,
4043                '|xns' : 'Roo.form'
4044               }
4045              ]
4046             }
4047            ]
4048           }
4049          ]
4050         }
4051        ]
4052       }
4053      }
4054     ]
4055    });
4056  }
4057 };