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