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