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