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