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