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