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