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